Commit ab1e40ff authored by Luca Barbato's avatar Luca Barbato Committed by Luca Barbato

Move the ivf muxer to a subcrate

parent 7ca05c8c
......@@ -12,7 +12,7 @@ autobins = false
comparative_bench = ["aom"]
decode_test = ["bindgen", "aom"]
decode_test_dav1d = ["dav1d-sys"]
binaries = ["y4m", "clap", "scan_fmt"]
binaries = ["ivf", "y4m", "clap", "scan_fmt"]
default = ["binaries", "nasm"]
aom = ["cmake"]
nasm = ["nasm-rs"]
......@@ -30,6 +30,7 @@ num-traits = "0.2"
paste = "0.1"
dav1d-sys = { version = "0.1.2", optional = true }
scan_fmt = { version = "0.1.3", optional = true }
ivf = { path = "ivf/", optional = true }
[build-dependencies]
cmake = { version = "0.1", optional = true }
......@@ -64,3 +65,6 @@ codegen-units = 1 # if > 1 enables parallel code generation which improves
[profile.bench]
codegen-units = 1
[workspace]
members = ["ivf"]
[package]
name = "ivf"
version = "0.1.0"
authors = ["Thomas Daede <tdaede@xiph.org>"]
edition = "2018"
[dependencies]
bitstream-io = "0.8"
/// Simple ivf muxer
///
use bitstream_io::{BitWriter, LittleEndian};
use std::io;
pub fn write_ivf_header(
output_file: &mut dyn io::Write, width: usize, height: usize,
framerate_num: usize,
framerate_den: usize
) {
let mut bw = BitWriter::endian(output_file, LittleEndian);
bw.write_bytes(b"DKIF").unwrap();
bw.write(16, 0).unwrap(); // version
bw.write(16, 32).unwrap(); // version
bw.write_bytes(b"AV01").unwrap();
bw.write(16, width as u16).unwrap();
bw.write(16, height as u16).unwrap();
bw.write(32, framerate_num as u32).unwrap();
bw.write(32, framerate_den as u32).unwrap();
bw.write(32, 0).unwrap();
bw.write(32, 0).unwrap();
}
pub fn write_ivf_frame(
output_file: &mut dyn io::Write, pts: u64, data: &[u8]
) {
let mut bw = BitWriter::endian(output_file, LittleEndian);
bw.write(32, data.len() as u32).unwrap();
bw.write(64, pts).unwrap();
bw.write_bytes(data).unwrap();
}
......@@ -7,37 +7,11 @@
// Media Patent License 1.0 was not distributed with this source code in the
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.
use bitstream_io::{BitWriter, LittleEndian};
use crate::decoder::VideoDetails;
use std::io;
use std::io::Write;
use std::slice;
pub fn write_ivf_header(
output_file: &mut dyn io::Write, width: usize, height: usize, num: usize,
den: usize
) {
let mut bw = BitWriter::endian(output_file, LittleEndian);
bw.write_bytes(b"DKIF").unwrap();
bw.write(16, 0).unwrap(); // version
bw.write(16, 32).unwrap(); // version
bw.write_bytes(b"AV01").unwrap();
bw.write(16, width as u16).unwrap();
bw.write(16, height as u16).unwrap();
bw.write(32, num as u32).unwrap();
bw.write(32, den as u32).unwrap();
bw.write(32, 0).unwrap();
bw.write(32, 0).unwrap();
}
pub fn write_ivf_frame(
output_file: &mut dyn io::Write, pts: u64, data: &[u8]
) {
let mut bw = BitWriter::endian(output_file, LittleEndian);
bw.write(32, data.len() as u32).unwrap();
bw.write(64, pts).unwrap();
bw.write_bytes(data).unwrap();
}
pub use ivf::*;
pub fn write_y4m_frame(y4m_enc: &mut y4m::Encoder<'_, Box<dyn Write>>, rec: &rav1e::Frame, y4m_details: VideoDetails) {
let pitch_y = if y4m_details.bit_depth > 8 { y4m_details.width * 2 } else { y4m_details.width };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment