summaryrefslogtreecommitdiffstats
path: root/libswresample
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-08-18 01:07:32 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2016-09-27 12:53:25 +0200
commit740f5105d5bdc6c9bab1a6aa0ccd3a3362d12daf (patch)
treee2a3f2caf951d65bc0e410e403790a51c7236621 /libswresample
parentdcc506a91e7745fc0e4d07e05ff8a13ee75ced41 (diff)
downloadffmpeg-streaming-740f5105d5bdc6c9bab1a6aa0ccd3a3362d12daf.zip
ffmpeg-streaming-740f5105d5bdc6c9bab1a6aa0ccd3a3362d12daf.tar.gz
swresample: Use double and float for matrixes for best quality and speed
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libswresample')
-rw-r--r--libswresample/rematrix.c11
-rw-r--r--libswresample/swresample_internal.h3
2 files changed, 12 insertions, 2 deletions
diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index ddba043..0d6138d 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -73,6 +73,9 @@ int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride)
for (out = 0; out < nb_out; out++) {
for (in = 0; in < nb_in; in++)
s->matrix[out][in] = matrix[in];
+ if (s->int_sample_fmt == AV_SAMPLE_FMT_FLTP)
+ for (in = 0; in < nb_in; in++)
+ s->matrix_flt[out][in] = matrix[in];
matrix += stride;
}
s->rematrix_custom = 1;
@@ -354,6 +357,12 @@ av_cold static int auto_matrix(SwrContext *s)
}
av_log(s, AV_LOG_DEBUG, "\n");
}
+ if (s->int_sample_fmt == AV_SAMPLE_FMT_FLTP) {
+ int i;
+ for (i = 0; i < FF_ARRAY_ELEMS(s->matrix[0])*FF_ARRAY_ELEMS(s->matrix[0]); i++)
+ s->matrix_flt[0][i] = s->matrix[0][i];
+ }
+
return 0;
}
@@ -513,7 +522,7 @@ int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mus
float v=0;
for(j=0; j<s->matrix_ch[out_i][0]; j++){
in_i= s->matrix_ch[out_i][1+j];
- v+= ((float*)in->ch[in_i])[i] * s->matrix[out_i][in_i];
+ v+= ((float*)in->ch[in_i])[i] * s->matrix_flt[out_i][in_i];
}
((float*)out->ch[out_i])[i]= v;
}
diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h
index 88dbc86..f2ea5a2 100644
--- a/libswresample/swresample_internal.h
+++ b/libswresample/swresample_internal.h
@@ -168,7 +168,8 @@ struct SwrContext {
struct ResampleContext *resample; ///< resampling context
struct Resampler const *resampler; ///< resampler virtual function table
- float matrix[SWR_CH_MAX][SWR_CH_MAX]; ///< floating point rematrixing coefficients
+ double matrix[SWR_CH_MAX][SWR_CH_MAX]; ///< floating point rematrixing coefficients
+ float matrix_flt[SWR_CH_MAX][SWR_CH_MAX]; ///< single precision floating point rematrixing coefficients
uint8_t *native_matrix;
uint8_t *native_one;
uint8_t *native_simd_one;
OpenPOWER on IntegriCloud