jsjpeg.js
/**
 * Read and decode the AC coefficients from the bit stream and load them into
 * the array of zig-zag'ed coefficients
 * 
 * F.2.2.2
 * 
 * @param {DataViewReader} reader Data source
 * @param {*} img Struct containing information about the image
 * @param {Array} zigzagCoeff 64-element array where we store the AC coefficients
 * @param {*} acTable Huffman table implementation for AC coefficients
 */
Read and decode the AC coefficients from the bit stream and load them into
the array of zig-zag'ed coefficients



@param {DataViewReader} reader Data source
@param {*} img Struct containing information about the image
@param {Array} zigzagCoeff 64-element array where we store the AC coefficients
@param {*} acTable Huffman table implementation for AC coefficients
Read and decode the AC coefficients from the bit stream and load them into the array of zig - zag ' ed coefficients @param { DataViewReader } reader Data source @param { * } img Struct containing information about the image @param { Array } zigzagCoeff 64 - element array where we store the AC coefficients @param { * } acTable Huffman table implementation for AC coefficients
function decodeACCoeffs(reader, img, zigzagCoeff, acTable) {
    for (let k = 1; k < 64; k++) {
        const rs = acTable.decodeHuffman(reader, img);
        const ssss = getLowNibble(rs);    
        const rrrr = getHighNibble(rs);   
        if (ssss === 0) {
            if (rrrr === 0xF) {
                k += 15;
                continue;
            } else if (rrrr === 0) {
                break;
            } else {
                console.error("Error: unexpected RRRR (expected 0 or 0x0f, got " + rrrr + ")");
            }
        } else {
            k += rrrr;
            const amp = receive(reader, img, ssss);
            const sign = extend(amp, ssss);
            zigzagCoeff[k] = sign;
        }
    }
}
function decodeACCoeffs ( reader , img , zigzagCoeff , acTable ) { for ( let k = 1 ; k < 64 ; k ++ ) { const rs = acTable . decodeHuffman ( reader , img ) ; const ssss = getLowNibble ( rs ) ; const rrrr = getHighNibble ( rs ) ; if ( ssss === 0 ) { if ( rrrr === 0xF ) { k += 15 ; continue ; } else if ( rrrr === 0 ) { break ; } else { console . error ( "Error: unexpected RRRR (expected 0 or 0x0f, got " + rrrr + ")" ) ; } } else { k += rrrr ; const amp = receive ( reader , img , ssss ) ; const sign = extend ( amp , ssss ) ; zigzagCoeff [ k ] = sign ; } } }
Read and decode the AC coefficients from the bit stream and load them into
 the array of zig-zag'ed coefficients
Read and decode the AC coefficients from the bit stream and load them into the array of zig - zag ' ed coefficients
// F.1.2.2 // Amplitude of next non-zero coeff in ZZ // Run length of zero coeffs in ZZ before next non-zero // console.log("ZRL"); // console.log("EOB"); // Other values undefined for Baseline  // Implements the 'DECODE_ZZ' function from Figure F.14 // Decode amplitude + sign // console.log("AC[" + k + "]: (" + amp + ", " + sign + ")");