From patchwork Mon Mar 27 16:47:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 40877 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:7a30:b0:df:834d:2c1a with SMTP id t48csp1485315pzh; Mon, 27 Mar 2023 09:47:40 -0700 (PDT) X-Google-Smtp-Source: AKy350aKyq13eEb4XafMO5Q9B2jEkk4XQVofyy0RnJeTk+cgjQ7U7Gf8cOwp9A06M/ywWFRDZtnz X-Received: by 2002:aa7:c7d4:0:b0:500:40b5:193a with SMTP id o20-20020aa7c7d4000000b0050040b5193amr12945737eds.17.1679935659821; Mon, 27 Mar 2023 09:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679935659; cv=none; d=google.com; s=arc-20160816; b=EhQSBSZtnS9WCk8ywqH27YfnLF699p1N0tnQT1ehUCH0s6jPO/QOUaFfsr9QCucwoa 41tCzbeQ4njS5oQFBRKlYvAI7UV1bikZEopZ59wy+rpRWWH8chyD9GFoEDrSt+syx1oZ b8qDI84gXRnptlkuLHbhrFWNoeiI7r6Xuc3srz6HyGdt/+JgNSKEiKAkMQYlSe9bVDVl W4GU+vKuYrTpd414iXo6cqSoWayFofPigrksEhnbZLJgwLiBdVUMaR2r4KYMmvi1L8DS laUtKOIpP+iSDxT6vCyIfmyPukvY0JPaVUow58qVpR/BESZiIMVqcRE8kv5boFh7argl j0MA== 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=hcxQZapIfB9EBl7f3v+zeTIdJ8VNYml2c3EUUJOHx7A=; b=O8dNfEqG4PSzeGBVD5/FgTMy5wuMGxS4xvk0cAtrqDae6Z4R9SRF747+HextkSilgE Pyg9JpYOvTEQxhHN00Cs5bWYzNegwitg+F1+mvOEq4cSS+3Cf8ZgxuRs7KtV26YDTgud y0iarlvbqwHafbYHNHRa21FE527psAskLZpdnDlkafFRoemoo+kag+2DSMudTjxPUALt fYJX+Xt0ARLIwlc8w/9rq7gM1y3C+r6w07gqpSuTORw4giZgiZ8lV7VpI9JGynLjRbQR U84vmGLTApidZyScsjhAM+LDNysMorSqp8l1GN5ftJuOAwXzIZxrLZNzwBusQsuRqGPq AgcQ== 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=rKwc40Pr; 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 bu2-20020a170906a14200b008d7fab1c562si21248428ejb.115.2023.03.27.09.47.39; Mon, 27 Mar 2023 09:47:39 -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=rKwc40Pr; 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 9AA9C68CB27; Mon, 27 Mar 2023 19:47:19 +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 3959E68C570 for ; Mon, 27 Mar 2023 19:47:11 +0300 (EEST) Received: by mail-qv1-f41.google.com with SMTP id m6so7299690qvq.0 for ; Mon, 27 Mar 2023 09:47:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ltnglobal-com.20210112.gappssmtp.com; s=20210112; t=1679935630; 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=0bCQOPrmDxAb+8BhhkfSXibGnT/xgDHTuqXZh1Sn7iE=; b=rKwc40Pr0AW2sbvcSKkrP8FDkyoLhe1os2iDkGkF+jtEmacTmnN2ot7Ll//Zx6WD6v 819OebJlFmHm7bNmZNpE0FoRI2V+NRPMjqE4IWv71V2ZmwTEKrGySlMOMNYuFFiLtu0w +PWTk9XC9PI+uPoYKL3JIRbpE/18bw62140Alcqp3xeEDa2aNE+y0upg9908S96QDnx4 38RTGSsM5bTq+Qb5VJYlNS36IygOZv/GV49gEBr/iyYmEMjBjIz3mIVnmBtjL/E/RNYC dPOE7pIpCspDdNL8Bzj8hLQMBZ7+Ssg/Ctoq200vYdCUCBsHPFsC+8nicXAXj+5OhO/c R58Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679935630; 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=0bCQOPrmDxAb+8BhhkfSXibGnT/xgDHTuqXZh1Sn7iE=; b=C+acU2Hr6xR4SBj99V028flzcOA5ULbyLgslrlkaDerWiqpPdy7Je2y8WFfrAkK91W vZzCNnPAxz48ozCdsPIpO5sB5oqCicBVenBG8HZIuIzYRCt3oReSAJZ3TdwHCLbIBzAJ TWsGvKgkrmlGfbc3/i6O3dbzeWj+va7SVSUjKCF+CZroGLUeEK6cYLbNzFq6gcGLI8xP aF8lWnNEV3uAJesXqMuiVGyv+USLK7gN3xBauYJAfTGSd2ijnWJLTXcbNGFVbj3plPtj BHxeJxkdI/mExBuc2Cq1fRWzIMdODkpcAQdAsChJDNlc+j0suvpgNNxDs02vpwqScIPB KJ0g== X-Gm-Message-State: AAQBX9fDsJ/Lt8E1lJBSNN8E8KK16HM/AvgwTO56uJ+8Voo67gtzGxLO gSTVCy5e7zEG54AFNURnfz5INxKF/g6iCzf2tBY= X-Received: by 2002:ad4:5fcb:0:b0:56b:340c:ee1a with SMTP id jq11-20020ad45fcb000000b0056b340cee1amr20283141qvb.49.1679935629908; Mon, 27 Mar 2023 09:47:09 -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.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2023 09:47:09 -0700 (PDT) From: Devin Heitmueller X-Google-Original-From: Devin Heitmueller To: ffmpeg-devel@ffmpeg.org Date: Mon, 27 Mar 2023 12:47:01 -0400 Message-Id: <20230327164704.12962-3-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 2/5] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: WrP/OpzXM77p 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c index 051d278f54..d2fab09c66 100644 --- a/libavfilter/vf_fps.c +++ b/libavfilter/vf_fps.c @@ -30,6 +30,7 @@ #include #include "libavutil/avassert.h" +#include "libavutil/ccfifo.h" #include "libavutil/eval.h" #include "libavutil/mathematics.h" #include "libavutil/opt.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); } + av_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,9 @@ static int config_props(AVFilterLink* outlink) s->in_pts_off, s->out_pts_off, s->start_time); } + if (!(s->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, "fps=%d/%d\n", outlink->frame_rate.num, outlink->frame_rate.den); return 0; @@ -242,6 +248,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); + av_ccfifo_extract(s->cc_fifo, frame); s->frames[s->frames_count++] = frame; s->frames_in++; @@ -289,7 +296,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); + av_ccfifo_inject(s->cc_fifo, frame); frame->pts = s->next_pts++; frame->duration = 1;