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

Diff of /xvidcore/src/bitstream/bitstream.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15, Fri Jun 14 12:26:06 2002 UTC revision 1.18, Sat Jun 22 07:23:10 2002 UTC
# Line 41  Line 41 
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                                            *    *  08.05.2002  add low_delay support for B_VOP decode                                            *
49    *              MinChen <chenm001@163.com>                                    *    *              MinChen <chenm001@163.com>                                    *
50    *  06.05.2002 low_delay                                                      *    *  06.05.2002 low_delay                                                      *
# Line 53  Line 57 
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    
# Line 108  Line 112 
112                  matrix[scan_tables[0][i++]] = value;                  matrix[scan_tables[0][i++]] = value;
113          }          }
114          while (value != 0 && i < 64);          while (value != 0 && i < 64);
115            i--;    // fix little bug at coeff not full
116    
117          while (i < 64) {          while (i < 64) {
118                  matrix[scan_tables[0][i++]] = last;                  matrix[scan_tables[0][i++]] = last;
# Line 140  Line 145 
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                          // DEBUG("visual_object_sequence");                          // DPRINTF("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) {                  } else if (start_code == VISOBJ_START_CODE) {
154                          // DEBUG("visual_object");                          //DPRINTF("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                          {                          {
# Line 158  Line 163 
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);
# Line 167  Line 172 
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
# Line 181  Line 186 
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) {                  } else if ((start_code & ~0xf) == VIDOBJLAY_START_CODE) {
189                          // DEBUG("video_object_layer");                          //DPRINTF("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
# Line 189  Line 194 
194                          // video_object_type_indication                          // video_object_type_indication
195                          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                          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
196                          {                          {
197                                  DEBUG1("video_object_type_indication not supported",                                  //DPRINTF("video_object_type_indication %i not supported ",
198                                             BitstreamShowBits(bs, 8));                                  //  BitstreamShowBits(bs, 8));
199                                  return -1;                                  return -1;
200                          }                          }
201                          BitstreamSkip(bs, 8);                          BitstreamSkip(bs, 8);
# Line 198  Line 203 
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                                  dec->low_delay = BitstreamGetBit(bs);   // 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
# Line 237  Line 242 
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
# Line 248  Line 253 
253  // *************************** for decode B-frame time ***********************  // *************************** for decode B-frame time ***********************
254                          time_increment_resolution = BitstreamGetBits(bs, 16);   // vop_time_increment_resolution                          time_increment_resolution = BitstreamGetBits(bs, 16);   // vop_time_increment_resolution
255                          time_increment_resolution--;                          time_increment_resolution--;
256                          //DEBUG1("time_increment_resolution=",time_increment_resolution);                          //DPRINTF("time_increment_resolution = %i",time_increment_resolution);
257                          if (time_increment_resolution > 0) {                          if (time_increment_resolution > 0) {
258                                  dec->time_inc_bits = log2bin(time_increment_resolution);                                  dec->time_inc_bits = log2bin(time_increment_resolution);
259                          } else {                          } else {
# Line 272  Line 277 
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                                                  DEBUG("FATAL: video dimension discrepancy ***");                                                  //DPRINTF("FATAL: video dimension discrepancy ***");
288                                                  DEBUG2("bitstream width/height", width, height);                                                  //DPRINTF("bitstream width/height  %i x %i", width, height);
289                                                  DEBUG2("param width/height", dec->width, dec->height);                                                  //DPRINTF("param width/height  %i x %i", dec->width, dec->height);
290                                                  return -1;                                                  return -1;
291                                          }                                          }
292    
293                                  }                                  }
294    
295                                  if ((dec->interlacing = BitstreamGetBit(bs))) {                                  if ((dec->interlacing = BitstreamGetBit(bs))) {
296                                          DEBUG("vol: interlacing");                                          //DPRINTF("vol: interlacing");
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    
# Line 311  Line 316 
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 {
# Line 325  Line 330 
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
# Line 348  Line 353 
353    
354                                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) {                                          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    
# Line 358  Line 363 
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                                                  DEBUG("IGNORED/TODO: quarter_sample");                                                  //DPRINTF("IGNORED/TODO: quarter_sample");
367                                          }                                          }
368                                  } else {                                  } else {
369                                          dec->quarterpel = 0;                                          dec->quarterpel = 0;
# Line 366  Line 371 
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                                          }                                          }
# Line 401  Line 406 
406                                  if ((dec->scalability = 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
# Line 410  Line 415 
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                                  }                                  }
# Line 419  Line 424 
424                          }                          }
425    
426                  } else if (start_code == GRPOFVOP_START_CODE) {                  } else if (start_code == GRPOFVOP_START_CODE) {
427                          // DEBUG("group_of_vop");                          //DPRINTF("group_of_vop");
428                          BitstreamSkip(bs, 32);                          BitstreamSkip(bs, 32);
429                          {                          {
430                                  int hours, minutes, seconds;                                  int hours, minutes, seconds;
# Line 428  Line 433 
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) {                  } else if (start_code == VOP_START_CODE) {
441                          // DEBUG("vop_start_code");                          //DPRINTF("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  // *************************** for decode B-frame time ***********************  // *************************** for decode B-frame time ***********************
448                          while (BitstreamGetBit(bs) != 0)        // time_base                          while (BitstreamGetBit(bs) != 0)        // time_base
# Line 445  Line 450 
450    
451                          READ_MARKER();                          READ_MARKER();
452    
453                          //DEBUG1("time_inc_bits", dec->time_inc_bits);                          //DPRINTF("time_inc_bits %i", dec->time_inc_bits);
454                          //DEBUG1("vop_time_incr", BitstreamShowBits(bs, dec->time_inc_bits));                          //DPRINTF("vop_time_incr %i", BitstreamShowBits(bs, dec->time_inc_bits));
455                          if (dec->time_inc_bits) {                          if (dec->time_inc_bits) {
456                                  //BitstreamSkip(bs, dec->time_inc_bits);    // vop_time_increment                                  //BitstreamSkip(bs, dec->time_inc_bits);    // vop_time_increment
457                                  time_increment = (BitstreamGetBits(bs, dec->time_inc_bits));    // vop_time_increment                                  time_increment = (BitstreamGetBits(bs, dec->time_inc_bits));    // vop_time_increment
# Line 465  Line 470 
470                                           time_incr) * time_increment_resolution + time_increment;                                           time_incr) * time_increment_resolution + time_increment;
471                                  dec->time_bp = (uint32_t) (dec->last_non_b_time - dec->time);                                  dec->time_bp = (uint32_t) (dec->last_non_b_time - dec->time);
472                          }                          }
473                          //DEBUG1("time_increment=",time_increment);                          //DPRINTF("time_increment %i",time_increment);
474    
475                          READ_MARKER();                          READ_MARKER();
476    
# Line 483  Line 488 
488                          if ((dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) &&                          if ((dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) &&
489                                  (coding_type == P_VOP)) {                                  (coding_type == P_VOP)) {
490                                  *rounding = BitstreamGetBit(bs);        // rounding_type                                  *rounding = BitstreamGetBit(bs);        // rounding_type
491                                  //DEBUG1("rounding", *rounding);                                  //DPRINTF("rounding %i", *rounding);
492                          }                          }
493    
494                          /* if (reduced_resolution_enable)                          /* if (reduced_resolution_enable)
# Line 504  Line 509 
509                                  vert_mc_ref = BitstreamGetBits(bs, 13);                                  vert_mc_ref = BitstreamGetBits(bs, 13);
510                                  READ_MARKER();                                  READ_MARKER();
511    
512                                  // DEBUG2("vop_width/height", width, height);                                  //DPRINTF("vop_width/height %i x %i", width, height);
513                                  // DEBUG2("ref             ", horiz_mc_ref, vert_mc_ref);                                  //DPRINTF("ref              %i x %i", horiz_mc_ref, vert_mc_ref);
514    
515                                  BitstreamSkip(bs, 1);   // change_conv_ratio_disable                                  BitstreamSkip(bs, 1);   // change_conv_ratio_disable
516                                  if (BitstreamGetBit(bs))        // vop_constant_alpha                                  if (BitstreamGetBit(bs))        // vop_constant_alpha
# Line 522  Line 527 
527    
528                                  if (dec->interlacing) {                                  if (dec->interlacing) {
529                                          if ((dec->top_field_first = BitstreamGetBit(bs))) {                                          if ((dec->top_field_first = BitstreamGetBit(bs))) {
530                                                  DEBUG("vop: top_field_first");                                                  //DPRINTF("vop: top_field_first");
531                                          }                                          }
532                                          if ((dec->alternate_vertical_scan = BitstreamGetBit(bs))) {                                          if ((dec->alternate_vertical_scan = BitstreamGetBit(bs))) {
533                                                  DEBUG("vop: alternate_vertical_scan");                                                  //DPRINTF("vop: alternate_vertical_scan");
534                                          }                                          }
535                                  }                                  }
536                          }                          }
# Line 533  Line 538 
538                          if ((*quant = BitstreamGetBits(bs, dec->quant_bits)) < 1)       // vop_quant                          if ((*quant = BitstreamGetBits(bs, dec->quant_bits)) < 1)       // vop_quant
539                                  *quant = 1;                                  *quant = 1;
540    
541                          //DEBUG1("quant", *quant);                          //DPRINTF("quant %i", *quant);
542    
543                          if (coding_type != I_VOP) {                          if (coding_type != I_VOP) {
544                                  *fcode_forward = BitstreamGetBits(bs, 3);       // fcode_forward                                  *fcode_forward = BitstreamGetBits(bs, 3);       // fcode_forward
# Line 550  Line 555 
555                          }                          }
556                          return coding_type;                          return coding_type;
557                  } else if (start_code == USERDATA_START_CODE) {                  } else if (start_code == USERDATA_START_CODE) {
558                          // DEBUG("user_data");                          //DPRINTF("user_data");
559                          BitstreamSkip(bs, 32);  // user_data_start_code                          BitstreamSkip(bs, 32);  // user_data_start_code
560                  } else                                  // start_code == ?                  } else                                  // start_code == ?
561                  {                  {
562                          if (BitstreamShowBits(bs, 24) == 0x000001) {                          if (BitstreamShowBits(bs, 24) == 0x000001) {
563                                  DEBUG1("*** WARNING: unknown start_code",                                  //DPRINTF("*** WARNING: unknown start_code %x",
564                                             BitstreamShowBits(bs, 32));                                  //         BitstreamShowBits(bs, 32));
565                          }                          }
566                          BitstreamSkip(bs, 8);                          BitstreamSkip(bs, 8);
567                  }                  }
568          }          }
569          while ((BitstreamPos(bs) >> 3) < bs->length);          while ((BitstreamPos(bs) >> 3) < bs->length);
570    
571          DEBUG("*** WARNING: no vop_start_code found");          //DPRINTF("*** WARNING: no vop_start_code found");
572          return -1;                                      /* ignore it */          return -1;                                      /* ignore it */
573  }  }
574    
# Line 577  Line 582 
582          int i, j;          int i, j;
583          const int last = matrix[scan_tables[0][63]];          const int last = matrix[scan_tables[0][63]];
584    
585          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--);
586    
587          for (i = 0; i <= j; i++) {          for (i = 0; i <= j; i++) {
588                  BitstreamPutBits(bs, matrix[scan_tables[0][i]], 8);                  BitstreamPutBits(bs, matrix[scan_tables[0][i]], 8);
# Line 613  Line 618 
618    
619  #ifdef BFRAMES  #ifdef BFRAMES
620          if (pParam->max_bframes > 0) {          if (pParam->max_bframes > 0) {
621                  dprintf("low_delay=1");                  //DPRINTF("low_delay=1");
622                  BitstreamPutBit(bs, 1); // vol_control_parameters                  BitstreamPutBit(bs, 1); // vol_control_parameters
623                  BitstreamPutBits(bs, 1, 2);     // chroma_format 1="4:2:0"                  BitstreamPutBits(bs, 1, 2);     // chroma_format 1="4:2:0"
624                  BitstreamPutBit(bs, 0); // low_delay                  BitstreamPutBit(bs, 0); // low_delay
# Line 693  Line 698 
698  void  void
699  BitstreamWriteVopHeader(Bitstream * const bs,  BitstreamWriteVopHeader(Bitstream * const bs,
700                                                  const MBParam * pParam,                                                  const MBParam * pParam,
701                                                  const FRAMEINFO * frame)                                                  const FRAMEINFO * frame,
702                                                    int vop_coded)
703  {  {
704  #ifdef BFRAMES  #ifdef BFRAMES
705          uint32_t i;          uint32_t i;
# Line 718  Line 724 
724          // time_increment: value=nth_of_sec, nbits = log2(resolution)          // time_increment: value=nth_of_sec, nbits = log2(resolution)
725  #ifdef BFRAMES  #ifdef BFRAMES
726          BitstreamPutBits(bs, frame->ticks, log2bin(pParam->fbase));          BitstreamPutBits(bs, frame->ticks, log2bin(pParam->fbase));
727          dprintf("[%i:%i] %c\n", frame->seconds, frame->ticks,          DPRINTF("[%i:%i] %c\n", frame->seconds, frame->ticks,
728                          frame->coding_type == I_VOP ? 'I' : frame->coding_type ==                          frame->coding_type == I_VOP ? 'I' : frame->coding_type ==
729                          P_VOP ? 'P' : 'B');                          P_VOP ? 'P' : 'B');
730  #else  #else
# Line 727  Line 733 
733    
734          WRITE_MARKER();          WRITE_MARKER();
735    
736            if (!vop_coded) {
737                    BitstreamPutBits(bs, 0, 1);
738                    return;
739            }
740    
741          BitstreamPutBits(bs, 1, 1);     // vop_coded          BitstreamPutBits(bs, 1, 1);     // vop_coded
742    
743          if (frame->coding_type == P_VOP)          if (frame->coding_type == P_VOP)
# Line 748  Line 759 
759                  BitstreamPutBits(bs, frame->bcode, 3);  // backward_fixed_code                  BitstreamPutBits(bs, frame->bcode, 3);  // backward_fixed_code
760    
761  }  }
762    
763    
764    void
765    BitstreamWriteUserData(Bitstream * const bs,
766                                                    uint8_t * data,
767                                                    const int length)
768    {
769            int i;
770    
771            BitstreamPad(bs);
772            BitstreamPutBits(bs, USERDATA_START_CODE, 32);
773    
774            for (i = 0; i < length; i++) {
775                    BitstreamPutBits(bs, data[i], 8);
776            }
777    
778    }

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.18

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