Skip to content

Commit

Permalink
Bump rust-av deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Luni-4 committed Sep 2, 2022
1 parent dafb1e8 commit 83567ed
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 49 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ codec-trait = ["av-codec"]

[dependencies]
vpx-sys = { version = "0.1.1", path = "vpx-sys" }
av-data = { version = "0.3.0" }
av-codec = { version = "0.2.2", optional = true }
av-data = "0.4.1"
av-codec = { version = "0.3.0", optional = true }

[workspace]
members = ["vpx-sys"]
44 changes: 23 additions & 21 deletions src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ use std::mem::MaybeUninit;
use std::ptr;
use std::sync::Arc;

use crate::data::frame::{new_default_frame, FrameType};
use crate::data::frame::{Frame, VideoInfo};
use crate::data::pixel::formats::YUV420;
use av_data::frame::{Frame, FrameBufferCopy, FrameType, VideoInfo};
use av_data::pixel::formats::YUV420;

use self::vpx_codec_err_t::*;

Expand All @@ -30,7 +29,7 @@ fn frame_from_img(img: vpx_image_t) -> Frame {
Arc::new(*format),
);

let mut frame = new_default_frame(video, None);
let mut frame = Frame::new_default_frame(video, None);

let src = img
.planes
Expand All @@ -40,7 +39,7 @@ fn frame_from_img(img: vpx_image_t) -> Frame {
.map(|((plane, line), chromaton)| unsafe {
std::slice::from_raw_parts(
*plane as *const u8,
*line as usize * chromaton.map(|c| c.get_height(img.h as usize)).unwrap_or(0)
*line as usize * chromaton.map(|c| c.get_height(img.h as usize)).unwrap_or(0),
)
});

Expand All @@ -60,6 +59,7 @@ pub struct VP9Decoder<T> {
}

unsafe impl<T: Send> Send for VP9Decoder<T> {} // TODO: Make sure it cannot be abused
unsafe impl<T: Sync> Sync for VP9Decoder<T> {} // TODO: Make sure it cannot be abused

impl<T> VP9Decoder<T> {
/// Create a new decoder
Expand Down Expand Up @@ -90,7 +90,7 @@ impl<T> VP9Decoder<T> {
iter: ptr::null(),
private_data: PhantomData,
})
},
}
_ => Err(ret),
}
}
Expand Down Expand Up @@ -193,20 +193,22 @@ impl<T> VPXCodec for VP9Decoder<T> {
#[cfg(feature = "codec-trait")]
mod decoder_trait {
use super::*;
use crate::codec::decoder::*;
use crate::codec::error::*;
use crate::data::frame::ArcFrame;
use crate::data::packet::Packet;
use crate::data::timeinfo::TimeInfo;
use av_codec::decoder::*;
use av_codec::error::*;
use av_data::frame::ArcFrame;
use av_data::packet::Packet;
use av_data::timeinfo::TimeInfo;
use std::sync::Arc;

struct Des {
pub struct Des {
descr: Descr,
}

impl Descriptor for Des {
fn create(&self) -> Box<dyn Decoder> {
Box::new(VP9Decoder::new().unwrap())
type OutputDecoder = VP9Decoder<TimeInfo>;

fn create(&self) -> Self::OutputDecoder {
VP9Decoder::new().unwrap()
}

fn describe(&self) -> &Descr {
Expand Down Expand Up @@ -241,7 +243,7 @@ mod decoder_trait {
/// VP9 Decoder
///
/// To be used with [av-codec](https://docs.rs/av-codec) `Context`.
pub const VP9_DESCR: &dyn Descriptor = &Des {
pub const VP9_DESCR: &Des = &Des {
descr: Descr {
codec: "vp9",
name: "vpx",
Expand All @@ -266,8 +268,8 @@ mod tests {

use super::super::encoder::tests as enc;
use super::super::encoder::VPXPacket;
use crate::data::rational::*;
use crate::data::timeinfo::TimeInfo;
use av_data::rational::*;
use av_data::timeinfo::TimeInfo;
#[test]
fn decode() {
let w = 800;
Expand Down Expand Up @@ -319,10 +321,10 @@ mod tests {
fn decode_codec_trait() {
use super::super::decoder::VP9_DESCR as DEC;
use super::super::encoder::VP9_DESCR as ENC;
use crate::codec::common::CodecList;
use crate::codec::decoder as de;
use crate::codec::encoder as en;
use crate::codec::error::*;
use av_codec::common::CodecList;
use av_codec::decoder as de;
use av_codec::encoder as en;
use av_codec::error::*;
use std::sync::Arc;

let encoders = en::Codecs::from_list(&[ENC]);
Expand Down
47 changes: 25 additions & 22 deletions src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use std::mem::MaybeUninit;
use std::os::raw::c_ulong;
use std::ptr;

use crate::data::frame::{Frame, FrameBufferConv, MediaKind};
use crate::data::packet::Packet;
use crate::data::pixel::formats::YUV420;
use crate::data::pixel::Formaton;
use av_data::frame::{Frame, FrameBufferConv, MediaKind};
use av_data::packet::Packet;
use av_data::pixel::formats::YUV420;
use av_data::pixel::Formaton;

use self::vpx_codec_err_t::*;

Expand Down Expand Up @@ -288,27 +288,29 @@ impl VPXCodec for VP9Encoder {
#[cfg(feature = "codec-trait")]
mod encoder_trait {
use super::*;
use crate::codec::encoder::*;
use crate::codec::error::*;
use crate::data::frame::ArcFrame;
use crate::data::params::{CodecParams, MediaKind, VideoInfo};
use crate::data::value::Value;
use av_codec::encoder::*;
use av_codec::error::*;
use av_data::frame::ArcFrame;
use av_data::params::{CodecParams, MediaKind, VideoInfo};
use av_data::value::Value;

struct Des {
pub struct Des {
descr: Descr,
}

struct Enc {
pub struct Enc {
cfg: VP9EncoderConfig,
enc: Option<VP9Encoder>,
}

impl Descriptor for Des {
fn create(&self) -> Box<dyn Encoder> {
Box::new(Enc {
type OutputEncoder = Enc;

fn create(&self) -> Self::OutputEncoder {
Enc {
cfg: VP9EncoderConfig::new().unwrap(),
enc: None,
})
}
}

fn describe(&self) -> &Descr {
Expand Down Expand Up @@ -452,7 +454,7 @@ mod encoder_trait {
/// VP9 Encoder
///
/// To be used with [av-codec](https://docs.rs/av-codec) `Encoder Context`.
pub const VP9_DESCR: &dyn Descriptor = &Des {
pub const VP9_DESCR: &Des = &Des {
descr: Descr {
codec: "vp9",
name: "vpx",
Expand Down Expand Up @@ -497,8 +499,8 @@ pub(crate) mod tests {
e.control(VP8E_SET_CQ_LEVEL, 4).unwrap();
}

use crate::data::rational::*;
use crate::data::timeinfo::TimeInfo;
use av_data::rational::*;
use av_data::timeinfo::TimeInfo;
pub fn setup(w: u32, h: u32, t: &TimeInfo) -> VP9Encoder {
let mut c = VP9EncoderConfig::new().unwrap();
c.cfg.g_w = w;
Expand All @@ -517,8 +519,8 @@ pub(crate) mod tests {
}

pub fn setup_frame(w: u32, h: u32, t: &TimeInfo) -> Frame {
use crate::data::frame::*;
use crate::data::pixel::formats;
use av_data::frame::*;
use av_data::pixel::formats;
use std::sync::Arc;

let v = VideoInfo::new(
Expand All @@ -529,7 +531,7 @@ pub(crate) mod tests {
Arc::new(*formats::YUV420),
);

new_default_frame(v, Some(t.clone()))
Frame::new_default_frame(v, Some(t.clone()))
}

#[test]
Expand Down Expand Up @@ -575,8 +577,9 @@ pub(crate) mod tests {
#[test]
fn encode_codec_trait() {
use super::VP9_DESCR;
use crate::codec::encoder::*;
use crate::codec::error::*;
use av_codec::common::CodecList;
use av_codec::encoder::*;
use av_codec::error::*;
use std::sync::Arc;

let encoders = Codecs::from_list(&[VP9_DESCR]);
Expand Down
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
extern crate av_data as data;
extern crate vpx_sys as ffi;

#[cfg(feature = "codec-trait")]
extern crate av_codec as codec;

pub mod common;
pub mod decoder;
pub mod encoder;

0 comments on commit 83567ed

Please sign in to comment.