From patchwork Sat Nov 10 17:46:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 10974 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 43C9644CA76 for ; Sat, 10 Nov 2018 19:46:54 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B46C0689DFA; Sat, 10 Nov 2018 19:46:25 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f98.google.com (mail-io1-f98.google.com [209.85.166.98]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D4AD76899C0 for ; Sat, 10 Nov 2018 19:46:17 +0200 (EET) Received: by mail-io1-f98.google.com with SMTP id y22-v6so3501603ioj.13 for ; Sat, 10 Nov 2018 09:46:54 -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:mime-version :content-transfer-encoding; bh=OlrxNKJ+1HC1EaMUpm2eMuUxuQAQRyCHSG0R0IUZIic=; b=WUQkL0sP1FDghpHHb+oCWom9jsr/VhL9nQPI80w7fFdouNKAHU0TzCNI/Uck/jAK4S jn2Jj54t1/oBGRIuqqsh5Yd+kPtvLM4g3tl/qDhAj+7xMpqoQfYVqQ3vBla45Oqi3rFU ODJ6z1rjnaTk0m1EVECQEPD3lLpm3Yz8+0HQvp4rCGURYtaV7GMI7t3XvU0Cy+t1nlSz 39fiHXypzMTf7edPabSrfUqJ9ln5qH2zVqSWWjRR5AtaMOOTPTbTJsqSNAKQ8ZDkTtHl HL2BzeGHp4aakKjdJjmBUnVWUy2XNTeIqskbodenlKewE7C+5ITfY6tGvyOu5t3bhl4n Dm/w== X-Gm-Message-State: AGRZ1gKvZTNUNycexsDPlLl9X03eFQdz540LnddNH9BfdqWEOTHH1WJo 0vliwXP5sx2MhpvBprYjFnTZUASq55wgNEA5CGJSh16MIrD3vA== X-Google-Smtp-Source: AJdET5fzwPyAW5kdBLkHUmE2tz+uNb1gRz37JbJ0Aeg9MA+fouWEMx7X0hOzPb1DOm/m7YGofrhfFEzblUmM X-Received: by 2002:a6b:b2d8:: with SMTP id b207-v6mr11790090iof.147.1541872013091; Sat, 10 Nov 2018 09:46: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 n69-v6sm378935itb.0.2018.11.10.09.46.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Nov 2018 09:46: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 551D8601A3; Sat, 10 Nov 2018 17:46:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1541872012; bh=jBnMXfbwLFbWqPbFwu9dIbZyK/pbAJUsSywAAxEIKQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DzYCmJLWGRS7WxV1NwypVBWrf5y6BV+/mG/mYKKbKt9TBxJ28MsOTW4O+3oNhdpBg v0LFr6sFLW9l5/mlQ2GMLTuiJhMDY5rWM5L9ShdXb6qJobIOdf8Mw4zpuA7zObDhkf l1v2AuF5mV4B5Qsnaah27WU+Slfh2zmOT/+c+ymbld+OVzw7FT+ALwIF1HoHJ5CFyV xu8GxEWc3AMmPYRU/eh0xqZ29tpwFes6mw0EZ9uIi40o5gFXcDNK9GjBfAnygQGQGu yTAU6AeMX4A/NBBlzWDT0Iq7MXVGpaW03R9klCXlCRjTLx+E6nAzaiCLawW9x6ngPw R3jmbzrOgGnRQ== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Sat, 10 Nov 2018 09:46:40 -0800 Message-Id: <20181110174641.28531-2-philipl@overt.org> In-Reply-To: <20181110174641.28531-1-philipl@overt.org> References: <20181110174641.28531-1-philipl@overt.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avfilter/yadif_common: Add field type tracking to help bwdif 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The bwdif filter can use common yadif frame management if we track when a field is the first or last field in a sequence. While this information is not used by yadif, the added benefit of removing the duplicated frame management logic makes it worth tracking this state in the common code. --- libavfilter/yadif.h | 14 ++++++++++++++ libavfilter/yadif_common.c | 12 +++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/libavfilter/yadif.h b/libavfilter/yadif.h index 32d6f4a0d4..02240a4dac 100644 --- a/libavfilter/yadif.h +++ b/libavfilter/yadif.h @@ -41,6 +41,12 @@ enum YADIFDeint { YADIF_DEINT_INTERLACED = 1, ///< only deinterlace frames marked as interlaced }; +enum YADIFCurrentField { + YADIF_FIELD_LAST = -1, ///< The last field in a sequence + YADIF_FIELD_FIRST = 0, ///< The first field in a sequence + YADIF_FIELD_NORMAL = 1, ///< A normal field in the middle of a sequence +}; + typedef struct YADIFContext { const AVClass *class; @@ -70,6 +76,14 @@ typedef struct YADIFContext { int eof; uint8_t *temp_line; int temp_line_size; + + /* + * An algorithm that treats first and/or last fields in a sequence + * differently can use this to detect those cases. It is the algorithm's + * responsibility to set the value to YADIF_FIELD_NORMAL after processing + * the first field. + */ + int current_field; ///< YADIFCurrentField } YADIFContext; void ff_yadif_init_x86(YADIFContext *yadif); diff --git a/libavfilter/yadif_common.c b/libavfilter/yadif_common.c index 19e8ac5281..213eca5396 100644 --- a/libavfilter/yadif_common.c +++ b/libavfilter/yadif_common.c @@ -44,6 +44,8 @@ static int return_frame(AVFilterContext *ctx, int is_second) av_frame_copy_props(yadif->out, yadif->cur); yadif->out->interlaced_frame = 0; + if (yadif->current_field == YADIF_FIELD_LAST) + yadif->current_field = YADIF_FIELD_FIRST; } yadif->filter(ctx, yadif->out, tff ^ !is_second, tff); @@ -103,9 +105,12 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame) yadif->cur = yadif->next; yadif->next = frame; - if (!yadif->cur && - !(yadif->cur = av_frame_clone(yadif->next))) - return AVERROR(ENOMEM); + if (!yadif->cur) { + yadif->cur = av_frame_clone(yadif->next); + if (!yadif->cur) + return AVERROR(ENOMEM); + yadif->current_field = YADIF_FIELD_FIRST; + } if (checkstride(yadif, yadif->next, yadif->cur)) { av_log(ctx, AV_LOG_VERBOSE, "Reallocating frame due to differing stride\n"); @@ -173,6 +178,7 @@ int ff_yadif_request_frame(AVFilterLink *link) if (!next) return AVERROR(ENOMEM); + yadif->current_field = YADIF_FIELD_LAST; next->pts = yadif->next->pts * 2 - yadif->cur->pts; ff_yadif_filter_frame(ctx->inputs[0], next);