init
This commit is contained in:
+55
@@ -0,0 +1,55 @@
|
||||
import type { HEVCFrame, HEVCStreamInfo, DecodeResult, DecoderOptions } from "./types.js";
|
||||
/**
|
||||
* HEVC/H.265 Decoder — JavaScript wrapper for the WASM module.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const decoder = await HEVCDecoder.create();
|
||||
* const { frames, info } = decoder.decode(bitstreamBytes);
|
||||
* console.log(`${info.width}x${info.height}, ${frames.length} frames`);
|
||||
* decoder.destroy();
|
||||
* ```
|
||||
*/
|
||||
export declare class HEVCDecoder {
|
||||
private _m;
|
||||
private _api;
|
||||
private _dec;
|
||||
private constructor();
|
||||
/**
|
||||
* Create a new decoder instance. Loads the WASM module.
|
||||
*/
|
||||
static create(options?: DecoderOptions): Promise<HEVCDecoder>;
|
||||
/**
|
||||
* Decode a complete HEVC bitstream.
|
||||
* @param data Raw .265 bitstream bytes
|
||||
*/
|
||||
decode(data: Uint8Array): DecodeResult;
|
||||
/** Number of decoded frames available */
|
||||
get frameCount(): number;
|
||||
/** Get stream info (available after decode) */
|
||||
get info(): HEVCStreamInfo | null;
|
||||
private _extractFrame;
|
||||
private _extractDrainedFrame;
|
||||
private _readFrameFromPtr;
|
||||
private _extractInfo;
|
||||
/**
|
||||
* Feed a chunk of data containing one or more complete NAL units.
|
||||
* The decoder accumulates parameter sets and decodes pictures incrementally.
|
||||
* Call drain() after each feed() to retrieve output-ready frames.
|
||||
*/
|
||||
feed(data: Uint8Array): void;
|
||||
/**
|
||||
* Drain output-ready frames from the decoder (§C.5.2 bumping process).
|
||||
* Returns frames in display order, only when ready per DPB constraints.
|
||||
* Frames are valid until the next feed() or destroy() call.
|
||||
*/
|
||||
drain(): HEVCFrame[];
|
||||
/**
|
||||
* Flush all remaining frames from the DPB (call at end of stream).
|
||||
* Returns all buffered frames in display order.
|
||||
*/
|
||||
flush(): HEVCFrame[];
|
||||
/** Release decoder resources */
|
||||
destroy(): void;
|
||||
}
|
||||
//# sourceMappingURL=decoder.d.ts.map
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
export { HEVCDecoder } from "./decoder.js";
|
||||
export type { HEVCFrame, HEVCStreamInfo, DecodeResult, DecoderOptions, WorkerRequest, WorkerResponse, } from "./types.js";
|
||||
export { H264Encoder } from "./h264-encoder.js";
|
||||
export type { H264EncoderConfig, EncodedChunk } from "./h264-encoder.js";
|
||||
export { FrameRenderer } from "./renderer.js";
|
||||
export { FMP4Demuxer } from "./fmp4-demuxer.js";
|
||||
export type { DemuxedSample, VideoTrackInfo } from "./fmp4-demuxer.js";
|
||||
export { FMP4Muxer } from "./fmp4-muxer.js";
|
||||
export type { MuxerInitConfig, MuxerSample } from "./fmp4-muxer.js";
|
||||
export { MSEController } from "./mse-controller.js";
|
||||
export { TranscodePipeline } from "./transcode-pipeline.js";
|
||||
export type { TranscodePipelineConfig } from "./transcode-pipeline.js";
|
||||
export { setLogLevel } from "./log.js";
|
||||
export type { LogLevel } from "./log.js";
|
||||
export { installMSEIntercept, uninstallMSEIntercept } from "./mse-intercept.js";
|
||||
export type { MSEInterceptConfig } from "./mse-intercept.js";
|
||||
export { SegmentTranscoder } from "./segment-transcoder.js";
|
||||
export type { SegmentTranscoderConfig, TranscodedInit } from "./segment-transcoder.js";
|
||||
export { TranscodeWorkerClient } from "./transcode-worker-client.js";
|
||||
export type { TranscodeWorkerClientConfig } from "./transcode-worker-client.js";
|
||||
export { hevcMimeToH264Codec } from "./codec-mapping.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+2227
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* YUV Frame Renderer — converts decoded YUV frames to displayable video.
|
||||
*
|
||||
* Uses VideoFrame + MediaStreamTrackGenerator when available (Chrome 94+),
|
||||
* falls back to WebGL canvas rendering.
|
||||
*/
|
||||
import type { HEVCFrame } from "./types.js";
|
||||
/**
|
||||
* Renderer that converts YUV frames to a <video>-compatible MediaStream
|
||||
* or renders directly to a canvas.
|
||||
*/
|
||||
export declare class FrameRenderer {
|
||||
private _generator;
|
||||
private _writer;
|
||||
private _canvas;
|
||||
private _gl;
|
||||
private _program;
|
||||
private _texY;
|
||||
private _texCb;
|
||||
private _texCr;
|
||||
/**
|
||||
* Check if MediaStreamTrackGenerator is available (Chrome 94+).
|
||||
* When available, frames can be piped to a <video> element.
|
||||
*/
|
||||
static get supportsMediaStream(): boolean;
|
||||
/**
|
||||
* Get a MediaStream that can be assigned to a <video>.srcObject.
|
||||
* Only available when supportsMediaStream is true.
|
||||
*/
|
||||
getMediaStream(): MediaStream | null;
|
||||
/**
|
||||
* Render a decoded YUV frame.
|
||||
*
|
||||
* If MediaStreamTrackGenerator is available, creates a VideoFrame and writes it.
|
||||
* Otherwise, renders to the provided canvas via WebGL.
|
||||
*/
|
||||
renderFrame(frame: HEVCFrame, timestamp: number): Promise<void>;
|
||||
/**
|
||||
* Initialize WebGL canvas fallback.
|
||||
* Call this if MediaStreamTrackGenerator is not supported.
|
||||
*/
|
||||
initCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
||||
private _renderToVideoFrame;
|
||||
private _initWebGL;
|
||||
private _renderToWebGL;
|
||||
/** Release all resources */
|
||||
destroy(): void;
|
||||
}
|
||||
//# sourceMappingURL=renderer.d.ts.map
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/** Decoded YUV frame — planes are copied out of WASM heap */
|
||||
export interface HEVCFrame {
|
||||
/** Luma plane (packed, no stride) */
|
||||
y: Uint16Array;
|
||||
/** Chroma Cb plane */
|
||||
cb: Uint16Array;
|
||||
/** Chroma Cr plane */
|
||||
cr: Uint16Array;
|
||||
/** Luma width (display, after conformance crop) */
|
||||
width: number;
|
||||
/** Luma height (display) */
|
||||
height: number;
|
||||
/** Chroma plane width */
|
||||
chromaWidth: number;
|
||||
/** Chroma plane height */
|
||||
chromaHeight: number;
|
||||
/** Bit depth (8 or 10) */
|
||||
bitDepth: number;
|
||||
/** Picture Order Count (display order) */
|
||||
poc: number;
|
||||
}
|
||||
/** Stream metadata — available after first decode */
|
||||
export interface HEVCStreamInfo {
|
||||
width: number;
|
||||
height: number;
|
||||
bitDepth: number;
|
||||
/** 0=mono, 1=4:2:0, 2=4:2:2, 3=4:4:4 */
|
||||
chromaFormat: number;
|
||||
/** Profile IDC (1=Main, 2=Main10) */
|
||||
profile: number;
|
||||
/** Level IDC (e.g. 93 = Level 3.1) */
|
||||
level: number;
|
||||
}
|
||||
/** Result of a decode call */
|
||||
export interface DecodeResult {
|
||||
frames: HEVCFrame[];
|
||||
info: HEVCStreamInfo | null;
|
||||
}
|
||||
/** Options for creating a decoder */
|
||||
export interface DecoderOptions {
|
||||
/** URL to the hevc-decode.js WASM glue file. Auto-resolved if omitted. */
|
||||
wasmUrl?: string;
|
||||
/** URL to the .wasm binary. Auto-resolved if omitted. */
|
||||
wasmBinaryUrl?: string;
|
||||
}
|
||||
/** Worker message types (main → worker) */
|
||||
export type WorkerRequest = {
|
||||
type: "init";
|
||||
wasmUrl: string;
|
||||
} | {
|
||||
type: "decode";
|
||||
data: ArrayBuffer;
|
||||
} | {
|
||||
type: "feed";
|
||||
data: ArrayBuffer;
|
||||
} | {
|
||||
type: "drain";
|
||||
} | {
|
||||
type: "flush";
|
||||
} | {
|
||||
type: "destroy";
|
||||
};
|
||||
/** Worker message types (worker → main) */
|
||||
export type WorkerResponse = {
|
||||
type: "ready";
|
||||
} | {
|
||||
type: "info";
|
||||
info: HEVCStreamInfo;
|
||||
} | {
|
||||
type: "frame";
|
||||
index: number;
|
||||
frame: HEVCFrame;
|
||||
} | {
|
||||
type: "done";
|
||||
frameCount: number;
|
||||
} | {
|
||||
type: "drained";
|
||||
frames: HEVCFrame[];
|
||||
} | {
|
||||
type: "flushed";
|
||||
frames: HEVCFrame[];
|
||||
} | {
|
||||
type: "error";
|
||||
message: string;
|
||||
};
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Reference in New Issue
Block a user