[FFmpeg-cvslog] lavc: deprecate AV_CODEC_FLAG_DROPCHANGED
Anton Khirnov
git at videolan.org
Sat Jul 15 11:22:52 EEST 2023
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun Jul 9 14:53:46 2023 +0200| [f264204de9d15f21d10a67304ee32347a5adb411] | committer: Anton Khirnov
lavc: deprecate AV_CODEC_FLAG_DROPCHANGED
This decoding flag makes decoders drop all frames after a parameter
change, but what exactly constitutes a parameter change is not well
defined and will typically depend on the exact use case.
This functionality then does not belong in libavcodec, but rather in
user code
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f264204de9d15f21d10a67304ee32347a5adb411
---
doc/APIchanges | 3 +++
libavcodec/avcodec.c | 2 ++
libavcodec/avcodec.h | 7 ++++---
libavcodec/decode.c | 11 +++++++++--
libavcodec/internal.h | 2 ++
libavcodec/options_table.h | 4 +++-
libavcodec/version_major.h | 1 +
7 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 27f835cfce..5afe8bcb75 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
API changes, most recent first:
+2023-07-xx - xxxxxxxxxx - lavc 60 - avcodec.h
+ Deprecate AV_CODEC_FLAG_DROPCHANGED without replacement.
+
2023-07-05 - xxxxxxxxxx - lavu 58.14.100 - random_seed.h
Add av_random_bytes()
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 8ccc610227..340abe830e 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -456,7 +456,9 @@ av_cold int avcodec_close(AVCodecContext *avctx)
av_bsf_free(&avci->bsf);
+#if FF_API_DROPCHANGED
av_channel_layout_uninit(&avci->initial_ch_layout);
+#endif
#if CONFIG_LCMS2
ff_icc_context_uninit(&avci->icc);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index d17bdc360d..fe41ecc3c9 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -226,11 +226,15 @@ typedef struct RcOverride{
* Use qpel MC.
*/
#define AV_CODEC_FLAG_QPEL (1 << 4)
+#if FF_API_DROPCHANGED
/**
* Don't output frames whose parameters differ from first
* decoded frame in stream.
+ *
+ * @deprecated callers should implement this functionality in their own code
*/
#define AV_CODEC_FLAG_DROPCHANGED (1 << 5)
+#endif
/**
* Request the encoder to output reconstructed frames, i.e.\ frames that would
* be produced by decoding the encoded bistream. These frames may be retrieved
@@ -2713,9 +2717,6 @@ int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt);
* no more output frames
* @retval AVERROR(EINVAL) codec not opened, or it is an encoder without the
* @ref AV_CODEC_FLAG_RECON_FRAME flag enabled
- * @retval AVERROR_INPUT_CHANGED current decoded frame has changed parameters with
- * respect to first decoded frame. Applicable when flag
- * AV_CODEC_FLAG_DROPCHANGED is set.
* @retval "other negative error code" legitimate decoding errors
*/
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame);
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 68525e47a6..a19cca1a7c 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -773,7 +773,7 @@ fail:
int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
{
AVCodecInternal *avci = avctx->internal;
- int ret, changed;
+ int ret;
if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))
return AVERROR(EINVAL);
@@ -803,6 +803,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
+#if FF_API_DROPCHANGED
if (avctx->flags & AV_CODEC_FLAG_DROPCHANGED) {
if (avctx->frame_num == 1) {
@@ -823,7 +824,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
if (avctx->frame_num > 1) {
- changed = avci->initial_format != frame->format;
+ int changed = avci->initial_format != frame->format;
switch(avctx->codec_type) {
case AVMEDIA_TYPE_VIDEO:
@@ -848,6 +849,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
}
}
+#endif
return 0;
fail:
av_frame_unref(frame);
@@ -1773,6 +1775,11 @@ int ff_decode_preinit(AVCodecContext *avctx)
if (ret < 0)
return ret;
+#if FF_API_DROPCHANGED
+ if (avctx->flags & AV_CODEC_FLAG_DROPCHANGED)
+ av_log(avctx, AV_LOG_WARNING, "The dropchanged flag is deprecated.\n");
+#endif
+
return 0;
}
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 868dd46b48..4dce9f6fbb 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -135,12 +135,14 @@ typedef struct AVCodecInternal {
AVFrame *buffer_frame;
int draining_done;
+#if FF_API_DROPCHANGED
/* used when avctx flag AV_CODEC_FLAG_DROPCHANGED is set */
int changed_frames_dropped;
int initial_format;
int initial_width, initial_height;
int initial_sample_rate;
AVChannelLayout initial_ch_layout;
+#endif
#if CONFIG_LCMS2
FFIccContext icc; /* used to read and write embedded ICC profiles */
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index f1a9729c0d..bb4b894b06 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -72,7 +72,9 @@ static const AVOption avcodec_options[] = {
{"ilme", "interlaced motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_INTERLACED_ME }, INT_MIN, INT_MAX, V|E, "flags"},
{"cgop", "closed GOP", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_CLOSED_GOP }, INT_MIN, INT_MAX, V|E, "flags"},
{"output_corrupt", "Output even potentially corrupted frames", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_OUTPUT_CORRUPT }, INT_MIN, INT_MAX, V|D, "flags"},
-{"drop_changed", "Drop frames whose parameters differ from first decoded frame", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_DROPCHANGED }, INT_MIN, INT_MAX, A|V|D, "flags"},
+#if FF_API_DROPCHANGED
+{"drop_changed", "Drop frames whose parameters differ from first decoded frame", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_DROPCHANGED }, INT_MIN, INT_MAX, A|V|D | AV_OPT_FLAG_DEPRECATED, "flags"},
+#endif
{"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, UINT_MAX, V|A|E|D|S, "flags2"},
{"fast", "allow non-spec-compliant speedup tricks", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_FAST }, INT_MIN, INT_MAX, V|E, "flags2"},
{"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"},
diff --git a/libavcodec/version_major.h b/libavcodec/version_major.h
index 2f5138d079..95c5aec0c5 100644
--- a/libavcodec/version_major.h
+++ b/libavcodec/version_major.h
@@ -48,6 +48,7 @@
#define FF_API_SLICE_OFFSET (LIBAVCODEC_VERSION_MAJOR < 61)
#define FF_API_SUBFRAMES (LIBAVCODEC_VERSION_MAJOR < 61)
#define FF_API_TICKS_PER_FRAME (LIBAVCODEC_VERSION_MAJOR < 61)
+#define FF_API_DROPCHANGED (LIBAVCODEC_VERSION_MAJOR < 61)
// reminder to remove CrystalHD decoders on next major bump
#define FF_CODEC_CRYSTAL_HD (LIBAVCODEC_VERSION_MAJOR < 61)
More information about the ffmpeg-cvslog
mailing list