[cvs] / xvidcore / src / bitstream / bitstream.c Repository:
ViewVC logotype

Annotation of /xvidcore/src/bitstream/bitstream.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (view) (download)

1 : Isibaar 1.1 /******************************************************************************
2 :     * *
3 :     * This file is part of XviD, a free MPEG-4 video encoder/decoder *
4 :     * *
5 :     * XviD is an implementation of a part of one or more MPEG-4 Video tools *
6 :     * as specified in ISO/IEC 14496-2 standard. Those intending to use this *
7 :     * software module in hardware or software products are advised that its *
8 :     * use may infringe existing patents or copyrights, and any such use *
9 :     * would be at such party's own risk. The original developer of this *
10 :     * software module and his/her company, and subsequent editors and their *
11 :     * companies, will have no liability for use of this software or *
12 :     * modifications or derivatives thereof. *
13 :     * *
14 :     * XviD is free software; you can redistribute it and/or modify it *
15 :     * under the terms of the GNU General Public License as published by *
16 :     * the Free Software Foundation; either version 2 of the License, or *
17 :     * (at your option) any later version. *
18 :     * *
19 :     * XviD is distributed in the hope that it will be useful, but *
20 :     * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 :     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 :     * GNU General Public License for more details. *
23 :     * *
24 :     * You should have received a copy of the GNU General Public License *
25 :     * along with this program; if not, write to the Free Software *
26 :     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
27 :     * *
28 :     ******************************************************************************/
29 :    
30 :     /******************************************************************************
31 :     * *
32 :     * bitstream.c *
33 :     * *
34 :     * Copyright (C) 2001 - Peter Ross <pross@cs.rmit.edu.au> *
35 :     * *
36 :     * For more information visit the XviD homepage: http://www.xvid.org *
37 :     * *
38 :     ******************************************************************************/
39 :    
40 :     /******************************************************************************
41 :     * *
42 :     * Revision history: *
43 :     * *
44 :     * 03.03.2002 qmatrix writing *
45 :     * 03.03.2002 merged BITREADER and BITWRITER *
46 :     * 30.02.2002 intra_dc_threshold support *
47 :     * 04.12.2001 support for additional headers *
48 :     * 16.12.2001 inital version *
49 :     * *
50 :     ******************************************************************************/
51 :    
52 :    
53 :     #include "bitstream.h"
54 :     #include "zigzag.h"
55 :    
56 :    
57 :     static int __inline log2bin(int value)
58 :     {
59 :     int n = 0;
60 :     while (value)
61 :     {
62 :     value >>= 1;
63 :     n++;
64 :     }
65 :     return n;
66 :     }
67 :    
68 :    
69 :     static const uint32_t intra_dc_threshold_table[] =
70 :     {
71 :     32, /* never use */
72 :     13,
73 :     15,
74 :     17,
75 :     19,
76 :     21,
77 :     23,
78 :     1,
79 :     };
80 :    
81 :    
82 :     /*
83 :     decode headers
84 :     returns coding_type, or -1 if error
85 :     */
86 :    
87 :     int BitstreamReadHeaders(Bitstream * bs, DECODER * dec, uint32_t * rounding, uint32_t * quant, uint32_t * fcode, uint32_t * intra_dc_threshold)
88 :     {
89 :     uint32_t vol_ver_id;
90 :     uint32_t time_inc_resolution;
91 :     uint32_t coding_type;
92 :     uint32_t start_code;
93 :    
94 :     do
95 :     {
96 :     BitstreamByteAlign(bs);
97 :     start_code = BitstreamShowBits(bs, 32);
98 :    
99 :     if (start_code == VISOBJSEQ_START_CODE)
100 :     {
101 :     // DEBUG("visual_object_sequence");
102 :     BitstreamSkip(bs, 32); // visual_object_sequence_start_code
103 :     BitstreamSkip(bs, 8); // profile_and_level_indication
104 :     }
105 :     else if (start_code == VISOBJSEQ_STOP_CODE)
106 :     {
107 :     BitstreamSkip(bs, 32); // visual_object_sequence_stop_code
108 :     }
109 :     else if (start_code == VISOBJ_START_CODE)
110 :     {
111 :     // DEBUG("visual_object");
112 :     BitstreamSkip(bs,32); // visual_object_start_code
113 :     if (BitstreamGetBit(bs)) // is_visual_object_identified
114 :     {
115 :     vol_ver_id = BitstreamGetBits(bs,4); // visual_object_ver_id
116 :     BitstreamSkip(bs, 3); // visual_object_priority
117 :     }
118 :     else
119 :     {
120 :     vol_ver_id = 1;
121 :     }
122 :    
123 :     if (BitstreamShowBits(bs, 4) != VISOBJ_TYPE_VIDEO) // visual_object_type
124 :     {
125 :     DEBUG("visual_object_type != video");
126 :     return -1;
127 :     }
128 :     BitstreamSkip(bs, 4);
129 :    
130 :     // video_signal_type
131 :    
132 :     if (BitstreamGetBit(bs)) // video_signal_type
133 :     {
134 :     DEBUG("+ video_signal_type");
135 :     BitstreamSkip(bs, 3); // video_format
136 :     BitstreamSkip(bs, 1); // video_range
137 :     if (BitstreamGetBit(bs)) // color_description
138 :     {
139 :     DEBUG("+ color_description");
140 :     BitstreamSkip(bs, 8); // color_primaries
141 :     BitstreamSkip(bs, 8); // transfer_characteristics
142 :     BitstreamSkip(bs, 8); // matrix_coefficients
143 :     }
144 :     }
145 :     }
146 :     else if ((start_code & ~0x1f) == VIDOBJ_START_CODE)
147 :     {
148 :     BitstreamSkip(bs, 32); // video_object_start_code
149 :     }
150 :     else if ((start_code & ~0xf) == VIDOBJLAY_START_CODE)
151 :     {
152 :     // DEBUG("video_object_layer");
153 :     BitstreamSkip(bs, 32); // video_object_layer_start_code
154 :    
155 :     BitstreamSkip(bs, 1); // random_accessible_vol
156 :    
157 :     // video_object_type_indication
158 :     if (BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_SIMPLE &&
159 :     BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_CORE &&
160 :     BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_MAIN &&
161 :     BitstreamShowBits(bs, 8) != 0) // BUGGY DIVX
162 :     {
163 :     DEBUG1("video_object_type_indication not supported", BitstreamShowBits(bs, 8));
164 :     return -1;
165 :     }
166 :     BitstreamSkip(bs, 8);
167 :    
168 :    
169 :     if (BitstreamGetBit(bs)) // is_object_layer_identifier
170 :     {
171 :     DEBUG("+ is_object_layer_identifier");
172 :     vol_ver_id = BitstreamGetBits(bs,4); // video_object_layer_verid
173 :     BitstreamSkip(bs, 3); // video_object_layer_priority
174 :     }
175 :     else
176 :     {
177 :     vol_ver_id = 1;
178 :     }
179 :     //DEBUGI("vol_ver_id", vol_ver_id);
180 :    
181 :     if (BitstreamGetBits(bs, 4) == VIDOBJLAY_AR_EXTPAR) // aspect_ratio_info
182 :     {
183 :     DEBUG("+ aspect_ratio_info");
184 :     BitstreamSkip(bs, 8); // par_width
185 :     BitstreamSkip(bs, 8); // par_height
186 :     }
187 :    
188 :     if (BitstreamGetBit(bs)) // vol_control_parameters
189 :     {
190 :     DEBUG("+ vol_control_parameters");
191 :     BitstreamSkip(bs, 2); // chroma_format
192 :     BitstreamSkip(bs, 1); // low_delay
193 :     if (BitstreamGetBit(bs)) // vbv_parameters
194 :     {
195 :     DEBUG("+ vbv_parameters");
196 :     BitstreamSkip(bs, 15); // first_half_bitrate
197 :     READ_MARKER();
198 :     BitstreamSkip(bs, 15); // latter_half_bitrate
199 :     READ_MARKER();
200 :     BitstreamSkip(bs, 15); // first_half_vbv_buffer_size
201 :     READ_MARKER();
202 :     BitstreamSkip(bs, 3); // latter_half_vbv_buffer_size
203 :     BitstreamSkip(bs, 11); // first_half_vbv_occupancy
204 :     READ_MARKER();
205 :     BitstreamSkip(bs, 15); // latter_half_vbv_occupancy
206 :     READ_MARKER();
207 :    
208 :     }
209 :     }
210 :    
211 :     dec->shape = BitstreamGetBits(bs, 2); // video_object_layer_shape
212 :     // DEBUG1("shape", dec->shape);
213 :    
214 :     if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE && vol_ver_id != 1)
215 :     {
216 :     BitstreamSkip(bs, 4); // video_object_layer_shape_extension
217 :     }
218 :    
219 :     READ_MARKER();
220 :    
221 :     time_inc_resolution = BitstreamGetBits(bs, 16); // vop_time_increment_resolution
222 :     time_inc_resolution--;
223 :     if (time_inc_resolution > 0)
224 :     {
225 :     dec->time_inc_bits = log2bin(time_inc_resolution);
226 :     }
227 :     else
228 :     {
229 :     // dec->time_inc_bits = 0;
230 :    
231 :     // for "old" xvid compatibility, set time_inc_bits = 1
232 :     dec->time_inc_bits = 1;
233 :     }
234 :    
235 :     READ_MARKER();
236 :    
237 :     if (BitstreamGetBit(bs)) // fixed_vop_rate
238 :     {
239 :     BitstreamSkip(bs, dec->time_inc_bits); // fixed_vop_time_increment
240 :     }
241 :    
242 :     if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY)
243 :     {
244 :    
245 :     if (dec->shape == VIDOBJLAY_SHAPE_RECTANGULAR)
246 :     {
247 :     uint32_t width, height;
248 :    
249 :     READ_MARKER();
250 :     width = BitstreamGetBits(bs, 13); // video_object_layer_width
251 :     //DEBUGI("width", width);
252 :     READ_MARKER();
253 :     height = BitstreamGetBits(bs, 13); // video_object_layer_height
254 :     //DEBUGI("height", height);
255 :     READ_MARKER();
256 :    
257 :     if (width != dec->width || height != dec->height)
258 :     {
259 :     DEBUG("FATAL: video dimension discrepancy ***");
260 :     DEBUG2("bitstream width/height", width, height);
261 :     DEBUG2("param width/height", dec->width, dec->height);
262 :     return -1;
263 :     }
264 :    
265 :     }
266 :    
267 :     if (BitstreamGetBit(bs)) // interlaced
268 :     {
269 :     DEBUG("TODO: interlaced");
270 :     // TODO
271 :     return -1;
272 :     }
273 :    
274 :     if (!BitstreamGetBit(bs)) // obmc_disable
275 :     {
276 :     DEBUG("IGNORED/TODO: !obmc_disable");
277 :     // TODO
278 :     // fucking divx4.02 has this enabled
279 :     }
280 :    
281 :     if (BitstreamGetBits(bs, (vol_ver_id == 1 ? 1 : 2))) // sprite_enable
282 :     {
283 :     DEBUG("sprite_enable; not supported");
284 :     return -1;
285 :     }
286 :    
287 :     if (vol_ver_id != 1 && dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR)
288 :     {
289 :     BitstreamSkip(bs, 1); // sadct_disable
290 :     }
291 :    
292 :     if (BitstreamGetBit(bs)) // not_8_bit
293 :     {
294 :     DEBUG("+ not_8_bit [IGNORED/TODO]");
295 :     dec->quant_bits = BitstreamGetBits(bs, 4); // quant_precision
296 :     BitstreamSkip(bs, 4); // bits_per_pixel
297 :     }
298 :     else
299 :     {
300 :     dec->quant_bits = 5;
301 :     }
302 :    
303 :     if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE)
304 :     {
305 :     BitstreamSkip(bs, 1); // no_gray_quant_update
306 :     BitstreamSkip(bs, 1); // composition_method
307 :     BitstreamSkip(bs, 1); // linear_composition
308 :     }
309 :    
310 :     dec->quant_type = BitstreamGetBit(bs); // quant_type
311 :     // DEBUG1("**** quant_type", dec->quant_type);
312 :    
313 :     if (dec->quant_type)
314 :     {
315 :     if (BitstreamGetBit(bs)) // load_intra_quant_mat
316 :     {
317 :     DEBUG("TODO: load_intra_quant_mat");
318 :     // TODO
319 :     return -1;
320 :     }
321 :     if (BitstreamGetBit(bs)) // load_inter_quant_mat
322 :     {
323 :     DEBUG("TODO: load_inter_quant_mat");
324 :     // TODO
325 :     return -1;
326 :     }
327 :    
328 :     if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE)
329 :     {
330 :     // TODO
331 :     DEBUG("TODO: grayscale matrix stuff");
332 :     return -1;
333 :     }
334 :     }
335 :    
336 :    
337 :     if (vol_ver_id != 1)
338 :     {
339 :     dec->quarterpel = BitstreamGetBit(bs); // quarter_sampe
340 :     if (dec->quarterpel)
341 :     {
342 :     DEBUG("IGNORED/TODO: quarter_sample");
343 :     }
344 :     }
345 :     else
346 :     {
347 :     dec->quarterpel = 0;
348 :     }
349 :    
350 :     if (!BitstreamGetBit(bs)) // complexity_estimation_disable
351 :     {
352 :     DEBUG("TODO: complexity_estimation header");
353 :     // TODO
354 :     return -1;
355 :     }
356 :    
357 :     if (!BitstreamGetBit(bs)) // resync_marker_disable
358 :     {
359 :     DEBUG("IGNORED/TODO: !resync_marker_disable");
360 :     // TODO
361 :     }
362 :    
363 :     if (BitstreamGetBit(bs)) // data_partitioned
364 :     {
365 :     DEBUG("+ data_partitioned");
366 :     BitstreamSkip(bs, 1); // reversible_vlc
367 :     }
368 :    
369 :     if (vol_ver_id != 1)
370 :     {
371 :     if (BitstreamGetBit(bs)) // newpred_enable
372 :     {
373 :     DEBUG("+ newpred_enable");
374 :     BitstreamSkip(bs, 2); // requested_upstream_message_type
375 :     BitstreamSkip(bs, 1); // newpred_segment_type
376 :     }
377 :     if (BitstreamGetBit(bs)) // reduced_resolution_vop_enable
378 :     {
379 :     DEBUG("TODO: reduced_resolution_vop_enable");
380 :     // TODO
381 :     return -1;
382 :     }
383 :     }
384 :    
385 :     if (BitstreamGetBit(bs)) // scalability
386 :     {
387 :     // TODO
388 :     DEBUG("TODO: scalability");
389 :     return -1;
390 :     }
391 :     }
392 :     else // dec->shape == BINARY_ONLY
393 :     {
394 :     if (vol_ver_id != 1)
395 :     {
396 :     if (BitstreamGetBit(bs)) // scalability
397 :     {
398 :     // TODO
399 :     DEBUG("TODO: scalability");
400 :     return -1;
401 :     }
402 :     }
403 :     BitstreamSkip(bs, 1); // resync_marker_disable
404 :    
405 :     }
406 :    
407 :     }
408 :     else if (start_code == GRPOFVOP_START_CODE)
409 :     {
410 :     // DEBUG("group_of_vop");
411 :     BitstreamSkip(bs, 32);
412 :     {
413 :     int hours, minutes, seconds;
414 :     hours = BitstreamGetBits(bs, 5);
415 :     minutes = BitstreamGetBits(bs, 6);
416 :     READ_MARKER();
417 :     seconds = BitstreamGetBits(bs, 6);
418 :     // DEBUG3("hms", hours, minutes, seconds);
419 :     }
420 :     BitstreamSkip(bs, 1); // closed_gov
421 :     BitstreamSkip(bs, 1); // broken_link
422 :     }
423 :     else if (start_code == VOP_START_CODE)
424 :     {
425 :     // DEBUG("vop_start_code");
426 :     BitstreamSkip(bs, 32); // vop_start_code
427 :    
428 :     coding_type = BitstreamGetBits(bs, 2); // vop_coding_type
429 :     //DEBUG1("coding_type", coding_type);
430 :    
431 :     while (BitstreamGetBit(bs) != 0) ; // time_base
432 :    
433 :     READ_MARKER();
434 :    
435 :     //DEBUG1("time_inc_bits", dec->time_inc_bits);
436 :     //DEBUG1("vop_time_incr", BitstreamShowBits(bs, dec->time_inc_bits));
437 :     if (dec->time_inc_bits)
438 :     {
439 :     BitstreamSkip(bs, dec->time_inc_bits); // vop_time_increment
440 :     }
441 :    
442 :     READ_MARKER();
443 :    
444 :     if (!BitstreamGetBit(bs)) // vop_coded
445 :     {
446 :     return N_VOP;
447 :     }
448 :    
449 :     /* if (newpred_enable)
450 :     {
451 :     }
452 :     */
453 :    
454 :     if (coding_type != I_VOP)
455 :     {
456 :     *rounding = BitstreamGetBit(bs); // rounding_type
457 :     //DEBUG1("rounding", *rounding);
458 :     }
459 :    
460 :     /* if (reduced_resolution_enable)
461 :     {
462 :     }
463 :     */
464 :    
465 :     if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR)
466 :     {
467 :     uint32_t width, height;
468 :     uint32_t horiz_mc_ref, vert_mc_ref;
469 :    
470 :     width = BitstreamGetBits(bs, 13);
471 :     READ_MARKER();
472 :     height = BitstreamGetBits(bs, 13);
473 :     READ_MARKER();
474 :     horiz_mc_ref = BitstreamGetBits(bs, 13);
475 :     READ_MARKER();
476 :     vert_mc_ref = BitstreamGetBits(bs, 13);
477 :     READ_MARKER();
478 :    
479 :     // DEBUG2("vop_width/height", width, height);
480 :     // DEBUG2("ref ", horiz_mc_ref, vert_mc_ref);
481 :    
482 :     BitstreamSkip(bs, 1); // change_conv_ratio_disable
483 :     if (BitstreamGetBit(bs)) // vop_constant_alpha
484 :     {
485 :     BitstreamSkip(bs, 8); // vop_constant_alpha_value
486 :     }
487 :     }
488 :    
489 :    
490 :     if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY)
491 :     {
492 :     // intra_dc_vlc_threshold
493 :     *intra_dc_threshold = intra_dc_threshold_table[ BitstreamGetBits(bs,3) ];
494 :    
495 :     /* if (interlaced)
496 :     {
497 :     BitstreamSkip(bs, 1); // top_field_first
498 :     BitstreamSkip(bs, 1); // alternative_vertical_scan_flag
499 :     */
500 :     }
501 :    
502 :     *quant = BitstreamGetBits(bs, dec->quant_bits); // vop_quant
503 :     //DEBUG1("quant", *quant);
504 :    
505 :     if (coding_type != I_VOP)
506 :     {
507 :     *fcode = BitstreamGetBits(bs, 3); // fcode_forward
508 :     }
509 :    
510 :     if (coding_type == B_VOP)
511 :     {
512 :     // *fcode_backward = BitstreamGetBits(bs, 3); // fcode_backward
513 :     }
514 :     return coding_type;
515 :     }
516 :     else if (start_code == USERDATA_START_CODE)
517 :     {
518 :     // DEBUG("user_data");
519 :     BitstreamSkip(bs, 32); // user_data_start_code
520 :     }
521 :     else // start_code == ?
522 :     {
523 :     if (BitstreamShowBits(bs, 24) == 0x000001)
524 :     {
525 :     DEBUG1("*** WARNING: unknown start_code", BitstreamShowBits(bs, 32));
526 :     }
527 :     BitstreamSkip(bs, 8);
528 :     }
529 :     }
530 :     while ((BitstreamPos(bs) >> 3) < bs->length);
531 :    
532 :     DEBUG("*** WARNING: no vop_start_code found");
533 :     return -1; /* ignore it */
534 :     }
535 :    
536 :    
537 :     /* write custom quant matrix */
538 :    
539 :     static void bs_put_matrix(Bitstream * bs, const int16_t * matrix)
540 :     {
541 :     int i, j;
542 :     const int last = matrix[scan_tables[0][63]];
543 :    
544 :     for (j = 63; j >= 0 && matrix[scan_tables[0][j - 1]] == last; j--) ;
545 :    
546 :     for (i = 0; i <= j; i++)
547 :     {
548 :     BitstreamPutBits(bs, matrix[scan_tables[0][i]], 8);
549 :     }
550 :    
551 :     if (j < 63)
552 :     {
553 :     BitstreamPutBits(bs, 0, 8);
554 :     }
555 :     }
556 :    
557 :    
558 :     /*
559 :     write vol header
560 :     */
561 :     void BitstreamWriteVolHeader(Bitstream * const bs,
562 :     const int width,
563 :     const int height,
564 :     const int quant_type)
565 :     {
566 :     // video object_start_code & vo_id
567 :     BitstreamPad(bs);
568 :     BitstreamPutBits(bs, VO_START_CODE, 27);
569 :     BitstreamPutBits(bs, 0, 5);
570 :    
571 :     // video_object_layer_start_code & vol_id
572 :     BitstreamPutBits(bs, VOL_START_CODE, 28);
573 :     BitstreamPutBits(bs, 0, 4);
574 :    
575 :     BitstreamPutBit(bs, 0); // random_accessible_vol
576 :     BitstreamPutBits(bs, 0, 8); // video_object_type_indication
577 :     BitstreamPutBit(bs, 0); // is_object_layer_identified (0=not given)
578 :     BitstreamPutBits(bs, 1, 4); // aspect_ratio_info (1=1:1)
579 :     BitstreamPutBit(bs, 0); // vol_control_parameters (0=not given)
580 :     BitstreamPutBits(bs, 0, 2); // video_object_layer_shape (0=rectangular)
581 :    
582 :     WRITE_MARKER();
583 :    
584 :     /* time_increment_resolution; ignored by current decore versions
585 :     eg. 2fps res=2 inc=1
586 :     25fps res=25 inc=1
587 :     29.97fps res=30000 inc=1001
588 :     */
589 :     BitstreamPutBits(bs, 2, 16);
590 :    
591 :     WRITE_MARKER();
592 :    
593 :     // fixed_vop_rate
594 :     BitstreamPutBit(bs, 0);
595 :    
596 :     // fixed_time_increment: value=nth_of_sec, nbits = log2(resolution)
597 :     // BitstreamPutBits(bs, 0, 15);
598 :    
599 :     WRITE_MARKER();
600 :     BitstreamPutBits(bs, width, 13); // width
601 :     WRITE_MARKER();
602 :     BitstreamPutBits(bs, height, 13); // height
603 :     WRITE_MARKER();
604 :    
605 :     BitstreamPutBit(bs, 0); // interlace
606 :     BitstreamPutBit(bs, 1); // obmc_disable (overlapped block motion compensation)
607 :     BitstreamPutBit(bs, 0); // sprite_enable
608 :     BitstreamPutBit(bs, 0); // not_in_bit
609 :    
610 :     // quant_type 0=h.263 1=mpeg4(quantizer tables)
611 :     BitstreamPutBit(bs, quant_type);
612 :     /*
613 :     if (quant_type)
614 :     {
615 :     BitstreamPutBit(bs, qmatrix->custom_intra); // load_intra_quant_mat
616 :     if (qmatrix->custom_intra)
617 :     {
618 :     bs_put_matrix(bs, qmatrix->intra);
619 :     }
620 :    
621 :     BitstreamPutBit(bs, qmatrix->custom_inter); // load_inter_quant_mat
622 :     if (qmatrix->custom_inter)
623 :     {
624 :     bs_put_matrix(bs, qmatrix->inter);
625 :     }
626 :    
627 :     }
628 :     */
629 :     if (quant_type)
630 :     {
631 :     BitstreamPutBit(bs, 0); // load_intra_quant_mat
632 :     BitstreamPutBit(bs, 0); // load_inter_quant_mat
633 :     }
634 :    
635 :     BitstreamPutBit(bs, 1); // complexity_estimation_disable
636 :     BitstreamPutBit(bs, 1); // resync_marker_disable
637 :     BitstreamPutBit(bs, 0); // data_partitioned
638 :     BitstreamPutBit(bs, 0); // scalability
639 :     }
640 :    
641 :    
642 :     /*
643 :     write vop header
644 :    
645 :     NOTE: doesnt handle bother with time_base & time_inc
646 :     time_base = n seconds since last resync (eg. last iframe)
647 :     time_inc = nth of a second since last resync
648 :     (decoder uses these values to determine precise time since last resync)
649 :     */
650 :     void BitstreamWriteVopHeader(Bitstream * const bs,
651 :     VOP_TYPE prediction_type,
652 :     const int rounding_type,
653 :     const uint32_t quant,
654 :     const uint32_t fcode)
655 :     {
656 :     BitstreamPad(bs);
657 :     BitstreamPutBits(bs, VOP_START_CODE, 32);
658 :    
659 :     BitstreamPutBits(bs, prediction_type, 2);
660 :    
661 :     // time_base = 0 write n x PutBit(1), PutBit(0)
662 :     BitstreamPutBits(bs, 0, 1);
663 :    
664 :     WRITE_MARKER();
665 :    
666 :     // time_increment: value=nth_of_sec, nbits = log2(resolution)
667 :     BitstreamPutBits(bs, 1, 1);
668 :    
669 :     WRITE_MARKER();
670 :    
671 :     BitstreamPutBits(bs, 1, 1); // vop_coded
672 :    
673 :     if (prediction_type != I_VOP)
674 :     BitstreamPutBits(bs, rounding_type, 1);
675 :    
676 :     BitstreamPutBits(bs, 0, 3); // intra_dc_vlc_threshold
677 :    
678 :     BitstreamPutBits(bs, quant, 5); // quantizer
679 :    
680 :     if (prediction_type != I_VOP)
681 :     BitstreamPutBits(bs, fcode, 3); // fixed_code = [1,4]
682 :     }

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4