Commit a7d885f6 authored by Luca Barbato's avatar Luca Barbato Committed by Thomas Daede

Make nasm optional

Useful to make sure the non-nasm codepath works as intended
parent 08a3d123
...@@ -12,8 +12,9 @@ repl = ["rustyline", "binaries"] ...@@ -12,8 +12,9 @@ repl = ["rustyline", "binaries"]
comparative_bench = ["aom"] comparative_bench = ["aom"]
decode_test = ["bindgen", "aom"] decode_test = ["bindgen", "aom"]
binaries = ["y4m", "clap"] binaries = ["y4m", "clap"]
default = ["binaries"] default = ["binaries", "nasm"]
aom = ["cmake"] aom = ["cmake"]
nasm = ["nasm-rs"]
[dependencies] [dependencies]
bitstream-io = "0.8" bitstream-io = "0.8"
...@@ -31,7 +32,7 @@ paste = "0.1" ...@@ -31,7 +32,7 @@ paste = "0.1"
cmake = { version = "0.1", optional = true } cmake = { version = "0.1", optional = true }
[target.'cfg(target_arch = "x86_64")'.build-dependencies] [target.'cfg(target_arch = "x86_64")'.build-dependencies]
nasm-rs = { git = "https://github.com/tdaede/nasm-rs.git" } nasm-rs = { git = "https://github.com/tdaede/nasm-rs.git", optional = true }
[target.'cfg(unix)'.build-dependencies] [target.'cfg(unix)'.build-dependencies]
pkg-config = "0.3.12" pkg-config = "0.3.12"
......
...@@ -7,7 +7,7 @@ extern crate pkg_config; ...@@ -7,7 +7,7 @@ extern crate pkg_config;
#[cfg(unix)] #[cfg(unix)]
#[cfg(feature = "decode_test")] #[cfg(feature = "decode_test")]
extern crate bindgen; extern crate bindgen;
#[cfg(target_arch = "x86_64")] #[cfg(all(target_arch = "x86_64", feature = "nasm"))]
extern crate nasm_rs; extern crate nasm_rs;
#[allow(unused_imports)] #[allow(unused_imports)]
...@@ -29,7 +29,7 @@ fn rerun_dir<P: AsRef<Path>>(dir: P) { ...@@ -29,7 +29,7 @@ fn rerun_dir<P: AsRef<Path>>(dir: P) {
} }
fn main() { fn main() {
#[cfg(all(target_arch = "x86_64", not(windows)))] { #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))] {
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
let out_dir = env::var("OUT_DIR").unwrap(); let out_dir = env::var("OUT_DIR").unwrap();
......
...@@ -18,7 +18,7 @@ use FrameState; ...@@ -18,7 +18,7 @@ use FrameState;
use libc; use libc;
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), not(windows)))] #[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), not(windows), feature = "nasm"))]
extern { extern {
fn rav1e_sad_4x4_hbd_ssse3( fn rav1e_sad_4x4_hbd_ssse3(
src: *const u16, src_stride: libc::ptrdiff_t, dst: *const u16, src: *const u16, src_stride: libc::ptrdiff_t, dst: *const u16,
...@@ -26,7 +26,7 @@ extern { ...@@ -26,7 +26,7 @@ extern {
) -> u32; ) -> u32;
} }
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
extern { extern {
fn rav1e_sad_8x8_hbd10_ssse3( fn rav1e_sad_8x8_hbd10_ssse3(
src: *const u16, src_stride: libc::ptrdiff_t, dst: *const u16, src: *const u16, src_stride: libc::ptrdiff_t, dst: *const u16,
...@@ -54,7 +54,7 @@ extern { ...@@ -54,7 +54,7 @@ extern {
) -> u32; ) -> u32;
} }
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
#[target_feature(enable = "ssse3")] #[target_feature(enable = "ssse3")]
unsafe fn sad_ssse3( unsafe fn sad_ssse3(
plane_org: &PlaneSlice, plane_ref: &PlaneSlice, blk_h: usize, blk_w: usize, plane_org: &PlaneSlice, plane_ref: &PlaneSlice, blk_h: usize, blk_w: usize,
...@@ -93,7 +93,7 @@ pub fn get_sad( ...@@ -93,7 +93,7 @@ pub fn get_sad(
plane_org: &PlaneSlice, plane_ref: &PlaneSlice, blk_h: usize, blk_w: usize, plane_org: &PlaneSlice, plane_ref: &PlaneSlice, blk_h: usize, blk_w: usize,
bit_depth: usize bit_depth: usize
) -> u32 { ) -> u32 {
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
{ {
if is_x86_feature_detected!("ssse3") && blk_h >= 4 && blk_w >= 4 { if is_x86_feature_detected!("ssse3") && blk_h >= 4 && blk_w >= 4 {
return unsafe { return unsafe {
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))] #![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))]
#![cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))] #![cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))]
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
use libc; use libc;
use num_traits::*; use num_traits::*;
...@@ -154,7 +154,7 @@ fn get_scaled_luma_q0(alpha_q3: i16, ac_pred_q3: i16) -> i32 { ...@@ -154,7 +154,7 @@ fn get_scaled_luma_q0(alpha_q3: i16, ac_pred_q3: i16) -> i32 {
} }
} }
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
macro_rules! decl_angular_ipred_fn { macro_rules! decl_angular_ipred_fn {
($f:ident) => { ($f:ident) => {
extern { extern {
...@@ -166,25 +166,25 @@ macro_rules! decl_angular_ipred_fn { ...@@ -166,25 +166,25 @@ macro_rules! decl_angular_ipred_fn {
}; };
} }
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
decl_angular_ipred_fn!(rav1e_ipred_dc_avx2); decl_angular_ipred_fn!(rav1e_ipred_dc_avx2);
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
decl_angular_ipred_fn!(rav1e_ipred_dc_128_avx2); decl_angular_ipred_fn!(rav1e_ipred_dc_128_avx2);
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
decl_angular_ipred_fn!(rav1e_ipred_dc_left_avx2); decl_angular_ipred_fn!(rav1e_ipred_dc_left_avx2);
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
decl_angular_ipred_fn!(rav1e_ipred_dc_top_avx2); decl_angular_ipred_fn!(rav1e_ipred_dc_top_avx2);
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
decl_angular_ipred_fn!(rav1e_ipred_h_avx2); decl_angular_ipred_fn!(rav1e_ipred_h_avx2);
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
decl_angular_ipred_fn!(rav1e_ipred_v_avx2); decl_angular_ipred_fn!(rav1e_ipred_v_avx2);
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
decl_angular_ipred_fn!(rav1e_ipred_paeth_avx2); decl_angular_ipred_fn!(rav1e_ipred_paeth_avx2);
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
decl_angular_ipred_fn!(rav1e_ipred_smooth_avx2); decl_angular_ipred_fn!(rav1e_ipred_smooth_avx2);
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
decl_angular_ipred_fn!(rav1e_ipred_smooth_h_avx2); decl_angular_ipred_fn!(rav1e_ipred_smooth_h_avx2);
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
decl_angular_ipred_fn!(rav1e_ipred_smooth_v_avx2); decl_angular_ipred_fn!(rav1e_ipred_smooth_v_avx2);
pub trait Intra<T>: Dim pub trait Intra<T>: Dim
...@@ -196,7 +196,7 @@ where ...@@ -196,7 +196,7 @@ where
{ {
#[cfg_attr(feature = "comparative_bench", inline(never))] #[cfg_attr(feature = "comparative_bench", inline(never))]
fn pred_dc(output: &mut [T], stride: usize, above: &[T], left: &[T]) { fn pred_dc(output: &mut [T], stride: usize, above: &[T], left: &[T]) {
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
{ {
if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") { if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") {
return unsafe { return unsafe {
...@@ -225,7 +225,7 @@ where ...@@ -225,7 +225,7 @@ where
#[cfg_attr(feature = "comparative_bench", inline(never))] #[cfg_attr(feature = "comparative_bench", inline(never))]
fn pred_dc_128(output: &mut [T], stride: usize, bit_depth: usize) { fn pred_dc_128(output: &mut [T], stride: usize, bit_depth: usize) {
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
{ {
use std::ptr; use std::ptr;
if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") { if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") {
...@@ -250,7 +250,7 @@ where ...@@ -250,7 +250,7 @@ where
#[cfg_attr(feature = "comparative_bench", inline(never))] #[cfg_attr(feature = "comparative_bench", inline(never))]
fn pred_dc_left(output: &mut [T], stride: usize, _above: &[T], left: &[T]) { fn pred_dc_left(output: &mut [T], stride: usize, _above: &[T], left: &[T]) {
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
{ {
if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") { if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") {
return unsafe { return unsafe {
...@@ -274,7 +274,7 @@ where ...@@ -274,7 +274,7 @@ where
#[cfg_attr(feature = "comparative_bench", inline(never))] #[cfg_attr(feature = "comparative_bench", inline(never))]
fn pred_dc_top(output: &mut [T], stride: usize, above: &[T], _left: &[T]) { fn pred_dc_top(output: &mut [T], stride: usize, above: &[T], _left: &[T]) {
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
{ {
if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") { if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") {
return unsafe { return unsafe {
...@@ -298,7 +298,7 @@ where ...@@ -298,7 +298,7 @@ where
#[cfg_attr(feature = "comparative_bench", inline(never))] #[cfg_attr(feature = "comparative_bench", inline(never))]
fn pred_h(output: &mut [T], stride: usize, left: &[T]) { fn pred_h(output: &mut [T], stride: usize, left: &[T]) {
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
{ {
if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") { if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") {
return unsafe { return unsafe {
...@@ -324,7 +324,7 @@ where ...@@ -324,7 +324,7 @@ where
#[cfg_attr(feature = "comparative_bench", inline(never))] #[cfg_attr(feature = "comparative_bench", inline(never))]
fn pred_v(output: &mut [T], stride: usize, above: &[T]) { fn pred_v(output: &mut [T], stride: usize, above: &[T]) {
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
{ {
if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") { if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") {
return unsafe { return unsafe {
...@@ -349,7 +349,7 @@ where ...@@ -349,7 +349,7 @@ where
output: &mut [T], stride: usize, above: &[T], left: &[T], output: &mut [T], stride: usize, above: &[T], left: &[T],
above_left: T above_left: T
) { ) {
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
{ {
if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") { if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") {
return unsafe { return unsafe {
...@@ -394,7 +394,7 @@ where ...@@ -394,7 +394,7 @@ where
fn pred_smooth( fn pred_smooth(
output: &mut [T], stride: usize, above: &[T], left: &[T] output: &mut [T], stride: usize, above: &[T], left: &[T]
) { ) {
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
{ {
if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") { if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") {
return unsafe { return unsafe {
...@@ -459,7 +459,7 @@ where ...@@ -459,7 +459,7 @@ where
fn pred_smooth_h( fn pred_smooth_h(
output: &mut [T], stride: usize, above: &[T], left: &[T] output: &mut [T], stride: usize, above: &[T], left: &[T]
) { ) {
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
{ {
if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") { if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") {
return unsafe { return unsafe {
...@@ -510,7 +510,7 @@ where ...@@ -510,7 +510,7 @@ where
fn pred_smooth_v( fn pred_smooth_v(
output: &mut [T], stride: usize, above: &[T], left: &[T] output: &mut [T], stride: usize, above: &[T], left: &[T]
) { ) {
#[cfg(all(target_arch = "x86_64", not(windows)))] #[cfg(all(target_arch = "x86_64", not(windows), feature = "nasm"))]
{ {
if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") { if size_of::<T>() == 1 && is_x86_feature_detected!("avx2") {
return unsafe { return unsafe {
......
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