comparison wmadec.c @ 4600:6ac364a4ce2b libavcodec

Supply context to tprintf
author mbardiaux
date Tue, 27 Feb 2007 09:39:04 +0000
parents 3975e734e07e
children 7b9ce6f729ae
comparison
equal deleted inserted replaced
4599:2cd245d65761 4600:6ac364a4ce2b
46 #define HGAINMAX ((13+HGAINVLCBITS-1)/HGAINVLCBITS) 46 #define HGAINMAX ((13+HGAINVLCBITS-1)/HGAINVLCBITS)
47 47
48 static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len); 48 static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len);
49 49
50 #ifdef TRACE 50 #ifdef TRACE
51 static void dump_shorts(const char *name, const short *tab, int n) 51 static void dump_shorts(WMADecodeContext *s, const char *name, const short *tab, int n)
52 { 52 {
53 int i; 53 int i;
54 54
55 tprintf("%s[%d]:\n", name, n); 55 tprintf(s->avctx, "%s[%d]:\n", name, n);
56 for(i=0;i<n;i++) { 56 for(i=0;i<n;i++) {
57 if ((i & 7) == 0) 57 if ((i & 7) == 0)
58 tprintf("%4d: ", i); 58 tprintf(s->avctx, "%4d: ", i);
59 tprintf(" %5d.0", tab[i]); 59 tprintf(s->avctx, " %5d.0", tab[i]);
60 if ((i & 7) == 7) 60 if ((i & 7) == 7)
61 tprintf("\n"); 61 tprintf(s->avctx, "\n");
62 } 62 }
63 } 63 }
64 64
65 static void dump_floats(const char *name, int prec, const float *tab, int n) 65 static void dump_floats(WMADecodeContext *s, const char *name, int prec, const float *tab, int n)
66 { 66 {
67 int i; 67 int i;
68 68
69 tprintf("%s[%d]:\n", name, n); 69 tprintf(s->avctx, "%s[%d]:\n", name, n);
70 for(i=0;i<n;i++) { 70 for(i=0;i<n;i++) {
71 if ((i & 7) == 0) 71 if ((i & 7) == 0)
72 tprintf("%4d: ", i); 72 tprintf(s->avctx, "%4d: ", i);
73 tprintf(" %8.*f", prec, tab[i]); 73 tprintf(s->avctx, " %8.*f", prec, tab[i]);
74 if ((i & 7) == 7) 74 if ((i & 7) == 7)
75 tprintf("\n"); 75 tprintf(s->avctx, "\n");
76 } 76 }
77 if ((i & 7) != 0) 77 if ((i & 7) != 0)
78 tprintf("\n"); 78 tprintf(s->avctx, "\n");
79 } 79 }
80 #endif 80 #endif
81 81
82 static int wma_decode_init(AVCodecContext * avctx) 82 static int wma_decode_init(AVCodecContext * avctx)
83 { 83 {
84 WMADecodeContext *s = avctx->priv_data; 84 WMADecodeContext *s = avctx->priv_data;
85 int i, flags1, flags2; 85 int i, flags1, flags2;
86 uint8_t *extradata; 86 uint8_t *extradata;
87
88 s->avctx = avctx;
87 89
88 /* extract flag infos */ 90 /* extract flag infos */
89 flags1 = 0; 91 flags1 = 0;
90 flags2 = 0; 92 flags2 = 0;
91 extradata = avctx->extradata; 93 extradata = avctx->extradata;
324 int coef_nb_bits, total_gain, parse_exponents; 326 int coef_nb_bits, total_gain, parse_exponents;
325 int nb_coefs[MAX_CHANNELS]; 327 int nb_coefs[MAX_CHANNELS];
326 float mdct_norm; 328 float mdct_norm;
327 329
328 #ifdef TRACE 330 #ifdef TRACE
329 tprintf("***decode_block: %d:%d\n", s->frame_count - 1, s->block_num); 331 tprintf(s->avctx, "***decode_block: %d:%d\n", s->frame_count - 1, s->block_num);
330 #endif 332 #endif
331 333
332 /* compute current block length */ 334 /* compute current block length */
333 if (s->use_variable_block_len) { 335 if (s->use_variable_block_len) {
334 n = av_log2(s->nb_block_sizes - 1) + 1; 336 n = av_log2(s->nb_block_sizes - 1) + 1;
565 v = exp_ptr[i]; 567 v = exp_ptr[i];
566 e2 += v * v; 568 e2 += v * v;
567 } 569 }
568 exp_power[j] = e2 / n; 570 exp_power[j] = e2 / n;
569 last_high_band = j; 571 last_high_band = j;
570 tprintf("%d: power=%f (%d)\n", j, exp_power[j], n); 572 tprintf(s->avctx, "%d: power=%f (%d)\n", j, exp_power[j], n);
571 } 573 }
572 exp_ptr += n; 574 exp_ptr += n;
573 } 575 }
574 576
575 /* main freqs and high freqs */ 577 /* main freqs and high freqs */
626 } 628 }
627 629
628 #ifdef TRACE 630 #ifdef TRACE
629 for(ch = 0; ch < s->nb_channels; ch++) { 631 for(ch = 0; ch < s->nb_channels; ch++) {
630 if (s->channel_coded[ch]) { 632 if (s->channel_coded[ch]) {
631 dump_floats("exponents", 3, s->exponents[ch], s->block_len); 633 dump_floats(s, "exponents", 3, s->exponents[ch], s->block_len);
632 dump_floats("coefs", 1, s->coefs[ch], s->block_len); 634 dump_floats(s, "coefs", 1, s->coefs[ch], s->block_len);
633 } 635 }
634 } 636 }
635 #endif 637 #endif
636 638
637 if (s->ms_stereo && s->channel_coded[1]) { 639 if (s->ms_stereo && s->channel_coded[1]) {
640 642
641 /* nominal case for ms stereo: we do it before mdct */ 643 /* nominal case for ms stereo: we do it before mdct */
642 /* no need to optimize this case because it should almost 644 /* no need to optimize this case because it should almost
643 never happen */ 645 never happen */
644 if (!s->channel_coded[0]) { 646 if (!s->channel_coded[0]) {
645 tprintf("rare ms-stereo case happened\n"); 647 tprintf(s->avctx, "rare ms-stereo case happened\n");
646 memset(s->coefs[0], 0, sizeof(float) * s->block_len); 648 memset(s->coefs[0], 0, sizeof(float) * s->block_len);
647 s->channel_coded[0] = 1; 649 s->channel_coded[0] = 1;
648 } 650 }
649 651
650 for(i = 0; i < s->block_len; i++) { 652 for(i = 0; i < s->block_len; i++) {
742 int ret, i, n, a, ch, incr; 744 int ret, i, n, a, ch, incr;
743 int16_t *ptr; 745 int16_t *ptr;
744 float *iptr; 746 float *iptr;
745 747
746 #ifdef TRACE 748 #ifdef TRACE
747 tprintf("***decode_frame: %d size=%d\n", s->frame_count++, s->frame_len); 749 tprintf(s->avctx, "***decode_frame: %d size=%d\n", s->frame_count++, s->frame_len);
748 #endif 750 #endif
749 751
750 /* read each block */ 752 /* read each block */
751 s->block_num = 0; 753 s->block_num = 0;
752 s->block_pos = 0; 754 s->block_pos = 0;
781 memset(&s->frame_out[ch][s->frame_len], 0, 783 memset(&s->frame_out[ch][s->frame_len], 0,
782 s->frame_len * sizeof(float)); 784 s->frame_len * sizeof(float));
783 } 785 }
784 786
785 #ifdef TRACE 787 #ifdef TRACE
786 dump_shorts("samples", samples, n * s->nb_channels); 788 dump_shorts(s, "samples", samples, n * s->nb_channels);
787 #endif 789 #endif
788 return 0; 790 return 0;
789 } 791 }
790 792
791 static int wma_decode_superframe(AVCodecContext *avctx, 793 static int wma_decode_superframe(AVCodecContext *avctx,
795 WMADecodeContext *s = avctx->priv_data; 797 WMADecodeContext *s = avctx->priv_data;
796 int nb_frames, bit_offset, i, pos, len; 798 int nb_frames, bit_offset, i, pos, len;
797 uint8_t *q; 799 uint8_t *q;
798 int16_t *samples; 800 int16_t *samples;
799 801
800 tprintf("***decode_superframe:\n"); 802 tprintf(avctx, "***decode_superframe:\n");
801 803
802 if(buf_size==0){ 804 if(buf_size==0){
803 s->last_superframe_len = 0; 805 s->last_superframe_len = 0;
804 return 0; 806 return 0;
805 } 807 }