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

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

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

revision 1.39, Wed Feb 19 21:59:30 2003 UTC revision 1.39.2.7, Mon May 12 12:30:13 2003 UTC
# Line 513  Line 513 
513                          DPRINTF(DPRINTF_HEADER, "vol id %i", start_code & VIDOBJLAY_START_CODE_MASK);                          DPRINTF(DPRINTF_HEADER, "vol id %i", start_code & VIDOBJLAY_START_CODE_MASK);
514    
515                          BitstreamSkip(bs, 32);  // video_object_layer_start_code                          BitstreamSkip(bs, 32);  // video_object_layer_start_code
   
516                          BitstreamSkip(bs, 1);   // random_accessible_vol                          BitstreamSkip(bs, 1);   // random_accessible_vol
517    
518                          // video_object_type_indication              BitstreamSkip(bs, 8);   // video_object_type_indication
                         if (BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_SIMPLE &&  
                                 BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_CORE &&  
                                 BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_MAIN &&  
                                 BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_ACE &&  
                                 BitstreamShowBits(bs, 8) != VIDOBJLAY_TYPE_ART_SIMPLE &&  
                                 BitstreamShowBits(bs, 8) != 0)  // BUGGY DIVX  
                         {  
                                 DPRINTF(DPRINTF_ERROR,"video_object_type_indication %i not supported ",  
                                         BitstreamShowBits(bs, 8));  
                                 return -1;  
                         }  
                         BitstreamSkip(bs, 8);  
   
