Revision 0e09997f

View differences:

libavcodec/ac3dec.c
188 188
    ff_fmt_convert_init(&s->fmt_conv, avctx);
189 189
    av_lfg_init(&s->dith_state, 0);
190 190

  
191
    /* ffdshow custom code */
192
#if CONFIG_AUDIO_FLOAT
193
    s->mul_bias = 1.0f;
194
#else
191 195
    /* set scale value for float to int16 conversion */
192 196
    s->mul_bias = 32767.0f;
197
#endif
193 198

  
194 199
    /* allow downmixing to stereo or mono */
195 200
    if (avctx->channels > 0 && avctx->request_channels > 0 &&
......
204 209
        if (!s->input_buffer)
205 210
            return AVERROR(ENOMEM);
206 211

  
212
    /* ffdshow custom code */
213
#if CONFIG_AUDIO_FLOAT
214
    avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
215
#else
207 216
    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
217
#endif
208 218
    return 0;
209 219
}
210 220

  
......
1299 1309
    const uint8_t *buf = avpkt->data;
1300 1310
    int buf_size = avpkt->size;
1301 1311
    AC3DecodeContext *s = avctx->priv_data;
1312
    /* ffdshow custom code */
1313
#if CONFIG_AUDIO_FLOAT
1314
    float *out_samples = (float *)data;
1315
#else
1302 1316
    int16_t *out_samples = (int16_t *)data;
1317
#endif
1303 1318
    int blk, ch, err;
1304 1319
    const uint8_t *channel_map;
1305 1320
    const float *output[AC3_MAX_CHANNELS];
......
1405 1420
            av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");
1406 1421
            err = 1;
1407 1422
        }
1423
        /* ffdshow custom code */
1424
#if CONFIG_AUDIO_FLOAT
1425
        float_interleave_noscale(out_samples, output, 256, s->out_channels);
1426
#else
1408 1427
        s->fmt_conv.float_to_int16_interleave(out_samples, output, 256, s->out_channels);
1428
#endif
1409 1429
        out_samples += 256 * s->out_channels;
1410 1430
    }
1411
    *data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t);
1431
    *data_size = s->num_blocks * 256 * avctx->channels * sizeof (out_samples[0]); /* ffdshow custom code */
1412 1432
    return FFMIN(buf_size, s->frame_size);
1413 1433
}
1414 1434

  
libavcodec/dca.c
1626 1626
    int lfe_samples;
1627 1627
    int num_core_channels = 0;
1628 1628
    int i;
1629
    /* ffdshow custom code */
1630
#if CONFIG_AUDIO_FLOAT
1631
    float *samples = data;
1632
#else
1629 1633
    int16_t *samples = data;
1634
#endif
1630 1635
    DCAContext *s = avctx->priv_data;
1631 1636
    int channels;
1632 1637
    int core_ss_end;
......
1812 1817
        return -1;
1813 1818
    }
1814 1819

  
1815
    if (*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels)
1820
    /* ffdshow custom code */
1821
    if (*data_size < (s->sample_blocks / 8) * 256 * sizeof(samples[0]) * channels)
1816 1822
        return -1;
1817
    *data_size = 256 / 8 * s->sample_blocks * sizeof(int16_t) * channels;
1823
    *data_size = 256 / 8 * s->sample_blocks * sizeof(samples[0]) * channels;
1818 1824

  
1819 1825
    /* filter to get final output */
1820 1826
    for (i = 0; i < (s->sample_blocks / 8); i++) {
......
1833 1839
            }
1834 1840
        }
1835 1841

  
1842
        /* interleave samples */
1843
#if CONFIG_AUDIO_FLOAT
1844
        /* ffdshow custom code */
1845
        float_interleave(samples, s->samples_chanptr, 256, channels);
1846
#else
1836 1847
        s->fmt_conv.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels);
1848
#endif
1837 1849
        samples += 256 * channels;
1838 1850
    }
1839 1851

  
......
1870 1882

  
1871 1883
    for (i = 0; i < DCA_PRIM_CHANNELS_MAX+1; i++)
1872 1884
        s->samples_chanptr[i] = s->samples + i * 256;
1885
    /* ffdshow custom code */
1886
#if CONFIG_AUDIO_FLOAT
1887
    avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
1888
#else
1873 1889
    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
1890
#endif
1874 1891

  
1875 1892
    s->scale_bias = 1.0;
1876 1893

  
libavcodec/fmtconvert.c
66 66
    if (HAVE_ALTIVEC) ff_fmt_convert_init_altivec(c, avctx);
67 67
    if (HAVE_MMX) ff_fmt_convert_init_x86(c, avctx);
68 68
}
69

  
70
/* ffdshow custom code */
71
void float_interleave(float *dst, const float **src, long len, int channels)
72
{
73
    int i,j,c;
74
    if(channels==2){
75
        for(i=0; i<len; i++){
76
            dst[2*i]   = src[0][i] / 32768.0f;
77
            dst[2*i+1] = src[1][i] / 32768.0f;
78
        }
79
    }else{
80
        for(c=0; c<channels; c++)
81
            for(i=0, j=c; i<len; i++, j+=channels)
82
                dst[j] = src[c][i] / 32768.0f;
83
    }
84
}
85

  
86
void float_interleave_noscale(float *dst, const float **src, long len, int channels)
87
{
88
    int i,j,c;
89
    if(channels==2){
90
        for(i=0; i<len; i++){
91
            dst[2*i]   = src[0][i];
92
            dst[2*i+1] = src[1][i];
93
        }
94
    }else{
95
        for(c=0; c<channels; c++)
96
            for(i=0, j=c; i<len; i++, j+=channels)
97
                dst[j] = src[c][i];
98
    }
99
}
libavcodec/fmtconvert.h
76 76
void ff_fmt_convert_init_altivec(FmtConvertContext *c, AVCodecContext *avctx);
77 77
void ff_fmt_convert_init_x86(FmtConvertContext *c, AVCodecContext *avctx);
78 78

  
79
/* ffdshow custom code */
80
void float_interleave(float *dst, const float **src, long len, int channels);
81
void float_interleave_noscale(float *dst, const float **src, long len, int channels);
82

  
79 83
#endif /* AVCODEC_FMTCONVERT_H */

Also available in: Unified diff