diff mbox series

[FFmpeg-devel,07/13] avcodec/hevcdec: check for DOVI configuration record in AVCodecContext side data

Message ID 20230720203415.41757-7-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel,01/13] avcodec/avcodec: add side data to AVCodecContext | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 fail Make failed
andriy/make_x86 fail Make failed

Commit Message

James Almer July 20, 2023, 8:34 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/hevcdec.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Andreas Rheinhardt July 23, 2023, 8:40 a.m. UTC | #1
James Almer:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavcodec/hevcdec.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
> index fcf19b4eb6..0d659e4c55 100644
> --- a/libavcodec/hevcdec.c
> +++ b/libavcodec/hevcdec.c
> @@ -3403,8 +3403,12 @@ static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
>      }
>  
>      sd = av_packet_get_side_data(avpkt, AV_PKT_DATA_DOVI_CONF, &sd_size);
> -    if (sd && sd_size > 0)
> +    if (sd && sd_size > 0) {
> +        av_log(avctx, AV_LOG_WARNING,
> +               "passing a DOVI configuration record through packet side data is "
> +               "deprecated and will stop working soon. Use AVCodecContext side data\n");

Doesn't this remove functionality that might be useful to some users
(namely the functionality to send new DOVI metadata)?

>          ff_dovi_update_cfg(&s->dovi_ctx, (AVDOVIDecoderConfigurationRecord *) sd);
> +    }
>  
>      s->ref = NULL;
>      ret    = decode_nal_units(s, avpkt->data, avpkt->size);
> @@ -3707,12 +3711,18 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx)
>      atomic_init(&s->wpp_err, 0);
>  
>      if (!avctx->internal->is_copy) {
> +        AVPacketSideData *sd;
> +
>          if (avctx->extradata_size > 0 && avctx->extradata) {
>              ret = hevc_decode_extradata(s, avctx->extradata, avctx->extradata_size, 1);
>              if (ret < 0) {
>                  return ret;
>              }
>          }
> +
> +        sd = av_packet_get_side_data_from_set(&avctx->side_data_set, AV_PKT_DATA_DOVI_CONF);
> +        if (sd && sd->size > 0)
> +            ff_dovi_update_cfg(&s->dovi_ctx, (AVDOVIDecoderConfigurationRecord *) sd->data);
>      }
>  
>      return 0;
James Almer July 23, 2023, 11:48 a.m. UTC | #2
On 7/23/2023 5:40 AM, Andreas Rheinhardt wrote:
> James Almer:
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>   libavcodec/hevcdec.c | 12 +++++++++++-
>>   1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
>> index fcf19b4eb6..0d659e4c55 100644
>> --- a/libavcodec/hevcdec.c
>> +++ b/libavcodec/hevcdec.c
>> @@ -3403,8 +3403,12 @@ static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
>>       }
>>   
>>       sd = av_packet_get_side_data(avpkt, AV_PKT_DATA_DOVI_CONF, &sd_size);
>> -    if (sd && sd_size > 0)
>> +    if (sd && sd_size > 0) {
>> +        av_log(avctx, AV_LOG_WARNING,
>> +               "passing a DOVI configuration record through packet side data is "
>> +               "deprecated and will stop working soon. Use AVCodecContext side data\n");
> 
> Doesn't this remove functionality that might be useful to some users
> (namely the functionality to send new DOVI metadata)?

Is this a valid scenario? lavf only exports this side data during 
read_header(). A change in DOVI profile would mean a brand new CVS, and 
afaik we require a new decoder to be fired up for this.

> 
>>           ff_dovi_update_cfg(&s->dovi_ctx, (AVDOVIDecoderConfigurationRecord *) sd);
>> +    }
>>   
>>       s->ref = NULL;
>>       ret    = decode_nal_units(s, avpkt->data, avpkt->size);
>> @@ -3707,12 +3711,18 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx)
>>       atomic_init(&s->wpp_err, 0);
>>   
>>       if (!avctx->internal->is_copy) {
>> +        AVPacketSideData *sd;
>> +
>>           if (avctx->extradata_size > 0 && avctx->extradata) {
>>               ret = hevc_decode_extradata(s, avctx->extradata, avctx->extradata_size, 1);
>>               if (ret < 0) {
>>                   return ret;
>>               }
>>           }
>> +
>> +        sd = av_packet_get_side_data_from_set(&avctx->side_data_set, AV_PKT_DATA_DOVI_CONF);
>> +        if (sd && sd->size > 0)
>> +            ff_dovi_update_cfg(&s->dovi_ctx, (AVDOVIDecoderConfigurationRecord *) sd->data);
>>       }
>>   
>>       return 0;
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Andreas Rheinhardt July 23, 2023, 12:17 p.m. UTC | #3
James Almer:
> On 7/23/2023 5:40 AM, Andreas Rheinhardt wrote:
>> James Almer:
>>> Signed-off-by: James Almer <jamrial@gmail.com>
>>> ---
>>>   libavcodec/hevcdec.c | 12 +++++++++++-
>>>   1 file changed, 11 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
>>> index fcf19b4eb6..0d659e4c55 100644
>>> --- a/libavcodec/hevcdec.c
>>> +++ b/libavcodec/hevcdec.c
>>> @@ -3403,8 +3403,12 @@ static int hevc_decode_frame(AVCodecContext
>>> *avctx, AVFrame *rframe,
>>>       }
>>>         sd = av_packet_get_side_data(avpkt, AV_PKT_DATA_DOVI_CONF,
>>> &sd_size);
>>> -    if (sd && sd_size > 0)
>>> +    if (sd && sd_size > 0) {
>>> +        av_log(avctx, AV_LOG_WARNING,
>>> +               "passing a DOVI configuration record through packet
>>> side data is "
>>> +               "deprecated and will stop working soon. Use
>>> AVCodecContext side data\n");
>>
>> Doesn't this remove functionality that might be useful to some users
>> (namely the functionality to send new DOVI metadata)?
> 
> Is this a valid scenario? lavf only exports this side data during
> read_header(). A change in DOVI profile would mean a brand new CVS, and
> afaik we require a new decoder to be fired up for this.
> 

Since when do we require this? I always thought that both H.264 and HEVC
decoders are supposed to allow new in-band extradata at any time.

>>
>>>           ff_dovi_update_cfg(&s->dovi_ctx,
>>> (AVDOVIDecoderConfigurationRecord *) sd);
>>> +    }
>>>         s->ref = NULL;
>>>       ret    = decode_nal_units(s, avpkt->data, avpkt->size);
>>> @@ -3707,12 +3711,18 @@ static av_cold int
>>> hevc_decode_init(AVCodecContext *avctx)
>>>       atomic_init(&s->wpp_err, 0);
>>>         if (!avctx->internal->is_copy) {
>>> +        AVPacketSideData *sd;
>>> +
>>>           if (avctx->extradata_size > 0 && avctx->extradata) {
>>>               ret = hevc_decode_extradata(s, avctx->extradata,
>>> avctx->extradata_size, 1);
>>>               if (ret < 0) {
>>>                   return ret;
>>>               }
>>>           }
>>> +
>>> +        sd = av_packet_get_side_data_from_set(&avctx->side_data_set,
>>> AV_PKT_DATA_DOVI_CONF);
>>> +        if (sd && sd->size > 0)
>>> +            ff_dovi_update_cfg(&s->dovi_ctx,
>>> (AVDOVIDecoderConfigurationRecord *) sd->data);
>>>       }
>>>         return 0;
>>
James Almer July 23, 2023, 12:22 p.m. UTC | #4
On 7/23/2023 9:17 AM, Andreas Rheinhardt wrote:
> James Almer:
>> On 7/23/2023 5:40 AM, Andreas Rheinhardt wrote:
>>> James Almer:
>>>> Signed-off-by: James Almer <jamrial@gmail.com>
>>>> ---
>>>>    libavcodec/hevcdec.c | 12 +++++++++++-
>>>>    1 file changed, 11 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
>>>> index fcf19b4eb6..0d659e4c55 100644
>>>> --- a/libavcodec/hevcdec.c
>>>> +++ b/libavcodec/hevcdec.c
>>>> @@ -3403,8 +3403,12 @@ static int hevc_decode_frame(AVCodecContext
>>>> *avctx, AVFrame *rframe,
>>>>        }
>>>>          sd = av_packet_get_side_data(avpkt, AV_PKT_DATA_DOVI_CONF,
>>>> &sd_size);
>>>> -    if (sd && sd_size > 0)
>>>> +    if (sd && sd_size > 0) {
>>>> +        av_log(avctx, AV_LOG_WARNING,
>>>> +               "passing a DOVI configuration record through packet
>>>> side data is "
>>>> +               "deprecated and will stop working soon. Use
>>>> AVCodecContext side data\n");
>>>
>>> Doesn't this remove functionality that might be useful to some users
>>> (namely the functionality to send new DOVI metadata)?
>>
>> Is this a valid scenario? lavf only exports this side data during
>> read_header(). A change in DOVI profile would mean a brand new CVS, and
>> afaik we require a new decoder to be fired up for this.
>>
> 
> Since when do we require this? I always thought that both H.264 and HEVC
> decoders are supposed to allow new in-band extradata at any time.

This is not something that would get propagated as new extradata type 
side data, though. That's limited to new SPS/PPS/VPS.

I nonetheless agree that this was supported until now, and it suddenly 
not working anymore when flushing the decoder and start decoding a new 
CVS without closing the avctx may be possible is not nice, so I'll 
remove this log message.

> 
>>>
>>>>            ff_dovi_update_cfg(&s->dovi_ctx,
>>>> (AVDOVIDecoderConfigurationRecord *) sd);
>>>> +    }
>>>>          s->ref = NULL;
>>>>        ret    = decode_nal_units(s, avpkt->data, avpkt->size);
>>>> @@ -3707,12 +3711,18 @@ static av_cold int
>>>> hevc_decode_init(AVCodecContext *avctx)
>>>>        atomic_init(&s->wpp_err, 0);
>>>>          if (!avctx->internal->is_copy) {
>>>> +        AVPacketSideData *sd;
>>>> +
>>>>            if (avctx->extradata_size > 0 && avctx->extradata) {
>>>>                ret = hevc_decode_extradata(s, avctx->extradata,
>>>> avctx->extradata_size, 1);
>>>>                if (ret < 0) {
>>>>                    return ret;
>>>>                }
>>>>            }
>>>> +
>>>> +        sd = av_packet_get_side_data_from_set(&avctx->side_data_set,
>>>> AV_PKT_DATA_DOVI_CONF);
>>>> +        if (sd && sd->size > 0)
>>>> +            ff_dovi_update_cfg(&s->dovi_ctx,
>>>> (AVDOVIDecoderConfigurationRecord *) sd->data);
>>>>        }
>>>>          return 0;
>>>
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index fcf19b4eb6..0d659e4c55 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -3403,8 +3403,12 @@  static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
     }
 
     sd = av_packet_get_side_data(avpkt, AV_PKT_DATA_DOVI_CONF, &sd_size);
-    if (sd && sd_size > 0)
+    if (sd && sd_size > 0) {
+        av_log(avctx, AV_LOG_WARNING,
+               "passing a DOVI configuration record through packet side data is "
+               "deprecated and will stop working soon. Use AVCodecContext side data\n");
         ff_dovi_update_cfg(&s->dovi_ctx, (AVDOVIDecoderConfigurationRecord *) sd);
+    }
 
     s->ref = NULL;
     ret    = decode_nal_units(s, avpkt->data, avpkt->size);
@@ -3707,12 +3711,18 @@  static av_cold int hevc_decode_init(AVCodecContext *avctx)
     atomic_init(&s->wpp_err, 0);
 
     if (!avctx->internal->is_copy) {
+        AVPacketSideData *sd;
+
         if (avctx->extradata_size > 0 && avctx->extradata) {
             ret = hevc_decode_extradata(s, avctx->extradata, avctx->extradata_size, 1);
             if (ret < 0) {
                 return ret;
             }
         }
+
+        sd = av_packet_get_side_data_from_set(&avctx->side_data_set, AV_PKT_DATA_DOVI_CONF);
+        if (sd && sd->size > 0)
+            ff_dovi_update_cfg(&s->dovi_ctx, (AVDOVIDecoderConfigurationRecord *) sd->data);
     }
 
     return 0;