[FFmpeg-cvslog] avcodec/libx265 - Add named option to set profile

Gyan Doshi git at videolan.org
Thu Dec 7 00:02:47 EET 2017


ffmpeg | branch: master | Gyan Doshi <gyandoshi at gmail.com> | Tue Dec  5 13:35:53 2017 +0530| [dc7d5f9f1904faebab73f5de60f2c360c8255333] | committer: Lou Logan

avcodec/libx265 - Add named option to set profile

Adds call to x265_param_apply_profile after x265_param_parse.
Added as private option since HEVC profiles other than
Main, Main 10 and MSP in AVCodecContext are consolidated in a single
constant.

Reviewed-by: Hendrik Leppkes <h.leppkes at gmail.com>
Reviewed-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
Reviewed-by: Lou Logan <lou at lrcd.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dc7d5f9f1904faebab73f5de60f2c360c8255333
---

 libavcodec/libx265.c | 14 ++++++++++++++
 libavcodec/version.h |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 4456e300f2..cbb106aeed 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -45,6 +45,7 @@ typedef struct libx265Context {
     int   forced_idr;
     char *preset;
     char *tune;
+    char *profile;
     char *x265_opts;
 } libx265Context;
 
@@ -220,6 +221,18 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
         }
     }
 
+    if (ctx->profile) {
+        if (ctx->api->param_apply_profile(ctx->params, ctx->profile) < 0) {
+            int i;
+            av_log(avctx, AV_LOG_ERROR, "Invalid or incompatible profile set: %s.\n", ctx->profile);
+            av_log(avctx, AV_LOG_INFO, "Possible profiles:");
+            for (i = 0; x265_profile_names[i]; i++)
+                av_log(avctx, AV_LOG_INFO, " %s", x265_profile_names[i]);
+            av_log(avctx, AV_LOG_INFO, "\n");
+            return AVERROR(EINVAL);
+        }
+    }
+
     ctx->encoder = ctx->api->encoder_open(ctx->params);
     if (!ctx->encoder) {
         av_log(avctx, AV_LOG_ERROR, "Cannot open libx265 encoder.\n");
@@ -392,6 +405,7 @@ static const AVOption options[] = {
     { "forced-idr",  "if forcing keyframes, force them as IDR frames",                              OFFSET(forced_idr),AV_OPT_TYPE_BOOL,   { .i64 =  0 },  0,       1, VE },
     { "preset",      "set the x265 preset",                                                         OFFSET(preset),    AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
     { "tune",        "set the x265 tune parameter",                                                 OFFSET(tune),      AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
+    { "profile",     "set the x265 profile",                                                        OFFSET(profile),   AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
     { "x265-params", "set the x265 configuration using a :-separated list of key=value parameters", OFFSET(x265_opts), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
     { NULL }
 };
diff --git a/libavcodec/version.h b/libavcodec/version.h
index d67b689142..3b5c3000be 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR   6
-#define LIBAVCODEC_VERSION_MICRO 102
+#define LIBAVCODEC_VERSION_MICRO 103
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list