[FFmpeg-devel,05/24] avfilter/vf_scale: make use of color_range from filter links

Submitted by Paul B Mahol on May 1, 2018, 7:39 p.m.

Details

Message ID 20180501194013.9552-5-onemda@gmail.com
State New
Headers show

Commit Message

Paul B Mahol May 1, 2018, 7:39 p.m.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/vf_scale.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index f741419e7e..c7f2b07f0b 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -302,9 +302,15 @@  static int config_props(AVFilterLink *outlink)
             if (scale->in_range != AVCOL_RANGE_UNSPECIFIED)
                 av_opt_set_int(*s, "src_range",
                                scale->in_range == AVCOL_RANGE_JPEG, 0);
+            else
+                av_opt_set_int(*s, "src_range",
+                               inlink->color_range == AVCOL_RANGE_JPEG, 0);
             if (scale->out_range != AVCOL_RANGE_UNSPECIFIED)
                 av_opt_set_int(*s, "dst_range",
                                scale->out_range == AVCOL_RANGE_JPEG, 0);
+           else
+                av_opt_set_int(*s, "dst_range",
+                               outlink->color_range == AVCOL_RANGE_JPEG, 0);
 
             if (scale->opts) {
                 AVDictionaryEntry *e = NULL;
@@ -415,6 +421,7 @@  static int filter_frame(AVFilterLink *link, AVFrame *in)
     if(   in->width  != link->w
        || in->height != link->h
        || in->format != link->format
+       || in->color_range != link->color_range
        || in->sample_aspect_ratio.den != link->sample_aspect_ratio.den || in->sample_aspect_ratio.num != link->sample_aspect_ratio.num) {
         int ret;
 
@@ -428,6 +435,7 @@  static int filter_frame(AVFilterLink *link, AVFrame *in)
         link->dst->inputs[0]->format = in->format;
         link->dst->inputs[0]->w      = in->width;
         link->dst->inputs[0]->h      = in->height;
+        link->dst->inputs[0]->color_range = in->color_range;
 
         link->dst->inputs[0]->sample_aspect_ratio.den = in->sample_aspect_ratio.den;
         link->dst->inputs[0]->sample_aspect_ratio.num = in->sample_aspect_ratio.num;