]> git.sesse.net Git - ffmpeg/commitdiff
lavr: do not pass sample count as a parameter to ff_audio_convert()
authorJustin Ruggles <justin.ruggles@gmail.com>
Thu, 1 Nov 2012 04:44:11 +0000 (00:44 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Tue, 27 Nov 2012 21:49:18 +0000 (16:49 -0500)
It will always be the number of samples in the input buffer, so just use that
directly instead of passing it as a separate parameter.

libavresample/audio_convert.c
libavresample/audio_convert.h
libavresample/utils.c

index e9835c8e8b9010b7df6b485d5ca9a754af21da70..dcf8a39b0632039b7b1bc78e9373247fa1658afc 100644 (file)
@@ -284,9 +284,10 @@ AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr,
     return ac;
 }
 
-int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in, int len)
+int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in)
 {
     int use_generic = 1;
+    int len         = in->nb_samples;
 
     /* determine whether to use the optimized function based on pointer and
        samples alignment in both the input and output */
index 2b8bface7d26b563f9530b9d64fac90a121c49ee..bc2722314035f4742f85a0855ce0da31a4dd6ffd 100644 (file)
@@ -72,13 +72,16 @@ AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr,
  * examined to determine whether to use the generic or optimized conversion
  * function (when available).
  *
+ * The number of samples to convert is determined by in->nb_samples. The output
+ * buffer must be large enough to handle this many samples. out->nb_samples is
+ * set by this function before a successful return.
+ *
  * @param ac     AudioConvert context
  * @param out    output audio data
  * @param in     input audio data
- * @param len    number of samples to convert
  * @return       0 on success, negative AVERROR code on failure
  */
-int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in, int len);
+int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in);
 
 /* arch-specific initialization functions */
 
index 2d15e37c4b3a8bc7a133dcfe4331ef8e435d5fe7..20b5fb1eeacf0b0117c6eee7ac9be0dd30f9f67f 100644 (file)
@@ -313,8 +313,8 @@ int attribute_align_arg avresample_convert(AVAudioResampleContext *avr,
                 if (ret < 0)
                     return ret;
                 av_dlog(avr, "[convert] %s to in_buffer\n", current_buffer->name);
-                ret = ff_audio_convert(avr->ac_in, avr->in_buffer, current_buffer,
-                                       current_buffer->nb_samples);
+                ret = ff_audio_convert(avr->ac_in, avr->in_buffer,
+                                       current_buffer);
                 if (ret < 0)
                     return ret;
             } else {
@@ -381,8 +381,7 @@ int attribute_align_arg avresample_convert(AVAudioResampleContext *avr,
         if (direct_output && out_samples >= current_buffer->nb_samples) {
             /* convert directly to output */
             av_dlog(avr, "[convert] %s to output\n", current_buffer->name);
-            ret = ff_audio_convert(avr->ac_out, &output_buffer, current_buffer,
-                                   current_buffer->nb_samples);
+            ret = ff_audio_convert(avr->ac_out, &output_buffer, current_buffer);
             if (ret < 0)
                 return ret;
 
@@ -395,7 +394,7 @@ int attribute_align_arg avresample_convert(AVAudioResampleContext *avr,
                 return ret;
             av_dlog(avr, "[convert] %s to out_buffer\n", current_buffer->name);
             ret = ff_audio_convert(avr->ac_out, avr->out_buffer,
-                                   current_buffer, current_buffer->nb_samples);
+                                   current_buffer);
             if (ret < 0)
                 return ret;
             current_buffer = avr->out_buffer;