summaryrefslogtreecommitdiff
path: root/libswresample
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-02-09 10:12:45 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-02-09 10:15:56 +0100
commitb74ecb82fa51aba52a95992668546afe8ed2bd9f (patch)
tree23309b89296731a599f108b752f2c6e927ddfec0 /libswresample
parent48ffaaaaef98640782cfdaaf21319a83292b62b2 (diff)
swresample/x86/rematrix_init: Check av_malloc* return codes, forward errors
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample')
-rw-r--r--libswresample/rematrix.c3
-rw-r--r--libswresample/swresample_internal.h2
-rw-r--r--libswresample/x86/rematrix_init.c11
3 files changed, 12 insertions, 4 deletions
diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index 6552a2fea2..f26ede79f2 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -415,7 +415,8 @@ av_cold int swri_rematrix_init(SwrContext *s){
s->matrix_ch[i][0]= ch_in;
}
- if(HAVE_YASM && HAVE_MMX) swri_rematrix_init_x86(s);
+ if(HAVE_YASM && HAVE_MMX)
+ return swri_rematrix_init_x86(s);
return 0;
}
diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h
index bb51272d6f..3e733368b0 100644
--- a/libswresample/swresample_internal.h
+++ b/libswresample/swresample_internal.h
@@ -183,7 +183,7 @@ void swri_noise_shaping_double(SwrContext *s, AudioData *dsts, const AudioData *
int swri_rematrix_init(SwrContext *s);
void swri_rematrix_free(SwrContext *s);
int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy);
-void swri_rematrix_init_x86(struct SwrContext *s);
+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_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt);
diff --git a/libswresample/x86/rematrix_init.c b/libswresample/x86/rematrix_init.c
index bf695747cd..918479a4a8 100644
--- a/libswresample/x86/rematrix_init.c
+++ b/libswresample/x86/rematrix_init.c
@@ -30,7 +30,7 @@ D(float, avx)
D(int16, mmx)
D(int16, sse2)
-av_cold void swri_rematrix_init_x86(struct SwrContext *s){
+av_cold int swri_rematrix_init_x86(struct SwrContext *s){
#if HAVE_YASM
int mm_flags = av_get_cpu_flags();
int nb_in = av_get_channel_layout_nb_channels(s->in_ch_layout);
@@ -52,6 +52,9 @@ av_cold void swri_rematrix_init_x86(struct SwrContext *s){
}
s->native_simd_matrix = av_mallocz_array(num, 2 * sizeof(int16_t));
s->native_simd_one = av_mallocz(2 * sizeof(int16_t));
+ if (!s->native_simd_matrix || !s->native_simd_one)
+ return AVERROR(ENOMEM);
+
for(i=0; i<nb_out; i++){
int sh = 0;
for(j=0; j<nb_in; j++)
@@ -75,9 +78,13 @@ av_cold void swri_rematrix_init_x86(struct SwrContext *s){
s->mix_2_1_simd = ff_mix_2_1_a_float_avx;
}
s->native_simd_matrix = av_mallocz_array(num, sizeof(float));
- memcpy(s->native_simd_matrix, s->native_matrix, num * sizeof(float));
s->native_simd_one = av_mallocz(sizeof(float));
+ if (!s->native_simd_matrix || !s->native_simd_one)
+ return AVERROR(ENOMEM);
+ memcpy(s->native_simd_matrix, s->native_matrix, num * sizeof(float));
memcpy(s->native_simd_one, s->native_one, sizeof(float));
}
#endif
+
+ return 0;
}