[FFmpeg-devel] [PATCH 3/5] lavc/h264dec: loosen new-extradata check

Ridley Combs rcombs at rcombs.me
Thu Jun 11 20:26:28 EEST 2020



> On Jun 11, 2020, at 07:53, James Almer <jamrial at gmail.com> wrote:
> 
> On 6/11/2020 1:43 AM, rcombs wrote:
>> ---
>> libavcodec/h264dec.c | 13 ++++++-------
>> 1 file changed, 6 insertions(+), 7 deletions(-)
>> 
>> diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
>> index 6270ea80df..0d7492cfad 100644
>> --- a/libavcodec/h264dec.c
>> +++ b/libavcodec/h264dec.c
>> @@ -988,6 +988,8 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
>>     AVFrame *pict      = data;
>>     int buf_index;
>>     int ret;
>> +    const uint8_t *new_extra;
>> +    int new_extra_size;
>> 
>>     h->flags = avctx->flags;
>>     h->setup_finished = 0;
>> @@ -999,13 +1001,10 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
>>     if (buf_size == 0)
>>         return send_next_delayed_frame(h, pict, got_frame, 0);
>> 
>> -    if (h->is_avc && av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {
>> -        int side_size;
>> -        uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
>> -        if (is_extra(side, side_size))
>> -            ff_h264_decode_extradata(side, side_size,
>> -                                     &h->ps, &h->is_avc, &h->nal_length_size,
>> -                                     avctx->err_recognition, avctx);
>> +    if ((new_extra = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &new_extra_size))) {
>> +        ff_h264_decode_extradata(new_extra, new_extra_size,
>> +                                 &h->ps, &h->is_avc, &h->nal_length_size,
>> +                                 avctx->err_recognition, avctx);
>>     }
>>     if (h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC) {
>>         if (is_extra(buf, buf_size))
> 
> This looks similar to
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200508020929.68603-1-ollywoodman@gmail.com/

Heh, yeah it's ultimately functionally the same, but has an entirely different purpose. The streams I'm working with _are_ avcC-formatted, but don't have extradata yet at init-time, so the is_avc flag isn't set when this code runs. The is_extra check was failing because some files have stub avcC extradata that doesn't contain any SPS/PPS arrays (they're sent inline instead).
Sounds like this change is a win/win, then?

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".



More information about the ffmpeg-devel mailing list