Browse code

vf_scale: Use correct chroma positions for YUV420P

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Kieran Kunhya authored on 2014/12/25 08:52:46
Showing 1 changed files
... ...
@@ -373,6 +373,17 @@ static int config_props(AVFilterLink *outlink)
373 373
             av_opt_set_int(*s, "dst_format", outfmt, 0);
374 374
             av_opt_set_int(*s, "sws_flags", scale->flags, 0);
375 375
 
376
+            /* Override YUV420P settings to have the correct (MPEG-2) chroma positions
377
+             * MPEG-2 chroma positions are used by convention
378
+             * XXX: support other 4:2:0 pixel formats */
379
+            if (inlink->format == AV_PIX_FMT_YUV420P) {
380
+                scale->in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
381
+            }
382
+
383
+            if (outlink->format == AV_PIX_FMT_YUV420P) {
384
+                scale->out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
385
+            }
386
+
376 387
             av_opt_set_int(*s, "src_h_chr_pos", scale->in_h_chr_pos, 0);
377 388
             av_opt_set_int(*s, "src_v_chr_pos", scale->in_v_chr_pos, 0);
378 389
             av_opt_set_int(*s, "dst_h_chr_pos", scale->out_h_chr_pos, 0);