Add makefile and fix warnings

This commit is contained in:
Alex Barney
2018-01-12 16:07:54 -06:00
parent 520109fffe
commit 54b469e488
14 changed files with 1353 additions and 1291 deletions

2
.gitignore vendored
View File

@@ -20,6 +20,8 @@ x86/
bld/
[Bb]in/
[Oo]bj/
[Oo]bj_shared/
[Oo]bj_static/
[Ll]og/
# Visual Studio 2015 cache/options directory

58
C/Makefile Normal file
View File

@@ -0,0 +1,58 @@
NAME = libatrac9
CC = gcc
AR = ar
SFLAGS = -O2
CFLAGS = -Wall -Wextra -std=c99
LFLAGS =
SHARED_SFLAGS = $(SFLAGS) -flto
SHARED_CFLAGS = $(CFLAGS) -fPIC
SHARED_LFLAGS = $(LFLAGS) -shared
SRCDIR = src
OBJDIR = obj
BINDIR = bin
STATIC_OBJDIR = $(OBJDIR)_static
SHARED_OBJDIR = $(OBJDIR)_shared
SRCS = $(wildcard $(SRCDIR)/*.c)
STATIC_OBJS = $(SRCS:$(SRCDIR)/%.c=$(STATIC_OBJDIR)/%.o)
SHARED_OBJS = $(SRCS:$(SRCDIR)/%.c=$(SHARED_OBJDIR)/%.o)
STATIC_NAME = $(BINDIR)/$(NAME).a
SHARED_NAME = $(BINDIR)/$(NAME).so
MKDIR = mkdir -p
RM = rm -f
RMDIR = rm -df
all: static shared
static: create_static_dir create_bin_dir $(STATIC_NAME)
shared: create_shared_dir create_bin_dir $(SHARED_NAME)
create_static_dir:
@$(MKDIR) $(STATIC_OBJDIR)
create_shared_dir:
@$(MKDIR) $(SHARED_OBJDIR)
create_bin_dir:
@$(MKDIR) $(BINDIR)
$(SHARED_NAME): $(SHARED_OBJS)
$(CC) $(SHARED_OBJS) $(SHARED_SFLAGS) $(SHARED_LFLAGS) -o $@
$(SHARED_OBJS): $(SHARED_OBJDIR)/%.o : $(SRCDIR)/%.c
$(CC) $(SHARED_SFLAGS) $(SHARED_CFLAGS) -c $< -o $@
$(STATIC_NAME): $(STATIC_OBJS)
$(AR) rcs $@ $^
$(STATIC_OBJS): $(STATIC_OBJDIR)/%.o : $(SRCDIR)/%.c
$(CC) $(SFLAGS) $(CFLAGS) -c $< -o $@
clean:
$(RM) $(SHARED_OBJS) $(SHARED_NAME) $(STATIC_OBJS) $(STATIC_NAME)
-@$(RMDIR) $(STATIC_OBJDIR) $(SHARED_OBJDIR) $(BINDIR) 2>/dev/null || true
.PHONY: all static shared create_static_dir create_shared_dir create_bin_dir clean

View File

@@ -10,4 +10,4 @@ void FillHighFrequencies(double* spectra, int groupABin, int groupBBin, int grou
void AddNoiseToSpectrum(channel* channel, int index, int count);
void rng_init(rng_cxt* rng, unsigned short seed);
unsigned short rng_next(rng_cxt* rng);
unsigned short rng_next(rng_cxt* rng);

View File

@@ -10,4 +10,4 @@ int peek_int(bit_reader_cxt* br, const int bits);
int read_int(bit_reader_cxt* br, const int bits);
int read_signed_int(bit_reader_cxt* br, const int bits);
int read_offset_binary(bit_reader_cxt* br, const int bits);
void align_position(bit_reader_cxt* br, const unsigned int multiple);
void align_position(bit_reader_cxt* br, const unsigned int multiple);

View File

@@ -102,7 +102,7 @@ void init_huffman_codebooks()
{
init_huffman_set(HuffmanScaleFactorsUnsigned, sizeof(HuffmanScaleFactorsUnsigned) / sizeof(HuffmanCodebook));
init_huffman_set(HuffmanScaleFactorsSigned, sizeof(HuffmanScaleFactorsSigned) / sizeof(HuffmanCodebook));
init_huffman_set(HuffmanSpectrum, sizeof(HuffmanSpectrum) / sizeof(HuffmanCodebook));
init_huffman_set((HuffmanCodebook*)HuffmanSpectrum, sizeof(HuffmanSpectrum) / sizeof(HuffmanCodebook));
}
void init_huffman_set(const HuffmanCodebook* codebooks, int count)

View File

@@ -30,4 +30,4 @@ typedef enum at9_status
if (status != ERR_SUCCESS) { \
return status; \
} \
} while (0)
} while (0)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -3,4 +3,4 @@
#include "structures.h"
void RunImdct(mdct* mdct, double* input, double* output);
void Dct4(mdct* mdct, double* input, double* output);
void Dct4(mdct* mdct, double* input, double* output);

View File

@@ -3,11 +3,15 @@
extern "C" {
#endif
#ifdef _MSC_VER
#ifdef COMPILING_DLL
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __declspec(dllimport)
#endif
#else
#define DLLEXPORT
#endif
#define ATRAC9_CONFIG_DATA_SIZE 4

View File

@@ -5,4 +5,4 @@
void DequantizeSpectra(block* block);
void DequantizeQuantUnit(channel* channel, int band);
void ScaleSpectrumBlock(block* block);
void ScaleSpectrumChannel(channel* channel);
void ScaleSpectrumChannel(channel* channel);

View File

@@ -4,12 +4,12 @@
static const ChannelConfig ChannelConfigs[6] =
{
{1, 1, Mono},
{2, 2, Mono, Mono},
{1, 2, Stereo},
{4, 6, Stereo, Mono, LFE, Stereo},
{5, 8, Stereo, Mono, LFE, Stereo, Stereo},
{2, 4, Stereo, Stereo},
{1, 1, {Mono}},
{2, 2, {Mono, Mono}},
{1, 2, {Stereo}},
{4, 6, {Stereo, Mono, LFE, Stereo}},
{5, 8, {Stereo, Mono, LFE, Stereo, Stereo}},
{2, 4, {Stereo, Stereo}},
};
static const int MaxHuffPrecision[2] = { 7, 1 };

View File

@@ -36,7 +36,6 @@ at9_status UnpackBlock(block* block, bit_reader_cxt* br)
at9_status ReadBlockHeader(block* block, bit_reader_cxt* br)
{
int firstInSuperframe = block->Frame->FrameIndex == 0;
block->FirstInSuperframe = !read_int(br, 1);
block->ReuseBandParams = read_int(br, 1);

View File

@@ -2,7 +2,6 @@
#define FALSE 0
#define TRUE 1
#define NULL 0
#ifndef M_PI
#define M_PI 3.14159265358979323846