Mercurial > libavcodec.hg
comparison h261.c @ 2047:541686b38a5e libavcodec
removing h263 specific code
author | michael |
---|---|
date | Sun, 30 May 2004 22:29:15 +0000 |
parents | 863ce5459aec |
children | c89a3019e088 |
comparison
equal
deleted
inserted
replaced
2046:863ce5459aec | 2047:541686b38a5e |
---|---|
660 H261Context *h= avctx->priv_data; | 660 H261Context *h= avctx->priv_data; |
661 MpegEncContext *s = &h->s; | 661 MpegEncContext *s = &h->s; |
662 int ret; | 662 int ret; |
663 AVFrame *pict = data; | 663 AVFrame *pict = data; |
664 | 664 |
665 #ifdef PRINT_FRAME_TIME | |
666 uint64_t time= rdtsc(); | |
667 #endif | |
668 #ifdef DEBUG | 665 #ifdef DEBUG |
669 printf("*****frame %d size=%d\n", avctx->frame_number, buf_size); | 666 printf("*****frame %d size=%d\n", avctx->frame_number, buf_size); |
670 printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); | 667 printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); |
671 #endif | 668 #endif |
672 s->flags= avctx->flags; | 669 s->flags= avctx->flags; |
673 s->flags2= avctx->flags2; | 670 s->flags2= avctx->flags2; |
674 | 671 |
675 /* no supplementary picture */ | 672 /* no supplementary picture */ |
676 if (buf_size == 0) { | 673 if (buf_size == 0) { |
677 /* special case for last picture */ | |
678 if (s->low_delay==0 && s->next_picture_ptr) { | |
679 *pict= *(AVFrame*)s->next_picture_ptr; | |
680 s->next_picture_ptr= NULL; | |
681 | |
682 *data_size = sizeof(AVFrame); | |
683 } | |
684 | 674 |
685 return 0; | 675 return 0; |
686 } | 676 } |
687 | 677 |
688 if(s->flags&CODEC_FLAG_TRUNCATED){ | 678 if(s->flags&CODEC_FLAG_TRUNCATED){ |
695 } | 685 } |
696 | 686 |
697 | 687 |
698 retry: | 688 retry: |
699 | 689 |
700 if(s->bitstream_buffer_size && buf_size<20){ | 690 init_get_bits(&s->gb, buf, buf_size*8); |
701 init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8); | |
702 }else | |
703 init_get_bits(&s->gb, buf, buf_size*8); | |
704 s->bitstream_buffer_size=0; | |
705 | 691 |
706 if(!s->context_initialized){ | 692 if(!s->context_initialized){ |
707 if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix | 693 if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix |
708 return -1; | 694 return -1; |
709 } | 695 } |
713 int i= ff_find_unused_picture(s, 0); | 699 int i= ff_find_unused_picture(s, 0); |
714 s->current_picture_ptr= &s->picture[i]; | 700 s->current_picture_ptr= &s->picture[i]; |
715 } | 701 } |
716 | 702 |
717 ret = h261_decode_picture_header(h); | 703 ret = h261_decode_picture_header(h); |
718 | |
719 if(ret==FRAME_SKIPED) return get_consumed_bytes(s, buf_size); | |
720 | 704 |
721 /* skip if the header was thrashed */ | 705 /* skip if the header was thrashed */ |
722 if (ret < 0){ | 706 if (ret < 0){ |
723 av_log(s->avctx, AV_LOG_ERROR, "header damaged\n"); | 707 av_log(s->avctx, AV_LOG_ERROR, "header damaged\n"); |
724 return -1; | 708 return -1; |
774 h->last_bits = 0; | 758 h->last_bits = 0; |
775 } | 759 } |
776 | 760 |
777 assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); | 761 assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); |
778 assert(s->current_picture.pict_type == s->pict_type); | 762 assert(s->current_picture.pict_type == s->pict_type); |
779 if(s->low_delay){ | 763 *pict= *(AVFrame*)&s->current_picture; |
780 *pict= *(AVFrame*)&s->current_picture; | 764 ff_print_debug_info(s, pict); |
781 ff_print_debug_info(s, pict); | |
782 }else{ | |
783 *pict= *(AVFrame*)&s->last_picture; | |
784 if(pict) | |
785 ff_print_debug_info(s, pict); | |
786 } | |
787 | 765 |
788 /* Return the Picture timestamp as the frame number */ | 766 /* Return the Picture timestamp as the frame number */ |
789 /* we substract 1 because it is added on utils.c */ | 767 /* we substract 1 because it is added on utils.c */ |
790 avctx->frame_number = s->picture_number - 1; | 768 avctx->frame_number = s->picture_number - 1; |
791 | 769 |
792 /* dont output the last pic after seeking */ | 770 *data_size = sizeof(AVFrame); |
793 if(s->last_picture_ptr || s->low_delay) | 771 |
794 *data_size = sizeof(AVFrame); | 772 return get_consumed_bytes(s, buf_size); |
795 #ifdef PRINT_FRAME_TIME | |
796 printf("%Ld\n", rdtsc()-time); | |
797 #endif | |
798 | |
799 return get_consumed_bytes(s, buf_size); | |
800 } | 773 } |
801 | 774 |
802 static int h261_decode_end(AVCodecContext *avctx) | 775 static int h261_decode_end(AVCodecContext *avctx) |
803 { | 776 { |
804 H261Context *h= avctx->priv_data; | 777 H261Context *h= avctx->priv_data; |