[FFmpeg-cvslog] swr: add double precision support to the rematrix code

Michael Niedermayer git at videolan.org
Wed May 2 01:18:42 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed May  2 00:50:00 2012 +0200| [f2e799a3d08b4a0ff2d2821f58e69cd40cda0a53] | committer: Michael Niedermayer

swr: add double precision support to the rematrix code

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f2e799a3d08b4a0ff2d2821f58e69cd40cda0a53
---

 libswresample/rematrix.c   |   30 ++++++++++++++++++++++++++++++
 libswresample/swresample.c |    5 +++--
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index 1eeb717..15e3ead 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -34,6 +34,18 @@
 #undef ONE
 #undef COEFF
 
+#define ONE (1.0)
+#define R(x) x
+#define SAMPLE double
+#define COEFF double
+#define RENAME(x) x ## _double
+#include "rematrix_template.c"
+#undef SAMPLE
+#undef RENAME
+#undef R
+#undef ONE
+#undef COEFF
+
 #define ONE (-32768)
 #define R(x) (((x) + 16384)>>15)
 #define SAMPLE int16_t
@@ -297,6 +309,15 @@ int swri_rematrix_init(SwrContext *s){
         *((float*)s->native_one) = 1.0;
         s->mix_1_1_f = copy_float;
         s->mix_2_1_f = sum2_float;
+    }else if(s->midbuf.fmt == AV_SAMPLE_FMT_DBLP){
+        s->native_matrix = av_mallocz(nb_in * nb_out * sizeof(double));
+        s->native_one    = av_mallocz(sizeof(double));
+        for (i = 0; i < nb_out; i++)
+            for (j = 0; j < nb_in; j++)
+                ((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j];
+        *((double*)s->native_one) = 1.0;
+        s->mix_1_1_f = copy_double;
+        s->mix_2_1_f = sum2_double;
     }else
         av_assert0(0);
     //FIXME quantize for integeres
@@ -353,6 +374,15 @@ int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mus
                     }
                     ((float*)out->ch[out_i])[i]= v;
                 }
+            }else if(s->int_sample_fmt == AV_SAMPLE_FMT_DBLP){
+                for(i=0; i<len; i++){
+                    double v=0;
+                    for(j=0; j<s->matrix_ch[out_i][0]; j++){
+                        in_i= s->matrix_ch[out_i][1+j];
+                        v+= ((double*)in->ch[in_i])[i] * s->matrix[out_i][in_i];
+                    }
+                    ((double*)out->ch[out_i])[i]= v;
+                }
             }else{
                 for(i=0; i<len; i++){
                     int v=0;
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index f0a6f0e..87a885b 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -216,8 +216,9 @@ int swr_init(struct SwrContext *s){
 
     if(   s->int_sample_fmt != AV_SAMPLE_FMT_S16P
         &&s->int_sample_fmt != AV_SAMPLE_FMT_S32P
-        &&s->int_sample_fmt != AV_SAMPLE_FMT_FLTP){
-        av_log(s, AV_LOG_ERROR, "Requested sample format %s is not supported internally, S16/S32/FLT is supported\n", av_get_sample_fmt_name(s->int_sample_fmt));
+        &&s->int_sample_fmt != AV_SAMPLE_FMT_FLTP
+        &&s->int_sample_fmt != AV_SAMPLE_FMT_DBLP){
+        av_log(s, AV_LOG_ERROR, "Requested sample format %s is not supported internally, S16/S32/FLT/DBL is supported\n", av_get_sample_fmt_name(s->int_sample_fmt));
         return AVERROR(EINVAL);
     }
 



More information about the ffmpeg-cvslog mailing list