Skip to content

Instantly share code, notes, and snippets.

@lu-zero
Created July 20, 2020 18:01
Show Gist options
  • Select an option

  • Save lu-zero/b9e25f0d1afea884f268ba10ccc8dba8 to your computer and use it in GitHub Desktop.

Select an option

Save lu-zero/b9e25f0d1afea884f268ba10ccc8dba8 to your computer and use it in GitHub Desktop.
diff --git a/rav1e_js/src/main.rs b/rav1e_js/src/main.rs
index 801e587a..284a7d8c 100644
--- a/rav1e_js/src/main.rs
+++ b/rav1e_js/src/main.rs
@@ -10,32 +10,32 @@ fn main() {
let mut buf = Vec::with_capacity(len);
buf.resize(len, 0_u8);
[buf.clone(), buf.clone(), buf]
};
let chroma_sampling = ChromaSampling::Cs444;
let (chroma_width, _) = chroma_sampling.get_chroma_dimensions(width, height);
- let mut f: Frame<u8> = Frame::new(width, height, chroma_sampling);
- f.planes[0].copy_from_raw_u8(data[0].as_slice(), width, 1);
- f.planes[1].copy_from_raw_u8(data[1].as_slice(), chroma_width, 1);
- f.planes[2].copy_from_raw_u8(data[2].as_slice(), chroma_width, 1);
-
let mut conf = EncoderConfig::default();
conf.color_description = Some(ColorDescription {
color_primaries: ColorPrimaries::BT709,
transfer_characteristics: TransferCharacteristics::BT709,
matrix_coefficients: MatrixCoefficients::BT709,
});
conf.height = height;
conf.width = width;
let mut ctx: Context<u8> =
Config::new().with_encoder_config(conf).new_context().unwrap();
+ let mut f = ctx.new_frame();
+ f.planes[0].copy_from_raw_u8(data[0].as_slice(), width, 1);
+ f.planes[1].copy_from_raw_u8(data[1].as_slice(), chroma_width, 1);
+ f.planes[2].copy_from_raw_u8(data[2].as_slice(), chroma_width, 1);
+
for _ in 0..70 {
ctx.send_frame(f.clone()).unwrap();
}
ctx.flush();
loop {
match ctx.receive_packet() {
Ok(p) => eprintln!("{:?}", p),
Err(e) => {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment