Browse code

swr: make audio convert code explicitely private.

Only what's declared in libswresample/swresample.h is public.

Clément Bœsch authored on 2011/11/16 16:00:31
Showing 4 changed files
... ...
@@ -34,7 +34,7 @@
34 34
 
35 35
 typedef void (conv_func_type)(uint8_t *po, const uint8_t *pi, int is, int os, uint8_t *end);
36 36
 
37
-struct AVAudioConvert {
37
+struct AudioConvert {
38 38
     int channels;
39 39
     conv_func_type *conv_f;
40 40
     const int *ch_map;
... ...
@@ -108,17 +108,17 @@ conv_func_type *fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB*AV_SAMPLE_FMT_NB] =
108 108
     FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL),
109 109
 };
110 110
 
111
-AVAudioConvert *swr_audio_convert_alloc(enum AVSampleFormat out_fmt,
112
-                                        enum AVSampleFormat in_fmt,
113
-                                        int channels, const int *ch_map,
114
-                                        int flags)
111
+AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt,
112
+                                       enum AVSampleFormat in_fmt,
113
+                                       int channels, const int *ch_map,
114
+                                       int flags)
115 115
 {
116
-    AVAudioConvert *ctx;
116
+    AudioConvert *ctx;
117 117
     conv_func_type *f = fmt_pair_to_conv_functions[out_fmt + AV_SAMPLE_FMT_NB*in_fmt];
118 118
 
119 119
     if (!f)
120 120
         return NULL;
121
-    ctx = av_malloc(sizeof(AVAudioConvert));
121
+    ctx = av_malloc(sizeof(*ctx));
122 122
     if (!ctx)
123 123
         return NULL;
124 124
     ctx->channels = channels;
... ...
@@ -127,12 +127,12 @@ AVAudioConvert *swr_audio_convert_alloc(enum AVSampleFormat out_fmt,
127 127
     return ctx;
128 128
 }
129 129
 
130
-void swr_audio_convert_free(AVAudioConvert **ctx)
130
+void swri_audio_convert_free(AudioConvert **ctx)
131 131
 {
132 132
     av_freep(ctx);
133 133
 }
134 134
 
135
-int swr_audio_convert(AVAudioConvert *ctx, AudioData *out, AudioData*in, int len)
135
+int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len)
136 136
 {
137 137
     int ch;
138 138
     const uint8_t null_input[8] = {0};
... ...
@@ -33,8 +33,8 @@
33 33
 #include "libavutil/cpu.h"
34 34
 #include "libavutil/audioconvert.h"
35 35
 
36
-struct AVAudioConvert;
37
-typedef struct AVAudioConvert AVAudioConvert;
36
+struct AudioConvert;
37
+typedef struct AudioConvert AudioConvert;
38 38
 
39 39
 /**
40 40
  * Create an audio sample format converter context
... ...
@@ -46,16 +46,16 @@ typedef struct AVAudioConvert AVAudioConvert;
46 46
  *               if all channels must be selected
47 47
  * @return NULL on error
48 48
  */
49
-AVAudioConvert *swr_audio_convert_alloc(enum AVSampleFormat out_fmt,
50
-                                        enum AVSampleFormat in_fmt,
51
-                                        int channels, const int *ch_map,
52
-                                        int flags);
49
+AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt,
50
+                                       enum AVSampleFormat in_fmt,
51
+                                       int channels, const int *ch_map,
52
+                                       int flags);
53 53
 
54 54
 /**
55 55
  * Free audio sample format converter context.
56 56
  * and set the pointer to NULL
57 57
  */
58
-void swr_audio_convert_free(AVAudioConvert **ctx);
58
+void swri_audio_convert_free(AudioConvert **ctx);
59 59
 
60 60
 /**
61 61
  * Convert between audio sample formats
... ...
@@ -63,6 +63,6 @@ void swr_audio_convert_free(AVAudioConvert **ctx);
63 63
  * @param[in] in array of input buffers for each channel
64 64
  * @param len length of audio frame size (measured in samples)
65 65
  */
66
-int swr_audio_convert(AVAudioConvert *ctx, AudioData *out, AudioData *in, int len);
66
+int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len);
67 67
 
68 68
 #endif /* AUDIOCONVERT_H */
