Update tremor/remove some unneeded switches

This commit is contained in:
libretroadmin 2022-05-30 01:36:53 +02:00
parent 5e840af3be
commit cfe250957d
50 changed files with 863 additions and 2635 deletions

View File

@ -1,8 +1,5 @@
DEBUG = 0
FRONTEND_SUPPORTS_RGB565 = 1
HAVE_RUST = 0
HAVE_OPENGL = 0
HAVE_JIT = 0
HAVE_CHD = 1
HAVE_CDROM = 0
@ -48,7 +45,7 @@ NEED_TREMOR = 1
NEED_BPP = 32
NEED_DEINTERLACER = 1
NEED_THREADING = 1
CORE_DEFINE := -DWANT_SS_EMU
CORE_DEFINE :=
TARGET_NAME := mednafen_saturn
ifeq ($(HAVE_OPENGL),1)
@ -451,16 +448,7 @@ LDFLAGS += $(fpic) $(SHARED)
FLAGS += $(fpic) $(NEW_GCC_FLAGS)
FLAGS += $(INCFLAGS)
FLAGS += $(ENDIANNESS_DEFINES) $(WARNINGS) -DPACKAGE=\"mednafen\" -DMPC_FIXED_POINT $(CORE_DEFINE) -DSTDC_HEADERS -D__STDC_LIMIT_MACROS -D__LIBRETRO__ -D_LOW_ACCURACY_ $(EXTRA_INCLUDES) $(SOUND_DEFINE) -D__STDC_CONSTANT_MACROS
ifeq ($(HAVE_RUST),1)
FLAGS += -DHAVE_RUST
LDFLAGS += -ldl -L. -lrsx
endif
ifeq ($(HAVE_JIT),1)
LDFLAGS += -ljit
endif
FLAGS += $(ENDIANNESS_DEFINES) $(WARNINGS) -DPACKAGE=\"mednafen\" $(CORE_DEFINE) -DSTDC_HEADERS -D__STDC_LIMIT_MACROS -D__LIBRETRO__ -D_LOW_ACCURACY_ $(EXTRA_INCLUDES) $(SOUND_DEFINE) -D__STDC_CONSTANT_MACROS
CXXFLAGS += $(FLAGS)
CFLAGS += $(FLAGS)

View File

@ -10,7 +10,6 @@ CDROM_DIR := $(MEDNAFEN_DIR)/cdrom
ZLIB_INCFLAGS := -I$(DEPS_DIR)/zlib
INCFLAGS := -I$(CORE_DIR) -I$(MEDNAFEN_DIR) -I$(MEDNAFEN_DIR)/include -I$(MEDNAFEN_DIR)/intl -I$(MEDNAFEN_DIR)/hw_sound -I$(MEDNAFEN_DIR)/hw_cpu -I$(MEDNAFEN_DIR)/hw_misc -I$(LIBRETRO_COMM_DIR)/include
ZLIB_SOURCES_C := $(DEPS_DIR)/zlib/adler32.c \
$(DEPS_DIR)/zlib/crc32.c \
$(DEPS_DIR)/zlib/inffast.c \
@ -25,30 +24,14 @@ ifeq ($(NEED_DEINTERLACER), 1)
FLAGS += -DNEED_DEINTERLACER
endif
ifeq ($(NEED_BPP), 8)
FLAGS += -DWANT_8BPP
endif
ifeq ($(NEED_BPP), 16)
FLAGS += -DWANT_16BPP
endif
ifeq ($(NEED_BPP), 32)
FLAGS += -DWANT_32BPP
endif
ifeq ($(WANT_NEW_API), 1)
FLAGS += -DWANT_NEW_API
endif
ifeq ($(NO_COMPUTED_GOTO), 1)
FLAGS += -DNO_COMPUTED_GOTO
endif
ifeq ($(FRONTEND_SUPPORTS_RGB565), 1)
FLAGS += -DFRONTEND_SUPPORTS_RGB565
endif
ifeq ($(NEED_CD), 1)
FLAGS += -DNEED_CD
endif
@ -124,7 +107,6 @@ SOURCES_CXX += $(CDROM_DIR)/CDAccess.cpp \
$(CDROM_DIR)/recover-raw.cpp \
$(CDROM_DIR)/l-ec.cpp \
$(CDROM_DIR)/edc_crc32.cpp
FLAGS += -DNEED_CD
ifeq ($(HAVE_CHD), 1)
ifneq ($(SYSTEM_LIBCHDR), 1)

View File

@ -3,7 +3,6 @@ LOCAL_PATH := $(call my-dir)
CORE_DIR := $(LOCAL_PATH)/..
DEBUG := 0
FRONTEND_SUPPORTS_RGB565 := 1
NEED_CD := 1
NEED_BPP := 32
NEED_DEINTERLACER := 1

View File

