[FFmpeg-devel] [PATCH 1/2 v2] avcodec/libaomenc: support setting chroma sample location
James Almer
jamrial at gmail.com
Wed Sep 19 04:14:46 EEST 2018
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavcodec/libaomenc.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 6a79d9b873..9669e82049 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -76,6 +76,7 @@ static const char *const ctlidstr[] = {
[AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
[AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
[AV1E_SET_COLOR_RANGE] = "AV1E_SET_COLOR_RANGE",
+ [AV1E_SET_CHROMA_SAMPLE_POSITION] = "AV1E_SET_CHROMA_SAMPLE_POSITION",
[AV1E_SET_COLOR_PRIMARIES] = "AV1E_SET_COLOR_PRIMARIES",
[AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
[AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS",
@@ -284,6 +285,28 @@ static void set_color_range(AVCodecContext *avctx)
codecctl_int(avctx, AV1E_SET_COLOR_RANGE, aom_cr);
}
+static void set_chroma_position(AVCodecContext *avctx)
+{
+ enum aom_chroma_sample_position aom_cps;
+
+ if (avctx->pix_fmt != AV_PIX_FMT_YUV420P &&
+ avctx->pix_fmt != AV_PIX_FMT_YUV420P10 &&
+ avctx->pix_fmt != AV_PIX_FMT_YUV420P12)
+ return;
+
+ switch (avctx->chroma_sample_location) {
+ case AVCHROMA_LOC_UNSPECIFIED: aom_cps = AOM_CSP_UNKNOWN; break;
+ case AVCHROMA_LOC_LEFT: aom_cps = AOM_CSP_VERTICAL; break;
+ case AVCHROMA_LOC_TOPLEFT: aom_cps = AOM_CSP_COLOCATED; break;
+ default:
+ av_log(avctx, AV_LOG_WARNING, "Unsupported chroma sample location (%d)\n",
+ avctx->chroma_sample_location);
+ return;
+ }
+
+ codecctl_int(avctx, AV1E_SET_CHROMA_SAMPLE_POSITION, aom_cps);
+}
+
static av_cold int aom_init(AVCodecContext *avctx,
const struct aom_codec_iface *iface)
{
@@ -452,6 +475,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, avctx->color_primaries);
codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, avctx->colorspace);
codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, avctx->color_trc);
+ set_chroma_position(avctx);
set_color_range(avctx);
// provide dummy value to initialize wrapper, values will be updated each _encode()
--
2.19.0
More information about the ffmpeg-devel
mailing list