41 |
* * |
* * |
42 |
* Revision history: * |
* Revision history: * |
43 |
* * |
* * |
44 |
|
* 22.05.2002 bs_put_matrix fix |
45 |
|
* 20.05.2002 added BitstreamWriteUserData * |
46 |
|
* 19.06.2002 Fix a little bug in use custom quant matrix * |
47 |
|
* MinChen <chenm001@163.com> * |
48 |
|
* 08.05.2002 add low_delay support for B_VOP decode * |
49 |
|
* MinChen <chenm001@163.com> * |
50 |
|
* 06.05.2002 low_delay * |
51 |
|
* 06.05.2002 fixed fincr/fbase error * |
52 |
|
* 01.05.2002 added BVOP support to BitstreamWriteVopHeader * |
53 |
|
* 15.04.2002 rewrite log2bin use asm386 By MinChen <chenm001@163.com> * |
54 |
|
* 26.03.2002 interlacing support * |
55 |
* 03.03.2002 qmatrix writing * |
* 03.03.2002 qmatrix writing * |
56 |
* 03.03.2002 merged BITREADER and BITWRITER * |
* 03.03.2002 merged BITREADER and BITWRITER * |
57 |
* 30.02.2002 intra_dc_threshold support * |
* 30.02.2002 intra_dc_threshold support * |
58 |
* 04.12.2001 support for additional headers * |
* 04.12.2001 support for additional headers * |
59 |
* 16.12.2001 inital version * |
* 16.12.2001 inital version * |
60 |
* * |
* |
61 |
******************************************************************************/ |
******************************************************************************/ |
62 |
|
|
63 |
|
|
64 |
#include "bitstream.h" |
#include "bitstream.h" |
65 |
#include "zigzag.h" |
#include "zigzag.h" |
66 |
|
#include "../quant/quant_matrix.h" |
67 |
|
|
68 |
|
|
69 |
static int __inline log2bin(int value) |
static uint32_t __inline |
70 |
|
log2bin(uint32_t value) |
71 |
{ |
{ |
72 |
|
/* Changed by Chenm001 */ |
73 |
|
#ifndef WIN32 |
74 |
int n = 0; |
int n = 0; |
75 |
while (value) |
|
76 |
{ |
while (value) { |
77 |
value >>= 1; |
value >>= 1; |
78 |
n++; |
n++; |
79 |
} |
} |
80 |
return n; |
return n; |
81 |
|
#else |
82 |
|
__asm { |
83 |
|
bsr eax, value |
84 |
|
inc eax |
85 |
|
} |
86 |
|
#endif |
87 |
} |
} |
88 |
|
|
89 |
|
|
90 |
static const uint32_t intra_dc_threshold_table[] = |
static const uint32_t intra_dc_threshold_table[] = { |
|
{ |
|
91 |
32, /* never use */ |
32, /* never use */ |
92 |
13, |
13, |
93 |
15, |
15, |
99 |
}; |
}; |
100 |
|
|
101 |
|
|
102 |
|
void |
103 |
|
bs_get_matrix(Bitstream * bs, |
104 |
|
uint8_t * matrix) |
105 |
|
{ |
106 |
|
int i = 0; |
107 |
|
int last, value = 0; |
108 |
|
|
109 |
|
do { |
110 |
|
last = value; |
111 |
|
value = BitstreamGetBits(bs, 8); |
112 |
|
matrix[scan_tables[0][i++]] = value; |
113 |
|
} |
114 |
|
while (value != 0 && i < 64); |
115 |
|
i--; // fix little bug at coeff not full |
116 |
|
|
117 |
|
while (i < 64) { |
118 |
|
matrix[scan_tables[0][i++]] = last; |
119 |
|
} |
120 |
|
} |
121 |
|
|
122 |
/* |
/* |
123 |
decode headers |
decode headers |
124 |
returns coding_type, or -1 if error |
returns coding_type, or -1 if error |
125 |
*/ |
*/ |
126 |
|
|
127 |
int BitstreamReadHeaders(Bitstream * bs, DECODER * dec, uint32_t * rounding, uint32_t * quant, uint32_t * fcode, uint32_t * intra_dc_threshold) |
int |
128 |
|
BitstreamReadHeaders(Bitstream * bs, |
129 |
|
DECODER * dec, |
130 |
|
uint32_t * rounding, |
131 |
|
uint32_t * quant, |
132 |
|
uint32_t * fcode_forward, |
133 |
|
uint32_t * fcode_backward, |
134 |
|
uint32_t * intra_dc_threshold) |
135 |
{ |
{ |
136 |
uint32_t vol_ver_id; |
uint32_t vol_ver_id; |
137 |
uint32_t time_inc_resolution; |
static uint32_t time_increment_resolution; |
138 |
uint32_t coding_type; |
uint32_t coding_type; |
139 |
uint32_t start_code; |
uint32_t start_code; |
140 |
|
uint32_t time_incr = 0; |
141 |
|
int32_t time_increment; |
142 |
|
|
143 |
do |
do { |
|
{ |
|
144 |
BitstreamByteAlign(bs); |
BitstreamByteAlign(bs); |
145 |
start_code = BitstreamShowBits(bs, 32); |
start_code = BitstreamShowBits(bs, 32); |
146 |
|
|
147 |
if (start_code == VISOBJSEQ_START_CODE) |
if (start_code == VISOBJSEQ_START_CODE) { |
148 |
{ |
// DPRINTF("visual_object_sequence"); |
|
// DEBUG("visual_object_sequence"); |
|
149 |
BitstreamSkip(bs, 32); // visual_object_sequence_start_code |
BitstreamSkip(bs, 32); // visual_object_sequence_start_code |
150 |
BitstreamSkip(bs, 8); // profile_and_level_indication |
BitstreamSkip(bs, 8); // profile_and_level_indication |
151 |
} |
} else if (start_code == VISOBJSEQ_STOP_CODE) { |
|
else if (start_code == VISOBJSEQ_STOP_CODE) |
|
|
{ |
|
152 |
BitstreamSkip(bs, 32); // visual_object_sequence_stop_code |
BitstreamSkip(bs, 32); // visual_object_sequence_stop_code |
153 |
} |
} else if (start_code == VISOBJ_START_CODE) { |
154 |
else if (start_code == VISOBJ_START_CODE) |
//DPRINTF("visual_object"); |
|
{ |
|
|
// DEBUG("visual_object"); |
|
155 |
BitstreamSkip(bs,32); // visual_object_start_code |
BitstreamSkip(bs,32); // visual_object_start_code |
156 |
if (BitstreamGetBit(bs)) // is_visual_object_identified |
if (BitstreamGetBit(bs)) // is_visual_object_identified |
157 |
{ |
{ |
158 |
vol_ver_id = BitstreamGetBits(bs,4); // visual_object_ver_id |
vol_ver_id = BitstreamGetBits(bs,4); // visual_object_ver_id |
159 |
BitstreamSkip(bs, 3); // visual_object_priority |
BitstreamSkip(bs, 3); // visual_object_priority |
160 |
} |
} else { |
|
else |
|
|
{ |
|
161 |
vol_ver_id = 1; |
vol_ver_id = 1; |
162 |
} |
} |
163 |
|
|
164 |
if (BitstreamShowBits(bs, 4) != VISOBJ_TYPE_VIDEO) // visual_object_type |
if (BitstreamShowBits(bs, 4) != VISOBJ_TYPE_VIDEO) // visual_object_type |
165 |
{ |
{ |
166 |
DEBUG("visual_object_type != video"); |
//DPRINTF("visual_object_type != video"); |
167 |
return -1; |
return -1; |
168 |
} |
} |
169 |
BitstreamSkip(bs, 4); |
BitstreamSkip(bs, 4); |
172 |
|
|
173 |
if (BitstreamGetBit(bs)) // video_signal_type |
if (BitstreamGetBit(bs)) // video_signal_type |
174 |
{ |
{ |
175 |
DEBUG("+ video_signal_type"); |
//DPRINTF("+ video_signal_type"); |
176 |
BitstreamSkip(bs, 3); // video_format |
BitstreamSkip(bs, 3); // video_format |
177 |
BitstreamSkip(bs, 1); // video_range |
BitstreamSkip(bs, 1); // video_range |
178 |
if (BitstreamGetBit(bs)) // color_description |
if (BitstreamGetBit(bs)) // color_description |
179 |
{ |
{ |
180 |
DEBUG("+ color_description"); |
//DPRINTF("+ color_description"); |
181 |
BitstreamSkip(bs, 8); // color_primaries |
BitstreamSkip(bs, 8); // color_primaries |
182 |
BitstreamSkip(bs, 8); // transfer_characteristics |
BitstreamSkip(bs, 8); // transfer_characteristics |
183 |
BitstreamSkip(bs, 8); // matrix_coefficients |
BitstreamSkip(bs, 8); // matrix_coefficients |
184 |
} |
} |
185 |
} |
} |
186 |
} |
} else if ((start_code & ~0x1f) == VIDOBJ_START_CODE) { |
|
else if ((start_code & ~0x1f) == VIDOBJ_START_CODE) |
|
|
{ |
|
187 |
BitstreamSkip(bs, 32); // video_object_start_code |
BitstreamSkip(bs, 32); // video_object_start_code |
188 |
} |
} else if ((start_code & ~0xf) == VIDOBJLAY_START_CODE) { |
189 |
else if ((start_code & ~0xf) == VIDOBJLAY_START_CODE) |
//DPRINTF("video_object_layer"); |
|
{ |
|
|
// DEBUG("video_object_layer"); |
|
190 |
BitstreamSkip(bs, 32); // video_object_layer_start_code |
BitstreamSkip(bs, 32); // video_object_layer_start_code |
191 |
|
|
192 |
BitstreamSkip(bs, 1); // random_accessible_vol |
BitstreamSkip(bs, 1); // random_accessible_vol |
193 |
|
|
194 |
// video_object_type_indication |
// video_object_type_indication |
195 |
if (BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_SIMPLE && |
if (BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_SIMPLE && BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_CORE && BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_MAIN && BitstreamShowBits(bs, 8) != 0) // BUGGY DIVX |
|
BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_CORE && |
|
|
BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_MAIN && |
|
|
BitstreamShowBits(bs, 8) != 0) // BUGGY DIVX |
|
196 |
{ |
{ |
197 |
DEBUG1("video_object_type_indication not supported", BitstreamShowBits(bs, 8)); |
//DPRINTF("video_object_type_indication %i not supported ", |
198 |
|
// BitstreamShowBits(bs, 8)); |
199 |
return -1; |
return -1; |
200 |
} |
} |
201 |
BitstreamSkip(bs, 8); |
BitstreamSkip(bs, 8); |
203 |
|
|
204 |
if (BitstreamGetBit(bs)) // is_object_layer_identifier |
if (BitstreamGetBit(bs)) // is_object_layer_identifier |
205 |
{ |
{ |
206 |
DEBUG("+ is_object_layer_identifier"); |
//DPRINTF("+ is_object_layer_identifier"); |
207 |
vol_ver_id = BitstreamGetBits(bs,4); // video_object_layer_verid |
vol_ver_id = BitstreamGetBits(bs,4); // video_object_layer_verid |
208 |
BitstreamSkip(bs, 3); // video_object_layer_priority |
BitstreamSkip(bs, 3); // video_object_layer_priority |
209 |
} |
} else { |
|
else |
|
|
{ |
|
210 |
vol_ver_id = 1; |
vol_ver_id = 1; |
211 |
} |
} |
212 |
//DEBUGI("vol_ver_id", vol_ver_id); |
//DPRINTF("vol_ver_id %i", vol_ver_id); |
213 |
|
|
214 |
if (BitstreamGetBits(bs, 4) == VIDOBJLAY_AR_EXTPAR) // aspect_ratio_info |
if (BitstreamGetBits(bs, 4) == VIDOBJLAY_AR_EXTPAR) // aspect_ratio_info |
215 |
{ |
{ |
216 |
DEBUG("+ aspect_ratio_info"); |
//DPRINTF("+ aspect_ratio_info"); |
217 |
BitstreamSkip(bs, 8); // par_width |
BitstreamSkip(bs, 8); // par_width |
218 |
BitstreamSkip(bs, 8); // par_height |
BitstreamSkip(bs, 8); // par_height |
219 |
} |
} |
220 |
|
|
221 |
if (BitstreamGetBit(bs)) // vol_control_parameters |
if (BitstreamGetBit(bs)) // vol_control_parameters |
222 |
{ |
{ |
223 |
DEBUG("+ vol_control_parameters"); |
//DPRINTF("+ vol_control_parameters"); |
224 |
BitstreamSkip(bs, 2); // chroma_format |
BitstreamSkip(bs, 2); // chroma_format |
225 |
BitstreamSkip(bs, 1); // low_delay |
dec->low_delay = BitstreamGetBit(bs); // low_delay |
226 |
if (BitstreamGetBit(bs)) // vbv_parameters |
if (BitstreamGetBit(bs)) // vbv_parameters |
227 |
{ |
{ |
228 |
DEBUG("+ vbv_parameters"); |
//DPRINTF("+ vbv_parameters"); |
229 |
BitstreamSkip(bs, 15); // first_half_bitrate |
BitstreamSkip(bs, 15); // first_half_bitrate |
230 |
READ_MARKER(); |
READ_MARKER(); |
231 |
BitstreamSkip(bs, 15); // latter_half_bitrate |
BitstreamSkip(bs, 15); // latter_half_bitrate |
242 |
} |
} |
243 |
|
|
244 |
dec->shape = BitstreamGetBits(bs, 2); // video_object_layer_shape |
dec->shape = BitstreamGetBits(bs, 2); // video_object_layer_shape |
245 |
// DEBUG1("shape", dec->shape); |
//DPRINTF("shape %i", dec->shape); |
246 |
|
|
247 |
if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE && vol_ver_id != 1) |
if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE && vol_ver_id != 1) { |
|
{ |
|
248 |
BitstreamSkip(bs, 4); // video_object_layer_shape_extension |
BitstreamSkip(bs, 4); // video_object_layer_shape_extension |
249 |
} |
} |
250 |
|
|
251 |
READ_MARKER(); |
READ_MARKER(); |
252 |
|
|
253 |
time_inc_resolution = BitstreamGetBits(bs, 16); // vop_time_increment_resolution |
// *************************** for decode B-frame time *********************** |
254 |
time_inc_resolution--; |
time_increment_resolution = BitstreamGetBits(bs, 16); // vop_time_increment_resolution |
255 |
if (time_inc_resolution > 0) |
time_increment_resolution--; |
256 |
{ |
//DPRINTF("time_increment_resolution = %i",time_increment_resolution); |
257 |
dec->time_inc_bits = log2bin(time_inc_resolution); |
if (time_increment_resolution > 0) { |
258 |
} |
dec->time_inc_bits = log2bin(time_increment_resolution); |
259 |
else |
} else { |
|
{ |
|
260 |
// dec->time_inc_bits = 0; |
// dec->time_inc_bits = 0; |
261 |
|
|
262 |
// for "old" xvid compatibility, set time_inc_bits = 1 |
// for "old" xvid compatibility, set time_inc_bits = 1 |
270 |
BitstreamSkip(bs, dec->time_inc_bits); // fixed_vop_time_increment |
BitstreamSkip(bs, dec->time_inc_bits); // fixed_vop_time_increment |
271 |
} |
} |
272 |
|
|
273 |
if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) |
if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) { |
|
{ |
|
274 |
|
|
275 |
if (dec->shape == VIDOBJLAY_SHAPE_RECTANGULAR) |
if (dec->shape == VIDOBJLAY_SHAPE_RECTANGULAR) { |
|
{ |
|
276 |
uint32_t width, height; |
uint32_t width, height; |
277 |
|
|
278 |
READ_MARKER(); |
READ_MARKER(); |
279 |
width = BitstreamGetBits(bs, 13); // video_object_layer_width |
width = BitstreamGetBits(bs, 13); // video_object_layer_width |
280 |
//DEBUGI("width", width); |
//DPRINTF("width %i", width); |
281 |
READ_MARKER(); |
READ_MARKER(); |
282 |
height = BitstreamGetBits(bs, 13); // video_object_layer_height |
height = BitstreamGetBits(bs, 13); // video_object_layer_height |
283 |
//DEBUGI("height", height); |
//DPRINTF("height %i", height); |
284 |
READ_MARKER(); |
READ_MARKER(); |
285 |
|
|
286 |
if (width != dec->width || height != dec->height) |
if (width != dec->width || height != dec->height) { |
287 |
{ |
//DPRINTF("FATAL: video dimension discrepancy ***"); |
288 |
DEBUG("FATAL: video dimension discrepancy ***"); |
//DPRINTF("bitstream width/height %i x %i", width, height); |
289 |
DEBUG2("bitstream width/height", width, height); |
//DPRINTF("param width/height %i x %i", dec->width, dec->height); |
|
DEBUG2("param width/height", dec->width, dec->height); |
|
290 |
return -1; |
return -1; |
291 |
} |
} |
292 |
|
|
293 |
} |
} |
294 |
|
|
295 |
if (BitstreamGetBit(bs)) // interlaced |
if ((dec->interlacing = BitstreamGetBit(bs))) { |
296 |
{ |
//DPRINTF("vol: interlacing"); |
|
DEBUG("TODO: interlaced"); |
|
|
// TODO |
|
|
return -1; |
|
297 |
} |
} |
298 |
|
|
299 |
if (!BitstreamGetBit(bs)) // obmc_disable |
if (!BitstreamGetBit(bs)) // obmc_disable |
300 |
{ |
{ |
301 |
DEBUG("IGNORED/TODO: !obmc_disable"); |
//DPRINTF("IGNORED/TODO: !obmc_disable"); |
302 |
// TODO |
// TODO |
303 |
// fucking divx4.02 has this enabled |
// fucking divx4.02 has this enabled |
304 |
} |
} |
305 |
|
|
306 |
if (BitstreamGetBits(bs, (vol_ver_id == 1 ? 1 : 2))) // sprite_enable |
if (BitstreamGetBits(bs, (vol_ver_id == 1 ? 1 : 2))) // sprite_enable |
307 |
{ |
{ |
308 |
DEBUG("sprite_enable; not supported"); |
//DPRINTF("sprite_enable; not supported"); |
309 |
return -1; |
return -1; |
310 |
} |
} |
311 |
|
|
312 |
if (vol_ver_id != 1 && dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) |
if (vol_ver_id != 1 && |
313 |
{ |
dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) { |
314 |
BitstreamSkip(bs, 1); // sadct_disable |
BitstreamSkip(bs, 1); // sadct_disable |
315 |
} |
} |
316 |
|
|
317 |
if (BitstreamGetBit(bs)) // not_8_bit |
if (BitstreamGetBit(bs)) // not_8_bit |
318 |
{ |
{ |
319 |
DEBUG("+ not_8_bit [IGNORED/TODO]"); |
//DPRINTF("+ not_8_bit [IGNORED/TODO]"); |
320 |
dec->quant_bits = BitstreamGetBits(bs, 4); // quant_precision |
dec->quant_bits = BitstreamGetBits(bs, 4); // quant_precision |
321 |
BitstreamSkip(bs, 4); // bits_per_pixel |
BitstreamSkip(bs, 4); // bits_per_pixel |
322 |
} |
} else { |
|
else |
|
|
{ |
|
323 |
dec->quant_bits = 5; |
dec->quant_bits = 5; |
324 |
} |
} |
325 |
|
|
326 |
if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) |
if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) { |
|
{ |
|
327 |
BitstreamSkip(bs, 1); // no_gray_quant_update |
BitstreamSkip(bs, 1); // no_gray_quant_update |
328 |
BitstreamSkip(bs, 1); // composition_method |
BitstreamSkip(bs, 1); // composition_method |
329 |
BitstreamSkip(bs, 1); // linear_composition |
BitstreamSkip(bs, 1); // linear_composition |
330 |
} |
} |
331 |
|
|
332 |
dec->quant_type = BitstreamGetBit(bs); // quant_type |
dec->quant_type = BitstreamGetBit(bs); // quant_type |
333 |
// DEBUG1("**** quant_type", dec->quant_type); |
//DPRINTF("**** quant_type %i", dec->quant_type); |
334 |
|
|
335 |
if (dec->quant_type) |
if (dec->quant_type) { |
|
{ |
|
336 |
if (BitstreamGetBit(bs)) // load_intra_quant_mat |
if (BitstreamGetBit(bs)) // load_intra_quant_mat |
337 |
{ |
{ |
338 |
DEBUG("TODO: load_intra_quant_mat"); |
uint8_t matrix[64]; |
339 |
// TODO |
|
340 |
return -1; |
bs_get_matrix(bs, matrix); |
341 |
} |
set_intra_matrix(matrix); |
342 |
|
} else |
343 |
|
set_intra_matrix(get_default_intra_matrix()); |
344 |
|
|
345 |
if (BitstreamGetBit(bs)) // load_inter_quant_mat |
if (BitstreamGetBit(bs)) // load_inter_quant_mat |
346 |
{ |
{ |
347 |
DEBUG("TODO: load_inter_quant_mat"); |
uint8_t matrix[64]; |
|
// TODO |
|
|
return -1; |
|
|
} |
|
348 |
|
|
349 |
if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) |
bs_get_matrix(bs, matrix); |
350 |
{ |
set_inter_matrix(matrix); |
351 |
|
} else |
352 |
|
set_inter_matrix(get_default_inter_matrix()); |
353 |
|
|
354 |
|
if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) { |
355 |
// TODO |
// TODO |
356 |
DEBUG("TODO: grayscale matrix stuff"); |
//DPRINTF("TODO: grayscale matrix stuff"); |
357 |
return -1; |
return -1; |
358 |
} |
} |
359 |
|
|
360 |
} |
} |
361 |
|
|
362 |
|
|
363 |
if (vol_ver_id != 1) |
if (vol_ver_id != 1) { |
|
{ |
|
364 |
dec->quarterpel = BitstreamGetBit(bs); // quarter_sampe |
dec->quarterpel = BitstreamGetBit(bs); // quarter_sampe |
365 |
if (dec->quarterpel) |
if (dec->quarterpel) { |
366 |
{ |
//DPRINTF("IGNORED/TODO: quarter_sample"); |
|
DEBUG("IGNORED/TODO: quarter_sample"); |
|
367 |
} |
} |
368 |
} |
} else { |
|
else |
|
|
{ |
|
369 |
dec->quarterpel = 0; |
dec->quarterpel = 0; |
370 |
} |
} |
371 |
|
|
372 |
if (!BitstreamGetBit(bs)) // complexity_estimation_disable |
if (!BitstreamGetBit(bs)) // complexity_estimation_disable |
373 |
{ |
{ |
374 |
DEBUG("TODO: complexity_estimation header"); |
//DPRINTF("TODO: complexity_estimation header"); |
375 |
// TODO |
// TODO |
376 |
return -1; |
return -1; |
377 |
} |
} |
378 |
|
|
379 |
if (!BitstreamGetBit(bs)) // resync_marker_disable |
if (!BitstreamGetBit(bs)) // resync_marker_disable |
380 |
{ |
{ |
381 |
DEBUG("IGNORED/TODO: !resync_marker_disable"); |
//DPRINTF("IGNORED/TODO: !resync_marker_disable"); |
382 |
// TODO |
// TODO |
383 |
} |
} |
384 |
|
|
385 |
if (BitstreamGetBit(bs)) // data_partitioned |
if (BitstreamGetBit(bs)) // data_partitioned |
386 |
{ |
{ |
387 |
DEBUG("+ data_partitioned"); |
//DPRINTF("+ data_partitioned"); |
388 |
BitstreamSkip(bs, 1); // reversible_vlc |
BitstreamSkip(bs, 1); // reversible_vlc |
389 |
} |
} |
390 |
|
|
391 |
if (vol_ver_id != 1) |
if (vol_ver_id != 1) { |
|
{ |
|
392 |
if (BitstreamGetBit(bs)) // newpred_enable |
if (BitstreamGetBit(bs)) // newpred_enable |
393 |
{ |
{ |
394 |
DEBUG("+ newpred_enable"); |
//DPRINTF("+ newpred_enable"); |
395 |
BitstreamSkip(bs, 2); // requested_upstream_message_type |
BitstreamSkip(bs, 2); // requested_upstream_message_type |
396 |
BitstreamSkip(bs, 1); // newpred_segment_type |
BitstreamSkip(bs, 1); // newpred_segment_type |
397 |
} |
} |
398 |
if (BitstreamGetBit(bs)) // reduced_resolution_vop_enable |
if (BitstreamGetBit(bs)) // reduced_resolution_vop_enable |
399 |
{ |
{ |
400 |
DEBUG("TODO: reduced_resolution_vop_enable"); |
//DPRINTF("TODO: reduced_resolution_vop_enable"); |
401 |
// TODO |
// TODO |
402 |
return -1; |
return -1; |
403 |
} |
} |
404 |
} |
} |
405 |
|
|
406 |
if (BitstreamGetBit(bs)) // scalability |
if ((dec->scalability = BitstreamGetBit(bs))) // scalability |
407 |
{ |
{ |
408 |
// TODO |
// TODO |
409 |
DEBUG("TODO: scalability"); |
//DPRINTF("TODO: scalability"); |
410 |
return -1; |
return -1; |
411 |
} |
} |
412 |
} |
} else // dec->shape == BINARY_ONLY |
|
else // dec->shape == BINARY_ONLY |
|
|
{ |
|
|
if (vol_ver_id != 1) |
|
413 |
{ |
{ |
414 |
|
if (vol_ver_id != 1) { |
415 |
if (BitstreamGetBit(bs)) // scalability |
if (BitstreamGetBit(bs)) // scalability |
416 |
{ |
{ |
417 |
// TODO |
// TODO |
418 |
DEBUG("TODO: scalability"); |
//DPRINTF("TODO: scalability"); |
419 |
return -1; |
return -1; |
420 |
} |
} |
421 |
} |
} |
423 |
|
|
424 |
} |
} |
425 |
|
|
426 |
} |
} else if (start_code == GRPOFVOP_START_CODE) { |
427 |
else if (start_code == GRPOFVOP_START_CODE) |
//DPRINTF("group_of_vop"); |
|
{ |
|
|
// DEBUG("group_of_vop"); |
|
428 |
BitstreamSkip(bs, 32); |
BitstreamSkip(bs, 32); |
429 |
{ |
{ |
430 |
int hours, minutes, seconds; |
int hours, minutes, seconds; |
431 |
|
|
432 |
hours = BitstreamGetBits(bs, 5); |
hours = BitstreamGetBits(bs, 5); |
433 |
minutes = BitstreamGetBits(bs, 6); |
minutes = BitstreamGetBits(bs, 6); |
434 |
READ_MARKER(); |
READ_MARKER(); |
435 |
seconds = BitstreamGetBits(bs, 6); |
seconds = BitstreamGetBits(bs, 6); |
436 |
// DEBUG3("hms", hours, minutes, seconds); |
//DPRINTF("%ih %im %is", hours, minutes, seconds); |
437 |
} |
} |
438 |
BitstreamSkip(bs, 1); // closed_gov |
BitstreamSkip(bs, 1); // closed_gov |
439 |
BitstreamSkip(bs, 1); // broken_link |
BitstreamSkip(bs, 1); // broken_link |
440 |
} |
} else if (start_code == VOP_START_CODE) { |
441 |
else if (start_code == VOP_START_CODE) |
//DPRINTF("vop_start_code"); |
|
{ |
|
|
// DEBUG("vop_start_code"); |
|
442 |
BitstreamSkip(bs, 32); // vop_start_code |
BitstreamSkip(bs, 32); // vop_start_code |
443 |
|
|
444 |
coding_type = BitstreamGetBits(bs, 2); // vop_coding_type |
coding_type = BitstreamGetBits(bs, 2); // vop_coding_type |
445 |
//DEBUG1("coding_type", coding_type); |
//DPRINTF("coding_type %i", coding_type); |
446 |
|
|
447 |
while (BitstreamGetBit(bs) != 0) ; // time_base |
// *************************** for decode B-frame time *********************** |
448 |
|
while (BitstreamGetBit(bs) != 0) // time_base |
449 |
|
time_incr++; |
450 |
|
|
451 |
READ_MARKER(); |
READ_MARKER(); |
452 |
|
|
453 |
//DEBUG1("time_inc_bits", dec->time_inc_bits); |
if (dec->time_inc_bits) { |
454 |
//DEBUG1("vop_time_incr", BitstreamShowBits(bs, dec->time_inc_bits)); |
time_increment = (BitstreamGetBits(bs, dec->time_inc_bits)); // vop_time_increment |
455 |
if (dec->time_inc_bits) |
} |
456 |
{ |
|
457 |
BitstreamSkip(bs, dec->time_inc_bits); // vop_time_increment |
/* |
458 |
|
DPRINTF("%c %i:%i", |
459 |
|
coding_type == I_VOP ? 'I' : coding_type == P_VOP ? 'P' : 'B', |
460 |
|
time_incr, time_increment); |
461 |
|
*/ |
462 |
|
|
463 |
|
if (coding_type != B_VOP) { |
464 |
|
dec->last_time_base = dec->time_base; |
465 |
|
dec->time_base += time_incr; |
466 |
|
dec->time = |
467 |
|
dec->time_base * time_increment_resolution + |
468 |
|
time_increment; |
469 |
|
dec->time_pp = (uint32_t) (dec->time - dec->last_non_b_time); |
470 |
|
dec->last_non_b_time = dec->time; |
471 |
|
} else { |
472 |
|
dec->time = |
473 |
|
(dec->last_time_base + |
474 |
|
time_incr) * time_increment_resolution + time_increment; |
475 |
|
dec->time_bp = (uint32_t) (dec->last_non_b_time - dec->time); |
476 |
} |
} |
477 |
|
//DPRINTF("time_increment %i",time_increment); |
478 |
|
|
479 |
READ_MARKER(); |
READ_MARKER(); |
480 |
|
|
481 |
if (!BitstreamGetBit(bs)) // vop_coded |
if (!BitstreamGetBit(bs)) // vop_coded |
482 |
{ |
{ |
483 |
|
//DPRINTF("**NOT CODED**"); |
484 |
return N_VOP; |
return N_VOP; |
485 |
} |
} |
486 |
|
|
489 |
} |
} |
490 |
*/ |
*/ |
491 |
|
|
492 |
if (coding_type != I_VOP) |
// fix a little bug by MinChen <chenm002@163.com> |
493 |
{ |
if ((dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) && |
494 |
|
(coding_type == P_VOP)) { |
495 |
*rounding = BitstreamGetBit(bs); // rounding_type |
*rounding = BitstreamGetBit(bs); // rounding_type |
496 |
//DEBUG1("rounding", *rounding); |
//DPRINTF("rounding %i", *rounding); |
497 |
} |
} |
498 |
|
|
499 |
/* if (reduced_resolution_enable) |
/* if (reduced_resolution_enable) |
501 |
} |
} |
502 |
*/ |
*/ |
503 |
|
|
504 |
if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) |
if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) { |
|
{ |
|
505 |
uint32_t width, height; |
uint32_t width, height; |
506 |
uint32_t horiz_mc_ref, vert_mc_ref; |
uint32_t horiz_mc_ref, vert_mc_ref; |
507 |
|
|
514 |
vert_mc_ref = BitstreamGetBits(bs, 13); |
vert_mc_ref = BitstreamGetBits(bs, 13); |
515 |
READ_MARKER(); |
READ_MARKER(); |
516 |
|
|
517 |
// DEBUG2("vop_width/height", width, height); |
//DPRINTF("vop_width/height %i x %i", width, height); |
518 |
// DEBUG2("ref ", horiz_mc_ref, vert_mc_ref); |
//DPRINTF("ref %i x %i", horiz_mc_ref, vert_mc_ref); |
519 |
|
|
520 |
BitstreamSkip(bs, 1); // change_conv_ratio_disable |
BitstreamSkip(bs, 1); // change_conv_ratio_disable |
521 |
if (BitstreamGetBit(bs)) // vop_constant_alpha |
if (BitstreamGetBit(bs)) // vop_constant_alpha |
525 |
} |
} |
526 |
|
|
527 |
|
|
528 |
if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) |
if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) { |
|
{ |
|
529 |
// intra_dc_vlc_threshold |
// intra_dc_vlc_threshold |
530 |
*intra_dc_threshold = intra_dc_threshold_table[ BitstreamGetBits(bs,3) ]; |
*intra_dc_threshold = |
531 |
|
intra_dc_threshold_table[BitstreamGetBits(bs, 3)]; |
532 |
|
|
533 |
/* if (interlaced) |
if (dec->interlacing) { |
534 |
{ |
if ((dec->top_field_first = BitstreamGetBit(bs))) { |
535 |
BitstreamSkip(bs, 1); // top_field_first |
//DPRINTF("vop: top_field_first"); |
536 |
BitstreamSkip(bs, 1); // alternative_vertical_scan_flag |
} |
537 |
*/ |
if ((dec->alternate_vertical_scan = BitstreamGetBit(bs))) { |
538 |
|
//DPRINTF("vop: alternate_vertical_scan"); |
539 |
|
} |
540 |
|
} |
541 |
} |
} |
542 |
|
|
543 |
*quant = BitstreamGetBits(bs, dec->quant_bits); // vop_quant |
if ((*quant = BitstreamGetBits(bs, dec->quant_bits)) < 1) // vop_quant |
544 |
//DEBUG1("quant", *quant); |
*quant = 1; |
545 |
|
|
546 |
if (coding_type != I_VOP) |
//DPRINTF("quant %i", *quant); |
547 |
{ |
|
548 |
*fcode = BitstreamGetBits(bs, 3); // fcode_forward |
if (coding_type != I_VOP) { |
549 |
|
*fcode_forward = BitstreamGetBits(bs, 3); // fcode_forward |
550 |
} |
} |
551 |
|
|
552 |
if (coding_type == B_VOP) |
if (coding_type == B_VOP) { |
553 |
{ |
*fcode_backward = BitstreamGetBits(bs, 3); // fcode_backward |
|
// *fcode_backward = BitstreamGetBits(bs, 3); // fcode_backward |
|
554 |
} |
} |
555 |
return coding_type; |
if (!dec->scalability) { |
556 |
|
if ((dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) && |
557 |
|
(coding_type != I_VOP)) { |
558 |
|
BitstreamSkip(bs, 1); // vop_shape_coding_type |
559 |
} |
} |
|
else if (start_code == USERDATA_START_CODE) |
|
|
{ |
|
|
// DEBUG("user_data"); |
|
|
BitstreamSkip(bs, 32); // user_data_start_code |
|
560 |
} |
} |
561 |
else // start_code == ? |
return coding_type; |
562 |
{ |
} else if (start_code == USERDATA_START_CODE) { |
563 |
if (BitstreamShowBits(bs, 24) == 0x000001) |
//DPRINTF("user_data"); |
564 |
|
BitstreamSkip(bs, 32); // user_data_start_code |
565 |
|
} else // start_code == ? |
566 |
{ |
{ |
567 |
DEBUG1("*** WARNING: unknown start_code", BitstreamShowBits(bs, 32)); |
if (BitstreamShowBits(bs, 24) == 0x000001) { |
568 |
|
//DPRINTF("*** WARNING: unknown start_code %x", |
569 |
|
// BitstreamShowBits(bs, 32)); |
570 |
} |
} |
571 |
BitstreamSkip(bs, 8); |
BitstreamSkip(bs, 8); |
572 |
} |
} |
573 |
} |
} |
574 |
while ((BitstreamPos(bs) >> 3) < bs->length); |
while ((BitstreamPos(bs) >> 3) < bs->length); |
575 |
|
|
576 |
DEBUG("*** WARNING: no vop_start_code found"); |
//DPRINTF("*** WARNING: no vop_start_code found"); |
577 |
return -1; /* ignore it */ |
return -1; /* ignore it */ |
578 |
} |
} |
579 |
|
|
580 |
|
|
581 |
/* write custom quant matrix */ |
/* write custom quant matrix */ |
582 |
|
|
583 |
static void bs_put_matrix(Bitstream * bs, const int16_t * matrix) |
static void |
584 |
|
bs_put_matrix(Bitstream * bs, |
585 |
|
const int16_t * matrix) |
586 |
{ |
{ |
587 |
int i, j; |
int i, j; |
588 |
const int last = matrix[scan_tables[0][63]]; |
const int last = matrix[scan_tables[0][63]]; |
589 |
|
|
590 |
for (j = 63; j >= 0 && matrix[scan_tables[0][j - 1]] == last; j--) ; |
for (j = 63; j > 0 && matrix[scan_tables[0][j - 1]] == last; j--); |
591 |
|
|
592 |
for (i = 0; i <= j; i++) |
for (i = 0; i <= j; i++) { |
|
{ |
|
593 |
BitstreamPutBits(bs, matrix[scan_tables[0][i]], 8); |
BitstreamPutBits(bs, matrix[scan_tables[0][i]], 8); |
594 |
} |
} |
595 |
|
|
596 |
if (j < 63) |
if (j < 63) { |
|
{ |
|
597 |
BitstreamPutBits(bs, 0, 8); |
BitstreamPutBits(bs, 0, 8); |
598 |
} |
} |
599 |
} |
} |
602 |
/* |
/* |
603 |
write vol header |
write vol header |
604 |
*/ |
*/ |
605 |
void BitstreamWriteVolHeader(Bitstream * const bs, |
void |
606 |
const int width, |
BitstreamWriteVolHeader(Bitstream * const bs, |
607 |
const int height, |
const MBParam * pParam, |
608 |
const int quant_type) |
const FRAMEINFO * frame) |
609 |
{ |
{ |
610 |
// video object_start_code & vo_id |
// video object_start_code & vo_id |
611 |
BitstreamPad(bs); |
BitstreamPad(bs); |
620 |
BitstreamPutBits(bs, 0, 8); // video_object_type_indication |
BitstreamPutBits(bs, 0, 8); // video_object_type_indication |
621 |
BitstreamPutBit(bs, 0); // is_object_layer_identified (0=not given) |
BitstreamPutBit(bs, 0); // is_object_layer_identified (0=not given) |
622 |
BitstreamPutBits(bs, 1, 4); // aspect_ratio_info (1=1:1) |
BitstreamPutBits(bs, 1, 4); // aspect_ratio_info (1=1:1) |
623 |
BitstreamPutBit(bs, 0); // vol_control_parameters (0=not given) |
|
624 |
|
#ifdef BFRAMES |
625 |
|
if (pParam->max_bframes > 0) { |
626 |
|
//DPRINTF("low_delay=1"); |
627 |
|
BitstreamPutBit(bs, 1); // vol_control_parameters |
628 |
|
BitstreamPutBits(bs, 1, 2); // chroma_format 1="4:2:0" |
629 |
|
BitstreamPutBit(bs, 0); // low_delay |
630 |
|
BitstreamPutBit(bs, 0); // vbv_parameters (0=not given) |
631 |
|
} else |
632 |
|
#endif |
633 |
|
{ |
634 |
|
BitstreamPutBits(bs, 0, 1); // vol_control_parameters (0=not given) |
635 |
|
} |
636 |
|
|
637 |
|
|
638 |
BitstreamPutBits(bs, 0, 2); // video_object_layer_shape (0=rectangular) |
BitstreamPutBits(bs, 0, 2); // video_object_layer_shape (0=rectangular) |
639 |
|
|
640 |
WRITE_MARKER(); |
WRITE_MARKER(); |
644 |
25fps res=25 inc=1 |
25fps res=25 inc=1 |
645 |
29.97fps res=30000 inc=1001 |
29.97fps res=30000 inc=1001 |
646 |
*/ |
*/ |
647 |
|
#ifdef BFRAMES |
648 |
|
BitstreamPutBits(bs, pParam->fbase, 16); |
649 |
|
#else |
650 |
BitstreamPutBits(bs, 2, 16); |
BitstreamPutBits(bs, 2, 16); |
651 |
|
#endif |
652 |
|
|
653 |
WRITE_MARKER(); |
WRITE_MARKER(); |
654 |
|
|
655 |
// fixed_vop_rate |
#ifdef BFRAMES |
656 |
BitstreamPutBit(bs, 0); |
BitstreamPutBit(bs, 1); // fixed_vop_rate = 1 |
657 |
|
BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase)); // fixed_vop_time_increment |
658 |
// fixed_time_increment: value=nth_of_sec, nbits = log2(resolution) |
#else |
659 |
// BitstreamPutBits(bs, 0, 15); |
BitstreamPutBit(bs, 0); // fixed_vop_rate = 0 |
660 |
|
#endif |
661 |
|
|
662 |
WRITE_MARKER(); |
WRITE_MARKER(); |
663 |
BitstreamPutBits(bs, width, 13); // width |
BitstreamPutBits(bs, pParam->width, 13); // width |
664 |
WRITE_MARKER(); |
WRITE_MARKER(); |
665 |
BitstreamPutBits(bs, height, 13); // height |
BitstreamPutBits(bs, pParam->height, 13); // height |
666 |
WRITE_MARKER(); |
WRITE_MARKER(); |
667 |
|
|
668 |
BitstreamPutBit(bs, 0); // interlace |
BitstreamPutBit(bs, frame->global_flags & XVID_INTERLACING); // interlace |
669 |
BitstreamPutBit(bs, 1); // obmc_disable (overlapped block motion compensation) |
BitstreamPutBit(bs, 1); // obmc_disable (overlapped block motion compensation) |
670 |
BitstreamPutBit(bs, 0); // sprite_enable |
BitstreamPutBit(bs, 0); // sprite_enable |
671 |
BitstreamPutBit(bs, 0); // not_in_bit |
BitstreamPutBit(bs, 0); // not_in_bit |
672 |
|
|
673 |
// quant_type 0=h.263 1=mpeg4(quantizer tables) |
// quant_type 0=h.263 1=mpeg4(quantizer tables) |
674 |
BitstreamPutBit(bs, quant_type); |
BitstreamPutBit(bs, pParam->m_quant_type); |
|
/* |
|
|
if (quant_type) |
|
|
{ |
|
|
BitstreamPutBit(bs, qmatrix->custom_intra); // load_intra_quant_mat |
|
|
if (qmatrix->custom_intra) |
|
|
{ |
|
|
bs_put_matrix(bs, qmatrix->intra); |
|
|
} |
|
675 |
|
|
676 |
BitstreamPutBit(bs, qmatrix->custom_inter); // load_inter_quant_mat |
if (pParam->m_quant_type) { |
677 |
if (qmatrix->custom_inter) |
BitstreamPutBit(bs, get_intra_matrix_status()); // load_intra_quant_mat |
678 |
{ |
if (get_intra_matrix_status()) { |
679 |
bs_put_matrix(bs, qmatrix->inter); |
bs_put_matrix(bs, get_intra_matrix()); |
680 |
} |
} |
681 |
|
|
682 |
|
BitstreamPutBit(bs, get_inter_matrix_status()); // load_inter_quant_mat |
683 |
|
if (get_inter_matrix_status()) { |
684 |
|
bs_put_matrix(bs, get_inter_matrix()); |
685 |
} |
} |
686 |
*/ |
|
|
if (quant_type) |
|
|
{ |
|
|
BitstreamPutBit(bs, 0); // load_intra_quant_mat |
|
|
BitstreamPutBit(bs, 0); // load_inter_quant_mat |
|
687 |
} |
} |
688 |
|
|
689 |
BitstreamPutBit(bs, 1); // complexity_estimation_disable |
BitstreamPutBit(bs, 1); // complexity_estimation_disable |
701 |
time_inc = nth of a second since last resync |
time_inc = nth of a second since last resync |
702 |
(decoder uses these values to determine precise time since last resync) |
(decoder uses these values to determine precise time since last resync) |
703 |
*/ |
*/ |
704 |
void BitstreamWriteVopHeader(Bitstream * const bs, |
void |
705 |
VOP_TYPE prediction_type, |
BitstreamWriteVopHeader(Bitstream * const bs, |
706 |
const int rounding_type, |
const MBParam * pParam, |
707 |
const uint32_t quant, |
const FRAMEINFO * frame, |
708 |
const uint32_t fcode) |
int vop_coded) |
709 |
{ |
{ |
710 |
|
#ifdef BFRAMES |
711 |
|
uint32_t i; |
712 |
|
#endif |
713 |
BitstreamPad(bs); |
BitstreamPad(bs); |
714 |
BitstreamPutBits(bs, VOP_START_CODE, 32); |
BitstreamPutBits(bs, VOP_START_CODE, 32); |
715 |
|
|
716 |
BitstreamPutBits(bs, prediction_type, 2); |
BitstreamPutBits(bs, frame->coding_type, 2); |
717 |
|
|
718 |
// time_base = 0 write n x PutBit(1), PutBit(0) |
// time_base = 0 write n x PutBit(1), PutBit(0) |
719 |
|
#ifdef BFRAMES |
720 |
|
for (i = 0; i < frame->seconds; i++) { |
721 |
|
BitstreamPutBit(bs, 1); |
722 |
|
} |
723 |
|
BitstreamPutBit(bs, 0); |
724 |
|
#else |
725 |
BitstreamPutBits(bs, 0, 1); |
BitstreamPutBits(bs, 0, 1); |
726 |
|
#endif |
727 |
|
|
728 |
WRITE_MARKER(); |
WRITE_MARKER(); |
729 |
|
|
730 |
// time_increment: value=nth_of_sec, nbits = log2(resolution) |
// time_increment: value=nth_of_sec, nbits = log2(resolution) |
731 |
|
#ifdef BFRAMES |
732 |
|
BitstreamPutBits(bs, frame->ticks, log2bin(pParam->fbase)); |
733 |
|
DPRINTF("[%i:%i] %c\n", frame->seconds, frame->ticks, |
734 |
|
frame->coding_type == I_VOP ? 'I' : frame->coding_type == |
735 |
|
P_VOP ? 'P' : 'B'); |
736 |
|
#else |
737 |
BitstreamPutBits(bs, 1, 1); |
BitstreamPutBits(bs, 1, 1); |
738 |
|
#endif |
739 |
|
|
740 |
WRITE_MARKER(); |
WRITE_MARKER(); |
741 |
|
|
742 |
|
if (!vop_coded) { |
743 |
|
BitstreamPutBits(bs, 0, 1); |
744 |
|
return; |
745 |
|
} |
746 |
|
|
747 |
BitstreamPutBits(bs, 1, 1); // vop_coded |
BitstreamPutBits(bs, 1, 1); // vop_coded |
748 |
|
|
749 |
if (prediction_type != I_VOP) |
if (frame->coding_type == P_VOP) |
750 |
BitstreamPutBits(bs, rounding_type, 1); |
BitstreamPutBits(bs, frame->rounding_type, 1); |
751 |
|
|
752 |
BitstreamPutBits(bs, 0, 3); // intra_dc_vlc_threshold |
BitstreamPutBits(bs, 0, 3); // intra_dc_vlc_threshold |
753 |
|
|
754 |
BitstreamPutBits(bs, quant, 5); // quantizer |
if (frame->global_flags & XVID_INTERLACING) { |
755 |
|
BitstreamPutBit(bs, 1); // top field first |
756 |
|
BitstreamPutBit(bs, 0); // alternate vertical scan |
757 |
|
} |
758 |
|
|
759 |
|
BitstreamPutBits(bs, frame->quant, 5); // quantizer |
760 |
|
|
761 |
|
if (frame->coding_type != I_VOP) |
762 |
|
BitstreamPutBits(bs, frame->fcode, 3); // forward_fixed_code |
763 |
|
|
764 |
|
if (frame->coding_type == B_VOP) |
765 |
|
BitstreamPutBits(bs, frame->bcode, 3); // backward_fixed_code |
766 |
|
|
767 |
|
} |
768 |
|
|
769 |
|
|
770 |
|
void |
771 |
|
BitstreamWriteUserData(Bitstream * const bs, |
772 |
|
uint8_t * data, |
773 |
|
const int length) |
774 |
|
{ |
775 |
|
int i; |
776 |
|
|
777 |
|
BitstreamPad(bs); |
778 |
|
BitstreamPutBits(bs, USERDATA_START_CODE, 32); |
779 |
|
|
780 |
|
for (i = 0; i < length; i++) { |
781 |
|
BitstreamPutBits(bs, data[i], 8); |
782 |
|
} |
783 |
|
|
|
if (prediction_type != I_VOP) |
|
|
BitstreamPutBits(bs, fcode, 3); // fixed_code = [1,4] |
|
784 |
} |
} |