double expdp_c(double a) { double Halfe = 0.5; //Zeroe = 0.0, Onee = 1.0, ; double Maxe = 1.7976931348623157e+308 ; double LnMaxe= 709.7827138470578 ; double a0e= 0.249999999999999993; double a1e= 0.694360001511792852e-2 ; double a2e= 0.165203300268279130e-4; double b0e= 0.5 ; double b1e= 0.555538666969001188e-1 ; double b2e= 0.495862884905441294e-3 ; double c1e= 0.693359375 ; /* 355/512 */ double C2e=-2.1219444005469058277e-4 ; double L2e = 1.4426950408889634074 ; /* log (base 2) of e */ double Ye,Xe,We,Re,Se,Be,Ce,De; int Ne, upper; Ye = a; Ce = Ye*L2e ; /* base e --> base 2 argument */ Ne = _dpint(Ce) ; /* get unbiased exponent as an int */ Se = Ne ; /* double(int N) */ Xe = (Ye - Se*c1e) - Se*C2e ; /* range reduction */ We = Xe*Xe ; Be = (b2e*We + b1e)*We + b0e ; /* denominator */ De = ((a2e*We + a1e)*We + a0e)*Xe ; /* numerator */ Re = Halfe + divdpMod_ci5( De, (Be-De) ) ; upper = 1024 + Ne; upper = _extu(upper,20,0); Se = _itod(upper,0x00000000); Ce = Re*Se ; /* scale by power of 2 */ if (a > LnMaxe) Ce = (Maxe) ; /* > LnMax returns MAX */ return (Ce) ; }
static inline int divide ( int num, int den ) { int i, sign ; sign = num >> 31 ; // test the sign of numerator num = _abs(num); num += den >> 1 ; den <<= NUM_NORM ; // align denominator for ( i = 0 ; i <= NUM_NORM ; i++ ) num = _subc(num, den); num = _extu(num, 31 - NUM_NORM, 31 - NUM_NORM); /* unsigned extraction */ if ( sign ) num = -num ; return (num); }
/** This function allows to get the luminance prediction of a non IDR picture when xFracl = 0 and yFracl = 1. @param image Table of current frame. @param refPicLXl Table of the reference decoded picture buffer. @param PicWidthSamples Stride of the reference buffer. @param stride Stride of the current image. */ void luma_sample_interp_0_1_TI(unsigned char image [], unsigned char refPicLXl[], const short PicWidthSamples, const short stride){ /* No horizontal interpolation */ unsigned int uiLine1,uiLine2,uiLine3,uiLine4,uiLine5,uiLine6,uiLine7,uiLine8,uiLine9; unsigned int uiTmpLine12_h,uiTmpLine34_h,uiTmpLine12_l,uiTmpLine34_l,uiTmpLine1234_4,uiTmpLine1234_2,uiTmpLine1234_3,uiTmpLine1234_1; unsigned int uiTmpLine56_h,uiTmpLine78_h,uiTmpLine56_l,uiTmpLine78_l,uiTmpLine5678_4,uiTmpLine5678_2,uiTmpLine5678_3,uiTmpLine5678_1; unsigned int tmpc1_1,tmpc1_2,tmpc2_1,tmpc2_2,tmpc1,tmpc2; unsigned int tmpc3_1,tmpc3_2,tmpc4_1,tmpc4_2,tmpc3,tmpc4; unsigned int tmp12,tmp34,tmpend1,tmpend2,tmpend3,tmpend4; unsigned int tmpl9l,tmpl9h; unsigned int input1,input2,input3,input4; unsigned char* pRefImgPtr; unsigned char* pImgPtr; pRefImgPtr = refPicLXl-(PicWidthSamples<<1); pImgPtr = image; uiLine1 = _mem4(pRefImgPtr); pRefImgPtr += PicWidthSamples; uiLine2 = _mem4(pRefImgPtr); pRefImgPtr += PicWidthSamples; uiLine3 = _mem4(pRefImgPtr); pRefImgPtr += PicWidthSamples; uiLine4 = _mem4(pRefImgPtr); pRefImgPtr += PicWidthSamples; uiLine5 = _mem4(pRefImgPtr); pRefImgPtr += PicWidthSamples; uiLine6 = _mem4(pRefImgPtr); pRefImgPtr += PicWidthSamples; uiLine7 = _mem4(pRefImgPtr); pRefImgPtr += PicWidthSamples; uiLine8 = _mem4(pRefImgPtr); pRefImgPtr += PicWidthSamples; uiLine9 = _mem4(pRefImgPtr); input1 = uiLine3; input2 = uiLine4; input3 = uiLine5; input4 = uiLine6; uiTmpLine12_h = _packh4(uiLine1,uiLine2); uiTmpLine34_h = _packh4(uiLine3,uiLine4); uiTmpLine12_l = _packl4(uiLine1,uiLine2); uiTmpLine34_l = _packl4(uiLine3,uiLine4); uiTmpLine1234_4 = _packh4(uiTmpLine12_h,uiTmpLine34_h); uiTmpLine1234_2 = _packl4(uiTmpLine12_h,uiTmpLine34_h); uiTmpLine1234_3 = _packh4(uiTmpLine12_l,uiTmpLine34_l); uiTmpLine1234_1 = _packl4(uiTmpLine12_l,uiTmpLine34_l); uiTmpLine56_h = _packh4(uiLine5,uiLine6); uiTmpLine78_h = _packh4(uiLine7,uiLine8); uiTmpLine56_l = _packl4(uiLine5,uiLine6); uiTmpLine78_l = _packl4(uiLine7,uiLine8); uiTmpLine5678_4 = _packh4(uiTmpLine56_h,uiTmpLine78_h); uiTmpLine5678_2 = _packl4(uiTmpLine56_h,uiTmpLine78_h); uiTmpLine5678_3 = _packh4(uiTmpLine56_l,uiTmpLine78_l); uiTmpLine5678_1 = _packl4(uiTmpLine56_l,uiTmpLine78_l); tmpc1_1 = _dotpsu4(0x01FB1414,uiTmpLine1234_1); tmpc1_2 = _dotpsu4(0xFB010000,uiTmpLine5678_1); tmpc2_1 = _dotpsu4(0x01FB1414,uiTmpLine1234_2); tmpc2_2 = _dotpsu4(0xFB010000,uiTmpLine5678_2); tmpc1 = _spack2(tmpc1_1,tmpc2_1); tmpc2 = _spack2(tmpc1_2,tmpc2_2); tmp12 = _sadd2(tmpc1,tmpc2); tmp12 = _shr2(_sadd2(tmp12,0x00100010),5); tmpc3_1 = _dotpsu4(0x01FB1414,uiTmpLine1234_3); tmpc3_2 = _dotpsu4(0xFB010000,uiTmpLine5678_3); tmpc4_1 = _dotpsu4(0x01FB1414,uiTmpLine1234_4); tmpc4_2 = _dotpsu4(0xFB010000,uiTmpLine5678_4); tmpc3 = _spack2(tmpc3_1,tmpc4_1); tmpc4 = _spack2(tmpc3_2,tmpc4_2); tmp34 = _sadd2(tmpc3,tmpc4); tmp34 = _shr2(_sadd2(tmp34,0x00100010),5); tmpend1 = _spacku4(tmp34,tmp12); tmpend1 = _swap4(tmpend1); _amem4(pImgPtr) = _avgu4(tmpend1,input1); pImgPtr += stride; tmpc1_1 = _dotpsu4(0x0001FB14,uiTmpLine1234_1); tmpc1_2 = _dotpsu4(0x14FB0100,uiTmpLine5678_1); tmpc2_1 = _dotpsu4(0x0001FB14,uiTmpLine1234_2); tmpc2_2 = _dotpsu4(0x14FB0100,uiTmpLine5678_2); tmpc1 = _spack2(tmpc1_1,tmpc2_1); tmpc2 = _spack2(tmpc1_2,tmpc2_2); tmp12 = _sadd2(tmpc1,tmpc2); tmp12 = _shr2(_sadd2(tmp12,0x00100010),5); tmpc3_1 = _dotpsu4(0x0001FB14,uiTmpLine1234_3); tmpc3_2 = _dotpsu4(0x14FB0100,uiTmpLine5678_3); tmpc4_1 = _dotpsu4(0x0001FB14,uiTmpLine1234_4); tmpc4_2 = _dotpsu4(0x14FB0100,uiTmpLine5678_4); tmpc3 = _spack2(tmpc3_1,tmpc4_1); tmpc4 = _spack2(tmpc3_2,tmpc4_2); tmp34 = _sadd2(tmpc3,tmpc4); tmp34 = _shr2(_sadd2(tmp34,0x00100010),5); tmpend2 = _spacku4(tmp34,tmp12); tmpend2 = _swap4(tmpend2); _amem4(pImgPtr) = _avgu4(tmpend2,input2); pImgPtr += stride; tmpc1_1 = _dotpsu4(0x000001FB,uiTmpLine1234_1); tmpc1_2 = _dotpsu4(0x1414FB01,uiTmpLine5678_1); tmpc2_1 = _dotpsu4(0x000001FB,uiTmpLine1234_2); tmpc2_2 = _dotpsu4(0x1414FB01,uiTmpLine5678_2); tmpc1 = _spack2(tmpc1_1,tmpc2_1); tmpc2 = _spack2(tmpc1_2,tmpc2_2); tmp12 = _sadd2(tmpc1,tmpc2); tmp12 = _shr2(_sadd2(tmp12,0x00100010),5); tmpc3_1 = _dotpsu4(0x000001FB,uiTmpLine1234_3); tmpc3_2 = _dotpsu4(0x1414FB01,uiTmpLine5678_3); tmpc4_1 = _dotpsu4(0x000001FB,uiTmpLine1234_4); tmpc4_2 = _dotpsu4(0x1414FB01,uiTmpLine5678_4); tmpc3 = _spack2(tmpc3_1,tmpc4_1); tmpc4 = _spack2(tmpc3_2,tmpc4_2); tmp34 = _sadd2(tmpc3,tmpc4); tmp34 = _shr2(_sadd2(tmp34,0x00100010),5); tmpend3 = _spacku4(tmp34,tmp12); tmpend3 = _swap4(tmpend3); _amem4(pImgPtr) = _avgu4(tmpend3,input3); pImgPtr += stride; uiLine9 = _swap4(uiLine9); tmpl9h = _unpkhu4 (uiLine9); tmpl9l = _unpklu4 (uiLine9); tmpc1_1 = _extu(uiTmpLine1234_1,24,24);//_dotpsu4(0x00000001,uiTmpLine1234_1); tmpc1_2 = _dotpsu4(0xFB1414FB,uiTmpLine5678_1); tmpc2_1 = _extu(uiTmpLine1234_2,24,24);//_dotpsu4(0x00000001,uiTmpLine1234_2); tmpc2_2 = _dotpsu4(0xFB1414FB,uiTmpLine5678_2); tmpc1 = _spack2(tmpc1_1,tmpc2_1); tmpc2 = _spack2(tmpc1_2,tmpc2_2); tmp12 = _sadd2(tmpc1,tmpc2); tmp12 = _sadd2(tmp12,tmpl9l); tmp12 = _shr2(_sadd2(tmp12,0x00100010),5); tmpc3_1 = _extu(uiTmpLine1234_3,24,24);//_dotpsu4(0x00000001,uiTmpLine1234_3); tmpc3_2 = _dotpsu4(0xFB1414FB,uiTmpLine5678_3); tmpc4_1 = _extu(uiTmpLine1234_4,24,24);//_dotpsu4(0x00000001,uiTmpLine1234_4); tmpc4_2 = _dotpsu4(0xFB1414FB,uiTmpLine5678_4); tmpc3 = _spack2(tmpc3_1,tmpc4_1); tmpc4 = _spack2(tmpc3_2,tmpc4_2); tmp34 = _sadd2(tmpc3,tmpc4); tmp34 = _sadd2(tmp34,tmpl9h); tmp34 = _shr2(_sadd2(tmp34,0x00100010),5); tmpend4 = _spacku4(tmp34,tmp12); tmpend4 = _swap4(tmpend4); _amem4(pImgPtr) = _avgu4(tmpend4,input4); }
double logdp_c(double a) { // double One=1.0 ; double Zero = 0.0, Half = 0.5 ; double srHalf= 0.70710678118654752440 ; /* sqrt(0.5) */ double MIN = 2.2250738585072014e-308 ; double LnMin = -708.3964185322641 ; double MAX = 1.7976931348623157e+308 ; double LnMax = 709.7827138470578 ; double a0 =-0.64124943423745581147e+2 ; double a1 = 0.16383943563021534222e+2 ; double a2 =-0.78956112887491257267e+0 ; double b0 =-0.76949932108494879777e+3 ; double b1 = 0.31203222091924532844e+3 ; double b2 =-0.35667977739034646171e+2 ; /* Note b3 = 1.0 */ double c1 = 0.693359375 ; /* 355/512 */ double c2 =-2.121944400546905827679e-4 ; double Y,Z,zn,zd,X,W,Rz,Sa,Bd,Cn,Da ; int N, exp, upper; Y = a ; exp = _extu(_hi(Y),1,21); N = exp - 1022; upper = _clr(_hi(Y),20,31); upper = 0x3fe00000 | upper; Z = _itod(upper, _lo(Y)); if (exp == 0) Z = 0; if (Z > srHalf) { zn=(Z-Half)-Half ; zd=Z*Half+Half ; } else { zn=Z-Half; zd=zn*Half+Half ; N=N-1 ; } //X = zn/zd; X = divdpMod_clog(zn,zd); W = X*X ; Bd= ( (W+b2) * W + b1) * W + b0 ; Cn= (W*a2 + a1) * W + a0 ; Rz= W * divdpMod_clog(Cn,Bd);//Cn / Bd ; Sa = X + X*Rz ; Cn= N ; Da = (Cn*c2 + Sa) + Cn*c1 ; if (Y <= Zero) Da = 0;//{Z = setnmx(Y) ; Da = (Z) ; } if (Y < MIN) Da = (LnMin) ; if (Y > MAX) Da = (LnMax) ; return (Da) ; }