comparison wmadec.c @ 7243:158c8bc08f81 libavcodec

Fix not coded channels / silence decoding. Fixes issue264 WMV audio stutter
author michael
date Fri, 11 Jul 2008 19:51:36 +0000
parents d90bc6cc1bfd
children 9aa321d5d510
comparison
equal deleted inserted replaced
7242:d90bc6cc1bfd 7243:158c8bc08f81
399 for(ch = 0; ch < s->nb_channels; ch++) { 399 for(ch = 0; ch < s->nb_channels; ch++) {
400 a = get_bits1(&s->gb); 400 a = get_bits1(&s->gb);
401 s->channel_coded[ch] = a; 401 s->channel_coded[ch] = a;
402 v |= a; 402 v |= a;
403 } 403 }
404
405 bsize = s->frame_len_bits - s->block_len_bits;
406
404 /* if no channel coded, no need to go further */ 407 /* if no channel coded, no need to go further */
405 /* XXX: fix potential framing problems */ 408 /* XXX: fix potential framing problems */
406 if (!v) 409 if (!v)
407 goto next; 410 goto next;
408
409 bsize = s->frame_len_bits - s->block_len_bits;
410 411
411 /* read total gain and extract corresponding number of bits for 412 /* read total gain and extract corresponding number of bits for
412 coef escape coding */ 413 coef escape coding */
413 total_gain = 1; 414 total_gain = 1;
414 for(;;) { 415 for(;;) {
677 s->coefs[0][i] = a + b; 678 s->coefs[0][i] = a + b;
678 s->coefs[1][i] = a - b; 679 s->coefs[1][i] = a - b;
679 } 680 }
680 } 681 }
681 682
683 next:
682 for(ch = 0; ch < s->nb_channels; ch++) { 684 for(ch = 0; ch < s->nb_channels; ch++) {
683 if (s->channel_coded[ch]) {
684 int n4, index, n; 685 int n4, index, n;
685 686
686 n = s->block_len; 687 n = s->block_len;
687 n4 = s->block_len / 2; 688 n4 = s->block_len / 2;
689 if(s->channel_coded[ch]){
688 s->mdct_ctx[bsize].fft.imdct_calc(&s->mdct_ctx[bsize], 690 s->mdct_ctx[bsize].fft.imdct_calc(&s->mdct_ctx[bsize],
689 s->output, s->coefs[ch], s->mdct_tmp); 691 s->output, s->coefs[ch], s->mdct_tmp);
692 }else
693 memset(s->output, 0, sizeof(s->output));
690 694
691 /* multiply by the window and add in the frame */ 695 /* multiply by the window and add in the frame */
692 index = (s->frame_len / 2) + s->block_pos - n4; 696 index = (s->frame_len / 2) + s->block_pos - n4;
693 wma_window(s, &s->frame_out[ch][index]); 697 wma_window(s, &s->frame_out[ch][index]);
694 698
695 /* specific fast case for ms-stereo : add to second 699 /* specific fast case for ms-stereo : add to second
696 channel if it is not coded */ 700 channel if it is not coded */
697 if (s->ms_stereo && !s->channel_coded[1]) { 701 if (s->ms_stereo && !s->channel_coded[1]) {
698 wma_window(s, &s->frame_out[1][index]); 702 wma_window(s, &s->frame_out[1][index]);
699 } 703 }
700 } 704 }
701 } 705
702 next:
703 /* update block number */ 706 /* update block number */
704 s->block_num++; 707 s->block_num++;
705 s->block_pos += s->block_len; 708 s->block_pos += s->block_len;
706 if (s->block_pos >= s->frame_len) 709 if (s->block_pos >= s->frame_len)
707 return 1; 710 return 1;