Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import crav1e lib.rs in rav1e and make it buildable using cargo-c #1381

Merged
merged 35 commits into from Jun 25, 2019
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e8bc3e6
crav1e: First iteration
lu-zero Sep 30, 2018
48ebc6c
crav1e: wip: Update to the new API and test the documentation capabil…
lu-zero Oct 10, 2018
91b7e87
crav1e: wip: Update the documentation and use cbindgen.toml
lu-zero Oct 16, 2018
74161d9
crav1e: Update to address some feedbacks
lu-zero Oct 30, 2018
4424a9a
crav1e: Use the libc::size_t and libc::ptrdiff_t
lu-zero Nov 1, 2018
6a5d0b0
crav1e: Support new color parameters
rzumer Dec 7, 2018
760cee2
crav1e: wip: Unbreak
lu-zero Dec 8, 2018
1038919
crav1e: Update to the current API
lu-zero Dec 11, 2018
0345cf1
crav1e: Update to the current rav1e API
lu-zero Feb 3, 2019
ba97f96
crav1e: Update API to the unified EncoderConfig
kodabb Feb 6, 2019
d35a36d
crav1e: Add wrappers for content_light and mastering_display
kodabb Feb 6, 2019
7a1632b
crav1e: Let rav1e_config_default() use defaults
kodabb Feb 6, 2019
8c3fd95
crav1e: Always use 16bit for now
lu-zero Feb 27, 2019
32e1688
crav1e: Update to the current API
lu-zero Mar 11, 2019
58a6bf0
crav1e: Update send_frame and receive_packet
lu-zero Mar 12, 2019
7f96aab
crav1e: lib: Wrap unref functions to be noops when NULL is passed in
kodabb Mar 12, 2019
c3e6c5c
crav1e: rav1e_frame_unref: Use Box instead of Arc
dwbuiten Mar 12, 2019
c3890b2
crav1e: Fix Packet providing a dangling pointer
lu-zero Mar 13, 2019
eab8e1b
crav1e: lib: Import option key parsing from rav1e
kodabb Mar 13, 2019
16d2d54
crav1e: lib: Introduce a new function to parse options as integer
kodabb Mar 13, 2019
838ff47
crav1e: Use make_mut in rav1e_frame_fill_plane
lu-zero Mar 13, 2019
2f386f6
crav1e: lib: Add return types to color properties functions
kodabb Mar 14, 2019
655c5e6
crav1e: Update to the current API
lu-zero Apr 4, 2019
2b4b55a
crav1e: Add bitrate option
dwbuiten Apr 22, 2019
c98c4da
crav1e: Add tile options
dwbuiten Apr 22, 2019
885b469
crav1e: api: Add Encoded state
dwbuiten May 24, 2019
ad0b602
crav1e: Add API to set the pixel format
dwbuiten May 26, 2019
cb3d277
crav1e: Do not use libc::strdup in status_to_str
lu-zero May 28, 2019
11d2353
crav1e: Validate the status_to_str input
lu-zero May 28, 2019
5cb7488
crav1e: api: Add function for setting time base
dwbuiten May 29, 2019
39295aa
crav1e: Fix a typo in the API doc
dwbuiten Jun 3, 2019
4b43945
crav1e: api: Add reservoir_frame_delay option
dwbuiten Jun 3, 2019
7049af7
crav1e: Update Packet API to latest
dwbuiten Jun 11, 2019
6e70030
crav1e: Use the current API
lu-zero Jun 15, 2019
7d55812
Make rav1e CAPI cargo-c buildable
lu-zero Jun 24, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

Make rav1e CAPI cargo-c buildable

It requires the git cargo-c until it is released
  • Loading branch information...
lu-zero committed Jun 24, 2019
commit 7d558125f42f4b503bcdcda5a82765da76a227e0
@@ -91,4 +91,4 @@ codegen-units = 1
lto = true

[workspace]
members = ["ivf", "crates/nasm_rs", "crates/avformat-sys"]
members = [".", "ivf", "crates/nasm_rs", "crates/avformat-sys"]
This conversation was marked as resolved by lu-zero

This comment has been minimized.

Copy link
@tdaede

tdaede Jun 24, 2019

Collaborator

wut

This comment has been minimized.

Copy link
@lu-zero

lu-zero Jun 24, 2019

Author Collaborator

It is a shortcoming of the toolchain, cargo-metadata does not have the concept of main crate and cargo-metadata does not put the main crate as first otherwise.

This comment has been minimized.

Copy link
@tdaede

tdaede Jun 24, 2019

Collaborator

have you filed an upstream bug?

This comment has been minimized.

Copy link
@lu-zero

lu-zero Jun 24, 2019

Author Collaborator

Yes, but cargo-metadata does not have a mean to provide the information I need.

@@ -0,0 +1,19 @@
header = "// SPDX-License-Identifier: MIT"
sys_includes = ["stddef.h", "stdint.h", "stdlib.h"]
no_includes = true
include_guard = "RAV1E_H"
tab_width = 4
style = "Type"
language = "C"

