aboutsummaryrefslogtreecommitdiffstats
path: root/libavresample/audio_mix.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-05-30 19:32:06 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-05-30 19:32:06 +0200
commita1fc1d2e1b4a5bcfd07549dce9735f24237aa32e (patch)
tree924f2f1428ad37e7265a8effffd0158bb2a4ef48 /libavresample/audio_mix.c
parent39f0a45a1a087e5bbef84fa3366942384ec32155 (diff)
parentd041dec3cba300aef6e489990be7242dcd808441 (diff)
downloadffmpeg-a1fc1d2e1b4a5bcfd07549dce9735f24237aa32e.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: pcm-mpeg: improve log message wording fate: add missing $(TARGET_PATH) to ac3-fixed-encode fate: fix md5sum replacement on some systems avprobe: correctly set the default formatter lavr: add x86-optimized function for mixing 2 to 1 s16p with q8 coeffs lavr: add x86-optimized functions for mixing 2 to 1 s16p with float coeffs lavr: add C functions for mixing 2 to 1 channels with s16p format avprobe: move formatter functions in the context Conflicts: ffprobe.c libavcodec/pcm-mpeg.c tests/fate/ac3.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavresample/audio_mix.c')
-rw-r--r--libavresample/audio_mix.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/libavresample/audio_mix.c b/libavresample/audio_mix.c
index 76f10eaab2..7ab11b0d4d 100644
--- a/libavresample/audio_mix.c
+++ b/libavresample/audio_mix.c
@@ -115,6 +115,50 @@ static void mix_2_to_1_fltp_flt_c(float **samples, float **matrix, int len,
}
}
+static void mix_2_to_1_s16p_flt_c(int16_t **samples, float **matrix, int len,
+ int out_ch, int in_ch)
+{
+ int16_t *src0 = samples[0];
+ int16_t *src1 = samples[1];
+ int16_t *dst = src0;
+ float m0 = matrix[0][0];
+ float m1 = matrix[0][1];
+
+ while (len > 4) {
+ *dst++ = av_clip_int16(lrintf(*src0++ * m0 + *src1++ * m1));
+ *dst++ = av_clip_int16(lrintf(*src0++ * m0 + *src1++ * m1));
+ *dst++ = av_clip_int16(lrintf(*src0++ * m0 + *src1++ * m1));
+ *dst++ = av_clip_int16(lrintf(*src0++ * m0 + *src1++ * m1));
+ len -= 4;
+ }
+ while (len > 0) {
+ *dst++ = av_clip_int16(lrintf(*src0++ * m0 + *src1++ * m1));
+ len--;
+ }
+}
+
+static void mix_2_to_1_s16p_q8_c(int16_t **samples, int16_t **matrix, int len,
+ int out_ch, int in_ch)
+{
+ int16_t *src0 = samples[0];
+ int16_t *src1 = samples[1];
+ int16_t *dst = src0;
+ int16_t m0 = matrix[0][0];
+ int16_t m1 = matrix[0][1];
+
+ while (len > 4) {
+ *dst++ = (*src0++ * m0 + *src1++ * m1) >> 8;
+ *dst++ = (*src0++ * m0 + *src1++ * m1) >> 8;
+ *dst++ = (*src0++ * m0 + *src1++ * m1) >> 8;
+ *dst++ = (*src0++ * m0 + *src1++ * m1) >> 8;
+ len -= 4;
+ }
+ while (len > 0) {
+ *dst++ = (*src0++ * m0 + *src1++ * m1) >> 8;
+ len--;
+ }
+}
+
static void mix_1_to_2_fltp_flt_c(float **samples, float **matrix, int len,
int out_ch, int in_ch)
{
@@ -229,6 +273,12 @@ static int mix_function_init(AudioMix *am)
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
2, 1, 1, 1, "C", mix_2_to_1_fltp_flt_c);
+ ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
+ 2, 1, 1, 1, "C", mix_2_to_1_s16p_flt_c);
+
+ ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_Q8,
+ 2, 1, 1, 1, "C", mix_2_to_1_s16p_q8_c);
+
ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
1, 2, 1, 1, "C", mix_1_to_2_fltp_flt_c);