195 |
dec->low_delay = 0; |
dec->low_delay = 0; |
196 |
dec->packed_mode = 0; |
dec->packed_mode = 0; |
197 |
dec->time_inc_resolution = 1; /* until VOL header says otherwise */ |
dec->time_inc_resolution = 1; /* until VOL header says otherwise */ |
198 |
|
dec->ver_id = 1; |
199 |
|
|
200 |
dec->bs_version = 0xffff; /* Initialize to very high value -> assume bugfree stream */ |
dec->bs_version = 0xffff; /* Initialize to very high value -> assume bugfree stream */ |
201 |
|
|
202 |
dec->fixed_dimensions = (dec->width > 0 && dec->height > 0); |
dec->fixed_dimensions = (dec->width > 0 && dec->height > 0); |
203 |
|
|
204 |
if (dec->fixed_dimensions) |
if (dec->fixed_dimensions) { |
205 |
return decoder_resize(dec); |
int ret = decoder_resize(dec); |
206 |
|
if (ret == XVID_ERR_MEMORY) create->handle = NULL; |
207 |
|
return ret; |
208 |
|
} |
209 |
else |
else |
210 |
return 0; |
return 0; |
211 |
} |
} |
751 |
bound = read_video_packet_header(bs, dec, 0, |
bound = read_video_packet_header(bs, dec, 0, |
752 |
&quant, NULL, NULL, &intra_dc_threshold); |
&quant, NULL, NULL, &intra_dc_threshold); |
753 |
x = bound % mb_width; |
x = bound % mb_width; |
754 |
y = bound / mb_width; |
y = MIN((bound / mb_width), (mb_height-1)); |
755 |
} |
} |
756 |
mb = &dec->mbs[y * dec->mb_width + x]; |
mb = &dec->mbs[y * dec->mb_width + x]; |
757 |
|
|
978 |
bound = read_video_packet_header(bs, dec, fcode - 1, |
bound = read_video_packet_header(bs, dec, fcode - 1, |
979 |
&quant, &fcode, NULL, &intra_dc_threshold); |
&quant, &fcode, NULL, &intra_dc_threshold); |
980 |
x = bound % mb_width; |
x = bound % mb_width; |
981 |
y = bound / mb_width; |
y = MIN((bound / mb_width), (mb_height-1)); |
982 |
} |
} |
983 |
mb = &dec->mbs[y * dec->mb_width + x]; |
mb = &dec->mbs[y * dec->mb_width + x]; |
984 |
|
|
1338 |
return -1; |
return -1; |
1339 |
} |
} |
1340 |
|
|
1341 |
|
static int __inline get_resync_len_b(const int fcode_backward, |
1342 |
|
const int fcode_forward) { |
1343 |
|
int resync_len = ((fcode_forward>fcode_backward) ? fcode_forward : fcode_backward) - 1; |
1344 |
|
if (resync_len < 1) resync_len = 1; |
1345 |
|
return resync_len; |
1346 |
|
} |
1347 |
|
|
1348 |
static void |
static void |
1349 |
decoder_bframe(DECODER * dec, |
decoder_bframe(DECODER * dec, |
1350 |
Bitstream * bs, |
Bitstream * bs, |
1356 |
VECTOR mv; |
VECTOR mv; |
1357 |
const VECTOR zeromv = {0,0}; |
const VECTOR zeromv = {0,0}; |
1358 |
int i; |
int i; |
1359 |
|
int resync_len; |
1360 |
|
|
1361 |
if (!dec->is_edged[0]) { |
if (!dec->is_edged[0]) { |
1362 |
start_timer(); |
start_timer(); |
1374 |
stop_edges_timer(); |
stop_edges_timer(); |
1375 |
} |
} |
1376 |
|
|
1377 |
|
resync_len = get_resync_len_b(fcode_backward, fcode_forward); |
1378 |
for (y = 0; y < dec->mb_height; y++) { |
for (y = 0; y < dec->mb_height; y++) { |
1379 |
/* Initialize Pred Motion Vector */ |
/* Initialize Pred Motion Vector */ |
1380 |
dec->p_fmv = dec->p_bmv = zeromv; |
dec->p_fmv = dec->p_bmv = zeromv; |
1381 |
for (x = 0; x < dec->mb_width; x++) { |
for (x = 0; x < dec->mb_width; x++) { |
1382 |
MACROBLOCK *mb = &dec->mbs[y * dec->mb_width + x]; |
MACROBLOCK *mb = &dec->mbs[y * dec->mb_width + x]; |
1383 |
MACROBLOCK *last_mb = &dec->last_mbs[y * dec->mb_width + x]; |
MACROBLOCK *last_mb = &dec->last_mbs[y * dec->mb_width + x]; |
|
const int fcode_max = (fcode_forward>fcode_backward) ? fcode_forward : fcode_backward; |
|
1384 |
int intra_dc_threshold; /* fake variable */ |
int intra_dc_threshold; /* fake variable */ |
1385 |
|
|
1386 |
if (check_resync_marker(bs, fcode_max - 1)) { |
if (check_resync_marker(bs, resync_len)) { |
1387 |
int bound = read_video_packet_header(bs, dec, fcode_max - 1, &quant, |
int bound = read_video_packet_header(bs, dec, resync_len, &quant, |
1388 |
&fcode_forward, &fcode_backward, &intra_dc_threshold); |
&fcode_forward, &fcode_backward, &intra_dc_threshold); |
1389 |
x = bound % dec->mb_width; |
x = bound % dec->mb_width; |
1390 |
y = bound / dec->mb_width; |
y = MIN((bound / dec->mb_width), (dec->mb_height-1)); |
1391 |
/* reset predicted macroblocks */ |
/* reset predicted macroblocks */ |
1392 |
dec->p_fmv = dec->p_bmv = zeromv; |
dec->p_fmv = dec->p_bmv = zeromv; |
1393 |
|
/* update resync len with new fcodes */ |
1394 |
|
resync_len = get_resync_len_b(fcode_backward, fcode_forward); |
1395 |
} |
} |
1396 |
|
|
1397 |
mv = |
mv = |
1631 |
if (coding_type == -2 || coding_type == -3) { /* vol and/or resize */ |
if (coding_type == -2 || coding_type == -3) { /* vol and/or resize */ |
1632 |
|
|
1633 |
if (coding_type == -3) |
if (coding_type == -3) |
1634 |
decoder_resize(dec); |
if (decoder_resize(dec)) return XVID_ERR_MEMORY; |
1635 |
|
|
1636 |
if(stats) { |
if(stats) { |
1637 |
stats->type = XVID_TYPE_VOL; |
stats->type = XVID_TYPE_VOL; |