From patchwork Sun Dec 10 14:06:48 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: 6680 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp1719644jah; Sun, 10 Dec 2017 06:07:55 -0800 (PST) X-Google-Smtp-Source: AGs4zMafuJfRsLH5U91X6dWmOKBrYlozP1ncBCL7OnslMdjVOXPmu9OdN7Nes7ZFcK6+1VYrPWrB X-Received: by 10.28.221.138 with SMTP id u132mr8146273wmg.113.1512914875185; Sun, 10 Dec 2017 06:07:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512914875; cv=none; d=google.com; s=arc-20160816; b=nqzblBxMGHWTIHgUb3gKOy9XHgqGUFGiHTkltz7MVuluLXXqyFRG1px4cyU3wmgNBo LB0WCySw/Jk2HaI7qasYJCvj/IHHzGuaV5PCZ2fLxwrH7vN5TR/2NcSaLvoVQiwegC7M 1q07wFy6VI2YdN8zs7/VWKSkTzZ0IWuw5z7Mnpr0PXVF40snBpoqIhivX0/m1a+zn5eZ WM1wegWo4YDeleancDmXO80aba7cuFVz+ThKCj83lMpQIsHbbnbwAdDiq/FZc+lnM/k0 wSIVfl63zre9qJQjC6RSVdAAAJUftEaOu6yfoDx0xKLRwAqI78shA44dyJTizYJuOvVi hAgQ== 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=Q6kadqV8q/qN08fsgk8BokHJNQbA2OUumiwDEHBeb04=; b=cTcTJU5uzLnjj1nCdQ3bhn5O+uVNLgWq7zmW9JRuAgYys9sPclKxbAomOtS3njzLpi yjMJiG7YmXu9gM4TF1vYiPD8rTIBwPuRktFRah6vth6I5R94CTf1PYq6xrioSTNk4svl N12MdqLpdzT0tjNuUr1ltKFjX5Ubupu/kokInRiNvX31dYFnOq0VhXlsAHKIAPNHCD1s o4lDHV/NVvHMVJxO9fMZP43cYj9Uy3o+0bd4p+NU25SHVDZCM18eb4KBji8rGI/CQBdW wutJ5+6WT7+SoG0GjOfGUsrx97wiBON5ouz0/s37iGOpa6e1Dd0SqyW5smbGISFA7Owc gcJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=dnd6NwW5; 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 z66si3968976wmb.94.2017.12.10.06.07.54; Sun, 10 Dec 2017 06:07:55 -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=dnd6NwW5; 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 E1C3568A486; Sun, 10 Dec 2017 16:07:42 +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 53A9468A457 for ; Sun, 10 Dec 2017 16:07:34 +0200 (EET) Received: by mail-wr0-f194.google.com with SMTP id o2so14982087wro.5 for ; Sun, 10 Dec 2017 06:07:41 -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=rVqO0mPhSTZDV6ZeSixfaZFQhocpAqpbvYzklq/+LaQ=; b=dnd6NwW5+bOKmqcVa+D6rkHEpQIYPBjud1bOrO65qsv4PdvMZv3wQlTTxiYYHCu2um T8VIz4HbzZEYX7jYeNzrDpiAlxmoy8ag1TBlguX2rMHGaMAHdWgz0HrMx0tlRrLbus6/ HrXGMTUnIgLDET91h756AM/HbhScEqxGduNOf1p/NQZ2Gw5V1CDnIp1lNvQezsIaaNRv NVj+fVQWZEbh/VSjATCAE+3YKfh5Qc0GY2g5465NH4YNJHogqbvIBQ8eOJpQTEqtuzqr +nk/Fz0Jy9vBNhvViXEfI9503gaOz7AOHbXccRaRKZADtj6Kt7kJ5MTwY4JvrvOwm7A9 4lig== 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=rVqO0mPhSTZDV6ZeSixfaZFQhocpAqpbvYzklq/+LaQ=; b=EdMLb/mxCHqqcW9VAGIzalEiPfJNUpwbML3wSDp9t/D5TrqiBiXqi8CY0MZQgtaTGt e7RHawVfIRZcq+wB3fdRtjnV/eimA/fTBsYSBWkpcnRQ+qsD9lRbM5xKPGuYhz6jBhsA MNCA7FAWEgs4Z3AGkuNG+bexPt1oVEp145LwH/pGX+baP+ek4X5/PpXTzLy80CMGuuk3 4FmOHNwlVOmNdH0BQ5UdLTzHgL5Vtxl4OoDhaNkg4X7C9Fd2+AZGN4K8NUWhNm6CGf+I rv+N/W78Sofm8SoxxyZp7SoMxcMdZ+FEQWRyVBEhiQNX3fBVWYTi3iv+ElH5HI/AYWlL LhoA== X-Gm-Message-State: AJaThX4vgGg26poBCwQlowIN/AfQ/jSh8rSUXySq3NzOxC/t5j36Yhh6 IsQVhXWD9gvMty55Hp9MxlhOig== X-Received: by 10.223.171.29 with SMTP id q29mr31328894wrc.141.1512914860986; Sun, 10 Dec 2017 06:07:40 -0800 (PST) Received: from localhost.localdomain ([94.250.174.60]) by smtp.gmail.com with ESMTPSA id m134sm6851813wmg.6.2017.12.10.06.07.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Dec 2017 06:07:40 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Dec 2017 15:06:48 +0100 Message-Id: <20171210140648.27537-2-onemda@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171210140648.27537-1-onemda@gmail.com> References: <20171210140648.27537-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH 03/29] avfilter/buffersrc: recognize color_range as additonal parameter and set it to input link 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 --- libavfilter/buffersrc.c | 18 ++++++++++++++++++ libavfilter/buffersrc.h | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index cd56f8ca45..51a1a9fb49 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -52,6 +52,7 @@ typedef struct BufferSourceContext { int w, h; enum AVPixelFormat pix_fmt; AVRational pixel_aspect; + int color_range; char *sws_param; AVBufferRef *hw_frames_ctx; @@ -109,6 +110,8 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *par s->h = param->height; if (param->sample_aspect_ratio.num > 0 && param->sample_aspect_ratio.den > 0) s->pixel_aspect = param->sample_aspect_ratio; + if (param->color_range > AVCOL_RANGE_UNSPECIFIED) + s->color_range = param->color_range; if (param->frame_rate.num > 0 && param->frame_rate.den > 0) s->frame_rate = param->frame_rate; if (param->hw_frames_ctx) { @@ -279,6 +282,11 @@ static av_cold int init_video(AVFilterContext *ctx) return AVERROR(EINVAL); } + if (!av_color_range_name(c->color_range)) { + av_log(ctx, AV_LOG_ERROR, "Invalid color_range parameter provided.\n"); + return AVERROR(EINVAL); + } + if (!(c->fifo = av_fifo_alloc(sizeof(AVFrame*)))) return AVERROR(ENOMEM); @@ -309,6 +317,15 @@ static const AVOption buffer_options[] = { { "time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V }, { "frame_rate", NULL, OFFSET(frame_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V }, { "sws_param", NULL, OFFSET(sws_param), AV_OPT_TYPE_STRING, .flags = V }, + { "color_range", NULL, OFFSET(color_range), AV_OPT_TYPE_INT, { .i64 = AVCOL_RANGE_UNSPECIFIED }, 0, INT_MAX, V, "range" }, + { "unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, V, "range"}, + { "unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, V, "range"}, + { "limited", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, V, "range"}, + { "tv", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, V, "range"}, + { "mpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, V, "range"}, + { "full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, V, "range"}, + { "pc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, V, "range"}, + { "jpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, V, "range"}, { NULL }, }; @@ -434,6 +451,7 @@ static int config_props(AVFilterLink *link) link->w = c->w; link->h = c->h; link->sample_aspect_ratio = c->pixel_aspect; + link->color_range = c->color_range; if (c->hw_frames_ctx) { link->hw_frames_ctx = av_buffer_ref(c->hw_frames_ctx); diff --git a/libavfilter/buffersrc.h b/libavfilter/buffersrc.h index 0652113f2b..cc32d532c2 100644 --- a/libavfilter/buffersrc.h +++ b/libavfilter/buffersrc.h @@ -114,6 +114,11 @@ typedef struct AVBufferSrcParameters { * Audio only, the audio channel layout */ uint64_t channel_layout; + + /** + * Video only + */ + int color_range; } AVBufferSrcParameters; /**