Mercurial > libavcodec.hg
comparison h263.c @ 234:5fc0c3af3fe4 libavcodec
alternative bitstream writer (disabled by default, uncomment #define ALT_BISTREAM_WRITER in common.h if u want to try it)
author | michaelni |
---|---|
date | Tue, 12 Feb 2002 15:43:16 +0000 |
parents | 840cd25bf259 |
children | 4bb6289eff93 |
comparison
equal
deleted
inserted
replaced
233:3f5b72726118 | 234:5fc0c3af3fe4 |
---|---|
62 int format; | 62 int format; |
63 | 63 |
64 align_put_bits(&s->pb); | 64 align_put_bits(&s->pb); |
65 | 65 |
66 /* Update the pointer to last GOB */ | 66 /* Update the pointer to last GOB */ |
67 s->ptr_lastgob = s->pb.buf_ptr; | 67 s->ptr_lastgob = pbBufPtr(&s->pb); |
68 s->gob_number = 0; | 68 s->gob_number = 0; |
69 | 69 |
70 put_bits(&s->pb, 22, 0x20); /* PSC */ | 70 put_bits(&s->pb, 22, 0x20); /* PSC */ |
71 put_bits(&s->pb, 8, ((s->picture_number * 30 * FRAME_RATE_BASE) / | 71 put_bits(&s->pb, 8, ((s->picture_number * 30 * FRAME_RATE_BASE) / |
72 s->frame_rate) & 0xff); | 72 s->frame_rate) & 0xff); |
150 int pdif=0; | 150 int pdif=0; |
151 | 151 |
152 /* Check to see if we need to put a new GBSC */ | 152 /* Check to see if we need to put a new GBSC */ |
153 /* for RTP packetization */ | 153 /* for RTP packetization */ |
154 if (s->rtp_mode) { | 154 if (s->rtp_mode) { |
155 pdif = s->pb.buf_ptr - s->ptr_lastgob; | 155 pdif = pbBufPtr(&s->pb) - s->ptr_lastgob; |
156 if (pdif >= s->rtp_payload_size) { | 156 if (pdif >= s->rtp_payload_size) { |
157 /* Bad luck, packet must be cut before */ | 157 /* Bad luck, packet must be cut before */ |
158 align_put_bits(&s->pb); | 158 align_put_bits(&s->pb); |
159 flush_put_bits(&s->pb); | 159 flush_put_bits(&s->pb); |
160 /* Call the RTP callback to send the last GOB */ | 160 /* Call the RTP callback to send the last GOB */ |
161 if (s->rtp_callback) { | 161 if (s->rtp_callback) { |
162 pdif = s->pb.buf_ptr - s->ptr_lastgob; | 162 pdif = pbBufPtr(&s->pb) - s->ptr_lastgob; |
163 s->rtp_callback(s->ptr_lastgob, pdif, s->gob_number); | 163 s->rtp_callback(s->ptr_lastgob, pdif, s->gob_number); |
164 } | 164 } |
165 s->ptr_lastgob = s->pb.buf_ptr; | 165 s->ptr_lastgob = pbBufPtr(&s->pb); |
166 put_bits(&s->pb, 17, 1); /* GBSC */ | 166 put_bits(&s->pb, 17, 1); /* GBSC */ |
167 s->gob_number = mb_line / s->gob_index; | 167 s->gob_number = mb_line / s->gob_index; |
168 put_bits(&s->pb, 5, s->gob_number); /* GN */ | 168 put_bits(&s->pb, 5, s->gob_number); /* GN */ |
169 put_bits(&s->pb, 2, s->pict_type == I_TYPE); /* GFID */ | 169 put_bits(&s->pb, 2, s->pict_type == I_TYPE); /* GFID */ |
170 put_bits(&s->pb, 5, s->qscale); /* GQUANT */ | 170 put_bits(&s->pb, 5, s->qscale); /* GQUANT */ |
174 /* Cut the packet before we can't */ | 174 /* Cut the packet before we can't */ |
175 align_put_bits(&s->pb); | 175 align_put_bits(&s->pb); |
176 flush_put_bits(&s->pb); | 176 flush_put_bits(&s->pb); |
177 /* Call the RTP callback to send the last GOB */ | 177 /* Call the RTP callback to send the last GOB */ |
178 if (s->rtp_callback) { | 178 if (s->rtp_callback) { |
179 pdif = s->pb.buf_ptr - s->ptr_lastgob; | 179 pdif = pbBufPtr(&s->pb) - s->ptr_lastgob; |
180 s->rtp_callback(s->ptr_lastgob, pdif, s->gob_number); | 180 s->rtp_callback(s->ptr_lastgob, pdif, s->gob_number); |
181 } | 181 } |
182 s->ptr_lastgob = s->pb.buf_ptr; | 182 s->ptr_lastgob = pbBufPtr(&s->pb); |
183 put_bits(&s->pb, 17, 1); /* GBSC */ | 183 put_bits(&s->pb, 17, 1); /* GBSC */ |
184 s->gob_number = mb_line / s->gob_index; | 184 s->gob_number = mb_line / s->gob_index; |
185 put_bits(&s->pb, 5, s->gob_number); /* GN */ | 185 put_bits(&s->pb, 5, s->gob_number); /* GN */ |
186 put_bits(&s->pb, 2, s->pict_type == I_TYPE); /* GFID */ | 186 put_bits(&s->pb, 2, s->pict_type == I_TYPE); /* GFID */ |
187 put_bits(&s->pb, 5, s->qscale); /* GQUANT */ | 187 put_bits(&s->pb, 5, s->qscale); /* GQUANT */ |
487 /* write mpeg4 VOP header */ | 487 /* write mpeg4 VOP header */ |
488 void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number) | 488 void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number) |
489 { | 489 { |
490 align_put_bits(&s->pb); | 490 align_put_bits(&s->pb); |
491 | 491 |
492 put_bits(&s->pb, 32, 0x1B6); /* vop header */ | 492 put_bits(&s->pb, 16, 0); /* vop header */ |
493 put_bits(&s->pb, 16, 0x1B6); /* vop header */ | |
493 put_bits(&s->pb, 2, s->pict_type - 1); /* pict type: I = 0 , P = 1 */ | 494 put_bits(&s->pb, 2, s->pict_type - 1); /* pict type: I = 0 , P = 1 */ |
494 /* XXX: time base + 1 not always correct */ | 495 /* XXX: time base + 1 not always correct */ |
495 put_bits(&s->pb, 1, 1); | 496 put_bits(&s->pb, 1, 1); |
496 put_bits(&s->pb, 1, 0); | 497 put_bits(&s->pb, 1, 0); |
497 | 498 |
844 #endif | 845 #endif |
845 s->gob_number = get_bits(&s->gb, 5); /* GN */ | 846 s->gob_number = get_bits(&s->gb, 5); /* GN */ |
846 gfid = get_bits(&s->gb, 2); /* GFID */ | 847 gfid = get_bits(&s->gb, 2); /* GFID */ |
847 s->qscale = get_bits(&s->gb, 5); /* GQUANT */ | 848 s->qscale = get_bits(&s->gb, 5); /* GQUANT */ |
848 #ifdef DEBUG | 849 #ifdef DEBUG |
849 fprintf(stderr, "\nGN: %u GFID: %u Quant: %u\n", gn, gfid, s->qscale); | 850 fprintf(stderr, "\nGN: %u GFID: %u Quant: %u\n", s->gob_number, gfid, s->qscale); |
850 #endif | 851 #endif |
851 return 1; | 852 return 1; |
852 } | 853 } |
853 return 0; | 854 return 0; |
854 | 855 |