History

libaomenc: enable 8, 10 and 12 bit RGB encoding

RGB pixel formats are one occasion where by pixel format we mean pixel format, primaries, transfer characteristic, and matrix coeffs, so we have to manually set them as they're set to unspecified by default, despite there only being a single possible combination.

Lynne committed 6 years ago

Commit 6a2f3f61 parent dabac261 file · +21 −5Browse files

Unified · Split

libavcodec/libaomenc.c+21−5
@@ -310,6 +310,7 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps, · 309 unmodified lines
310310 *img_fmt = AOM_IMG_FMT_I422;
311311 return 0;
312312 case AV_PIX_FMT_YUV444P:
313+ case AV_PIX_FMT_GBRP:
313314 enccfg->g_profile = FF_PROFILE_AV1_HIGH;
314315 *img_fmt = AOM_IMG_FMT_I444;
315316 return 0;
@@ -338,9 +339,13 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps, · 22 unmodified lines
338339 break;
339340 case AV_PIX_FMT_YUV444P10:
340341 case AV_PIX_FMT_YUV444P12:
342+ case AV_PIX_FMT_GBRP10:
343+ case AV_PIX_FMT_GBRP12:
341344 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
342− enccfg->g_bit_depth = enccfg->g_input_bit_depth =
343− avctx->pix_fmt == AV_PIX_FMT_YUV444P10 ? 10 : 12;
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;
344349 enccfg->g_profile =
345350 enccfg->g_bit_depth == 10 ? FF_PROFILE_AV1_HIGH : FF_PROFILE_AV1_PROFESSIONAL;
346351 *img_fmt = AOM_IMG_FMT_I44416;
@@ -749,9 +754,16 @@ static av_cold int aom_init(AVCodecContext *avctx, · 402 unmodified lines
749754 if (ctx->tune >= 0)
750755 codecctl_int(avctx, AOME_SET_TUNING, ctx->tune);
751756
752− codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, avctx->color_primaries);
753− codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, avctx->colorspace);
754− codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, avctx->color_trc);
757+ if (avctx->pix_fmt == AV_PIX_FMT_GBRP || avctx->pix_fmt == AV_PIX_FMT_GBRP10 ||
758+ avctx->pix_fmt == AV_PIX_FMT_GBRP12) {
759+ codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, AVCOL_PRI_BT709);
760+ codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, AVCOL_SPC_RGB);
761+ codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, AVCOL_TRC_IEC61966_2_1);
762+ } else {
763+ codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, avctx->color_primaries);
764+ codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, avctx->colorspace);
765+ codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, avctx->color_trc);
766+ }
755767 if (ctx->aq_mode >= 0)
756768 codecctl_int(avctx, AV1E_SET_AQ_MODE, ctx->aq_mode);
757769 if (ctx->frame_parallel >= 0)
@@ -1077,6 +1089,7 @@ static const enum AVPixelFormat av1_pix_fmts[] = { · 319 unmodified lines
10771089 AV_PIX_FMT_YUV420P,
10781090 AV_PIX_FMT_YUV422P,
10791091 AV_PIX_FMT_YUV444P,
1092+ AV_PIX_FMT_GBRP,
10801093 AV_PIX_FMT_NONE
10811094 };
10821095
@@ -1084,12 +1097,15 @@ static const enum AVPixelFormat av1_pix_fmts_highbd[] = { · 1 unmodified line
10841097 AV_PIX_FMT_YUV420P,
10851098 AV_PIX_FMT_YUV422P,
10861099 AV_PIX_FMT_YUV444P,
1100+ AV_PIX_FMT_GBRP,
10871101 AV_PIX_FMT_YUV420P10,
10881102 AV_PIX_FMT_YUV422P10,
10891103 AV_PIX_FMT_YUV444P10,
10901104 AV_PIX_FMT_YUV420P12,
10911105 AV_PIX_FMT_YUV422P12,
10921106 AV_PIX_FMT_YUV444P12,
1107+ AV_PIX_FMT_GBRP10,
1108+ AV_PIX_FMT_GBRP12,
10931109 AV_PIX_FMT_NONE
10941110 };
10951111

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