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 D247245718 for ; Fri, 21 Apr 2023 13:30:09 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BFC4268BF8C; Fri, 21 Apr 2023 16:29:31 +0300 (EEST) Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0C34668BF6F for ; Fri, 21 Apr 2023 16:29:23 +0300 (EEST) Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-3ee339e8c2fso9550871cf.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=1682083761; x=1684675761; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=n70T5p2X9pc1P+DSrkL+aOq9Z+kNMFaijosn6juOX3E=; b=juxUQJ/u453dPcF4PH+7JYtzO/wb3t5z6QO7H56/wzUsm6CqmEhSDM9pWCIhJiH4WQ BTMQEBfZB4ms2AUzWBdNLhNIT56oumaLMpU0Yzdl0wxZXbOyi/vFMf7KSa1BQnyEOUUP z14n+F/FyjT7Qq0XOHH6hsmLfRB4fH142r+8sM0yOOF/t2Yge2ckEYzFdVptPoRLdFgg 0GzhIemhOSYRVjBxVy90zdy4FoXGBt182wSlSnbBb+7NcBjpuDgvVV5rxn18elwMowpC SE7i8TNX/28YL3FfHfTaqfg1Bo44tfMuF9duEcQx295N7H0jBKhSiP0hXYTjKZSb1UKe cjhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682083761; x=1684675761; 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=n70T5p2X9pc1P+DSrkL+aOq9Z+kNMFaijosn6juOX3E=; b=KzeBds9ss9ypL/V7tZGKfYogAro00blkeVnwSWER0/EwUgv/UukhW1i2uiI/zWjoB3 YWboSzrrUx8NStECWUaqWK9/SmOMhrrJeACDkkcSb49LiZdsLxBXx8hWJMKLpahpixkI fdUuVBd/L14Yj6+mz96JI4igApmdiybuLLBa9KTxDbj1Qd1gJeOXr5CPAFX/yKwCzNKl vbsj0yRYfzNGx6rHsUcq9r8J3UVWLvcrcAWCA8D/Zv1iE5mhnRsgBlKRjLYUAl+MuibJ cnCbeOpgCgiqChQUk3nrtYsiuX2klcVZx+Jb01ex/m9AoKJuFOI+RCaqAnjYh7kW2P9I ODIw== X-Gm-Message-State: AAQBX9fLII6blUEqu2j8oZ5mTJZB4eZSPK3/vRx+tb1AfJnWeNQ4WmKv aGnB9eNYm+O+KBHHfCXUesTtOszZ2sYK035JjyQ= X-Google-Smtp-Source: AKy350Zt9Sy/lfAG1Zc0FmTKLrQJLdbCtFLiCuXKXUBy4f+YPKI35Y2RElVozq9k51S32m9/hbe2Rg== X-Received: by 2002:ac8:5ac3:0:b0:3e3:8035:7bf5 with SMTP id d3-20020ac85ac3000000b003e380357bf5mr7984034qtd.20.1682083761595; Fri, 21 Apr 2023 06:29:21 -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.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2023 06:29:21 -0700 (PDT) From: Devin Heitmueller X-Google-Original-From: Devin Heitmueller To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 Apr 2023 10:24:54 -0400 Message-Id: <1682087095-582-5-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 4/5] 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..090c7a7 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. Captions will be passed through\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".