Browse code

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

Baptiste Coudurier authored on 2011/05/11 08:40:21
Showing 2 changed files
... ...
@@ -435,7 +435,7 @@ void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec)
435 435
         const char *str;
436 436
         if (priv_ctx) {
437 437
             if (av_find_opt(priv_ctx, opt_names[i], NULL, flags, flags)) {
438
-                if (av_set_string3(priv_ctx, opt_names[i], opt_values[i], 0, NULL) < 0) {
438
+                if (av_set_string3(priv_ctx, opt_names[i], opt_values[i], 1, NULL) < 0) {
439 439
                     fprintf(stderr, "Invalid value '%s' for option '%s'\n",
440 440
                             opt_names[i], opt_values[i]);
441 441
                     exit(1);
... ...
@@ -35,13 +35,13 @@ typedef struct X264Context {
35 35
     uint8_t        *sei;
36 36
     int             sei_size;
37 37
     AVFrame         out_pic;
38
-    const char *preset;
39
-    const char *tune;
40
-    const char *profile;
41
-    const char *level;
38
+    char *preset;
39
+    char *tune;
40
+    char *profile;
41
+    char *level;
42 42
     int fastfirstpass;
43
-    const char *stats;
44
-    const char *weightp;
43
+    char *stats;
44
+    char *weightp;
45 45
 } X264Context;
46 46
 
47 47
 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)
163 163
     if (x4->enc)
164 164
         x264_encoder_close(x4->enc);
165 165
 
166
+    av_free(x4->preset);
167
+    av_free(x4->tune);
168
+    av_free(x4->profile);
169
+    av_free(x4->level);
170
+    av_free(x4->stats);
171
+    av_free(x4->weightp);
172
+
166 173
     return 0;
167 174
 }
168 175
 
... ...
@@ -185,7 +192,7 @@ static void check_default_settings(AVCodecContext *avctx)
185 185
     score += x4->params.analyse.inter == 0 && x4->params.analyse.i_subpel_refine == 8;
186 186
     if (score >= 5) {
187 187
         av_log(avctx, AV_LOG_ERROR, "Default settings detected, using medium profile\n");
188
-        x4->preset = "medium";
188
+        x4->preset = av_strdup("medium");
189 189
         if (avctx->bit_rate == 200*100)
190 190
             avctx->crf = 23;
191 191
     }