diff --git a/quest/m1/README.md b/quest/m1/README.md index 68a02e52c56..719b42552bb 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -143,7 +143,6 @@ Catalog HLS field. - [Buffered playback subscribes in ascending order](/quest/m1/buffered-ascending.md) - a buffered `` asks for the oldest group first, so a voice reply's opening arrives first, and audio's head hold shrinks to the floor - [JS reload config](/quest/m1/js-reload-config.md) - `@moq/net` reload takes Rust's `healthy` backoff and no ignored `extensions` - [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` - [JS resume reports drops](/quest/m1/resume-drops.md) - a routed JS subscriber reports its copies' dropped groups, so publishers forward SUBSCRIBE_DROP - [Lowered resume floor](/quest/m1/resume-floor.md) - lowering a resumed reader's floor re-offers groups only a released copy cached - [WebGPU on Safari](/quest/m1/webgpu-safari.md) - the WebGPU renderer is verified on Safari 26 for macOS and iOS 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 8eb121288f0..ab16582db9b 100644 --- a/rs/moq-video/src/encode/encoder.rs +++ b/rs/moq-video/src/encode/encoder.rs @@ -139,6 +139,11 @@ pub(crate) 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")), @@ -294,6 +299,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)) } @@ -380,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() } @@ -566,6 +571,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 72880c5476d..2610d823ea6 100644 --- a/rs/moq-video/src/encode/producer.rs +++ b/rs/moq-video/src/encode/producer.rs @@ -1114,6 +1114,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)); diff --git a/rs/moq-video/src/encode/sink.rs b/rs/moq-video/src/encode/sink.rs index 68a7fb684a2..472f72b8dc2 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> {