forge
Explore
Log in

Don't you dare go Hollow

The software decoder now agrees with ffmpeg, picture for picture

Browse files at this commit

1d9b2f4b6486bbb4b0ff4a635f74f31a162f2876Ahmet Kaan GümüşParent: 907dae0
  • deps
    • the software decoder now agrees with ffmpeg, picture for picture
Show full message
⬆️ deps(h264): the software decoder now agrees with ffmpeg, picture for picture

`rusty_h264` 0.8 was not bit-exact. Across a 1080p High and a 720p Main clip
-- 750 pictures, both with B-frames -- it reproduced ffmpeg's own decode
byte-for-byte on 26 of them and drifted on the other 724, worst case 69.8 dB
PSNR. That is invisible on a monitor and still wrong: it is the picture a
grade is measured on, the picture a still is exported from, and the picture a
software export re-encodes. 0.9.1 matches ffmpeg on all 750, which is the
property the manifest already demands of `ruopus` and `oxideav-ac3` and had
never actually checked here. Pinned exactly for the same reason they are.

It is faster by the same stroke: 247 Mpx/s against 171 decoding the 1080p
clip, 256 against 176 on the 720p one -- 1.44x, single-threaded, min of 20
interleaved rounds on a loaded box (a second binary built from the same 0.9.1
sources came within 1%, which is what the interleaving is for). Software
encode is a wash at 1.04x and 0.97x, so nothing about an export's speed
changes; what changes is what it encodes *from*.

The challenger measured against it, `rust_h264` 0.4.0 (MIT/Apache-2, pure
Rust, decode only), does not take the seat on either axis: 1.00x and 0.88x of
0.8's decode rate, so 0.69x of this crate's, and it is not bit-exact either --
256 of the same 750 pictures, worst 39.2 dB, and the mismatches are pixels
ffmpeg never emitted rather than a reordering. The gate wanted 1.25x and no
correctness regression; it returned neither.

