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
299 aom_img_fmt_t *img_fmt)299 aom_img_fmt_t *img_fmt)
300{300{
301 AOMContext av_unused *ctx = avctx->priv_data;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 switch (avctx->pix_fmt) {304 switch (avctx->pix_fmt) {
304 case AV_PIX_FMT_YUV420P:305 case AV_PIX_FMT_YUV420P:
305 enccfg->g_profile = FF_PROFILE_AV1_MAIN;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 case AV_PIX_FMT_YUV420P10:318 case AV_PIX_FMT_YUV420P10:
318 case AV_PIX_FMT_YUV420P12:319 case AV_PIX_FMT_YUV420P12:
319 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {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 enccfg->g_profile =321 enccfg->g_profile =
323 enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_MAIN : FF_PROFILE_AV1_PROFESSIONAL;322 enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_MAIN : FF_PROFILE_AV1_PROFESSIONAL;
324 *img_fmt = AOM_IMG_FMT_I42016;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 case AV_PIX_FMT_YUV422P10:328 case AV_PIX_FMT_YUV422P10:
330 case AV_PIX_FMT_YUV422P12:329 case AV_PIX_FMT_YUV422P12:
331 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {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 enccfg->g_profile = FF_PROFILE_AV1_PROFESSIONAL;331 enccfg->g_profile = FF_PROFILE_AV1_PROFESSIONAL;
335 *img_fmt = AOM_IMG_FMT_I42216;332 *img_fmt = AOM_IMG_FMT_I42216;
336 *flags |= AOM_CODEC_USE_HIGHBITDEPTH;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 case AV_PIX_FMT_GBRP10:339 case AV_PIX_FMT_GBRP10:
343 case AV_PIX_FMT_GBRP12:340 case AV_PIX_FMT_GBRP12:
344 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {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 enccfg->g_profile =342 enccfg->g_profile =
350 enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_HIGH : FF_PROFILE_AV1_PROFESSIONAL;343 enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_HIGH : FF_PROFILE_AV1_PROFESSIONAL;
351 *img_fmt = AOM_IMG_FMT_I44416;344 *img_fmt = AOM_IMG_FMT_I44416;
@@ -543,6 +536,7 @@ static av_cold int aom_init(AVCodecContext *avctx, · 191 unmodified lines
543 const struct aom_codec_iface *iface)536 const struct aom_codec_iface *iface)
544{537{
545 AOMContext *ctx = avctx->priv_data;538 AOMContext *ctx = avctx->priv_data;
539 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
546 struct aom_codec_enc_cfg enccfg = { 0 };540 struct aom_codec_enc_cfg enccfg = { 0 };
547#ifdef AOM_FRAME_IS_INTRAONLY541#ifdef AOM_FRAME_IS_INTRAONLY
548 aom_codec_flags_t flags =542 aom_codec_flags_t flags =
@@ -754,8 +748,7 @@ static av_cold int aom_init(AVCodecContext *avctx, · 205 unmodified lines
754 if (ctx->tune >= 0)748 if (ctx->tune >= 0)
755 codecctl_int(avctx, AOME_SET_TUNING, ctx->tune);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 ||751 if (desc->flags & AV_PIX_FMT_FLAG_RGB) {
758 avctx->pix_fmt == AV_PIX_FMT_GBRP12) {
759 codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, AVCOL_PRI_BT709);752 codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, AVCOL_PRI_BT709);
760 codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, AVCOL_SPC_RGB);753 codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, AVCOL_SPC_RGB);
761 codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, AVCOL_TRC_IEC61966_2_1);754 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