summaryrefslogtreecommitdiff
path: root/libavcodec/libaomenc.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2020-07-17 17:46:32 -0300
committerJames Almer <jamrial@gmail.com>2020-07-17 18:23:45 -0300
commit36e51c190bb9cca4bb846e7dae4aebc6570ff258 (patch)
treecf1e429fc053205b28224e01c74308b245f4a223 /libavcodec/libaomenc.c
parent6a2f3f60ae02c8c3c62645b1d54ecc86bb21080d (diff)
avcodec/libaomenc: use pix_fmt descriptors where useful
Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/libaomenc.c')
-rw-r--r--libavcodec/libaomenc.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 0d6a376ef0..b65e491824 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -299,7 +299,8 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps,
aom_img_fmt_t *img_fmt)
{
AOMContext av_unused *ctx = avctx->priv_data;
- enccfg->g_bit_depth = enccfg->g_input_bit_depth = 8;
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+ enccfg->g_bit_depth = enccfg->g_input_bit_depth = desc->comp[0].depth;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUV420P:
enccfg->g_profile = FF_PROFILE_AV1_MAIN;
@@ -317,8 +318,6 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps,
case AV_PIX_FMT_YUV420P10:
case AV_PIX_FMT_YUV420P12:
if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
- enccfg->g_bit_depth = enccfg->g_input_bit_depth =
- avctx->pix_fmt == AV_PIX_FMT_YUV420P10 ? 10 : 12;
enccfg->g_profile =
enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_MAIN : FF_PROFILE_AV1_PROFESSIONAL;
*img_fmt = AOM_IMG_FMT_I42016;
@@ -329,8 +328,6 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps,
case AV_PIX_FMT_YUV422P10:
case AV_PIX_FMT_YUV422P12:
if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
- enccfg->g_bit_depth = enccfg->g_input_bit_depth =
- avctx->pix_fmt == AV_PIX_FMT_YUV422P10 ? 10 : 12;
enccfg->g_profile = FF_PROFILE_AV1_PROFESSIONAL;
*img_fmt = AOM_IMG_FMT_I42216;
*flags |= AOM_CODEC_USE_HIGHBITDEPTH;
@@ -342,10 +339,6 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps,
case AV_PIX_FMT_GBRP10:
case AV_PIX_FMT_GBRP12:
if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
- enccfg->g_bit_depth = enccfg->g_input_bit_depth = 10;
- if (avctx->pix_fmt == AV_PIX_FMT_YUV444P12 ||
- avctx->pix_fmt == AV_PIX_FMT_GBRP12)
- enccfg->g_bit_depth = enccfg->g_input_bit_depth = 12;
enccfg->g_profile =
enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_HIGH : FF_PROFILE_AV1_PROFESSIONAL;
*img_fmt = AOM_IMG_FMT_I44416;
@@ -543,6 +536,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
const struct aom_codec_iface *iface)
{
AOMContext *ctx = avctx->priv_data;
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
struct aom_codec_enc_cfg enccfg = { 0 };
#ifdef AOM_FRAME_IS_INTRAONLY
aom_codec_flags_t flags =
@@ -754,8 +748,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
if (ctx->tune >= 0)
codecctl_int(avctx, AOME_SET_TUNING, ctx->tune);
- if (avctx->pix_fmt == AV_PIX_FMT_GBRP || avctx->pix_fmt == AV_PIX_FMT_GBRP10 ||
- avctx->pix_fmt == AV_PIX_FMT_GBRP12) {
+ if (desc->flags & AV_PIX_FMT_FLAG_RGB) {
codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, AVCOL_PRI_BT709);
codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, AVCOL_SPC_RGB);
codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, AVCOL_TRC_IEC61966_2_1);