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

Method new

libs/scrap/src/common/vram.rs:56–95  ·  view source on GitHub ↗
(cfg: EncoderCfg, _i444: bool)

Source from the content-addressed store, hash-verified

54
55impl EncoderApi for VRamEncoder {
56 fn new(cfg: EncoderCfg, _i444: bool) -> ResultType<Self>
57 where
58 Self: Sized,
59 {
60 match cfg {
61 EncoderCfg::VRAM(config) => {
62 let b = Self::convert_quality(config.quality, &config.feature);
63 let base_bitrate = base_bitrate(config.width as _, config.height as _);
64 let mut bitrate = base_bitrate * b / 100;
65 if base_bitrate <= 0 {
66 bitrate = base_bitrate;
67 }
68 let gop = config.keyframe_interval.unwrap_or(MAX_GOP as _) as i32;
69 let ctx = EncodeContext {
70 f: config.feature.clone(),
71 d: DynamicContext {
72 device: Some(config.device.device),
73 width: config.width as _,
74 height: config.height as _,
75 kbitrate: bitrate as _,
76 framerate: 30,
77 gop,
78 },
79 };
80 match Encoder::new(ctx.clone()) {
81 Ok(encoder) => Ok(VRamEncoder {
82 encoder,
83 ctx,
84 format: config.feature.data_format,
85 bitrate,
86 last_frame_len: 0,
87 same_bad_len_counter: 0,
88 config,
89 }),
90 Err(_) => Err(anyhow!(format!("Failed to create encoder"))),
91 }
92 }
93 _ => Err(anyhow!("encoder type mismatch")),
94 }
95 }
96
97 fn encode_to_message(
98 &mut self,

Callers

nothing calls this directly

Calls 2

base_bitrateFunction · 0.85
cloneMethod · 0.45

Tested by

no test coverage detected