[FFmpeg-devel] [PATCH 6/6] lavu/frame: deprecate AVFrame.pkt_{pos, size}

James Almer jamrial at gmail.com
Fri Mar 10 14:18:24 EET 2023


On 3/10/2023 8:56 AM, Anton Khirnov wrote:
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index d1ba7f167f..ed937a3055 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -287,8 +287,12 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame,
>           if (!(codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS))
>               frame->pkt_dts = pkt->dts;
>           if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
> +#if FF_API_FRAME_PKT
> +FF_DISABLE_DEPRECATION_WARNINGS
>               if(!avctx->has_b_frames)
>                   frame->pkt_pos = pkt->pos;
> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif
>               //FIXME these should be under if(!avctx->has_b_frames)
>               /* get_buffer is supposed to set frame parameters */
>               if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) {
> @@ -1312,9 +1316,13 @@ int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx,
>       };
>   
>       frame->pts          = pkt->pts;
> -    frame->pkt_pos      = pkt->pos;
>       frame->duration     = pkt->duration;
> +#if FF_API_FRAME_PKT
> +FF_DISABLE_DEPRECATION_WARNINGS
> +    frame->pkt_pos      = pkt->pos;
>       frame->pkt_size     = pkt->size;
> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif
>   
>       for (int i = 0; i < FF_ARRAY_ELEMS(sd); i++) {
>           size_t size;
> @@ -1355,7 +1363,11 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
>           int ret = ff_decode_frame_props_from_pkt(avctx, frame, pkt);
>           if (ret < 0)
>               return ret;
> +#if FF_API_FRAME_PKT
> +FF_DISABLE_DEPRECATION_WARNINGS
>           frame->pkt_size = pkt->stream_index;

The only remaining use of last_pkt_props->stream_index is in 
decode_simple_internal() where it subtracts the amount of bytes consumed 
from it, so maybe it should be wrapped too?

> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif
>       }
>   #if FF_API_REORDERED_OPAQUE
>   FF_DISABLE_DEPRECATION_WARNINGS


More information about the ffmpeg-devel mailing list