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 E442640169 for ; Thu, 3 Nov 2022 14:40:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BD5F968BF99; Thu, 3 Nov 2022 16:40:39 +0200 (EET) Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7EE7068B909 for ; Thu, 3 Nov 2022 16:40:33 +0200 (EET) MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nodoa.me; s=key1; t=1667486432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yyb7Xy0Y7QUl9cmCJimzmzyT00gspiPuXHb6Ey6Xx60=; b=mGUjuUwT/AgaODr4loOBXquGycF5QdMkFeHs5aLSYbAvn276QkNBxNrsbjLPDF1I9Bs08B gtsVzsUfDYks0HOtBsooJnEIjuGw8nlXUWhAIJu6aj6oLEXMGjWNw7LgRN2APekb2nMuQq 9HdriKMIkZGV2UCG3hCtqMCeoe7ggNU= Date: Thu, 03 Nov 2022 14:40:31 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: mail@nodoa.me Message-ID: <399842a707482604827e62860e98cb37@nodoa.me> To: ffmpeg-devel@ffmpeg.org X-Migadu-Flow: FLOW_OUT Subject: [FFmpeg-devel] [PATCH] lavfi/vf_fieldmatch: keep fields as-is if not matched properly 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 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: Makes it possible to use deinterlacers which output one frame for each field as fallback if field matching fails (combmatch=full). Currently, the documented example with fallback on a post-deinterlacer will only work in case the deinterlacer outputs one frame per first field (as yadif=mode=0). The reason for that is that fieldmatch will attempt to match the second field regardless of whether it recognizes the end result is still interlaced. This produces garbled output with for example mixed telecined 24fps and 60i content combined with a field-based deinterlaced such as yadif=mode=1. This patch orders fieldmatch to revert to using the second field of the current frame in case the end result is still interlaced and a post-deinterlacer is assumed to be used. Signed-off-by: lovesyk --- libavfilter/vf_fieldmatch.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_fieldmatch.c b/libavfilter/vf_fieldmatch.c index 40e559df9e..bf946beec9 100644 --- a/libavfilter/vf_fieldmatch.c +++ b/libavfilter/vf_fieldmatch.c @@ -680,7 +680,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVFilterLink *outlink = ctx->outputs[0]; FieldMatchContext *fm = ctx->priv; int combs[] = { -1, -1, -1, -1, -1 }; - int order, field, i, match, sc = 0, ret = 0; + int order, field, i, match, interlaced_frame, sc = 0, ret = 0; const int *fxo; AVFrame *gen_frames[] = { NULL, NULL, NULL, NULL, NULL }; AVFrame *dst = NULL; @@ -793,6 +793,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } } + /* keep fields as-is if not matched properly */ + interlaced_frame = combs[match] >= fm->combpel; + if (interlaced_frame && fm->combmatch == COMBMATCH_FULL) { + match = mC; + } + /* get output frame and drop the others */ if (fm->ppsrc) { /* field matching was based on a filtered/post-processed input, we now @@ -813,7 +819,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) /* mark the frame we are unable to match properly as interlaced so a proper * de-interlacer can take the relay */ - dst->interlaced_frame = combs[match] >= fm->combpel; + dst->interlaced_frame = interlaced_frame; if (dst->interlaced_frame) { av_log(ctx, AV_LOG_WARNING, "Frame #%"PRId64" at %s is still interlaced\n", outlink->frame_count_in, av_ts2timestr(in->pts, &inlink->time_base)); -- 2.34.2 _______________________________________________ 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".