Revision 1402ee72

View differences:

libavcodec/dca.c
67 67
#define DCA_LFE 0x80
68 68

  
69 69
#define HEADER_SIZE 14
70
#define CONVERT_BIAS 384
71 70

  
72 71
#define DCA_MAX_FRAME_SIZE 16384
73 72

  
......
159 158
    int hist_index[DCA_PRIM_CHANNELS_MAX];
160 159

  
161 160
    int output;                 ///< type of output
162
    int bias;                   ///< output bias
161
    float add_bias;             ///< output bias
162
    float scale_bias;           ///< output scale
163 163

  
164 164
    DECLARE_ALIGNED_16(float, samples[1536]);  /* 6 * 256 = 1536, might only need 5 */
165 165
    const float *samples_chanptr[6];
......
230 230
    static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 };
231 231
    static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 };
232 232

  
233
    s->bias = CONVERT_BIAS;
234

  
235 233
    init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);
236 234

  
237 235
    /* Sync code */
......
748 746
            //FIXME the coeffs are symetric, fix that
749 747
            for (j = 0; j < 512 / decifactor; j++)
750 748
                rTmp += samples_in[deciindex - j] * prCoeff[k + j * decifactor];
751
            samples_out[interp_index++] = rTmp / scale + bias;
749
            samples_out[interp_index++] = (rTmp * scale) + bias;
752 750
        }
753 751
    }
754 752
}
......
984 982
/*        static float pcm_to_double[8] =
985 983
            {32768.0, 32768.0, 524288.0, 524288.0, 0, 8388608.0, 8388608.0};*/
986 984
         qmf_32_subbands(s, k, subband_samples[k], &s->samples[256 * k],
987
                            M_SQRT1_2 /*pcm_to_double[s->source_pcm_res] */ ,
988
                            0 /*s->bias */ );
985
                            M_SQRT1_2*s->scale_bias /*pcm_to_double[s->source_pcm_res] */ ,
986
                            s->add_bias );
989 987
    }
990 988

  
991 989
    /* Down mixing */
......
1003 1001
                              s->lfe_data + lfe_samples +
1004 1002
                              2 * s->lfe * subsubframe,
1005 1003
                              &s->samples[256 * i_channels],
1006
                              256.0, 0 /* s->bias */);
1004
                              (1.0/256.0)*s->scale_bias,  s->add_bias);
1007 1005
        /* Outputs 20bits pcm samples */
1008 1006
    }
1009 1007

  
......
1214 1212
    for(i = 0; i < 6; i++)
1215 1213
        s->samples_chanptr[i] = s->samples + i * 256;
1216 1214
    avctx->sample_fmt = SAMPLE_FMT_S16;
1215

  
1216
    if(s->dsp.float_to_int16 == ff_float_to_int16_c) {
1217
        s->add_bias = 385.0f;
1218
        s->scale_bias = 1.0 / 32768.0;
1219
    } else {
1220
        s->add_bias = 0.0f;
1221
        s->scale_bias = 1.0;
1222
    }
1223

  
1224

  
1217 1225
    return 0;
1218 1226
}
1219 1227

  

Also available in: Unified diff