From patchwork Sat Dec 9 15:37:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 6629 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp808880jah; Sat, 9 Dec 2017 07:40:04 -0800 (PST) X-Google-Smtp-Source: AGs4zMbiXzUMnCAuk2UEmTwedICCVXR0WdPmg9pBDpkuBxitLciczrjyWlPkz2Ul5/qfuxk5C/8Y X-Received: by 10.223.136.253 with SMTP id g58mr30603689wrg.86.1512834004602; Sat, 09 Dec 2017 07:40:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512834004; cv=none; d=google.com; s=arc-20160816; b=Pwq+vWYpY7Kc7mnmDFIS/G5vbov+yQTeB35z/oYk5IPeLm6emHWt6maykKeLxuBxva ZESt2E6VRJ2xcpcmq+gEA/eWiEv95YJJDOrZ1/Gr0b4seBr9QUK/j4SvUZYWXLaXDhOW 61xG6tbHM8rEcIsfiUWYls0kZOrUf92F55glv6GGuuz9ZtkUx7LGH+9iL/3gs0wBAiez 2/2gAwHcsKs2FWfbEU8aOT4gP7RhXEX8O5zbI5nLTuMioNKY2Ha4y3nFlSZr8xyySYJN 4uJRekcbLFZ+7M/peBeH4oaAFxqbqjgrRGeFHiXJ66SG9CmnWZlsrfrxrNIhXUPgdgfT A4Uw== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=5Wzn5DT+RMuaBddPYB2YtFw88sRMr/xPE9qNZRh2kpQ=; b=hGd8lz5nmAITEE+fN62S7VNe4Ij/97nL14jJpFYdzcnSx6zgVxWYxNlIWukUIxfnvJ eKSMx9iaYg4Aeo2kQbQ5MkYnzqqUpN+43+yOlxlmUJH+Qvi0C3tv+SvL1AzxcFEQXVcL 8R+QhRCh2TOWvzopxg/RJknkEvOvPmx5+SVhFiaSnXJ4YuqilIwScW/aSM50zVbp/Vem xuMLighGSR8duT5MbeNSXRz2njVBWAc3YESJELbDupUzKCoXwv4WPbSaF4dgN+IJ0oBt ICNbezEO6b/enjtOmvG0FklNKIYSjXbQG+t3c6gHuHSVkqY74/s+fsPXJ3YZ+1taeL3F MXZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=iEMbHtyA; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l16si7781474wrh.275.2017.12.09.07.40.04; Sat, 09 Dec 2017 07:40:04 -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=@gmail.com header.s=20161025 header.b=iEMbHtyA; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A0D1B68A4C0; Sat, 9 Dec 2017 17:39:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CE82368A469 for ; Sat, 9 Dec 2017 17:39:00 +0200 (EET) Received: by mail-wm0-f66.google.com with SMTP id 64so7363531wme.3 for ; Sat, 09 Dec 2017 07:39:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=MwdSFn4eCiR9IKq8XnMESbJ1lOR6OelRom+OSf15AV4=; b=iEMbHtyAOXpyFqwCazgjjE2ugdeVbLa5PHU+64jBeU8YH/R13PwXro9TlNWC2W4ore OGq0ttZ1e31iPEj9dZl1IjBAGfdZdUyhsnU56oyrIZwpJTkqKfNYXApPdu1g2CtrUtzA WjgQbA4lB8B/XxzXE91g7sdeVpNMBTujbtFMxaO9wUtIF7lgOQ83LtIlSL3YipqkAKXN aO1QU7mc3dx0WoURAGZV88LWFYsIf04Y8hIiqy9HTu5bSyRPvfVjU+MevLyjQ0OeMA28 4hnlfldvLa08AahhlY3dVPKAm99YtSJ1X6o6Xl8MJGbNJgM6isueHFbhxeuPKhhdfd7B F3qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=MwdSFn4eCiR9IKq8XnMESbJ1lOR6OelRom+OSf15AV4=; b=ZshDx3bACATAiGQ8vLgitoYpAGh3Pj6pXUxzSKNqJ+SVzVzxCluTn9NKRFaUXv7Yaw ehWrV7RcTMPXG8loirYdvdhKY++q2F9X40ltXEQcC3NZbDrPjEZkUhA4V3t6Icq0u9ql 6jkXBeh2oxpdRtoI4kr5OJhZrh59eEwUpAGmvrgiQxqHb4DR6F0RPrXSFXsKcVfqpBqY C45POEni8VjTl3/RPxnrH1kTWwV9qO2+GzJ4E766NHbin4GBb1yszamFcDEI+CI31LTu 3trFlodFA3J3LonN68/UDy9NaGtW0GId5O60UT+WXw7xU2wgXbSo8ySdsDKyflGJKIiA CsZg== X-Gm-Message-State: AKGB3mLGowvalE3wHses7goEC8ZezzASkQdMmxmF/m8+IRt/ZG3Lm3r4 I4/1hvbc1A4hfX0abyW7rkN9Yw== X-Received: by 10.28.23.196 with SMTP id 187mr6629450wmx.101.1512833947098; Sat, 09 Dec 2017 07:39:07 -0800 (PST) Received: from localhost.localdomain ([94.250.174.60]) by smtp.gmail.com with ESMTPSA id 52sm14654536wrv.8.2017.12.09.07.39.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Dec 2017 07:39:06 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sat, 9 Dec 2017 16:37:58 +0100 Message-Id: <20171209153819.19007-6-onemda@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171209153819.19007-1-onemda@gmail.com> References: <20171209153819.19007-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH 06/27] fftools/ffmpeg_filter: auto insert scale filter to convert between different color_ranges if necessary 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: Paul B Mahol --- fftools/ffmpeg_filter.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 877fd670e6..e69bfe295c 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -449,6 +449,7 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, OutputStream *ost = ofilter->ost; OutputFile *of = output_files[ost->file_index]; AVFilterContext *last_filter = out->filter_ctx; + AVDictionaryEntry *cre = NULL; int pad_idx = out->pad_idx; int ret; char name[255]; @@ -461,7 +462,9 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, if (ret < 0) return ret; - if (ofilter->width || ofilter->height) { + cre = av_dict_get(ost->encoder_opts, "color_range", NULL, 0); + + if (ofilter->width || ofilter->height || (cre && cre->value) || ost->enc->color_range) { char args[255]; AVFilterContext *filter; AVDictionaryEntry *e = NULL; @@ -474,6 +477,12 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, av_strlcatf(args, sizeof(args), ":%s=%s", e->key, e->value); } + if (cre && cre->value) { + av_strlcatf(args, sizeof(args), ":out_range=%s", cre->value); + } else if (ost->enc->color_range) { + av_strlcatf(args, sizeof(args), ":out_range=%s", av_color_range_name(ost->enc->color_range)); + } + snprintf(name, sizeof(name), "scaler_out_%d_%d", ost->file_index, ost->index); if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"), @@ -777,10 +786,11 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, av_bprint_init(&args, 0, 1); av_bprintf(&args, "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:" - "pixel_aspect=%d/%d:sws_param=flags=%d", + "pixel_aspect=%d/%d:sws_param=flags=%d:color_range=%s", ifilter->width, ifilter->height, ifilter->format, tb.num, tb.den, sar.num, sar.den, - SWS_BILINEAR + ((ist->dec_ctx->flags&AV_CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0)); + SWS_BILINEAR + ((ist->dec_ctx->flags&AV_CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0), + av_color_range_name(ist->dec_ctx->color_range)); if (fr.num && fr.den) av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den); snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,