You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-11-23 21:54:53 +02:00
swresample/x86/rematrix_init: Avoid allocation for native_simd_one
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -562,7 +562,6 @@ av_cold int swri_rematrix_init(SwrContext *s){
|
||||
av_cold void swri_rematrix_free(SwrContext *s){
|
||||
av_freep(&s->native_matrix);
|
||||
av_freep(&s->native_simd_matrix);
|
||||
av_freep(&s->native_simd_one);
|
||||
}
|
||||
|
||||
int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy){
|
||||
|
||||
@@ -688,7 +688,7 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co
|
||||
|
||||
if(len1)
|
||||
for(ch=0; ch<preout->ch_count; ch++)
|
||||
s->mix_2_1_simd(conv_src->ch[ch], preout->ch[ch], s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos, s->native_simd_one, 0, 0, len1);
|
||||
s->mix_2_1_simd(conv_src->ch[ch], preout->ch[ch], s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos, &s->native_simd_one, 0, 0, len1);
|
||||
if(out_count != len1)
|
||||
for(ch=0; ch<preout->ch_count; ch++)
|
||||
s->mix_2_1_f(conv_src->ch[ch] + off, preout->ch[ch] + off, s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos + off, &s->native_one, 0, 0, out_count - len1);
|
||||
|
||||
@@ -179,7 +179,10 @@ struct SwrContext {
|
||||
double d;
|
||||
} native_one;
|
||||
uint8_t *native_matrix;
|
||||
uint8_t *native_simd_one;
|
||||
union {
|
||||
int16_t i16[2];
|
||||
float f;
|
||||
} native_simd_one;
|
||||
uint8_t *native_simd_matrix;
|
||||
uint8_t matrix_ch[SWR_CH_MAX][SWR_CH_MAX+1]; ///< Lists of input channels per output channel that have non zero rematrixing coefficients
|
||||
mix_1_1_func_type *mix_1_1_f;
|
||||
|
||||
@@ -48,8 +48,7 @@ av_cold int swri_rematrix_init_x86(struct SwrContext *s){
|
||||
s->mix_2_1_simd = ff_mix_2_1_a_int16_sse2;
|
||||
}
|
||||
s->native_simd_matrix = av_calloc(num, 2 * sizeof(int16_t));
|
||||
s->native_simd_one = av_mallocz(2 * sizeof(int16_t));
|
||||
if (!s->native_simd_matrix || !s->native_simd_one)
|
||||
if (!s->native_simd_matrix)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
for(i=0; i<nb_out; i++){
|
||||
@@ -63,8 +62,8 @@ av_cold int swri_rematrix_init_x86(struct SwrContext *s){
|
||||
((((int*)s->native_matrix)[i * nb_in + j]) + (1<<sh>>1)) >> sh;
|
||||
}
|
||||
}
|
||||
((int16_t*)s->native_simd_one)[1] = 14;
|
||||
((int16_t*)s->native_simd_one)[0] = 16384;
|
||||
s->native_simd_one.i16[1] = 14;
|
||||
s->native_simd_one.i16[0] = 16384;
|
||||
} else if(s->midbuf.fmt == AV_SAMPLE_FMT_FLTP){
|
||||
if(EXTERNAL_SSE(mm_flags)) {
|
||||
s->mix_1_1_simd = ff_mix_1_1_a_float_sse;
|
||||
@@ -75,11 +74,10 @@ av_cold int swri_rematrix_init_x86(struct SwrContext *s){
|
||||
s->mix_2_1_simd = ff_mix_2_1_a_float_avx;
|
||||
}
|
||||
s->native_simd_matrix = av_calloc(num, sizeof(float));
|
||||
s->native_simd_one = av_mallocz(sizeof(float));
|
||||
if (!s->native_simd_matrix || !s->native_simd_one)
|
||||
if (!s->native_simd_matrix)
|
||||
return AVERROR(ENOMEM);
|
||||
memcpy(s->native_simd_matrix, s->native_matrix, num * sizeof(float));
|
||||
memcpy(s->native_simd_one, &s->native_one.f, sizeof(float));
|
||||
s->native_simd_one.f = s->native_one.f;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user