From patchwork Sun Dec 10 13:14:13 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: 6655 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp1676879jah; Sun, 10 Dec 2017 05:16:43 -0800 (PST) X-Google-Smtp-Source: AGs4zMZP3ReRq1OI6stRG7p9lNdVGE7UyngSbGHDERGtlc/tn6Mx5A/lDPy3PipMtCf+hSHAelDN X-Received: by 10.28.169.198 with SMTP id s189mr9102290wme.65.1512911803273; Sun, 10 Dec 2017 05:16:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512911803; cv=none; d=google.com; s=arc-20160816; b=dTf84xeCoPM64UUSx7w92WqpK9iXuifcZ5su+UF3gCwb4mEiH1g0miBFl8FGD9bemh ktE8Sh9gh0SJdEkMLnVFEtw3cZiHhpP7lNQMO/LnVcOwtsdtbGDAqXHLcTCXsvtgBin3 A0JMqjKoZxezOBr2TX3gB+vYFh/LcT+e4tbX9aTCnl+fBw9v7pmpqG8tR8Q9aEMasXQZ Ggn8JbWrEcEUYOjqcarsknvo3Abqjw+wCOt7qDzS8GWO3xxStpycet9W2+5h/LaRFZXK Vp5mqbrqiTgLeWXSzaCndArZABedJjbxq7Eqxns3sWH7CHjaF1QMqTDIUA1gk4b52ttb Ai5g== 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=imQ5hNmmkYBFNAcDvdQhwYVv9ag5HyKuhJukYZZZBdrH5a1/uB3d8fN4o3MWM0hPXK VvyzaU6iIeWUGQKT3mDGzT8oUHijmhBXQMylUvyk6j30TtdK/pbg6ZdDEeROH81Fv47X 5iLriPwzL09X/sTRCh9Ddc7XzLD/FJB59jxelL8xTAyh3X4Pd9acfqxDUN3bYUA/51da aFb0e0IDqd/pBqVQyq2B50E1H5bg0cj99JQ1usbXEObAXO25Yk2BecMWZ3OMUOoAVIO1 AXL1ApIWWFGi/uBmCYuRxeAwBGg/3W0CkTQK23rCqJckulN1IpEh4nPdmMLrv+Z8eUn5 9Jzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=WcGd9p57; 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 b18si8309874wrb.250.2017.12.10.05.16.42; Sun, 10 Dec 2017 05:16:43 -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=WcGd9p57; 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 73F8968A646; Sun, 10 Dec 2017 15:15:29 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6642268A13C for ; Sun, 10 Dec 2017 15:15:22 +0200 (EET) Received: by mail-wr0-f194.google.com with SMTP id v105so14914378wrc.3 for ; Sun, 10 Dec 2017 05:15:29 -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=WcGd9p57NLwKB9fYikLE8oEadhvY/kzQROq35XOWCHOUimQsHfjLvpWyu1QNb+YHiE R2EiVmgBqhRinUiHq3Y9GFp61lOzz/42amxzytdcSbL0YWI3WeN81gi+T7kB01kUbaxO UegSh1OX91+p8KXNm9xqxWnFOClmYVKqVURfVDJI5SkhcJSi5T5HO/rYPiyjJguJBxzX 4iLatkahAtCsLwCDfoCE9N4Hzo/Dk2ETUlpwgrVQEe2aazcBwIAISj7TylyNvWAyd0vM GSOHXIMkCRSsqr7JoQNu5zUMzTvEzWStsFkp/BtGPgEf08csL4XqfmbI0tmcoCdXAVV6 DmIw== 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=YCO3ATW+L/Ysgku8/bvcDUvSgSAUu3vTvL6wPgrdxLXidby31JI3U3SUYVsDvrlbru f9qqEdnQ7MN3LWU7xP4dzXjl8CIoN3hXFDQhnt9UB2KIk9NSjhQHPaUtjjnf+d68l7F7 jFRfzu0eX4aZ9Utt9VQ2uP2QVmYiU1i3Sy6uwfIgieJW0ZjL7qlLiEoR5CrmtdpOyPFl TMfeyKgO6Cny+sWWE/ecMjasHAptLaDMiuwsI29qak83J/2A1qYZmp5tUM8sqb1BAhrh /jUne4TyFBAOmr2RCv+o/b7z6K8FaYEV4lDXKkIC3FkF9InzVQOtGMN0SqlgGKzm7zNn fJhg== X-Gm-Message-State: AJaThX7xZ/7m5i4sTC3W9MX8LcJrkb0dEISXhn+EtujZkThZRxKYADLw WEsp2HkwsIX1RACtC1qitb5IwA== X-Received: by 10.223.159.15 with SMTP id l15mr36115563wrf.155.1512911729058; Sun, 10 Dec 2017 05:15:29 -0800 (PST) Received: from localhost.localdomain ([94.250.174.60]) by smtp.gmail.com with ESMTPSA id g78sm1129877wmc.30.2017.12.10.05.15.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Dec 2017 05:15:28 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Dec 2017 14:14:13 +0100 Message-Id: <20171210131436.15791-6-onemda@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171210131436.15791-1-onemda@gmail.com> References: <20171210131436.15791-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH 06/29] 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,