[FFmpeg-devel] [PATCH] ffplay: Use sws_scale to scale subtitles

Michael Niedermayer michael at niedermayer.cc
Tue Jul 28 05:09:40 CEST 2015


On Tue, Jul 28, 2015 at 01:01:33AM +0200, Marton Balint wrote:
> 
> On Sun, 26 Jul 2015, Michael Niedermayer wrote:
> 
> >From: Michael Niedermayer <michael at niedermayer.cc>
> >
> >Fixes some files from Ticket679
> >
> >This also changes subtitles to 4:2:0 matching the output format and thus
> >simplifying the blend code.
> >This restricts placement to the chroma sample resolution though, speak up
> >if you consider this a problem, say so, the code could be changed to use
> >YUV444 for subtitles and scaling them down while blending, this would be
> >slower though.
> >The current code only uses a single swscale context and reinitializes it
> >as needed, this could be changed as well if needed
> 
> It is fine by me as it is.
> 
> >Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> >---
> >ffplay.c |  275 ++++++++++++++------------------------------------------------
> >1 file changed, 62 insertions(+), 213 deletions(-)
> >
> 
> [...]
> 
> >    for (;;) {
> >        if (!(sp = frame_queue_peek_writable(&is->subpq)))
> >@@ -2348,14 +2170,41 @@ static int subtitle_thread(void *arg)
> >
> >            for (i = 0; i < sp->sub.num_rects; i++)
> >            {
> >-                for (j = 0; j < sp->sub.rects[i]->nb_colors; j++)
> >-                {
> >-                    RGBA_IN(r, g, b, a, (uint32_t*)sp->sub.rects[i]->pict.data[1] + j);
> >-                    y = RGB_TO_Y_CCIR(r, g, b);
> >-                    u = RGB_TO_U_CCIR(r, g, b, 0);
> >-                    v = RGB_TO_V_CCIR(r, g, b, 0);
> >-                    YUVA_OUT((uint32_t*)sp->sub.rects[i]->pict.data[1] + j, y, u, v, a);
> >+                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.avctx->width;
> >+                int subh = is->subdec.avctx->height ? is->subdec.avctx->height : is->viddec.avctx->height;
> >+                int out_w = in_w * is->viddec.avctx->width  / subw;
> >+                int out_h = in_h * is->viddec.avctx->height / subh;
> 
> viddec.avctx may not be set here. I see no better way but to add two
> extra fields to VideoState and update them when opening a video
> stream and when decoding a new picture.

ok, posted a new version

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is what and why we do it that matters, not just one of them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150728/7668cc5d/attachment.sig>


More information about the ffmpeg-devel mailing list