1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

swresample/dither: check memory allocation

check memory allocation in swri_get_dither()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Ganesh Ajjanagadde 2015-06-02 23:17:48 -04:00 committed by Michael Niedermayer
parent 7495e728f5
commit 196b885a5f
3 changed files with 8 additions and 3 deletions

View File

@ -23,12 +23,15 @@
#include "noise_shaping_data.c"
void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt) {
int swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt) {
double scale = s->dither.noise_scale;
#define TMP_EXTRA 2
double *tmp = av_malloc_array(len + TMP_EXTRA, sizeof(double));
int i;
if (!tmp)
return AVERROR(ENOMEM);
for(i=0; i<len + TMP_EXTRA; i++){
double v;
seed = seed* 1664525 + 1013904223;
@ -70,6 +73,7 @@ void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSa
}
av_free(tmp);
return 0;
}
av_cold int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt)

View File

@ -627,7 +627,8 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co
return ret;
if(ret)
for(ch=0; ch<s->dither.noise.ch_count; ch++)
swri_get_dither(s, s->dither.noise.ch[ch], s->dither.noise.count, 12345678913579<<ch, s->dither.noise.fmt);
if((ret=swri_get_dither(s, s->dither.noise.ch[ch], s->dither.noise.count, 12345678913579<<ch, s->dither.noise.fmt))<0)
return ret;
av_assert0(s->dither.noise.ch_count == preout->ch_count);
if(s->dither.noise_pos + out_count > s->dither.noise.count)

View File

@ -192,7 +192,7 @@ void swri_rematrix_free(SwrContext *s);
int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy);
int swri_rematrix_init_x86(struct SwrContext *s);
void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt);
int swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt);
int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt);
void swri_audio_convert_init_aarch64(struct AudioConvert *ac,