4 |
* - Decoder Module - |
* - Decoder Module - |
5 |
* |
* |
6 |
* Copyright(C) 2002 MinChen <chenm001@163.com> |
* Copyright(C) 2002 MinChen <chenm001@163.com> |
7 |
* 2002-2004 Peter Ross <pross@xvid.org> |
* 2002-2010 Peter Ross <pross@xvid.org> |
8 |
* |
* |
9 |
* This program is free software ; you can redistribute it and/or modify |
* This program is free software ; you can redistribute it and/or modify |
10 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
20 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
* |
* |
23 |
* $Id: decoder.c,v 1.82 2010-08-10 14:17:23 Isibaar Exp $ |
* $Id$ |
24 |
* |
* |
25 |
****************************************************************************/ |
****************************************************************************/ |
26 |
|
|
172 |
dec->width = create->width; |
dec->width = create->width; |
173 |
dec->height = create->height; |
dec->height = create->height; |
174 |
|
|
175 |
|
dec->num_threads = MAX(0, create->num_threads); |
176 |
|
|
177 |
image_null(&dec->cur); |
image_null(&dec->cur); |
178 |
image_null(&dec->refn[0]); |
image_null(&dec->refn[0]); |
179 |
image_null(&dec->refn[1]); |
image_null(&dec->refn[1]); |
201 |
|
|
202 |
if (create->fourcc == ((int)('X')|((int)('V')<<8)| |
if (create->fourcc == ((int)('X')|((int)('V')<<8)| |
203 |
((int)('I')<<16)|((int)('D')<<24))) { /* XVID */ |
((int)('I')<<16)|((int)('D')<<24))) { /* XVID */ |
204 |
dec->bs_version = 1; /* Initially assume oldest xvid version */ |
dec->bs_version = 0; /* Initially assume oldest xvid version */ |
205 |
} |
} |
206 |
else { |
else { |
207 |
dec->bs_version = 0xffff; /* Initialize to very high value -> assume bugfree stream */ |
dec->bs_version = 0xffff; /* Initialize to very high value -> assume bugfree stream */ |
1391 |
MACROBLOCK *last_mb = &dec->last_mbs[y * dec->mb_width + x]; |
MACROBLOCK *last_mb = &dec->last_mbs[y * dec->mb_width + x]; |
1392 |
int intra_dc_threshold; /* fake variable */ |
int intra_dc_threshold; /* fake variable */ |
1393 |
|
|
|
if (check_resync_marker(bs, resync_len)) { |
|
|
int bound = read_video_packet_header(bs, dec, resync_len, &quant, |
|
|
&fcode_forward, &fcode_backward, &intra_dc_threshold); |
|
|
x = bound % dec->mb_width; |
|
|
y = MIN((bound / dec->mb_width), (dec->mb_height-1)); |
|
|
/* reset predicted macroblocks */ |
|
|
dec->p_fmv = dec->p_bmv = zeromv; |
|
|
/* update resync len with new fcodes */ |
|
|
resync_len = get_resync_len_b(fcode_backward, fcode_forward); |
|
|
} |
|
|
|
|
1394 |
mv = |
mv = |
1395 |
mb->b_mvs[0] = mb->b_mvs[1] = mb->b_mvs[2] = mb->b_mvs[3] = |
mb->b_mvs[0] = mb->b_mvs[1] = mb->b_mvs[2] = mb->b_mvs[3] = |
1396 |
mb->mvs[0] = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = zeromv; |
mb->mvs[0] = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = zeromv; |
1409 |
continue; |
continue; |
1410 |
} |
} |
1411 |
|
|
1412 |
|
if (check_resync_marker(bs, resync_len)) { |
1413 |
|
int bound = read_video_packet_header(bs, dec, resync_len, &quant, |
1414 |
|
&fcode_forward, &fcode_backward, &intra_dc_threshold); |
1415 |
|
|
1416 |
|
bound = MAX(0, bound-1); /* valid bound must always be >0 */ |
1417 |
|
x = bound % dec->mb_width; |
1418 |
|
y = MIN((bound / dec->mb_width), (dec->mb_height-1)); |
1419 |
|
/* reset predicted macroblocks */ |
1420 |
|
dec->p_fmv = dec->p_bmv = zeromv; |
1421 |
|
/* update resync len with new fcodes */ |
1422 |
|
resync_len = get_resync_len_b(fcode_backward, fcode_forward); |
1423 |
|
continue; /* re-init loop */ |
1424 |
|
} |
1425 |
|
|
1426 |
if (!BitstreamGetBit(bs)) { /* modb=='0' */ |
if (!BitstreamGetBit(bs)) { /* modb=='0' */ |
1427 |
const uint8_t modb2 = BitstreamGetBit(bs); |
const uint8_t modb2 = BitstreamGetBit(bs); |
1428 |
|
|
1536 |
image_copy(&dec->tmp, img, dec->edged_width, dec->height); |
image_copy(&dec->tmp, img, dec->edged_width, dec->height); |
1537 |
image_postproc(&dec->postproc, &dec->tmp, dec->edged_width, |
image_postproc(&dec->postproc, &dec->tmp, dec->edged_width, |
1538 |
mbs, dec->mb_width, dec->mb_height, dec->mb_width, |
mbs, dec->mb_width, dec->mb_height, dec->mb_width, |
1539 |
frame->general, brightness, dec->frames, (coding_type == B_VOP)); |
frame->general, brightness, dec->frames, (coding_type == B_VOP), dec->num_threads); |
1540 |
img = &dec->tmp; |
img = &dec->tmp; |
1541 |
} |
} |
1542 |
|
|
1647 |
if(stats) { |
if(stats) { |
1648 |
stats->type = XVID_TYPE_VOL; |
stats->type = XVID_TYPE_VOL; |
1649 |
stats->data.vol.general = 0; |
stats->data.vol.general = 0; |
1650 |
/*XXX: if (dec->interlacing) |
stats->data.vop.general = 0; |
1651 |
stats->data.vol.general |= ++INTERLACING; */ |
if (dec->interlacing) { |
1652 |
|
stats->data.vol.general |= XVID_VOL_INTERLACING; |
1653 |
|
if (dec->top_field_first) { |
1654 |
|
stats->data.vop.general |= XVID_VOP_TOPFIELDFIRST; |
1655 |
|
} |
1656 |
|
} |
1657 |
stats->data.vol.width = dec->width; |
stats->data.vol.width = dec->width; |
1658 |
stats->data.vol.height = dec->height; |
stats->data.vol.height = dec->height; |
1659 |
stats->data.vol.par = dec->aspect_ratio; |
stats->data.vol.par = dec->aspect_ratio; |
1670 |
goto repeat; |
goto repeat; |
1671 |
} |
} |
1672 |
|
|
1673 |
dec->p_bmv.x = dec->p_bmv.y = dec->p_fmv.y = dec->p_fmv.y = 0; /* init pred vector to 0 */ |
dec->p_bmv.x = dec->p_bmv.y = dec->p_fmv.x = dec->p_fmv.y = 0; /* init pred vector to 0 */ |
1674 |
|
|
1675 |
/* packed_mode: special-N_VOP treament */ |
/* packed_mode: special-N_VOP treament */ |
1676 |
if (dec->packed_mode && coding_type == N_VOP) { |
if (dec->packed_mode && coding_type == N_VOP) { |