forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

lib.rs66 lines, 2.3 KiBHistoryRawDownload
1//! H.264 software decoder and encoder.
2//!
3//! Decoder scope: I, P and B slices under both entropy coders (CAVLC and
4//! CABAC) of 8-bit, High 10 (9- and 10-bit), High 4:2:2 (4:2:0 and 4:2:2,
5//! 8 to 10 bits) and High 4:4:4 Predictive / CAVLC 4:4:4 Intra (4:4:4, separate
6//! colour planes, monochrome, lossless transform bypass; 8 to 10 bits, 14 bits
7//! with [`Decoder::set_wide_samples`]) progressive, PAFF and MBAFF streams — intra prediction, inter
8//! prediction with the full decoded picture buffer of clause 8.2, weighted
9//! prediction, and the in-loop deblocking filter — decoded bit-exactly against
10//! the JVT conformance suite. Frames come out in display order. Everything
11//! outside that scope returns a named [`Error::Unsupported`] — never wrong
12//! output.
13//!
14//! Implemented from Rec. ITU-T H.264 (V15, 08/2024) only; no third-party
15//! decoder source was consulted.
16//!
17//! Two entry surfaces over one decode core: [`Decoder`] takes NAL units, which
18//! is what a bitstream tool has, and [`H264Decoder`] implements
19//! [`ec_core::registry::Decoder`] over packets — including `avcC` extradata and
20//! length-prefixed NAL units — which is what a demuxer hands over.
21//!
22//! ```no_run
23//! use ec_core::registry::{CodecId, CodecParameters, Decoder};
24//! use ec_core::{Packet, TimeBase};
25//! use ec_h264::H264Decoder;
26//!
27//! # fn main() -> ec_core::Result<()> {
28//! let annex_b: Vec<u8> = std::fs::read("stream.264")?;
29//! let mut decoder = H264Decoder::new(CodecParameters::new(CodecId::H264))?;
30//! decoder.send_packet(&Packet::new(0, TimeBase::new(1, 25), annex_b))?;
31//! let frame = decoder.receive_frame()?; // the first decoded picture, I420 (I010 for High 10, I422/I210 for High 4:2:2, I444/I410 for 4:4:4)
32//! # let _ = frame;
33//! # Ok(())
34//! # }
35//! ```
36
37#![forbid(unsafe_code)]
38
39mod bits;
40mod cabac;
41mod cabac_tables;
42mod cavlc;
43mod codec;
44mod deblock;
45mod deblock_mbaff;
46mod decoder;
47mod dpb;
48mod enc;
49mod fmo;
50mod entropy;
51mod inter;
52mod inter16;
53mod mbaff;
54mod mv;
55mod pred;
56mod sample;
57mod tables;
58mod transform;
59
60pub use cabac::BitAccount;
61pub use codec::H264Decoder;
62pub use decoder::{Decoder, MbShapes, NalOutcome, OutputOrder};
63pub use ec_core::error::{Error, Result};
64#[cfg(feature = "enc-profile")]
65pub use enc::timing::mb_stages;
66pub use enc::{EncodeTimings, EncodedPicture, Encoder, EncoderConfig, PictureView, Preset};