From 595d0c678eb6672abfaaebfb48fbf5e5a7692803 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 24 Oct 2026 11:09:47 -0700 Subject: [PATCH 1/3] chore(quest): claim quest/m1/encoder-reorder.md Quest-Claim: 999d5304122d166c From a9929f2115fe86c9b499e534f9c09130da2cae5e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 24 Oct 2026 11:20:56 -0700 Subject: [PATCH 2/3] fix(video): declare confirmed encoder reorder bounds Use applied preset controls to advertise zero reordering when bitstream metadata omits it. Preserve parsed or inferred bounds for unconfirmed drivers. Policy and OpenH264 roundtrip tests and the full local CI gate pass. Co-Authored-By: GPT-6 --- quest/m1/README.md | 1 - quest/m1/encoder-reorder.md | 18 ------------------ rs/moq-video/src/encode/encoder.rs | 21 +++++++++++++++++++++ rs/moq-video/src/encode/producer.rs | 1 + 4 files changed, 22 insertions(+), 19 deletions(-) delete mode 100644 quest/m1/encoder-reorder.md diff --git a/quest/m1/README.md b/quest/m1/README.md index 9525ce400bd..0ae4c00f779 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -145,7 +145,6 @@ Binding durations wait on Duration support in the generated C. - [JS reload config](/quest/m1/js-reload-config.md) - `@moq/net` reload takes Rust's `healthy` backoff and no ignored `extensions` - [JS release preflight](/quest/m1/js-publish-preflight.md) - `release.ts` refuses a package whose `@moq/*` dependency is not on npm, so no dependent publishes uninstallable - [TS fidelity and recovery](/quest/m1/ts-reliability/README.md) - both modes have explicit profiles, automated validation, loss tests, and a dedicated guide -- [Encoders declare no reordering](/quest/m1/encoder-reorder.md) - moq-video encoders publish `reorder: 0` - [Rust resume checks compression](/quest/m1/resume-compress.md) - a same-epoch route copy with a different `compress` is refused instead of corrupting framing - [WebGPU on Safari](/quest/m1/webgpu-safari.md) - the WebGPU renderer is verified on Safari 26 for macOS and iOS - [JSON encoder options without a downcast](/quest/m1/json-encoder-options.md) - moq-mux's `json_snapshot` takes its `deltas` switch through a typed path any custom catalog entry can use, not an `Any` downcast diff --git a/quest/m1/encoder-reorder.md b/quest/m1/encoder-reorder.md deleted file mode 100644 index 1328ffa787f..00000000000 --- a/quest/m1/encoder-reorder.md +++ /dev/null @@ -1,18 +0,0 @@ -# [XS] moq-video encoders declare no reordering - -## Goal - -moq-video's encoders, which emit no B-frames, declare `reorder: 0` in the -`VideoHint` they publish, so readers take decode time from it instead of -guessing. - -## Plan - -[moq-dev/moq#6453](https://github.com/moq-dev/moq/pull/6453) adds -`VideoHint.reorder`, which `rendition_hint` -(`rs/moq-video/src/encode/producer.rs`) copies from the probed rendition, but -the encoders leave it unset, so their renditions stay on the inferred clock. -Declare `0` there, even when the SPS omits its bitstream restriction, and -assert it in an encoder test. - -Public API: none. Wire: none. diff --git a/rs/moq-video/src/encode/encoder.rs b/rs/moq-video/src/encode/encoder.rs index fdd6474655d..056b421aab7 100644 --- a/rs/moq-video/src/encode/encoder.rs +++ b/rs/moq-video/src/encode/encoder.rs @@ -142,6 +142,11 @@ pub struct Applied { } impl Applied { + // A confirmed preset disables frame reordering even when the bitstream omits its bound. + fn reorder(&self, parsed: Option) -> Option { + self.preset.map(|_| 0).or(parsed) + } + /// A report that `preset` took effect through `controls`. #[cfg_attr( not(any(feature = "openh264", feature = "nvidia", feature = "vaapi", target_os = "macos")), @@ -297,6 +302,7 @@ impl Config { // rides in an optional VUI. Fill them from the config that produced the rest. rendition.bitrate.get_or_insert(self.resolved_bitrate().as_bps()); rendition.framerate.get_or_insert(self.framerate.as_f64()); + rendition.reorder = sink.applied().reorder(rendition.reorder); Ok((rendition, sink)) } @@ -572,6 +578,21 @@ mod tests { use crate::{I420, Surface}; + #[test] + fn reorder_is_declared_only_for_confirmed_controls() { + for preset in [Preset::LowLatency, Preset::Balanced, Preset::Quality] { + let applied = Applied { + preset: Some(preset), + ..Applied::default() + }; + assert_eq!(applied.reorder(None), Some(0)); + assert_eq!(applied.reorder(Some(3)), Some(0)); + } + let unconfirmed = Applied::default(); + assert_eq!(unconfirmed.reorder(None), None); + assert_eq!(unconfirmed.reorder(Some(3)), Some(3)); + } + /// A mid-gray RGBA buffer: encodable without a camera. fn gray_rgba(width: u32, height: u32) -> Vec { vec![0x80u8; width as usize * height as usize * 4] diff --git a/rs/moq-video/src/encode/producer.rs b/rs/moq-video/src/encode/producer.rs index 84ca57a037a..523bc888829 100644 --- a/rs/moq-video/src/encode/producer.rs +++ b/rs/moq-video/src/encode/producer.rs @@ -1119,6 +1119,7 @@ mod tests { // Software (openh264) so the test is deterministic and never touches a // hardware backend. let (name, config) = roundtrip_rendition(Codec::H264, encoder::Kind::Software).await; + assert_eq!(config.reorder, Some(0)); assert!(name.ends_with(".avc3")); assert_eq!(config.coded_width, Some(320)); assert_eq!(config.coded_height, Some(240)); From b6ddda131183f879fb51f8b964aebe3983362bab Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 24 Oct 2026 21:45:22 -0700 Subject: [PATCH 3/3] fix(video): carry the applied controls across the sink thread Main's API audit (#6517) dropped Sink::applied, which the reorder bound reads when probing through a sink. Restore it crate-private, sending the backend's report back with the opened encoder. Co-Authored-By: Claude Opus 5.5 --- rs/moq-video/src/encode/encoder.rs | 1 - rs/moq-video/src/encode/sink.rs | 22 +++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/rs/moq-video/src/encode/encoder.rs b/rs/moq-video/src/encode/encoder.rs index c832a3c2ef4..a1f3c5889fc 100644 --- a/rs/moq-video/src/encode/encoder.rs +++ b/rs/moq-video/src/encode/encoder.rs @@ -386,7 +386,6 @@ impl Encoder { /// The latency and compression controls the backend applied for /// [`Config::preset`], fixed for the session's lifetime. - #[cfg(test)] pub(crate) fn applied(&self) -> Applied { self.backend.applied() } diff --git a/rs/moq-video/src/encode/sink.rs b/rs/moq-video/src/encode/sink.rs index 5cf73872892..89af1e140d1 100644 --- a/rs/moq-video/src/encode/sink.rs +++ b/rs/moq-video/src/encode/sink.rs @@ -21,7 +21,7 @@ use std::sync::Arc; use super::Encoded; -use super::encoder::Config; +use super::encoder::{Applied, Config}; use crate::{Error, Frame}; #[cfg(apple)] @@ -75,6 +75,12 @@ impl Sink { self.0.name() } + /// The latency and compression controls the backend applied, like the + /// encoder's own report. + pub(crate) fn applied(&self) -> Applied { + self.0.applied() + } + /// Cut a new group at the next frame, like /// [`Encoder::cut`](super::Encoder::cut). /// @@ -152,7 +158,7 @@ mod threaded { use tokio::sync::{mpsc, oneshot}; use super::super::Encoded; - use super::super::encoder::{Config, Encoder}; + use super::super::encoder::{Applied, Config, Encoder}; use crate::worker::{Ready, Worker}; use crate::{Error, Frame}; @@ -198,6 +204,7 @@ mod threaded { /// What the encode thread reports once its encoder is open. pub struct Opened { name: String, + applied: Applied, } /// Build an encoder for `config` and serve requests until the channel closes. @@ -210,6 +217,7 @@ mod threaded { // If the awaiting `open` was cancelled, give up before encoding. let opened = Opened { name: encoder.name().to_owned(), + applied: encoder.applied(), }; if !ready.ok(opened) { return; @@ -266,6 +274,10 @@ mod threaded { &self.0.info().name } + pub fn applied(&self) -> Applied { + self.0.info().applied.clone() + } + pub async fn cut(&mut self) -> Result<(), Error> { self.0.request(|resp| Request::Cut { resp }).await } @@ -300,7 +312,7 @@ mod inline { use std::sync::Arc; use super::super::Encoded; - use super::super::encoder::{Config, Encoder}; + use super::super::encoder::{Applied, Config, Encoder}; use crate::{Error, Frame}; /// An [`Encoder`] driven inline on the calling thread (see the module docs). @@ -320,6 +332,10 @@ mod inline { self.0.name() } + pub fn applied(&self) -> Applied { + self.0.applied() + } + /// Async only to match the threaded `Inner`; there's no thread to hand this /// to, so it runs inline. The same holds for the calls below. pub async fn cut(&mut self) -> Result<(), Error> {