From patchwork Wed Feb 21 22:25:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 7696 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.150.33 with SMTP id c30csp1323281jai; Wed, 21 Feb 2018 14:32:18 -0800 (PST) X-Google-Smtp-Source: AH8x226fj6G6aMXyCe0KlJzRggbtxqZise8cKpCzznDQ33iOPfrohyS5pa8kQ+96lzhVT4Jz5SzM X-Received: by 10.223.193.14 with SMTP id r14mr4315196wre.56.1519252338484; Wed, 21 Feb 2018 14:32:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519252338; cv=none; d=google.com; s=arc-20160816; b=zaSJPbJDLyPxLyH6uvLO3+iDmZjrLMAsVsmn2vuozX2xtosqcAXuODc+vlr00FpaQW nY7Fbodke6WxkR/MuYY+j3N/rIN3la9igo/pOqRf9SdUGOV+RuzTyB6AK8lrXvnI1k2d 2FdgWtrVyIbOwcw5CnUujwjBFMFkF7ekpKqKpkTbtxwtwwDDLD3GUx8d28YEgD4dCasL MFz8AweU4QNhDsnXtByL6FiQQ8X0bmY9p6QCZwGmmM6kZWiEWetn06Hi7QqLlr5Forxx WE3Tvgvba5jol4e76vLl880zqcK0s0B9PTim5UaNPdVhcaw6IED9fJ3elniimD6TnfSo Y4sg== 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=hQYiUaG6usfmwQabUKhPzUWnXZTLXuunqW6hv7zk0ms=; b=CEpT4feqIyCIkXcmxCHj5y8lM9gNkJ3AQK4AAYwAoJykgAjQNiRUwKxeURQqLXlySv QFkMqzn6ql0nyB6bOwxI/Zck5enjYvVLXH6+FZe4Iltm5njf00Zp2mjLubrT31OiQ/E1 Kigx522pROHJtHWLQ6h8fnQVsYy4Lh2iylCeUfklwbZVBDAdPIX72vBl6OVkFRG9Zjdq ECn1jHADdeqrkLlLcyROvZroXjegGManH0Jl91LebhFDgaF2s4G5J+7DGXX3VkfzhTDY XiRoEYT3oGJcOoN5uDgLZfvBqvluc7U8RYTQqWZh8Cf5ULuzPQI895+D3ZnHbRFLX0le xeWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=QcJ/bg8G; 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 x13si15868666wrg.466.2018.02.21.14.32.18; Wed, 21 Feb 2018 14:32:18 -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=QcJ/bg8G; 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 9D9A968A387; Thu, 22 Feb 2018 00:32:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it0-f100.google.com (mail-it0-f100.google.com [209.85.214.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A783A68A37E for ; Thu, 22 Feb 2018 00:32:08 +0200 (EET) Received: by mail-it0-f100.google.com with SMTP id o9so4021281itc.1 for ; Wed, 21 Feb 2018 14:32:10 -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=ZHFkd5BjbnlTbZAbtlZcU4S7FYxjaeL0BMdrxgMBRqc=; b=nPSCnJnUsNdYFanxucQYnaWP8XNR4DZrkxnI1+wix8edEfxBq/HCg9ZhyaVlV9oDtS 6P2xdPAgGYXHEfYd28dYOn1NO3mdzlARFv+3D0mHrshQndS2/0ss5woI9OLl097x5pmZ iRqKO2RceKNGOr3O8TkcqIbyAYIiJOFjC3mfhR59W8AdIJqK5bqxVnkpTIH+VK06M2Rb Ol4542gQvQXd24NC5gXYHCFfd5brSShNLi6iC8spJcEqwnaB2vvng6O40doyhDJcVJBV anmBR1hRLC7MAbXwLh1S8HIqTsw0ASdWjV+ktNsCZ9lRqqNvQV9J5xuaa+SO9qcbtoHF NCWg== X-Gm-Message-State: APf1xPDXdS3c0qu9oFkt3qHC9EcBp46Xqp11sbk8e/U/Ar4T4La8zgI5 65XpwV9LDPBnqscwR0SLsp5cYVl2PJC417sV/q5Q+15Sxx4JbQ== X-Received: by 10.36.179.6 with SMTP id e6mr5605642itf.67.1519251953270; Wed, 21 Feb 2018 14:25:53 -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 e8sm2559247itd.3.2018.02.21.14.25.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 14:25:53 -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 ABA18605F0; 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=olPpBhkijKgQsroa7BNzvrFRwpQSbHICgYY3CwypRVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QcJ/bg8GhpOvl8PwNnPI+IjfKicB1HsA1U+e1hVikA704QQERuHOgYKrdrFVUEwGO 0bDoq6o8Xh1hgnrLoZ4XMBZZzbleOVDyANknK1hA7oL2SZlNRbsLBxAARvJlY65qz9 lloC81X/cns43EMVJ72b6gJIjYWbIFUHcskX4seN2p0BLv529FdpA5L6Y2M/n1B9Gg jppqfOeRPiGeUmpLm/BOMG56Up44HuYiObX+/0odnZnF+35Zxxz/HwLXPae2kbyYfu 2LKqV4WO3tXpTQzs/ydx7pTO7j8COJrB5u9VKHaaRF5LNve6P191KbNOvJVKgtsbOZ RsP6LneBa0QMQ== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Wed, 21 Feb 2018 14:25:38 -0800 Message-Id: <20180221222538.7255-4-philipl@overt.org> In-Reply-To: <20180221222538.7255-1-philipl@overt.org> References: <20180221222538.7255-1-philipl@overt.org> Subject: [FFmpeg-devel] [PATCH 3/3] fftools/ffmpeg: Support passing colour range from decoder to encoder 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" This is relatively straightforward; we set the colour range from the encoder context into the buffersrc parameters and then set the range on the decoder from the buffersink. I did not touch ifilter as part of this change, as I'm not sure whether it is relevant. ifilter initialisation seems to be done from an AVFrame, and it seems conceptually undesirable to set the link colour range on that basis. The one possible reason to handle this is if if the input is not a decoder and so the color range would come from codecpar. If so, it could be handled as a separate change. Signed-off-by: Philip Langdale --- fftools/ffmpeg.c | 2 ++ fftools/ffmpeg_filter.c | 1 + 2 files changed, 3 insertions(+) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index a37de2ff98..ff824b864f 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3385,6 +3385,8 @@ static int init_output_stream_encode(OutputStream *ost) av_mul_q(ost->frame_aspect_ratio, (AVRational){ enc_ctx->height, enc_ctx->width }) : av_buffersink_get_sample_aspect_ratio(ost->filter->filter); + enc_ctx->color_range = av_buffersink_get_color_range(ost->filter->filter); + enc_ctx->pix_fmt = av_buffersink_get_format(ost->filter->filter); if (dec_ctx) enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample, diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 877fd670e6..30cb0bc378 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -755,6 +755,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, return AVERROR(ENOMEM); memset(par, 0, sizeof(*par)); par->format = AV_PIX_FMT_NONE; + par->color_range = ist->dec_ctx->color_range; if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) { av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n");