comparison h263dec.c @ 1278:483db104bb7b libavcodec

truncated h263 decoding support / H263-ES "demuxer"
author michaelni
date Thu, 22 May 2003 14:12:22 +0000
parents ad21a7b2349b
children 6e039762d5cb
comparison
equal deleted inserted replaced
1277:f3152eb76f1a 1278:483db104bb7b
339 pc->frame_start_found= vop_found; 339 pc->frame_start_found= vop_found;
340 pc->state= state; 340 pc->state= state;
341 return END_NOT_FOUND; 341 return END_NOT_FOUND;
342 } 342 }
343 343
344 static int h263_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
345 ParseContext *pc= &s->parse_context;
346 int vop_found, i;
347 uint32_t state;
348
349 vop_found= pc->frame_start_found;
350 state= pc->state;
351
352 i=0;
353 if(!vop_found){
354 for(i=0; i<buf_size; i++){
355 state= (state<<8) | buf[i];
356 if(state>>(32-22) == 0x20){
357 i++;
358 vop_found=1;
359 break;
360 }
361 }
362 }
363
364 if(vop_found){
365 for(; i<buf_size; i++){
366 state= (state<<8) | buf[i];
367 if(state>>(32-22) == 0x20){
368 pc->frame_start_found=0;
369 pc->state=-1;
370 return i-3;
371 }
372 }
373 }
374 pc->frame_start_found= vop_found;
375 pc->state= state;
376
377 return END_NOT_FOUND;
378 }
379
344 /** 380 /**
345 * draws an line from (ex, ey) -> (sx, sy). 381 * draws an line from (ex, ey) -> (sx, sy).
346 * @param w width of the image 382 * @param w width of the image
347 * @param h height of the image 383 * @param h height of the image
348 * @param stride stride/linesize of the image 384 * @param stride stride/linesize of the image
438 if(s->flags&CODEC_FLAG_TRUNCATED){ 474 if(s->flags&CODEC_FLAG_TRUNCATED){
439 int next; 475 int next;
440 476
441 if(s->codec_id==CODEC_ID_MPEG4){ 477 if(s->codec_id==CODEC_ID_MPEG4){
442 next= mpeg4_find_frame_end(s, buf, buf_size); 478 next= mpeg4_find_frame_end(s, buf, buf_size);
479 }else if(s->codec_id==CODEC_ID_H263){
480 next= h263_find_frame_end(s, buf, buf_size);
443 }else{ 481 }else{
444 fprintf(stderr, "this codec doesnt support truncated bitstreams\n"); 482 fprintf(stderr, "this codec doesnt support truncated bitstreams\n");
445 return -1; 483 return -1;
446 } 484 }
447 485
751 if(s->last_picture_ptr || s->low_delay) 789 if(s->last_picture_ptr || s->low_delay)
752 *data_size = sizeof(AVFrame); 790 *data_size = sizeof(AVFrame);
753 #ifdef PRINT_FRAME_TIME 791 #ifdef PRINT_FRAME_TIME
754 printf("%Ld\n", rdtsc()-time); 792 printf("%Ld\n", rdtsc()-time);
755 #endif 793 #endif
794
756 return get_consumed_bytes(s, buf_size); 795 return get_consumed_bytes(s, buf_size);
757 } 796 }
758 797
759 static const AVOption mpeg4_decoptions[] = 798 static const AVOption mpeg4_decoptions[] =
760 { 799 {
782 sizeof(MpegEncContext), 821 sizeof(MpegEncContext),
783 ff_h263_decode_init, 822 ff_h263_decode_init,
784 NULL, 823 NULL,
785 ff_h263_decode_end, 824 ff_h263_decode_end,
786 ff_h263_decode_frame, 825 ff_h263_decode_frame,
787 CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, 826 CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
788 }; 827 };
789 828
790 AVCodec msmpeg4v1_decoder = { 829 AVCodec msmpeg4v1_decoder = {
791 "msmpeg4v1", 830 "msmpeg4v1",
792 CODEC_TYPE_VIDEO, 831 CODEC_TYPE_VIDEO,