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 2687145EA1 for ; Fri, 14 Apr 2023 13:22:18 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0706368BE56; Fri, 14 Apr 2023 16:22:16 +0300 (EEST) Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DAC4468B196 for ; Fri, 14 Apr 2023 16:22:09 +0300 (EEST) Received: by mail-ot1-f52.google.com with SMTP id k22-20020a9d7016000000b006a43382e5b9so2154326otj.3 for ; Fri, 14 Apr 2023 06:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681478528; x=1684070528; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=je7zLtmZ1kDghpVl/i9iT0+r9iQVjQaDjx9fbw5LQt8=; b=shBBid/3IcFs8U8SY7qJfaB1Y+jeyb+/NCXhP9Aqoymf9Q37u6iLCbF7xM6sEiTJRx 2S+398WTA2D0kmOV9WTgWHFY27OHHot6QzE9t9QR7Jy7ggdxE2nc8Iq2EcxJX1Krk05e bR2dkolizurnxrqH+p87Y+3JjLSeudB+MFo8CNGXVGbyaKXBoEQyAz5rMAhgsU9xtd6k se8b3NzfBBONvhWZow5tmj+CWAU1rDTbAvfwqKJYbe0AkfnY0L4stW2bfwqCZJw+XpHJ 5pVeZdARazDztFJVpyJyTc88+D3BCAeuSNalQukB+fvfKAntMuCyGx/y8ERD6AkKR2kw FS/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681478528; x=1684070528; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=je7zLtmZ1kDghpVl/i9iT0+r9iQVjQaDjx9fbw5LQt8=; b=HK6Au1ZvJupcNwUOGN39Bej5faahUuJNi9w9bF9z7n9pNU541BBezU1VxTtTO4eeqS DTQMu3Y+rhIz8YV+sZ1t9hldjFaHrHPKlVWgI4vYoXjswPXja3QfQm8R53kT1lZA450W sXfTCz8PYqOuwIuA6CSXYEVV3c49sVMGDwjC+V8jQnH/f9RbyZ9PQaREE/vbafhb52BE i8oMeGE2pquJZ75hURgF6kVPoszwuwBRQrQfgebx4vAg2oSxtOkjHHeflTiOyVpeHTfD lbg5ega7uCy87i2gWQ+yBvvUMIFX4cQRqaOJZ54wBrlPoukspkBQ1Kx31PLKgneec3YP Oujg== X-Gm-Message-State: AAQBX9cKl3PYuGbmUdnprp2cqRlRJWwssWqs5psViNagi2PJjOuih/il aME2XBVGJzaSVtMVH0/ok5Xp/T7y5PQ= X-Google-Smtp-Source: AKy350YDVQxvrWg6waWGYfSzf+DCKwzkCaw2HbCvGFWT09ppM2/lJssg5Cn+HV8C+1a9cl4dM56OkA== X-Received: by 2002:a05:6830:1d62:b0:68f:2134:9a3a with SMTP id l2-20020a0568301d6200b0068f21349a3amr2524066oti.30.1681478527737; Fri, 14 Apr 2023 06:22:07 -0700 (PDT) Received: from [192.168.0.15] (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id v17-20020a9d5a11000000b006a205a8d5bdsm1706148oth.45.2023.04.14.06.22.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Apr 2023 06:22:07 -0700 (PDT) Message-ID: <9f8ed9f7-90fb-acb2-c8c4-15743c68734c@gmail.com> Date: Fri, 14 Apr 2023 10:22:06 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <1680904709-25951-1-git-send-email-dheitmueller@ltnglobal.com> <1680904709-25951-2-git-send-email-dheitmueller@ltnglobal.com> From: James Almer In-Reply-To: <1680904709-25951-2-git-send-email-dheitmueller@ltnglobal.com> Subject: Re: [FFmpeg-devel] [PATCH v2 1/5] ccfifo: Properly handle CEA-708 captions through framerate conversion 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 4/7/2023 6:58 PM, Devin Heitmueller wrote: > When transcoding video that contains 708 closed captions, the > caption data is tied to the frames as side data. Simply dropping > or adding frames to change the framerate will result in loss of > data, so the caption data needs to be preserved and reformatted. > > For example, without this patch converting 720p59 to 1080i59 > would result in loss of 50% of the caption bytes, resulting in > garbled 608 captions and 708 probably wouldn't render at all. > Further, the frames that are there will have an illegal > cc_count for the target framerate, so some decoders may ignore > the packets entirely. > > Extract the 608 and 708 tuples and insert them onto queues. Then > after dropping/adding frames, re-write the tuples back into the > resulting frames at the appropriate rate given the target > framerate. This includes both having the correct cc_count as > well as clocking out the 608 pairs at the appropriate rate. > > Signed-off-by: Devin Heitmueller > --- > libavfilter/Makefile | 1 + > libavfilter/ccfifo.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++++++ > libavfilter/ccfifo.h | 85 +++++++++++++++++++++++ > 3 files changed, 277 insertions(+) > create mode 100644 libavfilter/ccfifo.c > create mode 100644 libavfilter/ccfifo.h > > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index 71e198b..628ade8 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -14,6 +14,7 @@ OBJS = allfilters.o \ > buffersink.o \ > buffersrc.o \ > colorspace.o \ > + ccfifo.o \ > drawutils.o \ > fifo.o \ > formats.o \ > diff --git a/libavfilter/ccfifo.c b/libavfilter/ccfifo.c > new file mode 100644 > index 0000000..5db4149 > --- /dev/null > +++ b/libavfilter/ccfifo.c > @@ -0,0 +1,191 @@ > +/* > + * CEA-708 Closed Captioning FIFO > + * Copyright (c) 2023 LTN Global Communications > + * > + * Author: Devin Heitmueller > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#include "ccfifo.h" > + > +struct AVCCFifo { > + AVFifo *cc_608_fifo; > + AVFifo *cc_708_fifo; > + int expected_cc_count; > + int expected_608; > + int cc_detected; > + void *log_ctx; > +}; > + > +#define MAX_CC_ELEMENTS 128 > +#define CC_BYTES_PER_ENTRY 3 > + > +struct cc_lookup { > + int num; > + int den; > + int cc_count; > + int num_608; > +}; > + > +const static struct cc_lookup cc_lookup_vals[] = { > + { 15, 1, 40, 4 }, > + { 24, 1, 25, 3 }, > + { 24000, 1001, 25, 3 }, > + { 30, 1, 20, 2 }, > + { 30000, 1001, 20, 2}, > + { 60, 1, 10, 1 }, > + { 60000, 1001, 10, 1}, > +}; > + > +void av_ccfifo_freep(AVCCFifo **ccf) > +{ > + if (ccf && *ccf) { > + AVCCFifo *tmp = *ccf; > + if (tmp->cc_608_fifo) > + av_fifo_freep2(&tmp->cc_608_fifo); > + if (tmp->cc_708_fifo) > + av_fifo_freep2(&tmp->cc_708_fifo); > + av_freep(*ccf); > + } > +} > + > +AVCCFifo *av_ccfifo_alloc(AVRational *framerate, void *log_ctx) None of these functions should use the av_* prefix if they are meant to be internal, otherwise the symbols will be exported. Use ff_* instead. _______________________________________________ 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".