pub fn set_enabled(on: bool)Expand description
Turn accounting on (from the harness) — never on by default.
Examples found in repository?
examples/bit_accountant.rs (line 56)
44fn main() {
45 let path = std::env::args().nth(1).unwrap_or_else(|| "video-tests/clips/foreman_cif.y4m".into());
46 let n: usize = std::env::var("BA_FRAMES").ok().and_then(|v| v.parse().ok()).unwrap_or(24);
47 let qp: u8 = std::env::var("BA_QP").ok().and_then(|v| v.parse().ok()).unwrap_or(27);
48 let (w, h, frames) = read_y4m(&path, n);
49 let name = std::path::Path::new(&path).file_stem().unwrap().to_string_lossy().to_string();
50 for (pname, preset) in [("quality", Preset::Quality)] {
51 let mut cfg = EncoderConfig::new(w, h);
52 cfg.qp = qp;
53 cfg.gop_size = 60;
54 cfg.preset = preset;
55 rusty_h264_encoder::bitacct::reset();
56 rusty_h264_encoder::bitacct::set_enabled(true);
57 let mut enc = Encoder::new(cfg).unwrap();
58 let mut total = 0usize;
59 for f in &frames {
60 total += enc.encode(f).len();
61 }
62 rusty_h264_encoder::bitacct::add_actual_bytes(total);
63 rusty_h264_encoder::bitacct::set_enabled(false);
64 let mbs = (w.div_ceil(16) * h.div_ceil(16) * frames.len()) as u64;
65 rusty_h264_encoder::bitacct::dump(
66 &format!("{name} {pname} qp{qp} x{} ({} bytes)", frames.len(), total),
67 mbs,
68 );
69 if std::env::var_os("BA_MVDTAB").is_some() {
70 rusty_h264_encoder::bitacct::dump_mvd_table();
71 }
72 }
73}