* [FFmpeg-devel] [PATCH] avcodec/speexdec: limit max frame_size
@ 2025-01-29 1:21 shenleban tongying
2025-01-29 1:31 ` slbtty
0 siblings, 1 reply; 3+ messages in thread
From: shenleban tongying @ 2025-01-29 1:21 UTC (permalink / raw)
To: ffmpeg-devel
The max frame_size for speex format is 32000 Hz * 20 ms / 1000 ms = 640
close #11054 and #11078
Signed-off-by: shenleban tongying <shenlebantongying@gmail.com>
---
libavcodec/speexdec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c
index d25823ef6e..555012a343 100644
--- a/libavcodec/speexdec.c
+++ b/libavcodec/speexdec.c
@@ -1425,7 +1425,7 @@ static int parse_speex_extradata(AVCodecContext *avctx,
if (s->frame_size < NB_FRAME_SIZE << (s->mode > 0) ||
s->frame_size > INT32_MAX >> (s->mode > 0))
return AVERROR_INVALIDDATA;
- s->frame_size <<= (s->mode > 0);
+ s->frame_size = FFMIN(640, s->frame_size << (s->mode > 0));
s->vbr = bytestream_get_le32(&buf);
s->frames_per_packet = bytestream_get_le32(&buf);
if (s->frames_per_packet <= 0 ||
--
2.48.1
_______________________________________________
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/speexdec: limit max frame_size
2025-01-29 1:21 [FFmpeg-devel] [PATCH] avcodec/speexdec: limit max frame_size shenleban tongying
@ 2025-01-29 1:31 ` slbtty
2025-01-29 2:12 ` slbtty
0 siblings, 1 reply; 3+ messages in thread
From: slbtty @ 2025-01-29 1:31 UTC (permalink / raw)
To: ffmpeg-devel
Correction: this fix the sample from #11054 but not #11078.
Still trying to figure out why.
> On Jan 28, 2025, at 8:21 PM, shenleban tongying <shenlebantongying@gmail.com> wrote:
>
> The max frame_size for speex format is 32000 Hz * 20 ms / 1000 ms = 640
>
> close #11054 and #11078
>
> Signed-off-by: shenleban tongying <shenlebantongying@gmail.com>
> ---
> libavcodec/speexdec.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c
> index d25823ef6e..555012a343 100644
> --- a/libavcodec/speexdec.c
> +++ b/libavcodec/speexdec.c
> @@ -1425,7 +1425,7 @@ static int parse_speex_extradata(AVCodecContext *avctx,
> if (s->frame_size < NB_FRAME_SIZE << (s->mode > 0) ||
> s->frame_size > INT32_MAX >> (s->mode > 0))
> return AVERROR_INVALIDDATA;
> - s->frame_size <<= (s->mode > 0);
> + s->frame_size = FFMIN(640, s->frame_size << (s->mode > 0));
> s->vbr = bytestream_get_le32(&buf);
> s->frames_per_packet = bytestream_get_le32(&buf);
> if (s->frames_per_packet <= 0 ||
> --
> 2.48.1
>
_______________________________________________
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/speexdec: limit max frame_size
2025-01-29 1:31 ` slbtty
@ 2025-01-29 2:12 ` slbtty
0 siblings, 0 replies; 3+ messages in thread
From: slbtty @ 2025-01-29 2:12 UTC (permalink / raw)
To: ffmpeg-devel
Still not 100% certain about the reason,
but this works for both #11054 and #11078.
The max value of s->mode is 2 which means ultra wide band?
---
libavcodec/speexdec.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c
index d25823ef6e..a95d9890d8 100644
--- a/libavcodec/speexdec.c
+++ b/libavcodec/speexdec.c
@@ -1425,7 +1425,9 @@ static int parse_speex_extradata(AVCodecContext *avctx,
if (s->frame_size < NB_FRAME_SIZE << (s->mode > 0) ||
s->frame_size > INT32_MAX >> (s->mode > 0))
return AVERROR_INVALIDDATA;
- s->frame_size <<= (s->mode > 0);
+ if (s->mode >= 2)
+ s->frame_size *= 2;
+ s->frame_size = FFMIN(640, s->frame_size);
s->vbr = bytestream_get_le32(&buf);
s->frames_per_packet = bytestream_get_le32(&buf);
if (s->frames_per_packet <= 0 ||
--
2.48.1
> On Jan 28, 2025, at 8:31 PM, slbtty <shenlebantongying@gmail.com> wrote:
>
> Correction: this fix the sample from #11054 but not #11078.
>
> Still trying to figure out why.
>
>
>> On Jan 28, 2025, at 8:21 PM, shenleban tongying <shenlebantongying@gmail.com> wrote:
>>
>> The max frame_size for speex format is 32000 Hz * 20 ms / 1000 ms = 640
>>
>> close #11054 and #11078
>>
>> Signed-off-by: shenleban tongying <shenlebantongying@gmail.com>
>> ---
>> libavcodec/speexdec.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c
>> index d25823ef6e..555012a343 100644
>> --- a/libavcodec/speexdec.c
>> +++ b/libavcodec/speexdec.c
>> @@ -1425,7 +1425,7 @@ static int parse_speex_extradata(AVCodecContext *avctx,
>> if (s->frame_size < NB_FRAME_SIZE << (s->mode > 0) ||
>> s->frame_size > INT32_MAX >> (s->mode > 0))
>> return AVERROR_INVALIDDATA;
>> - s->frame_size <<= (s->mode > 0);
>> + s->frame_size = FFMIN(640, s->frame_size << (s->mode > 0));
>> s->vbr = bytestream_get_le32(&buf);
>> s->frames_per_packet = bytestream_get_le32(&buf);
>> if (s->frames_per_packet <= 0 ||
>> --
>> 2.48.1
>>
>
_______________________________________________
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".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-29 2:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-29 1:21 [FFmpeg-devel] [PATCH] avcodec/speexdec: limit max frame_size shenleban tongying
2025-01-29 1:31 ` slbtty
2025-01-29 2:12 ` slbtty
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