summaryrefslogtreecommitdiff
path: root/libavcodec/h264.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-04-29 14:21:33 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-04-29 14:21:33 +0000
commite4cb187db8f96634f2306538e134d40f2793e376 (patch)
tree7b8617c0ac55f1f437f65715a41dda57f56e3645 /libavcodec/h264.c
parent20da31792b1988d2f21f4c14548333405cd9c37d (diff)
remove duplicated find_frame_end() code
move codec specific code from parser.c -> <codecname>.c as far as its easily possible Originally committed as revision 3087 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r--libavcodec/h264.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index fa254e93b5..77c3393efc 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -5520,8 +5520,7 @@ static inline int decode_picture_parameter_set(H264Context *h){
* finds the end of the current frame in the bitstream.
* @return the position of the first byte of the next frame, or -1
*/
-static int find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
- ParseContext *pc= &s->parse_context;
+static int find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){
int i;
uint32_t state;
//printf("first %02X%02X%02X%02X\n", buf[0], buf[1],buf[2],buf[3]);
@@ -5544,6 +5543,27 @@ static int find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
return END_NOT_FOUND;
}
+static int h264_parse(AVCodecParserContext *s,
+ AVCodecContext *avctx,
+ uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size)
+{
+ ParseContext *pc = s->priv_data;
+ int next;
+
+ next= find_frame_end(pc, buf, buf_size);
+
+ if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
+ *poutbuf = NULL;
+ *poutbuf_size = 0;
+ return buf_size;
+ }
+
+ *poutbuf = (uint8_t *)buf;
+ *poutbuf_size = buf_size;
+ return next;
+}
+
static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
MpegEncContext * const s = &h->s;
AVCodecContext * const avctx= s->avctx;
@@ -5701,9 +5721,9 @@ static int decode_frame(AVCodecContext *avctx,
}
if(s->flags&CODEC_FLAG_TRUNCATED){
- int next= find_frame_end(s, buf, buf_size);
+ int next= find_frame_end(&s->parse_context, buf, buf_size);
- if( ff_combine_frame(s, next, &buf, &buf_size) < 0 )
+ if( ff_combine_frame(&s->parse_context, next, &buf, &buf_size) < 0 )
return buf_size;
//printf("next:%d buf_size:%d last_index:%d\n", next, buf_size, s->parse_context.last_index);
}
@@ -5970,4 +5990,12 @@ AVCodec h264_decoder = {
/*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
};
+AVCodecParser h264_parser = {
+ { CODEC_ID_H264 },
+ sizeof(ParseContext),
+ NULL,
+ h264_parse,
+ ff_parse_close,
+};
+
#include "svq3.c"