Mercurial > libavcodec.hg
diff parser.c @ 2979:bfabfdf9ce55 libavcodec
COSMETICS: tabs --> spaces, some prettyprinting
author | diego |
---|---|
date | Thu, 22 Dec 2005 01:10:11 +0000 |
parents | ef2149182f1c |
children | 0b546eab515d |
line wrap: on
line diff
--- a/parser.c Wed Dec 21 17:50:40 2005 +0000 +++ b/parser.c Thu Dec 22 01:10:11 2005 +0000 @@ -191,11 +191,11 @@ //#define END_NOT_FOUND (-100) -#define PICTURE_START_CODE 0x00000100 -#define SEQ_START_CODE 0x000001b3 -#define EXT_START_CODE 0x000001b5 -#define SLICE_MIN_START_CODE 0x00000101 -#define SLICE_MAX_START_CODE 0x000001af +#define PICTURE_START_CODE 0x00000100 +#define SEQ_START_CODE 0x000001b3 +#define EXT_START_CODE 0x000001b5 +#define SLICE_MIN_START_CODE 0x00000101 +#define SLICE_MAX_START_CODE 0x000001af typedef struct ParseContext1{ ParseContext pc; @@ -571,7 +571,7 @@ /*************************/ typedef struct MpegAudioParseContext { - uint8_t inbuf[MPA_MAX_CODED_FRAME_SIZE]; /* input buffer */ + uint8_t inbuf[MPA_MAX_CODED_FRAME_SIZE]; /* input buffer */ uint8_t *inbuf_ptr; int frame_size; int free_format_frame_size; @@ -608,8 +608,8 @@ *poutbuf_size = 0; buf_ptr = buf; while (buf_size > 0) { - len = s->inbuf_ptr - s->inbuf; - if (s->frame_size == 0) { + len = s->inbuf_ptr - s->inbuf; + if (s->frame_size == 0) { /* special case for next header for first frame in free format case (XXX: find a simpler method) */ if (s->free_format_next_header != 0) { @@ -621,34 +621,34 @@ s->free_format_next_header = 0; goto got_header; } - /* no header seen : find one. We need at least MPA_HEADER_SIZE + /* no header seen : find one. We need at least MPA_HEADER_SIZE bytes to parse it */ - len = MPA_HEADER_SIZE - len; - if (len > buf_size) - len = buf_size; - if (len > 0) { - memcpy(s->inbuf_ptr, buf_ptr, len); - buf_ptr += len; - buf_size -= len; - s->inbuf_ptr += len; - } - if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) { + len = MPA_HEADER_SIZE - len; + if (len > buf_size) + len = buf_size; + if (len > 0) { + memcpy(s->inbuf_ptr, buf_ptr, len); + buf_ptr += len; + buf_size -= len; + s->inbuf_ptr += len; + } + if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) { got_header: sr= avctx->sample_rate; - header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) | - (s->inbuf[2] << 8) | s->inbuf[3]; + header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) | + (s->inbuf[2] << 8) | s->inbuf[3]; ret = mpa_decode_header(avctx, header); if (ret < 0) { s->header_count= -2; - /* no sync found : move by one byte (inefficient, but simple!) */ - memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); - s->inbuf_ptr--; + /* no sync found : move by one byte (inefficient, but simple!) */ + memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); + s->inbuf_ptr--; dprintf("skip %x\n", header); /* reset free format frame size to give a chance to get a new bitrate */ s->free_format_frame_size = 0; - } else { + } else { if((header&SAME_HEADER_MASK) != (s->header&SAME_HEADER_MASK) && s->header) s->header_count= -3; s->header= header; @@ -657,26 +657,26 @@ #if 0 /* free format: prepare to compute frame size */ - if (decode_header(s, header) == 1) { - s->frame_size = -1; + if (decode_header(s, header) == 1) { + s->frame_size = -1; } #endif - } + } if(s->header_count <= 0) avctx->sample_rate= sr; //FIXME ugly - } + } } else #if 0 if (s->frame_size == -1) { /* free format : find next sync to compute frame size */ - len = MPA_MAX_CODED_FRAME_SIZE - len; - if (len > buf_size) - len = buf_size; + len = MPA_MAX_CODED_FRAME_SIZE - len; + if (len > buf_size) + len = buf_size; if (len == 0) { - /* frame too long: resync */ + /* frame too long: resync */ s->frame_size = 0; - memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); - s->inbuf_ptr--; + memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); + s->inbuf_ptr--; } else { uint8_t *p, *pend; uint32_t header1; @@ -720,19 +720,19 @@ s->inbuf_ptr += len; buf_size -= len; } - } else + } else #endif if (len < s->frame_size) { if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE) s->frame_size = MPA_MAX_CODED_FRAME_SIZE; - len = s->frame_size - len; - if (len > buf_size) - len = buf_size; - memcpy(s->inbuf_ptr, buf_ptr, len); - buf_ptr += len; - s->inbuf_ptr += len; - buf_size -= len; - } + len = s->frame_size - len; + if (len > buf_size) + len = buf_size; + memcpy(s->inbuf_ptr, buf_ptr, len); + buf_ptr += len; + s->inbuf_ptr += len; + buf_size -= len; + } // next_data: if (s->frame_size > 0 && (s->inbuf_ptr - s->inbuf) >= s->frame_size) { @@ -740,10 +740,10 @@ *poutbuf = s->inbuf; *poutbuf_size = s->inbuf_ptr - s->inbuf; } - s->inbuf_ptr = s->inbuf; - s->frame_size = 0; - break; - } + s->inbuf_ptr = s->inbuf; + s->frame_size = 0; + break; + } } return buf_ptr - buf; } @@ -783,7 +783,7 @@ const uint8_t *buf_ptr; int len, sample_rate, bit_rate; static const int ac3_channels[8] = { - 2, 1, 2, 3, 3, 4, 4, 5 + 2, 1, 2, 3, 3, 4, 4, 5 }; *poutbuf = NULL; @@ -812,7 +812,7 @@ memmove(s->inbuf, s->inbuf + 1, AC3_HEADER_SIZE - 1); s->inbuf_ptr--; } else { - s->frame_size = len; + s->frame_size = len; /* update codec info */ avctx->sample_rate = sample_rate; /* set channels,except if the user explicitly requests 1 or 2 channels, XXX/FIXME this is a bit ugly */ @@ -821,7 +821,7 @@ if (s->flags & A52_LFE) avctx->channels++; } - avctx->bit_rate = bit_rate; + avctx->bit_rate = bit_rate; avctx->frame_size = 6 * 256; } }