[svn] / branches / dev-api-3 / xvidcore / src / bitstream / bitstream.c Repository:
ViewVC logotype

Diff of /branches/dev-api-3/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 294, Fri Jul 12 00:49:59 2002 UTC
# Line 41  Line 41 
41    *                                                                            *    *                                                                            *
42    *  Revision history:                                                         *    *  Revision history:                                                         *
43    *                                                                            *    *                                                                            *
44    *      22.05.2002 bs_put_matrix fix    *  11.07.2002 add VOP width & height return to dec when dec->width           *
45      *             or dec->height is 0  (for use in examples/ex1.c)               *
46      *             MinChen <chenm001@163.com>                                     *
47      *  22.05.2002 bs_put_matrix fix                                              *
48    *  20.05.2002 added BitstreamWriteUserData                                   *    *  20.05.2002 added BitstreamWriteUserData                                   *
49    *  19.06.2002  Fix a little bug in use custom quant matrix                   *    *  19.06.2002  Fix a little bug in use custom quant matrix                   *
50    *              MinChen <chenm001@163.com>                                    *    *              MinChen <chenm001@163.com>                                    *
# Line 125  Line 128 
128  // for BVOP addbits == max(fcode,bcode) - 1  // for BVOP addbits == max(fcode,bcode) - 1
129  // returns mbpos  // returns mbpos
130  int  int
131  read_video_packet_header(Bitstream *bs, int addbits)  read_video_packet_header(Bitstream *bs, const int addbits, int * quant)
132  {  {
133          int nbits;          int nbits;
134          int mbnum;          int mbnum;
         int quant;  
135          int hec;          int hec;
136    
137          nbits = NUMBITS_VP_RESYNC_MARKER;          nbits = NUMBITS_VP_RESYNC_MARKER + addbits;
138    
139          BitstreamSkip(bs, BitstreamNumBitsToByteAlign(bs));          BitstreamSkip(bs, BitstreamNumBitsToByteAlign(bs));
140          BitstreamSkip(bs, nbits);          BitstreamSkip(bs, nbits);
141    
142            DPRINTF(DPRINTF_STARTCODE, "<video_packet_header>");
143    
144          // if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) {          // if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) {
145                  // hec                  // hec
146                  // vop_width                  // vop_width
# Line 147  Line 151 
151          //}          //}
152    
153          mbnum = BitstreamGetBits(bs, 9);          mbnum = BitstreamGetBits(bs, 9);
154          //printf("mbnum %i    [%i,%i]\n", mbnum, mbnum % dec->mb_width, mbnum / dec->mb_width);          DPRINTF(DPRINTF_HEADER, "mbnum %i", mbnum);
155    
156          // if (dec->shape != VIDOBJLAY_SHAPE_BINARYONLY)          // if (dec->shape != VIDOBJLAY_SHAPE_BINARYONLY)
157          quant = BitstreamGetBits(bs, 5);          *quant = BitstreamGetBits(bs, 5);
158            DPRINTF(DPRINTF_HEADER, "quant %i", *quant);
159    
160          // if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR)          // if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR)
161          hec = BitstreamGetBit(bs);          hec = BitstreamGetBit(bs);
162            DPRINTF(DPRINTF_HEADER, "header_extension_code %i", hec);
163          // if (hec)          // if (hec)
164          //   .. decoder hec-header ...          //   .. decoder hec-header ...
165    
# Line 167  Line 173 
173  returns coding_type, or -1 if error  returns coding_type, or -1 if error
174  */  */
175    
176    #define VIDOBJ_START_CODE_MASK          0x0000001f
177    #define VIDOBJLAY_START_CODE_MASK       0x0000000f
178    
179  int  int
180  BitstreamReadHeaders(Bitstream * bs,  BitstreamReadHeaders(Bitstream * bs,
181                                           DECODER * dec,                                           DECODER * dec,
# Line 188  Line 197 
197                  start_code = BitstreamShowBits(bs, 32);                  start_code = BitstreamShowBits(bs, 32);
198    
199                  if (start_code == VISOBJSEQ_START_CODE) {                  if (start_code == VISOBJSEQ_START_CODE) {
200                          // DPRINTF("visual_object_sequence");  
201                            int profile;
202    
203                            DPRINTF(DPRINTF_STARTCODE, "<visual_object_sequence>");
204    
205                          BitstreamSkip(bs, 32);  // visual_object_sequence_start_code                          BitstreamSkip(bs, 32);  // visual_object_sequence_start_code
206                          BitstreamSkip(bs, 8);   // profile_and_level_indication                          profile = BitstreamGetBits(bs, 8);      // profile_and_level_indication
207    
208                            DPRINTF(DPRINTF_HEADER, "profile_and_level_indication %i", profile);
209    
210                  } else if (start_code == VISOBJSEQ_STOP_CODE) {                  } else if (start_code == VISOBJSEQ_STOP_CODE) {
211    
212                          BitstreamSkip(bs, 32);  // visual_object_sequence_stop_code                          BitstreamSkip(bs, 32);  // visual_object_sequence_stop_code
213    
214                            DPRINTF(DPRINTF_STARTCODE, "</visual_object_sequence>");
215    
216                  } else if (start_code == VISOBJ_START_CODE) {                  } else if (start_code == VISOBJ_START_CODE) {
217                          //DPRINTF("visual_object");  
218                            DPRINTF(DPRINTF_STARTCODE, "<visual_object>");
219    
220                          BitstreamSkip(bs, 32);  // visual_object_start_code                          BitstreamSkip(bs, 32);  // visual_object_start_code
221                          if (BitstreamGetBit(bs))        // is_visual_object_identified                          if (BitstreamGetBit(bs))        // is_visual_object_identified
222                          {                          {
223                                  vol_ver_id = BitstreamGetBits(bs, 4);   // visual_object_ver_id                                  vol_ver_id = BitstreamGetBits(bs, 4);   // visual_object_ver_id
224                                    DPRINTF(DPRINTF_HEADER,"ver_id %i", vol_ver_id);
225                                  BitstreamSkip(bs, 3);   // visual_object_priority                                  BitstreamSkip(bs, 3);   // visual_object_priority
226                          } else {                          } else {
227                                  vol_ver_id = 1;                                  vol_ver_id = 1;
# Line 206  Line 229 
229    
230                          if (BitstreamShowBits(bs, 4) != VISOBJ_TYPE_VIDEO)      // visual_object_type                          if (BitstreamShowBits(bs, 4) != VISOBJ_TYPE_VIDEO)      // visual_object_type
231                          {                          {
232                                  //DPRINTF("visual_object_type != video");                                  DPRINTF(DPRINTF_ERROR, "visual_object_type != video");
233                                  return -1;                                  return -1;
234                          }                          }
235                          BitstreamSkip(bs, 4);                          BitstreamSkip(bs, 4);
# Line 215  Line 238 
238    
239                          if (BitstreamGetBit(bs))        // video_signal_type                          if (BitstreamGetBit(bs))        // video_signal_type
240                          {                          {
241                                  //DPRINTF("+ video_signal_type");                                  DPRINTF(DPRINTF_HEADER,"+ video_signal_type");
242                                  BitstreamSkip(bs, 3);   // video_format                                  BitstreamSkip(bs, 3);   // video_format
243                                  BitstreamSkip(bs, 1);   // video_range                                  BitstreamSkip(bs, 1);   // video_range
244                                  if (BitstreamGetBit(bs))        // color_description                                  if (BitstreamGetBit(bs))        // color_description
245                                  {                                  {
246                                          //DPRINTF("+ color_description");                                          DPRINTF(DPRINTF_HEADER,"+ color_description");
247                                          BitstreamSkip(bs, 8);   // color_primaries                                          BitstreamSkip(bs, 8);   // color_primaries
248                                          BitstreamSkip(bs, 8);   // transfer_characteristics                                          BitstreamSkip(bs, 8);   // transfer_characteristics
249                                          BitstreamSkip(bs, 8);   // matrix_coefficients                                          BitstreamSkip(bs, 8);   // matrix_coefficients
250                                  }                                  }
251                          }                          }
252                  } else if ((start_code & ~0x1f) == VIDOBJ_START_CODE) {                  } else if ((start_code & ~VIDOBJ_START_CODE_MASK) == VIDOBJ_START_CODE) {
253    
254                            DPRINTF(DPRINTF_STARTCODE, "<video_object>");
255                            DPRINTF(DPRINTF_HEADER, "vo id %i", start_code & VIDOBJ_START_CODE_MASK);
256    
257                          BitstreamSkip(bs, 32);  // video_object_start_code                          BitstreamSkip(bs, 32);  // video_object_start_code
258                  } else if ((start_code & ~0xf) == VIDOBJLAY_START_CODE) {  
259                          //DPRINTF("video_object_layer");                  } else if ((start_code & ~VIDOBJLAY_START_CODE_MASK) == VIDOBJLAY_START_CODE) {
260    
261                            DPRINTF(DPRINTF_STARTCODE, "<video_object_layer>");
262                            DPRINTF(DPRINTF_HEADER, "vol id %i", start_code & VIDOBJLAY_START_CODE_MASK);
263    
264                          BitstreamSkip(bs, 32);  // video_object_layer_start_code                          BitstreamSkip(bs, 32);  // video_object_layer_start_code
265    
266                          BitstreamSkip(bs, 1);   // random_accessible_vol                          BitstreamSkip(bs, 1);   // random_accessible_vol
# Line 237  Line 268 
268                          // video_object_type_indication                          // video_object_type_indication
269                          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
270                          {                          {
271                                  //DPRINTF("video_object_type_indication %i not supported ",                                  DPRINTF(DPRINTF_ERROR,"video_object_type_indication %i not supported ",
272                                  //  BitstreamShowBits(bs, 8));                                          BitstreamShowBits(bs, 8));
273                                  return -1;                                  return -1;
274                          }                          }
275                          BitstreamSkip(bs, 8);                          BitstreamSkip(bs, 8);
# Line 246  Line 277 
277    
278                          if (BitstreamGetBit(bs))        // is_object_layer_identifier                          if (BitstreamGetBit(bs))        // is_object_layer_identifier
279                          {                          {
280                                  //DPRINTF("+ is_object_layer_identifier");                                  DPRINTF(DPRINTF_HEADER, "+ is_object_layer_identifier");
281                                  vol_ver_id = BitstreamGetBits(bs, 4);   // video_object_layer_verid                                  vol_ver_id = BitstreamGetBits(bs, 4);   // video_object_layer_verid
282                                    DPRINTF(DPRINTF_HEADER,"ver_id %i", vol_ver_id);
283                                  BitstreamSkip(bs, 3);   // video_object_layer_priority                                  BitstreamSkip(bs, 3);   // video_object_layer_priority
284                          } else {                          } else {
285                                  vol_ver_id = 1;                                  vol_ver_id = 1;
286                          }                          }
                         //DPRINTF("vol_ver_id %i", vol_ver_id);  
287    
288                          if (BitstreamGetBits(bs, 4) == VIDOBJLAY_AR_EXTPAR)     // aspect_ratio_info                          if (BitstreamGetBits(bs, 4) == VIDOBJLAY_AR_EXTPAR)     // aspect_ratio_info
289                          {                          {
290                                  //DPRINTF("+ aspect_ratio_info");                                  DPRINTF(DPRINTF_HEADER, "+ aspect_ratio_info");
291                                  BitstreamSkip(bs, 8);   // par_width                                  BitstreamSkip(bs, 8);   // par_width
292                                  BitstreamSkip(bs, 8);   // par_height                                  BitstreamSkip(bs, 8);   // par_height
293                          }                          }
294    
295                          if (BitstreamGetBit(bs))        // vol_control_parameters                          if (BitstreamGetBit(bs))        // vol_control_parameters
296                          {                          {
297                                  //DPRINTF("+ vol_control_parameters");                                  DPRINTF(DPRINTF_HEADER, "+ vol_control_parameters");
298                                  BitstreamSkip(bs, 2);   // chroma_format                                  BitstreamSkip(bs, 2);   // chroma_format
299                                  dec->low_delay = BitstreamGetBit(bs);   // low_delay                                  dec->low_delay = BitstreamGetBit(bs);   // low_delay
300                                    DPRINTF(DPRINTF_HEADER, "low_delay %i", dec->low_delay);
301                                  if (BitstreamGetBit(bs))        // vbv_parameters                                  if (BitstreamGetBit(bs))        // vbv_parameters
302                                  {                                  {
303                                          //DPRINTF("+ vbv_parameters");                                          DPRINTF(DPRINTF_HEADER,"+ vbv_parameters");
304                                          BitstreamSkip(bs, 15);  // first_half_bitrate                                          BitstreamSkip(bs, 15);  // first_half_bitrate
305                                          READ_MARKER();                                          READ_MARKER();
306                                          BitstreamSkip(bs, 15);  // latter_half_bitrate                                          BitstreamSkip(bs, 15);  // latter_half_bitrate
# Line 285  Line 317 
317                          }                          }
318    
319                          dec->shape = BitstreamGetBits(bs, 2);   // video_object_layer_shape                          dec->shape = BitstreamGetBits(bs, 2);   // video_object_layer_shape
320                          //DPRINTF("shape %i", dec->shape);                          DPRINTF(DPRINTF_HEADER, "shape %i", dec->shape);
321    
322                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE && vol_ver_id != 1) {                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE && vol_ver_id != 1) {
323                                  BitstreamSkip(bs, 4);   // video_object_layer_shape_extension                                  BitstreamSkip(bs, 4);   // video_object_layer_shape_extension
# Line 295  Line 327 
327    
328  // *************************** for decode B-frame time ***********************  // *************************** for decode B-frame time ***********************
329                          time_increment_resolution = BitstreamGetBits(bs, 16);   // vop_time_increment_resolution                          time_increment_resolution = BitstreamGetBits(bs, 16);   // vop_time_increment_resolution
330    
331                            DPRINTF(DPRINTF_HEADER,"vop_time_increment_resolution %i", time_increment_resolution);
332    
333                          time_increment_resolution--;                          time_increment_resolution--;
334                          //DPRINTF("time_increment_resolution = %i",time_increment_resolution);  
335                          if (time_increment_resolution > 0) {                          if (time_increment_resolution > 0) {
336                                  dec->time_inc_bits = log2bin(time_increment_resolution);                                  dec->time_inc_bits = log2bin(time_increment_resolution);
337                          } else {                          } else {
338                                  // dec->time_inc_bits = 0;                                  // dec->time_inc_bits = 0;
   
339                                  // for "old" xvid compatibility, set time_inc_bits = 1                                  // for "old" xvid compatibility, set time_inc_bits = 1
340                                  dec->time_inc_bits = 1;                                  dec->time_inc_bits = 1;
341                          }                          }
# Line 310  Line 344 
344    
345                          if (BitstreamGetBit(bs))        // fixed_vop_rate                          if (BitstreamGetBit(bs))        // fixed_vop_rate
346                          {                          {
347                                    DPRINTF(DPRINTF_HEADER, "+ fixed_vop_rate");
348                                  BitstreamSkip(bs, dec->time_inc_bits);  // fixed_vop_time_increment                                  BitstreamSkip(bs, dec->time_inc_bits);  // fixed_vop_time_increment
349                          }                          }
350    
# Line 320  Line 355 
355    
356                                          READ_MARKER();                                          READ_MARKER();
357                                          width = BitstreamGetBits(bs, 13);       // video_object_layer_width                                          width = BitstreamGetBits(bs, 13);       // video_object_layer_width
                                         //DPRINTF("width %i", width);  
358                                          READ_MARKER();                                          READ_MARKER();
359                                          height = BitstreamGetBits(bs, 13);      // video_object_layer_height                                          height = BitstreamGetBits(bs, 13);      // video_object_layer_height
                                         //DPRINTF("height %i", height);  
360                                          READ_MARKER();                                          READ_MARKER();
361    
362                                            DPRINTF(DPRINTF_HEADER, "width %i", width);
363                                            DPRINTF(DPRINTF_HEADER, "height %i", height);
364    
365                                            // for auto set width & height
366                                            if (dec->width == 0)
367                                                    dec->width = width;
368                                            if (dec->height == 0)
369                                                    dec->height = height;
370    
371                                          if (width != dec->width || height != dec->height) {                                          if (width != dec->width || height != dec->height) {
372                                                  //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);  
373                                                  return -1;                                                  return -1;
374                                          }                                          }
375    
376                                  }                                  }
377    
378                                  if ((dec->interlacing = BitstreamGetBit(bs))) {                                  dec->interlacing = BitstreamGetBit(bs);
379                                          //DPRINTF("vol: interlacing");                                  DPRINTF(DPRINTF_HEADER, "interlace", dec->interlacing);
                                 }  
380    
381                                  if (!BitstreamGetBit(bs))       // obmc_disable                                  if (!BitstreamGetBit(bs))       // obmc_disable
382                                  {                                  {
383                                          //DPRINTF("IGNORED/TODO: !obmc_disable");                                          DPRINTF(DPRINTF_ERROR, "obmc_disabled==false not supported");
384                                          // TODO                                          // TODO
385                                          // fucking divx4.02 has this enabled                                          // fucking divx4.02 has this enabled
386                                  }                                  }
387    
388                                  if (BitstreamGetBits(bs, (vol_ver_id == 1 ? 1 : 2)))    // sprite_enable                                  if (BitstreamGetBits(bs, (vol_ver_id == 1 ? 1 : 2)))    // sprite_enable
389                                  {                                  {
390                                          //DPRINTF("sprite_enable; not supported");                                          DPRINTF(DPRINTF_ERROR, "spriate_enabled not supported");
391                                          return -1;                                          return -1;
392                                  }                                  }
393    
# Line 359  Line 398 
398    
399                                  if (BitstreamGetBit(bs))        // not_8_bit                                  if (BitstreamGetBit(bs))        // not_8_bit
400                                  {                                  {
401                                          //DPRINTF("+ not_8_bit [IGNORED/TODO]");                                          DPRINTF(DPRINTF_HEADER, "not_8_bit==true (ignored)");
402                                          dec->quant_bits = BitstreamGetBits(bs, 4);      // quant_precision                                          dec->quant_bits = BitstreamGetBits(bs, 4);      // quant_precision
403                                          BitstreamSkip(bs, 4);   // bits_per_pixel                                          BitstreamSkip(bs, 4);   // bits_per_pixel
404                                  } else {                                  } else {
# Line 373  Line 412 
412                                  }                                  }
413    
414                                  dec->quant_type = BitstreamGetBit(bs);  // quant_type                                  dec->quant_type = BitstreamGetBit(bs);  // quant_type
415                                  //DPRINTF("**** quant_type %i", dec->quant_type);                                  DPRINTF(DPRINTF_HEADER, "quant_type %i", dec->quant_type);
416    
417                                  if (dec->quant_type) {                                  if (dec->quant_type) {
418                                          if (BitstreamGetBit(bs))        // load_intra_quant_mat                                          if (BitstreamGetBit(bs))        // load_intra_quant_mat
419                                          {                                          {
420                                                  uint8_t matrix[64];                                                  uint8_t matrix[64];
421    
422                                                    DPRINTF(DPRINTF_HEADER, "load_intra_quant_mat");
423    
424                                                  bs_get_matrix(bs, matrix);                                                  bs_get_matrix(bs, matrix);
425                                                  set_intra_matrix(matrix);                                                  set_intra_matrix(matrix);
426                                          } else                                          } else
# Line 389  Line 430 
430                                          {                                          {
431                                                  uint8_t matrix[64];                                                  uint8_t matrix[64];
432    
433                                                    DPRINTF(DPRINTF_HEADER, "load_inter_quant_mat");
434    
435                                                  bs_get_matrix(bs, matrix);                                                  bs_get_matrix(bs, matrix);
436                                                  set_inter_matrix(matrix);                                                  set_inter_matrix(matrix);
437                                          } else                                          } else
438                                                  set_inter_matrix(get_default_inter_matrix());                                                  set_inter_matrix(get_default_inter_matrix());
439    
440                                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) {                                          if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) {
441                                                  // TODO                                                  DPRINTF(DPRINTF_ERROR, "greyscale matrix not supported");
                                                 //DPRINTF("TODO: grayscale matrix stuff");  
442                                                  return -1;                                                  return -1;
443                                          }                                          }
444    
# Line 406  Line 448 
448                                  if (vol_ver_id != 1) {                                  if (vol_ver_id != 1) {
449                                          dec->quarterpel = BitstreamGetBit(bs);  // quarter_sampe                                          dec->quarterpel = BitstreamGetBit(bs);  // quarter_sampe
450                                          if (dec->quarterpel) {                                          if (dec->quarterpel) {
451                                                  //DPRINTF("IGNORED/TODO: quarter_sample");                                                  DPRINTF(DPRINTF_ERROR, "quarter_sample not supported");
452                                          }                                          }
453                                  } else {                                  } else {
454                                          dec->quarterpel = 0;                                          dec->quarterpel = 0;
# Line 414  Line 456 
456    
457                                  if (!BitstreamGetBit(bs))       // complexity_estimation_disable                                  if (!BitstreamGetBit(bs))       // complexity_estimation_disable
458                                  {                                  {
459                                          //DPRINTF("TODO: complexity_estimation header");                                          DPRINTF(DPRINTF_ERROR, "complexity_estimation not supported");
                                         // TODO  
460                                          return -1;                                          return -1;
461                                  }                                  }
462    
463                                  if (!BitstreamGetBit(bs))       // resync_marker_disable                                  BitstreamSkip(bs, 1);   // resync_marker_disable
                                 {  
                                         //DPRINTF("IGNORED/TODO: !resync_marker_disable");  
                                         // TODO  
                                 }  
464    
465                                  if (BitstreamGetBit(bs))        // data_partitioned                                  if (BitstreamGetBit(bs))        // data_partitioned
466                                  {                                  {
467                                          //DPRINTF("+ data_partitioned");                                          DPRINTF(DPRINTF_ERROR, "data_partitioned not supported");
468                                          BitstreamSkip(bs, 1);   // reversible_vlc                                          BitstreamSkip(bs, 1);   // reversible_vlc
469                                  }                                  }
470    
471                                  if (vol_ver_id != 1) {                                  if (vol_ver_id != 1) {
472                                          if (BitstreamGetBit(bs))        // newpred_enable                                          if (BitstreamGetBit(bs))        // newpred_enable
473                                          {                                          {
474                                                  //DPRINTF("+ newpred_enable");                                                  DPRINTF(DPRINTF_HEADER, "+ newpred_enable");
475                                                  BitstreamSkip(bs, 2);   // requested_upstream_message_type                                                  BitstreamSkip(bs, 2);   // requested_upstream_message_type
476                                                  BitstreamSkip(bs, 1);   // newpred_segment_type                                                  BitstreamSkip(bs, 1);   // newpred_segment_type
477                                          }                                          }
478                                          if (BitstreamGetBit(bs))        // reduced_resolution_vop_enable                                          if (BitstreamGetBit(bs))        // reduced_resolution_vop_enable
479                                          {                                          {
480                                                  //DPRINTF("TODO: reduced_resolution_vop_enable");                                                  DPRINTF(DPRINTF_ERROR, "reduced_resolution_vop not supported");
                                                 // TODO  
481                                                  return -1;                                                  return -1;
482                                          }                                          }
483                                  }                                  }
484    
485                                  if ((dec->scalability = BitstreamGetBit(bs)))   // scalability                                  if ((dec->scalability = BitstreamGetBit(bs)))   // scalability
486                                  {                                  {
487                                          // TODO                                          DPRINTF(DPRINTF_ERROR, "scalability not supported");
                                         //DPRINTF("TODO: scalability");  
488                                          return -1;                                          return -1;
489                                  }                                  }
490                          } else                          // dec->shape == BINARY_ONLY                          } else                          // dec->shape == BINARY_ONLY
# Line 457  Line 492 
492                                  if (vol_ver_id != 1) {                                  if (vol_ver_id != 1) {
493                                          if (BitstreamGetBit(bs))        // scalability                                          if (BitstreamGetBit(bs))        // scalability
494                                          {                                          {
495                                                  // TODO                                          DPRINTF(DPRINTF_ERROR, "scalability not supported");
                                                 //DPRINTF("TODO: scalability");  
496                                                  return -1;                                                  return -1;
497                                          }                                          }
498                                  }                                  }
# Line 467  Line 501 
501                          }                          }
502    
503                  } else if (start_code == GRPOFVOP_START_CODE) {                  } else if (start_code == GRPOFVOP_START_CODE) {
504                          //DPRINTF("group_of_vop");  
505                            DPRINTF(DPRINTF_STARTCODE, "<group_of_vop>");
506    
507                          BitstreamSkip(bs, 32);                          BitstreamSkip(bs, 32);
508                          {                          {
509                                  int hours, minutes, seconds;                                  int hours, minutes, seconds;
# Line 476  Line 512 
512                                  minutes = BitstreamGetBits(bs, 6);                                  minutes = BitstreamGetBits(bs, 6);
513                                  READ_MARKER();                                  READ_MARKER();
514                                  seconds = BitstreamGetBits(bs, 6);                                  seconds = BitstreamGetBits(bs, 6);
515                                  //DPRINTF("%ih %im %is", hours, minutes, seconds);  
516                                    DPRINTF(DPRINTF_HEADER, "time %ih%im%is", hours);
517                          }                          }
518                          BitstreamSkip(bs, 1);   // closed_gov                          BitstreamSkip(bs, 1);   // closed_gov
519                          BitstreamSkip(bs, 1);   // broken_link                          BitstreamSkip(bs, 1);   // broken_link
520    
521                  } else if (start_code == VOP_START_CODE) {                  } else if (start_code == VOP_START_CODE) {
522                          //DPRINTF("vop_start_code");  
523                            DPRINTF(DPRINTF_STARTCODE, "<vop>");
524    
525                          BitstreamSkip(bs, 32);  // vop_start_code                          BitstreamSkip(bs, 32);  // vop_start_code
526    
527                          coding_type = BitstreamGetBits(bs, 2);  // vop_coding_type                          coding_type = BitstreamGetBits(bs, 2);  // vop_coding_type
528                          //DPRINTF("coding_type %i", coding_type);                          DPRINTF(DPRINTF_HEADER, "coding_type %i", coding_type);
529    
530  // *************************** for decode B-frame time ***********************  // *************************** for decode B-frame time ***********************
531                          while (BitstreamGetBit(bs) != 0)        // time_base                          while (BitstreamGetBit(bs) != 0)        // time_base
# Line 497  Line 537 
537                                  time_increment = (BitstreamGetBits(bs, dec->time_inc_bits));    // vop_time_increment                                  time_increment = (BitstreamGetBits(bs, dec->time_inc_bits));    // vop_time_increment
538                          }                          }
539    
540                          /*                          DPRINTF(DPRINTF_HEADER, "time_base %i", time_incr);
541                          DPRINTF("%c %i:%i",                          DPRINTF(DPRINTF_HEADER, "time_increment %i", time_increment);
542    
543                            DPRINTF(DPRINTF_TIMECODE, "%c %i:%i",
544                                  coding_type == I_VOP ? 'I' : coding_type == P_VOP ? 'P' : 'B',                                  coding_type == I_VOP ? 'I' : coding_type == P_VOP ? 'P' : 'B',
545                                  time_incr, time_increment);                                  time_incr, time_increment);
                         */  
546    
547                          if (coding_type != B_VOP) {                          if (coding_type != B_VOP) {
548                                  dec->last_time_base = dec->time_base;                                  dec->last_time_base = dec->time_base;
# Line 517  Line 558 
558                                           time_incr) * time_increment_resolution + time_increment;                                           time_incr) * time_increment_resolution + time_increment;
559                                  dec->time_bp = (uint32_t) (dec->last_non_b_time - dec->time);                                  dec->time_bp = (uint32_t) (dec->last_non_b_time - dec->time);
560                          }                          }
                         //DPRINTF("time_increment %i",time_increment);  
561    
562                          READ_MARKER();                          READ_MARKER();
563    
564                          if (!BitstreamGetBit(bs))       // vop_coded                          if (!BitstreamGetBit(bs))       // vop_coded
565                          {                          {
566                                  //DPRINTF("**NOT CODED**");                                  DPRINTF(DPRINTF_HEADER, "vop_coded==false");
567                                  return N_VOP;                                  return N_VOP;
568                          }                          }
569    
# Line 536  Line 576 
576                          if ((dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) &&                          if ((dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) &&
577                                  (coding_type == P_VOP)) {                                  (coding_type == P_VOP)) {
578                                  *rounding = BitstreamGetBit(bs);        // rounding_type                                  *rounding = BitstreamGetBit(bs);        // rounding_type
579                                  //DPRINTF("rounding %i", *rounding);                                  DPRINTF(DPRINTF_HEADER, "rounding %i", *rounding);
580                          }                          }
581    
582                          /* if (reduced_resolution_enable)                          /* if (reduced_resolution_enable)
# Line 557  Line 597 
597                                  vert_mc_ref = BitstreamGetBits(bs, 13);                                  vert_mc_ref = BitstreamGetBits(bs, 13);
598                                  READ_MARKER();                                  READ_MARKER();
599    
600                                  //DPRINTF("vop_width/height %i x %i", width, height);                                  DPRINTF(DPRINTF_HEADER, "width %i", width);
601                                  //DPRINTF("ref              %i x %i", horiz_mc_ref, vert_mc_ref);                                  DPRINTF(DPRINTF_HEADER, "height %i", height);
602                                    DPRINTF(DPRINTF_HEADER, "horiz_mc_ref %i", horiz_mc_ref);
603                                    DPRINTF(DPRINTF_HEADER, "vert_mc_ref %i", vert_mc_ref);
604    
605                                  BitstreamSkip(bs, 1);   // change_conv_ratio_disable                                  BitstreamSkip(bs, 1);   // change_conv_ratio_disable
606                                  if (BitstreamGetBit(bs))        // vop_constant_alpha                                  if (BitstreamGetBit(bs))        // vop_constant_alpha
# Line 574  Line 616 
616                                          intra_dc_threshold_table[BitstreamGetBits(bs, 3)];                                          intra_dc_threshold_table[BitstreamGetBits(bs, 3)];
617    
618                                  if (dec->interlacing) {                                  if (dec->interlacing) {
619                                          if ((dec->top_field_first = BitstreamGetBit(bs))) {                                          dec->top_field_first = BitstreamGetBit(bs);
620                                                  //DPRINTF("vop: top_field_first");                                          DPRINTF(DPRINTF_HEADER, "interlace top_field_first %i", dec->top_field_first);
621                                          }                                          dec->alternate_vertical_scan = BitstreamGetBit(bs);
622                                          if ((dec->alternate_vertical_scan = BitstreamGetBit(bs))) {                                          DPRINTF(DPRINTF_HEADER, "interlace alternate_vertical_scan %i", dec->alternate_vertical_scan);
623                                                  //DPRINTF("vop: alternate_vertical_scan");  
                                         }  
624                                  }                                  }
625                          }                          }
626    
627                          if ((*quant = BitstreamGetBits(bs, dec->quant_bits)) < 1)       // vop_quant                          if ((*quant = BitstreamGetBits(bs, dec->quant_bits)) < 1)       // vop_quant
628                                  *quant = 1;                                  *quant = 1;
629    
630                          //DPRINTF("quant %i", *quant);                          DPRINTF(DPRINTF_HEADER, "quant %i", *quant);
631    
632                          if (coding_type != I_VOP) {                          if (coding_type != I_VOP) {
633                                  *fcode_forward = BitstreamGetBits(bs, 3);       // fcode_forward                                  *fcode_forward = BitstreamGetBits(bs, 3);       // fcode_forward
634                                    DPRINTF(DPRINTF_HEADER, "fcode_forward %i", *fcode_forward);
635                          }                          }
636    
637                          if (coding_type == B_VOP) {                          if (coding_type == B_VOP) {
638                                  *fcode_backward = BitstreamGetBits(bs, 3);      // fcode_backward                                  *fcode_backward = BitstreamGetBits(bs, 3);      // fcode_backward
639                                    DPRINTF(DPRINTF_HEADER, "fcode_backward %i", *fcode_backward);
640                          }                          }
641                          if (!dec->scalability) {                          if (!dec->scalability) {
642                                  if ((dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) &&                                  if ((dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) &&
# Line 602  Line 645 
645                                  }                                  }
646                          }                          }
647                          return coding_type;                          return coding_type;
648    
649                  } else if (start_code == USERDATA_START_CODE) {                  } else if (start_code == USERDATA_START_CODE) {
650                          //DPRINTF("user_data");  
651                            DPRINTF(DPRINTF_STARTCODE, "<user_data>");
652    
653                          BitstreamSkip(bs, 32);  // user_data_start_code                          BitstreamSkip(bs, 32);  // user_data_start_code
654    
655                  } else                                  // start_code == ?                  } else                                  // start_code == ?
656                  {                  {
657                          if (BitstreamShowBits(bs, 24) == 0x000001) {                          if (BitstreamShowBits(bs, 24) == 0x000001) {
658                                  //DPRINTF("*** WARNING: unknown start_code %x",                                  DPRINTF(DPRINTF_STARTCODE, "<unknown: %x>", BitstreamShowBits(bs, 32));
                                 //         BitstreamShowBits(bs, 32));  
659                          }                          }
660                          BitstreamSkip(bs, 8);                          BitstreamSkip(bs, 8);
661                  }                  }
# Line 773  Line 819 
819          // time_increment: value=nth_of_sec, nbits = log2(resolution)          // time_increment: value=nth_of_sec, nbits = log2(resolution)
820  #ifdef BFRAMES  #ifdef BFRAMES
821          BitstreamPutBits(bs, frame->ticks, log2bin(pParam->fbase));          BitstreamPutBits(bs, frame->ticks, log2bin(pParam->fbase));
822          DPRINTF("[%i:%i] %c\n", frame->seconds, frame->ticks,          /*DPRINTF("[%i:%i] %c\n", frame->seconds, frame->ticks,
823                          frame->coding_type == I_VOP ? 'I' : frame->coding_type ==                          frame->coding_type == I_VOP ? 'I' : frame->coding_type ==
824                          P_VOP ? 'P' : 'B');                          P_VOP ? 'P' : 'B');*/
825  #else  #else
826          BitstreamPutBits(bs, 1, 1);          BitstreamPutBits(bs, 1, 1);
827  #endif  #endif

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

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