From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A1CC2458FE for ; Mon, 27 Mar 2023 16:47:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6363968CB26; Mon, 27 Mar 2023 19:47:19 +0300 (EEST) 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-Google-Smtp-Source: AKy350ZP0Wq0xFgsTLY+I8XbeQuSmPhxI++wf2Uru/Ie8N1WI9HX+vMh9tnyk20Cb5w2ae6jkm3wUA== 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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; -- 2.35.1.655.ga68dfadae5 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".