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

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

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

revision 248, Fri Jun 28 15:14:40 2002 UTC revision 252, Sun Jun 30 10:46:29 2002 UTC
# Line 125  Line 125 
125  // for BVOP addbits == max(fcode,bcode) - 1  // for BVOP addbits == max(fcode,bcode) - 1
126  // returns mbpos  // returns mbpos
127  int  int
128  read_video_packet_header(Bitstream *bs, int addbits)  read_video_packet_header(Bitstream *bs, const int addbits, int * quant)
129  {  {
130          int nbits;          int nbits;
131          int mbnum;          int mbnum;
         int quant;  
132          int hec;          int hec;
133    
134          nbits = NUMBITS_VP_RESYNC_MARKER;          nbits = NUMBITS_VP_RESYNC_MARKER + addbits;
135    
136          BitstreamSkip(bs, BitstreamNumBitsToByteAlign(bs));          BitstreamSkip(bs, BitstreamNumBitsToByteAlign(bs));
137          BitstreamSkip(bs, nbits);          BitstreamSkip(bs, nbits);
138    
139            DPRINTF(DPRINTF_STARTCODE, "<video_packet_header>");
140    
141          // if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) {          // if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) {
142                  // hec                  // hec
143                  // vop_width                  // vop_width
# Line 147  Line 148 
148          //}          //}
149    
150          mbnum = BitstreamGetBits(bs, 9);          mbnum = BitstreamGetBits(bs, 9);
151          //printf("mbnum %i    [%i,%i]\n", mbnum, mbnum % dec->mb_width, mbnum / dec->mb_width);          DPRINTF(DPRINTF_HEADER, "mbnum %i", mbnum);
152    
153          // if (dec->shape != VIDOBJLAY_SHAPE_BINARYONLY)          // if (dec->shape != VIDOBJLAY_SHAPE_BINARYONLY)
154          quant = BitstreamGetBits(bs, 5);          *quant = BitstreamGetBits(bs, 5);
155            DPRINTF(DPRINTF_HEADER, "quant %i", *quant);
156    
157          // if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR)          // if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR)
158          hec = BitstreamGetBit(bs);          hec = BitstreamGetBit(bs);
159            DPRINTF(DPRINTF_HEADER, "header_extension_code %i", hec);
160          // if (hec)          // if (hec)
161          //   .. decoder hec-header ...          //   .. decoder hec-header ...
162    
# Line 167  Line 170 
170  returns coding_type, or -1 if error  returns coding_type, or -1 if error
171  */  */
172    
173    #define VIDOBJ_START_CODE_MASK          0x0000001f
174    #define VIDOBJLAY_START_CODE_MASK       0x0000000f
175    
176  int  int
177  BitstreamReadHeaders(Bitstream * bs,  BitstreamReadHeaders(Bitstream * bs,
178                                           DECODER * dec,                                           DECODER * dec,
# Line 188  Line 194 
194                  start_code = BitstreamShowBits(bs, 32);                  start_code = BitstreamShowBits(bs, 32);
195    
196                  if (start_code == VISOBJSEQ_START_CODE) {                  if (start_code == VISOBJSEQ_START_CODE) {
197                          // DPRINTF("visual_object_sequence");  
198                            int profile;
199    
200                            DPRINTF(DPRINTF_STARTCODE, "<visual_object_sequence>");
201    
202                          BitstreamSkip(bs, 32);  // visual_object_sequence_start_code                          BitstreamSkip(bs, 32);  // visual_object_sequence_start_code
203                          BitstreamSkip(bs, 8);   // profile_and_level_indication                          profile = BitstreamGetBits(bs, 8);      // profile_and_level_indication
204    
205                            DPRINTF(DPRINTF_HEADER, "profile_and_level_indication %i", profile);
206    
207                  } else if (start_code == VISOBJSEQ_STOP_CODE) {                  } else if (start_code == VISOBJSEQ_STOP_CODE) {
208    
209                          BitstreamSkip(bs, 32);  // visual_object_sequence_stop_code                          BitstreamSkip(bs, 32);  // visual_object_sequence_stop_code
210    
211                            DPRINTF(DPRINTF_STARTCODE, "</visual_object_sequence>");
212    
213                  } else if (start_code == VISOBJ_START_CODE) {                  } else if (start_code == VISOBJ_START_CODE) {
214                          //DPRINTF("visual_object");  
215                            DPRINTF(DPRINTF_STARTCODE, "<visual_object>");
216    
217                          BitstreamSkip(bs, 32);  // visual_object_start_code                          BitstreamSkip(bs, 32);  // visual_object_start_code
218                          if (BitstreamGetBit(bs))        // is_visual_object_identified                          if (BitstreamGetBit(bs))        // is_visual_object_identified
219                          {                          {
220                                  vol_ver_id = BitstreamGetBits(bs, 4);   // visual_object_ver_id                                  vol_ver_id = BitstreamGetBits(bs, 4);   // visual_object_ver_id
221                                    DPRINTF(DPRINTF_HEADER,"ver_id %i", vol_ver_id);
222                                  BitstreamSkip(bs, 3);   // visual_object_priority                                  BitstreamSkip(bs, 3);   // visual_object_priority
223                          } else {                          } else {
224                                  vol_ver_id = 1;                                  vol_ver_id = 1;
# Line 206  Line 226 
226    
227                          if (BitstreamShowBits(bs, 4) != VISOBJ_TYPE_VIDEO)      // visual_object_type                          if (BitstreamShowBits(bs, 4) != VISOBJ_TYPE_VIDEO)      // visual_object_type
228                          {                          {
229                                  //DPRINTF("visual_object_type != video");                                  DPRINTF(DPRINTF_ERROR, "visual_object_type != video");
230                                  return -1;                                  return -1;
231                          }                          }
232                          BitstreamSkip(bs, 4);                          BitstreamSkip(bs, 4);
# Line 215  Line 235 
235    
236                          if (BitstreamGetBit(bs))        // video_signal_type                          if (BitstreamGetBit(bs))        // video_signal_type
237                          {                          {
238                                  //DPRINTF("+ video_signal_type");                                  DPRINTF(DPRINTF_HEADER,"+ video_signal_type");
239                                  BitstreamSkip(bs, 3);   // video_format                                  BitstreamSkip(bs, 3);   // video_format
240                                  BitstreamSkip(bs, 1);   // video_range                                  BitstreamSkip(bs, 1);   // video_range
241                                  if (BitstreamGetBit(bs))        // color_description                                  if (BitstreamGetBit(bs))        // color_description
242                                  {                                  {
243                                          //DPRINTF("+ color_description");                                          DPRINTF(DPRINTF_HEADER,"+ color_description");
244                                          BitstreamSkip(bs, 8);   // color_primaries                                          BitstreamSkip(bs, 8);   // color_primaries
245                                          BitstreamSkip(bs, 8);   // transfer_characteristics                                          BitstreamSkip(bs, 8);   // transfer_characteristics
246                                          BitstreamSkip(bs, 8);   // matrix_coefficients                                          BitstreamSkip(bs, 8);   // matrix_coefficients
247                                  }                                  }
248                          }                          }
249                  } else if ((start_code & ~0x1f) == VIDOBJ_START_CODE) {                  } else if ((start_code & ~VIDOBJ_START_CODE_MASK) == VIDOBJ_START_CODE) {
250    
251                            DPRINTF(DPRINTF_STARTCODE, "<video_object>");
252                            DPRINTF(DPRINTF_HEADER, "vo id %i", start_code & VIDOBJ_START_CODE_MASK);
253    
254                          BitstreamSkip(bs, 32);  // video_object_start_code                          BitstreamSkip(bs, 32);  // video_object_start_code
255                  } else if ((start_code & ~0xf) == VIDOBJLAY_START_CODE) {  
256                          //DPRINTF("video_object_layer");                  } else if ((start_code & ~VIDOBJLAY_START_CODE_MASK) == VIDOBJLAY_START_CODE) {
257    
258                            DPRINTF(DPRINTF_STARTCODE, "<video_object_layer>");
259                            DPRINTF(DPRINTF_HEADER, "vol id %i", start_code & VIDOBJLAY_START_CODE_MASK);
260    
261                          BitstreamSkip(bs, 32);  // video_object_layer_start_code                          BitstreamSkip(bs, 32);  // video_object_layer_start_code
262    
263                          BitstreamSkip(bs, 1);   // random_accessible_vol                          BitstreamSkip(bs, 1);   // random_accessible_vol
# Line 237  Line 265 
265                          // video_object_type_indication                          // video_object_type_indication
266                          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
267                          {                          {
268                                  //DPRINTF("video_object_type_indication %i not supported ",                                  DPRINTF(DPRINTF_ERROR,"video_object_type_indication %i not supported ",
269                                  //  BitstreamShowBits(bs, 8));                                          BitstreamShowBits(bs, 8));
270                                  return -1;                                  return -1;
271                          }                          }
272                          BitstreamSkip(bs, 8);                          BitstreamSkip(bs, 8);
# Line 246  Line 274 
274    
275                          if (BitstreamGetBit(bs))        // is_object_layer_identifier                          if (BitstreamGetBit(bs))        // is_object_layer_identifier
276                          {                          {
277                                  //DPRINTF("+ is_object_layer_identifier");                                  DPRINTF(DPRINTF_HEADER, "+ is_object_layer_identifier");
278                                  vol_ver_id = BitstreamGetBits(bs, 4);   // video_object_layer_verid                                  vol_ver_id = BitstreamGetBits(bs, 4);   // video_object_layer_verid
279                                    DPRINTF(DPRINTF_HEADER,"ver_id %i", vol_ver_id);
280                                  BitstreamSkip(bs, 3);   // video_object_layer_priority                                  BitstreamSkip(bs, 3);   // video_object_layer_priority
281                          } else {                          } else {
282                                  vol_ver_id = 1;                                  vol_ver_id = 1;
283                          }                          }
                         //DPRINTF("vol_ver_id %i", vol_ver_id);  
284    
285                          if (BitstreamGetBits(bs, 4) == VIDOBJLAY_AR_EXTPAR)     // aspect_ratio_info                          if (BitstreamGetBits(bs, 4) == VIDOBJLAY_AR_EXTPAR)     // aspect_ratio_info
286                          {                          {
287                                  //DPRINTF("+ aspect_ratio_info");                                  DPRINTF(DPRINTF_HEADER, "+ aspect_ratio_info");
288                                  BitstreamSkip(bs, 8);   // par_width                                  BitstreamSkip(bs, 8);   // par_width
289                                  BitstreamSkip(bs, 8);   // par_height                                  BitstreamSkip(bs, 8);   // par_height
290                          }                          }
291    
292                          if (BitstreamGetBit(bs))        // vol_control_parameters                          if (BitstreamGetBit(bs))        // vol_control_parameters
293                          {                          {
294                                  //DPRINTF("+ vol_control_parameters");                                  DPRINTF(DPRINTF_HEADER, "+ vol_control_parameters");
295                                  BitstreamSkip(bs, 2);   // chroma_format                                  BitstreamSkip(bs, 2);   // chroma_format
296                                  dec->low_delay = BitstreamGetBit(bs);   // low_delay                                  dec->low_delay = BitstreamGetBit(bs);   // low_delay
297                                    DPRINTF(DPRINTF_HEADER, "low_delay %i", dec->low_delay);
298                                  if (BitstreamGetBit(bs))        // vbv_parameters                                  if (BitstreamGetBit(bs))        // vbv_parameters
299                                  {                                  {
300                                          //DPRINTF("+ vbv_parameters");                                          DPRINTF(DPRINTF_HEADER,"+ vbv_parameters");
301                                          BitstreamSkip(bs, 15);  // first_half_bitrate                                          BitstreamSkip(bs, 15);  // first_half_bitrate
302                                          READ_MARKER();                                          READ_MARKER();
303                                          BitstreamSkip(bs, 15);  // latter_half_bitrate                                          BitstreamSkip(bs, 15);  // latter_half_bitrate
# Line 285  Line 314 
314                          }                          }
315    
316                          dec->shape = BitstreamGetBits(bs, 2);   // video_object_layer_shape                          dec->shape = BitstreamGetBits(bs, 2);   // video_object_layer_shape
317                          //DPRINTF("shape %i", dec->shape);                          DPRINTF(DPRINTF_HEADER, "shape %i", dec->shape);
318    
319                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE && vol_ver_id != 1) {                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE && vol_ver_id != 1) {
320                                  BitstreamSkip(bs, 4);   // video_object_layer_shape_extension                                  BitstreamSkip(bs, 4);   // video_object_layer_shape_extension
# Line 295  Line 324 
324    
325  // *************************** for decode B-frame time ***********************  // *************************** for decode B-frame time ***********************
326                          time_increment_resolution = BitstreamGetBits(bs, 16);   // vop_time_increment_resolution                          time_increment_resolution = BitstreamGetBits(bs, 16);   // vop_time_increment_resolution
327    
328                            DPRINTF(DPRINTF_HEADER,"vop_time_increment_resolution %i", time_increment_resolution);
329    
330                          time_increment_resolution--;                          time_increment_resolution--;
331                          //DPRINTF("time_increment_resolution = %i",time_increment_resolution);  
332                          if (time_increment_resolution > 0) {                          if (time_increment_resolution > 0) {
333                                  dec->time_inc_bits = log2bin(time_increment_resolution);                                  dec->time_inc_bits = log2bin(time_increment_resolution);
334                          } else {                          } else {
335                                  // dec->time_inc_bits = 0;                                  // dec->time_inc_bits = 0;
   
336                                  // for "old" xvid compatibility, set time_inc_bits = 1                                  // for "old" xvid compatibility, set time_inc_bits = 1
337                                  dec->time_inc_bits = 1;                                  dec->time_inc_bits = 1;
338                          }                          }
# Line 310  Line 341 
341    
342                          if (BitstreamGetBit(bs))        // fixed_vop_rate                          if (BitstreamGetBit(bs))        // fixed_vop_rate
343                          {                          {
344                                    DPRINTF(DPRINTF_HEADER, "+ fixed_vop_rate");
345                                  BitstreamSkip(bs, dec->time_inc_bits);  // fixed_vop_time_increment                                  BitstreamSkip(bs, dec->time_inc_bits);  // fixed_vop_time_increment
346                          }                          }
347    
# Line 320  Line 352 
352    
353                                          READ_MARKER();                                          READ_MARKER();
354                                          width = BitstreamGetBits(bs, 13);       // video_object_layer_width                                          width = BitstreamGetBits(bs, 13);       // video_object_layer_width
                                         //DPRINTF("width %i", width);  
355                                          READ_MARKER();                                          READ_MARKER();
356                                          height = BitstreamGetBits(bs, 13);      // video_object_layer_height                                          height = BitstreamGetBits(bs, 13);      // video_object_layer_height
                                         //DPRINTF("height %i", height);  
357                                          READ_MARKER();                                          READ_MARKER();
358    
359                                            DPRINTF(DPRINTF_HEADER, "width %i", width);
360                                            DPRINTF(DPRINTF_HEADER, "height %i", height);
361    
362                                          if (width != dec->width || height != dec->height) {                                          if (width != dec->width || height != dec->height) {
363                                                  //DPRINTF("FATAL: video dimension discrepancy ***");                                                  DPRINTF(DPRINTF_ERROR, "XVID_DEC_PARAM width/height does not match bitstream");
                                                 //DPRINTF("bitstream width/height  %i x %i", width, height);  
                                                 //DPRINTF("param width/height  %i x %i", dec->width, dec->height);  
364                                                  return -1;                                                  return -1;
365                                          }                                          }
366    
367                                  }                                  }
368    
369                                  if ((dec->interlacing = BitstreamGetBit(bs))) {                                  dec->interlacing = BitstreamGetBit(bs);
370                                          //DPRINTF("vol: interlacing");                                  DPRINTF(DPRINTF_HEADER, "interlace", dec->interlacing);
                                 }  
371    
372                                  if (!BitstreamGetBit(bs))       // obmc_disable                                  if (!BitstreamGetBit(bs))       // obmc_disable
373                                  {                                  {
374                                          //DPRINTF("IGNORED/TODO: !obmc_disable");                                          DPRINTF(DPRINTF_ERROR, "obmc_disabled==false not supported");
375                                          // TODO                                          // TODO
376                                          // fucking divx4.02 has this enabled                                          // fucking divx4.02 has this enabled
377                                  }                                  }
378    
379                                  if (BitstreamGetBits(bs, (vol_ver_id == 1 ? 1 : 2)))    // sprite_enable                                  if (BitstreamGetBits(bs, (vol_ver_id == 1 ? 1 : 2)))    // sprite_enable
380                                  {                                  {
381                                          //DPRINTF("sprite_enable; not supported");                                          DPRINTF(DPRINTF_ERROR, "spriate_enabled not supported");
382                                          return -1;                                          return -1;
383                                  }                                  }
384    
# Line 359  Line 389 
389    
390                                  if (BitstreamGetBit(bs))        // not_8_bit                                  if (BitstreamGetBit(bs))        // not_8_bit
391                                  {                                  {
392                                          //DPRINTF("+ not_8_bit [IGNORED/TODO]");                                          DPRINTF(DPRINTF_HEADER, "not_8_bit==true (ignored)");
393                                          dec->quant_bits = BitstreamGetBits(bs, 4);      // quant_precision                                          dec->quant_bits = BitstreamGetBits(bs, 4);      // quant_precision
394                                          BitstreamSkip(bs, 4);   // bits_per_pixel                                          BitstreamSkip(bs, 4);   // bits_per_pixel
395                                  } else {                                  } else {
# Line 373  Line 403 
403                                  }                                  }
404    
405                                  dec->quant_type = BitstreamGetBit(bs);  // quant_type                                  dec->quant_type = BitstreamGetBit(bs);  // quant_type
406                                  //DPRINTF("**** quant_type %i", dec->quant_type);                                  DPRINTF(DPRINTF_HEADER, "quant_type %i", dec->quant_type);
407    
408                                  if (dec->quant_type) {                                  if (dec->quant_type) {
409                                          if (BitstreamGetBit(bs))        // load_intra_quant_mat                                          if (BitstreamGetBit(bs))        // load_intra_quant_mat
410                                          {                                          {
411                                                  uint8_t matrix[64];                                                  uint8_t matrix[64];
412    
413                                                    DPRINTF(DPRINTF_HEADER, "load_intra_quant_mat");
414    
415                                                  bs_get_matrix(bs, matrix);                                                  bs_get_matrix(bs, matrix);
416                                                  set_intra_matrix(matrix);                                                  set_intra_matrix(matrix);
417                                          } else                                          } else
# Line 389  Line 421 
421                                          {                                          {
422                                                  uint8_t matrix[64];                                                  uint8_t matrix[64];
423    
424                                                    DPRINTF(DPRINTF_HEADER, "load_inter_quant_mat");
425    
426                                                  bs_get_matrix(bs, matrix);                                                  bs_get_matrix(bs, matrix);
427                                                  set_inter_matrix(matrix);                                                  set_inter_matrix(matrix);
428                                          } else                                          } else
429                                                  set_inter_matrix(get_default_inter_matrix());                                                  set_inter_matrix(get_default_inter_matrix());
430    
431                                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) {                                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) {
432                                                  // TODO                                                  DPRINTF(DPRINTF_ERROR, "greyscale matrix not supported");
                                                 //DPRINTF("TODO: grayscale matrix stuff");  
433                                                  return -1;                                                  return -1;
434                                          }                                          }
435    
# Line 406  Line 439 
439                                  if (vol_ver_id != 1) {                                  if (vol_ver_id != 1) {
440                                          dec->quarterpel = BitstreamGetBit(bs);  // quarter_sampe                                          dec->quarterpel = BitstreamGetBit(bs);  // quarter_sampe
441                                          if (dec->quarterpel) {                                          if (dec->quarterpel) {
442                                                  //DPRINTF("IGNORED/TODO: quarter_sample");                                                  DPRINTF(DPRINTF_ERROR, "quarter_sample not supported");
443                                          }                                          }
444                                  } else {                                  } else {
445                                          dec->quarterpel = 0;                                          dec->quarterpel = 0;
# Line 414  Line 447 
447    
448                                  if (!BitstreamGetBit(bs))       // complexity_estimation_disable                                  if (!BitstreamGetBit(bs))       // complexity_estimation_disable
449                                  {                                  {
450                                          //DPRINTF("TODO: complexity_estimation header");                                          DPRINTF(DPRINTF_ERROR, "complexity_estimation not supported");
                                         // TODO  
451                                          return -1;                                          return -1;
452                                  }                                  }
453    
454                                  if (!BitstreamGetBit(bs))       // resync_marker_disable                                  BitstreamSkip(bs, 1);   // resync_marker_disable
                                 {  
                                         //DPRINTF("IGNORED/TODO: !resync_marker_disable");  
                                         // TODO  
                                 }  
455    
456                                  if (BitstreamGetBit(bs))        // data_partitioned                                  if (BitstreamGetBit(bs))        // data_partitioned
457                                  {                                  {
458                                          //DPRINTF("+ data_partitioned");                                          DPRINTF(DPRINTF_ERROR, "data_partitioned not supported");
459                                          BitstreamSkip(bs, 1);   // reversible_vlc                                          BitstreamSkip(bs, 1);   // reversible_vlc
460                                  }                                  }
461    
462                                  if (vol_ver_id != 1) {                                  if (vol_ver_id != 1) {
463                                          if (BitstreamGetBit(bs))        // newpred_enable                                          if (BitstreamGetBit(bs))        // newpred_enable
464                                          {                                          {
465                                                  //DPRINTF("+ newpred_enable");                                                  DPRINTF(DPRINTF_HEADER, "+ newpred_enable");
466                                                  BitstreamSkip(bs, 2);   // requested_upstream_message_type                                                  BitstreamSkip(bs, 2);   // requested_upstream_message_type
467                                                  BitstreamSkip(bs, 1);   // newpred_segment_type                                                  BitstreamSkip(bs, 1);   // newpred_segment_type
468                                          }                                          }
469                                          if (BitstreamGetBit(bs))        // reduced_resolution_vop_enable                                          if (BitstreamGetBit(bs))        // reduced_resolution_vop_enable
470                                          {                                          {
471                                                  //DPRINTF("TODO: reduced_resolution_vop_enable");                                                  DPRINTF(DPRINTF_ERROR, "reduced_resolution_vop not supported");
                                                 // TODO  
472                                                  return -1;                                                  return -1;
473                                          }                                          }
474                                  }                                  }
475    
476                                  if ((dec->scalability = BitstreamGetBit(bs)))   // scalability                                  if ((dec->scalability = BitstreamGetBit(bs)))   // scalability
477                                  {                                  {
478                                          // TODO                                          DPRINTF(DPRINTF_ERROR, "scalability not supported");
                                         //DPRINTF("TODO: scalability");  
479                                          return -1;                                          return -1;
480                                  }                                  }
481                          } else                          // dec->shape == BINARY_ONLY                          } else                          // dec->shape == BINARY_ONLY
# Line 457  Line 483 
483                                  if (vol_ver_id != 1) {                                  if (vol_ver_id != 1) {
484                                          if (BitstreamGetBit(bs))        // scalability                                          if (BitstreamGetBit(bs))        // scalability
485                                          {                                          {
486                                                  // TODO                                          DPRINTF(DPRINTF_ERROR, "scalability not supported");
                                                 //DPRINTF("TODO: scalability");  
487                                                  return -1;                                                  return -1;
488                                          }                                          }
489                                  }                                  }
# Line 467  Line 492 
492                          }                          }
493    
494                  } else if (start_code == GRPOFVOP_START_CODE) {                  } else if (start_code == GRPOFVOP_START_CODE) {
495                          //DPRINTF("group_of_vop");  
496                            DPRINTF(DPRINTF_STARTCODE, "<group_of_vop>");
497    
498                          BitstreamSkip(bs, 32);                          BitstreamSkip(bs, 32);
499                          {                          {
500                                  int hours, minutes, seconds;                                  int hours, minutes, seconds;
# Line 476  Line 503 
503                                  minutes = BitstreamGetBits(bs, 6);                                  minutes = BitstreamGetBits(bs, 6);
504                                  READ_MARKER();                                  READ_MARKER();
505                                  seconds = BitstreamGetBits(bs, 6);                                  seconds = BitstreamGetBits(bs, 6);
506                                  //DPRINTF("%ih %im %is", hours, minutes, seconds);  
507                                    DPRINTF(DPRINTF_HEADER, "time %ih%im%is", hours);
508                          }                          }
509                          BitstreamSkip(bs, 1);   // closed_gov                          BitstreamSkip(bs, 1);   // closed_gov
510                          BitstreamSkip(bs, 1);   // broken_link                          BitstreamSkip(bs, 1);   // broken_link
511    
512                  } else if (start_code == VOP_START_CODE) {                  } else if (start_code == VOP_START_CODE) {
513                          //DPRINTF("vop_start_code");  
514                            DPRINTF(DPRINTF_STARTCODE, "<vop>");
515    
516                          BitstreamSkip(bs, 32);  // vop_start_code                          BitstreamSkip(bs, 32);  // vop_start_code
517    
518                          coding_type = BitstreamGetBits(bs, 2);  // vop_coding_type                          coding_type = BitstreamGetBits(bs, 2);  // vop_coding_type
519                          //DPRINTF("coding_type %i", coding_type);                          DPRINTF(DPRINTF_HEADER, "coding_type %i", coding_type);
520    
521  // *************************** for decode B-frame time ***********************  // *************************** for decode B-frame time ***********************
522                          while (BitstreamGetBit(bs) != 0)        // time_base                          while (BitstreamGetBit(bs) != 0)        // time_base
# Line 497  Line 528 
528                                  time_increment = (BitstreamGetBits(bs, dec->time_inc_bits));    // vop_time_increment                                  time_increment = (BitstreamGetBits(bs, dec->time_inc_bits));    // vop_time_increment
529                          }                          }
530    
531                          /*                          DPRINTF(DPRINTF_HEADER, "time_base %i", time_incr);
532                          DPRINTF("%c %i:%i",                          DPRINTF(DPRINTF_HEADER, "time_increment %i", time_increment);
533    
534                            DPRINTF(DPRINTF_TIMECODE, "%c %i:%i",
535                                  coding_type == I_VOP ? 'I' : coding_type == P_VOP ? 'P' : 'B',                                  coding_type == I_VOP ? 'I' : coding_type == P_VOP ? 'P' : 'B',
536                                  time_incr, time_increment);                                  time_incr, time_increment);
                         */  
537    
538                          if (coding_type != B_VOP) {                          if (coding_type != B_VOP) {
539                                  dec->last_time_base = dec->time_base;                                  dec->last_time_base = dec->time_base;
# Line 517  Line 549 
549                                           time_incr) * time_increment_resolution + time_increment;                                           time_incr) * time_increment_resolution + time_increment;
550                                  dec->time_bp = (uint32_t) (dec->last_non_b_time - dec->time);                                  dec->time_bp = (uint32_t) (dec->last_non_b_time - dec->time);
551                          }                          }
                         //DPRINTF("time_increment %i",time_increment);  
552    
553                          READ_MARKER();                          READ_MARKER();
554    
555                          if (!BitstreamGetBit(bs))       // vop_coded                          if (!BitstreamGetBit(bs))       // vop_coded
556                          {                          {
557                                  //DPRINTF("**NOT CODED**");                                  DPRINTF(DPRINTF_HEADER, "vop_coded==false");
558                                  return N_VOP;                                  return N_VOP;
559                          }                          }
560    
# Line 536  Line 567 
567                          if ((dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) &&                          if ((dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) &&
568                                  (coding_type == P_VOP)) {                                  (coding_type == P_VOP)) {
569                                  *rounding = BitstreamGetBit(bs);        // rounding_type                                  *rounding = BitstreamGetBit(bs);        // rounding_type
570                                  //DPRINTF("rounding %i", *rounding);                                  DPRINTF(DPRINTF_HEADER, "rounding %i", *rounding);
571                          }                          }
572    
573                          /* if (reduced_resolution_enable)                          /* if (reduced_resolution_enable)
# Line 557  Line 588 
588                                  vert_mc_ref = BitstreamGetBits(bs, 13);                                  vert_mc_ref = BitstreamGetBits(bs, 13);
589                                  READ_MARKER();                                  READ_MARKER();
590    
591                                  //DPRINTF("vop_width/height %i x %i", width, height);                                  DPRINTF(DPRINTF_HEADER, "width %i", width);
592                                  //DPRINTF("ref              %i x %i", horiz_mc_ref, vert_mc_ref);                                  DPRINTF(DPRINTF_HEADER, "height %i", height);
593                                    DPRINTF(DPRINTF_HEADER, "horiz_mc_ref %i", horiz_mc_ref);
594                                    DPRINTF(DPRINTF_HEADER, "vert_mc_ref %i", vert_mc_ref);
595    
596                                  BitstreamSkip(bs, 1);   // change_conv_ratio_disable                                  BitstreamSkip(bs, 1);   // change_conv_ratio_disable
597                                  if (BitstreamGetBit(bs))        // vop_constant_alpha                                  if (BitstreamGetBit(bs))        // vop_constant_alpha
# Line 574  Line 607 
607                                          intra_dc_threshold_table[BitstreamGetBits(bs, 3)];                                          intra_dc_threshold_table[BitstreamGetBits(bs, 3)];
608    
609                                  if (dec->interlacing) {                                  if (dec->interlacing) {
610                                          if ((dec->top_field_first = BitstreamGetBit(bs))) {                                          dec->top_field_first = BitstreamGetBit(bs);
611                                                  //DPRINTF("vop: top_field_first");                                          DPRINTF(DPRINTF_HEADER, "interlace top_field_first %i", dec->top_field_first);
612                                          }                                          dec->alternate_vertical_scan = BitstreamGetBit(bs);
613                                          if ((dec->alternate_vertical_scan = BitstreamGetBit(bs))) {                                          DPRINTF(DPRINTF_HEADER, "interlace alternate_vertical_scan %i", dec->alternate_vertical_scan);
614                                                  //DPRINTF("vop: alternate_vertical_scan");  
                                         }  
615                                  }                                  }
616                          }                          }
617    
618                          if ((*quant = BitstreamGetBits(bs, dec->quant_bits)) < 1)       // vop_quant                          if ((*quant = BitstreamGetBits(bs, dec->quant_bits)) < 1)       // vop_quant
619                                  *quant = 1;                                  *quant = 1;
620    
621                          //DPRINTF("quant %i", *quant);                          DPRINTF(DPRINTF_HEADER, "quant %i", *quant);
622    
623                          if (coding_type != I_VOP) {                          if (coding_type != I_VOP) {
624                                  *fcode_forward = BitstreamGetBits(bs, 3);       // fcode_forward                                  *fcode_forward = BitstreamGetBits(bs, 3);       // fcode_forward
625                                    DPRINTF(DPRINTF_HEADER, "fcode_forward %i", *fcode_forward);
626                          }                          }
627    
628                          if (coding_type == B_VOP) {                          if (coding_type == B_VOP) {
629                                  *fcode_backward = BitstreamGetBits(bs, 3);      // fcode_backward                                  *fcode_backward = BitstreamGetBits(bs, 3);      // fcode_backward
630                                    DPRINTF(DPRINTF_HEADER, "fcode_backward %i", *fcode_backward);
631                          }                          }
632                          if (!dec->scalability) {                          if (!dec->scalability) {
633                                  if ((dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) &&                                  if ((dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) &&
# Line 602  Line 636 
636                                  }                                  }
637                          }                          }
638                          return coding_type;                          return coding_type;
639    
640                  } else if (start_code == USERDATA_START_CODE) {                  } else if (start_code == USERDATA_START_CODE) {
641                          //DPRINTF("user_data");  
642                            DPRINTF(DPRINTF_STARTCODE, "<user_data>");
643    
644                          BitstreamSkip(bs, 32);  // user_data_start_code                          BitstreamSkip(bs, 32);  // user_data_start_code
645    
646                  } else                                  // start_code == ?                  } else                                  // start_code == ?
647                  {                  {
648                          if (BitstreamShowBits(bs, 24) == 0x000001) {                          if (BitstreamShowBits(bs, 24) == 0x000001) {
649                                  //DPRINTF("*** WARNING: unknown start_code %x",                                  DPRINTF(DPRINTF_STARTCODE, "<unknown: %x>", BitstreamShowBits(bs, 32));
                                 //         BitstreamShowBits(bs, 32));  
650                          }                          }
651                          BitstreamSkip(bs, 8);                          BitstreamSkip(bs, 8);
652                  }                  }
# Line 773  Line 810 
810          // time_increment: value=nth_of_sec, nbits = log2(resolution)          // time_increment: value=nth_of_sec, nbits = log2(resolution)
811  #ifdef BFRAMES  #ifdef BFRAMES
812          BitstreamPutBits(bs, frame->ticks, log2bin(pParam->fbase));          BitstreamPutBits(bs, frame->ticks, log2bin(pParam->fbase));
813          DPRINTF("[%i:%i] %c\n", frame->seconds, frame->ticks,          /*DPRINTF("[%i:%i] %c\n", frame->seconds, frame->ticks,
814                          frame->coding_type == I_VOP ? 'I' : frame->coding_type ==                          frame->coding_type == I_VOP ? 'I' : frame->coding_type ==
815                          P_VOP ? 'P' : 'B');                          P_VOP ? 'P' : 'B');*/
816  #else  #else
817          BitstreamPutBits(bs, 1, 1);          BitstreamPutBits(bs, 1, 1);
818  #endif  #endif

Legend:
Removed from v.248  
changed lines
  Added in v.252

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