Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion quest/m0/nightly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ near the paired threshold (re-check if one repeats), a one-off
- [Nightly's macOS platform job passes](/quest/m0/nightly/macos.md) - `moq-audio`'s tests compile on macOS again and the websocket version test's timeout is fixed if it recurs
- [The qmux startup benchmark's fake peer sends transport parameters](/quest/m0/nightly/qmux-bench-peer.md) - Audio quality's WebSocket startup step stops timing out
- [The moq-net session bench completes moq-transport-22 at 16 broadcasts](/quest/m0/nightly/session-bench-handshake.md) - the bench workload stops panicking on a handshake timeout
- [Bisect the moq-audio bus and moq-mux parameter_sets regressions](/quest/m0/nightly/bench-regressions.md) - two real benchmark regressions are explained and fixed or accepted
- [Moxygen conformance cells pass again](/quest/m0/nightly/moxygen-conformance.md) - the first-object signal and integer extensions survive, or moxygen's divergence is skipped with an upstream link
32 changes: 0 additions & 32 deletions quest/m0/nightly/bench-regressions.md

This file was deleted.

1 change: 1 addition & 0 deletions rs/moq-audio/src/aec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ fn channel(rate: u32) -> (ring::Producer, ring::Consumer) {
// is shaped to avoid.
pad: false,
trim: true,
comfort: false,
},
)
}
Expand Down
3 changes: 3 additions & 0 deletions rs/moq-audio/src/bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ impl Bus {
// the target depth, not by letting the ring run dry or full.
pad: true,
trim: true,
// No writer here declares a silence, so measuring for comfort
// noise would be wasted on every block.
comfort: false,
},
);
let port = self.open(input, strip, Queue::Live(cons))?;
Expand Down
2 changes: 2 additions & 0 deletions rs/moq-audio/src/playback/mixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ mod tests {
capacity: Duration::from_secs(1),
pad: true,
trim: true,
comfort: true,
},
);

Expand Down Expand Up @@ -818,6 +819,7 @@ mod tests {
capacity: Duration::from_millis(200),
pad: true,
trim: true,
comfort: true,
},
)
}
Expand Down
1 change: 1 addition & 0 deletions rs/moq-audio/src/playback/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ fn channel(input: &Input, rate: u32, bus: Layout) -> (Channel, ring::Consumer) {
// pays for emergency silence or trimming.
pad: true,
trim: true,
comfort: true,
},
);
cons.stretch(rate);
Expand Down
49 changes: 47 additions & 2 deletions rs/moq-audio/src/ring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ pub(crate) struct Config {
/// Trim back down to the latency once the queue fills three quarters of the
/// room above it.
pub trim: bool,
/// Measure what plays, so a declared silence fills with comfort noise at
/// its level. Without it a declared silence is plain silence, for a writer
/// that never declares one.
pub comfort: bool,
}

/// What a [`Producer::push`] did with its input.
Expand Down Expand Up @@ -157,6 +161,7 @@ pub(crate) fn channel(channels: usize, input_rate: u32, output_rate: u32, config
cleared: 0,
cushioned: 0,
comfort: crate::comfort::Comfort::new(output_rate, channels),
measure: config.comfort,
trim: config.trim,
skips: 0,
trimmed: 0,
Expand Down Expand Up @@ -495,6 +500,8 @@ pub(crate) struct Consumer {
/// Comfort noise already played at the pending resume.
cushioned: usize,
comfort: crate::comfort::Comfort,
/// Whether the comfort noise measures what plays; unmeasured, it fills plain silence.
measure: bool,
/// Trim only after filling three quarters of the current target's headroom.
trim: bool,
/// Times [`Read::Trimmed`] was returned, ever.
Expand Down Expand Up @@ -612,7 +619,7 @@ impl Consumer {
while done < output.len() {
if let Some(stretch) = self.stretch.as_mut().filter(|stretch| stretch.available() > 0) {
let frames = stretch.read(&mut output[done..]);
if !self.staged_prime {
if self.measure && !self.staged_prime {
self.comfort.played(&output[done..done + frames * channels]);
}
done += frames * channels;
Expand Down Expand Up @@ -642,7 +649,9 @@ impl Consumer {
debug_assert_eq!(read, frames * channels);
let prime = frames.min(self.prime);
self.prime -= prime;
self.comfort.played(&output[done + prime * channels..done + read]);
if self.measure {
self.comfort.played(&output[done + prime * channels..done + read]);
}
self.position = self.position.wrapping_add(frames);
self.consumed = self.consumed.wrapping_add(frames);
done += read;
Expand Down Expand Up @@ -756,6 +765,7 @@ mod tests {
capacity,
pad: false,
trim: false,
comfort: true,
},
);
cons.start();
Expand Down Expand Up @@ -838,6 +848,7 @@ mod tests {
capacity: Duration::from_millis(200),
pad: false,
trim: true,
comfort: true,
},
);
cons.start();
Expand Down Expand Up @@ -865,6 +876,7 @@ mod tests {
capacity: Duration::from_millis(100),
pad: false,
trim: false,
comfort: true,
},
);
assert_eq!(prod.push(&[0.5; 2 * STEREO]), Push::NotReady);
Expand Down Expand Up @@ -892,6 +904,7 @@ mod tests {
capacity: Duration::from_millis(100),
pad: true,
trim: true,
comfort: true,
},
);
cons.start();
Expand Down Expand Up @@ -920,6 +933,7 @@ mod tests {
capacity: Duration::from_millis(100),
pad: false,
trim: true,
comfort: true,
},
);
cons.start();
Expand Down Expand Up @@ -964,6 +978,7 @@ mod tests {
capacity: Duration::from_secs(3),
pad: false,
trim: false,
comfort: true,
},
);
cons.stretch(rate);
Expand Down Expand Up @@ -1018,6 +1033,7 @@ mod tests {
capacity: Duration::from_secs(1),
pad: false,
trim: false,
comfort: true,
},
);
cons.stretch(48_000);
Expand Down Expand Up @@ -1051,6 +1067,7 @@ mod tests {
capacity: Duration::from_secs(1),
pad: false,
trim: false,
comfort: true,
},
);
cons.stretch(48_000);
Expand Down Expand Up @@ -1079,6 +1096,7 @@ mod tests {
capacity: Duration::from_secs(1),
pad: true,
trim: false,
comfort: true,
},
);
cons.stretch(48_000);
Expand Down Expand Up @@ -1113,6 +1131,7 @@ mod tests {
capacity: Duration::from_millis(3050),
pad: false,
trim: true,
comfort: true,
},
);
cons.stretch(48_000);
Expand Down Expand Up @@ -1200,6 +1219,31 @@ mod tests {
assert_eq!(cons.read(&mut out), Read::Underflow { frames: 0 });
}

