comparison msmpeg4.c @ 208:2eb04d6be309 libavcodec

(commit by michael) bye bye weird al rounding bug ;)
author arpi_esp
date Tue, 15 Jan 2002 22:22:41 +0000
parents fceb435fae6b
children 73df666cacc7
comparison
equal deleted inserted replaced
207:6954f2830e4a 208:2eb04d6be309
183 code012(&s->pb, s->rl_table_index); 183 code012(&s->pb, s->rl_table_index);
184 184
185 put_bits(&s->pb, 1, s->dc_table_index); 185 put_bits(&s->pb, 1, s->dc_table_index);
186 186
187 put_bits(&s->pb, 1, s->mv_table_index); 187 put_bits(&s->pb, 1, s->mv_table_index);
188 s->no_rounding ^= 1; 188
189 if(s->flipflop_rounding){
190 s->no_rounding ^= 1;
191 }else{
192 s->no_rounding = 0;
193 }
189 } 194 }
190 195
191 if (!init_done) { 196 if (!init_done) {
192 /* init various encoding tables */ 197 /* init various encoding tables */
193 init_done = 1; 198 init_done = 1;
199 204
200 #ifdef DEBUG 205 #ifdef DEBUG
201 intra_count = 0; 206 intra_count = 0;
202 printf("*****frame %d:\n", frame_count++); 207 printf("*****frame %d:\n", frame_count++);
203 #endif 208 #endif
209 }
210
211 void msmpeg4_encode_ext_header(MpegEncContext * s)
212 {
213 if(s->pict_type == P_TYPE)
214 {
215 return; // P-Frames dont seem to have them and not even a 0 bit
216 }
217 else
218 {
219 s->flipflop_rounding=1;
220 s->bitrate= 910;
221
222 put_bits(&s->pb, 1, 1); // ext header indicator
223
224 put_bits(&s->pb, 4, 7); // ?
225
226 put_bits(&s->pb, 11, s->bitrate);
227
228 put_bits(&s->pb, 1, s->flipflop_rounding);
229 }
204 } 230 }
205 231
206 /* predict coded block */ 232 /* predict coded block */
207 static inline int coded_block_pred(MpegEncContext * s, int n, UINT8 **coded_block_ptr) 233 static inline int coded_block_pred(MpegEncContext * s, int n, UINT8 **coded_block_ptr)
208 { 234 {
652 } 678 }
653 679
654 int msmpeg4_decode_picture_header(MpegEncContext * s) 680 int msmpeg4_decode_picture_header(MpegEncContext * s)
655 { 681 {
656 int code; 682 int code;
657 static int weirdAl=0;
658 683
659 s->pict_type = get_bits(&s->gb, 2) + 1; 684 s->pict_type = get_bits(&s->gb, 2) + 1;
660 if (s->pict_type != I_TYPE && 685 if (s->pict_type != I_TYPE &&
661 s->pict_type != P_TYPE) 686 s->pict_type != P_TYPE)
662 return -1; 687 return -1;
694 s->use_skip_mb_code, 719 s->use_skip_mb_code,
695 s->rl_table_index, 720 s->rl_table_index,
696 s->rl_chroma_table_index, 721 s->rl_chroma_table_index,
697 s->dc_table_index, 722 s->dc_table_index,
698 s->mv_table_index);*/ 723 s->mv_table_index);*/
699 if(weirdAl) 724 if(s->flipflop_rounding){
700 s->no_rounding = 0; 725 s->no_rounding ^= 1;
701 else 726 }else{
702 s->no_rounding ^= 1; 727 s->no_rounding = 0;
703 } 728 }
729 // printf("%d", s->no_rounding);
730 }
731
732
704 #ifdef DEBUG 733 #ifdef DEBUG
705 printf("*****frame %d:\n", frame_count++); 734 printf("*****frame %d:\n", frame_count++);
706 #endif 735 #endif
736 return 0;
737 }
738
739 int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
740 {
741 int firstBit=0;
742
743 /* the alt_bitstream reader could read over the end so we need to check it */
744 if(get_bits_count(&s->gb) < buf_size*8) firstBit= get_bits1(&s->gb);
745
746 if(s->pict_type == P_TYPE)
747 {
748 if(firstBit) return -1; // havnt seen ext headers in P-Frames yet ;)
749 }
750 else
751 {
752 int unk;
753 if(!firstBit) // no header found
754 {
755 s->flipflop_rounding= 0;
756 s->bitrate= 0;
757 return 0;
758 }
759
760 unk= get_bits(&s->gb, 4);
761 s->bitrate= get_bits(&s->gb, 11);
762
763 // printf("%2d %4d ;; %1X\n", unk,s->bitrate, unk);
764
765 s->flipflop_rounding= get_bits1(&s->gb);
766 }
767
707 return 0; 768 return 0;
708 } 769 }
709 770
710 void memsetw(short *tab, int val, int n) 771 void memsetw(short *tab, int val, int n)
711 { 772 {