Mercurial > libavcodec.hg
comparison h263dec.c @ 4938:ee6c1ce06470 libavcodec
Move H.263 parser to its own file.
author | diego |
---|---|
date | Tue, 08 May 2007 08:52:38 +0000 |
parents | 0d1cc37d9430 |
children | 3fcb2f0d9ef1 |
comparison
equal
deleted
inserted
replaced
4937:a65cd5b551c2 | 4938:ee6c1ce06470 |
---|---|
26 */ | 26 */ |
27 | 27 |
28 #include "avcodec.h" | 28 #include "avcodec.h" |
29 #include "dsputil.h" | 29 #include "dsputil.h" |
30 #include "mpegvideo.h" | 30 #include "mpegvideo.h" |
31 #include "h263_parser.h" | |
31 | 32 |
32 //#define DEBUG | 33 //#define DEBUG |
33 //#define PRINT_FRAME_TIME | 34 //#define PRINT_FRAME_TIME |
34 | 35 |
35 int ff_h263_decode_init(AVCodecContext *avctx) | 36 int ff_h263_decode_init(AVCodecContext *avctx) |
356 pc->frame_start_found= vop_found; | 357 pc->frame_start_found= vop_found; |
357 pc->state= state; | 358 pc->state= state; |
358 return END_NOT_FOUND; | 359 return END_NOT_FOUND; |
359 } | 360 } |
360 | 361 |
361 static int h263_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){ | |
362 int vop_found, i; | |
363 uint32_t state; | |
364 | |
365 vop_found= pc->frame_start_found; | |
366 state= pc->state; | |
367 | |
368 i=0; | |
369 if(!vop_found){ | |
370 for(i=0; i<buf_size; i++){ | |
371 state= (state<<8) | buf[i]; | |
372 if(state>>(32-22) == 0x20){ | |
373 i++; | |
374 vop_found=1; | |
375 break; | |
376 } | |
377 } | |
378 } | |
379 | |
380 if(vop_found){ | |
381 for(; i<buf_size; i++){ | |
382 state= (state<<8) | buf[i]; | |
383 if(state>>(32-22) == 0x20){ | |
384 pc->frame_start_found=0; | |
385 pc->state=-1; | |
386 return i-3; | |
387 } | |
388 } | |
389 } | |
390 pc->frame_start_found= vop_found; | |
391 pc->state= state; | |
392 | |
393 return END_NOT_FOUND; | |
394 } | |
395 | |
396 #ifdef CONFIG_H263_PARSER | |
397 static int h263_parse(AVCodecParserContext *s, | |
398 AVCodecContext *avctx, | |
399 const uint8_t **poutbuf, int *poutbuf_size, | |
400 const uint8_t *buf, int buf_size) | |
401 { | |
402 ParseContext *pc = s->priv_data; | |
403 int next; | |
404 | |
405 next= h263_find_frame_end(pc, buf, buf_size); | |
406 | |
407 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { | |
408 *poutbuf = NULL; | |
409 *poutbuf_size = 0; | |
410 return buf_size; | |
411 } | |
412 | |
413 *poutbuf = buf; | |
414 *poutbuf_size = buf_size; | |
415 return next; | |
416 } | |
417 #endif | |
418 | |
419 int ff_h263_decode_frame(AVCodecContext *avctx, | 362 int ff_h263_decode_frame(AVCodecContext *avctx, |
420 void *data, int *data_size, | 363 void *data, int *data_size, |
421 uint8_t *buf, int buf_size) | 364 uint8_t *buf, int buf_size) |
422 { | 365 { |
423 MpegEncContext *s = avctx->priv_data; | 366 MpegEncContext *s = avctx->priv_data; |
452 int next; | 395 int next; |
453 | 396 |
454 if(s->codec_id==CODEC_ID_MPEG4){ | 397 if(s->codec_id==CODEC_ID_MPEG4){ |
455 next= ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size); | 398 next= ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size); |
456 }else if(s->codec_id==CODEC_ID_H263){ | 399 }else if(s->codec_id==CODEC_ID_H263){ |
457 next= h263_find_frame_end(&s->parse_context, buf, buf_size); | 400 next= ff_h263_find_frame_end(&s->parse_context, buf, buf_size); |
458 }else{ | 401 }else{ |
459 av_log(s->avctx, AV_LOG_ERROR, "this codec does not support truncated bitstreams\n"); | 402 av_log(s->avctx, AV_LOG_ERROR, "this codec does not support truncated bitstreams\n"); |
460 return -1; | 403 return -1; |
461 } | 404 } |
462 | 405 |
900 NULL, | 843 NULL, |
901 ff_h263_decode_end, | 844 ff_h263_decode_end, |
902 ff_h263_decode_frame, | 845 ff_h263_decode_frame, |
903 CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | 846 CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 |
904 }; | 847 }; |
905 | |
906 #ifdef CONFIG_H263_PARSER | |
907 AVCodecParser h263_parser = { | |
908 { CODEC_ID_H263 }, | |
909 sizeof(ParseContext), | |
910 NULL, | |
911 h263_parse, | |
912 ff_parse_close, | |
913 }; | |
914 #endif |