[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.39, Wed Feb 19 21:59:30 2003 UTC revision 1.39.2.10, Mon Jun 9 01:17:09 2003 UTC
# Line 121  Line 121 
121                  matrix[scan_tables[0][i++]] = value;                  matrix[scan_tables[0][i++]] = value;
122          }          }
123          while (value != 0 && i < 64);          while (value != 0 && i < 64);
124          i--;    // fix little bug at coeff not full          i--;    /* fix little bug at coeff not full */
125    
126          while (i < 64) {          while (i < 64) {
127                  matrix[scan_tables[0][i++]] = last;                  matrix[scan_tables[0][i++]] = last;
# Line 130  Line 130 
130    
131    
132    
133  // for PVOP addbits == fcode - 1  /*
134  // for BVOP addbits == max(fcode,bcode) - 1   * for PVOP addbits == fcode - 1
135  // returns mbpos   * for BVOP addbits == max(fcode,bcode) - 1
136     * returns mbpos
137     */
138  int  int
139  read_video_packet_header(Bitstream *bs,  read_video_packet_header(Bitstream *bs,
140                                                  DECODER * dec,                                                  DECODER * dec,
# Line 150  Line 152 
152          BitstreamSkip(bs, BitstreamNumBitsToByteAlign(bs));          BitstreamSkip(bs, BitstreamNumBitsToByteAlign(bs));
153          BitstreamSkip(bs, startcode_bits);          BitstreamSkip(bs, startcode_bits);
154    
155          DPRINTF(DPRINTF_STARTCODE, "<video_packet_header>");          DPRINTF(XVID_DEBUG_STARTCODE, "<video_packet_header>\n");
156    
157          if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR)          if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR)
158          {          {
# Line 169  Line 171 
171          }          }
172    
173          mbnum = BitstreamGetBits(bs, mbnum_bits);               /* macroblock_number */          mbnum = BitstreamGetBits(bs, mbnum_bits);               /* macroblock_number */
174          DPRINTF(DPRINTF_HEADER, "mbnum %i", mbnum);          DPRINTF(XVID_DEBUG_HEADER, "mbnum %i\n", mbnum);
175    
176          if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY)          if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY)
177          {          {
178                  *quant = BitstreamGetBits(bs, dec->quant_bits); /* quant_scale */                  *quant = BitstreamGetBits(bs, dec->quant_bits); /* quant_scale */
179                  DPRINTF(DPRINTF_HEADER, "quant %i", *quant);                  DPRINTF(XVID_DEBUG_HEADER, "quant %i\n", *quant);
180          }          }
181    
182          if (dec->shape == VIDOBJLAY_SHAPE_RECTANGULAR)          if (dec->shape == VIDOBJLAY_SHAPE_RECTANGULAR)
183                  hec = BitstreamGetBit(bs);              /* header_extension_code */                  hec = BitstreamGetBit(bs);              /* header_extension_code */
184    
185    
186          DPRINTF(DPRINTF_HEADER, "header_extension_code %i", hec);          DPRINTF(XVID_DEBUG_HEADER, "header_extension_code %i\n", hec);
187          if (hec)          if (hec)
188          {          {
189                  int time_base;                  int time_base;
# Line 193  Line 195 
195                  if (dec->time_inc_bits)                  if (dec->time_inc_bits)
196                          time_increment = (BitstreamGetBits(bs, dec->time_inc_bits));    /* vop_time_increment */                          time_increment = (BitstreamGetBits(bs, dec->time_inc_bits));    /* vop_time_increment */
197                  READ_MARKER();                  READ_MARKER();
198                  DPRINTF(DPRINTF_HEADER,"time %i:%i", time_base, time_increment);                  DPRINTF(XVID_DEBUG_HEADER,"time %i:%i\n", time_base, time_increment);
199    
200                  coding_type = BitstreamGetBits(bs, 2);                  coding_type = BitstreamGetBits(bs, 2);
201                  DPRINTF(DPRINTF_HEADER,"coding_type %i", coding_type);                  DPRINTF(XVID_DEBUG_HEADER,"coding_type %i\n", coding_type);
202    
203                  if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR)                  if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR)
204                  {                  {
# Line 212  Line 214 
214                          if (dec->sprite_enable == SPRITE_GMC && coding_type == S_VOP &&                          if (dec->sprite_enable == SPRITE_GMC && coding_type == S_VOP &&
215                                  dec->sprite_warping_points > 0)                                  dec->sprite_warping_points > 0)
216                          {                          {
217                                  // TODO: sprite trajectory                                  /* TODO: sprite trajectory */
218                          }                          }
219                          if (dec->reduced_resolution_enable &&                          if (dec->reduced_resolution_enable &&
220                                  dec->shape == VIDOBJLAY_SHAPE_RECTANGULAR &&                                  dec->shape == VIDOBJLAY_SHAPE_RECTANGULAR &&
# Line 224  Line 226 
226                          if (coding_type != I_VOP && fcode_forward)                          if (coding_type != I_VOP && fcode_forward)
227                          {                          {
228                                  *fcode_forward = BitstreamGetBits(bs, 3);                                  *fcode_forward = BitstreamGetBits(bs, 3);
229                                  DPRINTF(DPRINTF_HEADER,"fcode_forward %i", *fcode_forward);                                  DPRINTF(XVID_DEBUG_HEADER,"fcode_forward %i\n", *fcode_forward);
230                          }                          }
231    
232                          if (coding_type == B_VOP && fcode_backward)                          if (coding_type == B_VOP && fcode_backward)
233                          {                          {
234                                  *fcode_backward = BitstreamGetBits(bs, 3);                                  *fcode_backward = BitstreamGetBits(bs, 3);
235                                  DPRINTF(DPRINTF_HEADER,"fcode_backward %i", *fcode_backward);                                  DPRINTF(XVID_DEBUG_HEADER,"fcode_backward %i\n", *fcode_backward);
236                          }                          }
237                  }                  }
238    
# Line 242  Line 244 
244                  int vop_id_for_prediction;                  int vop_id_for_prediction;
245    
246                  vop_id = BitstreamGetBits(bs, MIN(dec->time_inc_bits + 3, 15));                  vop_id = BitstreamGetBits(bs, MIN(dec->time_inc_bits + 3, 15));
247                  DPRINTF(DPRINTF_HEADER, "vop_id %i", vop_id);                  DPRINTF(XVID_DEBUG_HEADER, "vop_id %i\n", vop_id);
248                  if (BitstreamGetBit(bs))        /* vop_id_for_prediction_indication */                  if (BitstreamGetBit(bs))        /* vop_id_for_prediction_indication */
249                  {                  {
250                          vop_id_for_prediction = BitstreamGetBits(bs, MIN(dec->time_inc_bits + 3, 15));                          vop_id_for_prediction = BitstreamGetBits(bs, MIN(dec->time_inc_bits + 3, 15));
251                          DPRINTF(DPRINTF_HEADER, "vop_id_for_prediction %i", vop_id_for_prediction);                          DPRINTF(XVID_DEBUG_HEADER, "vop_id_for_prediction %i\n", vop_id_for_prediction);
252                  }                  }
253                  READ_MARKER();                  READ_MARKER();
254          }          }
# Line 264  Line 266 
266          ESTIMATION * e = &dec->estimation;          ESTIMATION * e = &dec->estimation;
267    
268          e->method = BitstreamGetBits(bs, 2);    /* estimation_method */          e->method = BitstreamGetBits(bs, 2);    /* estimation_method */
269          DPRINTF(DPRINTF_HEADER,"+ complexity_estimation_header; method=%i", e->method);          DPRINTF(XVID_DEBUG_HEADER,"+ complexity_estimation_header; method=%i\n", e->method);
270    
271          if (e->method == 0 || e->method == 1)          if (e->method == 0 || e->method == 1)
272          {          {
# Line 450  Line 452 
452    
453                          int profile;                          int profile;
454    
455                          DPRINTF(DPRINTF_STARTCODE, "<visual_object_sequence>");                          DPRINTF(XVID_DEBUG_STARTCODE, "<visual_object_sequence>\n");
456    
457                          BitstreamSkip(bs, 32);  // visual_object_sequence_start_code                          BitstreamSkip(bs, 32);  /* visual_object_sequence_start_code */
458                          profile = BitstreamGetBits(bs, 8);      // profile_and_level_indication                          profile = BitstreamGetBits(bs, 8);      /* profile_and_level_indication */
459    
460                          DPRINTF(DPRINTF_HEADER, "profile_and_level_indication %i", profile);                          DPRINTF(XVID_DEBUG_HEADER, "profile_and_level_indication %i\n", profile);
461    
462                  } else if (start_code == VISOBJSEQ_STOP_CODE) {                  } else if (start_code == VISOBJSEQ_STOP_CODE) {
463    
464                          BitstreamSkip(bs, 32);  // visual_object_sequence_stop_code                          BitstreamSkip(bs, 32);  /* visual_object_sequence_stop_code */
465    
466                          DPRINTF(DPRINTF_STARTCODE, "</visual_object_sequence>");                          DPRINTF(XVID_DEBUG_STARTCODE, "</visual_object_sequence>\n");
467    
468                  } else if (start_code == VISOBJ_START_CODE) {                  } else if (start_code == VISOBJ_START_CODE) {
469                          int visobj_ver_id;                          int visobj_ver_id;
470    
471                          DPRINTF(DPRINTF_STARTCODE, "<visual_object>");                          DPRINTF(XVID_DEBUG_STARTCODE, "<visual_object>\n");
472    
473                          BitstreamSkip(bs, 32);  // visual_object_start_code                          BitstreamSkip(bs, 32);  /* visual_object_start_code */
474                          if (BitstreamGetBit(bs))        // is_visual_object_identified                          if (BitstreamGetBit(bs))        /* is_visual_object_identified */
475                          {                          {
476                                  visobj_ver_id = BitstreamGetBits(bs, 4);        // visual_object_ver_id                                  visobj_ver_id = BitstreamGetBits(bs, 4);        /* visual_object_ver_id */
477                                  DPRINTF(DPRINTF_HEADER,"visobj_ver_id %i", visobj_ver_id);                                  DPRINTF(XVID_DEBUG_HEADER,"visobj_ver_id %i\n", visobj_ver_id);
478                                  BitstreamSkip(bs, 3);   // visual_object_priority                                  BitstreamSkip(bs, 3);   /* visual_object_priority */
479                          } else {                          } else {
480                                  visobj_ver_id = 1;                                  visobj_ver_id = 1;
481                          }                          }
482    
483                          if (BitstreamShowBits(bs, 4) != VISOBJ_TYPE_VIDEO)      // visual_object_type                          if (BitstreamShowBits(bs, 4) != VISOBJ_TYPE_VIDEO)      /* visual_object_type */
484                          {                          {
485                                  DPRINTF(DPRINTF_ERROR, "visual_object_type != video");                                  DPRINTF(XVID_DEBUG_ERROR, "visual_object_type != video\n");
486                                  return -1;                                  return -1;
487                          }                          }
488                          BitstreamSkip(bs, 4);                          BitstreamSkip(bs, 4);
489    
490                          // video_signal_type                          /* video_signal_type */
491    
492                          if (BitstreamGetBit(bs))        // video_signal_type                          if (BitstreamGetBit(bs))        /* video_signal_type */
493                          {                          {
494                                  DPRINTF(DPRINTF_HEADER,"+ video_signal_type");                                  DPRINTF(XVID_DEBUG_HEADER,"+ video_signal_type\n");
495                                  BitstreamSkip(bs, 3);   // video_format                                  BitstreamSkip(bs, 3);   /* video_format */
496                                  BitstreamSkip(bs, 1);   // video_range                                  BitstreamSkip(bs, 1);   /* video_range */
497                                  if (BitstreamGetBit(bs))        // color_description                                  if (BitstreamGetBit(bs))        /* color_description */
498                                  {                                  {
499                                          DPRINTF(DPRINTF_HEADER,"+ color_description");                                          DPRINTF(XVID_DEBUG_HEADER,"+ color_description");
500                                          BitstreamSkip(bs, 8);   // color_primaries                                          BitstreamSkip(bs, 8);   /* color_primaries */
501                                          BitstreamSkip(bs, 8);   // transfer_characteristics                                          BitstreamSkip(bs, 8);   /* transfer_characteristics */
502                                          BitstreamSkip(bs, 8);   // matrix_coefficients                                          BitstreamSkip(bs, 8);   /* matrix_coefficients */
503                                  }                                  }
504                          }                          }
505                  } else if ((start_code & ~VIDOBJ_START_CODE_MASK) == VIDOBJ_START_CODE) {                  } else if ((start_code & ~VIDOBJ_START_CODE_MASK) == VIDOBJ_START_CODE) {
506    
507                          DPRINTF(DPRINTF_STARTCODE, "<video_object>");                          DPRINTF(XVID_DEBUG_STARTCODE, "<video_object>\n");
508                          DPRINTF(DPRINTF_HEADER, "vo id %i", start_code & VIDOBJ_START_CODE_MASK);                          DPRINTF(XVID_DEBUG_HEADER, "vo id %i\n", start_code & VIDOBJ_START_CODE_MASK);
509    
510                          BitstreamSkip(bs, 32);  // video_object_start_code                          BitstreamSkip(bs, 32);  /* video_object_start_code */
511    
512                  } else if ((start_code & ~VIDOBJLAY_START_CODE_MASK) == VIDOBJLAY_START_CODE) {                  } else if ((start_code & ~VIDOBJLAY_START_CODE_MASK) == VIDOBJLAY_START_CODE) {
513    
514                          DPRINTF(DPRINTF_STARTCODE, "<video_object_layer>");                          DPRINTF(XVID_DEBUG_STARTCODE, "<video_object_layer>\n");
515                          DPRINTF(DPRINTF_HEADER, "vol id %i", start_code & VIDOBJLAY_START_CODE_MASK);                          DPRINTF(XVID_DEBUG_HEADER, "vol id %i\n", start_code & VIDOBJLAY_START_CODE_MASK);
   
                         BitstreamSkip(bs, 32);  // video_object_layer_start_code  
   
                         BitstreamSkip(bs, 1);   // random_accessible_vol  
516    
517                          // video_object_type_indication                          BitstreamSkip(bs, 32);  /* video_object_layer_start_code */
518                          if (BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_SIMPLE &&                          BitstreamSkip(bs, 1);   /* random_accessible_vol */
                                 BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_CORE &&  
                                 BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_MAIN &&  
                                 BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_ACE &&  
                                 BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_ART_SIMPLE &&  
                                 BitstreamShowBits(bs, 8) != 0)  // BUGGY DIVX  
                         {  
                                 DPRINTF(DPRINTF_ERROR,"video_object_type_indication %i not supported ",  
                                         BitstreamShowBits(bs, 8));  
                                 return -1;  
                         }  
                         BitstreamSkip(bs, 8);  
519    
520                BitstreamSkip(bs, 8);   /* video_object_type_indication */
521    
522                          if (BitstreamGetBit(bs))        // is_object_layer_identifier                          if (BitstreamGetBit(bs))        /* is_object_layer_identifier */
523                          {                          {
524                                  DPRINTF(DPRINTF_HEADER, "+ is_object_layer_identifier");                                  DPRINTF(XVID_DEBUG_HEADER, "+ is_object_layer_identifier\n");
525                                  vol_ver_id = BitstreamGetBits(bs, 4);   // video_object_layer_verid                                  vol_ver_id = BitstreamGetBits(bs, 4);   /* video_object_layer_verid */
526                                  DPRINTF(DPRINTF_HEADER,"ver_id %i", vol_ver_id);                                  DPRINTF(XVID_DEBUG_HEADER,"ver_id %i\n", vol_ver_id);
527                                  BitstreamSkip(bs, 3);   // video_object_layer_priority                                  BitstreamSkip(bs, 3);   /* video_object_layer_priority */
528                          } else {                          } else {
529                                  vol_ver_id = 1;                                  vol_ver_id = 1;
530                          }                          }
531    
532                          dec->aspect_ratio = BitstreamGetBits(bs, 4);                          dec->aspect_ratio = BitstreamGetBits(bs, 4);
533    
534                          if (dec->aspect_ratio == VIDOBJLAY_AR_EXTPAR)   // aspect_ratio_info                          if (dec->aspect_ratio == VIDOBJLAY_AR_EXTPAR)   /* aspect_ratio_info */
535                          {                          {
536                                  DPRINTF(DPRINTF_HEADER, "+ aspect_ratio_info");                                  DPRINTF(XVID_DEBUG_HEADER, "+ aspect_ratio_info\n");
537                                  dec->par_width = BitstreamGetBits(bs, 8);       // par_width                                  dec->par_width = BitstreamGetBits(bs, 8);       /* par_width */
538                                  dec->par_height = BitstreamGetBits(bs, 8);      // par_height                                  dec->par_height = BitstreamGetBits(bs, 8);      /* par_height */
539                          }                          }
540    
541                          if (BitstreamGetBit(bs))        // vol_control_parameters                          if (BitstreamGetBit(bs))        /* vol_control_parameters */
542                          {                          {
543                                  DPRINTF(DPRINTF_HEADER, "+ vol_control_parameters");                                  DPRINTF(XVID_DEBUG_HEADER, "+ vol_control_parameters\n");
544                                  BitstreamSkip(bs, 2);   // chroma_format                                  BitstreamSkip(bs, 2);   /* chroma_format */
545                                  dec->low_delay = BitstreamGetBit(bs);   // low_delay                                  dec->low_delay = BitstreamGetBit(bs);   /* low_delay */
546                                  DPRINTF(DPRINTF_HEADER, "low_delay %i", dec->low_delay);                                  DPRINTF(XVID_DEBUG_HEADER, "low_delay %i\n", dec->low_delay);
547                                  if (BitstreamGetBit(bs))        // vbv_parameters                                  if (BitstreamGetBit(bs))        /* vbv_parameters */
548                                  {                                  {
549                                          unsigned int bitrate;                                          unsigned int bitrate;
550                                          unsigned int buffer_size;                                          unsigned int buffer_size;
551                                          unsigned int occupancy;                                          unsigned int occupancy;
552    
553                                          DPRINTF(DPRINTF_HEADER,"+ vbv_parameters");                                          DPRINTF(XVID_DEBUG_HEADER,"+ vbv_parameters\n");
554    
555                                          bitrate = BitstreamGetBits(bs,15) << 15;        // first_half_bit_rate                                          bitrate = BitstreamGetBits(bs,15) << 15;        /* first_half_bit_rate */
556                                          READ_MARKER();                                          READ_MARKER();
557                                          bitrate |= BitstreamGetBits(bs,15);             // latter_half_bit_rate                                          bitrate |= BitstreamGetBits(bs,15);             /* latter_half_bit_rate */
558                                          READ_MARKER();                                          READ_MARKER();
559    
560                                          buffer_size = BitstreamGetBits(bs, 15) << 3;    // first_half_vbv_buffer_size                                          buffer_size = BitstreamGetBits(bs, 15) << 3;    /* first_half_vbv_buffer_size */
561                                          READ_MARKER();                                          READ_MARKER();
562                                          buffer_size |= BitstreamGetBits(bs, 3);         // latter_half_vbv_buffer_size                                          buffer_size |= BitstreamGetBits(bs, 3);         /* latter_half_vbv_buffer_size */
563    
564                                          occupancy = BitstreamGetBits(bs, 11) << 15;     // first_half_vbv_occupancy                                          occupancy = BitstreamGetBits(bs, 11) << 15;     /* first_half_vbv_occupancy */
565                                          READ_MARKER();                                          READ_MARKER();
566                                          occupancy |= BitstreamGetBits(bs, 15);  // latter_half_vbv_occupancy                                          occupancy |= BitstreamGetBits(bs, 15);  /* latter_half_vbv_occupancy */
567                                          READ_MARKER();                                          READ_MARKER();
568    
569                                          DPRINTF(DPRINTF_HEADER,"bitrate %d (unit=400 bps)", bitrate);                                          DPRINTF(XVID_DEBUG_HEADER,"bitrate %d (unit=400 bps)\n", bitrate);
570                                          DPRINTF(DPRINTF_HEADER,"buffer_size %d (unit=16384 bits)", buffer_size);                                          DPRINTF(XVID_DEBUG_HEADER,"buffer_size %d (unit=16384 bits)\n", buffer_size);
571                                          DPRINTF(DPRINTF_HEADER,"occupancy %d (unit=64 bits)", occupancy);                                          DPRINTF(XVID_DEBUG_HEADER,"occupancy %d (unit=64 bits)\n", occupancy);
572                                  }                                  }
573                          }else{                          }else{
574                                  dec->low_delay = dec->low_delay_default;                                  dec->low_delay = dec->low_delay_default;
575                          }                          }
576    
577                          dec->shape = BitstreamGetBits(bs, 2);   // video_object_layer_shape                          dec->shape = BitstreamGetBits(bs, 2);   /* video_object_layer_shape */
578    
579                          DPRINTF(DPRINTF_HEADER, "shape %i", dec->shape);                          DPRINTF(XVID_DEBUG_HEADER, "shape %i\n", dec->shape);
580                          if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR)                          if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR)
581                          {                          {
582                                  DPRINTF(DPRINTF_ERROR,"non-rectangular shapes are not supported");                                  DPRINTF(XVID_DEBUG_ERROR,"non-rectangular shapes are not supported\n");
583                          }                          }
584    
585                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE && vol_ver_id != 1) {                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE && vol_ver_id != 1) {
586                                  BitstreamSkip(bs, 4);   // video_object_layer_shape_extension                                  BitstreamSkip(bs, 4);   /* video_object_layer_shape_extension */
587                          }                          }
588    
589                          READ_MARKER();                          READ_MARKER();
590    
591  // *************************** for decode B-frame time ***********************                          /********************** for decode B-frame time ***********************/
592                          dec->time_inc_resolution = BitstreamGetBits(bs, 16);    // vop_time_increment_resolution                          dec->time_inc_resolution = BitstreamGetBits(bs, 16);    /* vop_time_increment_resolution */
593                          DPRINTF(DPRINTF_HEADER,"vop_time_increment_resolution %i", dec->time_inc_resolution);                          DPRINTF(XVID_DEBUG_HEADER,"vop_time_increment_resolution %i\n", dec->time_inc_resolution);
594    
595  //                      dec->time_inc_resolution--;  #if 0
596                            dec->time_inc_resolution--;
597    #endif
598    
599                          if (dec->time_inc_resolution > 0) {                          if (dec->time_inc_resolution > 0) {
600                                  dec->time_inc_bits = log2bin(dec->time_inc_resolution-1);                                  dec->time_inc_bits = log2bin(dec->time_inc_resolution-1);
601                          } else {                          } else {
602                                  // dec->time_inc_bits = 0;  #if 0
603                                  // for "old" xvid compatibility, set time_inc_bits = 1                                  dec->time_inc_bits = 0;
604    #endif
605                                    /* for "old" xvid compatibility, set time_inc_bits = 1 */
606                                  dec->time_inc_bits = 1;                                  dec->time_inc_bits = 1;
607                          }                          }
608    
609                          READ_MARKER();                          READ_MARKER();
610    
611                          if (BitstreamGetBit(bs))        // fixed_vop_rate                          if (BitstreamGetBit(bs))        /* fixed_vop_rate */
612                          {                          {
613                                  DPRINTF(DPRINTF_HEADER, "+ fixed_vop_rate");                                  DPRINTF(XVID_DEBUG_HEADER, "+ fixed_vop_rate\n");
614                                  BitstreamSkip(bs, dec->time_inc_bits);  // fixed_vop_time_increment                                  BitstreamSkip(bs, dec->time_inc_bits);  /* fixed_vop_time_increment */
615                          }                          }
616    
617                          if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) {                          if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) {
# Line 628  Line 620 
620                                          uint32_t width, height;                                          uint32_t width, height;
621    
622                                          READ_MARKER();                                          READ_MARKER();
623                                          width = BitstreamGetBits(bs, 13);       // video_object_layer_width                                          width = BitstreamGetBits(bs, 13);       /* video_object_layer_width */
624                                          READ_MARKER();                                          READ_MARKER();
625                                          height = BitstreamGetBits(bs, 13);      // video_object_layer_height                                          height = BitstreamGetBits(bs, 13);      /* video_object_layer_height */
626                                          READ_MARKER();                                          READ_MARKER();
627    
628                                          DPRINTF(DPRINTF_HEADER, "width %i", width);                                          DPRINTF(XVID_DEBUG_HEADER, "width %i\n", width);
629                                          DPRINTF(DPRINTF_HEADER, "height %i", height);                                          DPRINTF(XVID_DEBUG_HEADER, "height %i\n", height);
630    
631                                          if (dec->width != width || dec->height != height)                                          if (dec->width != width || dec->height != height)
632                                          {                                          {
633                                                  if (dec->fixed_dimensions)                                                  if (dec->fixed_dimensions)
634                                                  {                                                  {
635                                                          DPRINTF(DPRINTF_ERROR, "XVID_DEC_PARAM width/height does not match bitstream");                                                          DPRINTF(XVID_DEBUG_ERROR, "decoder width/height does not match bitstream\n");
636                                                          return -1;                                                          return -1;
637                                                  }                                                  }
638                                                  resize = 1;                                                  resize = 1;
# Line 650  Line 642 
642                                  }                                  }
643    
644                                  dec->interlacing = BitstreamGetBit(bs);                                  dec->interlacing = BitstreamGetBit(bs);
645                                  DPRINTF(DPRINTF_HEADER, "interlacing %i", dec->interlacing);                                  DPRINTF(XVID_DEBUG_HEADER, "interlacing %i\n", dec->interlacing);
646    
647                                  if (!BitstreamGetBit(bs))       // obmc_disable                                  if (!BitstreamGetBit(bs))       /* obmc_disable */
648                                  {                                  {
649                                          DPRINTF(DPRINTF_ERROR, "obmc_disabled==false not supported");                                          DPRINTF(XVID_DEBUG_ERROR, "obmc_disabled==false not supported\n");
650                                          // TODO                                          /* TODO */
651                                          // fucking divx4.02 has this enabled                                          /* fucking divx4.02 has this enabled */
652                                  }                                  }
653    
654                                  dec->sprite_enable = BitstreamGetBits(bs, (vol_ver_id == 1 ? 1 : 2));   // sprite_enable                                  dec->sprite_enable = BitstreamGetBits(bs, (vol_ver_id == 1 ? 1 : 2));   /* sprite_enable */
655    
656                                  if (dec->sprite_enable == SPRITE_STATIC || dec->sprite_enable == SPRITE_GMC)                                  if (dec->sprite_enable == SPRITE_STATIC || dec->sprite_enable == SPRITE_GMC)
657                                  {                                  {
# Line 671  Line 663 
663                                                  int sprite_height;                                                  int sprite_height;
664                                                  int sprite_left_coord;                                                  int sprite_left_coord;
665                                                  int sprite_top_coord;                                                  int sprite_top_coord;
666                                                  sprite_width = BitstreamGetBits(bs, 13);                // sprite_width                                                  sprite_width = BitstreamGetBits(bs, 13);                /* sprite_width */
667                                                  READ_MARKER();                                                  READ_MARKER();
668                                                  sprite_height = BitstreamGetBits(bs, 13);       // sprite_height                                                  sprite_height = BitstreamGetBits(bs, 13);       /* sprite_height */
669                                                  READ_MARKER();                                                  READ_MARKER();
670                                                  sprite_left_coord = BitstreamGetBits(bs, 13);   // sprite_left_coordinate                                                  sprite_left_coord = BitstreamGetBits(bs, 13);   /* sprite_left_coordinate */
671                                                  READ_MARKER();                                                  READ_MARKER();
672                                                  sprite_top_coord = BitstreamGetBits(bs, 13);    // sprite_top_coordinate                                                  sprite_top_coord = BitstreamGetBits(bs, 13);    /* sprite_top_coordinate */
673                                                  READ_MARKER();                                                  READ_MARKER();
674                                          }                                          }
675                                          dec->sprite_warping_points = BitstreamGetBits(bs, 6);           // no_of_sprite_warping_points                                          dec->sprite_warping_points = BitstreamGetBits(bs, 6);           /* no_of_sprite_warping_points */
676                                          dec->sprite_warping_accuracy = BitstreamGetBits(bs, 2);         // sprite_warping_accuracy                                          dec->sprite_warping_accuracy = BitstreamGetBits(bs, 2);         /* sprite_warping_accuracy */
677                                          dec->sprite_brightness_change = BitstreamGetBits(bs, 1);                // brightness_change                                          dec->sprite_brightness_change = BitstreamGetBits(bs, 1);                /* brightness_change */
678                                          if (dec->sprite_enable != SPRITE_GMC)                                          if (dec->sprite_enable != SPRITE_GMC)
679                                          {                                          {
680                                                  low_latency_sprite_enable = BitstreamGetBits(bs, 1);            // low_latency_sprite_enable                                                  low_latency_sprite_enable = BitstreamGetBits(bs, 1);            /* low_latency_sprite_enable */
681                                          }                                          }
682                                  }                                  }
683    
684                                  if (vol_ver_id != 1 &&                                  if (vol_ver_id != 1 &&
685                                          dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) {                                          dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) {
686                                          BitstreamSkip(bs, 1);   // sadct_disable                                          BitstreamSkip(bs, 1);   /* sadct_disable */
687                                  }                                  }
688    
689                                  if (BitstreamGetBit(bs))        // not_8_bit                                  if (BitstreamGetBit(bs))        /* not_8_bit */
690                                  {                                  {
691                                          DPRINTF(DPRINTF_HEADER, "not_8_bit==true (ignored)");                                          DPRINTF(XVID_DEBUG_HEADER, "not_8_bit==true (ignored)\n");
692                                          dec->quant_bits = BitstreamGetBits(bs, 4);      // quant_precision                                          dec->quant_bits = BitstreamGetBits(bs, 4);      /* quant_precision */
693                                          BitstreamSkip(bs, 4);   // bits_per_pixel                                          BitstreamSkip(bs, 4);   /* bits_per_pixel */
694                                  } else {                                  } else {
695                                          dec->quant_bits = 5;                                          dec->quant_bits = 5;
696                                  }                                  }
697    
698                                  if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) {                                  if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) {
699                                          BitstreamSkip(bs, 1);   // no_gray_quant_update                                          BitstreamSkip(bs, 1);   /* no_gray_quant_update */
700                                          BitstreamSkip(bs, 1);   // composition_method                                          BitstreamSkip(bs, 1);   /* composition_method */
701                                          BitstreamSkip(bs, 1);   // linear_composition                                          BitstreamSkip(bs, 1);   /* linear_composition */
702                                  }                                  }
703    
704                                  dec->quant_type = BitstreamGetBit(bs);  // quant_type                                  dec->quant_type = BitstreamGetBit(bs);  /* quant_type */
705                                  DPRINTF(DPRINTF_HEADER, "quant_type %i", dec->quant_type);                                  DPRINTF(XVID_DEBUG_HEADER, "quant_type %i\n", dec->quant_type);
706    
707                                  if (dec->quant_type) {                                  if (dec->quant_type) {
708                                          if (BitstreamGetBit(bs))        // load_intra_quant_mat                                          if (BitstreamGetBit(bs))        /* load_intra_quant_mat */
709                                          {                                          {
710                                                  uint8_t matrix[64];                                                  uint8_t matrix[64];
711    
712                                                  DPRINTF(DPRINTF_HEADER, "load_intra_quant_mat");                                                  DPRINTF(XVID_DEBUG_HEADER, "load_intra_quant_mat\n");
713    
714                                                  bs_get_matrix(bs, matrix);                                                  bs_get_matrix(bs, matrix);
715                                                  set_intra_matrix(matrix);                                                  set_intra_matrix(matrix);
716                                          } else                                          } else
717                                                  set_intra_matrix(get_default_intra_matrix());                                                  set_intra_matrix(get_default_intra_matrix());
718    
719                                          if (BitstreamGetBit(bs))        // load_inter_quant_mat                                          if (BitstreamGetBit(bs))        /* load_inter_quant_mat */
720                                          {                                          {
721                                                  uint8_t matrix[64];                                                  uint8_t matrix[64];
722    
723                                                  DPRINTF(DPRINTF_HEADER, "load_inter_quant_mat");                                                  DPRINTF(XVID_DEBUG_HEADER, "load_inter_quant_mat\n");
724    
725                                                  bs_get_matrix(bs, matrix);                                                  bs_get_matrix(bs, matrix);
726                                                  set_inter_matrix(matrix);                                                  set_inter_matrix(matrix);
# Line 736  Line 728 
728                                                  set_inter_matrix(get_default_inter_matrix());                                                  set_inter_matrix(get_default_inter_matrix());
729    
730                                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) {                                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) {
731                                                  DPRINTF(DPRINTF_ERROR, "greyscale matrix not supported");                                                  DPRINTF(XVID_DEBUG_ERROR, "greyscale matrix not supported\n");
732                                                  return -1;                                                  return -1;
733                                          }                                          }
734    
# Line 744  Line 736 
736    
737    
738                                  if (vol_ver_id != 1) {                                  if (vol_ver_id != 1) {
739                                          dec->quarterpel = BitstreamGetBit(bs);  // quarter_sample                                          dec->quarterpel = BitstreamGetBit(bs);  /* quarter_sample */
740                                          DPRINTF(DPRINTF_HEADER,"quarterpel %i", dec->quarterpel);                                          DPRINTF(XVID_DEBUG_HEADER,"quarterpel %i\n", dec->quarterpel);
741                                  }                                  }
742                                  else                                  else
743                                          dec->quarterpel = 0;                                          dec->quarterpel = 0;
# Line 757  Line 749 
749                                          read_vol_complexity_estimation_header(bs, dec);                                          read_vol_complexity_estimation_header(bs, dec);
750                                  }                                  }
751    
752                                  BitstreamSkip(bs, 1);   // resync_marker_disable                                  BitstreamSkip(bs, 1);   /* resync_marker_disable */
753    
754                                  if (BitstreamGetBit(bs))        // data_partitioned                                  if (BitstreamGetBit(bs))        /* data_partitioned */
755                                  {                                  {
756                                          DPRINTF(DPRINTF_ERROR, "data_partitioned not supported");                                          DPRINTF(XVID_DEBUG_ERROR, "data_partitioned not supported\n");
757                                          BitstreamSkip(bs, 1);   // reversible_vlc                                          BitstreamSkip(bs, 1);   /* reversible_vlc */
758                                  }                                  }
759    
760                                  if (vol_ver_id != 1) {                                  if (vol_ver_id != 1) {
761                                          dec->newpred_enable = BitstreamGetBit(bs);                                          dec->newpred_enable = BitstreamGetBit(bs);
762                                          if (dec->newpred_enable)        // newpred_enable                                          if (dec->newpred_enable)        /* newpred_enable */
763                                          {                                          {
764                                                  DPRINTF(DPRINTF_HEADER, "+ newpred_enable");                                                  DPRINTF(XVID_DEBUG_HEADER, "+ newpred_enable\n");
765                                                  BitstreamSkip(bs, 2);   // requested_upstream_message_type                                                  BitstreamSkip(bs, 2);   /* requested_upstream_message_type */
766                                                  BitstreamSkip(bs, 1);   // newpred_segment_type                                                  BitstreamSkip(bs, 1);   /* newpred_segment_type */
767                                          }                                          }
768                                          dec->reduced_resolution_enable = BitstreamGetBit(bs);   /* reduced_resolution_vop_enable */                                          dec->reduced_resolution_enable = BitstreamGetBit(bs);   /* reduced_resolution_vop_enable */
769                                          DPRINTF(DPRINTF_HEADER, "reduced_resolution_enable %i", dec->reduced_resolution_enable);                                          DPRINTF(XVID_DEBUG_HEADER, "reduced_resolution_enable %i\n", dec->reduced_resolution_enable);
770                                  }                                  }
771                                  else                                  else
772                                  {                                  {
# Line 785  Line 777 
777                                  dec->scalability = BitstreamGetBit(bs); /* scalability */                                  dec->scalability = BitstreamGetBit(bs); /* scalability */
778                                  if (dec->scalability)                                  if (dec->scalability)
779                                  {                                  {
780                                          DPRINTF(DPRINTF_ERROR, "scalability not supported");                                          DPRINTF(XVID_DEBUG_ERROR, "scalability not supported\n");
781                                          BitstreamSkip(bs, 1);   /* hierarchy_type */                                          BitstreamSkip(bs, 1);   /* hierarchy_type */
782                                          BitstreamSkip(bs, 4);   /* ref_layer_id */                                          BitstreamSkip(bs, 4);   /* ref_layer_id */
783                                          BitstreamSkip(bs, 1);   /* ref_layer_sampling_direc */                                          BitstreamSkip(bs, 1);   /* ref_layer_sampling_direc */
# Line 804  Line 796 
796                                          }                                          }
797                                          return -1;                                          return -1;
798                                  }                                  }
799                          } else                          // dec->shape == BINARY_ONLY                          } else                          /* dec->shape == BINARY_ONLY */
800                          {                          {
801                                  if (vol_ver_id != 1) {                                  if (vol_ver_id != 1) {
802                                          dec->scalability = BitstreamGetBit(bs); /* scalability */                                          dec->scalability = BitstreamGetBit(bs); /* scalability */
803                                          if (dec->scalability)                                          if (dec->scalability)
804                                          {                                          {
805                                                  DPRINTF(DPRINTF_ERROR, "scalability not supported");                                                  DPRINTF(XVID_DEBUG_ERROR, "scalability not supported\n");
806                                                  BitstreamSkip(bs, 4);   /* ref_layer_id */                                                  BitstreamSkip(bs, 4);   /* ref_layer_id */
807                                                  BitstreamSkip(bs, 5);   /* hor_sampling_factor_n */                                                  BitstreamSkip(bs, 5);   /* hor_sampling_factor_n */
808                                                  BitstreamSkip(bs, 5);   /* hor_sampling_factor_m */                                                  BitstreamSkip(bs, 5);   /* hor_sampling_factor_m */
# Line 819  Line 811 
811                                                  return -1;                                                  return -1;
812                                          }                                          }
813                                  }                                  }
814                                  BitstreamSkip(bs, 1);   // resync_marker_disable                                  BitstreamSkip(bs, 1);   /* resync_marker_disable */
815    
816                          }                          }
817    
# Line 827  Line 819 
819    
820                  } else if (start_code == GRPOFVOP_START_CODE) {                  } else if (start_code == GRPOFVOP_START_CODE) {
821    
822                          DPRINTF(DPRINTF_STARTCODE, "<group_of_vop>");                          DPRINTF(XVID_DEBUG_STARTCODE, "<group_of_vop>\n");
823    
824                          BitstreamSkip(bs, 32);                          BitstreamSkip(bs, 32);
825                          {                          {
# Line 838  Line 830 
830                                  READ_MARKER();                                  READ_MARKER();
831                                  seconds = BitstreamGetBits(bs, 6);                                  seconds = BitstreamGetBits(bs, 6);
832    
833                                  DPRINTF(DPRINTF_HEADER, "time %ih%im%is", hours,minutes,seconds);                                  DPRINTF(XVID_DEBUG_HEADER, "time %ih%im%is\n", hours,minutes,seconds);
834                          }                          }
835                          BitstreamSkip(bs, 1);   // closed_gov                          BitstreamSkip(bs, 1);   /* closed_gov */
836                          BitstreamSkip(bs, 1);   // broken_link                          BitstreamSkip(bs, 1);   /* broken_link */
837    
838                  } else if (start_code == VOP_START_CODE) {                  } else if (start_code == VOP_START_CODE) {
839    
840                          DPRINTF(DPRINTF_STARTCODE, "<vop>");                          DPRINTF(XVID_DEBUG_STARTCODE, "<vop>\n");
841    
842                          BitstreamSkip(bs, 32);  // vop_start_code                          BitstreamSkip(bs, 32);  /* vop_start_code */
843    
844                          coding_type = BitstreamGetBits(bs, 2);  // vop_coding_type                          coding_type = BitstreamGetBits(bs, 2);  /* vop_coding_type */
845                          DPRINTF(DPRINTF_HEADER, "coding_type %i", coding_type);                          DPRINTF(XVID_DEBUG_HEADER, "coding_type %i\n", coding_type);
846    
847  // *************************** for decode B-frame time ***********************                          /*********************** for decode B-frame time ***********************/
848                          while (BitstreamGetBit(bs) != 0)        // time_base                          while (BitstreamGetBit(bs) != 0)        /* time_base */
849                                  time_incr++;                                  time_incr++;
850    
851                          READ_MARKER();                          READ_MARKER();
852    
853                          if (dec->time_inc_bits) {                          if (dec->time_inc_bits) {
854                                  time_increment = (BitstreamGetBits(bs, dec->time_inc_bits));    // vop_time_increment                                  time_increment = (BitstreamGetBits(bs, dec->time_inc_bits));    /* vop_time_increment */
855                          }                          }
856    
857                          DPRINTF(DPRINTF_HEADER, "time_base %i", time_incr);                          DPRINTF(XVID_DEBUG_HEADER, "time_base %i\n", time_incr);
858                          DPRINTF(DPRINTF_HEADER, "time_increment %i", time_increment);                          DPRINTF(XVID_DEBUG_HEADER, "time_increment %i\n", time_increment);
859    
860                          DPRINTF(DPRINTF_TIMECODE, "%c %i:%i",                          DPRINTF(XVID_DEBUG_TIMECODE, "%c %i:%i\n",
861                                  coding_type == I_VOP ? 'I' : coding_type == P_VOP ? 'P' : coding_type == B_VOP ? 'B' : 'S',                                  coding_type == I_VOP ? 'I' : coding_type == P_VOP ? 'P' : coding_type == B_VOP ? 'B' : 'S',
862                                  time_incr, time_increment);                                  time_incr, time_increment);
863    
# Line 874  Line 866 
866                                  dec->time_base += time_incr;                                  dec->time_base += time_incr;
867                                  dec->time = time_increment;                                  dec->time = time_increment;
868    
869  /*                                      dec->time_base * dec->time_inc_resolution +  #if 0
870                                            dec->time_base * dec->time_inc_resolution +
871                                          time_increment;                                          time_increment;
872  */                              dec->time_pp = (uint32_t)  #endif
873                                            dec->time_pp = (uint32_t)
874                                          (dec->time_inc_resolution + dec->time - dec->last_non_b_time)%dec->time_inc_resolution;                                          (dec->time_inc_resolution + dec->time - dec->last_non_b_time)%dec->time_inc_resolution;
875                                  dec->last_non_b_time = dec->time;                                  dec->last_non_b_time = dec->time;
876                          } else {                          } else {
877                                  dec->time = time_increment;                                  dec->time = time_increment;
878  /*  #if 0
879                                          (dec->last_time_base +                                          (dec->last_time_base +
880                                           time_incr) * dec->time_inc_resolution + time_increment;                                           time_incr) * dec->time_inc_resolution + time_increment;
881  */  #endif
882                                  dec->time_bp = (uint32_t)                                  dec->time_bp = (uint32_t)
883                                          (dec->time_inc_resolution + dec->last_non_b_time - dec->time)%dec->time_inc_resolution;                                          (dec->time_inc_resolution + dec->last_non_b_time - dec->time)%dec->time_inc_resolution;
884                          }                          }
885                          DPRINTF(DPRINTF_HEADER,"time_pp=%i", dec->time_pp);                          DPRINTF(XVID_DEBUG_HEADER,"time_pp=%i\n", dec->time_pp);
886                          DPRINTF(DPRINTF_HEADER,"time_bp=%i", dec->time_bp);                          DPRINTF(XVID_DEBUG_HEADER,"time_bp=%i\n", dec->time_bp);
887    
888                          READ_MARKER();                          READ_MARKER();
889    
890                          if (!BitstreamGetBit(bs))       // vop_coded                          if (!BitstreamGetBit(bs))       /* vop_coded */
891                          {                          {
892                                  DPRINTF(DPRINTF_HEADER, "vop_coded==false");                                  DPRINTF(XVID_DEBUG_HEADER, "vop_coded==false\n");
893                                  return N_VOP;                                  return N_VOP;
894                          }                          }
895    
# Line 905  Line 899 
899                                  int vop_id_for_prediction;                                  int vop_id_for_prediction;
900    
901                                  vop_id = BitstreamGetBits(bs, MIN(dec->time_inc_bits + 3, 15));                                  vop_id = BitstreamGetBits(bs, MIN(dec->time_inc_bits + 3, 15));
902                                  DPRINTF(DPRINTF_HEADER, "vop_id %i", vop_id);                                  DPRINTF(XVID_DEBUG_HEADER, "vop_id %i\n", vop_id);
903                                  if (BitstreamGetBit(bs))        /* vop_id_for_prediction_indication */                                  if (BitstreamGetBit(bs))        /* vop_id_for_prediction_indication */
904                                  {                                  {
905                                          vop_id_for_prediction = BitstreamGetBits(bs, MIN(dec->time_inc_bits + 3, 15));                                          vop_id_for_prediction = BitstreamGetBits(bs, MIN(dec->time_inc_bits + 3, 15));
906                                          DPRINTF(DPRINTF_HEADER, "vop_id_for_prediction %i", vop_id_for_prediction);                                          DPRINTF(XVID_DEBUG_HEADER, "vop_id_for_prediction %i\n", vop_id_for_prediction);
907                                  }                                  }
908                                  READ_MARKER();                                  READ_MARKER();
909                          }                          }
910    
911    
912    
913                          // fix a little bug by MinChen <chenm002@163.com>                          /* fix a little bug by MinChen <chenm002@163.com> */
914                          if ((dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) &&                          if ((dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) &&
915                                  ( (coding_type == P_VOP) || (coding_type == S_VOP && dec->sprite_enable == SPRITE_GMC) ) ) {                                  ( (coding_type == P_VOP) || (coding_type == S_VOP && dec->sprite_enable == SPRITE_GMC) ) ) {
916                                  *rounding = BitstreamGetBit(bs);        // rounding_type                                  *rounding = BitstreamGetBit(bs);        /* rounding_type */
917                                  DPRINTF(DPRINTF_HEADER, "rounding %i", *rounding);                                  DPRINTF(XVID_DEBUG_HEADER, "rounding %i\n", *rounding);
918                          }                          }
919    
920                          if (dec->reduced_resolution_enable &&                          if (dec->reduced_resolution_enable &&
# Line 928  Line 922 
922                                  (coding_type == P_VOP || coding_type == I_VOP)) {                                  (coding_type == P_VOP || coding_type == I_VOP)) {
923    
924                                  *reduced_resolution = BitstreamGetBit(bs);                                  *reduced_resolution = BitstreamGetBit(bs);
925                                  DPRINTF(DPRINTF_HEADER, "reduced_resolution %i", *reduced_resolution);                                  DPRINTF(XVID_DEBUG_HEADER, "reduced_resolution %i\n", *reduced_resolution);
926                          }                          }
927                          else                          else
928                          {                          {
# Line 950  Line 944 
944                                          vert_mc_ref = BitstreamGetBits(bs, 13);                                          vert_mc_ref = BitstreamGetBits(bs, 13);
945                                          READ_MARKER();                                          READ_MARKER();
946    
947                                          DPRINTF(DPRINTF_HEADER, "width %i", width);                                          DPRINTF(XVID_DEBUG_HEADER, "width %i\n", width);
948                                          DPRINTF(DPRINTF_HEADER, "height %i", height);                                          DPRINTF(XVID_DEBUG_HEADER, "height %i\n", height);
949                                          DPRINTF(DPRINTF_HEADER, "horiz_mc_ref %i", horiz_mc_ref);                                          DPRINTF(XVID_DEBUG_HEADER, "horiz_mc_ref %i\n", horiz_mc_ref);
950                                          DPRINTF(DPRINTF_HEADER, "vert_mc_ref %i", vert_mc_ref);                                          DPRINTF(XVID_DEBUG_HEADER, "vert_mc_ref %i\n", vert_mc_ref);
951                                  }                                  }
952    
953                                  BitstreamSkip(bs, 1);   // change_conv_ratio_disable                                  BitstreamSkip(bs, 1);   /* change_conv_ratio_disable */
954                                  if (BitstreamGetBit(bs))        // vop_constant_alpha                                  if (BitstreamGetBit(bs))        /* vop_constant_alpha */
955                                  {                                  {
956                                          BitstreamSkip(bs, 8);   // vop_constant_alpha_value                                          BitstreamSkip(bs, 8);   /* vop_constant_alpha_value */
957                                  }                                  }
958                          }                          }
959    
# Line 970  Line 964 
964                                          read_vop_complexity_estimation_header(bs, dec, coding_type);                                          read_vop_complexity_estimation_header(bs, dec, coding_type);
965                                  }                                  }
966    
967                                  // intra_dc_vlc_threshold                                  /* intra_dc_vlc_threshold */
968                                  *intra_dc_threshold =                                  *intra_dc_threshold =
969                                          intra_dc_threshold_table[BitstreamGetBits(bs, 3)];                                          intra_dc_threshold_table[BitstreamGetBits(bs, 3)];
970    
# Line 979  Line 973 
973    
974                                  if (dec->interlacing) {                                  if (dec->interlacing) {
975                                          dec->top_field_first = BitstreamGetBit(bs);                                          dec->top_field_first = BitstreamGetBit(bs);
976                                          DPRINTF(DPRINTF_HEADER, "interlace top_field_first %i", dec->top_field_first);                                          DPRINTF(XVID_DEBUG_HEADER, "interlace top_field_first %i\n", dec->top_field_first);
977                                          dec->alternate_vertical_scan = BitstreamGetBit(bs);                                          dec->alternate_vertical_scan = BitstreamGetBit(bs);
978                                          DPRINTF(DPRINTF_HEADER, "interlace alternate_vertical_scan %i", dec->alternate_vertical_scan);                                          DPRINTF(XVID_DEBUG_HEADER, "interlace alternate_vertical_scan %i\n", dec->alternate_vertical_scan);
979    
980                                  }                                  }
981                          }                          }
# Line 1015  Line 1009 
1009                                          gmc_warp->duv[i].x = x;                                          gmc_warp->duv[i].x = x;
1010                                          gmc_warp->duv[i].y = y;                                          gmc_warp->duv[i].y = y;
1011    
1012                                          DPRINTF(DPRINTF_HEADER,"sprite_warping_point[%i] xy=(%i,%i)", i, x, y);                                          DPRINTF(XVID_DEBUG_HEADER,"sprite_warping_point[%i] xy=(%i,%i)\n", i, x, y);
1013                                  }                                  }
1014    
1015                                  if (dec->sprite_brightness_change)                                  if (dec->sprite_brightness_change)
1016                                  {                                  {
1017                                          // XXX: brightness_change_factor()                                          /* XXX: brightness_change_factor() */
1018                                  }                                  }
1019                                  if (dec->sprite_enable == SPRITE_STATIC)                                  if (dec->sprite_enable == SPRITE_STATIC)
1020                                  {                                  {
1021                                          // XXX: todo                                          /* XXX: todo */
1022                                  }                                  }
1023    
1024                          }                          }
1025    
1026                          if ((*quant = BitstreamGetBits(bs, dec->quant_bits)) < 1)       // vop_quant                          if ((*quant = BitstreamGetBits(bs, dec->quant_bits)) < 1)       /* vop_quant */
1027                                  *quant = 1;                                  *quant = 1;
1028                          DPRINTF(DPRINTF_HEADER, "quant %i", *quant);                          DPRINTF(XVID_DEBUG_HEADER, "quant %i\n", *quant);
1029    
1030                          if (coding_type != I_VOP) {                          if (coding_type != I_VOP) {
1031                                  *fcode_forward = BitstreamGetBits(bs, 3);       // fcode_forward                                  *fcode_forward = BitstreamGetBits(bs, 3);       /* fcode_forward */
1032                                  DPRINTF(DPRINTF_HEADER, "fcode_forward %i", *fcode_forward);                                  DPRINTF(XVID_DEBUG_HEADER, "fcode_forward %i\n", *fcode_forward);
1033                          }                          }
1034    
1035                          if (coding_type == B_VOP) {                          if (coding_type == B_VOP) {
1036                                  *fcode_backward = BitstreamGetBits(bs, 3);      // fcode_backward                                  *fcode_backward = BitstreamGetBits(bs, 3);      /* fcode_backward */
1037                                  DPRINTF(DPRINTF_HEADER, "fcode_backward %i", *fcode_backward);                                  DPRINTF(XVID_DEBUG_HEADER, "fcode_backward %i\n", *fcode_backward);
1038                          }                          }
1039                          if (!dec->scalability) {                          if (!dec->scalability) {
1040                                  if ((dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) &&                                  if ((dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) &&
1041                                          (coding_type != I_VOP)) {                                          (coding_type != I_VOP)) {
1042                                          BitstreamSkip(bs, 1);   // vop_shape_coding_type                                          BitstreamSkip(bs, 1);   /* vop_shape_coding_type */
1043                                  }                                  }
1044                          }                          }
1045                          return coding_type;                          return coding_type;
# Line 1055  Line 1049 
1049                      int i, version, build;                      int i, version, build;
1050                          char packed;                          char packed;
1051    
1052                          BitstreamSkip(bs, 32);  // user_data_start_code                          BitstreamSkip(bs, 32);  /* user_data_start_code */
1053    
1054                          tmp[0] = BitstreamShowBits(bs, 8);                          tmp[0] = BitstreamShowBits(bs, 8);
1055    
# Line 1068  Line 1062 
1062                                  BitstreamSkip(bs, 8);                                  BitstreamSkip(bs, 8);
1063                          }                          }
1064    
1065                          DPRINTF(DPRINTF_STARTCODE, "<user_data>: %s\n", tmp);                          DPRINTF(XVID_DEBUG_STARTCODE, "<user_data>: %s\n", tmp);
1066    
1067                      /* divx detection */                      /* divx detection */
1068                          i = sscanf(tmp, "DivX%dBuild%d%c", &version, &build, &packed);                          i = sscanf(tmp, "DivX%dBuild%d%c", &version, &build, &packed);
# Line 1078  Line 1072 
1072                          if (i >= 2)                          if (i >= 2)
1073                          {                          {
1074                                  dec->packed_mode = (i == 3 && packed == 'p');                                  dec->packed_mode = (i == 3 && packed == 'p');
1075                                  DPRINTF(DPRINTF_HEADER, "divx version=%i, build=%i packed=%i",                                  DPRINTF(XVID_DEBUG_HEADER, "divx version=%i, build=%i packed=%i\n",
1076                                                  version, build, dec->packed_mode);                                                  version, build, dec->packed_mode);
1077                          }                          }
1078    
1079                  } else                                  // start_code == ?                  } else                                  /* start_code == ? */
1080                  {                  {
1081                          if (BitstreamShowBits(bs, 24) == 0x000001) {                          if (BitstreamShowBits(bs, 24) == 0x000001) {
1082                                  DPRINTF(DPRINTF_STARTCODE, "<unknown: %x>", BitstreamShowBits(bs, 32));                                  DPRINTF(XVID_DEBUG_STARTCODE, "<unknown: %x>\n", BitstreamShowBits(bs, 32));
1083                          }                          }
1084                          BitstreamSkip(bs, 8);                          BitstreamSkip(bs, 8);
1085                  }                  }
1086          }          }
1087          while ((BitstreamPos(bs) >> 3) < bs->length);          while ((BitstreamPos(bs) >> 3) < bs->length);
1088    
1089          //DPRINTF("*** WARNING: no vop_start_code found");  #if 0
1090            DPRINTF("*** WARNING: no vop_start_code found");
1091    #endif
1092          return -1;                                      /* ignore it */          return -1;                                      /* ignore it */
1093  }  }
1094    
# Line 1123  Line 1119 
1119  */  */
1120  void  void
1121  BitstreamWriteVolHeader(Bitstream * const bs,  BitstreamWriteVolHeader(Bitstream * const bs,
1122                                                  const MBParam * pParam,                                                  const MBParam * pParam)
                                                 const FRAMEINFO * const frame)  
