shithub: opus

Download patch

ref: d501f6143caa7adf6a2782a086f195016d9cf588
parent: 5e2196373f0b65a534069d4fcb46c4a06a9ad96a
author: Jean-Marc Valin <[email protected]>
date: Thu Feb 21 07:16:57 EST 2008

Doing intra-frame prediction backwards (and a few comments)

--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -39,7 +39,7 @@
 #include "vq.h"
 #include "cwrs.h"
 
-/* Applies a series of rotations so that pulses are spread like a two-sided
+/** Applies a series of rotations so that pulses are spread like a two-sided
 exponential. The effect of this is to reduce the tonal noise created by the
 sparse spectrum resulting from the pulse codebook */
 static void exp_rotation(float *X, int len, float theta, int dir, int stride, int iter)
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -154,7 +154,7 @@
    celt_free(st);
 }
 
-
+/** Apply window and compute the MDCT for all sub-frames and all channels in a frame */
 static float compute_mdcts(mdct_lookup *mdct_lookup, float *window, float *in, float *out, int N, int B, int C)
 {
    int i, c;
@@ -182,6 +182,7 @@
    return E;
 }
 
+/** Compute the IMDCT and apply window for all sub-frames and all channels in a frame */
 static void compute_inv_mdcts(mdct_lookup *mdct_lookup, float *window, float *X, float *out_mem, float *mdct_overlap, int N, int overlap, int B, int C)
 {
    int i, c, N4;
@@ -506,6 +507,8 @@
    celt_free(st);
 }
 
+/** Handles lost packets by just copying past data with the same offset as the last
+    pitch period */
 static void celt_decode_lost(CELTDecoder *st, short *pcm)
 {
    int i, c, N, B, C;
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -367,8 +367,8 @@
       float score;
       for (j=0;j<N;j++)
       {
-         xy += x[j]*Y[i+j];
-         yy += Y[i+j]*Y[i+j];
+         xy += x[j]*Y[i+N-j-1];
+         yy += Y[i+N-j-1]*Y[i+N-j-1];
       }
       score = xy*xy/(.001+yy);
       if (score > best_score)
@@ -397,7 +397,7 @@
    E = 1e-10;
    for (j=0;j<N;j++)
    {
-      P[j] = s*Y[best+j];
+      P[j] = s*Y[best+N-j-1];
       E += P[j]*P[j];
    }
    E = pred_gain/sqrt(E);
@@ -444,7 +444,7 @@
    E = 1e-10;
    for (j=0;j<N;j++)
    {
-      P[j] = s*Y[best+j];
+      P[j] = s*Y[best+N-j-1];
       E += P[j]*P[j];
    }
    E = pred_gain/sqrt(E);