From patchwork Mon Mar 27 16:47:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 40879 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:7a30:b0:df:834d:2c1a with SMTP id t48csp1485520pzh; Mon, 27 Mar 2023 09:47:57 -0700 (PDT) X-Google-Smtp-Source: AKy350ZAF/VpVYyx9RiMF4EMzsKC36wIaOtvj+RiUB5nT0TE+E8doL5BtsibCt/z2C+2hvbmWSNF X-Received: by 2002:a17:907:c608:b0:92b:e1ff:be4e with SMTP id ud8-20020a170907c60800b0092be1ffbe4emr14012750ejc.1.1679935677565; Mon, 27 Mar 2023 09:47:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679935677; cv=none; d=google.com; s=arc-20160816; b=sI/wXWcQIRSR8BmCPbzDCCCwoAZcdURQnS8Agf+84cJJTeheNv8gEevRa7fpL/z1R3 pAjjPtIdM7gC8BdgyOxYp0NDLGmJ8isKKroHLVReKZbbj4PlXfSmK2RPIUUO7yfosPzs TX4PLzy6UdE5DMBm3YjPs4m9J2GgwvJrIIe0pnEzoCDq3ZT3X15YNKQfHHGRMsB2GOOa h/qCk9XKGHnn0rsDLi73w79oGNUWCkoZSvPi44+j0AdQcGDQe1QtMkHRahwIHjwzI31p IJtssbdh0XwFobsaN2jbz8noAd+64ouORxX2u4mY2zV5vWneO2ycFJMbj+MlXshaghXJ 6YhQ== 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=7hHfzJO6vyBRj9dk7sPHVZQAgh3KLg9bCg0MOrvMnq8=; b=AwdhANIsr4YxeRVe4OKdZxHO4DnCCfFmPj5tXQNZp7MMwPqEwFXNUCSTBe+G/Fia4i 6EFZ9dJ5hnDFu8bMbCZRV711W9Nc6u7zz443nH2LLbsDWVv1NNHhbONRCIu83OYXFz2/ Ur7wTw2E7fFyJPiDvxfuFBEugdJR/IQnJWjM5fyPXPEwbFGv2mMsLgcO6+tR4u1c/F8x 32ZTanM9I6uo5j2ConAwcwlGd0d6KJtLXcue1A3HkSZVq7pyLW79fSnsvYCH0ZUgsc3q S+LpQTtHkGX4nnRAzx59IeYyqkLHSNQyDfWkBX4v6LcGa8lvmdhCo9fkfyGnkiDKVLBL A3mg== 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=bK2i4gvx; 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 w17-20020a170906131100b009332b99a1d0si22499697ejb.857.2023.03.27.09.47.57; Mon, 27 Mar 2023 09:47:57 -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=bK2i4gvx; 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 BFC0768CB51; Mon, 27 Mar 2023 19:47:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 84DFE68C9B9 for ; Mon, 27 Mar 2023 19:47:12 +0300 (EEST) Received: by mail-qv1-f41.google.com with SMTP id l7so7189694qvh.5 for ; Mon, 27 Mar 2023 09:47:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ltnglobal-com.20210112.gappssmtp.com; s=20210112; t=1679935631; 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=iwdsU5mMAz/VMxFzInA2ah2sSGhpvxB7qxJWVBiiXwI=; b=bK2i4gvxYJyNIEed95yXgJ6CjbO3N+M21Kk2uAEGktyygojRzlQdjzIXp+Sdv4VtBC UmFwABu302x3m1i8B9TanrtdqSQpfdtET63nAvBmHMHuby9fNirDXZ3wqWQPsBZchDC2 qW3KcCjCATh5X7CiJvkJwgLwME6kwNNfB0NfBDTQXyxKpVv9dFYMx9Llw+VHGkRh8Igj y7DurhpbFbNDfCfzWGft11t0+eS/r3OKTeup2soancnLUnvfkMYfQrkVo1Vl0NF9dU8N WxYL6tAhOa9H5sue3d0ybm4pUileGtVljlA6k9Tb+eldVMkTXqNxETPzWQpvGKcDzVsI zPEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679935631; 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=iwdsU5mMAz/VMxFzInA2ah2sSGhpvxB7qxJWVBiiXwI=; b=4T9CVbH+1FdmnaTuDLqUa+VEBVfWZWVN4yxEJVwExj7tnxkxE0xPVSqd0Fvxqj5rUi Ie4StVeb+/zlN5LpjpY3aK87kQgEHWZ77NMXQyh/LYr0PMRwuQ0NfVILovqEn3Y1v+sj Oda+TJ4R1MxTCr5x4fV7v6mCLHdHuZ21/WkJA7rK1YqsGrNFt/F76CwwhL9Arve04S3g yTln0bma4QXElWkysHC2GgOgRdKRZT5WmgmYHBF0K6CPpj5od7JMzofgH8W2LwQ2F6sc 0pgW0ttKrG+Lix8DVgZaVoT+w0o/YR2SzpJEH1gmY8KhRvV2/jDAD+aKfEO7tj2eW9q5 w4ag== X-Gm-Message-State: AAQBX9e2OUKQ0OLMB+R2788PXMZWTHgDzr42DCuKpOfoKQ0vC5V4YEI/ /xRtXXNSRNVyyNjJEWX0Gs42S4o5FjcHb9+IPOA= X-Received: by 2002:a05:6214:2506:b0:5c7:31af:2ea2 with SMTP id gf6-20020a056214250600b005c731af2ea2mr24328298qvb.12.1679935631137; Mon, 27 Mar 2023 09:47:11 -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 lf10-20020a0562142cca00b005dd8b9345e9sm3093100qvb.129.2023.03.27.09.47.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2023 09:47:10 -0700 (PDT) From: Devin Heitmueller X-Google-Original-From: Devin Heitmueller To: ffmpeg-devel@ffmpeg.org Date: Mon, 27 Mar 2023 12:47:03 -0400 Message-Id: <20230327164704.12962-5-dheitmueller@ltnglobal.com> X-Mailer: git-send-email 2.35.1.655.ga68dfadae5 In-Reply-To: <20230327164704.12962-1-dheitmueller@ltnglobal.com> References: <20230327164704.12962-1-dheitmueller@ltnglobal.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [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: 1nt/cHTMS6bR 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. Thanks to Thomas Mundt for review and noticing a couple of missed codepaths for injection on output. Signed-off-by: Devin Heitmueller --- libavfilter/tinterlace.h | 2 ++ libavfilter/vf_tinterlace.c | 8 ++++++++ 2 files changed, 10 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..226983c645 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 */ @@ -451,6 +456,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) if (!out) return AVERROR(ENOMEM); out->pts /= 2; // adjust pts to new framerate + av_ccfifo_inject(tinterlace->cc_fifo, out); ret = ff_filter_frame(outlink, out); return ret; } @@ -486,6 +492,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) out->pts = cur->pts*2; out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base); + av_ccfifo_inject(tinterlace->cc_fifo, out); if ((ret = ff_filter_frame(outlink, out)) < 0) return ret; @@ -521,6 +528,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base); out->duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); + av_ccfifo_inject(tinterlace->cc_fifo, out); ret = ff_filter_frame(outlink, out); return ret;