[FFmpeg-devel] [PATCH] allow non-repeating pulse vectors in ff_set_fixed_vector()

Ronald S. Bultje rsbultje
Thu Jan 28 15:39:12 CET 2010


Hi,

$subj, used in WMAVoice and adapted from a previous patch by Mans'
suggestions on how to make optimal code with gcc. The nice thing is
that the default behaviour (repeat) can be done in a one-liner for all
items in the array, whereas complex behaviour (like WMAVoice,
no-repeat) can be done in ways that punishes that decoder alone, not
others. (hence the "no-repeat" instead of "repeat").

Ronald
-------------- next part --------------
Index: libavcodec/acelp_vectors.c
===================================================================
--- libavcodec/acelp_vectors.c	(revision 21510)
+++ libavcodec/acelp_vectors.c	(working copy)
@@ -164,6 +164,7 @@
     int i;
     int mask = (1 << bits) - 1;
 
+    fixed_sparse->no_repeat_mask = 0;
     fixed_sparse->n = 2 * half_pulse_count;
     for (i = 0; i < half_pulse_count; i++) {
         const int pos1   = gray_decode[fixed_index[2*i+1] & mask] + i;
@@ -243,14 +244,14 @@
     int i;
 
     for (i=0; i < in->n; i++) {
-        int x   = in->x[i];
+        int x   = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1);
         float y = in->y[i] * scale;
 
         do {
             out[x] += y;
             y *= in->pitch_fac;
             x += in->pitch_lag;
-        } while (x < size);
+        } while (x < size && repeats);
     }
 }
 
@@ -259,11 +260,11 @@
     int i;
 
     for (i=0; i < in->n; i++) {
-        int x  = in->x[i];
+        int x  = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1);
 
         do {
             out[x] = 0.0;
             x += in->pitch_lag;
-        } while (x < size);
+        } while (x < size && repeats);
     }
 }
Index: libavcodec/acelp_vectors.h
===================================================================
--- libavcodec/acelp_vectors.h	(revision 21350)
+++ libavcodec/acelp_vectors.h	(working copy)
@@ -30,6 +30,7 @@
     int      n;
     int      x[10];
     float    y[10];
+    int      no_repeat_mask;
     int      pitch_lag;
     float    pitch_fac;
 } AMRFixed;



More information about the ffmpeg-devel mailing list