From patchwork Fri Mar 17 20:09:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 40715 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:d046:b0:cd:afd7:272c with SMTP id hv6csp14844pzb; Fri, 17 Mar 2023 13:10:24 -0700 (PDT) X-Google-Smtp-Source: AK7set99hV8eON0q9MMQBJfcuS/Dxu/D1xYmJjs26YWQJJ3h+Y8Hm79OJaoqGre/Y8v0B91INLZ9 X-Received: by 2002:aa7:d504:0:b0:4af:601e:6039 with SMTP id y4-20020aa7d504000000b004af601e6039mr4314608edq.22.1679083824318; Fri, 17 Mar 2023 13:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679083824; cv=none; d=google.com; s=arc-20160816; b=goSnDhFxQRkK5u47xBcmx9D60EeZuX4vnpopuJKCKax3Rxaj/ie46S1om1FaRO5J7O gXLKVdaTdQbQ+nH0UmTwp9gnS1/RUT5vFhAth4d3zFmeBwP5ogDJ7MpIBxQVFjQfarqb FzTDe1Y6f7f5sCOtnuwTK2LDkbJunsob4N2oARdyitozMkLjn8DTgd4Wpg0NFvN3dds0 wU5yj9dq4YMSTcQcgOZ4lLCMKQNl97ejNUKoMyxsY9Via7Nj8FwjEyFTB1lTfvhJhyJ+ Noy+IoreBlAVFwBgc2ovET7Xenw/792jMjR4id2NWgDmwVdc/qtICVhYqd3J5jZ9NjJd t3Vg== 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=zjQkdrbZ+j4RKa38yVVQEiHaHkHEw7YFDAh7LZY2yjQ07kTtd+X/PQIJNBuwqBQHjN MkXXeYMb2Ijmn+346APZ0m/xTC/eC1safcxqf8j050zf2B6x6hxg9UXrsarXrDyyApOC EmMO4A64Lq+rRGyjg6BbIFXvDuOiV+S9wtTej+LQuSPpdRYDBc67ElnIR4WadgaMoUFC KjA5DdDiy5DirbsTWBVe/2YXUpss5uEuotxPYXzs/vRlPxDSVyUuadHATDbbkSqjCj99 roKheI7VhkOzjrtdklzt45dj/SXEoWpVIt1M+s9IWL87GEhzn6kf6z4JiUQcwO+TtNsp WvnQ== 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=vpyhBzYs; 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 ay21-20020a056402203500b004fd1ee1380fsi3229813edb.612.2023.03.17.13.10.23; Fri, 17 Mar 2023 13:10:24 -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=vpyhBzYs; 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 4088168C269; Fri, 17 Mar 2023 22:09:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1722168C226 for ; Fri, 17 Mar 2023 22:09:49 +0200 (EET) Received: by mail-qt1-f182.google.com with SMTP id x1so6940430qtr.7 for ; Fri, 17 Mar 2023 13:09:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ltnglobal-com.20210112.gappssmtp.com; s=20210112; t=1679083787; 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=vpyhBzYs6c0VVbg3alkEp+7WDvZFZdOxqvg4sXdC0jXpDydZ+4AV8DooiCREMT/Csj hDBAw1R+hg6/tYKrz/g+hfV1Uj70uiU7Gri4ahRMGHrMQrDnyJWtHJtUMpXgFyCWQEH+ VYJtHQRH53fBsTftq7Q1Cmz83lwUGTn5MwbEdQp3XHRcjevNCi0KmeG3Aal5k4R4r7jm qMsJkRsEOdQ4SGW+2h3NKAGTkYVsOUuRbHFNIxwGnL4bYqtZaGpG73fSc0SrCCCDVjuS 0Wptc7m/BJ3jQJpa5vf46ZvyXRMScDlzQN01lRtdriiO1VYyYiNM0sYTDStkm632Ydnq tQtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679083787; 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=6npNRr/4uW9bMnp16WUJ3wnVSbXpLzzwcf0NiEZL2PRZjrdMxQmJRJJSSfqQ9ZWf8F ICxZW532/8jVHBqGV11NXiJa9DUSUpflwTcwbC8NL2IeMGxc26vyftVJTBc146G9k8HO cbTulCfNzuceSRDgiatVQKDAFQyjt+QBuW5QqVfoSdOadtiJESifTs02H2WQL1we9/mb 18BZumjytOTazDWOJnBLX6Xl6WvNoxHj5S60Fn9I9uDTH3HvEXyoX5wtydcBcNSrMOGA 5Gf4BCBX7fvJ6xjpYXKmLdM819oAjzx/oCZfSE+BeUiOxC8RrEpZ4L7JkZ9XxKF9w0Jf v3RQ== X-Gm-Message-State: AO0yUKXOBKjL7bcWHYYS/Ais3VUfR8ghudpfXKJCC0zvdtO5D+/Z1iOE We7MGxKHmeFZTjpKds/qNcRXMwYr4fRe4giCU0Q= X-Received: by 2002:a05:622a:44f:b0:3b8:340b:1aab with SMTP id o15-20020a05622a044f00b003b8340b1aabmr13690600qtx.25.1679083787639; Fri, 17 Mar 2023 13:09:47 -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 j5-20020ac86645000000b003bd0e7ff466sm2065685qtp.7.2023.03.17.13.09.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Mar 2023 13:09:47 -0700 (PDT) From: Devin Heitmueller X-Google-Original-From: Devin Heitmueller To: ffmpeg-devel@ffmpeg.org Date: Fri, 17 Mar 2023 16:09:38 -0400 Message-Id: <20230317200941.3936-3-dheitmueller@ltnglobal.com> X-Mailer: git-send-email 2.35.1.655.ga68dfadae5 In-Reply-To: <20230317200941.3936-1-dheitmueller@ltnglobal.com> References: <20230317200941.3936-1-dheitmueller@ltnglobal.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [RFC 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: Tzkbqp3aGqUf 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;