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 52A8042E28 for ; Mon, 9 May 2022 18:19:33 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CE19768B3CA; Mon, 9 May 2022 21:19:31 +0300 (EEST) Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 243A06801DD for ; Mon, 9 May 2022 21:19:26 +0300 (EEST) Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-2f7d19cac0bso154040537b3.13 for ; Mon, 09 May 2022 11:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=fXEYsz2yGcqlRm1/8aayTE/K1VzSx5glCPohVZ1ueBU=; b=TY/vJVhggnSFGDPfratiQxJre1/qOA4FLAHDNgc1ueTFmwYFFHg/Y3e/ZkE4XRAbM/ HYQdYXtl26Qmd+4sBNfJprlQ2BwVMTG5nG8Wum7nb6BocS/VWd+SWuCC6ipOxA9Kacjb gDXFsZ2s4yhDWDC8iCglDf5smusE4Lmbn8cVyXFfyuFWyc3JKUb42R059glhoylHtdMg 7qhfRN3hgMue2GtEBecSSU9FZK2Oq9JHRXaT2QsTTVMC+shHHUNCRULIO6TtuTwry2kX NgMby/y/HtmIL20Rx2ocnya9S3vcHWM+kvCkUEpnrrNoq1KUIgoyJ8GeOS045UzMe79Q P4/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=fXEYsz2yGcqlRm1/8aayTE/K1VzSx5glCPohVZ1ueBU=; b=19xGpaz2yOKutYnrcAqz/Iht4z1DK8yKiv4JrslEGOVHWDlOGKo+lVHuDSHnbYTNUv UVJN1X4Umd+05qU2Ec+8PAbLGKmeV0S62FIxTcliGgUAn9ZqvvwKf8/A9wPX2sBhGWe6 JOLdYrwi6l/kxe0kHtPNGWAgQ3GibGPGzd5NeRpYRQxHWnhZFN0nCfb6cbiAtWZXntMN lKfM80KHz7Mav44l6rbQz3WEk8ksEBc8ijMJ0CVfc5jlR4HxA07085pt6JwrNA7NUPCr +/ZdsMDXCmcv+sluA6eeZBFJSHczZyaHKs1brxVaX9Ed2eXk0nAjjlh/X2NGMawI3riV jLfQ== X-Gm-Message-State: AOAM531W+W/mUVDE8wEZCQYiTt43d6gSgMuMR6medmwImQVeuy1toG5L VLGyAclhmkwQ5Bnoivm/AMoJcdwEtcVJQKoAnCSvRnTo X-Google-Smtp-Source: ABdhPJzn3+7BUMmyx26zV7k16tPN6UgfjxJcWmuYf+UB5A8m/IDh2ufkW7xPTVX52DtxhV5xIC6uPxkSsftgyOPNfcE= X-Received: by 2002:a81:ac57:0:b0:2f1:99ec:91a2 with SMTP id z23-20020a81ac57000000b002f199ec91a2mr15161225ywj.329.1652120364389; Mon, 09 May 2022 11:19:24 -0700 (PDT) MIME-Version: 1.0 References: <20220505230458.1024-1-gsun@roblox.com> In-Reply-To: <20220505230458.1024-1-gsun@roblox.com> From: Guangyu Sun Date: Mon, 9 May 2022 11:19:13 -0700 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH] avformat/oggparsevorbis: Fix oggvorbis duration parsing for small files 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-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: On Thu, May 5, 2022 at 4:05 PM Guangyu Sun wrote: > The decoded Data is not returned from the first frame; it must be used > to 'prime' the decode engine. The duration of the first packet should > be ignored also by the container, to make sure the total duration is > trimmed correctly. > > If the file has multiple pages for the data packets. The duration of the > last packet can be correctly adjusted without being affected by the first > packet. But if the first packet and the last packet are located in the > same page, the duration of the last packet will have an unwanted offset. > > This commit fixes https://trac.ffmpeg.org/ticket/6367. > > dd if=/dev/zero of=./silence.raw count=1 bs=500 > oggenc --raw silence.raw --output=silence.ogg > oggdec --raw --output silence.oggdec.raw silence.ogg > ffmpeg -codec:a libvorbis -i silence.ogg -f s16le -codec:a pcm_s16le > silence.libvorbis.ffmpeg.raw > ffmpeg -i silence.ogg -f s16le -codec:a pcm_s16le silence.native.ffmpeg.raw > ls -l *.raw > > Signed-off-by: Guangyu Sun > --- > libavformat/oggparsevorbis.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c > index 289900f7cf..9a486c9fe8 100644 > --- a/libavformat/oggparsevorbis.c > +++ b/libavformat/oggparsevorbis.c > @@ -412,6 +412,7 @@ static int vorbis_packet(AVFormatContext *s, int idx) > struct ogg_stream *os = ogg->streams + idx; > struct oggvorbis_private *priv = os->private; > int duration, flags = 0; > + int first_page; > > if (!priv->vp) > return AVERROR_INVALIDDATA; > @@ -420,7 +421,8 @@ static int vorbis_packet(AVFormatContext *s, int idx) > * here we parse the duration of each packet in the first page and > compare > * the total duration to the page granule to find the encoder delay > and > * set the first timestamp */ > - if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & > OGG_FLAG_EOS) && (int64_t)os->granule>=0) { > + first_page = !os->lastpts || os->lastpts == AV_NOPTS_VALUE; > + if (first_page && !(os->flags & OGG_FLAG_EOS) && > (int64_t)os->granule>=0) { > int seg, d; > uint8_t *last_pkt = os->buf + os->pstart; > uint8_t *next_pkt = last_pkt; > @@ -479,6 +481,13 @@ static int vorbis_packet(AVFormatContext *s, int idx) > flags = 0; > } > os->pduration = duration; > + /* Data is not returned from the first frame; it must be used to > 'prime' > + * the decode engine. The duration of the first packet should be > ignored > + * also by the container, to make sure the total duration is > trimmed > + * correctly. > + */ > + if (first_page && os->segp == 1) > + os->pduration = 0; > } > > /* final packet handling > -- > 2.30.1 > > Ping. _______________________________________________ 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".