Mercurial > libavcodec.hg
comparison resample.c @ 9834:ce317c75222d libavcodec
give s->resample_context to avoid segfault, avclass was moved
author | bcoudurier |
---|---|
date | Thu, 11 Jun 2009 08:14:50 +0000 |
parents | fff66291d84d |
children | ff9ae6249d18 |
comparison
equal
deleted
inserted
replaced
9833:2023caf1ccd5 | 9834:ce317c75222d |
---|---|
255 if (!s->buffer_size[0] || s->buffer_size[0] < input_size) { | 255 if (!s->buffer_size[0] || s->buffer_size[0] < input_size) { |
256 av_free(s->buffer[0]); | 256 av_free(s->buffer[0]); |
257 s->buffer_size[0] = input_size; | 257 s->buffer_size[0] = input_size; |
258 s->buffer[0] = av_malloc(s->buffer_size[0]); | 258 s->buffer[0] = av_malloc(s->buffer_size[0]); |
259 if (!s->buffer[0]) { | 259 if (!s->buffer[0]) { |
260 av_log(s, AV_LOG_ERROR, "Could not allocate buffer\n"); | 260 av_log(s->resample_context, AV_LOG_ERROR, "Could not allocate buffer\n"); |
261 return 0; | 261 return 0; |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 obuf[0] = s->buffer[0]; | 265 obuf[0] = s->buffer[0]; |
266 | 266 |
267 if (av_audio_convert(s->convert_ctx[0], obuf, ostride, | 267 if (av_audio_convert(s->convert_ctx[0], obuf, ostride, |
268 ibuf, istride, nb_samples*s->input_channels) < 0) { | 268 ibuf, istride, nb_samples*s->input_channels) < 0) { |
269 av_log(s, AV_LOG_ERROR, "Audio sample format conversion failed\n"); | 269 av_log(s->resample_context, AV_LOG_ERROR, "Audio sample format conversion failed\n"); |
270 return 0; | 270 return 0; |
271 } | 271 } |
272 | 272 |
273 input = s->buffer[0]; | 273 input = s->buffer[0]; |
274 } | 274 } |
281 if (!s->buffer_size[1] || s->buffer_size[1] < lenout) { | 281 if (!s->buffer_size[1] || s->buffer_size[1] < lenout) { |
282 av_free(s->buffer[1]); | 282 av_free(s->buffer[1]); |
283 s->buffer_size[1] = lenout; | 283 s->buffer_size[1] = lenout; |
284 s->buffer[1] = av_malloc(s->buffer_size[1]); | 284 s->buffer[1] = av_malloc(s->buffer_size[1]); |
285 if (!s->buffer[1]) { | 285 if (!s->buffer[1]) { |
286 av_log(s, AV_LOG_ERROR, "Could not allocate buffer\n"); | 286 av_log(s->resample_context, AV_LOG_ERROR, "Could not allocate buffer\n"); |
287 return 0; | 287 return 0; |
288 } | 288 } |
289 } | 289 } |
290 | 290 |
291 output = s->buffer[1]; | 291 output = s->buffer[1]; |
346 const void *ibuf[1] = { output }; | 346 const void *ibuf[1] = { output }; |
347 void *obuf[1] = { output_bak }; | 347 void *obuf[1] = { output_bak }; |
348 | 348 |
349 if (av_audio_convert(s->convert_ctx[1], obuf, ostride, | 349 if (av_audio_convert(s->convert_ctx[1], obuf, ostride, |
350 ibuf, istride, nb_samples1*s->output_channels) < 0) { | 350 ibuf, istride, nb_samples1*s->output_channels) < 0) { |
351 av_log(s, AV_LOG_ERROR, "Audio sample format convertion failed\n"); | 351 av_log(s->resample_context, AV_LOG_ERROR, "Audio sample format convertion failed\n"); |
352 return 0; | 352 return 0; |
353 } | 353 } |
354 } | 354 } |
355 | 355 |
356 for(i=0; i<s->filter_channels; i++) | 356 for(i=0; i<s->filter_channels; i++) |