aboutsummaryrefslogtreecommitdiff
path: root/lvc/app/src/bin/main.rs
blob: 0b3596e379c356f009b41e5e5e912d322c40a374 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use bv1::{
    encode::{encode, EncodeConfig},
    P2, decode,
};
use clap::{Parser, Subcommand};
use std::io::{stdin, stdout};

#[derive(Parser)]
#[clap(about, version)]
struct Args {
    // Width of the video signal
    #[arg(short = 'W', long)]
    width: u16,
    // Height of the video signal
    #[arg(short = 'H', long)]
    height: u16,
    #[clap(subcommand)]
    action: Action,
}

#[derive(Clone, Subcommand)]
enum Action {
    // Compress video
    Encode {
        #[arg(short, long, default_value_t = 800)]
        max_block_size: usize,
        #[arg(short, long, default_value_t = 10_000)]
        attention_split: u32,
        #[arg(short, long, default_value_t = 10.)]
        threshold: f32,
        #[arg(short, long, default_value_t = 10)]
        keyframe_interval: usize,
    },
    // Decompress video
    Decode {
        #[arg(short, long)]
        debug: bool,
    },
}

fn main() {
    let args = Args::parse();

    let size = P2 {
        x: args.width as i32,
        y: args.height as i32,
    };
    match args.action {
        Action::Encode {
            max_block_size,
            threshold,
            attention_split,
            keyframe_interval,
        } => {
            let config = EncodeConfig {
                threshold,
                max_block_size,
                attention_split,
                keyframe_interval,
            };

            encode(config, size, stdin(), stdout()).unwrap();
        }
        Action::Decode { debug } => {
            decode(size, debug, stdin(), stdout()).unwrap();
        }
    }
}