idct.js
/**
 * Implement the Inverse Discrete Cosine Transformation defined in the JPEG spec.
 * 
 * Returns an array of the IDCT'ed coefficients
 * 
 * @param {*} coeffs Array of 64 coefficients to be processed
 */
Implement the Inverse Discrete Cosine Transformation defined in the JPEG spec.

Returns an array of the IDCT'ed coefficients

@param {*} coeffs Array of 64 coefficients to be processed
Implement the Inverse Discrete Cosine Transformation defined in the JPEG spec . Returns an array of the IDCT ' ed coefficients @param { * } coeffs Array of 64 coefficients to be processed
function idctCached(coeffs) {
    if (idctCache === undefined) {
        initIDCTCache();
    }
    let ret = new Array(coeffs.length);
    for (let y = 0, ystart = 0; y < DATA_UNIT_SIZE; y++, ystart += DATA_UNIT_SIZE) {
        for (let x = 0; x < DATA_UNIT_SIZE; x++) {
            let sum = 0;
            for (let v = 0, vstart = 0; v < DATA_UNIT_SIZE; v++, vstart += DATA_UNIT_SIZE) {
                for (let u = 0; u < DATA_UNIT_SIZE; u++) {
                    sum += C(u) * C(v) * coeffs[vstart + u] * idctCache[x][u] * idctCache[y][v];
                }
            }
            ret[ystart + x] = Math.round(sum / 4);
        }
    }
    return ret;
}
function idctCached ( coeffs ) { if ( idctCache === undefined ) { initIDCTCache ( ) ; } let ret = new Array ( coeffs . length ) ; for ( let y = 0 , ystart = 0 ; y < DATA_UNIT_SIZE ; y ++ , ystart += DATA_UNIT_SIZE ) { for ( let x = 0 ; x < DATA_UNIT_SIZE ; x ++ ) { let sum = 0 ; for ( let v = 0 , vstart = 0 ; v < DATA_UNIT_SIZE ; v ++ , vstart += DATA_UNIT_SIZE ) { for ( let u = 0 ; u < DATA_UNIT_SIZE ; u ++ ) { sum += C ( u ) * C ( v ) * coeffs [ vstart + u ] * idctCache [ x ] [ u ] * idctCache [ y ] [ v ] ; } } ret [ ystart + x ] = Math . round ( sum / 4 ) ; } } return ret ; }
Implement the Inverse Discrete Cosine Transformation defined in the JPEG spec.
Implement the Inverse Discrete Cosine Transformation defined in the JPEG spec .