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

extract-rpu: Add limit option #310

Merged
merged 2 commits into from
Sep 14, 2024
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
255 changes: 123 additions & 132 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ path = "src/main.rs"

[dependencies]
dolby_vision = { path = "dolby_vision", "features" = ["xml", "serde"] }
bitvec_helpers = { version = "3.1.5", default-features = false, features = ["bitstream-io"] }
hevc_parser = { version = "0.6.3", features = ["hevc_io"] }
bitvec_helpers = { version = "3.1.6", default-features = false, features = ["bitstream-io"] }
hevc_parser = { version = "0.6.4", features = ["hevc_io"] }
madvr_parse = "1.0.2"
hdr10plus = { version = "2.1.1", features = ["json"] }
hdr10plus = { version = "2.1.3", features = ["json"] }

anyhow = "1.0.86"
clap = { version = "4.5.16", features = ["derive", "wrap_help", "deprecated"] }
anyhow = "1.0.88"
clap = { version = "4.5.17", features = ["derive", "wrap_help", "deprecated"] }
clap_lex = "*"
indicatif = "0.17.8"
bitvec = "1.0.1"
serde = { version = "1.0.208", features = ["derive"] }
serde_json = { version = "1.0.125", features = ["preserve_order"] }
serde = { version = "1.0.210", features = ["derive"] }
serde_json = { version = "1.0.128", features = ["preserve_order"] }
itertools = "0.13.0"
plotters = { version = "0.3.6", default-features = false, features = ["bitmap_backend", "bitmap_encoder", "all_series"] }
plotters = { version = "0.3.7", default-features = false, features = ["bitmap_backend", "bitmap_encoder", "all_series"] }

[dev-dependencies]
assert_cmd = "2.0.16"
assert_fs = "1.1.2"
predicates = "3.1.2"

[build-dependencies]
anyhow = "1.0.86"
anyhow = "1.0.88"
vergen-gitcl = { version = "1.0.0", default-features = false, features = ["build"] }

[features]
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ For working with an HEVC source file, there are multiple options that apply to m

**Supports profiles 4, 5, 7, and 8**.

**Flags**:
- `-l`, `--limit` Number of frames to process from the input. Processing stops after N frames.

**Examples**:
```console
dovi_tool extract-rpu video.hevc
Expand Down
68 changes: 34 additions & 34 deletions dolby_vision/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dolby_vision/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ description = "Dolby Vision metadata parsing and writing"
repository = "https://github.com/quietvoid/dovi_tool/tree/main/dolby_vision"

[dependencies]
bitvec_helpers = { version = "3.1.5", default-features = false, features = ["bitstream-io"] }
anyhow = "1.0.86"
bitvec_helpers = { version = "3.1.6", default-features = false, features = ["bitstream-io"] }
anyhow = "1.0.88"
bitvec = "1.0.1"
crc = "3.2.1"
roxmltree = { version = "0.20.0", optional = true }
serde = { version = "1.0.208", features = ["derive"], "optional" = true }
serde_json = { version = "1.0.125", features = ["preserve_order"], "optional" = true }
serde = { version = "1.0.210", features = ["derive"], "optional" = true }
serde_json = { version = "1.0.128", features = ["preserve_order"], "optional" = true }
tinyvec = { version = "1.8.0", features = ["rustc_1_55"] }

libc = { version = "0.2", optional = true }
Expand Down
8 changes: 8 additions & 0 deletions src/commands/extract_rpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@ pub struct ExtractRpuArgs {
value_hint = ValueHint::FilePath
)]
pub rpu_out: Option<PathBuf>,

#[arg(
id = "limit",
long,
short = 'l',
help = "Stop processing input after N frames"
)]
pub limit: Option<u64>,
}
8 changes: 7 additions & 1 deletion src/dovi/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ impl Converter {

fn convert_raw_hevc(&self, pb: ProgressBar, options: CliOptions) -> Result<()> {
let dovi_writer = DoviWriter::new(None, None, None, Some(&self.output));
let mut dovi_processor = DoviProcessor::new(options, self.input.clone(), dovi_writer, pb);
let mut dovi_processor = DoviProcessor::new(
options,
self.input.clone(),
dovi_writer,
pb,
Default::default(),
);

dovi_processor.read_write_from_io(&self.format)
}
Expand Down
8 changes: 7 additions & 1 deletion src/dovi/demuxer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ impl Demuxer {
};

let dovi_writer = DoviWriter::new(bl_out, Some(self.el_out.as_path()), None, None);
let mut dovi_processor = DoviProcessor::new(options, self.input.clone(), dovi_writer, pb);
let mut dovi_processor = DoviProcessor::new(
options,
self.input.clone(),
dovi_writer,
pb,
Default::default(),
);

dovi_processor.read_write_from_io(&self.format)
}
Expand Down
10 changes: 10 additions & 0 deletions src/dovi/general_read_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub struct DoviProcessor {

progress_bar: ProgressBar,
dovi_writer: DoviWriter,

processor_opts: DoviProcessorOptions,
}

pub struct DoviWriter {
Expand All @@ -40,6 +42,11 @@ pub struct RpuNal {
data: Vec<u8>,
}

#[derive(Default)]
pub struct DoviProcessorOptions {
pub limit: Option<u64>,
}

impl DoviWriter {
pub fn new<P: AsRef<Path>>(
bl_out: Option<P>,
Expand Down Expand Up @@ -91,6 +98,7 @@ impl DoviProcessor {
input: PathBuf,
dovi_writer: DoviWriter,
progress_bar: ProgressBar,
processor_opts: DoviProcessorOptions,
) -> DoviProcessor {
DoviProcessor {
input,
Expand All @@ -101,6 +109,7 @@ impl DoviProcessor {
previous_rpu_index: 0,
progress_bar,
dovi_writer,
processor_opts,
}
}

Expand All @@ -109,6 +118,7 @@ impl DoviProcessor {

let processor_opts = HevcProcessorOpts {
parse_nals: true,
limit: self.processor_opts.limit,
..Default::default()
};
let mut processor = HevcProcessor::new(format.clone(), processor_opts, chunk_size);
Expand Down
Loading
Loading