forked from len0rd/rockbox
mikmod: Upgrade mikmod core from v3.2.0 to v3.3.11
* Get rid of the non-functional GT2 loader * Add the UMX loader * Add HQ mixer routines (and make it configurable) * Allow samplerate to be configured at run/playtime * Support >64KHz mixing/playback * Correctly restore non-boost status (The diff to upstream is much smaller now too!) Change-Id: Iaa4ac901ba9cd4123bb225656976e78271353a72
This commit is contained in:
parent
8c7780bafc
commit
b4e70422a3
43 changed files with 5072 additions and 2802 deletions
|
@ -6,12 +6,12 @@
|
|||
it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Library General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
|
@ -20,7 +20,7 @@
|
|||
|
||||
/*==============================================================================
|
||||
|
||||
$Id: sloader.c,v 1.3 2007/12/06 17:46:08 denis111 Exp $
|
||||
$Id$
|
||||
|
||||
Routines for loading samples. The sample loader utilizes the routines
|
||||
provided by the "registered" sample loader.
|
||||
|
@ -56,7 +56,7 @@ typedef struct ITPACK {
|
|||
int SL_Init(SAMPLOAD* s)
|
||||
{
|
||||
if(!sl_buffer)
|
||||
if(!(sl_buffer=MikMod_malloc(SLBUFSIZE*sizeof(SWORD)))) return 0;
|
||||
if(!(sl_buffer=(SWORD*)MikMod_malloc(SLBUFSIZE*sizeof(SWORD)))) return 0;
|
||||
|
||||
sl_rlength = s->length;
|
||||
if(s->infmt & SF_16BITS) sl_rlength>>=1;
|
||||
|
@ -68,16 +68,15 @@ int SL_Init(SAMPLOAD* s)
|
|||
void SL_Exit(SAMPLOAD *s)
|
||||
{
|
||||
if(sl_rlength>0) _mm_fseek(s->reader,sl_rlength,SEEK_CUR);
|
||||
if(sl_buffer) {
|
||||
MikMod_free(sl_buffer);
|
||||
sl_buffer=NULL;
|
||||
}
|
||||
|
||||
MikMod_free(sl_buffer);
|
||||
sl_buffer=NULL;
|
||||
}
|
||||
|
||||
/* unpack a 8bit IT packed sample */
|
||||
static int read_itcompr8(ITPACK* status,MREADER *reader,SWORD *sl_buffer,UWORD count,UWORD* incnt)
|
||||
static int read_itcompr8(ITPACK* status,MREADER *reader,SWORD *out,UWORD count,UWORD* incnt)
|
||||
{
|
||||
SWORD *dest=sl_buffer,*end=sl_buffer+count;
|
||||
SWORD *dest=out,*end=out+count;
|
||||
UWORD x,y,needbits,havebits,new_count=0;
|
||||
UWORD bits = status->bits;
|
||||
UWORD bufbits = status->bufbits;
|
||||
|
@ -145,13 +144,13 @@ static int read_itcompr8(ITPACK* status,MREADER *reader,SWORD *sl_buffer,UWORD c
|
|||
status->bufbits = bufbits;
|
||||
status->last = last;
|
||||
status->buf = buf;
|
||||
return (dest-sl_buffer);
|
||||
return (dest-out);
|
||||
}
|
||||
|
||||
/* unpack a 16bit IT packed sample */
|
||||
static int read_itcompr16(ITPACK *status,MREADER *reader,SWORD *sl_buffer,UWORD count,UWORD* incnt)
|
||||
static int read_itcompr16(ITPACK *status,MREADER *reader,SWORD *out,UWORD count,UWORD* incnt)
|
||||
{
|
||||
SWORD *dest=sl_buffer,*end=sl_buffer+count;
|
||||
SWORD *dest=out,*end=out+count;
|
||||
SLONG x,y,needbits,havebits,new_count=0;
|
||||
UWORD bits = status->bits;
|
||||
UWORD bufbits = status->bufbits;
|
||||
|
@ -219,7 +218,7 @@ static int read_itcompr16(ITPACK *status,MREADER *reader,SWORD *sl_buffer,UWORD
|
|||
status->bufbits = bufbits;
|
||||
status->last = last;
|
||||
status->buf = buf;
|
||||
return (dest-sl_buffer);
|
||||
return (dest-out);
|
||||
}
|
||||
|
||||
static int SL_LoadInternal(void* buffer,UWORD infmt,UWORD outfmt,int scalefactor,ULONG length,MREADER* reader,int dither)
|
||||
|
@ -231,9 +230,11 @@ static int SL_LoadInternal(void* buffer,UWORD infmt,UWORD outfmt,int scalefactor
|
|||
int result,c_block=0; /* compression bytes until next block */
|
||||
ITPACK status;
|
||||
UWORD incnt = 0;
|
||||
|
||||
memset(&status, 0, sizeof(status)); /* initialize status */
|
||||
|
||||
|
||||
status.buf = 0;
|
||||
status.last = 0;
|
||||
status.bufbits = 0;
|
||||
status.bits = 0;
|
||||
|
||||
while(length) {
|
||||
stodo=(length<SLBUFSIZE)?length:SLBUFSIZE;
|
||||
|
@ -261,6 +262,10 @@ static int SL_LoadInternal(void* buffer,UWORD infmt,UWORD outfmt,int scalefactor
|
|||
c_block -= stodo;
|
||||
} else {
|
||||
if(infmt&SF_16BITS) {
|
||||
if(_mm_eof(reader)) {
|
||||
_mm_errno=MMERR_NOT_A_STREAM;/* better error? */
|
||||
return 1;
|
||||
}
|
||||
if(infmt&SF_BIG_ENDIAN)
|
||||
_mm_read_M_SWORDS(sl_buffer,stodo,reader);
|
||||
else
|
||||
|
@ -269,6 +274,10 @@ static int SL_LoadInternal(void* buffer,UWORD infmt,UWORD outfmt,int scalefactor
|
|||
SBYTE *src;
|
||||
SWORD *dest;
|
||||
|
||||
if(_mm_eof(reader)) {
|
||||
_mm_errno=MMERR_NOT_A_STREAM;/* better error? */
|
||||
return 1;
|
||||
}
|
||||
reader->Read(reader,sl_buffer,sizeof(SBYTE)*stodo);
|
||||
src = (SBYTE*)sl_buffer;
|
||||
dest = sl_buffer;
|
||||
|
@ -288,7 +297,7 @@ static int SL_LoadInternal(void* buffer,UWORD infmt,UWORD outfmt,int scalefactor
|
|||
sl_old = sl_buffer[t];
|
||||
}
|
||||
|
||||
if((infmt^outfmt) & SF_SIGNED)
|
||||
if((infmt^outfmt) & SF_SIGNED)
|
||||
for(t=0;t<stodo;t++)
|
||||
sl_buffer[t]^= 0x8000;
|
||||
|
||||
|
@ -340,7 +349,7 @@ static int SL_LoadInternal(void* buffer,UWORD infmt,UWORD outfmt,int scalefactor
|
|||
int SL_Load(void* buffer,SAMPLOAD *smp,ULONG length)
|
||||
{
|
||||
return SL_LoadInternal(buffer,smp->infmt,smp->outfmt,smp->scalefactor,
|
||||
length,smp->reader,0);
|
||||
length,smp->reader,0);
|
||||
}
|
||||
|
||||
/* Registers a sample for loading when SL_LoadSamples() is called. */
|
||||
|
@ -357,7 +366,7 @@ SAMPLOAD* SL_RegisterSample(SAMPLE* s,int type,MREADER* reader)
|
|||
cruise = sndfxlist;
|
||||
} else
|
||||
return NULL;
|
||||
|
||||
|
||||
/* Allocate and add structure to the END of the list */
|
||||
if(!(news=(SAMPLOAD*)MikMod_malloc(sizeof(SAMPLOAD)))) return NULL;
|
||||
|
||||
|
@ -407,7 +416,7 @@ static ULONG SampleTotal(SAMPLOAD* samplist,int type)
|
|||
static ULONG RealSpeed(SAMPLOAD *s)
|
||||
{
|
||||
return(s->sample->speed/(s->scalefactor?s->scalefactor:1));
|
||||
}
|
||||
}
|
||||
|
||||
static int DitherSamples(SAMPLOAD* samplist,int type)
|
||||
{
|
||||
|
@ -417,7 +426,7 @@ static int DitherSamples(SAMPLOAD* samplist,int type)
|
|||
|
||||
if(!samplist) return 0;
|
||||
|
||||
if((maxsize=MD_SampleSpace(type)*1024))
|
||||
if((maxsize=MD_SampleSpace(type)*1024) != 0)
|
||||
while(SampleTotal(samplist,type)>maxsize) {
|
||||
/* First Pass - check for any 16 bit samples */
|
||||
s = samplist;
|
||||
|
@ -473,15 +482,15 @@ static int DitherSamples(SAMPLOAD* samplist,int type)
|
|||
|
||||
int SL_LoadSamples(void)
|
||||
{
|
||||
int ok;
|
||||
int rc;
|
||||
|
||||
_mm_critical = 0;
|
||||
|
||||
if((!musiclist)&&(!sndfxlist)) return 0;
|
||||
ok=DitherSamples(musiclist,MD_MUSIC)||DitherSamples(sndfxlist,MD_SNDFX);
|
||||
rc=DitherSamples(musiclist,MD_MUSIC)||DitherSamples(sndfxlist,MD_SNDFX);
|
||||
musiclist=sndfxlist=NULL;
|
||||
|
||||
return ok;
|
||||
return rc;
|
||||
}
|
||||
|
||||
void SL_Sample16to8(SAMPLOAD* s)
|
||||
|
@ -518,5 +527,4 @@ void SL_HalveSample(SAMPLOAD* s,int factor)
|
|||
s->sample->loopend = s->loopend / s->scalefactor;
|
||||
}
|
||||
|
||||
|
||||
/* ex:set ts=4: */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue