From patchwork Wed Dec 6 20:10:22 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: 6568 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp7406631jah; Wed, 6 Dec 2017 12:16:23 -0800 (PST) X-Google-Smtp-Source: AGs4zMZLl/2b17q01vBPNBWf2MAX8ukghF5hYmizLxGKUISx3rLIiQyzfEbcg67hmh6sCwEG0TcN X-Received: by 10.28.193.66 with SMTP id r63mr12311005wmf.18.1512591383787; Wed, 06 Dec 2017 12:16:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512591383; cv=none; d=google.com; s=arc-20160816; b=B/3y9TodSFyoIcj5YKXInqVOim6xh3//FYmPsiDrkl06OL+RBU76SB1kF6bPyEvtQe UWhabtmPApI7uVfajmQDuvhOd7wj8Yfsx2uKCshFLbXH3FnLTvdew/Xl5/QoAZSF2sat DbQkzLD6pCFRIGre6qtNbqPgAbiRJ+EMlYGxEKUx47TDxlWnxExjY/UVI57AsJDySqj7 msR+dAQN56dZtIXQR2rbqgS7iWTZ6MvNYY38XsLzQT5pNF5zvvfSUWtpZXmwdlZHg28i UFzVHkmWLI7aGE/+yGM0qAxK4EAx9h28eM9CqPZrCq+RjScBYUyTP5NkxjnDUb0+zoli 79bA== 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=gLUXK6lurW32TjPefXYAE1Bd8HSrrQx2aEtq3p1K6C0=; b=JJwlOAB6QUNcPFc7wwbU1lNxqvBwuxLKs5Xa64IJC08DnwuK8V/iikqHdbhFtj4xBT TjoYrPwUtBH6gkOgfi/Fgadmf6uhC0/LLw97S1feDUP+7XGa32EkDhkNeq9gN1Xvjeki MoReHy8hfaSQSXk2HDZvsmjAOwNOUCPytt7zQE3+oifyRyp8pNR15mDU5ECTG5Vnnia/ pfLlmog2QNs1/XfExqhrLan4JjLc6d4x31oPhhWQ2p1GzNdPJEaZgN7Y8wawNpTIeJWr TaxxElX+V9csKgc39sLASTbpt5A9MJ0F3gFLOk6d9kUrKLukdyTdV5ni07pPSvL/R5X+ JpSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=jUYmlXyE; 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 e45si2182377wrg.444.2017.12.06.12.16.23; Wed, 06 Dec 2017 12:16:23 -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=jUYmlXyE; 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 23ADD689EE1; Wed, 6 Dec 2017 22:16:16 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A1A746882C2 for ; Wed, 6 Dec 2017 22:16:09 +0200 (EET) Received: by mail-wr0-f193.google.com with SMTP id x49so5174987wrb.13 for ; Wed, 06 Dec 2017 12:16:15 -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=Ee555lqpPnhu4SkkVkcci46q94Uayc4SLrN/WcgjroU=; b=jUYmlXyExzCmOJfEDLK5RzZgeWlADAy9SbaFMhF5zHMTdit8oNFbqtkYej3tvbZ87C tNDlxD5CCWuEbhkNhWIeM3iFJSMzIzt80vsrWUgUvSSBHLvTxNrkZZ6da7yW/nTzf3Nf DdEIxd6vPS5qSVsoNn41RhV6rd1D3FKF4nxOHrcT+GYyfpbxRdDqlkVjEfBjhyyt+7k+ NcuAZMZZeDrn9Ssm1O5KU6Bzd+Ne9mshfhQ4J98YSO0lEGH8HGcLTZjri0sLNrf+DsPo 0W1UK34tjhaUIE7MxDgVeInm0yP6s78dlHsJiTuqbSowmrtxbWxlP6s/1j5Ld8bMVszx iBpQ== 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=Ee555lqpPnhu4SkkVkcci46q94Uayc4SLrN/WcgjroU=; b=S/UClU0XsLsIU/b7HGaAZVMM5GAnQyjNEHYfDw3fN1IRsq+KnqhhbFvEso1h619MpP RE4OWm6u4VPC5dPl+Iyz56K8c/dXGxbcfLafTSHuM0yCYDRHOBJrwwvb23wZ5x4crnAi ri9N9nmjd3P83lMMlaErRFWg5ciRUrTSolFxUq/63uBaOENZjEpckcRhNY1ahR9Xb1aw uHYZCmi8G3V6k3M9ryvRD38oTC+7P+E6c5zONU5R0sx4wNGtDsPSHNQ53mqQoMEXYpW5 NC/ZM5llpQnKRYyfqu+ftmaLDEvNRIaWrX8XAhv5hwGHr9pczF+VegMitFKOkqVM7OIi qL3Q== X-Gm-Message-State: AJaThX4gpuegOfLncz4xR6UiXMSomJ+dFWVuqWUU2ipYGqoBkGns9CFf Dt6TamuwH4q2Guouzsbh7JhDUA== X-Received: by 10.223.184.47 with SMTP id h44mr19374326wrf.11.1512591066546; Wed, 06 Dec 2017 12:11:06 -0800 (PST) Received: from localhost.localdomain ([94.250.174.60]) by smtp.gmail.com with ESMTPSA id 52sm4662782wrv.8.2017.12.06.12.11.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Dec 2017 12:11:05 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Dec 2017 21:10:22 +0100 Message-Id: <20171206201022.11073-2-onemda@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171206201022.11073-1-onemda@gmail.com> References: <20171206201022.11073-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/2] WIP: steps to ditch YUVJ formats 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 --- Does not work! Why? --- fftools/ffmpeg_filter.c | 9 +++++++-- libavfilter/avfilter.c | 2 ++ libavfilter/avfilter.h | 2 ++ libavfilter/buffersink.c | 1 + libavfilter/buffersink.h | 1 + libavfilter/buffersrc.c | 13 +++++++++++++ libavfilter/buffersrc.h | 5 +++++ libavfilter/vf_scale.c | 1 + 8 files changed, 32 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 877fd670e6..7a7d79e334 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -474,6 +474,10 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, av_strlcatf(args, sizeof(args), ":%s=%s", e->key, e->value); } + av_strlcatf(args, sizeof(args), ":out_range=%s:in_range=%s", + av_color_range_name(ost->enc_ctx->color_range), + av_color_range_name(last_filter->inputs[pad_idx]->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 +781,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, diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index b98b32bacb..4a579bb49d 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -336,6 +336,8 @@ int avfilter_config_links(AVFilterContext *filter) link->w = inlink->w; if (!link->h) link->h = inlink->h; + if (!link->color_range) + link->color_range = inlink->color_range; } else if (!link->w || !link->h) { av_log(link->src, AV_LOG_ERROR, "Video source filters must set their output link's " diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 47546c15e5..a5f4df74de 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -448,6 +448,8 @@ struct AVFilterLink { */ AVRational time_base; + int color_range; + /***************************************************************** * All fields below this line are not part of the public API. They * may not be used outside of libavfilter and can be changed and diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index 0f87b5439a..5f3c932d92 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -194,6 +194,7 @@ MAKE_AVFILTERLINK_ACCESSOR(AVRational , frame_rate ) MAKE_AVFILTERLINK_ACCESSOR(int , w ) MAKE_AVFILTERLINK_ACCESSOR(int , h ) MAKE_AVFILTERLINK_ACCESSOR(AVRational , sample_aspect_ratio) +MAKE_AVFILTERLINK_ACCESSOR(int , color_range ) MAKE_AVFILTERLINK_ACCESSOR(int , channels ) MAKE_AVFILTERLINK_ACCESSOR(uint64_t , channel_layout ) diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h index 21d6bb505b..c0acee48d6 100644 --- a/libavfilter/buffersink.h +++ b/libavfilter/buffersink.h @@ -114,6 +114,7 @@ AVRational av_buffersink_get_frame_rate (const AVFilterContext *c int av_buffersink_get_w (const AVFilterContext *ctx); int av_buffersink_get_h (const AVFilterContext *ctx); AVRational av_buffersink_get_sample_aspect_ratio (const AVFilterContext *ctx); +int av_buffersink_get_color_range (const AVFilterContext *ctx); int av_buffersink_get_channels (const AVFilterContext *ctx); uint64_t av_buffersink_get_channel_layout (const AVFilterContext *ctx); diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index cd56f8ca45..67f8bdf158 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 > 0) + 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) { @@ -309,6 +312,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 = 0 }, 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 +446,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..1004121c4e 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; /** diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 2fd9c90d84..be6dcb9307 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -578,6 +578,7 @@ static const AVOption scale_options[] = { { "in_range", "set input color range", OFFSET( in_range), AV_OPT_TYPE_INT, {.i64 = AVCOL_RANGE_UNSPECIFIED }, 0, 2, FLAGS, "range" }, { "out_range", "set output color range", OFFSET(out_range), AV_OPT_TYPE_INT, {.i64 = AVCOL_RANGE_UNSPECIFIED }, 0, 2, FLAGS, "range" }, { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_UNSPECIFIED }, 0, 0, FLAGS, "range" }, + { "unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_UNSPECIFIED }, 0, 0, FLAGS, "range" }, { "full", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_JPEG}, 0, 0, FLAGS, "range" }, { "jpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_JPEG}, 0, 0, FLAGS, "range" }, { "mpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_MPEG}, 0, 0, FLAGS, "range" },