image-in-browser
Version:
Package for encoding / decoding images, transforming images, applying filters, drawing primitives on images on the client side (no need for server Node.js)
223 lines (222 loc) • 7.29 kB
TypeScript
/** @format */
import { InputBuffer } from '../../common/input-buffer.js';
import { JpegComponent } from './jpeg-component.js';
import { JpegFrame } from './jpeg-frame.js';
/**
* Type definition for the decode function.
*
* @param {JpegComponent} component - The JPEG component to decode.
* @param {Int32Array} block - The block of data to decode.
*/
export type DecodeFunction = (component: JpegComponent, block: Int32Array) => void;
/**
* Class representing a JPEG scan.
*/
export declare class JpegScan {
private _input;
/**
* Gets the input buffer.
* @returns {InputBuffer<Uint8Array>} The input buffer.
*/
get input(): InputBuffer<Uint8Array>;
private _frame;
/**
* Gets the JPEG frame.
* @returns {JpegFrame} The JPEG frame.
*/
get frame(): JpegFrame;
private _precision;
/**
* Gets the precision.
* @returns {number} The precision.
*/
get precision(): number;
private _samplesPerLine;
/**
* Gets the samples per line.
* @returns {number} The samples per line.
*/
get samplesPerLine(): number;
private _scanLines;
/**
* Gets the scan lines.
* @returns {number} The scan lines.
*/
get scanLines(): number;
private _mcusPerLine;
/**
* Gets the MCUs per line.
* @returns {number} The MCUs per line.
*/
get mcusPerLine(): number;
private _progressive;
/**
* Gets whether the scan is progressive.
* @returns {boolean} True if the scan is progressive, false otherwise.
*/
get progressive(): boolean;
private _maxH;
/**
* Gets the maximum horizontal samples.
* @returns {number} The maximum horizontal samples.
*/
get maxH(): number;
private _maxV;
/**
* Gets the maximum vertical samples.
* @returns {number} The maximum vertical samples.
*/
get maxV(): number;
private _components;
/**
* Gets the components.
* @returns {Array<JpegComponent>} The components.
*/
get components(): Array<JpegComponent>;
private _resetInterval?;
/**
* Gets the reset interval.
* @returns {number | undefined} The reset interval.
*/
get resetInterval(): number | undefined;
private _spectralStart;
/**
* Gets the spectral start.
* @returns {number} The spectral start.
*/
get spectralStart(): number;
private _spectralEnd;
/**
* Gets the spectral end.
* @returns {number} The spectral end.
*/
get spectralEnd(): number;
private _successivePrev;
/**
* Gets the successive previous value.
* @returns {number} The successive previous value.
*/
get successivePrev(): number;
private _successive;
/**
* Gets the successive value.
* @returns {number} The successive value.
*/
get successive(): number;
private _bitsData;
/**
* Gets the bits data.
* @returns {number} The bits data.
*/
get bitsData(): number;
private _bitsCount;
/**
* Gets the bits count.
* @returns {number} The bits count.
*/
get bitsCount(): number;
private _eobrun;
/**
* Gets the EOB run.
* @returns {number} The EOB run.
*/
get eobrun(): number;
private _successiveACState;
/**
* Gets the successive AC state.
* @returns {number} The successive AC state.
*/
get successiveACState(): number;
private _successiveACNextValue;
/**
* Gets the successive AC next value.
* @returns {number} The successive AC next value.
*/
get successiveACNextValue(): number;
/**
* Initializes a new instance of the JpegScan class.
* @param {InputBuffer<Uint8Array>} input - The input buffer.
* @param {JpegFrame} frame - The JPEG frame.
* @param {Array<JpegComponent>} components - The components.
* @param {number} spectralStart - The spectral start.
* @param {number} spectralEnd - The spectral end.
* @param {number} successivePrev - The successive previous value.
* @param {number} successive - The successive value.
* @param {number} [resetInterval] - The reset interval.
*/
constructor(input: InputBuffer<Uint8Array>, frame: JpegFrame, components: Array<JpegComponent>, spectralStart: number, spectralEnd: number, successivePrev: number, successive: number, resetInterval?: number);
/**
* Reads a single bit from the input buffer.
* @returns {number | undefined} The bit read or undefined if end of stream.
*/
private readBit;
/**
* Decodes a Huffman encoded value.
* @param {Array<HuffmanNode | undefined>} tree - The Huffman tree.
* @returns {number | undefined} The decoded value or undefined if end of stream.
*/
private decodeHuffman;
/**
* Receives a specified number of bits from the input buffer.
* @param {number} length - The number of bits to receive.
* @returns {number | undefined} The received bits or undefined if end of stream.
*/
private receive;
/**
* Receives and extends a specified number of bits from the input buffer.
* @param {number | undefined} length - The number of bits to receive and extend.
* @returns {number} The received and extended bits.
*/
private receiveAndExtend;
/**
* Decodes a baseline JPEG component.
* @param {JpegComponent} component - The JPEG component.
* @param {Int32Array} zz - The block of data to decode.
*/
private decodeBaseline;
/**
* Decodes the first DC coefficient of a progressive JPEG component.
* @param {JpegComponent} component - The JPEG component.
* @param {Int32Array} zz - The block of data to decode.
*/
private decodeDCFirst;
/**
* Decodes the successive DC coefficients of a progressive JPEG component.
* @param {JpegComponent} _ - The JPEG component (unused).
* @param {Int32Array} zz - The block of data to decode.
*/
private decodeDCSuccessive;
/**
* Decodes the first AC coefficients of a progressive JPEG component.
* @param {JpegComponent} component - The JPEG component.
* @param {Int32Array} zz - The block of data to decode.
*/
private decodeACFirst;
/**
* Decodes the successive AC coefficients of a progressive JPEG component.
* @param {JpegComponent} component - The JPEG component.
* @param {Int32Array} zz - The block of data to decode.
* @throws {LibError} If there is an invalid progressive encoding.
*/
private decodeACSuccessive;
/**
* Decodes a MCU (Minimum Coded Unit) of a JPEG component.
* @param {JpegComponent} component - The JPEG component.
* @param {DecodeFunction} decodeFn - The decode function.
* @param {number} mcu - The MCU index.
* @param {number} row - The row index.
* @param {number} col - The column index.
*/
private decodeMcu;
/**
* Decodes a block of a JPEG component.
* @param {JpegComponent} component - The JPEG component.
* @param {DecodeFunction} decodeFn - The decode function.
* @param {number} mcu - The MCU index.
*/
private decodeBlock;
/**
* Decodes the JPEG scan.
*/
decode(): void;
}