/// A queue that measures nothing fills a declared silence with plain silence.
#[test]
fn an_unmeasured_declared_silence_is_silent() {
let (mut prod, mut cons) = channel(
STEREO,
48_000,
48_000,
Config {
latency: Duration::from_millis(50),
capacity: Duration::from_secs(1),
pad: false,
trim: false,
comfort: false,
},
);
cons.start();
assert_eq!(prod.push(&[0.0002; 4800 * STEREO]), Push::Ok);
let mut out = vec![0.0; (LATENCY + 4800) * STEREO];
assert_eq!(cons.read(&mut out), Read::Ok);
prod.end();
let mut out = vec![1.0; 1000 * STEREO];
assert_eq!(cons.read(&mut out), Read::Comfort { frames: 0 });
assert!(out.iter().all(|&sample| sample == 0.0));
}

/// A next utterance pushed while the end's tail still plays waits behind it,
/// with comfort noise topping the wait up to one latency.
#[test]
Expand Down Expand Up @@ -1296,6 +1340,7 @@ mod tests {
capacity: Duration::from_secs(1),
pad: true,
trim: false,
comfort: true,
},
);
cons.stretch(48_000);
Expand Down
17 changes: 11 additions & 6 deletions rs/moq-mux/src/codec/annexb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,16 @@ pub(crate) type ParameterSets = BTreeMap<(u8, u32), Bytes>;
/// Adopt the parameter sets of one type that an access unit or init defined: each layer it
/// defined any for replaces that layer's retained sets, dropping ids the new configuration no
/// longer uses, while every other layer keeps its own. An empty `sets` changes nothing.
pub(crate) fn adopt_parameter_sets(retained: &mut ParameterSets, sets: ParameterSets) {
retained.retain(|(layer, _), _| !sets.keys().any(|(defined, _)| defined == layer));
retained.extend(sets);
pub(crate) fn adopt_parameter_sets(retained: &mut ParameterSets, mut sets: ParameterSets) {
let defined = layers(&sets);
retained.retain(|&(layer, _), _| defined & 1 << layer == 0);
// Appending to an emptied map moves `sets` in rather than inserting each set.
retained.append(&mut sets);
}

/// The layers `sets` holds any for, as a bitmask: `nuh_layer_id` has six bits.
fn layers(sets: &ParameterSets) -> u64 {
sets.keys().fold(0, |mask, &(layer, _)| mask | 1 << layer)
}

/// The NAL syntax an [`InBand`] transform reads.
Expand Down Expand Up @@ -441,9 +448,7 @@ pub(crate) fn reconcile_keyframe_params(
) -> Result<()> {
let mut missing = false;
for (retained, seen) in retained.iter_mut().zip(seen.iter_mut()) {
missing |= retained
.keys()
.any(|(layer, _)| !seen.keys().any(|(defined, _)| defined == layer));
missing |= layers(retained) & !layers(seen) != 0;
adopt_parameter_sets(retained, std::mem::take(*seen));
seen.clone_from(retained);
}
Expand Down
Loading