[FFmpeg-devel] [PATCH] ffplay: Use sws_scale to scale subtitles
Michael Niedermayer
michael at niedermayer.cc
Wed Jul 29 16:31:35 CEST 2015
On Wed, Jul 29, 2015 at 02:22:02AM +0200, Marton Balint wrote:
>
> On Tue, 28 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
> >
> >Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> >---
> >ffplay.c | 284 ++++++++++++++++----------------------------------------------
> >1 file changed, 71 insertions(+), 213 deletions(-)
> >
>
> [...]
>
> >@@ -2348,14 +2176,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_width;
> >+ int subh = is->subdec.avctx->height ? is->subdec.avctx->height : is->viddec_height;
> >+ int out_w = in_w * is->viddec_width / subw;
> >+ int out_h = in_h * is->viddec_height / subh;
>
> You should check for zero viddec_width/height here. E.g.:
> out_w = is->viddec_width ? in_w * is->viddec_width / subw : in_w;
> out_h = is->viddec_height ? in_h * is->viddec_height / subh : in_h;
added
>
> Otherwise LGTM.
applied
thanks
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- 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/20150729/d5d0c286/attachment.sig>
More information about the ffmpeg-devel
mailing list