Unified · Split
| @@ -299,7 +299,8 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps, · 298 unmodified lines | ||
| 299 | 299 | aom_img_fmt_t *img_fmt) |
| 300 | 300 | { |
| 301 | 301 | AOMContext av_unused *ctx = avctx->priv_data; |
| 302 | − enccfg->g_bit_depth = enccfg->g_input_bit_depth = 8; | |
| 302 | + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); | |
| 303 | + enccfg->g_bit_depth = enccfg->g_input_bit_depth = desc->comp[0].depth; | |
| 303 | 304 | switch (avctx->pix_fmt) { |
| 304 | 305 | case AV_PIX_FMT_YUV420P: |
| 305 | 306 | enccfg->g_profile = FF_PROFILE_AV1_MAIN; |
| @@ -317,8 +318,6 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps, · 11 unmodified lines | ||
| 317 | 318 | case AV_PIX_FMT_YUV420P10: |
| 318 | 319 | case AV_PIX_FMT_YUV420P12: |
| 319 | 320 | if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) { |
| 320 | − enccfg->g_bit_depth = enccfg->g_input_bit_depth = | |
| 321 | − avctx->pix_fmt == AV_PIX_FMT_YUV420P10 ? 10 : 12; | |
| 322 | 321 | enccfg->g_profile = |
| 323 | 322 | enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_MAIN : FF_PROFILE_AV1_PROFESSIONAL; |
| 324 | 323 | *img_fmt = AOM_IMG_FMT_I42016; |
| @@ -329,8 +328,6 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps, · 4 unmodified lines | ||
| 329 | 328 | case AV_PIX_FMT_YUV422P10: |
| 330 | 329 | case AV_PIX_FMT_YUV422P12: |
| 331 | 330 | if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) { |
| 332 | − enccfg->g_bit_depth = enccfg->g_input_bit_depth = | |
| 333 | − avctx->pix_fmt == AV_PIX_FMT_YUV422P10 ? 10 : 12; | |
| 334 | 331 | enccfg->g_profile = FF_PROFILE_AV1_PROFESSIONAL; |
| 335 | 332 | *img_fmt = AOM_IMG_FMT_I42216; |
| 336 | 333 | *flags |= AOM_CODEC_USE_HIGHBITDEPTH; |
| @@ -342,10 +339,6 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps, · 5 unmodified lines | ||
| 342 | 339 | case AV_PIX_FMT_GBRP10: |
| 343 | 340 | case AV_PIX_FMT_GBRP12: |
| 344 | 341 | if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) { |
| 345 | − enccfg->g_bit_depth = enccfg->g_input_bit_depth = 10; | |
| 346 | − if (avctx->pix_fmt == AV_PIX_FMT_YUV444P12 || | |
| 347 | − avctx->pix_fmt == AV_PIX_FMT_GBRP12) | |
| 348 | − enccfg->g_bit_depth = enccfg->g_input_bit_depth = 12; | |
| 349 | 342 | enccfg->g_profile = |
| 350 | 343 | enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_HIGH : FF_PROFILE_AV1_PROFESSIONAL; |
| 351 | 344 | *img_fmt = AOM_IMG_FMT_I44416; |
| @@ -543,6 +536,7 @@ static av_cold int aom_init(AVCodecContext *avctx, · 191 unmodified lines | ||
| 543 | 536 | const struct aom_codec_iface *iface) |
| 544 | 537 | { |
| 545 | 538 | AOMContext *ctx = avctx->priv_data; |
| 539 | + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); | |
| 546 | 540 | struct aom_codec_enc_cfg enccfg = { 0 }; |
| 547 | 541 | #ifdef AOM_FRAME_IS_INTRAONLY |
| 548 | 542 | aom_codec_flags_t flags = |
| @@ -754,8 +748,7 @@ static av_cold int aom_init(AVCodecContext *avctx, · 205 unmodified lines | ||
| 754 | 748 | if (ctx->tune >= 0) |
| 755 | 749 | codecctl_int(avctx, AOME_SET_TUNING, ctx->tune); |
| 756 | 750 | |
| 757 | − if (avctx->pix_fmt == AV_PIX_FMT_GBRP || avctx->pix_fmt == AV_PIX_FMT_GBRP10 || | |
| 758 | − avctx->pix_fmt == AV_PIX_FMT_GBRP12) { | |
| 751 | + if (desc->flags & AV_PIX_FMT_FLAG_RGB) { | |
| 759 | 752 | codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, AVCOL_PRI_BT709); |
| 760 | 753 | codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, AVCOL_SPC_RGB); |
| 761 | 754 | codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, AVCOL_TRC_IEC61966_2_1); |