[FFmpeg-devel] [PATCH] ffplay: add scale_subtitles option to allow disabling the scaling
Michael Niedermayer
michaelni at gmx.at
Wed Jul 29 16:52:20 CEST 2015
From: Michael Niedermayer <michael at niedermayer.cc>
This theoretically is faster and might be useful on some low end embeded systems
Inspired-by: Compns reply
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
ffplay.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/ffplay.c b/ffplay.c
index cc61dde..dee8596 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -346,6 +346,7 @@ static int nb_vfilters = 0;
static char *afilters = NULL;
#endif
static int autorotate = 1;
+static int scale_subtitlies = 1;
/* current context */
static int is_full_screen;
@@ -2178,12 +2179,17 @@ static int subtitle_thread(void *arg)
{
int in_w = sp->sub.rects[i]->w;
int in_h = sp->sub.rects[i]->h;
- int subw = is->subdec.avctx->width ? is->subdec.avctx->width : is->viddec_width;
- int subh = is->subdec.avctx->height ? is->subdec.avctx->height : is->viddec_height;
- int out_w = is->viddec_width ? in_w * is->viddec_width / subw : in_w;
- int out_h = is->viddec_height ? in_h * is->viddec_height / subh : in_h;
+ int subw = is->subdec.avctx->width;
+ int subh = is->subdec.avctx->height;
+ int out_w = in_w;
+ int out_h = in_h;
AVPicture newpic;
+ if (subw && subh && is->viddec_width && is->viddec_height && scale_subtitlies) {
+ out_w = in_w * is->viddec_width / subw;
+ out_h = in_h * is->viddec_height / subh;
+ }
+
//can not use avpicture_alloc as it is not compatible with avsubtitle_free()
av_image_fill_linesizes(newpic.linesize, AV_PIX_FMT_YUVA420P, out_w);
newpic.data[0] = av_malloc(newpic.linesize[0] * out_h);
@@ -3586,6 +3592,7 @@ static const OptionDef options[] = {
{ "scodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &subtitle_codec_name }, "force subtitle decoder", "decoder_name" },
{ "vcodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &video_codec_name }, "force video decoder", "decoder_name" },
{ "autorotate", OPT_BOOL, { &autorotate }, "automatically rotate video", "" },
+ { "scale_subtitlies", OPT_BOOL, { &scale_subtitlies }, "rescale subtitles depending on video size", "" },
{ NULL, },
};
--
1.7.9.5
More information about the ffmpeg-devel
mailing list