]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/af_headphone.c
doc/APIchanges: add hashes and version numbers for recent entries
[ffmpeg] / libavfilter / af_headphone.c
index 8b0a431c4566223e8f187c290d32a51da8daaee8..ad6195662b6447f2d0e7eb083a3d3872c61a072e 100644 (file)
@@ -163,23 +163,22 @@ static int headphone_convolute(AVFilterContext *ctx, void *arg, int jobnr, int n
     }
 
     for (i = 0; i < in->nb_samples; i++) {
-        const float *temp_ir = ir;
+        const float *cur_ir = ir;
 
         *dst = 0;
         for (l = 0; l < in_channels; l++) {
             *(buffer[l] + wr) = src[l];
         }
 
-        for (l = 0; l < in_channels; l++) {
+        for (l = 0; l < in_channels; cur_ir += air_len, l++) {
             const float *const bptr = buffer[l];
 
             if (l == s->lfe_channel) {
                 *dst += *(buffer[s->lfe_channel] + wr) * s->gain_lfe;
-                temp_ir += air_len;
                 continue;
             }
 
-            read = (wr - (ir_len - 1) + buffer_length) & modulo;
+            read = (wr - (ir_len - 1)) & modulo;
 
             if (read + ir_len < buffer_length) {
                 memcpy(temp_src, bptr + read, ir_len * sizeof(*temp_src));
@@ -190,8 +189,7 @@ static int headphone_convolute(AVFilterContext *ctx, void *arg, int jobnr, int n
                 memcpy(temp_src + len, bptr, (air_len - len) * sizeof(*temp_src));
             }
 
-            dst[0] += s->scalarproduct_float(temp_ir, temp_src, FFALIGN(ir_len, 32));
-            temp_ir += air_len;
+            dst[0] += s->scalarproduct_float(cur_ir, temp_src, FFALIGN(ir_len, 32));
         }
 
         if (fabsf(dst[0]) > 1)
@@ -283,6 +281,8 @@ static int headphone_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
 
     for (j = 0; j < in->nb_samples; j++) {
         dst[2 * j] += fft_acc[j].re * fft_scale;
+        if (fabsf(dst[2 * j]) > 1)
+            n_clippings[0]++;
     }
 
     for (j = 0; j < ir_len - 1; j++) {
@@ -291,14 +291,6 @@ static int headphone_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
         *(ringbuffer + write_pos) += fft_acc[in->nb_samples + j].re * fft_scale;
     }
 
-    for (i = 0; i < out->nb_samples; i++) {
-        if (fabsf(dst[0]) > 1) {
-            n_clippings[0]++;
-        }
-
-        dst += 2;
-    }
-
     *write = wr;
 
     return 0;
@@ -752,7 +744,7 @@ static const AVFilterPad outputs[] = {
     { NULL }
 };
 
-AVFilter ff_af_headphone = {
+const AVFilter ff_af_headphone = {
     .name          = "headphone",
     .description   = NULL_IF_CONFIG_SMALL("Apply headphone binaural spatialization with HRTFs in additional streams."),
     .priv_size     = sizeof(HeadphoneContext),