Commit 085e9e3a authored by Vittorio Giovara's avatar Vittorio Giovara

Move a few structures and enums from encoder to api

parent 50269cb6
......@@ -191,6 +191,28 @@ impl SpeedSettings {
}
}
#[allow(dead_code, non_camel_case_types)]
#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)]
#[repr(C)]
pub enum FrameType {
KEY,
INTER,
INTRA_ONLY,
SWITCH
}
impl fmt::Display for FrameType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::FrameType::*;
match self {
KEY => write!(f, "Key frame"),
INTER => write!(f, "Inter frame"),
INTRA_ONLY => write!(f, "Intra only frame"),
SWITCH => write!(f, "Switching frame"),
}
}
}
#[derive(Clone, Copy, Debug, PartialOrd, PartialEq)]
pub enum PredictionModesSetting {
Simple,
......@@ -198,6 +220,48 @@ pub enum PredictionModesSetting {
ComplexAll,
}
#[derive(Copy, Clone, Debug, PartialEq)]
#[repr(C)]
pub enum ChromaSampling {
Cs420,
Cs422,
Cs444,
Cs400,
}
impl Default for ChromaSampling {
fn default() -> Self {
ChromaSampling::Cs420
}
}
impl ChromaSampling {
// Provides the sampling period in the horizontal and vertical axes.
pub fn sampling_period(self) -> (usize, usize) {
use self::ChromaSampling::*;
match self {
Cs420 => (2, 2),
Cs422 => (2, 1),
Cs444 => (1, 1),
Cs400 => (2, 2),
}
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
#[repr(C)]
pub enum ChromaSamplePosition {
Unknown,
Vertical,
Colocated
}
impl Default for ChromaSamplePosition {
fn default() -> Self {
ChromaSamplePosition::Unknown
}
}
arg_enum!{
#[derive(Debug, Clone, Copy, PartialEq)]
#[repr(C)]
......@@ -765,4 +829,4 @@ impl From<&FrameInvariants> for FirstPassFrame {
frame_type: fi.frame_type,
}
}
}
\ No newline at end of file
}
......@@ -9,6 +9,7 @@
use clap::{App, Arg, ArgMatches};
use crate::{ColorPrimaries, TransferCharacteristics, MatrixCoefficients};
use rav1e::FrameType;
use rav1e::*;
use std::{fmt, io};
......
......@@ -4,8 +4,8 @@ use rav1e::Rational;
use crate::decoder::DecodeError;
use crate::decoder::Decoder;
use crate::decoder::VideoDetails;
use crate::encoder::ChromaSamplePosition;
use crate::encoder::ChromaSampling;
use crate::ChromaSamplePosition;
use crate::ChromaSampling;
use crate::encoder::Frame;
impl Decoder for y4m::Decoder<'_, Box<dyn Read>> {
......
......@@ -196,48 +196,6 @@ impl Default for Tune {
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
#[repr(C)]
pub enum ChromaSampling {
Cs420,
Cs422,
Cs444,
Cs400,
}
impl Default for ChromaSampling {
fn default() -> Self {
ChromaSampling::Cs420
}
}
impl ChromaSampling {
// Provides the sampling period in the horizontal and vertical axes.
pub fn sampling_period(self) -> (usize, usize) {
use self::ChromaSampling::*;
match self {
Cs420 => (2, 2),
Cs422 => (2, 1),
Cs444 => (1, 1),
Cs400 => (2, 2),
}
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
#[repr(C)]
pub enum ChromaSamplePosition {
Unknown,
Vertical,
Colocated
}
impl Default for ChromaSamplePosition {
fn default() -> Self {
ChromaSamplePosition::Unknown
}
}
#[derive(Copy, Clone, Debug)]
pub struct Sequence {
// OBU Sequence header of AV1
......@@ -875,18 +833,6 @@ pub struct InterPropsConfig {
pub group_idx: u64,
}
#[allow(dead_code, non_camel_case_types)]
#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)]
#[repr(C)]
pub enum FrameType {
KEY,
INTER,
INTRA_ONLY,
SWITCH
}
//const REFERENCE_MODES: usize = 3;
#[allow(dead_code,non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ReferenceMode {
......@@ -897,18 +843,6 @@ pub enum ReferenceMode {
pub const ALL_REF_FRAMES_MASK: u32 = (1 << REF_FRAMES) - 1;
impl fmt::Display for FrameType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::FrameType::*;
match self {
KEY => write!(f, "Key frame"),
INTER => write!(f, "Inter frame"),
INTRA_ONLY => write!(f, "Intra only frame"),
SWITCH => write!(f, "Switching frame"),
}
}
}
trait UncompressedHeader {
// Start of OBU Headers
fn write_obu_header(
......
......@@ -12,8 +12,9 @@
use self::BlockSize::*;
use self::TxSize::*;
use crate::api::ChromaSampling;
use crate::context::*;
use crate::encoder::{ChromaSampling, FrameInvariants};
use crate::encoder::FrameInvariants;
use crate::mc::*;
use crate::plane::*;
use crate::predict::*;
......
......@@ -10,17 +10,16 @@
#![allow(non_camel_case_types)]
use crate::api::PredictionModesSetting;
use crate::api::*;
use crate::cdef::*;
use crate::context::*;
use crate::ec::{OD_BITRES, Writer, WriterCounter};
use crate::encoder::{ChromaSampling, ReferenceMode};
use crate::encoder::ReferenceMode;
use crate::encode_block_a;
use crate::encode_block_b;
use crate::encode_block_with_modes;
use crate::FrameInvariants;
use crate::FrameState;
use crate::FrameType;
use crate::luma_ac;
use crate::me::*;
use crate::motion_compensate;
......
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