[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.17, Thu Jun 20 14:05:58 2002 UTC revision 1.21, Fri Jun 28 15:14:40 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                                   *    *  20.05.2002 added BitstreamWriteUserData                                   *
46    *  19.06.2002  Fix a little bug in use custom quant matrix                   *    *  19.06.2002  Fix a little bug in use custom quant matrix                   *
47    *              MinChen <chenm001@163.com>                                    *    *              MinChen <chenm001@163.com>                                    *
# Line 118  Line 119 
119          }          }
120  }  }
121    
122    
123    
124    // for PVOP addbits == fcode - 1
125    // for BVOP addbits == max(fcode,bcode) - 1
126    // returns mbpos
127    int
128    read_video_packet_header(Bitstream *bs, int addbits)
129    {
130            int nbits;
131            int mbnum;
132            int quant;
133            int hec;
134    
135            nbits = NUMBITS_VP_RESYNC_MARKER;
136    
137            BitstreamSkip(bs, BitstreamNumBitsToByteAlign(bs));
138            BitstreamSkip(bs, nbits);
139    
140            // if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) {
141                    // hec
142                    // vop_width
143                    // marker_bit
144                    // vop_height
145                    // marker_bit
146    
147            //}
148    
149            mbnum = BitstreamGetBits(bs, 9);
150            //printf("mbnum %i    [%i,%i]\n", mbnum, mbnum % dec->mb_width, mbnum / dec->mb_width);
151    
152            // if (dec->shape != VIDOBJLAY_SHAPE_BINARYONLY)
153            quant = BitstreamGetBits(bs, 5);
154    
155            // if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR)
156            hec = BitstreamGetBit(bs);
157            // if (hec)
158            //   .. decoder hec-header ...
159    
160            return mbnum;
161    }
162    
163    
164    
165  /*  /*
166  decode headers  decode headers
167  returns coding_type, or -1 if error  returns coding_type, or -1 if error
# Line 144  Line 188 
188                  start_code = BitstreamShowBits(bs, 32);                  start_code = BitstreamShowBits(bs, 32);
189    
190                  if (start_code == VISOBJSEQ_START_CODE) {                  if (start_code == VISOBJSEQ_START_CODE) {
191                          // DEBUG("visual_object_sequence");                          // DPRINTF("visual_object_sequence");
192                          BitstreamSkip(bs, 32);  // visual_object_sequence_start_code                          BitstreamSkip(bs, 32);  // visual_object_sequence_start_code
193                          BitstreamSkip(bs, 8);   // profile_and_level_indication                          BitstreamSkip(bs, 8);   // profile_and_level_indication
194                  } else if (start_code == VISOBJSEQ_STOP_CODE) {                  } else if (start_code == VISOBJSEQ_STOP_CODE) {
195                          BitstreamSkip(bs, 32);  // visual_object_sequence_stop_code                          BitstreamSkip(bs, 32);  // visual_object_sequence_stop_code
196                  } else if (start_code == VISOBJ_START_CODE) {                  } else if (start_code == VISOBJ_START_CODE) {
197                          // DEBUG("visual_object");                          //DPRINTF("visual_object");
198                          BitstreamSkip(bs, 32);  // visual_object_start_code                          BitstreamSkip(bs, 32);  // visual_object_start_code
199                          if (BitstreamGetBit(bs))        // is_visual_object_identified                          if (BitstreamGetBit(bs))        // is_visual_object_identified
200                          {                          {
# Line 162  Line 206 
206    
207                          if (BitstreamShowBits(bs, 4) != VISOBJ_TYPE_VIDEO)      // visual_object_type                          if (BitstreamShowBits(bs, 4) != VISOBJ_TYPE_VIDEO)      // visual_object_type
208                          {                          {
209                                  DEBUG("visual_object_type != video");                                  //DPRINTF("visual_object_type != video");
210                                  return -1;                                  return -1;
211                          }                          }
212                          BitstreamSkip(bs, 4);                          BitstreamSkip(bs, 4);
# Line 171  Line 215 
215    
216                          if (BitstreamGetBit(bs))        // video_signal_type                          if (BitstreamGetBit(bs))        // video_signal_type
217                          {                          {
218                                  DEBUG("+ video_signal_type");                                  //DPRINTF("+ video_signal_type");
219                                  BitstreamSkip(bs, 3);   // video_format                                  BitstreamSkip(bs, 3);   // video_format
220                                  BitstreamSkip(bs, 1);   // video_range                                  BitstreamSkip(bs, 1);   // video_range
221                                  if (BitstreamGetBit(bs))        // color_description                                  if (BitstreamGetBit(bs))        // color_description
222                                  {                                  {
223                                          DEBUG("+ color_description");                                          //DPRINTF("+ color_description");
224                                          BitstreamSkip(bs, 8);   // color_primaries                                          BitstreamSkip(bs, 8);   // color_primaries
225                                          BitstreamSkip(bs, 8);   // transfer_characteristics                                          BitstreamSkip(bs, 8);   // transfer_characteristics
226                                          BitstreamSkip(bs, 8);   // matrix_coefficients                                          BitstreamSkip(bs, 8);   // matrix_coefficients
# Line 185  Line 229 
229                  } else if ((start_code & ~0x1f) == VIDOBJ_START_CODE) {                  } else if ((start_code & ~0x1f) == VIDOBJ_START_CODE) {
230                          BitstreamSkip(bs, 32);  // video_object_start_code                          BitstreamSkip(bs, 32);  // video_object_start_code
231                  } else if ((start_code & ~0xf) == VIDOBJLAY_START_CODE) {                  } else if ((start_code & ~0xf) == VIDOBJLAY_START_CODE) {
232                          // DEBUG("video_object_layer");                          //DPRINTF("video_object_layer");
233                          BitstreamSkip(bs, 32);  // video_object_layer_start_code                          BitstreamSkip(bs, 32);  // video_object_layer_start_code
234    
235                          BitstreamSkip(bs, 1);   // random_accessible_vol                          BitstreamSkip(bs, 1);   // random_accessible_vol
# Line 193  Line 237 
237                          // video_object_type_indication                          // video_object_type_indication
238                          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
239                          {                          {
240                                  DEBUG1("video_object_type_indication not supported",                                  //DPRINTF("video_object_type_indication %i not supported ",
241                                             BitstreamShowBits(bs, 8));                                  //  BitstreamShowBits(bs, 8));
242                                  return -1;                                  return -1;
243                          }                          }
244                          BitstreamSkip(bs, 8);                          BitstreamSkip(bs, 8);
# Line 202  Line 246 
246    
247                          if (BitstreamGetBit(bs))        // is_object_layer_identifier                          if (BitstreamGetBit(bs))        // is_object_layer_identifier
248                          {                          {
249                                  DEBUG("+ is_object_layer_identifier");                                  //DPRINTF("+ is_object_layer_identifier");
250                                  vol_ver_id = BitstreamGetBits(bs, 4);   // video_object_layer_verid                                  vol_ver_id = BitstreamGetBits(bs, 4);   // video_object_layer_verid
251                                  BitstreamSkip(bs, 3);   // video_object_layer_priority                                  BitstreamSkip(bs, 3);   // video_object_layer_priority
252                          } else {                          } else {
253                                  vol_ver_id = 1;                                  vol_ver_id = 1;
254                          }                          }
255                          //DEBUGI("vol_ver_id", vol_ver_id);                          //DPRINTF("vol_ver_id %i", vol_ver_id);
256    
257                          if (BitstreamGetBits(bs, 4) == VIDOBJLAY_AR_EXTPAR)     // aspect_ratio_info                          if (BitstreamGetBits(bs, 4) == VIDOBJLAY_AR_EXTPAR)     // aspect_ratio_info
258                          {                          {
259                                  DEBUG("+ aspect_ratio_info");                                  //DPRINTF("+ aspect_ratio_info");
260                                  BitstreamSkip(bs, 8);   // par_width                                  BitstreamSkip(bs, 8);   // par_width
261                                  BitstreamSkip(bs, 8);   // par_height                                  BitstreamSkip(bs, 8);   // par_height
262                          }                          }
263    
264                          if (BitstreamGetBit(bs))        // vol_control_parameters                          if (BitstreamGetBit(bs))        // vol_control_parameters
265                          {                          {
266                                  DEBUG("+ vol_control_parameters");                                  //DPRINTF("+ vol_control_parameters");
267                                  BitstreamSkip(bs, 2);   // chroma_format                                  BitstreamSkip(bs, 2);   // chroma_format
268                                  dec->low_delay = BitstreamGetBit(bs);   // low_delay                                  dec->low_delay = BitstreamGetBit(bs);   // low_delay
269                                  if (BitstreamGetBit(bs))        // vbv_parameters                                  if (BitstreamGetBit(bs))        // vbv_parameters
270                                  {                                  {
271                                          DEBUG("+ vbv_parameters");                                          //DPRINTF("+ vbv_parameters");
272                                          BitstreamSkip(bs, 15);  // first_half_bitrate                                          BitstreamSkip(bs, 15);  // first_half_bitrate
273                                          READ_MARKER();                                          READ_MARKER();
274                                          BitstreamSkip(bs, 15);  // latter_half_bitrate                                          BitstreamSkip(bs, 15);  // latter_half_bitrate
# Line 241  Line 285 
285                          }                          }
286    
287                          dec->shape = BitstreamGetBits(bs, 2);   // video_object_layer_shape                          dec->shape = BitstreamGetBits(bs, 2);   // video_object_layer_shape
288                          // DEBUG1("shape", dec->shape);                          //DPRINTF("shape %i", dec->shape);
289    
290                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE && vol_ver_id != 1) {                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE && vol_ver_id != 1) {
291                                  BitstreamSkip(bs, 4);   // video_object_layer_shape_extension                                  BitstreamSkip(bs, 4);   // video_object_layer_shape_extension
# Line 252  Line 296 
296  // *************************** for decode B-frame time ***********************  // *************************** for decode B-frame time ***********************
297                          time_increment_resolution = BitstreamGetBits(bs, 16);   // vop_time_increment_resolution                          time_increment_resolution = BitstreamGetBits(bs, 16);   // vop_time_increment_resolution
298                          time_increment_resolution--;                          time_increment_resolution--;
299                          //DEBUG1("time_increment_resolution=",time_increment_resolution);                          //DPRINTF("time_increment_resolution = %i",time_increment_resolution);
300                          if (time_increment_resolution > 0) {                          if (time_increment_resolution > 0) {
301                                  dec->time_inc_bits = log2bin(time_increment_resolution);                                  dec->time_inc_bits = log2bin(time_increment_resolution);
302                          } else {                          } else {
# Line 276  Line 320 
320    
321                                          READ_MARKER();                                          READ_MARKER();
322                                          width = BitstreamGetBits(bs, 13);       // video_object_layer_width                                          width = BitstreamGetBits(bs, 13);       // video_object_layer_width
323                                          //DEBUGI("width", width);                                          //DPRINTF("width %i", width);
324                                          READ_MARKER();                                          READ_MARKER();
325                                          height = BitstreamGetBits(bs, 13);      // video_object_layer_height                                          height = BitstreamGetBits(bs, 13);      // video_object_layer_height
326                                          //DEBUGI("height", height);                                          //DPRINTF("height %i", height);
327                                          READ_MARKER();                                          READ_MARKER();
328    
329                                          if (width != dec->width || height != dec->height) {                                          if (width != dec->width || height != dec->height) {
330                                                  DEBUG("FATAL: video dimension discrepancy ***");                                                  //DPRINTF("FATAL: video dimension discrepancy ***");
331                                                  DEBUG2("bitstream width/height", width, height);                                                  //DPRINTF("bitstream width/height  %i x %i", width, height);
332                                                  DEBUG2("param width/height", dec->width, dec->height);                                                  //DPRINTF("param width/height  %i x %i", dec->width, dec->height);
333                                                  return -1;                                                  return -1;
334                                          }                                          }
335    
336                                  }                                  }
337    
338                                  if ((dec->interlacing = BitstreamGetBit(bs))) {                                  if ((dec->interlacing = BitstreamGetBit(bs))) {
339                                          DEBUG("vol: interlacing");                                          //DPRINTF("vol: interlacing");
340                                  }                                  }
341    
342                                  if (!BitstreamGetBit(bs))       // obmc_disable                                  if (!BitstreamGetBit(bs))       // obmc_disable
343                                  {                                  {
344                                          DEBUG("IGNORED/TODO: !obmc_disable");                                          //DPRINTF("IGNORED/TODO: !obmc_disable");
345                                          // TODO                                          // TODO
346                                          // fucking divx4.02 has this enabled                                          // fucking divx4.02 has this enabled
347                                  }                                  }
348    
349                                  if (BitstreamGetBits(bs, (vol_ver_id == 1 ? 1 : 2)))    // sprite_enable                                  if (BitstreamGetBits(bs, (vol_ver_id == 1 ? 1 : 2)))    // sprite_enable
350                                  {                                  {
351                                          DEBUG("sprite_enable; not supported");                                          //DPRINTF("sprite_enable; not supported");
352                                          return -1;                                          return -1;
353                                  }                                  }
354    
# Line 315  Line 359 
359    
360                                  if (BitstreamGetBit(bs))        // not_8_bit                                  if (BitstreamGetBit(bs))        // not_8_bit
361                                  {                                  {
362                                          DEBUG("+ not_8_bit [IGNORED/TODO]");                                          //DPRINTF("+ not_8_bit [IGNORED/TODO]");
363                                          dec->quant_bits = BitstreamGetBits(bs, 4);      // quant_precision                                          dec->quant_bits = BitstreamGetBits(bs, 4);      // quant_precision
364                                          BitstreamSkip(bs, 4);   // bits_per_pixel                                          BitstreamSkip(bs, 4);   // bits_per_pixel
365                                  } else {                                  } else {
# Line 329  Line 373 
373                                  }                                  }
374    
375                                  dec->quant_type = BitstreamGetBit(bs);  // quant_type                                  dec->quant_type = BitstreamGetBit(bs);  // quant_type
376                                  // DEBUG1("**** quant_type", dec->quant_type);                                  //DPRINTF("**** quant_type %i", dec->quant_type);
377    
378                                  if (dec->quant_type) {                                  if (dec->quant_type) {
379                                          if (BitstreamGetBit(bs))        // load_intra_quant_mat                                          if (BitstreamGetBit(bs))        // load_intra_quant_mat
# Line 352  Line 396 
396    
397                                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) {                                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) {
398                                                  // TODO                                                  // TODO
399                                                  DEBUG("TODO: grayscale matrix stuff");                                                  //DPRINTF("TODO: grayscale matrix stuff");
400                                                  return -1;                                                  return -1;
401                                          }                                          }
402    
# Line 362  Line 406 
406                                  if (vol_ver_id != 1) {                                  if (vol_ver_id != 1) {
407                                          dec->quarterpel = BitstreamGetBit(bs);  // quarter_sampe                                          dec->quarterpel = BitstreamGetBit(bs);  // quarter_sampe
408                                          if (dec->quarterpel) {                                          if (dec->quarterpel) {
409                                                  DEBUG("IGNORED/TODO: quarter_sample");                                                  //DPRINTF("IGNORED/TODO: quarter_sample");
410                                          }                                          }
411                                  } else {                                  } else {
412                                          dec->quarterpel = 0;                                          dec->quarterpel = 0;
# Line 370  Line 414 
414    
415                                  if (!BitstreamGetBit(bs))       // complexity_estimation_disable                                  if (!BitstreamGetBit(bs))       // complexity_estimation_disable
416                                  {                                  {
417                                          DEBUG("TODO: complexity_estimation header");                                          //DPRINTF("TODO: complexity_estimation header");
418                                          // TODO                                          // TODO
419                                          return -1;                                          return -1;
420                                  }                                  }
421    
422                                  if (!BitstreamGetBit(bs))       // resync_marker_disable                                  if (!BitstreamGetBit(bs))       // resync_marker_disable
423                                  {                                  {
424                                          DEBUG("IGNORED/TODO: !resync_marker_disable");                                          //DPRINTF("IGNORED/TODO: !resync_marker_disable");
425                                          // TODO                                          // TODO
426                                  }                                  }
427    
428                                  if (BitstreamGetBit(bs))        // data_partitioned                                  if (BitstreamGetBit(bs))        // data_partitioned
429                                  {                                  {
430                                          DEBUG("+ data_partitioned");                                          //DPRINTF("+ data_partitioned");
431                                          BitstreamSkip(bs, 1);   // reversible_vlc                                          BitstreamSkip(bs, 1);   // reversible_vlc
432                                  }                                  }
433    
434                                  if (vol_ver_id != 1) {                                  if (vol_ver_id != 1) {
435                                          if (BitstreamGetBit(bs))        // newpred_enable                                          if (BitstreamGetBit(bs))        // newpred_enable
436                                          {                                          {
437                                                  DEBUG("+ newpred_enable");                                                  //DPRINTF("+ newpred_enable");
438                                                  BitstreamSkip(bs, 2);   // requested_upstream_message_type                                                  BitstreamSkip(bs, 2);   // requested_upstream_message_type
439                                                  BitstreamSkip(bs, 1);   // newpred_segment_type                                                  BitstreamSkip(bs, 1);   // newpred_segment_type
440                                          }                                          }
441                                          if (BitstreamGetBit(bs))        // reduced_resolution_vop_enable                                          if (BitstreamGetBit(bs))        // reduced_resolution_vop_enable
442                                          {                                          {
443                                                  DEBUG("TODO: reduced_resolution_vop_enable");                                                  //DPRINTF("TODO: reduced_resolution_vop_enable");
444                                                  // TODO                                                  // TODO
445                                                  return -1;                                                  return -1;
446                                          }                                          }
# Line 405  Line 449 
449                                  if ((dec->scalability = BitstreamGetBit(bs)))   // scalability                                  if ((dec->scalability = BitstreamGetBit(bs)))   // scalability
450                                  {                                  {
451                                          // TODO                                          // TODO
452                                          DEBUG("TODO: scalability");                                          //DPRINTF("TODO: scalability");
453                                          return -1;                                          return -1;
454                                  }                                  }
455                          } else                          // dec->shape == BINARY_ONLY                          } else                          // dec->shape == BINARY_ONLY
# Line 414  Line 458 
458                                          if (BitstreamGetBit(bs))        // scalability                                          if (BitstreamGetBit(bs))        // scalability
459                                          {                                          {
460                                                  // TODO                                                  // TODO
461                                                  DEBUG("TODO: scalability");                                                  //DPRINTF("TODO: scalability");
462                                                  return -1;                                                  return -1;
463                                          }                                          }
464                                  }                                  }
# Line 423  Line 467 
467                          }                          }
468    
469                  } else if (start_code == GRPOFVOP_START_CODE) {                  } else if (start_code == GRPOFVOP_START_CODE) {
470                          // DEBUG("group_of_vop");                          //DPRINTF("group_of_vop");
471                          BitstreamSkip(bs, 32);                          BitstreamSkip(bs, 32);
472                          {                          {
473                                  int hours, minutes, seconds;                                  int hours, minutes, seconds;
# Line 432  Line 476 
476                                  minutes = BitstreamGetBits(bs, 6);                                  minutes = BitstreamGetBits(bs, 6);
477                                  READ_MARKER();                                  READ_MARKER();
478                                  seconds = BitstreamGetBits(bs, 6);                                  seconds = BitstreamGetBits(bs, 6);
479                                  // DEBUG3("hms", hours, minutes, seconds);                                  //DPRINTF("%ih %im %is", hours, minutes, seconds);
480                          }                          }
481                          BitstreamSkip(bs, 1);   // closed_gov                          BitstreamSkip(bs, 1);   // closed_gov
482                          BitstreamSkip(bs, 1);   // broken_link                          BitstreamSkip(bs, 1);   // broken_link
483                  } else if (start_code == VOP_START_CODE) {                  } else if (start_code == VOP_START_CODE) {
484                          // DEBUG("vop_start_code");                          //DPRINTF("vop_start_code");
485                          BitstreamSkip(bs, 32);  // vop_start_code                          BitstreamSkip(bs, 32);  // vop_start_code
486    
487                          coding_type = BitstreamGetBits(bs, 2);  // vop_coding_type                          coding_type = BitstreamGetBits(bs, 2);  // vop_coding_type
488                          //DEBUG1("coding_type", coding_type);                          //DPRINTF("coding_type %i", coding_type);
489    
490  // *************************** for decode B-frame time ***********************  // *************************** for decode B-frame time ***********************
491                          while (BitstreamGetBit(bs) != 0)        // time_base                          while (BitstreamGetBit(bs) != 0)        // time_base
# Line 449  Line 493 
493    
494                          READ_MARKER();                          READ_MARKER();
495    
                         //DEBUG1("time_inc_bits", dec->time_inc_bits);  
                         //DEBUG1("vop_time_incr", BitstreamShowBits(bs, dec->time_inc_bits));  
496                          if (dec->time_inc_bits) {                          if (dec->time_inc_bits) {
                                 //BitstreamSkip(bs, dec->time_inc_bits);    // vop_time_increment  
497                                  time_increment = (BitstreamGetBits(bs, dec->time_inc_bits));    // vop_time_increment                                  time_increment = (BitstreamGetBits(bs, dec->time_inc_bits));    // vop_time_increment
498                          }                          }
499    
500                            /*
501                            DPRINTF("%c %i:%i",
502                                    coding_type == I_VOP ? 'I' : coding_type == P_VOP ? 'P' : 'B',
503                                    time_incr, time_increment);
504                            */
505    
506                          if (coding_type != B_VOP) {                          if (coding_type != B_VOP) {
507                                  dec->last_time_base = dec->time_base;                                  dec->last_time_base = dec->time_base;
508                                  dec->time_base += time_incr;                                  dec->time_base += time_incr;
# Line 469  Line 517 
517                                           time_incr) * time_increment_resolution + time_increment;                                           time_incr) * time_increment_resolution + time_increment;
518                                  dec->time_bp = (uint32_t) (dec->last_non_b_time - dec->time);                                  dec->time_bp = (uint32_t) (dec->last_non_b_time - dec->time);
519                          }                          }
520                          //DEBUG1("time_increment=",time_increment);                          //DPRINTF("time_increment %i",time_increment);
521    
522                          READ_MARKER();                          READ_MARKER();
523    
524                          if (!BitstreamGetBit(bs))       // vop_coded                          if (!BitstreamGetBit(bs))       // vop_coded
525                          {                          {
526                                    //DPRINTF("**NOT CODED**");
527                                  return N_VOP;                                  return N_VOP;
528                          }                          }
529    
# Line 487  Line 536 
536                          if ((dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) &&                          if ((dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) &&
537                                  (coding_type == P_VOP)) {                                  (coding_type == P_VOP)) {
538                                  *rounding = BitstreamGetBit(bs);        // rounding_type                                  *rounding = BitstreamGetBit(bs);        // rounding_type
539                                  //DEBUG1("rounding", *rounding);                                  //DPRINTF("rounding %i", *rounding);
540                          }                          }
541    
542                          /* if (reduced_resolution_enable)                          /* if (reduced_resolution_enable)
# Line 508  Line 557 
557                                  vert_mc_ref = BitstreamGetBits(bs, 13);                                  vert_mc_ref = BitstreamGetBits(bs, 13);
558                                  READ_MARKER();                                  READ_MARKER();
559    
560                                  // DEBUG2("vop_width/height", width, height);                                  //DPRINTF("vop_width/height %i x %i", width, height);
561                                  // DEBUG2("ref             ", horiz_mc_ref, vert_mc_ref);                                  //DPRINTF("ref              %i x %i", horiz_mc_ref, vert_mc_ref);
562    
563                                  BitstreamSkip(bs, 1);   // change_conv_ratio_disable                                  BitstreamSkip(bs, 1);   // change_conv_ratio_disable
564                                  if (BitstreamGetBit(bs))        // vop_constant_alpha                                  if (BitstreamGetBit(bs))        // vop_constant_alpha
# Line 526  Line 575 
575    
576                                  if (dec->interlacing) {                                  if (dec->interlacing) {
577                                          if ((dec->top_field_first = BitstreamGetBit(bs))) {                                          if ((dec->top_field_first = BitstreamGetBit(bs))) {
578                                                  DEBUG("vop: top_field_first");                                                  //DPRINTF("vop: top_field_first");
579                                          }                                          }
580                                          if ((dec->alternate_vertical_scan = BitstreamGetBit(bs))) {                                          if ((dec->alternate_vertical_scan = BitstreamGetBit(bs))) {
581                                                  DEBUG("vop: alternate_vertical_scan");                                                  //DPRINTF("vop: alternate_vertical_scan");
582                                          }                                          }
583                                  }                                  }
584                          }                          }
# Line 537  Line 586 
586                          if ((*quant = BitstreamGetBits(bs, dec->quant_bits)) < 1)       // vop_quant                          if ((*quant = BitstreamGetBits(bs, dec->quant_bits)) < 1)       // vop_quant
587                                  *quant = 1;                                  *quant = 1;
588    
589                          //DEBUG1("quant", *quant);                          //DPRINTF("quant %i", *quant);
590    
591                          if (coding_type != I_VOP) {                          if (coding_type != I_VOP) {
592                                  *fcode_forward = BitstreamGetBits(bs, 3);       // fcode_forward                                  *fcode_forward = BitstreamGetBits(bs, 3);       // fcode_forward
# Line 554  Line 603 
603                          }                          }
604                          return coding_type;                          return coding_type;
605                  } else if (start_code == USERDATA_START_CODE) {                  } else if (start_code == USERDATA_START_CODE) {
606                          // DEBUG("user_data");                          //DPRINTF("user_data");
607                          BitstreamSkip(bs, 32);  // user_data_start_code                          BitstreamSkip(bs, 32);  // user_data_start_code
608                  } else                                  // start_code == ?                  } else                                  // start_code == ?
609                  {                  {
610                          if (BitstreamShowBits(bs, 24) == 0x000001) {                          if (BitstreamShowBits(bs, 24) == 0x000001) {
611                                  DEBUG1("*** WARNING: unknown start_code",                                  //DPRINTF("*** WARNING: unknown start_code %x",
612                                             BitstreamShowBits(bs, 32));                                  //         BitstreamShowBits(bs, 32));
613                          }                          }
614                          BitstreamSkip(bs, 8);                          BitstreamSkip(bs, 8);
615                  }                  }
616          }          }
617          while ((BitstreamPos(bs) >> 3) < bs->length);          while ((BitstreamPos(bs) >> 3) < bs->length);
618    
619          DEBUG("*** WARNING: no vop_start_code found");          //DPRINTF("*** WARNING: no vop_start_code found");
620          return -1;                                      /* ignore it */          return -1;                                      /* ignore it */
621  }  }
622    
# Line 581  Line 630 
630          int i, j;          int i, j;
631          const int last = matrix[scan_tables[0][63]];          const int last = matrix[scan_tables[0][63]];
632    
633          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--);
634    
635          for (i = 0; i <= j; i++) {          for (i = 0; i <= j; i++) {
636                  BitstreamPutBits(bs, matrix[scan_tables[0][i]], 8);                  BitstreamPutBits(bs, matrix[scan_tables[0][i]], 8);
# Line 617  Line 666 
666    
667  #ifdef BFRAMES  #ifdef BFRAMES
668          if (pParam->max_bframes > 0) {          if (pParam->max_bframes > 0) {
669                  DPRINTF("low_delay=1");                  //DPRINTF("low_delay=1");
670                  BitstreamPutBit(bs, 1); // vol_control_parameters                  BitstreamPutBit(bs, 1); // vol_control_parameters
671                  BitstreamPutBits(bs, 1, 2);     // chroma_format 1="4:2:0"                  BitstreamPutBits(bs, 1, 2);     // chroma_format 1="4:2:0"
672                  BitstreamPutBit(bs, 0); // low_delay                  BitstreamPutBit(bs, 0); // low_delay
# Line 646  Line 695 
695    
696          WRITE_MARKER();          WRITE_MARKER();
697    
698          // fixed_vop_rate  #ifdef BFRAMES
699          BitstreamPutBit(bs, 0);          BitstreamPutBit(bs, 1);         // fixed_vop_rate = 1
700            BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase));    // fixed_vop_time_increment
701          // fixed_time_increment: value=nth_of_sec, nbits = log2(resolution)  #else
702          // BitstreamPutBits(bs, 0, 15);          BitstreamPutBit(bs, 0);         // fixed_vop_rate = 0
703    #endif
704    
705          WRITE_MARKER();          WRITE_MARKER();
706          BitstreamPutBits(bs, pParam->width, 13);        // width          BitstreamPutBits(bs, pParam->width, 13);        // width

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.21

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