Commit 285d45f9 authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Thomas Daede

Move IVF writer calls out of public encoder API.

parent 634d1a99
// Copyright (c) 2017-2018, The rav1e contributors. All rights reserved
//
// This source code is subject to the terms of the BSD 2 Clause License and
// the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
// was not distributed with this source code in the LICENSE file, you can
// obtain it at www.aomedia.org/license/software. If the Alliance for Open
// 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 std::io;
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();
}
......@@ -12,10 +12,13 @@ extern crate rav1e;
extern crate y4m;
#[macro_use]
extern crate scan_fmt;
extern crate bitstream_io;
mod common;
mod decoder;
mod muxer;
use common::*;
use muxer::*;
use rav1e::*;
use std::slice;
......
......@@ -24,7 +24,7 @@ use transform::*;
use util::*;
use partition::PartitionType::*;
use bitstream_io::{BitWriter, BigEndian, LittleEndian};
use bitstream_io::{BitWriter, BigEndian};
use std;
use std::{fmt, io};
use std::io::Write;
......@@ -867,32 +867,6 @@ impl fmt::Display for FrameType {
}
}
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();
}
trait UncompressedHeader {
// Start of OBU Headers
fn write_obu_header(
......
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