[parse]
parse_deps = true
include = ['rav1e']

[export]
prefix = "Ra"
item_types = ["enums", "structs", "unions", "typedefs", "opaque", "functions"]

[enum]
rename_variants = "ScreamingSnakeCase"
prefix_with_name = true
@@ -5,12 +5,6 @@
//!
//! This is the C-compatible API

extern crate rav1e;
extern crate libc;
extern crate num_traits;
#[macro_use]
extern crate num_derive;

use std::slice;
use std::sync::Arc;

@@ -22,8 +16,11 @@ use std::os::raw::c_int;
use libc::size_t;
use libc::ptrdiff_t;

use num_derive::*;
use num_traits::cast::FromPrimitive;

use crate::prelude as rav1e;

/// Raw video Frame
///
/// It can be allocated throught rav1e_frame_new(), populated using rav1e_frame_fill_plane()
@@ -87,7 +84,7 @@ pub struct Context {
last_err: Option<rav1e::EncoderStatus>,
}

type FrameType = rav1e::data::FrameType;
type FrameType = rav1e::FrameType;

/// Encoded Packet
///
@@ -106,18 +103,18 @@ pub struct Packet {
pub frame_type: FrameType,
}

type PixelRange=rav1e::color::PixelRange;
type ChromaSamplePosition=rav1e::color::ChromaSamplePosition;
type ChromaSampling=rav1e::color::ChromaSampling;
type MatrixCoefficients=rav1e::color::MatrixCoefficients;
type ColorPrimaries=rav1e::color::ColorPrimaries;
type TransferCharacteristics=rav1e::color::TransferCharacteristics;
type Rational=rav1e::data::Rational;
type PixelRange=rav1e::PixelRange;
type ChromaSamplePosition=rav1e::ChromaSamplePosition;
type ChromaSampling=rav1e::ChromaSampling;
type MatrixCoefficients=rav1e::MatrixCoefficients;
type ColorPrimaries=rav1e::ColorPrimaries;
type TransferCharacteristics=rav1e::TransferCharacteristics;
type Rational=rav1e::Rational;

#[no_mangle]
pub unsafe extern "C" fn rav1e_config_default() -> *mut Config {
let cfg = rav1e::Config {
enc: rav1e::config::EncoderConfig::default(),
enc: rav1e::EncoderConfig::default(),
threads: 0,
};

@@ -192,7 +189,7 @@ pub unsafe extern "C" fn rav1e_config_set_color_description(cfg: *mut Config,
primaries: ColorPrimaries,
transfer: TransferCharacteristics
) -> c_int {
(*cfg).cfg.enc.color_description = Some(rav1e::color::ColorDescription {
(*cfg).cfg.enc.color_description = Some(rav1e::ColorDescription {
matrix_coefficients: matrix,
color_primaries: primaries,
transfer_characteristics: transfer,
@@ -209,7 +206,7 @@ pub unsafe extern "C" fn rav1e_config_set_content_light(cfg: *mut Config,
max_content_light_level: u16,
max_frame_average_light_level: u16
) -> c_int {
(*cfg).cfg.enc.content_light = Some(rav1e::color::ContentLight {
(*cfg).cfg.enc.content_light = Some(rav1e::ContentLight {
max_content_light_level,
max_frame_average_light_level,
});
@@ -226,12 +223,12 @@ pub unsafe extern "C" fn rav1e_config_set_content_light(cfg: *mut Config,
/// Returns a negative value on error or 0.
#[no_mangle]
pub unsafe extern "C" fn rav1e_config_set_mastering_display(cfg: *mut Config,
primaries: [rav1e::data::Point; 3],
white_point: rav1e::data::Point,
primaries: [rav1e::Point; 3],
white_point: rav1e::Point,
max_luminance: u32,
min_luminance: u32
) -> c_int {
(*cfg).cfg.enc.mastering_display = Some(rav1e::color::MasteringDisplay {
(*cfg).cfg.enc.mastering_display = Some(rav1e::MasteringDisplay {
primaries,
white_point,
max_luminance,
@@ -260,7 +257,7 @@ unsafe fn option_match(
match key {
"width" => enc.width = value.parse().map_err(|_| ())?,
"height" => enc.height = value.parse().map_err(|_| ())?,
"speed" => enc.speed_settings = rav1e::config::SpeedSettings::from_preset(value.parse().map_err(|_| ())?),
"speed" => enc.speed_settings = rav1e::SpeedSettings::from_preset(value.parse().map_err(|_| ())?),

"threads" => (*cfg).cfg.threads = value.parse().map_err(|_| ())?,

@@ -15,6 +15,9 @@
#[macro_use]
extern crate pretty_assertions;

#[cfg(cargo_c)]
mod capi;

mod ec;
mod partition;
mod plane;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.