shithub: opus

Download patch

ref: 8c4877bd5231f47f4624803f88a461739774a9d4
parent: 50bf8b0121378ae259b98549d015a8b48ab2db57
author: Jean-Marc Valin <[email protected]>
date: Mon Apr 21 08:15:16 EDT 2008

Bit better indexing in intra_prediction()

--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -267,7 +267,7 @@
 #define MAX_INTRA 32
 #define LOG_MAX_INTRA 5
       
-void intra_prediction(celt_norm_t *x, celt_mask_t *W, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int B, int N0, ec_enc *enc)
+void intra_prediction(celt_norm_t * restrict x, celt_mask_t *W, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int B, int N0, ec_enc *enc)
 {
    int i,j,c;
    int best=0;
@@ -289,9 +289,15 @@
 
    /* Reverse the samples of x without reversing the channels */
    for (c=0;c<B;c++)
-      for (j=0;j<N;j++)
-         Xr[B*N-B*j-B+c] = x[B*j+c];
-
+   {
+      celt_norm_t * restrict Xrp = &Xr[B*N-B+c];
+      const celt_norm_t * restrict xp = &x[c];
+      j=0; do {
+         *Xrp = *xp;
+         Xrp -= B;
+         xp += B;
+      } while (++j<N); /* Promises we loop at least once */
+   }
    /* Compute yy for i=0 */
    j=0;
    do {
--- a/libcelt/vq.h
+++ b/libcelt/vq.h
@@ -73,7 +73,7 @@
  * @param N0 Number of valid offsets
  * @param enc Entropy encoder state
  */
-void intra_prediction(celt_norm_t *x, celt_mask_t *W, int N, int K, celt_norm_t *Y, celt_norm_t *P, int B, int N0, ec_enc *enc);
+void intra_prediction(celt_norm_t * restrict x, celt_mask_t *W, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int B, int N0, ec_enc *enc);
 
 void intra_unquant(celt_norm_t *x, int N, int K, celt_norm_t *Y, celt_norm_t *P, int B, int N0, ec_dec *dec);