@ -1,8 +0,0 @@
tremor git 7c30a66346199f3f09017a09567c6c8a3a0eedc8
libogg 1.3.2
With modifications like:
perl -p -i -e "s/<ogg\/ogg.h>/\"ogg.h\"/g" ./* && perl -p -i -e "s/<ogg\/os_types.h>/\"os_types.h\"/g" ./*
Jan 20, 2013:
Mednafen-specific modifications to os_types.h, os.h, and misc.h - config_types.h was removed.

View File

@ -1,13 +0,0 @@
noinst_LIBRARIES += libvorbisidec.a
libvorbisidec_a_CFLAGS = @AM_CFLAGS@ @CFLAG_VISIBILITY@ -Wno-shadow -Wno-unused
libvorbisidec_a_CPPFLAGS= -I$(srcdir)/tremor
libvorbisidec_a_SOURCES = tremor/mdct.c tremor/block.c tremor/window.c \
tremor/synthesis.c tremor/info.c \
tremor/floor1.c tremor/floor0.c tremor/vorbisfile.c \
tremor/res012.c tremor/mapping0.c tremor/registry.c tremor/codebook.c \
tremor/sharedbook.c tremor/framing.c tremor/bitwise.c
mednafen_LDADD += libvorbisidec.a
mednafen_DEPENDENCIES += libvorbisidec.a

46
mednafen/tremor/README Normal file
View File

@ -0,0 +1,46 @@
This README covers the Ogg Vorbis 'Tremor' integer playback codec
source as of date 2002 09 02, version 1.0.0.
******
The C source in this package will build on any ANSI C compiler and
function completely and properly on any platform. The included build
system assumes GNU build system and make tools (m4, automake,
autoconf, libtool and gmake). GCC is not required, although GCC is
the most tested compiler. To build using GNU tools, type in the
source directory:
./autogen.sh
make
Currently, the source implements playback in pure C on all platforms
except ARM, where a [currently] small amount of assembly (see
asm_arm.h) is used to implement 64 bit math operations and fast LSP
computation. If building on ARM without the benefit of GNU build
system tools, be sure that '_ARM_ASSEM_' is #defined by the build
system if this assembly is desired, else the resulting library will
use whatever 64 bit math builtins the compiler implements.
No math library is required by this source. No floating point
operations are used at any point in either setup or decode. This
decoder library will properly decode any past, current or future
Vorbis I file or stream.
********
The build system produces a static and [when supported by the OS]
dynamic library named 'libvorbisidec'. This library exposes an API
nearly identical to the BSD reference library's 'libvorbisfile',
including all the features familiar to users of vorbisfile. This API
is similar enough that the proper header file to include is named
'ivorbisfile.h' [included in the source build directory]. Lower level
libvorbis-style headers and structures are in 'ivorbiscodec.h'
[included in the source build directory]. A simple example program,
ivorbisfile_example.c, can be built with 'make example'.
********
Detailed Tremor API Documentation begins at doc/index.html
Monty
xiph.org

View File

@ -20,7 +20,7 @@
#if !defined(_V_WIDE_MATH) && !defined(_LOW_ACCURACY_)
#define _V_WIDE_MATH
static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
static inline int32_t MULT32(int32_t x, int32_t y) {
int lo,hi;
asm volatile("smull\t%0, %1, %2, %3"
: "=&r"(lo),"=&r"(hi)
@ -29,11 +29,11 @@ static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
return(hi);
}
static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
static inline int32_t MULT31(int32_t x, int32_t y) {
return MULT32(x,y)<<1;
}
static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
static inline int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
int lo,hi;
asm volatile("smull %0, %1, %2, %3\n\t"
"movs %0, %0, lsr #15\n\t"
@ -46,9 +46,9 @@ static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
#define MB() asm volatile ("" : : : "memory")
static inline void XPROD32(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
static inline void XPROD32(int32_t a, int32_t b,
int32_t t, int32_t v,
int32_t *x, int32_t *y)
{
int x1, y1, l;
asm( "smull %0, %1, %4, %6\n\t"
@ -64,9 +64,9 @@ static inline void XPROD32(ogg_int32_t a, ogg_int32_t b,
*y = y1;
}
static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
static inline void XPROD31(int32_t a, int32_t b,
int32_t t, int32_t v,
int32_t *x, int32_t *y)
{
int x1, y1, l;
asm( "smull %0, %1, %4, %6\n\t"
@ -82,9 +82,9 @@ static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
*y = y1 << 1;
}
static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
static inline void XNPROD31(int32_t a, int32_t b,
int32_t t, int32_t v,
int32_t *x, int32_t *y)
{
int x1, y1, l;
asm( "rsb %2, %4, #0\n\t"
@ -105,7 +105,7 @@ static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
#ifndef _V_CLIP_MATH
#define _V_CLIP_MATH
static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
static inline int32_t CLIP_TO_15(int32_t x) {
int tmp;
asm volatile("subs %1, %0, #32768\n\t"
"movpl %0, #0x7f00\n\t"
@ -123,13 +123,13 @@ static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
#ifndef _V_LSP_MATH_ASM
#define _V_LSP_MATH_ASM
static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
ogg_int32_t *qexpp,
ogg_int32_t *ilsp,ogg_int32_t wi,
ogg_int32_t m){
static inline void lsp_loop_asm(uint32_t *qip,uint32_t *pip,
int32_t *qexpp,
int32_t *ilsp,int32_t wi,
int32_t m){
ogg_uint32_t qi=*qip,pi=*pip;
ogg_int32_t qexp=*qexpp;
uint32_t qi=*qip,pi=*pip;
int32_t qexp=*qexpp;
asm("mov r0,%3;"
"movs r1,%5,asr#1;"
@ -216,10 +216,10 @@ static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
*qexpp=qexp;
}
static inline void lsp_norm_asm(ogg_uint32_t *qip,ogg_int32_t *qexpp){
static inline void lsp_norm_asm(uint32_t *qip,int32_t *qexpp){
ogg_uint32_t qi=*qip;
ogg_int32_t qexp=*qexpp;
uint32_t qi=*qip;
int32_t qexp=*qexpp;
asm("tst %0,#0x0000ff00;"
"moveq %0,%0,lsl #8;"

View File

@ -39,7 +39,7 @@ typedef struct{
void (*free_look) (vorbis_look_floor *);
void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *);
int (*inverse2) (struct vorbis_block *,vorbis_look_floor *,
void *buffer,ogg_int32_t *);
void *buffer,int32_t *);
} vorbis_func_floor;
typedef struct{
@ -81,7 +81,7 @@ typedef struct{
void (*free_info) (vorbis_info_residue *);
void (*free_look) (vorbis_look_residue *);
int (*inverse) (struct vorbis_block *,vorbis_look_residue *,
ogg_int32_t **,int *,int);
int32_t **,int *,int);
} vorbis_func_residue;
typedef struct vorbis_info_residue0{

View File

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2014 *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: packing variable sized words into an octet stream
last mod: $Id: bitwise.c 19149 2014-05-27 16:26:23Z giles $
last mod: $Id: bitwise.c 18051 2011-08-04 17:56:39Z giles $
********************************************************************/
@ -39,7 +39,7 @@ static const unsigned int mask8B[]=
void oggpack_writeinit(oggpack_buffer *b){
memset(b,0,sizeof(*b));
b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT);
b->ptr=b->buffer=malloc(BUFFER_INCREMENT);
b->buffer[0]='\0';
b->storage=BUFFER_INCREMENT;
}
@ -86,7 +86,7 @@ void oggpack_write(oggpack_buffer *b,unsigned long value,int bits){
void *ret;
if(!b->ptr)return;
if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err;
ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
ret=realloc(b->buffer,b->storage+BUFFER_INCREMENT);
if(!ret) goto err;
b->buffer=ret;
b->storage+=BUFFER_INCREMENT;
@ -129,7 +129,7 @@ void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits){
void *ret;
if(!b->ptr)return;
if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err;
ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
ret=realloc(b->buffer,b->storage+BUFFER_INCREMENT);
if(!ret) goto err;
b->buffer=ret;
b->storage+=BUFFER_INCREMENT;
@ -187,22 +187,8 @@ static void oggpack_writecopy_helper(oggpack_buffer *b,
unsigned char *ptr=(unsigned char *)source;
long bytes=bits/8;
long pbytes=(b->endbit+bits)/8;
bits-=bytes*8;
/* expand storage up-front */
if(b->endbyte+pbytes>=b->storage){
void *ret;
if(!b->ptr) goto err;
if(b->storage>b->endbyte+pbytes+BUFFER_INCREMENT) goto err;
b->storage=b->endbyte+pbytes+BUFFER_INCREMENT;
ret=_ogg_realloc(b->buffer,b->storage);
if(!ret) goto err;
b->buffer=ret;
b->ptr=b->buffer+b->endbyte;
}
/* copy whole octets */
if(b->endbit){
int i;
/* unaligned copy. Do it the hard way. */
@ -210,13 +196,23 @@ static void oggpack_writecopy_helper(oggpack_buffer *b,
w(b,(unsigned long)(ptr[i]),8);
}else{
/* aligned block copy */
if(b->endbyte+bytes+1>=b->storage){
void *ret;
if(!b->ptr) goto err;
if(b->endbyte+bytes+BUFFER_INCREMENT>b->storage) goto err;
b->storage=b->endbyte+bytes+BUFFER_INCREMENT;
ret=realloc(b->buffer,b->storage);
if(!ret) goto err;
b->buffer=ret;
b->ptr=b->buffer+b->endbyte;
}
memmove(b->ptr,source,bytes);
b->ptr+=bytes;
b->endbyte+=bytes;
*b->ptr=0;
}
/* copy trailing bits */
}
if(bits){
if(msb)
w(b,(unsigned long)(ptr[bytes]>>(8-bits)),bits);
@ -248,7 +244,8 @@ void oggpackB_reset(oggpack_buffer *b){
}
void oggpack_writeclear(oggpack_buffer *b){
if(b->buffer)_ogg_free(b->buffer);
if(b->buffer)
free(b->buffer);
memset(b,0,sizeof(*b));
}
@ -524,565 +521,4 @@ unsigned char *oggpackB_get_buffer(oggpack_buffer *b){
return oggpack_get_buffer(b);
}
/* Self test of the bitwise routines; everything else is based on
them, so they damned well better be solid. */
#ifdef _V_SELFTEST
#include <stdio.h>
static int ilog(unsigned int v){
int ret=0;
while(v){
ret++;
v>>=1;
}
return(ret);
}
oggpack_buffer o;
oggpack_buffer r;
void report(char *in){
fprintf(stderr,"%s",in);
exit(1);
}
void cliptest(unsigned long *b,int vals,int bits,int *comp,int compsize){
long bytes,i;
unsigned char *buffer;
oggpack_reset(&o);
for(i=0;i<vals;i++)
oggpack_write(&o,b[i],bits?bits:ilog(b[i]));
buffer=oggpack_get_buffer(&o);
bytes=oggpack_bytes(&o);
if(bytes!=compsize)report("wrong number of bytes!\n");
for(i=0;i<bytes;i++)if(buffer[i]!=comp[i]){
for(i=0;i<bytes;i++)fprintf(stderr,"%x %x\n",(int)buffer[i],(int)comp[i]);
report("wrote incorrect value!\n");
}
oggpack_readinit(&r,buffer,bytes);
for(i=0;i<vals;i++){
int tbit=bits?bits:ilog(b[i]);
if(oggpack_look(&r,tbit)==-1)
report("out of data!\n");
if(oggpack_look(&r,tbit)!=(b[i]&mask[tbit]))
report("looked at incorrect value!\n");
if(tbit==1)
if(oggpack_look1(&r)!=(b[i]&mask[tbit]))
report("looked at single bit incorrect value!\n");
if(tbit==1){
if(oggpack_read1(&r)!=(b[i]&mask[tbit]))
report("read incorrect single bit value!\n");
}else{
if(oggpack_read(&r,tbit)!=(b[i]&mask[tbit]))
report("read incorrect value!\n");
}
}
if(oggpack_bytes(&r)!=bytes)report("leftover bytes after read!\n");
}
void cliptestB(unsigned long *b,int vals,int bits,int *comp,int compsize){
long bytes,i;
unsigned char *buffer;
oggpackB_reset(&o);
for(i=0;i<vals;i++)
oggpackB_write(&o,b[i],bits?bits:ilog(b[i]));
buffer=oggpackB_get_buffer(&o);
bytes=oggpackB_bytes(&o);
if(bytes!=compsize)report("wrong number of bytes!\n");
for(i=0;i<bytes;i++)if(buffer[i]!=comp[i]){
for(i=0;i<bytes;i++)fprintf(stderr,"%x %x\n",(int)buffer[i],(int)comp[i]);
report("wrote incorrect value!\n");
}
oggpackB_readinit(&r,buffer,bytes);
for(i=0;i<vals;i++){
int tbit=bits?bits:ilog(b[i]);
if(oggpackB_look(&r,tbit)==-1)
report("out of data!\n");
if(oggpackB_look(&r,tbit)!=(b[i]&mask[tbit]))
report("looked at incorrect value!\n");
if(tbit==1)
if(oggpackB_look1(&r)!=(b[i]&mask[tbit]))
report("looked at single bit incorrect value!\n");
if(tbit==1){
if(oggpackB_read1(&r)!=(b[i]&mask[tbit]))
report("read incorrect single bit value!\n");
}else{
if(oggpackB_read(&r,tbit)!=(b[i]&mask[tbit]))
report("read incorrect value!\n");
}
}
if(oggpackB_bytes(&r)!=bytes)report("leftover bytes after read!\n");
}
void copytest(int prefill, int copy){
oggpack_buffer source_write;
oggpack_buffer dest_write;
oggpack_buffer source_read;
oggpack_buffer dest_read;
unsigned char *source;
unsigned char *dest;
long source_bytes,dest_bytes;
int i;
oggpack_writeinit(&source_write);
oggpack_writeinit(&dest_write);
for(i=0;i<(prefill+copy+7)/8;i++)
oggpack_write(&source_write,(i^0x5a)&0xff,8);
source=oggpack_get_buffer(&source_write);
source_bytes=oggpack_bytes(&source_write);
/* prefill */
oggpack_writecopy(&dest_write,source,prefill);
/* check buffers; verify end byte masking */
dest=oggpack_get_buffer(&dest_write);
dest_bytes=oggpack_bytes(&dest_write);
if(dest_bytes!=(prefill+7)/8){
fprintf(stderr,"wrong number of bytes after prefill! %ld!=%d\n",dest_bytes,(prefill+7)/8);
exit(1);
}
oggpack_readinit(&source_read,source,source_bytes);
oggpack_readinit(&dest_read,dest,dest_bytes);
for(i=0;i<prefill;i+=8){
int s=oggpack_read(&source_read,prefill-i<8?prefill-i:8);
int d=oggpack_read(&dest_read,prefill-i<8?prefill-i:8);
if(s!=d){
fprintf(stderr,"prefill=%d mismatch! byte %d, %x!=%x\n",prefill,i/8,s,d);
exit(1);
}
}
if(prefill<dest_bytes){
if(oggpack_read(&dest_read,dest_bytes-prefill)!=0){
fprintf(stderr,"prefill=%d mismatch! trailing bits not zero\n",prefill);
exit(1);
}
}
/* second copy */
oggpack_writecopy(&dest_write,source,copy);
/* check buffers; verify end byte masking */
dest=oggpack_get_buffer(&dest_write);
dest_bytes=oggpack_bytes(&dest_write);
if(dest_bytes!=(copy+prefill+7)/8){
fprintf(stderr,"wrong number of bytes after prefill+copy! %ld!=%d\n",dest_bytes,(copy+prefill+7)/8);
exit(1);
}
oggpack_readinit(&source_read,source,source_bytes);
oggpack_readinit(&dest_read,dest,dest_bytes);
for(i=0;i<prefill;i+=8){
int s=oggpack_read(&source_read,prefill-i<8?prefill-i:8);
int d=oggpack_read(&dest_read,prefill-i<8?prefill-i:8);
if(s!=d){
fprintf(stderr,"prefill=%d mismatch! byte %d, %x!=%x\n",prefill,i/8,s,d);
exit(1);
}
}
oggpack_readinit(&source_read,source,source_bytes);
for(i=0;i<copy;i+=8){
int s=oggpack_read(&source_read,copy-i<8?copy-i:8);
int d=oggpack_read(&dest_read,copy-i<8?copy-i:8);
if(s!=d){
fprintf(stderr,"prefill=%d copy=%d mismatch! byte %d, %x!=%x\n",prefill,copy,i/8,s,d);
exit(1);
}
}
if(copy+prefill<dest_bytes){
if(oggpack_read(&dest_read,dest_bytes-copy-prefill)!=0){
fprintf(stderr,"prefill=%d copy=%d mismatch! trailing bits not zero\n",prefill,copy);
exit(1);
}
}
oggpack_writeclear(&source_write);
oggpack_writeclear(&dest_write);
}
void copytestB(int prefill, int copy){
oggpack_buffer source_write;
oggpack_buffer dest_write;
oggpack_buffer source_read;
oggpack_buffer dest_read;
unsigned char *source;
unsigned char *dest;
long source_bytes,dest_bytes;
int i;
oggpackB_writeinit(&source_write);
oggpackB_writeinit(&dest_write);
for(i=0;i<(prefill+copy+7)/8;i++)
oggpackB_write(&source_write,(i^0x5a)&0xff,8);
source=oggpackB_get_buffer(&source_write);
source_bytes=oggpackB_bytes(&source_write);
/* prefill */
oggpackB_writecopy(&dest_write,source,prefill);
/* check buffers; verify end byte masking */
dest=oggpackB_get_buffer(&dest_write);
dest_bytes=oggpackB_bytes(&dest_write);
if(dest_bytes!=(prefill+7)/8){
fprintf(stderr,"wrong number of bytes after prefill! %ld!=%d\n",dest_bytes,(prefill+7)/8);
exit(1);
}
oggpackB_readinit(&source_read,source,source_bytes);
oggpackB_readinit(&dest_read,dest,dest_bytes);
for(i=0;i<prefill;i+=8){
int s=oggpackB_read(&source_read,prefill-i<8?prefill-i:8);
int d=oggpackB_read(&dest_read,prefill-i<8?prefill-i:8);
if(s!=d){
fprintf(stderr,"prefill=%d mismatch! byte %d, %x!=%x\n",prefill,i/8,s,d);
exit(1);
}
}
if(prefill<dest_bytes){
if(oggpackB_read(&dest_read,dest_bytes-prefill)!=0){
fprintf(stderr,"prefill=%d mismatch! trailing bits not zero\n",prefill);
exit(1);
}
}
/* second copy */
oggpackB_writecopy(&dest_write,source,copy);
/* check buffers; verify end byte masking */
dest=oggpackB_get_buffer(&dest_write);
dest_bytes=oggpackB_bytes(&dest_write);
if(dest_bytes!=(copy+prefill+7)/8){
fprintf(stderr,"wrong number of bytes after prefill+copy! %ld!=%d\n",dest_bytes,(copy+prefill+7)/8);
exit(1);
}
oggpackB_readinit(&source_read,source,source_bytes);
oggpackB_readinit(&dest_read,dest,dest_bytes);
for(i=0;i<prefill;i+=8){
int s=oggpackB_read(&source_read,prefill-i<8?prefill-i:8);
int d=oggpackB_read(&dest_read,prefill-i<8?prefill-i:8);
if(s!=d){
fprintf(stderr,"prefill=%d mismatch! byte %d, %x!=%x\n",prefill,i/8,s,d);
exit(1);
}
}
oggpackB_readinit(&source_read,source,source_bytes);
for(i=0;i<copy;i+=8){
int s=oggpackB_read(&source_read,copy-i<8?copy-i:8);
int d=oggpackB_read(&dest_read,copy-i<8?copy-i:8);
if(s!=d){
fprintf(stderr,"prefill=%d copy=%d mismatch! byte %d, %x!=%x\n",prefill,copy,i/8,s,d);
exit(1);
}
}
if(copy+prefill<dest_bytes){
if(oggpackB_read(&dest_read,dest_bytes-copy-prefill)!=0){
fprintf(stderr,"prefill=%d copy=%d mismatch! trailing bits not zero\n",prefill,copy);
exit(1);
}
}
oggpackB_writeclear(&source_write);
oggpackB_writeclear(&dest_write);
}
int main(void){
unsigned char *buffer;
long bytes,i,j;
static unsigned long testbuffer1[]=
{18,12,103948,4325,543,76,432,52,3,65,4,56,32,42,34,21,1,23,32,546,456,7,
567,56,8,8,55,3,52,342,341,4,265,7,67,86,2199,21,7,1,5,1,4};
int test1size=43;
static unsigned long testbuffer2[]=
{216531625L,1237861823,56732452,131,3212421,12325343,34547562,12313212,
1233432,534,5,346435231,14436467,7869299,76326614,167548585,
85525151,0,12321,1,349528352};
int test2size=21;
static unsigned long testbuffer3[]=
{1,0,14,0,1,0,12,0,1,0,0,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,1,1,1,1,0,0,1,
0,1,30,1,1,1,0,0,1,0,0,0,12,0,11,0,1,0,0,1};
int test3size=56;
static unsigned long large[]=
{2136531625L,2137861823,56732452,131,3212421,12325343,34547562,12313212,
1233432,534,5,2146435231,14436467,7869299,76326614,167548585,
85525151,0,12321,1,2146528352};
int onesize=33;
static int one[33]={146,25,44,151,195,15,153,176,233,131,196,65,85,172,47,40,
34,242,223,136,35,222,211,86,171,50,225,135,214,75,172,
223,4};
static int oneB[33]={150,101,131,33,203,15,204,216,105,193,156,65,84,85,222,
8,139,145,227,126,34,55,244,171,85,100,39,195,173,18,
245,251,128};
int twosize=6;
static int two[6]={61,255,255,251,231,29};
static int twoB[6]={247,63,255,253,249,120};
int threesize=54;
static int three[54]={169,2,232,252,91,132,156,36,89,13,123,176,144,32,254,
142,224,85,59,121,144,79,124,23,67,90,90,216,79,23,83,
58,135,196,61,55,129,183,54,101,100,170,37,127,126,10,
100,52,4,14,18,86,77,1};
static int threeB[54]={206,128,42,153,57,8,183,251,13,89,36,30,32,144,183,
130,59,240,121,59,85,223,19,228,180,134,33,107,74,98,
233,253,196,135,63,2,110,114,50,155,90,127,37,170,104,
200,20,254,4,58,106,176,144,0};
int foursize=38;
static int four[38]={18,6,163,252,97,194,104,131,32,1,7,82,137,42,129,11,72,
132,60,220,112,8,196,109,64,179,86,9,137,195,208,122,169,
28,2,133,0,1};
static int fourB[38]={36,48,102,83,243,24,52,7,4,35,132,10,145,21,2,93,2,41,
1,219,184,16,33,184,54,149,170,132,18,30,29,98,229,67,
129,10,4,32};
int fivesize=45;
static int five[45]={169,2,126,139,144,172,30,4,80,72,240,59,130,218,73,62,
241,24,210,44,4,20,0,248,116,49,135,100,110,130,181,169,
84,75,159,2,1,0,132,192,8,0,0,18,22};
static int fiveB[45]={1,84,145,111,245,100,128,8,56,36,40,71,126,78,213,226,
124,105,12,0,133,128,0,162,233,242,67,152,77,205,77,
172,150,169,129,79,128,0,6,4,32,0,27,9,0};
int sixsize=7;
static int six[7]={17,177,170,242,169,19,148};
static int sixB[7]={136,141,85,79,149,200,41};
/* Test read/write together */
/* Later we test against pregenerated bitstreams */
oggpack_writeinit(&o);
fprintf(stderr,"\nSmall preclipped packing (LSb): ");
cliptest(testbuffer1,test1size,0,one,onesize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nNull bit call (LSb): ");
cliptest(testbuffer3,test3size,0,two,twosize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nLarge preclipped packing (LSb): ");
cliptest(testbuffer2,test2size,0,three,threesize);
fprintf(stderr,"ok.");
fprintf(stderr,"\n32 bit preclipped packing (LSb): ");
oggpack_reset(&o);
for(i=0;i<test2size;i++)
oggpack_write(&o,large[i],32);
buffer=oggpack_get_buffer(&o);
bytes=oggpack_bytes(&o);
oggpack_readinit(&r,buffer,bytes);
for(i=0;i<test2size;i++){
if(oggpack_look(&r,32)==-1)report("out of data. failed!");
if(oggpack_look(&r,32)!=large[i]){
fprintf(stderr,"%ld != %ld (%lx!=%lx):",oggpack_look(&r,32),large[i],
oggpack_look(&r,32),large[i]);
report("read incorrect value!\n");
}
oggpack_adv(&r,32);
}
if(oggpack_bytes(&r)!=bytes)report("leftover bytes after read!\n");
fprintf(stderr,"ok.");
fprintf(stderr,"\nSmall unclipped packing (LSb): ");
cliptest(testbuffer1,test1size,7,four,foursize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nLarge unclipped packing (LSb): ");
cliptest(testbuffer2,test2size,17,five,fivesize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nSingle bit unclipped packing (LSb): ");
cliptest(testbuffer3,test3size,1,six,sixsize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nTesting read past end (LSb): ");
oggpack_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
for(i=0;i<64;i++){
if(oggpack_read(&r,1)!=0){
fprintf(stderr,"failed; got -1 prematurely.\n");
exit(1);
}
}
if(oggpack_look(&r,1)!=-1 ||
oggpack_read(&r,1)!=-1){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
oggpack_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
if(oggpack_read(&r,30)!=0 || oggpack_read(&r,16)!=0){
fprintf(stderr,"failed 2; got -1 prematurely.\n");
exit(1);
}
if(oggpack_look(&r,18)!=0 ||
oggpack_look(&r,18)!=0){
fprintf(stderr,"failed 3; got -1 prematurely.\n");
exit(1);
}
if(oggpack_look(&r,19)!=-1 ||
oggpack_look(&r,19)!=-1){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
if(oggpack_look(&r,32)!=-1 ||
oggpack_look(&r,32)!=-1){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
oggpack_writeclear(&o);
fprintf(stderr,"ok.");
/* this is partly glassbox; we're mostly concerned about the allocation boundaries */
fprintf(stderr,"\nTesting aligned writecopies (LSb): ");
for(i=0;i<71;i++)
for(j=0;j<5;j++)
copytest(j*8,i);
for(i=BUFFER_INCREMENT*8-71;i<BUFFER_INCREMENT*8+71;i++)
for(j=0;j<5;j++)
copytest(j*8,i);
fprintf(stderr,"ok. ");
fprintf(stderr,"\nTesting unaligned writecopies (LSb): ");
for(i=0;i<71;i++)
for(j=1;j<40;j++)
if(j&0x7)
copytest(j,i);
for(i=BUFFER_INCREMENT*8-71;i<BUFFER_INCREMENT*8+71;i++)
for(j=1;j<40;j++)
if(j&0x7)
copytest(j,i);
fprintf(stderr,"ok. \n");
/********** lazy, cut-n-paste retest with MSb packing ***********/
/* Test read/write together */
/* Later we test against pregenerated bitstreams */
oggpackB_writeinit(&o);
fprintf(stderr,"\nSmall preclipped packing (MSb): ");
cliptestB(testbuffer1,test1size,0,oneB,onesize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nNull bit call (MSb): ");
cliptestB(testbuffer3,test3size,0,twoB,twosize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nLarge preclipped packing (MSb): ");
cliptestB(testbuffer2,test2size,0,threeB,threesize);
fprintf(stderr,"ok.");
fprintf(stderr,"\n32 bit preclipped packing (MSb): ");
oggpackB_reset(&o);
for(i=0;i<test2size;i++)
oggpackB_write(&o,large[i],32);
buffer=oggpackB_get_buffer(&o);
bytes=oggpackB_bytes(&o);
oggpackB_readinit(&r,buffer,bytes);
for(i=0;i<test2size;i++){
if(oggpackB_look(&r,32)==-1)report("out of data. failed!");
if(oggpackB_look(&r,32)!=large[i]){
fprintf(stderr,"%ld != %ld (%lx!=%lx):",oggpackB_look(&r,32),large[i],
oggpackB_look(&r,32),large[i]);
report("read incorrect value!\n");
}
oggpackB_adv(&r,32);
}
if(oggpackB_bytes(&r)!=bytes)report("leftover bytes after read!\n");
fprintf(stderr,"ok.");
fprintf(stderr,"\nSmall unclipped packing (MSb): ");
cliptestB(testbuffer1,test1size,7,fourB,foursize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nLarge unclipped packing (MSb): ");
cliptestB(testbuffer2,test2size,17,fiveB,fivesize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nSingle bit unclipped packing (MSb): ");
cliptestB(testbuffer3,test3size,1,sixB,sixsize);
fprintf(stderr,"ok.");
fprintf(stderr,"\nTesting read past end (MSb): ");
oggpackB_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
for(i=0;i<64;i++){
if(oggpackB_read(&r,1)!=0){
fprintf(stderr,"failed; got -1 prematurely.\n");
exit(1);
}
}
if(oggpackB_look(&r,1)!=-1 ||
oggpackB_read(&r,1)!=-1){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
oggpackB_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
if(oggpackB_read(&r,30)!=0 || oggpackB_read(&r,16)!=0){
fprintf(stderr,"failed 2; got -1 prematurely.\n");
exit(1);
}
if(oggpackB_look(&r,18)!=0 ||
oggpackB_look(&r,18)!=0){
fprintf(stderr,"failed 3; got -1 prematurely.\n");
exit(1);
}
if(oggpackB_look(&r,19)!=-1 ||
oggpackB_look(&r,19)!=-1){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
if(oggpackB_look(&r,32)!=-1 ||
oggpackB_look(&r,32)!=-1){
fprintf(stderr,"failed; read past end without -1.\n");
exit(1);
}
fprintf(stderr,"ok.");
oggpackB_writeclear(&o);
/* this is partly glassbox; we're mostly concerned about the allocation boundaries */
fprintf(stderr,"\nTesting aligned writecopies (MSb): ");
for(i=0;i<71;i++)
for(j=0;j<5;j++)
copytestB(j*8,i);
for(i=BUFFER_INCREMENT*8-71;i<BUFFER_INCREMENT*8+71;i++)
for(j=0;j<5;j++)
copytestB(j*8,i);
fprintf(stderr,"ok. ");
fprintf(stderr,"\nTesting unaligned writecopies (MSb): ");
for(i=0;i<71;i++)
for(j=1;j<40;j++)
if(j&0x7)
copytestB(j,i);
for(i=BUFFER_INCREMENT*8-71;i<BUFFER_INCREMENT*8+71;i++)
for(j=1;j<40;j++)
if(j&0x7)
copytestB(j,i);
fprintf(stderr,"ok. \n\n");
return(0);
}
#endif /* _V_SELFTEST */
#undef BUFFER_INCREMENT

View File

@ -0,0 +1,3 @@
mednafen/tremor/bitwise.o: mednafen/tremor/bitwise.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ogg.h

View File

@ -15,7 +15,6 @@
********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ogg.h"
@ -92,9 +91,9 @@ int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){
void *_vorbis_block_alloc(vorbis_block *vb,long bytes){
bytes=(bytes+(WORD_ALIGN-1)) & ~(WORD_ALIGN-1);
if(bytes+vb->localtop>vb->localalloc){
/* can't just _ogg_realloc... there are outstanding pointers */
/* can't just realloc... there are outstanding pointers */
if(vb->localstore){
struct alloc_chain *link=(struct alloc_chain *)_ogg_malloc(sizeof(*link));
struct alloc_chain *link=(struct alloc_chain *)malloc(sizeof(*link));
vb->totaluse+=vb->localtop;
link->next=vb->reap;
link->ptr=vb->localstore;
@ -102,7 +101,7 @@ void *_vorbis_block_alloc(vorbis_block *vb,long bytes){
}
/* highly conservative */
vb->localalloc=bytes;
vb->localstore=_ogg_malloc(vb->localalloc);
vb->localstore=malloc(vb->localalloc);
vb->localtop=0;
}
{
@ -118,14 +117,14 @@ void _vorbis_block_ripcord(vorbis_block *vb){
struct alloc_chain *reap=vb->reap;
while(reap){
struct alloc_chain *next=reap->next;
_ogg_free(reap->ptr);
free(reap->ptr);
memset(reap,0,sizeof(*reap));
_ogg_free(reap);
free(reap);
reap=next;
}
/* consolidate storage */
if(vb->totaluse){
vb->localstore=_ogg_realloc(vb->localstore,vb->totaluse+vb->localalloc);
vb->localstore=realloc(vb->localstore,vb->totaluse+vb->localalloc);
vb->localalloc+=vb->totaluse;
vb->totaluse=0;
}
@ -137,7 +136,8 @@ void _vorbis_block_ripcord(vorbis_block *vb){
int vorbis_block_clear(vorbis_block *vb){
_vorbis_block_ripcord(vb);
if(vb->localstore)_ogg_free(vb->localstore);
if(vb->localstore)
free(vb->localstore);
memset(vb,0,sizeof(*vb));
return(0);
@ -151,7 +151,7 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
if(ci==NULL) return 1;
memset(v,0,sizeof(*v));
b=(private_state *)(v->backend_state=_ogg_calloc(1,sizeof(*b)));
b=(private_state *)(v->backend_state=calloc(1,sizeof(*b)));
v->vi=vi;
b->modebits=ilog(ci->modes);
@ -162,7 +162,7 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
/* finish the codebooks */
if(!ci->fullbooks){
ci->fullbooks=(codebook *)_ogg_calloc(ci->books,sizeof(*ci->fullbooks));
ci->fullbooks=(codebook *)calloc(ci->books,sizeof(*ci->fullbooks));
for(i=0;i<ci->books;i++){
if(ci->book_param[i]==NULL)
goto abort_books;
@ -175,10 +175,10 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
}
v->pcm_storage=ci->blocksizes[1];
v->pcm=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcm));
v->pcmret=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcmret));
v->pcm=(int32_t **)malloc(vi->channels*sizeof(*v->pcm));
v->pcmret=(int32_t **)malloc(vi->channels*sizeof(*v->pcmret));
for(i=0;i<vi->channels;i++)
v->pcm[i]=(ogg_int32_t *)_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i]));
v->pcm[i]=(int32_t *)calloc(v->pcm_storage,sizeof(*v->pcm[i]));
/* all 1 (large block) or 0 (small block) */
/* explicitly set for the sake of clarity */
@ -186,7 +186,7 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
v->W=0; /* current window size */
/* initialize all the mapping/backend lookups */
b->mode=(vorbis_look_mapping **)_ogg_calloc(ci->modes,sizeof(*b->mode));
b->mode=(vorbis_look_mapping **)calloc(ci->modes,sizeof(*b->mode));
for(i=0;i<ci->modes;i++){
int mapnum=ci->mode_param[i]->mapping;
int maptype=ci->map_type[mapnum];
@ -239,11 +239,15 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){
codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL);
private_state *b=(private_state *)v->backend_state;
if(v->pcm){
for(i=0;i<vi->channels;i++)
if(v->pcm[i])_ogg_free(v->pcm[i]);
_ogg_free(v->pcm);
if(v->pcmret)_ogg_free(v->pcmret);
if(v->pcm)
{
if(vi)
for(i=0;i<vi->channels;i++)
if(v->pcm[i])
free(v->pcm[i]);
free(v->pcm);
if(v->pcmret)
free(v->pcmret);
}
/* free mode lookups; these are actually vorbis_look_mapping structs */
@ -255,9 +259,11 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){
}
}
if(b){
if(b->mode)_ogg_free(b->mode);
_ogg_free(b);
if(b)
{
if(b->mode)
free(b->mode);
free(b);
}
memset(v,0,sizeof(*v));
@ -316,30 +322,30 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
if(v->lW){
if(v->W){
/* large/large */
ogg_int32_t *pcm=v->pcm[j]+prevCenter;
ogg_int32_t *p=vb->pcm[j];
int32_t *pcm=v->pcm[j]+prevCenter;
int32_t *p=vb->pcm[j];
for(i=0;i<n1;i++)
pcm[i]+=p[i];
}else{
/* large/small */
ogg_int32_t *pcm=v->pcm[j]+prevCenter+n1/2-n0/2;
ogg_int32_t *p=vb->pcm[j];
int32_t *pcm=v->pcm[j]+prevCenter+n1/2-n0/2;
int32_t *p=vb->pcm[j];
for(i=0;i<n0;i++)
pcm[i]+=p[i];
}
}else{
if(v->W){
/* small/large */
ogg_int32_t *pcm=v->pcm[j]+prevCenter;
ogg_int32_t *p=vb->pcm[j]+n1/2-n0/2;
int32_t *pcm=v->pcm[j]+prevCenter;
int32_t *p=vb->pcm[j]+n1/2-n0/2;
for(i=0;i<n0;i++)
pcm[i]+=p[i];
for(;i<n1/2+n0/2;i++)
pcm[i]=p[i];
}else{
/* small/small */
ogg_int32_t *pcm=v->pcm[j]+prevCenter;
ogg_int32_t *p=vb->pcm[j];
int32_t *pcm=v->pcm[j]+prevCenter;
int32_t *p=vb->pcm[j];
for(i=0;i<n0;i++)
pcm[i]+=p[i];
}
@ -347,8 +353,8 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
/* the copy section */
{
ogg_int32_t *pcm=v->pcm[j]+thisCenter;
ogg_int32_t *p=vb->pcm[j]+n;
int32_t *pcm=v->pcm[j]+thisCenter;
int32_t *p=vb->pcm[j]+n;
for(i=0;i<n;i++)
pcm[i]=p[i];
}
@ -403,7 +409,7 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
then spec says the end is cut, not beginning */
long extra=b->sample_count-vb->granulepos;
/* we use ogg_int64_t for granule positions because a
/* we use int64_t for granule positions because a
uint64 isn't universally available. Unfortunately,
that means granposes can be 'negative' and result in
extra being negative */
@ -451,7 +457,7 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
if(extra > v->pcm_current - v->pcm_returned)
extra = v->pcm_current - v->pcm_returned;
/* we use ogg_int64_t for granule positions because a
/* we use int64_t for granule positions because a
uint64 isn't universally available. Unfortunately,
that means granposes can be 'negative' and result in
extra being negative */
@ -475,7 +481,7 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
}
/* pcm==NULL indicates we just want the pending samples, no more */
int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm){
int vorbis_synthesis_pcmout(vorbis_dsp_state *v,int32_t ***pcm){
vorbis_info *vi=v->vi;
if(v->pcm_returned>-1 && v->pcm_returned<v->pcm_current){
if(pcm){

7
mednafen/tremor/block.d Normal file
View File

@ -0,0 +1,7 @@
mednafen/tremor/block.o: mednafen/tremor/block.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ogg.h mednafen/tremor/ivorbiscodec.h \
mednafen/tremor/codec_internal.h mednafen/tremor/codebook.h \
mednafen/tremor/window.h mednafen/tremor/registry.h \
mednafen/tremor/backends.h mednafen/tremor/misc.h mednafen/tremor/os.h \
libretro-common/include/retro_inline.h mednafen/tremor/asm_arm.h

View File

@ -27,7 +27,7 @@
readies the codebook auxiliary structures for decode *************/
static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){
long i,j;
static_codebook *s=_ogg_calloc(1,sizeof(*s));
static_codebook *s=calloc(1,sizeof(*s));
/* make sure alignment is correct */
if(oggpack_read(opb,24)!=0x564342)goto _eofout;
@ -48,7 +48,7 @@ static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){
if((s->entries*(unused?1:5)+7)>>3>opb->storage-oggpack_bytes(opb))
goto _eofout;
/* unordered */
s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
s->lengthlist=(long *)malloc(sizeof(*s->lengthlist)*s->entries);
/* allocated but unused entries? */
if(unused){
@ -78,7 +78,7 @@ static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){
{
long length=oggpack_read(opb,5)+1;
if(length==0)goto _eofout;
s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
s->lengthlist=(long *)malloc(sizeof(*s->lengthlist)*s->entries);
for(i=0;i<s->entries;){
long num=oggpack_read(opb,_ilog(s->entries-i));
@ -127,7 +127,7 @@ static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){
/* quantized values */
if((quantvals*s->q_quant+7)>>3>opb->storage-oggpack_bytes(opb))
goto _eofout;
s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals);
s->quantlist=(long *)malloc(sizeof(*s->quantlist)*quantvals);
for(i=0;i<quantvals;i++)
s->quantlist[i]=oggpack_read(opb,s->q_quant);
@ -155,7 +155,7 @@ static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){
be. The first-stage decode table catches most words so that
bitreverse is not in the main execution path. */
static ogg_uint32_t bitreverse(ogg_uint32_t x){
static uint32_t bitreverse(uint32_t x){
x= ((x>>16)&0x0000ffff) | ((x<<16)&0xffff0000);
x= ((x>> 8)&0x00ff00ff) | ((x<< 8)&0xff00ff00);
x= ((x>> 4)&0x0f0f0f0f) | ((x<< 4)&0xf0f0f0f0);
@ -163,7 +163,7 @@ static ogg_uint32_t bitreverse(ogg_uint32_t x){
return((x>> 1)&0x55555555) | ((x<< 1)&0xaaaaaaaa);
}
STIN long decode_packed_entry_number(codebook *book,
static INLINE long decode_packed_entry_number(codebook *book,
oggpack_buffer *b){
int read=book->dec_maxlength;
long lo,hi;
@ -195,7 +195,7 @@ STIN long decode_packed_entry_number(codebook *book,
/* bisect search for the codeword in the ordered list */
{
ogg_uint32_t testword=bitreverse((ogg_uint32_t)lok);
uint32_t testword=bitreverse((uint32_t)lok);
while(hi-lo>1){
long p=(hi-lo)>>1;
@ -242,12 +242,12 @@ long vorbis_book_decode(codebook *book, oggpack_buffer *b){
/* returns 0 on OK or -1 on eof *************************************/
/* decode vector / dim granularity gaurding is done in the upper layer */
long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
long vorbis_book_decodevs_add(codebook *book,int32_t *a,
oggpack_buffer *b,int n,int point){
if(book->used_entries>0){
int step=n/book->dim;
long *entry = (long *)alloca(sizeof(*entry)*step);
ogg_int32_t **t = (ogg_int32_t **)alloca(sizeof(*t)*step);
int32_t **t = (int32_t **)alloca(sizeof(*t)*step);
int i,j,o;
int shift=point-book->binarypoint;
@ -258,7 +258,7 @@ long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
t[i] = book->valuelist+entry[i]*book->dim;
}
for(i=0,o=0;i<book->dim;i++,o+=step)
for (j=0;o+j<n && j<step;j++)
for (j=0;j<step;j++)
a[o+j]+=t[j][i]>>shift;
}else{
for (i = 0; i < step; i++) {
@ -267,7 +267,7 @@ long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
t[i] = book->valuelist+entry[i]*book->dim;
}
for(i=0,o=0;i<book->dim;i++,o+=step)
for (j=0;o+j<n && j<step;j++)
for (j=0;j<step;j++)
a[o+j]+=t[j][i]<<-shift;
}
}
@ -275,11 +275,11 @@ long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
}
/* decode vector / dim granularity gaurding is done in the upper layer */
long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
long vorbis_book_decodev_add(codebook *book,int32_t *a,
oggpack_buffer *b,int n,int point){
if(book->used_entries>0){
int i,j,entry;
ogg_int32_t *t;
int32_t *t;
int shift=point-book->binarypoint;
if(shift>=0){
@ -287,7 +287,7 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;i<n && j<book->dim;)
for (j=0;j<book->dim;)
a[i++]+=t[j++]>>shift;
}
}else{
@ -295,7 +295,7 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;i<n && j<book->dim;)
for (j=0;j<book->dim;)
a[i++]+=t[j++]<<-shift;
}
}
@ -306,11 +306,11 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
/* unlike the others, we guard against n not being an integer number
of <dim> internally rather than in the upper layer (called only by
floor0) */
long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
long vorbis_book_decodev_set(codebook *book,int32_t *a,
oggpack_buffer *b,int n,int point){
if(book->used_entries>0){
int i,j,entry;
ogg_int32_t *t;
int32_t *t;
int shift=point-book->binarypoint;
if(shift>=0){
@ -345,22 +345,22 @@ long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
}
/* decode vector / dim granularity gaurding is done in the upper layer */
long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,\
long vorbis_book_decodevv_add(codebook *book,int32_t **a,\
long offset,int ch,
oggpack_buffer *b,int n,int point){
if(book->used_entries>0){
long i,j,entry;
int chptr=0;
int shift=point-book->binarypoint;
int m=offset+n;
if(shift>=0){
for(i=offset;i<m;){
for(i=offset;i<offset+n;){
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
{
const ogg_int32_t *t = book->valuelist+entry*book->dim;
for (j=0;i<m && j<book->dim;j++){
const int32_t *t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;j++){
a[chptr++][i]+=t[j]>>shift;
if(chptr==ch){
chptr=0;
@ -371,12 +371,12 @@ long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,\
}
}else{
for(i=offset;i<m;){
for(i=offset;i<offset+n;){
entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1);
{
const ogg_int32_t *t = book->valuelist+entry*book->dim;
for (j=0;i<m && j<book->dim;j++){
const int32_t *t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;j++){
a[chptr++][i]+=t[j]<<-shift;
if(chptr==ch){
chptr=0;

View File

@ -0,0 +1,5 @@
mednafen/tremor/codebook.o: mednafen/tremor/codebook.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ogg.h mednafen/tremor/ivorbiscodec.h \
mednafen/tremor/codebook.h mednafen/tremor/misc.h mednafen/tremor/os.h \
libretro-common/include/retro_inline.h mednafen/tremor/asm_arm.h

View File

@ -62,12 +62,12 @@ typedef struct codebook{
/* the below are ordered by bitreversed codeword and only used
entries are populated */
int binarypoint;
ogg_int32_t *valuelist; /* list of dim*entries actual entry values */
ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */
int32_t *valuelist; /* list of dim*entries actual entry values */
uint32_t *codelist; /* list of bitstream codewords for each entry */
int *dec_index;
char *dec_codelengths;
ogg_uint32_t *dec_firsttable;
uint32_t *dec_firsttable;
int dec_firsttablen;
int dec_maxlength;
@ -85,13 +85,13 @@ extern long _book_maptype1_quantvals(const static_codebook *b);
extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b);
extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a,
extern long vorbis_book_decodevs_add(codebook *book, int32_t *a,
oggpack_buffer *b,int n,int point);
extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a,
extern long vorbis_book_decodev_set(codebook *book, int32_t *a,
oggpack_buffer *b,int n,int point);
extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a,
extern long vorbis_book_decodev_add(codebook *book, int32_t *a,
oggpack_buffer *b,int n,int point);
extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a,
extern long vorbis_book_decodevv_add(codebook *book, int32_t **a,
long off,int ch,
oggpack_buffer *b,int n,int point);

View File

@ -45,7 +45,7 @@ typedef struct private_state {
int modebits;
vorbis_look_mapping **mode;
ogg_int64_t sample_count;
int64_t sample_count;
} private_state;

View File

@ -35,7 +35,7 @@ typedef struct {
int *linearmap;
vorbis_info_floor0 *vi;
ogg_int32_t *lsp_look;
int32_t *lsp_look;
} vorbis_look_floor0;
@ -48,7 +48,7 @@ typedef struct {
returns in m.8 format */
static long ADJUST_SQRT2[2]={8192,5792};
STIN ogg_int32_t vorbis_invsqlook_i(long a,long e){
static INLINE int32_t vorbis_invsqlook_i(long a,long e){
long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1);
long d=a&INVSQ_LOOKUP_I_MASK; /* 0.10 */
long val=INVSQ_LOOKUP_I[i]- /* 1.16 */
@ -60,7 +60,7 @@ STIN ogg_int32_t vorbis_invsqlook_i(long a,long e){
/* interpolated lookup based fromdB function, domain -140dB to 0dB only */
/* a is in n.12 format */
STIN ogg_int32_t vorbis_fromdBlook_i(long a){
static INLINE int32_t vorbis_fromdBlook_i(long a){
int i=(-a)>>(12-FROMdB2_SHIFT);
if(i<0) return 0x7fffffff;
if(i>=(FROMdB_LOOKUP_SZ<<FROMdB_SHIFT))return 0;
@ -70,7 +70,7 @@ STIN ogg_int32_t vorbis_fromdBlook_i(long a){
/* interpolated lookup based cos function, domain 0 to PI only */
/* a is in 0.16 format, where 0==0, 2^^16-1==PI, return 0.14 */
STIN ogg_int32_t vorbis_coslook_i(long a){
static INLINE int32_t vorbis_coslook_i(long a){
int i=a>>COS_LOOKUP_I_SHIFT;
int d=a&COS_LOOKUP_I_MASK;
return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>>
@ -79,7 +79,7 @@ STIN ogg_int32_t vorbis_coslook_i(long a){
/* interpolated lookup based cos function */
/* a is in 0.16 format, where 0==0, 2^^16==PI, return .LSP_FRACBITS */
STIN ogg_int32_t vorbis_coslook2_i(long a){
static INLINE int32_t vorbis_coslook2_i(long a){
a=a&0x1ffff;
if(a>0x10000)a=0x20000-a;
@ -102,7 +102,7 @@ static const int barklook[28]={
};
/* used in init only; interpolate the long way */
STIN ogg_int32_t toBARK(int n){
static INLINE int32_t toBARK(int n){
int i;
for(i=0;i<27;i++)
if(n>=barklook[i] && n<barklook[i+1])break;
@ -133,11 +133,11 @@ static const unsigned char MLOOP_2[64]={
static const unsigned char MLOOP_3[8]={0,1,2,2,3,3,3,3};
void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
ogg_int32_t *lsp,int m,
ogg_int32_t amp,
ogg_int32_t ampoffset,
ogg_int32_t *icos){
void vorbis_lsp_to_curve(int32_t *curve,int *map,int n,int ln,
int32_t *lsp,int m,
int32_t amp,
int32_t ampoffset,
int32_t *icos){
/* 0 <= m < 256 */
@ -145,13 +145,13 @@ void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
int i;
int ampoffseti=ampoffset*4096;
int ampi=amp;
ogg_int32_t *ilsp=(ogg_int32_t *)alloca(m*sizeof(*ilsp));
int32_t *ilsp=(int32_t *)alloca(m*sizeof(*ilsp));
/* lsp is in 8.24, range 0 to PI; coslook wants it in .16 0 to 1*/
for(i=0;i<m;i++){
#ifndef _LOW_ACCURACY_
ogg_int32_t val=MULT32(lsp[i],0x517cc2);
int32_t val=MULT32(lsp[i],0x517cc2);
#else
ogg_int32_t val=((lsp[i]>>10)*0x517d)>>14;
int32_t val=((lsp[i]>>10)*0x517d)>>14;
#endif
/* safeguard against a malicious stream */
@ -166,10 +166,10 @@ void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
i=0;
while(i<n){
int j,k=map[i];
ogg_uint32_t pi=46341; /* 2**-.5 in 0.16 */
ogg_uint32_t qi=46341;
ogg_int32_t qexp=0,shift;
ogg_int32_t wi=icos[k];
uint32_t pi=46341; /* 2**-.5 in 0.16 */
uint32_t qi=46341;
int32_t qexp=0,shift;
int32_t wi=icos[k];
#ifdef _V_LSP_MATH_ASM
lsp_loop_asm(&qi,&pi,&qexp,ilsp,wi,m);
@ -292,7 +292,7 @@ static void floor0_free_info(vorbis_info_floor *i){
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
if(info){
memset(info,0,sizeof(*info));
_ogg_free(info);
free(info);
}
}
@ -300,10 +300,12 @@ static void floor0_free_look(vorbis_look_floor *i){
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
if(look){
if(look->linearmap)_ogg_free(look->linearmap);
if(look->lsp_look)_ogg_free(look->lsp_look);
if(look->linearmap)
free(look->linearmap);
if(look->lsp_look)
free(look->lsp_look);
memset(look,0,sizeof(*look));
_ogg_free(look);
free(look);
}
}
@ -311,7 +313,7 @@ static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
int j;
vorbis_info_floor0 *info=(vorbis_info_floor0 *)_ogg_malloc(sizeof(*info));
vorbis_info_floor0 *info=(vorbis_info_floor0 *)malloc(sizeof(*info));
info->order=oggpack_read(opb,8);
info->rate=oggpack_read(opb,16);
info->barkmap=oggpack_read(opb,16);
@ -351,7 +353,7 @@ static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi
vorbis_info *vi=vd->vi;
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
vorbis_look_floor0 *look=(vorbis_look_floor0 *)_ogg_calloc(1,sizeof(*look));
vorbis_look_floor0 *look=(vorbis_look_floor0 *)calloc(1,sizeof(*look));
look->m=info->order;
look->n=ci->blocksizes[mi->blockflag]/2;
look->ln=info->barkmap;
@ -363,7 +365,7 @@ static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi
the encoder may do what it wishes in filling them. They're
necessary in some mapping combinations to keep the scale spacing
accurate */
look->linearmap=(int *)_ogg_malloc((look->n+1)*sizeof(*look->linearmap));
look->linearmap=(int *)malloc((look->n+1)*sizeof(*look->linearmap));
for(j=0;j<look->n;j++){
int val=(look->ln*
@ -374,7 +376,7 @@ static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi
}
look->linearmap[j]=-1;
look->lsp_look=(ogg_int32_t *)_ogg_malloc(look->ln*sizeof(*look->lsp_look));
look->lsp_look=(int32_t *)malloc(look->ln*sizeof(*look->lsp_look));
for(j=0;j<look->ln;j++)
look->lsp_look[j]=vorbis_coslook2_i(0x10000*j/look->ln);
@ -395,8 +397,8 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
if(booknum!=-1 && booknum<info->numbooks){ /* be paranoid */
codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup;
codebook *b=ci->fullbooks+info->books[booknum];
ogg_int32_t last=0;
ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1));
int32_t last=0;
int32_t *lsp=(int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1));
if(vorbis_book_decodev_set(b,lsp,&vb->opb,look->m,-24)==-1)goto eop;
for(j=0;j<look->m;){
@ -413,13 +415,13 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
}
static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
void *memo,ogg_int32_t *out){
void *memo,int32_t *out){
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
vorbis_info_floor0 *info=look->vi;
if(memo){
ogg_int32_t *lsp=(ogg_int32_t *)memo;
ogg_int32_t amp=lsp[look->m];
int32_t *lsp=(int32_t *)memo;
int32_t amp=lsp[look->m];
/* take the coefficients back to a spectral envelope curve */
vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln,

8
mednafen/tremor/floor0.d Normal file
View File

@ -0,0 +1,8 @@
mednafen/tremor/floor0.o: mednafen/tremor/floor0.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ogg.h mednafen/tremor/ivorbiscodec.h \
mednafen/tremor/codec_internal.h mednafen/tremor/codebook.h \
mednafen/tremor/registry.h mednafen/tremor/backends.h \
mednafen/tremor/misc.h mednafen/tremor/os.h \
libretro-common/include/retro_inline.h mednafen/tremor/asm_arm.h \
mednafen/tremor/block.h mednafen/tremor/lsp_lookup.h

View File

@ -47,7 +47,7 @@ static void floor1_free_info(vorbis_info_floor *i){
vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
if(info){
memset(info,0,sizeof(*info));
_ogg_free(info);
free(info);
}
}
@ -55,7 +55,7 @@ static void floor1_free_look(vorbis_look_floor *i){
vorbis_look_floor1 *look=(vorbis_look_floor1 *)i;
if(look){
memset(look,0,sizeof(*look));
_ogg_free(look);
free(look);
}
}
@ -76,7 +76,7 @@ static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
int j,k,count=0,maxclass=-1,rangebits;
vorbis_info_floor1 *info=(vorbis_info_floor1 *)_ogg_calloc(1,sizeof(*info));
vorbis_info_floor1 *info=(vorbis_info_floor1 *)calloc(1,sizeof(*info));
/* read partitions */
info->partitions=oggpack_read(opb,5); /* only 0 to 31 legal */
for(j=0;j<info->partitions;j++){
@ -141,7 +141,7 @@ static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,vorbis_info_mode *mi,
int *sortpointer[VIF_POSIT+2];
vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
vorbis_look_floor1 *look=(vorbis_look_floor1 *)_ogg_calloc(1,sizeof(*look));
vorbis_look_floor1 *look=(vorbis_look_floor1 *)calloc(1,sizeof(*look));
int i,j,n=0;
look->vi=info;
@ -229,7 +229,7 @@ static int render_point(int x0,int x1,int y0,int y1,int x){
# define XdB(n) (n)
#endif
static const ogg_int32_t FLOOR_fromdB_LOOKUP[256]={
static const int32_t FLOOR_fromdB_LOOKUP[256]={
XdB(0x000000e5), XdB(0x000000f4), XdB(0x00000103), XdB(0x00000114),
XdB(0x00000126), XdB(0x00000139), XdB(0x0000014e), XdB(0x00000163),
XdB(0x0000017a), XdB(0x00000193), XdB(0x000001ad), XdB(0x000001c9),
@ -296,7 +296,7 @@ static const ogg_int32_t FLOOR_fromdB_LOOKUP[256]={
XdB(0x69f80e9a), XdB(0x70dafda8), XdB(0x78307d76), XdB(0x7fffffff),
};
static void render_line(int n, int x0,int x1,int y0,int y1,ogg_int32_t *d){
static void render_line(int n, int x0,int x1,int y0,int y1,int32_t *d){
int dy=y1-y0;
int adx=x1-x0;
int ady=abs(dy);
@ -412,7 +412,7 @@ static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
}
static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
ogg_int32_t *out){
int32_t *out){
vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
vorbis_info_floor1 *info=look->vi;

8
mednafen/tremor/floor1.d Normal file
View File

@ -0,0 +1,8 @@
mednafen/tremor/floor1.o: mednafen/tremor/floor1.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ogg.h mednafen/tremor/ivorbiscodec.h \
mednafen/tremor/codec_internal.h mednafen/tremor/codebook.h \
mednafen/tremor/registry.h mednafen/tremor/backends.h \
mednafen/tremor/misc.h mednafen/tremor/os.h \
libretro-common/include/retro_inline.h mednafen/tremor/asm_arm.h \
mednafen/tremor/block.h

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
mednafen/tremor/framing.o: mednafen/tremor/framing.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ogg.h

View File

@ -94,11 +94,14 @@ void vorbis_comment_clear(vorbis_comment *vc){
long i;
if(vc->user_comments){
for(i=0;i<vc->comments;i++)
if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
_ogg_free(vc->user_comments);
if(vc->user_comments[i])
free(vc->user_comments[i]);
free(vc->user_comments);
}
if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
if(vc->vendor)_ogg_free(vc->vendor);
if(vc->comment_lengths)
free(vc->comment_lengths);
if(vc->vendor)
free(vc->vendor);
memset(vc,0,sizeof(*vc));
}
}
@ -113,7 +116,7 @@ int vorbis_info_blocksize(vorbis_info *vi,int zo){
/* used by synthesis, which has a full, alloced vi */
void vorbis_info_init(vorbis_info *vi){
memset(vi,0,sizeof(*vi));
vi->codec_setup=(codec_setup_info *)_ogg_calloc(1,sizeof(codec_setup_info));
vi->codec_setup=(codec_setup_info *)calloc(1,sizeof(codec_setup_info));
}
void vorbis_info_clear(vorbis_info *vi){
@ -123,7 +126,8 @@ void vorbis_info_clear(vorbis_info *vi){
if(ci){
for(i=0;i<ci->modes;i++)
if(ci->mode_param[i])_ogg_free(ci->mode_param[i]);
if(ci->mode_param[i])
free(ci->mode_param[i]);
for(i=0;i<ci->maps;i++) /* unpack does the range checking */
if(ci->map_param[i])
@ -146,9 +150,9 @@ void vorbis_info_clear(vorbis_info *vi){
vorbis_book_clear(ci->fullbooks+i);
}
if(ci->fullbooks)
_ogg_free(ci->fullbooks);
free(ci->fullbooks);
_ogg_free(ci);
free(ci);
}
memset(vi,0,sizeof(*vi));
@ -193,13 +197,13 @@ static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){
vendorlen=oggpack_read(opb,32);
if(vendorlen<0)goto err_out;
if(vendorlen>opb->storage-oggpack_bytes(opb))goto err_out;
vc->vendor=(char *)_ogg_calloc(vendorlen+1,1);
vc->vendor=(char *)calloc(vendorlen+1,1);
if(vc->vendor==NULL)goto err_out;
_v_readstring(opb,vc->vendor,vendorlen);
i=oggpack_read(opb,32);
if(i<0||i>=INT_MAX||i>(opb->storage-oggpack_bytes(opb))>>2)goto err_out;
vc->user_comments=(char **)_ogg_calloc(i+1,sizeof(*vc->user_comments));
vc->comment_lengths=(int *)_ogg_calloc(i+1, sizeof(*vc->comment_lengths));
vc->user_comments=(char **)calloc(i+1,sizeof(*vc->user_comments));
vc->comment_lengths=(int *)calloc(i+1, sizeof(*vc->comment_lengths));
if(vc->user_comments==NULL||vc->comment_lengths==NULL)goto err_out;
vc->comments=i;
@ -207,7 +211,7 @@ static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){
int len=oggpack_read(opb,32);
if(len<0||len>opb->storage-oggpack_bytes(opb))goto err_out;
vc->comment_lengths[i]=len;
vc->user_comments[i]=(char *)_ogg_calloc(len+1,1);
vc->user_comments[i]=(char *)calloc(len+1,1);
if(vc->user_comments[i]==NULL){
vc->comments=i;
goto err_out;
@ -227,6 +231,7 @@ static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){
static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
int i;
if(!ci)return(OV_EFAULT);
/* codebooks */
ci->books=oggpack_read(opb,8)+1;
@ -281,7 +286,7 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
ci->modes=oggpack_read(opb,6)+1;
if(ci->modes<=0)goto err_out;
for(i=0;i<ci->modes;i++){
ci->mode_param[i]=(vorbis_info_mode *)_ogg_calloc(1,sizeof(*ci->mode_param[i]));
ci->mode_param[i]=(vorbis_info_mode *)calloc(1,sizeof(*ci->mode_param[i]));
ci->mode_param[i]->blockflag=oggpack_read(opb,1);
ci->mode_param[i]->windowtype=oggpack_read(opb,16);
ci->mode_param[i]->transformtype=oggpack_read(opb,16);
@ -366,10 +371,6 @@ int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op)
/* um... we didn't get the initial header */
return(OV_EBADHEADER);
}
if(vc->vendor!=NULL){
/* previously initialized comment header */
return(OV_EBADHEADER);
}
return(_vorbis_unpack_comment(vc,&opb));
@ -378,14 +379,6 @@ int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op)
/* um... we didn;t get the initial header or comments yet */
return(OV_EBADHEADER);
}
if(vi->codec_setup==NULL){
/* improperly initialized vorbis_info */
return(OV_EFAULT);
}
if(((codec_setup_info *)vi->codec_setup)->books>0){
/* previously initialized setup header */
return(OV_EBADHEADER);
}
return(_vorbis_unpack_books(vi,&opb));

7
mednafen/tremor/info.d Normal file
View File

@ -0,0 +1,7 @@
mednafen/tremor/info.o: mednafen/tremor/info.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ogg.h mednafen/tremor/ivorbiscodec.h \
mednafen/tremor/codec_internal.h mednafen/tremor/codebook.h \
mednafen/tremor/registry.h mednafen/tremor/backends.h \
mednafen/tremor/window.h mednafen/tremor/misc.h mednafen/tremor/os.h \
libretro-common/include/retro_inline.h mednafen/tremor/asm_arm.h

View File

@ -60,8 +60,8 @@ typedef struct vorbis_dsp_state{
int analysisp;
vorbis_info *vi;
ogg_int32_t **pcm;
ogg_int32_t **pcmret;
int32_t **pcm;
int32_t **pcmret;
int pcm_storage;
int pcm_current;
int pcm_returned;
@ -74,15 +74,15 @@ typedef struct vorbis_dsp_state{
long nW;
long centerW;
ogg_int64_t granulepos;
ogg_int64_t sequence;
int64_t granulepos;
int64_t sequence;
void *backend_state;
} vorbis_dsp_state;
typedef struct vorbis_block{
/* necessary stream state for linking to the framing abstraction */
ogg_int32_t **pcm; /* this is a pointer into local storage */
int32_t **pcm; /* this is a pointer into local storage */
oggpack_buffer opb;
long lW;
@ -92,8 +92,8 @@ typedef struct vorbis_block{
int mode;
int eofflag;
ogg_int64_t granulepos;
ogg_int64_t sequence;
int64_t granulepos;
int64_t sequence;
vorbis_dsp_state *vd; /* For read-only access of configuration */
/* local storage to avoid remallocing; it's up to the mapping to
@ -174,7 +174,7 @@ extern int vorbis_synthesis_restart(vorbis_dsp_state *v);
extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op);
extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm);
extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,int32_t ***pcm);
extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);

View File

@ -26,8 +26,7 @@ extern "C"
#include <stdio.h>
#include "ivorbiscodec.h"
#define CHUNKSIZE 65535
#define READSIZE 1024
#define CHUNKSIZE 1024
/* The function prototypes for the callbacks are basically the same as for
* the stdio functions fread, fseek, fclose, ftell.
* The one difference is that the FILE * arguments have been replaced with
@ -40,7 +39,7 @@ extern "C"
*/
typedef struct {
size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource);
int (*seek_func) (void *datasource, ogg_int64_t offset, int whence);
int (*seek_func) (void *datasource, int64_t offset, int whence);
int (*close_func) (void *datasource);
long (*tell_func) (void *datasource);
} ov_callbacks;
@ -54,28 +53,28 @@ typedef struct {
typedef struct OggVorbis_File {
void *datasource; /* Pointer to a FILE *, etc. */
int seekable;
ogg_int64_t offset;
ogg_int64_t end;
int64_t offset;
int64_t end;
ogg_sync_state oy;
/* If the FILE handle isn't seekable (eg, a pipe), only the current
stream appears */
int links;
ogg_int64_t *offsets;
ogg_int64_t *dataoffsets;
ogg_uint32_t *serialnos;
ogg_int64_t *pcmlengths;
int64_t *offsets;
int64_t *dataoffsets;
uint32_t *serialnos;
int64_t *pcmlengths;
vorbis_info *vi;
vorbis_comment *vc;
/* Decoding working state local storage */
ogg_int64_t pcm_offset;
int64_t pcm_offset;
int ready_state;
ogg_uint32_t current_serialno;
uint32_t current_serialno;
int current_link;
ogg_int64_t bittrack;
ogg_int64_t samptrack;
int64_t bittrack;
int64_t samptrack;
ogg_stream_state os; /* take physical pages, weld into a logical
stream of packets */
@ -87,34 +86,28 @@ typedef struct OggVorbis_File {
} OggVorbis_File;
extern int ov_clear(OggVorbis_File *vf);
extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);
extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
const char *initial, long ibytes, ov_callbacks callbacks);
extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);
extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
const char *initial, long ibytes, ov_callbacks callbacks);
extern int ov_test_open(OggVorbis_File *vf);
extern long ov_bitrate(OggVorbis_File *vf,int i);
extern long ov_bitrate_instant(OggVorbis_File *vf);
extern long ov_streams(OggVorbis_File *vf);
extern long ov_seekable(OggVorbis_File *vf);
extern long ov_serialnumber(OggVorbis_File *vf,int i);
extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);
extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
extern ogg_int64_t ov_time_total(OggVorbis_File *vf,int i);
extern int64_t ov_raw_total(OggVorbis_File *vf,int i);
extern int64_t ov_pcm_total(OggVorbis_File *vf,int i);
extern int64_t ov_time_total(OggVorbis_File *vf,int i);
extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos);
extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);
extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
extern int ov_time_seek(OggVorbis_File *vf,ogg_int64_t pos);
extern int ov_time_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
extern int ov_raw_seek(OggVorbis_File *vf,int64_t pos);
extern int ov_pcm_seek(OggVorbis_File *vf,int64_t pos);
extern int ov_pcm_seek_page(OggVorbis_File *vf,int64_t pos);
extern int ov_time_seek(OggVorbis_File *vf,int64_t pos);
extern int ov_time_seek_page(OggVorbis_File *vf,int64_t pos);
extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
extern ogg_int64_t ov_time_tell(OggVorbis_File *vf);
extern int64_t ov_raw_tell(OggVorbis_File *vf);
extern int64_t ov_pcm_tell(OggVorbis_File *vf);
extern int64_t ov_time_tell(OggVorbis_File *vf);
extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);

View File

@ -18,7 +18,7 @@
#ifndef _V_LOOKUP_DATA_H_
#define _V_LOOKUP_DATA_H_
#include "os_types.h"
#include <stdint.h>
#define FROMdB_LOOKUP_SZ 35
#define FROMdB2_LOOKUP_SZ 32
@ -26,7 +26,7 @@
#define FROMdB2_SHIFT 3
#define FROMdB2_MASK 31
static const ogg_int32_t FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={
static const int32_t FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={
0x003fffff, 0x0028619b, 0x00197a96, 0x0010137a,
0x000a24b0, 0x00066666, 0x000409c3, 0x00028c42,
0x00019b8c, 0x000103ab, 0x0000a3d7, 0x00006760,
@ -37,7 +37,7 @@ static const ogg_int32_t FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={
0x0000000b, 0x00000007, 0x00000004, 0x00000003,
0x00000002, 0x00000001, 0x00000001};
static const ogg_int32_t FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={
static const int32_t FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={
0x000001fc, 0x000001f5, 0x000001ee, 0x000001e7,
0x000001e0, 0x000001d9, 0x000001d2, 0x000001cc,
0x000001c5, 0x000001bf, 0x000001b8, 0x000001b2,
@ -92,7 +92,7 @@ static const long INVSQ_LOOKUP_IDel[64]={
#define COS_LOOKUP_I_SHIFT 9
#define COS_LOOKUP_I_MASK 511
#define COS_LOOKUP_I_SZ 128
static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={
static const int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={
16384, 16379, 16364, 16340,
16305, 16261, 16207, 16143,
16069, 15986, 15893, 15791,

View File

@ -57,7 +57,7 @@ static void mapping0_free_info(vorbis_info_mapping *i){
vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)i;
if(info){
memset(info,0,sizeof(*info));
_ogg_free(info);
free(info);
}
}
@ -71,12 +71,12 @@ static void mapping0_free_look(vorbis_look_mapping *look){
l->residue_func[i]->free_look(l->residue_look[i]);
}
_ogg_free(l->floor_func);
_ogg_free(l->residue_func);
_ogg_free(l->floor_look);
_ogg_free(l->residue_look);
free(l->floor_func);
free(l->residue_func);
free(l->floor_look);
free(l->residue_look);
memset(l,0,sizeof(*l));
_ogg_free(l);
free(l);
}
}
@ -85,16 +85,16 @@ static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode
int i;
vorbis_info *vi=vd->vi;
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)_ogg_calloc(1,sizeof(*look));
vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)calloc(1,sizeof(*look));
vorbis_info_mapping0 *info=look->map=(vorbis_info_mapping0 *)m;
look->mode=vm;
look->floor_look=(vorbis_look_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_look));
look->floor_look=(vorbis_look_floor **)calloc(info->submaps,sizeof(*look->floor_look));
look->residue_look=(vorbis_look_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_look));
look->residue_look=(vorbis_look_residue **)calloc(info->submaps,sizeof(*look->residue_look));
look->floor_func=(vorbis_func_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_func));
look->residue_func=(vorbis_func_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_func));
look->floor_func=(vorbis_func_floor **)calloc(info->submaps,sizeof(*look->floor_func));
look->residue_func=(vorbis_func_residue **)calloc(info->submaps,sizeof(*look->residue_func));
for(i=0;i<info->submaps;i++){
int floornum=info->floorsubmap[i];
@ -127,7 +127,7 @@ static int ilog(unsigned int v){
/* also responsible for range checking */
static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){
int i,b;
vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)_ogg_calloc(1,sizeof(*info));
vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)calloc(1,sizeof(*info));
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
memset(info,0,sizeof(*info));
@ -194,7 +194,7 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
int i,j;
long n=vb->pcmend=ci->blocksizes[vb->W];
ogg_int32_t **pcmbundle=(ogg_int32_t **)alloca(sizeof(*pcmbundle)*vi->channels);
int32_t **pcmbundle=(int32_t **)alloca(sizeof(*pcmbundle)*vi->channels);
int *zerobundle=(int *)alloca(sizeof(*zerobundle)*vi->channels);
int *nonzero =(int *)alloca(sizeof(*nonzero)*vi->channels);
@ -249,12 +249,12 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
/* channel coupling */
for(i=info->coupling_steps-1;i>=0;i--){
ogg_int32_t *pcmM=vb->pcm[info->coupling_mag[i]];
ogg_int32_t *pcmA=vb->pcm[info->coupling_ang[i]];
int32_t *pcmM=vb->pcm[info->coupling_mag[i]];
int32_t *pcmA=vb->pcm[info->coupling_ang[i]];
for(j=0;j<n/2;j++){
ogg_int32_t mag=pcmM[j];
ogg_int32_t ang=pcmA[j];
int32_t mag=pcmM[j];
int32_t ang=pcmA[j];
if(mag>0)
if(ang>0){
@ -280,7 +280,7 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
/* compute and apply spectral envelope */
for(i=0;i<vi->channels;i++){
ogg_int32_t *pcm=vb->pcm[i];
int32_t *pcm=vb->pcm[i];
int submap=info->chmuxlist[i];
look->floor_func[submap]->
inverse2(vb,look->floor_look[submap],floormemo[i],pcm);
@ -292,7 +292,7 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
/* transform the PCM data; takes PCM vector, vb; modifies PCM vector */
/* only MDCT right now.... */
for(i=0;i<vi->channels;i++){
ogg_int32_t *pcm=vb->pcm[i];
int32_t *pcm=vb->pcm[i];
mdct_backward(n,pcm,pcm);
}
@ -301,7 +301,7 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
/* window the data */
for(i=0;i<vi->channels;i++){
ogg_int32_t *pcm=vb->pcm[i];
int32_t *pcm=vb->pcm[i];
if(nonzero[i])
_vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
else

View File

@ -0,0 +1,8 @@
mednafen/tremor/mapping0.o: mednafen/tremor/mapping0.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ogg.h mednafen/tremor/ivorbiscodec.h \
mednafen/tremor/mdct.h mednafen/tremor/misc.h mednafen/tremor/os.h \
libretro-common/include/retro_inline.h mednafen/tremor/asm_arm.h \
mednafen/tremor/codec_internal.h mednafen/tremor/codebook.h \
mednafen/tremor/window.h mednafen/tremor/registry.h \
mednafen/tremor/backends.h

View File

@ -13,7 +13,7 @@
function: normalized modified discrete cosine transform
power of two length transform only [64 <= n ]
last mod: $Id: mdct.c 19172 2014-06-24 14:44:34Z xiphmont $
last mod: $Id: mdct.c,v 1.9 2002/10/16 09:17:39 xiphmont Exp $
Original algorithm adapted long ago from _The use of multirate filter
banks for coding of high quality digital audio_, by T. Sporer,
@ -40,7 +40,7 @@
/* 8 point butterfly (in place) */
STIN void mdct_butterfly_8(DATA_TYPE *x){
static INLINE void mdct_butterfly_8(DATA_TYPE *x){
REG_TYPE r0 = x[4] + x[0];
REG_TYPE r1 = x[4] - x[0];
@ -63,7 +63,7 @@ STIN void mdct_butterfly_8(DATA_TYPE *x){
}
/* 16 point butterfly (in place, 4 register) */
STIN void mdct_butterfly_16(DATA_TYPE *x){
static INLINE void mdct_butterfly_16(DATA_TYPE *x){
REG_TYPE r0, r1;
@ -94,7 +94,7 @@ STIN void mdct_butterfly_16(DATA_TYPE *x){
}
/* 32 point butterfly (in place, 4 register) */
STIN void mdct_butterfly_32(DATA_TYPE *x){
static INLINE void mdct_butterfly_32(DATA_TYPE *x){
REG_TYPE r0, r1;
@ -145,7 +145,7 @@ STIN void mdct_butterfly_32(DATA_TYPE *x){
}
/* N/stage point generic N stage butterfly (in place, 2 register) */
STIN void mdct_butterfly_generic(DATA_TYPE *x,int points,int step){
static INLINE void mdct_butterfly_generic(DATA_TYPE *x,int points,int step){
LOOKUP_T *T = sincos_lookup0;
DATA_TYPE *x1 = x + points - 8;
@ -231,7 +231,7 @@ STIN void mdct_butterfly_generic(DATA_TYPE *x,int points,int step){
}while(T>sincos_lookup0);
}
STIN void mdct_butterflies(DATA_TYPE *x,int points,int shift){
static INLINE void mdct_butterflies(DATA_TYPE *x,int points,int shift){
int stages=8-shift;
int i,j;
@ -248,11 +248,11 @@ STIN void mdct_butterflies(DATA_TYPE *x,int points,int shift){
static unsigned char bitrev[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
STIN int bitrev12(int x){
static INLINE int bitrev12(int x){
return bitrev[x>>8]|(bitrev[(x&0x0f0)>>4]<<4)|(((int)bitrev[x&0x00f])<<8);
}
STIN void mdct_bitreverse(DATA_TYPE *x,int n,int step,int shift){
static INLINE void mdct_bitreverse(DATA_TYPE *x,int n,int step,int shift){
int bit = 0;
DATA_TYPE *w0 = x;

6
mednafen/tremor/mdct.d Normal file
View File

@ -0,0 +1,6 @@
mednafen/tremor/mdct.o: mednafen/tremor/mdct.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ivorbiscodec.h mednafen/tremor/ogg.h \
mednafen/tremor/codebook.h mednafen/tremor/misc.h mednafen/tremor/os.h \
libretro-common/include/retro_inline.h mednafen/tremor/asm_arm.h \
mednafen/tremor/mdct.h mednafen/tremor/mdct_lookup.h

View File

@ -21,8 +21,8 @@
#include "ivorbiscodec.h"
#include "misc.h"
#define DATA_TYPE ogg_int32_t
#define REG_TYPE register ogg_int32_t
#define DATA_TYPE int32_t
#define REG_TYPE register int32_t
#ifdef _LOW_ACCURACY_
#define cPI3_8 (0x0062)

View File

@ -18,7 +18,7 @@
#include "misc.h"
/* {sin(2*i*PI/4096), cos(2*i*PI/4096)}, with i = 0 to 512 */
static const LOOKUP_T sincos_lookup0[1026] = {
static LOOKUP_T sincos_lookup0[1026] = {
X(0x00000000), X(0x7fffffff), X(0x003243f5), X(0x7ffff621),
X(0x006487e3), X(0x7fffd886), X(0x0096cbc1), X(0x7fffa72c),
X(0x00c90f88), X(0x7fff6216), X(0x00fb5330), X(0x7fff0943),
@ -279,7 +279,7 @@ static const LOOKUP_T sincos_lookup0[1026] = {
};
/* {sin((2*i+1)*PI/4096), cos((2*i+1)*PI/4096)}, with i = 0 to 511 */
static const LOOKUP_T sincos_lookup1[1024] = {
static LOOKUP_T sincos_lookup1[1024] = {
X(0x001921fb), X(0x7ffffd88), X(0x004b65ee), X(0x7fffe9cb),
X(0x007da9d4), X(0x7fffc251), X(0x00afeda8), X(0x7fff8719),
X(0x00e23160), X(0x7fff3824), X(0x011474f6), X(0x7ffed572),

View File

@ -19,13 +19,14 @@
#define _V_RANDOM_H_
#include "ivorbiscodec.h"
#include "os.h"
#include <stdint.h>
#ifdef _LOW_ACCURACY_
# define X(n) (((((n)>>22)+1)>>1) - ((((n)>>22)+1)>>9))
# define LOOKUP_T const unsigned char
# define LOOKUP_T const uint8_t
#else
# define X(n) (n)
# define LOOKUP_T const ogg_int32_t
# define LOOKUP_T const int32_t
#endif
#include "asm_arm.h"
@ -41,40 +42,38 @@
#include <sys/types.h>
#endif
#if OGG_BYTE_ORDER==OGG_LITTLE_ENDIAN
#ifdef MSB_FIRST
union magic {
struct {
ogg_int32_t lo;
ogg_int32_t hi;
int32_t hi;
int32_t lo;
} halves;
ogg_int64_t whole;
int64_t whole;
};
#endif
#if OGG_BYTE_ORDER==OGG_BIG_ENDIAN
#else
union magic {
struct {
ogg_int32_t hi;
ogg_int32_t lo;
int32_t lo;
int32_t hi;
} halves;
ogg_int64_t whole;
int64_t whole;
};
#endif
STIN ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
static INLINE int32_t MULT32(int32_t x, int32_t y) {
union magic magic;
magic.whole = (ogg_int64_t)x * y;
magic.whole = (int64_t)x * y;
return magic.halves.hi;
}
STIN ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
static INLINE int32_t MULT31(int32_t x, int32_t y) {
return MULT32(x,y)<<1;
}
STIN ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
static INLINE int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
union magic magic;
magic.whole = (ogg_int64_t)x * y;
return ((ogg_uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17);
magic.whole = (int64_t)x * y;
return ((uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17);
}
#else
@ -93,15 +92,15 @@ STIN ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
* tables in this case.
*/
STIN ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
static INLINE int32_t MULT32(int32_t x, int32_t y) {
return (x >> 9) * y; /* y preshifted >>23 */
}
STIN ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
static INLINE int32_t MULT31(int32_t x, int32_t y) {
return (x >> 8) * y; /* y preshifted >>23 */
}
STIN ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
static INLINE int32_t MULT31_SHIFT15(int32_t x, int32_t y) {
return (x >> 6) * y; /* y preshifted >>9 */
}
@ -138,25 +137,25 @@ STIN ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
#else
STIN void XPROD32(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
static INLINE void XPROD32(int32_t a, int32_t b,
int32_t t, int32_t v,
int32_t *x, int32_t *y)
{
*x = MULT32(a, t) + MULT32(b, v);
*y = MULT32(b, t) - MULT32(a, v);
}
STIN void XPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
static INLINE void XPROD31(int32_t a, int32_t b,
int32_t t, int32_t v,
int32_t *x, int32_t *y)
{
*x = MULT31(a, t) + MULT31(b, v);
*y = MULT31(b, t) - MULT31(a, v);
}
STIN void XNPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
static INLINE void XNPROD31(int32_t a, int32_t b,
int32_t t, int32_t v,
int32_t *x, int32_t *y)
{
*x = MULT31(a, t) - MULT31(b, v);
*y = MULT31(b, t) + MULT31(a, v);
@ -169,7 +168,7 @@ STIN void XNPROD31(ogg_int32_t a, ogg_int32_t b,
#ifndef _V_CLIP_MATH
#define _V_CLIP_MATH
STIN ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
static INLINE int32_t CLIP_TO_15(int32_t x) {
int ret=x;
ret-= ((x<=32767)-1)&(x-32767);
ret-= ((x>=-32768)-1)&(x+32768);
@ -178,10 +177,11 @@ STIN ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
#endif
STIN ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
ogg_int32_t b,ogg_int32_t bp,
ogg_int32_t *p){
if(a && b){
static INLINE int32_t VFLOAT_MULT(int32_t a,int32_t ap,
int32_t b,int32_t bp,
int32_t *p){
if(a && b)
{
#ifndef _LOW_ACCURACY_
*p=ap+bp+32;
return MULT32(a,b);
@ -189,23 +189,23 @@ STIN ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
*p=ap+bp+31;
return (a>>15)*(b>>16);
#endif
}else
return 0;
}
return 0;
}
int _ilog(unsigned int);
STIN ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap,
ogg_int32_t i,
ogg_int32_t *p){
static INLINE int32_t VFLOAT_MULTI(int32_t a,int32_t ap,
int32_t i,
int32_t *p){
int ip=_ilog(abs(i))-31;
return VFLOAT_MULT(a,ap,i<<-ip,ip,p);
}
STIN ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap,
ogg_int32_t b,ogg_int32_t bp,
ogg_int32_t *p){
static INLINE int32_t VFLOAT_ADD(int32_t a,int32_t ap,
int32_t b,int32_t bp,
int32_t *p){
if(!a){
*p=bp;

View File

@ -21,8 +21,8 @@
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "os_types.h"
typedef struct {
void *iov_base;
@ -58,7 +58,7 @@ typedef struct {
int *lacing_vals; /* The values that will go to the segment table */
ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
int64_t *granule_vals; /* granulepos values for headers. Not compact
this way, but it is simple coupled to the
lacing fifo */
long lacing_storage;
@ -75,12 +75,12 @@ typedef struct {
of a logical bitstream */
long serialno;
long pageno;
ogg_int64_t packetno; /* sequence number for decode; the framing
int64_t packetno; /* sequence number for decode; the framing
knows where there's a hole in the data,
but we need coupling so that the codec
(which is in a separate abstraction
layer) also knows about the gap */
ogg_int64_t granulepos;
int64_t granulepos;
} ogg_stream_state;
@ -93,9 +93,9 @@ typedef struct {
long b_o_s;
long e_o_s;
ogg_int64_t granulepos;
int64_t granulepos;
ogg_int64_t packetno; /* sequence number for decode; the framing
int64_t packetno; /* sequence number for decode; the framing
knows where there's a hole in the data,
but we need coupling so that the codec
(which is in a separate abstraction
@ -157,7 +157,7 @@ extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b);
extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov,
int count, long e_o_s, ogg_int64_t granulepos);
int count, long e_o_s, int64_t granulepos);
extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
extern int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill);
extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
@ -195,7 +195,7 @@ extern int ogg_page_version(const ogg_page *og);
extern int ogg_page_continued(const ogg_page *og);
extern int ogg_page_bos(const ogg_page *og);
extern int ogg_page_eos(const ogg_page *og);
extern ogg_int64_t ogg_page_granulepos(const ogg_page *og);
extern int64_t ogg_page_granulepos(const ogg_page *og);
extern int ogg_page_serialno(const ogg_page *og);
extern long ogg_page_pageno(const ogg_page *og);
extern int ogg_page_packets(const ogg_page *og);

View File

@ -17,20 +17,10 @@
********************************************************************/
#include <stdint.h>
#include <math.h>
#include "os_types.h"
#ifndef _V_IFDEFJAIL_H_
# define _V_IFDEFJAIL_H_
# ifdef __GNUC__
# define STIN static __inline__
# elif _WIN32
# define STIN static __inline
# endif
#else
# define STIN static
#endif
#include <retro_inline.h>
#ifndef M_PI
# define M_PI (3.1415926536f)
@ -51,12 +41,4 @@
# include <memory.h>
#endif
#ifndef min
# define min(x,y) ((x)>(y)?(y):(x))
#endif
#ifndef max
# define max(x,y) ((x)<(y)?(y):(x))
#endif
#endif /* _OS_H */

View File

@ -1,54 +0,0 @@
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: #ifdef jail to whip a few platforms into the UNIX ideal.
last mod: $Id: os_types.h 17712 2010-12-03 17:10:02Z xiphmont $
********************************************************************/
/*
Modified for usage in Mednafen
*/
#ifndef _OS_TYPES_H
#define _OS_TYPES_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define OGG_BIG_ENDIAN 4321
#define OGG_LITTLE_ENDIAN 1234
#ifdef MSB_FIRST
#define OGG_BYTE_ORDER OGG_BIG_ENDIAN
#else
#define OGG_BYTE_ORDER OGG_LITTLE_ENDIAN
#endif
/* make it easy on the folks that want to compile the libs with a
different malloc than stdlib */
#define _ogg_malloc malloc
#define _ogg_calloc calloc
#define _ogg_realloc realloc
#define _ogg_free free
#include <inttypes.h>
typedef int16_t ogg_int16_t;
typedef uint16_t ogg_uint16_t;
typedef int32_t ogg_int32_t;
typedef uint32_t ogg_uint32_t;
typedef int64_t ogg_int64_t;
typedef uint64_t ogg_uint64_t;
#endif /* _OS_TYPES_H */

View File

@ -0,0 +1,7 @@
mednafen/tremor/registry.o: mednafen/tremor/registry.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ivorbiscodec.h mednafen/tremor/ogg.h \
mednafen/tremor/codec_internal.h mednafen/tremor/codebook.h \
mednafen/tremor/registry.h mednafen/tremor/backends.h \
mednafen/tremor/misc.h mednafen/tremor/os.h \
libretro-common/include/retro_inline.h mednafen/tremor/asm_arm.h

View File

@ -46,7 +46,7 @@ void res0_free_info(vorbis_info_residue *i){
vorbis_info_residue0 *info=(vorbis_info_residue0 *)i;
if(info){
memset(info,0,sizeof(*info));
_ogg_free(info);
free(info);
}
}
@ -57,14 +57,15 @@ void res0_free_look(vorbis_look_residue *i){
vorbis_look_residue0 *look=(vorbis_look_residue0 *)i;
for(j=0;j<look->parts;j++)
if(look->partbooks[j])_ogg_free(look->partbooks[j]);
_ogg_free(look->partbooks);
if(look->partbooks[j])
free(look->partbooks[j]);
free(look->partbooks);
for(j=0;j<look->partvals;j++)
_ogg_free(look->decodemap[j]);
_ogg_free(look->decodemap);
free(look->decodemap[j]);
free(look->decodemap);
memset(look,0,sizeof(*look));
_ogg_free(look);
free(look);
}
}
@ -89,7 +90,7 @@ static int icount(unsigned int v){
/* vorbis_info is for range checking */
vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){
int j,acc=0;
vorbis_info_residue0 *info=(vorbis_info_residue0 *)_ogg_calloc(1,sizeof(*info));
vorbis_info_residue0 *info=(vorbis_info_residue0 *)calloc(1,sizeof(*info));
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
info->begin=oggpack_read(opb,24);
@ -154,7 +155,7 @@ vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){
vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
vorbis_info_residue *vr){
vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
vorbis_look_residue0 *look=(vorbis_look_residue0 *)_ogg_calloc(1,sizeof(*look));
vorbis_look_residue0 *look=(vorbis_look_residue0 *)calloc(1,sizeof(*look));
codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
int j,k,acc=0;
@ -168,13 +169,13 @@ vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
look->phrasebook=ci->fullbooks+info->groupbook;
dim=look->phrasebook->dim;
look->partbooks=(codebook ***)_ogg_calloc(look->parts,sizeof(*look->partbooks));
look->partbooks=(codebook ***)calloc(look->parts,sizeof(*look->partbooks));
for(j=0;j<look->parts;j++){
int stages=ilog(info->secondstages[j]);
if(stages){
if(stages>maxstage)maxstage=stages;
look->partbooks[j]=(codebook **)_ogg_calloc(stages,sizeof(*look->partbooks[j]));
look->partbooks[j]=(codebook **)calloc(stages,sizeof(*look->partbooks[j]));
for(k=0;k<stages;k++)
if(info->secondstages[j]&(1<<k)){
look->partbooks[j][k]=ci->fullbooks+info->booklist[acc++];
@ -189,11 +190,11 @@ vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
look->partvals=look->parts;
for(j=1;j<dim;j++)look->partvals*=look->parts;
look->stages=maxstage;
look->decodemap=(int **)_ogg_malloc(look->partvals*sizeof(*look->decodemap));
look->decodemap=(int **)malloc(look->partvals*sizeof(*look->decodemap));
for(j=0;j<look->partvals;j++){
long val=j;
long mult=look->partvals/look->parts;
look->decodemap[j]=(int *)_ogg_malloc(dim*sizeof(*look->decodemap[j]));
look->decodemap[j]=(int *)malloc(dim*sizeof(*look->decodemap[j]));
for(k=0;k<dim;k++){
long deco=val/mult;
val-=deco*mult;
@ -208,8 +209,8 @@ vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
/* a truncated packet here just means 'stop working'; it's not an error */
static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
ogg_int32_t **in,int ch,
long (*decodepart)(codebook *, ogg_int32_t *,
int32_t **in,int ch,
long (*decodepart)(codebook *, int32_t *,
oggpack_buffer *,int,int)){
long i,j,k,l,s;
@ -267,7 +268,7 @@ static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
}
int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,
ogg_int32_t **in,int *nonzero,int ch){
int32_t **in,int *nonzero,int ch){
int i,used=0;
for(i=0;i<ch;i++)
if(nonzero[i])
@ -279,7 +280,7 @@ int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,
}
int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,
ogg_int32_t **in,int *nonzero,int ch){
int32_t **in,int *nonzero,int ch){
int i,used=0;
for(i=0;i<ch;i++)
if(nonzero[i])
@ -292,7 +293,7 @@ int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,
/* duplicate code here as speed is somewhat more important */
int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
ogg_int32_t **in,int *nonzero,int ch){
int32_t **in,int *nonzero,int ch){
long i,k,l,s;
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
vorbis_info_residue0 *info=look->info;

8
mednafen/tremor/res012.d Normal file
View File

@ -0,0 +1,8 @@
mednafen/tremor/res012.o: mednafen/tremor/res012.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ogg.h mednafen/tremor/ivorbiscodec.h \
mednafen/tremor/codec_internal.h mednafen/tremor/codebook.h \
mednafen/tremor/registry.h mednafen/tremor/backends.h \
mednafen/tremor/misc.h mednafen/tremor/os.h \
libretro-common/include/retro_inline.h mednafen/tremor/asm_arm.h \
mednafen/tremor/block.h

View File

@ -41,7 +41,7 @@ int _ilog(unsigned int v){
#define VQ_FMAN 21
#define VQ_FEXP_BIAS 768 /* bias toward values smaller than 1. */
static ogg_int32_t _float32_unpack(long val,int *point){
static int32_t _float32_unpack(long val,int *point){
long mant=val&0x1fffff;
int sign=val&0x80000000;
long exp =(val&0x7fe00000L)>>VQ_FMAN;
@ -67,16 +67,16 @@ static ogg_int32_t _float32_unpack(long val,int *point){
/* given a list of word lengths, generate a list of codewords. Works
for length ordered or unordered, always assigns the lowest valued
codewords first. Extended to handle unused entries (length 0) */
ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
uint32_t *_make_words(long *l,long n,long sparsecount){
long i,j,count=0;
ogg_uint32_t marker[33];
ogg_uint32_t *r=(ogg_uint32_t *)_ogg_malloc((sparsecount?sparsecount:n)*sizeof(*r));
uint32_t marker[33];
uint32_t *r=(uint32_t *)malloc((sparsecount?sparsecount:n)*sizeof(*r));
memset(marker,0,sizeof(marker));
for(i=0;i<n;i++){
long length=l[i];
if(length>0){
ogg_uint32_t entry=marker[length];
uint32_t entry=marker[length];
/* when we claim a node for an entry, we also claim the nodes
below it (pruning off the imagined tree that may have dangled
@ -84,10 +84,11 @@ ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
above for leaves */
/* update ourself */
if(length<32 && (entry>>length)){
/* error condition; the lengths must specify an overpopulated tree */
_ogg_free(r);
return(NULL);
if(length<32 && (entry>>length))
{
/* error condition; the lengths must specify an overpopulated tree */
free(r);
return(NULL);
}
r[count++]=entry;
@ -127,18 +128,20 @@ ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
which appears to be underpopulated because the tree doesn't
really exist; there's only one possible 'codeword' or zero bits,
but the above tree-gen code doesn't mark that. */
if(sparsecount != 1){
for(i=1;i<33;i++)
if(marker[i] & (0xffffffffUL>>(32-i))){
_ogg_free(r);
return(NULL);
}
if(sparsecount != 1)
{
for(i=1;i<33;i++)
if(marker[i] & (0xffffffffUL>>(32-i)))
{
free(r);
return(NULL);
}
}
/* bitreverse the words because our bitwise packer/unpacker is LSb
endian */
for(i=0,count=0;i<n;i++){
ogg_uint32_t temp=0;
uint32_t temp=0;
for(j=0;j<l[i];j++){
temp<<=1;
temp|=(r[count]>>j)&1;
@ -191,130 +194,140 @@ long _book_maptype1_quantvals(const static_codebook *b){
the values in the quant vector). in map type 2, all the values came
in in an explicit list. Both value lists must be unpacked */
ogg_int32_t *_book_unquantize(const static_codebook *b,int n,int *sparsemap,
int *maxpoint){
long j,k,count=0;
if(b->maptype==1 || b->maptype==2){
int quantvals;
int minpoint,delpoint;
ogg_int32_t mindel=_float32_unpack(b->q_min,&minpoint);
ogg_int32_t delta=_float32_unpack(b->q_delta,&delpoint);
ogg_int32_t *r=(ogg_int32_t *)_ogg_calloc(n*b->dim,sizeof(*r));
int *rp=(int *)_ogg_calloc(n*b->dim,sizeof(*rp));
int32_t *_book_unquantize(const static_codebook *b,int n,int *sparsemap,
int *maxpoint)
{
long j,k,count=0;
if(b->maptype==1 || b->maptype==2)
{
int quantvals;
int minpoint,delpoint;
int32_t mindel=_float32_unpack(b->q_min,&minpoint);
int32_t delta=_float32_unpack(b->q_delta,&delpoint);
int32_t *r=(int32_t *)calloc(n*b->dim,sizeof(*r));
int *rp=(int *)calloc(n*b->dim,sizeof(*rp));
*maxpoint=minpoint;
*maxpoint=minpoint;
/* maptype 1 and 2 both use a quantized value vector, but
different sizes */
switch(b->maptype){
case 1:
/* most of the time, entries%dimensions == 0, but we need to be
well defined. We define that the possible vales at each
scalar is values == entries/dim. If entries%dim != 0, we'll
have 'too few' values (values*dim<entries), which means that
we'll have 'left over' entries; left over entries use zeroed
values (and are wasted). So don't generate codebooks like
that */
quantvals=_book_maptype1_quantvals(b);
for(j=0;j<b->entries;j++){
if((sparsemap && b->lengthlist[j]) || !sparsemap){
ogg_int32_t last=0;
int lastpoint=0;
int indexdiv=1;
for(k=0;k<b->dim;k++){
int index= (j/indexdiv)%quantvals;
int point=0;
int val=VFLOAT_MULTI(delta,delpoint,
abs(b->quantlist[index]),&point);
/* maptype 1 and 2 both use a quantized value vector, but
different sizes */
switch(b->maptype){
case 1:
/* most of the time, entries%dimensions == 0, but we need to be
well defined. We define that the possible vales at each
scalar is values == entries/dim. If entries%dim != 0, we'll
have 'too few' values (values*dim<entries), which means that
we'll have 'left over' entries; left over entries use zeroed
values (and are wasted). So don't generate codebooks like
that */
quantvals=_book_maptype1_quantvals(b);
for(j=0;j<b->entries;j++){
if((sparsemap && b->lengthlist[j]) || !sparsemap){
int32_t last=0;
int lastpoint=0;
int indexdiv=1;
for(k=0;k<b->dim;k++){
int index= (j/indexdiv)%quantvals;
int point=0;
int val=VFLOAT_MULTI(delta,delpoint,
abs(b->quantlist[index]),&point);
val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
val=VFLOAT_ADD(last,lastpoint,val,point,&point);
if(b->q_sequencep){
last=val;
lastpoint=point;
}
if(sparsemap){
r[sparsemap[count]*b->dim+k]=val;
rp[sparsemap[count]*b->dim+k]=point;
}else{
r[count*b->dim+k]=val;
rp[count*b->dim+k]=point;
}
if(*maxpoint<point)*maxpoint=point;
indexdiv*=quantvals;
}
count++;
}
val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
val=VFLOAT_ADD(last,lastpoint,val,point,&point);
if(b->q_sequencep){
last=val;
lastpoint=point;
}
if(sparsemap){
r[sparsemap[count]*b->dim+k]=val;
rp[sparsemap[count]*b->dim+k]=point;
}else{
r[count*b->dim+k]=val;
rp[count*b->dim+k]=point;
}
if(*maxpoint<point)*maxpoint=point;
indexdiv*=quantvals;
}
count++;
}
}
break;
case 2:
for(j=0;j<b->entries;j++){
if((sparsemap && b->lengthlist[j]) || !sparsemap){
int32_t last=0;
int lastpoint=0;
for(k=0;k<b->dim;k++){
int point=0;
int val=VFLOAT_MULTI(delta,delpoint,
abs(b->quantlist[j*b->dim+k]),&point);
val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
val=VFLOAT_ADD(last,lastpoint,val,point,&point);
if(b->q_sequencep){
last=val;
lastpoint=point;
}
if(sparsemap){
r[sparsemap[count]*b->dim+k]=val;
rp[sparsemap[count]*b->dim+k]=point;
}else{
r[count*b->dim+k]=val;
rp[count*b->dim+k]=point;
}
if(*maxpoint<point)*maxpoint=point;
}
count++;
}
}
break;
}
break;
case 2:
for(j=0;j<b->entries;j++){
if((sparsemap && b->lengthlist[j]) || !sparsemap){
ogg_int32_t last=0;
int lastpoint=0;
for(k=0;k<b->dim;k++){
int point=0;
int val=VFLOAT_MULTI(delta,delpoint,
abs(b->quantlist[j*b->dim+k]),&point);
for(j=0;j<n*b->dim;j++)
if(rp[j]<*maxpoint)
r[j]>>=*maxpoint-rp[j];
val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
val=VFLOAT_ADD(last,lastpoint,val,point,&point);
if(b->q_sequencep){
last=val;
lastpoint=point;
}
if(sparsemap){
r[sparsemap[count]*b->dim+k]=val;
rp[sparsemap[count]*b->dim+k]=point;
}else{
r[count*b->dim+k]=val;
rp[count*b->dim+k]=point;
}
if(*maxpoint<point)*maxpoint=point;
}
count++;
}
}
break;
}
for(j=0;j<n*b->dim;j++)
if(rp[j]<*maxpoint)
r[j]>>=*maxpoint-rp[j];
_ogg_free(rp);
return(r);
}
return(NULL);
free(rp);
return(r);
}
return(NULL);
}
void vorbis_staticbook_destroy(static_codebook *b){
if(b->quantlist)_ogg_free(b->quantlist);
if(b->lengthlist)_ogg_free(b->lengthlist);
memset(b,0,sizeof(*b));
_ogg_free(b);
void vorbis_staticbook_destroy(static_codebook *b)
{
if(b->quantlist)
free(b->quantlist);
if(b->lengthlist)
free(b->lengthlist);
memset(b,0,sizeof(*b));
free(b);
}
void vorbis_book_clear(codebook *b){
/* static book is not cleared; we're likely called on the lookup and
the static codebook belongs to the info struct */
if(b->valuelist)_ogg_free(b->valuelist);
if(b->codelist)_ogg_free(b->codelist);
if(b->valuelist)
free(b->valuelist);
if(b->codelist)
free(b->codelist);
if(b->dec_index)_ogg_free(b->dec_index);
if(b->dec_codelengths)_ogg_free(b->dec_codelengths);
if(b->dec_firsttable)_ogg_free(b->dec_firsttable);
if(b->dec_index)
free(b->dec_index);
if(b->dec_codelengths)
free(b->dec_codelengths);
if(b->dec_firsttable)
free(b->dec_firsttable);
memset(b,0,sizeof(*b));
}
static ogg_uint32_t bitreverse(ogg_uint32_t x){
static uint32_t bitreverse(uint32_t x){
x= ((x>>16)&0x0000ffffUL) | ((x<<16)&0xffff0000UL);
x= ((x>> 8)&0x00ff00ffUL) | ((x<< 8)&0xff00ff00UL);
x= ((x>> 4)&0x0f0f0f0fUL) | ((x<< 4)&0xf0f0f0f0UL);
@ -323,8 +336,8 @@ static ogg_uint32_t bitreverse(ogg_uint32_t x){
}
static int sort32a(const void *a,const void *b){
return (**(ogg_uint32_t **)a>**(ogg_uint32_t **)b)-
(**(ogg_uint32_t **)a<**(ogg_uint32_t **)b);
return (**(uint32_t **)a>**(uint32_t **)b)-
(**(uint32_t **)a<**(uint32_t **)b);
}
/* decode codebook arrangement is more heavily optimized than encode */
@ -354,8 +367,8 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
by sorted bitreversed codeword to allow treeless decode. */
/* perform sort */
ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries);
ogg_uint32_t **codep=(ogg_uint32_t **)alloca(sizeof(*codep)*n);
uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries);
uint32_t **codep=(uint32_t **)alloca(sizeof(*codep)*n);
if(codes==NULL)goto err_out;
@ -367,7 +380,7 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
qsort(codep,n,sizeof(*codep),sort32a);
sortindex=(int *)alloca(n*sizeof(*sortindex));
c->codelist=(ogg_uint32_t *)_ogg_malloc(n*sizeof(*c->codelist));
c->codelist=(uint32_t *)malloc(n*sizeof(*c->codelist));
/* the index is a reverse index */
for(i=0;i<n;i++){
int position=codep[i]-codes;
@ -376,18 +389,16 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
for(i=0;i<n;i++)
c->codelist[sortindex[i]]=codes[i];
_ogg_free(codes);
free(codes);
c->valuelist=_book_unquantize(s,n,sortindex,&c->binarypoint);
c->dec_index=(int *)_ogg_malloc(n*sizeof(*c->dec_index));
c->dec_index=(int *)malloc(n*sizeof(*c->dec_index));
for(n=0,i=0;i<s->entries;i++)
if(s->lengthlist[i]>0)
c->dec_index[sortindex[n++]]=i;
c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths));
c->dec_codelengths=(char *)malloc(n*sizeof(*c->dec_codelengths));
for(n=0,i=0;i<s->entries;i++)
if(s->lengthlist[i]>0)
c->dec_codelengths[sortindex[n++]]=s->lengthlist[i];
@ -397,14 +408,14 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
if(c->dec_firsttablen>8)c->dec_firsttablen=8;
tabn=1<<c->dec_firsttablen;
c->dec_firsttable=(ogg_uint32_t *)_ogg_calloc(tabn,sizeof(*c->dec_firsttable));
c->dec_firsttable=(uint32_t *)calloc(tabn,sizeof(*c->dec_firsttable));
c->dec_maxlength=0;
for(i=0;i<n;i++){
if(c->dec_maxlength<c->dec_codelengths[i])
c->dec_maxlength=c->dec_codelengths[i];
if(c->dec_codelengths[i]<=c->dec_firsttablen){
ogg_uint32_t orig=bitreverse(c->codelist[i]);
uint32_t orig=bitreverse(c->codelist[i]);
for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++)
c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1;
}
@ -413,11 +424,11 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
/* now fill in 'unused' entries in the firsttable with hi/lo search
hints for the non-direct-hits */
{
ogg_uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen);
uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen);
long lo=0,hi=0;
for(i=0;i<tabn;i++){
ogg_uint32_t word=i<<(32-c->dec_firsttablen);
uint32_t word=i<<(32-c->dec_firsttablen);
if(c->dec_firsttable[bitreverse(word)]==0){
while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
while( hi<n && word>=(c->codelist[hi]&mask))hi++;

View File

@ -0,0 +1,6 @@
mednafen/tremor/sharedbook.o: mednafen/tremor/sharedbook.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ogg.h mednafen/tremor/misc.h \
mednafen/tremor/ivorbiscodec.h mednafen/tremor/os.h \
libretro-common/include/retro_inline.h mednafen/tremor/asm_arm.h \
mednafen/tremor/codebook.h

View File

@ -67,15 +67,15 @@ static int _vorbis_synthesis1(vorbis_block *vb,ogg_packet *op,int decodep){
/* more setup */
vb->granulepos=op->granulepos;
vb->sequence=op->packetno; /* first block is third packet */
vb->sequence=op->packetno-3; /* first block is third packet */
vb->eofflag=op->e_o_s;
if(decodep){
/* alloc pcm passback storage */
vb->pcmend=ci->blocksizes[vb->W];
vb->pcm=(ogg_int32_t **)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels);
vb->pcm=(int32_t **)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels);
for(i=0;i<vi->channels;i++)
vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
vb->pcm[i]=(int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
/* unpack_header enforces range checking */
type=ci->map_type[ci->mode_param[mode]->mapping];
@ -124,7 +124,7 @@ long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){
/* read our mode and pre/post windowsize */
mode=oggpack_read(&opb,modebits);
}
if(mode==-1 || !ci->mode_param[mode])return(OV_EBADPACKET);
if(mode==-1)return(OV_EBADPACKET);
return(ci->blocksizes[ci->mode_param[mode]->blockflag]);
}

View File

@ -0,0 +1,8 @@
mednafen/tremor/synthesis.o: mednafen/tremor/synthesis.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ogg.h mednafen/tremor/ivorbiscodec.h \
mednafen/tremor/codec_internal.h mednafen/tremor/codebook.h \
mednafen/tremor/registry.h mednafen/tremor/backends.h \
mednafen/tremor/misc.h mednafen/tremor/os.h \
libretro-common/include/retro_inline.h mednafen/tremor/asm_arm.h \
mednafen/tremor/block.h

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
mednafen/tremor/vorbisfile.o: mednafen/tremor/vorbisfile.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/ivorbiscodec.h mednafen/tremor/ogg.h \
mednafen/tremor/ivorbisfile.h mednafen/tremor/os.h \
libretro-common/include/retro_inline.h mednafen/tremor/misc.h \
mednafen/tremor/asm_arm.h

View File

@ -52,7 +52,7 @@ const void *_vorbis_window(int type, int left){
}
}
void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2],
void _vorbis_apply_window(int32_t *d,const void *window_p[2],
long *blocksizes,
int lW,int W,int nW){

6
mednafen/tremor/window.d Normal file
View File

@ -0,0 +1,6 @@
mednafen/tremor/window.o: mednafen/tremor/window.c \
lightning-lightrec-include/debug.h libretro-common/include/libretro.h \
mednafen/tremor/misc.h mednafen/tremor/ivorbiscodec.h \
mednafen/tremor/ogg.h mednafen/tremor/os.h \
libretro-common/include/retro_inline.h mednafen/tremor/asm_arm.h \
mednafen/tremor/window.h mednafen/tremor/window_lookup.h

View File

@ -19,7 +19,7 @@
#define _V_WINDOW_
extern const void *_vorbis_window(int type,int left);
extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2],
extern void _vorbis_apply_window(int32_t *d,const void *window[2],
long *blocksizes,
int lW,int W,int nW);

View File

@ -15,10 +15,7 @@
********************************************************************/
#include "os_types.h"
static const LOOKUP_T vwin64[32] = {
static LOOKUP_T vwin64[32] = {
X(0x001f0003), X(0x01168c98), X(0x030333c8), X(0x05dfe3a4),
X(0x09a49562), X(0x0e45df18), X(0x13b47ef2), X(0x19dcf676),
X(0x20a74d83), X(0x27f7137c), X(0x2fabb05a), X(0x37a1105a),
@ -29,7 +26,7 @@ static const LOOKUP_T vwin64[32] = {
X(0x7fdd78a5), X(0x7ff6ec6d), X(0x7ffed0e9), X(0x7ffffc3f),
};
static const LOOKUP_T vwin128[64] = {
static LOOKUP_T vwin128[64] = {
X(0x0007c04d), X(0x0045bb89), X(0x00c18b87), X(0x017ae294),
X(0x02714a4e), X(0x03a4217a), X(0x05129952), X(0x06bbb24f),
X(0x089e38a1), X(0x0ab8c073), X(0x0d09a228), X(0x0f8ef6bd),
@ -48,7 +45,7 @@ static const LOOKUP_T vwin128[64] = {
X(0x7ffdcf39), X(0x7fff6dac), X(0x7fffed01), X(0x7fffffc4),
};
static const LOOKUP_T vwin256[128] = {
static LOOKUP_T vwin256[128] = {
X(0x0001f018), X(0x00117066), X(0x00306e9e), X(0x005ee5f1),
X(0x009ccf26), X(0x00ea208b), X(0x0146cdea), X(0x01b2c87f),
X(0x022dfedf), X(0x02b85ced), X(0x0351cbbd), X(0x03fa317f),
@ -83,7 +80,7 @@ static const LOOKUP_T vwin256[128] = {
X(0x7fffdcd2), X(0x7ffff6d6), X(0x7ffffed0), X(0x7ffffffc),
};
static const LOOKUP_T vwin512[256] = {
static LOOKUP_T vwin512[256] = {
X(0x00007c06), X(0x00045c32), X(0x000c1c62), X(0x0017bc4c),
X(0x00273b7a), X(0x003a9955), X(0x0051d51c), X(0x006cede7),
X(0x008be2a9), X(0x00aeb22a), X(0x00d55b0d), X(0x00ffdbcc),
@ -150,7 +147,7 @@ static const LOOKUP_T vwin512[256] = {
X(0x7ffffdcd), X(0x7fffff6d), X(0x7fffffed), X(0x7fffffff),
};
static const LOOKUP_T vwin1024[512] = {
static LOOKUP_T vwin1024[512] = {
X(0x00001f02), X(0x0001170e), X(0x00030724), X(0x0005ef40),
X(0x0009cf59), X(0x000ea767), X(0x0014775e), X(0x001b3f2e),
X(0x0022fec8), X(0x002bb618), X(0x00356508), X(0x00400b81),
@ -281,7 +278,7 @@ static const LOOKUP_T vwin1024[512] = {
X(0x7fffffdd), X(0x7ffffff7), X(0x7fffffff), X(0x7fffffff),
};
static const LOOKUP_T vwin2048[1024] = {
static LOOKUP_T vwin2048[1024] = {
X(0x000007c0), X(0x000045c4), X(0x0000c1ca), X(0x00017bd3),
X(0x000273de), X(0x0003a9eb), X(0x00051df9), X(0x0006d007),
X(0x0008c014), X(0x000aee1e), X(0x000d5a25), X(0x00100428),
@ -540,7 +537,7 @@ static const LOOKUP_T vwin2048[1024] = {
X(0x7ffffffe), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff),
};
static const LOOKUP_T vwin4096[2048] = {
static LOOKUP_T vwin4096[2048] = {
X(0x000001f0), X(0x00001171), X(0x00003072), X(0x00005ef5),
X(0x00009cf8), X(0x0000ea7c), X(0x00014780), X(0x0001b405),
X(0x0002300b), X(0x0002bb91), X(0x00035698), X(0x0004011e),
@ -1055,7 +1052,7 @@ static const LOOKUP_T vwin4096[2048] = {
X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff),
};
static const LOOKUP_T vwin8192[4096] = {
static LOOKUP_T vwin8192[4096] = {
X(0x0000007c), X(0x0000045c), X(0x00000c1d), X(0x000017bd),
X(0x0000273e), X(0x00003a9f), X(0x000051e0), X(0x00006d02),
X(0x00008c03), X(0x0000aee5), X(0x0000d5a7), X(0x00010049),