History

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.

Marton Balint committed 1 year ago

Commit 19c95ec1 parent 8a29b4e16 files · +76 −1Browse files

Unified · Split

16 files
  1. doc/APIchanges +3 −0
  2. libavcodec/av1dec.c +8 −0
  3. libavcodec/avcodec.c +4 −0
  4. libavcodec/avcodec.h +3 −0
  5. libavcodec/h2645_sei.c +8 −0
  6. libavcodec/hevc/hevcdec.c +8 −0
  7. libavcodec/jpeg2000dec.c +4 −0
  8. libavcodec/libdav1d.c +8 −0
  9. libavcodec/mjpegdec.c +8 −0
  10. libavcodec/mpeg12dec.c +4 −0
  11. libavcodec/pthread_frame.c +4 −0
  12. libavcodec/version.h +1 −1
  13. libavcodec/version_major.h +1 −0
  14. libavcodec/vp9.c +4 −0
  15. libavcodec/webp.c +4 −0
  16. libavformat/dump.c +4 −0
doc/APIchanges+3−0
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 · 1 unmodified line
22
33 API changes, most recent first:
44
5+2025-01-05 - xxxxxxxxxx - lavc 61.31.100 - avcodec.h
6+ Deprecate AVCodecContext->properties.
7+
58 2025-01-05 - xxxxxxxxxx - lavc 61.30.100 - frame.h
69 Add AV_FRAME_FLAG_LOSSLESS.
710
libavcodec/av1dec.c+8−0
@@ -788,10 +788,14 @@ static int set_context_with_sequence(AVCodecContext *avctx, · 787 unmodified lines
788788 break;
789789 }
790790
791+#if FF_API_CODEC_PROPS
792+FF_DISABLE_DEPRECATION_WARNINGS
791793 if (seq->film_grain_params_present)
792794 avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
793795 else
794796 avctx->properties &= ~FF_CODEC_PROPERTY_FILM_GRAIN;
797+FF_ENABLE_DEPRECATION_WARNINGS
798+#endif
795799
796800 if (avctx->width != width || avctx->height != height) {
797801 int ret = ff_set_dimensions(avctx, width, height);
@@ -983,7 +987,11 @@ static int export_itut_t35(AVCodecContext *avctx, AVFrame *frame, · 185 unmodified lines
983987 if (ret < 0)
984988 return ret;
985989
990+#if FF_API_CODEC_PROPS
991+FF_DISABLE_DEPRECATION_WARNINGS
986992 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
993+FF_ENABLE_DEPRECATION_WARNINGS
994+#endif
987995 break;
988996 }
989997 default: // ignore unsupported identifiers
libavcodec/avcodec.c+4−0
@@ -647,12 +647,16 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) · 646 unmodified lines
647647 if (encode) {
648648 av_bprintf(&bprint, ", q=%d-%d", enc->qmin, enc->qmax);
649649 } else {
650+#if FF_API_CODEC_PROPS
651+FF_DISABLE_DEPRECATION_WARNINGS
650652 if (enc->properties & FF_CODEC_PROPERTY_CLOSED_CAPTIONS)
651653 av_bprintf(&bprint, ", Closed Captions");
652654 if (enc->properties & FF_CODEC_PROPERTY_FILM_GRAIN)
653655 av_bprintf(&bprint, ", Film Grain");
654656 if (enc->properties & FF_CODEC_PROPERTY_LOSSLESS)
655657 av_bprintf(&bprint, ", lossless");
658+FF_ENABLE_DEPRECATION_WARNINGS
659+#endif
656660 }
657661 break;
658662 case AVMEDIA_TYPE_AUDIO:
libavcodec/avcodec.h+3−0
@@ -1806,15 +1806,18 @@ typedef struct AVCodecContext { · 1805 unmodified lines
18061806 #define FF_LEVEL_UNKNOWN -99
18071807 #endif
18081808
1809+#if FF_API_CODEC_PROPS
18091810 /**
18101811 * Properties of the stream that gets decoded
18111812 * - encoding: unused
18121813 * - decoding: set by libavcodec
18131814 */
1815+ attribute_deprecated
18141816 unsigned properties;
18151817 #define FF_CODEC_PROPERTY_LOSSLESS 0x00000001
18161818 #define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002
18171819 #define FF_CODEC_PROPERTY_FILM_GRAIN 0x00000004
1820+#endif
18181821
18191822 /**
18201823 * Skip loop filtering for selected frames.
libavcodec/h2645_sei.c+8−0
@@ -807,7 +807,11 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei, · 806 unmodified lines
807807 if (!sd)
808808 av_buffer_unref(&a53->buf_ref);
809809 a53->buf_ref = NULL;
810+#if FF_API_CODEC_PROPS
811+FF_DISABLE_DEPRECATION_WARNINGS
810812 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
813+FF_ENABLE_DEPRECATION_WARNINGS
814+#endif
811815 }
812816
813817 ret = h2645_sei_to_side_data(avctx, sei, &frame->side_data, &frame->nb_side_data);
@@ -900,7 +904,11 @@ FF_ENABLE_DEPRECATION_WARNINGS · 86 unmodified lines
900904 else
901905 fgc->present = fgc->persistence_flag;
902906
907+#if FF_API_CODEC_PROPS
908+FF_DISABLE_DEPRECATION_WARNINGS
903909 avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
910+FF_ENABLE_DEPRECATION_WARNINGS
911+#endif
904912 }
905913
906914 #if CONFIG_HEVC_SEI
libavcodec/hevc/hevcdec.c+8−0
@@ -403,8 +403,12 @@ static int export_stream_params_from_sei(HEVCContext *s) · 402 unmodified lines
403403 {
404404 AVCodecContext *avctx = s->avctx;
405405
406+#if FF_API_CODEC_PROPS
407+FF_DISABLE_DEPRECATION_WARNINGS
406408 if (s->sei.common.a53_caption.buf_ref)
407409 s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
410+FF_ENABLE_DEPRECATION_WARNINGS
411+#endif
408412
409413 if (s->sei.common.alternative_transfer.present &&
410414 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) · 1 unmodified line
412416 avctx->color_trc = s->sei.common.alternative_transfer.preferred_transfer_characteristics;
413417 }
414418
419+#if FF_API_CODEC_PROPS
420+FF_DISABLE_DEPRECATION_WARNINGS
415421 if ((s->sei.common.film_grain_characteristics && s->sei.common.film_grain_characteristics->present) ||
416422 s->sei.common.aom_film_grain.enable)
417423 avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
424+FF_ENABLE_DEPRECATION_WARNINGS
425+#endif
418426
419427 return 0;
420428 }
libavcodec/jpeg2000dec.c+4−0
@@ -542,9 +542,13 @@ static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c) · 541 unmodified lines
542542 /* set integer 9/7 DWT in case of BITEXACT flag */
543543 if ((s->avctx->flags & AV_CODEC_FLAG_BITEXACT) && (c->transform == FF_DWT97))
544544 c->transform = FF_DWT97_INT;
545+#if FF_API_CODEC_PROPS
545546 else if (c->transform == FF_DWT53) {
547+FF_DISABLE_DEPRECATION_WARNINGS
546548 s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
549+FF_ENABLE_DEPRECATION_WARNINGS
547550 }
551+#endif
548552
549553 if (c->csty & JPEG2000_CSTY_PREC) {
550554 int i;
libavcodec/libdav1d.c+8−0
@@ -162,10 +162,14 @@ static void libdav1d_init_params(AVCodecContext *c, const Dav1dSequenceHeader *s · 161 unmodified lines
162162 (unsigned)seq->num_units_in_tick,
163163 (unsigned)seq->time_scale);
164164
165+#if FF_API_CODEC_PROPS
166+FF_DISABLE_DEPRECATION_WARNINGS
165167 if (seq->film_grain_present)
166168 c->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
167169 else
168170 c->properties &= ~FF_CODEC_PROPERTY_FILM_GRAIN;
171+FF_ENABLE_DEPRECATION_WARNINGS
172+#endif
169173 }
170174
171175 static av_cold int libdav1d_parse_extradata(AVCodecContext *c)
@@ -533,7 +537,11 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) · 361 unmodified lines
533537 if (res < 0)
534538 goto fail;
535539
540+#if FF_API_CODEC_PROPS
541+FF_DISABLE_DEPRECATION_WARNINGS
536542 c->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
543+FF_ENABLE_DEPRECATION_WARNINGS
544+#endif
537545 break;
538546 }
539547 default: // ignore unsupported identifiers
libavcodec/mjpegdec.c+8−0
@@ -2508,7 +2508,11 @@ redo_for_pal8: · 2507 unmodified lines
25082508 break;
25092509 case SOF3:
25102510 avctx->profile = AV_PROFILE_MJPEG_HUFFMAN_LOSSLESS;
2511+#if FF_API_CODEC_PROPS
2512+FF_DISABLE_DEPRECATION_WARNINGS
25112513 avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
2514+FF_ENABLE_DEPRECATION_WARNINGS
2515+#endif
25122516 s->lossless = 1;
25132517 s->ls = 0;
25142518 s->progressive = 0;
@@ -2517,7 +2521,11 @@ redo_for_pal8: · 2 unmodified lines
25172521 break;
25182522 case SOF48:
25192523 avctx->profile = AV_PROFILE_MJPEG_JPEG_LS;
2524+#if FF_API_CODEC_PROPS
2525+FF_DISABLE_DEPRECATION_WARNINGS
25202526 avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
2527+FF_ENABLE_DEPRECATION_WARNINGS
2528+#endif
25212529 s->lossless = 1;
25222530 s->ls = 1;
25232531 s->progressive = 0;
libavcodec/mpeg12dec.c+4−0
@@ -1919,7 +1919,11 @@ static void mpeg_set_cc_format(AVCodecContext *avctx, enum Mpeg2ClosedCaptionsFo · 1918 unmodified lines
19191919 av_log(avctx, AV_LOG_DEBUG, "CC: first seen substream is %s format\n", label);
19201920 }
19211921
1922+#if FF_API_CODEC_PROPS
1923+FF_DISABLE_DEPRECATION_WARNINGS
19221924 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
1925+FF_ENABLE_DEPRECATION_WARNINGS
1926+#endif
19231927 }
19241928
19251929 static int mpeg_decode_a53_cc(AVCodecContext *avctx,
libavcodec/pthread_frame.c+4−0
@@ -365,7 +365,11 @@ static int update_context_from_thread(AVCodecContext *dst, const AVCodecContext · 364 unmodified lines
365365
366366 dst->has_b_frames = src->has_b_frames;
367367 dst->idct_algo = src->idct_algo;
368+#if FF_API_CODEC_PROPS
369+FF_DISABLE_DEPRECATION_WARNINGS
368370 dst->properties = src->properties;
371+FF_ENABLE_DEPRECATION_WARNINGS
372+#endif
369373
370374 dst->bits_per_coded_sample = src->bits_per_coded_sample;
371375 dst->sample_aspect_ratio = src->sample_aspect_ratio;
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929
3030 #include "version_major.h"
3131
32−#define LIBAVCODEC_VERSION_MINOR 30
32+#define LIBAVCODEC_VERSION_MINOR 31
3333 #define LIBAVCODEC_VERSION_MICRO 100
3434
3535 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
libavcodec/version_major.h+1−0
@@ -49,6 +49,7 @@ · 48 unmodified lines
4949 #define FF_API_VDPAU_ALLOC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 62)
5050 #define FF_API_QUALITY_FACTOR (LIBAVCODEC_VERSION_MAJOR < 62)
5151 #define FF_API_V408_CODECID (LIBAVCODEC_VERSION_MAJOR < 62)
52+#define FF_API_CODEC_PROPS (LIBAVCODEC_VERSION_MAJOR < 63)
5253
5354 // reminder to remove the OMX encoder on next major bump
5455 #define FF_CODEC_OMX (LIBAVCODEC_VERSION_MAJOR < 62)
libavcodec/vp9.c+4−0
@@ -682,8 +682,12 @@ static int decode_frame_header(AVCodecContext *avctx, · 681 unmodified lines
682682 s->s.h.uvac_qdelta = get_bits1(&s->gb) ? get_sbits_inv(&s->gb, 4) : 0;
683683 s->s.h.lossless = s->s.h.yac_qi == 0 && s->s.h.ydc_qdelta == 0 &&
684684 s->s.h.uvdc_qdelta == 0 && s->s.h.uvac_qdelta == 0;
685+#if FF_API_CODEC_PROPS
686+FF_DISABLE_DEPRECATION_WARNINGS
685687 if (s->s.h.lossless)
686688 avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
689+FF_ENABLE_DEPRECATION_WARNINGS
690+#endif
687691
688692 /* segmentation header info */
689693 if ((s->s.h.segmentation.enabled = get_bits1(&s->gb))) {
libavcodec/webp.c+4−0
@@ -1407,7 +1407,11 @@ static int webp_decode_frame(AVCodecContext *avctx, AVFrame *p, · 1406 unmodified lines
14071407 chunk_size, 0);
14081408 if (ret < 0)
14091409 return ret;
1410+#if FF_API_CODEC_PROPS
1411+FF_DISABLE_DEPRECATION_WARNINGS
14101412 avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
1413+FF_ENABLE_DEPRECATION_WARNINGS
1414+#endif
14111415 }
14121416 bytestream2_skip(&gb, chunk_size);
14131417 break;
libavformat/dump.c+4−0
@@ -620,7 +620,11 @@ static void dump_stream_format(const AVFormatContext *ic, int i, · 619 unmodified lines
620620
621621 // Fields which are missing from AVCodecParameters need to be taken from the AVCodecContext
622622 if (sti->avctx) {
623+#if FF_API_CODEC_PROPS
624+FF_DISABLE_DEPRECATION_WARNINGS
623625 avctx->properties = sti->avctx->properties;
626+FF_ENABLE_DEPRECATION_WARNINGS
627+#endif
624628 avctx->codec = sti->avctx->codec;
625629 avctx->qmin = sti->avctx->qmin;
626630 avctx->qmax = sti->avctx->qmax;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t