55 |
* 22.12.2001 lock based interpolation |
* 22.12.2001 lock based interpolation |
56 |
* 01.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
* 01.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
57 |
* |
* |
58 |
* $Id: decoder.c,v 1.37.2.28 2003-01-11 20:37:46 chl Exp $ |
* $Id: decoder.c,v 1.37.2.29 2003-01-11 21:22:24 chl Exp $ |
59 |
* |
* |
60 |
*************************************************************************/ |
*************************************************************************/ |
61 |
|
|
412 |
const MACROBLOCK * pMB, |
const MACROBLOCK * pMB, |
413 |
const uint32_t x_pos, |
const uint32_t x_pos, |
414 |
const uint32_t y_pos, |
const uint32_t y_pos, |
415 |
const uint32_t acpred_flag, |
const uint32_t fcode, |
416 |
const uint32_t cbp, |
const uint32_t cbp, |
417 |
Bitstream * bs, |
Bitstream * bs, |
418 |
const uint32_t quant, |
const uint32_t quant, |
621 |
stop_transfer_timer(); |
stop_transfer_timer(); |
622 |
} |
} |
623 |
|
|
624 |
|
static __inline int gmc_sanitize(int value, int quarterpel, int fcode) |
625 |
|
{ |
626 |
|
int length = 1 << (fcode+4); |
627 |
|
|
628 |
|
if (quarterpel) value *= 2; |
629 |
|
|
630 |
|
if (value < -length) |
631 |
|
return -length; |
632 |
|
else if (value >= length) |
633 |
|
return length-1; |
634 |
|
else return value; |
635 |
|
} |
636 |
|
|
637 |
|
|
638 |
static void |
static void |
639 |
decoder_mbgmc(DECODER * dec, |
decoder_mbgmc(DECODER * dec, |
640 |
MACROBLOCK * const pMB, |
MACROBLOCK * const pMB, |
641 |
const uint32_t x_pos, |
const uint32_t x_pos, |
642 |
const uint32_t y_pos, |
const uint32_t y_pos, |
643 |
const uint32_t acpred_flag, |
const uint32_t fcode, |
644 |
const uint32_t cbp, |
const uint32_t cbp, |
645 |
Bitstream * bs, |
Bitstream * bs, |
646 |
const uint32_t quant, |
const uint32_t quant, |
663 |
pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = pMB->amv; |
pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = pMB->amv; |
664 |
|
|
665 |
start_timer(); |
start_timer(); |
666 |
transfer16x16_copy(pY_Cur, dec->gmc.y + (y_pos << 4)*stride + (x_pos << 4), stride); |
|
667 |
|
/* this is where the calculations are done */ |
668 |
|
|
669 |
|
{ |
670 |
|
pMB->amv = generate_GMCimageMB(&dec->gmc_data, &dec->refn[0], x_pos, y_pos, |
671 |
|
stride, stride2, dec->quarterpel, rounding, &dec->cur); |
672 |
|
|
673 |
|
pMB->amv.x = gmc_sanitize(pMB->amv.x, dec->quarterpel, fcode); |
674 |
|
pMB->amv.y = gmc_sanitize(pMB->amv.y, dec->quarterpel, fcode); |
675 |
|
} |
676 |
|
pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = pMB->amv; |
677 |
|
|
678 |
|
|
679 |
|
/* transfer16x16_copy(pY_Cur, dec->gmc.y + (y_pos << 4)*stride + (x_pos << 4), stride); |
680 |
transfer8x8_copy(pU_Cur, dec->gmc.u + (y_pos << 3)*stride2 + (x_pos << 3), stride2); |
transfer8x8_copy(pU_Cur, dec->gmc.u + (y_pos << 3)*stride2 + (x_pos << 3), stride2); |
681 |
transfer8x8_copy(pV_Cur, dec->gmc.v + (y_pos << 3)*stride2 + (x_pos << 3), stride2); |
transfer8x8_copy(pV_Cur, dec->gmc.v + (y_pos << 3)*stride2 + (x_pos << 3), stride2); |
682 |
|
*/ |
683 |
|
|
684 |
|
|
685 |
stop_transfer_timer(); |
stop_transfer_timer(); |
686 |
|
|
687 |
if (!cbp) return; |
if (!cbp) return; |
863 |
|
|
864 |
|
|
865 |
|
|
|
static __inline int gmc_sanitize(int value, int quarterpel, int fcode) |
|
|
{ |
|
|
int length = 1 << (fcode+4); |
|
|
|
|
|
if (quarterpel) value *= 2; |
|
|
|
|
|
if (value < -length) |
|
|
return -length; |
|
|
else if (value >= length) |
|
|
return length-1; |
|
|
else return value; |
|
|
} |
|
866 |
|
|
867 |
|
|
868 |
/* for P_VOP set gmc_warp to NULL */ |
/* for P_VOP set gmc_warp to NULL */ |
883 |
uint32_t mb_width = dec->mb_width; |
uint32_t mb_width = dec->mb_width; |
884 |
uint32_t mb_height = dec->mb_height; |
uint32_t mb_height = dec->mb_height; |
885 |
|
|
|
static int framecount=0; |
|
886 |
if (reduced_resolution) |
if (reduced_resolution) |
887 |
{ |
{ |
888 |
mb_width = (dec->width + 31) / 32; |
mb_width = (dec->width + 31) / 32; |
909 |
(2 << dec->sprite_warping_accuracy), gmc_warp, |
(2 << dec->sprite_warping_accuracy), gmc_warp, |
910 |
dec->width, dec->height, &dec->gmc_data); |
dec->width, dec->height, &dec->gmc_data); |
911 |
|
|
912 |
|
/* image warping is done block-based in decoder_mbgmc(), now */ |
913 |
|
/* |
914 |
generate_GMCimage(&dec->gmc_data, &dec->refn[0], |
generate_GMCimage(&dec->gmc_data, &dec->refn[0], |
915 |
mb_width, mb_height, |
mb_width, mb_height, |
916 |
dec->edged_width, dec->edged_width/2, |
dec->edged_width, dec->edged_width/2, |
917 |
fcode, dec->quarterpel, 0, |
fcode, dec->quarterpel, 0, |
918 |
rounding, dec->mbs, &dec->gmc); |
rounding, dec->mbs, &dec->gmc); |
919 |
|
*/ |
920 |
} |
} |
921 |
|
|
922 |
bound = 0; |
bound = 0; |
1010 |
} |
} |
1011 |
|
|
1012 |
if (mcsel) { |
if (mcsel) { |
1013 |
decoder_mbgmc(dec, mb, x, y, 0, cbp, bs, quant, |
decoder_mbgmc(dec, mb, x, y, fcode, cbp, bs, quant, |
1014 |
rounding, reduced_resolution); |
rounding, reduced_resolution); |
1015 |
continue; |
continue; |
1016 |
|
|
1043 |
continue; |
continue; |
1044 |
} |
} |
1045 |
|
|
1046 |
decoder_mbinter(dec, mb, x, y, 0, cbp, bs, quant, |
decoder_mbinter(dec, mb, x, y, fcode, cbp, bs, quant, |
1047 |
rounding, reduced_resolution); |
rounding, reduced_resolution); |
1048 |
|
|
1049 |
} |
} |
1053 |
|
|
1054 |
start_timer(); |
start_timer(); |
1055 |
|
|
1056 |
decoder_mbgmc(dec, mb, x, y, 0, 0x00, bs, quant, |
decoder_mbgmc(dec, mb, x, y, fcode, 0x00, bs, quant, |
1057 |
rounding, reduced_resolution); |
rounding, reduced_resolution); |
1058 |
|
|
1059 |
stop_transfer_timer(); |
stop_transfer_timer(); |