Revision f8a93a20

View differences:

libavcodec/aac.c
1719 1719
/**
1720 1720
 * Conduct IMDCT and windowing.
1721 1721
 */
1722
static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce)
1722
static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce, float bias)
1723 1723
{
1724 1724
    IndividualChannelStream *ics = &sce->ics;
1725 1725
    float *in    = sce->coeffs;
......
1751 1751
     */
1752 1752
    if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) &&
1753 1753
            (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) {
1754
        ac->dsp.vector_fmul_window(    out,               saved,            buf,         lwindow_prev, ac->add_bias, 512);
1754
        ac->dsp.vector_fmul_window(    out,               saved,            buf,         lwindow_prev, bias, 512);
1755 1755
    } else {
1756 1756
        for (i = 0; i < 448; i++)
1757
            out[i] = saved[i] + ac->add_bias;
1757
            out[i] = saved[i] + bias;
1758 1758

  
1759 1759
        if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
1760
            ac->dsp.vector_fmul_window(out + 448 + 0*128, saved + 448,      buf + 0*128, swindow_prev, ac->add_bias, 64);
1761
            ac->dsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow,      ac->add_bias, 64);
1762
            ac->dsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow,      ac->add_bias, 64);
1763
            ac->dsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow,      ac->add_bias, 64);
1764
            ac->dsp.vector_fmul_window(temp,              buf + 3*128 + 64, buf + 4*128, swindow,      ac->add_bias, 64);
1760
            ac->dsp.vector_fmul_window(out + 448 + 0*128, saved + 448,      buf + 0*128, swindow_prev, bias, 64);
1761
            ac->dsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow,      bias, 64);
1762
            ac->dsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow,      bias, 64);
1763
            ac->dsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow,      bias, 64);
1764
            ac->dsp.vector_fmul_window(temp,              buf + 3*128 + 64, buf + 4*128, swindow,      bias, 64);
1765 1765
            memcpy(                    out + 448 + 4*128, temp, 64 * sizeof(float));
1766 1766
        } else {
1767
            ac->dsp.vector_fmul_window(out + 448,         saved + 448,      buf,         swindow_prev, ac->add_bias, 64);
1767
            ac->dsp.vector_fmul_window(out + 448,         saved + 448,      buf,         swindow_prev, bias, 64);
1768 1768
            for (i = 576; i < 1024; i++)
1769
                out[i] = buf[i-512] + ac->add_bias;
1769
                out[i] = buf[i-512] + bias;
1770 1770
        }
1771 1771
    }
1772 1772

  
1773 1773
    // buffer update
1774 1774
    if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
1775 1775
        for (i = 0; i < 64; i++)
1776
            saved[i] = temp[64 + i] - ac->add_bias;
1776
            saved[i] = temp[64 + i] - bias;
1777 1777
        ac->dsp.vector_fmul_window(saved + 64,  buf + 4*128 + 64, buf + 5*128, swindow, 0, 64);
1778 1778
        ac->dsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 0, 64);
1779 1779
        ac->dsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 0, 64);
......
1884 1884
static void spectral_to_sample(AACContext *ac)
1885 1885
{
1886 1886
    int i, type;
1887
    float imdct_bias = (ac->m4ac.sbr <= 0) ? ac->add_bias : 0.0f;
1887 1888
    for (type = 3; type >= 0; type--) {
1888 1889
        for (i = 0; i < MAX_ELEM_ID; i++) {
1889 1890
            ChannelElement *che = ac->che[type][i];
......
1897 1898
                if (type <= TYPE_CPE)
1898 1899
                    apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling);
1899 1900
                if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) {
1900
                    imdct_and_windowing(ac, &che->ch[0]);
1901
                    imdct_and_windowing(ac, &che->ch[0], imdct_bias);
1901 1902
                    if (ac->m4ac.sbr > 0) {
1902 1903
                        ff_sbr_dequant(ac, &che->sbr, type == TYPE_CPE ? TYPE_CPE : TYPE_SCE);
1903 1904
                        ff_sbr_apply(ac, &che->sbr, 0, che->ch[0].ret, che->ch[0].ret);
1904 1905
                    }
1905 1906
                }
1906 1907
                if (type == TYPE_CPE) {
1907
                    imdct_and_windowing(ac, &che->ch[1]);
1908
                    imdct_and_windowing(ac, &che->ch[1], imdct_bias);
1908 1909
                    if (ac->m4ac.sbr > 0)
1909 1910
                        ff_sbr_apply(ac, &che->sbr, 1, che->ch[1].ret, che->ch[1].ret);
1910 1911
                }
libavcodec/aacsbr.c
1126 1126
 */
1127 1127
static void sbr_qmf_analysis(DSPContext *dsp, RDFTContext *rdft, const float *in, float *x,
1128 1128
                             float z[320], float W[2][32][32][2],
1129
                             float bias, float scale)
1129
                             float scale)
1130 1130
{
1131 1131
    int i, k;
1132 1132
    memcpy(W[0], W[1], sizeof(W[0]));
1133 1133
    memcpy(x    , x+1024, (320-32)*sizeof(x[0]));
1134
    if (scale != 1.0f || bias != 0.0f)
1134
    if (scale != 1.0f)
1135 1135
        for (i = 0; i < 1024; i++)
1136
            x[288 + i] = (in[i] - bias) * scale;
1136
            x[288 + i] = in[i] * scale;
1137 1137
    else
1138 1138
        memcpy(x+288, in, 1024*sizeof(*x));
1139 1139
    for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames
......
1719 1719
    /* decode channel */
1720 1720
    sbr_qmf_analysis(&ac->dsp, &sbr->rdft, in, sbr->data[ch].analysis_filterbank_samples,
1721 1721
                     (float*)sbr->qmf_filter_scratch,
1722
                     sbr->data[ch].W, ac->add_bias, 1/(-1024 * ac->sf_scale));
1722
                     sbr->data[ch].W, 1/(-1024 * ac->sf_scale));
1723 1723
    sbr_lf_gen(ac, sbr, sbr->X_low, sbr->data[ch].W);
1724 1724
    if (sbr->start) {
1725 1725
        sbr_hf_inverse_filter(sbr->alpha0, sbr->alpha1, sbr->X_low, sbr->k[0]);

Also available in: Unified diff