[FFmpeg-devel] [PATCH][RFC] variable frame sizes

Michael Niedermayer michaelni
Mon May 25 13:49:32 CEST 2009


On Sun, May 24, 2009 at 01:39:04AM -0700, Eric Buehl wrote:
> Part of my patch updates the resample_height and resample_width values
> whenever a new frame size is detected.  Also, these values are not global;
> they are contained in the AVOutputStream struct which I also see has a
> per-stream resample context.  This means that the situation I described
> earlier was incorrect: when there are multiple output streams, the context
> is NOT constantly switching and being re-initialized.
> 
> I have added some debug prints to demonstrate this in the attached patch.
> It shows that two separate scaler contexts are created (one for each output
> stream).  Then, as each stream's frame size changes, the appropriate context
> is reinitialized exactly once per stream at the appropriate time.
> 
> FFmpeg version SVN-r18886, Copyright (c) 2000-2009 Fabrice Bellard, et al.
>   configuration: --enable-pthreads --enable-libfaac --enable-libx264
> --enable-decoders --enable-gpl --enable-libfaad --enable-nonfree
>   libavutil     50. 3. 0 / 50. 3. 0
>   libavcodec    52.29. 0 / 52.29. 0
>   libavformat   52.33. 0 / 52.33. 0
>   libavdevice   52. 2. 0 / 52. 2. 0
>   libswscale     0. 7. 1 /  0. 7. 1
>   built on May 24 2009 01:17:40, gcc: 4.3.2 20081105 (Red Hat 4.3.2-7)
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'a.mov':
>   Duration: 00:00:22.10, start: 0.000000, bitrate: 6337 kb/s
>     Stream #0.0(eng): Video: mjpeg, yuvj422p, 640x360 [PAR 72:72 DAR 16:9],
> 23.98 tbr, 23.98 tbn, 23.98 tbc
> Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'b.mov':
>   Duration: 00:00:12.13, start: 0.000000, bitrate: 5771 kb/s
>     Stream #1.0(eng): Video: mjpeg, yuvj422p, 640x360 [PAR 72:72 DAR 16:9],
> 23.98 tbr, 23.98 tbn, 23.98 tbc
> SWSCTX ost:0x24e4d30 swctx:0x24f7ac0 initialized to resample from 640x360
> SWSCTX ost:0x24e4f00 swctx:0x25f3820 initialized to resample from 640x360
> Output #0, mp4, to 'c.mp4':
>     Stream #0.0(eng): Video: mpeg4, yuv420p, 100x100 [PAR 16:9 DAR 16:9],
> q=2-31, 200 kb/s, 2997 tbn, 23.98 tbc
>     Stream #0.1(eng): Video: mpeg4, yuv420p, 200x200 [PAR 16:9 DAR 16:9],
> q=2-31, 200 kb/s, 2997 tbn, 23.98 tbc
> Stream mapping:
>   Stream #0.0 -> #0.0
>   Stream #1.0 -> #0.1
> Press [q] to stop encoding
> SWSCTX ost:0x24e4f00 swctx:0x25f3820 REinitialized to resample from
> 640x180ts/s
> SWSCTX ost:0x24e4d30 swctx:0x2822ad0 REinitialized to resample from
> 640x180its/s
> frame=  530 fps=286 q=2.0 Lq=2.0 size=     715kB time=12.14 bitrate=
> 482.9kbits/s
> video:707kB audio:0kB global headers:0kB muxing overhead 1.123081%
> 
> 
> It is entirely possible that I am missing something here, so please be kind
> if I am. :)
[...]
> @@ -923,6 +924,27 @@
>      if (ost->video_resample) {
>          padding_src = NULL;
>          final_picture = &ost->pict_tmp;
> +        if(   (ost->resample_height != (ist->st->codec->height - (frame_topBand + frame_bottomBand)))
> +           || (ost->resample_width != (ist->st->codec->width - (frame_leftBand + frame_rightBand)))){
> +            sws_freeContext(ost->img_resample_ctx);
> +            sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
> +            ost->img_resample_ctx = sws_getContext(
> +                ist->st->codec->width - (frame_leftBand + frame_rightBand),
> +                ist->st->codec->height - (frame_topBand + frame_bottomBand),
> +                ist->st->codec->pix_fmt,
> +                ost->st->codec->width - (frame_padleft + frame_padright),
> +                ost->st->codec->height - (frame_padtop + frame_padbottom),

frame_topBand, frame_leftBand, frame_bottomBand, frame_rightBand are global
variables
They do not contain valid values for more than 1 stream after the streams
have been created


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

It is not what we do, but why we do it that matters.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090525/b017af03/attachment.pgp>



More information about the ffmpeg-devel mailing list