From patchwork Fri May 5 19:09: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: 41501 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp690541pzb; Fri, 5 May 2023 11:22:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ68az6ba7+OLreASemMkUy2d9BjB9okq6bfWoFR2JfG1chZsh3QDTJATHXBzTLUZg3/PLdp X-Received: by 2002:a17:907:26c6:b0:91f:b13f:a028 with SMTP id bp6-20020a17090726c600b0091fb13fa028mr1774701ejc.34.1683310922336; Fri, 05 May 2023 11:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683310922; cv=none; d=google.com; s=arc-20160816; b=JxcZMYiAPSUGMm1dV+Um05LP63t1X1/NWOOP0ANMKCK5cQVT/9loy7oktBsFwuU1KW KEzXpUBbPWyI9xIIMkVAzMK03+BOdPfmPOSroZdiU9Du+HRvDCeEnVolGUOWZuLFyxOM xPJ1XRf0IYoeUEcTkPn/lL09YW6IDuBGbMXGxaaSLg995uq5kz/7Pm3NKP/lNqNdj+mF XlLJKpS23MFdN8W5mcO99EsiUYXs05prJl7qqb7veCH9ATdDA00aVV1JDbuwZyfW2+mF JLTZbczg4q/1IP1Rio1Wl7IziP7PibhsYdByRte7aR2phevyHT/fkQz1bGtObCTGnBsf uY8A== 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=i/Ql5yBOaLTnnMeO3UnuNKhMMHjT1qC21ceeShMd/aE=; b=0oqwbb5c+WTBTW2EUfT5VospQyfrdCnh7Y1b6LqmkNhAHt9n8+agQAm6hjzePW5xVq YlddZ0pzTR/+aifOtZb5oXKusIaAyGs5EJGU8mMN3i39/0yMfKvZOy5B9X8Er86B3ZSu fI+xuKoT1C2lerrRVJtfKQOwqok37F+qfmMZEz7E2nxDL/71bW6JEtq6zIwBJg+eBs7w v/Nvabr+WexFr7zlh7GtEqA2OEEboLuJia3AsznPSqmmZZvDr+8kbjd0u47+mxyrH1qQ n5nyCCs5JohBmb4oTLv08x0XjZQQYzgSA64mw+KyJ+QvB+JoFwk01iAJkbyRg06U5BOf xN+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ltnglobal-com.20221208.gappssmtp.com header.s=20221208 header.b=GQwQgrzs; 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 g23-20020a1709061e1700b009659c34e845si1557255ejj.166.2023.05.05.11.22.00; Fri, 05 May 2023 11:22:02 -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.20221208.gappssmtp.com header.s=20221208 header.b=GQwQgrzs; 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 5BA8468C186; Fri, 5 May 2023 21:21:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ua1-f51.google.com (mail-ua1-f51.google.com [209.85.222.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C523668BFAF for ; Fri, 5 May 2023 21:21:42 +0300 (EEST) Received: by mail-ua1-f51.google.com with SMTP id a1e0cc1a2514c-77d049b9040so15391829241.1 for ; Fri, 05 May 2023 11:21:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ltnglobal-com.20221208.gappssmtp.com; s=20221208; t=1683310901; x=1685902901; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=VhC2/eK2+zuscWyj1kOpnDgubrv9ynrNIh/81ZaAl1g=; b=GQwQgrzsiyKP9ZDarKBeoLApRi1giLlXDvBDP2KPIIoWYQlxBBtgenMlsKl51G7j6Q yzp7fuJpdc1OKG8pfAl1KR9/Onx2XYT5HUNlDx7sNuk2q5TVD1LyiU6jh7Di9RVktKie 3PY0KTazJxOzS2NQElb2DyVpHus1fpliWBZ1bVL9QxSBGeVbShoFUZvC71sQB4WXptEq gV+bNIz6vmfKaLN3LFWSZcW6OL6jK2EcvDnDQ/QDJJyAZNZz/h1L81kPxHGX9pKzGaN/ AI2e9s51y5XsCGWdeKv2Q/b5A975z11UAgQtoBuR+bjB7JrxFk07ZuDT+NxALZlLXV7D a11Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683310901; x=1685902901; 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=VhC2/eK2+zuscWyj1kOpnDgubrv9ynrNIh/81ZaAl1g=; b=ZenXzqYHscS8jMmH3pbE/oeren5ue6RzusZK9H2b49b9yl9h+24XMv/xeJZUIgUjQy 9Z0+NM2FSXfyP1tg9EyPwJKQDt5HrUBP6PO+t7N4ga8Utcn1b1xxqrmcu2ZqdUKhQgo0 v1lnEcGQHZlhol2KTaXckTi6+41BP/uCgzmMTB8SjaaA6W9ul0JgdogipUklmGSssW2q q4ODhpbc6Quxunclk2ZZdoIuC5Jbywl3WwRLPFQcsQlEpjSGJqS8MVp04EmIf+vYBd8H 6+b9dVZ0tHVHTAc7P9PSkwRhoiOXvWX25bTi9isZNpZQMG4Rh7LVHQ276GyaFW9+YMFX GvOg== X-Gm-Message-State: AC+VfDyaSejQf8Iuf7GVJv1DmDLOTeTLHEUt69gq8gFGaqtGOTo0Kjte MCjm7RAvAuE6jDlqoN8KqXhuerz/4wOGvK2zHPo= X-Received: by 2002:ac8:5848:0:b0:3f2:11db:9658 with SMTP id h8-20020ac85848000000b003f211db9658mr14230868qth.2.1683310401753; Fri, 05 May 2023 11:13:21 -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 d1-20020a05620a166100b0074e26158cf2sm747289qko.93.2023.05.05.11.13.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 May 2023 11:13:21 -0700 (PDT) From: Devin Heitmueller X-Google-Original-From: Devin Heitmueller To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 May 2023 15:09:03 -0400 Message-Id: <1683313747-3775-3-git-send-email-dheitmueller@ltnglobal.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1683313747-3775-1-git-send-email-dheitmueller@ltnglobal.com> References: <1683313747-3775-1-git-send-email-dheitmueller@ltnglobal.com> Subject: [FFmpeg-devel] [PATCH v6 2/6] vf_fps: properly preserve CEA-708 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: CaCvqE8gE1cX The existing implementation made an attempt to remove duplicate captions if increasing the framerate, but made no attempt to handle reducing the framerate, nor did it rewrite the caption payloads to have the appropriate cc_count (e.g. the cc_count needs to change from 20 to 10 when going from 1080i59 to 720p59 and vice-versa). Make use of the new ccfifo mechanism to ensure that caption data is properly preserved. Signed-off-by: Devin Heitmueller --- libavfilter/vf_fps.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c index 051d278..824e7a1 100644 --- a/libavfilter/vf_fps.c +++ b/libavfilter/vf_fps.c @@ -34,6 +34,7 @@ #include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "avfilter.h" +#include "ccfifo.h" #include "filters.h" #include "internal.h" @@ -85,6 +86,7 @@ typedef struct FPSContext { AVFrame *frames[2]; ///< buffered frames int frames_count; ///< number of buffered frames + AVCCFifo *cc_fifo; ///< closed captions int64_t next_pts; ///< pts of the next frame to output @@ -165,6 +167,7 @@ static av_cold void uninit(AVFilterContext *ctx) frame = shift_frame(ctx, s); av_frame_free(&frame); } + ff_ccfifo_freep(&s->cc_fifo); av_log(ctx, AV_LOG_VERBOSE, "%d frames in, %d frames out; %d frames dropped, " "%d frames duplicated.\n", s->frames_in, s->frames_out, s->drop, s->dup); @@ -210,6 +213,11 @@ static int config_props(AVFilterLink* outlink) s->in_pts_off, s->out_pts_off, s->start_time); } + if (!(s->cc_fifo = ff_ccfifo_alloc(outlink->frame_rate, ctx))) { + av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); + return AVERROR(ENOMEM); + } + av_log(ctx, AV_LOG_VERBOSE, "fps=%d/%d\n", outlink->frame_rate.num, outlink->frame_rate.den); return 0; @@ -242,6 +250,7 @@ static int read_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *inlink, av_log(ctx, AV_LOG_DEBUG, "Read frame with in pts %"PRId64", out pts %"PRId64"\n", in_pts, frame->pts); + ff_ccfifo_extract(s->cc_fifo, frame); s->frames[s->frames_count++] = frame; s->frames_in++; @@ -289,7 +298,7 @@ static int write_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *outlin if (!frame) return AVERROR(ENOMEM); // Make sure Closed Captions will not be duplicated - av_frame_remove_side_data(s->frames[0], AV_FRAME_DATA_A53_CC); + ff_ccfifo_inject(s->cc_fifo, frame); frame->pts = s->next_pts++; frame->duration = 1;