shithub: opus

Download patch

ref: 8848171b2fd695ae1db362286db40b5588005c37
parent: 8ea01eed109b3621f3b9e0186ac017119509a5dc
author: Jean-Marc Valin <[email protected]>
date: Wed Nov 13 06:57:31 EST 2013

Variable frame size fixes (still not exposed in the API)

This fixes an actual error in the downmix (using the float version even
for the int API), as well as a bunch of conversion warnings.

--- a/src/analysis.h
+++ b/src/analysis.h
@@ -60,7 +60,7 @@
    int last_music;
    int last_transition;
    int count;
-   opus_val32   subframe_mem[3];
+   float subframe_mem[3];
    int analysis_offset;
    /** Probability of having speech for time i to DETECT_SIZE-1 (and music before).
        pspeech[0] is the probability that all frames in the window are speech. */
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -686,7 +686,7 @@
 }
 
 int optimize_framesize(const opus_val16 *x, int len, int C, opus_int32 Fs,
-                int bitrate, opus_val16 tonality, opus_val32 *mem, int buffering,
+                int bitrate, opus_val16 tonality, float *mem, int buffering,
                 downmix_func downmix)
 {
    int N;
@@ -693,7 +693,7 @@
    int i;
    float e[MAX_DYNAMIC_FRAMESIZE+4];
    float e_1[MAX_DYNAMIC_FRAMESIZE+3];
-   float memx;
+   opus_val32 memx;
    int bestLM=0;
    int subframe;
    int pos;
@@ -720,11 +720,12 @@
       pos=1;
    }
    N=IMIN(len/subframe, MAX_DYNAMIC_FRAMESIZE);
-   memx = x[0];
+   /* Just silencing a warning, it's really initialized later */
+   memx = 0;
    for (i=0;i<N;i++)
    {
       float tmp;
-      float tmpx;
+      opus_val32 tmpx;
       int j;
       tmp=EPSILON;
 
@@ -734,7 +735,7 @@
       for (j=0;j<subframe;j++)
       {
          tmpx = sub[j];
-         tmp += (tmpx-memx)*(tmpx-memx);
+         tmp += (tmpx-memx)*(float)(tmpx-memx);
          memx = tmpx;
       }
       e[i+pos] = tmp;
@@ -858,7 +859,7 @@
       int variable_duration, int C, opus_int32 Fs, int bitrate_bps,
       int delay_compensation, downmix_func downmix
 #ifndef DISABLE_FLOAT_API
-      , opus_val32 *subframe_mem
+      , float *subframe_mem
 #endif
       )
 {
@@ -1993,7 +1994,7 @@
       delay_compensation = st->delay_compensation;
    frame_size = compute_frame_size(pcm, analysis_frame_size,
          st->variable_duration, st->channels, st->Fs, st->bitrate_bps,
-         delay_compensation, downmix_float
+         delay_compensation, downmix_int
 #ifndef DISABLE_FLOAT_API
          , st->analysis.subframe_mem
 #endif
@@ -2017,7 +2018,7 @@
       delay_compensation = st->delay_compensation;
    frame_size = compute_frame_size(pcm, analysis_frame_size,
          st->variable_duration, st->channels, st->Fs, st->bitrate_bps,
-         delay_compensation, downmix_float, st->analysis.subframe_mem);
+         delay_compensation, downmix_int, st->analysis.subframe_mem);
 
    ALLOC(in, frame_size*st->channels, float);
 
--- a/src/opus_private.h
+++ b/src/opus_private.h
@@ -87,7 +87,7 @@
 void downmix_int(const void *_x, opus_val32 *sub, int subframe, int offset, int c1, int c2, int C);
 
 int optimize_framesize(const opus_val16 *x, int len, int C, opus_int32 Fs,
-                int bitrate, opus_val16 tonality, opus_val32 *mem, int buffering,
+                int bitrate, opus_val16 tonality, float *mem, int buffering,
                 downmix_func downmix);
 
 int encode_size(int size, unsigned char *data);
@@ -98,7 +98,7 @@
       int variable_duration, int C, opus_int32 Fs, int bitrate_bps,
       int delay_compensation, downmix_func downmix
 #ifndef DISABLE_FLOAT_API
-      , opus_val32 *subframe_mem
+      , float *subframe_mem
 #endif
       );