Mercurial > libavcodec.hg
comparison h261.c @ 2290:89a5e4601343 libavcodec
nonsense removial
author | michael |
---|---|
date | Fri, 08 Oct 2004 21:45:29 +0000 |
parents | 21f450be6cb5 |
children | c4e882a7c07c |
comparison
equal
deleted
inserted
replaced
2289:5443c3fc2448 | 2290:89a5e4601343 |
---|---|
128 | 128 |
129 s->codec_id= avctx->codec->id; | 129 s->codec_id= avctx->codec->id; |
130 | 130 |
131 h261_decode_init_vlc(h); | 131 h261_decode_init_vlc(h); |
132 | 132 |
133 h->bits_left = 0; | |
134 h->last_bits = 0; | |
135 h->gob_start_code_skipped = 0; | 133 h->gob_start_code_skipped = 0; |
136 | 134 |
137 return 0; | 135 return 0; |
138 } | 136 } |
139 | 137 |
484 * @return <0 if no startcode found | 482 * @return <0 if no startcode found |
485 */ | 483 */ |
486 int h261_decode_picture_header(H261Context *h){ | 484 int h261_decode_picture_header(H261Context *h){ |
487 MpegEncContext * const s = &h->s; | 485 MpegEncContext * const s = &h->s; |
488 int format, i; | 486 int format, i; |
489 uint32_t startcode; | 487 uint32_t startcode= 0; |
490 align_get_bits(&s->gb); | |
491 | |
492 startcode = (h->last_bits << (12 - (8-h->bits_left))) | get_bits(&s->gb, 20-8 - (8- h->bits_left)); | |
493 | 488 |
494 for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>24; i-=1){ | 489 for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>24; i-=1){ |
495 startcode = ((startcode << 1) | get_bits(&s->gb, 1)) & 0x000FFFFF; | 490 startcode = ((startcode << 1) | get_bits(&s->gb, 1)) & 0x000FFFFF; |
496 | 491 |
497 if(startcode == 0x10) | 492 if(startcode == 0x10) |
644 | 639 |
645 /** | 640 /** |
646 * returns the number of bytes consumed for building the current frame | 641 * returns the number of bytes consumed for building the current frame |
647 */ | 642 */ |
648 static int get_consumed_bytes(MpegEncContext *s, int buf_size){ | 643 static int get_consumed_bytes(MpegEncContext *s, int buf_size){ |
649 int pos= (get_bits_count(&s->gb)+7)>>3; | |
650 | |
651 if(s->flags&CODEC_FLAG_TRUNCATED){ | 644 if(s->flags&CODEC_FLAG_TRUNCATED){ |
645 int pos= (get_bits_count(&s->gb)+7)>>3; | |
652 pos -= s->parse_context.last_index; | 646 pos -= s->parse_context.last_index; |
653 if(pos<0) pos=0;// padding is not really read so this might be -1 | 647 if(pos<0) pos=0;// padding is not really read so this might be -1 |
654 return pos; | 648 return pos; |
655 }else{ | 649 }else{ |
650 int pos= get_bits_count(&s->gb)>>3; | |
656 if(pos==0) pos=1; //avoid infinite loops (i doubt thats needed but ...) | 651 if(pos==0) pos=1; //avoid infinite loops (i doubt thats needed but ...) |
657 if(pos+10>buf_size) pos=buf_size; // oops ;) | 652 if(pos+10>buf_size) pos=buf_size; // oops ;) |
658 | 653 |
659 return pos; | 654 return pos; |
660 } | 655 } |
676 s->flags= avctx->flags; | 671 s->flags= avctx->flags; |
677 s->flags2= avctx->flags2; | 672 s->flags2= avctx->flags2; |
678 | 673 |
679 /* no supplementary picture */ | 674 /* no supplementary picture */ |
680 if (buf_size == 0) { | 675 if (buf_size == 0) { |
681 | |
682 return 0; | 676 return 0; |
683 } | 677 } |
684 | 678 |
685 if(s->flags&CODEC_FLAG_TRUNCATED){ | 679 if(s->flags&CODEC_FLAG_TRUNCATED){ |
686 int next; | 680 int next; |
747 if(ff_h261_resync(h)<0) | 741 if(ff_h261_resync(h)<0) |
748 break; | 742 break; |
749 h261_decode_gob(h); | 743 h261_decode_gob(h); |
750 } | 744 } |
751 MPV_frame_end(s); | 745 MPV_frame_end(s); |
752 | |
753 // h261 doesn't have byte aligned codes | |
754 // store the bits of the next frame that are left in the last byte | |
755 // in the H261Context and remember the number of stored bits | |
756 { | |
757 int bitsleft; | |
758 int current_pos= get_bits_count(&s->gb)>>3; | |
759 bitsleft = (current_pos<<3) - get_bits_count(&s->gb); | |
760 h->bits_left = - bitsleft; | |
761 if(bitsleft > 0) | |
762 h->last_bits= get_bits(&s->gb, 8 - h->bits_left); | |
763 else | |
764 h->last_bits = 0; | |
765 } | |
766 | 746 |
767 assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); | 747 assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); |
768 assert(s->current_picture.pict_type == s->pict_type); | 748 assert(s->current_picture.pict_type == s->pict_type); |
769 *pict= *(AVFrame*)&s->current_picture; | 749 *pict= *(AVFrame*)&s->current_picture; |
770 ff_print_debug_info(s, pict); | 750 ff_print_debug_info(s, pict); |