[FFmpeg-cvslog] avcodec: deprecate AVCodecContext properties
Marton Balint
git at videolan.org
Mon Jan 6 00:05:30 EET 2025
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sun Dec 8 21:51:20 2024 +0100| [19c95ecbff84eebca254d200c941ce07868ee707] | committer: Marton Balint
avcodec: deprecate AVCodecContext properties
These properties are unreliable because they depend on the frames decoded so
far, users should check directly the presence of the decoded AVFrame side data
or AVFrame flags.
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=19c95ecbff84eebca254d200c941ce07868ee707
---
doc/APIchanges | 3 +++
libavcodec/av1dec.c | 8 ++++++++
libavcodec/avcodec.c | 4 ++++
libavcodec/avcodec.h | 3 +++
libavcodec/h2645_sei.c | 8 ++++++++
libavcodec/hevc/hevcdec.c | 8 ++++++++
libavcodec/jpeg2000dec.c | 4 ++++
libavcodec/libdav1d.c | 8 ++++++++
libavcodec/mjpegdec.c | 8 ++++++++
libavcodec/mpeg12dec.c | 4 ++++
libavcodec/pthread_frame.c | 4 ++++
libavcodec/version.h | 2 +-
libavcodec/version_major.h | 1 +
libavcodec/vp9.c | 4 ++++
libavcodec/webp.c | 4 ++++
libavformat/dump.c | 4 ++++
16 files changed, 76 insertions(+), 1 deletion(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index f28c55e99a..d2c84e3905 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
API changes, most recent first:
+2025-01-05 - xxxxxxxxxx - lavc 61.31.100 - avcodec.h
+ Deprecate AVCodecContext->properties.
+
2025-01-05 - xxxxxxxxxx - lavc 61.30.100 - frame.h
Add AV_FRAME_FLAG_LOSSLESS.
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 17651e640f..7c54e36220 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -788,10 +788,14 @@ static int set_context_with_sequence(AVCodecContext *avctx,
break;
}
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
if (seq->film_grain_params_present)
avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
else
avctx->properties &= ~FF_CODEC_PROPERTY_FILM_GRAIN;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (avctx->width != width || avctx->height != height) {
int ret = ff_set_dimensions(avctx, width, height);
@@ -983,7 +987,11 @@ static int export_itut_t35(AVCodecContext *avctx, AVFrame *frame,
if (ret < 0)
return ret;
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
break;
}
default: // ignore unsupported identifiers
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index f91549ddba..e7e2c09222 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -647,12 +647,16 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
if (encode) {
av_bprintf(&bprint, ", q=%d-%d", enc->qmin, enc->qmax);
} else {
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
if (enc->properties & FF_CODEC_PROPERTY_CLOSED_CAPTIONS)
av_bprintf(&bprint, ", Closed Captions");
if (enc->properties & FF_CODEC_PROPERTY_FILM_GRAIN)
av_bprintf(&bprint, ", Film Grain");
if (enc->properties & FF_CODEC_PROPERTY_LOSSLESS)
av_bprintf(&bprint, ", lossless");
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
break;
case AVMEDIA_TYPE_AUDIO:
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 12e6e8749f..403f02d841 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1806,15 +1806,18 @@ typedef struct AVCodecContext {
#define FF_LEVEL_UNKNOWN -99
#endif
+#if FF_API_CODEC_PROPS
/**
* Properties of the stream that gets decoded
* - encoding: unused
* - decoding: set by libavcodec
*/
+ attribute_deprecated
unsigned properties;
#define FF_CODEC_PROPERTY_LOSSLESS 0x00000001
#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002
#define FF_CODEC_PROPERTY_FILM_GRAIN 0x00000004
+#endif
/**
* Skip loop filtering for selected frames.
diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index c8fa975bf4..2494daaf3c 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -807,7 +807,11 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
if (!sd)
av_buffer_unref(&a53->buf_ref);
a53->buf_ref = NULL;
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
ret = h2645_sei_to_side_data(avctx, sei, &frame->side_data, &frame->nb_side_data);
@@ -900,7 +904,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
else
fgc->present = fgc->persistence_flag;
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
#if CONFIG_HEVC_SEI
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 1a2f668053..4fc48c28a7 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -403,8 +403,12 @@ static int export_stream_params_from_sei(HEVCContext *s)
{
AVCodecContext *avctx = s->avctx;
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
if (s->sei.common.a53_caption.buf_ref)
s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (s->sei.common.alternative_transfer.present &&
av_color_transfer_name(s->sei.common.alternative_transfer.preferred_transfer_characteristics) &&
@@ -412,9 +416,13 @@ static int export_stream_params_from_sei(HEVCContext *s)
avctx->color_trc = s->sei.common.alternative_transfer.preferred_transfer_characteristics;
}
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
if ((s->sei.common.film_grain_characteristics && s->sei.common.film_grain_characteristics->present) ||
s->sei.common.aom_film_grain.enable)
avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
return 0;
}
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index df13bea815..e5e897a29f 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -542,9 +542,13 @@ static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)
/* set integer 9/7 DWT in case of BITEXACT flag */
if ((s->avctx->flags & AV_CODEC_FLAG_BITEXACT) && (c->transform == FF_DWT97))
c->transform = FF_DWT97_INT;
+#if FF_API_CODEC_PROPS
else if (c->transform == FF_DWT53) {
+FF_DISABLE_DEPRECATION_WARNINGS
s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
+FF_ENABLE_DEPRECATION_WARNINGS
}
+#endif
if (c->csty & JPEG2000_CSTY_PREC) {
int i;
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index ff67f44bd3..f4cbc927b5 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -162,10 +162,14 @@ static void libdav1d_init_params(AVCodecContext *c, const Dav1dSequenceHeader *s
(unsigned)seq->num_units_in_tick,
(unsigned)seq->time_scale);
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
if (seq->film_grain_present)
c->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
else
c->properties &= ~FF_CODEC_PROPERTY_FILM_GRAIN;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
static av_cold int libdav1d_parse_extradata(AVCodecContext *c)
@@ -533,7 +537,11 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
if (res < 0)
goto fail;
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
c->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
break;
}
default: // ignore unsupported identifiers
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index fefa5e7877..bd1b502e50 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2508,7 +2508,11 @@ redo_for_pal8:
break;
case SOF3:
avctx->profile = AV_PROFILE_MJPEG_HUFFMAN_LOSSLESS;
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
s->lossless = 1;
s->ls = 0;
s->progressive = 0;
@@ -2517,7 +2521,11 @@ redo_for_pal8:
break;
case SOF48:
avctx->profile = AV_PROFILE_MJPEG_JPEG_LS;
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
s->lossless = 1;
s->ls = 1;
s->progressive = 0;
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 208ee28b04..bbcaa71e2e 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1919,7 +1919,11 @@ static void mpeg_set_cc_format(AVCodecContext *avctx, enum Mpeg2ClosedCaptionsFo
av_log(avctx, AV_LOG_DEBUG, "CC: first seen substream is %s format\n", label);
}
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
static int mpeg_decode_a53_cc(AVCodecContext *avctx,
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 4960352307..d9df0d62a8 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -365,7 +365,11 @@ static int update_context_from_thread(AVCodecContext *dst, const AVCodecContext
dst->has_b_frames = src->has_b_frames;
dst->idct_algo = src->idct_algo;
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
dst->properties = src->properties;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
dst->bits_per_coded_sample = src->bits_per_coded_sample;
dst->sample_aspect_ratio = src->sample_aspect_ratio;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index aeb58e3fed..497389d3f3 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "version_major.h"
-#define LIBAVCODEC_VERSION_MINOR 30
+#define LIBAVCODEC_VERSION_MINOR 31
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavcodec/version_major.h b/libavcodec/version_major.h
index 86f4218b65..35df5eb779 100644
--- a/libavcodec/version_major.h
+++ b/libavcodec/version_major.h
@@ -49,6 +49,7 @@
#define FF_API_VDPAU_ALLOC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 62)
#define FF_API_QUALITY_FACTOR (LIBAVCODEC_VERSION_MAJOR < 62)
#define FF_API_V408_CODECID (LIBAVCODEC_VERSION_MAJOR < 62)
+#define FF_API_CODEC_PROPS (LIBAVCODEC_VERSION_MAJOR < 63)
// reminder to remove the OMX encoder on next major bump
#define FF_CODEC_OMX (LIBAVCODEC_VERSION_MAJOR < 62)
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index dd0efdc8d1..83cd8a1565 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -682,8 +682,12 @@ static int decode_frame_header(AVCodecContext *avctx,
s->s.h.uvac_qdelta = get_bits1(&s->gb) ? get_sbits_inv(&s->gb, 4) : 0;
s->s.h.lossless = s->s.h.yac_qi == 0 && s->s.h.ydc_qdelta == 0 &&
s->s.h.uvdc_qdelta == 0 && s->s.h.uvac_qdelta == 0;
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
if (s->s.h.lossless)
avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
/* segmentation header info */
if ((s->s.h.segmentation.enabled = get_bits1(&s->gb))) {
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index a965e50ac4..9f83b518ad 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -1407,7 +1407,11 @@ static int webp_decode_frame(AVCodecContext *avctx, AVFrame *p,
chunk_size, 0);
if (ret < 0)
return ret;
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
bytestream2_skip(&gb, chunk_size);
break;
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 3db11e010c..3d37623a41 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -620,7 +620,11 @@ static void dump_stream_format(const AVFormatContext *ic, int i,
// Fields which are missing from AVCodecParameters need to be taken from the AVCodecContext
if (sti->avctx) {
+#if FF_API_CODEC_PROPS
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->properties = sti->avctx->properties;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
avctx->codec = sti->avctx->codec;
avctx->qmin = sti->avctx->qmin;
avctx->qmax = sti->avctx->qmax;
More information about the ffmpeg-cvslog
mailing list