From patchwork Fri Apr 7 21:58:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 41019 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp627635pzb; Fri, 7 Apr 2023 14:03:33 -0700 (PDT) X-Google-Smtp-Source: AKy350bGe7yu/jjh6YEbKVO5r5Dtj9h67R2ccFDUHPjxX36AupLFgQJqv771+aNPnukNr0yEsn/4 X-Received: by 2002:a17:906:58d4:b0:93e:6f40:d141 with SMTP id e20-20020a17090658d400b0093e6f40d141mr926078ejs.40.1680901412971; Fri, 07 Apr 2023 14:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680901412; cv=none; d=google.com; s=arc-20160816; b=VPf81+OOjsofWnxwN95eUFkUDbzC8toXEF1ZeabslHbQt219r1sHTK+StmCERectVe 4l99b81+4w9E4SvHZo6omXAQgIOv0aBoc6HBw7yu8MaN5EID3HEd6FQS2PRevf/H68Sy CQBT0tlOgi3h5SoV/UP3bClcn+DSQb3vqwRGUZEV2JFc2H84oAXNd/T2svski18d7MpH PfR4OuzMPKKY04eYjdN1FZA2WJEhyxxloYFIY6bFV8r0dGrLYydB9WJ4/RxDUD6sR1EO KYx6HTvCm/zn+7gtGAiOgIgVEiIjZ/brFR9caJ5/xJ3KeDMX2KHFXxXTZG8RgESZQ5Vd noKg== 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=SvPLUPcTKt6EqD8wDZKUsiX6ezuEXBo10ZcT1+v7U8s=; b=0MN/6gfVFRtfJ7JFBb9Wz9WHG3oTA6wTTfT+IqLKPGiiOC5IG6mMIPpa17Lm4Gn118 v+rVbM70KDA/fJ6CA9/HmnVNEF7O0msubL6Z1QVPOin/AEkWrHkU8ef/T7ybK9kPkDHY 0QjQrE9PqYPrijAllD6Lko3JpayTHm2ZtD7yVuUe2z1Hm1tG1cRs7wZDb1oz6QXc3Qi1 zFABMZorFUlRj2UZEN6PzkYwEqZaDSi6vbKJrSPMdZpW4jbZQFDL7ZPjBRJ4Y1IuWZuG EIRBaqI/DPii+EnK+vlqfLRqQ18eCCx+OeXa0vGMboRoRDT9nLMkzHiqtnLtwCDT7pOC +QfA== 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=tDyxlCYm; 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 gg11-20020a170906e28b00b00947eadd521fsi3574852ejb.333.2023.04.07.14.03.32; Fri, 07 Apr 2023 14:03:32 -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=tDyxlCYm; 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 1517F68B815; Sat, 8 Apr 2023 00:03:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5E57A689D6E for ; Sat, 8 Apr 2023 00:03:04 +0300 (EEST) Received: by mail-qv1-f46.google.com with SMTP id l1so3204265qvv.4 for ; Fri, 07 Apr 2023 14:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ltnglobal-com.20210112.gappssmtp.com; s=20210112; t=1680901383; x=1683493383; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=y3zUV4HoAAcSZDj0fY9VeI4retV5G+49wX4qL3f2y4w=; b=tDyxlCYmUm+CugSMujgozLV0M7iMLoDeK5aLScDf7bGLIcoqlc65m718aFMnxjS5TL 9Eus6+jDOv0Kuozsm2E/LLCmi91FgQ9n6Dz1L/fDh7i+HsqWsdaJsOjayojmSj2NVHOb KBKEhl9La6GzRfExwtfBB3LS3Z45UfM04164+klszWBKafduk4Rr8wtTbMMqFD/OJubj 1nvGKAfhrI1KzgxYORHMegmzN2Uc3Xaw7CKd+bbt1pwTxJGnJthgQc0GI/118IjlpPaG vZ/bas/gz+bTnBcs0OJG1mJW0IOGZQ/QCa1pLtlQp9+4rJcLQTR+0sSIOwUIadg3ky/x 9kug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680901383; x=1683493383; 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=y3zUV4HoAAcSZDj0fY9VeI4retV5G+49wX4qL3f2y4w=; b=66MSNiV+ixQkwKcgkA3FoQxFhdGiHkOhdCqhWhvppTynWQZzmP+Mx7SA5O/p5n8hVK jzIXkEfx8pXQFrf+wYZOBcatv6QXglbBXp8eBRA4O3C5s9RhZGichGxrIn7LN0ycBA62 D3Yx7z+VZoTktIew7SB+3B0LkO5gAuqU4Hh7Z5LuPNJraxbAIodG0Q01On0Ud9MITGLy AsyYB3bsf2RQdpwX5NxNo0NyMqOpHnCgmkm1Tqr28rHp6Zzd0DauZNOUKcNtEk7llK/Z WUTgwCFSKf7W/45NAwopDES5x+uVShnJ1TNSr7+Gh3BZpY1ZskVF9JL9cI+68nnQnHy4 CYtg== X-Gm-Message-State: AAQBX9eGZhnj+aAZrseGY7y2sIQyRjgckNtI+zwu8JDTWgyXQMxXw55g UFs5tX/iiOD/eTkz1ERNuzTxaNmZm9p99OyqES8= X-Received: by 2002:a05:6214:c4d:b0:5c1:b700:2caa with SMTP id r13-20020a0562140c4d00b005c1b7002caamr6419682qvj.26.1680901383006; Fri, 07 Apr 2023 14:03:03 -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.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Apr 2023 14:03:02 -0700 (PDT) From: Devin Heitmueller X-Google-Original-From: Devin Heitmueller To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Apr 2023 17:58:26 -0400 Message-Id: <1680904709-25951-3-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 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: nyEgUR8KkC5D 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..3f18bfc 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); } + 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;