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
2 2
3API changes, most recent first:3API changes, most recent first:
4 4
52025-01-05 - xxxxxxxxxx - lavc 61.31.100 - avcodec.h
6 Deprecate AVCodecContext->properties.
7
52025-01-05 - xxxxxxxxxx - lavc 61.30.100 - frame.h82025-01-05 - xxxxxxxxxx - lavc 61.30.100 - frame.h
6 Add AV_FRAME_FLAG_LOSSLESS.9 Add AV_FRAME_FLAG_LOSSLESS.
7 10
libavcodec/av1dec.c+8−0
@@ -788,10 +788,14 @@ static int set_context_with_sequence(AVCodecContext *avctx, · 787 unmodified lines
788 break;788 break;
789 }789 }
790 790
791#if FF_API_CODEC_PROPS
792FF_DISABLE_DEPRECATION_WARNINGS
791 if (seq->film_grain_params_present)793 if (seq->film_grain_params_present)
792 avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;794 avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
793 else795 else
794 avctx->properties &= ~FF_CODEC_PROPERTY_FILM_GRAIN;796 avctx->properties &= ~FF_CODEC_PROPERTY_FILM_GRAIN;
797FF_ENABLE_DEPRECATION_WARNINGS
798#endif
795 799
796 if (avctx->width != width || avctx->height != height) {800 if (avctx->width != width || avctx->height != height) {
797 int ret = ff_set_dimensions(avctx, width, height);801 int ret = ff_set_dimensions(avctx, width, height);
@@ -983,7 +987,11 @@ static int export_itut_t35(AVCodecContext *avctx, AVFrame *frame, · 185 unmodified lines
983 if (ret < 0)987 if (ret < 0)
984 return ret;988 return ret;
985 989
990#if FF_API_CODEC_PROPS
991FF_DISABLE_DEPRECATION_WARNINGS
986 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;992 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
993FF_ENABLE_DEPRECATION_WARNINGS
994#endif
987 break;995 break;
988 }996 }
989 default: // ignore unsupported identifiers997 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
647 if (encode) {647 if (encode) {
648 av_bprintf(&bprint, ", q=%d-%d", enc->qmin, enc->qmax);648 av_bprintf(&bprint, ", q=%d-%d", enc->qmin, enc->qmax);
649 } else {649 } else {
650#if FF_API_CODEC_PROPS
651FF_DISABLE_DEPRECATION_WARNINGS
650 if (enc->properties & FF_CODEC_PROPERTY_CLOSED_CAPTIONS)652 if (enc->properties & FF_CODEC_PROPERTY_CLOSED_CAPTIONS)
651 av_bprintf(&bprint, ", Closed Captions");653 av_bprintf(&bprint, ", Closed Captions");
652 if (enc->properties & FF_CODEC_PROPERTY_FILM_GRAIN)654 if (enc->properties & FF_CODEC_PROPERTY_FILM_GRAIN)
653 av_bprintf(&bprint, ", Film Grain");655 av_bprintf(&bprint, ", Film Grain");
654 if (enc->properties & FF_CODEC_PROPERTY_LOSSLESS)656 if (enc->properties & FF_CODEC_PROPERTY_LOSSLESS)
655 av_bprintf(&bprint, ", lossless");657 av_bprintf(&bprint, ", lossless");
658FF_ENABLE_DEPRECATION_WARNINGS
659#endif
656 }660 }
657 break;661 break;
658 case AVMEDIA_TYPE_AUDIO:662 case AVMEDIA_TYPE_AUDIO:
libavcodec/avcodec.h+3−0
@@ -1806,15 +1806,18 @@ typedef struct AVCodecContext { · 1805 unmodified lines
1806#define FF_LEVEL_UNKNOWN -991806#define FF_LEVEL_UNKNOWN -99
1807#endif1807#endif
1808 1808
1809#if FF_API_CODEC_PROPS
1809 /**1810 /**
1810 * Properties of the stream that gets decoded1811 * Properties of the stream that gets decoded
1811 * - encoding: unused1812 * - encoding: unused
1812 * - decoding: set by libavcodec1813 * - decoding: set by libavcodec
1813 */1814 */
1815 attribute_deprecated
1814 unsigned properties;1816 unsigned properties;
1815#define FF_CODEC_PROPERTY_LOSSLESS 0x000000011817#define FF_CODEC_PROPERTY_LOSSLESS 0x00000001
1816#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x000000021818#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002
1817#define FF_CODEC_PROPERTY_FILM_GRAIN 0x000000041819#define FF_CODEC_PROPERTY_FILM_GRAIN 0x00000004
1820#endif
1818 1821
1819 /**1822 /**
1820 * Skip loop filtering for selected frames.1823 * 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
807 if (!sd)807 if (!sd)
808 av_buffer_unref(&a53->buf_ref);808 av_buffer_unref(&a53->buf_ref);
809 a53->buf_ref = NULL;809 a53->buf_ref = NULL;
810#if FF_API_CODEC_PROPS
811FF_DISABLE_DEPRECATION_WARNINGS
810 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;812 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
813FF_ENABLE_DEPRECATION_WARNINGS
814#endif
811 }815 }
812 816
813 ret = h2645_sei_to_side_data(avctx, sei, &frame->side_data, &frame->nb_side_data);817 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
900 else904 else
901 fgc->present = fgc->persistence_flag;905 fgc->present = fgc->persistence_flag;
902 906
907#if FF_API_CODEC_PROPS
908FF_DISABLE_DEPRECATION_WARNINGS
903 avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;909 avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
910FF_ENABLE_DEPRECATION_WARNINGS
911#endif
904 }912 }
905 913
906#if CONFIG_HEVC_SEI914#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
403{403{
404 AVCodecContext *avctx = s->avctx;404 AVCodecContext *avctx = s->avctx;
405 405
406#if FF_API_CODEC_PROPS
407FF_DISABLE_DEPRECATION_WARNINGS
406 if (s->sei.common.a53_caption.buf_ref)408 if (s->sei.common.a53_caption.buf_ref)
407 s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;409 s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
410FF_ENABLE_DEPRECATION_WARNINGS
411#endif
408 412
409 if (s->sei.common.alternative_transfer.present &&413 if (s->sei.common.alternative_transfer.present &&
410 av_color_transfer_name(s->sei.common.alternative_transfer.preferred_transfer_characteristics) &&414 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
412 avctx->color_trc = s->sei.common.alternative_transfer.preferred_transfer_characteristics;416 avctx->color_trc = s->sei.common.alternative_transfer.preferred_transfer_characteristics;
413 }417 }
414 418
419#if FF_API_CODEC_PROPS
420FF_DISABLE_DEPRECATION_WARNINGS
415 if ((s->sei.common.film_grain_characteristics && s->sei.common.film_grain_characteristics->present) ||421 if ((s->sei.common.film_grain_characteristics && s->sei.common.film_grain_characteristics->present) ||
416 s->sei.common.aom_film_grain.enable)422 s->sei.common.aom_film_grain.enable)
417 avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;423 avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
424FF_ENABLE_DEPRECATION_WARNINGS
425#endif
418 426
419 return 0;427 return 0;
420}428}
libavcodec/jpeg2000dec.c+4−0
@@ -542,9 +542,13 @@ static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c) · 541 unmodified lines
542 /* set integer 9/7 DWT in case of BITEXACT flag */542 /* set integer 9/7 DWT in case of BITEXACT flag */
543 if ((s->avctx->flags & AV_CODEC_FLAG_BITEXACT) && (c->transform == FF_DWT97))543 if ((s->avctx->flags & AV_CODEC_FLAG_BITEXACT) && (c->transform == FF_DWT97))
544 c->transform = FF_DWT97_INT;544 c->transform = FF_DWT97_INT;
545#if FF_API_CODEC_PROPS
545 else if (c->transform == FF_DWT53) {546 else if (c->transform == FF_DWT53) {
547FF_DISABLE_DEPRECATION_WARNINGS
546 s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;548 s->avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
549FF_ENABLE_DEPRECATION_WARNINGS
547 }550 }
551#endif
548 552
549 if (c->csty & JPEG2000_CSTY_PREC) {553 if (c->csty & JPEG2000_CSTY_PREC) {
550 int i;554 int i;
libavcodec/libdav1d.c+8−0
@@ -162,10 +162,14 @@ static void libdav1d_init_params(AVCodecContext *c, const Dav1dSequenceHeader *s · 161 unmodified lines
162 (unsigned)seq->num_units_in_tick,162 (unsigned)seq->num_units_in_tick,
163 (unsigned)seq->time_scale);163 (unsigned)seq->time_scale);
164 164
165#if FF_API_CODEC_PROPS
166FF_DISABLE_DEPRECATION_WARNINGS
165 if (seq->film_grain_present)167 if (seq->film_grain_present)
166 c->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;168 c->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
167 else169 else
168 c->properties &= ~FF_CODEC_PROPERTY_FILM_GRAIN;170 c->properties &= ~FF_CODEC_PROPERTY_FILM_GRAIN;
171FF_ENABLE_DEPRECATION_WARNINGS
172#endif
169}173}
170 174
171static av_cold int libdav1d_parse_extradata(AVCodecContext *c)175static av_cold int libdav1d_parse_extradata(AVCodecContext *c)
@@ -533,7 +537,11 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) · 361 unmodified lines
533 if (res < 0)537 if (res < 0)
534 goto fail;538 goto fail;
535 539
540#if FF_API_CODEC_PROPS
541FF_DISABLE_DEPRECATION_WARNINGS
536 c->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;542 c->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
543FF_ENABLE_DEPRECATION_WARNINGS
544#endif
537 break;545 break;
538 }546 }
539 default: // ignore unsupported identifiers547 default: // ignore unsupported identifiers
libavcodec/mjpegdec.c+8−0
@@ -2508,7 +2508,11 @@ redo_for_pal8: · 2507 unmodified lines
2508 break;2508 break;
2509 case SOF3:2509 case SOF3:
2510 avctx->profile = AV_PROFILE_MJPEG_HUFFMAN_LOSSLESS;2510 avctx->profile = AV_PROFILE_MJPEG_HUFFMAN_LOSSLESS;
2511#if FF_API_CODEC_PROPS
2512FF_DISABLE_DEPRECATION_WARNINGS
2511 avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;2513 avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
2514FF_ENABLE_DEPRECATION_WARNINGS
2515#endif
2512 s->lossless = 1;2516 s->lossless = 1;
2513 s->ls = 0;2517 s->ls = 0;
2514 s->progressive = 0;2518 s->progressive = 0;
@@ -2517,7 +2521,11 @@ redo_for_pal8: · 2 unmodified lines
2517 break;2521 break;
2518 case SOF48:2522 case SOF48:
2519 avctx->profile = AV_PROFILE_MJPEG_JPEG_LS;2523 avctx->profile = AV_PROFILE_MJPEG_JPEG_LS;
2524#if FF_API_CODEC_PROPS
2525FF_DISABLE_DEPRECATION_WARNINGS
2520 avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;2526 avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
2527FF_ENABLE_DEPRECATION_WARNINGS
2528#endif
2521 s->lossless = 1;2529 s->lossless = 1;
2522 s->ls = 1;2530 s->ls = 1;
2523 s->progressive = 0;2531 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
1919 av_log(avctx, AV_LOG_DEBUG, "CC: first seen substream is %s format\n", label);1919 av_log(avctx, AV_LOG_DEBUG, "CC: first seen substream is %s format\n", label);
1920 }1920 }
1921 1921
1922#if FF_API_CODEC_PROPS
1923FF_DISABLE_DEPRECATION_WARNINGS
1922 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;1924 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
1925FF_ENABLE_DEPRECATION_WARNINGS
1926#endif
1923}1927}
1924 1928
1925static int mpeg_decode_a53_cc(AVCodecContext *avctx,1929static 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
365 365
366 dst->has_b_frames = src->has_b_frames;366 dst->has_b_frames = src->has_b_frames;
367 dst->idct_algo = src->idct_algo;367 dst->idct_algo = src->idct_algo;
368#if FF_API_CODEC_PROPS
369FF_DISABLE_DEPRECATION_WARNINGS
368 dst->properties = src->properties;370 dst->properties = src->properties;
371FF_ENABLE_DEPRECATION_WARNINGS
372#endif
369 373
370 dst->bits_per_coded_sample = src->bits_per_coded_sample;374 dst->bits_per_coded_sample = src->bits_per_coded_sample;
371 dst->sample_aspect_ratio = src->sample_aspect_ratio;375 dst->sample_aspect_ratio = src->sample_aspect_ratio;
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
29 29
30#include "version_major.h"30#include "version_major.h"
31 31
32#define LIBAVCODEC_VERSION_MINOR 3032#define LIBAVCODEC_VERSION_MINOR 31
33#define LIBAVCODEC_VERSION_MICRO 10033#define LIBAVCODEC_VERSION_MICRO 100
34 34
35#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \35#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
libavcodec/version_major.h+1−0
@@ -49,6 +49,7 @@ · 48 unmodified lines
49#define FF_API_VDPAU_ALLOC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 62)49#define FF_API_VDPAU_ALLOC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 62)
50#define FF_API_QUALITY_FACTOR (LIBAVCODEC_VERSION_MAJOR < 62)50#define FF_API_QUALITY_FACTOR (LIBAVCODEC_VERSION_MAJOR < 62)
51#define FF_API_V408_CODECID (LIBAVCODEC_VERSION_MAJOR < 62)51#define FF_API_V408_CODECID (LIBAVCODEC_VERSION_MAJOR < 62)
52#define FF_API_CODEC_PROPS (LIBAVCODEC_VERSION_MAJOR < 63)
52 53
53// reminder to remove the OMX encoder on next major bump54// reminder to remove the OMX encoder on next major bump
54#define FF_CODEC_OMX (LIBAVCODEC_VERSION_MAJOR < 62)55#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
682 s->s.h.uvac_qdelta = get_bits1(&s->gb) ? get_sbits_inv(&s->gb, 4) : 0;682 s->s.h.uvac_qdelta = get_bits1(&s->gb) ? get_sbits_inv(&s->gb, 4) : 0;
683 s->s.h.lossless = s->s.h.yac_qi == 0 && s->s.h.ydc_qdelta == 0 &&683 s->s.h.lossless = s->s.h.yac_qi == 0 && s->s.h.ydc_qdelta == 0 &&
684 s->s.h.uvdc_qdelta == 0 && s->s.h.uvac_qdelta == 0;684 s->s.h.uvdc_qdelta == 0 && s->s.h.uvac_qdelta == 0;
685#if FF_API_CODEC_PROPS
686FF_DISABLE_DEPRECATION_WARNINGS
685 if (s->s.h.lossless)687 if (s->s.h.lossless)
686 avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;688 avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
689FF_ENABLE_DEPRECATION_WARNINGS
690#endif
687 691
688 /* segmentation header info */692 /* segmentation header info */
689 if ((s->s.h.segmentation.enabled = get_bits1(&s->gb))) {693 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
1407 chunk_size, 0);1407 chunk_size, 0);
1408 if (ret < 0)1408 if (ret < 0)
1409 return ret;1409 return ret;
1410#if FF_API_CODEC_PROPS
1411FF_DISABLE_DEPRECATION_WARNINGS
1410 avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;1412 avctx->properties |= FF_CODEC_PROPERTY_LOSSLESS;
1413FF_ENABLE_DEPRECATION_WARNINGS
1414#endif
1411 }1415 }
1412 bytestream2_skip(&gb, chunk_size);1416 bytestream2_skip(&gb, chunk_size);
1413 break;1417 break;
libavformat/dump.c+4−0
@@ -620,7 +620,11 @@ static void dump_stream_format(const AVFormatContext *ic, int i, · 619 unmodified lines
620 620
621 // Fields which are missing from AVCodecParameters need to be taken from the AVCodecContext621 // Fields which are missing from AVCodecParameters need to be taken from the AVCodecContext
622 if (sti->avctx) {622 if (sti->avctx) {
623#if FF_API_CODEC_PROPS
624FF_DISABLE_DEPRECATION_WARNINGS
623 avctx->properties = sti->avctx->properties;625 avctx->properties = sti->avctx->properties;
626FF_ENABLE_DEPRECATION_WARNINGS
627#endif
624 avctx->codec = sti->avctx->codec;628 avctx->codec = sti->avctx->codec;
625 avctx->qmin = sti->avctx->qmin;629 avctx->qmin = sti->avctx->qmin;
626 avctx->qmax = sti->avctx->qmax;630 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