From: Paul B Mahol <onemda@gmail.com> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH] speexdec fix Date: Tue, 6 Sep 2022 10:03:51 +0200 Message-ID: <CAPYw7P5idqjFA+gx7t35ZUpCs+8R_3co5GNc58cyd2MJmHCT9Q@mail.gmail.com> (raw) In-Reply-To: <166245104712.3205.17673747682508396684@lain.khirnov.net> On Tue, Sep 6, 2022 at 9:57 AM Anton Khirnov <anton@khirnov.net> wrote: > 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 <onemda@gmail.com> > > 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 <onemda@gmail.com> > > --- > > 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? > Dunno, documentation is not clear on this. > > Also, a test would be nice. > ENOTIME > > -- > 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". > _______________________________________________ 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".
next prev parent reply other threads:[~2022-09-06 8:00 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-03 16:24 Paul B Mahol 2022-09-06 7:57 ` Anton Khirnov 2022-09-06 8:03 ` Paul B Mahol [this message] 2022-09-06 8:03 ` Anton Khirnov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=CAPYw7P5idqjFA+gx7t35ZUpCs+8R_3co5GNc58cyd2MJmHCT9Q@mail.gmail.com \ --to=onemda@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git