[FFmpeg-devel] [PATCH]Add a 4444 profile to a prores encoder

Carl Eugen Hoyos cehoyos at ag.or.at
Wed Sep 12 13:42:54 CEST 2012


Hi!

When encoding prores wth -pix_fmt yuv444p, QuickTime shows "ProRes 422".
(I don't know if this actually affects QuickTime decoding.)

Attached patch was tested on ffmpeg-user and allows to write a profile that 
allows QuickTime to show "4444" (but I have no idea if the values for the 
profile are really correct).

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 53c74a4..a9ab541 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -43,6 +43,7 @@ enum {
     PRORES_PROFILE_LT,
     PRORES_PROFILE_STANDARD,
     PRORES_PROFILE_HQ,
+    PRORES_PROFILE_4444,
 };
 
 enum {
@@ -121,7 +122,7 @@ static const struct prores_profile {
     int         max_quant;
     int         br_tab[NUM_MB_LIMITS];
     int         quant;
-} prores_profile_info[4] = {
+} prores_profile_info[5] = {
     {
         .full_name = "proxy",
         .tag       = MKTAG('a', 'p', 'c', 'o'),
@@ -153,8 +154,15 @@ static const struct prores_profile {
         .max_quant = 6,
         .br_tab    = { 1566, 1216, 1070, 950 },
         .quant     = QUANT_MAT_HQ,
-    }
-// for 4444 profile bitrate numbers are { 2350, 1828, 1600, 1425 }
+    },
+    {
+        .full_name = "4444",
+        .tag       = MKTAG('a', 'p', '4', 'h'),
+        .min_quant = 1,
+        .max_quant = 6,
+        .br_tab    = { 2350, 1828, 1600, 1425 },
+        .quant     = QUANT_MAT_DEFAULT,
+    },
 };
 
 #define TRELLIS_WIDTH 16
@@ -890,6 +898,9 @@ static av_cold int encode_init(AVCodecContext *avctx)
     if (!avctx->coded_frame)
         return AVERROR(ENOMEM);
 
+    if (avctx->pix_fmt == PIX_FMT_YUV444P10)
+        ctx->profile = PRORES_PROFILE_4444;
+
     ff_proresdsp_init(&ctx->dsp, avctx);
     ff_init_scantable(ctx->dsp.dct_permutation, &ctx->scantable,
                       interlaced ? ff_prores_interlaced_scan
@@ -1022,7 +1033,7 @@ static const AVOption options[] = {
         AV_OPT_TYPE_INT, { .i64 = 8 }, 1, MAX_MBS_PER_SLICE, VE },
     { "profile",       NULL, OFFSET(profile), AV_OPT_TYPE_INT,
         { .i64 = PRORES_PROFILE_STANDARD },
-        PRORES_PROFILE_PROXY, PRORES_PROFILE_HQ, VE, "profile" },
+        PRORES_PROFILE_PROXY, PRORES_PROFILE_4444, VE, "profile" },
     { "proxy",         NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRORES_PROFILE_PROXY },
         0, 0, VE, "profile" },
     { "lt",            NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRORES_PROFILE_LT },
@@ -1031,6 +1042,8 @@ static const AVOption options[] = {
         0, 0, VE, "profile" },
     { "hq",            NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRORES_PROFILE_HQ },
         0, 0, VE, "profile" },
+    { "4444",          NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRORES_PROFILE_4444 },
+        0, 0, VE, "profile" },
     { "vendor", "vendor ID", OFFSET(vendor),
         AV_OPT_TYPE_STRING, { .str = "Lavc" }, CHAR_MIN, CHAR_MAX, VE },
     { "bits_per_mb", "desired bits per macroblock", OFFSET(bits_per_mb),


More information about the ffmpeg-devel mailing list