Revision 5a2f421a

View differences:

libavcodec/pcm.c
26 26

  
27 27
#include "avcodec.h"
28 28
#include "bitstream.h" // for ff_reverse
29
#include "bytestream.h"
29 30

  
30 31
/* from g711.c by SUN microsystems (unrestricted use) */
31 32

  
......
248 249
            uint32_t tmp = ff_reverse[*samples >> 8] +
249 250
                           (ff_reverse[*samples & 0xff] << 8);
250 251
            tmp <<= 4; // sync flags would go here
251
            dst[2] = tmp & 0xff;
252
            tmp >>= 8;
253
            dst[1] = tmp & 0xff;
254
            dst[0] = tmp >> 8;
252
            bytestream_put_be24(&dst, tmp);
255 253
            samples++;
256
            dst += 3;
257 254
        }
258 255
        break;
259 256
    case CODEC_ID_PCM_S16LE:
260 257
        for(;n>0;n--) {
261 258
            v = *samples++;
262
            dst[0] = v & 0xff;
263
            dst[1] = v >> 8;
264
            dst += 2;
259
            bytestream_put_le16(&dst, v);
265 260
        }
266 261
        break;
267 262
    case CODEC_ID_PCM_S16BE:
268 263
        for(;n>0;n--) {
269 264
            v = *samples++;
270
            dst[0] = v >> 8;
271
            dst[1] = v;
272
            dst += 2;
265
            bytestream_put_be16(&dst, v);
273 266
        }
274 267
        break;
275 268
    case CODEC_ID_PCM_U16LE:
276 269
        for(;n>0;n--) {
277 270
            v = *samples++;
278 271
            v += 0x8000;
279
            dst[0] = v & 0xff;
280
            dst[1] = v >> 8;
281
            dst += 2;
272
            bytestream_put_le16(&dst, v);
282 273
        }
283 274
        break;
284 275
    case CODEC_ID_PCM_U16BE:
285 276
        for(;n>0;n--) {
286 277
            v = *samples++;
287 278
            v += 0x8000;
288
            dst[0] = v >> 8;
289
            dst[1] = v;
290
            dst += 2;
279
            bytestream_put_be16(&dst, v);
291 280
        }
292 281
        break;
293 282
    case CODEC_ID_PCM_S8:
......
425 414
    case CODEC_ID_PCM_S24DAUD:
426 415
        n = buf_size / 3;
427 416
        for(;n>0;n--) {
428
          uint32_t v = src[0] << 16 | src[1] << 8 | src[2];
417
          uint32_t v = bytestream_get_be24(&src);
429 418
          v >>= 4; // sync flags are here
430 419
          *samples++ = ff_reverse[(v >> 8) & 0xff] +
431 420
                       (ff_reverse[v & 0xff] << 8);
432
          src += 3;
433 421
        }
434 422
        break;
435 423
    case CODEC_ID_PCM_S16LE:
436 424
        n = buf_size >> 1;
437 425
        for(;n>0;n--) {
438
            *samples++ = src[0] | (src[1] << 8);
439
            src += 2;
426
            *samples++ = bytestream_get_le16(&src);
440 427
        }
441 428
        break;
442 429
    case CODEC_ID_PCM_S16BE:
443 430
        n = buf_size >> 1;
444 431
        for(;n>0;n--) {
445
            *samples++ = (src[0] << 8) | src[1];
446
            src += 2;
432
            *samples++ = bytestream_get_be16(&src);
447 433
        }
448 434
        break;
449 435
    case CODEC_ID_PCM_U16LE:
450 436
        n = buf_size >> 1;
451 437
        for(;n>0;n--) {
452
            *samples++ = (src[0] | (src[1] << 8)) - 0x8000;
453
            src += 2;
438
            *samples++ = bytestream_get_le16(&src) - 0x8000;
454 439
        }
455 440
        break;
456 441
    case CODEC_ID_PCM_U16BE:
457 442
        n = buf_size >> 1;
458 443
        for(;n>0;n--) {
459
            *samples++ = ((src[0] << 8) | src[1]) - 0x8000;
460
            src += 2;
444
            *samples++ = bytestream_get_be16(&src) - 0x8000;
461 445
        }
462 446
        break;
463 447
    case CODEC_ID_PCM_S8:

Also available in: Unified diff