forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiBdfeffbcTahinli2 months ago3180 commits

lib.rs56 lines, 1.9 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 4:2:0 progressive streams — intra prediction, inter
5//! prediction with the full decoded picture buffer of clause 8.2, weighted
6//! prediction, and the in-loop deblocking filter — decoded bit-exactly against
7//! the JVT conformance suite. Frames come out in display order. Everything
8//! outside that scope returns a named [`Error::Unsupported`] — never wrong
9//! output.
10//!
11//! Implemented from Rec. ITU-T H.264 (V15, 08/2024) only; no third-party
12//! decoder source was consulted.
13//!
14//! Two entry surfaces over one decode core: [`Decoder`] takes NAL units, which
15//! is what a bitstream tool has, and [`H264Decoder`] implements
16//! [`ec_core::registry::Decoder`] over packets — including `avcC` extradata and
17//! length-prefixed NAL units — which is what a demuxer hands over.
18//!
19//! ```no_run
20//! use ec_core::registry::{CodecId, CodecParameters, Decoder};
21//! use ec_core::{Packet, TimeBase};
22//! use ec_h264::H264Decoder;
23//!
24//! # fn main() -> ec_core::Result<()> {
25//! let annex_b: Vec<u8> = std::fs::read("stream.264")?;
26//! let mut decoder = H264Decoder::new(CodecParameters::new(CodecId::H264))?;
27//! decoder.send_packet(&Packet::new(0, TimeBase::new(1, 25), annex_b))?;
28//! let frame = decoder.receive_frame()?; // the first decoded picture, I420
29//! # let _ = frame;
30//! # Ok(())
31//! # }
32//! ```
33
34#![forbid(unsafe_code)]
35
36mod bits;
37mod cabac;
38mod cabac_tables;
39mod cavlc;
40mod codec;
41mod deblock;
42mod decoder;
43mod dpb;
44mod enc;
45mod entropy;
46mod inter;
47mod mv;
48mod pred;
49mod tables;
50mod transform;
51
52pub use cabac::BitAccount;
53pub use codec::H264Decoder;
54pub use decoder::{Decoder, MbShapes, NalOutcome, OutputOrder};
55pub use ec_core::error::{Error, Result};
56pub use enc::{EncodedPicture, Encoder, EncoderConfig, PictureView, Preset};