`default-features = false` stays, and keeps the vendored openh264 SIMD kernels
(`asm`, `nasm` at build time) out of a build this project promises needs no
tools. It does not keep out `rusty_alloc`: the facade pulls its sub-crates with
their own defaults and `rusty_h264-common` installs that allocator process-wide
for the whole app. Nothing downstream can switch it off. Measured at 0.104 s
against glibc's 0.142 s on 2M mixed allocations, so it is a gift rather than a
tax -- but it is a gift nobody asked for, and the manifest now says so.
Cargo.lockmodified+37 -8
@@ -5012,11 +5012,30 @@ checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
5012 name = "rusty_aac"5012 name = "rusty_aac"
5013 version = "0.5.0"5013 version = "0.5.0"
5014 5014
5015+[[package]]
5016+name = "rusty_alloc"
5017+version = "0.3.2"
5018+source = "registry+https://github.com/rust-lang/crates.io-index"
5019+checksum = "b5f05c71564028538eeba6e2e08c6a512267e85e6a1584beca45c6f26af8651b"
5020+dependencies = [
5021+ "libc",
5022+ "windows-sys 0.60.2",
5023+]
5024+
5025+[[package]]
5026+name = "rusty_alloc-api"
5027+version = "0.3.2"
5028+source = "registry+https://github.com/rust-lang/crates.io-index"
5029+checksum = "65c8c3ecd14424ba980d005147945a745836dea7798d447c419e08be1f79e88f"
5030+dependencies = [
5031+ "rusty_alloc",
5032+]
5033+
5015 [[package]]5034 [[package]]
5016 name = "rusty_h264"5035 name = "rusty_h264"
5017-version = "0.8.0"5036+version = "0.9.1"
5018 source = "registry+https://github.com/rust-lang/crates.io-index"5037 source = "registry+https://github.com/rust-lang/crates.io-index"
5019-checksum = "6fbafa4757ced9c5c1d1185aa936bb040b00c456098874f209e04ed1c1c2d73b"5038+checksum = "690044fc22dedcc09367177bd50cc7f6b46b72f3227d35a9311e69c64c2a73d4"
5020 dependencies = [5039 dependencies = [
5021 "rusty_h264-common",5040 "rusty_h264-common",
5022 "rusty_h264-decoder",5041 "rusty_h264-decoder",
@@ -5025,28 +5044,29 @@ dependencies = [
5025 5044
5026 [[package]]5045 [[package]]
5027 name = "rusty_h264-common"5046 name = "rusty_h264-common"
5028-version = "0.8.0"5047+version = "0.9.1"
5029 source = "registry+https://github.com/rust-lang/crates.io-index"5048 source = "registry+https://github.com/rust-lang/crates.io-index"
5030-checksum = "421e458fcfcb2580232f212f99451f9075a03d00752a934ee27be6148a6765e3"5049+checksum = "ed3c3c7ad3a43386460736b7552ab82239bdd703bedcf8c7f5d0032c50cfb8cb"
5031 dependencies = [5050 dependencies = [
5032 "bytemuck",5051 "bytemuck",
5052+ "rusty_alloc-api",
5033 "wide",5053 "wide",
5034 ]5054 ]
5035 5055
5036 [[package]]5056 [[package]]
5037 name = "rusty_h264-decoder"5057 name = "rusty_h264-decoder"
5038-version = "0.8.0"5058+version = "0.9.1"
5039 source = "registry+https://github.com/rust-lang/crates.io-index"5059 source = "registry+https://github.com/rust-lang/crates.io-index"
5040-checksum = "6316ecba57a77d530fff4fab7be9cc3e0e107e381360ac9d2ffa0895b5b0947a"5060+checksum = "1cd475fe0f7480930bf735275111922733a323cb9ef7d83d825a0222ccde9fb4"
5041 dependencies = [5061 dependencies = [
5042 "rusty_h264-common",5062 "rusty_h264-common",
5043 ]5063 ]
5044 5064
5045 [[package]]5065 [[package]]
5046 name = "rusty_h264-encoder"5066 name = "rusty_h264-encoder"
5047-version = "0.8.0"5067+version = "0.9.1"
5048 source = "registry+https://github.com/rust-lang/crates.io-index"5068 source = "registry+https://github.com/rust-lang/crates.io-index"
5049-checksum = "f4fb69d8977d1d067d6d603df0614678c4a35ac1201fff38783c8847e429c879"5069+checksum = "8100c6b118fa62ff4f021b47cf2d6feb423dad78e3dec5d8dfc2d0ff3a6729bb"
5050 dependencies = [5070 dependencies = [
5051 "rusty_h264-common",5071 "rusty_h264-common",
5052 ]5072 ]
@@ -7190,6 +7210,15 @@ dependencies = [
7190 "windows-targets 0.52.6",7210 "windows-targets 0.52.6",
7191 ]7211 ]
7192 7212
7213+[[package]]
7214+name = "windows-sys"
7215+version = "0.60.2"
7216+source = "registry+https://github.com/rust-lang/crates.io-index"
7217+checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
7218+dependencies = [
7219+ "windows-targets 0.53.5",
7220+]
7221+
7193 [[package]]7222 [[package]]
7194 name = "windows-sys"7223 name = "windows-sys"
7195 version = "0.61.2"7224 version = "0.61.2"
crates/engine/Cargo.tomlmodified+24 -1
@@ -28,7 +28,30 @@ mp4 = "0.14"
28 # pulls this exact version in through `png`, and it is the pure-Rust inflate the28 # pulls this exact version in through `png`, and it is the pure-Rust inflate the
29 # rest of the ecosystem is built on.29 # rest of the ecosystem is built on.
30 miniz_oxide = "0.8"30 miniz_oxide = "0.8"
31-rusty_h264 = { version = "0.8", default-features = false }31+# The software H.264 pair, and the only software decoder this project has for
32+# any format. Pinned exactly, like `ruopus` and `oxideav-ac3` below, because a
33+# decoder is a bit-exactness dependency -- and 0.9.1 is where that stopped being
34+# a figure of speech. Measured 2026-08-12 against ffmpeg's own decode of a 1080p
35+# High and a 720p Main clip, 750 pictures between them: 0.8 matched it
36+# byte-for-byte on 26 of the 750 and drifted on the rest (worst 69.8 dB PSNR --
37+# invisible, but wrong); 0.9.1 matches on all 750. It is also 1.44x faster at it
38+# (247 Mpx/s against 171 on the 1080p clip, single-threaded); software *encode*
39+# is unchanged within noise, so this is a decode bump that the encoder came
40+# along with. `default-features = false` is what keeps `asm` off: those are
41+# vendored openh264 SIMD kernels that want `nasm` at build time, which this
42+# project's no-install rule forbids, and the crate enables them by default.
43+#
44+# What that line does not turn off, and cannot: the facade asks for its three
45+# sub-crates with *their* defaults, and `rusty_h264-common`'s default installs
46+# `rusty_alloc` -- a pure-Rust mimalloc remake, MIT -- as the process-wide
47+# `#[global_allocator]`, for the whole application rather than the codec. No
48+# feature choice downstream switches it back off; only a vendored `common`
49+# would. It is not a regression to pay for: the same 2M-allocation churn runs in
50+# 0.104 s under it against 0.142 s under glibc's, so it stays, and this
51+# paragraph is the disclosure. Frame-threaded decode arrived in 0.9 as well and
52+# is opt-in through `RS_H264_FRAME_THREADS`, unset here -- the decode loop is
53+# serial exactly as it was.
54+rusty_h264 = { version = "=0.9.1", default-features = false }
32 # Both halves of AAC, and the only crate here that is asked for both. The55 # Both halves of AAC, and the only crate here that is asked for both. The
33 # *encoder*, so an mp4's sound can be a mix rather than a copy: an equalized (or56 # *encoder*, so an mp4's sound can be a mix rather than a copy: an equalized (or
34 # otherwise processed) lane has to be decoded, and what is decoded has to be57 # otherwise processed) lane has to be decoded, and what is decoded has to be