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 84D8C45FEB for ; Fri, 28 Apr 2023 15:43:01 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C9DE768C02E; Fri, 28 Apr 2023 18:42:22 +0300 (EEST) Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 46BA568C006 for ; Fri, 28 Apr 2023 18:42:14 +0300 (EEST) Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-75131c2997bso668479185a.1 for ; Fri, 28 Apr 2023 08:42:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ltnglobal-com.20221208.gappssmtp.com; s=20221208; t=1682696533; x=1685288533; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=RECp0FoM08xJycNye3PsgZXhNbgE1KGRGsbU9jKw71w=; b=kWsP+JSJT1U3wTjuTG8MugAuf92Cyi2IvrKNXOFf9Wg4QNpkhtIth8Hbo+s252ETOG FTfu9TatJ5DwGTciPlwOuVYoIrVI8z7NfvDZo52d/2SgNFO/aSB3+UMOCAsIvuJZGDPW qfKVh0menZSZO4s15u6+S9ncUbAlq7FTAPFRSnz8jbSdXTRZx+jFCEne1QOTU6ybZDr/ +AqQZs5KmlLMedDeqF/VGwX5qJoL+yCHJXDjrCwvou4kU4aaxC+SMlgySb6hHIMqmEY7 zivJZW/9InU/3geRq3FqEinN9lJ1wGV44yWAhVjy/hy9vWHJ1Ul1eqk3T6HW7UPkBFDb ygKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682696533; x=1685288533; 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=RECp0FoM08xJycNye3PsgZXhNbgE1KGRGsbU9jKw71w=; b=PcQ93axZXQkrC74DaFiJihEjYAGxjhuRHZzkG3X6k3+ue6X71fYgC2PKhOjrPHlU09 cJcd7ZhMM/jU9auq6uZlQkIyGZOeCKQaEtBWtLvP1gARdlJaiWOwP1BDir0wKMqqGfUP vCjqwVdRvv49d8I0kJYzijhtN9B348rHDFpY1JkVVMXq9tSk/DLgUjdssAE2yHyXK+Ga z3CqLD0UyJSsEyPsBfuBt7ZCFY7R//AoUb1sktVxFA0vAinNCIaVfP+5YYUDhjA/mPKl 74V6rjAhEOfCv4Ftspj/hyJ5//xhvvyCwCet/0LLf7AD+i00NcsjuzRbuKcExADTczVH cZ5w== X-Gm-Message-State: AC+VfDxpeiuOrxyXJMx+B9/xrCrtELFdHKaZa0YL7FtFWnU4WSX295vX adxMRKGXsEBb1RKnFTK7pLjtiJOzrEmJCfzeI90= X-Google-Smtp-Source: ACHHUZ4O5+YeMfyM/jRH922P//AKRAVT0sYhpcdT3kD2xQzf0imPE2aa9W8iRqRu+Lrw5AuyRIqgyQ== X-Received: by 2002:a05:622a:170a:b0:3ef:2f81:7865 with SMTP id h10-20020a05622a170a00b003ef2f817865mr17984055qtk.33.1682696532709; Fri, 28 Apr 2023 08:42:12 -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 do54-20020a05620a2b3600b0074e13ed6ee9sm6733873qkb.132.2023.04.28.08.42.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Apr 2023 08:42:12 -0700 (PDT) From: Devin Heitmueller X-Google-Original-From: Devin Heitmueller To: ffmpeg-devel@ffmpeg.org Date: Fri, 28 Apr 2023 12:37:49 -0400 Message-Id: <1682699871-22331-5-git-send-email-dheitmueller@ltnglobal.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682699871-22331-1-git-send-email-dheitmueller@ltnglobal.com> References: <1682699871-22331-1-git-send-email-dheitmueller@ltnglobal.com> Subject: [FFmpeg-devel] [PATCH v4 4/6] tinterlace: Properly preserve CEA-708 closed 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 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: Because the interlacing filter halves the effective framerate, we need to ensure that no CEA-708 data is lost as frames are merged. Make use of the new ccfifo mechanism to ensure that caption data is properly preserved as frames pass through the filter. Thanks to Thomas Mundt for review and noticing a couple of missed codepaths for injection on output. Thanks to Lance Wang for pointing out a memory leak. Signed-off-by: Devin Heitmueller --- libavfilter/tinterlace.h | 2 ++ libavfilter/vf_tinterlace.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/libavfilter/tinterlace.h b/libavfilter/tinterlace.h index 37b6c10..9f5ce7e 100644 --- a/libavfilter/tinterlace.h +++ b/libavfilter/tinterlace.h @@ -32,6 +32,7 @@ #include "libavutil/pixdesc.h" #include "drawutils.h" #include "avfilter.h" +#include "ccfifo.h" #define TINTERLACE_FLAG_VLPF 01 #define TINTERLACE_FLAG_CVLPF 2 @@ -77,6 +78,7 @@ typedef struct TInterlaceContext { const AVPixFmtDescriptor *csp; void (*lowpass_line)(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp, ptrdiff_t mref, ptrdiff_t pref, int clip_max); + AVCCFifo *cc_fifo; } TInterlaceContext; void ff_tinterlace_init_x86(TInterlaceContext *interlace); diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c index 0326292..309bf83 100644 --- a/libavfilter/vf_tinterlace.c +++ b/libavfilter/vf_tinterlace.c @@ -203,6 +203,7 @@ static av_cold void uninit(AVFilterContext *ctx) av_frame_free(&tinterlace->next); av_freep(&tinterlace->black_data[0][0]); av_freep(&tinterlace->black_data[1][0]); + ff_ccfifo_freep(&tinterlace->cc_fifo); } static int config_out_props(AVFilterLink *outlink) @@ -291,6 +292,9 @@ static int config_out_props(AVFilterLink *outlink) #endif } + if (!(tinterlace->cc_fifo = ff_ccfifo_alloc(&outlink->frame_rate, ctx))) + av_log(ctx, AV_LOG_VERBOSE, "Failure to setup CC FIFO queue\n"); + av_log(ctx, AV_LOG_VERBOSE, "mode:%d filter:%s h:%d -> h:%d\n", tinterlace->mode, (tinterlace->flags & TINTERLACE_FLAG_CVLPF) ? "complex" : (tinterlace->flags & TINTERLACE_FLAG_VLPF) ? "linear" : "off", @@ -375,6 +379,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) tinterlace->cur = tinterlace->next; tinterlace->next = picref; + ff_ccfifo_extract(tinterlace->cc_fifo, picref); + cur = tinterlace->cur; next = tinterlace->next; /* we need at least two frames */ @@ -451,6 +457,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) if (!out) return AVERROR(ENOMEM); out->pts /= 2; // adjust pts to new framerate + ff_ccfifo_inject(tinterlace->cc_fifo, out); ret = ff_filter_frame(outlink, out); return ret; } @@ -486,6 +493,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) out->pts = cur->pts*2; out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base); + ff_ccfifo_inject(tinterlace->cc_fifo, out); if ((ret = ff_filter_frame(outlink, out)) < 0) return ret; @@ -521,6 +529,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base); out->duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); + ff_ccfifo_inject(tinterlace->cc_fifo, out); ret = ff_filter_frame(outlink, out); return ret; -- 1.8.3.1 _______________________________________________ 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".