From patchwork Wed Apr 4 01:43:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 8309 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp4337553jad; Tue, 3 Apr 2018 18:44:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/7X15o4kPG87Rz3h+ZSD5I5nsyV9pzCoC542e6e4qYdwwbKQ12cgMBOFsYATE9xXlwPUPb X-Received: by 10.223.226.13 with SMTP id j13mr12110380wri.118.1522806280938; Tue, 03 Apr 2018 18:44:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522806280; cv=none; d=google.com; s=arc-20160816; b=0tI9aMKHEiaRjx6Pv/AXi6Oo+EJtAvWZYDcy1/GGs7ceaz62hVhIxx2vJeWT4qYmHt IMSOZ6CG4Ztbwfur05uS/73PexLgEDmTm9JelyL2dgGJm0H3bNbHBOv25UXWPyW5nYiC ItfmdJVak05/E9RaLEsWivkdOoeuxyulkJie1egdgCRo8f79NIHoerpQg7WAqosVz1k5 Ck/Zs3HuXVk2tpgEPdEIOy8arDBnqdCgZ9qK+9YXZIe1aIsBJCweAckxLO8BNcUu/ztG NOKDZKIDiAJeuz+ejvfsVyHbk+LZmmxERLyhMreVwUrSKgm7rey25hOPCrMh14iX6xG7 hwkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=D5xhr+W7Z+9LFwVxUA3TgRZEdXQJzYvnCMasn66gL/Q=; b=nePnh6p0NxmGpPcgoy0HP1G4FeRc5Ipv5LekBB8dUStchmPj1RsHRpbn1ZB4p4GsNG Ab3iusEgD9JiDvalgHJ9O1lIQfh6SGvvEru0VO3yUDPMHr8u/whGWJZ3G7mUL0UcmJ8s +H4o6RRoqTOqYBOBGSsfkZlJcPMD7HLD22pqhA+PRVuakghYRR9gj1Sl5PYR1GxACMfp otVA096MGz4F6gYTuHdLZCB7SxynB0XjnvDo2Ho9xG56ke8Zp+NaQLnYgz6cuHBS3Lb7 Vr6jlhMxLVUOMZ8SFMf9WDPT4ZL5ME3nc4VccOR3g13qJH6gpn57DTFKk0hGY7lFRIfs ioYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f2si667784wmc.83.2018.04.03.18.44.40; Tue, 03 Apr 2018 18:44:40 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3AD3A689EC0; Wed, 4 Apr 2018 04:44:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-1.mx.upcmail.net (vie01a-qmta-pe02-1.mx.upcmail.net [62.179.121.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A316E689E46 for ; Wed, 4 Apr 2018 04:44:16 +0300 (EEST) Received: from [172.31.218.37] (helo=vie01a-dmta-pe03-1.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1f3XTZ-0006Om-4o for ffmpeg-devel@ffmpeg.org; Wed, 04 Apr 2018 03:44:37 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1f3XTY-0007zy-8k for ffmpeg-devel@ffmpeg.org; Wed, 04 Apr 2018 03:44:36 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id W1kX1x0010S5wYM011kYR9; Wed, 04 Apr 2018 03:44:32 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 4 Apr 2018 03:43:52 +0200 Message-Id: <20180404014352.28442-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.16.2 Subject: [FFmpeg-devel] [PATCH] avfilter/vf_scale: Set full range for RGB formats X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Michael Niedermayer --- libavfilter/vf_scale.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index f741419e7e..bd5c63aa9b 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -406,6 +406,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) AVFilterLink *outlink = link->dst->outputs[0]; AVFrame *out; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format); + const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(outlink->format); char buf[32]; int in_range; @@ -496,7 +497,11 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) table, out_full, brightness, contrast, saturation); - out->color_range = out_full ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; + // color_range describes YUV, it is undefined for RGB + if ((out_desc->flags & AV_PIX_FMT_FLAG_RGB) && out_desc->nb_components != 1) { + out->color_range = AVCOL_RANGE_JPEG; + } else + out->color_range = out_full ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; } av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,