From patchwork Fri Apr 21 14:24:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 41289 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1312805pzb; Fri, 21 Apr 2023 06:29:52 -0700 (PDT) X-Google-Smtp-Source: AKy350b5OWmH+n0HCL+J3JatjfLMS74kEWdZzgGjO0M5b38BbedL+G8WSeo1FzGJyxdmHH8mYQcs X-Received: by 2002:aa7:c592:0:b0:506:c288:118 with SMTP id g18-20020aa7c592000000b00506c2880118mr5055822edq.39.1682083792699; Fri, 21 Apr 2023 06:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682083792; cv=none; d=google.com; s=arc-20160816; b=oqjlvLctUIbny61XLiuPh1Dv4iC70mEcwcT49+IQ3NnhXsCJ31VF/0ASpV8sVypFi/ R7CN5eZDxErIENFbOa0cxAtCPXMI5wpmOiMxsd1UE+pCHHAos0+R7CGj1io2TDTY1AM3 qOAe8HhbVFLmplFkQahKM7zo1tOpFFSAaqtv6XfL/LulT+LFu1Edc+UWBiRsvPE4YkqT ta/NcI5S4so90dK3ELFSk85uJD4IBx1TsYRWMYGERqiLFY35P5mEUGB6X1FMdE2fYwve wMz+j1zAnQW0YFNE5jOzzPr8AQPkEbUSr79uoGdzm3lpfiFpTeKw8W394RfmWKxj+pKu Ppdw== 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=RVrpmOrowsLwtM0TRquoTPXS2zxKfF8tREpA8M7y79E=; b=ARuXSLWKY6O2S7RgfbWyrQxHiZzvVztBoOTNLaj6AHLLQrZzr8q9353eAVW/V6Pn/I KYeJX5HOeJZgo1eQuH6mHRb/PqJq1Pr95VCAWxTeg70ntiqYS7T5qxxtFgGnwWuk/Vjl tAyht40/MCzuyATIxsjuQHUNE/ZI/NcnA1j+pToTYsUJvFeditGMag8HzJ+I8DPXP/8y 9LmOy2nXVKndT+hpgdj1i+I79i8rqw0uEdmL61yT87yxCHUQQwTh6Yix9LCfLz9NXQ52 96edS3KheLxXau7snkPZf3RW6TqS8FbGXZ5CTMVWR3VGOqwcRX6bS42bW43ySZx0Dv0A NECQ== 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=26KJBV1b; 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 q11-20020aa7da8b000000b005084710b840si1277884eds.661.2023.04.21.06.29.52; Fri, 21 Apr 2023 06:29:52 -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=26KJBV1b; 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 0904E68BF89; Fri, 21 Apr 2023 16:29:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 145E26808A9 for ; Fri, 21 Apr 2023 16:29:22 +0300 (EEST) Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-74dd7f52f18so588714085a.0 for ; Fri, 21 Apr 2023 06:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ltnglobal-com.20221208.gappssmtp.com; s=20221208; t=1682083760; x=1684675760; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=nW8mqH+MItVKYQuVteI+1QrqXRzb+1QWctuI6goP5+c=; b=26KJBV1bA6OxthyArFdt0PbCggFmhBGT1BDb1Qf8ZvHuImJ5FjJRBknQix/ZMFgtwF RCCiFePsXu/8UjUyTKLtszbkB8AnH7n5gEllmtHqOSHczw60Fz9Kyi44kove8TNl8kUx OqZkfxA9Us7moxx4Njf7k05lg8zMV48qtoD/n+1rKIH01R18VDASoM5oinDiiB5mlebp pyk/KltYOG0Hbg09BwUHUAbfJmHNplE4h2FKpbVyTZYvsWJlV6Q+3bl1Xe4JrMnA0qyb u83j7hL4DCJ5jAGPgwVlZllyQAv+5Ex79+jFRm7vSp2Gl7z/5eo+dE5twJGzp3o0IHRc Tmug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682083760; x=1684675760; 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=nW8mqH+MItVKYQuVteI+1QrqXRzb+1QWctuI6goP5+c=; b=XGkrF5C1WHKRtgFeNv0+TzJU9TapoTbB8l+mp7ljCiBkYVys/RK7TqdunwnsuCXrek hKoCsXk87OgmL5BsKBjm7SFGgg4PbutduwU0TY/LrYRe5UYKAkNBHEKjiDYlWuFenMz3 dACR2a3fOCLhfo+C9dx4XCnqRaTb8EpDZsbMqciGN67Z3drvSMmfvHAeIGPEZCXcU6ZA kqT45OF1rqA6aaRD+XvPkimMLruWgdoKG9H2J7ew0iPnZrOGC7k+G+LogtqDS2NpZHtA EuI+z1OQac+JIX0nkdEEIzLxCOQrQtM6P+HsUYol8LBCpYr8iRdlY75JE874rLlIYzb0 aMNw== X-Gm-Message-State: AAQBX9crvUSPZYqbfJZFK5iMLyC8qMotFoL0XhfJrN4aYE2slzLnp3iQ A1GAJiQ8/mQUbkbb3RSa7BTaOV6kZ01Y64+OJ+c= X-Received: by 2002:ad4:5aa7:0:b0:5dd:5c8d:866f with SMTP id u7-20020ad45aa7000000b005dd5c8d866fmr11027268qvg.23.1682083760259; Fri, 21 Apr 2023 06:29:20 -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 b142-20020ae9eb94000000b0074abc456dddsm1305626qkg.134.2023.04.21.06.29.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2023 06:29:19 -0700 (PDT) From: Devin Heitmueller X-Google-Original-From: Devin Heitmueller To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 Apr 2023 10:24:52 -0400 Message-Id: <1682087095-582-3-git-send-email-dheitmueller@ltnglobal.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682087095-582-1-git-send-email-dheitmueller@ltnglobal.com> References: <1682087095-582-1-git-send-email-dheitmueller@ltnglobal.com> Subject: [FFmpeg-devel] [PATCH v3 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: TxkMhDiytZgf 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 051d278..06e7441 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,9 @@ 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_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); + ff_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); + ff_ccfifo_inject(s->cc_fifo, frame); frame->pts = s->next_pts++; frame->duration = 1;