Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

feat(poc-native): CPU decode measured every way — the wall is CPU↔GPU transport

Etienne Lescot62d538f21d30
diff --git a/docs/architecture/rendering-architecture.md b/docs/architecture/rendering-architecture.md
index d088dda79..da8659173 100644
--- a/docs/architecture/rendering-architecture.md
+++ b/docs/architecture/rendering-architecture.md
@@ -724,6 +724,37 @@ quoted as "native loses."**
the only path that can turn the 256 fps encoder ceiling into real throughput.
It is deep unsafe interop (days, not hours).
+**D.5 — The CPU-native path was pushed to its ceiling, and it loses by
+construction (measured 2026-07-17).** The product owner rejected "31 fps is a pipe
+artifact, so native might still win" and asked to actually beat the browser. The
+CPU path was driven as far as it goes:
+
+| native pipeline | throughput |
+|---|---:|
+| subprocess pipes (decode+encode) | 31 fps |
+| in-process CPU decode, synchronous | 25 fps |
+| in-process CPU decode, **threaded** (overlapped), no encode | 61 fps |
+| threaded decode + composite + h264_amf | ~48 fps |
+| threaded, no readback, no encode (isolates the descent) | 68 fps |
+| — WebCodecs (browser) | 79 fps |
+| — d3d11va decode → h264_amf, all on GPU | 256 fps |
+
+Threading the decode was the real lever (25 → 61): the subprocess version's
+advantage was never "pipes", it was parallel decode. But the CPU path plateaus
+UNDER the browser, and the reason is now pinned by the no-readback probe: the
+descent (GPU→CPU) is only ~10 % (61 → 68); the wall is **CPU↔GPU transport** — 9 MB
+uploaded per frame on input, 8 MB read back on output, plus CPU swscale at both
+ends (YUV→RGBA decode, RGBA→NV12 encode). The browser pays none of this: WebCodecs
+decodes into GPU-backed `VideoFrame`s that `importExternalTexture` wraps with no
+CPU copy. **Its edge is GPU-residency, and no CPU-side trick can match it.**
+
+So the product owner is right in principle — native's *ceiling* (256 fps) crushes
+the browser (79) — but only the GPU-resident path reaches it: hardware decode
+straight into GPU textures (no upload) + zero-descent GPU→encoder (no readback).
+That is the deep D3D11/D3D12 (or Vulkan Video) interop, unbuilt, and it is the only
+thing that turns 256 into real throughput. The CPU-transport native pipeline is
+measured out at ~48–68 fps; that is its ceiling.
+
**The standing conclusion is unchanged but now grounded on both sides:** the web
platform (WebCodecs) hands you the on-device fast path for free (79 fps, no interop
written); native offers a much higher ceiling (256 fps encoder) but only behind
diff --git a/poc-native/.gitignore b/poc-native/.gitignore
index 95466d85b..fd6c09d27 100644
--- a/poc-native/.gitignore
+++ b/poc-native/.gitignore
@@ -3,3 +3,4 @@
*.bmp
out-preview.png
out.mp4
+/ffmpeg-dev
diff --git a/poc-native/Cargo.lock b/poc-native/Cargo.lock
new file mode 100644
index 000000000..bbc143170
--- /dev/null
+++ b/poc-native/Cargo.lock
@@ -0,0 +1,1296 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "aho-corasick"
+version = "1.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "android_system_properties"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "arrayvec"
+version = "0.7.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"
+
+[[package]]
+name = "ash"
+version = "0.38.0+1.3.281"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f"
+dependencies = [
+ "libloading",
+]
+
+[[package]]
+name = "bindgen"
+version = "0.72.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895"
+dependencies = [
+ "bitflags 2.13.1",
+ "cexpr",
+ "clang-sys",
+ "itertools",
+ "proc-macro2",
+ "quote",
+ "regex",
+ "rustc-hash 2.1.3",
+ "shlex 1.3.0",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "bit-set"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0481a0e032742109b1133a095184ee93d88f3dc9e0d28a5d033dc77a073f44f"
+dependencies = [
+ "bit-vec",
+]
+
+[[package]]
+name = "bit-vec"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2c54ff287cfc0a34f38a6b832ea1bd8e448a330b3e40a50859e6488bee07f22"
+
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
+[[package]]
+name = "bitflags"
+version = "2.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
+
+[[package]]
+name = "block"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
+
+[[package]]
+name = "bumpalo"
+version = "3.20.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
+
+[[package]]
+name = "bytemuck"
+version = "1.25.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6aedf8ae72766347502cf3cb4f41cf5e9cc37d28bee90f1fdaaae15f9cf9424"
+dependencies = [
+ "bytemuck_derive",
+]
+
+[[package]]
+name = "bytemuck_derive"
+version = "1.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f65693059b6b9c588b9f62fed1cedbf0a8b805631457ea162d68f0de186f3de5"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "cc"
+version = "1.2.67"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e17dd265a7d0f31ef544e1b20e03add05d3b45b491b633b10d67145d2acc1a38"
+dependencies = [
+ "find-msvc-tools",
+ "shlex 2.0.1",
+]
+
+[[package]]
+name = "cexpr"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
+dependencies = [
+ "nom",
+]
+
+[[package]]
+name = "cfg-if"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
+
+[[package]]
+name = "cfg_aliases"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
+
+[[package]]
+name = "clang-sys"
+version = "1.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
+dependencies = [
+ "glob",
+ "libc",
+ "libloading",
+]
+
+[[package]]
+name = "codespan-reporting"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
+dependencies = [
+ "termcolor",
+ "unicode-width",
+]
+
+[[package]]
+name = "com"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e17887fd17353b65b1b2ef1c526c83e26cd72e74f598a8dc1bee13a48f3d9f6"
+dependencies = [
+ "com_macros",
+]
+
+[[package]]
+name = "com_macros"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d375883580a668c7481ea6631fc1a8863e33cc335bf56bfad8d7e6d4b04b13a5"
+dependencies = [
+ "com_macros_support",
+ "proc-macro2",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "com_macros_support"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ad899a1087a9296d5644792d7cb72b8e34c1bec8e7d4fbc002230169a6e8710c"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "core-foundation"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "core-foundation-sys"
+version = "0.8.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
+
+[[package]]
+name = "core-graphics-types"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf"
+dependencies = [
+ "bitflags 1.3.2",
+ "core-foundation",
+ "libc",
+]
+
+[[package]]
+name = "d3d12"
+version = "22.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bdbd1f579714e3c809ebd822c81ef148b1ceaeb3d535352afc73fd0c4c6a0017"
+dependencies = [
+ "bitflags 2.13.1",
+ "libloading",
+ "winapi",
+]
+
+[[package]]
+name = "document-features"
+version = "0.2.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61"
+dependencies = [
+ "litrs",
+]
+
+[[package]]
+name = "either"
+version = "1.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
+
+[[package]]
+name = "equivalent"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
+
+[[package]]
+name = "ffmpeg-next"
+version = "8.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f7c4bd5ab1ac61f29c634df1175d350ded29cf74c3c6d4f7030431a5ae3c7d5d"
+dependencies = [
+ "bitflags 2.13.1",
+ "ffmpeg-sys-next",
+ "libc",
+]
+
+[[package]]
+name = "ffmpeg-sys-next"
+version = "8.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a314bc0e022a33a99567ed4bd2576bd58ffd8fcff7891c29194cfecc26a62547"
+dependencies = [
+ "bindgen",
+ "cc",
+ "libc",
+ "num_cpus",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "find-msvc-tools"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
+
+[[package]]
+name = "foldhash"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
+
+[[package]]
+name = "foreign-types"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
+dependencies = [
+ "foreign-types-macros",
+ "foreign-types-shared",
+]
+
+[[package]]
+name = "foreign-types-macros"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "foreign-types-shared"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
+
+[[package]]
+name = "futures-core"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d"
+
+[[package]]
+name = "futures-task"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393"
+
+[[package]]
+name = "futures-util"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "pin-project-lite",
+ "slab",
+]
+
+[[package]]
+name = "gl_generator"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
+dependencies = [
+ "khronos_api",
+ "log",
+ "xml-rs",
+]
+
+[[package]]
+name = "glob"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
+
+[[package]]
+name = "glow"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bd348e04c43b32574f2de31c8bb397d96c9fcfa1371bd4ca6d8bdc464ab121b1"
+dependencies = [
+ "js-sys",
+ "slotmap",
+ "wasm-bindgen",
+ "web-sys",
+]
+
+[[package]]
+name = "glutin_wgl_sys"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e"
+dependencies = [
+ "gl_generator",
+]
+
+[[package]]
+name = "gpu-alloc"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "45cf04b2726f02df5508c6de726acdc90cdf97ac771a9a0ffd8ba10a6e696bf9"
+dependencies = [
+ "bitflags 2.13.1",
+ "gpu-alloc-types",
+]
+
+[[package]]
+name = "gpu-alloc-types"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b2bbed164dd10ed526c2e4fe3e721ca4a71c61730e5aafac6844b417b3227058"
+dependencies = [
+ "bitflags 2.13.1",
+]
+
+[[package]]
+name = "gpu-allocator"
+version = "0.26.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fdd4240fc91d3433d5e5b0fc5b67672d771850dc19bbee03c1381e19322803d7"
+dependencies = [
+ "log",
+ "presser",
+ "thiserror",
+ "winapi",
+ "windows",
+]
+
+[[package]]
+name = "gpu-descriptor"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b89c83349105e3732062a895becfc71a8f921bb71ecbbdd8ff99263e3b53a0ca"
+dependencies = [
+ "bitflags 2.13.1",
+ "gpu-descriptor-types",
+ "hashbrown 0.15.5",
+]
+
+[[package]]
+name = "gpu-descriptor-types"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91"
+dependencies = [
+ "bitflags 2.13.1",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.15.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
+dependencies = [
+ "foldhash",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.17.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
+
+[[package]]
+name = "hassle-rs"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "af2a7e73e1f34c48da31fb668a907f250794837e08faa144fd24f0b8b741e890"
+dependencies = [
+ "bitflags 2.13.1",
+ "com",
+ "libc",
+ "libloading",
+ "thiserror",
+ "widestring",
+ "winapi",
+]
+
+[[package]]
+name = "hermit-abi"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c"
+
+[[package]]
+name = "hexf-parse"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
+
+[[package]]
+name = "indexmap"
+version = "2.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
+dependencies = [
+ "equivalent",
+ "hashbrown 0.17.1",
+]
+
+[[package]]
+name = "itertools"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "jni-sys"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258"
+dependencies = [
+ "jni-sys 0.4.1",
+]
+
+[[package]]
+name = "jni-sys"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2"
+dependencies = [
+ "jni-sys-macros",
+]
+
+[[package]]
+name = "jni-sys-macros"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264"
+dependencies = [
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "js-sys"
+version = "0.3.103"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102"
+dependencies = [
+ "cfg-if",
+ "futures-util",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "khronos-egl"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76"
+dependencies = [
+ "libc",
+ "libloading",
+ "pkg-config",
+]
+
+[[package]]
+name = "khronos_api"
+version = "3.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
+
+[[package]]
+name = "libc"
+version = "0.2.186"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
+
+[[package]]
+name = "libloading"
+version = "0.8.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
+dependencies = [
+ "cfg-if",
+ "windows-link",
+]
+
+[[package]]
+name = "litrs"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092"
+
+[[package]]
+name = "lock_api"
+version = "0.4.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
+dependencies = [
+ "scopeguard",
+]
+
+[[package]]
+name = "log"
+version = "0.4.33"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
+
+[[package]]
+name = "malloc_buf"
+version = "0.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "memchr"
+version = "2.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
+
+[[package]]
+name = "metal"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ecfd3296f8c56b7c1f6fbac3c71cefa9d78ce009850c45000015f206dc7fa21"
+dependencies = [
+ "bitflags 2.13.1",
+ "block",
+ "core-graphics-types",
+ "foreign-types",
+ "log",
+ "objc",
+ "paste",
+]
+
+[[package]]
+name = "minimal-lexical"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
+
+[[package]]
+name = "naga"
+version = "22.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8bd5a652b6faf21496f2cfd88fc49989c8db0825d1f6746b1a71a6ede24a63ad"
+dependencies = [
+ "arrayvec",
+ "bit-set",
+ "bitflags 2.13.1",
+ "cfg_aliases",
+ "codespan-reporting",
+ "hexf-parse",
+ "indexmap",
+ "log",
+ "rustc-hash 1.1.0",
+ "spirv",
+ "termcolor",
+ "thiserror",
+ "unicode-xid",
+]
+
+[[package]]
+name = "ndk-sys"
+version = "0.5.0+25.2.9519653"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691"
+dependencies = [
+ "jni-sys 0.3.1",
+]
+
+[[package]]
+name = "nom"
+version = "7.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
+dependencies = [
+ "memchr",
+ "minimal-lexical",
+]
+
+[[package]]
+name = "num_cpus"
+version = "1.17.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b"
+dependencies = [
+ "hermit-abi",
+ "libc",
+]
+
+[[package]]
+name = "objc"
+version = "0.2.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
+dependencies = [
+ "malloc_buf",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.21.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+
+[[package]]
+name = "parking_lot"
+version = "0.12.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
+dependencies = [
+ "lock_api",
+ "parking_lot_core",
+]
+
+[[package]]
+name = "parking_lot_core"
+version = "0.9.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall",
+ "smallvec",
+ "windows-link",
+]
+
+[[package]]
+name = "paste"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
+
+[[package]]
+name = "pkg-config"
+version = "0.3.33"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e"
+
+[[package]]
+name = "poc-native"
+version = "0.1.0"
+dependencies = [
+ "bytemuck",
+ "ffmpeg-next",
+ "pollster",
+ "wgpu",
+]
+
+[[package]]
+name = "pollster"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
+
+[[package]]
+name = "presser"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.106"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "profiling"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5"
+
+[[package]]
+name = "quote"
+version = "1.0.46"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "range-alloc"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08"
+
+[[package]]
+name = "raw-window-handle"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539"
+
+[[package]]
+name = "redox_syscall"
+version = "0.5.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
+dependencies = [
+ "bitflags 2.13.1",
+]
+
+[[package]]
+name = "regex"
+version = "1.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fcfdb36bda0c880c5931cdc7a2bcdc8ba4556847b9d912bca70bc94708711ad"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.8.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
+
+[[package]]
+name = "renderdoc-sys"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832"
+
+[[package]]
+name = "rustc-hash"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
+
+[[package]]
+name = "rustc-hash"
+version = "2.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
+
+[[package]]
+name = "rustversion"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
+
+[[package]]
+name = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
+[[package]]
+name = "shlex"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
+
+[[package]]
+name = "shlex"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
+
+[[package]]
+name = "slab"
+version = "0.4.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
+
+[[package]]
+name = "slotmap"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038"
+dependencies = [
+ "version_check",
+]
+
+[[package]]
+name = "smallvec"
+version = "1.15.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90"
+
+[[package]]
+name = "spirv"
+version = "0.3.0+sdk-1.3.268.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844"
+dependencies = [
+ "bitflags 2.13.1",
+]
+
+[[package]]
+name = "static_assertions"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+
+[[package]]
+name = "syn"
+version = "1.0.109"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.119"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "termcolor"
+version = "1.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "thiserror"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
+
+[[package]]
+name = "unicode-width"
+version = "0.1.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
+
+[[package]]
+name = "unicode-xid"
+version = "0.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
+
+[[package]]
+name = "vcpkg"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
+
+[[package]]
+name = "version_check"
+version = "0.9.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
+
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.126"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4"
+dependencies = [
+ "cfg-if",
+ "once_cell",
+ "rustversion",
+ "wasm-bindgen-macro",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-futures"
+version = "0.4.76"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c62df1340f32221cb9c54d6a27b030e3dba64361d4a95bed55f9aacb44da291d"
+dependencies = [
+ "js-sys",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.126"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.126"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e"
+dependencies = [
+ "bumpalo",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.126"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "web-sys"
+version = "0.3.103"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8622dcb61c0bcc9fffa6938bed81210af2da9a7e4a1a834b2e37a59b6dfb6141"
+dependencies = [
+ "js-sys",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "wgpu"
+version = "22.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e1d1c4ba43f80542cf63a0a6ed3134629ae73e8ab51e4b765a67f3aa062eb433"
+dependencies = [
+ "arrayvec",
+ "cfg_aliases",
+ "document-features",
+ "js-sys",
+ "log",
+ "naga",
+ "parking_lot",
+ "profiling",
+ "raw-window-handle",
+ "smallvec",
+ "static_assertions",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "web-sys",
+ "wgpu-core",
+ "wgpu-hal",
+ "wgpu-types",
+]
+
+[[package]]
+name = "wgpu-core"
+version = "22.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0348c840d1051b8e86c3bcd31206080c5e71e5933dabd79be1ce732b0b2f089a"
+dependencies = [
+ "arrayvec",
+ "bit-vec",
+ "bitflags 2.13.1",
+ "cfg_aliases",
+ "document-features",
+ "indexmap",
+ "log",
+ "naga",
+ "once_cell",
+ "parking_lot",
+ "profiling",
+ "raw-window-handle",
+ "rustc-hash 1.1.0",
+ "smallvec",
+ "thiserror",
+ "wgpu-hal",
+ "wgpu-types",
+]
+
+[[package]]
+name = "wgpu-hal"
+version = "22.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6bbf4b4de8b2a83c0401d9e5ae0080a2792055f25859a02bf9be97952bbed4f"
+dependencies = [
+ "android_system_properties",
+ "arrayvec",
+ "ash",
+ "bit-set",
+ "bitflags 2.13.1",
+ "block",
+ "cfg_aliases",
+ "core-graphics-types",
+ "d3d12",
+ "glow",
+ "glutin_wgl_sys",
+ "gpu-alloc",
+ "gpu-allocator",
+ "gpu-descriptor",
+ "hassle-rs",
+ "js-sys",
+ "khronos-egl",
+ "libc",
+ "libloading",
+ "log",
+ "metal",
+ "naga",
+ "ndk-sys",
+ "objc",
+ "once_cell",
+ "parking_lot",
+ "profiling",
+ "range-alloc",
+ "raw-window-handle",
+ "renderdoc-sys",
+ "rustc-hash 1.1.0",
+ "smallvec",
+ "thiserror",
+ "wasm-bindgen",
+ "web-sys",
+ "wgpu-types",
+ "winapi",
+]
+
+[[package]]
+name = "wgpu-types"
+version = "22.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc9d91f0e2c4b51434dfa6db77846f2793149d8e73f800fa2e41f52b8eac3c5d"
+dependencies = [
+ "bitflags 2.13.1",
+ "js-sys",
+ "web-sys",
+]
+
+[[package]]
+name = "widestring"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-util"
+version = "0.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "windows"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be"
+dependencies = [
+ "windows-core",
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-core"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+[[package]]
+name = "windows-sys"
+version = "0.61.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "xml-rs"
+version = "0.8.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f"
diff --git a/poc-native/Cargo.toml b/poc-native/Cargo.toml
index 9d2430b14..f06fe897e 100644
--- a/poc-native/Cargo.toml
+++ b/poc-native/Cargo.toml
@@ -13,6 +13,7 @@ edition = "2021"
wgpu = "22"
pollster = "0.3"
bytemuck = { version = "1", features = ["derive"] }
+ffmpeg-next = "8.1.0"
[profile.release]
opt-level = 3
diff --git a/poc-native/src/bin/ffcheck.rs b/poc-native/src/bin/ffcheck.rs
new file mode 100644
index 000000000..06cd42352
--- /dev/null
+++ b/poc-native/src/bin/ffcheck.rs
@@ -0,0 +1,9 @@
+// Minimal: can ffmpeg-next link against the 8.1.2 dev libs and open a decoder?
+fn main() {
+ ffmpeg_next::init().expect("ffmpeg init");
+ let ictx = ffmpeg_next::format::input(&"../poc/media/screen.mp4").expect("open");
+ let stream = ictx.streams().best(ffmpeg_next::media::Type::Video).expect("video stream");
+ let dec = ffmpeg_next::codec::context::Context::from_parameters(stream.parameters()).unwrap();
+ let v = dec.decoder().video().unwrap();
+ println!("in-process decode OK: {}x{} {:?}", v.width(), v.height(), v.format());
+}
diff --git a/poc-native/src/bin/throughput2.rs b/poc-native/src/bin/throughput2.rs
new file mode 100644
index 000000000..c01650702
--- /dev/null
+++ b/poc-native/src/bin/throughput2.rs
@@ -0,0 +1,169 @@
+// Native throughput, take 2: IN-PROCESS decode (ffmpeg-next / libavcodec), no
+// subprocess decode pipes. The measured wall of throughput.rs was the two decode
+// pipes moving 1.4 GB of uncompressed RGBA between processes; libavcodec keeps
+// decoded frames in memory, exactly as the browser's WebCodecs does.
+//
+// Composite on wgpu (composite.wgsl unchanged). Encode stays a subprocess pipe
+// for now — measured negligible (31.2 with it vs 31.7 without). Point 2
+// (zero-descent GPU->encoder) comes after this proves in-process decode wins.
+
+use std::io::Write;
+use std::process::{Command, Stdio};
+use std::time::Instant;
+
+use ffmpeg_next as ff;
+use ff::software::scaling::{Context as Scaler, Flags};
+use ff::util::format::Pixel;
+
+const OUT_W: u32 = 1920;
+const OUT_H: u32 = 1080;
+const FPS: u32 = 30;
+const SCREEN_W: u32 = 1920;
+const SCREEN_H: u32 = 1032;
+const WEBCAM_W: u32 = 640;
+const WEBCAM_H: u32 = 480;
+const FRAMES: u32 = 180;
+
+#[repr(C)]
+#[derive(Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
+struct Uniforms { a: [f32; 4], screen: [f32; 4], webcam: [f32; 4], fx: [f32; 4], b: [f32; 4], mb: [f32; 4], cursor: [f32; 4], cursor_fx: [f32; 4] }
+
+fn ease(x: f32) -> f32 { if x < 0.5 { 4.0 * x * x * x } else { 1.0 - (-2.0 * x + 2.0).powi(3) / 2.0 } }
+fn rstr(t: f32, s: f32, e: f32, r: f32) -> f32 { if t <= s || t >= e { return 0.0; } ease(((t - s) / r).min(1.0).min((e - t) / r)) }
+fn lerp(a: f32, b: f32, t: f32) -> f32 { a + (b - a) * t }
+
+fn evaluate(t: f32, prev: Option<(f32, f32)>) -> (Uniforms, (f32, f32)) {
+ let pad = 45.0; let s = 1.0 - (pad / 100.0) * 0.4;
+ let (bw, bh) = (OUT_W as f32 * s, OUT_H as f32 * s);
+ let bs = [ (OUT_W as f32 - bw) / 2.0, (OUT_H as f32 - bh) / 2.0, bw, bh ];
+ let size = (OUT_H as f32 * 0.22).round(); let margin = (OUT_H as f32 * 0.04).round();
+ let bwc = [ OUT_W as f32 - size - margin, OUT_H as f32 - size - margin, size, size ];
+ let zooms = [(1.0, 3.2, 1.7, 0.62, 0.42, 0.55), (4.4, 6.5, 2.3, 0.3, 0.7, 0.5)];
+ let (mut zoom, mut fxn, mut fyn, mut str_) = (1.0f32, 0.5f32, 0.5f32, 0.0f32);
+ for (st, en, sc, cx, cy, rr) in zooms { let v = rstr(t, st, en, rr); if v > str_ { str_ = v; zoom = lerp(1.0, sc, v); fxn = cx; fyn = cy; } }
+ let fxp = bs[0] + bs[2] * fxn; let fyp = bs[1] + bs[3] * fyn;
+ let screen = [ fxp - (fxp - bs[0]) * zoom, fyp - (fyp - bs[1]) * zoom, bs[2] * zoom, bs[3] * zoom ];
+ let mv = rstr(t, 2.4, 5.0, 0.6);
+ let pw = (OUT_W as f32 * 0.34).round(); let ph = (pw * 0.75).round();
+ let panel = [ OUT_W as f32 - pw - margin, OUT_H as f32 - ph - margin, pw, ph ];
+ let webcam = [ lerp(bwc[0], panel[0], mv), lerp(bwc[1], panel[1], mv), lerp(bwc[2], panel[2], mv), lerp(bwc[3], panel[3], mv) ];
+ let wrad = lerp(bwc[2].min(bwc[3]) / 2.0, 26.0, mv);
+ let (cx, cy) = (screen[0] + screen[2] / 2.0, screen[1] + screen[3] / 2.0);
+ let (mut sbx, mut sby) = (0.0f32, 0.0f32);
+ if let Some((px, py)) = prev { sbx = ((cx - px) * 0.9).clamp(-22.0, 22.0); sby = ((cy - py) * 0.9).clamp(-22.0, 22.0); }
+ let u = Uniforms {
+ a: [OUT_W as f32, OUT_H as f32, t, 28.0], screen, webcam,
+ fx: [0.7, 0.0, 16.0, 22.0], b: [wrad, 0.0, WEBCAM_W as f32 / WEBCAM_H as f32, 0.0],
+ mb: [sbx, sby, 0.0, 0.0], cursor: [screen[0] + 0.52 * screen[2], screen[1] + 0.90 * screen[3], OUT_H as f32 * 0.05, 1.0], cursor_fx: [0.0, 0.0, 1.0, 0.0],
+ };
+ (u, (cx, cy))
+}
+
+// In-process decoder → tightly-packed RGBA at source resolution.
+struct Dec { ictx: ff::format::context::Input, dec: ff::decoder::Video, scaler: Scaler, idx: usize, w: u32, h: u32 }
+impl Dec {
+ fn open(path: &str, w: u32, h: u32) -> Self {
+ let ictx = ff::format::input(&path).expect("open input");
+ let st = ictx.streams().best(ff::media::Type::Video).expect("video stream");
+ let idx = st.index();
+ let dec = ff::codec::context::Context::from_parameters(st.parameters()).unwrap().decoder().video().unwrap();
+ let scaler = Scaler::get(dec.format(), dec.width(), dec.height(), Pixel::RGBA, w, h, Flags::BILINEAR).unwrap();
+ Dec { ictx, dec, scaler, idx, w, h }
+ }
+ fn next(&mut self, out: &mut Vec<u8>) -> bool {
+ let mut frame = ff::util::frame::Video::empty();
+ loop {
+ if self.dec.receive_frame(&mut frame).is_ok() {
+ let mut rgba = ff::util::frame::Video::empty();
+ self.scaler.run(&frame, &mut rgba).unwrap();
+ let stride = rgba.stride(0);
+ let row = (self.w * 4) as usize;
+ let data = rgba.data(0);
+ out.clear();
+ for y in 0..self.h as usize { let o = y * stride; out.extend_from_slice(&data[o..o + row]); }
+ return true;
+ }
+ // need more input
+ let mut got = false;
+ for (s, p) in self.ictx.packets() {
+ if s.index() == self.idx { self.dec.send_packet(&p).ok(); got = true; break; }
+ }
+ if !got { self.dec.send_eof().ok(); return self.dec.receive_frame(&mut frame).map(|_| { let mut rgba = ff::util::frame::Video::empty(); self.scaler.run(&frame, &mut rgba).unwrap(); let stride = rgba.stride(0); let row = (self.w*4) as usize; let data = rgba.data(0); out.clear(); for y in 0..self.h as usize { let o=y*stride; out.extend_from_slice(&data[o..o+row]); } true }).unwrap_or(false); }
+ }
+ }
+}
+
+fn tex2d(d: &wgpu::Device, w: u32, h: u32) -> wgpu::Texture {
+ d.create_texture(&wgpu::TextureDescriptor { label: None, size: wgpu::Extent3d { width: w, height: h, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 1, dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8Unorm, usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST, view_formats: &[] })
+}
+fn upload(q: &wgpu::Queue, t: &wgpu::Texture, w: u32, h: u32, d: &[u8]) {
+ q.write_texture(wgpu::ImageCopyTexture { texture: t, mip_level: 0, origin: wgpu::Origin3d::ZERO, aspect: wgpu::TextureAspect::All }, d, wgpu::ImageDataLayout { offset: 0, bytes_per_row: Some(w * 4), rows_per_image: Some(h) }, wgpu::Extent3d { width: w, height: h, depth_or_array_layers: 1 });
+}
+
+fn main() {
+ ff::init().expect("ffmpeg init");
+ let no_encode = std::env::args().nth(1).as_deref() == Some("no-encode");
+
+ let mut screen = Dec::open("../poc/media/screen.mp4", SCREEN_W, SCREEN_H);
+ let mut webcam = Dec::open("../poc/media/webcam.mp4", WEBCAM_W, WEBCAM_H);
+
+ let mut enc = (!no_encode).then(|| Command::new("ffmpeg")
+ .args(["-hide_banner", "-loglevel", "error", "-y", "-f", "rawvideo", "-pixel_format", "rgba", "-video_size", &format!("{OUT_W}x{OUT_H}"), "-framerate", &FPS.to_string(), "-i", "-", "-c:v", "h264_amf", "-b:v", "8M", "-usage", "transcoding", "out2.mp4"])
+ .stdin(Stdio::piped()).spawn().expect("encode spawn"));
+ let mut ein = enc.as_mut().map(|e| e.stdin.take().unwrap());
+
+ let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::default());
+ let adapter = pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions { power_preference: wgpu::PowerPreference::HighPerformance, ..Default::default() })).unwrap();
+ println!("native gpu: {} (backend {:?})", adapter.get_info().name, adapter.get_info().backend);
+ let (device, queue) = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor { label: None, required_features: wgpu::Features::empty(), required_limits: wgpu::Limits::default(), memory_hints: wgpu::MemoryHints::Performance }, None)).unwrap();
+
+ let st = tex2d(&device, SCREEN_W, SCREEN_H); let wt = tex2d(&device, WEBCAM_W, WEBCAM_H);
+ let sv = st.create_view(&Default::default()); let wv = wt.create_view(&Default::default());
+ let sampler = device.create_sampler(&wgpu::SamplerDescriptor { mag_filter: wgpu::FilterMode::Linear, min_filter: wgpu::FilterMode::Linear, ..Default::default() });
+ let ubuf = device.create_buffer(&wgpu::BufferDescriptor { label: None, size: std::mem::size_of::<Uniforms>() as u64, usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST, mapped_at_creation: false });
+ let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor { label: None, source: wgpu::ShaderSource::Wgsl(include_str!("../composite.wgsl").into()) });
+ let fmt = wgpu::TextureFormat::Rgba8Unorm;
+ let pipe = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: None, layout: None, vertex: wgpu::VertexState { module: &shader, entry_point: "vs", buffers: &[], compilation_options: Default::default() }, fragment: Some(wgpu::FragmentState { module: &shader, entry_point: "fs", targets: &[Some(wgpu::ColorTargetState { format: fmt, blend: None, write_mask: wgpu::ColorWrites::ALL })], compilation_options: Default::default() }), primitive: Default::default(), depth_stencil: None, multisample: Default::default(), multiview: None, cache: None });
+ let target = device.create_texture(&wgpu::TextureDescriptor { label: None, size: wgpu::Extent3d { width: OUT_W, height: OUT_H, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 1, dimension: wgpu::TextureDimension::D2, format: fmt, usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC, view_formats: &[] });
+ let tv = target.create_view(&Default::default());
+ let bind = device.create_bind_group(&wgpu::BindGroupDescriptor { label: None, layout: &pipe.get_bind_group_layout(0), entries: &[wgpu::BindGroupEntry { binding: 0, resource: ubuf.as_entire_binding() }, wgpu::BindGroupEntry { binding: 1, resource: wgpu::BindingResource::Sampler(&sampler) }, wgpu::BindGroupEntry { binding: 2, resource: wgpu::BindingResource::TextureView(&sv) }, wgpu::BindGroupEntry { binding: 3, resource: wgpu::BindingResource::TextureView(&wv) }] });
+ let bpr = ((OUT_W * 4 + 255) & !255) as u64;
+ let rbuf = device.create_buffer(&wgpu::BufferDescriptor { label: None, size: bpr * OUT_H as u64, usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ, mapped_at_creation: false });
+
+ let (mut srgba, mut wrgba) = (Vec::new(), Vec::new());
+ let mut tight = vec![0u8; (OUT_W * OUT_H * 4) as usize];
+ let mut prev = None; let warm = FRAMES / 4; let mut warm_t = Instant::now(); let mut done = 0u32;
+
+ for i in 0..FRAMES {
+ if i == warm { warm_t = Instant::now(); }
+ if !screen.next(&mut srgba) { break; }
+ webcam.next(&mut wrgba); // reuse last on EOF
+ // 60->30: pull an extra screen frame so screen time tracks 30fps output
+ screen.next(&mut Vec::new());
+
+ let t = i as f32 / FPS as f32;
+ let (u, memo) = evaluate(t, prev); prev = Some(memo);
+ upload(&queue, &st, SCREEN_W, SCREEN_H, &srgba);
+ if !wrgba.is_empty() { upload(&queue, &wt, WEBCAM_W, WEBCAM_H, &wrgba); }
+ queue.write_buffer(&ubuf, 0, bytemuck::bytes_of(&u));
+
+ let mut e = device.create_command_encoder(&Default::default());
+ { let mut p = e.begin_render_pass(&wgpu::RenderPassDescriptor { label: None, color_attachments: &[Some(wgpu::RenderPassColorAttachment { view: &tv, resolve_target: None, ops: wgpu::Operations { load: wgpu::LoadOp::Clear(wgpu::Color::BLACK), store: wgpu::StoreOp::Store } })], depth_stencil_attachment: None, timestamp_writes: None, occlusion_query_set: None });
+ p.set_pipeline(&pipe); p.set_bind_group(0, &bind, &[]); p.draw(0..3, 0..1); }
+ e.copy_texture_to_buffer(wgpu::ImageCopyTexture { texture: &target, mip_level: 0, origin: wgpu::Origin3d::ZERO, aspect: wgpu::TextureAspect::All }, wgpu::ImageCopyBuffer { buffer: &rbuf, layout: wgpu::ImageDataLayout { offset: 0, bytes_per_row: Some(bpr as u32), rows_per_image: Some(OUT_H) } }, wgpu::Extent3d { width: OUT_W, height: OUT_H, depth_or_array_layers: 1 });
+ queue.submit([e.finish()]);
+
+ let slice = rbuf.slice(..);
+ slice.map_async(wgpu::MapMode::Read, |_| {});
+ device.poll(wgpu::Maintain::Wait);
+ { let m = slice.get_mapped_range(); for y in 0..OUT_H { let s = (y as u64 * bpr) as usize; let d = (y * OUT_W * 4) as usize; tight[d..d + (OUT_W * 4) as usize].copy_from_slice(&m[s..s + (OUT_W * 4) as usize]); } }
+ rbuf.unmap();
+ if let Some(w) = ein.as_mut() { w.write_all(&tight).expect("encode pipe"); }
+ done = i + 1;
+ }
+
+ drop(ein);
+ if let Some(mut e) = enc { let _ = e.wait(); }
+ let wf = done.saturating_sub(warm); let secs = warm_t.elapsed().as_secs_f32();
+ println!("native throughput (in-process decode): {:.1} fps ({wf} frames after warm-up in {secs:.2}s{})", wf as f32 / secs, if no_encode { ", no encode" } else { ", + h264_amf" });
+}
diff --git a/poc-native/src/bin/throughput3.rs b/poc-native/src/bin/throughput3.rs
new file mode 100644
index 000000000..0b89cd475
--- /dev/null
+++ b/poc-native/src/bin/throughput3.rs
@@ -0,0 +1,180 @@
+// Native throughput, take 3: in-process decode ON THREADS, overlapped with the
+// composite/encode loop — because take 2 proved the wall was synchronous
+// single-threaded decode blocking the hot loop, not "in-process" itself. The
+// subprocess version won its 31 fps by decoding in parallel processes; this does
+// the same in one process, over channels, and keeps the frames in memory (no pipe).
+
+use std::io::Write;
+use std::process::{Command, Stdio};
+use std::sync::mpsc::sync_channel;
+use std::thread;
+use std::time::Instant;
+
+use ffmpeg_next as ff;
+use ff::software::scaling::{Context as Scaler, Flags};
+use ff::util::format::Pixel;
+
+const OUT_W: u32 = 1920;
+const OUT_H: u32 = 1080;
+const FPS: u32 = 30;
+const SCREEN_W: u32 = 1920;
+const SCREEN_H: u32 = 1032;
+const WEBCAM_W: u32 = 640;
+const WEBCAM_H: u32 = 480;
+const FRAMES: u32 = 180;
+
+#[repr(C)]
+#[derive(Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
+struct Uniforms { a: [f32; 4], screen: [f32; 4], webcam: [f32; 4], fx: [f32; 4], b: [f32; 4], mb: [f32; 4], cursor: [f32; 4], cursor_fx: [f32; 4] }
+
+fn ease(x: f32) -> f32 { if x < 0.5 { 4.0 * x * x * x } else { 1.0 - (-2.0 * x + 2.0).powi(3) / 2.0 } }
+fn rstr(t: f32, s: f32, e: f32, r: f32) -> f32 { if t <= s || t >= e { return 0.0; } ease(((t - s) / r).min(1.0).min((e - t) / r)) }
+fn lerp(a: f32, b: f32, t: f32) -> f32 { a + (b - a) * t }
+
+fn evaluate(t: f32, prev: Option<(f32, f32)>) -> (Uniforms, (f32, f32)) {
+ let pad = 45.0; let s = 1.0 - (pad / 100.0) * 0.4;
+ let (bw, bh) = (OUT_W as f32 * s, OUT_H as f32 * s);
+ let bs = [ (OUT_W as f32 - bw) / 2.0, (OUT_H as f32 - bh) / 2.0, bw, bh ];
+ let size = (OUT_H as f32 * 0.22).round(); let margin = (OUT_H as f32 * 0.04).round();
+ let bwc = [ OUT_W as f32 - size - margin, OUT_H as f32 - size - margin, size, size ];
+ let zooms = [(1.0, 3.2, 1.7, 0.62, 0.42, 0.55), (4.4, 6.5, 2.3, 0.3, 0.7, 0.5)];
+ let (mut zoom, mut fxn, mut fyn, mut str_) = (1.0f32, 0.5f32, 0.5f32, 0.0f32);
+ for (st, en, sc, cx, cy, rr) in zooms { let v = rstr(t, st, en, rr); if v > str_ { str_ = v; zoom = lerp(1.0, sc, v); fxn = cx; fyn = cy; } }
+ let fxp = bs[0] + bs[2] * fxn; let fyp = bs[1] + bs[3] * fyn;
+ let screen = [ fxp - (fxp - bs[0]) * zoom, fyp - (fyp - bs[1]) * zoom, bs[2] * zoom, bs[3] * zoom ];
+ let mv = rstr(t, 2.4, 5.0, 0.6);
+ let pw = (OUT_W as f32 * 0.34).round(); let ph = (pw * 0.75).round();
+ let panel = [ OUT_W as f32 - pw - margin, OUT_H as f32 - ph - margin, pw, ph ];
+ let webcam = [ lerp(bwc[0], panel[0], mv), lerp(bwc[1], panel[1], mv), lerp(bwc[2], panel[2], mv), lerp(bwc[3], panel[3], mv) ];
+ let wrad = lerp(bwc[2].min(bwc[3]) / 2.0, 26.0, mv);
+ let (cx, cy) = (screen[0] + screen[2] / 2.0, screen[1] + screen[3] / 2.0);
+ let (mut sbx, mut sby) = (0.0f32, 0.0f32);
+ if let Some((px, py)) = prev { sbx = ((cx - px) * 0.9).clamp(-22.0, 22.0); sby = ((cy - py) * 0.9).clamp(-22.0, 22.0); }
+ let u = Uniforms { a: [OUT_W as f32, OUT_H as f32, t, 28.0], screen, webcam, fx: [0.7, 0.0, 16.0, 22.0], b: [wrad, 0.0, WEBCAM_W as f32 / WEBCAM_H as f32, 0.0], mb: [sbx, sby, 0.0, 0.0], cursor: [screen[0] + 0.52 * screen[2], screen[1] + 0.90 * screen[3], OUT_H as f32 * 0.05, 1.0], cursor_fx: [0.0, 0.0, 1.0, 0.0] };
+ (u, (cx, cy))
+}
+
+// A decode thread: owns the ffmpeg decoder, sends tightly-packed RGBA frames over
+// a bounded channel. Bounded so a fast decoder cannot run away with memory; the
+// blocking send IS the backpressure. Every 2nd source frame is dropped for the
+// 60->30 sources so content time roughly tracks the 30 fps output.
+fn spawn_decode(path: &'static str, w: u32, h: u32, take_every: u32) -> std::sync::mpsc::Receiver<Vec<u8>> {
+ let (tx, rx) = sync_channel::<Vec<u8>>(4);
+ thread::spawn(move || {
+ let mut ictx = match ff::format::input(&path) { Ok(c) => c, Err(_) => return };
+ let st = ictx.streams().best(ff::media::Type::Video).unwrap();
+ let idx = st.index();
+ let mut dec = ff::codec::context::Context::from_parameters(st.parameters()).unwrap().decoder().video().unwrap();
+ let mut scaler = Scaler::get(dec.format(), dec.width(), dec.height(), Pixel::RGBA, w, h, Flags::BILINEAR).unwrap();
+ let row = (w * 4) as usize;
+ let mut n = 0u32;
+ let mut emit = |frame: &ff::util::frame::Video, scaler: &mut Scaler| -> bool {
+ let mut rgba = ff::util::frame::Video::empty();
+ scaler.run(frame, &mut rgba).unwrap();
+ let stride = rgba.stride(0); let data = rgba.data(0);
+ let mut out = vec![0u8; (w * h * 4) as usize];
+ for y in 0..h as usize { let o = y * stride; out[y * row..y * row + row].copy_from_slice(&data[o..o + row]); }
+ tx.send(out).is_ok()
+ };
+ for (s, p) in ictx.packets() {
+ if s.index() != idx { continue; }
+ if dec.send_packet(&p).is_err() { continue; }
+ let mut frame = ff::util::frame::Video::empty();
+ while dec.receive_frame(&mut frame).is_ok() {
+ n += 1;
+ if n % take_every == 0 && !emit(&frame, &mut scaler) { return; }
+ }
+ }
+ });
+ rx
+}
+
+fn tex2d(d: &wgpu::Device, w: u32, h: u32) -> wgpu::Texture {
+ d.create_texture(&wgpu::TextureDescriptor { label: None, size: wgpu::Extent3d { width: w, height: h, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 1, dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8Unorm, usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST, view_formats: &[] })
+}
+fn upload(q: &wgpu::Queue, t: &wgpu::Texture, w: u32, h: u32, d: &[u8]) {
+ q.write_texture(wgpu::ImageCopyTexture { texture: t, mip_level: 0, origin: wgpu::Origin3d::ZERO, aspect: wgpu::TextureAspect::All }, d, wgpu::ImageDataLayout { offset: 0, bytes_per_row: Some(w * 4), rows_per_image: Some(h) }, wgpu::Extent3d { width: w, height: h, depth_or_array_layers: 1 });
+}
+
+fn main() {
+ ff::init().expect("ffmpeg init");
+ let no_encode = std::env::args().nth(1).as_deref() == Some("no-encode");
+ let screen_rx = spawn_decode("../poc/media/screen.mp4", SCREEN_W, SCREEN_H, 2); // 60->30
+ let webcam_rx = spawn_decode("../poc/media/webcam.mp4", WEBCAM_W, WEBCAM_H, 1);
+
+ // Encoder on its own thread too: the 8 MB/frame pipe write to ffmpeg must not
+ // block the composite loop. The main loop sends a composited frame over a
+ // bounded channel; the thread does the blocking write. Bounded = backpressure.
+ let mut enc_join = None;
+ let enc_tx = (!no_encode).then(|| {
+ let (tx, rx) = sync_channel::<Vec<u8>>(4);
+ enc_join = Some(thread::spawn(move || {
+ let mut enc = Command::new("ffmpeg")
+ .args(["-hide_banner", "-loglevel", "error", "-y", "-f", "rawvideo", "-pixel_format", "rgba", "-video_size", &format!("{OUT_W}x{OUT_H}"), "-framerate", &FPS.to_string(), "-i", "-", "-c:v", "h264_amf", "-b:v", "8M", "-usage", "transcoding", "out3.mp4"])
+ .stdin(Stdio::piped()).spawn().expect("encode spawn");
+ let mut ein = enc.stdin.take().unwrap();
+ for frame in rx.iter() { if ein.write_all(&frame).is_err() { break; } }
+ drop(ein);
+ let _ = enc.wait();
+ }));
+ tx
+ });
+
+ let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::default());
+ let adapter = pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions { power_preference: wgpu::PowerPreference::HighPerformance, ..Default::default() })).unwrap();
+ println!("native gpu: {} (backend {:?})", adapter.get_info().name, adapter.get_info().backend);
+ let (device, queue) = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor { label: None, required_features: wgpu::Features::empty(), required_limits: wgpu::Limits::default(), memory_hints: wgpu::MemoryHints::Performance }, None)).unwrap();
+
+ let st = tex2d(&device, SCREEN_W, SCREEN_H); let wt = tex2d(&device, WEBCAM_W, WEBCAM_H);
+ let sv = st.create_view(&Default::default()); let wv = wt.create_view(&Default::default());
+ let sampler = device.create_sampler(&wgpu::SamplerDescriptor { mag_filter: wgpu::FilterMode::Linear, min_filter: wgpu::FilterMode::Linear, ..Default::default() });
+ let ubuf = device.create_buffer(&wgpu::BufferDescriptor { label: None, size: std::mem::size_of::<Uniforms>() as u64, usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST, mapped_at_creation: false });
+ let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor { label: None, source: wgpu::ShaderSource::Wgsl(include_str!("../composite.wgsl").into()) });
+ let fmt = wgpu::TextureFormat::Rgba8Unorm;
+ let pipe = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: None, layout: None, vertex: wgpu::VertexState { module: &shader, entry_point: "vs", buffers: &[], compilation_options: Default::default() }, fragment: Some(wgpu::FragmentState { module: &shader, entry_point: "fs", targets: &[Some(wgpu::ColorTargetState { format: fmt, blend: None, write_mask: wgpu::ColorWrites::ALL })], compilation_options: Default::default() }), primitive: Default::default(), depth_stencil: None, multisample: Default::default(), multiview: None, cache: None });
+ let target = device.create_texture(&wgpu::TextureDescriptor { label: None, size: wgpu::Extent3d { width: OUT_W, height: OUT_H, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 1, dimension: wgpu::TextureDimension::D2, format: fmt, usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC, view_formats: &[] });
+ let tv = target.create_view(&Default::default());
+ let bind = device.create_bind_group(&wgpu::BindGroupDescriptor { label: None, layout: &pipe.get_bind_group_layout(0), entries: &[wgpu::BindGroupEntry { binding: 0, resource: ubuf.as_entire_binding() }, wgpu::BindGroupEntry { binding: 1, resource: wgpu::BindingResource::Sampler(&sampler) }, wgpu::BindGroupEntry { binding: 2, resource: wgpu::BindingResource::TextureView(&sv) }, wgpu::BindGroupEntry { binding: 3, resource: wgpu::BindingResource::TextureView(&wv) }] });
+ let bpr = ((OUT_W * 4 + 255) & !255) as u64;
+ let rbuf = device.create_buffer(&wgpu::BufferDescriptor { label: None, size: bpr * OUT_H as u64, usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ, mapped_at_creation: false });
+
+ let mut tight = vec![0u8; (OUT_W * OUT_H * 4) as usize];
+ let mut last_webcam: Option<Vec<u8>> = None;
+ let mut prev = None; let warm = FRAMES / 4; let mut warm_t = Instant::now(); let mut done = 0u32;
+
+ for i in 0..FRAMES {
+ if i == warm { warm_t = Instant::now(); }
+ let srgba = match screen_rx.recv() { Ok(f) => f, Err(_) => break };
+ let wrgba = match webcam_rx.try_recv() { Ok(f) => { last_webcam = Some(f.clone()); f }, Err(_) => last_webcam.clone().unwrap_or_else(|| vec![0u8; (WEBCAM_W * WEBCAM_H * 4) as usize]) };
+
+ let t = i as f32 / FPS as f32;
+ let (u, memo) = evaluate(t, prev); prev = Some(memo);
+ upload(&queue, &st, SCREEN_W, SCREEN_H, &srgba);
+ upload(&queue, &wt, WEBCAM_W, WEBCAM_H, &wrgba);
+ queue.write_buffer(&ubuf, 0, bytemuck::bytes_of(&u));
+
+ let mut e = device.create_command_encoder(&Default::default());
+ { let mut p = e.begin_render_pass(&wgpu::RenderPassDescriptor { label: None, color_attachments: &[Some(wgpu::RenderPassColorAttachment { view: &tv, resolve_target: None, ops: wgpu::Operations { load: wgpu::LoadOp::Clear(wgpu::Color::BLACK), store: wgpu::StoreOp::Store } })], depth_stencil_attachment: None, timestamp_writes: None, occlusion_query_set: None });
+ p.set_pipeline(&pipe); p.set_bind_group(0, &bind, &[]); p.draw(0..3, 0..1); }
+ e.copy_texture_to_buffer(wgpu::ImageCopyTexture { texture: &target, mip_level: 0, origin: wgpu::Origin3d::ZERO, aspect: wgpu::TextureAspect::All }, wgpu::ImageCopyBuffer { buffer: &rbuf, layout: wgpu::ImageDataLayout { offset: 0, bytes_per_row: Some(bpr as u32), rows_per_image: Some(OUT_H) } }, wgpu::Extent3d { width: OUT_W, height: OUT_H, depth_or_array_layers: 1 });
+ queue.submit([e.finish()]);
+ if std::env::args().any(|a| a == "no-readback") {
+ // Probe: isolate decode+composite from the descent. Still fence, so the
+ // composite actually completes (no empty-loop artifact).
+ device.poll(wgpu::Maintain::Wait);
+ } else {
+ let slice = rbuf.slice(..);
+ slice.map_async(wgpu::MapMode::Read, |_| {});
+ device.poll(wgpu::Maintain::Wait);
+ { let m = slice.get_mapped_range(); for y in 0..OUT_H { let s = (y as u64 * bpr) as usize; let d = (y * OUT_W * 4) as usize; tight[d..d + (OUT_W * 4) as usize].copy_from_slice(&m[s..s + (OUT_W * 4) as usize]); } }
+ rbuf.unmap();
+ if let Some(tx) = &enc_tx { tx.send(tight.clone()).ok(); }
+ }
+ done = i + 1;
+ }
+
+ drop(enc_tx); // closes the channel → encode thread flushes and muxes
+ if let Some(j) = enc_join { let _ = j.join(); } // include the drain in the wall
+ let wf = done.saturating_sub(warm); let secs = warm_t.elapsed().as_secs_f32();
+ println!("native throughput (threaded in-process decode): {:.1} fps ({wf} frames after warm-up in {secs:.2}s{})", wf as f32 / secs, if no_encode { ", no encode" } else { ", + h264_amf" });
+}