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 6DB724432D for ; Tue, 6 Sep 2022 07:57:36 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4F73868BA86; Tue, 6 Sep 2022 10:57:34 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0A27D68B6F7 for ; Tue, 6 Sep 2022 10:57:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id AAB91240D0E for ; Tue, 6 Sep 2022 09:57:27 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id MycB6LIkWAxl for ; Tue, 6 Sep 2022 09:57:27 +0200 (CEST) Received: from lain.khirnov.net (lain.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 0FA45240D03 for ; Tue, 6 Sep 2022 09:57:27 +0200 (CEST) Received: by lain.khirnov.net (Postfix, from userid 1000) id 265891601B2; Tue, 6 Sep 2022 09:57:27 +0200 (CEST) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: References: Mail-Followup-To: FFmpeg development discussions and patches Date: Tue, 06 Sep 2022 09:57:27 +0200 Message-ID: <166245104712.3205.17673747682508396684@lain.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] speexdec fix 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: Quoting Paul B Mahol (2022-09-03 18:24:51) > Patch attached. > > From 6a90e5d582ba2fc3a08fb08fb1b5f3f38d315b3f Mon Sep 17 00:00:00 2001 > From: Paul B Mahol > Date: Sat, 3 Sep 2022 18:17:23 +0200 > Subject: [PATCH] avcodec/speexdec: improve support for speex in non-ogg > > Signed-off-by: Paul B Mahol > --- > libavcodec/speexdec.c | 16 +++++++++++----- > 1 file changed, 11 insertions(+), 5 deletions(-) > > diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c > index 83981fc454..9793d939fc 100644 > --- a/libavcodec/speexdec.c > +++ b/libavcodec/speexdec.c > @@ -1462,7 +1462,7 @@ static av_cold int speex_decode_init(AVCodecContext *avctx) > default: s->mode = 2; > } > > - s->frames_per_packet = 1; > + s->frames_per_packet = 64; > s->frame_size = NB_FRAME_SIZE << s->mode; > } > > @@ -1537,6 +1537,7 @@ static int speex_decode_frame(AVCodecContext *avctx, AVFrame *frame, > int *got_frame_ptr, AVPacket *avpkt) > { > SpeexContext *s = avctx->priv_data; > + int frames_per_packet = s->frames_per_packet; > const float scale = 1.f / 32768.f; > int buf_size = avpkt->size; > float *dst; > @@ -1547,26 +1548,31 @@ static int speex_decode_frame(AVCodecContext *avctx, AVFrame *frame, > if ((ret = init_get_bits8(&s->gb, avpkt->data, buf_size)) < 0) > return ret; > > - frame->nb_samples = FFALIGN(s->frame_size * s->frames_per_packet, 4); > + frame->nb_samples = FFALIGN(s->frame_size * frames_per_packet, 4); > if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) > return ret; > > dst = (float *)frame->extended_data[0]; > - for (int i = 0; i < s->frames_per_packet; i++) { > + for (int i = 0; i < frames_per_packet; i++) { > ret = speex_modes[s->mode].decode(avctx, &s->st[s->mode], &s->gb, dst + i * s->frame_size); > if (ret < 0) > return ret; > if (avctx->ch_layout.nb_channels == 2) > speex_decode_stereo(dst + i * s->frame_size, s->frame_size, &s->stereo); > + if (get_bits_left(&s->gb) < 5 || > + show_bits(&s->gb, 5) == 15) { > + frames_per_packet = i + 1; > + break; > + } > } > > dst = (float *)frame->extended_data[0]; > s->fdsp->vector_fmul_scalar(dst, dst, scale, frame->nb_samples * frame->ch_layout.nb_channels); > - frame->nb_samples = s->frame_size * s->frames_per_packet; > + frame->nb_samples = s->frame_size * frames_per_packet; > > *got_frame_ptr = 1; > > - return buf_size; > + return (get_bits_count(&s->gb) + 7) >> 3; Doesn't this need AV_CODEC_CAP_SUBFRAMES? Also, a test would be nice. -- Anton Khirnov _______________________________________________ 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".