MCPcopy Create free account
hub / github.com/Recordscript/recordscript / test_vpx

Function test_vpx

libs/scrap/examples/benchmark.rs:96–174  ·  view source on GitHub ↗
(
    c: &mut Capturer,
    codec_id: VpxVideoCodecId,
    width: usize,
    height: usize,
    quality: Q,
    yuv_count: usize,
    i444: bool,
)

Source from the content-addressed store, hash-verified

94}
95
96fn test_vpx(
97 c: &mut Capturer,
98 codec_id: VpxVideoCodecId,
99 width: usize,
100 height: usize,
101 quality: Q,
102 yuv_count: usize,
103 i444: bool,
104) {
105 let config = EncoderCfg::VPX(VpxEncoderConfig {
106 width: width as _,
107 height: height as _,
108 quality,
109 codec: codec_id,
110 keyframe_interval: None,
111 });
112 let mut encoder = VpxEncoder::new(config, i444).unwrap();
113 let mut vpxs = vec![];
114 let start = Instant::now();
115 let mut size = 0;
116 let mut yuv = Vec::new();
117 let mut mid_data = Vec::new();
118 let mut counter = 0;
119 let mut time_sum = Duration::ZERO;
120 loop {
121 match c.frame(std::time::Duration::from_millis(30)) {
122 Ok(frame) => {
123 let tmp_timer = Instant::now();
124 let frame = frame.to(encoder.yuvfmt(), &mut yuv, &mut mid_data).unwrap();
125 let yuv = frame.yuv().unwrap();
126 for ref frame in encoder
127 .encode(start.elapsed().as_millis() as _, &yuv, STRIDE_ALIGN)
128 .unwrap()
129 {
130 size += frame.data.len();
131 vpxs.push(frame.data.to_vec());
132 counter += 1;
133 print!("\r{codec_id:?} {}/{}", counter, yuv_count);
134 std::io::stdout().flush().ok();
135 }
136 for ref frame in encoder.flush().unwrap() {
137 size += frame.data.len();
138 vpxs.push(frame.data.to_vec());
139 counter += 1;
140 print!("\r{codec_id:?} {}/{}", counter, yuv_count);
141 std::io::stdout().flush().ok();
142 }
143 time_sum += tmp_timer.elapsed();
144 }
145 Err(e) => {
146 log::error!("{e:?}");
147 }
148 }
149 if counter >= yuv_count {
150 println!();
151 break;
152 }
153 }

Callers 1

mainFunction · 0.85

Calls 7

yuvMethod · 0.80
frameMethod · 0.45
toMethod · 0.45
yuvfmtMethod · 0.45
encodeMethod · 0.45
flushMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected