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 8E9F9433B2 for ; Thu, 8 Sep 2022 08:38:00 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7FBEB68B9E6; Thu, 8 Sep 2022 11:37:58 +0300 (EEST) Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 51B1168B9CA for ; Thu, 8 Sep 2022 11:37:52 +0300 (EEST) Received: by mail-yb1-f172.google.com with SMTP id c9so25323833ybf.5 for ; Thu, 08 Sep 2022 01:37:52 -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:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=CEEFz7M289I/SuMYnEdpthZ60PW9mp7YbFrfzBPJHRQ=; b=H0UHZAzet0IQnJT414zLNcaUQOVyEIPhRDWF6RjuapZ06KC4p8S+rNpXqAqkPlXWXv nZgiaVYZpz9sJUwNadVazQ9WGbtdISD+84why7uU5GkjDmXybHbX4vvMJ1j01S8ADKVi sqi6eG4oLeSaNbX1zDSVQJCtIUrRgECNIOrQ2K3vLM3H8nUvcNT6iGPJfDSNOkKt/enW yyFjHdPzK/PMivAYy6aiIsrTfdINNN6FcZ62HQiDahvXztnVqtLkJjgOmM7RGp6yRBTH ZdQo9N0t7BSNbCMzPsepUet0M6A8Il7/hOXcgK7LNutdg/31yIXzZU12Jf9WrKt21HJW eJ8A== 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:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=CEEFz7M289I/SuMYnEdpthZ60PW9mp7YbFrfzBPJHRQ=; b=OttwDKMgFtZ7Qiqof1SuUMMzBRRwXWKwyKvwswhqyr9PB68zzmTvKh2T1A0fXVoVUj w8xgEJtttNTJ5Q47exydeIJjG0jzuduxS2fXCuhcOQ/5jqyQrWd6fWjADh9JLv08MqTF U4EcqdkqajtQM8Y1WzWeQAqW+j67fSu2U81ifqceMKrpDNj3c2UV+KaxTdN7/FqC+jFg qqyvzmTr2Oelsu44Dp1Lm+Qq7u9i/bLscQdLCv8v/twsMkWQV/PVvEDCEBpXj3R6bLXq WMEtpwwLCurRqKQAE0uXy/lq5XSWnXNR3rOmCVyl9tznTXK1ZAjV2ntuWua0JyoaoThO Dq0Q== X-Gm-Message-State: ACgBeo0nUNi7zgbUcZN26A6Fm9TRQusjSp+v/cvYFvR5Fe4yvHk5WgAF rCC0zzByT0hKG5pt5rmvT7Ds9pkrZhYpCi5iGeiZomjB X-Google-Smtp-Source: AA6agR6MHm6go7PXN+UAi4j0VQYoq/vxYeZzgqQdtTHCBRtq97xe5tvqfqpemTkQQRBSycN1hl2YmcFuhA4woWXMHy0= X-Received: by 2002:a05:6902:10c3:b0:69a:ae8:1600 with SMTP id w3-20020a05690210c300b0069a0ae81600mr6154658ybu.227.1662626270732; Thu, 08 Sep 2022 01:37:50 -0700 (PDT) MIME-Version: 1.0 References: <20220908082505.953-1-jyrkive@nekonyansoft.com> In-Reply-To: <20220908082505.953-1-jyrkive@nekonyansoft.com> From: Paul B Mahol Date: Thu, 8 Sep 2022 10:40:57 +0200 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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 Thu, Sep 8, 2022 at 10:26 AM 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 removes the first_frame flag entirely and instead uses the > presentation timestamp to determine if it's the first frame. > Proper solution is to fetch initial/first pts and use that one instead using of using fragile pts < 0. > --- > libavcodec/vorbisdec.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c > index 4d03947c49..d4b030d7b9 100644 > --- a/libavcodec/vorbisdec.c > +++ b/libavcodec/vorbisdec.c > @@ -130,7 +130,6 @@ typedef struct vorbis_context_s { > AVFloatDSPContext *fdsp; > > FFTContext mdct[2]; > - uint8_t first_frame; > uint32_t version; > uint8_t audio_channels; > uint32_t audio_samplerate; > @@ -1845,8 +1844,7 @@ static int vorbis_decode_frame(AVCodecContext > *avctx, AVFrame *frame, > if ((len = vorbis_parse_audio_packet(vc, channel_ptrs)) <= 0) > return len; > > - if (!vc->first_frame) { > - vc->first_frame = 1; > + if (frame->pts < 0) { > *got_frame_ptr = 0; > av_frame_unref(frame); > return buf_size; > @@ -1881,7 +1879,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 > > _______________________________________________ > 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".