jsjpeg.js
/**
 * Generate lookup table for marker codes (Table B.1)
 */
Generate lookup table for marker codes (Table B.1)
Generate lookup table for marker codes ( Table B . 1 )
function createMarkerCodeTable() {
    codes = new Map([
        [0xC0, "SOF0"],     
        [0xC1, "SOF1"],     
        [0xC2, "SOF2"],     
        [0xC3, "SOF3"],     
        [0xC5, "SOF5"],     
        [0xC6, "SOF6"],     
        [0xC7, "SOF7"],     
        [0xC8, "JPG"],      
        [0xC9, "SOF9"],     
        [0xCA, "SOF10"],    
        [0xCB, "SOF11"],    
        [0xCD, "SOF13"],    
        [0xCE, "SOF14"],    
        [0xCF, "SOF15"],    
        [0xC4, "DHT"],     
        [0xCC, "DAC"],     
        [0xD8, "SOI*"],     
        [0xD9, "EOI*"],     
        [0xDA, "SOS"],      
        [0xDB, "DQT"],      
        [0xDC, "DNL"],      
        [0xDD, "DRI"],      
        [0xDE, "DHP"],      
        [0xDF, "EXP"],      
        [0xFE, "COM"],      
        [0x01, "TEM*"],     
    ]);
    for (let i = 0; i < 8; i++) {
        codes.set(0xD0 + i, "RST" + i); 
    }
    for (let i = 0; i <= 0xF; i++) {
        codes.set(0xE0 + i, "APP" + i.toString(16).toUpperCase());
    }
    for (let i = 0; i <= 0xD; i++) {
        codes.set(0xF0 + i, "JPG" + i.toString(16).toUpperCase());
    }
    for (let i = 2; i <= 0xBF; i++) {
        codes.set(0x00 + i, "RES");
    }
    return codes;
}
function createMarkerCodeTable ( ) { codes = new Map ( [ [ 0xC0 , "SOF0" ] , [ 0xC1 , "SOF1" ] , [ 0xC2 , "SOF2" ] , [ 0xC3 , "SOF3" ] , [ 0xC5 , "SOF5" ] , [ 0xC6 , "SOF6" ] , [ 0xC7 , "SOF7" ] , [ 0xC8 , "JPG" ] , [ 0xC9 , "SOF9" ] , [ 0xCA , "SOF10" ] , [ 0xCB , "SOF11" ] , [ 0xCD , "SOF13" ] , [ 0xCE , "SOF14" ] , [ 0xCF , "SOF15" ] , [ 0xC4 , "DHT" ] , [ 0xCC , "DAC" ] , [ 0xD8 , "SOI*" ] , [ 0xD9 , "EOI*" ] , [ 0xDA , "SOS" ] , [ 0xDB , "DQT" ] , [ 0xDC , "DNL" ] , [ 0xDD , "DRI" ] , [ 0xDE , "DHP" ] , [ 0xDF , "EXP" ] , [ 0xFE , "COM" ] , [ 0x01 , "TEM*" ] , ] ) ; for ( let i = 0 ; i < 8 ; i ++ ) { codes . set ( 0xD0 + i , "RST" + i ) ; } for ( let i = 0 ; i <= 0xF ; i ++ ) { codes . set ( 0xE0 + i , "APP" + i . toString ( 16 ) . toUpperCase ( ) ) ; } for ( let i = 0 ; i <= 0xD ; i ++ ) { codes . set ( 0xF0 + i , "JPG" + i . toString ( 16 ) . toUpperCase ( ) ) ; } for ( let i = 2 ; i <= 0xBF ; i ++ ) { codes . set ( 0x00 + i , "RES" ) ; } return codes ; }
Generate lookup table for marker codes (Table B.1)
Generate lookup table for marker codes ( Table B . 1 )
// Code assignments // SOF markers, non-differential, Huffman-coding  // Baseline DCT // Extended sequential DCT // Progressive DCT // Lossless (sequential) // SOF markers, differential, Huffman-coding // Differential sequenctial DCT // Differential progressive DCT // Differential lossless (sequential) // SOF markers, non-differential, arithmetic coding // (Reserved) // Extended sequential DCT // Progressive DCT // Lossless (sequential) // SOF markers, differential, arithmetic coding // Differential sequential DCT // Differential progressive DCT // Differential lossless (sequential) // Huffman table spec // Define Huffman table(s) // Arithmetic coding conditioning spec // Define arithmetic coding conditioning(s) // Other markers // Start of image // End of image // Start of sequence // Define quantization table // Define number of lines // Define restart interval // Define hierarchical progression // Expand reference component(s) // Comment // Reserved markers // For temp private in arithmetic coding // Restart interval termination // Restart with modulo 8 count 'm' // Reserved for application segmentation // Reserved for JPEG extensions // Reserved