... ...
@@ -119,9 +119,9 @@ void swr_free(SwrContext **ss){
119 119
         free_temp(&s->midbuf);
120 120
         free_temp(&s->preout);
121 121
         free_temp(&s->in_buffer);
122
-        swr_audio_convert_free(&s-> in_convert);
123
-        swr_audio_convert_free(&s->out_convert);
124
-        swr_audio_convert_free(&s->full_convert);
122
+        swri_audio_convert_free(&s-> in_convert);
123
+        swri_audio_convert_free(&s->out_convert);
124
+        swri_audio_convert_free(&s->full_convert);
125 125
         swr_resample_free(&s->resample);
126 126
     }
127 127
 
... ...
@@ -136,9 +136,9 @@ int swr_init(SwrContext *s){
136 136
     free_temp(&s->midbuf);
137 137
     free_temp(&s->preout);
138 138
     free_temp(&s->in_buffer);
139
-    swr_audio_convert_free(&s-> in_convert);
140
-    swr_audio_convert_free(&s->out_convert);
141
-    swr_audio_convert_free(&s->full_convert);
139
+    swri_audio_convert_free(&s-> in_convert);
140
+    swri_audio_convert_free(&s->out_convert);
141
+    swri_audio_convert_free(&s->full_convert);
142 142
 
143 143
     s-> in.planar= s-> in_sample_fmt >= 0x100;
144 144
     s->out.planar= s->out_sample_fmt >= 0x100;
... ...
@@ -209,15 +209,15 @@ av_assert0(s->out.ch_count);
209 209
     s->out.bps= av_get_bytes_per_sample(s->out_sample_fmt);
210 210
 
211 211
     if(!s->resample && !s->rematrix && !s->channel_map){
212
-        s->full_convert = swr_audio_convert_alloc(s->out_sample_fmt,
213
-                                                  s-> in_sample_fmt, s-> in.ch_count, NULL, 0);
212
+        s->full_convert = swri_audio_convert_alloc(s->out_sample_fmt,
213
+                                                   s-> in_sample_fmt, s-> in.ch_count, NULL, 0);
214 214
         return 0;
215 215
     }
216 216
 
217
-    s->in_convert = swr_audio_convert_alloc(s->int_sample_fmt,
218
-                                            s-> in_sample_fmt, s->used_ch_count, s->channel_map, 0);
219
-    s->out_convert= swr_audio_convert_alloc(s->out_sample_fmt,
220
-                                            s->int_sample_fmt, s->out.ch_count, NULL, 0);
217
+    s->in_convert = swri_audio_convert_alloc(s->int_sample_fmt,
218
+                                             s-> in_sample_fmt, s->used_ch_count, s->channel_map, 0);
219
+    s->out_convert= swri_audio_convert_alloc(s->out_sample_fmt,
220
+                                             s->int_sample_fmt, s->out.ch_count, NULL, 0);
221 221
 
222 222
 
223 223
     s->postin= s->in;
... ...
@@ -335,7 +335,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
335 335
 
336 336
     if(s->full_convert){
337 337
         av_assert0(!s->resample);
338
-        swr_audio_convert(s->full_convert, out, in, in_count);
338
+        swri_audio_convert(s->full_convert, out, in, in_count);
339 339
         return out_count;
340 340
     }
341 341
 
... ...
@@ -385,7 +385,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
385 385
     }
386 386
 
387 387
     if(in != postin){
388
-        swr_audio_convert(s->in_convert, postin, in, in_count);
388
+        swri_audio_convert(s->in_convert, postin, in, in_count);
389 389
     }
390 390
 
391 391
     if(s->resample_first){
... ...
@@ -402,7 +402,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
402 402
 
403 403
     if(preout != out){
404 404
 //FIXME packed doesnt need more than 1 chan here!
405
-        swr_audio_convert(s->out_convert, out, preout, out_count);
405
+        swri_audio_convert(s->out_convert, out, preout, out_count);
406 406
     }
407 407
     if(!in_arg)
408 408
         s->in_buffer_count = 0;
... ...
@@ -58,9 +58,9 @@ typedef struct SwrContext {          //FIXME find unused fields
58 58
     int in_buffer_count;
59 59
     int resample_in_constraint;
60 60
 
61
-    struct AVAudioConvert *in_convert;
62
-    struct AVAudioConvert *out_convert;
63
-    struct AVAudioConvert *full_convert;
61
+    struct AudioConvert *in_convert;
62
+    struct AudioConvert *out_convert;
63
+    struct AudioConvert *full_convert;
64 64
     struct AVResampleContext *resample;
65 65
 
66 66
     float matrix[SWR_CH_MAX][SWR_CH_MAX];