Browse code

avfilter/vf_scale: Fix chroma positioning for 4:2:0 pixel format

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Maksym Veremeyenko authored on 2017/02/07 00:03:17
Showing 1 changed files
... ...
@@ -285,6 +285,7 @@ static int config_props(AVFilterLink *outlink)
285 285
         int i;
286 286
 
287 287
         for (i = 0; i < 3; i++) {
288
+            int in_v_chr_pos = scale->in_v_chr_pos, out_v_chr_pos = scale->out_v_chr_pos;
288 289
             struct SwsContext **s = swscs[i];
289 290
             *s = sws_alloc_context();
290 291
             if (!*s)
... ...
@@ -317,17 +318,17 @@ static int config_props(AVFilterLink *outlink)
317 317
              * MPEG-2 chroma positions are used by convention
318 318
              * XXX: support other 4:2:0 pixel formats */
319 319
             if (inlink0->format == AV_PIX_FMT_YUV420P && scale->in_v_chr_pos == -513) {
320
-                scale->in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
320
+                in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
321 321
             }
322 322
 
323 323
             if (outlink->format == AV_PIX_FMT_YUV420P && scale->out_v_chr_pos == -513) {
324
-                scale->out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
324
+                out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
325 325
             }
326 326
 
327 327
             av_opt_set_int(*s, "src_h_chr_pos", scale->in_h_chr_pos, 0);
328
-            av_opt_set_int(*s, "src_v_chr_pos", scale->in_v_chr_pos, 0);
328
+            av_opt_set_int(*s, "src_v_chr_pos", in_v_chr_pos, 0);
329 329
             av_opt_set_int(*s, "dst_h_chr_pos", scale->out_h_chr_pos, 0);
330
-            av_opt_set_int(*s, "dst_v_chr_pos", scale->out_v_chr_pos, 0);
330
+            av_opt_set_int(*s, "dst_v_chr_pos", out_v_chr_pos, 0);
331 331
 
332 332
             if ((ret = sws_init_context(*s, NULL, NULL)) < 0)
333 333
                 return ret;