# HG changeset patch # User michael # Date 1067554262 0 # Node ID eb26d190cf5a55d3799e7dfd6cd3390c6b700c39 # Parent de5e2acd0f80569ccfb001088a149243a91c9dcb move identical code into its own function intXY_t -> int_fastXY_t diff -r de5e2acd0f80 -r eb26d190cf5a faandct.c --- a/faandct.c Thu Oct 30 21:05:00 2003 +0000 +++ b/faandct.c Thu Oct 30 22:51:02 2003 +0000 @@ -70,16 +70,13 @@ B7*B0, B7*B1, B7*B2, B7*B3, B7*B4, B7*B5, B7*B6, B7*B7, }; -void ff_faandct(DCTELEM * data) +static always_inline void row_fdct(FLOAT temp[64], DCTELEM * data) { FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; FLOAT tmp10, tmp11, tmp12, tmp13; FLOAT z1, z2, z3, z4, z5, z11, z13; - FLOAT temp[64]; int i; - emms_c(); - for (i=0; i<8*8; i+=8) { tmp0= data[0 + i] + data[7 + i]; tmp7= data[0 + i] - data[7 + i]; @@ -118,7 +115,20 @@ temp[3 + i]= z13 - z2; temp[1 + i]= z11 + z4; temp[7 + i]= z11 - z4; - } + } +} + +void ff_faandct(DCTELEM * data) +{ + FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + FLOAT tmp10, tmp11, tmp12, tmp13; + FLOAT z1, z2, z3, z4, z5, z11, z13; + FLOAT temp[64]; + int i; + + emms_c(); + + row_fdct(temp, data); for (i=0; i<8; i++) { tmp0= temp[8*0 + i] + temp[8*7 + i]; @@ -165,51 +175,13 @@ { FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; FLOAT tmp10, tmp11, tmp12, tmp13; - FLOAT z1, z2, z3, z4, z5, z11, z13; + FLOAT z1; FLOAT temp[64]; int i; emms_c(); - for (i=0; i<8*8; i+=8) { - tmp0= data[0 + i] + data[7 + i]; - tmp7= data[0 + i] - data[7 + i]; - tmp1= data[1 + i] + data[6 + i]; - tmp6= data[1 + i] - data[6 + i]; - tmp2= data[2 + i] + data[5 + i]; - tmp5= data[2 + i] - data[5 + i]; - tmp3= data[3 + i] + data[4 + i]; - tmp4= data[3 + i] - data[4 + i]; - - tmp10= tmp0 + tmp3; - tmp13= tmp0 - tmp3; - tmp11= tmp1 + tmp2; - tmp12= tmp1 - tmp2; - - temp[0 + i]= tmp10 + tmp11; - temp[4 + i]= tmp10 - tmp11; - - z1= (tmp12 + tmp13)*A1; - temp[2 + i]= tmp13 + z1; - temp[6 + i]= tmp13 - z1; - - tmp10= tmp4 + tmp5; - tmp11= tmp5 + tmp6; - tmp12= tmp6 + tmp7; - - z5= (tmp10 - tmp12) * A5; - z2= tmp10*A2 + z5; - z4= tmp12*A4 + z5; - z3= tmp11*A1; - - z11= tmp7 + z3; - z13= tmp7 - z3; - - temp[5 + i]= z13 + z2; - temp[3 + i]= z13 - z2; - temp[1 + i]= z11 + z4; - temp[7 + i]= z11 - z4; - } + row_fdct(temp, data); for (i=0; i<8; i++) { tmp0 = temp[8*0 + i] + temp[8*1 + i]; diff -r de5e2acd0f80 -r eb26d190cf5a jfdctfst.c --- a/jfdctfst.c Thu Oct 30 21:05:00 2003 +0000 +++ b/jfdctfst.c Thu Oct 30 22:51:02 2003 +0000 @@ -112,17 +112,10 @@ #define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -fdct_ifast (DCTELEM * data) -{ - DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - DCTELEM tmp10, tmp11, tmp12, tmp13; - DCTELEM z1, z2, z3, z4, z5, z11, z13; +static always_inline void row_fdct(DCTELEM * data){ + int_fast16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + int_fast16_t tmp10, tmp11, tmp12, tmp13; + int_fast16_t z1, z2, z3, z4, z5, z11, z13; DCTELEM *dataptr; int ctr; SHIFT_TEMPS @@ -176,7 +169,24 @@ dataptr += DCTSIZE; /* advance pointer to next row */ } +} +/* + * Perform the forward DCT on one block of samples. + */ + +GLOBAL(void) +fdct_ifast (DCTELEM * data) +{ + int_fast16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + int_fast16_t tmp10, tmp11, tmp12, tmp13; + int_fast16_t z1, z2, z3, z4, z5, z11, z13; + DCTELEM *dataptr; + int ctr; + SHIFT_TEMPS + + row_fdct(data); + /* Pass 2: process columns. */ dataptr = data; @@ -235,63 +245,15 @@ GLOBAL(void) fdct_ifast248 (DCTELEM * data) { - DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - DCTELEM tmp10, tmp11, tmp12, tmp13; - DCTELEM z1, z2, z3, z4, z5, z11, z13; + int_fast16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + int_fast16_t tmp10, tmp11, tmp12, tmp13; + int_fast16_t z1; DCTELEM *dataptr; int ctr; SHIFT_TEMPS - /* Pass 1: process rows. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = tmp10 + tmp11; /* phase 3 */ - dataptr[4] = tmp10 - tmp11; - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ - dataptr[2] = tmp13 + z1; /* phase 5 */ - dataptr[6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ - z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ - z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ - z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[5] = z13 + z2; /* phase 6 */ - dataptr[3] = z13 - z2; - dataptr[1] = z11 + z4; - dataptr[7] = z11 - z4; - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - + row_fdct(data); + /* Pass 2: process columns. */ dataptr = data; diff -r de5e2acd0f80 -r eb26d190cf5a jfdctint.c --- a/jfdctint.c Thu Oct 30 21:05:00 2003 +0000 +++ b/jfdctint.c Thu Oct 30 22:51:02 2003 +0000 @@ -148,16 +148,10 @@ #endif -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -ff_jpeg_fdct_islow (DCTELEM * data) -{ - int32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - int32_t tmp10, tmp11, tmp12, tmp13; - int32_t z1, z2, z3, z4, z5; +static always_inline void row_fdct(DCTELEM * data){ + int_fast32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + int_fast32_t tmp10, tmp11, tmp12, tmp13; + int_fast32_t z1, z2, z3, z4, z5; DCTELEM *dataptr; int ctr; SHIFT_TEMPS @@ -225,6 +219,23 @@ dataptr += DCTSIZE; /* advance pointer to next row */ } +} + +/* + * Perform the forward DCT on one block of samples. + */ + +GLOBAL(void) +ff_jpeg_fdct_islow (DCTELEM * data) +{ + int_fast32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + int_fast32_t tmp10, tmp11, tmp12, tmp13; + int_fast32_t z1, z2, z3, z4, z5; + DCTELEM *dataptr; + int ctr; + SHIFT_TEMPS + + row_fdct(data); /* Pass 2: process columns. * We remove the PASS1_BITS scaling, but leave the results scaled up @@ -304,76 +315,14 @@ GLOBAL(void) ff_fdct248_islow (DCTELEM * data) { - int32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - int32_t tmp10, tmp11, tmp12, tmp13; - int32_t z1, z2, z3, z4, z5; + int_fast32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + int_fast32_t tmp10, tmp11, tmp12, tmp13; + int_fast32_t z1; DCTELEM *dataptr; int ctr; SHIFT_TEMPS - /* Pass 1: process rows. */ - /* Note results are scaled up by sqrt(8) compared to a true DCT; */ - /* furthermore, we scale the results by 2**PASS1_BITS. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part per LL&M figure 1 --- note that published figure is faulty; - * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". - */ - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS); - dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS-PASS1_BITS); - dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS-PASS1_BITS); - - /* Odd part per figure 8 --- note paper omits factor of sqrt(2). - * cK represents cos(K*pi/16). - * i0..i3 in the paper are tmp4..tmp7 here. - */ - - z1 = tmp4 + tmp7; - z2 = tmp5 + tmp6; - z3 = tmp4 + tmp6; - z4 = tmp5 + tmp7; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); - dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); - dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); - dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); - - dataptr += DCTSIZE; /* advance pointer to next row */ - } + row_fdct(data); /* Pass 2: process columns. * We remove the PASS1_BITS scaling, but leave the results scaled up