Adapted from MIT-licensed PL_MPEG by Dominic Szablewski. Original C input/attribution: third_party/pl_mpeg. This is a separate Jai implementation using layouts and checked bounds/I/O; no Jai port input.
#import "pl_mpeg";
Procedures#
Buffer#
Pixels#
IDCT#
Two separable integer passes adapted from the licensed public C pl_mpeg implementation. Coefficients use the decoder's premultiplied scale.
Video#
Transactional variable-length parsing: incomplete custom matrices retain the header cursor for a later callback/append, without exposing partial metadata.
Motion#
Motion reconstruction and integer half-pixel filtering adapted from public C pl_mpeg (MIT); source attribution is in third_party/pl_mpeg/README.md.
The parameter is named d; it denotes the reference frame here.
Reconstruction#
Entropy decoding, dequantization and frame ordering adapted from licensed public C pl_mpeg. Reviewed Jai records remain the actual live decoder state.
Synthesis#
Direct MPEG synthesis matrix. Kept separate from entropy/sample decoding so a future verified factorization can replace it without changing the public API.
Audio#
Program#
Linear seeks retain real decoded frames and work without a side index. The precise/nonprecise frame selection and audio alignment require contract review.
Types#
- FILE
- FIXED_MEM
- RING
- APPEND
- SEQUENCE
- SLICE_FIRST
- SLICE_LAST
- PICTURE
- EXTENSION
- USER_DATA
- PACK
- END
- SYSTEM
- PRIVATE
- AUDIO_1
- AUDIO_2
- AUDIO_3
- AUDIO_4
- VIDEO_1
- NOT_FOUND
- index: s16
- value: s16
- index: s16
- value: u16
- bit_index: s64
- capacity: s64
- length: s64
- total_size: s64
- discard_read_bytes: := false
- has_ended: := false
- free_when_done: := false
- close_when_done: := false
- file_initted: := false
- fh: File
- load_callback: Buffer_Load_Callback
- load_callback_user_data: *void
- bytes: *u8
- mode: Buffer_Mode
Plane storage and the integer BT.601 transform adapted from the licensed public C pl_mpeg implementation; see third_party/pl_mpeg/README.md.
- width: s32
- height: s32
- data: *u8
- levels: u16
- group: u8
- bits: u8
- STEREO
- JOINT_STEREO
- DUAL_CHANNEL
- MONO
- INTRA
- PREDICTIVE
- B
Canonical shapes retain ABI field order.
- full_px: s32
- is_set: s32
- r_size: s32
- h: s32
- v: s32
- framerate: float64
- time: float64
- frames_decoded: s32
- width: s32
- height: s32
- mb_width: s32
- mb_height: s32
- mb_size: s32
- luma_width: s32
- luma_height: s32
- chroma_width: s32
- chroma_height: s32
- start_code: Start_Code
- picture_type: Picture_Type
- motion_forward: Video_Motion
- motion_backward: Video_Motion
- has_sequence_header: := false
- quantizer_scale: s32
- slice_begin: := false
- macroblock_address: s32
- mb_row: s32
- mb_col: s32
- macroblock_type: s32
- macroblock_intra: s32
- dc_predictor: [3] s32
- buffer: *Buffer
- destroy_buffer_when_done: bool
- frame_current: Frame
- frame_forward: Frame
- frame_backward: Frame
- frames_data: *u8
- block_data: [64] s32
- intra_quant_matrix: [64] u8
- non_intra_quant_matrix: [64] u8
- has_reference_frame: := false
- assume_no_b_frames: := false
Canonical shapes retain ABI field order.
- time: float64
- count: u32
- interleaved: [SAMPLES_PER_FRAME * 2] float
- time: float64
- samples_decoded: s32
- samplerate_index: s32
- bitrate_index: s32
- version: s32
- layer: s32
- mode: Audio_Mode
- bound: s32
- v_pos: s32
- next_frame_data_size: s32
- has_header: := false
- buffer: *Buffer
- destroy_buffer_when_done: bool
- allocation: [2][32] *Quantizer_Spec
- scale_factor_info: [2][32] u8
- scale_factor: [2][32][3] s32
- sample: [2][32][3] s32
- samples: Samples
- D: [1024] float
- V: [2][1024] float
- U: [32] float
Canonical high-level playback record. Private demux state is defined below.
- demux: *Demux
- time: float64
- has_ended: bool
- loop: bool
- has_decoders: bool
- video_enabled: := true
- video_packet_type: Start_Code
- video_buffer: *Buffer
- video_decoder: *Video
- audio_enabled: := true
- audio_stream_index: s32
- audio_packet_type: Start_Code
- audio_lead_time: float64
- audio_buffer: *Buffer
- audio_decoder: *Audio
- video_decode_callback: Video_Decode_Callback
- video_decode_callback_user_data: *void
- audio_decode_callback: Audio_Decode_Callback
- audio_decode_callback_user_data: *void
- type: Start_Code
- pts: float64
- data: [] u8