From patchwork Fri Mar 17 20:09:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 40717 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:d046:b0:cd:afd7:272c with SMTP id hv6csp15367pzb; Fri, 17 Mar 2023 13:11:13 -0700 (PDT) X-Google-Smtp-Source: AK7set9GmBvnVgCIIiyAgD2/qW0H2AlCArfXqaR13ZYvBB52mIY/mOB+0kA7gk3EL+BHbRelr1Fg X-Received: by 2002:a50:fe81:0:b0:4fb:5a36:1539 with SMTP id d1-20020a50fe81000000b004fb5a361539mr3846539edt.25.1679083873744; Fri, 17 Mar 2023 13:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679083873; cv=none; d=google.com; s=arc-20160816; b=l781EvkYcp8O3mwrElllCn7zCE5CM6Rn10h6KJXsT6XmuR6i8ZME4LwWmHxkY9srFt PzMgKqeOB71k0zkUXwwzM5wbNtTa9hhW7XA8wAkg1f8WwyKb6mLyU97jhdUkHnyXrMzF K0X7KnKuVXPJHOUP6vA9CQyYDgTg8ztzeXoiYXzdFRGFXZXwC5JSqq3y66MfYwcSXF10 57buBniUtC4iSl4SBV9CpD/pW19PbZVY4bCOdZOGnBOefrJSHmdZUyCWDN+c+OLxmd73 ICLbvSgEw62OPRUJpVLLHkv8enwsqW/jB2l4GOum5jNT8FrCjCGWxN+7TiierZlsLk4s FVGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=BPYRTCjp1JkAXKfV+urP/css97O5YWfiz6PCjBB+Z64=; b=E2yc6XdrO4oQ54/fLVtOxXmerJ2ZV2TGRnPnhWqPM9UaTcIfAmlMw96jk3MxEBGCwt DtMxvECTlhZsHXNNXl6B+U3XN9JsaQf9IFTUz57jV6qmQ+fT69VNPJxr4XZxrnA7hFm7 BM8FxEHzST8Kl3s4kOzGHnPsfOHDMlTQtEbHtauECrl1zyER0Zx7s/mCHuGp0y4xlv1G 5gx1OP8PGD5rZTp5zJ7sa1v7dmNRwmL2coUWM8rN4gP3Gf1siowTq5qjZ3WhthQuQFW3 JRVvLGhfpI8WG4I90xT//NoeRWZX+LsQN918ytAxtpQmao4IKZ1rv2KprAb1lSkO7gPC W6mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ltnglobal-com.20210112.gappssmtp.com header.s=20210112 header.b=xZfaDC4h; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n15-20020aa7db4f000000b004fa39a6af22si3445837edt.445.2023.03.17.13.10.51; Fri, 17 Mar 2023 13:11:13 -0700 (PDT) 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=@ltnglobal-com.20210112.gappssmtp.com header.s=20210112 header.b=xZfaDC4h; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 664D768C277; Fri, 17 Mar 2023 22:09:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6868568C257 for ; Fri, 17 Mar 2023 22:09:50 +0200 (EET) Received: by mail-qt1-f181.google.com with SMTP id i24so6958304qtm.6 for ; Fri, 17 Mar 2023 13:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ltnglobal-com.20210112.gappssmtp.com; s=20210112; t=1679083789; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qWr2BIavd2S5WylSPqSwJnA/Bfz+SM9WD8XI0N1PtRo=; b=xZfaDC4hb5np7RI5JEhBl4gzi4cJnjQlPYLOntmvBCEkzZPfHv/OGCeuc8Bd9iexl7 UAeMed2a5BkpzSejDu4MbA604q9dKQ+45ISdGbnRJtLcQjEzZnDCX5Fo4T7Co0Su9cQp 47Zawgc5N5s/gjck1pINjFG3Sf6Edl1JOagYYaRQ2diuxlU3Z3FrhdUbjmU1fXl/cGtZ gVauoBP+a1IFDKPhOaNXt9j76ePVLqRMEdwzxV/KEy+5TaV9DhNC2uh6TH8nm4cnSog3 QOVNLT/x7n46M+wfP6aFvWmjMAwi6cMD77aBWsTLfPE5aJSryXhHgDIDhq5E1pI5ZTry 3xbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679083789; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qWr2BIavd2S5WylSPqSwJnA/Bfz+SM9WD8XI0N1PtRo=; b=dAFp/nzn5/5AcJF2aSyBoIn+49UKZ4otKHplaWSUXPlMGAQrAiFuyNYY14/9Q2oXSw tNoeK+Fsilpc5cuG2K7eVAUCO8G3dMztW7Sn4Fo1m3olREIIuarLI+0R/oTQYzH1BjRN +/AExenw05yR9E2Q/0+kgRVOuva3CEYwq2E5/POKCiWPoUz03arPuNoTFCxOqIFa/AgE tZMAqKQ8rWqtVHbxQngjlQmtuzWwpWEKhMiuDilXxj9g1KESuPYejRzQx2+jxJcfgUqG eOO8Km92hc28UT7NCSLTo1cQVRmKNoHeuz+TXtg1/aeJtm8/Sj6Urni1UIoYSN3OLlIO RHwA== X-Gm-Message-State: AO0yUKUQsviWSGoG0QCDrU+q/pAgwOQRfP5iM8FF6FjZgdKExLZD789j 6iLVXU43mfWAZRyRBVVQ7Yc6qQv7RydrVlgy3v0= X-Received: by 2002:a05:622a:86:b0:3dc:38e:8f5 with SMTP id o6-20020a05622a008600b003dc038e08f5mr3034845qtw.49.1679083788981; Fri, 17 Mar 2023 13:09:48 -0700 (PDT) Received: from klab-nyc-kernellabs2.localdomain (pool-71-105-132-214.nycmny.fios.verizon.net. [71.105.132.214]) by smtp.gmail.com with ESMTPSA id j5-20020ac86645000000b003bd0e7ff466sm2065685qtp.7.2023.03.17.13.09.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Mar 2023 13:09:48 -0700 (PDT) From: Devin Heitmueller X-Google-Original-From: Devin Heitmueller To: ffmpeg-devel@ffmpeg.org Date: Fri, 17 Mar 2023 16:09:40 -0400 Message-Id: <20230317200941.3936-5-dheitmueller@ltnglobal.com> X-Mailer: git-send-email 2.35.1.655.ga68dfadae5 In-Reply-To: <20230317200941.3936-1-dheitmueller@ltnglobal.com> References: <20230317200941.3936-1-dheitmueller@ltnglobal.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [RFC PATCH 4/5] tinterlace: Properly preserve CEA-708 closed captions 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: Devin Heitmueller Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: MQrDtuSFO96I Because the interlacing filter halves the effective framerate, we need to ensure that no CEA-708 data is lost as frames are merged. Make use of the new ccfifo mechanism to ensure that caption data is properly preserved as frames pass through the filter. Signed-off-by: Devin Heitmueller --- libavfilter/tinterlace.h | 2 ++ libavfilter/vf_tinterlace.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/libavfilter/tinterlace.h b/libavfilter/tinterlace.h index 37b6c10c08..30574c2ebf 100644 --- a/libavfilter/tinterlace.h +++ b/libavfilter/tinterlace.h @@ -30,6 +30,7 @@ #include "libavutil/bswap.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" +#include "libavutil/ccfifo.h" #include "drawutils.h" #include "avfilter.h" @@ -77,6 +78,7 @@ typedef struct TInterlaceContext { const AVPixFmtDescriptor *csp; void (*lowpass_line)(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp, ptrdiff_t mref, ptrdiff_t pref, int clip_max); + AVCCFifo *cc_fifo; } TInterlaceContext; void ff_tinterlace_init_x86(TInterlaceContext *interlace); diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c index 032629279a..260386a889 100644 --- a/libavfilter/vf_tinterlace.c +++ b/libavfilter/vf_tinterlace.c @@ -291,6 +291,9 @@ static int config_out_props(AVFilterLink *outlink) #endif } + if (!(tinterlace->cc_fifo = av_ccfifo_alloc(&outlink->frame_rate, ctx))) + av_log(ctx, AV_LOG_VERBOSE, "Failure to setup CC FIFO queue. Captions will be passed through\n"); + av_log(ctx, AV_LOG_VERBOSE, "mode:%d filter:%s h:%d -> h:%d\n", tinterlace->mode, (tinterlace->flags & TINTERLACE_FLAG_CVLPF) ? "complex" : (tinterlace->flags & TINTERLACE_FLAG_VLPF) ? "linear" : "off", @@ -375,6 +378,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) tinterlace->cur = tinterlace->next; tinterlace->next = picref; + av_ccfifo_extract(tinterlace->cc_fifo, picref); + cur = tinterlace->cur; next = tinterlace->next; /* we need at least two frames */ @@ -390,6 +395,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) if (!out) return AVERROR(ENOMEM); av_frame_copy_props(out, cur); + av_ccfifo_inject(tinterlace->cc_fifo, out); out->height = outlink->h; out->interlaced_frame = 1; out->top_field_first = 1; @@ -423,6 +429,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) if (!out) return AVERROR(ENOMEM); av_frame_copy_props(out, cur); + av_ccfifo_inject(tinterlace->cc_fifo, out); out->height = outlink->h; out->sample_aspect_ratio = av_mul_q(cur->sample_aspect_ratio, av_make_q(2, 1)); @@ -459,6 +466,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) if (!out) return AVERROR(ENOMEM); av_frame_copy_props(out, cur); + av_ccfifo_inject(tinterlace->cc_fifo, out); out->interlaced_frame = 1; out->top_field_first = tff; @@ -481,6 +489,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) out = av_frame_clone(cur); if (!out) return AVERROR(ENOMEM); + av_ccfifo_inject(tinterlace->cc_fifo, out); out->interlaced_frame = 1; if (cur->pts != AV_NOPTS_VALUE) out->pts = cur->pts*2; @@ -495,6 +504,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) if (!out) return AVERROR(ENOMEM); av_frame_copy_props(out, next); + av_ccfifo_inject(tinterlace->cc_fifo, out); out->interlaced_frame = 1; out->top_field_first = !tff;