[FFmpeg-devel] [PATCH 1/2] avcodec/libdav1d: try to set decoder context parameters during init()

James Almer jamrial at gmail.com
Mon May 18 17:58:01 EEST 2020


On 5/18/2020 11:43 AM, Anton Khirnov wrote:
> Quoting James Almer (2020-05-11 16:27:55)
>> If extradata is available, use it to initialize the AVCodecContext before
>> packet data is seen. Also, don't constantly overwrite it after it's set.
>>
>> Signed-off-by: James Almer <jamrial at gmail.com>
>> ---
>> The main benefit from this is using ff_decode_frame_props() to fill frame
>> props, which includes copying any relevant side data that may be present in
>> packets, like for example container mastering metadata propagated by a demuxer.
>>
>>  libavcodec/libdav1d.c | 102 +++++++++++++++++++++++++++++-------------
>>  1 file changed, 71 insertions(+), 31 deletions(-)
>>
>> diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
>> index 5248e3f9f5..72f06c550e 100644
>> --- a/libavcodec/libdav1d.c
>> +++ b/libavcodec/libdav1d.c
>> @@ -42,6 +42,8 @@ typedef struct Libdav1dContext {
>>      int apply_grain;
>>      int operating_point;
>>      int all_layers;
>> +
>> +    int inited;
>>  } Libdav1dContext;
>>  
>>  static const enum AVPixelFormat pix_fmt[][3] = {
>> @@ -117,9 +119,59 @@ static void libdav1d_picture_release(Dav1dPicture *p, void *cookie)
>>      av_buffer_unref(&buf);
>>  }
>>  
>> +static int libdav1d_init_params(AVCodecContext *c, Dav1dSequenceHeader *seq)
>> +{
>> +    Libdav1dContext *dav1d = c->priv_data;
>> +    int res;
>> +
>> +    if (dav1d->inited)
>> +        return 0;
> 
> Changing parameters mid-stream is not supported?

Sequence Headers are not meant to change within a video sequence. Afaik,
the only params that can change between frames are its dimensions, and
that's already handled by looking at the values on a given Dav1dPicture.
But libdav1d does seem to gracefully handle changes in seq headers by
assuming it's a new sequence and resetting its internal state, so i
guess I'll remove it.


More information about the ffmpeg-devel mailing list