summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-03-10 10:48:34 +0100
committerAnton Khirnov <anton@khirnov.net>2023-03-20 10:42:09 +0100
commit27f8c9b27bce42a4a6a4c64e03fab769579c8683 (patch)
tree4c7d7bce3e4f99a9b864eae726d2280b7b415044 /libavutil
parent2fb3ee17877415fde76a7582797349484844b74d (diff)
downloadffmpeg-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 'libavutil')
-rw-r--r--libavutil/frame.c8
-rw-r--r--libavutil/frame.h10
-rw-r--r--libavutil/version.h1
3 files changed, 19 insertions, 0 deletions
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 9545477acc..5c9afb0d03 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -48,8 +48,12 @@ FF_DISABLE_DEPRECATION_WARNINGS
frame->pkt_duration = 0;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
+#if FF_API_FRAME_PKT
+FF_DISABLE_DEPRECATION_WARNINGS
frame->pkt_pos = -1;
frame->pkt_size = -1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
frame->time_base = (AVRational){ 0, 1 };
frame->key_frame = 1;
frame->sample_aspect_ratio = (AVRational){ 0, 1 };
@@ -279,8 +283,12 @@ static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy)
dst->sample_rate = src->sample_rate;
dst->opaque = src->opaque;
dst->pkt_dts = src->pkt_dts;
+#if FF_API_FRAME_PKT
+FF_DISABLE_DEPRECATION_WARNINGS
dst->pkt_pos = src->pkt_pos;
dst->pkt_size = src->pkt_size;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
#if FF_API_PKT_DURATION
FF_DISABLE_DEPRECATION_WARNINGS
dst->pkt_duration = src->pkt_duration;
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 4ed27cf43f..5b58c14ac3 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -622,12 +622,17 @@ typedef struct AVFrame {
*/
int64_t best_effort_timestamp;
+#if FF_API_FRAME_PKT
/**
* reordered pos from the last AVPacket that has been input into the decoder
* - encoding: unused
* - decoding: Read by user.
+ * @deprecated use AV_CODEC_FLAG_COPY_OPAQUE to pass through arbitrary user
+ * data from packets to frames
*/
+ attribute_deprecated
int64_t pkt_pos;
+#endif
#if FF_API_PKT_DURATION
/**
@@ -673,14 +678,19 @@ typedef struct AVFrame {
int channels;
#endif
+#if FF_API_FRAME_PKT
/**
* size of the corresponding packet containing the compressed
* frame.
* It is set to a negative value if unknown.
* - encoding: unused
* - decoding: set by libavcodec, read by user.
+ * @deprecated use AV_CODEC_FLAG_COPY_OPAQUE to pass through arbitrary user
+ * data from packets to frames
*/
+ attribute_deprecated
int pkt_size;
+#endif
/**
* For hwaccel-format frames, this should be a reference to the
diff --git a/libavutil/version.h b/libavutil/version.h
index a89a0d406f..93aa7a1050 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -114,6 +114,7 @@
#define FF_API_REORDERED_OPAQUE (LIBAVUTIL_VERSION_MAJOR < 59)
#define FF_API_FRAME_PICTURE_NUMBER (LIBAVUTIL_VERSION_MAJOR < 59)
#define FF_API_HDR_VIVID_THREE_SPLINE (LIBAVUTIL_VERSION_MAJOR < 59)
+#define FF_API_FRAME_PKT (LIBAVUTIL_VERSION_MAJOR < 59)
/**
* @}