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 2530C43D41 for ; Thu, 8 Sep 2022 12:12:03 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4452868BA7A; Thu, 8 Sep 2022 15:12:00 +0300 (EEST) Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7C1BF68B9D0 for ; Thu, 8 Sep 2022 15:11:53 +0300 (EEST) Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-3452214cec6so119985047b3.1 for ; Thu, 08 Sep 2022 05:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date; bh=OdpzXDyKyjBvGrAocqyKh5fWAlbW7y8kOiyJZmSyUEc=; b=T4NHTYzQSWqUduRoRljAdCi5BZGwUiPE3pKthkirm/8bRMGZRnFkqHh7pkWsvS4VDf flzgJOOvkB79nVjDugl+aMEXj04SYCHeQpa2wVId2ftOC+ehV0fizE4aSlg1DjUaptaR vThtfsOw4JsajcWo0nN62lSEdD3jPf7oswVGNjUasu9ZM9VRH8hO0i4dcRIGkhJnOBVY IZv5/Cz5ikVGgC0hcDs7nkMQJ3KMXcH8DDMRMbCMTxbJNtncBBYa4HHnanY7sG/hSQJo KiNLFcEww2j1rB7Z1A27oJM7bA3GF1Z8A2o6f3PmpwFnhYacsaYNJWWjmeC82ZnwK7Ds sPtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=OdpzXDyKyjBvGrAocqyKh5fWAlbW7y8kOiyJZmSyUEc=; b=WJIzRakJiT+i9DG0yRQdY1c4nMTeryZ+53y8MGV5DmOslicR79R6zKKZ9z9ucdmwaU kM2AhyZVhRKrYNBd7Qk9aingbYoZpWgkzLzaWcwfzUMZyUYyANea3vQM99TNDe+WiHzb xkwhi5uTZnz9aYW/NdNIXRrDpIOyOhSta86lg3iaax5tzcQAvauD1xp3Mhjh/tHZDp84 iDGd9dH8cZe+pZvPP7ZY96OCnyzLH63fcPCtoIXjWYAP/bB+FmEu0Nrjd6nLvn3Sj7Op 3+dRG3KOOrIfSolk/+XdvjHmyvrb49g4kgdrme6L7ptgHOLXMfUfETxcTbEInnVImbse JKiA== X-Gm-Message-State: ACgBeo16J3NUMNbiAa/KKQAFAywFrMAFizr6u5raxdo7ouvSYkX1nMRg ahRgJ2XZAR1s2MG1KMe8AzJrIdr1AkRlVd4ju6FraWOp X-Google-Smtp-Source: AA6agR72Vty949oNrUo/V6Uz+Wov7cr3cnjAcA3IhmMypbyd0FSEYBkCUaljX7bE4RmTeeUPHzUl7KoVgjUrntEWjVo= X-Received: by 2002:a81:4e4e:0:b0:348:8a78:9905 with SMTP id c75-20020a814e4e000000b003488a789905mr2823465ywb.40.1662639111308; Thu, 08 Sep 2022 05:11:51 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a81:7402:0:0:0:0:0 with HTTP; Thu, 8 Sep 2022 05:11:50 -0700 (PDT) In-Reply-To: <20220908113632.1056-2-jyrkive@nekonyansoft.com> References: <20220908113632.1056-1-jyrkive@nekonyansoft.com> <20220908113632.1056-2-jyrkive@nekonyansoft.com> From: Paul B Mahol Date: Thu, 8 Sep 2022 14:11:50 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH] avcodec: Vorbis decode: don't use a flag to determine if frames have been output 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: Jyrki Vesterinen 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 9/8/22, jyrkive@nekonyansoft.com wrote: > From: Jyrki Vesterinen > > If a developer using FFmpeg libraries seeks into an earlier position and > calls > avcodec_flush_buffers() afterwards as recommended, the Vorbis decoder will > drop > the next frame, since buffer flushing clears the first_frame flag. As a > result, > the audio samples the calling code receives may be ahead of the requested > seek > position, which is unacceptable in some use cases such as playing a looping > sound effect. > > This commit records the presentation timestamp of the first frame and > determines after that if the new frame is the first frame (possible after > seeking to the start) by comparing its pts to the stored pts. > --- > libavcodec/vorbisdec.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c > index 4d03947c49..38a5367be3 100644 > --- a/libavcodec/vorbisdec.c > +++ b/libavcodec/vorbisdec.c > @@ -131,6 +131,7 @@ typedef struct vorbis_context_s { > > FFTContext mdct[2]; > uint8_t first_frame; > + int64_t initial_pts; > uint32_t version; > uint8_t audio_channels; > uint32_t audio_samplerate; > @@ -1847,6 +1848,10 @@ static int vorbis_decode_frame(AVCodecContext *avctx, > AVFrame *frame, > > if (!vc->first_frame) { > vc->first_frame = 1; > + vc->initial_pts = frame->pts; > + } > + > + if (frame->pts == vc->initial_pts) { > *got_frame_ptr = 0; > av_frame_unref(frame); > return buf_size; > @@ -1881,7 +1886,6 @@ static av_cold void vorbis_decode_flush(AVCodecContext > *avctx) > sizeof(*vc->saved)); > } > vc->previous_window = -1; > - vc->first_frame = 0; > } > > const FFCodec ff_vorbis_decoder = { > -- > 2.37.2.windows.2 > LGTM > _______________________________________________ > 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". > _______________________________________________ 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".