Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move framerate to chunk #742

Merged
merged 1 commit into from
Mar 30, 2023
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
14 changes: 4 additions & 10 deletions av1an-core/src/broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ impl<'a> Broker<'a> {
}
}

let frame_rate = self.project.input.frame_rate().unwrap();

crossbeam_utils::thread::scope(|s| {
let consumers: Vec<_> = (0..self.project.workers)
.map(|idx| (receiver.clone(), &self, idx))
Expand All @@ -162,12 +160,9 @@ impl<'a> Broker<'a> {
}

while let Ok(mut chunk) = rx.recv() {
if let Err(e) = queue.encode_chunk(
&mut chunk,
worker_id,
frame_rate,
Arc::clone(&audio_size_ref),
) {
if let Err(e) =
queue.encode_chunk(&mut chunk, worker_id, Arc::clone(&audio_size_ref))
{
error!("[chunk {}] {}", chunk.index, e);

tx.send(()).unwrap();
Expand Down Expand Up @@ -196,7 +191,6 @@ impl<'a> Broker<'a> {
&self,
chunk: &mut Chunk,
worker_id: usize,
frame_rate: f64,
audio_size_bytes: Arc<AtomicU64>,
) -> Result<(), Box<EncoderCrash>> {
let st_time = Instant::now();
Expand Down Expand Up @@ -261,7 +255,7 @@ impl<'a> Broker<'a> {
.unwrap();

update_progress_bar_estimates(
frame_rate,
chunk.frame_rate,
self.project.frames,
self.project.verbosity,
audio_size_bytes.load(atomic::Ordering::SeqCst),
Expand Down
7 changes: 6 additions & 1 deletion av1an-core/src/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ use std::path::Path;
use av1_grain::{generate_photon_noise_params, write_grain_table, NoiseGenArgs};
use serde::{Deserialize, Serialize};

use crate::encoder::Encoder;
use crate::settings::insert_noise_table_params;
use crate::Input;
use crate::{encoder::Encoder, settings::insert_noise_table_params};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Chunk {
Expand All @@ -17,6 +18,7 @@ pub struct Chunk {
pub start_frame: usize,
// End frame is exclusive, i.e. the range of frames is `start_frame..end_frame`
pub end_frame: usize,
pub frame_rate: f64,
pub passes: u8,
pub video_params: Vec<String>,
pub encoder: Encoder,
Expand Down Expand Up @@ -95,6 +97,7 @@ mod tests {
output_ext: "ivf".to_owned(),
start_frame: 0,
end_frame: 5,
frame_rate: 30.0,
tq_cq: None,
passes: 1,
video_params: vec![],
Expand All @@ -112,6 +115,7 @@ mod tests {
output_ext: "ivf".to_owned(),
start_frame: 0,
end_frame: 5,
frame_rate: 30.0,
tq_cq: None,
passes: 1,
video_params: vec![],
Expand All @@ -130,6 +134,7 @@ mod tests {
output_ext: "ivf".to_owned(),
start_frame: 0,
end_frame: 5,
frame_rate: 30.0,
tq_cq: None,
passes: 1,
video_params: vec![],
Expand Down
9 changes: 9 additions & 0 deletions av1an-core/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,8 @@ properly into a mkv file. Specify mkvmerge as the concatenation method by settin

let output_ext = self.encoder.output_extension();

let frame_rate = self.input.frame_rate().unwrap();

let mut chunk = Chunk {
temp: self.temp.clone(),
index,
Expand All @@ -864,6 +866,7 @@ properly into a mkv file. Specify mkvmerge as the concatenation method by settin
output_ext: output_ext.to_owned(),
start_frame,
end_frame,
frame_rate,
video_params: overrides
.as_ref()
.map_or_else(|| self.video_params.clone(), |ovr| ovr.video_params.clone()),
Expand Down Expand Up @@ -904,6 +907,8 @@ properly into a mkv file. Specify mkvmerge as the concatenation method by settin

let output_ext = self.encoder.output_extension();

let frame_rate = self.input.frame_rate().unwrap();

let mut chunk = Chunk {
temp: self.temp.clone(),
index,
Expand All @@ -912,6 +917,7 @@ properly into a mkv file. Specify mkvmerge as the concatenation method by settin
output_ext: output_ext.to_owned(),
start_frame: scene.start_frame,
end_frame: scene.end_frame,
frame_rate,
video_params: scene
.zone_overrides
.as_ref()
Expand Down Expand Up @@ -1077,6 +1083,8 @@ properly into a mkv file. Specify mkvmerge as the concatenation method by settin

let num_frames = num_frames(Path::new(file))?;

let frame_rate = self.input.frame_rate().unwrap();

let mut chunk = Chunk {
temp: self.temp.clone(),
input: Input::Video(PathBuf::from(file)),
Expand All @@ -1085,6 +1093,7 @@ properly into a mkv file. Specify mkvmerge as the concatenation method by settin
index,
start_frame: 0,
end_frame: num_frames,
frame_rate,
video_params: overrides
.as_ref()
.map_or_else(|| self.video_params.clone(), |ovr| ovr.video_params.clone()),
Expand Down