History

avcodec/libaomenc: use pix_fmt descriptors where useful

James Almer committed 6 years ago

Commit 36e51c11 parent 6a2f3f61 file · +4 −11Browse files

Unified · Split

libavcodec/libaomenc.c+4−11
@@ -299,7 +299,8 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps, · 298 unmodified lines
299299 aom_img_fmt_t *img_fmt)
300300 {
301301 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;
303304 switch (avctx->pix_fmt) {
304305 case AV_PIX_FMT_YUV420P:
305306 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
317318 case AV_PIX_FMT_YUV420P10:
318319 case AV_PIX_FMT_YUV420P12:
319320 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;
322321 enccfg->g_profile =
323322 enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_MAIN : FF_PROFILE_AV1_PROFESSIONAL;
324323 *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
329328 case AV_PIX_FMT_YUV422P10:
330329 case AV_PIX_FMT_YUV422P12:
331330 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;
334331 enccfg->g_profile = FF_PROFILE_AV1_PROFESSIONAL;
335332 *img_fmt = AOM_IMG_FMT_I42216;
336333 *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
342339 case AV_PIX_FMT_GBRP10:
343340 case AV_PIX_FMT_GBRP12:
344341 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;
349342 enccfg->g_profile =
350343 enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_HIGH : FF_PROFILE_AV1_PROFESSIONAL;
351344 *img_fmt = AOM_IMG_FMT_I44416;
@@ -543,6 +536,7 @@ static av_cold int aom_init(AVCodecContext *avctx, · 191 unmodified lines
543536 const struct aom_codec_iface *iface)
544537 {
545538 AOMContext *ctx = avctx->priv_data;
539+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
546540 struct aom_codec_enc_cfg enccfg = { 0 };
547541 #ifdef AOM_FRAME_IS_INTRAONLY
548542 aom_codec_flags_t flags =
@@ -754,8 +748,7 @@ static av_cold int aom_init(AVCodecContext *avctx, · 205 unmodified lines
754748 if (ctx->tune >= 0)
755749 codecctl_int(avctx, AOME_SET_TUNING, ctx->tune);
756750
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) {
759752 codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, AVCOL_PRI_BT709);
760753 codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, AVCOL_SPC_RGB);
761754 codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, AVCOL_TRC_IEC61966_2_1);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t