[FFmpeg-cvslog] Allocate per codec options, now that options are freed between inputs and outputs.

Baptiste Coudurier git at videolan.org
Wed May 11 01:43:35 CEST 2011


ffmpeg | branch: master | Baptiste Coudurier <baptiste.coudurier at gmail.com> | Tue May 10 16:40:21 2011 -0700| [580fa76c5c8b4372247221a4602527a060e2d5b4] | committer: Baptiste Coudurier

Allocate per codec options, now that options are freed between inputs and outputs.

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

 cmdutils.c           |    2 +-
 libavcodec/libx264.c |   21 ++++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index 38e152a..11391af 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -435,7 +435,7 @@ void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec)
         const char *str;
         if (priv_ctx) {
             if (av_find_opt(priv_ctx, opt_names[i], NULL, flags, flags)) {
-                if (av_set_string3(priv_ctx, opt_names[i], opt_values[i], 0, NULL) < 0) {
+                if (av_set_string3(priv_ctx, opt_names[i], opt_values[i], 1, NULL) < 0) {
                     fprintf(stderr, "Invalid value '%s' for option '%s'\n",
                             opt_names[i], opt_values[i]);
                     exit(1);
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 7d137a7..838cb70 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -35,13 +35,13 @@ typedef struct X264Context {
     uint8_t        *sei;
     int             sei_size;
     AVFrame         out_pic;
-    const char *preset;
-    const char *tune;
-    const char *profile;
-    const char *level;
+    char *preset;
+    char *tune;
+    char *profile;
+    char *level;
     int fastfirstpass;
-    const char *stats;
-    const char *weightp;
+    char *stats;
+    char *weightp;
 } X264Context;
 
 static void X264_log(void *p, int level, const char *fmt, va_list args)
@@ -163,6 +163,13 @@ static av_cold int X264_close(AVCodecContext *avctx)
     if (x4->enc)
         x264_encoder_close(x4->enc);
 
+    av_free(x4->preset);
+    av_free(x4->tune);
+    av_free(x4->profile);
+    av_free(x4->level);
+    av_free(x4->stats);
+    av_free(x4->weightp);
+
     return 0;
 }
 
@@ -185,7 +192,7 @@ static void check_default_settings(AVCodecContext *avctx)
     score += x4->params.analyse.inter == 0 && x4->params.analyse.i_subpel_refine == 8;
     if (score >= 5) {
         av_log(avctx, AV_LOG_ERROR, "Default settings detected, using medium profile\n");
-        x4->preset = "medium";
+        x4->preset = av_strdup("medium");
         if (avctx->bit_rate == 200*100)
             avctx->crf = 23;
     }



More information about the ffmpeg-cvslog mailing list