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) != VIDOBJLAY_TYPE_ASP && |
|
|
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 |
{ |
{ |
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->vol_flags & XVID_QUARTERPEL) || |
if ( (pParam->vol_flags & XVID_VOL_QUARTERPEL) || |
1120 |
(pParam->vol_flags & XVID_GMC) || |
(pParam->vol_flags & XVID_VOL_GMC) || |
1121 |
(pParam->vol_flags & XVID_REDUCED_ENABLE)) |
(pParam->vol_flags & XVID_VOL_REDUCED_ENABLE)) |
1122 |
vol_ver_id = 2; |
vol_ver_id = 2; |
1123 |
|
|
1124 |
if ((pParam->vol_flags & XVID_REDUCED_ENABLE)) |
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->vol_flags & XVID_QUARTERPEL) || |
if ((pParam->vol_flags & XVID_VOL_QUARTERPEL) || |
1129 |
(pParam->vol_flags & XVID_GMC)) |
(pParam->vol_flags & XVID_VOL_GMC)) { |
1130 |
profile = 0xf3; /* advanced simple profile/level 2 */ |
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); |
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 |
{ |
{ |
1207 |
BitstreamPutBits(bs, pParam->height, 13); // height |
BitstreamPutBits(bs, pParam->height, 13); // height |
1208 |
WRITE_MARKER(); |
WRITE_MARKER(); |
1209 |
|
|
1210 |
BitstreamPutBit(bs, pParam->vol_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 ((pParam->vol_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 |
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->vol_flags & XVID_MPEGQUANT); |
BitstreamPutBit(bs, pParam->vol_flags & XVID_VOL_MPEGQUANT); |
1233 |
|
|
1234 |
if ((pParam->vol_flags & XVID_MPEGQUANT)) { |
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()); |
1245 |
} |
} |
1246 |
|
|
1247 |
if (vol_ver_id != 1) { |
if (vol_ver_id != 1) { |
1248 |
if ((pParam->vol_flags & XVID_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 |
1259 |
{ |
{ |
1260 |
BitstreamPutBit(bs, 0); // newpred_enable |
BitstreamPutBit(bs, 0); // newpred_enable |
1261 |
|
|
1262 |
BitstreamPutBit(bs, (pParam->vol_flags & XVID_REDUCED_ENABLE)?1:0); |
BitstreamPutBit(bs, (pParam->vol_flags & XVID_VOL_REDUCED_ENABLE)?1:0); |
1263 |
/* reduced_resolution_vop_enabled */ |
/* reduced_resolution_vop_enabled */ |
1264 |
} |
} |
1265 |
|
|
1267 |
|
|
1268 |
/* fake divx5 id, to ensure compatibility with divx5 decoder */ |
/* fake divx5 id, to ensure compatibility with divx5 decoder */ |
1269 |
#define DIVX5_ID "DivX000b000p" |
#define DIVX5_ID "DivX000b000p" |
1270 |
if (pParam->max_bframes > 0 && (pParam->global_flags & XVID_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 |
|
|
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 ((frame->vol_flags & XVID_REDUCED_ENABLE)) |
if ((frame->vol_flags & XVID_VOL_REDUCED_ENABLE)) |
1328 |
BitstreamPutBit(bs, (frame->vop_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->vol_flags & XVID_INTERLACING)) { |
if ((frame->vol_flags & XVID_VOL_INTERLACING)) { |
1333 |
BitstreamPutBit(bs, (frame->vop_flags & XVID_TOPFIELDFIRST)); |
BitstreamPutBit(bs, (frame->vop_flags & XVID_VOP_TOPFIELDFIRST)); |
1334 |
BitstreamPutBit(bs, (frame->vop_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) { |
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 ((frame->vol_flags & XVID_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 |
} |
} |