]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/resample.c
Use DECLARE_ALIGNED in yet another place
[ffmpeg] / libavcodec / resample.c
index 55ece0e1cbb0a187f707d06d8768de471b37f607..c6547d8d8178f215bd1caabaf6f94a302212bfbc 100644 (file)
@@ -1,25 +1,27 @@
 /*
- * Sample rate convertion for both audio and video
+ * samplerate conversion for both audio and video
  * Copyright (c) 2000 Fabrice Bellard.
  *
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /**
  * @file resample.c
- * Sample rate convertion for both audio and video.
+ * samplerate conversion for both audio and video
  */
 
 #include "avcodec.h"
@@ -131,14 +133,14 @@ ReSampleContext *audio_resample_init(int output_channels, int input_channels,
 
     if ( input_channels > 2)
       {
-        av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported.");
+        av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported.\n");
         return NULL;
       }
 
     s = av_mallocz(sizeof(ReSampleContext));
     if (!s)
       {
-        av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for resample context.");
+        av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for resample context.\n");
         return NULL;
       }
 
@@ -159,7 +161,8 @@ ReSampleContext *audio_resample_init(int output_channels, int input_channels,
     if(s->filter_channels>2)
       s->filter_channels = 2;
 
-    s->resample_context= av_resample_init(output_rate, input_rate, 16, 10, 0, 1.0);
+#define TAPS 16
+    s->resample_context= av_resample_init(output_rate, input_rate, TAPS, 10, 0, 0.8);
 
     return s;
 }
@@ -182,15 +185,15 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl
 
     /* XXX: move those malloc to resample init code */
     for(i=0; i<s->filter_channels; i++){
-        bufin[i]= (short*) av_malloc( (nb_samples + s->temp_len) * sizeof(short) );
+        bufin[i]= av_malloc( (nb_samples + s->temp_len) * sizeof(short) );
         memcpy(bufin[i], s->temp[i], s->temp_len * sizeof(short));
         buftmp2[i] = bufin[i] + s->temp_len;
     }
 
     /* make some zoom to avoid round pb */
-    lenout= (int)(nb_samples * s->ratio) + 16;
-    bufout[0]= (short*) av_malloc( lenout * sizeof(short) );
-    bufout[1]= (short*) av_malloc( lenout * sizeof(short) );
+    lenout= 4*nb_samples * s->ratio + 16;
+    bufout[0]= av_malloc( lenout * sizeof(short) );
+    bufout[1]= av_malloc( lenout * sizeof(short) );
 
     if (s->input_channels == 2 &&
         s->output_channels == 1) {