Hi, 2014-08-24 18:56 GMT+02:00 Michael Niedermayer <michae...@gmx.at>: > aggree, a PRORES_PROFILE_AUTO seems like a good idea > with it mismatching profile and pixel format can be errors while > by default the profile can be selected based on the pixel format
The attached patch makes it selects either 4444 or HQ profile depending on whether there's an alpha channel. If a profile is selected that does not have alpha but the input data has alpha, it warns that it will not encode it. Best regards, -- Christophe
From 0b134da9eba4f6f08422d22a1a0428f564fe8f11 Mon Sep 17 00:00:00 2001 From: Christophe Gisquet <christophe.gisq...@gmail.com> Date: Mon, 18 Aug 2014 11:27:50 +0200 Subject: [PATCH] proresenc_ks: allow auto-selecting profile The user may not know how to select the profile, nor what he needs, in particular to encode alpha. Therefore, use an automatic selection as default, and warn when the manually selected profile may cause issues. --- libavcodec/proresenc_kostya.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c index c30c9c0..cdeb917 100644 --- a/libavcodec/proresenc_kostya.c +++ b/libavcodec/proresenc_kostya.c @@ -40,6 +40,7 @@ #define MAX_PLANES 4 enum { + PRORES_PROFILE_AUTO = -1, PRORES_PROFILE_PROXY = 0, PRORES_PROFILE_LT, PRORES_PROFILE_STANDARD, @@ -1146,7 +1147,21 @@ static av_cold int encode_init(AVCodecContext *avctx) "there should be an integer power of two MBs per slice\n"); return AVERROR(EINVAL); } + if (ctx->profile == PRORES_PROFILE_AUTO) { + ctx->profile = av_pix_fmt_desc_get(avctx->pix_fmt)->flags & AV_PIX_FMT_FLAG_ALPHA + ? PRORES_PROFILE_4444 : PRORES_PROFILE_HQ; + av_log(avctx, AV_LOG_INFO, "Autoselected %s. It can be overriden " + "through -profile option.\n", ctx->profile == PRORES_PROFILE_4444 + ? "4:4:4:4 profile because of the alpha channel" + : "HQ profile to keep best quality"); + } if (av_pix_fmt_desc_get(avctx->pix_fmt)->flags & AV_PIX_FMT_FLAG_ALPHA) { + if (ctx->profile != PRORES_PROFILE_4444) { + // force alpha and warn + av_log(avctx, AV_LOG_WARNING, "Profile selected will not " + "encode alpha. Override with -profile if needed.\n"); + ctx->alpha_bits = 0; + } if (ctx->alpha_bits & 7) { av_log(avctx, AV_LOG_ERROR, "alpha bits should be 0, 8 or 16\n"); return AVERROR(EINVAL); @@ -1280,8 +1295,10 @@ static const AVOption options[] = { { "mbs_per_slice", "macroblocks per slice", OFFSET(mbs_per_slice), 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_4444, VE, "profile" }, + { .i64 = PRORES_PROFILE_AUTO }, + PRORES_PROFILE_AUTO, PRORES_PROFILE_4444, VE, "profile" }, + { "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRORES_PROFILE_AUTO }, + 0, 0, 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 }, -- 1.9.2.msysgit.0
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel