[FFmpeg-devel] [PATCH 04/42] avcodec/h264_ps: Use RefStruct API for SPS/PPS

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Thu Sep 28 18:49:15 EEST 2023


Anton Khirnov:
> Quoting Andreas Rheinhardt (2023-09-19 21:56:56)
>> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
>> index 5657327f0c..632f5b23b2 100644
>> --- a/libavcodec/h264_slice.c
>> +++ b/libavcodec/h264_slice.c
>> @@ -363,25 +361,16 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
>>  
>>      // SPS/PPS
>>      for (i = 0; i < FF_ARRAY_ELEMS(h->ps.sps_list); i++) {
>> -        ret = av_buffer_replace(&h->ps.sps_list[i], h1->ps.sps_list[i]);
>> -        if (ret < 0)
>> -            return ret;
>> +        ff_refstruct_replace(&h->ps.sps_list[i], h1->ps.sps_list[i]);
>>      }
>>      for (i = 0; i < FF_ARRAY_ELEMS(h->ps.pps_list); i++) {
>> -        ret = av_buffer_replace(&h->ps.pps_list[i], h1->ps.pps_list[i]);
>> -        if (ret < 0)
>> -            return ret;
>> +        ff_refstruct_replace(&h->ps.pps_list[i], h1->ps.pps_list[i]);
>>      }
>>  
>> -    ret = av_buffer_replace(&h->ps.pps_ref, h1->ps.pps_ref);
>> -    if (ret < 0)
>> -        return ret;
>> -    h->ps.pps = NULL;
>> +    ff_refstruct_replace(&h->ps.pps, h1->ps.pps);
>>      h->ps.sps = NULL;
>> -    if (h1->ps.pps_ref) {
>> -        h->ps.pps = (const PPS*)h->ps.pps_ref->data;
>> +    if (h1->ps.pps)
>>          h->ps.sps = h->ps.pps->sps;
> 
> nit: this would look better as
>        h->ps.sps = h->ps.pps ? h->ps.pps->sps : NULL
> 

Is there actually a reason not to just use h->ps.sps = h1->ps.sps?

- Andreas



More information about the ffmpeg-devel mailing list