1123  {  {
1124          static const unsigned int vo_id = 0;          static const unsigned int vo_id = 0;
1125          static const unsigned int vol_id = 0;          static const unsigned int vol_id = 0;
1126          int vol_ver_id=1;          int vol_ver_id=1;
1127          int profile = 0x03;     /* simple profile/level 3 */      int vol_type_ind=VIDOBJLAY_TYPE_SIMPLE;
1128    
1129          if ( pParam->m_quarterpel ||  (frame->global_flags & XVID_GMC) ||          if ( (pParam->vol_flags & XVID_VOL_QUARTERPEL) ||
1130                   (pParam->global & XVID_GLOBAL_REDUCED))           (pParam->vol_flags & XVID_VOL_GMC) ||
1131                     (pParam->vol_flags & XVID_VOL_REDUCED_ENABLE))
1132                  vol_ver_id = 2;                  vol_ver_id = 2;
1133    
1134          if ((pParam->global & XVID_GLOBAL_REDUCED))      if ((pParam->vol_flags & XVID_VOL_REDUCED_ENABLE)) {
1135                  profile = 0x93; /* advanced realtime simple profile/level 3 */          vol_type_ind = VIDOBJLAY_TYPE_ART_SIMPLE;
1136        }
1137    
1138            if ((pParam->vol_flags & XVID_VOL_QUARTERPEL) ||
1139            (pParam->vol_flags & XVID_VOL_GMC)) {
1140            vol_type_ind = VIDOBJLAY_TYPE_ASP;
1141        }
1142    
1143          if (pParam->m_quarterpel ||  (frame->global_flags & XVID_GMC))          /* visual_object_sequence_start_code */
1144                  profile = 0xf3; /* advanced simple profile/level 2 */  #if 0
1145            BitstreamPad(bs);
1146    #endif
1147    
1148          // visual_object_sequence_start_code          /*
1149  //      BitstreamPad(bs);           * no padding here, anymore. You have to make sure that you are
1150  /* no padding here, anymore. You have to make sure that you are           * byte aligned, and that always 1-8 padding bits have been written
1151     byte aligned, and that always 1-8 padding bits have been written */           */
1152    
1153        if (pParam->profile) {
1154          BitstreamPutBits(bs, VISOBJSEQ_START_CODE, 32);          BitstreamPutBits(bs, VISOBJSEQ_START_CODE, 32);
1155          BitstreamPutBits(bs, profile, 8);              BitstreamPutBits(bs, pParam->profile, 8);
1156        }
1157    
1158          // visual_object_start_code          /* visual_object_start_code */
1159          BitstreamPad(bs);          BitstreamPad(bs);
1160          BitstreamPutBits(bs, VISOBJ_START_CODE, 32);          BitstreamPutBits(bs, VISOBJ_START_CODE, 32);
1161          BitstreamPutBits(bs, 0, 1);             // is_visual_object_identifier          BitstreamPutBits(bs, 0, 1);             /* is_visual_object_identifier */
1162          BitstreamPutBits(bs, VISOBJ_TYPE_VIDEO, 4);             // visual_object_type          BitstreamPutBits(bs, VISOBJ_TYPE_VIDEO, 4);             /* visual_object_type */
1163    
1164          // video object_start_code & vo_id          /* video object_start_code & vo_id */
1165          BitstreamPad(bs);          BitstreamPad(bs);
1166          BitstreamPutBits(bs, VIDOBJ_START_CODE|(vo_id&0x5), 32);          BitstreamPutBits(bs, VIDOBJ_START_CODE|(vo_id&0x5), 32);
1167    
1168          // video_object_layer_start_code & vol_id          /* video_object_layer_start_code & vol_id */
1169          BitstreamPad(bs);          BitstreamPad(bs);
1170          BitstreamPutBits(bs, VIDOBJLAY_START_CODE|(vol_id&0x4), 32);          BitstreamPutBits(bs, VIDOBJLAY_START_CODE|(vol_id&0x4), 32);
1171    
1172          BitstreamPutBit(bs, 0);         // random_accessible_vol          BitstreamPutBit(bs, 0);         /* random_accessible_vol */
1173          BitstreamPutBits(bs, 0, 8);     // video_object_type_indication          BitstreamPutBits(bs, vol_type_ind, 8);  /* video_object_type_indication */
1174    
1175          if (vol_ver_id == 1)          if (vol_ver_id == 1)
1176          {          {
1177                  BitstreamPutBit(bs, 0);                         // is_object_layer_identified (0=not given)                  BitstreamPutBit(bs, 0);                         /* is_object_layer_identified (0=not given) */
1178          }          }
1179          else          else
1180          {          {
1181                  BitstreamPutBit(bs, 1);         // is_object_layer_identified                  BitstreamPutBit(bs, 1);         /* is_object_layer_identified */
1182                  BitstreamPutBits(bs, vol_ver_id, 4);    // vol_ver_id == 2                  BitstreamPutBits(bs, vol_ver_id, 4);    /* vol_ver_id == 2 */
1183                  BitstreamPutBits(bs, 4, 3); // vol_ver_priority (1==lowest, 7==highest) ??                  BitstreamPutBits(bs, 4, 3); /* vol_ver_priority (1==lowest, 7==highest) ?? */
1184          }          }
1185    
1186          BitstreamPutBits(bs, 1, 4);     // aspect_ratio_info (1=1:1)          BitstreamPutBits(bs, 1, 4);     /* aspect_ratio_info (1=1:1) */
1187    
1188          BitstreamPutBit(bs, 1); // vol_control_parameters          BitstreamPutBit(bs, 1); /* vol_control_parameters */
1189          BitstreamPutBits(bs, 1, 2);     // chroma_format 1="4:2:0"          BitstreamPutBits(bs, 1, 2);     /* chroma_format 1="4:2:0" */
1190    
1191          if (pParam->max_bframes > 0) {          if (pParam->max_bframes > 0) {
1192                  BitstreamPutBit(bs, 0); // low_delay                  BitstreamPutBit(bs, 0); /* low_delay */
1193          } else          } else
1194          {          {
1195                  BitstreamPutBit(bs, 1); // low_delay                  BitstreamPutBit(bs, 1); /* low_delay */
1196          }          }
1197          BitstreamPutBit(bs, 0); // vbv_parameters (0=not given)          BitstreamPutBit(bs, 0); /* vbv_parameters (0=not given) */
1198    
1199          BitstreamPutBits(bs, 0, 2);     // video_object_layer_shape (0=rectangular)          BitstreamPutBits(bs, 0, 2);     /* video_object_layer_shape (0=rectangular) */
1200    
1201          WRITE_MARKER();          WRITE_MARKER();
1202    
1203          /* time_inc_resolution; ignored by current decore versions          /*
1204             eg. 2fps     res=2       inc=1           * time_inc_resolution; ignored by current decore versions
1205             25fps        res=25      inc=1           * eg. 2fps     res=2       inc=1
1206             29.97fps res=30000   inc=1001           *     25fps    res=25      inc=1
1207             *     29.97fps res=30000   inc=1001
1208           */           */
1209          BitstreamPutBits(bs, pParam->fbase, 16);          BitstreamPutBits(bs, pParam->fbase, 16);
1210    
1211          WRITE_MARKER();          WRITE_MARKER();
1212    
1213          BitstreamPutBit(bs, 1);         // fixed_vop_rate = 1      if (pParam->fincr>0) {
1214          BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase));    // fixed_vop_time_increment              BitstreamPutBit(bs, 1);             /* fixed_vop_rate = 1 */
1215                BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase));        /* fixed_vop_time_increment */
1216        }else{
1217            BitstreamPutBit(bs, 0);         /* fixed_vop_rate = 0 */
1218        }
1219    
1220          WRITE_MARKER();          WRITE_MARKER();
1221          BitstreamPutBits(bs, pParam->width, 13);        // width          BitstreamPutBits(bs, pParam->width, 13);        /* width */
1222          WRITE_MARKER();          WRITE_MARKER();
1223          BitstreamPutBits(bs, pParam->height, 13);       // height          BitstreamPutBits(bs, pParam->height, 13);       /* height */
1224          WRITE_MARKER();          WRITE_MARKER();
1225    
1226          BitstreamPutBit(bs, frame->global_flags & XVID_INTERLACING);    // interlace          BitstreamPutBit(bs, pParam->vol_flags & XVID_VOL_INTERLACING);  /* interlace */
1227          BitstreamPutBit(bs, 1);         // obmc_disable (overlapped block motion compensation)          BitstreamPutBit(bs, 1);         /* obmc_disable (overlapped block motion compensation) */
1228    
1229          if (vol_ver_id != 1)          if (vol_ver_id != 1)
1230          {       if (frame->global_flags & XVID_GMC)          {       if ((pParam->vol_flags & XVID_VOL_GMC))
1231                  {       BitstreamPutBits(bs, 2, 2);             // sprite_enable=='GMC'                  {       BitstreamPutBits(bs, 2, 2);             /* sprite_enable=='GMC' */
1232                          BitstreamPutBits(bs, 2, 6);             // no_of_sprite_warping_points                          BitstreamPutBits(bs, 2, 6);             /* no_of_sprite_warping_points */
1233                          BitstreamPutBits(bs, 3, 2);             // sprite_warping_accuracy 0==1/2, 1=1/4, 2=1/8, 3=1/16                          BitstreamPutBits(bs, 3, 2);             /* sprite_warping_accuracy 0==1/2, 1=1/4, 2=1/8, 3=1/16 */
1234                          BitstreamPutBit(bs, 0);                 // sprite_brightness_change (not supported)                          BitstreamPutBit(bs, 0);                 /* sprite_brightness_change (not supported) */
1235    
1236  /* currently we use no_of_sprite_warping_points==2, sprite_warping_accuracy==3                          /*
1237     for DivX5 compatability */                           * currently we use no_of_sprite_warping_points==2, sprite_warping_accuracy==3
1238                             * for DivX5 compatability
1239                             */
1240    
1241                  } else                  } else
1242                          BitstreamPutBits(bs, 0, 2);             // sprite_enable==off                          BitstreamPutBits(bs, 0, 2);             /* sprite_enable==off */
1243          }          }
1244          else          else
1245                  BitstreamPutBit(bs, 0);         // sprite_enable==off                  BitstreamPutBit(bs, 0);         /* sprite_enable==off */
1246    
1247          BitstreamPutBit(bs, 0);         // not_8_bit          BitstreamPutBit(bs, 0);         /* not_8_bit */
1248    
1249          // quant_type   0=h.263  1=mpeg4(quantizer tables)          /* quant_type   0=h.263  1=mpeg4(quantizer tables) */
1250          BitstreamPutBit(bs, pParam->m_quant_type);          BitstreamPutBit(bs, pParam->vol_flags & XVID_VOL_MPEGQUANT);
1251    
1252          if (pParam->m_quant_type) {          if ((pParam->vol_flags & XVID_VOL_MPEGQUANT)) {
1253                  BitstreamPutBit(bs, get_intra_matrix_status()); // load_intra_quant_mat                  BitstreamPutBit(bs, get_intra_matrix_status()); /* load_intra_quant_mat */
1254                  if (get_intra_matrix_status()) {                  if (get_intra_matrix_status()) {
1255                          bs_put_matrix(bs, get_intra_matrix());                          bs_put_matrix(bs, get_intra_matrix());
1256                  }                  }
1257    
1258                  BitstreamPutBit(bs, get_inter_matrix_status()); // load_inter_quant_mat                  BitstreamPutBit(bs, get_inter_matrix_status()); /* load_inter_quant_mat */
1259                  if (get_inter_matrix_status()) {                  if (get_inter_matrix_status()) {
1260                          bs_put_matrix(bs, get_inter_matrix());                          bs_put_matrix(bs, get_inter_matrix());
1261                  }                  }
# Line 1250  Line 1263 
1263          }          }
1264    
1265          if (vol_ver_id != 1) {          if (vol_ver_id != 1) {
1266                  if (pParam->m_quarterpel)                  if ((pParam->vol_flags & XVID_VOL_QUARTERPEL))
1267                          BitstreamPutBit(bs, 1);         //  quarterpel                          BitstreamPutBit(bs, 1);         /* quarterpel  */
1268                  else                  else
1269                          BitstreamPutBit(bs, 0);         // no quarterpel                          BitstreamPutBit(bs, 0);         /* no quarterpel */
1270          }          }
1271    
1272          BitstreamPutBit(bs, 1);         // complexity_estimation_disable          BitstreamPutBit(bs, 1);         /* complexity_estimation_disable */
1273          BitstreamPutBit(bs, 1);         // resync_marker_disable          BitstreamPutBit(bs, 1);         /* resync_marker_disable */
1274          BitstreamPutBit(bs, 0);         // data_partitioned          BitstreamPutBit(bs, 0);         /* data_partitioned */
1275    
1276          if (vol_ver_id != 1)          if (vol_ver_id != 1)
1277          {          {
1278                  BitstreamPutBit(bs, 0);         // newpred_enable                  BitstreamPutBit(bs, 0);         /* newpred_enable */
1279    
1280                  BitstreamPutBit(bs, (pParam->global & XVID_GLOBAL_REDUCED)?1:0);                  BitstreamPutBit(bs, (pParam->vol_flags & XVID_VOL_REDUCED_ENABLE)?1:0);
1281                                                                          /* reduced_resolution_vop_enabled */                                                                          /* reduced_resolution_vop_enabled */
1282          }          }
1283    
1284          BitstreamPutBit(bs, 0);         // scalability          BitstreamPutBit(bs, 0);         /* scalability */
1285    
1286          /* fake divx5 id, to ensure compatibility with divx5 decoder */          /* fake divx5 id, to ensure compatibility with divx5 decoder */
1287  #define DIVX5_ID "DivX501b481p"  #define DIVX5_ID "DivX000b000p"
1288          if (pParam->max_bframes > 0 && (pParam->global & XVID_GLOBAL_PACKED)) {          if (pParam->max_bframes > 0 && (pParam->global_flags & XVID_GLOBAL_PACKED)) {
1289                  BitstreamWriteUserData(bs, DIVX5_ID, strlen(DIVX5_ID));                  BitstreamWriteUserData(bs, DIVX5_ID, strlen(DIVX5_ID));
1290          }          }
1291    
# Line 1294  Line 1307 
1307  {  {
1308          uint32_t i;          uint32_t i;
1309    
1310  //      BitstreamPad(bs);  #if 0
1311  /* no padding here, anymore. You have to make sure that you are          BitstreamPad(bs);
1312     byte aligned, and that always 1-8 padding bits have been written */  #endif
1313    
1314            /*
1315             * no padding here, anymore. You have to make sure that you are
1316             * byte aligned, and that always 1-8 padding bits have been written
1317             */
1318    
1319          BitstreamPutBits(bs, VOP_START_CODE, 32);          BitstreamPutBits(bs, VOP_START_CODE, 32);
1320    
1321          BitstreamPutBits(bs, frame->coding_type, 2);          BitstreamPutBits(bs, frame->coding_type, 2);
1322          DPRINTF(DPRINTF_HEADER, "coding_type = %i", frame->coding_type);  #if 0
1323            DPRINTF(XVID_DEBUG_HEADER, "coding_type = %i\n", frame->coding_type);
1324    #endif
1325    
1326          for (i = 0; i < frame->seconds; i++) {          for (i = 0; i < frame->seconds; i++) {
1327                  BitstreamPutBit(bs, 1);                  BitstreamPutBit(bs, 1);
# Line 1310  Line 1330 
1330    
1331          WRITE_MARKER();          WRITE_MARKER();
1332    
1333          // time_increment: value=nth_of_sec, nbits = log2(resolution)          /* time_increment: value=nth_of_sec, nbits = log2(resolution) */
1334    
1335          BitstreamPutBits(bs, frame->ticks, log2bin(pParam->fbase));          BitstreamPutBits(bs, frame->ticks, log2bin(pParam->fbase));
1336          /*DPRINTF("[%i:%i] %c", frame->seconds, frame->ticks,  #if 0
1337                          frame->coding_type == I_VOP ? 'I' : frame->coding_type ==          DPRINTF("[%i:%i] %c",
1338                          P_VOP ? 'P' : 'B');*/                          frame->seconds, frame->ticks,
1339                            frame->coding_type == I_VOP ? 'I' :
1340                            frame->coding_type == P_VOP ? 'P' :
1341                            frame->coding_type == S_VOP ? 'S' :     'B');
1342    #endif
1343    
1344          WRITE_MARKER();          WRITE_MARKER();
1345    
# Line 1324  Line 1348 
1348                  return;                  return;
1349          }          }
1350    
1351          BitstreamPutBits(bs, 1, 1);     // vop_coded          BitstreamPutBits(bs, 1, 1);     /* vop_coded */
1352    
1353          if ( (frame->coding_type == P_VOP) || (frame->coding_type == S_VOP) )          if ( (frame->coding_type == P_VOP) || (frame->coding_type == S_VOP) )
1354                  BitstreamPutBits(bs, frame->rounding_type, 1);                  BitstreamPutBits(bs, frame->rounding_type, 1);
1355    
1356          if ((pParam->global & XVID_GLOBAL_REDUCED))          if ((frame->vol_flags & XVID_VOL_REDUCED_ENABLE))
1357                  BitstreamPutBit(bs, (frame->global_flags & XVID_REDUCED)?1:0);                  BitstreamPutBit(bs, (frame->vop_flags & XVID_VOP_REDUCED)?1:0);
1358    
1359          BitstreamPutBits(bs, 0, 3);     // intra_dc_vlc_threshold          BitstreamPutBits(bs, 0, 3);     /* intra_dc_vlc_threshold */
1360    
1361          if (frame->global_flags & XVID_INTERLACING) {          if ((frame->vol_flags & XVID_VOL_INTERLACING)) {
1362                  BitstreamPutBit(bs, (frame->global_flags & XVID_TOPFIELDFIRST));                  BitstreamPutBit(bs, (frame->vop_flags & XVID_VOP_TOPFIELDFIRST));
1363                  BitstreamPutBit(bs, (frame->global_flags & XVID_ALTERNATESCAN));                  BitstreamPutBit(bs, (frame->vop_flags & XVID_VOP_ALTERNATESCAN));
1364          }          }
1365    
1366          if (frame->coding_type == S_VOP) {          if (frame->coding_type == S_VOP) {
1367                  if (1)  {               // no_of_sprite_warping_points>=1 (we use 2!)                  if (1)  {               /* no_of_sprite_warping_points>=1 (we use 2!) */
1368                          int k;                          int k;
1369                          for (k=0;k<2;k++)                          for (k=0;k<2;k++)
1370                          {                          {
1371                                  bs_put_spritetrajectory(bs, frame->warp.duv[k].x ); // du[k]                                  bs_put_spritetrajectory(bs, frame->warp.duv[k].x ); /* du[k]  */
1372                                  WRITE_MARKER();                                  WRITE_MARKER();
1373    
1374                                  bs_put_spritetrajectory(bs, frame->warp.duv[k].y ); // dv[k]                                  bs_put_spritetrajectory(bs, frame->warp.duv[k].y ); /* dv[k]  */
1375                                  WRITE_MARKER();                                  WRITE_MARKER();
1376    
1377                          if (pParam->m_quarterpel)                          if ((frame->vol_flags & XVID_VOL_QUARTERPEL))
1378                          {                          {
1379                                  DPRINTF(DPRINTF_HEADER,"sprite_warping_point[%i] xy=(%i,%i) *QPEL*", k, frame->warp.duv[k].x/2, frame->warp.duv[k].y/2);                                  DPRINTF(XVID_DEBUG_HEADER,"sprite_warping_point[%i] xy=(%i,%i) *QPEL*\n", k, frame->warp.duv[k].x/2, frame->warp.duv[k].y/2);
1380                          }                          }
1381                          else                          else
1382                          {                          {
1383                                  DPRINTF(DPRINTF_HEADER,"sprite_warping_point[%i] xy=(%i,%i)", k, frame->warp.duv[k].x, frame->warp.duv[k].y);                                  DPRINTF(XVID_DEBUG_HEADER,"sprite_warping_point[%i] xy=(%i,%i)\n", k, frame->warp.duv[k].x, frame->warp.duv[k].y);
1384                          }                          }
1385                          }                          }
1386                  }                  }
1387          }          }
1388    
1389    
1390          DPRINTF(DPRINTF_HEADER, "quant = %i", frame->quant);  #if 0
1391            DPRINTF(XVID_DEBUG_HEADER, "quant = %i\n", frame->quant);
1392    #endif
1393    
1394          BitstreamPutBits(bs, frame->quant, 5);  // quantizer          BitstreamPutBits(bs, frame->quant, 5);  /* quantizer */
1395    
1396          if (frame->coding_type != I_VOP)          if (frame->coding_type != I_VOP)
1397                  BitstreamPutBits(bs, frame->fcode, 3);  // forward_fixed_code                  BitstreamPutBits(bs, frame->fcode, 3);  /* forward_fixed_code */
1398    
1399          if (frame->coding_type == B_VOP)          if (frame->coding_type == B_VOP)
1400                  BitstreamPutBits(bs, frame->bcode, 3);  // backward_fixed_code                  BitstreamPutBits(bs, frame->bcode, 3);  /* backward_fixed_code */
1401    
1402  }  }
1403    

Legend:
Removed from v.1.39  
changed lines
  Added in v.1.39.2.10

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