Skip to content

Commit 904df72

Browse files
authored
Migrate grain synth code to external crate and allow chroma grain synth (#653)
* Migrate grain parsing and generation code to external crate * Add `--chroma-noise` option to enable chroma grain synth This implementation is simplistic in that it only enables chroma scaling from luma noise based on the `--photon-noise` strength. However, it's 100% more chroma noise capability than av1an had previously. * Disable unnecessary feature in av1-grain * Fix unit test code
1 parent 3e32699 commit 904df72

File tree

7 files changed

+55
-278
lines changed

7 files changed

+55
-278
lines changed

Cargo.lock

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

av1an-cli/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ pub struct CliOpts {
347347
#[clap(long, help_heading = "ENCODING")]
348348
pub photon_noise: Option<u8>,
349349

350+
/// Adds chroma grain synthesis to the grain table generated by `--photon-noise`. (Default: false)
351+
#[clap(long, help_heading = "ENCODING", requires = "photon-noise")]
352+
pub chroma_noise: bool,
353+
350354
/// Determines method used for concatenating encoded chunks and audio into output file
351355
///
352356
/// ffmpeg - Uses ffmpeg for concatenation. Unfortunately, ffmpeg sometimes produces files
@@ -618,6 +622,7 @@ pub fn parse_cli(args: CliOpts) -> anyhow::Result<Vec<EncodeArgs>> {
618622
photon_noise: args
619623
.photon_noise
620624
.and_then(|arg| if arg == 0 { None } else { Some(arg) }),
625+
chroma_noise: args.chroma_noise,
621626
sc_pix_format: args.sc_pix_format,
622627
keep: args.keep,
623628
max_tries: args.max_tries,

av1an-core/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ arrayvec = "0.7.2"
2020
atty = "0.2.14"
2121
av-format = "0.3.1"
2222
av-ivf = "0.2.2"
23+
av1-grain = { version = "0.1.1", default-features = false, features = [
24+
"create",
25+
] }
2326
memchr = "2.4.1"
2427
anyhow = "1.0.42"
2528
rand = "0.8.4"

av1an-core/src/grain.rs

-263
This file was deleted.

av1an-core/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ use std::time::Instant;
3535

3636
use ::ffmpeg::color::TransferCharacteristic;
3737
use anyhow::Context;
38+
use av1_grain::TransferFunction;
3839
use chunk::Chunk;
3940
use dashmap::DashMap;
40-
use grain::TransferFunction;
4141
use once_cell::sync::OnceCell;
4242
use serde::{Deserialize, Serialize};
4343
use strum::{Display, EnumString, IntoStaticStr};
@@ -52,7 +52,6 @@ pub mod chunk;
5252
pub mod concat;
5353
pub mod encoder;
5454
pub mod ffmpeg;
55-
mod grain;
5655
pub(crate) mod parse;
5756
pub mod progress_bar;
5857
pub mod scene_detect;

av1an-core/src/scenes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ fn get_test_args() -> EncodeArgs {
271271
encoder: Encoder::aom,
272272
extra_splits_len: Some(100),
273273
photon_noise: Some(10),
274+
chroma_noise: false,
274275
sc_pix_format: None,
275276
keep: false,
276277
max_tries: 3,

0 commit comments

Comments
 (0)