Even smarter. No stream meta stored but just the ranges for each channel.
This commit is contained in:
parent
79fca548b1
commit
26515b9ee0
@ -43,21 +43,18 @@ impl SimpleClipDetector {
|
|||||||
smgr.addInQueue(tx);
|
smgr.addInQueue(tx);
|
||||||
rayon::spawn(
|
rayon::spawn(
|
||||||
move || {
|
move || {
|
||||||
let mut streammeta: Option<Arc<StreamMetaData>> = None;
|
|
||||||
let mut mins = vec![];
|
let mut mins = vec![];
|
||||||
let mut maxs = vec![];
|
let mut maxs = vec![];
|
||||||
|
let mut ranges = vec![];
|
||||||
loop {
|
loop {
|
||||||
if let Ok(msg) = rx.recv_timeout(Duration::from_millis(1500)) {
|
if let Ok(msg) = rx.recv_timeout(Duration::from_millis(1500)) {
|
||||||
match msg {
|
match msg {
|
||||||
InStreamMsg::StreamStarted(meta) => {
|
InStreamMsg::StreamStarted(meta) => {
|
||||||
mins.resize(meta.nchannels(), 0.);
|
mins.resize(meta.nchannels(), 0.);
|
||||||
maxs.resize(meta.nchannels(), 0.);
|
maxs.resize(meta.nchannels(), 0.);
|
||||||
streammeta = Some(meta);
|
ranges = meta.channelInfo.iter().map(|ch| ch.range).collect();
|
||||||
}
|
}
|
||||||
InStreamMsg::InStreamData(dat) => {
|
InStreamMsg::InStreamData(dat) => {
|
||||||
let meta = streammeta
|
|
||||||
.as_ref()
|
|
||||||
.expect("If we are here, stream metadata should be available");
|
|
||||||
let flt = dat.getFloatData();
|
let flt = dat.getFloatData();
|
||||||
// Update channel maximum values
|
// Update channel maximum values
|
||||||
flt.columns()
|
flt.columns()
|
||||||
@ -71,12 +68,10 @@ impl SimpleClipDetector {
|
|||||||
.for_each(|(coli, mini)| *mini = min(coli));
|
.for_each(|(coli, mini)| *mini = min(coli));
|
||||||
|
|
||||||
// Compare minima and maxima against clip limits
|
// Compare minima and maxima against clip limits
|
||||||
maxs.iter()
|
maxs.iter().zip(mins.iter()).zip(ranges.iter()).for_each(
|
||||||
.zip(mins.iter())
|
|((max, min), range)| {
|
||||||
.zip(&meta.channelInfo)
|
let min_for_clip = CLIP_REL_LIMIT * range.0;
|
||||||
.for_each(|((max, min), ch)| {
|
let max_for_clip = CLIP_REL_LIMIT * range.1;
|
||||||
let min_for_clip = CLIP_REL_LIMIT * ch.range.0;
|
|
||||||
let max_for_clip = CLIP_REL_LIMIT * ch.range.1;
|
|
||||||
if *max >= max_for_clip {
|
if *max >= max_for_clip {
|
||||||
clipstate.store(true, Relaxed);
|
clipstate.store(true, Relaxed);
|
||||||
// We do not have to do anything anymore. The signal
|
// We do not have to do anything anymore. The signal
|
||||||
@ -91,7 +86,8 @@ impl SimpleClipDetector {
|
|||||||
// blocks anymore.
|
// blocks anymore.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// Ignore other stream messages
|
// Ignore other stream messages
|
||||||
_ => {}
|
_ => {}
|
||||||
|
Loading…
Reference in New Issue
Block a user