Skip to content

Commit 9b53c84

Browse files
committed
Add a progress callback
1 parent 45d6754 commit 9b53c84

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/api/config/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ pub use rate::{RateControlConfig, RateControlSummary};
2525
mod speedsettings;
2626
pub use speedsettings::*;
2727

28+
mod progress;
29+
pub use progress::*;
30+
2831
pub use crate::tiling::TilingInfo;
2932

3033
/// Enumeration of possible invalid configuration errors.
@@ -131,6 +134,8 @@ pub struct Config {
131134
#[cfg(feature = "unstable")]
132135
/// Number of parallel encoding slots
133136
pub(crate) slots: usize,
137+
/// Granular progress callback called when a macroblock is processed.
138+
pub(crate) progress: Option<Arc<dyn GranularProgress>>,
134139
}
135140

136141
impl Config {
@@ -185,6 +190,14 @@ impl Config {
185190
self.slots = slots;
186191
self
187192
}
193+
194+
/// Set a granular progress callback
195+
pub fn with_granular_progress(
196+
mut self, progress: Arc<dyn GranularProgress>,
197+
) -> Self {
198+
self.progress = Some(progress);
199+
self
200+
}
188201
}
189202

190203
fn check_tile_log2(n: usize) -> bool {

src/api/config/progress.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) 2020, The rav1e contributors. All rights reserved
2+
//
3+
// This source code is subject to the terms of the BSD 2 Clause License and
4+
// the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
5+
// was not distributed with this source code in the LICENSE file, you can
6+
// obtain it at www.aomedia.org/license/software. If the Alliance for Open
7+
// Media Patent License 1.0 was not distributed with this source code in the
8+
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.
9+
10+
/// Information provided to the progress callback
11+
#[derive(Debug, Clone)]
12+
pub struct ProgressData {}
13+
14+
/// Progress callback
15+
pub trait GranularProgress: std::fmt::Debug + Sync + Send {
16+
/// Return if the encoding process should continue or not
17+
fn progress(&self, info: &ProgressData) -> bool;
18+
}
19+
20+
#[derive(Debug)]
21+
pub(crate) struct DefaultProgress {}
22+
23+
impl GranularProgress for DefaultProgress {
24+
fn progress(&self, _info: &ProgressData) -> bool {
25+
true
26+
}
27+
}

0 commit comments

Comments
 (0)