[FFmpeg-devel] [PATCH, v2 2/4] avc/avcodec: add AV_CODEC_CAP_VARIABLE_DIMENSIONS flag

Anton Khirnov anton at khirnov.net
Thu Feb 20 10:44:16 EET 2020


Quoting Fu, Linjie (2020-02-19 17:25:30)
> > Yes, that's what I mean. Flush and destroy an AVCodecContext and open a
> > new one. But then why is there a need for this flag?
> > 
> Previously I intended to add close and re-init inside specific encoder like [1],
> without destroy AVCodecContext, and some codec [2] may support
> dynamic resolution encoding without reinitialization. (which allows resolution
> changing on P/inter frame, not only I/key frame).
> 
> So it's more secure to add a flag to declare the capability, and add the support
> for encoders step by step.

The concern here is that libavcodec encoders have always assumed that
the stream parameters are set once and never change afterwards.
Violating that constraint might lead to undefined behaviour in code that
relies on this assumption, and it would be quite hard to identify all
such code.

So the question is whether this danger and the effort required to avoid
it are justified. Do we get sufficient benefits from having parameter
change capability inside encoders over just creating a new encoder
instance when needed? Do people really need to change resolution
mid-GOP?

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list