[FFmpeg-cvslog] libswresample: support directly converting sampleformats and packed/ planar in a single pass.

Michael Niedermayer git at videolan.org
Thu Oct 6 00:23:57 CEST 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Oct  5 23:46:50 2011 +0200| [503e5e9db5f8ab7f0782e27ddd0265a2b22bd7b6] | committer: Michael Niedermayer

libswresample: support directly converting sampleformats and packed/planar in a single pass.

Previously a intermediate planar format was used when both input and output where packed.

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

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

 libswresample/swresample.c          |   14 ++++++++++++++
 libswresample/swresample_internal.h |    1 +
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index 7276c7a..65591f3 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -110,6 +110,7 @@ void swr_free(SwrContext **ss){
         free_temp(&s->in_buffer);
         swr_audio_convert_free(&s-> in_convert);
         swr_audio_convert_free(&s->out_convert);
+        swr_audio_convert_free(&s->full_convert);
         swr_resample_free(&s->resample);
     }
 
@@ -138,6 +139,7 @@ int swr_init(SwrContext *s){
     free_temp(&s->in_buffer);
     swr_audio_convert_free(&s-> in_convert);
     swr_audio_convert_free(&s->out_convert);
+    swr_audio_convert_free(&s->full_convert);
 
     s-> in.planar= s-> in_sample_fmt >= 0x100;
     s->out.planar= s->out_sample_fmt >= 0x100;
@@ -196,6 +198,12 @@ av_assert0(s->out.ch_count);
     s->int_bps= av_get_bits_per_sample_fmt(s->int_sample_fmt)/8;
     s->out.bps= av_get_bits_per_sample_fmt(s->out_sample_fmt)/8;
 
+    if(!s->resample && !s->rematrix){
+        s->full_convert = swr_audio_convert_alloc(s->out_sample_fmt,
+                                                  s-> in_sample_fmt, s-> in.ch_count, 0);
+        return 0;
+    }
+
     s->in_convert = swr_audio_convert_alloc(s->int_sample_fmt,
                                             s-> in_sample_fmt, s-> in.ch_count, 0);
     s->out_convert= swr_audio_convert_alloc(s->out_sample_fmt,
@@ -291,6 +299,12 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
     fill_audiodata(in ,  in_arg);
     fill_audiodata(out, out_arg);
 
+    if(s->full_convert){
+        av_assert0(!s->resample);
+        swr_audio_convert(s->full_convert, out, in, in_count);
+        return out_count;
+    }
+
 //     in_max= out_count*(int64_t)s->in_sample_rate / s->out_sample_rate + resample_filter_taps;
 //     in_count= FFMIN(in_count, in_in + 2 - s->hist_buffer_count);
 
diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h
index c883269..a9f1fe1 100644
--- a/libswresample/swresample_internal.h
+++ b/libswresample/swresample_internal.h
@@ -58,6 +58,7 @@ typedef struct SwrContext {          //FIXME find unused fields
 
     struct AVAudioConvert *in_convert;
     struct AVAudioConvert *out_convert;
+    struct AVAudioConvert *full_convert;
     struct AVResampleContext *resample;
 
     float matrix[SWR_CH_MAX][SWR_CH_MAX];



More information about the ffmpeg-cvslog mailing list