Mercurial > libavcodec.hg
comparison h264.c @ 1988:b5753525f9a8 libavcodec
remove duplicated find_frame_end() code
move codec specific code from parser.c -> <codecname>.c as far as its easily possible
author | michael |
---|---|
date | Thu, 29 Apr 2004 14:21:33 +0000 |
parents | 54411768fa38 |
children | 141a9539e270 |
comparison
equal
deleted
inserted
replaced
1987:d9e067853051 | 1988:b5753525f9a8 |
---|---|
5518 | 5518 |
5519 /** | 5519 /** |
5520 * finds the end of the current frame in the bitstream. | 5520 * finds the end of the current frame in the bitstream. |
5521 * @return the position of the first byte of the next frame, or -1 | 5521 * @return the position of the first byte of the next frame, or -1 |
5522 */ | 5522 */ |
5523 static int find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){ | 5523 static int find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){ |
5524 ParseContext *pc= &s->parse_context; | |
5525 int i; | 5524 int i; |
5526 uint32_t state; | 5525 uint32_t state; |
5527 //printf("first %02X%02X%02X%02X\n", buf[0], buf[1],buf[2],buf[3]); | 5526 //printf("first %02X%02X%02X%02X\n", buf[0], buf[1],buf[2],buf[3]); |
5528 // mb_addr= pc->mb_addr - 1; | 5527 // mb_addr= pc->mb_addr - 1; |
5529 state= pc->state; | 5528 state= pc->state; |
5540 } | 5539 } |
5541 } | 5540 } |
5542 | 5541 |
5543 pc->state= state; | 5542 pc->state= state; |
5544 return END_NOT_FOUND; | 5543 return END_NOT_FOUND; |
5544 } | |
5545 | |
5546 static int h264_parse(AVCodecParserContext *s, | |
5547 AVCodecContext *avctx, | |
5548 uint8_t **poutbuf, int *poutbuf_size, | |
5549 const uint8_t *buf, int buf_size) | |
5550 { | |
5551 ParseContext *pc = s->priv_data; | |
5552 int next; | |
5553 | |
5554 next= find_frame_end(pc, buf, buf_size); | |
5555 | |
5556 if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) { | |
5557 *poutbuf = NULL; | |
5558 *poutbuf_size = 0; | |
5559 return buf_size; | |
5560 } | |
5561 | |
5562 *poutbuf = (uint8_t *)buf; | |
5563 *poutbuf_size = buf_size; | |
5564 return next; | |
5545 } | 5565 } |
5546 | 5566 |
5547 static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){ | 5567 static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){ |
5548 MpegEncContext * const s = &h->s; | 5568 MpegEncContext * const s = &h->s; |
5549 AVCodecContext * const avctx= s->avctx; | 5569 AVCodecContext * const avctx= s->avctx; |
5699 if (buf_size == 0) { | 5719 if (buf_size == 0) { |
5700 return 0; | 5720 return 0; |
5701 } | 5721 } |
5702 | 5722 |
5703 if(s->flags&CODEC_FLAG_TRUNCATED){ | 5723 if(s->flags&CODEC_FLAG_TRUNCATED){ |
5704 int next= find_frame_end(s, buf, buf_size); | 5724 int next= find_frame_end(&s->parse_context, buf, buf_size); |
5705 | 5725 |
5706 if( ff_combine_frame(s, next, &buf, &buf_size) < 0 ) | 5726 if( ff_combine_frame(&s->parse_context, next, &buf, &buf_size) < 0 ) |
5707 return buf_size; | 5727 return buf_size; |
5708 //printf("next:%d buf_size:%d last_index:%d\n", next, buf_size, s->parse_context.last_index); | 5728 //printf("next:%d buf_size:%d last_index:%d\n", next, buf_size, s->parse_context.last_index); |
5709 } | 5729 } |
5710 | 5730 |
5711 if(s->avctx->extradata_size && s->picture_number==0){ | 5731 if(s->avctx->extradata_size && s->picture_number==0){ |
5968 decode_end, | 5988 decode_end, |
5969 decode_frame, | 5989 decode_frame, |
5970 /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED, | 5990 /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED, |
5971 }; | 5991 }; |
5972 | 5992 |
5993 AVCodecParser h264_parser = { | |
5994 { CODEC_ID_H264 }, | |
5995 sizeof(ParseContext), | |
5996 NULL, | |
5997 h264_parse, | |
5998 ff_parse_close, | |
5999 }; | |
6000 | |
5973 #include "svq3.c" | 6001 #include "svq3.c" |