519    
520                          if (BitstreamGetBit(bs))        // is_object_layer_identifier                          if (BitstreamGetBit(bs))        // is_object_layer_identifier
521                          {                          {
# Line 640  Line 626 
626                                          {                                          {
627                                                  if (dec->fixed_dimensions)                                                  if (dec->fixed_dimensions)
628                                                  {                                                  {
629                                                          DPRINTF(DPRINTF_ERROR, "XVID_DEC_PARAM width/height does not match bitstream");                                                          DPRINTF(DPRINTF_ERROR, "decoder width/height does not match bitstream");
630                                                          return -1;                                                          return -1;
631                                                  }                                                  }
632                                                  resize = 1;                                                  resize = 1;
# Line 1068  Line 1054 
1054                                  BitstreamSkip(bs, 8);                                  BitstreamSkip(bs, 8);
1055                          }                          }
1056    
1057                          DPRINTF(DPRINTF_STARTCODE, "<user_data>: %s\n", tmp);                          DPRINTF(DPRINTF_STARTCODE, "<user_data>: %s", tmp);
1058    
1059                      /* divx detection */                      /* divx detection */
1060                          i = sscanf(tmp, "DivX%dBuild%d%c", &version, &build, &packed);                          i = sscanf(tmp, "DivX%dBuild%d%c", &version, &build, &packed);
# Line 1123  Line 1109 
1109  */  */
1110  void  void
1111  BitstreamWriteVolHeader(Bitstream * const bs,  BitstreamWriteVolHeader(Bitstream * const bs,
1112                                                  const MBParam * pParam,                                                  const MBParam * pParam)
                                                 const FRAMEINFO * const frame)  
1113  {  {
1114          static const unsigned int vo_id = 0;          static const unsigned int vo_id = 0;
1115          static const unsigned int vol_id = 0;          static const unsigned int vol_id = 0;
1116          int vol_ver_id=1;          int vol_ver_id=1;
1117          int profile = 0x03;     /* simple profile/level 3 */      int vol_type_ind=VIDOBJLAY_TYPE_SIMPLE;
1118    
1119          if ( pParam->m_quarterpel ||  (frame->global_flags & XVID_GMC) ||          if ( (pParam->vol_flags & XVID_VOL_QUARTERPEL) ||
1120                   (pParam->global & XVID_GLOBAL_REDUCED))           (pParam->vol_flags & XVID_VOL_GMC) ||
1121                     (pParam->vol_flags & XVID_VOL_REDUCED_ENABLE))
1122                  vol_ver_id = 2;                  vol_ver_id = 2;
1123    
1124          if ((pParam->global & XVID_GLOBAL_REDUCED))      if ((pParam->vol_flags & XVID_VOL_REDUCED_ENABLE)) {
1125                  profile = 0x93; /* advanced realtime simple profile/level 3 */          vol_type_ind = VIDOBJLAY_TYPE_ART_SIMPLE;
1126        }
1127    
1128          if (pParam->m_quarterpel ||  (frame->global_flags & XVID_GMC))          if ((pParam->vol_flags & XVID_VOL_QUARTERPEL) ||
1129                  profile = 0xf3; /* advanced simple profile/level 2 */          (pParam->vol_flags & XVID_VOL_GMC)) {
1130            vol_type_ind = VIDOBJLAY_TYPE_ASP;
1131        }
1132    
1133          // visual_object_sequence_start_code          // visual_object_sequence_start_code
1134  //      BitstreamPad(bs);  //      BitstreamPad(bs);
1135  /* no padding here, anymore. You have to make sure that you are  /* no padding here, anymore. You have to make sure that you are
1136     byte aligned, and that always 1-8 padding bits have been written */     byte aligned, and that always 1-8 padding bits have been written */
1137    
1138        if (pParam->profile) {
1139          BitstreamPutBits(bs, VISOBJSEQ_START_CODE, 32);          BitstreamPutBits(bs, VISOBJSEQ_START_CODE, 32);
1140          BitstreamPutBits(bs, profile, 8);              BitstreamPutBits(bs, pParam->profile, 8);
1141        }
1142    
1143          // visual_object_start_code          // visual_object_start_code
1144          BitstreamPad(bs);          BitstreamPad(bs);
# Line 1164  Line 1155 
1155          BitstreamPutBits(bs, VIDOBJLAY_START_CODE|(vol_id&0x4), 32);          BitstreamPutBits(bs, VIDOBJLAY_START_CODE|(vol_id&0x4), 32);
1156    
1157          BitstreamPutBit(bs, 0);         // random_accessible_vol          BitstreamPutBit(bs, 0);         // random_accessible_vol
1158          BitstreamPutBits(bs, 0, 8);     // video_object_type_indication          BitstreamPutBits(bs, vol_type_ind, 8);  // video_object_type_indication
1159    
1160          if (vol_ver_id == 1)          if (vol_ver_id == 1)
1161          {          {
# Line 1203  Line 1194 
1194    
1195          WRITE_MARKER();          WRITE_MARKER();
1196    
1197        if (pParam->fincr>0) {
1198          BitstreamPutBit(bs, 1);         // fixed_vop_rate = 1          BitstreamPutBit(bs, 1);         // fixed_vop_rate = 1
1199          BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase));    // fixed_vop_time_increment          BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase));    // fixed_vop_time_increment
1200        }else{
1201            BitstreamPutBit(bs, 0);         // fixed_vop_rate = 0
1202        }
1203    
1204          WRITE_MARKER();          WRITE_MARKER();
1205          BitstreamPutBits(bs, pParam->width, 13);        // width          BitstreamPutBits(bs, pParam->width, 13);        // width
# Line 1212  Line 1207 
1207          BitstreamPutBits(bs, pParam->height, 13);       // height          BitstreamPutBits(bs, pParam->height, 13);       // height
1208          WRITE_MARKER();          WRITE_MARKER();
1209    
1210          BitstreamPutBit(bs, frame->global_flags & XVID_INTERLACING);    // interlace          BitstreamPutBit(bs, pParam->vol_flags & XVID_VOL_INTERLACING);  // interlace
1211          BitstreamPutBit(bs, 1);         // obmc_disable (overlapped block motion compensation)          BitstreamPutBit(bs, 1);         // obmc_disable (overlapped block motion compensation)
1212    
1213          if (vol_ver_id != 1)          if (vol_ver_id != 1)
1214          {       if (frame->global_flags & XVID_GMC)          {       if ((pParam->vol_flags & XVID_VOL_GMC))
1215                  {       BitstreamPutBits(bs, 2, 2);             // sprite_enable=='GMC'                  {       BitstreamPutBits(bs, 2, 2);             // sprite_enable=='GMC'
1216                          BitstreamPutBits(bs, 2, 6);             // no_of_sprite_warping_points                          BitstreamPutBits(bs, 2, 6);             // no_of_sprite_warping_points
1217                          BitstreamPutBits(bs, 3, 2);             // sprite_warping_accuracy 0==1/2, 1=1/4, 2=1/8, 3=1/16                          BitstreamPutBits(bs, 3, 2);             // sprite_warping_accuracy 0==1/2, 1=1/4, 2=1/8, 3=1/16
# Line 1234  Line 1229 
1229          BitstreamPutBit(bs, 0);         // not_8_bit          BitstreamPutBit(bs, 0);         // not_8_bit
1230    
1231          // quant_type   0=h.263  1=mpeg4(quantizer tables)          // quant_type   0=h.263  1=mpeg4(quantizer tables)
1232          BitstreamPutBit(bs, pParam->m_quant_type);          BitstreamPutBit(bs, pParam->vol_flags & XVID_VOL_MPEGQUANT);
1233    
1234          if (pParam->m_quant_type) {          if ((pParam->vol_flags & XVID_VOL_MPEGQUANT)) {
1235                  BitstreamPutBit(bs, get_intra_matrix_status()); // load_intra_quant_mat                  BitstreamPutBit(bs, get_intra_matrix_status()); // load_intra_quant_mat
1236                  if (get_intra_matrix_status()) {                  if (get_intra_matrix_status()) {
1237                          bs_put_matrix(bs, get_intra_matrix());                          bs_put_matrix(bs, get_intra_matrix());
# Line 1250  Line 1245 
1245          }          }
1246    
1247          if (vol_ver_id != 1) {          if (vol_ver_id != 1) {
1248                  if (pParam->m_quarterpel)                  if ((pParam->vol_flags & XVID_VOL_QUARTERPEL))
1249                          BitstreamPutBit(bs, 1);         //  quarterpel                          BitstreamPutBit(bs, 1);         //  quarterpel
1250                  else                  else
1251                          BitstreamPutBit(bs, 0);         // no quarterpel                          BitstreamPutBit(bs, 0);         // no quarterpel
# Line 1264  Line 1259 
1259          {          {
1260                  BitstreamPutBit(bs, 0);         // newpred_enable                  BitstreamPutBit(bs, 0);         // newpred_enable
1261    
1262                  BitstreamPutBit(bs, (pParam->global & XVID_GLOBAL_REDUCED)?1:0);                  BitstreamPutBit(bs, (pParam->vol_flags & XVID_VOL_REDUCED_ENABLE)?1:0);
1263                                                                          /* reduced_resolution_vop_enabled */                                                                          /* reduced_resolution_vop_enabled */
1264          }          }
1265    
1266          BitstreamPutBit(bs, 0);         // scalability          BitstreamPutBit(bs, 0);         // scalability
1267    
1268          /* fake divx5 id, to ensure compatibility with divx5 decoder */          /* fake divx5 id, to ensure compatibility with divx5 decoder */
1269  #define DIVX5_ID "DivX501b481p"  #define DIVX5_ID "DivX000b000p"
1270          if (pParam->max_bframes > 0 && (pParam->global & XVID_GLOBAL_PACKED)) {          if (pParam->max_bframes > 0 && (pParam->global_flags & XVID_GLOBAL_PACKED)) {
1271                  BitstreamWriteUserData(bs, DIVX5_ID, strlen(DIVX5_ID));                  BitstreamWriteUserData(bs, DIVX5_ID, strlen(DIVX5_ID));
1272          }          }
1273    
# Line 1329  Line 1324 
1324          if ( (frame->coding_type == P_VOP) || (frame->coding_type == S_VOP) )          if ( (frame->coding_type == P_VOP) || (frame->coding_type == S_VOP) )
1325                  BitstreamPutBits(bs, frame->rounding_type, 1);                  BitstreamPutBits(bs, frame->rounding_type, 1);
1326    
1327          if ((pParam->global & XVID_GLOBAL_REDUCED))          if ((frame->vol_flags & XVID_VOL_REDUCED_ENABLE))
1328                  BitstreamPutBit(bs, (frame->global_flags & XVID_REDUCED)?1:0);                  BitstreamPutBit(bs, (frame->vop_flags & XVID_VOP_REDUCED)?1:0);
1329    
1330          BitstreamPutBits(bs, 0, 3);     // intra_dc_vlc_threshold          BitstreamPutBits(bs, 0, 3);     // intra_dc_vlc_threshold
1331    
1332          if (frame->global_flags & XVID_INTERLACING) {          if ((frame->vol_flags & XVID_VOL_INTERLACING)) {
1333                  BitstreamPutBit(bs, (frame->global_flags & XVID_TOPFIELDFIRST));                  BitstreamPutBit(bs, (frame->vop_flags & XVID_VOP_TOPFIELDFIRST));
1334                  BitstreamPutBit(bs, (frame->global_flags & XVID_ALTERNATESCAN));                  BitstreamPutBit(bs, (frame->vop_flags & XVID_VOP_ALTERNATESCAN));
1335          }          }
1336    
1337          if (frame->coding_type == S_VOP) {          if (frame->coding_type == S_VOP) {
# Line 1350  Line 1345 
1345                                  bs_put_spritetrajectory(bs, frame->warp.duv[k].y ); // dv[k]                                  bs_put_spritetrajectory(bs, frame->warp.duv[k].y ); // dv[k]
1346                                  WRITE_MARKER();                                  WRITE_MARKER();
1347    
1348                          if (pParam->m_quarterpel)                          if ((frame->vol_flags & XVID_VOL_QUARTERPEL))
1349                          {                          {
1350                                  DPRINTF(DPRINTF_HEADER,"sprite_warping_point[%i] xy=(%i,%i) *QPEL*", k, frame->warp.duv[k].x/2, frame->warp.duv[k].y/2);                                  DPRINTF(DPRINTF_HEADER,"sprite_warping_point[%i] xy=(%i,%i) *QPEL*", k, frame->warp.duv[k].x/2, frame->warp.duv[k].y/2);
1351                          }                          }

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

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