src/main/java/org/jcodec/common/dct/IntDCT.java
private static void pass2(IntBuffer outptr, IntBuffer wsptr) {
        for (int ctr = 0; ctr < DCTSIZE; ctr++) {
            /* Even part: reverse the even part of the forward DCT. */
            /* The rotator is sqrt(2)c(-6). */

            int z2 = wsptr.get(2);
            int z3 = wsptr.get(6);

            int z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
            int tmp2 = z1 + MULTIPLY(z3, -FIX_1_847759065);
            int tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865);

            int tmp0 = ((int) wsptr.get(0) + (int) wsptr.get(4)) << CONST_BITS;
            int tmp1 = ((int) wsptr.get(0) - (int) wsptr.get(4)) << CONST_BITS;

            int tmp10 = tmp0 + tmp3;
            int tmp13 = tmp0 - tmp3;
            int tmp11 = tmp1 + tmp2;
            int tmp12 = tmp1 - tmp2;

            /*
             * Odd part per figure 8; the matrix is unitary and hence its
             * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
             */

            tmp0 = (int) wsptr.get(7);
            tmp1 = (int) wsptr.get(5);
            tmp2 = (int) wsptr.get(3);
            tmp3 = (int) wsptr.get(1);

            z1 = tmp0 + tmp3;
            z2 = tmp1 + tmp2;
            z3 = tmp0 + tmp2;
            int z4 = tmp1 + tmp3;
            int z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) c3 */

            tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) (-c1+c3+c5-c7) */
            tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) ( c1+c3-c5+c7) */
            tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) ( c1+c3+c5-c7) */
            tmp3 = MULTIPLY(tmp3, 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;

            tmp0 += z1 + z3;
            tmp1 += z2 + z4;
            tmp2 += z2 + z3;
            tmp3 += z1 + z4;

            /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */

            int D = CONST_BITS + PASS1_BITS + 3;
            outptr.put(range_limit(DESCALE(tmp10 + tmp3, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp11 + tmp2, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp12 + tmp1, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp13 + tmp0, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp13 - tmp0, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp12 - tmp1, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp11 - tmp2, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp10 - tmp3, D) & RANGE_MASK));

            wsptr = doAdvance(wsptr, DCTSIZE); /* advance pointer to next row */

        }
    }
private static void pass2(IntBuffer outptr, IntBuffer wsptr) {
        for (int ctr = 0; ctr < DCTSIZE; ctr++) {
            /* Even part: reverse the even part of the forward DCT. */
            /* The rotator is sqrt(2)c(-6). */

            int z2 = wsptr.get(2);
            int z3 = wsptr.get(6);

            int z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
            int tmp2 = z1 + MULTIPLY(z3, -FIX_1_847759065);
            int tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865);

            int tmp0 = ((int) wsptr.get(0) + (int) wsptr.get(4)) << CONST_BITS;
            int tmp1 = ((int) wsptr.get(0) - (int) wsptr.get(4)) << CONST_BITS;

            int tmp10 = tmp0 + tmp3;
            int tmp13 = tmp0 - tmp3;
            int tmp11 = tmp1 + tmp2;
            int tmp12 = tmp1 - tmp2;

            /*
             * Odd part per figure 8; the matrix is unitary and hence its
             * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
             */

            tmp0 = (int) wsptr.get(7);
            tmp1 = (int) wsptr.get(5);
            tmp2 = (int) wsptr.get(3);
            tmp3 = (int) wsptr.get(1);

            z1 = tmp0 + tmp3;
            z2 = tmp1 + tmp2;
            z3 = tmp0 + tmp2;
            int z4 = tmp1 + tmp3;
            int z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) c3 */

            tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) (-c1+c3+c5-c7) */
            tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) ( c1+c3-c5+c7) */
            tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) ( c1+c3+c5-c7) */
            tmp3 = MULTIPLY(tmp3, 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;

            tmp0 += z1 + z3;
            tmp1 += z2 + z4;
            tmp2 += z2 + z3;
            tmp3 += z1 + z4;

            /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */

            int D = CONST_BITS + PASS1_BITS + 3;
            outptr.put(range_limit(DESCALE(tmp10 + tmp3, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp11 + tmp2, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp12 + tmp1, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp13 + tmp0, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp13 - tmp0, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp12 - tmp1, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp11 - tmp2, D) & RANGE_MASK));
            outptr.put(range_limit(DESCALE(tmp10 - tmp3, D) & RANGE_MASK));

            wsptr = doAdvance(wsptr, DCTSIZE); /* advance pointer to next row */

        }
    }
