Revision 7d5aaa04 libavcodec/pcm.c

View differences:

libavcodec/pcm.c
169 169
 */
170 170
static inline void encode_from16(int bps, int le, int us,
171 171
                               short **samples, uint8_t **dst, int n) {
172
    int usum = us ? 0x8000 : 0;
172 173
    if (bps > 2)
173 174
        memset(*dst, 0, n * bps);
174 175
    if (le) *dst += bps - 2;
175 176
    for(;n>0;n--) {
176 177
        register int v = *(*samples)++;
177
        if (us) v += 0x8000;
178
        v += usum;
178 179
        (*dst)[le] = v >> 8;
179 180
        (*dst)[1 - le] = v;
180 181
        *dst += bps;
......
361 362
static inline void decode_to16(int bps, int le, int us,
362 363
                               uint8_t **src, short **samples, int src_len)
363 364
{
365
    int usum = us ? -0x8000 : 0;
364 366
    register int n = src_len / bps;
365 367
    if (le) *src += bps - 2;
366 368
    for(;n>0;n--) {
367
        *(*samples)++ = ((*src)[le] << 8 | (*src)[1 - le]) - (us?0x8000:0);
369
        *(*samples)++ = ((*src)[le] << 8 | (*src)[1 - le]) + usum;
368 370
        *src += bps;
369 371
    }
370 372
    if (le) *src -= bps - 2;

Also available in: Unified diff