Commit 30e7a93bee for ffmpeg
commit 30e7a93bee1a57967c368e9292f593337e7f40cc
Author: Kacper Michajłow <kasper93@gmail.com>
Date: Wed Sep 9 07:13:03 2026 +0200
avfilter/buffersink: add support for chroma locations
Lets the caller read back the negotiated chroma location and constrain the
sink to a list of accepted ones.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
diff --git a/doc/APIchanges b/doc/APIchanges
index 80683f77e2..7d83410b6b 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,8 +2,9 @@ The last version increases of all libraries were on 2026-06-23.
API changes, most recent first:
-2026-09-xx - xxxxxxxxxx - lavfi 12.4.102 - avfilter.h buffersrc.h
- Add AVFilterLink.chroma_location and AVBufferSrcParameters.chroma_location.
+2026-09-xx - xxxxxxxxxx - lavfi 12.5.100 - avfilter.h buffersrc.h buffersink.h
+ Add AVFilterLink.chroma_location, AVBufferSrcParameters.chroma_location and
+ av_buffersink_get_chroma_location().
2026-09-xx - xxxxxxxxxx - lavc 63.16.100 - avcodec.h
Add AV_CODEC_CONFIG_CHROMA_LOCATION.
diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index e829007557..b198ef363f 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -58,6 +58,9 @@ typedef struct BufferSinkContext {
int *alphamodes;
unsigned nb_alphamodes;
+ int *chromalocations;
+ unsigned nb_chromalocations;
+
/* only used for audio */
enum AVSampleFormat *sample_formats;
unsigned nb_sample_formats;
@@ -169,6 +172,7 @@ static int init_video(AVFilterContext *ctx)
TERMINATE_ARRAY(colorranges, -1);
TERMINATE_ARRAY(colorspaces, -1);
TERMINATE_ARRAY(alphamodes, -1);
+ TERMINATE_ARRAY(chromalocations, -1);
return common_init(ctx);
}
@@ -248,6 +252,7 @@ MAKE_AVFILTERLINK_ACCESSOR(AVRational , sample_aspect_ratio)
MAKE_AVFILTERLINK_ACCESSOR(enum AVColorSpace, colorspace)
MAKE_AVFILTERLINK_ACCESSOR(enum AVColorRange, color_range)
MAKE_AVFILTERLINK_ACCESSOR(enum AVAlphaMode , alpha_mode)
+MAKE_AVFILTERLINK_ACCESSOR(enum AVChromaLocation, chroma_location)
MAKE_AVFILTERLINK_ACCESSOR(int , sample_rate )
@@ -314,6 +319,11 @@ static int vsink_query_formats(const AVFilterContext *ctx,
if (ret < 0)
return ret;
}
+ if (buf->nb_chromalocations) {
+ ret = ff_set_common_chroma_locations_from_list2(ctx, cfg_in, cfg_out, buf->chromalocations);
+ if (ret < 0)
+ return ret;
+ }
if (buf->nb_alphamodes) {
ret = ff_set_common_alpha_modes_from_list2(ctx, cfg_in, cfg_out, buf->alphamodes);
if (ret < 0)
@@ -358,6 +368,8 @@ static const AVOption buffersink_options[] = {
AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
{ "colorranges", "array of supported color ranges", OFFSET(colorranges),
AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
+ { "chromalocations", "array of supported chroma locations", OFFSET(chromalocations),
+ AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
{ "alphamodes", "array of supported color ranges", OFFSET(alphamodes),
AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 4e658a9795..0601aefff8 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -59,6 +59,7 @@
* - colorspaces (array of int),
* - colorranges (array of int),
* - alphamodes (array of int),
+ * - chromalocations (array of int),
* - sample_formats (array of sample formats),
* - samplerates (array of int),
* - channel_layouts (array of channel layouts)
@@ -117,6 +118,7 @@ AVRational av_buffersink_get_sample_aspect_ratio (const AVFilterContext *c
enum AVColorSpace av_buffersink_get_colorspace (const AVFilterContext *ctx);
enum AVColorRange av_buffersink_get_color_range (const AVFilterContext *ctx);
enum AVAlphaMode av_buffersink_get_alpha_mode (const AVFilterContext *ctx);
+enum AVChromaLocation av_buffersink_get_chroma_location(const AVFilterContext *ctx);
int av_buffersink_get_channels (const AVFilterContext *ctx);
int av_buffersink_get_ch_layout (const AVFilterContext *ctx,
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 19a7c929cc..523a7fe0a6 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,8 +31,8 @@
#include "version_major.h"
-#define LIBAVFILTER_VERSION_MINOR 4
-#define LIBAVFILTER_VERSION_MICRO 102
+#define LIBAVFILTER_VERSION_MINOR 5
+#define LIBAVFILTER_VERSION_MICRO 100
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \