Changeset 7859740c in ffmpeg
- Timestamp:
- Dec 18, 2011, 7:51:40 PM (13 years ago)
- Branches:
- master
- Children:
- af3f2a87
- Parents:
- 6b6b84ae
- git-author:
- Michael Niedermayer <michaelni@gmx.at> (12/18/11 19:12:16)
- git-committer:
- Michael Niedermayer <michaelni@gmx.at> (12/18/11 19:51:40)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libavcodec/adx_parser.c
r6b6b84ae r7859740c 23 23 * ADX audio parser 24 24 * 25 * Reads header to extradata and splits packets into individual blocks.25 * Splits packets into individual blocks. 26 26 */ 27 27 … … 34 34 int header_size; 35 35 int block_size; 36 int buf_pos;36 int remaining; 37 37 } ADXParseContext; 38 39 #define MIN_HEADER_SIZE 2440 38 41 39 static int adx_parse(AVCodecParserContext *s1, … … 47 45 ParseContext *pc = &s->pc; 48 46 int next = END_NOT_FOUND; 47 int i; 48 uint64_t state= pc->state64; 49 49 50 if (!avctx->extradata_size) { 51 int ret; 50 if(!s->header_size){ 51 for(i=0; i<buf_size; i++){ 52 state= (state<<8) | buf[i]; 53 if((state&0xFFFF0000FFFFFF00) == 0x8000000003120400ULL && (state&0xFF) && ((state>>32)&0xFFFF)>=4){ 54 s->header_size= ((state>>32)&0xFFFF) + 4; 55 s->block_size = BLOCK_SIZE * (state&0xFF); 56 s->remaining = i - 7 + s->header_size + s->block_size; 57 break; 58 } 59 } 60 pc->state64= state; 61 } 52 62 53 ff_combine_frame(pc, END_NOT_FOUND, &buf, &buf_size); 54 55 if (!s->header_size && pc->index >= MIN_HEADER_SIZE) { 56 if (ret = avpriv_adx_decode_header(avctx, pc->buffer, pc->index, 57 &s->header_size, NULL)) 58 return AVERROR_INVALIDDATA; 63 if (s->header_size) { 64 if (!s->remaining) { 65 s->remaining = s->block_size; 59 66 } 60 if (s->header_size && s->header_size <= pc->index) { 61 avctx->extradata = av_mallocz(s->header_size + FF_INPUT_BUFFER_PADDING_SIZE); 62 if (!avctx->extradata) 63 return AVERROR(ENOMEM); 64 avctx->extradata_size = s->header_size; 65 memcpy(avctx->extradata, pc->buffer, s->header_size); 66 memmove(pc->buffer, pc->buffer + s->header_size, s->header_size); 67 pc->index -= s->header_size; 68 } 69 *poutbuf = NULL; 70 *poutbuf_size = 0; 71 return buf_size; 67 if (s->remaining<=buf_size) { 68 next= s->remaining; 69 s->remaining = 0; 70 } else 71 s->remaining -= buf_size; 72 72 } 73 s->block_size = BLOCK_SIZE * avctx->channels;74 75 if (pc->index - s->buf_pos >= s->block_size) {76 *poutbuf = &pc->buffer[s->buf_pos];77 *poutbuf_size = s->block_size;78 s->buf_pos += s->block_size;79 return 0;80 }81 if (pc->index && s->buf_pos) {82 memmove(pc->buffer, &pc->buffer[s->buf_pos], pc->index - s->buf_pos);83 pc->index -= s->buf_pos;84 s->buf_pos = 0;85 }86 if (buf_size + pc->index >= s->block_size)87 next = s->block_size - pc->index;88 73 89 74 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0 || !buf_size) {
Note:
See TracChangeset
for help on using the changeset viewer.