comparison mpegaudiodec.c @ 1414:5ee7bd7ee76d libavcodec

memmove fixes (Jon Burgess)
author bellard
date Sun, 24 Aug 2003 22:01:33 +0000
parents 592fb56e562f
children aece5836c588
comparison
equal deleted inserted replaced
1413:724e6477f2a8 1414:5ee7bd7ee76d
1458 static void seek_to_maindata(MPADecodeContext *s, unsigned int backstep) 1458 static void seek_to_maindata(MPADecodeContext *s, unsigned int backstep)
1459 { 1459 {
1460 uint8_t *ptr; 1460 uint8_t *ptr;
1461 1461
1462 /* compute current position in stream */ 1462 /* compute current position in stream */
1463 ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3); 1463 ptr = (uint8_t *)(s->gb.buffer + (get_bits_count(&s->gb)>>3));
1464 1464
1465 /* copy old data before current one */ 1465 /* copy old data before current one */
1466 ptr -= backstep; 1466 ptr -= backstep;
1467 memcpy(ptr, s->inbuf1[s->inbuf_index ^ 1] + 1467 memcpy(ptr, s->inbuf1[s->inbuf_index ^ 1] +
1468 BACKSTEP_SIZE + s->old_frame_size - backstep, backstep); 1468 BACKSTEP_SIZE + s->old_frame_size - backstep, backstep);
2374 header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) | 2374 header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
2375 (s->inbuf[2] << 8) | s->inbuf[3]; 2375 (s->inbuf[2] << 8) | s->inbuf[3];
2376 2376
2377 if (check_header(header) < 0) { 2377 if (check_header(header) < 0) {
2378 /* no sync found : move by one byte (inefficient, but simple!) */ 2378 /* no sync found : move by one byte (inefficient, but simple!) */
2379 memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); 2379 memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
2380 s->inbuf_ptr--; 2380 s->inbuf_ptr--;
2381 dprintf("skip %x\n", header); 2381 dprintf("skip %x\n", header);
2382 /* reset free format frame size to give a chance 2382 /* reset free format frame size to give a chance
2383 to get a new bitrate */ 2383 to get a new bitrate */
2384 s->free_format_frame_size = 0; 2384 s->free_format_frame_size = 0;
2400 if (len > buf_size) 2400 if (len > buf_size)
2401 len = buf_size; 2401 len = buf_size;
2402 if (len == 0) { 2402 if (len == 0) {
2403 /* frame too long: resync */ 2403 /* frame too long: resync */
2404 s->frame_size = 0; 2404 s->frame_size = 0;
2405 memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); 2405 memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
2406 s->inbuf_ptr--; 2406 s->inbuf_ptr--;
2407 } else { 2407 } else {
2408 uint8_t *p, *pend; 2408 uint8_t *p, *pend;
2409 uint32_t header1; 2409 uint32_t header1;
2410 int padding; 2410 int padding;