[FFmpeg-devel] [PATCH] avcodec/hevcdec: Remove hevc_decode_extradata()

James Almer jamrial at gmail.com
Thu Jul 6 18:56:39 EEST 2017


On 7/6/2017 12:54 PM, wm4 wrote:
> On Thu,  6 Jul 2017 17:08:27 +0200
> Michael Niedermayer <michael at niedermayer.cc> wrote:
> 
>> This function wrapped around ff_hevc_decode_extradata() and export_stream_params(),
>> but from the 2 callers one needs to skip export_stream_params() so its simpler to
>> directly call the needed code.
>>
>> Moving the 2nd part of the code out was suggested by wm4
>>
>> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
>> ---
>>  libavcodec/hevcdec.c | 40 ++++++++++++++++------------------------
>>  1 file changed, 16 insertions(+), 24 deletions(-)
>>
>> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
>> index 55f51211c3..7c112b29d6 100644
>> --- a/libavcodec/hevcdec.c
>> +++ b/libavcodec/hevcdec.c
>> @@ -3057,28 +3057,6 @@ static int verify_md5(HEVCContext *s, AVFrame *frame)
>>      return 0;
>>  }
>>  
>> -static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length, int first)
>> -{
>> -    int ret, i;
>> -
>> -    ret = ff_hevc_decode_extradata(buf, length, &s->ps, &s->sei, &s->is_nalff,
>> -                                   &s->nal_length_size, s->avctx->err_recognition,
>> -                                   s->apply_defdispwin, s->avctx);
>> -    if (ret < 0)
>> -        return ret;
>> -
>> -    /* export stream parameters from the first SPS */
>> -    for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) {
>> -        if (first && s->ps.sps_list[i]) {
>> -            const HEVCSPS *sps = (const HEVCSPS*)s->ps.sps_list[i]->data;
>> -            export_stream_params(s->avctx, &s->ps, sps);
>> -            break;
>> -        }
>> -    }
>> -
>> -    return 0;
>> -}
>> -
>>  static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output,
>>                               AVPacket *avpkt)
>>  {
>> @@ -3099,7 +3077,9 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output,
>>      new_extradata = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
>>                                              &new_extradata_size);
>>      if (new_extradata && new_extradata_size > 0) {
>> -        ret = hevc_decode_extradata(s, new_extradata, new_extradata_size, 0);
>> +        ret = ff_hevc_decode_extradata(new_extradata, new_extradata_size, &s->ps, &s->sei, &s->is_nalff,
>> +                                       &s->nal_length_size, s->avctx->err_recognition,
>> +                                       s->apply_defdispwin, s->avctx);
>>          if (ret < 0)
>>              return ret;
>>      }
>> @@ -3387,11 +3367,23 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx)
>>          s->threads_number = 1;
>>  
>>      if (avctx->extradata_size > 0 && avctx->extradata) {
>> -        ret = hevc_decode_extradata(s, avctx->extradata, avctx->extradata_size, 1);
>> +        int i;
>> +        ret = ff_hevc_decode_extradata(avctx->extradata, avctx->extradata_size, &s->ps, &s->sei, &s->is_nalff,
>> +                                       &s->nal_length_size, s->avctx->err_recognition,
>> +                                       s->apply_defdispwin, s->avctx);
>>          if (ret < 0) {
>>              hevc_decode_free(avctx);
>>              return ret;
>>          }
>> +
>> +        /* export stream parameters from the first SPS */
>> +        for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) {
>> +            if (s->ps.sps_list[i]) {
>> +                const HEVCSPS *sps = (const HEVCSPS*)s->ps.sps_list[i]->data;
>> +                export_stream_params(s->avctx, &s->ps, sps);
>> +                break;
>> +            }
>> +        }
>>      }
>>  
>>      if((avctx->active_thread_type & FF_THREAD_FRAME) && avctx->thread_count > 1)
> 
> That duplicates the relatively "complicated" ff_hevc_decode_extradata
> call though.

Not really, since the two first arguments are of course different.


More information about the ffmpeg-devel mailing list