[FFmpeg-devel] [PATCH v2 1/4] avcodec/av1dec: expose skip mode frame index

Timo Rothenpieler timo at rothenpieler.org
Tue Nov 10 16:43:36 EET 2020


On 10.11.2020 15:19, James Almer wrote:
> On 11/10/2020 10:42 AM, Timo Rothenpieler wrote:
>> Signed-off-by: Timo Rothenpieler <timo at rothenpieler.org>
>> Co-authored-by: James Almer <jamrial at gmail.com>
>> ---
>>   libavcodec/av1dec.c | 80 +++++++++++++++++++++++++++++++++++++++++++++
>>   libavcodec/av1dec.h |  3 ++
>>   2 files changed, 83 insertions(+)
>>
>> diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
>> index 56712279aa..1afed66499 100644
>> --- a/libavcodec/av1dec.c
>> +++ b/libavcodec/av1dec.c
>> @@ -145,6 +145,78 @@ static void global_motion_params(AV1DecContext *s)
>>       }
>>   }
>> +static int get_relative_dist(const AV1RawSequenceHeader *seq,
>> +                             unsigned int a, unsigned int b)
>> +{
>> +    unsigned int diff = a - b;
>> +    unsigned int m = 1 << seq->order_hint_bits_minus_1;
>> +    return (diff & (m - 1)) - (diff & m);
>> +}
>> +
>> +static void skip_mode_params(AV1DecContext *s)
>> +{
>> +    const AV1RawFrameHeader *header = s->raw_frame_header;
>> +    const AV1RawSequenceHeader *seq = s->raw_seq;
>> +
>> +    int forward_idx,  backward_idx;
>> +    int forward_hint, backward_hint;
>> +    int second_forward_idx, second_forward_hint;
>> +    int ref_hint, dist, i;
>> +
>> +    if (!header->skip_mode_present)
>> +        return;
> 
> Actually, i was partly wrong, AV1Frames are not zero initialized by 
> av1_frame_alloc(), only when the decoder is initialized as part of the 
> AV1DecContext allocation. So if you don't zero them here, you should 
> probably do it in av1_frame_unref(), same as order_hint.
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".

Right now they'd just be in an undefined state when !skip_mode_present, 
which is fine by me, given that the field does not have a meaning in 
that case anyway.

But zeroing the field is probably cleaner.
Will add to patch locally


More information about the ffmpeg-devel mailing list