aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/af_volume.c
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 /libavfilter/af_volume.c
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 'libavfilter/af_volume.c')
-rw-r--r--libavfilter/af_volume.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
index f6e183df8d..926529947c 100644
--- a/libavfilter/af_volume.c
+++ b/libavfilter/af_volume.c
@@ -48,7 +48,9 @@ static const char *const var_names[] = {
"nb_channels", ///< number of channels
"nb_consumed_samples", ///< number of samples consumed by the filter
"nb_samples", ///< number of samples in the current frame
+#if FF_API_FRAME_PKT
"pos", ///< position in the file of the frame
+#endif
"pts", ///< frame presentation timestamp
"sample_rate", ///< sample rate
"startpts", ///< PTS at start of stream
@@ -288,7 +290,9 @@ static int config_output(AVFilterLink *outlink)
vol->var_values[VAR_N] =
vol->var_values[VAR_NB_CONSUMED_SAMPLES] =
vol->var_values[VAR_NB_SAMPLES] =
+#if FF_API_FRAME_PKT
vol->var_values[VAR_POS] =
+#endif
vol->var_values[VAR_PTS] =
vol->var_values[VAR_STARTPTS] =
vol->var_values[VAR_STARTT] =
@@ -330,7 +334,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
AVFilterLink *outlink = inlink->dst->outputs[0];
int nb_samples = buf->nb_samples;
AVFrame *out_buf;
- int64_t pos;
AVFrameSideData *sd = av_frame_get_side_data(buf, AV_FRAME_DATA_REPLAYGAIN);
int ret;
@@ -380,8 +383,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
vol->var_values[VAR_T ] = TS2T(buf->pts, inlink->time_base);
vol->var_values[VAR_N ] = inlink->frame_count_out;
- pos = buf->pkt_pos;
- vol->var_values[VAR_POS] = pos == -1 ? NAN : pos;
+#if FF_API_FRAME_PKT
+FF_DISABLE_DEPRECATION_WARNINGS
+ {
+ int64_t pos;
+ pos = buf->pkt_pos;
+ vol->var_values[VAR_POS] = pos == -1 ? NAN : pos;
+ }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (vol->eval_mode == EVAL_MODE_FRAME)
set_volume(ctx);