1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00

avcodec: add AV_CODEC_CONFIG_CHROMA_LOCATION

Lets an encoder state which chroma sample locations it can accept, so the
caller can convert to one.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
This commit is contained in:
Kacper Michajłow
2026-09-09 07:12:50 +02:00
parent 00e49750e8
commit c200628eac
5 changed files with 20 additions and 1 deletions

View File

@@ -5,6 +5,9 @@ API changes, most recent first:
2026-09-xx - xxxxxxxxxx - lavfi 12.4.101 - avfilter.h
Add AVFilterLink.chroma_location.
2026-09-xx - xxxxxxxxxx - lavc 63.16.100 - avcodec.h
Add AV_CODEC_CONFIG_CHROMA_LOCATION.
2026-08-xx - xxxxxxxxxx - lavf 63.7.100 - avformat.h
Add AV_STREAM_GROUP_PARAMS_GAIN_MAP.

View File

@@ -810,6 +810,10 @@ int ff_default_get_supported_config(const AVCodecContext *avctx,
*out_num_configs = av_popcount(alpha_modes);
return 0;
case AV_CODEC_CONFIG_CHROMA_LOCATION:
WRAP_CONFIG(AVMEDIA_TYPE_VIDEO, chroma_locations, loc,
enum AVChromaLocation, loc == AVCHROMA_LOC_UNSPECIFIED);
default:
return AVERROR(EINVAL);
}

View File

@@ -2593,6 +2593,7 @@ enum AVCodecConfig {
AV_CODEC_CONFIG_COLOR_RANGE, ///< AVColorRange, terminated by AVCOL_RANGE_UNSPECIFIED
AV_CODEC_CONFIG_COLOR_SPACE, ///< AVColorSpace, terminated by AVCOL_SPC_UNSPECIFIED
AV_CODEC_CONFIG_ALPHA_MODE, ///< AVAlphaMode, terminated by AVALPHA_MODE_UNSPECIFIED
AV_CODEC_CONFIG_CHROMA_LOCATION, ///< AVChromaLocation, terminated by AVCHROMA_LOC_UNSPECIFIED
};
/**

View File

@@ -154,6 +154,14 @@ typedef struct FFCodec {
*/
unsigned alpha_modes:2;
/**
* This field determines the chroma sample locations supported by an
* encoder, terminated by AVCHROMA_LOC_UNSPECIFIED. Only needs to be set
* by encoders whose format defines the chroma siting, a NULL list means
* the encoder accepts whatever it is given.
*/
const enum AVChromaLocation *chroma_locations;
/**
* This field determines the type of the codec (decoder/encoder)
* and also the exact callback cb implemented by the codec.
@@ -411,6 +419,9 @@ int ff_default_get_supported_config(const struct AVCodecContext *avctx,
#define CODEC_PIXFMTS(...) CODEC_PIXFMTS_ARRAY(((const enum AVPixelFormat[]) { __VA_ARGS__, AV_PIX_FMT_NONE }))
#define CODEC_PIXFMTS_ARRAY(array) CODEC_ARRAY(pix_fmts, (array))
#define CODEC_CHROMA_LOCS(...) CODEC_CHROMA_LOCS_ARRAY(((const enum AVChromaLocation[]) { __VA_ARGS__, AVCHROMA_LOC_UNSPECIFIED }))
#define CODEC_CHROMA_LOCS_ARRAY(array) CODEC_ARRAY(chroma_locations, (array))
#define CODEC_ARRAY(field, array) \
.field = (array) \

View File

@@ -29,7 +29,7 @@
#include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 15
#define LIBAVCODEC_VERSION_MINOR 16
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \