comparison resample.c @ 2967:ef2149182f1c libavcodec

COSMETICS: Remove all trailing whitespace.
author diego
date Sat, 17 Dec 2005 18:14:38 +0000
parents e25782262d7d
children bfabfdf9ce55
comparison
equal deleted inserted replaced
2966:564788471dd4 2967:ef2149182f1c
122 *output++ = 0; /* right surroud */ 122 *output++ = 0; /* right surroud */
123 *output++ = 0; /* low freq */ 123 *output++ = 0; /* low freq */
124 } 124 }
125 } 125 }
126 126
127 ReSampleContext *audio_resample_init(int output_channels, int input_channels, 127 ReSampleContext *audio_resample_init(int output_channels, int input_channels,
128 int output_rate, int input_rate) 128 int output_rate, int input_rate)
129 { 129 {
130 ReSampleContext *s; 130 ReSampleContext *s;
131 131
132 if ( input_channels > 2) 132 if ( input_channels > 2)
133 { 133 {
134 av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported."); 134 av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported.");
135 return NULL; 135 return NULL;
136 } 136 }
141 av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for resample context."); 141 av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for resample context.");
142 return NULL; 142 return NULL;
143 } 143 }
144 144
145 s->ratio = (float)output_rate / (float)input_rate; 145 s->ratio = (float)output_rate / (float)input_rate;
146 146
147 s->input_channels = input_channels; 147 s->input_channels = input_channels;
148 s->output_channels = output_channels; 148 s->output_channels = output_channels;
149 149
150 s->filter_channels = s->input_channels; 150 s->filter_channels = s->input_channels;
151 if (s->output_channels < s->filter_channels) 151 if (s->output_channels < s->filter_channels)
152 s->filter_channels = s->output_channels; 152 s->filter_channels = s->output_channels;
153 153
154 /* 154 /*
158 */ 158 */
159 if(s->filter_channels>2) 159 if(s->filter_channels>2)
160 s->filter_channels = 2; 160 s->filter_channels = 2;
161 161
162 s->resample_context= av_resample_init(output_rate, input_rate, 16, 10, 0, 1.0); 162 s->resample_context= av_resample_init(output_rate, input_rate, 16, 10, 0, 1.0);
163 163
164 return s; 164 return s;
165 } 165 }
166 166
167 /* resample audio. 'nb_samples' is the number of input samples */ 167 /* resample audio. 'nb_samples' is the number of input samples */
168 /* XXX: optimize it ! */ 168 /* XXX: optimize it ! */
184 for(i=0; i<s->filter_channels; i++){ 184 for(i=0; i<s->filter_channels; i++){
185 bufin[i]= (short*) av_malloc( (nb_samples + s->temp_len) * sizeof(short) ); 185 bufin[i]= (short*) av_malloc( (nb_samples + s->temp_len) * sizeof(short) );
186 memcpy(bufin[i], s->temp[i], s->temp_len * sizeof(short)); 186 memcpy(bufin[i], s->temp[i], s->temp_len * sizeof(short));
187 buftmp2[i] = bufin[i] + s->temp_len; 187 buftmp2[i] = bufin[i] + s->temp_len;
188 } 188 }
189 189
190 /* make some zoom to avoid round pb */ 190 /* make some zoom to avoid round pb */
191 lenout= (int)(nb_samples * s->ratio) + 16; 191 lenout= (int)(nb_samples * s->ratio) + 16;
192 bufout[0]= (short*) av_malloc( lenout * sizeof(short) ); 192 bufout[0]= (short*) av_malloc( lenout * sizeof(short) );
193 bufout[1]= (short*) av_malloc( lenout * sizeof(short) ); 193 bufout[1]= (short*) av_malloc( lenout * sizeof(short) );
194 194