From patchwork Wed Feb 21 22:25:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 7695 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.150.33 with SMTP id c30csp1323610jai; Wed, 21 Feb 2018 14:32:44 -0800 (PST) X-Google-Smtp-Source: AH8x225QKPjR9A6hkMhOVAFl8T/1i99eFZP86csBpKdmBChAS4L/1mBtFM74aSQKIz0sNg1FKMb/ X-Received: by 10.28.15.10 with SMTP id 10mr3272236wmp.75.1519252364431; Wed, 21 Feb 2018 14:32:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519252364; cv=none; d=google.com; s=arc-20160816; b=LiDBxWfe4pbyxXPxyP/3pzJJloGMZjO6HvUvyRzUDux+57WjTn0LxjqhZas6LJ43EL 9+tqSKRde4o/z1c7oCd9n6dHIdYYTKeD178DkaOAKtrg4Wn/gc9pku8MRhLlveDhf9s4 C1wsacyQJdL09OEj02Wc5xGdP3GRnLBE/A/2as5f/V0nwP+qmV0gx+aZ0PGqMW88RlU7 5jQy1MXgGXJVKRxJv11prmpXW5WleWd1lF9EWTqINhhA/qUUNCmM0si1Ek0SNw9FMrqh E0UaiLSUCOB2c2SXDt2d8ZToEQWP2OaUefw1UtxcDtnKKpcLG+GJ1ctx7rwyg2GexXNC DY7g== 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:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=NTszsFp4bk9Cj8vof9CRTFdF9AlNP4jK/vUE8yyz6a4=; b=ZExyrtNqxXVhQhrpf9xhWdDz7ISIbEeeWfPRJq0atDc0Gy7bX0KiP8g8q0Zr6J01gT M+ZialbKxl8opBKVr3tvhR3lKc1D3H6KtUvP9ieTvZOLIzkSoCQnfnTMhnQGsOYKZa5K FuAdiAejfKHIr1I86t4/l0RlwCSej2J1RUjI29HK6qxoOkv5DtFaMCfDoeQodlZWs+gV PQYwkwn5qiTQkgWm/D+sYXSnhHEWSdx4zgKJLXsQ4p0X5TKUasAhoSChkyy8rzVZ8BBv 6sm1kFynJujPBQagtFwOu6dF7T9ZIcznLY4Ss2a3Kh5VYFsFEGahTehK2RMA0tu7p2eo 5Zgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=bbMN/imD; 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 s26si10574619wma.200.2018.02.21.14.32.44; Wed, 21 Feb 2018 14:32:44 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=bbMN/imD; 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 4B64668A3B4; Thu, 22 Feb 2018 00:32:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f226.google.com (mail-io0-f226.google.com [209.85.223.226]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0ECAF68A2A9 for ; Thu, 22 Feb 2018 00:32:35 +0200 (EET) Received: by mail-io0-f226.google.com with SMTP id l12so3848504ioc.10 for ; Wed, 21 Feb 2018 14:32:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=fzdmZhJJMgKt8q2kvQoJEUr3aRsyrCXHwmSPNDEH2j0=; b=Prcsxw/U/KmLXS1W+a9FvxbqLlISdxYWcQmaC/kk3VCDW7eTwe7BqWcV9qF5WZSBX9 JPD19lwnmsBP2YxdHX8SmQkggBFPJ07Uq96rouiD6iUorTB0ORfb0/uCElFaA0OiEdN0 MQUp3awBZ1YFoLdv+fb70OfXn/spk2VxrdSTiEGRvb5bZkR6TgPs6U0Jp4NuRT3UC0be JQsFfFyoahGo9tlhUAGPuV90T/pIcnfD6s9eTguw2w3TH2mPMuTIG4i/aVZQ+MHMsTjV E7gucRWoiwD72/Nq4HXuO9pFgH+KvGtZdkLHlGbaF/xouzc6mVxNOUOkvYsnrBlCVTWa qaWQ== X-Gm-Message-State: APf1xPB37X89ktYHvqdQcxVi1kBRwF/fil5xH43gvM8BJCAa3utOUTAU ETUM2qa/z3R820L/U0Ck+RKYLrRMxjk5fgd3WG8F9n5k04Tv6A== X-Received: by 10.107.192.2 with SMTP id q2mr136672iof.112.1519251952836; Wed, 21 Feb 2018 14:25:52 -0800 (PST) Received: from mail.overt.org (155.208.178.107.bc.googleusercontent.com. [107.178.208.155]) by smtp-relay.gmail.com with ESMTPS id 138sm8250911itx.0.2018.02.21.14.25.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 14:25:52 -0800 (PST) X-Relaying-Domain: gapps.overt.org Received: from authenticated-user (mail.overt.org [107.178.208.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id 472EA605EF; Wed, 21 Feb 2018 22:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1519251952; bh=J4BIMLhjAOwet58Z/SFzUpI5fwkbZNjpKkGckI+/674=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bbMN/imDc4VHzizb7UWs564pqQXgm368xjdbDiWPj5Mgc7+SAMurzl+hXztQ3MjhI s8vxXVmnFMH/M3N9FfCU0UErZdTo2dlXyCU2iRcNfgN3Y+nQPlfOc+ObY64le4hCFF C+TCSdCsDPMmfVCwaPvglCFZfQbJcPNQC2FPJHpGRet7UgSiGOFfCtOr/5pIw5Mez1 lwWcRsGZMZbNoRSAXch5bajzPtxRBRHeol2NDwFx5bwo0aACnGIRkncPx9sC4hGO7m LPHNvQbwx/AUJy3UZCoTURl1ytFfiNM7Qv0nKnis8Dd6FcdnWSrrDAvryJQj3sK7yU PnTJ+AXDlOgwA== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Wed, 21 Feb 2018 14:25:37 -0800 Message-Id: <20180221222538.7255-3-philipl@overt.org> In-Reply-To: <20180221222538.7255-1-philipl@overt.org> References: <20180221222538.7255-1-philipl@overt.org> Subject: [FFmpeg-devel] [PATCH 2/3] avfilter: Set output link colour range where appropriate 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 Cc: Philip Langdale MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Certain filters set or modify the output colour range. Today, they do that per-frame, but now that we have a link property, they need to set that as well. Signed-off-by: Philip Langdale --- libavfilter/avf_showcqt.c | 1 + libavfilter/avf_showspectrum.c | 1 + libavfilter/version.h | 2 +- libavfilter/vf_colorspace.c | 4 ++++ libavfilter/vf_scale.c | 8 +++++++- libavfilter/vf_setparams.c | 11 +++++++++++ libavfilter/vf_waveform.c | 1 + libavfilter/vf_zscale.c | 21 +++++++++++++++++++-- 8 files changed, 45 insertions(+), 4 deletions(-) diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c index 875ba48cee..ee6654358a 100644 --- a/libavfilter/avf_showcqt.c +++ b/libavfilter/avf_showcqt.c @@ -1363,6 +1363,7 @@ static int config_output(AVFilterLink *outlink) outlink->h = s->height; s->format = outlink->format; outlink->sample_aspect_ratio = av_make_q(1, 1); + outlink->color_range = AVCOL_RANGE_JPEG; outlink->frame_rate = s->rate; outlink->time_base = av_mul_q(av_inv_q(s->rate), av_make_q(1, PTS_STEP)); av_log(ctx, AV_LOG_INFO, "video: %dx%d %s %d/%d fps, bar_h = %d, axis_h = %d, sono_h = %d.\n", diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index 956f62f3ad..52fa018317 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -307,6 +307,7 @@ static int config_output(AVFilterLink *outlink) outlink->w = s->w; outlink->h = s->h; outlink->sample_aspect_ratio = (AVRational){1,1}; + outlink->color_range = AVCOL_RANGE_JPEG; if (s->legend) { s->start_x = log10(inlink->sample_rate) * 25; diff --git a/libavfilter/version.h b/libavfilter/version.h index babb4187b4..1f0497b3e6 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,7 +31,7 @@ #define LIBAVFILTER_VERSION_MAJOR 7 #define LIBAVFILTER_VERSION_MINOR 13 -#define LIBAVFILTER_VERSION_MICRO 100 +#define LIBAVFILTER_VERSION_MICRO 101 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c index 71ea08a20f..5455648710 100644 --- a/libavfilter/vf_colorspace.c +++ b/libavfilter/vf_colorspace.c @@ -1048,6 +1048,7 @@ static int config_props(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->dst; AVFilterLink *inlink = outlink->src->inputs[0]; + ColorSpaceContext *s = ctx->priv; if (inlink->w % 2 || inlink->h % 2) { av_log(ctx, AV_LOG_ERROR, "Invalid odd size (%dx%d)\n", @@ -1060,6 +1061,9 @@ static int config_props(AVFilterLink *outlink) outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; outlink->time_base = inlink->time_base; + if (s->user_rng != AVCOL_RANGE_UNSPECIFIED) + outlink->color_range = s->user_rng; + return 0; } diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 9f45032e85..21ae709d6b 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -342,11 +342,16 @@ static int config_props(AVFilterLink *outlink) } else outlink->sample_aspect_ratio = inlink0->sample_aspect_ratio; - av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d fmt:%s sar:%d/%d flags:0x%0x\n", + if (scale->out_range != AVCOL_RANGE_UNSPECIFIED) + outlink->color_range = scale->out_range; + + av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s sar:%d/%d range:%d -> w:%d h:%d fmt:%s sar:%d/%d range:%d flags:0x%0x\n", inlink ->w, inlink ->h, av_get_pix_fmt_name( inlink->format), inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den, + inlink->color_range, outlink->w, outlink->h, av_get_pix_fmt_name(outlink->format), outlink->sample_aspect_ratio.num, outlink->sample_aspect_ratio.den, + outlink->color_range, scale->flags); return 0; @@ -363,6 +368,7 @@ static int config_props_ref(AVFilterLink *outlink) outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; outlink->time_base = inlink->time_base; outlink->frame_rate = inlink->frame_rate; + outlink->color_range = inlink->color_range; return 0; } diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c index 8427f98ba8..2b47e2d20b 100644 --- a/libavfilter/vf_setparams.c +++ b/libavfilter/vf_setparams.c @@ -56,6 +56,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) return ff_filter_frame(ctx->outputs[0], frame); } +static int config_output(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + SetParamsContext *s = ctx->priv; + + if (s->color_range >= 0) + outlink->color_range = s->color_range; + return 0; +} + static const AVFilterPad inputs[] = { { .name = "default", @@ -69,6 +79,7 @@ static const AVFilterPad outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_output, }, { NULL } }; diff --git a/libavfilter/vf_waveform.c b/libavfilter/vf_waveform.c index 02a7046f33..b610336ea2 100644 --- a/libavfilter/vf_waveform.c +++ b/libavfilter/vf_waveform.c @@ -2744,6 +2744,7 @@ static int config_output(AVFilterLink *outlink) } outlink->sample_aspect_ratio = (AVRational){1,1}; + outlink->color_range = AVCOL_RANGE_JPEG; return 0; } diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c index 6e1d36cb4c..c1cd55bd36 100644 --- a/libavfilter/vf_zscale.c +++ b/libavfilter/vf_zscale.c @@ -299,11 +299,16 @@ static int config_props(AVFilterLink *outlink) } else outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; - av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d fmt:%s sar:%d/%d\n", + if (s->range > -1) + outlink->color_range = convert_zimg_range(s->range); + + av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s sar:%d/%d range: %d-> w:%d h:%d fmt:%s sar:%d/%d range:%d\n", inlink ->w, inlink ->h, av_get_pix_fmt_name( inlink->format), inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den, + inlink->color_range, outlink->w, outlink->h, av_get_pix_fmt_name(outlink->format), - outlink->sample_aspect_ratio.num, outlink->sample_aspect_ratio.den); + outlink->sample_aspect_ratio.num, outlink->sample_aspect_ratio.den, + outlink->color_range); return 0; fail: @@ -457,6 +462,18 @@ static int convert_range(enum AVColorRange color_range) return ZIMG_RANGE_LIMITED; } +static int convert_zimg_range(int zimg_range) +{ + switch (zimg_range) { + case ZIMG_RANGE_LIMITED: + return AVCOL_RANGE_MPEG; + case ZIMG_RANGE_FULL: + return AVCOL_RANGE_JPEG; + default: + return AVCOL_RANGE_UNSPECIFIED; + } +} + static void format_init(zimg_image_format *format, AVFrame *frame, const AVPixFmtDescriptor *desc, int colorspace, int primaries, int transfer, int range, int location) {