aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/codec_internal.h
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2024-04-03 22:19:28 +0200
committerNiklas Haas <git@haasn.dev>2024-09-08 13:59:25 +0200
commit3305767560a6303f474fffa3afb10c500059b455 (patch)
treec94bba9e72eebcbf78288a7e1c02f2797dd58854 /libavcodec/codec_internal.h
parent703288cec6522655e8533c89efa3cd6df9613b99 (diff)
downloadffmpeg-3305767560a6303f474fffa3afb10c500059b455.tar.gz
avcodec: add avcodec_get_supported_config()
This replaces the myriad of existing lists in AVCodec by a unified API call, allowing us to (ultimately) trim down the sizeof(AVCodec) quite substantially, while also making this more trivially extensible. In addition to the already covered lists, add two new entries for color space and color range, mirroring the newly added negotiable fields in libavfilter. Once the deprecation period passes for the existing public fields, the rough plan is to move the commonly used fields (such as pix_fmt/sample_fmt) into FFCodec, possibly as a union of audio and video configuration types, and then implement the rarely used fields with custom callbacks.
Diffstat (limited to 'libavcodec/codec_internal.h')
-rw-r--r--libavcodec/codec_internal.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h
index 2f9eb479d4..5863760564 100644
--- a/libavcodec/codec_internal.h
+++ b/libavcodec/codec_internal.h
@@ -22,6 +22,7 @@
#include <stdint.h>
#include "libavutil/attributes.h"
+#include "avcodec.h"
#include "codec.h"
#include "config.h"
@@ -269,8 +270,34 @@ typedef struct FFCodec {
* List of supported codec_tags, terminated by FF_CODEC_TAGS_END.
*/
const uint32_t *codec_tags;
+
+ /**
+ * Custom callback for avcodec_get_supported_config(). If absent,
+ * ff_default_get_supported_config() will be used. `out_num_configs` will
+ * always be set to a valid pointer.
+ */
+ int (*get_supported_config)(const AVCodecContext *avctx,
+ const AVCodec *codec,
+ enum AVCodecConfig config,
+ unsigned flags,
+ const void **out_configs,
+ int *out_num_configs);
} FFCodec;
+/**
+ * Default implementation for avcodec_get_supported_config(). Will return the
+ * relevant fields from AVCodec if present, or NULL otherwise.
+ *
+ * For AVCODEC_CONFIG_COLOR_RANGE, the output will depend on the bitmask in
+ * FFCodec.color_ranges, with a value of 0 returning NULL.
+ */
+int ff_default_get_supported_config(const AVCodecContext *avctx,
+ const AVCodec *codec,
+ enum AVCodecConfig config,
+ unsigned flags,
+ const void **out_configs,
+ int *out_num_configs);
+
#if CONFIG_SMALL
#define CODEC_LONG_NAME(str) .p.long_name = NULL
#else