Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.
My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
int wma_decode_superframe_init(WMADecodeContext* s, const uint8_t *buf, int buf_size); int wma_decode_superframe_frame(WMADecodeContext* s, - int32_t *samples, const uint8_t *buf, int buf_size); #endif /* return 0 if OK. return 1 if last block of frame. return -1 if unrecorrable error. */ -static int wma_decode_block(WMADecodeContext *s, int32_t *scratch_buffer) +static int wma_decode_block(WMADecodeContext *s) { int n, v, a, ch, code, bsize; int coef_nb_bits, total_gain; } for(ch = 0; ch < s->nb_channels; ++ch) - { + { + /* BLOCK_MAX_SIZE is 2048 (samples) and MAX_CHANNELS is 2. */ + static uint32_t scratch_buf[BLOCK_MAX_SIZE * MAX_CHANNELS] IBSS_ATTR; if (s->channel_coded[ch]) { int n4, index; n4 = s->block_len >>1; - ff_imdct_calc( (s->frame_len_bits - bsize + 1), - (int32_t*)scratch_buffer, + ff_imdct_calc((s->frame_len_bits - bsize + 1), + scratch_buf, (*(s->coefs))[ch]); /* add in the frame */ index = (s->frame_len / 2) + s->block_pos - n4; - wma_window(s, scratch_buffer, &((*s->frame_out)[ch][index])); + wma_window(s, scratch_buf, &((*s->frame_out)[ch][index])); channel if it is not coded */ if (s->ms_stereo && !s->channel_coded[1]) { - wma_window(s, scratch_buffer, &((*s->frame_out)[1][index])); + wma_window(s, scratch_buf, &((*s->frame_out)[1][index])); } } } } /* decode a frame of frame_len samples */ -static int wma_decode_frame(WMADecodeContext *s, int32_t *samples) +static int wma_decode_frame(WMADecodeContext *s) { - int ret, i, n, ch, incr; - int32_t *ptr; - fixed32 *iptr; + int ret; /* read each block */ s->block_num = 0; for(;;) { - ret = wma_decode_block(s, samples); + ret = wma_decode_block(s); if (ret < 0) { break; } } - - /* return frame with full 30-bit precision */ - n = s->frame_len; - incr = s->nb_channels; - for(ch = 0; ch < s->nb_channels; ++ch) - { - ptr = samples + ch; - iptr = &((*s->frame_out)[ch][0]); - - for (i=0;i<n;++i) - { - *ptr = (*iptr++); - ptr += incr; - } - - memmove(&((*s->frame_out)[ch][0]), &((*s->frame_out)[ch][s->frame_len]), - s->frame_len * sizeof(fixed32)); - } - + return 0; } */ int wma_decode_superframe_frame(WMADecodeContext* s, - int32_t* samples, /*output*/ const uint8_t *buf, /*input*/ int buf_size) { - int pos, len; + int pos, len, ch; uint8_t *q; int done = 0; + + for(ch = 0; ch < s->nb_channels; ch++) + memmove(&((*s->frame_out)[ch][0]), + &((*s->frame_out)[ch][s->frame_len]), + s->frame_len * sizeof(fixed32)); + if ((s->use_bit_reservoir) && (s->current_frame == 0)) { if (s->last_superframe_len > 0) /* this frame is stored in the last superframe and in the current one */ - if (wma_decode_frame(s, samples) < 0) + if (wma_decode_frame(s) < 0) { goto fail; } /* If we haven't decoded a frame yet, do it now */ if (!done) { - if (wma_decode_frame(s, samples) < 0) + if (wma_decode_frame(s) < 0) { goto fail; } CODEC_HEADER -/* The output buffer containing the decoded samples (channels 0 and 1) - BLOCK_MAX_SIZE is 2048 (samples) and MAX_CHANNELS is 2. - */ - -static uint32_t decoded[BLOCK_MAX_SIZE * MAX_CHANNELS] IBSS_ATTR; - /* NOTE: WMADecodeContext is 120152 bytes (on x86) */ static WMADecodeContext wmadec; resume_offset = 0; ci->configure(DSP_SWITCH_FREQUENCY, wfx.rate); ci->configure(DSP_SET_STEREO_MODE, wfx.channels == 1 ? - STEREO_MONO : STEREO_INTERLEAVED); + STEREO_MONO : STEREO_NONINTERLEAVED); codec_set_replaygain(ci->id3); /* The main decoding loop */ for (i=0; i < wmadec.nb_frames; i++) { wmares = wma_decode_superframe_frame(&wmadec, - decoded, audiobuf, audiobufsize); ci->yield (); goto new_packet; } } else if (wmares > 0) { - ci->pcmbuf_insert(decoded, NULL, wmares); + ci->pcmbuf_insert(wmadec.frame_out[0], wmadec.frame_out[1], wmares); elapsedtime += (wmares*10)/(wfx.rate/100); ci->set_elapsed(elapsedtime); } |