From: Gavriloaie Eugen-Andrei <[email protected]>
It is a shortcut to set all the params using x264_param_parse,
makes simpler importing settings from other software using x264.
---
Version without strtok. Once the av_dict_set_string (or something similar
named differently) lands I can change this to use it.
libavcodec/libx264.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index e9cbbad..4a7c35e 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -70,6 +70,7 @@ typedef struct X264Context {
int slice_max_size;
char *stats;
int nal_hrd;
+ char *x264_params;
} X264Context;
static void X264_log(void *p, int level, const char *fmt, va_list args)
@@ -407,6 +408,34 @@ static av_cold int X264_init(AVCodecContext *avctx)
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER)
x4->params.b_repeat_headers = 0;
+ if (x4->x264_params) {
+ char *p = x4->x264_params;
+ char *key = NULL;
+ char *val = NULL;
+ int c, k;
+
+ while (*p && (c = strcspn(p, ":"))) {
+ p[c] = '\0';
+
+ k = strcspn(p, "=");
+ if (!k) {
+ av_log(avctx, AV_LOG_WARNING, "Error parsing %s\n", p);
+ break;
+ }
+
+ key = p;
+ val = p + k + 1;
+
+ p[k] = '\0';
+
+ if (x264_param_parse(&x4->params, key, val) < 0)
+ av_log(avctx, AV_LOG_WARNING,
+ "Error parsing option '%s=%s'.\n",
+ key, val);
+ p += c + 1;
+ }
+ }
+
// update AVCodecContext with x264 parameters
avctx->has_b_frames = x4->params.i_bframe ?
x4->params.i_bframe_pyramid ? 2 : 1 : 0;
@@ -527,6 +556,7 @@ static const AVOption options[] = {
{ "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_NONE},
INT_MIN, INT_MAX, VE, "nal-hrd" },
{ "vbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_VBR},
INT_MIN, INT_MAX, VE, "nal-hrd" },
{ "cbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_CBR},
INT_MIN, INT_MAX, VE, "nal-hrd" },
+ { "x264-params", "Override the x264 configuration using a :-separated
list of key=value list of parameters", OFFSET(x264_params), AV_OPT_TYPE_STRING,
{ 0 }, 0, 0, VE },
{ NULL },
};
--
1.8.0.2
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel