comparison h261.c @ 4905:4578b68578bb libavcodec

Move H.261 parser to its own file.
author diego
date Fri, 04 May 2007 19:38:10 +0000
parents 1f1a0e67b961
children f99e40a7155b
comparison
equal deleted inserted replaced
4904:811b9d7e1d3d 4905:4578b68578bb
854 } 854 }
855 855
856 return -1; 856 return -1;
857 } 857 }
858 858
859 #ifdef CONFIG_H261_PARSER
860 static int h261_find_frame_end(ParseContext *pc, AVCodecContext* avctx, const uint8_t *buf, int buf_size){
861 int vop_found, i, j;
862 uint32_t state;
863
864 vop_found= pc->frame_start_found;
865 state= pc->state;
866
867 for(i=0; i<buf_size && !vop_found; i++){
868 state= (state<<8) | buf[i];
869 for(j=0; j<8; j++){
870 if(((state>>j)&0xFFFFF) == 0x00010){
871 vop_found=1;
872 break;
873 }
874 }
875 }
876 if(vop_found){
877 for(; i<buf_size; i++){
878 state= (state<<8) | buf[i];
879 for(j=0; j<8; j++){
880 if(((state>>j)&0xFFFFF) == 0x00010){
881 pc->frame_start_found=0;
882 pc->state= state>>(2*8);
883 return i-1;
884 }
885 }
886 }
887 }
888
889 pc->frame_start_found= vop_found;
890 pc->state= state;
891 return END_NOT_FOUND;
892 }
893
894 static int h261_parse(AVCodecParserContext *s,
895 AVCodecContext *avctx,
896 uint8_t **poutbuf, int *poutbuf_size,
897 const uint8_t *buf, int buf_size)
898 {
899 ParseContext *pc = s->priv_data;
900 int next;
901
902 next= h261_find_frame_end(pc,avctx, buf, buf_size);
903 if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
904 *poutbuf = NULL;
905 *poutbuf_size = 0;
906 return buf_size;
907 }
908 *poutbuf = (uint8_t *)buf;
909 *poutbuf_size = buf_size;
910 return next;
911 }
912 #endif
913
914 /** 859 /**
915 * returns the number of bytes consumed for building the current frame 860 * returns the number of bytes consumed for building the current frame
916 */ 861 */
917 static int get_consumed_bytes(MpegEncContext *s, int buf_size){ 862 static int get_consumed_bytes(MpegEncContext *s, int buf_size){
918 int pos= get_bits_count(&s->gb)>>3; 863 int pos= get_bits_count(&s->gb)>>3;
1043 NULL, 988 NULL,
1044 h261_decode_end, 989 h261_decode_end,
1045 h261_decode_frame, 990 h261_decode_frame,
1046 CODEC_CAP_DR1, 991 CODEC_CAP_DR1,
1047 }; 992 };
1048
1049 #ifdef CONFIG_H261_PARSER
1050 AVCodecParser h261_parser = {
1051 { CODEC_ID_H261 },
1052 sizeof(ParseContext),
1053 NULL,
1054 h261_parse,
1055 ff_parse_close,
1056 };
1057 #endif