diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-03-10 10:48:34 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-03-20 10:42:09 +0100 |
commit | 27f8c9b27bce42a4a6a4c64e03fab769579c8683 (patch) | |
tree | 4c7d7bce3e4f99a9b864eae726d2280b7b415044 /libavcodec | |
parent | 2fb3ee17877415fde76a7582797349484844b74d (diff) | |
download | ffmpeg-27f8c9b27bce42a4a6a4c64e03fab769579c8683.tar.gz |
lavu/frame: deprecate AVFrame.pkt_{pos,size}
These fields are supposed to store information about the packet the
frame was decoded from, specifically the byte offset it was stored at
and its size.
However,
- the fields are highly ad-hoc - there is no strong reason why
specifically those (and not any other) packet properties should have a
dedicated field in AVFrame; unlike e.g. the timestamps, there is no
fundamental link between coded packet offset/size and decoded frames
- they only make sense for frames produced by decoding demuxed packets,
and even then it is not always the case that the encoded data was
stored in the file as a contiguous sequence of bytes (in order for pos
to be well-defined)
- pkt_pos was added without much explanation, apparently to allow
passthrough of this information through lavfi in order to handle byte
seeking in ffplay. That is now implemented using arbitrary user data
passthrough in AVFrame.opaque_ref.
- several filters use pkt_pos as a variable available to user-supplied
expressions, but there seems to be no established motivation for using them.
- pkt_size was added for use in ffprobe, but that too is now handled
without using this field. Additonally, the values of this field
produced by libavcodec are flawed, as described in the previous
ffprobe conversion commit.
In summary - these fields are ill-defined and insufficiently motivated,
so deprecate them.
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/av1dec.c | 4 | ||||
-rw-r--r-- | libavcodec/crystalhd.c | 6 | ||||
-rw-r--r-- | libavcodec/cuviddec.c | 6 | ||||
-rw-r--r-- | libavcodec/decode.c | 18 | ||||
-rw-r--r-- | libavcodec/libuavs3d.c | 8 |
5 files changed, 39 insertions, 3 deletions
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 4d3b559b96..5c14756a57 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -1074,7 +1074,11 @@ static int set_output_frame(AVCodecContext *avctx, AVFrame *frame, frame->pts = pkt->pts; frame->pkt_dts = pkt->dts; +#if FF_API_FRAME_PKT +FF_DISABLE_DEPRECATION_WARNINGS frame->pkt_size = pkt->size; +FF_ENABLE_DEPRECATION_WARNINGS +#endif *got_frame = 1; diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c index 688cdffbcb..a48d60f123 100644 --- a/libavcodec/crystalhd.c +++ b/libavcodec/crystalhd.c @@ -549,9 +549,13 @@ static inline CopyRet copy_frame(AVCodecContext *avctx, frame->pts = pkt_pts; - frame->pkt_pos = -1; frame->duration = 0; +#if FF_API_FRAME_PKT +FF_DISABLE_DEPRECATION_WARNINGS + frame->pkt_pos = -1; frame->pkt_size = -1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (!priv->need_second_field) { *got_frame = 1; diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c index 4ba7918b64..76e70aa648 100644 --- a/libavcodec/cuviddec.c +++ b/libavcodec/cuviddec.c @@ -623,9 +623,13 @@ static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame) /* CUVIDs opaque reordering breaks the internal pkt logic. * So set pkt_pts and clear all the other pkt_ fields. */ - frame->pkt_pos = -1; frame->duration = 0; +#if FF_API_FRAME_PKT +FF_DISABLE_DEPRECATION_WARNINGS + frame->pkt_pos = -1; frame->pkt_size = -1; +FF_ENABLE_DEPRECATION_WARNINGS +#endif frame->interlaced_frame = !parsed_frame.is_deinterlacing && !parsed_frame.dispinfo.progressive_frame; diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 22a0f8eb25..40f5a3ba59 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -139,8 +139,10 @@ static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt) av_packet_unref(avci->last_pkt_props); if (pkt) { ret = av_packet_copy_props(avci->last_pkt_props, pkt); +#if FF_API_FRAME_PKT if (!ret) avci->last_pkt_props->stream_index = pkt->size; // Needed for ff_decode_frame_props(). +#endif } return ret; } @@ -287,8 +289,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)) { @@ -460,8 +466,10 @@ FF_ENABLE_DEPRECATION_WARNINGS pkt->pts = AV_NOPTS_VALUE; pkt->dts = AV_NOPTS_VALUE; if (!(codec->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) { +#if FF_API_FRAME_PKT // See extract_packet_props() comment. avci->last_pkt_props->stream_index = avci->last_pkt_props->stream_index - consumed; +#endif avci->last_pkt_props->pts = AV_NOPTS_VALUE; avci->last_pkt_props->dts = AV_NOPTS_VALUE; } @@ -1313,9 +1321,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; @@ -1356,7 +1368,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; +FF_ENABLE_DEPRECATION_WARNINGS +#endif } #if FF_API_REORDERED_OPAQUE FF_DISABLE_DEPRECATION_WARNINGS diff --git a/libavcodec/libuavs3d.c b/libavcodec/libuavs3d.c index b1ccb151e6..5c08d2b8d3 100644 --- a/libavcodec/libuavs3d.c +++ b/libavcodec/libuavs3d.c @@ -79,8 +79,12 @@ static void uavs3d_output_callback(uavs3d_io_frm_t *dec_frame) { frm->pts = dec_frame->pts; frm->pkt_dts = dec_frame->dts; +#if FF_API_FRAME_PKT +FF_DISABLE_DEPRECATION_WARNINGS frm->pkt_pos = dec_frame->pkt_pos; frm->pkt_size = dec_frame->pkt_size; +FF_ENABLE_DEPRECATION_WARNINGS +#endif #if FF_API_FRAME_PICTURE_NUMBER FF_DISABLE_DEPRECATION_WARNINGS frm->coded_picture_number = dec_frame->dtr; @@ -175,8 +179,12 @@ static int libuavs3d_decode_frame(AVCodecContext *avctx, AVFrame *frm, uavs3d_io_frm_t *frm_dec = &h->dec_frame; buf_end = buf + buf_size; +#if FF_API_FRAME_PKT +FF_DISABLE_DEPRECATION_WARNINGS frm_dec->pkt_pos = avpkt->pos; frm_dec->pkt_size = avpkt->size; +FF_ENABLE_DEPRECATION_WARNINGS +#endif while (!finish) { int bs_len; |