private static void pass2 ( IntBuffer outptr , IntBuffer wsptr ) { for ( int ctr = 0 ; ctr < DCTSIZE ; ctr ++ ) { /* Even part: reverse the even part of the forward DCT. */ /* The rotator is sqrt(2)c(-6). */ int z2 = wsptr . get ( 2 ) ; int z3 = wsptr . get ( 6 ) ; int z1 = MULTIPLY ( z2 + z3 , FIX_0_541196100 ) ; int tmp2 = z1 + MULTIPLY ( z3 , - FIX_1_847759065 ) ; int tmp3 = z1 + MULTIPLY ( z2 , FIX_0_765366865 ) ; int tmp0 = ( ( int ) wsptr . get ( 0 ) + ( int ) wsptr . get ( 4 ) ) << CONST_BITS ; int tmp1 = ( ( int ) wsptr . get ( 0 ) - ( int ) wsptr . get ( 4 ) ) << CONST_BITS ; int tmp10 = tmp0 + tmp3 ; int tmp13 = tmp0 - tmp3 ; int tmp11 = tmp1 + tmp2 ; int tmp12 = tmp1 - tmp2 ; /*
             * Odd part per figure 8; the matrix is unitary and hence its
             * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
             */ tmp0 = ( int ) wsptr . get ( 7 ) ; tmp1 = ( int ) wsptr . get ( 5 ) ; tmp2 = ( int ) wsptr . get ( 3 ) ; tmp3 = ( int ) wsptr . get ( 1 ) ; z1 = tmp0 + tmp3 ; z2 = tmp1 + tmp2 ; z3 = tmp0 + tmp2 ; int z4 = tmp1 + tmp3 ; int z5 = MULTIPLY ( z3 + z4 , FIX_1_175875602 ) ; /* sqrt(2) c3 */ tmp0 = MULTIPLY ( tmp0 , FIX_0_298631336 ) ; /* sqrt(2) (-c1+c3+c5-c7) */ tmp1 = MULTIPLY ( tmp1 , FIX_2_053119869 ) ; /* sqrt(2) ( c1+c3-c5+c7) */ tmp2 = MULTIPLY ( tmp2 , FIX_3_072711026 ) ; /* sqrt(2) ( c1+c3+c5-c7) */ tmp3 = MULTIPLY ( tmp3 , 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 ; tmp0 += z1 + z3 ; tmp1 += z2 + z4 ; tmp2 += z2 + z3 ; tmp3 += z1 + z4 ; /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ int D = CONST_BITS + PASS1_BITS + 3 ; outptr . put ( range_limit ( DESCALE ( tmp10 + tmp3 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp11 + tmp2 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp12 + tmp1 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp13 + tmp0 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp13 - tmp0 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp12 - tmp1 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp11 - tmp2 , D ) & RANGE_MASK ) ) ; outptr . put ( range_limit ( DESCALE ( tmp10 - tmp3 , D ) & RANGE_MASK ) ) ; wsptr = doAdvance ( wsptr , DCTSIZE ) ; /* advance pointer to next row */ } }
Pass 2: process rows from work array, store into output array.

Note that we must descale the results by a factor of 8 == 23, and also
undo the PASS1_BITS scaling.
Pass 2 : process rows from work array store into output array .