[FFmpeg-devel] [PATCH] h264: update avctx width/height when flushing

Michael Niedermayer michaelni at gmx.at
Fri Jun 12 20:40:16 CEST 2015


On Fri, Jun 12, 2015 at 06:19:47PM +0200, Andreas Cadhalpun wrote:
> On 10.06.2015 21:50, Michael Niedermayer wrote:
> > On Wed, Jun 10, 2015 at 09:10:31PM +0200, Andreas Cadhalpun wrote:
> >> On 10.06.2015 12:01, Michael Niedermayer wrote:
> >>>> also avctx->pix_fmt would then still potentially not match the last
> >>>> output frame, also pix_fmt has the same problem as above
> >>
> >> Yes, pix_fmt should also be updated. Attached patch does this, but
> > 
> >> this caused changes in some h264 reinit fate tests. Is that a problem?
> > 
> > looking at the testfile with ffplay shows heavy artifacts after the
> > patch and no artifacts before
> 
> Yes, that's bad...
> 
> >>>> ive fixed one use of width/height not to depend on the AVCodecContext
> >>>> value but a 2nd remains
> >>>
> >>> actually theres more code that uses it
> >>> ff_h264_draw_horiz_band() and its callers use h->avctx->height too
> >>
> >> Could these be fixed to use a new H264Context field instead?
> > 
> > i think it might be possible for them to use the AVFrame height
> > but the code should be tested
> 
> I tried a few things, but couldn't get it to work that way.
> In the end I decided to work around the differing expectations of the h264
> decoder and the API users by backing up and restoring the internally
> used values. See attached patch.
> I tested this extensively and it fixes the problem without introducing
> another one as far as I can tell.
> One can see the effect, when using -loglevel debug, e.g. for the
> reinit-small_422_9-to-small_420_9.h264 sample:
>  * Without the patch:
> [...]
> [h264 @ 0x196e320] Reinit context to 240x208, pix_fmt: yuv420p9le
> Frame parameters mismatch context 240,196,80 != 240,196,70
>     Last message repeated 1 times
> Input stream #0:0 frame changed from size:240x196 fmt:yuv422p9le to size:240x196 fmt:yuv420p9le
> [...]
> 
>  * With the patch:
> [...]
> [h264 @ 0x2707320] Reinit context to 240x208, pix_fmt: yuv420p9le
> Input stream #0:0 frame changed from size:240x196 fmt:yuv422p9le to size:240x196 fmt:yuv420p9le
> [...]
> 
> The messages about the parameter mismatch for the two frames disappear.

Maybe the code should be moved to avcodec_decode_video2()
and the variables to AVCodecInternal
and then maybe a FF_CODEC_CAP_... could be used to mark decoders which
need this code. That way it could be used for other decoders too
but the patch as is is probably ok too as is, though it does feel a
bit inelegant either way

[...]

-- 
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: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150612/7a4ee2f7/attachment.asc>


More information about the ffmpeg-devel mailing list