Browse code

avfilter/vf_scale: use the inputs color range when its set and its not overridden

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

Michael Niedermayer authored on 2013/07/25 08:27:00
Showing 1 changed files
... ...
@@ -392,6 +392,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
392 392
     AVFrame *out;
393 393
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
394 394
     char buf[32];
395
+    int in_range;
395 396
 
396 397
     if(   in->width  != link->w
397 398
        || in->height != link->h
... ...
@@ -429,9 +430,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
429 429
     if(scale->output_is_pal)
430 430
         avpriv_set_systematic_pal2((uint32_t*)out->data[1], outlink->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : outlink->format);
431 431
 
432
+    in_range = av_frame_get_color_range(in);
433
+
432 434
     if (   scale->in_color_matrix
433 435
         || scale->out_color_matrix
434 436
         || scale-> in_range != AVCOL_RANGE_UNSPECIFIED
437
+        || in_range != AVCOL_RANGE_UNSPECIFIED
435 438
         || scale->out_range != AVCOL_RANGE_UNSPECIFIED) {
436 439
         int in_full, out_full, brightness, contrast, saturation;
437 440
         const int *inv_table, *table;
... ...
@@ -447,6 +451,8 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
447 447
 
448 448
         if (scale-> in_range != AVCOL_RANGE_UNSPECIFIED)
449 449
             in_full  = (scale-> in_range == AVCOL_RANGE_JPEG);
450
+        else if (in_range != AVCOL_RANGE_UNSPECIFIED)
451
+            in_full  = (in_range == AVCOL_RANGE_JPEG);
450 452
         if (scale->out_range != AVCOL_RANGE_UNSPECIFIED)
451 453
             out_full = (scale->out_range == AVCOL_RANGE_JPEG);
452 454