[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.22, Sun Jun 30 10:46:29 2002 UTC revision 1.28.2.3, Sat Oct 5 21:27:20 2002 UTC
# Line 41  Line 41 
41    *                                                                            *    *                                                                            *
42    *  Revision history:                                                         *    *  Revision history:                                                         *
43    *                                                                            *    *                                                                            *
44    *      22.05.2002 bs_put_matrix fix    *  04.10.2002 qpel support - Isibaar                                                                             *
45      *  11.07.2002 add VOP width & height return to dec when dec->width           *
46      *             or dec->height is 0  (for use in examples/ex1.c)               *
47      *             MinChen <chenm001@163.com>                                     *
48      *  22.05.2002 bs_put_matrix fix                                              *
49    *  20.05.2002 added BitstreamWriteUserData                                   *    *  20.05.2002 added BitstreamWriteUserData                                   *
50    *  19.06.2002  Fix a little bug in use custom quant matrix                   *    *  19.06.2002  Fix a little bug in use custom quant matrix                   *
51    *              MinChen <chenm001@163.com>                                    *    *              MinChen <chenm001@163.com>                                    *
# Line 57  Line 61 
61    *      30.02.2002     intra_dc_threshold support                             *    *      30.02.2002     intra_dc_threshold support                             *
62    *      04.12.2001     support for additional headers                         *    *      04.12.2001     support for additional headers                         *
63    *      16.12.2001     inital version                                         *    *      16.12.2001     inital version                                         *
64    *    *                                                                                                                                                        *
65    ******************************************************************************/    ******************************************************************************/
66    
67    
# Line 327  Line 331 
331    
332                          DPRINTF(DPRINTF_HEADER,"vop_time_increment_resolution %i", time_increment_resolution);                          DPRINTF(DPRINTF_HEADER,"vop_time_increment_resolution %i", time_increment_resolution);
333    
334                          time_increment_resolution--;  //                      time_increment_resolution--;
335    
336                          if (time_increment_resolution > 0) {                          if (time_increment_resolution > 0) {
337                                  dec->time_inc_bits = log2bin(time_increment_resolution);                                  dec->time_inc_bits = log2bin(time_increment_resolution-1);
338                          } else {                          } else {
339                                  // dec->time_inc_bits = 0;                                  // dec->time_inc_bits = 0;
340                                  // for "old" xvid compatibility, set time_inc_bits = 1                                  // for "old" xvid compatibility, set time_inc_bits = 1
# Line 359  Line 363 
363                                          DPRINTF(DPRINTF_HEADER, "width %i", width);                                          DPRINTF(DPRINTF_HEADER, "width %i", width);
364                                          DPRINTF(DPRINTF_HEADER, "height %i", height);                                          DPRINTF(DPRINTF_HEADER, "height %i", height);
365    
366                                            // for auto set width & height
367                                            if (dec->width == 0)
368                                                    dec->width = width;
369                                            if (dec->height == 0)
370                                                    dec->height = height;
371    
372                                          if (width != dec->width || height != dec->height) {                                          if (width != dec->width || height != dec->height) {
373                                                  DPRINTF(DPRINTF_ERROR, "XVID_DEC_PARAM width/height does not match bitstream");                                                  DPRINTF(DPRINTF_ERROR, "XVID_DEC_PARAM width/height does not match bitstream");
374                                                  return -1;                                                  return -1;
# Line 437  Line 447 
447    
448    
449                                  if (vol_ver_id != 1) {                                  if (vol_ver_id != 1) {
450                                          dec->quarterpel = BitstreamGetBit(bs);  // quarter_sampe                                          DEBUG("QUARTERPEL BITSTREAM");
451                                          if (dec->quarterpel) {                                          dec->quarterpel = BitstreamGetBit(bs);  // quarter_sample
                                                 DPRINTF(DPRINTF_ERROR, "quarter_sample not supported");  
452                                          }                                          }
453                                  } else {                                  else
454                                          dec->quarterpel = 0;                                          dec->quarterpel = 0;
455                                  }  
456    
457                                  if (!BitstreamGetBit(bs))       // complexity_estimation_disable                                  if (!BitstreamGetBit(bs))       // complexity_estimation_disable
458                                  {                                  {
# Line 538  Line 547 
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;
549                                  dec->time_base += time_incr;                                  dec->time_base += time_incr;
550                                  dec->time =                                  dec->time = time_increment;
551                                          dec->time_base * time_increment_resolution +  
552    /*                                      dec->time_base * time_increment_resolution +
553                                          time_increment;                                          time_increment;
554                                  dec->time_pp = (uint32_t) (dec->time - dec->last_non_b_time);  */                              dec->time_pp = (uint32_t)
555                                            (time_increment_resolution + dec->time - dec->last_non_b_time)%time_increment_resolution;
556                                  dec->last_non_b_time = dec->time;                                  dec->last_non_b_time = dec->time;
557                          } else {                          } else {
558                                  dec->time =                                  dec->time = time_increment;
559    /*
560                                          (dec->last_time_base +                                          (dec->last_time_base +
561                                           time_incr) * time_increment_resolution + time_increment;                                           time_incr) * time_increment_resolution + time_increment;
562                                  dec->time_bp = (uint32_t) (dec->last_non_b_time - dec->time);  */
563                                    dec->time_bp = (uint32_t)
564                                            (time_increment_resolution + dec->last_non_b_time - dec->time)%time_increment_resolution;
565                          }                          }
566    
567                          READ_MARKER();                          READ_MARKER();
# Line 606  Line 620 
620                                  *intra_dc_threshold =                                  *intra_dc_threshold =
621                                          intra_dc_threshold_table[BitstreamGetBits(bs, 3)];                                          intra_dc_threshold_table[BitstreamGetBits(bs, 3)];
622    
623                                    dec->top_field_first = 0;
624                                    dec->alternate_vertical_scan = 0;
625    
626                                  if (dec->interlacing) {                                  if (dec->interlacing) {
627                                          dec->top_field_first = BitstreamGetBit(bs);                                          dec->top_field_first = BitstreamGetBit(bs);
628                                          DPRINTF(DPRINTF_HEADER, "interlace top_field_first %i", dec->top_field_first);                                          DPRINTF(DPRINTF_HEADER, "interlace top_field_first %i", dec->top_field_first);
# Line 698  Line 715 
715    
716          BitstreamPutBit(bs, 0);         // random_accessible_vol          BitstreamPutBit(bs, 0);         // random_accessible_vol
717          BitstreamPutBits(bs, 0, 8);     // video_object_type_indication          BitstreamPutBits(bs, 0, 8);     // video_object_type_indication
718    
719            if (pParam->m_quarterpel == 0)
720            {
721          BitstreamPutBit(bs, 0);         // is_object_layer_identified (0=not given)          BitstreamPutBit(bs, 0);         // is_object_layer_identified (0=not given)
722            }
723            else
724            {
725                    BitstreamPutBit(bs, 1);         // is_object_layer_identified
726                    BitstreamPutBits(bs, 2, 4);     // vol_ver_id == 2
727                    BitstreamPutBits(bs, 0, 3); // vol_ver_priority = 0 ??
728            }
729    
730          BitstreamPutBits(bs, 1, 4);     // aspect_ratio_info (1=1:1)          BitstreamPutBits(bs, 1, 4);     // aspect_ratio_info (1=1:1)
731    
 #ifdef BFRAMES  
         if (pParam->max_bframes > 0) {  
                 //DPRINTF("low_delay=1");  
732                  BitstreamPutBit(bs, 1); // vol_control_parameters                  BitstreamPutBit(bs, 1); // vol_control_parameters
733                  BitstreamPutBits(bs, 1, 2);     // chroma_format 1="4:2:0"                  BitstreamPutBits(bs, 1, 2);     // chroma_format 1="4:2:0"
734    
735    #ifdef BFRAMES
736            if (pParam->max_bframes > 0) {
737                  BitstreamPutBit(bs, 0); // low_delay                  BitstreamPutBit(bs, 0); // low_delay
                 BitstreamPutBit(bs, 0); // vbv_parameters (0=not given)  
738          } else          } else
739  #endif  #endif
740          {          {
741                  BitstreamPutBits(bs, 0, 1);     // vol_control_parameters (0=not given)                  BitstreamPutBit(bs, 1); // low_delay
742          }          }
743            BitstreamPutBit(bs, 0); // vbv_parameters (0=not given)
744    
745          BitstreamPutBits(bs, 0, 2);     // video_object_layer_shape (0=rectangular)          BitstreamPutBits(bs, 0, 2);     // video_object_layer_shape (0=rectangular)
746    
# Line 727  Line 754 
754  #ifdef BFRAMES  #ifdef BFRAMES
755          BitstreamPutBits(bs, pParam->fbase, 16);          BitstreamPutBits(bs, pParam->fbase, 16);
756  #else  #else
757          BitstreamPutBits(bs, 2, 16);          BitstreamPutBits(bs, pParam->fbase, 16);
758  #endif  #endif
759    
760          WRITE_MARKER();          WRITE_MARKER();
# Line 736  Line 763 
763          BitstreamPutBit(bs, 1);         // fixed_vop_rate = 1          BitstreamPutBit(bs, 1);         // fixed_vop_rate = 1
764          BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase));    // fixed_vop_time_increment          BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase));    // fixed_vop_time_increment
765  #else  #else
766          BitstreamPutBit(bs, 0);         // fixed_vop_rate = 0          BitstreamPutBit(bs, 1);         // fixed_vop_rate = 1
767            BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase));    // fixed_vop_time_increment
768  #endif  #endif
769    
770          WRITE_MARKER();          WRITE_MARKER();
# Line 747  Line 775 
775    
776          BitstreamPutBit(bs, frame->global_flags & XVID_INTERLACING);    // interlace          BitstreamPutBit(bs, frame->global_flags & XVID_INTERLACING);    // interlace
777          BitstreamPutBit(bs, 1);         // obmc_disable (overlapped block motion compensation)          BitstreamPutBit(bs, 1);         // obmc_disable (overlapped block motion compensation)
778    
779            if (pParam->m_quarterpel == 0)
780            {
781          BitstreamPutBit(bs, 0);         // sprite_enable          BitstreamPutBit(bs, 0);         // sprite_enable
782            }
783            else
784            {
785                    BitstreamPutBits(bs, 0, 2);             // sprite_enable
786            }
787    
788          BitstreamPutBit(bs, 0);         // not_in_bit          BitstreamPutBit(bs, 0);         // not_in_bit
789    
790          // quant_type   0=h.263  1=mpeg4(quantizer tables)          // quant_type   0=h.263  1=mpeg4(quantizer tables)
# Line 766  Line 803 
803    
804          }          }
805    
806            if (pParam->m_quarterpel)
807            {
808                    BitstreamPutBit(bs, 1);
809            }
810    
811          BitstreamPutBit(bs, 1);         // complexity_estimation_disable          BitstreamPutBit(bs, 1);         // complexity_estimation_disable
812          BitstreamPutBit(bs, 1);         // resync_marker_disable          BitstreamPutBit(bs, 1);         // resync_marker_disable
813          BitstreamPutBit(bs, 0);         // data_partitioned          BitstreamPutBit(bs, 0);         // data_partitioned
814    
815            if (pParam->m_quarterpel)
816            {
817                    BitstreamPutBit(bs, 0);         // newpred_enable
818                    BitstreamPutBit(bs, 0);         // reduced_resolution_vop_enabled
819            }
820    
821          BitstreamPutBit(bs, 0);         // scalability          BitstreamPutBit(bs, 0);         // scalability
822  }  }
823    
# Line 787  Line 836 
836                                                  const FRAMEINFO * frame,                                                  const FRAMEINFO * frame,
837                                                  int vop_coded)                                                  int vop_coded)
838  {  {
 #ifdef BFRAMES  
839          uint32_t i;          uint32_t i;
840  #endif  
841          BitstreamPad(bs);          BitstreamPad(bs);
842          BitstreamPutBits(bs, VOP_START_CODE, 32);          BitstreamPutBits(bs, VOP_START_CODE, 32);
843    
844          BitstreamPutBits(bs, frame->coding_type, 2);          BitstreamPutBits(bs, frame->coding_type, 2);
845    
         // time_base = 0  write n x PutBit(1), PutBit(0)  
846  #ifdef BFRAMES  #ifdef BFRAMES
847          for (i = 0; i < frame->seconds; i++) {          for (i = 0; i < frame->seconds; i++) {
848                  BitstreamPutBit(bs, 1);                  BitstreamPutBit(bs, 1);
849          }          }
850          BitstreamPutBit(bs, 0);          BitstreamPutBit(bs, 0);
851  #else  #else
852          BitstreamPutBits(bs, 0, 1);          for (i = 0; i < frame->seconds; i++) {
853                    BitstreamPutBit(bs, 1);
854            }
855            BitstreamPutBit(bs, 0);
856    //      BitstreamPutBits(bs, 0, 1);
857  #endif  #endif
858    
859          WRITE_MARKER();          WRITE_MARKER();
# Line 814  Line 865 
865                          frame->coding_type == I_VOP ? 'I' : frame->coding_type ==                          frame->coding_type == I_VOP ? 'I' : frame->coding_type ==
866                          P_VOP ? 'P' : 'B');*/                          P_VOP ? 'P' : 'B');*/
867  #else  #else
868          BitstreamPutBits(bs, 1, 1);          BitstreamPutBits(bs, frame->ticks, log2bin(pParam->fbase));
869    //      BitstreamPutBits(bs, 1, 1);
870  #endif  #endif
871    
872          WRITE_MARKER();          WRITE_MARKER();
# Line 832  Line 884 
884          BitstreamPutBits(bs, 0, 3);     // intra_dc_vlc_threshold          BitstreamPutBits(bs, 0, 3);     // intra_dc_vlc_threshold
885    
886          if (frame->global_flags & XVID_INTERLACING) {          if (frame->global_flags & XVID_INTERLACING) {
887                  BitstreamPutBit(bs, 1); // top field first                  BitstreamPutBit(bs, (frame->global_flags & XVID_TOPFIELDFIRST));
888                  BitstreamPutBit(bs, 0); // alternate vertical scan                  BitstreamPutBit(bs, (frame->global_flags & XVID_ALTERNATESCAN));
889          }          }
890    
891          BitstreamPutBits(bs, frame->quant, 5);  // quantizer          BitstreamPutBits(bs, frame->quant, 5);  // quantizer

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.28.2.3

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