[FFmpeg-cvslog] resample: support double precission resampling

Michael Niedermayer git at videolan.org
Tue Apr 10 14:02:57 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Apr 10 13:38:10 2012 +0200| [24ab1abfb6d55bf330022df4b10d7aec80b3f116] | committer: Michael Niedermayer

resample: support double precission resampling

This commit is dedicated to the audiophiles who can hear it when a
needle is dropped on the moon.

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

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

 libswresample/resample.c            |   29 +++++++++++++++++++++++++++++
 libswresample/swresample_internal.h |    1 +
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/libswresample/resample.c b/libswresample/resample.c
index d158e76..cdd00ba 100644
--- a/libswresample/resample.c
+++ b/libswresample/resample.c
@@ -143,6 +143,10 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap
             for(i=0;i<tap_count;i++)
                 ((float*)filter)[ph * tap_count + i] = tab[i] * scale / norm;
             break;
+        case AV_SAMPLE_FMT_DBL:
+            for(i=0;i<tap_count;i++)
+                ((double*)filter)[ph * tap_count + i] = tab[i] * scale / norm;
+            break;
         }
     }
 #if 0
@@ -211,6 +215,10 @@ ResampleContext *swri_resample_init(ResampleContext *c, int out_rate, int in_rat
             c->felem_size   = 4;
             c->filter_shift = 0;
             break;
+        case AV_SAMPLE_FMT_DBL:
+            c->felem_size   = 8;
+            c->filter_shift = 0;
+            break;
         default:
             av_log(NULL, AV_LOG_ERROR, "Unsupported sample format\n");
             return NULL;
@@ -330,6 +338,26 @@ int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensatio
 #define OUT(d, v) d = v
 #include "resample_template.c"
 
+#undef RENAME
+#undef FELEM
+#undef FELEM2
+#undef DELEM
+#undef FELEML
+#undef OUT
+#undef FELEM_MIN
+#undef FELEM_MAX
+#undef FILTER_SHIFT
+
+
+#define RENAME(N) N ## _double
+#define FILTER_SHIFT 0
+#define DELEM  double
+#define FELEM  double
+#define FELEM2 double
+#define FELEML double
+#define OUT(d, v) d = v
+#include "resample_template.c"
+
 
 int swri_multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed){
     int i, ret= -1;
@@ -338,6 +366,7 @@ int swri_multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, Aud
         if(c->format == AV_SAMPLE_FMT_S16) ret= swri_resample_int16(c, (int16_t*)dst->ch[i], (const int16_t*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count);
         if(c->format == AV_SAMPLE_FMT_S32) ret= swri_resample_int32(c, (int32_t*)dst->ch[i], (const int32_t*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count);
         if(c->format == AV_SAMPLE_FMT_FLT) ret= swri_resample_float(c, (float  *)dst->ch[i], (const float  *)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count);
+        if(c->format == AV_SAMPLE_FMT_DBL) ret= swri_resample_double(c,(double *)dst->ch[i], (const double *)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count);
     }
 
     return ret;
diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h
index f9f490a..618afc1 100644
--- a/libswresample/swresample_internal.h
+++ b/libswresample/swresample_internal.h
@@ -85,6 +85,7 @@ void swri_resample_compensate(struct ResampleContext *c, int sample_delta, int c
 int swri_resample_int16(struct ResampleContext *c, int16_t *dst, const int16_t *src, int *consumed, int src_size, int dst_size, int update_ctx);
 int swri_resample_int32(struct ResampleContext *c, int32_t *dst, const int32_t *src, int *consumed, int src_size, int dst_size, int update_ctx);
 int swri_resample_float(struct ResampleContext *c, float   *dst, const float   *src, int *consumed, int src_size, int dst_size, int update_ctx);
+int swri_resample_double(struct ResampleContext *c,double  *dst, const double  *src, int *consumed, int src_size, int dst_size, int update_ctx);
 
 int swri_rematrix_init(SwrContext *s);
 int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy);



More information about the ffmpeg-cvslog mailing list