CMakelists changes to use cmake APPLE variable, change uint to unsigned int in idct.c

pull/5/head
Mark Jessop 2019-04-23 10:14:39 +09:30
parent aed7d02fbf
commit 12a67e9bf2
2 changed files with 12 additions and 21 deletions

View File

@ -28,19 +28,8 @@ endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
# Set default flags
set(CMAKE_C_FLAGS "-Wall -W -Wextra -Wno-unused-function -O3 -g -I. -MD ${CMAKE_C_FLAGS}")
# Check for OSX
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
endif()
if(MACOSX)
message(STATUS "Looking for available CPU optimizations on an OSX system...")
execute_process(COMMAND sysctl -a COMMAND grep machdep.cpu.leaf7_features COMMAND grep -c AVX2
OUTPUT_VARIABLE AVX2)
execute_process(COMMAND sysctl -a COMMAND grep machdep.cpu.features COMMAND grep -c AVX
OUTPUT_VARIABLE AVX)
elseif(UNIX)
# Detection of available CPU optimizations
if(UNIX AND NOT APPLE)
message(STATUS "Looking for available CPU optimizations on Linux/BSD system...")
execute_process(COMMAND grep -c "avx2" /proc/cpuinfo
OUTPUT_VARIABLE AVX2)
@ -48,6 +37,13 @@ elseif(UNIX)
OUTPUT_VARIABLE AVX)
execute_process(COMMAND grep -c "neon" /proc/cpuinfo
OUTPUT_VARIABLE NEON)
elseif(APPLE)
# Under OSX we need to look through a few sysctl entries to determine what our CPU supports.
message(STATUS "Looking for available CPU optimizations on an OSX system...")
execute_process(COMMAND sysctl -a COMMAND grep machdep.cpu.leaf7_features COMMAND grep -c AVX2
OUTPUT_VARIABLE AVX2)
execute_process(COMMAND sysctl -a COMMAND grep machdep.cpu.features COMMAND grep -c AVX
OUTPUT_VARIABLE AVX)
else()
message(STATUS "System is not *nix, processor specific optimizations cannot be determined.")
message(" You can try setting them manually, e.g.: -DAVX2=1 or -DAVX=1 or -DNEON=1")

View File

@ -15,11 +15,6 @@
#include "freq.h"
#include "lpcnet_quant.h"
#ifdef __APPLE__
#include <sys/types.h>
#define uint u_int
#endif
#define NB_BANDS 18
/* meaured using -m option, then pasted in here */
@ -33,8 +28,8 @@ float std[] = {
int main(int argc, char *argv[]) {
FILE *fin, *fout;
fin = stdin; fout = stdout;
uint ret;
uint stride = NB_BANDS;
unsigned int ret;
unsigned int stride = NB_BANDS;
int measure = 0;
int scaling = 0;
@ -68,7 +63,7 @@ int main(int argc, char *argv[]) {
float sum[NB_BANDS] = {0.0};
float sumsq[NB_BANDS] = {0.0};
float dctLy[stride], Ly[stride];
uint i; for(i=0; i<stride; i++) Ly[stride] = 0.0;
unsigned int i; for(i=0; i<stride; i++) Ly[stride] = 0.0;
long n = 0;
while(fread(dctLy, sizeof(float), stride, fin) == stride) {
idct(Ly, dctLy);