static int decode_init(AVCodecContext * avctx)
{
MPADecodeContext *s = avctx->priv_data;
- static int init;
+ static int init=0;
int i, j, k;
if(!init) {
band_index_long[i][22] = k;
}
- /* compute n ^ (4/3) and store it in mantissa/exp format */
- table_4_3_exp = av_mallocz(TABLE_4_3_SIZE *
- sizeof(table_4_3_exp[0]));
- if (!table_4_3_exp)
+ /* compute n ^ (4/3) and store it in mantissa/exp format */
+ if (!av_mallocz_static(&table_4_3_exp,
+ TABLE_4_3_SIZE * sizeof(table_4_3_exp[0])))
+ return -1;
+ if (!av_mallocz_static(&table_4_3_value,
+ TABLE_4_3_SIZE * sizeof(table_4_3_value[0])))
return -1;
- table_4_3_value = av_mallocz(TABLE_4_3_SIZE *
- sizeof(table_4_3_value[0]));
- if (!table_4_3_value) {
- av_free(table_4_3_exp);
- return -1;
- }
int_pow_init();
for(i=1;i<TABLE_4_3_SIZE;i++) {
return 0;
}
-/* tab[i][j] = 1.0 / (2.0 * cos(pi*(2*k+1) / 2^(6 - j))) */;
+/* tab[i][j] = 1.0 / (2.0 * cos(pi*(2*k+1) / 2^(6 - j))) */
/* cos(i*pi/64) */
UINT8 *ptr;
/* compute current position in stream */
-#ifdef ALT_BITSTREAM_READER
- ptr = s->gb.buffer + (s->gb.index>>3);
-#else
- ptr = s->gb.buf_ptr - (s->gb.bit_cnt >> 3);
-#endif
+ ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3);
+
/* copy old data before current one */
ptr -= backstep;
memcpy(ptr, s->inbuf1[s->inbuf_index ^ 1] +
BACKSTEP_SIZE + s->old_frame_size - backstep, backstep);
/* init get bits again */
- init_get_bits(&s->gb, ptr, s->frame_size + backstep);
+ init_get_bits(&s->gb, ptr, (s->frame_size + backstep)*8);
/* prepare next buffer */
s->inbuf_index ^= 1;
{
int s_index;
int linbits, code, x, y, l, v, i, j, k, pos;
- UINT8 *last_buf_ptr;
- UINT32 last_bit_buf;
- int last_bit_cnt;
+ GetBitContext last_gb;
VLC *vlc;
UINT8 *code_table;
/* high frequencies */
vlc = &huff_quad_vlc[g->count1table_select];
- last_buf_ptr = NULL;
- last_bit_buf = 0;
- last_bit_cnt = 0;
+ last_gb.buffer = NULL;
while (s_index <= 572) {
pos = get_bits_count(&s->gb);
if (pos >= end_pos) {
- if (pos > end_pos && last_buf_ptr != NULL) {
+ if (pos > end_pos && last_gb.buffer != NULL) {
/* some encoders generate an incorrect size for this
part. We must go back into the data */
s_index -= 4;
-#ifdef ALT_BITSTREAM_READER
- s->gb.buffer = last_buf_ptr;
- s->gb.index = last_bit_cnt;
-#else
- s->gb.buf_ptr = last_buf_ptr;
- s->gb.bit_buf = last_bit_buf;
- s->gb.bit_cnt = last_bit_cnt;
-#endif
+ s->gb = last_gb;
}
break;
}
-#ifdef ALT_BITSTREAM_READER
- last_buf_ptr = s->gb.buffer;
- last_bit_cnt = s->gb.index;
-#else
- last_buf_ptr = s->gb.buf_ptr;
- last_bit_buf = s->gb.bit_buf;
- last_bit_cnt = s->gb.bit_cnt;
-#endif
-
+ last_gb= s->gb;
+
code = get_vlc(&s->gb, vlc);
dprintf("t=%d code=%d\n", g->count1table_select, code);
if (code < 0)
short *samples_ptr;
init_get_bits(&s->gb, s->inbuf + HEADER_SIZE,
- s->inbuf_ptr - s->inbuf - HEADER_SIZE);
+ (s->inbuf_ptr - s->inbuf - HEADER_SIZE)*8);
/* skip error protection field */
if (s->error_protection)
if (len > buf_size)
len = buf_size;
if (len == 0) {
- /* frame too long: resync */
+ /* frame too long: resync */
s->frame_size = 0;
+ memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
+ s->inbuf_ptr--;
} else {
UINT8 *p, *pend;
UINT32 header1;
break;
}
next_data:
+ ;
}
return buf_ptr - buf;
}