[FFmpeg-devel] [PATCH 2/2] proresenc: move profile handling to global avcodec options
Timothy Gu
timothygu99 at gmail.com
Fri Jul 18 03:04:07 CEST 2014
This allows users to use the two encoders with the same syntax.
Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
---
libavcodec/avcodec.h | 5 +++++
libavcodec/options_table.h | 5 +++++
libavcodec/proresenc_anatoliy.c | 5 -----
libavcodec/proresenc_kostya.c | 44 +++++++++++++++++++++--------------------
4 files changed, 33 insertions(+), 26 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 93ba4d0..cd29065 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2862,6 +2862,11 @@ typedef struct AVCodecContext {
#define FF_PROFILE_JPEG2000_DCINEMA_2K 3
#define FF_PROFILE_JPEG2000_DCINEMA_4K 4
+#define FF_PROFILE_PRORES_PROXY 0
+#define FF_PROFILE_PRORES_LT 1
+#define FF_PROFILE_PRORES_STANDARD 2
+#define FF_PROFILE_PRORES_HQ 3
+#define FF_PROFILE_PRORES_4444 4
#define FF_PROFILE_HEVC_MAIN 1
#define FF_PROFILE_HEVC_MAIN_10 2
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index cbefa52..7d0a425 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -338,6 +338,11 @@ static const AVOption avcodec_options[] = {
{"dts_96_24", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_96_24 }, INT_MIN, INT_MAX, A|E, "profile"},
{"dts_hd_hra", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_HRA }, INT_MIN, INT_MAX, A|E, "profile"},
{"dts_hd_ma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_MA }, INT_MIN, INT_MAX, A|E, "profile"},
+{"prores_proxy", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_PROXY }, INT_MIN, INT_MAX, V|E, "profile" },
+{"prores_lt", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_LT }, INT_MIN, INT_MAX, V|E, "profile" },
+{"prores_standard",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_STANDARD }, INT_MIN, INT_MAX, V|E, "profile" },
+{"prores_hq", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_HQ }, INT_MIN, INT_MAX, V|E, "profile" },
+{"prores_4444", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_4444 }, INT_MIN, INT_MAX, V|E, "profile" },
{"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"},
{"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"},
{"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|A|D},
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index b8531cd..b66f405 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -36,11 +36,6 @@
#define DEFAULT_SLICE_MB_WIDTH 8
-#define FF_PROFILE_PRORES_PROXY 0
-#define FF_PROFILE_PRORES_LT 1
-#define FF_PROFILE_PRORES_STANDARD 2
-#define FF_PROFILE_PRORES_HQ 3
-
static const AVProfile profiles[] = {
{ FF_PROFILE_PRORES_PROXY, "apco"},
{ FF_PROFILE_PRORES_LT, "apcs"},
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 93bcde7..9505df0 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -40,14 +40,6 @@
#define MAX_PLANES 4
enum {
- PRORES_PROFILE_PROXY = 0,
- PRORES_PROFILE_LT,
- PRORES_PROFILE_STANDARD,
- PRORES_PROFILE_HQ,
- PRORES_PROFILE_4444,
-};
-
-enum {
QUANT_MAT_PROXY = 0,
QUANT_MAT_LT,
QUANT_MAT_STANDARD,
@@ -1214,6 +1206,19 @@ static av_cold int encode_init(AVCodecContext *avctx)
avctx->codec_tag = ctx->profile_info->tag;
+ if (avctx->profile == FF_PROFILE_UNKNOWN) {
+ avctx->profile = FF_PROFILE_PRORES_STANDARD;
+ av_log(avctx, AV_LOG_INFO,
+ "no profile specified. encoding with ProRes standard (apcn) profile\n");
+ } else if (avctx->profile < FF_PROFILE_PRORES_PROXY
+ || avctx->profile > FF_PROFILE_PRORES_4444) {
+ av_log(avctx, AV_LOG_ERROR,
+ "unknown profile %d. Supported profiles: prores_proxy, prores_lt,\n"
+ "prores_standard, prores_hq, prores_4444.\n",
+ avctx->profile);
+ return AVERROR(EINVAL);
+ }
+
av_log(avctx, AV_LOG_DEBUG,
"profile %d, %d slices, interlacing: %s, %d bits per MB\n",
ctx->profile, ctx->slices_per_picture * ctx->pictures_per_frame,
@@ -1230,19 +1235,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
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" },
- { "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 },
- 0, 0, VE, "profile" },
- { "standard", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRORES_PROFILE_STANDARD },
- 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),
@@ -1273,6 +1265,15 @@ static const AVClass proresenc_class = {
.version = LIBAVUTIL_VERSION_INT,
};
+static const AVProfile profiles[] = {
+ { FF_PROFILE_PRORES_PROXY, "apco"},
+ { FF_PROFILE_PRORES_LT, "apcs"},
+ { FF_PROFILE_PRORES_STANDARD, "apcn"},
+ { FF_PROFILE_PRORES_HQ, "apch"},
+ { FF_PROFILE_PRORES_4444, "ap4h"},
+ { FF_PROFILE_UNKNOWN }
+};
+
AVCodec ff_prores_ks_encoder = {
.name = "prores_ks",
.long_name = NULL_IF_CONFIG_SMALL("Apple ProRes (iCodec Pro)"),
@@ -1288,4 +1289,5 @@ AVCodec ff_prores_ks_encoder = {
AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_NONE
},
.priv_class = &proresenc_class,
+ .profiles = profiles,
};
--
1.9.1
More information about the ffmpeg-devel
mailing list