comparison flacdec.c @ 9210:ca10c935dc56 libavcodec

flacdec: cosmetics: rename 'decorrelation' to 'ch_mode'
author jbr
date Sat, 21 Mar 2009 00:47:04 +0000
parents 443f056ba7e7
children 2acf888276af
comparison
equal deleted inserted replaced
9209:514b73a654c9 9210:ca10c935dc56
54 54
55 int blocksize; ///< number of samples in the current frame 55 int blocksize; ///< number of samples in the current frame
56 int curr_bps; ///< bps for current subframe, adjusted for channel correlation and wasted bits 56 int curr_bps; ///< bps for current subframe, adjusted for channel correlation and wasted bits
57 int sample_shift; ///< shift required to make output samples 16-bit or 32-bit 57 int sample_shift; ///< shift required to make output samples 16-bit or 32-bit
58 int is32; ///< flag to indicate if output should be 32-bit instead of 16-bit 58 int is32; ///< flag to indicate if output should be 32-bit instead of 16-bit
59 int decorrelation; ///< channel decorrelation type in the current frame 59 int ch_mode; ///< channel decorrelation type in the current frame
60 int got_streaminfo; ///< indicates if the STREAMINFO has been read 60 int got_streaminfo; ///< indicates if the STREAMINFO has been read
61 61
62 int32_t *decoded[FLAC_MAX_CHANNELS]; ///< decoded samples 62 int32_t *decoded[FLAC_MAX_CHANNELS]; ///< decoded samples
63 uint8_t *bitstream; 63 uint8_t *bitstream;
64 unsigned int bitstream_size; 64 unsigned int bitstream_size;
436 int type, wasted = 0; 436 int type, wasted = 0;
437 int i, tmp; 437 int i, tmp;
438 438
439 s->curr_bps = s->bps; 439 s->curr_bps = s->bps;
440 if (channel == 0) { 440 if (channel == 0) {
441 if (s->decorrelation == FLAC_CHMODE_RIGHT_SIDE) 441 if (s->ch_mode == FLAC_CHMODE_RIGHT_SIDE)
442 s->curr_bps++; 442 s->curr_bps++;
443 } else { 443 } else {
444 if (s->decorrelation == FLAC_CHMODE_LEFT_SIDE || s->decorrelation == FLAC_CHMODE_MID_SIDE) 444 if (s->ch_mode == FLAC_CHMODE_LEFT_SIDE || s->ch_mode == FLAC_CHMODE_MID_SIDE)
445 s->curr_bps++; 445 s->curr_bps++;
446 } 446 }
447 447
448 if (get_bits1(&s->gb)) { 448 if (get_bits1(&s->gb)) {
449 av_log(s->avctx, AV_LOG_ERROR, "invalid subframe padding\n"); 449 av_log(s->avctx, AV_LOG_ERROR, "invalid subframe padding\n");
491 } 491 }
492 492
493 static int decode_frame(FLACContext *s, int alloc_data_size) 493 static int decode_frame(FLACContext *s, int alloc_data_size)
494 { 494 {
495 int blocksize_code, sample_rate_code, sample_size_code, assignment, i, crc8; 495 int blocksize_code, sample_rate_code, sample_size_code, assignment, i, crc8;
496 int decorrelation, bps, blocksize, samplerate; 496 int ch_mode, bps, blocksize, samplerate;
497 497
498 blocksize_code = get_bits(&s->gb, 4); 498 blocksize_code = get_bits(&s->gb, 4);
499 499
500 sample_rate_code = get_bits(&s->gb, 4); 500 sample_rate_code = get_bits(&s->gb, 4);
501 501
502 assignment = get_bits(&s->gb, 4); /* channel assignment */ 502 assignment = get_bits(&s->gb, 4); /* channel assignment */
503 if (assignment < FLAC_MAX_CHANNELS && s->channels == assignment+1) 503 if (assignment < FLAC_MAX_CHANNELS && s->channels == assignment+1)
504 decorrelation = FLAC_CHMODE_INDEPENDENT; 504 ch_mode = FLAC_CHMODE_INDEPENDENT;
505 else if (assignment >= FLAC_MAX_CHANNELS && assignment < 11 && s->channels == 2) 505 else if (assignment >= FLAC_MAX_CHANNELS && assignment < 11 && s->channels == 2)
506 decorrelation = assignment; 506 ch_mode = assignment;
507 else { 507 else {
508 av_log(s->avctx, AV_LOG_ERROR, "unsupported channel assignment %d (channels=%d)\n", 508 av_log(s->avctx, AV_LOG_ERROR, "unsupported channel assignment %d (channels=%d)\n",
509 assignment, s->channels); 509 assignment, s->channels);
510 return -1; 510 return -1;
511 } 511 }
585 } 585 }
586 586
587 s->blocksize = blocksize; 587 s->blocksize = blocksize;
588 s->samplerate = samplerate; 588 s->samplerate = samplerate;
589 s->bps = bps; 589 s->bps = bps;
590 s->decorrelation= decorrelation; 590 s->ch_mode = ch_mode;
591 591
592 // dump_headers(s->avctx, (FLACStreaminfo *)s); 592 // dump_headers(s->avctx, (FLACStreaminfo *)s);
593 593
594 /* subframes */ 594 /* subframes */
595 for (i = 0; i < s->channels; i++) { 595 for (i = 0; i < s->channels; i++) {
700 *samples_16++ = (right) << s->sample_shift;\ 700 *samples_16++ = (right) << s->sample_shift;\
701 }\ 701 }\
702 }\ 702 }\
703 break; 703 break;
704 704
705 switch (s->decorrelation) { 705 switch (s->ch_mode) {
706 case FLAC_CHMODE_INDEPENDENT: 706 case FLAC_CHMODE_INDEPENDENT:
707 for (j = 0; j < s->blocksize; j++) { 707 for (j = 0; j < s->blocksize; j++) {
708 for (i = 0; i < s->channels; i++) { 708 for (i = 0; i < s->channels; i++) {
709 if (s->is32) 709 if (s->is32)
710 *samples_32++ = s->decoded[i][j] << s->sample_shift; 710 *samples_32++ = s->decoded[i][j] << s->sample_shift;