438 |
uint32_t coding_type; |
uint32_t coding_type; |
439 |
uint32_t start_code; |
uint32_t start_code; |
440 |
uint32_t time_incr = 0; |
uint32_t time_incr = 0; |
441 |
int32_t time_increment; |
int32_t time_increment = 0; |
442 |
int resize = 0; |
int resize = 0; |
443 |
|
|
444 |
do { |
do { |
640 |
{ |
{ |
641 |
if (dec->fixed_dimensions) |
if (dec->fixed_dimensions) |
642 |
{ |
{ |
643 |
DPRINTF(DPRINTF_ERROR, "XVID_DEC_PARAM width/height does not match bitstream"); |
DPRINTF(DPRINTF_ERROR, "decoder width/height does not match bitstream"); |
644 |
return -1; |
return -1; |
645 |
} |
} |
646 |
resize = 1; |
resize = 1; |
1123 |
*/ |
*/ |
1124 |
void |
void |
1125 |
BitstreamWriteVolHeader(Bitstream * const bs, |
BitstreamWriteVolHeader(Bitstream * const bs, |
1126 |
const MBParam * pParam, |
const MBParam * pParam) |
|
const FRAMEINFO * const frame) |
|
1127 |
{ |
{ |
1128 |
static const unsigned int vo_id = 0; |
static const unsigned int vo_id = 0; |
1129 |
static const unsigned int vol_id = 0; |
static const unsigned int vol_id = 0; |
1130 |
int vol_ver_id=1; |
int vol_ver_id=1; |
1131 |
int profile = 0x03; /* simple profile/level 3 */ |
int profile = 0x03; /* simple profile/level 3 */ |
1132 |
|
|
1133 |
if ( pParam->m_quarterpel || (frame->global_flags & XVID_GMC) || |
if ( (pParam->vol_flags & XVID_QUARTERPEL) || |
1134 |
(pParam->global & XVID_GLOBAL_REDUCED)) |
(pParam->vol_flags & XVID_GMC) || |
1135 |
|
(pParam->vol_flags & XVID_REDUCED_ENABLE)) |
1136 |
vol_ver_id = 2; |
vol_ver_id = 2; |
1137 |
|
|
1138 |
if ((pParam->global & XVID_GLOBAL_REDUCED)) |
if ((pParam->vol_flags & XVID_REDUCED_ENABLE)) |
1139 |
profile = 0x93; /* advanced realtime simple profile/level 3 */ |
profile = 0x93; /* advanced realtime simple profile/level 3 */ |
1140 |
|
|
1141 |
if (pParam->m_quarterpel || (frame->global_flags & XVID_GMC)) |
if ((pParam->vol_flags & XVID_QUARTERPEL) || |
1142 |
|
(pParam->vol_flags & XVID_GMC)) |
1143 |
profile = 0xf3; /* advanced simple profile/level 2 */ |
profile = 0xf3; /* advanced simple profile/level 2 */ |
1144 |
|
|
1145 |
// visual_object_sequence_start_code |
// visual_object_sequence_start_code |
1213 |
BitstreamPutBits(bs, pParam->height, 13); // height |
BitstreamPutBits(bs, pParam->height, 13); // height |
1214 |
WRITE_MARKER(); |
WRITE_MARKER(); |
1215 |
|
|
1216 |
BitstreamPutBit(bs, frame->global_flags & XVID_INTERLACING); // interlace |
BitstreamPutBit(bs, pParam->vol_flags & XVID_INTERLACING); // interlace |
1217 |
BitstreamPutBit(bs, 1); // obmc_disable (overlapped block motion compensation) |
BitstreamPutBit(bs, 1); // obmc_disable (overlapped block motion compensation) |
1218 |
|
|
1219 |
if (vol_ver_id != 1) |
if (vol_ver_id != 1) |
1220 |
{ if (frame->global_flags & XVID_GMC) |
{ if ((pParam->vol_flags & XVID_GMC)) |
1221 |
{ BitstreamPutBits(bs, 2, 2); // sprite_enable=='GMC' |
{ BitstreamPutBits(bs, 2, 2); // sprite_enable=='GMC' |
1222 |
BitstreamPutBits(bs, 2, 6); // no_of_sprite_warping_points |
BitstreamPutBits(bs, 2, 6); // no_of_sprite_warping_points |
1223 |
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 |
1235 |
BitstreamPutBit(bs, 0); // not_8_bit |
BitstreamPutBit(bs, 0); // not_8_bit |
1236 |
|
|
1237 |
// quant_type 0=h.263 1=mpeg4(quantizer tables) |
// quant_type 0=h.263 1=mpeg4(quantizer tables) |
1238 |
BitstreamPutBit(bs, pParam->m_quant_type); |
BitstreamPutBit(bs, pParam->vol_flags & XVID_MPEGQUANT); |
1239 |
|
|
1240 |
if (pParam->m_quant_type) { |
if ((pParam->vol_flags & XVID_MPEGQUANT)) { |
1241 |
BitstreamPutBit(bs, get_intra_matrix_status()); // load_intra_quant_mat |
BitstreamPutBit(bs, get_intra_matrix_status()); // load_intra_quant_mat |
1242 |
if (get_intra_matrix_status()) { |
if (get_intra_matrix_status()) { |
1243 |
bs_put_matrix(bs, get_intra_matrix()); |
bs_put_matrix(bs, get_intra_matrix()); |
1251 |
} |
} |
1252 |
|
|
1253 |
if (vol_ver_id != 1) { |
if (vol_ver_id != 1) { |
1254 |
if (pParam->m_quarterpel) |
if ((pParam->vol_flags & XVID_QUARTERPEL)) |
1255 |
BitstreamPutBit(bs, 1); // quarterpel |
BitstreamPutBit(bs, 1); // quarterpel |
1256 |
else |
else |
1257 |
BitstreamPutBit(bs, 0); // no quarterpel |
BitstreamPutBit(bs, 0); // no quarterpel |
1265 |
{ |
{ |
1266 |
BitstreamPutBit(bs, 0); // newpred_enable |
BitstreamPutBit(bs, 0); // newpred_enable |
1267 |
|
|
1268 |
BitstreamPutBit(bs, (pParam->global & XVID_GLOBAL_REDUCED)?1:0); |
BitstreamPutBit(bs, (pParam->vol_flags & XVID_REDUCED_ENABLE)?1:0); |
1269 |
/* reduced_resolution_vop_enabled */ |
/* reduced_resolution_vop_enabled */ |
1270 |
} |
} |
1271 |
|
|
1272 |
BitstreamPutBit(bs, 0); // scalability |
BitstreamPutBit(bs, 0); // scalability |
1273 |
|
|
1274 |
/* fake divx5 id, to ensure compatibility with divx5 decoder */ |
/* fake divx5 id, to ensure compatibility with divx5 decoder */ |
1275 |
#define DIVX5_ID "DivX501b481p" |
#define DIVX5_ID "DivX000b000p" |
1276 |
if (pParam->max_bframes > 0 && (pParam->global & XVID_GLOBAL_PACKED)) { |
if (pParam->max_bframes > 0 && (pParam->global_flags & XVID_PACKED)) { |
1277 |
BitstreamWriteUserData(bs, DIVX5_ID, strlen(DIVX5_ID)); |
BitstreamWriteUserData(bs, DIVX5_ID, strlen(DIVX5_ID)); |
1278 |
} |
} |
1279 |
|
|
1330 |
if ( (frame->coding_type == P_VOP) || (frame->coding_type == S_VOP) ) |
if ( (frame->coding_type == P_VOP) || (frame->coding_type == S_VOP) ) |
1331 |
BitstreamPutBits(bs, frame->rounding_type, 1); |
BitstreamPutBits(bs, frame->rounding_type, 1); |
1332 |
|
|
1333 |
if ((pParam->global & XVID_GLOBAL_REDUCED)) |
if ((frame->vol_flags & XVID_REDUCED_ENABLE)) |
1334 |
BitstreamPutBit(bs, (frame->global_flags & XVID_REDUCED)?1:0); |
BitstreamPutBit(bs, (frame->vop_flags & XVID_REDUCED)?1:0); |
1335 |
|
|
1336 |
BitstreamPutBits(bs, 0, 3); // intra_dc_vlc_threshold |
BitstreamPutBits(bs, 0, 3); // intra_dc_vlc_threshold |
1337 |
|
|
1338 |
if (frame->global_flags & XVID_INTERLACING) { |
if ((frame->vol_flags & XVID_INTERLACING)) { |
1339 |
BitstreamPutBit(bs, (frame->global_flags & XVID_TOPFIELDFIRST)); |
BitstreamPutBit(bs, (frame->vop_flags & XVID_TOPFIELDFIRST)); |
1340 |
BitstreamPutBit(bs, (frame->global_flags & XVID_ALTERNATESCAN)); |
BitstreamPutBit(bs, (frame->vop_flags & XVID_ALTERNATESCAN)); |
1341 |
} |
} |
1342 |
|
|
1343 |
if (frame->coding_type == S_VOP) { |
if (frame->coding_type == S_VOP) { |
1351 |
bs_put_spritetrajectory(bs, frame->warp.duv[k].y ); // dv[k] |
bs_put_spritetrajectory(bs, frame->warp.duv[k].y ); // dv[k] |
1352 |
WRITE_MARKER(); |
WRITE_MARKER(); |
1353 |
|
|
1354 |
if (pParam->m_quarterpel) |
if ((frame->vol_flags & XVID_QUARTERPEL)) |
1355 |
{ |
{ |
1356 |
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); |
1357 |
} |
} |