From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C0CD940D3A for ; Fri, 16 Dec 2022 16:15:52 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8695968BA97; Fri, 16 Dec 2022 18:15:48 +0200 (EET) Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ED591680396 for ; Fri, 16 Dec 2022 18:15:41 +0200 (EET) Received: by mail-pg1-f182.google.com with SMTP id w37so2082551pga.5 for ; Fri, 16 Dec 2022 08:15:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=VxlKTaSeZhKnj72BzEe0Se6QpAidQzLJjdZNiZuywu0=; b=myzg6dfiAOVdPRjwJ02vuh9hkU3+KwAXQf0Lbjy2+zolLtzAPTnvfRVNR4CiEraR53 FWff66LO7hbm0VfdODd27vHT2uI/O/+IXuO2hu8rUm95QATvwSXIf9yYHBIteLPCanvo w5a+uNBYmEQpfWgKbgPMnt/ak8fUQ0uVoKysG2r4yXHmWqgCCILNjM81q2YMatolAiSs ekyS/KVv8zUdVKnolNtMVxHkf9Xn0IW3TBcoYkV2y4P1pL3JTEv8ltnrSkx8rcmvVHdV TkrjeJC9CK+6bBnZ//M+CC4bhytpz/nDb8Kjhx9xaPt2nRcV84LGlyvvvdhdARIwYesJ 5N3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VxlKTaSeZhKnj72BzEe0Se6QpAidQzLJjdZNiZuywu0=; b=Ao6Je6gG0Dx1QZimDPx8eByTmlt9s7RJDKTR9q47oq+6KxLQuF2c1g9jgR+x+SB9CK B8HJRYI9shEzK4qGEaMffZ+Pe34nFjKqs7MGwmPyhRw1c+bivg4VRQdaok7fO8jUOnaB Nbs3+znCuxpEXOyZ9eszKgpjFI638tii1RhuKM4gpyrJEnQ3cjkfRDZyMfO9b7bycEl2 fQDWANPQFEsd61vptFf9Hc4yEfek6PIN05vD/lhML29rZFS0b51kvQj4HGv9v+hk5XXM wd5Y/tQHzICFJX6bR3WZ9jDAaHWagJYISICVGEWJeKUZcDnINEsBVm33/vgKiHp+1hpe H+jA== X-Gm-Message-State: ANoB5pkb0I6gV3oEm8PMIRtn+1un2GI0ygAb6rzR/wnz4/Gxpyh/2F+E /Dso5W4G2rOS8vaA+23QphmiptvYJLOSuJ6pgjwgNTKT X-Google-Smtp-Source: AA0mqf7USWZRfdTcrR7MEAOjwz/K2Uc8WVhUCnR4MWdpOCQQyCcOU+21QRq9cEz4FkcEGX8QtlAe3p4xcOM9rcSqSa0= X-Received: by 2002:a63:5910:0:b0:477:2793:f821 with SMTP id n16-20020a635910000000b004772793f821mr88315451pgb.150.1671207339184; Fri, 16 Dec 2022 08:15:39 -0800 (PST) MIME-Version: 1.0 References: <20221209002806.22424-1-ffmpeg@haasn.xyz> <20221209002806.22424-2-ffmpeg@haasn.xyz> In-Reply-To: <20221209002806.22424-2-ffmpeg@haasn.xyz> From: Thomas Mundt Date: Fri, 16 Dec 2022 17:15:40 +0100 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_tinterlace: support full-range YUV X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Niklas Haas Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Am Fr., 9. Dez. 2022 um 01:28 Uhr schrieb Niklas Haas : > From: Niklas Haas > > This filter, when used in the "pad" mode, currently makes the > distinction between limited and full range solely by testing for YUVJ > pixel formats at link setup time. This is deprecated and should be > improved to perform the detection based on the per-frame metadata. > > In order to make this distinction based on color range metadata, which > is only known at the time of filtering frames, for simplicity, we simply > allocate two copies of the "black" frame - one for limited range and the > other for full range metadata. This could be done more dynamically (e.g. > as-needed or simply by blitting the appropriate pixel value directly), > but this change is relatively simple and preserves the structure of the > existing code. > > This commit actually fixes a bug in FATE - the new output is correct for > the first time. The previous md5 ref was of a frame that incorrectly > combined full-range pixel data with limited-range black fields. The > corresponding result has been updated. > > Signed-off-by: Niklas Haas > --- > libavfilter/tinterlace.h | 2 +- > libavfilter/vf_tinterlace.c | 26 ++++++++++++++------ > tests/ref/fate/filter-pixfmts-tinterlace_pad | 2 +- > 3 files changed, 20 insertions(+), 10 deletions(-) > > diff --git a/libavfilter/tinterlace.h b/libavfilter/tinterlace.h > index 4059ebf81a..37b6c10c08 100644 > --- a/libavfilter/tinterlace.h > +++ b/libavfilter/tinterlace.h > @@ -70,7 +70,7 @@ typedef struct TInterlaceContext { > int vsub; ///< chroma vertical subsampling > AVFrame *cur; > AVFrame *next; > - uint8_t *black_data[4]; ///< buffer used to fill padded lines > + uint8_t *black_data[2][4]; ///< buffer used to fill padded lines > (limited/full) > int black_linesize[4]; > FFDrawContext draw; > FFDrawColor color; > diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c > index 7c54861de4..032629279a 100644 > --- a/libavfilter/vf_tinterlace.c > +++ b/libavfilter/vf_tinterlace.c > @@ -201,7 +201,8 @@ static av_cold void uninit(AVFilterContext *ctx) > > av_frame_free(&tinterlace->cur ); > av_frame_free(&tinterlace->next); > - av_freep(&tinterlace->black_data[0]); > + av_freep(&tinterlace->black_data[0][0]); > + av_freep(&tinterlace->black_data[1][0]); > } > > static int config_out_props(AVFilterLink *outlink) > @@ -225,14 +226,22 @@ static int config_out_props(AVFilterLink *outlink) > int ret; > ff_draw_init(&tinterlace->draw, outlink->format, 0); > ff_draw_color(&tinterlace->draw, &tinterlace->color, black); > - if (ff_fmt_is_in(outlink->format, full_scale_yuvj_pix_fmts)) > - tinterlace->color.comp[0].u8[0] = 0; > - ret = av_image_alloc(tinterlace->black_data, > tinterlace->black_linesize, > + /* limited range */ > + if (!ff_fmt_is_in(outlink->format, full_scale_yuvj_pix_fmts)) { > + ret = av_image_alloc(tinterlace->black_data[0], > tinterlace->black_linesize, > + outlink->w, outlink->h, outlink->format, > 16); > + if (ret < 0) > + return ret; > + ff_fill_rectangle(&tinterlace->draw, &tinterlace->color, > tinterlace->black_data[0], > + tinterlace->black_linesize, 0, 0, > outlink->w, outlink->h); > + } > + /* full range */ > + tinterlace->color.comp[0].u8[0] = 0; > + ret = av_image_alloc(tinterlace->black_data[1], > tinterlace->black_linesize, > outlink->w, outlink->h, outlink->format, 16); > if (ret < 0) > return ret; > - > - ff_fill_rectangle(&tinterlace->draw, &tinterlace->color, > tinterlace->black_data, > + ff_fill_rectangle(&tinterlace->draw, &tinterlace->color, > tinterlace->black_data[1], > tinterlace->black_linesize, 0, 0, outlink->w, > outlink->h); > } > if (tinterlace->flags & (TINTERLACE_FLAG_VLPF | TINTERLACE_FLAG_CVLPF) > @@ -360,7 +369,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *picref) > AVFilterLink *outlink = ctx->outputs[0]; > TInterlaceContext *tinterlace = ctx->priv; > AVFrame *cur, *next, *out; > - int field, tff, ret; > + int field, tff, full, ret; > > av_frame_free(&tinterlace->cur); > tinterlace->cur = tinterlace->next; > @@ -418,6 +427,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *picref) > out->sample_aspect_ratio = av_mul_q(cur->sample_aspect_ratio, > av_make_q(2, 1)); > > field = (1 + outlink->frame_count_in) & 1 ? FIELD_UPPER : > FIELD_LOWER; > + full = out->color_range == AVCOL_RANGE_JPEG || > ff_fmt_is_in(out->format, full_scale_yuvj_pix_fmts); > /* copy upper and lower fields */ > copy_picture_field(tinterlace, out->data, out->linesize, > (const uint8_t **)cur->data, cur->linesize, > @@ -425,7 +435,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *picref) > FIELD_UPPER_AND_LOWER, 1, field, > tinterlace->flags); > /* pad with black the other field */ > copy_picture_field(tinterlace, out->data, out->linesize, > - (const uint8_t **)tinterlace->black_data, > tinterlace->black_linesize, > + (const uint8_t > **)tinterlace->black_data[full], tinterlace->black_linesize, > inlink->format, inlink->w, inlink->h, > FIELD_UPPER_AND_LOWER, 1, !field, > tinterlace->flags); > break; > diff --git a/tests/ref/fate/filter-pixfmts-tinterlace_pad > b/tests/ref/fate/filter-pixfmts-tinterlace_pad > index 81a6961215..29321e542b 100644 > --- a/tests/ref/fate/filter-pixfmts-tinterlace_pad > +++ b/tests/ref/fate/filter-pixfmts-tinterlace_pad > @@ -1,4 +1,4 @@ > -gray 7ef396fecd8d1c9fe32173e4415ba671 > +gray 227a6fe36a31fbef80210823454131ea > yuv410p 35bc11d0d32efc9e9a969be7d720f4e6 > yuv411p 17ef3cd22a74f7368b5e02f68779f294 > yuv420p 93d5b6a4c44d67e4d4447e8dd0bf3d33 > -- > 2.38.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > Looks OK for me. Regards, Thomas _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".