Mercurial > libavcodec.hg
comparison msmpeg4.c @ 251:75091bfc577b libavcodec
fixing msmpeg4 decoding if fps < 16 (i thought it was a indicator for the ext header, its the fps indeed)
author | michaelni |
---|---|
date | Fri, 22 Feb 2002 19:19:01 +0000 |
parents | 214ac77c0948 |
children | fb9e77674bd4 |
comparison
equal
deleted
inserted
replaced
250:3449316664b5 | 251:75091bfc577b |
---|---|
19 #include <stdlib.h> | 19 #include <stdlib.h> |
20 #include <stdio.h> | 20 #include <stdio.h> |
21 #include "common.h" | 21 #include "common.h" |
22 #include "dsputil.h" | 22 #include "dsputil.h" |
23 #include "mpegvideo.h" | 23 #include "mpegvideo.h" |
24 #include "avcodec.h" | |
24 | 25 |
25 /* | 26 /* |
26 * You can also call this codec : MPEG4 with a twist ! | 27 * You can also call this codec : MPEG4 with a twist ! |
27 * | 28 * |
28 * TODO: | 29 * TODO: |
210 #endif | 211 #endif |
211 } | 212 } |
212 | 213 |
213 void msmpeg4_encode_ext_header(MpegEncContext * s) | 214 void msmpeg4_encode_ext_header(MpegEncContext * s) |
214 { | 215 { |
215 if(s->pict_type == P_TYPE) | |
216 { | |
217 return; // P-Frames dont seem to have them and not even a 0 bit | |
218 } | |
219 else | |
220 { | |
221 s->flipflop_rounding=1; | 216 s->flipflop_rounding=1; |
222 s->bitrate= 910; | 217 s->bitrate= 910; // FIXME |
223 | 218 |
224 put_bits(&s->pb, 1, 1); // ext header indicator | 219 put_bits(&s->pb, 5, s->frame_rate / FRAME_RATE_BASE); //yes 29.97 -> 29 |
225 | |
226 put_bits(&s->pb, 4, 7); // ? | |
227 | 220 |
228 put_bits(&s->pb, 11, s->bitrate); | 221 put_bits(&s->pb, 11, s->bitrate); |
229 | 222 |
230 put_bits(&s->pb, 1, s->flipflop_rounding); | 223 put_bits(&s->pb, 1, s->flipflop_rounding); |
231 } | |
232 } | 224 } |
233 | 225 |
234 /* predict coded block */ | 226 /* predict coded block */ |
235 static inline int coded_block_pred(MpegEncContext * s, int n, UINT8 **coded_block_ptr) | 227 static inline int coded_block_pred(MpegEncContext * s, int n, UINT8 **coded_block_ptr) |
236 { | 228 { |
746 return 0; | 738 return 0; |
747 } | 739 } |
748 | 740 |
749 int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size) | 741 int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size) |
750 { | 742 { |
751 int firstBit=0; | |
752 | |
753 /* the alt_bitstream reader could read over the end so we need to check it */ | 743 /* the alt_bitstream reader could read over the end so we need to check it */ |
754 if(get_bits_count(&s->gb) < buf_size*8) firstBit= get_bits1(&s->gb); | 744 if(get_bits_count(&s->gb) + 16 < buf_size*8) |
755 | |
756 if(s->pict_type == P_TYPE) | |
757 { | 745 { |
758 if(firstBit) return -1; // havnt seen ext headers in P-Frames yet ;) | 746 int fps; |
747 | |
748 fps= get_bits(&s->gb, 5); | |
749 s->bitrate= get_bits(&s->gb, 11); | |
750 s->flipflop_rounding= get_bits1(&s->gb); | |
751 | |
752 // printf("fps:%2d bps:%2d roundingType:%1d\n", fps, s->bitrate, s->flipflop_rounding); | |
759 } | 753 } |
760 else | 754 else |
761 { | 755 { |
762 int unk; | 756 s->flipflop_rounding= 0; |
763 if(!firstBit) // no header found | 757 s->bitrate= 0; |
764 { | 758 } |
765 s->flipflop_rounding= 0; | 759 |
766 s->bitrate= 0; | |
767 return 0; | |
768 } | |
769 | |
770 unk= get_bits(&s->gb, 4); | |
771 s->bitrate= get_bits(&s->gb, 11); | |
772 | |
773 // printf("%2d %4d ;; %1X\n", unk,s->bitrate, unk); | |
774 | |
775 s->flipflop_rounding= get_bits1(&s->gb); | |
776 } | |
777 | |
778 return 0; | 760 return 0; |
779 } | 761 } |
780 | 762 |
781 static inline void memsetw(short *tab, int val, int n) | 763 static inline void memsetw(short *tab, int val, int n) |
782 { | 764 { |