From patchwork Fri Apr 7 21:58:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 41017 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp627832pzb; Fri, 7 Apr 2023 14:03:51 -0700 (PDT) X-Google-Smtp-Source: AKy350aHbKO0BLBsfOR+KBbPl0VI6U+lCnTC/JAjdMyzVQfnRuSoA7unX7VOO6KsN7VRYW4+vukg X-Received: by 2002:a17:906:9bf5:b0:8b0:ad0b:7ab8 with SMTP id de53-20020a1709069bf500b008b0ad0b7ab8mr609958ejc.14.1680901430994; Fri, 07 Apr 2023 14:03:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680901430; cv=none; d=google.com; s=arc-20160816; b=eqhEudfPjbztHXeP20LoTcMnQ9pDmLhMgpqYstAY17+d3Lmkl/IA7DVuC09TXiwZvN P+PNoEgF6qFQP4VGbmAKAcpczDhUs8e5eaJPmgK0qYgfYa2etgbeEnUDIcu7sjNg89FW KQRX+iYju3lwtDm+1P/XTGaEY7jzBSBMEWU4U/EDG4+CxnD+78pxLP2t5IW5Qg1VjLBX FlkoSzYTX9oEHpiaqCqkTNU0N3sHIrswAWKEr7kTQq7X8UW7mAIJok/chiCduXvV8FO+ PbzqL2TTnjH1S0kpalKwCk9CsQbmnYPRZTHgjKjr2phoCuVo4Krl4BcCvwlL0eEGjPPO qdqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=o3gYJwzzWZW9ND3pJnmcEXkpItJyKfeYKhyvWadQJLI=; b=0yUZHQ/d8IamF90psxByt047Q8rJJaUZWjKD1bk+CQ9ntsKJpNmaGNxUFdczZmJc9m mKIjUyYyzTK3sQueFPLr23MYk78+l7tSr9fFeZQUwQGJRXAJhIPUtPS4NJyt8Vgmwjen T0TQDwM14FRt/QVlI66m+R5ShV05I3dQdf146o2BVAkdL89I+RuNRFGpLYE7X8tlh0g5 JYmKd0ioBbWDjj8qLLYcCbreb4Cy909TDS0SgeGWV+Hxbmovew36X8aX1ZBfPUgQV1Ch ObTFD9iYkkcaPpIHFM6pH34TQ9TIYZrcwZ5kslfn9sOd3nU5mGDdKvxps9KKy6Gydw/D jjHQ== 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=b9+JWZAz; 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 k23-20020a170906681700b008f100fd5096si4080480ejr.887.2023.04.07.14.03.50; Fri, 07 Apr 2023 14:03:50 -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=b9+JWZAz; 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 DAD3868BAEC; Sat, 8 Apr 2023 00:03:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A79AE68B6CA for ; Sat, 8 Apr 2023 00:03:05 +0300 (EEST) Received: by mail-qv1-f43.google.com with SMTP id kj14so4638qvb.12 for ; Fri, 07 Apr 2023 14:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ltnglobal-com.20210112.gappssmtp.com; s=20210112; t=1680901384; x=1683493384; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=rRpMBNpUWem3BV21BZG3HkzeATIVq7Xa7cR2Qq7/quo=; b=b9+JWZAzyw4urCUMOBkC2w/kkQsrutUXVb+q1ItC0IKrryDxk5WO3NxAWF74mRgyl3 350U5GJr52/WNTUpiAFfmWZEfoZ5svtB3N2r7hBu6WekG5iJqlriGMeh6s7c8x5oT/Wd X6n3pOc7gsR2/ImdbVpNPIZ8nDIPc1xoVh5J2R983V15fqsOJ7sW0K5yLhnSQBtjuBsv aZi2RRbGLckDnw7ZBJoTpEmwcmZGI8A6RsY8+AqcmiWIQADYXVlneis5yQ+8dvgQxgMW ofK9x/VrJ7RUyme8vU8VcevB0sH3DdfK75bsM0JFenH2WVkckVRhFK8kE+Ot9JVOAlCl Vy1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680901384; x=1683493384; h=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=rRpMBNpUWem3BV21BZG3HkzeATIVq7Xa7cR2Qq7/quo=; b=eQ8aWEzcDFif2b2+wBl05Y/4Gh/V4qe1lnxodW6EnJIxasjJeoyQLtnBJttY/rQqdv GEflkRUHFy7b3FLkD93F1yONwaky847BBt96YHdI2RwINGfer3JbQzWxfeVT2n6mm1QC hH6qb7kJkPk/L0Ab5YDvCiCHyisUVjDvH8z5btSLM4m39sbyJS5S/K5MAl9gwo5WabMS O/3hOi8Qy8fw8Gjf4GINWCAVcFWT0jzaL+pvyAePD4A02DnukKr9WMnd+f+1wF6+IQxd BkXbYJN+RRlCOfdYKPu33pbjtt7rwOjgsvDEP/K/Cd3kLcK/xEEjVCKu215DjO/0080t wlvA== X-Gm-Message-State: AAQBX9ehcTi3xEG7Q8FWvh40NlzyyOEdm6SBQ5yRBPfWPO2q9vHovqMd 7UfkusHt3smZUeQanu2bwxLEQceAepBg0jAK0+M= X-Received: by 2002:a05:6214:1316:b0:5cb:ab2e:b15c with SMTP id pn22-20020a056214131600b005cbab2eb15cmr7556145qvb.30.1680901384230; Fri, 07 Apr 2023 14:03:04 -0700 (PDT) Received: from ltnt-nyc-580testdevin.livetimenet.com (pool-71-105-132-214.nycmny.fios.verizon.net. [71.105.132.214]) by smtp.gmail.com with ESMTPSA id z13-20020ad4414d000000b005dd8b9345d8sm1405143qvp.112.2023.04.07.14.03.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Apr 2023 14:03:03 -0700 (PDT) From: Devin Heitmueller X-Google-Original-From: Devin Heitmueller To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Apr 2023 17:58:28 -0400 Message-Id: <1680904709-25951-5-git-send-email-dheitmueller@ltnglobal.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1680904709-25951-1-git-send-email-dheitmueller@ltnglobal.com> References: <1680904709-25951-1-git-send-email-dheitmueller@ltnglobal.com> Subject: [FFmpeg-devel] [PATCH v2 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: OdPY1oQkyigm 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 37b6c10..9f5ce7e 100644 --- a/libavfilter/tinterlace.h +++ b/libavfilter/tinterlace.h @@ -32,6 +32,7 @@ #include "libavutil/pixdesc.h" #include "drawutils.h" #include "avfilter.h" +#include "ccfifo.h" #define TINTERLACE_FLAG_VLPF 01 #define TINTERLACE_FLAG_CVLPF 2 @@ -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 0326292..226983c 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;