/programs/media/ac97snd/ac97snd/k_lib.asm |
---|
File deleted |
\ No newline at end of file |
/programs/media/ac97snd/ac97snd/proc32.inc |
---|
File deleted |
/programs/media/ac97snd/ac97snd/ac97wav.c |
---|
File deleted |
/programs/media/ac97snd/ac97snd/ac97wav.h |
---|
File deleted |
/programs/media/ac97snd/ac97snd/crt.c |
---|
File deleted |
/programs/media/ac97snd/ac97snd/ac97snd.vcproj |
---|
File deleted |
/programs/media/ac97snd/ac97snd/struct.inc |
---|
File deleted |
/programs/media/ac97snd/ac97snd/crt.h |
---|
File deleted |
/programs/media/ac97snd/mpg/pow.asm |
---|
File deleted |
/programs/media/ac97snd/mpg/layer3.h |
---|
File deleted |
/programs/media/ac97snd/mpg/mpg.vcproj |
---|
File deleted |
/programs/media/ac97snd/mpg/getbits.h |
---|
File deleted |
/programs/media/ac97snd/mpg/e_pow.c |
---|
File deleted |
/programs/media/ac97snd/mpg/l2tables.h |
---|
File deleted |
/programs/media/ac97snd/mpg/mpg123.h |
---|
File deleted |
/programs/media/ac97snd/mpg/readers.c |
---|
File deleted |
/programs/media/ac97snd/mpg/math_private.h |
---|
File deleted |
/programs/media/ac97snd/mpg/huffman.h |
---|
File deleted |
/programs/media/ac97snd/mpg/tabinit.c |
---|
File deleted |
\ No newline at end of file |
/programs/media/ac97snd/mpg/decode_i386.c |
---|
File deleted |
/programs/media/ac97snd/mpg/layer1.c |
---|
File deleted |
/programs/media/ac97snd/mpg/dct64_i386.c |
---|
File deleted |
/programs/media/ac97snd/mpg/decode_i486.c |
---|
File deleted |
/programs/media/ac97snd/mpg/layer2.c |
---|
File deleted |
/programs/media/ac97snd/mpg/dct64_i486.c |
---|
File deleted |
/programs/media/ac97snd/mpg/layer3.c |
---|
File deleted |
/programs/media/ac97snd/mpg/proc32.inc |
---|
File deleted |
/programs/media/ac97snd/mpg/getbits.c |
---|
File deleted |
/programs/media/ac97snd/sound.h |
---|
File deleted |
/programs/media/ac97snd/ac97snd.sln |
---|
File deleted |
/programs/media/ac97snd/fasm.rules |
---|
File deleted |
/programs/media/ac97snd/kolibri.h |
---|
File deleted |
/programs/media/ac97snd/trunk/sound.h |
---|
0,0 → 1,136 |
#ifndef _SOUND_H_ |
#define _SOUND_H_ |
#ifdef __cplusplus |
extern "C" |
{ |
#endif |
#define SOUND_VERSION 0x0101 |
#define PCM_ALL 0 |
#define PCM_OUT 0x08000000 |
#define PCM_RING 0x10000000 |
#define PCM_STATIC 0x20000000 |
#define PCM_FLOAT 0x40000000 |
#define PCM_FILTER 0x80000000 |
#define PCM_2_16_48 1 |
#define PCM_1_16_48 2 |
#define PCM_2_16_44 3 |
#define PCM_1_16_44 4 |
#define PCM_2_16_32 5 |
#define PCM_1_16_32 6 |
#define PCM_2_16_24 7 |
#define PCM_1_16_24 8 |
#define PCM_2_16_22 9 |
#define PCM_1_16_22 10 |
#define PCM_2_16_16 11 |
#define PCM_1_16_16 12 |
#define PCM_2_16_12 13 |
#define PCM_1_16_12 14 |
#define PCM_2_16_11 15 |
#define PCM_1_16_11 16 |
#define PCM_2_16_8 17 |
#define PCM_1_16_8 18 |
#define PCM_2_8_48 19 |
#define PCM_1_8_48 20 |
#define PCM_2_8_44 21 |
#define PCM_1_8_44 22 |
#define PCM_2_8_32 23 |
#define PCM_1_8_32 24 |
#define PCM_2_8_24 25 |
#define PCM_1_8_24 26 |
#define PCM_2_8_22 27 |
#define PCM_1_8_22 28 |
#define PCM_2_8_16 29 |
#define PCM_1_8_16 30 |
#define PCM_2_8_12 31 |
#define PCM_1_8_12 32 |
#define PCM_2_8_11 33 |
#define PCM_1_8_11 34 |
#define PCM_2_8_8 35 |
#define PCM_1_8_8 36 |
#define SRV_GETVERSION 0 |
#define SND_CREATE_BUFF 1 |
#define SND_DESTROY_BUFF 2 |
#define SND_SETFORMAT 3 |
#define SND_GETFORMAT 4 |
#define SND_RESET 5 |
#define SND_SETPOS 6 |
#define SND_GETPOS 7 |
#define SND_SETBUFF 8 |
#define SND_OUT 9 |
#define SND_PLAY 10 |
#define SND_STOP 11 |
#define SND_SETVOLUME 12 |
#define SND_GETVOLUME 13 |
#define SND_SETPAN 14 |
#define SND_GETPAN 15 |
#define SND_GETBUFFSIZE 16 |
#define SND_GETFREESPACE 17 |
#define PLAY_SYNC 0x80000000 |
typedef unsigned int SNDBUF; |
int _stdcall InitSound(int *version); |
int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf); |
int _stdcall DestroyBuffer(SNDBUF hBuff); |
int _stdcall SetFormat(SNDBUF hBuff, unsigned int format); |
int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format); |
int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags); |
int _stdcall SetBufferPos(SNDBUF hBuff, int offset); |
int _stdcall GetBufferPos(SNDBUF hBuff, int *offset); |
int _stdcall GetBufferSize(SNDBUF hBuff, int *size); |
int _stdcall GetBufferFree(SNDBUF hBuff, int *free); |
int _stdcall SetBuffer(SNDBUF hBuff,void* buff, |
int offs, int size); |
int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size); |
int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags); |
int _stdcall StopBuffer(SNDBUF hBuff); |
int _stdcall SetVolume(SNDBUF hBuff, int left, int right); |
int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right); |
int _stdcall SetPan(SNDBUF hBuff, int pan); |
int _stdcall GetPan(SNDBUF hBuff, int *pan); |
int _stdcall GetMasterVol(int* vol); |
int _stdcall SetMasterVol(int vol); |
typedef struct |
{ |
unsigned int riff_id; |
unsigned int riff_size; |
unsigned int riff_format; |
unsigned int fmt_id; |
unsigned int fmt_size; |
unsigned short int wFormatTag; |
unsigned short int nChannels; |
unsigned int nSamplesPerSec; |
unsigned int nAvgBytesPerSec; |
unsigned short int nBlockAlign; |
unsigned short int wBitsPerSample; |
unsigned int data_id; |
unsigned int data_size; |
} WAVEHEADER; |
unsigned int _stdcall test_wav(WAVEHEADER *hdr); |
#ifdef __cplusplus |
extern "C" |
} |
#endif |
#endif //_SOUND_H_ |
/programs/media/ac97snd/trunk/ac97.sln |
---|
0,0 → 1,44 |
|
Microsoft Visual Studio Solution File, Format Version 9.00 |
# Visual Studio 2005 |
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pe2kos", "pe2kos\pe2kos.vcproj", "{50E3FB09-4E3A-4998-A824-6830405193AE}" |
EndProject |
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp3dec", "mp3dec\mp3dec.vcproj", "{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}" |
EndProject |
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ac97", "ac97\ac97.vcproj", "{1C94A897-DA4F-45B2-B8A6-B97AD837828E}" |
ProjectSection(ProjectDependencies) = postProject |
{CF807B93-2860-41DF-A4D2-5B92B52DFD96} = {CF807B93-2860-41DF-A4D2-5B92B52DFD96} |
{C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1} = {C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1} |
EndProjectSection |
EndProject |
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpg", "mpg\mpg.vcproj", "{CF807B93-2860-41DF-A4D2-5B92B52DFD96}" |
EndProject |
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sound", "sound\sound.vcproj", "{C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1}" |
EndProject |
Global |
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
Debug|Win32 = Debug|Win32 |
Release|Win32 = Release|Win32 |
EndGlobalSection |
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
{50E3FB09-4E3A-4998-A824-6830405193AE}.Debug|Win32.ActiveCfg = Debug|Win32 |
{50E3FB09-4E3A-4998-A824-6830405193AE}.Debug|Win32.Build.0 = Debug|Win32 |
{50E3FB09-4E3A-4998-A824-6830405193AE}.Release|Win32.ActiveCfg = Release|Win32 |
{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Debug|Win32.ActiveCfg = Debug|Win32 |
{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Release|Win32.ActiveCfg = Release|Win32 |
{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Release|Win32.Build.0 = Release|Win32 |
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Debug|Win32.ActiveCfg = Debug|Win32 |
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Release|Win32.ActiveCfg = Release|Win32 |
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Release|Win32.Build.0 = Release|Win32 |
{CF807B93-2860-41DF-A4D2-5B92B52DFD96}.Debug|Win32.ActiveCfg = Debug|Win32 |
{CF807B93-2860-41DF-A4D2-5B92B52DFD96}.Release|Win32.ActiveCfg = Release|Win32 |
{CF807B93-2860-41DF-A4D2-5B92B52DFD96}.Release|Win32.Build.0 = Release|Win32 |
{C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1}.Debug|Win32.ActiveCfg = Debug|Win32 |
{C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1}.Debug|Win32.Build.0 = Debug|Win32 |
{C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1}.Release|Win32.ActiveCfg = Release|Win32 |
{C8D44F9A-B5DF-4A94-AA92-47D9945FD4F1}.Release|Win32.Build.0 = Release|Win32 |
EndGlobalSection |
GlobalSection(SolutionProperties) = preSolution |
HideSolutionNode = FALSE |
EndGlobalSection |
EndGlobal |
/programs/media/ac97snd/trunk/ac97wav.c |
---|
0,0 → 1,585 |
// |
// This file is part of the AC97 mp3 player. |
// (C) copyright Serge 2006 |
// email: infinity_sound@mail.ru |
// |
// This program is free software; you can redistribute it and/or modify |
// it under the terms of the GNU 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 General Public License for more details. |
#include "kolibri.h" |
#include "string.h" |
#include "ac97wav.h" |
#include "mpg/mpg123.h" |
#include "sound.h" |
#define MP3_ERROR_OUT_OF_BUFFER 5 |
int m_last_error; |
void _stdcall thread_proc(void *param); |
void _stdcall create_thread(void *proc, void *param, int stack_size); |
void _stdcall send_ipc(int dst, DWORD code); |
void touch(char *buf, int size); |
int mp3FindSync(byte* buf, int size, int* sync); |
int stream_read_raw(struct reader *rd,unsigned char *buf, int size); |
char *fname; |
struct reader rd; |
struct frame fr; |
DWORD hDrv; |
DWORD hSound; |
SNDBUF hBuff; |
CTRL_INFO info; |
FILEINFO fileinfo; |
int m_vol; |
int l_vol=-700; //-7db |
int r_vol=-700; |
int pan =0; |
DWORD status; |
DWORD offset; |
DWORD first_sync; |
unsigned char *testbuff; |
unsigned char *outbuf; |
unsigned char *inpbuf; |
unsigned char *outPtr; |
int inpsize; |
int outsize; |
int outremain; |
int totalout; |
int done; |
char header[] = "AC97 MP3 player"; |
char buttons_text[]=" Play Stop << >> Vol- Vol+"; |
void (*snd_play)(); |
void draw_window() |
{ |
BeginDraw(); |
DrawWindow(100,100,299,72,0x404040,3,0,0,0); |
make_button(7,24,45,13, 0x10|BT_NORMAL,0x808080); |
make_button(56,24,45,13, 0x11|BT_NORMAL,0x808080); |
make_button(104,24,45,13, 0x12|BT_NORMAL,0x808080); |
make_button(152,24,45,13, 0x13|BT_NORMAL,0x808080); |
make_button(200,24,45,13, 0x14|BT_NORMAL,0x808080); |
make_button(248,24,45,13, 0x15|BT_NORMAL,0x808080); |
make_button(7,41,286,11, 0x30|BT_HIDE|BT_NOFRAME,0x404040); |
draw_bar(7,41,286,11,0x404040); |
draw_bar(7,55,286,11,0x404040); |
write_text(12,58,0x004000|FONT0, fname, strlen(fname)); |
write_text(11,57,0x00FF20|FONT0, fname, strlen(fname)); |
write_text(8,8,0xFFFFFF|FONT0, header, strlen(header)); |
write_text(12,28,0x404040|FONT0,buttons_text,strlen(buttons_text)); |
write_text(11,27,0xA0FFA0|FONT0,buttons_text,strlen(buttons_text)); |
EndDraw(); |
}; |
void draw_progress_bar() |
{ DWORD x; |
x = 287.0f * (float)(rd.filepos-rd.strremain)/(float)fileinfo.size; |
if(x==0) return; |
draw_bar(7,41,x,11,0xA0A0A0); |
draw_bar(x+7,41,287-x,11,0x404040); |
}; |
void debug_out_str(char* str) |
{ |
while (*str != 0) |
{ |
debug_out(*str); |
str++; |
} |
} |
int main(int argc, char *argv[]) //int argc, char *argv[]) |
{ |
DWORD fmt; |
DWORD r_bytes; |
int retval; |
int err; |
int ver; |
fname = argv[1]; |
debug_out_str("\n\rPlay file "); |
debug_out_str(fname); |
debug_out_str("\n\r"); |
InitHeap(1024*1024); |
if(get_fileinfo(fname, &fileinfo)==FILE_NOT_FOUND) |
{ debug_out_str("\n\rfile not found\n\r"); |
return 0; |
}; |
if(err = InitSound(&ver)) |
{ |
debug_out_str("Sound service not installed\n\r"); |
return 0; |
} |
if( (SOUND_VERSION>(ver&0xFFFF)) || |
(SOUND_VERSION<(ver >> 16))) |
{ |
debug_out_str("Sound service version mismatch\n\r"); |
return 0; |
} |
testbuff = UserAlloc(4096); |
get_fileinfo(fname, &fileinfo); |
offset = 0; |
retval=read_file (fname,testbuff,0,2048,&r_bytes); |
if (retval) return 0; |
inpbuf = UserAlloc(0x10000); |
touch(inpbuf, 0x10000); |
create_reader(&rd, inpbuf, 0x10000); |
init_reader(&rd,fname); |
fmt = test_wav((WAVEHEADER*)testbuff); |
if (fmt != 0) |
{ |
snd_play = &play_wave; |
set_reader(&rd, 44); |
outbuf = UserAlloc(32*1024); |
touch(outbuf, 32768); |
} |
else |
{ fmt = test_mp3(testbuff); |
if(fmt ==0) return 0; |
snd_play = &play_mp3; |
outremain = 0x40000 ; |
outbuf = UserAlloc(outremain); |
touch(outbuf, outremain); |
make_decode_tables(32767); |
init_layer2(); |
init_layer3(32); |
fr.single = -1; |
}; |
status = ST_PLAY; |
if (err = CreateBuffer(fmt,0, &hBuff)) |
{ |
debug_out_str("create buffer return error\n\r"); |
; return 0; |
} |
SetVolume(hBuff,l_vol,r_vol); |
GetVolume(hBuff,&l_vol,&r_vol); |
create_thread(thread_proc, 0, 4096); |
while(1) |
{ delay(10); |
switch(status) |
{ case ST_PLAY: |
snd_play(); |
continue; |
case ST_STOP: |
StopBuffer(hBuff); |
status = ST_DONE; |
continue; |
case ST_EXIT: |
StopBuffer(hBuff); |
DestroyBuffer(hBuff); |
return 0; |
}; |
}; |
return 0; |
}; |
void touch(char *buf, int size) |
{ int i; |
char a; |
for ( i = 0;i < size; i+=4096) |
a = buf[i]; |
}; |
DWORD test_mp3(char *buf) |
{ unsigned long hdr; |
WAVEHEADER whdr; |
while (1) |
{ if(rd.filepos > 102400) |
return 0; |
if(!rd.head_read(&rd,&hdr)) |
return 0; |
if(!decode_header(&fr,hdr)) |
{ rd.strpos-=3; |
rd.stream-=3; |
rd.strremain+=3; |
continue; |
}; |
break; |
}; |
first_sync = rd.filepos-rd.strremain-4; |
whdr.riff_id = 0x46464952; |
whdr.riff_format = 0x45564157; |
whdr.wFormatTag = 0x01; |
whdr.nSamplesPerSec = freqs[fr.sampling_frequency]; |
whdr.nChannels = 2; //mpginfo.channels; |
whdr.wBitsPerSample = 16; |
return test_wav(&whdr); |
}; |
void play_mp3() |
{ char *outPtr; |
int totalout; |
int outcount; |
// memset(&fr,0,sizeof(fr)); |
fr.down_sample_sblimit = 32; |
fr.single = -1; |
reset_mpg(); |
outPtr = outbuf; |
totalout=0; |
done = 0; |
outremain=0x40000; |
memset(outbuf,0,0x40000); |
set_reader(&rd, 0); //;first_sync); |
while(1) |
{ if(status!=ST_PLAY) |
break; |
for(;;) |
{ outcount = 0; |
if( !read_frame(&rd, &fr)) |
{ done = 1; |
break; |
}; |
fr.do_layer(&fr, outPtr,&outcount); |
outPtr+= outcount; |
totalout+=outcount; |
outremain-=outcount; |
if(outremain < outcount*2) |
break; |
}; |
if(done) |
{ if(totalout < 4096) |
{ memset(outPtr,0,4096-totalout); |
totalout = 4096; |
}; |
} |
else |
if(totalout < 8192) |
continue; |
outPtr = outbuf; |
while (totalout >= 4096) |
{ |
WaveOut(hBuff,outPtr,4096); |
if(status!=ST_PLAY) |
{ if(status != ST_EXIT) |
status = ST_STOP; |
return; |
}; |
totalout-=4096; |
outPtr+=4096; |
outremain+=4096; |
}; |
if(done) |
break; |
memmove(outbuf,outPtr, totalout); |
outPtr = outbuf+totalout; |
} |
if(status != ST_EXIT) |
status = ST_STOP; |
}; |
void play_wave() |
{ int retval; |
set_reader(&rd,44); |
retval = 0; |
while(1) |
{ |
if(status!=ST_PLAY) |
break; |
if( !stream_read_raw(&rd,outbuf,32768)) |
{ done = 1; |
break; |
}; |
WaveOut(hBuff,outbuf,32768); |
}; |
if(status != ST_EXIT) |
status = ST_STOP; |
}; |
void snd_stop() |
{ |
StopBuffer(hBuff); |
}; |
void _stdcall thread_proc(void *param) |
{ int evnt; |
int pos; |
int key; |
_asm |
{ |
mov eax, 66 |
mov ebx, 1 |
mov ecx, 1 |
int 0x40 |
}; |
draw_window(); |
while(1) |
{ if(status==ST_PLAY) |
{ draw_progress_bar(); |
evnt = wait_for_event(80); |
} |
else |
evnt = wait_for_event_infinite(); |
switch(evnt) |
{ |
case EV_REDRAW: |
draw_window(); |
break; |
case EV_KEY: |
if(!get_key(&key)) |
{ |
switch(key) |
{ case 0xE0: |
case 0xE1: |
break; |
default: |
switch (key) |
{ |
case 0x01: //Esc |
status = ST_EXIT; |
exit(); |
break; |
case 0x47: //Home |
if(l_vol < 0) |
{ l_vol+=100; |
r_vol+=100; |
SetVolume(hBuff,l_vol,r_vol); |
}; |
break; |
case 0x4F: //End |
if(l_vol > -10000) |
{ l_vol-=100; |
r_vol-=100; |
SetVolume(hBuff,l_vol,r_vol); |
}; |
break; |
case 0x53: |
if(pan > -10000) |
{ pan -=100; |
SetPan(hBuff,pan); |
}; |
break; |
case 0x51: |
if(pan < 10000) |
{ pan +=100; |
SetPan(hBuff,pan); |
}; |
break; |
} |
}; |
}; |
break; |
case EV_BUTTON: |
switch(get_button_id()) |
{ case 1: |
status = ST_EXIT; |
exit(); |
break; |
case 0x10: |
status = ST_PLAY; |
continue; |
case 0x11: |
status = ST_STOP; |
break; |
// case 0x12: |
// case 0x13: |
case 0x14: |
if(l_vol > -10000) |
{ |
l_vol-=100; |
r_vol-=100; |
SetVolume(hBuff,l_vol,r_vol); |
}; |
break; |
case 0x15: |
if(l_vol < 0) |
{ l_vol+=100; |
r_vol+=100; |
SetVolume(hBuff,l_vol,r_vol); |
}; |
break; |
case 0x30: |
if(status==ST_DONE) |
break; |
pos = (GetMousePos(REL_WINDOW)>>16)-7; |
offset = ((fileinfo.size-44)/286*pos+44)&0xFFFFFFFC; |
set_reader(&rd, offset); |
draw_progress_bar(); |
break; |
}; |
}; |
}; |
}; |
void delay (int val) |
{ |
_asm |
{ mov eax,5 |
mov ebx, [val] |
int 0x40 |
}; |
} |
int wait_for_event(int time) |
{ int retval; |
_asm |
{ mov eax,23 |
mov ebx,[time] |
int 0x40 |
mov [retval], eax |
}; |
return retval; |
}; |
int wait_for_event_infinite() |
{ int retval; |
_asm |
{ mov eax,10 |
int 0x40 |
mov [retval], eax |
}; |
return retval; |
}; |
void BeginDraw() |
{_asm |
{ mov eax,12 |
mov ebx, 1 |
int 0x40 |
}; |
}; |
void EndDraw() |
{ _asm |
{ mov eax,12 |
mov ebx, 2 |
int 0x40 |
}; |
}; |
///********* |
void *memmove ( void * dst, void * src, int count) |
{ void *ret; |
ret = dst; |
if (dst <= src || (char *)dst >= ((char *)src + count)) |
{ |
while (count--) |
{ *(char *)dst = *(char *)src; |
dst = (char *)dst + 1; |
src = (char *)src + 1; |
} |
} |
else |
{ |
dst = (char *)dst + count - 1; |
src = (char *)src + count - 1; |
while (count--) |
{ *(char *)dst = *(char *)src; |
dst = (char *)dst - 1; |
src = (char *)src - 1; |
} |
} |
return ret; |
}; |
//**********/ |
void * __cdecl mem_cpy(void * dst,const void * src,size_t count) |
{ void * ret = dst; |
while (count--) |
{ *(char *)dst = *(char *)src; |
dst = (char *)dst + 1; |
src = (char *)src + 1; |
}; |
return(ret); |
} |
// debug_out_str(formats[fmt]); |
// debug_out_str("\x0D\x0A\x00"); |
// debug_out_str("pci cmd: "); |
// debug_out_hex(info.pci_cmd); |
// debug_out_str("\x0D\x0A\x00"); |
// debug_out_str("irq line: "); |
// debug_out_hex(info.irq); |
// debug_out_str("\x0D\x0A\x00"); |
// debug_out_str("global control: "); |
// debug_out_hex(info.glob_cntrl); |
// debug_out_str("\x0D\x0A\x00"); |
// debug_out_str("global status: "); |
// debug_out_hex(info.glob_sta); |
// debug_out_str("\x0D\x0A\x00"); |
// call _print_volume |
// debug_out_hex(whdr.nChannels); |
// debug_out_str("\x0D\x0A\x00"); |
// debug_out_hex(whdr.nSamplesPerSec); |
// debug_out_str("\x0D\x0A\x00"); |
// debug_out_hex(fmt); |
// debug_out_str("\x0D\x0A\x00"); |
/programs/media/ac97snd/trunk/ac97wav.h |
---|
0,0 → 1,31 |
// |
// This file is part of the AC97 mp3 player. |
// (C) copyright Serge 2006 |
// email: infinity_sound@mail.ru |
// |
// This program is free software; you can redistribute it and/or modify |
// it under the terms of the GNU 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 General Public License for more details. |
#define ST_DONE 0x0 |
#define ST_PLAY 0x1 |
#define ST_EXIT 0x2 |
#define ST_STOP 0x4 |
DWORD test_mp3(char *buf); |
//void (*snd_play)(); |
void wave_out(char* buff); |
void play_wave(); |
void play_mp3(); |
void snd_stop(); |
/programs/media/ac97snd/trunk/k_lib.asm |
---|
0,0 → 1,495 |
format MS COFF |
include "proc32.inc" |
section '.text' code readable executable |
public _InitHeap@4 |
public _UserAlloc@4 |
public _CreateThread@8 |
public _GetMousePos@4 |
public _get_fileinfo@8 |
public _read_file@20 |
public _get_key@4 |
public _get_button_id |
public _DrawWindow@36 |
public _make_button@24 |
public _draw_bar@20 |
public _write_text@20 |
public _debug_out@4 |
public _debug_out_hex@4 |
public _create_thread@12 |
public _memset |
struc FILEIO |
{ .cmd dd ? |
.offset dd ? |
dd ? |
.count dd ? |
.buff dd ? |
db ? |
.name dd ? |
}; |
align 4 |
_create_thread@12: |
.thr_proc equ esp+4 |
.param equ esp+8 |
.stack_size equ esp+12 |
mov eax, 68 |
mov ebx, 12 |
mov ecx, [.stack_size] |
add ecx, 4095 |
and ecx, -4096 |
int 0x40 |
test eax, eax |
jz .fail |
lea edx, [eax+ecx-12] |
mov [edx], dword .exit_point |
mov ebx, [.param] |
mov [edx+4], ebx |
mov [edx+8], ecx |
mov eax, 51 |
mov ebx, 1 |
mov ecx, [.thr_proc] |
int 0x40 |
ret 12 |
.fail: |
not eax |
ret 12 |
align 4 |
.exit_point: |
pop ecx |
mov eax, 68 |
mov ebx, 13 |
int 0x40 |
mov eax, -1 |
int 0x40 |
restore .thr_proc |
restore .param |
restore .stack_size |
align 4 |
proc _get_button_id |
mov eax,17 |
int 0x40 |
test al,al |
jnz @F |
shr eax,8 |
ret |
@@: |
xor eax,eax |
dec eax |
ret |
endp |
align 4 |
proc _get_fileinfo@8 stdcall, name:dword, info:dword |
push ebx |
push esi |
push edi |
xor eax, eax |
mov ebx, [name] |
mov ecx, [info] |
mov [fileio.cmd], 5 |
mov [fileio.offset], eax |
mov [fileio.offset+4], eax |
mov [fileio.count], eax |
mov [fileio.buff], ecx |
mov byte [fileio.buff+4], al |
mov [fileio.name], ebx |
mov eax, 70 |
lea ebx, [fileio] |
int 0x40 |
pop edi |
pop esi |
pop ebx |
ret |
endp |
align 4 |
proc _read_file@20 stdcall,name:dword, buff:dword, offset:dword,\ |
count:dword,reads:dword |
push ebx |
push esi |
push edi |
xor eax, eax |
mov ebx, [name] |
mov edx, [offset] |
mov esi, [buff] |
mov edi, [count] |
mov [fileio.cmd], eax |
mov [fileio.offset], edx |
mov [fileio.offset+4], eax |
mov [fileio.count], edi |
mov [fileio.buff], esi |
mov byte [fileio.buff+4], al |
mov [fileio.name], ebx |
mov eax, 70 |
lea ebx, [fileio] |
int 0x40 |
mov esi, [reads] |
test esi, esi |
jz @f |
mov [esi], ebx |
@@: |
pop edi |
pop esi |
pop ebx |
ret |
endp |
align 4 |
proc _get_key@4 stdcall, key:dword |
push ebx |
push ecx |
mov eax, 2 |
int 0x40 |
mov ebx, [key] |
mov ecx, eax |
shr ecx, 8 |
mov [ebx], ecx |
movzx eax, al |
pop ecx |
pop ebx |
ret |
endp |
align 4 |
proc _InitHeap@4 stdcall, heap_size:dword |
push ebx |
mov eax, 68 |
mov ebx, 11 |
mov ecx, [heap_size] |
int 0x40 |
pop ebx |
ret |
endp |
align 4 |
proc _UserAlloc@4 stdcall, alloc_size:dword |
push ebx |
mov eax, 68 |
mov ebx, 12 |
mov ecx, [alloc_size] |
int 0x40 |
pop ebx |
ret |
endp |
align 4 |
proc _CreateThread@8 stdcall, fn:dword, p_stack:dword |
push ebx |
mov eax, 51 |
mov ebx, 1 |
mov ecx, [fn] |
mov edx,[p_stack] |
int 0x40 |
pop ebx |
ret |
endp |
align 4 |
proc _GetMousePos@4 stdcall,rel_type:dword |
push ebx |
mov eax, 37 |
mov ebx, [rel_type] |
int 0x40 |
pop ebx |
ret |
endp |
align 4 |
proc _DrawWindow@36 stdcall, x:dword, y:dword, sx:dword, sy:dword,\ |
workcolor:dword, style:dword, captioncolor:dword,\ |
windowtype:dword, bordercolor:dword |
push ebx edi esi |
mov ebx, [x] |
mov ecx, [y] |
shl ebx, 16 |
shl ecx, 16 |
mov bx, word [sx] |
mov cx, word [sy] |
mov edx,[style] |
shl edx,24 |
add edx,[workcolor] |
mov esi,[windowtype] |
shl esi,24 |
add esi,[captioncolor] |
mov edi,[bordercolor] |
xor eax,eax |
int 0x40 |
pop esi edi ebx |
ret |
endp |
align 4 |
_make_button@24: |
;arg1 - x |
;arg2 - y |
;arg3 - xsize |
;arg4 - ysize |
;arg5 - id |
;arg6 - color |
push ebx esi |
mov ebx,[esp+12] |
shl ebx,16 |
mov bx,[esp+20] |
mov ecx,[esp+16] |
shl ecx,16 |
mov cx,[esp+24] |
mov edx,[esp+28] |
mov esi,[esp+32] |
mov eax,8 |
int 0x40 |
pop esi ebx |
ret 24 |
align 4 |
_draw_bar@20: |
;arg1 - x |
;arg2 - y |
;arg3 - xsize |
;arg4 - ysize |
;arg5 - color |
push ebx |
mov eax,13 |
mov ebx,[esp+8] |
shl ebx,16 |
mov bx,[esp+16] |
mov ecx,[esp+12] |
shl ecx,16 |
mov cx,[esp+20] |
mov edx,[esp+24] |
int 0x40 |
pop ebx |
ret 20 |
_write_text@20: |
;arg1 - x |
;arg2 - y |
;arg3 - color |
;arg4 - text |
;arg5 - len |
push ebx esi |
mov eax,4 |
mov ebx,[esp+12] |
shl ebx,16 |
mov bx,[esp+16] |
mov ecx,[esp+20] |
mov edx,[esp+24] |
mov esi,[esp+28] |
int 0x40 |
pop esi ebx |
ret 20 |
align 4 |
proc _debug_out@4 stdcall, val:dword |
push ebx |
mov ecx,[val] |
mov ebx,1 |
mov eax,63 |
int 0x40 |
pop ebx |
ret |
endp |
align 4 |
proc _debug_out_hex@4 stdcall val:dword |
locals |
count dd ? |
endl |
mov [count], 8 |
.new_char: |
rol [val], 4 |
mov ecx, [val] |
and ecx, 0x0f |
mov cl,byte [__hexdigits+ecx] |
mov eax, 63 |
mov ebx, 1 |
int 0x40 |
dec [count] |
jnz .new_char |
ret |
endp |
align 4 |
_memset: |
mov edx,[esp + 0ch] |
mov ecx,[esp + 4] |
test edx,edx |
jz short toend |
xor eax,eax |
mov al,[esp + 8] |
push edi |
mov edi,ecx |
cmp edx,4 |
jb tail |
neg ecx |
and ecx,3 |
jz short dwords |
sub edx,ecx |
adjust_loop: |
mov [edi],al |
add edi,1 |
sub ecx,1 |
jnz adjust_loop |
dwords: |
mov ecx,eax |
shl eax,8 |
add eax,ecx |
mov ecx,eax |
shl eax,10h |
add eax,ecx |
mov ecx,edx |
and edx,3 |
shr ecx,2 |
jz tail |
cld |
rep stosd |
main_loop_tail: |
test edx,edx |
jz finish |
tail: |
mov [edi],al |
add edi,1 |
sub edx,1 |
jnz tail |
finish: |
mov eax,[esp + 8] |
pop edi |
ret |
toend: |
mov eax,[esp + 4] |
ret |
public _allmul |
_allmul: |
mov eax, [esp+8] |
mov ecx, [esp+16] |
or ecx,eax |
mov ecx, [esp+12] |
jnz .hard |
mov eax, [esp+4] |
mul ecx |
ret 16 |
.hard: |
push ebx |
mul ecx |
mov ebx,eax |
mov eax, [esp+8] |
mul dword [esp+20] |
add ebx,eax |
mov eax,[esp+8] |
mul ecx |
add edx,ebx |
pop ebx |
ret 16 |
align 4 |
_allshr: |
cmp cl,64 |
jae .sign |
cmp cl, 32 |
jae .MORE32 |
shrd eax,edx,cl |
sar edx,cl |
ret |
.MORE32: |
mov eax,edx |
sar edx,31 |
and cl,31 |
sar eax,cl |
ret |
.sign: |
sar edx,31 |
mov eax,edx |
ret |
public __ftol2_sse |
align 4 |
__ftol2_sse: |
push ebp |
mov ebp, esp |
sub esp, 20 |
and esp, 0xFFFFFFF0 |
fld st0 |
fst dword [esp+18] |
fistp qword [esp+10] |
fild qword [esp+10] |
mov edx, [esp+18] |
mov eax, [esp+10] |
test eax, eax |
jz .QnaNZ |
.not_QnaNZ: |
fsubp st1, st0 |
test edx, edx |
jns .pos |
fstp dword [esp] |
mov ecx, [esp] |
xor ecx, 0x80000000 |
add ecx, 0x7FFFFFFF |
adc eax, 0 |
mov edx, [esp+14] |
adc edx, 0 |
jmp .exit |
.pos: |
fstp dword [esp] |
mov ecx, [esp] |
add ecx, 0x7FFFFFFF |
sbb eax, 0 |
jmp .exit |
.QnaNZ: |
mov edx, [esp+14] |
test edx, 0x7FFFFFFF |
jne .not_QnaNZ |
fstp dword [esp+18] |
fstp dword [esp+18] |
.exit: |
leave |
ret |
public __fltused |
__fltused dd 0 |
align 4 |
__hexdigits db '0123456789ABCDEF' |
align 4 |
fileio FILEIO |
/programs/media/ac97snd/trunk/kolibri.h |
---|
0,0 → 1,107 |
#ifdef __cplusplus |
extern "C" |
{ |
#endif |
#define FONT0 0x00000000 |
#define FONT1 0x10000000 |
#define BT_NORMAL 0x00000000 |
#define BT_NOFRAME 0x20000000 |
#define BT_HIDE 0x40000000 |
#define BT_DEL 0x80000000 |
#define EV_REDRAW 1 |
#define EV_KEY 2 |
#define EV_BUTTON 3 |
#define EV_IPC 7 |
#define REL_SCREEN 0 |
#define REL_WINDOW 1 |
#define FILE_NOT_FOUND 5 |
#define FILE_EOF 6 |
typedef unsigned int DWORD; |
typedef unsigned short int WORD; |
typedef struct |
{ DWORD pci_cmd; |
DWORD irq; |
DWORD glob_cntrl; |
DWORD glob_sta; |
DWORD codec_io_base; |
DWORD ctrl_io_base; |
DWORD codec_mem_base; |
DWORD ctrl_mem_base; |
DWORD codec_id; |
} CTRL_INFO; |
typedef struct |
{ DWORD cmd; |
DWORD offset; |
DWORD r1; |
DWORD count; |
DWORD buff; |
char r2; |
char *name; |
} FILEIO; |
typedef struct |
{ DWORD attr; |
DWORD flags; |
DWORD cr_time; |
DWORD cr_date; |
DWORD acc_time; |
DWORD acc_date; |
DWORD mod_time; |
DWORD mod_date; |
DWORD size; |
DWORD size_high; |
} FILEINFO; |
void _stdcall InitHeap(int heap_size); |
void* _stdcall UserAlloc(int size); |
int _stdcall UserFree(void* p); |
void _stdcall GetNotify(void *event); |
void _stdcall CreateThread(void *fn, char *p_stack); |
DWORD _stdcall GetMousePos(DWORD rel_type); |
void _stdcall debug_out_hex(DWORD val); |
void debug_out_str(char* str); |
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo); |
int _stdcall create_file(const char *name); |
int _stdcall read_file (const char *name,char*buff,DWORD offset, DWORD count,DWORD *reads); |
int _stdcall write_file(const char *name,char*buff,int offset,int count,int *writes); |
//void exit(); |
int _stdcall get_key(int *key); |
int _stdcall remap_key(int key); |
int _cdecl get_button_id(); |
void delay(int val); |
int wait_for_event(int time); |
int wait_for_event_infinite(); |
void BeginDraw(void); |
void EndDraw(void); |
void _stdcall GetScreenSize(int *x, int*y); |
void _stdcall DrawWindow(int x,int y, int sx, int sy,int workcolor,int style, |
int captioncolor,int windowtype,int bordercolor); |
void _stdcall debug_out(int ch); |
void _stdcall make_button(int x, int y, int xsize, int ysize, int id, int color); |
void _stdcall draw_bar(int x, int y, int xsize, int ysize, int color); |
void _stdcall write_text(int x,int y,int color,char* text,int len); |
#ifdef __cplusplus |
extern "C" |
} |
#endif |
/programs/media/ac97snd/trunk/crt.h |
---|
0,0 → 1,13 |
typedef unsigned __int32 Dword; |
typedef unsigned __int16 Word; |
typedef unsigned __int8 Byte; |
typedef unsigned __int32 size_t; |
extern char *__argv[2]; |
void crtStartUp(); |
int __cdecl _purecall(); |
int __cdecl atexit( void (__cdecl *func )( void )); |
void exit(); |
int main(); |
/programs/media/ac97snd/trunk/mpg/decode_i386.c |
---|
0,0 → 1,269 |
/* |
decode_i386.c: decode for i386 (really faster?) |
copyright 1995-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Michael Hipp |
slighlty optimized for machines without autoincrement/decrement. |
The performance is highly compiler dependend. Maybe |
the decode.c version for 'normal' processor may be faster |
even for Intel processors. |
*/ |
//#include <stdlib.h> |
#include <math.h> |
//#include <string.h> |
//#include "config.h" |
#include "mpg123.h" |
#if 0 |
/* old WRITE_SAMPLE */ |
#define WRITE_SAMPLE(samples,sum,clip) \ |
if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \ |
else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \ |
else { *(samples) = sum; } |
#else |
/* new WRITE_SAMPLE */ |
/* keep in mind that we are on known little-endian i386 here and special tricks are allowed... */ |
#define WRITE_SAMPLE(samples,sum,clip) { \ |
double dtemp; int v; /* sizeof(int) == 4 */ \ |
dtemp = ((((65536.0 * 65536.0 * 16)+(65536.0 * 0.5))* 65536.0)) + (sum); \ |
v = ((*(int *)&dtemp) - 0x80000000); \ |
if( v > 32767) { *(samples) = 0x7fff; (clip)++; } \ |
else if( v < -32768) { *(samples) = -0x8000; (clip)++; } \ |
else { *(samples) = v; } \ |
} |
#endif |
#if 0 |
int synth_1to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt) |
{ |
short samples_tmp[64]; |
short *tmp1 = samples_tmp + channel; |
int i,ret; |
int pnt1 = 0; |
ret = synth_1to1(bandPtr,channel,(unsigned char *)samples_tmp,&pnt1); |
samples += channel + *pnt; |
for(i=0;i<32;i++) { |
*samples = conv16to8[*tmp1>>AUSHIFT]; |
samples += 2; |
tmp1 += 2; |
} |
*pnt += 64; |
return ret; |
} |
int synth_1to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt) |
{ |
short samples_tmp[64]; |
short *tmp1 = samples_tmp; |
int i,ret; |
int pnt1 = 0; |
ret = synth_1to1(bandPtr,0,(unsigned char *)samples_tmp,&pnt1); |
samples += *pnt; |
for(i=0;i<32;i++) { |
*samples++ = conv16to8[*tmp1>>AUSHIFT]; |
tmp1+=2; |
} |
*pnt += 32; |
return ret; |
} |
int synth_1to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt) |
{ |
short samples_tmp[64]; |
short *tmp1 = samples_tmp; |
int i,ret; |
int pnt1 = 0; |
ret = synth_1to1(bandPtr,0,(unsigned char *)samples_tmp,&pnt1); |
samples += *pnt; |
for(i=0;i<32;i++) { |
*samples++ = conv16to8[*tmp1>>AUSHIFT]; |
*samples++ = conv16to8[*tmp1>>AUSHIFT]; |
tmp1 += 2; |
} |
*pnt += 64; |
return ret; |
} |
int synth_1to1_mono(real *bandPtr,unsigned char *samples,int *pnt) |
{ |
short samples_tmp[64]; |
short *tmp1 = samples_tmp; |
int i,ret; |
int pnt1 = 0; |
ret = synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); |
samples += *pnt; |
for(i=0;i<32;i++) { |
*( (short *) samples) = *tmp1; |
samples += 2; |
tmp1 += 2; |
} |
*pnt += 64; |
return ret; |
} |
#endif |
int synth_1to1_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt) |
{ |
int i,ret; |
ret = synth_1to1(bandPtr,0,samples,pnt); |
samples = samples + *pnt - 128; |
for(i=0;i<32;i++) { |
((short *)samples)[1] = ((short *)samples)[0]; |
samples+=4; |
} |
return ret; |
} |
static real buffs[2][2][0x110]; |
static const int step = 2; |
static int bo = 1; |
void init_dct() |
{ |
bo = 1; |
memset(buffs,0, sizeof(buffs)); |
}; |
int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt) |
{ |
#ifndef PENTIUM_OPT |
short *samples = (short *) (out + *pnt); |
real *b0,(*buf)[0x110]; |
int clip = 0; |
int bo1; |
#endif |
// if(have_eq_settings) |
// do_equalizer(bandPtr,channel); |
#ifndef PENTIUM_OPT |
if(!channel) { |
bo--; |
bo &= 0xf; |
buf = buffs[0]; |
} |
else { |
samples++; |
buf = buffs[1]; |
} |
if(bo & 0x1) { |
b0 = buf[0]; |
bo1 = bo; |
dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr); |
} |
else { |
b0 = buf[1]; |
bo1 = bo+1; |
dct64(buf[0]+bo,buf[1]+bo+1,bandPtr); |
} |
{ |
register int j; |
real *window = decwin + 16 - bo1; |
for (j=16;j;j--,b0+=0x10,window+=0x20,samples+=step) |
{ |
real sum; |
sum = window[0x0] * b0[0x0]; |
sum -= window[0x1] * b0[0x1]; |
sum += window[0x2] * b0[0x2]; |
sum -= window[0x3] * b0[0x3]; |
sum += window[0x4] * b0[0x4]; |
sum -= window[0x5] * b0[0x5]; |
sum += window[0x6] * b0[0x6]; |
sum -= window[0x7] * b0[0x7]; |
sum += window[0x8] * b0[0x8]; |
sum -= window[0x9] * b0[0x9]; |
sum += window[0xA] * b0[0xA]; |
sum -= window[0xB] * b0[0xB]; |
sum += window[0xC] * b0[0xC]; |
sum -= window[0xD] * b0[0xD]; |
sum += window[0xE] * b0[0xE]; |
sum -= window[0xF] * b0[0xF]; |
WRITE_SAMPLE(samples,sum,clip); |
} |
{ |
real sum; |
sum = window[0x0] * b0[0x0]; |
sum += window[0x2] * b0[0x2]; |
sum += window[0x4] * b0[0x4]; |
sum += window[0x6] * b0[0x6]; |
sum += window[0x8] * b0[0x8]; |
sum += window[0xA] * b0[0xA]; |
sum += window[0xC] * b0[0xC]; |
sum += window[0xE] * b0[0xE]; |
WRITE_SAMPLE(samples,sum,clip); |
b0-=0x10,window-=0x20,samples+=step; |
} |
window += bo1<<1; |
for (j=15;j;j--,b0-=0x10,window-=0x20,samples+=step) |
{ |
real sum; |
sum = -window[-0x1] * b0[0x0]; |
sum -= window[-0x2] * b0[0x1]; |
sum -= window[-0x3] * b0[0x2]; |
sum -= window[-0x4] * b0[0x3]; |
sum -= window[-0x5] * b0[0x4]; |
sum -= window[-0x6] * b0[0x5]; |
sum -= window[-0x7] * b0[0x6]; |
sum -= window[-0x8] * b0[0x7]; |
sum -= window[-0x9] * b0[0x8]; |
sum -= window[-0xA] * b0[0x9]; |
sum -= window[-0xB] * b0[0xA]; |
sum -= window[-0xC] * b0[0xB]; |
sum -= window[-0xD] * b0[0xC]; |
sum -= window[-0xE] * b0[0xD]; |
sum -= window[-0xF] * b0[0xE]; |
sum -= window[-0x0] * b0[0xF]; |
WRITE_SAMPLE(samples,sum,clip); |
} |
} |
*pnt += 128; |
return clip; |
#elif defined(USE_MMX) |
{ |
static short buffs[2][2][0x110]; |
static int bo = 1; |
short *samples = (short *) (out + *pnt); |
synth_1to1_MMX(bandPtr, channel, samples, (short *) buffs, &bo); |
*pnt += 128; |
return 0; |
} |
#else |
{ |
int ret; |
ret = synth_1to1_pent(bandPtr,channel,out+*pnt); |
*pnt += 128; |
return ret; |
} |
#endif |
} |
/programs/media/ac97snd/trunk/mpg/layer3.c |
---|
0,0 → 1,1961 |
/* |
leyer3.c: the layer 3 decoder |
copyright 1995-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Michael Hipp |
Optimize-TODO: put short bands into the band-field without the stride of 3 reals |
Length-optimze: unify long and short band code where it is possible |
The int-vs-pointer situation has to be cleaned up. |
*/ |
//#include <stdlib.h> |
//#include "config.h" |
#include "mpg123.h" |
#include "huffman.h" |
//#include "common.h" |
//#include "debug.h" |
#include "getbits.h" |
static real ispow[8207]; |
static real aa_ca[8],aa_cs[8]; |
static real COS1[12][6]; |
static real win[4][36]; |
static real win1[4][36]; |
static real gainpow2[256+118+4]; |
#ifdef USE_3DNOW |
real COS9[9]; |
static real COS6_1,COS6_2; |
real tfcos36[9]; |
#else |
static real COS9[9]; |
static real COS6_1,COS6_2; |
static real tfcos36[9]; |
#endif |
static real tfcos12[3]; |
#define NEW_DCT9 |
#ifdef NEW_DCT9 |
static real cos9[3],cos18[3]; |
#endif |
struct bandInfoStruct { |
int longIdx[23]; |
int longDiff[22]; |
int shortIdx[14]; |
int shortDiff[13]; |
}; |
int longLimit[9][23]; |
int shortLimit[9][14]; |
struct bandInfoStruct bandInfo[9] = { |
/* MPEG 1.0 */ |
{ {0,4,8,12,16,20,24,30,36,44,52,62,74, 90,110,134,162,196,238,288,342,418,576}, |
{4,4,4,4,4,4,6,6,8, 8,10,12,16,20,24,28,34,42,50,54, 76,158}, |
{0,4*3,8*3,12*3,16*3,22*3,30*3,40*3,52*3,66*3, 84*3,106*3,136*3,192*3}, |
{4,4,4,4,6,8,10,12,14,18,22,30,56} } , |
{ {0,4,8,12,16,20,24,30,36,42,50,60,72, 88,106,128,156,190,230,276,330,384,576}, |
{4,4,4,4,4,4,6,6,6, 8,10,12,16,18,22,28,34,40,46,54, 54,192}, |
{0,4*3,8*3,12*3,16*3,22*3,28*3,38*3,50*3,64*3, 80*3,100*3,126*3,192*3}, |
{4,4,4,4,6,6,10,12,14,16,20,26,66} } , |
{ {0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576} , |
{4,4,4,4,4,4,6,6,8,10,12,16,20,24,30,38,46,56,68,84,102, 26} , |
{0,4*3,8*3,12*3,16*3,22*3,30*3,42*3,58*3,78*3,104*3,138*3,180*3,192*3} , |
{4,4,4,4,6,8,12,16,20,26,34,42,12} } , |
/* MPEG 2.0 */ |
{ {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576}, |
{6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54 } , |
{0,4*3,8*3,12*3,18*3,24*3,32*3,42*3,56*3,74*3,100*3,132*3,174*3,192*3} , |
{4,4,4,6,6,8,10,14,18,26,32,42,18 } } , |
/* mhipp trunk has 330 -> 332 without further explanation ... */ |
{ {0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,330,394,464,540,576}, |
{6,6,6,6,6,6,8,10,12,14,16,18,22,26,32,38,46,52,64,70,76,36 } , |
{0,4*3,8*3,12*3,18*3,26*3,36*3,48*3,62*3,80*3,104*3,136*3,180*3,192*3} , |
{4,4,4,6,8,10,12,14,18,24,32,44,12 } } , |
{ {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576}, |
{6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54 }, |
{0,4*3,8*3,12*3,18*3,26*3,36*3,48*3,62*3,80*3,104*3,134*3,174*3,192*3}, |
{4,4,4,6,8,10,12,14,18,24,30,40,18 } } , |
/* MPEG 2.5 */ |
{ {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576} , |
{6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54}, |
{0,12,24,36,54,78,108,144,186,240,312,402,522,576}, |
{4,4,4,6,8,10,12,14,18,24,30,40,18} }, |
{ {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576} , |
{6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54}, |
{0,12,24,36,54,78,108,144,186,240,312,402,522,576}, |
{4,4,4,6,8,10,12,14,18,24,30,40,18} }, |
{ {0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576}, |
{12,12,12,12,12,12,16,20,24,28,32,40,48,56,64,76,90,2,2,2,2,2}, |
{0, 24, 48, 72,108,156,216,288,372,480,486,492,498,576}, |
{8,8,8,12,16,20,24,28,36,2,2,2,26} } , |
}; |
static int mapbuf0[9][152]; |
static int mapbuf1[9][156]; |
static int mapbuf2[9][44]; |
static int *map[9][3]; |
static int *mapend[9][3]; |
static unsigned int n_slen2[512]; /* MPEG 2.0 slen for 'normal' mode */ |
static unsigned int i_slen2[256]; /* MPEG 2.0 slen for intensity stereo */ |
static real tan1_1[16],tan2_1[16],tan1_2[16],tan2_2[16]; |
static real pow1_1[2][16],pow2_1[2][16],pow1_2[2][16],pow2_2[2][16]; |
#ifdef GAPLESS |
/* still a dirty hack, places in bytes (zero-based)... */ |
static unsigned long position; /* position in raw decoder bytestream */ |
static unsigned long begin; /* first byte to play == number to skip */ |
static unsigned long end; /* last byte to play */ |
static unsigned long ignore; /* forcedly ignore stuff in between */ |
static int bytified; |
/* input in bytes already */ |
void layer3_gapless_init(unsigned long b, unsigned long e) |
{ |
bytified = 0; |
position = 0; |
ignore = 0; |
begin = b; |
end = e; |
debug2("layer3_gapless_init: from %lu to %lu samples", begin, end); |
} |
void layer3_gapless_set_position(unsigned long frames, struct frame* fr, struct audio_info_struct *ai) |
{ |
position = samples_to_bytes(frames*spf(fr), fr, ai); |
debug1("set; position now %lu", position); |
} |
void layer3_gapless_bytify(struct frame *fr, struct audio_info_struct *ai) |
{ |
if(!bytified) |
{ |
begin = samples_to_bytes(begin, fr, ai); |
end = samples_to_bytes(end, fr, ai); |
bytified = 1; |
debug2("bytified: begin=%lu; end=%5lu", begin, end); |
} |
} |
/* I need initialized fr here! */ |
void layer3_gapless_set_ignore(unsigned long frames, struct frame *fr, struct audio_info_struct *ai) |
{ |
ignore = samples_to_bytes(frames*spf(fr), fr, ai); |
} |
/* |
take the (partially or fully) filled and remove stuff for gapless mode if needed |
pcm_point may then be smaller than before... |
*/ |
void layer3_gapless_buffercheck() |
{ |
/* pcm_point bytes added since last position... */ |
unsigned long new_pos = position + pcm_point; |
if(begin && (position < begin)) |
{ |
debug4("new_pos %lu (old: %lu), begin %lu, pcm_point %i", new_pos, position, begin, pcm_point); |
if(new_pos < begin) |
{ |
if(ignore > pcm_point) ignore -= pcm_point; |
else ignore = 0; |
pcm_point = 0; /* full of padding/delay */ |
} |
else |
{ |
unsigned long ignored = begin-position; |
/* we need to shift the memory to the left... */ |
debug3("old pcm_point: %i, begin %lu; good bytes: %i", pcm_point, begin, (int)(new_pos-begin)); |
if(ignore > ignored) ignore -= ignored; |
else ignore = 0; |
pcm_point -= ignored; |
debug3("shifting %i bytes from %p to %p", pcm_point, pcm_sample+(int)(begin-position), pcm_sample); |
memmove(pcm_sample, pcm_sample+(int)(begin-position), pcm_point); |
} |
} |
/* I don't cover the case with both end and begin in chunk! */ |
else if(end && (new_pos > end)) |
{ |
ignore = 0; |
/* either end in current chunk or chunk totally out */ |
debug2("ending at position %lu / point %i", new_pos, pcm_point); |
if(position < end) pcm_point -= new_pos-end; |
else pcm_point = 0; |
debug1("set pcm_point to %i", pcm_point); |
} |
else if(ignore) |
{ |
if(pcm_point < ignore) |
{ |
ignore -= pcm_point; |
debug2("ignored %i bytes; pcm_point = 0; %lu bytes left", pcm_point, ignore); |
pcm_point = 0; |
} |
else |
{ |
/* we need to shift the memory to the left... */ |
debug3("old pcm_point: %i, to ignore: %lu; good bytes: %i", pcm_point, ignore, pcm_point-(int)ignore); |
pcm_point -= ignore; |
debug3("shifting %i bytes from %p to %p", pcm_point, pcm_sample+ignore, pcm_sample); |
memmove(pcm_sample, pcm_sample+ignore, pcm_point); |
ignore = 0; |
} |
} |
position = new_pos; |
} |
#endif |
/* |
* init tables for layer-3 |
*/ |
real hybridIn [2][SBLIMIT][SSLIMIT]; |
real hybridOut[2][SSLIMIT][SBLIMIT]; |
static real block[2][2][SBLIMIT*SSLIMIT] = { { { 0, } } }; |
static int blc[2]={0,0}; |
void reset_mpg() |
{ |
memset(block,0,sizeof(block)); |
blc[0]=0; |
blc[1]=0; |
init_dct(); |
}; |
#pragma warning(disable:4244) |
void init_layer3(int down_sample_sblimit) |
{ |
int i,j,k,l; |
for(i=-256;i<118+4;i++) |
#ifdef USE_MMX |
if(!param.down_sample) |
gainpow2[i+256] = 16384.0 * pow((double)2.0,-0.25 * (double) (i+210) ); |
else |
#endif |
gainpow2[i+256] = DOUBLE_TO_REAL(pow_test((double)2.0,-0.25 * (double) (i+210))); |
for(i=0;i<8207;i++) |
ispow[i] = DOUBLE_TO_REAL(pow_test((double)i,(double)4.0/3.0)); |
for (i=0;i<8;i++) { |
static double Ci[8]={-0.6,-0.535,-0.33,-0.185,-0.095,-0.041,-0.0142,-0.0037}; |
double sq=sqrt(1.0+Ci[i]*Ci[i]); |
aa_cs[i] = DOUBLE_TO_REAL(1.0/sq); |
aa_ca[i] = DOUBLE_TO_REAL(Ci[i]/sq); |
} |
for(i=0;i<18;i++) { |
win[0][i] = win[1][i] = DOUBLE_TO_REAL(0.5 * sin( M_PI / 72.0 * (double) (2*(i+0) +1) ) / cos ( M_PI * (double) (2*(i+0) +19) / 72.0 )); |
win[0][i+18] = win[3][i+18] = DOUBLE_TO_REAL(0.5 * sin( M_PI / 72.0 * (double) (2*(i+18)+1) ) / cos ( M_PI * (double) (2*(i+18)+19) / 72.0 )); |
} |
for(i=0;i<6;i++) { |
win[1][i+18] = DOUBLE_TO_REAL(0.5 / cos ( M_PI * (double) (2*(i+18)+19) / 72.0 )); |
win[3][i+12] = DOUBLE_TO_REAL(0.5 / cos ( M_PI * (double) (2*(i+12)+19) / 72.0 )); |
win[1][i+24] = DOUBLE_TO_REAL(0.5 * sin( M_PI / 24.0 * (double) (2*i+13) ) / cos ( M_PI * (double) (2*(i+24)+19) / 72.0 )); |
win[1][i+30] = win[3][i] = DOUBLE_TO_REAL(0.0); |
win[3][i+6 ] = DOUBLE_TO_REAL(0.5 * sin( M_PI / 24.0 * (double) (2*i+1) ) / cos ( M_PI * (double) (2*(i+6 )+19) / 72.0 )); |
} |
for(i=0;i<9;i++) |
COS9[i] = DOUBLE_TO_REAL(cos( M_PI / 18.0 * (double) i)); |
for(i=0;i<9;i++) |
tfcos36[i] = DOUBLE_TO_REAL(0.5 / cos ( M_PI * (double) (i*2+1) / 36.0 )); |
for(i=0;i<3;i++) |
tfcos12[i] = DOUBLE_TO_REAL(0.5 / cos ( M_PI * (double) (i*2+1) / 12.0 )); |
COS6_1 = DOUBLE_TO_REAL(cos( M_PI / 6.0 * (double) 1)); |
COS6_2 = DOUBLE_TO_REAL(cos( M_PI / 6.0 * (double) 2)); |
#ifdef NEW_DCT9 |
cos9[0] = DOUBLE_TO_REAL(cos(1.0*M_PI/9.0)); |
cos9[1] = DOUBLE_TO_REAL(cos(5.0*M_PI/9.0)); |
cos9[2] = DOUBLE_TO_REAL(cos(7.0*M_PI/9.0)); |
cos18[0] = DOUBLE_TO_REAL(cos(1.0*M_PI/18.0)); |
cos18[1] = DOUBLE_TO_REAL(cos(11.0*M_PI/18.0)); |
cos18[2] = DOUBLE_TO_REAL(cos(13.0*M_PI/18.0)); |
#endif |
for(i=0;i<12;i++) { |
win[2][i] = DOUBLE_TO_REAL(0.5 * sin( M_PI / 24.0 * (double) (2*i+1) ) / cos ( M_PI * (double) (2*i+7) / 24.0 )); |
for(j=0;j<6;j++) |
COS1[i][j] = DOUBLE_TO_REAL(cos( M_PI / 24.0 * (double) ((2*i+7)*(2*j+1)) )); |
} |
for(j=0;j<4;j++) { |
static int len[4] = { 36,36,12,36 }; |
for(i=0;i<len[j];i+=2) |
win1[j][i] = + win[j][i]; |
for(i=1;i<len[j];i+=2) |
win1[j][i] = - win[j][i]; |
} |
for(i=0;i<16;i++) { |
double t = tan( (double) i * M_PI / 12.0 ); |
tan1_1[i] = DOUBLE_TO_REAL(t / (1.0+t)); |
tan2_1[i] = DOUBLE_TO_REAL(1.0 / (1.0 + t)); |
tan1_2[i] = DOUBLE_TO_REAL(M_SQRT2 * t / (1.0+t)); |
tan2_2[i] = DOUBLE_TO_REAL(M_SQRT2 / (1.0 + t)); |
for(j=0;j<2;j++) { |
double base = pow_test(2.0,-0.25*(j+1.0)); |
double p1=1.0,p2=1.0; |
if(i > 0) { |
if( i & 1 ) |
p1 = pow_test(base,(i+1.0)*0.5); |
else |
p2 = pow_test(base,i*0.5); |
} |
pow1_1[j][i] = DOUBLE_TO_REAL(p1); |
pow2_1[j][i] = DOUBLE_TO_REAL(p2); |
pow1_2[j][i] = DOUBLE_TO_REAL(M_SQRT2 * p1); |
pow2_2[j][i] = DOUBLE_TO_REAL(M_SQRT2 * p2); |
} |
} |
for(j=0;j<9;j++) { |
struct bandInfoStruct *bi = &bandInfo[j]; |
int *mp; |
int cb,lwin; |
int *bdf; |
mp = map[j][0] = mapbuf0[j]; |
bdf = bi->longDiff; |
for(i=0,cb = 0; cb < 8 ; cb++,i+=*bdf++) { |
*mp++ = (*bdf) >> 1; |
*mp++ = i; |
*mp++ = 3; |
*mp++ = cb; |
} |
bdf = bi->shortDiff+3; |
for(cb=3;cb<13;cb++) { |
int l = (*bdf++) >> 1; |
for(lwin=0;lwin<3;lwin++) { |
*mp++ = l; |
*mp++ = i + lwin; |
*mp++ = lwin; |
*mp++ = cb; |
} |
i += 6*l; |
} |
mapend[j][0] = mp; |
mp = map[j][1] = mapbuf1[j]; |
bdf = bi->shortDiff+0; |
for(i=0,cb=0;cb<13;cb++) { |
int l = (*bdf++) >> 1; |
for(lwin=0;lwin<3;lwin++) { |
*mp++ = l; |
*mp++ = i + lwin; |
*mp++ = lwin; |
*mp++ = cb; |
} |
i += 6*l; |
} |
mapend[j][1] = mp; |
mp = map[j][2] = mapbuf2[j]; |
bdf = bi->longDiff; |
for(cb = 0; cb < 22 ; cb++) { |
*mp++ = (*bdf++) >> 1; |
*mp++ = cb; |
} |
mapend[j][2] = mp; |
} |
for(j=0;j<9;j++) { |
for(i=0;i<23;i++) { |
longLimit[j][i] = (bandInfo[j].longIdx[i] - 1 + 8) / 18 + 1; |
if(longLimit[j][i] > (down_sample_sblimit) ) |
longLimit[j][i] = down_sample_sblimit; |
} |
for(i=0;i<14;i++) { |
shortLimit[j][i] = (bandInfo[j].shortIdx[i] - 1) / 18 + 1; |
if(shortLimit[j][i] > (down_sample_sblimit) ) |
shortLimit[j][i] = down_sample_sblimit; |
} |
} |
for(i=0;i<5;i++) { |
for(j=0;j<6;j++) { |
for(k=0;k<6;k++) { |
int n = k + j * 6 + i * 36; |
i_slen2[n] = i|(j<<3)|(k<<6)|(3<<12); |
} |
} |
} |
for(i=0;i<4;i++) { |
for(j=0;j<4;j++) { |
for(k=0;k<4;k++) { |
int n = k + j * 4 + i * 16; |
i_slen2[n+180] = i|(j<<3)|(k<<6)|(4<<12); |
} |
} |
} |
for(i=0;i<4;i++) { |
for(j=0;j<3;j++) { |
int n = j + i * 3; |
i_slen2[n+244] = i|(j<<3) | (5<<12); |
n_slen2[n+500] = i|(j<<3) | (2<<12) | (1<<15); |
} |
} |
for(i=0;i<5;i++) { |
for(j=0;j<5;j++) { |
for(k=0;k<4;k++) { |
for(l=0;l<4;l++) { |
int n = l + k * 4 + j * 16 + i * 80; |
n_slen2[n] = i|(j<<3)|(k<<6)|(l<<9)|(0<<12); |
} |
} |
} |
} |
for(i=0;i<5;i++) { |
for(j=0;j<5;j++) { |
for(k=0;k<4;k++) { |
int n = k + j * 4 + i * 20; |
n_slen2[n+400] = i|(j<<3)|(k<<6)|(1<<12); |
} |
} |
} |
} |
/* |
* read additional side information (for MPEG 1 and MPEG 2) |
*/ |
static int III_get_side_info(struct III_sideinfo *si,int stereo, |
int ms_stereo,long sfreq,int single,int lsf) |
{ |
int ch, gr; |
int powdiff = (single == 3) ? 4 : 0; |
static const int tabs[2][5] = { { 2,9,5,3,4 } , { 1,8,1,2,9 } }; |
const int *tab = tabs[lsf]; |
si->main_data_begin = getbits(tab[1]); |
if (stereo == 1) |
si->private_bits = getbits_fast(tab[2]); |
else |
si->private_bits = getbits_fast(tab[3]); |
if(!lsf) { |
for (ch=0; ch<stereo; ch++) { |
si->ch[ch].gr[0].scfsi = -1; |
si->ch[ch].gr[1].scfsi = getbits_fast(4); |
} |
} |
for (gr=0; gr<tab[0]; gr++) { |
for (ch=0; ch<stereo; ch++) { |
register struct gr_info_s *gr_info = &(si->ch[ch].gr[gr]); |
gr_info->part2_3_length = getbits(12); |
gr_info->big_values = getbits(9); |
if(gr_info->big_values > 288) { |
gr_info->big_values = 288; |
} |
gr_info->pow2gain = gainpow2+256 - getbits_fast(8) + powdiff; |
if(ms_stereo) |
gr_info->pow2gain += 2; |
gr_info->scalefac_compress = getbits(tab[4]); |
if(get1bit()) { /* window switch flag */ |
int i; |
gr_info->block_type = getbits_fast(2); |
gr_info->mixed_block_flag = get1bit(); |
gr_info->table_select[0] = getbits_fast(5); |
gr_info->table_select[1] = getbits_fast(5); |
/* |
* table_select[2] not needed, because there is no region2, |
* but to satisfy some verifications tools we set it either. |
*/ |
gr_info->table_select[2] = 0; |
for(i=0;i<3;i++) |
gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(3)<<3); |
if(gr_info->block_type == 0) { |
/* exit(1); */ |
return 1; |
} |
/* region_count/start parameters are implicit in this case. */ |
if(!lsf || gr_info->block_type == 2) |
gr_info->region1start = 36>>1; |
else { |
/* check this again for 2.5 and sfreq=8 */ |
if(sfreq == 8) |
gr_info->region1start = 108>>1; |
else |
gr_info->region1start = 54>>1; |
} |
gr_info->region2start = 576>>1; |
} |
else { |
int i,r0c,r1c; |
for (i=0; i<3; i++) |
gr_info->table_select[i] = getbits_fast(5); |
r0c = getbits_fast(4); |
r1c = getbits_fast(3); |
gr_info->region1start = bandInfo[sfreq].longIdx[r0c+1] >> 1 ; |
gr_info->region2start = bandInfo[sfreq].longIdx[r0c+1+r1c+1] >> 1; |
gr_info->block_type = 0; |
gr_info->mixed_block_flag = 0; |
} |
if(!lsf) |
gr_info->preflag = get1bit(); |
gr_info->scalefac_scale = get1bit(); |
gr_info->count1table_select = get1bit(); |
} |
} |
return 0; |
} |
/* |
* read scalefactors |
*/ |
static int III_get_scale_factors_1(int *scf,struct gr_info_s *gr_info,int ch,int gr) |
{ |
static const unsigned char slen[2][16] = { |
{0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4}, |
{0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3} |
}; |
int numbits; |
int num0 = slen[0][gr_info->scalefac_compress]; |
int num1 = slen[1][gr_info->scalefac_compress]; |
if (gr_info->block_type == 2) { |
int i=18; |
numbits = (num0 + num1) * 18; |
if (gr_info->mixed_block_flag) { |
for (i=8;i;i--) |
*scf++ = getbits_fast(num0); |
i = 9; |
numbits -= num0; /* num0 * 17 + num1 * 18 */ |
} |
for (;i;i--) |
*scf++ = getbits_fast(num0); |
for (i = 18; i; i--) |
*scf++ = getbits_fast(num1); |
*scf++ = 0; *scf++ = 0; *scf++ = 0; /* short[13][0..2] = 0 */ |
} |
else { |
int i; |
int scfsi = gr_info->scfsi; |
if(scfsi < 0) { /* scfsi < 0 => granule == 0 */ |
for(i=11;i;i--) |
*scf++ = getbits_fast(num0); |
for(i=10;i;i--) |
*scf++ = getbits_fast(num1); |
numbits = (num0 + num1) * 10 + num0; |
*scf++ = 0; |
} |
else { |
numbits = 0; |
if(!(scfsi & 0x8)) { |
for (i=0;i<6;i++) |
*scf++ = getbits_fast(num0); |
numbits += num0 * 6; |
} |
else { |
scf += 6; |
} |
if(!(scfsi & 0x4)) { |
for (i=0;i<5;i++) |
*scf++ = getbits_fast(num0); |
numbits += num0 * 5; |
} |
else { |
scf += 5; |
} |
if(!(scfsi & 0x2)) { |
for(i=0;i<5;i++) |
*scf++ = getbits_fast(num1); |
numbits += num1 * 5; |
} |
else { |
scf += 5; |
} |
if(!(scfsi & 0x1)) { |
for (i=0;i<5;i++) |
*scf++ = getbits_fast(num1); |
numbits += num1 * 5; |
} |
else { |
scf += 5; |
} |
*scf++ = 0; /* no l[21] in original sources */ |
} |
} |
return numbits; |
} |
static int III_get_scale_factors_2(int *scf,struct gr_info_s *gr_info,int i_stereo) |
{ |
unsigned char *pnt; |
int i,j,n=0,numbits=0; |
unsigned int slen; |
static const unsigned char stab[3][6][4] = { |
{ { 6, 5, 5,5 } , { 6, 5, 7,3 } , { 11,10,0,0} , |
{ 7, 7, 7,0 } , { 6, 6, 6,3 } , { 8, 8,5,0} } , |
{ { 9, 9, 9,9 } , { 9, 9,12,6 } , { 18,18,0,0} , |
{12,12,12,0 } , {12, 9, 9,6 } , { 15,12,9,0} } , |
{ { 6, 9, 9,9 } , { 6, 9,12,6 } , { 15,18,0,0} , |
{ 6,15,12,0 } , { 6,12, 9,6 } , { 6,18,9,0} } }; |
if(i_stereo) /* i_stereo AND second channel -> do_layer3() checks this */ |
slen = i_slen2[gr_info->scalefac_compress>>1]; |
else |
slen = n_slen2[gr_info->scalefac_compress]; |
gr_info->preflag = (slen>>15) & 0x1; |
n = 0; |
if( gr_info->block_type == 2 ) { |
n++; |
if(gr_info->mixed_block_flag) |
n++; |
} |
pnt = stab[n][(slen>>12)&0x7]; |
for(i=0;i<4;i++) { |
int num = slen & 0x7; |
slen >>= 3; |
if(num) { |
for(j=0;j<(int)(pnt[i]);j++) |
*scf++ = getbits_fast(num); |
numbits += pnt[i] * num; |
} |
else { |
for(j=0;j<(int)(pnt[i]);j++) |
*scf++ = 0; |
} |
} |
n = (n << 1) + 1; |
for(i=0;i<n;i++) |
*scf++ = 0; |
return numbits; |
} |
static int pretab1[22] = {0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0}; |
static int pretab2[22] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
/* |
* Dequantize samples (includes huffman decoding) |
*/ |
/* 24 is enough because tab13 has max. a 19 bit huffvector */ |
#define BITSHIFT ((sizeof(long)-1)*8) |
#define REFRESH_MASK \ |
while(num < BITSHIFT) { \ |
mask |= ((unsigned long)getbyte())<<(BITSHIFT-num); \ |
num += 8; \ |
part2remain -= 8; } |
static int III_dequantize_sample(real xr[SBLIMIT][SSLIMIT],int *scf, |
struct gr_info_s *gr_info,int sfreq,int part2bits) |
{ |
int shift = 1 + gr_info->scalefac_scale; |
real *xrpnt = (real *) xr; |
int l[3],l3; |
int part2remain = gr_info->part2_3_length - part2bits; |
int *me; |
/* mhipp tree has this split up a bit... */ |
int num=getbitoffset(); |
long mask = (long) getbits(num)<<(BITSHIFT+8-num); |
part2remain -= num; |
{ |
int bv = gr_info->big_values; |
int region1 = gr_info->region1start; |
int region2 = gr_info->region2start; |
if(region1 > region2) |
{ |
return 1; |
} |
l3 = ((576>>1)-bv)>>1; |
/* |
* we may lose the 'odd' bit here !! |
* check this later again |
*/ |
if(bv <= region1) { |
l[0] = bv; l[1] = 0; l[2] = 0; |
} |
else { |
l[0] = region1; |
if(bv <= region2) { |
l[1] = bv - l[0]; l[2] = 0; |
} |
else { |
l[1] = region2 - l[0]; l[2] = bv - region2; |
} |
} |
} |
if(gr_info->block_type == 2) { |
/* |
* decoding with short or mixed mode BandIndex table |
*/ |
int i,max[4]; |
int step=0,lwin=3,cb=0; |
register real v = 0.0; |
register int *m,mc; |
if(gr_info->mixed_block_flag) { |
max[3] = -1; |
max[0] = max[1] = max[2] = 2; |
m = map[sfreq][0]; |
me = mapend[sfreq][0]; |
} |
else { |
max[0] = max[1] = max[2] = max[3] = -1; |
/* max[3] not really needed in this case */ |
m = map[sfreq][1]; |
me = mapend[sfreq][1]; |
} |
mc = 0; |
for(i=0;i<2;i++) { |
int lp = l[i]; |
struct newhuff *h = ht+gr_info->table_select[i]; |
for(;lp;lp--,mc--) { |
register int x,y; |
if( (!mc) ) { |
mc = *m++; |
xrpnt = ((real *) xr) + (*m++); |
lwin = *m++; |
cb = *m++; |
if(lwin == 3) { |
v = gr_info->pow2gain[(*scf++) << shift]; |
step = 1; |
} |
else { |
v = gr_info->full_gain[lwin][(*scf++) << shift]; |
step = 3; |
} |
} |
{ |
register short *val = h->table; |
REFRESH_MASK; |
while((y=*val++)<0) { |
if (mask < 0) |
val -= y; |
num--; |
mask <<= 1; |
} |
x = y >> 4; |
y &= 0xf; |
} |
if(x == 15 && h->linbits) { |
max[lwin] = cb; |
REFRESH_MASK; |
x += ((unsigned long) mask) >> (BITSHIFT+8-h->linbits); |
num -= h->linbits+1; |
mask <<= h->linbits; |
if(mask < 0) |
*xrpnt = REAL_MUL(-ispow[x], v); |
else |
*xrpnt = REAL_MUL(ispow[x], v); |
mask <<= 1; |
} |
else if(x) { |
max[lwin] = cb; |
if(mask < 0) |
*xrpnt = REAL_MUL(-ispow[x], v); |
else |
*xrpnt = REAL_MUL(ispow[x], v); |
num--; |
mask <<= 1; |
} |
else |
*xrpnt = DOUBLE_TO_REAL(0.0); |
xrpnt += step; |
if(y == 15 && h->linbits) { |
max[lwin] = cb; |
REFRESH_MASK; |
y += ((unsigned long) mask) >> (BITSHIFT+8-h->linbits); |
num -= h->linbits+1; |
mask <<= h->linbits; |
if(mask < 0) |
*xrpnt = REAL_MUL(-ispow[y], v); |
else |
*xrpnt = REAL_MUL(ispow[y], v); |
mask <<= 1; |
} |
else if(y) { |
max[lwin] = cb; |
if(mask < 0) |
*xrpnt = REAL_MUL(-ispow[y], v); |
else |
*xrpnt = REAL_MUL(ispow[y], v); |
num--; |
mask <<= 1; |
} |
else |
*xrpnt = DOUBLE_TO_REAL(0.0); |
xrpnt += step; |
} |
} |
for(;l3 && (part2remain+num > 0);l3--) { |
/* not mixing code and declarations to keep C89 happy */ |
struct newhuff* h; |
register short* val; |
register short a; |
/* This is only a humble hack to prevent a special segfault. */ |
/* More insight into the real workings is still needed. */ |
/* especially why there are (valid?) files that make xrpnt exceed the array with 4 bytes without segfaulting, more seems to be really bad, though. */ |
#ifdef DEBUG |
if(!(xrpnt < &xr[SBLIMIT][0])) |
{ |
if(param.verbose) debug2("attempted soft xrpnt overflow (%p !< %p) ?", (void*) xrpnt, (void*) &xr[SBLIMIT][0]); |
} |
#endif |
if(!(xrpnt < &xr[SBLIMIT][0]+5)) |
{ |
return 2; |
} |
h = htc+gr_info->count1table_select; |
val = h->table; |
REFRESH_MASK; |
while((a=*val++)<0) { |
if (mask < 0) |
val -= a; |
num--; |
mask <<= 1; |
} |
if(part2remain+num <= 0) { |
num -= part2remain+num; |
break; |
} |
for(i=0;i<4;i++) { |
if(!(i & 1)) { |
if(!mc) { |
mc = *m++; |
xrpnt = ((real *) xr) + (*m++); |
lwin = *m++; |
cb = *m++; |
if(lwin == 3) { |
v = gr_info->pow2gain[(*scf++) << shift]; |
step = 1; |
} |
else { |
v = gr_info->full_gain[lwin][(*scf++) << shift]; |
step = 3; |
} |
} |
mc--; |
} |
if( (a & (0x8>>i)) ) { |
max[lwin] = cb; |
if(part2remain+num <= 0) { |
break; |
} |
if(mask < 0) |
*xrpnt = -v; |
else |
*xrpnt = v; |
num--; |
mask <<= 1; |
} |
else |
*xrpnt = DOUBLE_TO_REAL(0.0); |
xrpnt += step; |
} |
} |
if(lwin < 3) { /* short band? */ |
while(1) { |
for(;mc > 0;mc--) { |
*xrpnt = DOUBLE_TO_REAL(0.0); xrpnt += 3; /* short band -> step=3 */ |
*xrpnt = DOUBLE_TO_REAL(0.0); xrpnt += 3; |
} |
if(m >= me) |
break; |
mc = *m++; |
xrpnt = ((real *) xr) + *m++; |
if(*m++ == 0) |
break; /* optimize: field will be set to zero at the end of the function */ |
m++; /* cb */ |
} |
} |
gr_info->maxband[0] = max[0]+1; |
gr_info->maxband[1] = max[1]+1; |
gr_info->maxband[2] = max[2]+1; |
gr_info->maxbandl = max[3]+1; |
{ |
int rmax = max[0] > max[1] ? max[0] : max[1]; |
rmax = (rmax > max[2] ? rmax : max[2]) + 1; |
gr_info->maxb = rmax ? shortLimit[sfreq][rmax] : longLimit[sfreq][max[3]+1]; |
} |
} |
else { |
/* |
* decoding with 'long' BandIndex table (block_type != 2) |
*/ |
int *pretab = gr_info->preflag ? pretab1 : pretab2; |
int i,max = -1; |
int cb = 0; |
int *m = map[sfreq][2]; |
register real v = 0.0; |
int mc = 0; |
/* |
* long hash table values |
*/ |
for(i=0;i<3;i++) { |
int lp = l[i]; |
struct newhuff *h = ht+gr_info->table_select[i]; |
for(;lp;lp--,mc--) { |
int x,y; |
if(!mc) { |
mc = *m++; |
cb = *m++; |
if(cb == 21) |
v = 0.0; |
else |
v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift]; |
} |
{ |
register short *val = h->table; |
REFRESH_MASK; |
while((y=*val++)<0) { |
if (mask < 0) |
val -= y; |
num--; |
mask <<= 1; |
} |
x = y >> 4; |
y &= 0xf; |
} |
if (x == 15 && h->linbits) { |
max = cb; |
REFRESH_MASK; |
x += ((unsigned long) mask) >> (BITSHIFT+8-h->linbits); |
num -= h->linbits+1; |
mask <<= h->linbits; |
if(mask < 0) |
*xrpnt++ = REAL_MUL(-ispow[x], v); |
else |
*xrpnt++ = REAL_MUL(ispow[x], v); |
mask <<= 1; |
} |
else if(x) { |
max = cb; |
if(mask < 0) |
*xrpnt++ = REAL_MUL(-ispow[x], v); |
else |
*xrpnt++ = REAL_MUL(ispow[x], v); |
num--; |
mask <<= 1; |
} |
else |
*xrpnt++ = DOUBLE_TO_REAL(0.0); |
if (y == 15 && h->linbits) { |
max = cb; |
REFRESH_MASK; |
y += ((unsigned long) mask) >> (BITSHIFT+8-h->linbits); |
num -= h->linbits+1; |
mask <<= h->linbits; |
if(mask < 0) |
*xrpnt++ = REAL_MUL(-ispow[y], v); |
else |
*xrpnt++ = REAL_MUL(ispow[y], v); |
mask <<= 1; |
} |
else if(y) { |
max = cb; |
if(mask < 0) |
*xrpnt++ = REAL_MUL(-ispow[y], v); |
else |
*xrpnt++ = REAL_MUL(ispow[y], v); |
num--; |
mask <<= 1; |
} |
else |
*xrpnt++ = DOUBLE_TO_REAL(0.0); |
} |
} |
/* |
* short (count1table) values |
*/ |
for(;l3 && (part2remain+num > 0);l3--) { |
struct newhuff *h = htc+gr_info->count1table_select; |
register short *val = h->table,a; |
REFRESH_MASK; |
while((a=*val++)<0) { |
if (mask < 0) |
val -= a; |
num--; |
mask <<= 1; |
} |
if(part2remain+num <= 0) { |
num -= part2remain+num; |
break; |
} |
for(i=0;i<4;i++) { |
if(!(i & 1)) { |
if(!mc) { |
mc = *m++; |
cb = *m++; |
if(cb == 21) |
v = 0.0; |
else |
v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift]; |
} |
mc--; |
} |
if ( (a & (0x8>>i)) ) { |
max = cb; |
if(part2remain+num <= 0) { |
break; |
} |
if(mask < 0) |
*xrpnt++ = -v; |
else |
*xrpnt++ = v; |
num--; |
mask <<= 1; |
} |
else |
*xrpnt++ = DOUBLE_TO_REAL(0.0); |
} |
} |
gr_info->maxbandl = max+1; |
gr_info->maxb = longLimit[sfreq][gr_info->maxbandl]; |
} |
part2remain += num; |
backbits(num); |
num = 0; |
while(xrpnt < &xr[SBLIMIT][0]) |
*xrpnt++ = DOUBLE_TO_REAL(0.0); |
while( part2remain > 16 ) { |
getbits(16); /* Dismiss stuffing Bits */ |
part2remain -= 16; |
} |
if(part2remain > 0) |
getbits(part2remain); |
else if(part2remain < 0) { |
return 1; /* -> error */ |
} |
return 0; |
} |
/* |
* III_stereo: calculate real channel values for Joint-I-Stereo-mode |
*/ |
static void III_i_stereo(real xr_buf[2][SBLIMIT][SSLIMIT],int *scalefac, |
struct gr_info_s *gr_info,int sfreq,int ms_stereo,int lsf) |
{ |
real (*xr)[SBLIMIT*SSLIMIT] = (real (*)[SBLIMIT*SSLIMIT] ) xr_buf; |
struct bandInfoStruct *bi = &bandInfo[sfreq]; |
const real *tab1,*tab2; |
#if 1 |
int tab; |
/* TODO: optimize as static */ |
static const real *tabs[3][2][2] = { |
{ { tan1_1,tan2_1 } , { tan1_2,tan2_2 } }, |
{ { pow1_1[0],pow2_1[0] } , { pow1_2[0],pow2_2[0] } } , |
{ { pow1_1[1],pow2_1[1] } , { pow1_2[1],pow2_2[1] } } |
}; |
tab = lsf + (gr_info->scalefac_compress & lsf); |
tab1 = tabs[tab][ms_stereo][0]; |
tab2 = tabs[tab][ms_stereo][1]; |
#else |
if(lsf) { |
int p = gr_info->scalefac_compress & 0x1; |
if(ms_stereo) { |
tab1 = pow1_2[p]; tab2 = pow2_2[p]; |
} |
else { |
tab1 = pow1_1[p]; tab2 = pow2_1[p]; |
} |
} |
else { |
if(ms_stereo) { |
tab1 = tan1_2; tab2 = tan2_2; |
} |
else { |
tab1 = tan1_1; tab2 = tan2_1; |
} |
} |
#endif |
if (gr_info->block_type == 2) { |
int lwin,do_l = 0; |
if( gr_info->mixed_block_flag ) |
do_l = 1; |
for (lwin=0;lwin<3;lwin++) { /* process each window */ |
/* get first band with zero values */ |
int is_p,sb,idx,sfb = gr_info->maxband[lwin]; /* sfb is minimal 3 for mixed mode */ |
if(sfb > 3) |
do_l = 0; |
for(;sfb<12;sfb++) { |
is_p = scalefac[sfb*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */ |
if(is_p != 7) { |
real t1,t2; |
sb = bi->shortDiff[sfb]; |
idx = bi->shortIdx[sfb] + lwin; |
t1 = tab1[is_p]; t2 = tab2[is_p]; |
for (; sb > 0; sb--,idx+=3) { |
real v = xr[0][idx]; |
xr[0][idx] = REAL_MUL(v, t1); |
xr[1][idx] = REAL_MUL(v, t2); |
} |
} |
} |
#if 1 |
/* in the original: copy 10 to 11 , here: copy 11 to 12 |
maybe still wrong??? (copy 12 to 13?) */ |
is_p = scalefac[11*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */ |
sb = bi->shortDiff[12]; |
idx = bi->shortIdx[12] + lwin; |
#else |
is_p = scalefac[10*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */ |
sb = bi->shortDiff[11]; |
idx = bi->shortIdx[11] + lwin; |
#endif |
if(is_p != 7) { |
real t1,t2; |
t1 = tab1[is_p]; t2 = tab2[is_p]; |
for ( ; sb > 0; sb--,idx+=3 ) { |
real v = xr[0][idx]; |
xr[0][idx] = REAL_MUL(v, t1); |
xr[1][idx] = REAL_MUL(v, t2); |
} |
} |
} /* end for(lwin; .. ; . ) */ |
/* also check l-part, if ALL bands in the three windows are 'empty' |
* and mode = mixed_mode |
*/ |
if (do_l) { |
int sfb = gr_info->maxbandl; |
int idx; |
if(sfb > 21) return; /* similarity fix related to CVE-2006-1655 */ |
idx = bi->longIdx[sfb]; |
for ( ; sfb<8; sfb++ ) { |
int sb = bi->longDiff[sfb]; |
int is_p = scalefac[sfb]; /* scale: 0-15 */ |
if(is_p != 7) { |
real t1,t2; |
t1 = tab1[is_p]; t2 = tab2[is_p]; |
for ( ; sb > 0; sb--,idx++) { |
real v = xr[0][idx]; |
xr[0][idx] = REAL_MUL(v, t1); |
xr[1][idx] = REAL_MUL(v, t2); |
} |
} |
else |
idx += sb; |
} |
} |
} |
else { /* ((gr_info->block_type != 2)) */ |
int sfb = gr_info->maxbandl; |
int is_p,idx; |
if(sfb > 21) return; /* tightened fix for CVE-2006-1655 */ |
idx = bi->longIdx[sfb]; |
for ( ; sfb<21; sfb++) { |
int sb = bi->longDiff[sfb]; |
is_p = scalefac[sfb]; /* scale: 0-15 */ |
if(is_p != 7) { |
real t1,t2; |
t1 = tab1[is_p]; t2 = tab2[is_p]; |
for ( ; sb > 0; sb--,idx++) { |
real v = xr[0][idx]; |
xr[0][idx] = REAL_MUL(v, t1); |
xr[1][idx] = REAL_MUL(v, t2); |
} |
} |
else |
idx += sb; |
} |
is_p = scalefac[20]; |
if(is_p != 7) { /* copy l-band 20 to l-band 21 */ |
int sb; |
real t1 = tab1[is_p],t2 = tab2[is_p]; |
for ( sb = bi->longDiff[21]; sb > 0; sb--,idx++ ) { |
real v = xr[0][idx]; |
xr[0][idx] = REAL_MUL(v, t1); |
xr[1][idx] = REAL_MUL(v, t2); |
} |
} |
} /* ... */ |
} |
static void III_antialias(real xr[SBLIMIT][SSLIMIT],struct gr_info_s *gr_info) { |
int sblim; |
if(gr_info->block_type == 2) { |
if(!gr_info->mixed_block_flag) |
return; |
sblim = 1; |
} |
else { |
sblim = gr_info->maxb-1; |
} |
/* 31 alias-reduction operations between each pair of sub-bands */ |
/* with 8 butterflies between each pair */ |
{ |
int sb; |
real *xr1=(real *) xr[1]; |
for(sb=sblim;sb;sb--,xr1+=10) { |
int ss; |
real *cs=aa_cs,*ca=aa_ca; |
real *xr2 = xr1; |
for(ss=7;ss>=0;ss--) |
{ /* upper and lower butterfly inputs */ |
register real bu = *--xr2,bd = *xr1; |
*xr2 = REAL_MUL(bu, *cs) - REAL_MUL(bd, *ca); |
*xr1++ = REAL_MUL(bd, *cs++) + REAL_MUL(bu, *ca++); |
} |
} |
} |
} |
/* |
// This is an optimized DCT from Jeff Tsay's maplay 1.2+ package. |
// Saved one multiplication by doing the 'twiddle factor' stuff |
// together with the window mul. (MH) |
// |
// This uses Byeong Gi Lee's Fast Cosine Transform algorithm, but the |
// 9 point IDCT needs to be reduced further. Unfortunately, I don't |
// know how to do that, because 9 is not an even number. - Jeff. |
// |
////////////////////////////////////////////////////////////////// |
// |
// 9 Point Inverse Discrete Cosine Transform |
// |
// This piece of code is Copyright 1997 Mikko Tommila and is freely usable |
// by anybody. The algorithm itself is of course in the public domain. |
// |
// Again derived heuristically from the 9-point WFTA. |
// |
// The algorithm is optimized (?) for speed, not for small rounding errors or |
// good readability. |
// |
// 36 additions, 11 multiplications |
// |
// Again this is very likely sub-optimal. |
// |
// The code is optimized to use a minimum number of temporary variables, |
// so it should compile quite well even on 8-register Intel x86 processors. |
// This makes the code quite obfuscated and very difficult to understand. |
// |
// References: |
// [1] S. Winograd: "On Computing the Discrete Fourier Transform", |
// Mathematics of Computation, Volume 32, Number 141, January 1978, |
// Pages 175-199 |
*/ |
/*------------------------------------------------------------------*/ |
/* */ |
/* Function: Calculation of the inverse MDCT */ |
/* */ |
/*------------------------------------------------------------------*/ |
#ifdef USE_3DNOW |
void dct36(real *inbuf,real *o1,real *o2,real *wintab,real *tsbuf) |
#else |
static void dct36(real *inbuf,real *o1,real *o2,real *wintab,real *tsbuf) |
#endif |
{ |
#ifdef NEW_DCT9 |
real tmp[18]; |
#endif |
{ |
register real *in = inbuf; |
in[17]+=in[16]; in[16]+=in[15]; in[15]+=in[14]; |
in[14]+=in[13]; in[13]+=in[12]; in[12]+=in[11]; |
in[11]+=in[10]; in[10]+=in[9]; in[9] +=in[8]; |
in[8] +=in[7]; in[7] +=in[6]; in[6] +=in[5]; |
in[5] +=in[4]; in[4] +=in[3]; in[3] +=in[2]; |
in[2] +=in[1]; in[1] +=in[0]; |
in[17]+=in[15]; in[15]+=in[13]; in[13]+=in[11]; in[11]+=in[9]; |
in[9] +=in[7]; in[7] +=in[5]; in[5] +=in[3]; in[3] +=in[1]; |
#ifdef NEW_DCT9 |
#if 1 |
{ |
real t3; |
{ |
real t0, t1, t2; |
t0 = REAL_MUL(COS6_2, (in[8] + in[16] - in[4])); |
t1 = REAL_MUL(COS6_2, in[12]); |
t3 = in[0]; |
t2 = t3 - t1 - t1; |
tmp[1] = tmp[7] = t2 - t0; |
tmp[4] = t2 + t0 + t0; |
t3 += t1; |
t2 = REAL_MUL(COS6_1, (in[10] + in[14] - in[2])); |
tmp[1] -= t2; |
tmp[7] += t2; |
} |
{ |
real t0, t1, t2; |
t0 = REAL_MUL(cos9[0], (in[4] + in[8] )); |
t1 = REAL_MUL(cos9[1], (in[8] - in[16])); |
t2 = REAL_MUL(cos9[2], (in[4] + in[16])); |
tmp[2] = tmp[6] = t3 - t0 - t2; |
tmp[0] = tmp[8] = t3 + t0 + t1; |
tmp[3] = tmp[5] = t3 - t1 + t2; |
} |
} |
{ |
real t1, t2, t3; |
t1 = REAL_MUL(cos18[0], (in[2] + in[10])); |
t2 = REAL_MUL(cos18[1], (in[10] - in[14])); |
t3 = REAL_MUL(COS6_1, in[6]); |
{ |
real t0 = t1 + t2 + t3; |
tmp[0] += t0; |
tmp[8] -= t0; |
} |
t2 -= t3; |
t1 -= t3; |
t3 = REAL_MUL(cos18[2], (in[2] + in[14])); |
t1 += t3; |
tmp[3] += t1; |
tmp[5] -= t1; |
t2 -= t3; |
tmp[2] += t2; |
tmp[6] -= t2; |
} |
#else |
{ |
real t0, t1, t2, t3, t4, t5, t6, t7; |
t1 = REAL_MUL(COS6_2, in[12]); |
t2 = REAL_MUL(COS6_2, (in[8] + in[16] - in[4])); |
t3 = in[0] + t1; |
t4 = in[0] - t1 - t1; |
t5 = t4 - t2; |
tmp[4] = t4 + t2 + t2; |
t0 = REAL_MUL(cos9[0], (in[4] + in[8])); |
t1 = REAL_MUL(cos9[1], (in[8] - in[16])); |
t2 = REAL_MUL(cos9[2], (in[4] + in[16])); |
t6 = t3 - t0 - t2; |
t0 += t3 + t1; |
t3 += t2 - t1; |
t2 = REAL_MUL(cos18[0], (in[2] + in[10])); |
t4 = REAL_MUL(cos18[1], (in[10] - in[14])); |
t7 = REAL_MUL(COS6_1, in[6]); |
t1 = t2 + t4 + t7; |
tmp[0] = t0 + t1; |
tmp[8] = t0 - t1; |
t1 = REAL_MUL(cos18[2], (in[2] + in[14])); |
t2 += t1 - t7; |
tmp[3] = t3 + t2; |
t0 = REAL_MUL(COS6_1, (in[10] + in[14] - in[2])); |
tmp[5] = t3 - t2; |
t4 -= t1 + t7; |
tmp[1] = t5 - t0; |
tmp[7] = t5 + t0; |
tmp[2] = t6 + t4; |
tmp[6] = t6 - t4; |
} |
#endif |
{ |
real t0, t1, t2, t3, t4, t5, t6, t7; |
t1 = REAL_MUL(COS6_2, in[13]); |
t2 = REAL_MUL(COS6_2, (in[9] + in[17] - in[5])); |
t3 = in[1] + t1; |
t4 = in[1] - t1 - t1; |
t5 = t4 - t2; |
t0 = REAL_MUL(cos9[0], (in[5] + in[9])); |
t1 = REAL_MUL(cos9[1], (in[9] - in[17])); |
tmp[13] = REAL_MUL((t4 + t2 + t2), tfcos36[17-13]); |
t2 = REAL_MUL(cos9[2], (in[5] + in[17])); |
t6 = t3 - t0 - t2; |
t0 += t3 + t1; |
t3 += t2 - t1; |
t2 = REAL_MUL(cos18[0], (in[3] + in[11])); |
t4 = REAL_MUL(cos18[1], (in[11] - in[15])); |
t7 = REAL_MUL(COS6_1, in[7]); |
t1 = t2 + t4 + t7; |
tmp[17] = REAL_MUL((t0 + t1), tfcos36[17-17]); |
tmp[9] = REAL_MUL((t0 - t1), tfcos36[17-9]); |
t1 = REAL_MUL(cos18[2], (in[3] + in[15])); |
t2 += t1 - t7; |
tmp[14] = REAL_MUL((t3 + t2), tfcos36[17-14]); |
t0 = REAL_MUL(COS6_1, (in[11] + in[15] - in[3])); |
tmp[12] = REAL_MUL((t3 - t2), tfcos36[17-12]); |
t4 -= t1 + t7; |
tmp[16] = REAL_MUL((t5 - t0), tfcos36[17-16]); |
tmp[10] = REAL_MUL((t5 + t0), tfcos36[17-10]); |
tmp[15] = REAL_MUL((t6 + t4), tfcos36[17-15]); |
tmp[11] = REAL_MUL((t6 - t4), tfcos36[17-11]); |
} |
#define MACRO(v) { \ |
real tmpval; \ |
tmpval = tmp[(v)] + tmp[17-(v)]; \ |
out2[9+(v)] = REAL_MUL(tmpval, w[27+(v)]); \ |
out2[8-(v)] = REAL_MUL(tmpval, w[26-(v)]); \ |
tmpval = tmp[(v)] - tmp[17-(v)]; \ |
ts[SBLIMIT*(8-(v))] = out1[8-(v)] + REAL_MUL(tmpval, w[8-(v)]); \ |
ts[SBLIMIT*(9+(v))] = out1[9+(v)] + REAL_MUL(tmpval, w[9+(v)]); } |
{ |
register real *out2 = o2; |
register real *w = wintab; |
register real *out1 = o1; |
register real *ts = tsbuf; |
MACRO(0); |
MACRO(1); |
MACRO(2); |
MACRO(3); |
MACRO(4); |
MACRO(5); |
MACRO(6); |
MACRO(7); |
MACRO(8); |
} |
#else |
{ |
#define MACRO0(v) { \ |
real tmp; \ |
out2[9+(v)] = REAL_MUL((tmp = sum0 + sum1), w[27+(v)]); \ |
out2[8-(v)] = REAL_MUL(tmp, w[26-(v)]); } \ |
sum0 -= sum1; \ |
ts[SBLIMIT*(8-(v))] = out1[8-(v)] + REAL_MUL(sum0, w[8-(v)]); \ |
ts[SBLIMIT*(9+(v))] = out1[9+(v)] + REAL_MUL(sum0, w[9+(v)]); |
#define MACRO1(v) { \ |
real sum0,sum1; \ |
sum0 = tmp1a + tmp2a; \ |
sum1 = REAL_MUL((tmp1b + tmp2b), tfcos36[(v)]); \ |
MACRO0(v); } |
#define MACRO2(v) { \ |
real sum0,sum1; \ |
sum0 = tmp2a - tmp1a; \ |
sum1 = REAL_MUL((tmp2b - tmp1b), tfcos36[(v)]); \ |
MACRO0(v); } |
register const real *c = COS9; |
register real *out2 = o2; |
register real *w = wintab; |
register real *out1 = o1; |
register real *ts = tsbuf; |
real ta33,ta66,tb33,tb66; |
ta33 = REAL_MUL(in[2*3+0], c[3]); |
ta66 = REAL_MUL(in[2*6+0], c[6]); |
tb33 = REAL_MUL(in[2*3+1], c[3]); |
tb66 = REAL_MUL(in[2*6+1], c[6]); |
{ |
real tmp1a,tmp2a,tmp1b,tmp2b; |
tmp1a = REAL_MUL(in[2*1+0], c[1]) + ta33 + REAL_MUL(in[2*5+0], c[5]) + REAL_MUL(in[2*7+0], c[7]); |
tmp1b = REAL_MUL(in[2*1+1], c[1]) + tb33 + REAL_MUL(in[2*5+1], c[5]) + REAL_MUL(in[2*7+1], c[7]); |
tmp2a = REAL_MUL(in[2*2+0], c[2]) + REAL_MUL(in[2*4+0], c[4]) + ta66 + REAL_MUL(in[2*8+0], c[8]); |
tmp2b = REAL_MUL(in[2*2+1], c[2]) + REAL_MUL(in[2*4+1], c[4]) + tb66 + REAL_MUL(in[2*8+1], c[8]); |
MACRO1(0); |
MACRO2(8); |
} |
{ |
real tmp1a,tmp2a,tmp1b,tmp2b; |
tmp1a = REAL_MUL(( in[2*1+0] - in[2*5+0] - in[2*7+0] ), c[3]); |
tmp1b = REAL_MUL(( in[2*1+1] - in[2*5+1] - in[2*7+1] ), c[3]); |
tmp2a = REAL_MUL(( in[2*2+0] - in[2*4+0] - in[2*8+0] ), c[6]) - in[2*6+0] + in[2*0+0]; |
tmp2b = REAL_MUL(( in[2*2+1] - in[2*4+1] - in[2*8+1] ), c[6]) - in[2*6+1] + in[2*0+1]; |
MACRO1(1); |
MACRO2(7); |
} |
{ |
real tmp1a,tmp2a,tmp1b,tmp2b; |
tmp1a = REAL_MUL(in[2*1+0], c[5]) - ta33 - REAL_MUL(in[2*5+0], c[7]) + REAL_MUL(in[2*7+0], c[1]); |
tmp1b = REAL_MUL(in[2*1+1], c[5]) - tb33 - REAL_MUL(in[2*5+1], c[7]) + REAL_MUL(in[2*7+1], c[1]); |
tmp2a = - REAL_MUL(in[2*2+0], c[8]) - REAL_MUL(in[2*4+0], c[2]) + ta66 + REAL_MUL(in[2*8+0], c[4]); |
tmp2b = - REAL_MUL(in[2*2+1], c[8]) - REAL_MUL(in[2*4+1], c[2]) + tb66 + REAL_MUL(in[2*8+1], c[4]); |
MACRO1(2); |
MACRO2(6); |
} |
{ |
real tmp1a,tmp2a,tmp1b,tmp2b; |
tmp1a = REAL_MUL(in[2*1+0], c[7]) - ta33 + REAL_MUL(in[2*5+0], c[1]) - REAL_MUL(in[2*7+0], c[5]); |
tmp1b = REAL_MUL(in[2*1+1], c[7]) - tb33 + REAL_MUL(in[2*5+1], c[1]) - REAL_MUL(in[2*7+1], c[5]); |
tmp2a = - REAL_MUL(in[2*2+0], c[4]) + REAL_MUL(in[2*4+0], c[8]) + ta66 - REAL_MUL(in[2*8+0], c[2]); |
tmp2b = - REAL_MUL(in[2*2+1], c[4]) + REAL_MUL(in[2*4+1], c[8]) + tb66 - REAL_MUL(in[2*8+1], c[2]); |
MACRO1(3); |
MACRO2(5); |
} |
{ |
real sum0,sum1; |
sum0 = in[2*0+0] - in[2*2+0] + in[2*4+0] - in[2*6+0] + in[2*8+0]; |
sum1 = REAL_MUL((in[2*0+1] - in[2*2+1] + in[2*4+1] - in[2*6+1] + in[2*8+1] ), tfcos36[4]); |
MACRO0(4); |
} |
} |
#endif |
} |
} |
/* |
* new DCT12 |
*/ |
static void dct12(real *in,real *rawout1,real *rawout2,register real *wi,register real *ts) |
{ |
#define DCT12_PART1 \ |
in5 = in[5*3]; \ |
in5 += (in4 = in[4*3]); \ |
in4 += (in3 = in[3*3]); \ |
in3 += (in2 = in[2*3]); \ |
in2 += (in1 = in[1*3]); \ |
in1 += (in0 = in[0*3]); \ |
\ |
in5 += in3; in3 += in1; \ |
\ |
in2 = REAL_MUL(in2, COS6_1); \ |
in3 = REAL_MUL(in3, COS6_1); \ |
#define DCT12_PART2 \ |
in0 += REAL_MUL(in4, COS6_2); \ |
\ |
in4 = in0 + in2; \ |
in0 -= in2; \ |
\ |
in1 += REAL_MUL(in5, COS6_2); \ |
\ |
in5 = REAL_MUL((in1 + in3), tfcos12[0]); \ |
in1 = REAL_MUL((in1 - in3), tfcos12[2]); \ |
\ |
in3 = in4 + in5; \ |
in4 -= in5; \ |
\ |
in2 = in0 + in1; \ |
in0 -= in1; |
{ |
real in0,in1,in2,in3,in4,in5; |
register real *out1 = rawout1; |
ts[SBLIMIT*0] = out1[0]; ts[SBLIMIT*1] = out1[1]; ts[SBLIMIT*2] = out1[2]; |
ts[SBLIMIT*3] = out1[3]; ts[SBLIMIT*4] = out1[4]; ts[SBLIMIT*5] = out1[5]; |
DCT12_PART1 |
{ |
real tmp0,tmp1 = (in0 - in4); |
{ |
real tmp2 = REAL_MUL((in1 - in5), tfcos12[1]); |
tmp0 = tmp1 + tmp2; |
tmp1 -= tmp2; |
} |
ts[(17-1)*SBLIMIT] = out1[17-1] + REAL_MUL(tmp0, wi[11-1]); |
ts[(12+1)*SBLIMIT] = out1[12+1] + REAL_MUL(tmp0, wi[6+1]); |
ts[(6 +1)*SBLIMIT] = out1[6 +1] + REAL_MUL(tmp1, wi[1]); |
ts[(11-1)*SBLIMIT] = out1[11-1] + REAL_MUL(tmp1, wi[5-1]); |
} |
DCT12_PART2 |
ts[(17-0)*SBLIMIT] = out1[17-0] + REAL_MUL(in2, wi[11-0]); |
ts[(12+0)*SBLIMIT] = out1[12+0] + REAL_MUL(in2, wi[6+0]); |
ts[(12+2)*SBLIMIT] = out1[12+2] + REAL_MUL(in3, wi[6+2]); |
ts[(17-2)*SBLIMIT] = out1[17-2] + REAL_MUL(in3, wi[11-2]); |
ts[(6 +0)*SBLIMIT] = out1[6+0] + REAL_MUL(in0, wi[0]); |
ts[(11-0)*SBLIMIT] = out1[11-0] + REAL_MUL(in0, wi[5-0]); |
ts[(6 +2)*SBLIMIT] = out1[6+2] + REAL_MUL(in4, wi[2]); |
ts[(11-2)*SBLIMIT] = out1[11-2] + REAL_MUL(in4, wi[5-2]); |
} |
in++; |
{ |
real in0,in1,in2,in3,in4,in5; |
register real *out2 = rawout2; |
DCT12_PART1 |
{ |
real tmp0,tmp1 = (in0 - in4); |
{ |
real tmp2 = REAL_MUL((in1 - in5), tfcos12[1]); |
tmp0 = tmp1 + tmp2; |
tmp1 -= tmp2; |
} |
out2[5-1] = REAL_MUL(tmp0, wi[11-1]); |
out2[0+1] = REAL_MUL(tmp0, wi[6+1]); |
ts[(12+1)*SBLIMIT] += REAL_MUL(tmp1, wi[1]); |
ts[(17-1)*SBLIMIT] += REAL_MUL(tmp1, wi[5-1]); |
} |
DCT12_PART2 |
out2[5-0] = REAL_MUL(in2, wi[11-0]); |
out2[0+0] = REAL_MUL(in2, wi[6+0]); |
out2[0+2] = REAL_MUL(in3, wi[6+2]); |
out2[5-2] = REAL_MUL(in3, wi[11-2]); |
ts[(12+0)*SBLIMIT] += REAL_MUL(in0, wi[0]); |
ts[(17-0)*SBLIMIT] += REAL_MUL(in0, wi[5-0]); |
ts[(12+2)*SBLIMIT] += REAL_MUL(in4, wi[2]); |
ts[(17-2)*SBLIMIT] += REAL_MUL(in4, wi[5-2]); |
} |
in++; |
{ |
real in0,in1,in2,in3,in4,in5; |
register real *out2 = rawout2; |
out2[12]=out2[13]=out2[14]=out2[15]=out2[16]=out2[17]=0.0; |
DCT12_PART1 |
{ |
real tmp0,tmp1 = (in0 - in4); |
{ |
real tmp2 = REAL_MUL((in1 - in5), tfcos12[1]); |
tmp0 = tmp1 + tmp2; |
tmp1 -= tmp2; |
} |
out2[11-1] = REAL_MUL(tmp0, wi[11-1]); |
out2[6 +1] = REAL_MUL(tmp0, wi[6+1]); |
out2[0+1] += REAL_MUL(tmp1, wi[1]); |
out2[5-1] += REAL_MUL(tmp1, wi[5-1]); |
} |
DCT12_PART2 |
out2[11-0] = REAL_MUL(in2, wi[11-0]); |
out2[6 +0] = REAL_MUL(in2, wi[6+0]); |
out2[6 +2] = REAL_MUL(in3, wi[6+2]); |
out2[11-2] = REAL_MUL(in3, wi[11-2]); |
out2[0+0] += REAL_MUL(in0, wi[0]); |
out2[5-0] += REAL_MUL(in0, wi[5-0]); |
out2[0+2] += REAL_MUL(in4, wi[2]); |
out2[5-2] += REAL_MUL(in4, wi[5-2]); |
} |
} |
/* |
* III_hybrid |
*/ |
#ifdef USE_3DNOW |
static void III_hybrid(real fsIn[SBLIMIT][SSLIMIT],real tsOut[SSLIMIT][SBLIMIT],int ch,struct gr_info_s *gr_info,struct frame *fr) |
#else |
static void III_hybrid(real fsIn[SBLIMIT][SSLIMIT],real tsOut[SSLIMIT][SBLIMIT], |
int ch,struct gr_info_s *gr_info) |
#endif |
{ |
real *tspnt = (real *) tsOut; |
real *rawout1,*rawout2; |
int bt,sb = 0; |
{ |
int b = blc[ch]; |
rawout1=block[b][ch]; |
b=-b+1; |
rawout2=block[b][ch]; |
blc[ch] = b; |
} |
if(gr_info->mixed_block_flag) { |
sb = 2; |
#ifdef USE_3DNOW |
(fr->dct36)(fsIn[0],rawout1,rawout2,win[0],tspnt); |
(fr->dct36)(fsIn[1],rawout1+18,rawout2+18,win1[0],tspnt+1); |
#else |
dct36(fsIn[0],rawout1,rawout2,win[0],tspnt); |
dct36(fsIn[1],rawout1+18,rawout2+18,win1[0],tspnt+1); |
#endif |
rawout1 += 36; rawout2 += 36; tspnt += 2; |
} |
bt = gr_info->block_type; |
if(bt == 2) { |
for (; sb<gr_info->maxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36) { |
dct12(fsIn[sb] ,rawout1 ,rawout2 ,win[2] ,tspnt); |
dct12(fsIn[sb+1],rawout1+18,rawout2+18,win1[2],tspnt+1); |
} |
} |
else { |
for (; sb<gr_info->maxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36) { |
#ifdef USE_3DNOW |
(fr->dct36)(fsIn[sb],rawout1,rawout2,win[bt],tspnt); |
(fr->dct36)(fsIn[sb+1],rawout1+18,rawout2+18,win1[bt],tspnt+1); |
#else |
dct36(fsIn[sb],rawout1,rawout2,win[bt],tspnt); |
dct36(fsIn[sb+1],rawout1+18,rawout2+18,win1[bt],tspnt+1); |
#endif |
} |
} |
for(;sb<SBLIMIT;sb++,tspnt++) { |
int i; |
for(i=0;i<SSLIMIT;i++) { |
tspnt[i*SBLIMIT] = *rawout1++; |
*rawout2++ = DOUBLE_TO_REAL(0.0); |
} |
} |
} |
int do_layer3(struct frame *fr,byte *pcm_sample,int *pcm_point) |
{ |
int gr, ch, ss,clip=0; |
int scalefacs[2][39]; /* max 39 for short[13][3] mode, mixed: 38, long: 22 */ |
struct III_sideinfo sideinfo; |
int stereo = fr->stereo; |
int single = fr->single; |
int ms_stereo,i_stereo; |
int sfreq = fr->sampling_frequency; |
int stereo1,granules; |
if(stereo == 1) { /* stream is mono */ |
stereo1 = 1; |
single = 0; |
} |
else if(single >= 0) /* stream is stereo, but force to mono */ |
stereo1 = 1; |
else |
stereo1 = 2; |
if(fr->mode == MPG_MD_JOINT_STEREO) { |
ms_stereo = (fr->mode_ext & 0x2)>>1; |
i_stereo = fr->mode_ext & 0x1; |
} |
else |
ms_stereo = i_stereo = 0; |
if(fr->lsf) { |
granules = 1; |
#if 0 |
III_get_side_info_2(&sideinfo,stereo,ms_stereo,sfreq,single); |
#endif |
} |
else { |
granules = 2; |
} |
/* quick hack to keep the music playing */ |
/* after having seen this nasty test file... */ |
if(III_get_side_info(&sideinfo,stereo,ms_stereo,sfreq,single,fr->lsf)) |
{ |
return clip; |
} |
set_pointer(sideinfo.main_data_begin); |
for (gr=0;gr<granules;gr++) |
{ |
{ |
struct gr_info_s *gr_info = &(sideinfo.ch[0].gr[gr]); |
long part2bits; |
if(fr->lsf) |
part2bits = III_get_scale_factors_2(scalefacs[0],gr_info,0); |
else |
part2bits = III_get_scale_factors_1(scalefacs[0],gr_info,0,gr); |
if(III_dequantize_sample(hybridIn[0], scalefacs[0],gr_info,sfreq,part2bits)) |
return clip; |
} |
if(stereo == 2) { |
struct gr_info_s *gr_info = &(sideinfo.ch[1].gr[gr]); |
long part2bits; |
if(fr->lsf) |
part2bits = III_get_scale_factors_2(scalefacs[1],gr_info,i_stereo); |
else |
part2bits = III_get_scale_factors_1(scalefacs[1],gr_info,1,gr); |
if(III_dequantize_sample(hybridIn[1],scalefacs[1],gr_info,sfreq,part2bits)) |
return clip; |
if(ms_stereo) { |
int i; |
int maxb = sideinfo.ch[0].gr[gr].maxb; |
if(sideinfo.ch[1].gr[gr].maxb > maxb) |
maxb = sideinfo.ch[1].gr[gr].maxb; |
for(i=0;i<SSLIMIT*maxb;i++) { |
real tmp0 = ((real *)hybridIn[0])[i]; |
real tmp1 = ((real *)hybridIn[1])[i]; |
((real *)hybridIn[0])[i] = tmp0 + tmp1; |
((real *)hybridIn[1])[i] = tmp0 - tmp1; |
} |
} |
if(i_stereo) |
III_i_stereo(hybridIn,scalefacs[1],gr_info,sfreq,ms_stereo,fr->lsf); |
if(ms_stereo || i_stereo || (single == 3) ) { |
if(gr_info->maxb > sideinfo.ch[0].gr[gr].maxb) |
sideinfo.ch[0].gr[gr].maxb = gr_info->maxb; |
else |
gr_info->maxb = sideinfo.ch[0].gr[gr].maxb; |
} |
switch(single) { |
case 3: |
{ |
register int i; |
register real *in0 = (real *) hybridIn[0],*in1 = (real *) hybridIn[1]; |
for(i=0;i<SSLIMIT*gr_info->maxb;i++,in0++) |
*in0 = (*in0 + *in1++); /* *0.5 done by pow-scale */ |
} |
break; |
case 1: |
{ |
register int i; |
register real *in0 = (real *) hybridIn[0],*in1 = (real *) hybridIn[1]; |
for(i=0;i<SSLIMIT*gr_info->maxb;i++) |
*in0++ = *in1++; |
} |
break; |
} |
} |
for(ch=0;ch<stereo1;ch++) { |
struct gr_info_s *gr_info = &(sideinfo.ch[ch].gr[gr]); |
III_antialias(hybridIn[ch],gr_info); |
#ifdef USE_3DNOW |
III_hybrid(hybridIn[ch], hybridOut[ch], ch,gr_info,fr); |
#else |
III_hybrid(hybridIn[ch], hybridOut[ch], ch,gr_info); |
#endif |
} |
#ifdef I486_OPT |
if (fr->synth != synth_1to1 || single >= 0) { |
#endif |
for(ss=0;ss<SSLIMIT;ss++) { |
if(single >= 0) { |
clip += (fr->synth_mono)(hybridOut[0][ss],pcm_sample,pcm_point); |
} |
else { |
int p1=*pcm_point; |
clip += (fr->synth)(hybridOut[0][ss],0,pcm_sample,&p1); |
clip += (fr->synth)(hybridOut[1][ss],1,pcm_sample,pcm_point); |
} |
#ifdef VARMODESUPPORT |
if (playlimit < 128) { |
pcm_point -= playlimit >> 1; |
playlimit = 0; |
} |
else |
playlimit -= 128; |
#endif |
} |
#ifdef I486_OPT |
} else { |
/* Only stereo, 16 bits benefit from the 486 optimization. */ |
ss=0; |
while (ss < SSLIMIT) { |
int n; |
n=(0x40000 - *pcm_point) / (2*2*32); |
if (n > (SSLIMIT-ss)) n=SSLIMIT-ss; |
synth_1to1_486(hybridOut[0][ss],0,pcm_sample+*pcm_point,n); |
synth_1to1_486(hybridOut[1][ss],1,pcm_sample+*pcm_point,n); |
ss+=n; |
*pcm_point+=(2*2*32)*n; |
} |
} |
#endif |
} |
return clip; |
} |
/programs/media/ac97snd/trunk/mpg/mpg123.h |
---|
0,0 → 1,359 |
/* |
mpg123: main code of the program (not of the decoder...) |
copyright 1995-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Michael Hipp |
mpg123 defines |
used source: musicout.h from mpegaudio package |
*/ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <stdio.h> |
#include <math.h> |
#ifndef _AUDIO_H_ |
#define _AUDIO_H_ |
typedef unsigned char byte; |
#define off_t long |
//#define I486_OPT 1 |
#define SKIP_JUNK 1 |
# define M_PI 3.14159265358979323846 |
# define M_SQRT2 1.41421356237309504880 |
# define REAL_IS_FLOAT |
# define NEW_DCT9 |
#ifdef REAL_IS_FLOAT |
# define real float |
# define REAL_SCANF "%f" |
# define REAL_PRINTF "%f" |
#else |
# define real double |
# define REAL_SCANF "%lf" |
# define REAL_PRINTF "%f" |
#endif |
#ifndef DOUBLE_TO_REAL |
# define DOUBLE_TO_REAL(x) (x) |
#endif |
#ifndef REAL_TO_SHORT |
# define REAL_TO_SHORT(x) (x) |
#endif |
#ifndef REAL_PLUS_32767 |
# define REAL_PLUS_32767 32767.0 |
#endif |
#ifndef REAL_MINUS_32768 |
# define REAL_MINUS_32768 -32768.0 |
#endif |
#ifndef REAL_MUL |
# define REAL_MUL(x, y) ((x) * (y)) |
#endif |
#define INLINE |
/* AUDIOBUFSIZE = n*64 with n=1,2,3 ... */ |
#define AUDIOBUFSIZE 16384 |
#define FALSE 0 |
#define TRUE 1 |
#define MAX_NAME_SIZE 81 |
#define SBLIMIT 32 |
#define SCALE_BLOCK 12 |
#define SSLIMIT 18 |
#define MPG_MD_STEREO 0 |
#define MPG_MD_JOINT_STEREO 1 |
#define MPG_MD_DUAL_CHANNEL 2 |
#define MPG_MD_MONO 3 |
/* I suspect that 32767 would be a better idea here, but Michael put this in... */ |
#define MAXOUTBURST 32768 |
/* Pre Shift fo 16 to 8 bit converter table */ |
#define AUSHIFT (3) |
struct bitstream_info |
{ int bitindex; |
unsigned char *wordpointer; |
}; |
extern struct bitstream_info bsi; |
struct reader |
{ char *hFile; |
unsigned char *buffer; |
unsigned char *stream; |
int strpos; |
int strremain; |
int filelen; |
int filepos; |
int (*head_read)(struct reader *,unsigned long *newhead); |
int (*read_frame_body)(struct reader *,unsigned char *,int size); |
}; |
struct al_table |
{ short bits; |
short d; |
}; |
struct frame { |
struct al_table *alloc; |
int (*synth)(real *,int,unsigned char *,int *); |
int (*synth_mono)(real *,unsigned char *,int *); |
int stereo; /* I _think_ 1 for mono and 2 for stereo */ |
int jsbound; |
int single; |
int II_sblimit; |
int down_sample_sblimit; |
int lsf; /* 0: MPEG 1.0; 1: MPEG 2.0/2.5 -- both used as bool and array index! */ |
int mpeg25; |
int down_sample; |
int header_change; |
int lay; |
int (*do_layer)(struct frame *fr,byte *pcm_out, int *pcm_size); |
int error_protection; |
int bitrate_index; |
int sampling_frequency; |
int padding; |
int extension; |
int mode; |
int mode_ext; |
int copyright; |
int original; |
int emphasis; |
int framesize; /* computed framesize */ |
int vbr; /* 1 if variable bitrate was detected */ |
unsigned long num; /* the nth frame in some stream... */ |
}; |
#if 0 |
struct parameter { |
int aggressive; /* renice to max. priority */ |
int shuffle; /* shuffle/random play */ |
int remote; /* remote operation */ |
int remote_err; /* remote operation to stderr */ |
int outmode; /* where to out the decoded sampels */ |
int quiet; /* shut up! */ |
int xterm_title; /* Change xterm title to song names? */ |
long usebuffer; /* second level buffer size */ |
int tryresync; /* resync stream after error */ |
int verbose; /* verbose level */ |
int force_mono; |
int force_stereo; |
int force_8bit; |
long force_rate; |
int down_sample; |
int checkrange; |
long doublespeed; |
long halfspeed; |
int force_reopen; |
long realtime; |
char filename[256]; |
long listentry; /* possibility to choose playback of one entry in playlist (0: off, > 0 : select, < 0; just show list*/ |
int rva; /* (which) rva to do: <0: nothing, 0: radio/mix/track 1: album/audiophile */ |
char* listname; /* name of playlist */ |
int long_id3; |
}; |
#endif |
#if 0 |
struct reader { |
int (*init)(struct reader *); |
void (*close)(struct reader *); |
int (*head_read)(struct reader *,unsigned long *newhead); |
int (*head_shift)(struct reader *,unsigned long *head); |
long (*skip_bytes)(struct reader *,off_t len); |
int (*read_frame_body)(struct reader *,unsigned char *,int size); |
int (*back_bytes)(struct reader *,off_t bytes); |
int (*back_frame)(struct reader *,struct frame *,long num); |
off_t (*tell)(struct reader *); |
void (*rewind)(struct reader *); |
off_t filelen; |
off_t filepos; |
int filept; |
int flags; |
unsigned char id3buf[128]; |
}; |
#endif |
#define READER_FD_OPENED 0x1 |
#define READER_ID3TAG 0x2 |
#define READER_SEEKABLE 0x4 |
//extern void audio_flush(int, struct audio_info_struct *); |
//extern void print_header(struct frame *); |
//extern void print_header_compact(struct frame *); |
//extern void print_id3_tag(unsigned char *buf); |
//extern int split_dir_file(const char *path, char **dname, char **fname); |
extern unsigned int get1bit(void); |
extern unsigned int getbits(int); |
extern unsigned int getbits_fast(int); |
//extern void backbits(int); |
//extern int getbitoffset(void); |
//extern int getbyte(void); |
//extern void set_pointer(long); |
//extern unsigned char *pcm_sample; |
//extern int pcm_point; |
//extern int audiobufsize; |
//extern int OutputDescriptor; |
#ifdef VARMODESUPPORT |
extern int varmode; |
extern int playlimit; |
#endif |
struct gr_info_s { |
int scfsi; |
unsigned part2_3_length; |
unsigned big_values; |
unsigned scalefac_compress; |
unsigned block_type; |
unsigned mixed_block_flag; |
unsigned table_select[3]; |
unsigned subblock_gain[3]; |
unsigned maxband[3]; |
unsigned maxbandl; |
unsigned maxb; |
unsigned region1start; |
unsigned region2start; |
unsigned preflag; |
unsigned scalefac_scale; |
unsigned count1table_select; |
real *full_gain[3]; |
real *pow2gain; |
}; |
struct III_sideinfo |
{ |
unsigned main_data_begin; |
unsigned private_bits; |
struct { |
struct gr_info_s gr[2]; |
} ch[2]; |
}; |
extern int open_stream(char *,int fd); |
extern void read_frame_init (struct frame* fr); |
int read_frame(struct reader *rd, struct frame *fr); |
/* why extern? */ |
void prepare_audioinfo(struct frame *fr, struct audio_info_struct *nai); |
int play_frame(int init,struct frame *fr); |
int do_layer1(struct frame *fr,byte *pcm_sample, int *pcm_point); |
int do_layer2(struct frame *fr,byte *pcm_sample, int *pcm_point); |
int do_layer3(struct frame *fr,byte *pcm_sample, int *pcm_point); |
extern void do_equalizer(real *bandPtr,int channel); |
#ifdef PENTIUM_OPT |
extern int synth_1to1_pent (real *,int,unsigned char *); |
#endif |
extern int synth_1to1 (real *,int,unsigned char *,int *); |
extern int synth_1to1_8bit (real *,int,unsigned char *,int *); |
extern int synth_1to1_mono (real *,unsigned char *,int *); |
extern int synth_1to1_mono2stereo (real *,unsigned char *,int *); |
extern int synth_1to1_8bit_mono (real *,unsigned char *,int *); |
extern int synth_1to1_8bit_mono2stereo (real *,unsigned char *,int *); |
extern int synth_2to1 (real *,int,unsigned char *,int *); |
extern int synth_2to1_8bit (real *,int,unsigned char *,int *); |
extern int synth_2to1_mono (real *,unsigned char *,int *); |
extern int synth_2to1_mono2stereo (real *,unsigned char *,int *); |
extern int synth_2to1_8bit_mono (real *,unsigned char *,int *); |
extern int synth_2to1_8bit_mono2stereo (real *,unsigned char *,int *); |
extern int synth_4to1 (real *,int,unsigned char *,int *); |
extern int synth_4to1_8bit (real *,int,unsigned char *,int *); |
extern int synth_4to1_mono (real *,unsigned char *,int *); |
extern int synth_4to1_mono2stereo (real *,unsigned char *,int *); |
extern int synth_4to1_8bit_mono (real *,unsigned char *,int *); |
extern int synth_4to1_8bit_mono2stereo (real *,unsigned char *,int *); |
extern int synth_ntom (real *,int,unsigned char *,int *); |
extern int synth_ntom_8bit (real *,int,unsigned char *,int *); |
extern int synth_ntom_mono (real *,unsigned char *,int *); |
extern int synth_ntom_mono2stereo (real *,unsigned char *,int *); |
extern int synth_ntom_8bit_mono (real *,unsigned char *,int *); |
extern int synth_ntom_8bit_mono2stereo (real *,unsigned char *,int *); |
extern void rewindNbits(int bits); |
extern int hsstell(void); |
extern void set_pointer(long); |
extern void huffman_decoder(int ,int *); |
extern void huffman_count1(int,int *); |
extern void print_stat(struct frame *fr,unsigned long no,long buffsize,struct audio_info_struct *ai); |
extern int get_songlen(struct frame *fr,int no); |
extern void init_layer3(int); |
extern void init_layer2(void); |
extern void make_decode_tables(long scale); |
extern int make_conv16to8_table(int); |
extern void dct64(real *,real *,real *); |
#ifdef USE_MMX |
extern void dct64_MMX(short *a,short *b,real *c); |
extern int synth_1to1_MMX(real *, int, short *, short *, int *); |
#endif |
extern int synth_ntom_set_step(long,long); |
extern unsigned char *conv16to8; |
extern long freqs[9]; |
extern real muls[27][64]; |
extern real decwin[512+32]; |
#ifndef USE_MMX |
extern real *pnts[5]; |
#endif |
extern real equalizer[2][32]; |
extern real equalizer_sum[2][32]; |
extern int equalizer_cnt; |
extern struct audio_name audio_val2name[]; |
//extern struct parameter param; |
/* 486 optimizations */ |
#define FIR_BUFFER_SIZE 128 |
extern void dct64_486(int *a,int *b,real *c); |
extern int synth_1to1_486(real *bandPtr,int channel,unsigned char *out,int nb_blocks); |
/* 3DNow! optimizations */ |
#ifdef USE_3DNOW |
extern int getcpuflags(void); |
extern void dct36(real *,real *,real *,real *,real *); |
extern void dct36_3dnow(real *,real *,real *,real *,real *); |
extern int synth_1to1_3dnow(real *,int,unsigned char *,int *); |
#endif |
/* avoid the SIGINT in terminal control */ |
void next_track(void); |
extern long outscale; |
#endif |
void set_pointer(long backstep); |
int __stdcall create_reader(struct reader *rd,byte *buffer, int buffsize); |
int __stdcall init_reader(struct reader *rd, char *file); |
int __stdcall decode_header(struct frame *fr,unsigned long newhead); |
int __stdcall set_reader(struct reader *rd, unsigned int filepos); |
double pow_test(double, double); |
void * __cdecl mem_cpy(void * dst,const void * src,size_t count); |
void init_dct(); |
void reset_mpg(); |
#ifdef __cplusplus |
} |
#endif |
/programs/media/ac97snd/trunk/mpg/readers.c |
---|
0,0 → 1,889 |
#include "mpg123.h" |
#include "..\kolibri.h" |
#define MAXFRAMESIZE 3456 |
static int fsizeold=0,ssize; |
static unsigned char bsspace[2][MAXFRAMESIZE+512]; /* MAXFRAMESIZE */ |
static unsigned char *bsbuf=bsspace[1],*bsbufold; |
static int bsnum=0; |
static unsigned long oldhead = 0; |
unsigned long firsthead=0; |
struct bitstream_info bsi; |
int tabsel_123[2][3][16] = { |
{ {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,}, |
{0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,}, |
{0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,} }, |
{ {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,}, |
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,}, |
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,} } |
}; |
int freqs[9] = { 44100, 48000, 32000, 22050, 24000, 16000 , 11025 , 12000 , 8000 }; |
int stream_head_read(struct reader *rd,unsigned long *newhead); |
int stream_read_raw(struct reader *rd,unsigned char *buf, int size); |
void set_synth_functions(struct frame *fr) |
{ |
#ifdef USE_3DNOW |
static func_dct36 funcs_dct36[2] = {dct36 , dct36_3dnow}; |
#endif |
fr->synth = synth_1to1; |
fr->synth_mono = synth_1to1_mono2stereo;; |
/* TODO: make autodetection for _all_ x86 optimizations (maybe just for i586+ and keep separate 486 build?) */ |
#ifdef USE_3DNOW |
/* check cpuflags bit 31 (3DNow!) and 23 (MMX) */ |
if((param.stat_3dnow < 2) && |
((param.stat_3dnow == 1) || |
(getcpuflags() & 0x80800000) == 0x80800000)) |
{ |
fr->synth = funcs[2][ds]; /* 3DNow! optimized synth_1to1() */ |
fr->dct36 = funcs_dct36[1]; /* 3DNow! optimized dct36() */ |
} |
else |
{ |
fr->dct36 = funcs_dct36[0]; |
} |
#endif |
} |
int __stdcall create_reader(struct reader *rd,byte *buffer, int buffsize) |
{ rd->head_read = stream_head_read; |
rd->read_frame_body = stream_read_raw; |
rd->buffer = buffer; |
rd->stream = buffer; |
rd->strpos = 0; |
rd->strremain = 0; |
rd->filepos = 0; |
return 1; |
}; |
int __stdcall init_reader(struct reader *rd, char *file) |
{ FILEINFO fileinfo; |
int retval; |
int bytes; |
rd->hFile = file; |
get_fileinfo(file, &fileinfo); |
rd->filelen = fileinfo.size; |
rd->strpos = 0; |
retval=read_file (file,rd->buffer,0,0x10000,&bytes); |
if (retval) return 0; |
rd->strremain = bytes; |
rd->filepos = bytes; |
return 1; |
}; |
static int fill_reader(struct reader *rd) |
{ int retval; |
int bytes; |
mem_cpy(rd->buffer,rd->stream,rd->strremain); |
rd->stream = rd->buffer; |
retval=read_file (rd->hFile,rd->buffer+rd->strremain,rd->filepos, |
0x10000-rd->strremain,&bytes); |
if (retval) return 0; |
if(!bytes) return 0; |
rd->strremain+=bytes; |
rd->filepos+=bytes; |
rd->strpos = 0; |
return 1; |
}; |
int __stdcall set_reader(struct reader *rd, unsigned int filepos) |
{ int retval; |
unsigned int bytes; |
retval=read_file (rd->hFile,rd->buffer,filepos,0x10000,&bytes); |
if (retval) return 0; |
rd->stream = rd->buffer; |
rd->strremain=bytes; |
rd->filepos=filepos+bytes; |
rd->strpos = 0; |
fsizeold=0; |
firsthead=0; |
bsbufold = 0; |
bsbuf = bsspace[1]; |
bsnum = 0; |
ssize=0; |
oldhead=0; |
memset(bsspace,0,sizeof(bsspace)); |
return 1; |
}; |
static int stream_head_read(struct reader *rd,unsigned long *newhead) |
{ |
if(rd->strremain < 4) |
if( !fill_reader(rd)) |
return 0; |
*newhead = (rd->stream[0]<<24)|(rd->stream[1] << 16)| |
(rd->stream[2] << 8)| rd->stream[3]; |
rd->strpos+=4; |
rd->stream+=4; |
rd->strremain-=4; |
return TRUE; |
}; |
int stream_read_raw(struct reader *rd,unsigned char *buf, int size) |
{ |
if(rd->strremain < size) |
if( !fill_reader(rd)) |
return 0; |
mem_cpy(buf,rd->stream,size); |
rd->strpos+=size; |
rd->stream+=size; |
rd->strremain-=size; |
return 1; |
}; |
void set_pointer(long backstep) |
{ |
bsi.wordpointer = bsbuf + ssize - backstep; |
if (backstep) |
mem_cpy(bsi.wordpointer,bsbufold+fsizeold-backstep,backstep); |
bsi.bitindex = 0; |
} |
int head_check(unsigned long head) |
{ if |
( |
/* first 11 bits are set to 1 for frame sync */ |
((head & 0xffe00000) != 0xffe00000) |
|| |
/* layer: 01,10,11 is 1,2,3; 00 is reserved */ |
(!((head>>17)&3)) |
|| |
/* 1111 means bad bitrate */ |
(((head>>12)&0xf) == 0xf) |
|| |
/* 0000 means free format... */ |
(((head>>12)&0xf) == 0x0) |
|| |
/* sampling freq: 11 is reserved */ |
(((head>>10)&0x3) == 0x3 ) |
/* here used to be a mpeg 2.5 check... re-enabled 2.5 decoding due to lack of evidence that it is really not good */ |
) |
{ |
return FALSE; |
} |
/* if no check failed, the header is valid (hopefully)*/ |
else |
{ |
return TRUE; |
} |
} |
int __stdcall decode_header(struct frame *fr,unsigned long newhead) |
{ |
if(!head_check(newhead)) |
return 0; |
if( newhead & (1<<20) ) |
{ fr->lsf = (newhead & (1<<19)) ? 0x0 : 0x1; |
fr->mpeg25 = 0; |
} |
else |
{ fr->lsf = 1; |
fr->mpeg25 = 1; |
}; |
fr->lay = 4-((newhead>>17)&3); |
if(fr->mpeg25) |
fr->sampling_frequency = 6 + ((newhead>>10)&0x3); |
else |
fr->sampling_frequency = ((newhead>>10)&0x3) + (fr->lsf*3); |
fr->error_protection = ((newhead>>16)&0x1)^0x1; |
fr->bitrate_index = ((newhead>>12)&0xf); |
fr->padding = ((newhead>>9)&0x1); |
fr->extension = ((newhead>>8)&0x1); |
fr->mode = ((newhead>>6)&0x3); |
fr->mode_ext = ((newhead>>4)&0x3); |
fr->copyright = ((newhead>>3)&0x1); |
fr->original = ((newhead>>2)&0x1); |
fr->emphasis = newhead & 0x3; |
fr->stereo = (fr->mode == MPG_MD_MONO) ? 1 : 2; |
oldhead = newhead; |
if(!fr->bitrate_index) |
return (0); |
switch(fr->lay) |
{ case 1: |
fr->do_layer = do_layer1; |
#ifdef VARMODESUPPORT |
if (varmode) { |
error("Sorry, layer-1 not supported in varmode."); |
return (0); |
} |
#endif |
fr->framesize = (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000; |
fr->framesize /= freqs[fr->sampling_frequency]; |
fr->framesize = ((fr->framesize+fr->padding)<<2)-4; |
break; |
case 2: |
fr->do_layer = do_layer2; |
#ifdef VARMODESUPPORT |
if (varmode) { |
error("Sorry, layer-2 not supported in varmode."); |
return (0); |
} |
#endif |
fr->framesize = (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000; |
fr->framesize /= freqs[fr->sampling_frequency]; |
fr->framesize += fr->padding - 4; |
break; |
case 3: |
fr->do_layer = do_layer3; |
if(fr->lsf) |
ssize = (fr->stereo == 1) ? 9 : 17; |
else |
ssize = (fr->stereo == 1) ? 17 : 32; |
if(fr->error_protection) |
ssize += 2; |
fr->framesize = (long) tabsel_123[fr->lsf][2][fr->bitrate_index] * 144000; |
fr->framesize /= freqs[fr->sampling_frequency]<<(fr->lsf); |
fr->framesize = fr->framesize + fr->padding - 4; |
break; |
default: |
return (0); |
} |
if (fr->framesize > MAXFRAMESIZE) |
return (0); |
return 1; |
} |
int read_frame(struct reader *rd, struct frame *fr) |
{ unsigned long newhead; |
static unsigned char ssave[34]; |
//off_t framepos; |
fsizeold=fr->framesize; /* for Layer3 */ |
read_again: |
if(!rd->head_read(rd,&newhead)) |
return FALSE; |
if(!decode_header(fr,newhead)) |
{ rd->strpos-=3; |
rd->stream-=3; |
rd->strremain+=3; |
goto read_again; |
}; |
#if 0 |
if(1 || oldhead != newhead || !oldhead) |
{ |
init_resync: |
#ifdef SKIP_JUNK |
/* watch out for junk/tags on beginning of stream by invalid header */ |
if(!firsthead && !head_check(newhead) && !free_format_header(newhead)) { |
int i; |
/* check for id3v2; first three bytes (of 4) are "ID3" */ |
if((newhead & (unsigned long) 0xffffff00) == (unsigned long) 0x49443300) |
{ |
int id3length = 0; |
id3length = parse_new_id3(newhead, rd); |
goto read_again; |
} |
else if(param.verbose > 1) fprintf(stderr,"Note: Junk at the beginning (0x%08lx)\n",newhead); |
/* I even saw RIFF headers at the beginning of MPEG streams ;( */ |
if(newhead == ('R'<<24)+('I'<<16)+('F'<<8)+'F') { |
if(param.verbose > 1) fprintf(stderr, "Note: Looks like a RIFF header.\n"); |
if(!rd->head_read(rd,&newhead)) |
return 0; |
while(newhead != ('d'<<24)+('a'<<16)+('t'<<8)+'a') { |
if(!rd->head_shift(rd,&newhead)) |
return 0; |
} |
if(!rd->head_read(rd,&newhead)) |
return 0; |
if(param.verbose > 1) fprintf(stderr,"Note: Skipped RIFF header!\n"); |
goto read_again; |
} |
/* unhandled junk... just continue search for a header */ |
/* step in byte steps through next 64K */ |
for(i=0;i<65536;i++) { |
if(!rd->head_shift(rd,&newhead)) |
return 0; |
/* if(head_check(newhead)) */ |
if(head_check(newhead) && decode_header(fr, newhead)) |
break; |
} |
if(i == 65536) { |
if(!param.quiet) error("Giving up searching valid MPEG header after 64K of junk."); |
return 0; |
} |
/* |
* should we additionaly check, whether a new frame starts at |
* the next expected position? (some kind of read ahead) |
* We could implement this easily, at least for files. |
*/ |
} |
#endif |
/* first attempt of read ahead check to find the real first header; cannot believe what junk is out there! */ |
/* for now, a spurious first free format header screws up here; need free format support for detecting false free format headers... */ |
if(!firsthead && rd->flags & READER_SEEKABLE && head_check(newhead) && decode_header(fr, newhead)) |
{ |
unsigned long nexthead = 0; |
int hd = 0; |
off_t start = rd->tell(rd); |
debug1("doing ahead check with BPF %d", fr->framesize+4); |
/* step framesize bytes forward and read next possible header*/ |
if(rd->back_bytes(rd, -fr->framesize)) |
{ |
error("cannot seek!"); |
return 0; |
} |
hd = rd->head_read(rd,&nexthead); |
if(rd->back_bytes(rd, rd->tell(rd)-start)) |
{ |
error("cannot seek!"); |
return 0; |
} |
if(!hd) |
{ |
warning("cannot read next header, a one-frame stream? Duh..."); |
} |
else |
{ |
debug2("does next header 0x%08lx match first 0x%08lx?", nexthead, newhead); |
/* not allowing free format yet */ |
if(!head_check(nexthead) || (nexthead & HDRCMPMASK) != (newhead & HDRCMPMASK)) |
{ |
debug("No, the header was not valid, start from beginning..."); |
/* try next byte for valid header */ |
if(rd->back_bytes(rd, 3)) |
{ |
error("cannot seek!"); |
return 0; |
} |
goto read_again; |
} |
} |
} |
/* why has this head check been avoided here before? */ |
if(!head_check(newhead)) |
{ |
if(!firsthead && free_format_header(newhead)) |
{ |
error1("Header 0x%08lx seems to indicate a free format stream; I do not handle that yet", newhead); |
goto read_again; |
return 0; |
} |
/* and those ugly ID3 tags */ |
if((newhead & 0xffffff00) == ('T'<<24)+('A'<<16)+('G'<<8)) { |
rd->skip_bytes(rd,124); |
if (param.verbose > 1) fprintf(stderr,"Note: Skipped ID3 Tag!\n"); |
goto read_again; |
} |
/* duplicated code from above! */ |
/* check for id3v2; first three bytes (of 4) are "ID3" */ |
if((newhead & (unsigned long) 0xffffff00) == (unsigned long) 0x49443300) |
{ |
int id3length = 0; |
id3length = parse_new_id3(newhead, rd); |
goto read_again; |
} |
else if (give_note) |
{ |
fprintf(stderr,"Note: Illegal Audio-MPEG-Header 0x%08lx at offset 0x%lx.\n", newhead,rd->tell(rd)-4); |
} |
if(give_note && (newhead & 0xffffff00) == ('b'<<24)+('m'<<16)+('p'<<8)) fprintf(stderr,"Note: Could be a BMP album art.\n"); |
if (param.tryresync || do_recover) { |
int try = 0; |
/* TODO: make this more robust, I'd like to cat two mp3 fragments together (in a dirty way) and still have mpg123 beign able to decode all it somehow. */ |
if(give_note) fprintf(stderr, "Note: Trying to resync...\n"); |
/* Read more bytes until we find something that looks |
reasonably like a valid header. This is not a |
perfect strategy, but it should get us back on the |
track within a short time (and hopefully without |
too much distortion in the audio output). */ |
do { |
if(!rd->head_shift(rd,&newhead)) |
return 0; |
/* debug2("resync try %i, got newhead 0x%08lx", try, newhead); */ |
if (!oldhead) |
{ |
debug("going to init_resync..."); |
goto init_resync; /* "considered harmful", eh? */ |
} |
/* we should perhaps collect a list of valid headers that occured in file... there can be more */ |
/* Michael's new resync routine seems to work better with the one frame readahead (and some input buffering?) */ |
} while |
( |
++try < RESYNC_LIMIT |
&& (newhead & HDRCMPMASK) != (oldhead & HDRCMPMASK) |
&& (newhead & HDRCMPMASK) != (firsthead & HDRCMPMASK) |
); |
/* too many false positives |
}while (!(head_check(newhead) && decode_header(fr, newhead))); */ |
if(try == RESYNC_LIMIT) |
{ |
error("giving up resync - your stream is not nice... perhaps an improved routine could catch up"); |
return 0; |
} |
if (give_note) |
fprintf (stderr, "Note: Skipped %d bytes in input.\n", try); |
} |
else |
{ |
error("not attempting to resync..."); |
return (0); |
} |
} |
if (!firsthead) { |
if(!decode_header(fr,newhead)) |
{ |
error("decode header failed before first valid one, going to read again"); |
goto read_again; |
} |
} |
else |
if(!decode_header(fr,newhead)) |
{ |
error("decode header failed - goto resync"); |
/* return 0; */ |
goto init_resync; |
} |
} |
else |
fr->header_change = 0; |
#endif |
bsbufold = bsbuf; |
bsbuf = bsspace[bsnum]+512; |
bsnum = (bsnum + 1) & 1; |
/* if filepos is invalid, so is framepos */ |
//framepos = rd->filepos - 4; |
/* read main data into memory */ |
/* 0 is error! */ |
if(!rd->read_frame_body(rd,bsbuf,fr->framesize)) |
return 0; |
#if 0 |
if(!firsthead) |
{ |
/* following stuff is actually layer3 specific (in practice, not in theory) */ |
if(fr->lay == 3) |
{ |
/* |
going to look for Xing or Info at some position after the header |
MPEG 1 MPEG 2/2.5 (LSF) |
Stereo, Joint Stereo, Dual Channel 32 17 |
Mono 17 9 |
Also, how to avoid false positives? I guess I should interpret more of the header to rule that out(?). |
I hope that ensuring all zeros until tag start is enough. |
*/ |
size_t lame_offset = (fr->stereo == 2) ? (fr->lsf ? 17 : 32 ) : (fr->lsf ? 9 : 17); |
if(fr->framesize >= 120+lame_offset) /* traditional Xing header is 120 bytes */ |
{ |
size_t i; |
int lame_type = 0; |
/* only search for tag when all zero before it (apart from checksum) */ |
for(i=2; i < lame_offset; ++i) if(bsbuf[i] != 0) break; |
if(i == lame_offset) |
{ |
if |
( |
(bsbuf[lame_offset] == 'I') |
&& (bsbuf[lame_offset+1] == 'n') |
&& (bsbuf[lame_offset+2] == 'f') |
&& (bsbuf[lame_offset+3] == 'o') |
) |
{ |
lame_type = 1; /* We still have to see what there is */ |
} |
else if |
( |
(bsbuf[lame_offset] == 'X') |
&& (bsbuf[lame_offset+1] == 'i') |
&& (bsbuf[lame_offset+2] == 'n') |
&& (bsbuf[lame_offset+3] == 'g') |
) |
{ |
lame_type = 2; |
vbr = VBR; /* Xing header means always VBR */ |
} |
if(lame_type) |
{ |
unsigned long xing_flags; |
/* we have one of these headers... */ |
if(param.verbose > 1) fprintf(stderr, "Note: Xing/Lame/Info header detected\n"); |
/* now interpret the Xing part, I have 120 bytes total for sure */ |
/* there are 4 bytes for flags, but only the last byte contains known ones */ |
lame_offset += 4; /* now first byte after Xing/Name */ |
/* 4 bytes dword for flags */ |
#define make_long(a, o) ((((unsigned long) a[o]) << 24) | (((unsigned long) a[o+1]) << 16) | (((unsigned long) a[o+2]) << 8) | ((unsigned long) a[o+3])) |
/* 16 bit */ |
#define make_short(a,o) ((((unsigned short) a[o]) << 8) | ((unsigned short) a[o+1])) |
xing_flags = make_long(bsbuf, lame_offset); |
lame_offset += 4; |
debug1("Xing: flags 0x%08lx", xing_flags); |
if(xing_flags & 1) /* frames */ |
{ |
/* |
In theory, one should use that value for skipping... |
When I know the exact number of samples I could simply count in audio_flush, |
but that's problematic with seeking and such. |
I still miss the real solution for detecting the end. |
*/ |
track_frames = make_long(bsbuf, lame_offset); |
if(track_frames > TRACK_MAX_FRAMES) track_frames = 0; /* endless stream? */ |
#ifdef GAPLESS |
/* if no further info there, remove/add at least the decoder delay */ |
if(param.gapless) |
{ |
unsigned long length = track_frames * spf(fr); |
if(length > 1) |
layer3_gapless_init(DECODER_DELAY+GAP_SHIFT, length+DECODER_DELAY+GAP_SHIFT); |
} |
#endif |
debug1("Xing: %lu frames", track_frames); |
lame_offset += 4; |
} |
if(xing_flags & 0x2) /* bytes */ |
{ |
#ifdef DEBUG |
unsigned long xing_bytes = make_long(bsbuf, lame_offset); |
debug1("Xing: %lu bytes", xing_bytes); |
#endif |
lame_offset += 4; |
} |
if(xing_flags & 0x4) /* TOC */ |
{ |
lame_offset += 100; /* just skip */ |
} |
if(xing_flags & 0x8) /* VBR quality */ |
{ |
#ifdef DEBUG |
unsigned long xing_quality = make_long(bsbuf, lame_offset); |
debug1("Xing: quality = %lu", xing_quality); |
#endif |
lame_offset += 4; |
} |
/* I guess that either 0 or LAME extra data follows */ |
/* there may this crc16 be floating around... (?) */ |
if(bsbuf[lame_offset] != 0) |
{ |
unsigned char lame_vbr; |
float replay_gain[2] = {0,0}; |
float peak = 0; |
float gain_offset = 0; /* going to be +6 for old lame that used 83dB */ |
char nb[10]; |
memcpy(nb, bsbuf+lame_offset, 9); |
nb[9] = 0; |
debug1("Info: Encoder: %s", nb); |
if(!strncmp("LAME", nb, 4)) |
{ |
gain_offset = 6; |
debug("TODO: finish lame detetcion..."); |
} |
lame_offset += 9; |
/* the 4 big bits are tag revision, the small bits vbr method */ |
lame_vbr = bsbuf[lame_offset] & 15; |
debug1("Info: rev %u", bsbuf[lame_offset] >> 4); |
debug1("Info: vbr mode %u", lame_vbr); |
lame_offset += 1; |
switch(lame_vbr) |
{ |
/* from rev1 proposal... not sure if all good in practice */ |
case 1: |
case 8: vbr = CBR; break; |
case 2: |
case 9: vbr = ABR; break; |
default: vbr = VBR; /* 00==unknown is taken as VBR */ |
} |
/* skipping: lowpass filter value */ |
lame_offset += 1; |
/* replaygain */ |
/* 32bit float: peak amplitude -- why did I parse it as int before??*/ |
/* Ah, yes, lame seems to store it as int since some day in 2003; I've only seen zeros anyway until now, bah! */ |
if |
( |
(bsbuf[lame_offset] != 0) |
|| (bsbuf[lame_offset+1] != 0) |
|| (bsbuf[lame_offset+2] != 0) |
|| (bsbuf[lame_offset+3] != 0) |
) |
{ |
debug("Wow! Is there _really_ a non-zero peak value? Now is it stored as float or int - how should I know?"); |
peak = *(float*) (bsbuf+lame_offset); |
} |
debug1("Info: peak = %f (I won't use this)", peak); |
peak = 0; /* until better times arrived */ |
lame_offset += 4; |
/* |
ReplayGain values - lame only writes radio mode gain... |
16bit gain, 3 bits name, 3 bits originator, sign (1=-, 0=+), dB value*10 in 9 bits (fixed point) |
ignore the setting if name or originator == 000! |
radio 0 0 1 0 1 1 1 0 0 1 1 1 1 1 0 1 |
audiophile 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0 |
*/ |
for(i =0; i < 2; ++i) |
{ |
unsigned char origin = (bsbuf[lame_offset] >> 2) & 0x7; /* the 3 bits after that... */ |
if(origin != 0) |
{ |
unsigned char gt = bsbuf[lame_offset] >> 5; /* only first 3 bits */ |
if(gt == 1) gt = 0; /* radio */ |
else if(gt == 2) gt = 1; /* audiophile */ |
else continue; |
/* get the 9 bits into a number, divide by 10, multiply sign... happy bit banging */ |
replay_gain[0] = ((bsbuf[lame_offset] & 0x2) ? -0.1 : 0.1) * (make_short(bsbuf, lame_offset) & 0x1f); |
} |
lame_offset += 2; |
} |
debug1("Info: Radio Gain = %03.1fdB", replay_gain[0]); |
debug1("Info: Audiophile Gain = %03.1fdB", replay_gain[1]); |
for(i=0; i < 2; ++i) |
{ |
if(rva_level[i] <= 0) |
{ |
rva_peak[i] = 0; /* at some time the parsed peak should be used */ |
rva_gain[i] = replay_gain[i]; |
rva_level[i] = 0; |
} |
} |
lame_offset += 1; /* skipping encoding flags byte */ |
if(vbr == ABR) |
{ |
abr_rate = bsbuf[lame_offset]; |
debug1("Info: ABR rate = %u", abr_rate); |
} |
lame_offset += 1; |
/* encoder delay and padding, two 12 bit values... lame does write them from int ...*/ |
#ifdef GAPLESS |
if(param.gapless) |
{ |
/* |
Temporary hack that doesn't work with seeking and also is not waterproof but works most of the time; |
in future the lame delay/padding and frame number info should be passed to layer3.c and the junk samples avoided at the source. |
*/ |
unsigned long length = track_frames * spf(fr); |
unsigned long skipbegin = DECODER_DELAY + ((((int) bsbuf[lame_offset]) << 4) | (((int) bsbuf[lame_offset+1]) >> 4)); |
unsigned long skipend = -DECODER_DELAY + (((((int) bsbuf[lame_offset+1]) << 8) | (((int) bsbuf[lame_offset+2]))) & 0xfff); |
debug3("preparing gapless mode for layer3: length %lu, skipbegin %lu, skipend %lu", length, skipbegin, skipend); |
if(length > 1) |
layer3_gapless_init(skipbegin+GAP_SHIFT, (skipend < length) ? length-skipend+GAP_SHIFT : length+GAP_SHIFT); |
} |
#endif |
} |
/* switch buffer back ... */ |
bsbuf = bsspace[bsnum]+512; |
bsnum = (bsnum + 1) & 1; |
goto read_again; |
} |
} |
} |
} /* end block for Xing/Lame/Info tag */ |
firsthead = newhead; /* _now_ it's time to store it... the first real header */ |
debug1("firsthead: %08lx", firsthead); |
/* now adjust volume */ |
do_rva(); |
/* and print id3 info */ |
if(!param.quiet) print_id3_tag(rd->flags & READER_ID3TAG ? rd->id3buf : NULL); |
} |
#endif |
bsi.bitindex = 0; |
bsi.wordpointer = (unsigned char *) bsbuf; |
set_synth_functions(fr); |
if (fr->error_protection) |
getbits(16); |
return 1; |
} |
#if 0 |
static int stream_back_bytes(struct reader *rds, off_t bytes) |
{ |
if(stream_lseek(rds,-bytes,SEEK_CUR) < 0) |
return -1; |
/* you sure you want the buffer to resync here? */ |
if(param.usebuffer) |
buffer_resync(); |
return 0; |
} |
/* this function strangely is define to seek num frames _back_ (and is called with -offset - duh!) */ |
/* also... let that int be a long in future! */ |
static int stream_back_frame(struct reader *rds,struct frame *fr,long num) |
{ |
if(rds->flags & READER_SEEKABLE) |
{ |
unsigned long newframe, preframe; |
if(num > 0) /* back! */ |
{ |
if(num > fr->num) newframe = 0; |
else newframe = fr->num-num; |
} |
else newframe = fr->num-num; |
/* two leading frames? hm, doesn't seem to be really needed... */ |
/*if(newframe > 1) newframe -= 2; |
else newframe = 0;*/ |
/* now seek to nearest leading index position and read from there until newframe is reached */ |
if(stream_lseek(rds,frame_index_find(newframe, &preframe),SEEK_SET) < 0) |
return -1; |
debug2("going to %lu; just got %lu", newframe, preframe); |
fr->num = preframe; |
while(fr->num < newframe) |
{ |
/* try to be non-fatal now... frameNum only gets advanced on success anyway */ |
if(!read_frame(fr)) break; |
} |
/* this is not needed at last? */ |
/*read_frame(fr); |
read_frame(fr);*/ |
if(fr->lay == 3) { |
set_pointer(512); |
} |
debug1("arrived at %lu", fr->num); |
if(param.usebuffer) |
buffer_resync(); |
return 0; |
} |
else return -1; /* invalid, no seek happened */ |
} |
static int stream_head_read(struct reader *rds,unsigned long *newhead) |
{ |
unsigned char hbuf[4]; |
if(fullread(rds,hbuf,4) != 4) |
return FALSE; |
*newhead = ((unsigned long) hbuf[0] << 24) | |
((unsigned long) hbuf[1] << 16) | |
((unsigned long) hbuf[2] << 8) | |
(unsigned long) hbuf[3]; |
return TRUE; |
} |
static int stream_head_shift(struct reader *rds,unsigned long *head) |
{ |
unsigned char hbuf; |
if(fullread(rds,&hbuf,1) != 1) |
return 0; |
*head <<= 8; |
*head |= hbuf; |
*head &= 0xffffffff; |
return 1; |
} |
static off_t stream_skip_bytes(struct reader *rds,off_t len) |
{ |
if (rds->filelen >= 0) { |
off_t ret = stream_lseek(rds, len, SEEK_CUR); |
if (param.usebuffer) |
buffer_resync(); |
return ret; |
} else if (len >= 0) { |
unsigned char buf[1024]; /* ThOr: Compaq cxx complained and it makes sense to me... or should one do a cast? What for? */ |
off_t ret; |
while (len > 0) { |
off_t num = len < sizeof(buf) ? len : sizeof(buf); |
ret = fullread(rds, buf, num); |
if (ret < 0) |
return ret; |
len -= ret; |
} |
return rds->filepos; |
} else |
return -1; |
} |
static int stream_read_frame_body(struct reader *rds,unsigned char *buf, |
int size) |
{ |
long l; |
if( (l=fullread(rds,buf,size)) != size) |
{ |
if(l <= 0) |
return 0; |
memset(buf+l,0,size-l); |
} |
return 1; |
} |
static off_t stream_tell(struct reader *rds) |
{ |
return rds->filepos; |
} |
static void stream_rewind(struct reader *rds) |
{ |
stream_lseek(rds,0,SEEK_SET); |
if(param.usebuffer) |
buffer_resync(); |
} |
static off_t get_fileinfo(struct reader *rds,char *buf) |
{ |
off_t len; |
if((len=lseek(rds->filept,0,SEEK_END)) < 0) { |
return -1; |
} |
if(lseek(rds->filept,-128,SEEK_END) < 0) |
return -1; |
if(fullread(rds,(unsigned char *)buf,128) != 128) { |
return -1; |
} |
if(!strncmp(buf,"TAG",3)) { |
len -= 128; |
} |
if(lseek(rds->filept,0,SEEK_SET) < 0) |
return -1; |
if(len <= 0) |
return -1; |
return len; |
} |
#endif |
/programs/media/ac97snd/trunk/mpg/common.c |
---|
0,0 → 1,136 |
#include <stdlib.h> |
#include "mpg123.h" |
int tabsel_123[2][3][16] = { |
{ {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,}, |
{0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,}, |
{0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,} }, |
{ {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,}, |
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,}, |
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,} } |
}; |
long freqs[9] = { 44100, 48000, 32000, |
22050, 24000, 16000 , |
11025 , 12000 , 8000 }; |
#define HDRCMPMASK 0xfffffd00 |
struct bitstream_info bsi; |
int ssize; |
unsigned long read_header(BYTE *mpeg) |
{ unsigned long hdr; |
hdr = *mpeg++; |
hdr <<= 8; |
hdr |= *mpeg++; |
hdr <<= 8; |
hdr |= *mpeg++; |
hdr <<= 8; |
hdr |= *mpeg++; |
return hdr; |
}; |
int head_check(unsigned long head) |
{ |
if( (head & 0xffe00000) != 0xffe00000) |
return FALSE; |
if(!((head>>17)&3)) |
return FALSE; |
if( ((head>>12)&0xf) == 0xf) |
return FALSE; |
if( ((head>>10)&0x3) == 0x3 ) |
return FALSE; |
return TRUE; |
} |
int decode_header(struct frame *fr,unsigned long newhead) |
{ |
if( newhead & (1<<20) ) { |
fr->lsf = (newhead & (1<<19)) ? 0x0 : 0x1; |
fr->mpeg25 = 0; |
} |
else { |
fr->lsf = 1; |
fr->mpeg25 = 1; |
} |
fr->lay = 4-((newhead>>17)&3); |
if( ((newhead>>10)&0x3) == 0x3) { |
fprintf(stderr,"Stream error, reserved sampling rate\n"); |
return 0; |
} |
if(fr->mpeg25) { |
fr->sampling_frequency = 6 + ((newhead>>10)&0x3); |
} |
else |
fr->sampling_frequency = ((newhead>>10)&0x3) + (fr->lsf*3); |
fr->error_protection = ((newhead>>16)&0x1)^0x1; |
if(fr->mpeg25) /* allow Bitrate change for 2.5 ... */ |
fr->bitrate_index = ((newhead>>12)&0xf); |
fr->bitrate_index = ((newhead>>12)&0xf); |
fr->padding = ((newhead>>9)&0x1); |
fr->extension = ((newhead>>8)&0x1); |
fr->mode = ((newhead>>6)&0x3); |
fr->mode_ext = ((newhead>>4)&0x3); |
fr->copyright = ((newhead>>3)&0x1); |
fr->original = ((newhead>>2)&0x1); |
fr->emphasis = newhead & 0x3; |
fr->stereo = (fr->mode == MPG_MD_MONO) ? 1 : 2; |
if(!fr->bitrate_index) |
{ |
fprintf(stderr, "Stream error, free format bitrate index not supported\n"); |
return 0; |
} |
switch(fr->lay) |
{ |
case 1: |
fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? |
(fr->mode_ext<<2)+4 : 32; |
fr->framesize = (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000; |
fr->framesize /= freqs[fr->sampling_frequency]; |
fr->framesize = ((fr->framesize+fr->padding)<<2)-4; |
break; |
case 2: |
fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? |
(fr->mode_ext<<2)+4 : fr->II_sblimit; |
fr->framesize = (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000; |
fr->framesize /= freqs[fr->sampling_frequency]; |
fr->framesize += fr->padding - 4; |
break; |
case 3: |
fr->do_layer = do_layer3; |
if(fr->lsf) |
ssize = (fr->stereo == 1) ? 9 : 17; |
else |
ssize = (fr->stereo == 1) ? 17 : 32; |
if(fr->error_protection) |
ssize += 2; |
fr->framesize = (long) tabsel_123[fr->lsf][2][fr->bitrate_index] * 144000; |
fr->framesize /= freqs[fr->sampling_frequency]<<(fr->lsf); |
fr->framesize = fr->framesize + fr->padding - 4; |
break; |
default: |
return (0); |
} |
return 1; |
} |
//void set_pointer(long backstep) |
//{ |
// bsi.wordpointer = bsbuf + ssize - backstep; |
// if (backstep) |
// memcpy(bsi.wordpointer,bsbufold+fsizeold-backstep,backstep); |
// bsi.bitindex = 0; |
//} |
/programs/media/ac97snd/trunk/mpg/dct64_i386.c |
---|
0,0 → 1,337 |
/* |
dct64_i386.c: DCT64, a C variant for i386 |
copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Michael Hipp |
*/ |
/* |
* Discrete Cosine Tansform (DCT) for subband synthesis |
* optimized for machines with no auto-increment. |
* The performance is highly compiler dependend. Maybe |
* the dct64.c version for 'normal' processor may be faster |
* even for Intel processors. |
*/ |
//#include "config.h" |
#include "mpg123.h" |
static void dct64_1(real *out0,real *out1,real *b1,real *b2,real *samples) |
{ |
{ |
register real *costab = pnts[0]; |
b1[0x00] = samples[0x00] + samples[0x1F]; |
b1[0x01] = samples[0x01] + samples[0x1E]; |
b1[0x1F] = (samples[0x00] - samples[0x1F]) * costab[0x0]; |
b1[0x1E] = (samples[0x01] - samples[0x1E]) * costab[0x1]; |
b1[0x02] = samples[0x02] + samples[0x1D]; |
b1[0x03] = samples[0x03] + samples[0x1C]; |
b1[0x1D] = (samples[0x02] - samples[0x1D]) * costab[0x2]; |
b1[0x1C] = (samples[0x03] - samples[0x1C]) * costab[0x3]; |
b1[0x04] = samples[0x04] + samples[0x1B]; |
b1[0x05] = samples[0x05] + samples[0x1A]; |
b1[0x1B] = (samples[0x04] - samples[0x1B]) * costab[0x4]; |
b1[0x1A] = (samples[0x05] - samples[0x1A]) * costab[0x5]; |
b1[0x06] = samples[0x06] + samples[0x19]; |
b1[0x07] = samples[0x07] + samples[0x18]; |
b1[0x19] = (samples[0x06] - samples[0x19]) * costab[0x6]; |
b1[0x18] = (samples[0x07] - samples[0x18]) * costab[0x7]; |
b1[0x08] = samples[0x08] + samples[0x17]; |
b1[0x09] = samples[0x09] + samples[0x16]; |
b1[0x17] = (samples[0x08] - samples[0x17]) * costab[0x8]; |
b1[0x16] = (samples[0x09] - samples[0x16]) * costab[0x9]; |
b1[0x0A] = samples[0x0A] + samples[0x15]; |
b1[0x0B] = samples[0x0B] + samples[0x14]; |
b1[0x15] = (samples[0x0A] - samples[0x15]) * costab[0xA]; |
b1[0x14] = (samples[0x0B] - samples[0x14]) * costab[0xB]; |
b1[0x0C] = samples[0x0C] + samples[0x13]; |
b1[0x0D] = samples[0x0D] + samples[0x12]; |
b1[0x13] = (samples[0x0C] - samples[0x13]) * costab[0xC]; |
b1[0x12] = (samples[0x0D] - samples[0x12]) * costab[0xD]; |
b1[0x0E] = samples[0x0E] + samples[0x11]; |
b1[0x0F] = samples[0x0F] + samples[0x10]; |
b1[0x11] = (samples[0x0E] - samples[0x11]) * costab[0xE]; |
b1[0x10] = (samples[0x0F] - samples[0x10]) * costab[0xF]; |
} |
{ |
register real *costab = pnts[1]; |
b2[0x00] = b1[0x00] + b1[0x0F]; |
b2[0x01] = b1[0x01] + b1[0x0E]; |
b2[0x0F] = (b1[0x00] - b1[0x0F]) * costab[0]; |
b2[0x0E] = (b1[0x01] - b1[0x0E]) * costab[1]; |
b2[0x02] = b1[0x02] + b1[0x0D]; |
b2[0x03] = b1[0x03] + b1[0x0C]; |
b2[0x0D] = (b1[0x02] - b1[0x0D]) * costab[2]; |
b2[0x0C] = (b1[0x03] - b1[0x0C]) * costab[3]; |
b2[0x04] = b1[0x04] + b1[0x0B]; |
b2[0x05] = b1[0x05] + b1[0x0A]; |
b2[0x0B] = (b1[0x04] - b1[0x0B]) * costab[4]; |
b2[0x0A] = (b1[0x05] - b1[0x0A]) * costab[5]; |
b2[0x06] = b1[0x06] + b1[0x09]; |
b2[0x07] = b1[0x07] + b1[0x08]; |
b2[0x09] = (b1[0x06] - b1[0x09]) * costab[6]; |
b2[0x08] = (b1[0x07] - b1[0x08]) * costab[7]; |
/* */ |
b2[0x10] = b1[0x10] + b1[0x1F]; |
b2[0x11] = b1[0x11] + b1[0x1E]; |
b2[0x1F] = (b1[0x1F] - b1[0x10]) * costab[0]; |
b2[0x1E] = (b1[0x1E] - b1[0x11]) * costab[1]; |
b2[0x12] = b1[0x12] + b1[0x1D]; |
b2[0x13] = b1[0x13] + b1[0x1C]; |
b2[0x1D] = (b1[0x1D] - b1[0x12]) * costab[2]; |
b2[0x1C] = (b1[0x1C] - b1[0x13]) * costab[3]; |
b2[0x14] = b1[0x14] + b1[0x1B]; |
b2[0x15] = b1[0x15] + b1[0x1A]; |
b2[0x1B] = (b1[0x1B] - b1[0x14]) * costab[4]; |
b2[0x1A] = (b1[0x1A] - b1[0x15]) * costab[5]; |
b2[0x16] = b1[0x16] + b1[0x19]; |
b2[0x17] = b1[0x17] + b1[0x18]; |
b2[0x19] = (b1[0x19] - b1[0x16]) * costab[6]; |
b2[0x18] = (b1[0x18] - b1[0x17]) * costab[7]; |
} |
{ |
register real *costab = pnts[2]; |
b1[0x00] = b2[0x00] + b2[0x07]; |
b1[0x07] = (b2[0x00] - b2[0x07]) * costab[0]; |
b1[0x01] = b2[0x01] + b2[0x06]; |
b1[0x06] = (b2[0x01] - b2[0x06]) * costab[1]; |
b1[0x02] = b2[0x02] + b2[0x05]; |
b1[0x05] = (b2[0x02] - b2[0x05]) * costab[2]; |
b1[0x03] = b2[0x03] + b2[0x04]; |
b1[0x04] = (b2[0x03] - b2[0x04]) * costab[3]; |
b1[0x08] = b2[0x08] + b2[0x0F]; |
b1[0x0F] = (b2[0x0F] - b2[0x08]) * costab[0]; |
b1[0x09] = b2[0x09] + b2[0x0E]; |
b1[0x0E] = (b2[0x0E] - b2[0x09]) * costab[1]; |
b1[0x0A] = b2[0x0A] + b2[0x0D]; |
b1[0x0D] = (b2[0x0D] - b2[0x0A]) * costab[2]; |
b1[0x0B] = b2[0x0B] + b2[0x0C]; |
b1[0x0C] = (b2[0x0C] - b2[0x0B]) * costab[3]; |
b1[0x10] = b2[0x10] + b2[0x17]; |
b1[0x17] = (b2[0x10] - b2[0x17]) * costab[0]; |
b1[0x11] = b2[0x11] + b2[0x16]; |
b1[0x16] = (b2[0x11] - b2[0x16]) * costab[1]; |
b1[0x12] = b2[0x12] + b2[0x15]; |
b1[0x15] = (b2[0x12] - b2[0x15]) * costab[2]; |
b1[0x13] = b2[0x13] + b2[0x14]; |
b1[0x14] = (b2[0x13] - b2[0x14]) * costab[3]; |
b1[0x18] = b2[0x18] + b2[0x1F]; |
b1[0x1F] = (b2[0x1F] - b2[0x18]) * costab[0]; |
b1[0x19] = b2[0x19] + b2[0x1E]; |
b1[0x1E] = (b2[0x1E] - b2[0x19]) * costab[1]; |
b1[0x1A] = b2[0x1A] + b2[0x1D]; |
b1[0x1D] = (b2[0x1D] - b2[0x1A]) * costab[2]; |
b1[0x1B] = b2[0x1B] + b2[0x1C]; |
b1[0x1C] = (b2[0x1C] - b2[0x1B]) * costab[3]; |
} |
{ |
register real const cos0 = pnts[3][0]; |
register real const cos1 = pnts[3][1]; |
b2[0x00] = b1[0x00] + b1[0x03]; |
b2[0x03] = (b1[0x00] - b1[0x03]) * cos0; |
b2[0x01] = b1[0x01] + b1[0x02]; |
b2[0x02] = (b1[0x01] - b1[0x02]) * cos1; |
b2[0x04] = b1[0x04] + b1[0x07]; |
b2[0x07] = (b1[0x07] - b1[0x04]) * cos0; |
b2[0x05] = b1[0x05] + b1[0x06]; |
b2[0x06] = (b1[0x06] - b1[0x05]) * cos1; |
b2[0x08] = b1[0x08] + b1[0x0B]; |
b2[0x0B] = (b1[0x08] - b1[0x0B]) * cos0; |
b2[0x09] = b1[0x09] + b1[0x0A]; |
b2[0x0A] = (b1[0x09] - b1[0x0A]) * cos1; |
b2[0x0C] = b1[0x0C] + b1[0x0F]; |
b2[0x0F] = (b1[0x0F] - b1[0x0C]) * cos0; |
b2[0x0D] = b1[0x0D] + b1[0x0E]; |
b2[0x0E] = (b1[0x0E] - b1[0x0D]) * cos1; |
b2[0x10] = b1[0x10] + b1[0x13]; |
b2[0x13] = (b1[0x10] - b1[0x13]) * cos0; |
b2[0x11] = b1[0x11] + b1[0x12]; |
b2[0x12] = (b1[0x11] - b1[0x12]) * cos1; |
b2[0x14] = b1[0x14] + b1[0x17]; |
b2[0x17] = (b1[0x17] - b1[0x14]) * cos0; |
b2[0x15] = b1[0x15] + b1[0x16]; |
b2[0x16] = (b1[0x16] - b1[0x15]) * cos1; |
b2[0x18] = b1[0x18] + b1[0x1B]; |
b2[0x1B] = (b1[0x18] - b1[0x1B]) * cos0; |
b2[0x19] = b1[0x19] + b1[0x1A]; |
b2[0x1A] = (b1[0x19] - b1[0x1A]) * cos1; |
b2[0x1C] = b1[0x1C] + b1[0x1F]; |
b2[0x1F] = (b1[0x1F] - b1[0x1C]) * cos0; |
b2[0x1D] = b1[0x1D] + b1[0x1E]; |
b2[0x1E] = (b1[0x1E] - b1[0x1D]) * cos1; |
} |
{ |
register real const cos0 = pnts[4][0]; |
b1[0x00] = b2[0x00] + b2[0x01]; |
b1[0x01] = (b2[0x00] - b2[0x01]) * cos0; |
b1[0x02] = b2[0x02] + b2[0x03]; |
b1[0x03] = (b2[0x03] - b2[0x02]) * cos0; |
b1[0x02] += b1[0x03]; |
b1[0x04] = b2[0x04] + b2[0x05]; |
b1[0x05] = (b2[0x04] - b2[0x05]) * cos0; |
b1[0x06] = b2[0x06] + b2[0x07]; |
b1[0x07] = (b2[0x07] - b2[0x06]) * cos0; |
b1[0x06] += b1[0x07]; |
b1[0x04] += b1[0x06]; |
b1[0x06] += b1[0x05]; |
b1[0x05] += b1[0x07]; |
b1[0x08] = b2[0x08] + b2[0x09]; |
b1[0x09] = (b2[0x08] - b2[0x09]) * cos0; |
b1[0x0A] = b2[0x0A] + b2[0x0B]; |
b1[0x0B] = (b2[0x0B] - b2[0x0A]) * cos0; |
b1[0x0A] += b1[0x0B]; |
b1[0x0C] = b2[0x0C] + b2[0x0D]; |
b1[0x0D] = (b2[0x0C] - b2[0x0D]) * cos0; |
b1[0x0E] = b2[0x0E] + b2[0x0F]; |
b1[0x0F] = (b2[0x0F] - b2[0x0E]) * cos0; |
b1[0x0E] += b1[0x0F]; |
b1[0x0C] += b1[0x0E]; |
b1[0x0E] += b1[0x0D]; |
b1[0x0D] += b1[0x0F]; |
b1[0x10] = b2[0x10] + b2[0x11]; |
b1[0x11] = (b2[0x10] - b2[0x11]) * cos0; |
b1[0x12] = b2[0x12] + b2[0x13]; |
b1[0x13] = (b2[0x13] - b2[0x12]) * cos0; |
b1[0x12] += b1[0x13]; |
b1[0x14] = b2[0x14] + b2[0x15]; |
b1[0x15] = (b2[0x14] - b2[0x15]) * cos0; |
b1[0x16] = b2[0x16] + b2[0x17]; |
b1[0x17] = (b2[0x17] - b2[0x16]) * cos0; |
b1[0x16] += b1[0x17]; |
b1[0x14] += b1[0x16]; |
b1[0x16] += b1[0x15]; |
b1[0x15] += b1[0x17]; |
b1[0x18] = b2[0x18] + b2[0x19]; |
b1[0x19] = (b2[0x18] - b2[0x19]) * cos0; |
b1[0x1A] = b2[0x1A] + b2[0x1B]; |
b1[0x1B] = (b2[0x1B] - b2[0x1A]) * cos0; |
b1[0x1A] += b1[0x1B]; |
b1[0x1C] = b2[0x1C] + b2[0x1D]; |
b1[0x1D] = (b2[0x1C] - b2[0x1D]) * cos0; |
b1[0x1E] = b2[0x1E] + b2[0x1F]; |
b1[0x1F] = (b2[0x1F] - b2[0x1E]) * cos0; |
b1[0x1E] += b1[0x1F]; |
b1[0x1C] += b1[0x1E]; |
b1[0x1E] += b1[0x1D]; |
b1[0x1D] += b1[0x1F]; |
} |
out0[0x10*16] = b1[0x00]; |
out0[0x10*12] = b1[0x04]; |
out0[0x10* 8] = b1[0x02]; |
out0[0x10* 4] = b1[0x06]; |
out0[0x10* 0] = b1[0x01]; |
out1[0x10* 0] = b1[0x01]; |
out1[0x10* 4] = b1[0x05]; |
out1[0x10* 8] = b1[0x03]; |
out1[0x10*12] = b1[0x07]; |
#if 1 |
out0[0x10*14] = b1[0x08] + b1[0x0C]; |
out0[0x10*10] = b1[0x0C] + b1[0x0a]; |
out0[0x10* 6] = b1[0x0A] + b1[0x0E]; |
out0[0x10* 2] = b1[0x0E] + b1[0x09]; |
out1[0x10* 2] = b1[0x09] + b1[0x0D]; |
out1[0x10* 6] = b1[0x0D] + b1[0x0B]; |
out1[0x10*10] = b1[0x0B] + b1[0x0F]; |
out1[0x10*14] = b1[0x0F]; |
#else |
b1[0x08] += b1[0x0C]; |
out0[0x10*14] = b1[0x08]; |
b1[0x0C] += b1[0x0a]; |
out0[0x10*10] = b1[0x0C]; |
b1[0x0A] += b1[0x0E]; |
out0[0x10* 6] = b1[0x0A]; |
b1[0x0E] += b1[0x09]; |
out0[0x10* 2] = b1[0x0E]; |
b1[0x09] += b1[0x0D]; |
out1[0x10* 2] = b1[0x09]; |
b1[0x0D] += b1[0x0B]; |
out1[0x10* 6] = b1[0x0D]; |
b1[0x0B] += b1[0x0F]; |
out1[0x10*10] = b1[0x0B]; |
out1[0x10*14] = b1[0x0F]; |
#endif |
{ |
real tmp; |
tmp = b1[0x18] + b1[0x1C]; |
out0[0x10*15] = tmp + b1[0x10]; |
out0[0x10*13] = tmp + b1[0x14]; |
tmp = b1[0x1C] + b1[0x1A]; |
out0[0x10*11] = tmp + b1[0x14]; |
out0[0x10* 9] = tmp + b1[0x12]; |
tmp = b1[0x1A] + b1[0x1E]; |
out0[0x10* 7] = tmp + b1[0x12]; |
out0[0x10* 5] = tmp + b1[0x16]; |
tmp = b1[0x1E] + b1[0x19]; |
out0[0x10* 3] = tmp + b1[0x16]; |
out0[0x10* 1] = tmp + b1[0x11]; |
tmp = b1[0x19] + b1[0x1D]; |
out1[0x10* 1] = tmp + b1[0x11]; |
out1[0x10* 3] = tmp + b1[0x15]; |
tmp = b1[0x1D] + b1[0x1B]; |
out1[0x10* 5] = tmp + b1[0x15]; |
out1[0x10* 7] = tmp + b1[0x13]; |
tmp = b1[0x1B] + b1[0x1F]; |
out1[0x10* 9] = tmp + b1[0x13]; |
out1[0x10*11] = tmp + b1[0x17]; |
out1[0x10*13] = b1[0x17] + b1[0x1F]; |
out1[0x10*15] = b1[0x1F]; |
} |
} |
/* |
* the call via dct64 is a trick to force GCC to use |
* (new) registers for the b1,b2 pointer to the bufs[xx] field |
*/ |
void dct64(real *a,real *b,real *c) |
{ |
real bufs[0x40]; |
dct64_1(a,b,bufs,bufs+0x20,c); |
} |
/programs/media/ac97snd/trunk/mpg/dct64_i486.c |
---|
0,0 → 1,342 |
/* |
dct64_i486.c: DCT64, a plain C variant for i486 |
copyright 1998-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Fabrice Bellard |
*/ |
/* Discrete Cosine Tansform (DCT) for subband synthesis. |
* |
* This code is optimized for 80486. It should be compiled with gcc |
* 2.7.2 or higher. |
* |
* Note: This code does not give the necessary accuracy. Moreover, no |
* overflow test are done. |
* |
* (c) 1998 Fabrice Bellard. |
*/ |
#include "mpg123.h" |
#define COS_0_0 16403 |
#define COS_0_1 16563 |
#define COS_0_2 16890 |
#define COS_0_3 17401 |
#define COS_0_4 18124 |
#define COS_0_5 19101 |
#define COS_0_6 20398 |
#define COS_0_7 22112 |
#define COS_0_8 24396 |
#define COS_0_9 27503 |
#define COS_0_10 31869 |
#define COS_0_11 38320 |
#define COS_0_12 48633 |
#define COS_0_13 67429 |
#define COS_0_14 111660 |
#define COS_0_15 333906 |
#define COS_1_0 16463 |
#define COS_1_1 17121 |
#define COS_1_2 18577 |
#define COS_1_3 21195 |
#define COS_1_4 25826 |
#define COS_1_5 34756 |
#define COS_1_6 56441 |
#define COS_1_7 167154 |
#define COS_2_0 16704 |
#define COS_2_1 19704 |
#define COS_2_2 29490 |
#define COS_2_3 83981 |
#define COS_3_0 17733 |
#define COS_3_1 42813 |
#define COS_4_0 23170 |
#define SETOUT(out,n,expr) out[FIR_BUFFER_SIZE*(n)]=(expr) |
#define MULL(a,b) (((long)(a)*(long)(b)) >> 15) |
#define MUL(a,b) \ |
(\ |
((!(b & 0x3F)) ? (((a)*(b >> 6)) >> 9) :\ |
((!(b & 0x1F)) ? (((a)*(b >> 5)) >> 10) :\ |
((!(b & 0x0F)) ? (((a)*(b >> 4)) >> 11) :\ |
((!(b & 0x07)) ? (((a)*(b >> 3)) >> 12) :\ |
((!(b & 0x03)) ? (((a)*(b >> 2)) >> 13) :\ |
((!(b & 0x01)) ? (((a)*(b >> 1)) >> 14) :\ |
(((a)*(b )) >> 15)))))))) |
void dct64_1_486(int *out0,int *out1,int *b1,int *b2) |
{ |
b1[0x00] = b2[0x00] + b2[0x1F]; |
b1[0x1F] = MUL((b2[0x00] - b2[0x1F]),COS_0_0); |
b1[0x01] = b2[0x01] + b2[0x1E]; |
b1[0x1E] = MUL((b2[0x01] - b2[0x1E]),COS_0_1); |
b1[0x02] = b2[0x02] + b2[0x1D]; |
b1[0x1D] = MUL((b2[0x02] - b2[0x1D]),COS_0_2); |
b1[0x03] = b2[0x03] + b2[0x1C]; |
b1[0x1C] = MUL((b2[0x03] - b2[0x1C]),COS_0_3); |
b1[0x04] = b2[0x04] + b2[0x1B]; |
b1[0x1B] = MUL((b2[0x04] - b2[0x1B]),COS_0_4); |
b1[0x05] = b2[0x05] + b2[0x1A]; |
b1[0x1A] = MUL((b2[0x05] - b2[0x1A]),COS_0_5); |
b1[0x06] = b2[0x06] + b2[0x19]; |
b1[0x19] = MUL((b2[0x06] - b2[0x19]),COS_0_6); |
b1[0x07] = b2[0x07] + b2[0x18]; |
b1[0x18] = MUL((b2[0x07] - b2[0x18]),COS_0_7); |
b1[0x08] = b2[0x08] + b2[0x17]; |
b1[0x17] = MUL((b2[0x08] - b2[0x17]),COS_0_8); |
b1[0x09] = b2[0x09] + b2[0x16]; |
b1[0x16] = MUL((b2[0x09] - b2[0x16]),COS_0_9); |
b1[0x0A] = b2[0x0A] + b2[0x15]; |
b1[0x15] = MUL((b2[0x0A] - b2[0x15]),COS_0_10); |
b1[0x0B] = b2[0x0B] + b2[0x14]; |
b1[0x14] = MUL((b2[0x0B] - b2[0x14]),COS_0_11); |
b1[0x0C] = b2[0x0C] + b2[0x13]; |
b1[0x13] = MUL((b2[0x0C] - b2[0x13]),COS_0_12); |
b1[0x0D] = b2[0x0D] + b2[0x12]; |
b1[0x12] = MULL((b2[0x0D] - b2[0x12]),COS_0_13); |
b1[0x0E] = b2[0x0E] + b2[0x11]; |
b1[0x11] = MULL((b2[0x0E] - b2[0x11]),COS_0_14); |
b1[0x0F] = b2[0x0F] + b2[0x10]; |
b1[0x10] = MULL((b2[0x0F] - b2[0x10]),COS_0_15); |
b2[0x00] = b1[0x00] + b1[0x0F]; |
b2[0x0F] = MUL((b1[0x00] - b1[0x0F]),COS_1_0); |
b2[0x01] = b1[0x01] + b1[0x0E]; |
b2[0x0E] = MUL((b1[0x01] - b1[0x0E]),COS_1_1); |
b2[0x02] = b1[0x02] + b1[0x0D]; |
b2[0x0D] = MUL((b1[0x02] - b1[0x0D]),COS_1_2); |
b2[0x03] = b1[0x03] + b1[0x0C]; |
b2[0x0C] = MUL((b1[0x03] - b1[0x0C]),COS_1_3); |
b2[0x04] = b1[0x04] + b1[0x0B]; |
b2[0x0B] = MUL((b1[0x04] - b1[0x0B]),COS_1_4); |
b2[0x05] = b1[0x05] + b1[0x0A]; |
b2[0x0A] = MUL((b1[0x05] - b1[0x0A]),COS_1_5); |
b2[0x06] = b1[0x06] + b1[0x09]; |
b2[0x09] = MUL((b1[0x06] - b1[0x09]),COS_1_6); |
b2[0x07] = b1[0x07] + b1[0x08]; |
b2[0x08] = MULL((b1[0x07] - b1[0x08]),COS_1_7); |
b2[0x10] = b1[0x10] + b1[0x1F]; |
b2[0x1F] = MUL((b1[0x1F] - b1[0x10]),COS_1_0); |
b2[0x11] = b1[0x11] + b1[0x1E]; |
b2[0x1E] = MUL((b1[0x1E] - b1[0x11]),COS_1_1); |
b2[0x12] = b1[0x12] + b1[0x1D]; |
b2[0x1D] = MUL((b1[0x1D] - b1[0x12]),COS_1_2); |
b2[0x13] = b1[0x13] + b1[0x1C]; |
b2[0x1C] = MUL((b1[0x1C] - b1[0x13]),COS_1_3); |
b2[0x14] = b1[0x14] + b1[0x1B]; |
b2[0x1B] = MUL((b1[0x1B] - b1[0x14]),COS_1_4); |
b2[0x15] = b1[0x15] + b1[0x1A]; |
b2[0x1A] = MUL((b1[0x1A] - b1[0x15]),COS_1_5); |
b2[0x16] = b1[0x16] + b1[0x19]; |
b2[0x19] = MUL((b1[0x19] - b1[0x16]),COS_1_6); |
b2[0x17] = b1[0x17] + b1[0x18]; |
b2[0x18] = MULL((b1[0x18] - b1[0x17]),COS_1_7); |
b1[0x00] = b2[0x00] + b2[0x07]; |
b1[0x07] = MUL((b2[0x00] - b2[0x07]),COS_2_0); |
b1[0x01] = b2[0x01] + b2[0x06]; |
b1[0x06] = MUL((b2[0x01] - b2[0x06]),COS_2_1); |
b1[0x02] = b2[0x02] + b2[0x05]; |
b1[0x05] = MUL((b2[0x02] - b2[0x05]),COS_2_2); |
b1[0x03] = b2[0x03] + b2[0x04]; |
b1[0x04] = MULL((b2[0x03] - b2[0x04]),COS_2_3); |
b1[0x08] = b2[0x08] + b2[0x0F]; |
b1[0x0F] = MUL((b2[0x0F] - b2[0x08]),COS_2_0); |
b1[0x09] = b2[0x09] + b2[0x0E]; |
b1[0x0E] = MUL((b2[0x0E] - b2[0x09]),COS_2_1); |
b1[0x0A] = b2[0x0A] + b2[0x0D]; |
b1[0x0D] = MUL((b2[0x0D] - b2[0x0A]),COS_2_2); |
b1[0x0B] = b2[0x0B] + b2[0x0C]; |
b1[0x0C] = MULL((b2[0x0C] - b2[0x0B]),COS_2_3); |
b1[0x10] = b2[0x10] + b2[0x17]; |
b1[0x17] = MUL((b2[0x10] - b2[0x17]),COS_2_0); |
b1[0x11] = b2[0x11] + b2[0x16]; |
b1[0x16] = MUL((b2[0x11] - b2[0x16]),COS_2_1); |
b1[0x12] = b2[0x12] + b2[0x15]; |
b1[0x15] = MUL((b2[0x12] - b2[0x15]),COS_2_2); |
b1[0x13] = b2[0x13] + b2[0x14]; |
b1[0x14] = MULL((b2[0x13] - b2[0x14]),COS_2_3); |
b1[0x18] = b2[0x18] + b2[0x1F]; |
b1[0x1F] = MUL((b2[0x1F] - b2[0x18]),COS_2_0); |
b1[0x19] = b2[0x19] + b2[0x1E]; |
b1[0x1E] = MUL((b2[0x1E] - b2[0x19]),COS_2_1); |
b1[0x1A] = b2[0x1A] + b2[0x1D]; |
b1[0x1D] = MUL((b2[0x1D] - b2[0x1A]),COS_2_2); |
b1[0x1B] = b2[0x1B] + b2[0x1C]; |
b1[0x1C] = MULL((b2[0x1C] - b2[0x1B]),COS_2_3); |
b2[0x00] = b1[0x00] + b1[0x03]; |
b2[0x03] = MUL((b1[0x00] - b1[0x03]),COS_3_0); |
b2[0x01] = b1[0x01] + b1[0x02]; |
b2[0x02] = MUL((b1[0x01] - b1[0x02]),COS_3_1); |
b2[0x04] = b1[0x04] + b1[0x07]; |
b2[0x07] = MUL((b1[0x07] - b1[0x04]),COS_3_0); |
b2[0x05] = b1[0x05] + b1[0x06]; |
b2[0x06] = MUL((b1[0x06] - b1[0x05]),COS_3_1); |
b2[0x08] = b1[0x08] + b1[0x0B]; |
b2[0x0B] = MUL((b1[0x08] - b1[0x0B]),COS_3_0); |
b2[0x09] = b1[0x09] + b1[0x0A]; |
b2[0x0A] = MUL((b1[0x09] - b1[0x0A]),COS_3_1); |
b2[0x0C] = b1[0x0C] + b1[0x0F]; |
b2[0x0F] = MUL((b1[0x0F] - b1[0x0C]),COS_3_0); |
b2[0x0D] = b1[0x0D] + b1[0x0E]; |
b2[0x0E] = MUL((b1[0x0E] - b1[0x0D]),COS_3_1); |
b2[0x10] = b1[0x10] + b1[0x13]; |
b2[0x13] = MUL((b1[0x10] - b1[0x13]),COS_3_0); |
b2[0x11] = b1[0x11] + b1[0x12]; |
b2[0x12] = MUL((b1[0x11] - b1[0x12]),COS_3_1); |
b2[0x14] = b1[0x14] + b1[0x17]; |
b2[0x17] = MUL((b1[0x17] - b1[0x14]),COS_3_0); |
b2[0x15] = b1[0x15] + b1[0x16]; |
b2[0x16] = MUL((b1[0x16] - b1[0x15]),COS_3_1); |
b2[0x18] = b1[0x18] + b1[0x1B]; |
b2[0x1B] = MUL((b1[0x18] - b1[0x1B]),COS_3_0); |
b2[0x19] = b1[0x19] + b1[0x1A]; |
b2[0x1A] = MUL((b1[0x19] - b1[0x1A]),COS_3_1); |
b2[0x1C] = b1[0x1C] + b1[0x1F]; |
b2[0x1F] = MUL((b1[0x1F] - b1[0x1C]),COS_3_0); |
b2[0x1D] = b1[0x1D] + b1[0x1E]; |
b2[0x1E] = MUL((b1[0x1E] - b1[0x1D]),COS_3_1); |
{ |
int i; |
for(i=0;i<32;i+=4) { |
b1[i+0x00] = b2[i+0x00] + b2[i+0x01]; |
b1[i+0x01] = MUL((b2[i+0x00] - b2[i+0x01]),COS_4_0); |
b1[i+0x02] = b2[i+0x02] + b2[i+0x03]; |
b1[i+0x03] = MUL((b2[i+0x03] - b2[i+0x02]),COS_4_0); |
} |
} |
b1[0x02] += b1[0x03]; |
b1[0x06] += b1[0x07]; |
b1[0x04] += b1[0x06]; |
b1[0x06] += b1[0x05]; |
b1[0x05] += b1[0x07]; |
b1[0x0A] += b1[0x0B]; |
b1[0x0E] += b1[0x0F]; |
b1[0x0C] += b1[0x0E]; |
b1[0x0E] += b1[0x0D]; |
b1[0x0D] += b1[0x0F]; |
b1[0x12] += b1[0x13]; |
b1[0x16] += b1[0x17]; |
b1[0x14] += b1[0x16]; |
b1[0x16] += b1[0x15]; |
b1[0x15] += b1[0x17]; |
b1[0x1A] += b1[0x1B]; |
b1[0x1E] += b1[0x1F]; |
b1[0x1C] += b1[0x1E]; |
b1[0x1E] += b1[0x1D]; |
b1[0x1D] += b1[0x1F]; |
SETOUT(out0,16,b1[0x00]); |
SETOUT(out0,12,b1[0x04]); |
SETOUT(out0, 8,b1[0x02]); |
SETOUT(out0, 4,b1[0x06]); |
SETOUT(out0, 0,b1[0x01]); |
SETOUT(out1, 0,b1[0x01]); |
SETOUT(out1, 4,b1[0x05]); |
SETOUT(out1, 8,b1[0x03]); |
SETOUT(out1,12,b1[0x07]); |
b1[0x08] += b1[0x0C]; |
SETOUT(out0,14,b1[0x08]); |
b1[0x0C] += b1[0x0a]; |
SETOUT(out0,10,b1[0x0C]); |
b1[0x0A] += b1[0x0E]; |
SETOUT(out0, 6,b1[0x0A]); |
b1[0x0E] += b1[0x09]; |
SETOUT(out0, 2,b1[0x0E]); |
b1[0x09] += b1[0x0D]; |
SETOUT(out1, 2,b1[0x09]); |
b1[0x0D] += b1[0x0B]; |
SETOUT(out1, 6,b1[0x0D]); |
b1[0x0B] += b1[0x0F]; |
SETOUT(out1,10,b1[0x0B]); |
SETOUT(out1,14,b1[0x0F]); |
b1[0x18] += b1[0x1C]; |
SETOUT(out0,15,b1[0x10] + b1[0x18]); |
SETOUT(out0,13,b1[0x18] + b1[0x14]); |
b1[0x1C] += b1[0x1a]; |
SETOUT(out0,11,b1[0x14] + b1[0x1C]); |
SETOUT(out0, 9,b1[0x1C] + b1[0x12]); |
b1[0x1A] += b1[0x1E]; |
SETOUT(out0, 7,b1[0x12] + b1[0x1A]); |
SETOUT(out0, 5,b1[0x1A] + b1[0x16]); |
b1[0x1E] += b1[0x19]; |
SETOUT(out0, 3,b1[0x16] + b1[0x1E]); |
SETOUT(out0, 1,b1[0x1E] + b1[0x11]); |
b1[0x19] += b1[0x1D]; |
SETOUT(out1, 1,b1[0x11] + b1[0x19]); |
SETOUT(out1, 3,b1[0x19] + b1[0x15]); |
b1[0x1D] += b1[0x1B]; |
SETOUT(out1, 5,b1[0x15] + b1[0x1D]); |
SETOUT(out1, 7,b1[0x1D] + b1[0x13]); |
b1[0x1B] += b1[0x1F]; |
SETOUT(out1, 9,b1[0x13] + b1[0x1B]); |
SETOUT(out1,11,b1[0x1B] + b1[0x17]); |
SETOUT(out1,13,b1[0x17] + b1[0x1F]); |
SETOUT(out1,15,b1[0x1F]); |
} |
/* |
* the call via dct64 is a trick to force GCC to use |
* (new) registers for the b1,b2 pointer to the bufs[xx] field |
*/ |
void dct64_486(int *a,int *b,real *samples) |
{ |
int bufs[64]; |
int i; |
#ifdef REAL_IS_FIXED |
#define TOINT(a) ((a) * 32768 / (int)REAL_FACTOR) |
for(i=0;i<32;i++) { |
bufs[i]=TOINT(samples[i]); |
} |
#else |
int *p = bufs; |
register double const scale = ((65536.0 * 32) + 1) * 65536.0; |
for(i=0;i<32;i++) { |
*((double *) (p++)) = scale + *samples++; /* beware on bufs overrun: 8B store from x87 */ |
} |
#endif |
dct64_1_486(a,b,bufs+32,bufs); |
} |
/programs/media/ac97snd/trunk/mpg/decode_i486.c |
---|
0,0 → 1,255 |
/* |
decode_i486.c: i486 decode |
copyright 1998-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Fabrice Bellard |
*/ |
/* |
* Subband Synthesis for MPEG Audio. |
* |
* Version optimized for 80486 by using integer arithmetic, |
* multiplications by shift and add, and by increasing locality in |
* order to fit the 8KB L1 cache. This code should be compiled with gcc |
* 2.7.2 or higher. |
* |
* Note: this version does not guaranty a good accuracy. The filter |
* coefficients are quantified on 14 bits. |
* |
* (c) 1998 Fabrice Bellard |
*/ |
//#include <stdlib.h> |
#include "mpg123.h" |
#define FIR_SIZE 16 |
#define FIR16_1(pos,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15) \ |
{\ |
int sum;\ |
sum=(c0)*b0[0]+(c1)*b0[1]+(c2)*b0[2]+(c3)*b0[3]+\ |
(c4)*b0[4]+(c5)*b0[5]+(c6)*b0[6]+(c7)*b0[7]+\ |
(c8)*b0[8]+(c9)*b0[9]+(c10)*b0[10]+(c11)*b0[11]+\ |
(c12)*b0[12]+(c13)*b0[13]+(c14)*b0[14]+(c15)*b0[15];\ |
sum=(sum+(1 << 13))>>14;\ |
if (sum<-32768) sum=-32768;\ |
else if (sum>32767) sum=32767;\ |
samples[2*(pos)]=sum;\ |
b0+=FIR_BUFFER_SIZE;\ |
} |
#define FIR16_2(pos1,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,\ |
pos2,d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15) \ |
{\ |
int sum1,sum2,v;\ |
\ |
v=b0[0];\ |
sum1=(c0)*v;\ |
sum2=(d0)*v;\ |
v=b0[1];\ |
sum1+=(c1)*v;\ |
sum2+=(d1)*v;\ |
v=b0[2];\ |
sum1+=(c2)*v;\ |
sum2+=(d2)*v;\ |
v=b0[3];\ |
sum1+=(c3)*v;\ |
sum2+=(d3)*v;\ |
v=b0[4];\ |
sum1+=(c4)*v;\ |
sum2+=(d4)*v;\ |
v=b0[5];\ |
sum1+=(c5)*v;\ |
sum2+=(d5)*v;\ |
v=b0[6];\ |
sum1+=(c6)*v;\ |
sum2+=(d6)*v;\ |
v=b0[7];\ |
sum1+=(c7)*v;\ |
sum2+=(d7)*v;\ |
v=b0[8];\ |
sum1+=(c8)*v;\ |
sum2+=(d8)*v;\ |
v=b0[9];\ |
sum1+=(c9)*v;\ |
sum2+=(d9)*v;\ |
v=b0[10];\ |
sum1+=(c10)*v;\ |
sum2+=(d10)*v;\ |
v=b0[11];\ |
sum1+=(c11)*v;\ |
sum2+=(d11)*v;\ |
v=b0[12];\ |
sum1+=(c12)*v;\ |
sum2+=(d12)*v;\ |
v=b0[13];\ |
sum1+=(c13)*v;\ |
sum2+=(d13)*v;\ |
v=b0[14];\ |
sum1+=(c14)*v;\ |
sum2+=(d14)*v;\ |
v=b0[15];\ |
sum1+=(c15)*v;\ |
sum2+=(d15)*v;\ |
\ |
sum1=(sum1+(1<<13))>>14;\ |
sum2=(sum2+(1<<13))>>14;\ |
\ |
if (sum1<-32768) sum1=-32768;\ |
else if (sum1>32767) sum1=32767;\ |
samples[(pos1)*2]=sum1;\ |
\ |
if (sum2<-32768) sum2=-32768;\ |
else if (sum2>32767) sum2=32767;\ |
samples[(pos2)*2]=sum2;\ |
b0+=FIR_BUFFER_SIZE;\ |
} |
int synth_1to1_486(real *bandPtr,int channel,unsigned char *out,int nb_blocks) |
{ |
static int buffs[2][2][17*FIR_BUFFER_SIZE]; |
static int bo[2] = { FIR_SIZE-1, FIR_SIZE-1 }; |
short *samples = (short *) out; |
int *b0,(*buf)[17*FIR_BUFFER_SIZE]; |
int clip = 0; |
int block,b,bo_start; |
/* samples address */ |
samples+=channel; |
bo_start=bo[channel]; |
buf = buffs[channel]; |
b=bo_start; |
for(block=0;block<nb_blocks;block++) { |
/* FIR offset */ |
b++; |
if (b >= FIR_BUFFER_SIZE) { |
int *p,*q; |
int c,i,j; |
/* we shift the buffers */ |
for(c=0;c<2;c++) { |
p=&buf[c][0]+1; |
q=p+(FIR_BUFFER_SIZE-FIR_SIZE); |
for(i=0;i<17;i++) { |
for(j=0;j<FIR_SIZE-1;j++) p[j]=q[j]; |
p+=FIR_BUFFER_SIZE; |
q+=FIR_BUFFER_SIZE; |
} |
} |
/* we update 'bo' accordingly */ |
b=bo[channel]=FIR_SIZE; |
} |
if(b & 1) { |
dct64_486(buf[1]+b,buf[0]+b,bandPtr); |
} else { |
dct64_486(buf[0]+b,buf[1]+b,bandPtr); |
} |
bandPtr+=32; |
} |
bo[channel]=b; |
/* filter bank: part 1 */ |
b=bo_start; |
for(block=0;block<nb_blocks;block++) { |
b++; |
if (b >= FIR_BUFFER_SIZE) b=FIR_SIZE; |
if(b & 1) { |
b0 = buf[0] + b - (FIR_SIZE-1); |
} else { |
b0 = buf[1] + b - (FIR_SIZE-1); |
} |
FIR16_1(0,-7,53,-114,509,-1288,1643,-9372,18759,9372,1643,1288,509,114,53,7,0); |
FIR16_2(1,-6,52,-100,515,-1197,1783,-8910,18748,9834,1489,1379,500,129,54,7,0, |
31,0,-7,54,-129,500,-1379,1489,-9834,18748,8910,1783,1197,515,100,52,6); |
FIR16_2(2,-6,50,-86,520,-1106,1910,-8447,18714,10294,1322,1469,488,145,55,8,0, |
30,0,-8,55,-145,488,-1469,1322,-10294,18714,8447,1910,1106,520,86,50,6); |
FIR16_2(3,-5,49,-73,521,-1015,2023,-7986,18657,10751,1140,1559,473,161,56,9,0, |
29,0,-9,56,-161,473,-1559,1140,-10751,18657,7986,2023,1015,521,73,49,5); |
samples+=64; |
} |
samples-=64*nb_blocks; |
/* filter bank: part 2 */ |
b=bo_start; |
for(block=0;block<nb_blocks;block++) { |
b++; |
if (b >= FIR_BUFFER_SIZE) b=FIR_SIZE; |
if(b & 1) { |
b0 = buf[0] + b - (FIR_SIZE-1) + 4*FIR_BUFFER_SIZE; |
} else { |
b0 = buf[1] + b - (FIR_SIZE-1) + 4*FIR_BUFFER_SIZE; |
} |
FIR16_2(4,-4,47,-61,521,-926,2123,-7528,18578,11205,944,1647,455,177,56,10,0, |
28,0,-10,56,-177,455,-1647,944,-11205,18578,7528,2123,926,521,61,47,4); |
FIR16_2(5,-4,45,-49,518,-837,2210,-7072,18477,11654,733,1733,434,194,57,11,0, |
27,0,-11,57,-194,434,-1733,733,-11654,18477,7072,2210,837,518,49,45,4); |
FIR16_2(6,-4,44,-38,514,-751,2284,-6620,18353,12097,509,1817,411,212,57,12,0, |
26,0,-12,57,-212,411,-1817,509,-12097,18353,6620,2284,751,514,38,44,4); |
FIR16_2(7,-3,42,-27,508,-665,2347,-6173,18208,12534,270,1899,383,229,56,13,0, |
25,0,-13,56,-229,383,-1899,270,-12534,18208,6173,2347,665,508,27,42,3); |
samples+=64; |
} |
samples-=64*nb_blocks; |
/* filter bank: part 3 */ |
b=bo_start; |
for(block=0;block<nb_blocks;block++) { |
b++; |
if (b >= FIR_BUFFER_SIZE) b=FIR_SIZE; |
if(b & 1) { |
b0 = buf[0] + b - (FIR_SIZE-1) + 8*FIR_BUFFER_SIZE; |
} else { |
b0 = buf[1] + b - (FIR_SIZE-1) + 8*FIR_BUFFER_SIZE; |
} |
FIR16_2(8,-3,40,-18,500,-582,2398,-5732,18042,12963,17,1977,353,247,56,14,0, |
24,0,-14,56,-247,353,-1977,17,-12963,18042,5732,2398,582,500,18,40,3); |
FIR16_2(9,-2,38,-9,490,-501,2437,-5297,17855,13383,-249,2052,320,266,55,15,0, |
23,0,-15,55,-266,320,-2052,-249,-13383,17855,5297,2437,501,490,9,38,2); |
FIR16_2(10,-2,36,0,479,-423,2465,-4869,17647,13794,-530,2122,282,284,53,17,0, |
22,0,-17,53,-284,282,-2122,-530,-13794,17647,4869,2465,423,479,0,36,2); |
FIR16_2(11,-2,34,7,467,-347,2483,-4449,17419,14194,-825,2188,242,302,52,18,0, |
21,0,-18,52,-302,242,-2188,-825,-14194,17419,4449,2483,347,467,-7,34,2); |
samples+=64; |
} |
samples-=64*nb_blocks; |
/* filter bank: part 4 */ |
b=bo_start; |
for(block=0;block<nb_blocks;block++) { |
b++; |
if (b >= FIR_BUFFER_SIZE) b=FIR_SIZE; |
if(b & 1) { |
b0 = buf[0] + b - (FIR_SIZE-1) + 12*FIR_BUFFER_SIZE; |
} else { |
b0 = buf[1] + b - (FIR_SIZE-1) + 12*FIR_BUFFER_SIZE; |
} |
FIR16_2(12,-2,33,14,454,-273,2491,-4038,17173,14583,-1133,2249,198,320,50,19,0, |
20,0,-19,50,-320,198,-2249,-1133,-14583,17173,4038,2491,273,454,-14,33,2); |
FIR16_2(13,-1,31,20,439,-203,2489,-3637,16907,14959,-1454,2304,151,339,47,21,-1, |
19,-1,-21,47,-339,151,-2304,-1454,-14959,16907,3637,2489,203,439,-20,31,1); |
FIR16_2(14,-1,29,26,424,-136,2479,-3245,16623,15322,-1788,2354,100,357,44,22,-1, |
18,-1,-22,44,-357,100,-2354,-1788,-15322,16623,3245,2479,136,424,-26,29,1); |
FIR16_2(15,-1,27,31,408,-72,2459,-2863,16322,15671,-2135,2396,46,374,40,24,-1, |
17,-1,-24,40,-374,46,-2396,-2135,-15671,16322,2863,2459,72,408,-31,27,1); |
FIR16_1(16,-1,0,36,0,-11,0,-2493,0,16004,0,2431,0,391,0,26,0); |
samples+=64; |
} |
return clip; |
} |
/programs/media/ac97snd/trunk/mpg/e_pow.c |
---|
0,0 → 1,358 |
/* @(#)e_pow.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* Modified by Naohiko Shimizu/Tokai University, Japan 1997/08/25, |
for performance improvement on pipelined processors. |
*/ |
#if defined(LIBM_SCCS) && !defined(lint) |
static char rcsid[] = "$NetBSD: e_pow.c,v 1.9 1995/05/12 04:57:32 jtc Exp $"; |
#endif |
/* __ieee754_pow(x,y) return x**y |
* |
* n |
* Method: Let x = 2 * (1+f) |
* 1. Compute and return log2(x) in two pieces: |
* log2(x) = w1 + w2, |
* where w1 has 53-24 = 29 bit trailing zeros. |
* 2. Perform y*log2(x) = n+y' by simulating muti-precision |
* arithmetic, where |y'|<=0.5. |
* 3. Return x**y = 2**n*exp(y'*log2) |
* |
* Special cases: |
* 1. (anything) ** 0 is 1 |
* 2. (anything) ** 1 is itself |
* 3. (anything) ** NAN is NAN |
* 4. NAN ** (anything except 0) is NAN |
* 5. +-(|x| > 1) ** +INF is +INF |
* 6. +-(|x| > 1) ** -INF is +0 |
* 7. +-(|x| < 1) ** +INF is +0 |
* 8. +-(|x| < 1) ** -INF is +INF |
* 9. +-1 ** +-INF is NAN |
* 10. +0 ** (+anything except 0, NAN) is +0 |
* 11. -0 ** (+anything except 0, NAN, odd integer) is +0 |
* 12. +0 ** (-anything except 0, NAN) is +INF |
* 13. -0 ** (-anything except 0, NAN, odd integer) is +INF |
* 14. -0 ** (odd integer) = -( +0 ** (odd integer) ) |
* 15. +INF ** (+anything except 0,NAN) is +INF |
* 16. +INF ** (-anything except 0,NAN) is +0 |
* 17. -INF ** (anything) = -0 ** (-anything) |
* 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer) |
* 19. (-anything except 0 and inf) ** (non-integer) is NAN |
* |
* Accuracy: |
* pow(x,y) returns x**y nearly rounded. In particular |
* pow(integer,integer) |
* always returns the correct integer provided it is |
* representable. |
* |
* Constants : |
* The hexadecimal values are the intended ones for the following |
* constants. The decimal values may be used, provided that the |
* compiler will convert from decimal to binary accurately enough |
* to produce the hexadecimal values shown. |
*/ |
#include "math.h" |
#include "math_private.h" |
#define zero C[0] |
#define one C[1] |
#define two C[2] |
#define two53 C[3] |
#define huge C[4] |
#define tiny C[5] |
#define L1 C[6] |
#define L2 C[7] |
#define L3 C[8] |
#define L4 C[9] |
#define L5 C[10] |
#define L6 C[11] |
#define P1 C[12] |
#define P2 C[13] |
#define P3 C[14] |
#define P4 C[15] |
#define P5 C[16] |
#define lg2 C[17] |
#define lg2_h C[18] |
#define lg2_l C[19] |
#define ovt C[20] |
#define cp C[21] |
#define cp_h C[22] |
#define cp_l C[23] |
#define ivln2 C[24] |
#define ivln2_h C[25] |
#define ivln2_l C[26] |
double _cdecl scalbn(double,int); |
#define EXTRACT_WORDS(ix0,ix1,d) \ |
do { \ |
ieee_double_shape_type ew_u; \ |
ew_u.value = (d); \ |
(ix0) = ew_u.parts.msw; \ |
(ix1) = ew_u.parts.lsw; \ |
} while (0) |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
bp[] = {1.0, 1.5,}, |
dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */ |
dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */ |
C[] = { |
0.0, |
1.0, |
2.0, |
9007199254740992.0 , |
1.0e300, |
1.0e-300, |
5.99999999999994648725e-01 , |
4.28571428578550184252e-01 , |
3.33333329818377432918e-01 , |
2.72728123808534006489e-01 , |
2.30660745775561754067e-01 , |
2.06975017800338417784e-01 , |
1.66666666666666019037e-01 , |
-2.77777777770155933842e-03 , |
6.61375632143793436117e-05 , |
-1.65339022054652515390e-06 , |
4.13813679705723846039e-08 , |
6.93147180559945286227e-01 , |
6.93147182464599609375e-01 , |
-1.90465429995776804525e-09 , |
8.0085662595372944372e-0017 , |
9.61796693925975554329e-01 , |
9.61796700954437255859e-01 , |
-7.02846165095275826516e-09 , |
1.44269504088896338700e+00 , |
1.44269502162933349609e+00 , |
1.92596299112661746887e-08 }; |
double pow_test(x,y) |
double x, y; |
{ |
double z,ax,z_h,z_l,p_h,p_l; |
double y1,t1,t2,r,s,t,u,v,w, t12,t14,r_1,r_2,r_3; |
int32_t i,j,k,yisint,n; |
int32_t hx,hy,ix,iy; |
u_int32_t lx,ly; |
EXTRACT_WORDS(hx,lx,x); |
EXTRACT_WORDS(hy,ly,y); |
ix = hx&0x7fffffff; iy = hy&0x7fffffff; |
/* y==zero: x**0 = 1 */ |
if((iy|ly)==0) return C[1]; |
/* +-NaN return x+y */ |
if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) || |
iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) |
return x+y; |
/* determine if y is an odd int when x < 0 |
* yisint = 0 ... y is not an integer |
* yisint = 1 ... y is an odd int |
* yisint = 2 ... y is an even int |
*/ |
yisint = 0; |
if(hx<0) { |
if(iy>=0x43400000) yisint = 2; /* even integer y */ |
else if(iy>=0x3ff00000) { |
k = (iy>>20)-0x3ff; /* exponent */ |
if(k>20) { |
j = ly>>(52-k); |
if((u_int32_t)(j<<(52-k))==ly) yisint = 2-(j&1); |
} else if(ly==0) { |
j = iy>>(20-k); |
if((int32_t)(j<<(20-k))==iy) yisint = 2-(j&1); |
} |
} |
} |
/* special value of y */ |
if(ly==0) { |
if (iy==0x7ff00000) { /* y is +-inf */ |
if(((ix-0x3ff00000)|lx)==0) |
return y - y; /* inf**+-1 is NaN */ |
else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */ |
return (hy>=0)? y: C[0]; |
else /* (|x|<1)**-,+inf = inf,0 */ |
return (hy<0)?-y: C[0]; |
} |
if(iy==0x3ff00000) { /* y is +-1 */ |
if(hy<0) return C[1]/x; else return x; |
} |
if(hy==0x40000000) return x*x; /* y is 2 */ |
if(hy==0x3fe00000) { /* y is 0.5 */ |
if(hx>=0) /* x >= +0 */ |
return sqrt(x); |
} |
} |
ax = fabs(x); |
/* special value of x */ |
if(lx==0) { |
if(ix==0x7ff00000||ix==0||ix==0x3ff00000){ |
z = ax; /*x is +-0,+-inf,+-1*/ |
if(hy<0) z = C[1]/z; /* z = (1/|x|) */ |
if(hx<0) { |
if(((ix-0x3ff00000)|yisint)==0) { |
z = (z-z)/(z-z); /* (-1)**non-int is NaN */ |
} else if(yisint==1) |
z = -z; /* (x<0)**odd = -(|x|**odd) */ |
} |
return z; |
} |
} |
/* (x<0)**(non-int) is NaN */ |
if(((((u_int32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x); |
/* |y| is huge */ |
if(iy>0x41e00000) { /* if |y| > 2**31 */ |
if(iy>0x43f00000){ /* if |y| > 2**64, must o/uflow */ |
if(ix<=0x3fefffff) return (hy<0)? C[4]*C[4]:C[5]*C[5]; |
if(ix>=0x3ff00000) return (hy>0)? C[4]*C[4]:C[5]*C[5]; |
} |
/* over/underflow if x is not close to one */ |
if(ix<0x3fefffff) return (hy<0)? C[4]*C[4]:C[5]*C[5]; |
if(ix>0x3ff00000) return (hy>0)? C[4]*C[4]:C[5]*C[5]; |
/* now |1-x| is tiny <= 2**-20, suffice to compute |
log(x) by x-x^2/2+x^3/3-x^4/4 */ |
t = x-1; /* t has 20 trailing zeros */ |
w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25)); |
u = C[25]*t; /* ivln2_h has 21 sig. bits */ |
v = t*C[26]-w*C[24]; |
t1 = u+v; |
SET_LOW_WORD(t1,0); |
t2 = v-(t1-u); |
} else { |
double s2,s_h,s_l,t_h,t_l,s22,s24,s26,r1,r2,r3; |
n = 0; |
/* take care subnormal number */ |
if(ix<0x00100000) |
{ax *= C[3]; n -= 53; GET_HIGH_WORD(ix,ax); } |
n += ((ix)>>20)-0x3ff; |
j = ix&0x000fffff; |
/* determine interval */ |
ix = j|0x3ff00000; /* normalize ix */ |
if(j<=0x3988E) k=0; /* |x|<sqrt(3/2) */ |
else if(j<0xBB67A) k=1; /* |x|<sqrt(3) */ |
else {k=0;n+=1;ix -= 0x00100000;} |
SET_HIGH_WORD(ax,ix); |
/* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ |
u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */ |
v = C[1]/(ax+bp[k]); |
s = u*v; |
s_h = s; |
SET_LOW_WORD(s_h,0); |
/* t_h=ax+bp[k] High */ |
t_h = C[0]; |
SET_HIGH_WORD(t_h,((ix>>1)|0x20000000)+0x00080000+(k<<18)); |
t_l = ax - (t_h-bp[k]); |
s_l = v*((u-s_h*t_h)-s_h*t_l); |
/* compute log(ax) */ |
s2 = s*s; |
#ifdef DO_NOT_USE_THIS |
r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); |
#else |
r1 = C[10]+s2*C[11]; s22=s2*s2; |
r2 = C[8]+s2*C[9]; s24=s22*s22; |
r3 = C[6]+s2*C[7]; s26=s24*s22; |
r = r3*s22 + r2*s24 + r1*s26; |
#endif |
r += s_l*(s_h+s); |
s2 = s_h*s_h; |
t_h = 3.0+s2+r; |
SET_LOW_WORD(t_h,0); |
t_l = r-((t_h-3.0)-s2); |
/* u+v = s*(1+...) */ |
u = s_h*t_h; |
v = s_l*t_h+t_l*s; |
/* 2/(3log2)*(s+...) */ |
p_h = u+v; |
SET_LOW_WORD(p_h,0); |
p_l = v-(p_h-u); |
z_h = C[22]*p_h; /* cp_h+cp_l = 2/(3*log2) */ |
z_l = C[23]*p_h+p_l*C[21]+dp_l[k]; |
/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ |
t = (double)n; |
t1 = (((z_h+z_l)+dp_h[k])+t); |
SET_LOW_WORD(t1,0); |
t2 = z_l-(((t1-t)-dp_h[k])-z_h); |
} |
s = C[1]; /* s (sign of result -ve**odd) = -1 else = 1 */ |
if(((((u_int32_t)hx>>31)-1)|(yisint-1))==0) |
s = -C[1];/* (-ve)**(odd int) */ |
/* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ |
y1 = y; |
SET_LOW_WORD(y1,0); |
p_l = (y-y1)*t1+y*t2; |
p_h = y1*t1; |
z = p_l+p_h; |
EXTRACT_WORDS(j,i,z); |
if (j>=0x40900000) { /* z >= 1024 */ |
if(((j-0x40900000)|i)!=0) /* if z > 1024 */ |
return s*C[4]*C[4]; /* overflow */ |
else { |
if(p_l+C[20]>z-p_h) return s*C[4]*C[4]; /* overflow */ |
} |
} else if((j&0x7fffffff)>=0x4090cc00 ) { /* z <= -1075 */ |
if(((j-0xc090cc00)|i)!=0) /* z < -1075 */ |
return s*C[5]*C[5]; /* underflow */ |
else { |
if(p_l<=z-p_h) return s*C[5]*C[5]; /* underflow */ |
} |
} |
/* |
* compute 2**(p_h+p_l) |
*/ |
i = j&0x7fffffff; |
k = (i>>20)-0x3ff; |
n = 0; |
if(i>0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */ |
n = j+(0x00100000>>(k+1)); |
k = ((n&0x7fffffff)>>20)-0x3ff; /* new k for n */ |
t = C[0]; |
SET_HIGH_WORD(t,n&~(0x000fffff>>k)); |
n = ((n&0x000fffff)|0x00100000)>>(20-k); |
if(j<0) n = -n; |
p_h -= t; |
} |
t = p_l+p_h; |
SET_LOW_WORD(t,0); |
u = t*C[18]; |
v = (p_l-(t-p_h))*C[17]+t*C[19]; |
z = u+v; |
w = v-(z-u); |
t = z*z; |
#ifdef DO_NOT_USE_THIS |
t1 = z - t*(C[12]+t*(C[13]+t*(C[14]+t*(C[15]+t*C[16])))); |
#else |
r_1 = C[15]+t*C[16]; t12 = t*t; |
r_2 = C[13]+t*C[14]; t14 = t12*t12; |
r_3 = t*C[12]; |
t1 = z - r_3 - t12*r_2 - t14*r_1; |
#endif |
r = (z*t1)/(t1-C[2])-(w+z*w); |
z = C[1]-(r-z); |
GET_HIGH_WORD(j,z); |
j += (n<<20); |
if((j>>20)<=0) z = scalbn(z,n); /* subnormal output */ |
else SET_HIGH_WORD(z,j); |
return s*z; |
} |
/programs/media/ac97snd/trunk/mpg/getbits.c |
---|
0,0 → 1,134 |
/* |
getbits |
copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Michael Hipp |
*/ |
#include "mpg123.h" |
#if 0 |
static void check_buffer_range(int size) |
{ |
int pos = (bsi.wordpointer-bsbuf) + (size>>3); |
if( pos >= fsizeold) { |
fprintf(stderr,"Pointer out of range (%d,%d)!\n",pos,fsizeold); |
} |
} |
#endif |
void backbits(int number_of_bits) |
{ |
bsi.bitindex -= number_of_bits; |
bsi.wordpointer += (bsi.bitindex>>3); |
bsi.bitindex &= 0x7; |
} |
int getbitoffset(void) |
{ |
return (-bsi.bitindex)&0x7; |
} |
int getbyte(void) |
{ |
#ifdef DEBUG_GETBITS |
if(bsi.bitindex) |
fprintf(stderr,"getbyte called unsynched!\n"); |
#endif |
return *bsi.wordpointer++; |
} |
unsigned int getbits(int number_of_bits) |
{ |
unsigned long rval; |
#ifdef DEBUG_GETBITS |
fprintf(stderr,"g%d",number_of_bits); |
#endif |
if(!number_of_bits) |
return 0; |
#if 0 |
check_buffer_range(number_of_bits+bsi.bitindex); |
#endif |
{ |
rval = bsi.wordpointer[0]; |
rval <<= 8; |
rval |= bsi.wordpointer[1]; |
rval <<= 8; |
rval |= bsi.wordpointer[2]; |
rval <<= bsi.bitindex; |
rval &= 0xffffff; |
bsi.bitindex += number_of_bits; |
rval >>= (24-number_of_bits); |
bsi.wordpointer += (bsi.bitindex>>3); |
bsi.bitindex &= 7; |
} |
#ifdef DEBUG_GETBITS |
fprintf(stderr,":%x ",rval); |
#endif |
return rval; |
} |
unsigned int getbits_fast(int number_of_bits) |
{ |
unsigned int rval; |
#ifdef DEBUG_GETBITS |
fprintf(stderr,"g%d",number_of_bits); |
#endif |
#if 0 |
check_buffer_range(number_of_bits+bsi.bitindex); |
#endif |
rval = (unsigned char) (bsi.wordpointer[0] << bsi.bitindex); |
rval |= ((unsigned int) bsi.wordpointer[1]<<bsi.bitindex)>>8; |
rval <<= number_of_bits; |
rval >>= 8; |
bsi.bitindex += number_of_bits; |
bsi.wordpointer += (bsi.bitindex>>3); |
bsi.bitindex &= 7; |
#ifdef DEBUG_GETBITS |
fprintf(stderr,":%x ",rval); |
#endif |
return rval; |
} |
unsigned int get1bit(void) |
{ |
unsigned char rval; |
#ifdef DEBUG_GETBITS |
fprintf(stderr,"g%d",1); |
#endif |
#if 0 |
check_buffer_range(1+bsi.bitindex); |
#endif |
rval = *bsi.wordpointer << bsi.bitindex; |
bsi.bitindex++; |
bsi.wordpointer += (bsi.bitindex>>3); |
bsi.bitindex &= 7; |
#ifdef DEBUG_GETBITS |
fprintf(stderr,":%d ",rval>>7); |
#endif |
return rval>>7; |
} |
/programs/media/ac97snd/trunk/mpg/getbits.h |
---|
0,0 → 1,45 |
/* |
getbits |
copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Michael Hipp |
*/ |
#ifndef _MPG123_GETBITS_H_ |
#define _MPG123_GETBITS_H_ |
/* that's the same file as getits.c but with defines to |
force inlining */ |
static unsigned long rval; |
static unsigned char rval_uc; |
#define backbits(nob) ((void)( \ |
bsi.bitindex -= nob, \ |
bsi.wordpointer += (bsi.bitindex>>3), \ |
bsi.bitindex &= 0x7 )) |
#define getbitoffset() ((-bsi.bitindex)&0x7) |
#define getbyte() (*bsi.wordpointer++) |
#define getbits(nob) ( \ |
rval = bsi.wordpointer[0], rval <<= 8, rval |= bsi.wordpointer[1], \ |
rval <<= 8, rval |= bsi.wordpointer[2], rval <<= bsi.bitindex, \ |
rval &= 0xffffff, bsi.bitindex += nob, \ |
rval >>= (24-nob), bsi.wordpointer += (bsi.bitindex>>3), \ |
bsi.bitindex &= 7,rval) |
#define getbits_fast(nob) ( \ |
rval = (unsigned char) (bsi.wordpointer[0] << bsi.bitindex), \ |
rval |= ((unsigned long) bsi.wordpointer[1]<<bsi.bitindex)>>8, \ |
rval <<= nob, rval >>= 8, \ |
bsi.bitindex += nob, bsi.wordpointer += (bsi.bitindex>>3), \ |
bsi.bitindex &= 7, rval ) |
#define get1bit() ( \ |
rval_uc = *bsi.wordpointer << bsi.bitindex, bsi.bitindex++, \ |
bsi.wordpointer += (bsi.bitindex>>3), bsi.bitindex &= 7, rval_uc>>7 ) |
#endif |
/programs/media/ac97snd/trunk/mpg/huffman.h |
---|
0,0 → 1,340 |
/* |
huffman.h: huffman tables ... recalcualted to work with optimzed decoder scheme (MH) |
copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Michael Hipp |
probably we could save a few bytes of memory, because the |
smaller tables are often the part of a bigger table |
*/ |
#ifndef _MPG123_HUFFMAN_H_ |
#define _MPG123_HUFFMAN_H_ |
struct newhuff |
{ |
unsigned int linbits; |
short *table; |
}; |
static short tab0[] = |
{ |
0 |
}; |
static short tab1[] = |
{ |
-5, -3, -1, 17, 1, 16, 0 |
}; |
static short tab2[] = |
{ |
-15, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 17, -1, 1, |
16, 0 |
}; |
static short tab3[] = |
{ |
-13, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 16, 17, -1, |
1, 0 |
}; |
static short tab5[] = |
{ |
-29, -25, -23, -15, -7, -5, -3, -1, 51, 35, 50, 49, -3, -1, 19, |
3, -1, 48, 34, -3, -1, 18, 33, -1, 2, 32, 17, -1, 1, 16, |
0 |
}; |
static short tab6[] = |
{ |
-25, -19, -13, -9, -5, -3, -1, 51, 3, 35, -1, 50, 48, -1, 19, |
49, -3, -1, 34, 2, 18, -3, -1, 33, 32, 1, -1, 17, -1, 16, |
0 |
}; |
static short tab7[] = |
{ |
-69, -65, -57, -39, -29, -17, -11, -7, -3, -1, 85, 69, -1, 84, 83, |
-1, 53, 68, -3, -1, 37, 82, 21, -5, -1, 81, -1, 5, 52, -1, |
80, -1, 67, 51, -5, -3, -1, 36, 66, 20, -1, 65, 64, -11, -7, |
-3, -1, 4, 35, -1, 50, 3, -1, 19, 49, -3, -1, 48, 34, 18, |
-5, -1, 33, -1, 2, 32, 17, -1, 1, 16, 0 |
}; |
static short tab8[] = |
{ |
-65, -63, -59, -45, -31, -19, -13, -7, -5, -3, -1, 85, 84, 69, 83, |
-3, -1, 53, 68, 37, -3, -1, 82, 5, 21, -5, -1, 81, -1, 52, |
67, -3, -1, 80, 51, 36, -5, -3, -1, 66, 20, 65, -3, -1, 4, |
64, -1, 35, 50, -9, -7, -3, -1, 19, 49, -1, 3, 48, 34, -1, |
2, 32, -1, 18, 33, 17, -3, -1, 1, 16, 0 |
}; |
static short tab9[] = |
{ |
-63, -53, -41, -29, -19, -11, -5, -3, -1, 85, 69, 53, -1, 83, -1, |
84, 5, -3, -1, 68, 37, -1, 82, 21, -3, -1, 81, 52, -1, 67, |
-1, 80, 4, -7, -3, -1, 36, 66, -1, 51, 64, -1, 20, 65, -5, |
-3, -1, 35, 50, 19, -1, 49, -1, 3, 48, -5, -3, -1, 34, 2, |
18, -1, 33, 32, -3, -1, 17, 1, -1, 16, 0 |
}; |
static short tab10[] = |
{ |
-125,-121,-111, -83, -55, -35, -21, -13, -7, -3, -1, 119, 103, -1, 118, |
87, -3, -1, 117, 102, 71, -3, -1, 116, 86, -1, 101, 55, -9, -3, |
-1, 115, 70, -3, -1, 85, 84, 99, -1, 39, 114, -11, -5, -3, -1, |
100, 7, 112, -1, 98, -1, 69, 53, -5, -1, 6, -1, 83, 68, 23, |
-17, -5, -1, 113, -1, 54, 38, -5, -3, -1, 37, 82, 21, -1, 81, |
-1, 52, 67, -3, -1, 22, 97, -1, 96, -1, 5, 80, -19, -11, -7, |
-3, -1, 36, 66, -1, 51, 4, -1, 20, 65, -3, -1, 64, 35, -1, |
50, 3, -3, -1, 19, 49, -1, 48, 34, -7, -3, -1, 18, 33, -1, |
2, 32, 17, -1, 1, 16, 0 |
}; |
static short tab11[] = |
{ |
-121,-113, -89, -59, -43, -27, -17, -7, -3, -1, 119, 103, -1, 118, 117, |
-3, -1, 102, 71, -1, 116, -1, 87, 85, -5, -3, -1, 86, 101, 55, |
-1, 115, 70, -9, -7, -3, -1, 69, 84, -1, 53, 83, 39, -1, 114, |
-1, 100, 7, -5, -1, 113, -1, 23, 112, -3, -1, 54, 99, -1, 96, |
-1, 68, 37, -13, -7, -5, -3, -1, 82, 5, 21, 98, -3, -1, 38, |
6, 22, -5, -1, 97, -1, 81, 52, -5, -1, 80, -1, 67, 51, -1, |
36, 66, -15, -11, -7, -3, -1, 20, 65, -1, 4, 64, -1, 35, 50, |
-1, 19, 49, -5, -3, -1, 3, 48, 34, 33, -5, -1, 18, -1, 2, |
32, 17, -3, -1, 1, 16, 0 |
}; |
static short tab12[] = |
{ |
-115, -99, -73, -45, -27, -17, -9, -5, -3, -1, 119, 103, 118, -1, 87, |
117, -3, -1, 102, 71, -1, 116, 101, -3, -1, 86, 55, -3, -1, 115, |
85, 39, -7, -3, -1, 114, 70, -1, 100, 23, -5, -1, 113, -1, 7, |
112, -1, 54, 99, -13, -9, -3, -1, 69, 84, -1, 68, -1, 6, 5, |
-1, 38, 98, -5, -1, 97, -1, 22, 96, -3, -1, 53, 83, -1, 37, |
82, -17, -7, -3, -1, 21, 81, -1, 52, 67, -5, -3, -1, 80, 4, |
36, -1, 66, 20, -3, -1, 51, 65, -1, 35, 50, -11, -7, -5, -3, |
-1, 64, 3, 48, 19, -1, 49, 34, -1, 18, 33, -7, -5, -3, -1, |
2, 32, 0, 17, -1, 1, 16 |
}; |
static short tab13[] = |
{ |
-509,-503,-475,-405,-333,-265,-205,-153,-115, -83, -53, -35, -21, -13, -9, |
-7, -5, -3, -1, 254, 252, 253, 237, 255, -1, 239, 223, -3, -1, 238, |
207, -1, 222, 191, -9, -3, -1, 251, 206, -1, 220, -1, 175, 233, -1, |
236, 221, -9, -5, -3, -1, 250, 205, 190, -1, 235, 159, -3, -1, 249, |
234, -1, 189, 219, -17, -9, -3, -1, 143, 248, -1, 204, -1, 174, 158, |
-5, -1, 142, -1, 127, 126, 247, -5, -1, 218, -1, 173, 188, -3, -1, |
203, 246, 111, -15, -7, -3, -1, 232, 95, -1, 157, 217, -3, -1, 245, |
231, -1, 172, 187, -9, -3, -1, 79, 244, -3, -1, 202, 230, 243, -1, |
63, -1, 141, 216, -21, -9, -3, -1, 47, 242, -3, -1, 110, 156, 15, |
-5, -3, -1, 201, 94, 171, -3, -1, 125, 215, 78, -11, -5, -3, -1, |
200, 214, 62, -1, 185, -1, 155, 170, -1, 31, 241, -23, -13, -5, -1, |
240, -1, 186, 229, -3, -1, 228, 140, -1, 109, 227, -5, -1, 226, -1, |
46, 14, -1, 30, 225, -15, -7, -3, -1, 224, 93, -1, 213, 124, -3, |
-1, 199, 77, -1, 139, 184, -7, -3, -1, 212, 154, -1, 169, 108, -1, |
198, 61, -37, -21, -9, -5, -3, -1, 211, 123, 45, -1, 210, 29, -5, |
-1, 183, -1, 92, 197, -3, -1, 153, 122, 195, -7, -5, -3, -1, 167, |
151, 75, 209, -3, -1, 13, 208, -1, 138, 168, -11, -7, -3, -1, 76, |
196, -1, 107, 182, -1, 60, 44, -3, -1, 194, 91, -3, -1, 181, 137, |
28, -43, -23, -11, -5, -1, 193, -1, 152, 12, -1, 192, -1, 180, 106, |
-5, -3, -1, 166, 121, 59, -1, 179, -1, 136, 90, -11, -5, -1, 43, |
-1, 165, 105, -1, 164, -1, 120, 135, -5, -1, 148, -1, 119, 118, 178, |
-11, -3, -1, 27, 177, -3, -1, 11, 176, -1, 150, 74, -7, -3, -1, |
58, 163, -1, 89, 149, -1, 42, 162, -47, -23, -9, -3, -1, 26, 161, |
-3, -1, 10, 104, 160, -5, -3, -1, 134, 73, 147, -3, -1, 57, 88, |
-1, 133, 103, -9, -3, -1, 41, 146, -3, -1, 87, 117, 56, -5, -1, |
131, -1, 102, 71, -3, -1, 116, 86, -1, 101, 115, -11, -3, -1, 25, |
145, -3, -1, 9, 144, -1, 72, 132, -7, -5, -1, 114, -1, 70, 100, |
40, -1, 130, 24, -41, -27, -11, -5, -3, -1, 55, 39, 23, -1, 113, |
-1, 85, 7, -7, -3, -1, 112, 54, -1, 99, 69, -3, -1, 84, 38, |
-1, 98, 53, -5, -1, 129, -1, 8, 128, -3, -1, 22, 97, -1, 6, |
96, -13, -9, -5, -3, -1, 83, 68, 37, -1, 82, 5, -1, 21, 81, |
-7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20, -19, -11, |
-5, -1, 65, -1, 4, 64, -3, -1, 35, 50, 19, -3, -1, 49, 3, |
-1, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16, |
0 |
}; |
static short tab15[] = |
{ |
-495,-445,-355,-263,-183,-115, -77, -43, -27, -13, -7, -3, -1, 255, 239, |
-1, 254, 223, -1, 238, -1, 253, 207, -7, -3, -1, 252, 222, -1, 237, |
191, -1, 251, -1, 206, 236, -7, -3, -1, 221, 175, -1, 250, 190, -3, |
-1, 235, 205, -1, 220, 159, -15, -7, -3, -1, 249, 234, -1, 189, 219, |
-3, -1, 143, 248, -1, 204, 158, -7, -3, -1, 233, 127, -1, 247, 173, |
-3, -1, 218, 188, -1, 111, -1, 174, 15, -19, -11, -3, -1, 203, 246, |
-3, -1, 142, 232, -1, 95, 157, -3, -1, 245, 126, -1, 231, 172, -9, |
-3, -1, 202, 187, -3, -1, 217, 141, 79, -3, -1, 244, 63, -1, 243, |
216, -33, -17, -9, -3, -1, 230, 47, -1, 242, -1, 110, 240, -3, -1, |
31, 241, -1, 156, 201, -7, -3, -1, 94, 171, -1, 186, 229, -3, -1, |
125, 215, -1, 78, 228, -15, -7, -3, -1, 140, 200, -1, 62, 109, -3, |
-1, 214, 227, -1, 155, 185, -7, -3, -1, 46, 170, -1, 226, 30, -5, |
-1, 225, -1, 14, 224, -1, 93, 213, -45, -25, -13, -7, -3, -1, 124, |
199, -1, 77, 139, -1, 212, -1, 184, 154, -7, -3, -1, 169, 108, -1, |
198, 61, -1, 211, 210, -9, -5, -3, -1, 45, 13, 29, -1, 123, 183, |
-5, -1, 209, -1, 92, 208, -1, 197, 138, -17, -7, -3, -1, 168, 76, |
-1, 196, 107, -5, -1, 182, -1, 153, 12, -1, 60, 195, -9, -3, -1, |
122, 167, -1, 166, -1, 192, 11, -1, 194, -1, 44, 91, -55, -29, -15, |
-7, -3, -1, 181, 28, -1, 137, 152, -3, -1, 193, 75, -1, 180, 106, |
-5, -3, -1, 59, 121, 179, -3, -1, 151, 136, -1, 43, 90, -11, -5, |
-1, 178, -1, 165, 27, -1, 177, -1, 176, 105, -7, -3, -1, 150, 74, |
-1, 164, 120, -3, -1, 135, 58, 163, -17, -7, -3, -1, 89, 149, -1, |
42, 162, -3, -1, 26, 161, -3, -1, 10, 160, 104, -7, -3, -1, 134, |
73, -1, 148, 57, -5, -1, 147, -1, 119, 9, -1, 88, 133, -53, -29, |
-13, -7, -3, -1, 41, 103, -1, 118, 146, -1, 145, -1, 25, 144, -7, |
-3, -1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 71, -7, |
-3, -1, 40, 130, -1, 24, 129, -7, -3, -1, 116, 8, -1, 128, 86, |
-3, -1, 101, 55, -1, 115, 70, -17, -7, -3, -1, 39, 114, -1, 100, |
23, -3, -1, 85, 113, -3, -1, 7, 112, 54, -7, -3, -1, 99, 69, |
-1, 84, 38, -3, -1, 98, 22, -3, -1, 6, 96, 53, -33, -19, -9, |
-5, -1, 97, -1, 83, 68, -1, 37, 82, -3, -1, 21, 81, -3, -1, |
5, 80, 52, -7, -3, -1, 67, 36, -1, 66, 51, -1, 65, -1, 20, |
4, -9, -3, -1, 35, 50, -3, -1, 64, 3, 19, -3, -1, 49, 48, |
34, -9, -7, -3, -1, 18, 33, -1, 2, 32, 17, -3, -1, 1, 16, |
0 |
}; |
static short tab16[] = |
{ |
-509,-503,-461,-323,-103, -37, -27, -15, -7, -3, -1, 239, 254, -1, 223, |
253, -3, -1, 207, 252, -1, 191, 251, -5, -1, 175, -1, 250, 159, -3, |
-1, 249, 248, 143, -7, -3, -1, 127, 247, -1, 111, 246, 255, -9, -5, |
-3, -1, 95, 245, 79, -1, 244, 243, -53, -1, 240, -1, 63, -29, -19, |
-13, -7, -5, -1, 206, -1, 236, 221, 222, -1, 233, -1, 234, 217, -1, |
238, -1, 237, 235, -3, -1, 190, 205, -3, -1, 220, 219, 174, -11, -5, |
-1, 204, -1, 173, 218, -3, -1, 126, 172, 202, -5, -3, -1, 201, 125, |
94, 189, 242, -93, -5, -3, -1, 47, 15, 31, -1, 241, -49, -25, -13, |
-5, -1, 158, -1, 188, 203, -3, -1, 142, 232, -1, 157, 231, -7, -3, |
-1, 187, 141, -1, 216, 110, -1, 230, 156, -13, -7, -3, -1, 171, 186, |
-1, 229, 215, -1, 78, -1, 228, 140, -3, -1, 200, 62, -1, 109, -1, |
214, 155, -19, -11, -5, -3, -1, 185, 170, 225, -1, 212, -1, 184, 169, |
-5, -1, 123, -1, 183, 208, 227, -7, -3, -1, 14, 224, -1, 93, 213, |
-3, -1, 124, 199, -1, 77, 139, -75, -45, -27, -13, -7, -3, -1, 154, |
108, -1, 198, 61, -3, -1, 92, 197, 13, -7, -3, -1, 138, 168, -1, |
153, 76, -3, -1, 182, 122, 60, -11, -5, -3, -1, 91, 137, 28, -1, |
192, -1, 152, 121, -1, 226, -1, 46, 30, -15, -7, -3, -1, 211, 45, |
-1, 210, 209, -5, -1, 59, -1, 151, 136, 29, -7, -3, -1, 196, 107, |
-1, 195, 167, -1, 44, -1, 194, 181, -23, -13, -7, -3, -1, 193, 12, |
-1, 75, 180, -3, -1, 106, 166, 179, -5, -3, -1, 90, 165, 43, -1, |
178, 27, -13, -5, -1, 177, -1, 11, 176, -3, -1, 105, 150, -1, 74, |
164, -5, -3, -1, 120, 135, 163, -3, -1, 58, 89, 42, -97, -57, -33, |
-19, -11, -5, -3, -1, 149, 104, 161, -3, -1, 134, 119, 148, -5, -3, |
-1, 73, 87, 103, 162, -5, -1, 26, -1, 10, 160, -3, -1, 57, 147, |
-1, 88, 133, -9, -3, -1, 41, 146, -3, -1, 118, 9, 25, -5, -1, |
145, -1, 144, 72, -3, -1, 132, 117, -1, 56, 131, -21, -11, -5, -3, |
-1, 102, 40, 130, -3, -1, 71, 116, 24, -3, -1, 129, 128, -3, -1, |
8, 86, 55, -9, -5, -1, 115, -1, 101, 70, -1, 39, 114, -5, -3, |
-1, 100, 85, 7, 23, -23, -13, -5, -1, 113, -1, 112, 54, -3, -1, |
99, 69, -1, 84, 38, -3, -1, 98, 22, -1, 97, -1, 6, 96, -9, |
-5, -1, 83, -1, 53, 68, -1, 37, 82, -1, 81, -1, 21, 5, -33, |
-23, -13, -7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20, |
-5, -1, 65, -1, 4, 64, -1, 35, 50, -3, -1, 19, 49, -3, -1, |
3, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16, |
0 |
}; |
static short tab24[] = |
{ |
-451,-117, -43, -25, -15, -7, -3, -1, 239, 254, -1, 223, 253, -3, -1, |
207, 252, -1, 191, 251, -5, -1, 250, -1, 175, 159, -1, 249, 248, -9, |
-5, -3, -1, 143, 127, 247, -1, 111, 246, -3, -1, 95, 245, -1, 79, |
244, -71, -7, -3, -1, 63, 243, -1, 47, 242, -5, -1, 241, -1, 31, |
240, -25, -9, -1, 15, -3, -1, 238, 222, -1, 237, 206, -7, -3, -1, |
236, 221, -1, 190, 235, -3, -1, 205, 220, -1, 174, 234, -15, -7, -3, |
-1, 189, 219, -1, 204, 158, -3, -1, 233, 173, -1, 218, 188, -7, -3, |
-1, 203, 142, -1, 232, 157, -3, -1, 217, 126, -1, 231, 172, 255,-235, |
-143, -77, -45, -25, -15, -7, -3, -1, 202, 187, -1, 141, 216, -5, -3, |
-1, 14, 224, 13, 230, -5, -3, -1, 110, 156, 201, -1, 94, 186, -9, |
-5, -1, 229, -1, 171, 125, -1, 215, 228, -3, -1, 140, 200, -3, -1, |
78, 46, 62, -15, -7, -3, -1, 109, 214, -1, 227, 155, -3, -1, 185, |
170, -1, 226, 30, -7, -3, -1, 225, 93, -1, 213, 124, -3, -1, 199, |
77, -1, 139, 184, -31, -15, -7, -3, -1, 212, 154, -1, 169, 108, -3, |
-1, 198, 61, -1, 211, 45, -7, -3, -1, 210, 29, -1, 123, 183, -3, |
-1, 209, 92, -1, 197, 138, -17, -7, -3, -1, 168, 153, -1, 76, 196, |
-3, -1, 107, 182, -3, -1, 208, 12, 60, -7, -3, -1, 195, 122, -1, |
167, 44, -3, -1, 194, 91, -1, 181, 28, -57, -35, -19, -7, -3, -1, |
137, 152, -1, 193, 75, -5, -3, -1, 192, 11, 59, -3, -1, 176, 10, |
26, -5, -1, 180, -1, 106, 166, -3, -1, 121, 151, -3, -1, 160, 9, |
144, -9, -3, -1, 179, 136, -3, -1, 43, 90, 178, -7, -3, -1, 165, |
27, -1, 177, 105, -1, 150, 164, -17, -9, -5, -3, -1, 74, 120, 135, |
-1, 58, 163, -3, -1, 89, 149, -1, 42, 162, -7, -3, -1, 161, 104, |
-1, 134, 119, -3, -1, 73, 148, -1, 57, 147, -63, -31, -15, -7, -3, |
-1, 88, 133, -1, 41, 103, -3, -1, 118, 146, -1, 25, 145, -7, -3, |
-1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 40, -17, -7, |
-3, -1, 130, 24, -1, 71, 116, -5, -1, 129, -1, 8, 128, -1, 86, |
101, -7, -5, -1, 23, -1, 7, 112, 115, -3, -1, 55, 39, 114, -15, |
-7, -3, -1, 70, 100, -1, 85, 113, -3, -1, 54, 99, -1, 69, 84, |
-7, -3, -1, 38, 98, -1, 22, 97, -5, -3, -1, 6, 96, 53, -1, |
83, 68, -51, -37, -23, -15, -9, -3, -1, 37, 82, -1, 21, -1, 5, |
80, -1, 81, -1, 52, 67, -3, -1, 36, 66, -1, 51, 20, -9, -5, |
-1, 65, -1, 4, 64, -1, 35, 50, -1, 19, 49, -7, -5, -3, -1, |
3, 48, 34, 18, -1, 33, -1, 2, 32, -3, -1, 17, 1, -1, 16, |
0 |
}; |
static short tab_c0[] = |
{ |
-29, -21, -13, -7, -3, -1, 11, 15, -1, 13, 14, -3, -1, 7, 5, |
9, -3, -1, 6, 3, -1, 10, 12, -3, -1, 2, 1, -1, 4, 8, |
0 |
}; |
static short tab_c1[] = |
{ |
-15, -7, -3, -1, 15, 14, -1, 13, 12, -3, -1, 11, 10, -1, 9, |
8, -7, -3, -1, 7, 6, -1, 5, 4, -3, -1, 3, 2, -1, 1, |
0 |
}; |
static struct newhuff ht[] = |
{ |
{ /* 0 */ 0 , tab0 } , |
{ /* 2 */ 0 , tab1 } , |
{ /* 3 */ 0 , tab2 } , |
{ /* 3 */ 0 , tab3 } , |
{ /* 0 */ 0 , tab0 } , |
{ /* 4 */ 0 , tab5 } , |
{ /* 4 */ 0 , tab6 } , |
{ /* 6 */ 0 , tab7 } , |
{ /* 6 */ 0 , tab8 } , |
{ /* 6 */ 0 , tab9 } , |
{ /* 8 */ 0 , tab10 } , |
{ /* 8 */ 0 , tab11 } , |
{ /* 8 */ 0 , tab12 } , |
{ /* 16 */ 0 , tab13 } , |
{ /* 0 */ 0 , tab0 } , |
{ /* 16 */ 0 , tab15 } , |
{ /* 16 */ 1 , tab16 } , |
{ /* 16 */ 2 , tab16 } , |
{ /* 16 */ 3 , tab16 } , |
{ /* 16 */ 4 , tab16 } , |
{ /* 16 */ 6 , tab16 } , |
{ /* 16 */ 8 , tab16 } , |
{ /* 16 */ 10, tab16 } , |
{ /* 16 */ 13, tab16 } , |
{ /* 16 */ 4 , tab24 } , |
{ /* 16 */ 5 , tab24 } , |
{ /* 16 */ 6 , tab24 } , |
{ /* 16 */ 7 , tab24 } , |
{ /* 16 */ 8 , tab24 } , |
{ /* 16 */ 9 , tab24 } , |
{ /* 16 */ 11, tab24 } , |
{ /* 16 */ 13, tab24 } |
}; |
static struct newhuff htc[] = |
{ |
{ /* 1 , 1 , */ 0 , tab_c0 } , |
{ /* 1 , 1 , */ 0 , tab_c1 } |
}; |
#endif |
/programs/media/ac97snd/trunk/mpg/l2tables.h |
---|
0,0 → 1,164 |
/* |
l2tables.h: Layer 2 Alloc tables |
copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Michael Hipp |
most other tables are calculated on program start (which is (of course) not ISO-conform) |
Layer-3 huffman table is in huffman.h |
*/ |
#ifndef _MPG123_L2TABLES_H_ |
#define _MPG123_L2TABLES_H_ |
struct al_table alloc_0[] = { |
{4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511}, |
{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767}, |
{4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511}, |
{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767}, |
{4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511}, |
{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{2,0},{5,3},{7,5},{16,-32767}, |
{2,0},{5,3},{7,5},{16,-32767}, |
{2,0},{5,3},{7,5},{16,-32767}, |
{2,0},{5,3},{7,5},{16,-32767} }; |
struct al_table alloc_1[] = { |
{4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511}, |
{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767}, |
{4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511}, |
{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767}, |
{4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511}, |
{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767}, |
{2,0},{5,3},{7,5},{16,-32767}, |
{2,0},{5,3},{7,5},{16,-32767}, |
{2,0},{5,3},{7,5},{16,-32767}, |
{2,0},{5,3},{7,5},{16,-32767}, |
{2,0},{5,3},{7,5},{16,-32767}, |
{2,0},{5,3},{7,5},{16,-32767}, |
{2,0},{5,3},{7,5},{16,-32767} }; |
struct al_table alloc_2[] = { |
{4,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255}, |
{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383}, |
{4,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255}, |
{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63} }; |
struct al_table alloc_3[] = { |
{4,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255}, |
{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383}, |
{4,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255}, |
{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63} }; |
struct al_table alloc_4[] = { |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191}, |
{4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127}, |
{9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9}, |
{2,0},{5,3},{7,5},{10,9} }; |
#endif |
/programs/media/ac97snd/trunk/mpg/layer1.c |
---|
0,0 → 1,151 |
/* |
layer1.c: the layer 1 decoder |
copyright 1995-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Michael Hipp |
may have a few bugs after last optimization ... |
*/ |
#include "mpg123.h" |
void I_step_one(unsigned int balloc[], unsigned int scale_index[2][SBLIMIT],struct frame *fr) |
{ |
unsigned int *ba=balloc; |
unsigned int *sca = (unsigned int *) scale_index; |
if(fr->stereo == 2) { |
int i; |
int jsbound = fr->jsbound; |
for (i=0;i<jsbound;i++) { |
*ba++ = getbits(4); |
*ba++ = getbits(4); |
} |
for (i=jsbound;i<SBLIMIT;i++) |
*ba++ = getbits(4); |
ba = balloc; |
for (i=0;i<jsbound;i++) { |
if ((*ba++)) |
*sca++ = getbits(6); |
if ((*ba++)) |
*sca++ = getbits(6); |
} |
for (i=jsbound;i<SBLIMIT;i++) |
if ((*ba++)) { |
*sca++ = getbits(6); |
*sca++ = getbits(6); |
} |
} |
else { |
int i; |
for (i=0;i<SBLIMIT;i++) |
*ba++ = getbits(4); |
ba = balloc; |
for (i=0;i<SBLIMIT;i++) |
if ((*ba++)) |
*sca++ = getbits(6); |
} |
} |
void I_step_two(real fraction[2][SBLIMIT],unsigned int balloc[2*SBLIMIT], |
unsigned int scale_index[2][SBLIMIT],struct frame *fr) |
{ |
int i,n; |
int smpb[2*SBLIMIT]; /* values: 0-65535 */ |
int *sample; |
register unsigned int *ba; |
register unsigned int *sca = (unsigned int *) scale_index; |
if(fr->stereo == 2) { |
int jsbound = fr->jsbound; |
register real *f0 = fraction[0]; |
register real *f1 = fraction[1]; |
ba = balloc; |
for (sample=smpb,i=0;i<jsbound;i++) { |
if ((n = *ba++)) |
*sample++ = getbits(n+1); |
if ((n = *ba++)) |
*sample++ = getbits(n+1); |
} |
for (i=jsbound;i<SBLIMIT;i++) |
if ((n = *ba++)) |
*sample++ = getbits(n+1); |
ba = balloc; |
for (sample=smpb,i=0;i<jsbound;i++) { |
if((n=*ba++)) |
*f0++ = (real) ( ((-1)<<n) + (*sample++) + 1) * muls[n+1][*sca++]; |
else |
*f0++ = 0.0; |
if((n=*ba++)) |
*f1++ = (real) ( ((-1)<<n) + (*sample++) + 1) * muls[n+1][*sca++]; |
else |
*f1++ = 0.0; |
} |
for (i=jsbound;i<SBLIMIT;i++) { |
if ((n=*ba++)) { |
real samp = ( ((-1)<<n) + (*sample++) + 1); |
*f0++ = samp * muls[n+1][*sca++]; |
*f1++ = samp * muls[n+1][*sca++]; |
} |
else |
*f0++ = *f1++ = 0.0; |
} |
for(i=fr->down_sample_sblimit;i<32;i++) |
fraction[0][i] = fraction[1][i] = 0.0; |
} |
else { |
register real *f0 = fraction[0]; |
ba = balloc; |
for (sample=smpb,i=0;i<SBLIMIT;i++) |
if ((n = *ba++)) |
*sample++ = getbits(n+1); |
ba = balloc; |
for (sample=smpb,i=0;i<SBLIMIT;i++) { |
if((n=*ba++)) |
*f0++ = (real) ( ((-1)<<n) + (*sample++) + 1) * muls[n+1][*sca++]; |
else |
*f0++ = 0.0; |
} |
for(i=fr->down_sample_sblimit;i<32;i++) |
fraction[0][i] = 0.0; |
} |
} |
int do_layer1(struct frame *fr,byte *pcm_sample, int *pcm_point) |
{ |
int clip=0; |
int i,stereo = fr->stereo; |
unsigned int balloc[2*SBLIMIT]; |
unsigned int scale_index[2][SBLIMIT]; |
real fraction[2][SBLIMIT]; |
int single = fr->single; |
fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext<<2)+4 : 32; |
if(stereo == 1 || single == 3) |
single = 0; |
I_step_one(balloc,scale_index,fr); |
for (i=0;i<SCALE_BLOCK;i++) |
{ |
I_step_two(fraction,balloc,scale_index,fr); |
if(single >= 0) |
{ |
clip += (fr->synth_mono)( (real *) fraction[single],pcm_sample,pcm_point); |
} |
else { |
int p1=*pcm_point; |
clip += (fr->synth)( (real *) fraction[0],0,pcm_sample,&p1); |
clip += (fr->synth)( (real *) fraction[1],1,pcm_sample,pcm_point); |
} |
} |
return clip; |
} |
/programs/media/ac97snd/trunk/mpg/layer2.c |
---|
0,0 → 1,306 |
/* |
layer2.c: the layer 2 decoder, root of mpg123 |
copyright 1994-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Michael Hipp |
mpg123 started as mp2 decoder a long time ago... |
*/ |
#include "mpg123.h" |
#include "l2tables.h" |
static int grp_3tab[32 * 3] = { 0, }; /* used: 27 */ |
static int grp_5tab[128 * 3] = { 0, }; /* used: 125 */ |
static int grp_9tab[1024 * 3] = { 0, }; /* used: 729 */ |
real muls[27][64]; /* also used by layer 1 */ |
void init_layer2(void) |
{ |
static double mulmul[27] = { |
0.0 , -2.0/3.0 , 2.0/3.0 , |
2.0/7.0 , 2.0/15.0 , 2.0/31.0, 2.0/63.0 , 2.0/127.0 , 2.0/255.0 , |
2.0/511.0 , 2.0/1023.0 , 2.0/2047.0 , 2.0/4095.0 , 2.0/8191.0 , |
2.0/16383.0 , 2.0/32767.0 , 2.0/65535.0 , |
-4.0/5.0 , -2.0/5.0 , 2.0/5.0, 4.0/5.0 , |
-8.0/9.0 , -4.0/9.0 , -2.0/9.0 , 2.0/9.0 , 4.0/9.0 , 8.0/9.0 }; |
static int base[3][9] = { |
{ 1 , 0, 2 , } , |
{ 17, 18, 0 , 19, 20 , } , |
{ 21, 1, 22, 23, 0, 24, 25, 2, 26 } }; |
int i,j,k,l,len; |
real *table; |
static int tablen[3] = { 3 , 5 , 9 }; |
static int *itable,*tables[3] = { grp_3tab , grp_5tab , grp_9tab }; |
for(i=0;i<3;i++) |
{ |
itable = tables[i]; |
len = tablen[i]; |
for(j=0;j<len;j++) |
for(k=0;k<len;k++) |
for(l=0;l<len;l++) |
{ |
*itable++ = base[i][l]; |
*itable++ = base[i][k]; |
*itable++ = base[i][j]; |
} |
} |
for(k=0;k<27;k++) |
{ |
double m=mulmul[k]; |
table = muls[k]; |
#ifdef USE_MMX |
if(!param.down_sample) |
for(j=3,i=0;i<63;i++,j--) |
*table++ = 16384 * m * pow(2.0,(double) j / 3.0); |
else |
#endif |
for(j=3,i=0;i<63;i++,j--) |
*table++ = m * pow_test(2.0,(double) j / 3.0); |
*table++ = 0.0; |
} |
} |
void II_step_one(unsigned int *bit_alloc,int *scale,struct frame *fr) |
{ |
int stereo = fr->stereo-1; |
int sblimit = fr->II_sblimit; |
int jsbound = fr->jsbound; |
int sblimit2 = fr->II_sblimit<<stereo; |
struct al_table *alloc1 = fr->alloc; |
int i; |
static unsigned int scfsi_buf[64]; |
unsigned int *scfsi,*bita; |
int sc,step; |
bita = bit_alloc; |
if(stereo) |
{ |
for (i=jsbound;i;i--,alloc1+=(1<<step)) |
{ |
*bita++ = (char) getbits(step=alloc1->bits); |
*bita++ = (char) getbits(step); |
} |
for (i=sblimit-jsbound;i;i--,alloc1+=(1<<step)) |
{ |
bita[0] = (char) getbits(step=alloc1->bits); |
bita[1] = bita[0]; |
bita+=2; |
} |
bita = bit_alloc; |
scfsi=scfsi_buf; |
for (i=sblimit2;i;i--) |
if (*bita++) |
*scfsi++ = (char) getbits_fast(2); |
} |
else /* mono */ |
{ |
for (i=sblimit;i;i--,alloc1+=(1<<step)) |
*bita++ = (char) getbits(step=alloc1->bits); |
bita = bit_alloc; |
scfsi=scfsi_buf; |
for (i=sblimit;i;i--) |
if (*bita++) |
*scfsi++ = (char) getbits_fast(2); |
} |
bita = bit_alloc; |
scfsi=scfsi_buf; |
for (i=sblimit2;i;i--) |
if (*bita++) |
switch (*scfsi++) |
{ |
case 0: |
*scale++ = getbits_fast(6); |
*scale++ = getbits_fast(6); |
*scale++ = getbits_fast(6); |
break; |
case 1 : |
*scale++ = sc = getbits_fast(6); |
*scale++ = sc; |
*scale++ = getbits_fast(6); |
break; |
case 2: |
*scale++ = sc = getbits_fast(6); |
*scale++ = sc; |
*scale++ = sc; |
break; |
default: /* case 3 */ |
*scale++ = getbits_fast(6); |
*scale++ = sc = getbits_fast(6); |
*scale++ = sc; |
break; |
} |
} |
void II_step_two(unsigned int *bit_alloc,real fraction[2][4][SBLIMIT],int *scale,struct frame *fr,int x1) |
{ |
int i,j,k,ba; |
int stereo = fr->stereo; |
int sblimit = fr->II_sblimit; |
int jsbound = fr->jsbound; |
struct al_table *alloc2,*alloc1 = fr->alloc; |
unsigned int *bita=bit_alloc; |
int d1,step; |
for (i=0;i<jsbound;i++,alloc1+=(1<<step)) |
{ |
step = alloc1->bits; |
for (j=0;j<stereo;j++) |
{ |
if ( (ba=*bita++) ) |
{ |
k=(alloc2 = alloc1+ba)->bits; |
if( (d1=alloc2->d) < 0) |
{ |
real cm=muls[k][scale[x1]]; |
fraction[j][0][i] = ((real) ((int)getbits(k) + d1)) * cm; |
fraction[j][1][i] = ((real) ((int)getbits(k) + d1)) * cm; |
fraction[j][2][i] = ((real) ((int)getbits(k) + d1)) * cm; |
} |
else |
{ |
static int *table[] = { 0,0,0,grp_3tab,0,grp_5tab,0,0,0,grp_9tab }; |
unsigned int idx,*tab,m=scale[x1]; |
idx = (unsigned int) getbits(k); |
tab = (unsigned int *) (table[d1] + idx + idx + idx); |
fraction[j][0][i] = muls[*tab++][m]; |
fraction[j][1][i] = muls[*tab++][m]; |
fraction[j][2][i] = muls[*tab][m]; |
} |
scale+=3; |
} |
else |
fraction[j][0][i] = fraction[j][1][i] = fraction[j][2][i] = 0.0; |
} |
} |
for (i=jsbound;i<sblimit;i++,alloc1+=(1<<step)) |
{ |
step = alloc1->bits; |
bita++; /* channel 1 and channel 2 bitalloc are the same */ |
if ( (ba=*bita++) ) |
{ |
k=(alloc2 = alloc1+ba)->bits; |
if( (d1=alloc2->d) < 0) |
{ |
real cm; |
cm=muls[k][scale[x1+3]]; |
fraction[1][0][i] = (fraction[0][0][i] = (real) ((int)getbits(k) + d1) ) * cm; |
fraction[1][1][i] = (fraction[0][1][i] = (real) ((int)getbits(k) + d1) ) * cm; |
fraction[1][2][i] = (fraction[0][2][i] = (real) ((int)getbits(k) + d1) ) * cm; |
cm=muls[k][scale[x1]]; |
fraction[0][0][i] *= cm; fraction[0][1][i] *= cm; fraction[0][2][i] *= cm; |
} |
else |
{ |
static int *table[] = { 0,0,0,grp_3tab,0,grp_5tab,0,0,0,grp_9tab }; |
unsigned int idx,*tab,m1,m2; |
m1 = scale[x1]; m2 = scale[x1+3]; |
idx = (unsigned int) getbits(k); |
tab = (unsigned int *) (table[d1] + idx + idx + idx); |
fraction[0][0][i] = muls[*tab][m1]; fraction[1][0][i] = muls[*tab++][m2]; |
fraction[0][1][i] = muls[*tab][m1]; fraction[1][1][i] = muls[*tab++][m2]; |
fraction[0][2][i] = muls[*tab][m1]; fraction[1][2][i] = muls[*tab][m2]; |
} |
scale+=6; |
} |
else { |
fraction[0][0][i] = fraction[0][1][i] = fraction[0][2][i] = |
fraction[1][0][i] = fraction[1][1][i] = fraction[1][2][i] = 0.0; |
} |
/* |
should we use individual scalefac for channel 2 or |
is the current way the right one , where we just copy channel 1 to |
channel 2 ?? |
The current 'strange' thing is, that we throw away the scalefac |
values for the second channel ...!! |
-> changed .. now we use the scalefac values of channel one !! |
*/ |
} |
if(sblimit > (fr->down_sample_sblimit) ) |
sblimit = fr->down_sample_sblimit; |
for(i=sblimit;i<SBLIMIT;i++) |
for (j=0;j<stereo;j++) |
fraction[j][0][i] = fraction[j][1][i] = fraction[j][2][i] = 0.0; |
} |
static void II_select_table(struct frame *fr) |
{ |
static int translate[3][2][16] = |
{ { { 0,2,2,2,2,2,2,0,0,0,1,1,1,1,1,0 } , |
{ 0,2,2,0,0,0,1,1,1,1,1,1,1,1,1,0 } } , |
{ { 0,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0 } , |
{ 0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0 } } , |
{ { 0,3,3,3,3,3,3,0,0,0,1,1,1,1,1,0 } , |
{ 0,3,3,0,0,0,1,1,1,1,1,1,1,1,1,0 } } }; |
int table,sblim; |
static struct al_table *tables[5] = |
{ alloc_0, alloc_1, alloc_2, alloc_3 , alloc_4 }; |
static int sblims[5] = { 27 , 30 , 8, 12 , 30 }; |
if(fr->sampling_frequency >= 3) /* Or equivalent: (fr->lsf == 1) */ |
table = 4; |
else |
table = translate[fr->sampling_frequency][2-fr->stereo][fr->bitrate_index]; |
sblim = sblims[table]; |
fr->alloc = tables[table]; |
fr->II_sblimit = sblim; |
} |
int do_layer2(struct frame *fr,byte *pcm_sample,int *pcm_point) |
{ |
int clip=0; |
int i,j; |
int stereo = fr->stereo; |
real fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */ |
unsigned int bit_alloc[64]; |
int scale[192]; |
int single = fr->single; |
II_select_table(fr); |
fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? |
(fr->mode_ext<<2)+4 : fr->II_sblimit; |
if (fr->jsbound > fr->II_sblimit) { |
fr->jsbound=fr->II_sblimit; |
} |
if(stereo == 1 || single == 3) |
single = 0; |
II_step_one(bit_alloc, scale, fr); |
for (i=0;i<SCALE_BLOCK;i++) |
{ |
II_step_two(bit_alloc,fraction,scale,fr,i>>2); |
for (j=0;j<3;j++) |
{ |
if(single >= 0) |
{ |
clip += (fr->synth_mono) (fraction[single][j],pcm_sample,pcm_point); |
} |
else { |
int p1=*pcm_point; |
clip += (fr->synth) (fraction[0][j],0,pcm_sample, &p1); |
clip += (fr->synth) (fraction[1][j],1,pcm_sample,pcm_point); |
} |
} |
} |
return clip; |
} |
/programs/media/ac97snd/trunk/mpg/layer3.h |
---|
0,0 → 1,17 |
/* |
layer3.h: some functions for interfacing to layer3 (gapless support) |
copyright 2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Thomas Orgis. |
*/ |
/* init part 1; set start/end in samples_*/ |
void layer3_gapless_init(unsigned long b, unsigned long e); |
/* init part 2; transform to byte addresses with new info */ |
void layer3_gapless_bytify(struct frame *fr, struct audio_info_struct *ai); |
/* after some seeking action to a new frame, the decoder needs to know which one is coming next */ |
void layer3_gapless_set_position(unsigned long frames, struct frame* fr, struct audio_info_struct *ai); |
void layer3_gapless_set_ignore(unsigned long frames, struct frame* fr, struct audio_info_struct *ai); |
/* removing the gaps from buffer */ |
void layer3_gapless_buffercheck(); |
/programs/media/ac97snd/trunk/mpg/math_private.h |
---|
0,0 → 1,209 |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* from: @(#)fdlibm.h 5.1 93/09/24 |
* $Id: math_private.h,v 1.8 1998/11/27 11:33:46 drepper Exp $ |
*/ |
#ifndef _MATH_PRIVATE_H_ |
#define _MATH_PRIVATE_H_ |
/* The original fdlibm code used statements like: |
n0 = ((*(int*)&one)>>29)^1; * index of high word * |
ix0 = *(n0+(int*)&x); * high word of x * |
ix1 = *((1-n0)+(int*)&x); * low word of x * |
to dig two 32 bit words out of the 64 bit IEEE floating point |
value. That is non-ANSI, and, moreover, the gcc instruction |
scheduler gets it wrong. We instead use the following macros. |
Unlike the original code, we determine the endianness at compile |
time, not at run time; I don't see much benefit to selecting |
endianness at run time. */ |
/* A union which permits us to convert between a double and two 32 bit |
ints. */ |
typedef int int32_t; |
typedef unsigned int u_int32_t; |
typedef union |
{ |
double value; |
struct |
{ |
u_int32_t lsw; |
u_int32_t msw; |
} parts; |
} ieee_double_shape_type; |
/* Get two 32 bit ints from a double. */ |
#define EXTRACT_WORDS(ix0,ix1,d) \ |
do { \ |
ieee_double_shape_type ew_u; \ |
ew_u.value = (d); \ |
(ix0) = ew_u.parts.msw; \ |
(ix1) = ew_u.parts.lsw; \ |
} while (0) |
/* Get the more significant 32 bit int from a double. */ |
#define GET_HIGH_WORD(i,d) \ |
do { \ |
ieee_double_shape_type gh_u; \ |
gh_u.value = (d); \ |
(i) = gh_u.parts.msw; \ |
} while (0) |
/* Get the less significant 32 bit int from a double. */ |
#define GET_LOW_WORD(i,d) \ |
do { \ |
ieee_double_shape_type gl_u; \ |
gl_u.value = (d); \ |
(i) = gl_u.parts.lsw; \ |
} while (0) |
/* Set a double from two 32 bit ints. */ |
#define INSERT_WORDS(d,ix0,ix1) \ |
do { \ |
ieee_double_shape_type iw_u; \ |
iw_u.parts.msw = (ix0); \ |
iw_u.parts.lsw = (ix1); \ |
(d) = iw_u.value; \ |
} while (0) |
/* Set the more significant 32 bits of a double from an int. */ |
#define SET_HIGH_WORD(d,v) \ |
do { \ |
ieee_double_shape_type sh_u; \ |
sh_u.value = (d); \ |
sh_u.parts.msw = (v); \ |
(d) = sh_u.value; \ |
} while (0) |
/* Set the less significant 32 bits of a double from an int. */ |
#define SET_LOW_WORD(d,v) \ |
do { \ |
ieee_double_shape_type sl_u; \ |
sl_u.value = (d); \ |
sl_u.parts.lsw = (v); \ |
(d) = sl_u.value; \ |
} while (0) |
/* A union which permits us to convert between a float and a 32 bit |
int. */ |
typedef union |
{ |
float value; |
u_int32_t word; |
} ieee_float_shape_type; |
/* Get a 32 bit int from a float. */ |
#define GET_FLOAT_WORD(i,d) \ |
do { \ |
ieee_float_shape_type gf_u; \ |
gf_u.value = (d); \ |
(i) = gf_u.word; \ |
} while (0) |
/* Set a float from a 32 bit int. */ |
#define SET_FLOAT_WORD(d,i) \ |
do { \ |
ieee_float_shape_type sf_u; \ |
sf_u.word = (i); \ |
(d) = sf_u.value; \ |
} while (0) |
/* A union which permits us to convert between a long double and |
three 32 bit ints. */ |
typedef union |
{ |
long double value; |
struct |
{ |
u_int32_t lsw; |
u_int32_t msw; |
unsigned int sign_exponent:16; |
unsigned int empty:16; |
} parts; |
} ieee_long_double_shape_type; |
/* Get three 32 bit ints from a double. */ |
#define GET_LDOUBLE_WORDS(exp,ix0,ix1,d) \ |
do { \ |
ieee_long_double_shape_type ew_u; \ |
ew_u.value = (d); \ |
(exp) = ew_u.parts.sign_exponent; \ |
(ix0) = ew_u.parts.msw; \ |
(ix1) = ew_u.parts.lsw; \ |
} while (0) |
/* Set a double from two 32 bit ints. */ |
#define SET_LDOUBLE_WORDS(d,exp,ix0,ix1) \ |
do { \ |
ieee_long_double_shape_type iw_u; \ |
iw_u.parts.sign_exponent = (exp); \ |
iw_u.parts.msw = (ix0); \ |
iw_u.parts.lsw = (ix1); \ |
(d) = iw_u.value; \ |
} while (0) |
/* Get the more significant 32 bits of a long double mantissa. */ |
#define GET_LDOUBLE_MSW(v,d) \ |
do { \ |
ieee_long_double_shape_type sh_u; \ |
sh_u.value = (d); \ |
(v) = sh_u.parts.msw; \ |
} while (0) |
/* Set the more significant 32 bits of a long double mantissa from an int. */ |
#define SET_LDOUBLE_MSW(d,v) \ |
do { \ |
ieee_long_double_shape_type sh_u; \ |
sh_u.value = (d); \ |
sh_u.parts.msw = (v); \ |
(d) = sh_u.value; \ |
} while (0) |
/* Get int from the exponent of a long double. */ |
#define GET_LDOUBLE_EXP(exp,d) \ |
do { \ |
ieee_long_double_shape_type ge_u; \ |
ge_u.value = (d); \ |
(exp) = ge_u.parts.sign_exponent; \ |
} while (0) |
/* Set exponent of a long double from an int. */ |
#define SET_LDOUBLE_EXP(d,exp) \ |
do { \ |
ieee_long_double_shape_type se_u; \ |
se_u.value = (d); \ |
se_u.parts.sign_exponent = (exp); \ |
(d) = se_u.value; \ |
} while (0) |
#endif /* _MATH_PRIVATE_H_ */ |
/programs/media/ac97snd/trunk/mpg/mpg.vcproj |
---|
0,0 → 1,365 |
<?xml version="1.0" encoding="windows-1251"?> |
<VisualStudioProject |
ProjectType="Visual C++" |
Version="8,00" |
Name="mpg" |
ProjectGUID="{CF807B93-2860-41DF-A4D2-5B92B52DFD96}" |
RootNamespace="mpg" |
Keyword="Win32Proj" |
> |
<Platforms> |
<Platform |
Name="Win32" |
/> |
</Platforms> |
<ToolFiles> |
</ToolFiles> |
<Configurations> |
<Configuration |
Name="Debug|Win32" |
OutputDirectory="$(SolutionDir)$(ConfigurationName)" |
IntermediateDirectory="$(ConfigurationName)" |
ConfigurationType="4" |
CharacterSet="1" |
> |
<Tool |
Name="VCPreBuildEventTool" |
/> |
<Tool |
Name="VCCustomBuildTool" |
/> |
<Tool |
Name="VCXMLDataGeneratorTool" |
/> |
<Tool |
Name="VCWebServiceProxyGeneratorTool" |
/> |
<Tool |
Name="VCMIDLTool" |
/> |
<Tool |
Name="VCCLCompilerTool" |
Optimization="0" |
PreprocessorDefinitions="WIN32;_DEBUG;_LIB" |
MinimalRebuild="true" |
BasicRuntimeChecks="3" |
RuntimeLibrary="3" |
UsePrecompiledHeader="0" |
WarningLevel="3" |
Detect64BitPortabilityProblems="true" |
DebugInformationFormat="4" |
/> |
<Tool |
Name="VCManagedResourceCompilerTool" |
/> |
<Tool |
Name="VCResourceCompilerTool" |
/> |
<Tool |
Name="VCPreLinkEventTool" |
/> |
<Tool |
Name="VCLibrarianTool" |
/> |
<Tool |
Name="VCALinkTool" |
/> |
<Tool |
Name="VCXDCMakeTool" |
/> |
<Tool |
Name="VCBscMakeTool" |
/> |
<Tool |
Name="VCFxCopTool" |
/> |
<Tool |
Name="VCPostBuildEventTool" |
/> |
</Configuration> |
<Configuration |
Name="Release|Win32" |
OutputDirectory="$(SolutionDir)$(ConfigurationName)" |
IntermediateDirectory="$(ConfigurationName)" |
ConfigurationType="4" |
CharacterSet="1" |
WholeProgramOptimization="1" |
> |
<Tool |
Name="VCPreBuildEventTool" |
/> |
<Tool |
Name="VCCustomBuildTool" |
/> |
<Tool |
Name="VCXMLDataGeneratorTool" |
/> |
<Tool |
Name="VCWebServiceProxyGeneratorTool" |
/> |
<Tool |
Name="VCMIDLTool" |
/> |
<Tool |
Name="VCCLCompilerTool" |
Optimization="3" |
InlineFunctionExpansion="1" |
EnableIntrinsicFunctions="true" |
FavorSizeOrSpeed="2" |
OmitFramePointers="true" |
PreprocessorDefinitions="WIN32;NDEBUG;_LIB" |
ExceptionHandling="0" |
RuntimeLibrary="0" |
StructMemberAlignment="1" |
BufferSecurityCheck="false" |
FloatingPointModel="2" |
UsePrecompiledHeader="0" |
AssemblerOutput="0" |
WarningLevel="3" |
Detect64BitPortabilityProblems="true" |
DebugInformationFormat="3" |
/> |
<Tool |
Name="VCManagedResourceCompilerTool" |
/> |
<Tool |
Name="VCResourceCompilerTool" |
/> |
<Tool |
Name="VCPreLinkEventTool" |
/> |
<Tool |
Name="VCLibrarianTool" |
/> |
<Tool |
Name="VCALinkTool" |
/> |
<Tool |
Name="VCXDCMakeTool" |
/> |
<Tool |
Name="VCBscMakeTool" |
/> |
<Tool |
Name="VCFxCopTool" |
/> |
<Tool |
Name="VCPostBuildEventTool" |
/> |
</Configuration> |
</Configurations> |
<References> |
</References> |
<Files> |
<Filter |
Name="Source Files" |
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" |
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" |
> |
<File |
RelativePath=".\dct64_i386.c" |
> |
<FileConfiguration |
Name="Release|Win32" |
> |
<Tool |
Name="VCCLCompilerTool" |
ExpandAttributedSource="false" |
AssemblerOutput="4" |
/> |
</FileConfiguration> |
</File> |
<File |
RelativePath=".\dct64_i486.c" |
> |
<FileConfiguration |
Name="Release|Win32" |
ExcludedFromBuild="true" |
> |
<Tool |
Name="VCCLCompilerTool" |
/> |
</FileConfiguration> |
</File> |
<File |
RelativePath=".\decode_2to1.c" |
> |
<FileConfiguration |
Name="Debug|Win32" |
ExcludedFromBuild="true" |
> |
<Tool |
Name="VCCLCompilerTool" |
/> |
</FileConfiguration> |
<FileConfiguration |
Name="Release|Win32" |
ExcludedFromBuild="true" |
> |
<Tool |
Name="VCCLCompilerTool" |
/> |
</FileConfiguration> |
</File> |
<File |
RelativePath=".\decode_4to1.c" |
> |
<FileConfiguration |
Name="Debug|Win32" |
ExcludedFromBuild="true" |
> |
<Tool |
Name="VCCLCompilerTool" |
/> |
</FileConfiguration> |
<FileConfiguration |
Name="Release|Win32" |
ExcludedFromBuild="true" |
> |
<Tool |
Name="VCCLCompilerTool" |
/> |
</FileConfiguration> |
</File> |
<File |
RelativePath=".\decode_i386.c" |
> |
</File> |
<File |
RelativePath=".\decode_i486.c" |
> |
<FileConfiguration |
Name="Release|Win32" |
ExcludedFromBuild="true" |
> |
<Tool |
Name="VCCLCompilerTool" |
/> |
</FileConfiguration> |
</File> |
<File |
RelativePath=".\decode_ntom.c" |
> |
<FileConfiguration |
Name="Debug|Win32" |
ExcludedFromBuild="true" |
> |
<Tool |
Name="VCCLCompilerTool" |
/> |
</FileConfiguration> |
<FileConfiguration |
Name="Release|Win32" |
ExcludedFromBuild="true" |
> |
<Tool |
Name="VCCLCompilerTool" |
/> |
</FileConfiguration> |
</File> |
<File |
RelativePath=".\e_pow.c" |
> |
</File> |
<File |
RelativePath=".\getbits.c" |
> |
</File> |
<File |
RelativePath=".\layer1.c" |
> |
</File> |
<File |
RelativePath=".\layer2.c" |
> |
</File> |
<File |
RelativePath=".\layer3.c" |
> |
<FileConfiguration |
Name="Release|Win32" |
> |
<Tool |
Name="VCCLCompilerTool" |
ExpandAttributedSource="true" |
AssemblerOutput="4" |
AssemblerListingLocation="$(IntDir)\" |
/> |
</FileConfiguration> |
</File> |
<File |
RelativePath=".\pow.asm" |
> |
<FileConfiguration |
Name="Release|Win32" |
> |
<Tool |
Name="VCCustomBuildTool" |
CommandLine="e:\fasm\fasm.exe $(InputPath) $(TargetDir)\$(InputName).obj
" |
Outputs="$(OutDir)\$(InputName).obj" |
/> |
</FileConfiguration> |
</File> |
<File |
RelativePath=".\readers.c" |
> |
<FileConfiguration |
Name="Release|Win32" |
> |
<Tool |
Name="VCCLCompilerTool" |
ExpandAttributedSource="false" |
AssemblerOutput="4" |
/> |
</FileConfiguration> |
</File> |
<File |
RelativePath=".\tabinit.c" |
> |
</File> |
</Filter> |
<Filter |
Name="Header Files" |
Filter="h;hpp;hxx;hm;inl;inc;xsd" |
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" |
> |
<File |
RelativePath=".\getbits.h" |
> |
</File> |
<File |
RelativePath=".\huffman.h" |
> |
</File> |
<File |
RelativePath=".\l2tables.h" |
> |
</File> |
<File |
RelativePath=".\layer3.h" |
> |
</File> |
<File |
RelativePath=".\mpg123.h" |
> |
</File> |
</Filter> |
<Filter |
Name="Resource Files" |
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" |
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" |
> |
<File |
RelativePath="E:\arrow.cur" |
FileType="32" |
> |
</File> |
</Filter> |
<File |
RelativePath=".\ReadMe.txt" |
> |
</File> |
</Files> |
<Globals> |
</Globals> |
</VisualStudioProject> |
/programs/media/ac97snd/trunk/mpg/tabinit.c |
---|
0,0 → 1,159 |
/* |
tabinit.c: initialize tables... |
copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1 |
see COPYING and AUTHORS files in distribution or http://mpg123.de |
initially written by Michael Hipp |
*/ |
//#include <stdlib.h> |
//#include "config.h" |
#include "mpg123.h" |
//#include "debug.h" |
static unsigned char *conv16to8_buf = NULL; |
unsigned char *conv16to8; |
#ifndef USE_MMX |
real decwin[512+32]; |
#ifdef USE_ALTIVEC |
static real __attribute__ ((aligned (16))) cos64[16]; |
static real __attribute__ ((aligned (16))) cos32[8]; |
static real __attribute__ ((aligned (16))) cos16[4]; |
static real __attribute__ ((aligned (16))) cos8[2]; |
static real __attribute__ ((aligned (16))) cos4[1]; |
#else |
static real cos64[16],cos32[8],cos16[4],cos8[2],cos4[1]; |
#endif |
real *pnts[] = { cos64,cos32,cos16,cos8,cos4 }; |
static long intwinbase[] = { |
0, -1, -1, -1, -1, -1, -1, -2, -2, -2, |
-2, -3, -3, -4, -4, -5, -5, -6, -7, -7, |
-8, -9, -10, -11, -13, -14, -16, -17, -19, -21, |
-24, -26, -29, -31, -35, -38, -41, -45, -49, -53, |
-58, -63, -68, -73, -79, -85, -91, -97, -104, -111, |
-117, -125, -132, -139, -147, -154, -161, -169, -176, -183, |
-190, -196, -202, -208, -213, -218, -222, -225, -227, -228, |
-228, -227, -224, -221, -215, -208, -200, -189, -177, -163, |
-146, -127, -106, -83, -57, -29, 2, 36, 72, 111, |
153, 197, 244, 294, 347, 401, 459, 519, 581, 645, |
711, 779, 848, 919, 991, 1064, 1137, 1210, 1283, 1356, |
1428, 1498, 1567, 1634, 1698, 1759, 1817, 1870, 1919, 1962, |
2001, 2032, 2057, 2075, 2085, 2087, 2080, 2063, 2037, 2000, |
1952, 1893, 1822, 1739, 1644, 1535, 1414, 1280, 1131, 970, |
794, 605, 402, 185, -45, -288, -545, -814, -1095, -1388, |
-1692, -2006, -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788, |
-5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597, -7910, -8209, |
-8491, -8755, -8998, -9219, -9416, -9585, -9727, -9838, -9916, -9959, |
-9966, -9935, -9863, -9750, -9592, -9389, -9139, -8840, -8492, -8092, |
-7640, -7134, -6574, -5959, -5288, -4561, -3776, -2935, -2037, -1082, |
-70, 998, 2122, 3300, 4533, 5818, 7154, 8540, 9975, 11455, |
12980, 14548, 16155, 17799, 19478, 21189, 22929, 24694, 26482, 28289, |
30112, 31947, 33791, 35640, 37489, 39336, 41176, 43006, 44821, 46617, |
48390, 50137, 51853, 53534, 55178, 56778, 58333, 59838, 61289, 62684, |
64019, 65290, 66494, 67629, 68692, 69679, 70590, 71420, 72169, 72835, |
73415, 73908, 74313, 74630, 74856, 74992, 75038 }; |
#pragma warning(disable:4244) |
void make_decode_tables(long scaleval) |
{ |
int i,j,k,kr,divv; |
real *costab; |
int idx; |
for(i=0;i<5;i++) |
{ |
kr=0x10>>i; divv=0x40>>i; |
costab = pnts[i]; |
for(k=0;k<kr;k++) |
costab[k] = DOUBLE_TO_REAL(1.0 / (2.0 * cos(M_PI * ((double) k * 2.0 + 1.0) / (double) divv))); |
} |
idx = 0; |
scaleval = -scaleval; |
for(i=0,j=0;i<256;i++,j++,idx+=32) |
{ |
if(idx < 512+16) |
decwin[idx+16] = decwin[idx] = DOUBLE_TO_REAL((double) intwinbase[j] / 65536.0 * (double) scaleval); |
if(i % 32 == 31) |
idx -= 1023; |
if(i % 64 == 63) |
scaleval = - scaleval; |
} |
for( /* i=256 */ ;i<512;i++,j--,idx+=32) |
{ |
if(idx < 512+16) |
decwin[idx+16] = decwin[idx] = DOUBLE_TO_REAL((double) intwinbase[j] / 65536.0 * (double) scaleval); |
if(i % 32 == 31) |
idx -= 1023; |
if(i % 64 == 63) |
scaleval = - scaleval; |
} |
} |
#endif |
#if 0 |
int make_conv16to8_table(int mode) |
{ |
int i; |
/* |
* ????: 8.0 is right but on SB cards '2.0' is a better value ??? |
*/ |
const double mul = 8.0; |
if(!conv16to8_buf) { |
conv16to8_buf = (unsigned char *) malloc(8192); |
if(!conv16to8_buf) { |
error("Can't allocate 16 to 8 converter table!"); |
return -1; |
} |
conv16to8 = conv16to8_buf + 4096; |
} |
if(mode == AUDIO_FORMAT_ULAW_8) { |
double m=127.0 / log(256.0); |
int c1; |
for(i=-4096;i<4096;i++) { |
/* dunno whether this is a valid transformation rule ?!?!? */ |
if(i < 0) |
c1 = 127 - (int) (log( 1.0 - 255.0 * (double) i*mul / 32768.0 ) * m); |
else |
c1 = 255 - (int) (log( 1.0 + 255.0 * (double) i*mul / 32768.0 ) * m); |
if(c1 < 0 || c1 > 255) |
fprintf(stderr,"Converror %d %d\n",i,c1); |
if(c1 == 0) |
c1 = 2; |
conv16to8[i] = (unsigned char) c1; |
} |
} |
else if(mode == AUDIO_FORMAT_SIGNED_8) { |
for(i=-4096;i<4096;i++) { |
conv16to8[i] = i>>5; |
} |
} |
else if(mode == AUDIO_FORMAT_UNSIGNED_8) { |
for(i=-4096;i<4096;i++) { |
conv16to8[i] = (i>>5)+128; |
} |
} |
else { |
for(i=-4096;i<4096;i++) { |
conv16to8[i] = 0; |
} |
} |
return 0; |
} |
#endif |
/programs/media/ac97snd/trunk/crt.c |
---|
0,0 → 1,74 |
#include "crt.h" |
#define atexitBufferSize 32 |
char pureCallMessage[] = "PURE function call!"; |
char *__argv[2]; |
int __argc; |
void (__cdecl *atExitList[atexitBufferSize])(); |
int atExitFnNum = 0; |
int main(int argc, char *argv[]); |
void exit() |
{ int i; |
for ( i = atExitFnNum - 1; i >= 0; i-- ) |
atExitList[i](); |
__asm |
{ |
mov eax, -1 |
int 0x40 |
}; |
}; |
int __cdecl atexit( void (__cdecl *func )( void )) |
{ |
// |
if ( atExitFnNum < atexitBufferSize ) |
{ |
// |
atExitList[atExitFnNum++] = func; |
return 0; |
} |
else |
{ |
return 1; |
} |
} |
int __cdecl _purecall() |
{ |
exit(); |
return 0; |
} |
#pragma section(".CRT$XCA",long,read,write) |
#pragma section(".CRT$XCZ",long,read,write) |
typedef void (__cdecl *_PVFV)(void); |
__declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { 0 }; |
__declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { 0 }; |
// |
#pragma comment(linker, "/merge:.CRT=.rdata") |
// |
void crtStartUp() |
{_PVFV *pbegin; |
_asm {fninit}; |
for ( pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) |
{ |
// |
if ( *pbegin != 0 ) |
(**pbegin)(); |
} |
__argc = 2; |
__argv[0] = *((char **)0x20); |
__argv[1] = *((char **)0x1C); |
main(__argc, __argv); |
exit(); |
} |
/programs/media/ac97snd/trunk/PROC32.INC |
---|
0,0 → 1,268 |
; Macroinstructions for defining and calling procedures |
macro stdcall proc,[arg] ; directly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call proc } |
macro invoke proc,[arg] ; indirectly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call [proc] } |
macro ccall proc,[arg] ; directly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call proc |
if size@ccall |
add esp,size@ccall |
end if } |
macro cinvoke proc,[arg] ; indirectly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call [proc] |
if size@ccall |
add esp,size@ccall |
end if } |
macro proc [args] ; define procedure |
{ common |
match name params, args> |
\{ define@proc name,<params \} } |
prologue@proc equ prologuedef |
macro prologuedef procname,flag,parmbytes,localbytes,reglist |
{ if parmbytes | localbytes |
push ebp |
mov ebp,esp |
if localbytes |
sub esp,localbytes |
end if |
end if |
irps reg, reglist \{ push reg \} } |
epilogue@proc equ epiloguedef |
macro epiloguedef procname,flag,parmbytes,localbytes,reglist |
{ irps reg, reglist \{ reverse pop reg \} |
if parmbytes | localbytes |
leave |
end if |
if flag and 10000b |
retn |
else |
retn parmbytes |
end if } |
macro define@proc name,statement |
{ local params,flag,regs,parmbytes,localbytes,current |
if used name |
name: |
match =stdcall args, statement \{ params equ args |
flag = 11b \} |
match =stdcall, statement \{ params equ |
flag = 11b \} |
match =c args, statement \{ params equ args |
flag = 10001b \} |
match =c, statement \{ params equ |
flag = 10001b \} |
match =params, params \{ params equ statement |
flag = 0 \} |
virtual at ebp+8 |
match =uses reglist=,args, params \{ regs equ reglist |
params equ args \} |
match =regs =uses reglist, regs params \{ regs equ reglist |
params equ \} |
match =regs, regs \{ regs equ \} |
match =,args, params \{ defargs@proc args \} |
match =args@proc args, args@proc params \{ defargs@proc args \} |
parmbytes = $ - (ebp+8) |
end virtual |
name # % = parmbytes/4 |
all@vars equ |
current = 0 |
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \} |
macro locals |
\{ virtual at ebp-localbytes+current |
macro label . \\{ deflocal@proc .,:, \\} |
struc db [val] \\{ \common deflocal@proc .,db,val \\} |
struc dw [val] \\{ \common deflocal@proc .,dw,val \\} |
struc dp [val] \\{ \common deflocal@proc .,dp,val \\} |
struc dd [val] \\{ \common deflocal@proc .,dd,val \\} |
struc dt [val] \\{ \common deflocal@proc .,dt,val \\} |
struc dq [val] \\{ \common deflocal@proc .,dq,val \\} |
struc rb cnt \\{ deflocal@proc .,rb cnt, \\} |
struc rw cnt \\{ deflocal@proc .,rw cnt, \\} |
struc rp cnt \\{ deflocal@proc .,rp cnt, \\} |
struc rd cnt \\{ deflocal@proc .,rd cnt, \\} |
struc rt cnt \\{ deflocal@proc .,rt cnt, \\} |
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} |
macro endl |
\{ purge label |
restruc db,dw,dp,dd,dt,dq |
restruc rb,rw,rp,rd,rt,rq |
restruc byte,word,dword,pword,tword,qword |
current = $-(ebp-localbytes) |
end virtual \} |
macro ret operand |
\{ match any, operand \\{ retn operand \\} |
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs> |
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} |
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2 |
end if \} } |
macro defargs@proc [arg] |
{ common |
if ~ arg eq |
forward |
local ..arg,current@arg |
match argname:type, arg |
\{ current@arg equ argname |
label ..arg type |
argname equ ..arg |
if dqword eq type |
dd ?,?,?,? |
else if tbyte eq type |
dd ?,?,? |
else if qword eq type | pword eq type |
dd ?,? |
else |
dd ? |
end if \} |
match =current@arg,current@arg |
\{ current@arg equ arg |
arg equ ..arg |
..arg dd ? \} |
common |
args@proc equ current@arg |
forward |
restore current@arg |
common |
end if } |
macro deflocal@proc name,def,[val] |
{ common |
match vars, all@vars \{ all@vars equ all@vars, \} |
all@vars equ all@vars name |
forward |
local ..var,..tmp |
..var def val |
match =?, val \{ ..tmp equ \} |
match any =dup (=?), val \{ ..tmp equ \} |
match tmp : value, ..tmp : val |
\{ tmp: end virtual |
initlocal@proc ..var,def value |
virtual at tmp\} |
common |
match first rest, ..var, \{ name equ first \} } |
macro initlocal@proc name,def |
{ virtual at name |
def |
size@initlocal = $ - name |
end virtual |
position@initlocal = 0 |
while size@initlocal > position@initlocal |
virtual at name |
def |
if size@initlocal - position@initlocal < 2 |
current@initlocal = 1 |
load byte@initlocal byte from name+position@initlocal |
else if size@initlocal - position@initlocal < 4 |
current@initlocal = 2 |
load word@initlocal word from name+position@initlocal |
else |
current@initlocal = 4 |
load dword@initlocal dword from name+position@initlocal |
end if |
end virtual |
if current@initlocal = 1 |
mov byte [name+position@initlocal],byte@initlocal |
else if current@initlocal = 2 |
mov word [name+position@initlocal],word@initlocal |
else |
mov dword [name+position@initlocal],dword@initlocal |
end if |
position@initlocal = position@initlocal + current@initlocal |
end while } |
macro endp |
{ purge ret,locals,endl |
finish@proc |
purge finish@proc |
restore regs@proc |
match all,args@proc \{ restore all \} |
restore args@proc |
match all,all@vars \{ restore all \} } |
macro local [var] |
{ common |
locals |
forward done@local equ |
match varname[count]:vartype, var |
\{ match =BYTE, vartype \\{ varname rb count |
restore done@local \\} |
match =WORD, vartype \\{ varname rw count |
restore done@local \\} |
match =DWORD, vartype \\{ varname rd count |
restore done@local \\} |
match =PWORD, vartype \\{ varname rp count |
restore done@local \\} |
match =QWORD, vartype \\{ varname rq count |
restore done@local \\} |
match =TBYTE, vartype \\{ varname rt count |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
rq count+count |
restore done@local \\} |
match , done@local \\{ virtual |
varname vartype |
end virtual |
rb count*sizeof.\#vartype |
restore done@local \\} \} |
match :varname:vartype, done@local:var |
\{ match =BYTE, vartype \\{ varname db ? |
restore done@local \\} |
match =WORD, vartype \\{ varname dw ? |
restore done@local \\} |
match =DWORD, vartype \\{ varname dd ? |
restore done@local \\} |
match =PWORD, vartype \\{ varname dp ? |
restore done@local \\} |
match =QWORD, vartype \\{ varname dq ? |
restore done@local \\} |
match =TBYTE, vartype \\{ varname dt ? |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
dq ?,? |
restore done@local \\} |
match , done@local \\{ varname vartype |
restore done@local \\} \} |
match ,done@local |
\{ var |
restore done@local \} |
common |
endl } |
/programs/media/ac97snd/trunk/mp3dec/PROC32.INC |
---|
0,0 → 1,268 |
; Macroinstructions for defining and calling procedures |
macro stdcall proc,[arg] ; directly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call proc } |
macro invoke proc,[arg] ; indirectly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call [proc] } |
macro ccall proc,[arg] ; directly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call proc |
if size@ccall |
add esp,size@ccall |
end if } |
macro cinvoke proc,[arg] ; indirectly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call [proc] |
if size@ccall |
add esp,size@ccall |
end if } |
macro proc [args] ; define procedure |
{ common |
match name params, args> |
\{ define@proc name,<params \} } |
prologue@proc equ prologuedef |
macro prologuedef procname,flag,parmbytes,localbytes,reglist |
{ if parmbytes | localbytes |
push ebp |
mov ebp,esp |
if localbytes |
sub esp,localbytes |
end if |
end if |
irps reg, reglist \{ push reg \} } |
epilogue@proc equ epiloguedef |
macro epiloguedef procname,flag,parmbytes,localbytes,reglist |
{ irps reg, reglist \{ reverse pop reg \} |
if parmbytes | localbytes |
leave |
end if |
if flag and 10000b |
retn |
else |
retn parmbytes |
end if } |
macro define@proc name,statement |
{ local params,flag,regs,parmbytes,localbytes,current |
if used name |
name: |
match =stdcall args, statement \{ params equ args |
flag = 11b \} |
match =stdcall, statement \{ params equ |
flag = 11b \} |
match =c args, statement \{ params equ args |
flag = 10001b \} |
match =c, statement \{ params equ |
flag = 10001b \} |
match =params, params \{ params equ statement |
flag = 0 \} |
virtual at ebp+8 |
match =uses reglist=,args, params \{ regs equ reglist |
params equ args \} |
match =regs =uses reglist, regs params \{ regs equ reglist |
params equ \} |
match =regs, regs \{ regs equ \} |
match =,args, params \{ defargs@proc args \} |
match =args@proc args, args@proc params \{ defargs@proc args \} |
parmbytes = $ - (ebp+8) |
end virtual |
name # % = parmbytes/4 |
all@vars equ |
current = 0 |
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \} |
macro locals |
\{ virtual at ebp-localbytes+current |
macro label . \\{ deflocal@proc .,:, \\} |
struc db [val] \\{ \common deflocal@proc .,db,val \\} |
struc dw [val] \\{ \common deflocal@proc .,dw,val \\} |
struc dp [val] \\{ \common deflocal@proc .,dp,val \\} |
struc dd [val] \\{ \common deflocal@proc .,dd,val \\} |
struc dt [val] \\{ \common deflocal@proc .,dt,val \\} |
struc dq [val] \\{ \common deflocal@proc .,dq,val \\} |
struc rb cnt \\{ deflocal@proc .,rb cnt, \\} |
struc rw cnt \\{ deflocal@proc .,rw cnt, \\} |
struc rp cnt \\{ deflocal@proc .,rp cnt, \\} |
struc rd cnt \\{ deflocal@proc .,rd cnt, \\} |
struc rt cnt \\{ deflocal@proc .,rt cnt, \\} |
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} |
macro endl |
\{ purge label |
restruc db,dw,dp,dd,dt,dq |
restruc rb,rw,rp,rd,rt,rq |
restruc byte,word,dword,pword,tword,qword |
current = $-(ebp-localbytes) |
end virtual \} |
macro ret operand |
\{ match any, operand \\{ retn operand \\} |
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs> |
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} |
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2 |
end if \} } |
macro defargs@proc [arg] |
{ common |
if ~ arg eq |
forward |
local ..arg,current@arg |
match argname:type, arg |
\{ current@arg equ argname |
label ..arg type |
argname equ ..arg |
if dqword eq type |
dd ?,?,?,? |
else if tbyte eq type |
dd ?,?,? |
else if qword eq type | pword eq type |
dd ?,? |
else |
dd ? |
end if \} |
match =current@arg,current@arg |
\{ current@arg equ arg |
arg equ ..arg |
..arg dd ? \} |
common |
args@proc equ current@arg |
forward |
restore current@arg |
common |
end if } |
macro deflocal@proc name,def,[val] |
{ common |
match vars, all@vars \{ all@vars equ all@vars, \} |
all@vars equ all@vars name |
forward |
local ..var,..tmp |
..var def val |
match =?, val \{ ..tmp equ \} |
match any =dup (=?), val \{ ..tmp equ \} |
match tmp : value, ..tmp : val |
\{ tmp: end virtual |
initlocal@proc ..var,def value |
virtual at tmp\} |
common |
match first rest, ..var, \{ name equ first \} } |
macro initlocal@proc name,def |
{ virtual at name |
def |
size@initlocal = $ - name |
end virtual |
position@initlocal = 0 |
while size@initlocal > position@initlocal |
virtual at name |
def |
if size@initlocal - position@initlocal < 2 |
current@initlocal = 1 |
load byte@initlocal byte from name+position@initlocal |
else if size@initlocal - position@initlocal < 4 |
current@initlocal = 2 |
load word@initlocal word from name+position@initlocal |
else |
current@initlocal = 4 |
load dword@initlocal dword from name+position@initlocal |
end if |
end virtual |
if current@initlocal = 1 |
mov byte [name+position@initlocal],byte@initlocal |
else if current@initlocal = 2 |
mov word [name+position@initlocal],word@initlocal |
else |
mov dword [name+position@initlocal],dword@initlocal |
end if |
position@initlocal = position@initlocal + current@initlocal |
end while } |
macro endp |
{ purge ret,locals,endl |
finish@proc |
purge finish@proc |
restore regs@proc |
match all,args@proc \{ restore all \} |
restore args@proc |
match all,all@vars \{ restore all \} } |
macro local [var] |
{ common |
locals |
forward done@local equ |
match varname[count]:vartype, var |
\{ match =BYTE, vartype \\{ varname rb count |
restore done@local \\} |
match =WORD, vartype \\{ varname rw count |
restore done@local \\} |
match =DWORD, vartype \\{ varname rd count |
restore done@local \\} |
match =PWORD, vartype \\{ varname rp count |
restore done@local \\} |
match =QWORD, vartype \\{ varname rq count |
restore done@local \\} |
match =TBYTE, vartype \\{ varname rt count |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
rq count+count |
restore done@local \\} |
match , done@local \\{ virtual |
varname vartype |
end virtual |
rb count*sizeof.\#vartype |
restore done@local \\} \} |
match :varname:vartype, done@local:var |
\{ match =BYTE, vartype \\{ varname db ? |
restore done@local \\} |
match =WORD, vartype \\{ varname dw ? |
restore done@local \\} |
match =DWORD, vartype \\{ varname dd ? |
restore done@local \\} |
match =PWORD, vartype \\{ varname dp ? |
restore done@local \\} |
match =QWORD, vartype \\{ varname dq ? |
restore done@local \\} |
match =TBYTE, vartype \\{ varname dt ? |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
dq ?,? |
restore done@local \\} |
match , done@local \\{ varname vartype |
restore done@local \\} \} |
match ,done@local |
\{ var |
restore done@local \} |
common |
endl } |
/programs/media/ac97snd/trunk/mp3dec/bstream.c |
---|
0,0 → 1,212 |
/* max bits required for any lookup - change if htable changes */ |
/* quad required 10 bit w/signs must have (MAXBITS+2) >= 10 */ |
#define MAXBITS 9 |
static unsigned int bitbuf; |
static int bits; |
static unsigned char *bs_ptr; |
static unsigned char *bs_ptr0; |
static unsigned char *bs_ptr_end; // optional for overrun test |
void bitget_init(unsigned char *buf) |
{ |
bs_ptr0 = bs_ptr = buf; |
bits = 0; |
bitbuf = 0; |
} |
int bitget(int n) |
{ |
unsigned int x; |
if (bits < n) |
{ /* refill bit buf if necessary */ |
while (bits <= 24) |
{ |
bitbuf = (bitbuf << 8) | *bs_ptr++; |
bits += 8; |
} |
} |
bits -= n; |
x = bitbuf >> bits; |
bitbuf -= x << bits; |
return x; |
} |
void bitget_skip(int n) |
{ |
unsigned int k; |
if (bits < n) |
{ |
n -= bits; |
k = n >> 3; |
/*--- bytes = n/8 --*/ |
bs_ptr += k; |
n -= k << 3; |
bitbuf = *bs_ptr++; |
bits = 8; |
} |
bits -= n; |
bitbuf -= (bitbuf >> bits) << bits; |
} |
void bitget_init_end(unsigned char *buf_end) |
{ |
bs_ptr_end = buf_end; |
} |
/*------------- check overrun -------------*/ |
int bitget_overrun() |
{ |
return bs_ptr > bs_ptr_end; |
} |
/*------------- get n bits from bitstream -------------*/ |
int bitget_bits_used() |
{ |
unsigned int n; /* compute bits used from last init call */ |
n = ((bs_ptr - bs_ptr0) << 3) - bits; |
return n; |
} |
/*------------- check for n bits in bitbuf -------------*/ |
void bitget_check(int n) |
{ |
if (bits < n) |
{ |
while (bits <= 24) |
{ |
bitbuf = (bitbuf << 8) | *bs_ptr++; |
bits += 8; |
} |
} |
} |
#if 0 |
/*------------- get 1 bit from bitstream -------------*/ |
int bitget_1bit() |
{ |
unsigned int x; |
if (bits <= 0) |
{ /* refill bit buf if necessary */ |
while (bits <= 24) |
{ |
bitbuf = (bitbuf << 8) | *bs_ptr++; |
bits += 8; |
} |
} |
bits--; |
x = bitbuf >> bits; |
bitbuf -= x << bits; |
return x; |
} |
/*------------- get 1 bit from bitstream NO CHECK -------------*/ |
int bitget_1bit() |
{ |
unsigned int x; |
bits--; |
x = bitbuf >> bits; |
bitbuf -= x << bits; |
return x; |
} |
#endif |
/* only huffman */ |
/*----- get n bits - checks for n+2 avail bits (linbits+sign) -----*/ |
int bitget_lb(int n) |
{ |
unsigned int x; |
if (bits < (n + 2)) |
{ /* refill bit buf if necessary */ |
while (bits <= 24) |
{ |
bitbuf = (bitbuf << 8) | *bs_ptr++; |
bits += 8; |
} |
} |
bits -= n; |
x = bitbuf >> bits; |
bitbuf -= x << bits; |
return x; |
} |
/*------------- get n bits but DO NOT remove from bitstream --*/ |
int bitget2(int n) |
{ |
unsigned int x; |
if (bits < (MAXBITS + 2)) |
{ /* refill bit buf if necessary */ |
while (bits <= 24) |
{ |
bitbuf = (bitbuf << 8) | *bs_ptr++; |
bits += 8; |
} |
} |
x = bitbuf >> (bits - n); |
return x; |
} |
/*------------- remove n bits from bitstream ---------*/ |
void bitget_purge(int n) |
{ |
bits -= n; |
bitbuf -= (bitbuf >> bits) << bits; |
} |
void mac_bitget_check(int n) |
{ |
if( bits < n ) { |
while( bits <= 24 ) { |
bitbuf = (bitbuf << 8) | *bs_ptr++; |
bits += 8; |
} |
} |
} |
int mac_bitget(int n) |
{ |
unsigned int code; |
bits -= n; |
code = bitbuf >> bits; |
bitbuf -= code << bits; |
return code; |
} |
int mac_bitget2(int n) |
{ |
return (bitbuf >> (bits-n)); |
} |
int mac_bitget_1bit() |
{ |
unsigned int code; |
bits--; |
code = bitbuf >> bits; |
bitbuf -= code << bits; |
return code; |
} |
void mac_bitget_purge(int n) |
{ |
bits -= n; |
bitbuf -= (bitbuf >> bits) << bits; |
} |
/* |
#define mac_bitget(n) ( bits -= n, \ |
code = bitbuf >> bits, \ |
bitbuf -= code << bits, \ |
code ) |
#define mac_bitget_1bit() ( bits--, \ |
code = bitbuf >> bits, \ |
bitbuf -= code << bits, \ |
code ) |
*/ |
/programs/media/ac97snd/trunk/mp3dec/bstream.h |
---|
0,0 → 1,23 |
typedef unsigned char byte; |
typedef unsigned int uint; |
typedef void (*SBT_PROC) (float *sample, void *pcm, int n); |
typedef void (*XFORM_PROC) (void *pcm, int igr); |
void bitget_init(unsigned char *buf); |
void bitget_init_end(unsigned char *buf_end); |
int bitget_overrun(); |
int bitget_bits_used(); |
void bitget_check(int n); |
int bitget(int n); |
void bitget_skip(int n); |
//int bitget_1bit(); |
int bitget_lb(int n); |
int bitget2(int n); |
void bitget_purge(int n); |
void mac_bitget_check(int n); |
int mac_bitget(int n); |
int mac_bitget_1bit(); |
int mac_bitget2(int n); |
void mac_bitget_purge(int n); |
/programs/media/ac97snd/trunk/mp3dec/e_pow.c |
---|
0,0 → 1,358 |
/* @(#)e_pow.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* Modified by Naohiko Shimizu/Tokai University, Japan 1997/08/25, |
for performance improvement on pipelined processors. |
*/ |
#if defined(LIBM_SCCS) && !defined(lint) |
static char rcsid[] = "$NetBSD: e_pow.c,v 1.9 1995/05/12 04:57:32 jtc Exp $"; |
#endif |
/* __ieee754_pow(x,y) return x**y |
* |
* n |
* Method: Let x = 2 * (1+f) |
* 1. Compute and return log2(x) in two pieces: |
* log2(x) = w1 + w2, |
* where w1 has 53-24 = 29 bit trailing zeros. |
* 2. Perform y*log2(x) = n+y' by simulating muti-precision |
* arithmetic, where |y'|<=0.5. |
* 3. Return x**y = 2**n*exp(y'*log2) |
* |
* Special cases: |
* 1. (anything) ** 0 is 1 |
* 2. (anything) ** 1 is itself |
* 3. (anything) ** NAN is NAN |
* 4. NAN ** (anything except 0) is NAN |
* 5. +-(|x| > 1) ** +INF is +INF |
* 6. +-(|x| > 1) ** -INF is +0 |
* 7. +-(|x| < 1) ** +INF is +0 |
* 8. +-(|x| < 1) ** -INF is +INF |
* 9. +-1 ** +-INF is NAN |
* 10. +0 ** (+anything except 0, NAN) is +0 |
* 11. -0 ** (+anything except 0, NAN, odd integer) is +0 |
* 12. +0 ** (-anything except 0, NAN) is +INF |
* 13. -0 ** (-anything except 0, NAN, odd integer) is +INF |
* 14. -0 ** (odd integer) = -( +0 ** (odd integer) ) |
* 15. +INF ** (+anything except 0,NAN) is +INF |
* 16. +INF ** (-anything except 0,NAN) is +0 |
* 17. -INF ** (anything) = -0 ** (-anything) |
* 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer) |
* 19. (-anything except 0 and inf) ** (non-integer) is NAN |
* |
* Accuracy: |
* pow(x,y) returns x**y nearly rounded. In particular |
* pow(integer,integer) |
* always returns the correct integer provided it is |
* representable. |
* |
* Constants : |
* The hexadecimal values are the intended ones for the following |
* constants. The decimal values may be used, provided that the |
* compiler will convert from decimal to binary accurately enough |
* to produce the hexadecimal values shown. |
*/ |
#include "math.h" |
#include "math_private.h" |
#define zero C[0] |
#define one C[1] |
#define two C[2] |
#define two53 C[3] |
#define huge C[4] |
#define tiny C[5] |
#define L1 C[6] |
#define L2 C[7] |
#define L3 C[8] |
#define L4 C[9] |
#define L5 C[10] |
#define L6 C[11] |
#define P1 C[12] |
#define P2 C[13] |
#define P3 C[14] |
#define P4 C[15] |
#define P5 C[16] |
#define lg2 C[17] |
#define lg2_h C[18] |
#define lg2_l C[19] |
#define ovt C[20] |
#define cp C[21] |
#define cp_h C[22] |
#define cp_l C[23] |
#define ivln2 C[24] |
#define ivln2_h C[25] |
#define ivln2_l C[26] |
double scalbn(double,int); |
#define EXTRACT_WORDS(ix0,ix1,d) \ |
do { \ |
ieee_double_shape_type ew_u; \ |
ew_u.value = (d); \ |
(ix0) = ew_u.parts.msw; \ |
(ix1) = ew_u.parts.lsw; \ |
} while (0) |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
bp[] = {1.0, 1.5,}, |
dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */ |
dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */ |
C[] = { |
0.0, |
1.0, |
2.0, |
9007199254740992.0 , |
1.0e300, |
1.0e-300, |
5.99999999999994648725e-01 , |
4.28571428578550184252e-01 , |
3.33333329818377432918e-01 , |
2.72728123808534006489e-01 , |
2.30660745775561754067e-01 , |
2.06975017800338417784e-01 , |
1.66666666666666019037e-01 , |
-2.77777777770155933842e-03 , |
6.61375632143793436117e-05 , |
-1.65339022054652515390e-06 , |
4.13813679705723846039e-08 , |
6.93147180559945286227e-01 , |
6.93147182464599609375e-01 , |
-1.90465429995776804525e-09 , |
8.0085662595372944372e-0017 , |
9.61796693925975554329e-01 , |
9.61796700954437255859e-01 , |
-7.02846165095275826516e-09 , |
1.44269504088896338700e+00 , |
1.44269502162933349609e+00 , |
1.92596299112661746887e-08 }; |
double pow_test(x,y) |
double x, y; |
{ |
double z,ax,z_h,z_l,p_h,p_l; |
double y1,t1,t2,r,s,t,u,v,w, t12,t14,r_1,r_2,r_3; |
int32_t i,j,k,yisint,n; |
int32_t hx,hy,ix,iy; |
u_int32_t lx,ly; |
EXTRACT_WORDS(hx,lx,x); |
EXTRACT_WORDS(hy,ly,y); |
ix = hx&0x7fffffff; iy = hy&0x7fffffff; |
/* y==zero: x**0 = 1 */ |
if((iy|ly)==0) return C[1]; |
/* +-NaN return x+y */ |
if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) || |
iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) |
return x+y; |
/* determine if y is an odd int when x < 0 |
* yisint = 0 ... y is not an integer |
* yisint = 1 ... y is an odd int |
* yisint = 2 ... y is an even int |
*/ |
yisint = 0; |
if(hx<0) { |
if(iy>=0x43400000) yisint = 2; /* even integer y */ |
else if(iy>=0x3ff00000) { |
k = (iy>>20)-0x3ff; /* exponent */ |
if(k>20) { |
j = ly>>(52-k); |
if((u_int32_t)(j<<(52-k))==ly) yisint = 2-(j&1); |
} else if(ly==0) { |
j = iy>>(20-k); |
if((int32_t)(j<<(20-k))==iy) yisint = 2-(j&1); |
} |
} |
} |
/* special value of y */ |
if(ly==0) { |
if (iy==0x7ff00000) { /* y is +-inf */ |
if(((ix-0x3ff00000)|lx)==0) |
return y - y; /* inf**+-1 is NaN */ |
else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */ |
return (hy>=0)? y: C[0]; |
else /* (|x|<1)**-,+inf = inf,0 */ |
return (hy<0)?-y: C[0]; |
} |
if(iy==0x3ff00000) { /* y is +-1 */ |
if(hy<0) return C[1]/x; else return x; |
} |
if(hy==0x40000000) return x*x; /* y is 2 */ |
if(hy==0x3fe00000) { /* y is 0.5 */ |
if(hx>=0) /* x >= +0 */ |
return sqrt(x); |
} |
} |
ax = fabs(x); |
/* special value of x */ |
if(lx==0) { |
if(ix==0x7ff00000||ix==0||ix==0x3ff00000){ |
z = ax; /*x is +-0,+-inf,+-1*/ |
if(hy<0) z = C[1]/z; /* z = (1/|x|) */ |
if(hx<0) { |
if(((ix-0x3ff00000)|yisint)==0) { |
z = (z-z)/(z-z); /* (-1)**non-int is NaN */ |
} else if(yisint==1) |
z = -z; /* (x<0)**odd = -(|x|**odd) */ |
} |
return z; |
} |
} |
/* (x<0)**(non-int) is NaN */ |
if(((((u_int32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x); |
/* |y| is huge */ |
if(iy>0x41e00000) { /* if |y| > 2**31 */ |
if(iy>0x43f00000){ /* if |y| > 2**64, must o/uflow */ |
if(ix<=0x3fefffff) return (hy<0)? C[4]*C[4]:C[5]*C[5]; |
if(ix>=0x3ff00000) return (hy>0)? C[4]*C[4]:C[5]*C[5]; |
} |
/* over/underflow if x is not close to one */ |
if(ix<0x3fefffff) return (hy<0)? C[4]*C[4]:C[5]*C[5]; |
if(ix>0x3ff00000) return (hy>0)? C[4]*C[4]:C[5]*C[5]; |
/* now |1-x| is tiny <= 2**-20, suffice to compute |
log(x) by x-x^2/2+x^3/3-x^4/4 */ |
t = x-1; /* t has 20 trailing zeros */ |
w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25)); |
u = C[25]*t; /* ivln2_h has 21 sig. bits */ |
v = t*C[26]-w*C[24]; |
t1 = u+v; |
SET_LOW_WORD(t1,0); |
t2 = v-(t1-u); |
} else { |
double s2,s_h,s_l,t_h,t_l,s22,s24,s26,r1,r2,r3; |
n = 0; |
/* take care subnormal number */ |
if(ix<0x00100000) |
{ax *= C[3]; n -= 53; GET_HIGH_WORD(ix,ax); } |
n += ((ix)>>20)-0x3ff; |
j = ix&0x000fffff; |
/* determine interval */ |
ix = j|0x3ff00000; /* normalize ix */ |
if(j<=0x3988E) k=0; /* |x|<sqrt(3/2) */ |
else if(j<0xBB67A) k=1; /* |x|<sqrt(3) */ |
else {k=0;n+=1;ix -= 0x00100000;} |
SET_HIGH_WORD(ax,ix); |
/* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ |
u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */ |
v = C[1]/(ax+bp[k]); |
s = u*v; |
s_h = s; |
SET_LOW_WORD(s_h,0); |
/* t_h=ax+bp[k] High */ |
t_h = C[0]; |
SET_HIGH_WORD(t_h,((ix>>1)|0x20000000)+0x00080000+(k<<18)); |
t_l = ax - (t_h-bp[k]); |
s_l = v*((u-s_h*t_h)-s_h*t_l); |
/* compute log(ax) */ |
s2 = s*s; |
#ifdef DO_NOT_USE_THIS |
r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); |
#else |
r1 = C[10]+s2*C[11]; s22=s2*s2; |
r2 = C[8]+s2*C[9]; s24=s22*s22; |
r3 = C[6]+s2*C[7]; s26=s24*s22; |
r = r3*s22 + r2*s24 + r1*s26; |
#endif |
r += s_l*(s_h+s); |
s2 = s_h*s_h; |
t_h = 3.0+s2+r; |
SET_LOW_WORD(t_h,0); |
t_l = r-((t_h-3.0)-s2); |
/* u+v = s*(1+...) */ |
u = s_h*t_h; |
v = s_l*t_h+t_l*s; |
/* 2/(3log2)*(s+...) */ |
p_h = u+v; |
SET_LOW_WORD(p_h,0); |
p_l = v-(p_h-u); |
z_h = C[22]*p_h; /* cp_h+cp_l = 2/(3*log2) */ |
z_l = C[23]*p_h+p_l*C[21]+dp_l[k]; |
/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ |
t = (double)n; |
t1 = (((z_h+z_l)+dp_h[k])+t); |
SET_LOW_WORD(t1,0); |
t2 = z_l-(((t1-t)-dp_h[k])-z_h); |
} |
s = C[1]; /* s (sign of result -ve**odd) = -1 else = 1 */ |
if(((((u_int32_t)hx>>31)-1)|(yisint-1))==0) |
s = -C[1];/* (-ve)**(odd int) */ |
/* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ |
y1 = y; |
SET_LOW_WORD(y1,0); |
p_l = (y-y1)*t1+y*t2; |
p_h = y1*t1; |
z = p_l+p_h; |
EXTRACT_WORDS(j,i,z); |
if (j>=0x40900000) { /* z >= 1024 */ |
if(((j-0x40900000)|i)!=0) /* if z > 1024 */ |
return s*C[4]*C[4]; /* overflow */ |
else { |
if(p_l+C[20]>z-p_h) return s*C[4]*C[4]; /* overflow */ |
} |
} else if((j&0x7fffffff)>=0x4090cc00 ) { /* z <= -1075 */ |
if(((j-0xc090cc00)|i)!=0) /* z < -1075 */ |
return s*C[5]*C[5]; /* underflow */ |
else { |
if(p_l<=z-p_h) return s*C[5]*C[5]; /* underflow */ |
} |
} |
/* |
* compute 2**(p_h+p_l) |
*/ |
i = j&0x7fffffff; |
k = (i>>20)-0x3ff; |
n = 0; |
if(i>0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */ |
n = j+(0x00100000>>(k+1)); |
k = ((n&0x7fffffff)>>20)-0x3ff; /* new k for n */ |
t = C[0]; |
SET_HIGH_WORD(t,n&~(0x000fffff>>k)); |
n = ((n&0x000fffff)|0x00100000)>>(20-k); |
if(j<0) n = -n; |
p_h -= t; |
} |
t = p_l+p_h; |
SET_LOW_WORD(t,0); |
u = t*C[18]; |
v = (p_l-(t-p_h))*C[17]+t*C[19]; |
z = u+v; |
w = v-(z-u); |
t = z*z; |
#ifdef DO_NOT_USE_THIS |
t1 = z - t*(C[12]+t*(C[13]+t*(C[14]+t*(C[15]+t*C[16])))); |
#else |
r_1 = C[15]+t*C[16]; t12 = t*t; |
r_2 = C[13]+t*C[14]; t14 = t12*t12; |
r_3 = t*C[12]; |
t1 = z - r_3 - t12*r_2 - t14*r_1; |
#endif |
r = (z*t1)/(t1-C[2])-(w+z*w); |
z = C[1]-(r-z); |
GET_HIGH_WORD(j,z); |
j += (n<<20); |
if((j>>20)<=0) z = scalbn(z,n); /* subnormal output */ |
else SET_HIGH_WORD(z,j); |
return s*z; |
} |
/programs/media/ac97snd/trunk/mp3dec/fdct.c |
---|
0,0 → 1,290 |
#include <math.h> |
static float coef32[31]; /* 32 pt dct coefs */ |
void fdct_init() /* gen coef for N=32 (31 coefs) */ |
{ |
int p, n, i, k; |
double t, pi; |
pi = 4.0 * atan(1.0); |
n = 16; |
k = 0; |
for (i = 0; i < 5; i++, n = n / 2) { |
for (p = 0; p < n; p++, k++) { |
t = (pi / (4 * n)) * (2 * p + 1); |
coef32[k] = (float) (0.50 / cos(t)); |
} |
} |
} |
static void forward_bf(int m, int n, float x[], float f[], float coef[]) |
{ |
int i, j, n2; |
int p, q, p0, k; |
p0 = 0; |
n2 = n >> 1; |
for (i = 0; i < m; i++, p0 += n) { |
k = 0; |
p = p0; |
q = p + n - 1; |
for (j = 0; j < n2; j++, p++, q--, k++) { |
f[p] = x[p] + x[q]; |
f[n2 + p] = coef[k] * (x[p] - x[q]); |
} |
} |
} |
/*------------------------------------------------------------*/ |
static void back_bf(int m, int n, float x[], float f[]) |
{ |
int i, j, n2, n21; |
int p, q, p0; |
p0 = 0; |
n2 = n >> 1; |
n21 = n2 - 1; |
for (i = 0; i < m; i++, p0 += n) { |
p = p0; |
q = p0; |
for (j = 0; j < n2; j++, p += 2, q++) |
f[p] = x[q]; |
p = p0 + 1; |
for (j = 0; j < n21; j++, p += 2, q++) |
f[p] = x[q] + x[q + 1]; |
f[p] = x[q]; |
} |
} |
/*------------------------------------------------------------*/ |
extern int m_enableEQ; |
extern float m_equalizer[32]; |
void fdct32(float x[], float c[]) |
{ |
float a[32]; /* ping pong buffers */ |
float b[32]; |
int p, q; |
if (m_enableEQ) { |
for (p = 0; p < 32; p++) x[p] *= m_equalizer[p]; |
} |
/* special first stage */ |
for (p = 0, q = 31; p < 16; p++, q--) { |
a[p] = x[p] + x[q]; |
a[16 + p] = coef32[p] * (x[p] - x[q]); |
} |
forward_bf(2, 16, a, b, coef32 + 16); |
forward_bf(4, 8, b, a, coef32 + 16 + 8); |
forward_bf(8, 4, a, b, coef32 + 16 + 8 + 4); |
forward_bf(16, 2, b, a, coef32 + 16 + 8 + 4 + 2); |
back_bf(8, 4, a, b); |
back_bf(4, 8, b, a); |
back_bf(2, 16, a, b); |
back_bf(1, 32, b, c); |
} |
/*------------------------------------------------------------*/ |
void fdct32_dual(float x[], float c[]) |
{ |
float a[32]; /* ping pong buffers */ |
float b[32]; |
int p, pp, qq; |
if (m_enableEQ) { |
for (p = 0; p < 32; p++) x[p] *= m_equalizer[p]; |
} |
/* special first stage for dual chan (interleaved x) */ |
pp = 0; |
qq = 2 * 31; |
for (p = 0; p < 16; p++, pp += 2, qq -= 2) |
{ |
a[p] = x[pp] + x[qq]; |
a[16 + p] = coef32[p] * (x[pp] - x[qq]); |
} |
forward_bf(2, 16, a, b, coef32 + 16); |
forward_bf(4, 8, b, a, coef32 + 16 + 8); |
forward_bf(8, 4, a, b, coef32 + 16 + 8 + 4); |
forward_bf(16, 2, b, a, coef32 + 16 + 8 + 4 + 2); |
back_bf(8, 4, a, b); |
back_bf(4, 8, b, a); |
back_bf(2, 16, a, b); |
back_bf(1, 32, b, c); |
} |
/*---------------convert dual to mono------------------------------*/ |
void fdct32_dual_mono(float x[], float c[]) |
{ |
float a[32]; /* ping pong buffers */ |
float b[32]; |
float t1, t2; |
int p, pp, qq; |
/* special first stage */ |
pp = 0; |
qq = 2 * 31; |
for (p = 0; p < 16; p++, pp += 2, qq -= 2) |
{ |
t1 = 0.5F * (x[pp] + x[pp + 1]); |
t2 = 0.5F * (x[qq] + x[qq + 1]); |
a[p] = t1 + t2; |
a[16 + p] = coef32[p] * (t1 - t2); |
} |
forward_bf(2, 16, a, b, coef32 + 16); |
forward_bf(4, 8, b, a, coef32 + 16 + 8); |
forward_bf(8, 4, a, b, coef32 + 16 + 8 + 4); |
forward_bf(16, 2, b, a, coef32 + 16 + 8 + 4 + 2); |
back_bf(8, 4, a, b); |
back_bf(4, 8, b, a); |
back_bf(2, 16, a, b); |
back_bf(1, 32, b, c); |
} |
/*------------------------------------------------------------*/ |
/*---------------- 16 pt fdct -------------------------------*/ |
void fdct16(float x[], float c[]) |
{ |
float a[16]; /* ping pong buffers */ |
float b[16]; |
int p, q; |
/* special first stage (drop highest sb) */ |
a[0] = x[0]; |
a[8] = coef32[16] * x[0]; |
for (p = 1, q = 14; p < 8; p++, q--) |
{ |
a[p] = x[p] + x[q]; |
a[8 + p] = coef32[16 + p] * (x[p] - x[q]); |
} |
forward_bf(2, 8, a, b, coef32 + 16 + 8); |
forward_bf(4, 4, b, a, coef32 + 16 + 8 + 4); |
forward_bf(8, 2, a, b, coef32 + 16 + 8 + 4 + 2); |
back_bf(4, 4, b, a); |
back_bf(2, 8, a, b); |
back_bf(1, 16, b, c); |
} |
/*------------------------------------------------------------*/ |
/*---------------- 16 pt fdct dual chan---------------------*/ |
void fdct16_dual(float x[], float c[]) |
{ |
float a[16]; /* ping pong buffers */ |
float b[16]; |
int p, pp, qq; |
/* special first stage for interleaved input */ |
a[0] = x[0]; |
a[8] = coef32[16] * x[0]; |
pp = 2; |
qq = 2 * 14; |
for (p = 1; p < 8; p++, pp += 2, qq -= 2) |
{ |
a[p] = x[pp] + x[qq]; |
a[8 + p] = coef32[16 + p] * (x[pp] - x[qq]); |
} |
forward_bf(2, 8, a, b, coef32 + 16 + 8); |
forward_bf(4, 4, b, a, coef32 + 16 + 8 + 4); |
forward_bf(8, 2, a, b, coef32 + 16 + 8 + 4 + 2); |
back_bf(4, 4, b, a); |
back_bf(2, 8, a, b); |
back_bf(1, 16, b, c); |
} |
/*------------------------------------------------------------*/ |
/*---------------- 16 pt fdct dual to mono-------------------*/ |
void fdct16_dual_mono(float x[], float c[]) |
{ |
float a[16]; /* ping pong buffers */ |
float b[16]; |
float t1, t2; |
int p, pp, qq; |
/* special first stage */ |
a[0] = 0.5F * (x[0] + x[1]); |
a[8] = coef32[16] * a[0]; |
pp = 2; |
qq = 2 * 14; |
for (p = 1; p < 8; p++, pp += 2, qq -= 2) |
{ |
t1 = 0.5F * (x[pp] + x[pp + 1]); |
t2 = 0.5F * (x[qq] + x[qq + 1]); |
a[p] = t1 + t2; |
a[8 + p] = coef32[16 + p] * (t1 - t2); |
} |
forward_bf(2, 8, a, b, coef32 + 16 + 8); |
forward_bf(4, 4, b, a, coef32 + 16 + 8 + 4); |
forward_bf(8, 2, a, b, coef32 + 16 + 8 + 4 + 2); |
back_bf(4, 4, b, a); |
back_bf(2, 8, a, b); |
back_bf(1, 16, b, c); |
} |
/*------------------------------------------------------------*/ |
/*---------------- 8 pt fdct -------------------------------*/ |
void fdct8(float x[], float c[]) |
{ |
float a[8]; /* ping pong buffers */ |
float b[8]; |
int p, q; |
/* special first stage */ |
b[0] = x[0] + x[7]; |
b[4] = coef32[16 + 8] * (x[0] - x[7]); |
for (p = 1, q = 6; p < 4; p++, q--) |
{ |
b[p] = x[p] + x[q]; |
b[4 + p] = coef32[16 + 8 + p] * (x[p] - x[q]); |
} |
forward_bf(2, 4, b, a, coef32 + 16 + 8 + 4); |
forward_bf(4, 2, a, b, coef32 + 16 + 8 + 4 + 2); |
back_bf(2, 4, b, a); |
back_bf(1, 8, a, c); |
} |
/*---------------- 8 pt fdct dual chan---------------------*/ |
void fdct8_dual(float x[], float c[]) |
{ |
float a[8]; /* ping pong buffers */ |
float b[8]; |
int p, pp, qq; |
/* special first stage for interleaved input */ |
b[0] = x[0] + x[14]; |
b[4] = coef32[16 + 8] * (x[0] - x[14]); |
pp = 2; |
qq = 2 * 6; |
for (p = 1; p < 4; p++, pp += 2, qq -= 2) |
{ |
b[p] = x[pp] + x[qq]; |
b[4 + p] = coef32[16 + 8 + p] * (x[pp] - x[qq]); |
} |
forward_bf(2, 4, b, a, coef32 + 16 + 8 + 4); |
forward_bf(4, 2, a, b, coef32 + 16 + 8 + 4 + 2); |
back_bf(2, 4, b, a); |
back_bf(1, 8, a, c); |
} |
/*---------------- 8 pt fdct dual to mono---------------------*/ |
void fdct8_dual_mono(float x[], float c[]) |
{ |
float a[8]; /* ping pong buffers */ |
float b[8]; |
float t1, t2; |
int p, pp, qq; |
/* special first stage */ |
t1 = 0.5F * (x[0] + x[1]); |
t2 = 0.5F * (x[14] + x[15]); |
b[0] = t1 + t2; |
b[4] = coef32[16 + 8] * (t1 - t2); |
pp = 2; |
qq = 2 * 6; |
for (p = 1; p < 4; p++, pp += 2, qq -= 2) |
{ |
t1 = 0.5F * (x[pp] + x[pp + 1]); |
t2 = 0.5F * (x[qq] + x[qq + 1]); |
b[p] = t1 + t2; |
b[4 + p] = coef32[16 + 8 + p] * (t1 - t2); |
} |
forward_bf(2, 4, b, a, coef32 + 16 + 8 + 4); |
forward_bf(4, 2, a, b, coef32 + 16 + 8 + 4 + 2); |
back_bf(2, 4, b, a); |
back_bf(1, 8, a, c); |
} |
/programs/media/ac97snd/trunk/mp3dec/imdct.c |
---|
0,0 → 1,222 |
#include <math.h> |
/*------ 18 point xform -------*/ |
static float w[18]; |
static float w2[9]; |
static float coef[9][4]; |
static float v[6]; |
static float v2[3]; |
static float coef87; |
/* |
typedef struct |
{ |
float *w; |
float *w2; |
void *coef; |
} |
IMDCT_INIT_BLOCK; |
static IMDCT_INIT_BLOCK imdct_info_18 = |
{w, w2, coef}; |
static IMDCT_INIT_BLOCK imdct_info_6 = |
{v, v2, &coef87}; |
*/ |
/*=============================================================*/ |
void imdct_init() |
{ |
int k, p, n; |
double t, pi; |
// IMDCT_INIT_BLOCK *addr; |
// float *w, *w2; |
// float *v, *v2, *coef87; |
/*--- 18 point --*/ |
// addr = imdct_init_addr_18(); |
// w = addr->w; |
// w2 = addr->w2; |
// coef = addr->coef; |
/*----*/ |
n = 18; |
pi = 4.0 * atan(1.0); |
t = pi / (4 * n); |
for (p = 0; p < n; p++) |
w[p] = (float) (2.0 * cos(t * (2 * p + 1))); |
for (p = 0; p < 9; p++) |
w2[p] = (float) (2.0 *cos(2 * t * (2 * p + 1))); |
t = pi / (2 * n); |
for (k = 0; k < 9; k++) |
{ |
for (p = 0; p < 4; p++) |
coef[k][p] = (float) (cos(t * (2 * k) * (2 * p + 1))); |
} |
/*--- 6 point */ |
// addr = imdct_init_addr_6(); |
// v = addr->w; |
// v2 = addr->w2; |
// coef87 = addr->coef; |
/*----*/ |
n = 6; |
pi = 4.0 * atan(1.0); |
t = pi / (4 * n); |
for (p = 0; p < n; p++) |
v[p] = (float) (2.0 *cos(t * (2 * p + 1))); |
for (p = 0; p < 3; p++) |
v2[p] = (float) (2.0 *cos(2 * t * (2 * p + 1))); |
t = pi / (2 * n); |
k = 1; |
p = 0; |
coef87 = (float) (cos(t * (2 * k) * (2 * p + 1))); |
/* adjust scaling to save a few mults */ |
for (p = 0; p < 6; p++) |
v[p] = v[p] / 2.0f; |
coef87 = (float) (2.0 * coef87); |
} |
/*--------------------------------------------------------------------*/ |
void imdct18(float f[18]) /* 18 point */ |
{ |
int p; |
float a[9], b[9]; |
float ap, bp, a8p, b8p; |
float g1, g2; |
for (p = 0; p < 4; p++) |
{ |
g1 = w[p] * f[p]; |
g2 = w[17 - p] * f[17 - p]; |
ap = g1 + g2; // a[p] |
bp = w2[p] * (g1 - g2); // b[p] |
g1 = w[8 - p] * f[8 - p]; |
g2 = w[9 + p] * f[9 + p]; |
a8p = g1 + g2; // a[8-p] |
b8p = w2[8 - p] * (g1 - g2); // b[8-p] |
a[p] = ap + a8p; |
a[5 + p] = ap - a8p; |
b[p] = bp + b8p; |
b[5 + p] = bp - b8p; |
} |
g1 = w[p] * f[p]; |
g2 = w[17 - p] * f[17 - p]; |
a[p] = g1 + g2; |
b[p] = w2[p] * (g1 - g2); |
f[0] = 0.5f * (a[0] + a[1] + a[2] + a[3] + a[4]); |
f[1] = 0.5f * (b[0] + b[1] + b[2] + b[3] + b[4]); |
f[2] = coef[1][0] * a[5] + coef[1][1] * a[6] + coef[1][2] * a[7] |
+ coef[1][3] * a[8]; |
f[3] = coef[1][0] * b[5] + coef[1][1] * b[6] + coef[1][2] * b[7] |
+ coef[1][3] * b[8] - f[1]; |
f[1] = f[1] - f[0]; |
f[2] = f[2] - f[1]; |
f[4] = coef[2][0] * a[0] + coef[2][1] * a[1] + coef[2][2] * a[2] |
+ coef[2][3] * a[3] - a[4]; |
f[5] = coef[2][0] * b[0] + coef[2][1] * b[1] + coef[2][2] * b[2] |
+ coef[2][3] * b[3] - b[4] - f[3]; |
f[3] = f[3] - f[2]; |
f[4] = f[4] - f[3]; |
f[6] = coef[3][0] * (a[5] - a[7] - a[8]); |
f[7] = coef[3][0] * (b[5] - b[7] - b[8]) - f[5]; |
f[5] = f[5] - f[4]; |
f[6] = f[6] - f[5]; |
f[8] = coef[4][0] * a[0] + coef[4][1] * a[1] + coef[4][2] * a[2] |
+ coef[4][3] * a[3] + a[4]; |
f[9] = coef[4][0] * b[0] + coef[4][1] * b[1] + coef[4][2] * b[2] |
+ coef[4][3] * b[3] + b[4] - f[7]; |
f[7] = f[7] - f[6]; |
f[8] = f[8] - f[7]; |
f[10] = coef[5][0] * a[5] + coef[5][1] * a[6] + coef[5][2] * a[7] |
+ coef[5][3] * a[8]; |
f[11] = coef[5][0] * b[5] + coef[5][1] * b[6] + coef[5][2] * b[7] |
+ coef[5][3] * b[8] - f[9]; |
f[9] = f[9] - f[8]; |
f[10] = f[10] - f[9]; |
f[12] = 0.5f * (a[0] + a[2] + a[3]) - a[1] - a[4]; |
f[13] = 0.5f * (b[0] + b[2] + b[3]) - b[1] - b[4] - f[11]; |
f[11] = f[11] - f[10]; |
f[12] = f[12] - f[11]; |
f[14] = coef[7][0] * a[5] + coef[7][1] * a[6] + coef[7][2] * a[7] |
+ coef[7][3] * a[8]; |
f[15] = coef[7][0] * b[5] + coef[7][1] * b[6] + coef[7][2] * b[7] |
+ coef[7][3] * b[8] - f[13]; |
f[13] = f[13] - f[12]; |
f[14] = f[14] - f[13]; |
f[16] = coef[8][0] * a[0] + coef[8][1] * a[1] + coef[8][2] * a[2] |
+ coef[8][3] * a[3] + a[4]; |
f[17] = coef[8][0] * b[0] + coef[8][1] * b[1] + coef[8][2] * b[2] |
+ coef[8][3] * b[3] + b[4] - f[15]; |
f[15] = f[15] - f[14]; |
f[16] = f[16] - f[15]; |
f[17] = f[17] - f[16]; |
} |
/*--------------------------------------------------------------------*/ |
/* does 3, 6 pt dct. changes order from f[i][window] c[window][i] */ |
void imdct6_3(float f[]) /* 6 point */ |
{ |
int w; |
float buf[18]; |
float *a, *c; // b[i] = a[3+i] |
float g1, g2; |
float a02, b02; |
c = f; |
a = buf; |
for (w = 0; w < 3; w++) |
{ |
g1 = v[0] * f[3 * 0]; |
g2 = v[5] * f[3 * 5]; |
a[0] = g1 + g2; |
a[3 + 0] = v2[0] * (g1 - g2); |
g1 = v[1] * f[3 * 1]; |
g2 = v[4] * f[3 * 4]; |
a[1] = g1 + g2; |
a[3 + 1] = v2[1] * (g1 - g2); |
g1 = v[2] * f[3 * 2]; |
g2 = v[3] * f[3 * 3]; |
a[2] = g1 + g2; |
a[3 + 2] = v2[2] * (g1 - g2); |
a += 6; |
f++; |
} |
a = buf; |
for (w = 0; w < 3; w++) |
{ |
a02 = (a[0] + a[2]); |
b02 = (a[3 + 0] + a[3 + 2]); |
c[0] = a02 + a[1]; |
c[1] = b02 + a[3 + 1]; |
c[2] = coef87 * (a[0] - a[2]); |
c[3] = coef87 * (a[3 + 0] - a[3 + 2]) - c[1]; |
c[1] = c[1] - c[0]; |
c[2] = c[2] - c[1]; |
c[4] = a02 - a[1] - a[1]; |
c[5] = b02 - a[3 + 1] - a[3 + 1] - c[3]; |
c[3] = c[3] - c[2]; |
c[4] = c[4] - c[3]; |
c[5] = c[5] - c[4]; |
a += 6; |
c += 6; |
} |
} |
/programs/media/ac97snd/trunk/mp3dec/l1dec.c |
---|
0,0 → 1,202 |
#include "bstream.h" |
#include "mp3dec.h" |
extern MPEG_DECODE_OPTION m_option; |
extern float m_sample[2304]; |
extern int m_nsb_limit; |
extern SBT_PROC m_sbt_proc; |
extern int m_max_sb; |
extern int m_stereo_sb; |
extern int m_bat[4][16]; |
extern int m_ballo[64]; |
extern unsigned int m_samp_dispatch[66]; |
extern float m_c_value[64]; |
extern unsigned int m_sf_dispatch[66]; |
extern float m_sf_table[64]; |
extern float m_cs_factor[3][64]; |
float m_look_c_valueL1[18]; |
float *m_cs_factorL1 = m_cs_factor[0]; |
int m_nbatL1; |
int m_bit_skip; |
static const int look_joint[16] = |
{ /* lookup stereo sb's by mode+ext */ |
64, 64, 64, 64, /* stereo */ |
2 * 4, 2 * 8, 2 * 12, 2 * 16, /* joint */ |
64, 64, 64, 64, /* dual */ |
32, 32, 32, 32, /* mono */ |
}; |
static const int bat_bit_masterL1[] = |
{ |
0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 |
}; |
void unpack_baL1(); |
void unpack_sfL1(); |
void unpack_sampL1(); |
void L1decode_frame(MPEG_HEADER* h, byte* mpeg, byte* pcm) |
{ |
int crc_size; |
crc_size = (h->error_prot) ? 2 : 0; |
bitget_init(mpeg + 4 + crc_size); |
m_stereo_sb = look_joint[(h->mode << 2) + h->mode_ext]; |
unpack_baL1(); /* unpack bit allocation */ |
unpack_sfL1(); /* unpack scale factor */ |
unpack_sampL1(); /* unpack samples */ |
m_sbt_proc(m_sample, pcm, 12); |
} |
void unpack_baL1() |
{ |
int j; |
int nstereo; |
m_bit_skip = 0; |
nstereo = m_stereo_sb; |
for (j = 0; j < m_nbatL1; j++) |
{ |
bitget_check(4); |
m_ballo[j] = m_samp_dispatch[j] = mac_bitget(4); |
if (j >= m_nsb_limit) |
m_bit_skip += bat_bit_masterL1[m_samp_dispatch[j]]; |
m_c_value[j] = m_look_c_valueL1[m_samp_dispatch[j]]; |
if (--nstereo < 0) |
{ |
m_ballo[j + 1] = m_ballo[j]; |
// flag as joint |
m_samp_dispatch[j] += 15; |
// flag for sf |
m_samp_dispatch[j + 1] = m_samp_dispatch[j]; |
m_c_value[j + 1] = m_c_value[j]; |
j++; |
} |
} |
// terminate with bit skip and end |
m_samp_dispatch[m_nsb_limit] = 31; |
m_samp_dispatch[j] = 30; |
} |
// unpack scale factor |
// combine dequant and scale factors |
void unpack_sfL1() |
{ |
int i; |
for (i = 0; i < m_nbatL1; i++) |
{ |
if (m_ballo[i]) |
{ |
bitget_check(6); |
m_cs_factorL1[i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
} |
} |
} |
// unpack samples |
#define UNPACKL1_N(n) \ |
s[k] = m_cs_factorL1[k]*(bitget(n)-((1 << n-1) -1)); \ |
goto dispatch; |
#define UNPACKL1J_N(n) \ |
tmp = (bitget(n)-((1 << n-1) -1)); \ |
s[k] = m_cs_factorL1[k]*tmp; \ |
s[k+1] = m_cs_factorL1[k+1]*tmp; \ |
k++; \ |
goto dispatch; |
void unpack_sampL1() |
{ |
int j, k; |
float *s; |
long tmp; |
s = m_sample; |
for (j = 0; j < 12; j++) |
{ |
k = -1; |
dispatch: |
switch (m_samp_dispatch[++k]) |
{ |
case 0: |
s[k] = 0.0F; |
goto dispatch; |
case 1: |
UNPACKL1_N(2) /* 3 levels */ |
case 2: |
UNPACKL1_N(3) /* 7 levels */ |
case 3: |
UNPACKL1_N(4) /* 15 levels */ |
case 4: |
UNPACKL1_N(5) /* 31 levels */ |
case 5: |
UNPACKL1_N(6) /* 63 levels */ |
case 6: |
UNPACKL1_N(7) /* 127 levels */ |
case 7: |
UNPACKL1_N(8) /* 255 levels */ |
case 8: |
UNPACKL1_N(9) /* 511 levels */ |
case 9: |
UNPACKL1_N(10) /* 1023 levels */ |
case 10: |
UNPACKL1_N(11) /* 2047 levels */ |
case 11: |
UNPACKL1_N(12) /* 4095 levels */ |
case 12: |
UNPACKL1_N(13) /* 8191 levels */ |
case 13: |
UNPACKL1_N(14) /* 16383 levels */ |
case 14: |
UNPACKL1_N(15) /* 32767 levels */ |
/* -- joint ---- */ |
case 15 + 0: |
s[k + 1] = s[k] = 0.0F; |
k++; /* skip right chan dispatch */ |
goto dispatch; |
/* -- joint ---- */ |
case 15 + 1: |
UNPACKL1J_N(2) /* 3 levels */ |
case 15 + 2: |
UNPACKL1J_N(3) /* 7 levels */ |
case 15 + 3: |
UNPACKL1J_N(4) /* 15 levels */ |
case 15 + 4: |
UNPACKL1J_N(5) /* 31 levels */ |
case 15 + 5: |
UNPACKL1J_N(6) /* 63 levels */ |
case 15 + 6: |
UNPACKL1J_N(7) /* 127 levels */ |
case 15 + 7: |
UNPACKL1J_N(8) /* 255 levels */ |
case 15 + 8: |
UNPACKL1J_N(9) /* 511 levels */ |
case 15 + 9: |
UNPACKL1J_N(10) /* 1023 levels */ |
case 15 + 10: |
UNPACKL1J_N(11) /* 2047 levels */ |
case 15 + 11: |
UNPACKL1J_N(12) /* 4095 levels */ |
case 15 + 12: |
UNPACKL1J_N(13) /* 8191 levels */ |
case 15 + 13: |
UNPACKL1J_N(14) /* 16383 levels */ |
case 15 + 14: |
UNPACKL1J_N(15) /* 32767 levels */ |
/* -- end of dispatch -- */ |
case 31: |
bitget_skip(m_bit_skip); |
case 30: |
s += 64; |
} /* end switch */ |
} /* end j loop */ |
} |
/programs/media/ac97snd/trunk/mp3dec/l1init.c |
---|
0,0 → 1,87 |
#include "bstream.h" |
#include "mp3dec.h" |
#include <math.h> |
extern MPEG_DECODE_OPTION m_option; |
extern int m_frequency; |
extern float m_sample[2304]; |
extern int m_nsb_limit; |
extern int m_max_sb; |
extern int m_stereo_sb; |
extern SBT_PROC m_sbt_proc; |
extern float m_look_c_valueL1[18]; |
extern int m_nbatL1; |
//extern "sbt.c" |
void sbt_mono(float *sample, signed short *pcm, int ch); |
void sbt_dual(float *sample, signed short *pcm, int ch); |
void sbt16_mono(float *sample, signed short *pcm, int ch); |
void sbt16_dual(float *sample, signed short *pcm, int ch); |
void sbt8_mono(float *sample, signed short *pcm, int ch); |
void sbt8_dual(float *sample, signed short *pcm, int ch); |
void sbtB_mono(float *sample, unsigned char *pcm, int ch); |
void sbtB_dual(float *sample, unsigned char *pcm, int ch); |
void sbtB16_mono(float *sample, unsigned char *pcm, int ch); |
void sbtB16_dual(float *sample, unsigned char *pcm, int ch); |
void sbtB8_mono(float *sample, unsigned char *pcm, int ch); |
void sbtB8_dual(float *sample, unsigned char *pcm, int ch); |
static const SBT_PROC sbt_table[2][3][2] = |
{ |
sbt_mono, |
sbt_dual, |
sbt16_mono, |
sbt16_dual, |
sbt8_mono, |
sbt8_dual, |
sbtB_mono, |
sbtB_dual, |
sbtB16_mono, |
sbtB16_dual, |
sbtB8_mono, |
sbtB8_dual, |
}; |
void L1table_init() |
{ |
int i, stepL1; |
for (stepL1 = 4, i = 1; i < 16; i++, stepL1 <<= 1) { |
m_look_c_valueL1[i] = (float) (2.0 / (stepL1 - 1)); |
} |
} |
int L1decode_start(MPEG_HEADER* h) |
{ |
int i, k, bit_code, limit; |
/*- caller limit -*/ |
m_nbatL1 = 32; |
m_max_sb = m_nbatL1; |
m_nsb_limit = (m_option.freqLimit * 64L + m_frequency / 2) / m_frequency; |
/*---- limit = 0.94*(32>>reduction_code); ----*/ |
limit = (32 >> m_option.reduction); |
if (limit > 8) |
limit--; |
if (m_nsb_limit > limit) |
m_nsb_limit = limit; |
if (m_nsb_limit > m_max_sb) |
m_nsb_limit = m_max_sb; |
if (h->mode != 3) { /* adjust for 2 channel modes */ |
m_nbatL1 *= 2; |
m_max_sb *= 2; |
m_nsb_limit *= 2; |
} |
/* set sbt function */ |
bit_code = (m_option.convert & 8) ? 1 : 0; |
k = (h->mode == 3) ? 0 : (1 + m_option.convert); |
m_sbt_proc = sbt_table[bit_code][m_option.reduction][k];//[2][3][2] |
for (i = 0; i < 768; i++) |
m_sample[i] = 0.0F; |
return 1; |
} |
/programs/media/ac97snd/trunk/mp3dec/l2dec.c |
---|
0,0 → 1,306 |
#include "bstream.h" |
#include "mp3dec.h" |
extern float m_sample[2304]; |
extern int m_nsb_limit; |
int m_stereo_sb; |
int m_max_sb; |
SBT_PROC m_sbt_proc; |
float m_sf_table[64]; |
float m_look_c_valueL2[18]; |
char m_group3_table[32][3]; |
char m_group5_table[128][3]; |
short m_group9_table[1024][3]; |
int m_nbat[4];// = {3, 8, 12, 7}; |
int m_bat[4][16]; |
int m_ballo[64]; |
uint m_samp_dispatch[66]; |
float m_c_value[64]; |
uint m_sf_dispatch[66]; |
float m_cs_factor[3][64]; |
int m_bit_skip; |
static const int look_joint[16] = |
{ /* lookup stereo sb's by mode+ext */ |
64, 64, 64, 64, /* stereo */ |
2 * 4, 2 * 8, 2 * 12, 2 * 16, /* joint */ |
64, 64, 64, 64, /* dual */ |
32, 32, 32, 32, /* mono */ |
}; |
static const int bat_bit_masterL2[] = |
{ |
0, 5, 7, 9, 10, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48 |
}; |
void unpack_ba(); |
void unpack_sfs(); |
void unpack_sf(); |
void unpack_samp(); |
void L2decode_frame(MPEG_HEADER* h, byte* mpeg, byte* pcm) |
{ |
int crc_size; |
crc_size = (h->error_prot) ? 2 : 0; |
bitget_init(mpeg + 4 + crc_size); |
m_stereo_sb = look_joint[(h->mode << 2) + h->mode_ext]; |
unpack_ba(); // unpack bit allocation |
unpack_sfs(); // unpack scale factor selectors |
unpack_sf(); // unpack scale factor |
unpack_samp(); // unpack samples |
m_sbt_proc(m_sample, pcm, 36); |
} |
void unpack_ba() |
{ |
int i, j, k; |
int nstereo; |
int nbit[4] = {4, 4, 3, 2}; |
m_bit_skip = 0; |
nstereo = m_stereo_sb; |
k = 0; |
for (i = 0; i < 4; i++) { |
for (j = 0; j < m_nbat[i]; j++, k++) { |
bitget_check(4); |
m_ballo[k] = m_samp_dispatch[k] = m_bat[i][mac_bitget(nbit[i])]; |
if (k >= m_nsb_limit) |
m_bit_skip += bat_bit_masterL2[m_samp_dispatch[k]]; |
m_c_value[k] = m_look_c_valueL2[m_samp_dispatch[k]]; |
if (--nstereo < 0) { |
m_ballo[k + 1] = m_ballo[k]; |
m_samp_dispatch[k] += 18; /* flag as joint */ |
m_samp_dispatch[k + 1] = m_samp_dispatch[k]; /* flag for sf */ |
m_c_value[k + 1] = m_c_value[k]; |
k++; |
j++; |
} |
} |
} |
m_samp_dispatch[m_nsb_limit] = 37; /* terminate the dispatcher with skip */ |
m_samp_dispatch[k] = 36; /* terminate the dispatcher */ |
} |
void unpack_sfs() /* unpack scale factor selectors */ |
{ |
int i; |
for (i = 0; i < m_max_sb; i++) { |
bitget_check(2); |
if (m_ballo[i]) |
m_sf_dispatch[i] = mac_bitget(2); |
else |
m_sf_dispatch[i] = 4; /* no allo */ |
} |
m_sf_dispatch[i] = 5; /* terminate dispatcher */ |
} |
void unpack_sf() /* unpack scale factor */ |
{ /* combine dequant and scale factors */ |
int i; |
i = -1; |
dispatch:switch (m_sf_dispatch[++i]) |
{ |
case 0: /* 3 factors 012 */ |
bitget_check(18); |
m_cs_factor[0][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
m_cs_factor[1][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
m_cs_factor[2][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
goto dispatch; |
case 1: /* 2 factors 002 */ |
bitget_check(12); |
m_cs_factor[1][i] = m_cs_factor[0][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
m_cs_factor[2][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
goto dispatch; |
case 2: /* 1 factor 000 */ |
bitget_check(6); |
m_cs_factor[2][i] = m_cs_factor[1][i] = m_cs_factor[0][i] = |
m_c_value[i] * m_sf_table[mac_bitget(6)]; |
goto dispatch; |
case 3: /* 2 factors 022 */ |
bitget_check(12); |
m_cs_factor[0][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
m_cs_factor[2][i] = m_cs_factor[1][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
goto dispatch; |
case 4: /* no allo */ |
/*-- m_cs_factor[2][i] = m_cs_factor[1][i] = m_cs_factor[0][i] = 0.0; --*/ |
goto dispatch; |
case 5: /* all done */ |
; |
} /* end switch */ |
} |
/*-------------------------------------------------------------------------*/ |
#define UNPACK_N(n) s[k] = m_cs_factor[i][k]*(bitget(n)-((1 << n-1) -1)); \ |
s[k+64] = m_cs_factor[i][k]*(bitget(n)-((1 << n-1) -1)); \ |
s[k+128] = m_cs_factor[i][k]*(bitget(n)-((1 << n-1) -1)); \ |
goto dispatch; |
#define UNPACK_N2(n) bitget_check(3*n); \ |
s[k] = m_cs_factor[i][k]*(mac_bitget(n)-((1 << n-1) -1)); \ |
s[k+64] = m_cs_factor[i][k]*(mac_bitget(n)-((1 << n-1) -1)); \ |
s[k+128] = m_cs_factor[i][k]*(mac_bitget(n)-((1 << n-1) -1)); \ |
goto dispatch; |
#define UNPACK_N3(n) bitget_check(2*n); \ |
s[k] = m_cs_factor[i][k]*(mac_bitget(n)-((1 << n-1) -1)); \ |
s[k+64] = m_cs_factor[i][k]*(mac_bitget(n)-((1 << n-1) -1)); \ |
bitget_check(n); \ |
s[k+128] = m_cs_factor[i][k]*(mac_bitget(n)-((1 << n-1) -1)); \ |
goto dispatch; |
#define UNPACKJ_N(n) tmp = (bitget(n)-((1 << n-1) -1)); \ |
s[k] = m_cs_factor[i][k]*tmp; \ |
s[k+1] = m_cs_factor[i][k+1]*tmp; \ |
tmp = (bitget(n)-((1 << n-1) -1)); \ |
s[k+64] = m_cs_factor[i][k]*tmp; \ |
s[k+64+1] = m_cs_factor[i][k+1]*tmp; \ |
tmp = (bitget(n)-((1 << n-1) -1)); \ |
s[k+128] = m_cs_factor[i][k]*tmp; \ |
s[k+128+1] = m_cs_factor[i][k+1]*tmp; \ |
k++; /* skip right chan dispatch */ \ |
goto dispatch; |
/*-------------------------------------------------------------------------*/ |
void unpack_samp() /* unpack samples */ |
{ |
int i, j, k; |
float *s; |
int n; |
long tmp; |
s = m_sample; |
for (i = 0; i < 3; i++) |
{ /* 3 groups of scale factors */ |
for (j = 0; j < 4; j++) |
{ |
k = -1; |
dispatch:switch (m_samp_dispatch[++k]) |
{ |
case 0: |
s[k + 128] = s[k + 64] = s[k] = 0.0F; |
goto dispatch; |
case 1: /* 3 levels grouped 5 bits */ |
bitget_check(5); |
n = mac_bitget(5); |
s[k] = m_cs_factor[i][k] * m_group3_table[n][0]; |
s[k + 64] = m_cs_factor[i][k] * m_group3_table[n][1]; |
s[k + 128] = m_cs_factor[i][k] * m_group3_table[n][2]; |
goto dispatch; |
case 2: /* 5 levels grouped 7 bits */ |
bitget_check(7); |
n = mac_bitget(7); |
s[k] = m_cs_factor[i][k] * m_group5_table[n][0]; |
s[k + 64] = m_cs_factor[i][k] * m_group5_table[n][1]; |
s[k + 128] = m_cs_factor[i][k] * m_group5_table[n][2]; |
goto dispatch; |
case 3: |
UNPACK_N2(3) /* 7 levels */ |
case 4: /* 9 levels grouped 10 bits */ |
bitget_check(10); |
n = mac_bitget(10); |
s[k] = m_cs_factor[i][k] * m_group9_table[n][0]; |
s[k + 64] = m_cs_factor[i][k] * m_group9_table[n][1]; |
s[k + 128] = m_cs_factor[i][k] * m_group9_table[n][2]; |
goto dispatch; |
case 5: |
UNPACK_N2(4) /* 15 levels */ |
case 6: |
UNPACK_N2(5) /* 31 levels */ |
case 7: |
UNPACK_N2(6) /* 63 levels */ |
case 8: |
UNPACK_N2(7) /* 127 levels */ |
case 9: |
UNPACK_N2(8) /* 255 levels */ |
case 10: |
UNPACK_N3(9) /* 511 levels */ |
case 11: |
UNPACK_N3(10) /* 1023 levels */ |
case 12: |
UNPACK_N3(11) /* 2047 levels */ |
case 13: |
UNPACK_N3(12) /* 4095 levels */ |
case 14: |
UNPACK_N(13) /* 8191 levels */ |
case 15: |
UNPACK_N(14) /* 16383 levels */ |
case 16: |
UNPACK_N(15) /* 32767 levels */ |
case 17: |
UNPACK_N(16) /* 65535 levels */ |
/* -- joint ---- */ |
case 18 + 0: |
s[k + 128 + 1] = s[k + 128] = s[k + 64 + 1] = s[k + 64] = s[k + 1] = s[k] = 0.0F; |
k++; /* skip right chan dispatch */ |
goto dispatch; |
case 18 + 1: /* 3 levels grouped 5 bits */ |
n = bitget(5); |
s[k] = m_cs_factor[i][k] * m_group3_table[n][0]; |
s[k + 1] = m_cs_factor[i][k + 1] * m_group3_table[n][0]; |
s[k + 64] = m_cs_factor[i][k] * m_group3_table[n][1]; |
s[k + 64 + 1] = m_cs_factor[i][k + 1] * m_group3_table[n][1]; |
s[k + 128] = m_cs_factor[i][k] * m_group3_table[n][2]; |
s[k + 128 + 1] = m_cs_factor[i][k + 1] * m_group3_table[n][2]; |
k++; /* skip right chan dispatch */ |
goto dispatch; |
case 18 + 2: /* 5 levels grouped 7 bits */ |
n = bitget(7); |
s[k] = m_cs_factor[i][k] * m_group5_table[n][0]; |
s[k + 1] = m_cs_factor[i][k + 1] * m_group5_table[n][0]; |
s[k + 64] = m_cs_factor[i][k] * m_group5_table[n][1]; |
s[k + 64 + 1] = m_cs_factor[i][k + 1] * m_group5_table[n][1]; |
s[k + 128] = m_cs_factor[i][k] * m_group5_table[n][2]; |
s[k + 128 + 1] = m_cs_factor[i][k + 1] * m_group5_table[n][2]; |
k++; /* skip right chan dispatch */ |
goto dispatch; |
case 18 + 3: |
UNPACKJ_N(3) /* 7 levels */ |
case 18 + 4: /* 9 levels grouped 10 bits */ |
n = bitget(10); |
s[k] = m_cs_factor[i][k] * m_group9_table[n][0]; |
s[k + 1] = m_cs_factor[i][k + 1] * m_group9_table[n][0]; |
s[k + 64] = m_cs_factor[i][k] * m_group9_table[n][1]; |
s[k + 64 + 1] = m_cs_factor[i][k + 1] * m_group9_table[n][1]; |
s[k + 128] = m_cs_factor[i][k] * m_group9_table[n][2]; |
s[k + 128 + 1] = m_cs_factor[i][k + 1] * m_group9_table[n][2]; |
k++; /* skip right chan dispatch */ |
goto dispatch; |
case 18 + 5: |
UNPACKJ_N(4) /* 15 levels */ |
case 18 + 6: |
UNPACKJ_N(5) /* 31 levels */ |
case 18 + 7: |
UNPACKJ_N(6) /* 63 levels */ |
case 18 + 8: |
UNPACKJ_N(7) /* 127 levels */ |
case 18 + 9: |
UNPACKJ_N(8) /* 255 levels */ |
case 18 + 10: |
UNPACKJ_N(9) /* 511 levels */ |
case 18 + 11: |
UNPACKJ_N(10) /* 1023 levels */ |
case 18 + 12: |
UNPACKJ_N(11) /* 2047 levels */ |
case 18 + 13: |
UNPACKJ_N(12) /* 4095 levels */ |
case 18 + 14: |
UNPACKJ_N(13) /* 8191 levels */ |
case 18 + 15: |
UNPACKJ_N(14) /* 16383 levels */ |
case 18 + 16: |
UNPACKJ_N(15) /* 32767 levels */ |
case 18 + 17: |
UNPACKJ_N(16) /* 65535 levels */ |
/* -- end of dispatch -- */ |
case 37: |
bitget_skip(m_bit_skip); |
case 36: |
s += 3 * 64; |
} /* end switch */ |
} /* end j loop */ |
} /* end i loop */ |
} |
/programs/media/ac97snd/trunk/mp3dec/l2init.c |
---|
0,0 → 1,205 |
#include "bstream.h" |
#include "mp3dec.h" |
#include <math.h> |
extern MPEG_DECODE_OPTION m_option; |
extern int m_frequency; |
extern float m_sample[2304]; |
extern int m_nsb_limit; |
extern int m_max_sb; |
extern SBT_PROC m_sbt_proc; |
extern float m_sf_table[64]; |
extern float m_look_c_valueL2[18]; |
extern char m_group3_table[32][3]; |
extern char m_group5_table[128][3]; |
extern short m_group9_table[1024][3]; |
extern int m_nbat[4];// = {3, 8, 12, 7}; |
extern int m_bat[4][16]; |
/* ABCD_INDEX = lookqt[mode][sr_index][br_index] */ |
/* -1 = invalid */ |
static const char lookqt[4][3][16] = |
{ |
1, -1, -1, -1, 2, -1, 2, 0, 0, 0, 1, 1, 1, 1, 1, -1, /* 44ks stereo */ |
0, -1, -1, -1, 2, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, -1, /* 48ks */ |
1, -1, -1, -1, 3, -1, 3, 0, 0, 0, 1, 1, 1, 1, 1, -1, /* 32ks */ |
1, -1, -1, -1, 2, -1, 2, 0, 0, 0, 1, 1, 1, 1, 1, -1, /* 44ks joint stereo */ |
0, -1, -1, -1, 2, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, -1, /* 48ks */ |
1, -1, -1, -1, 3, -1, 3, 0, 0, 0, 1, 1, 1, 1, 1, -1, /* 32ks */ |
1, -1, -1, -1, 2, -1, 2, 0, 0, 0, 1, 1, 1, 1, 1, -1, /* 44ks dual chan */ |
0, -1, -1, -1, 2, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, -1, /* 48ks */ |
1, -1, -1, -1, 3, -1, 3, 0, 0, 0, 1, 1, 1, 1, 1, -1, /* 32ks */ |
// mono extended beyond legal br index |
// 1,2,2,0,0,0,1,1,1,1,1,1,1,1,1,-1, /* 44ks single chan */ |
// 0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,-1, /* 48ks */ |
// 1,3,3,0,0,0,1,1,1,1,1,1,1,1,1,-1, /* 32ks */ |
// legal mono |
1, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, /* 44ks single chan */ |
0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, /* 48ks */ |
1, 3, 3, 0, 0, 0, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, /* 32ks */ |
}; |
/* bit allocation table look up */ |
/* table per mpeg spec tables 3b2a/b/c/d /e is mpeg2 */ |
/* look_bat[abcd_index][4][16] */ |
static const unsigned char look_bat[5][4][16] = |
{ |
/* LOOK_BATA */ |
0, 1, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, |
0, 1, 2, 3, 4, 5, 6, 17, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 1, 2, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
/* LOOK_BATB */ |
0, 1, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, |
0, 1, 2, 3, 4, 5, 6, 17, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 1, 2, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
/* LOOK_BATC */ |
0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 1, 2, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
/* LOOK_BATD */ |
0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 1, 2, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
/* LOOK_BATE */ |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 1, 2, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 1, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
}; |
/* look_nbat[abcd_index]][4] */ |
static const unsigned char look_nbat[5][4] = |
{ |
3, 8, 12, 4, |
3, 8, 12, 7, |
2, 0, 6, 0, |
2, 0, 10, 0, |
4, 0, 7, 19, |
}; |
//extern "sbt.c" |
void sbt_mono(float *sample, signed short *pcm, int ch); |
void sbt_dual(float *sample, signed short *pcm, int ch); |
void sbt16_mono(float *sample, signed short *pcm, int ch); |
void sbt16_dual(float *sample, signed short *pcm, int ch); |
void sbt8_mono(float *sample, signed short *pcm, int ch); |
void sbt8_dual(float *sample, signed short *pcm, int ch); |
void sbtB_mono(float *sample, unsigned char *pcm, int ch); |
void sbtB_dual(float *sample, unsigned char *pcm, int ch); |
void sbtB16_mono(float *sample, unsigned char *pcm, int ch); |
void sbtB16_dual(float *sample, unsigned char *pcm, int ch); |
void sbtB8_mono(float *sample, unsigned char *pcm, int ch); |
void sbtB8_dual(float *sample, unsigned char *pcm, int ch); |
static const SBT_PROC sbt_table[2][3][2] = |
{ |
sbt_mono, |
sbt_dual, |
sbt16_mono, |
sbt16_dual, |
sbt8_mono, |
sbt8_dual, |
sbtB_mono, |
sbtB_dual, |
sbtB16_mono, |
sbtB16_dual, |
sbtB8_mono, |
sbtB8_dual, |
}; |
void L2table_init() |
{ |
int i, j, code; |
long stepL2[18] = { |
0, 3, 5, 7, 9, 15, 31, 63, 127, |
255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535 |
}; |
//c_values (dequant) |
for (i = 1; i < 18; i++) { |
m_look_c_valueL2[i] = 2.0F / stepL2[i]; |
} |
//scale factor table, scale by 32768 for 16 pcm output |
for (i = 0; i < 64; i++) { |
m_sf_table[i] = (float) (32768.0 * 2.0 * pow_test(2.0, -i / 3.0)); |
} |
//grouped 3 level lookup table 5 bit token |
for (i = 0; i < 32; i++) { |
code = i; |
for (j = 0; j < 3; j++) { |
m_group3_table[i][j] = (char) ((code % 3) - 1); |
code /= 3; |
} |
} |
//grouped 5 level lookup table 7 bit token |
for (i = 0; i < 128; i++) { |
code = i; |
for (j = 0; j < 3; j++) { |
m_group5_table[i][j] = (char) ((code % 5) - 2); |
code /= 5; |
} |
} |
//grouped 9 level lookup table 10 bit token |
for (i = 0; i < 1024; i++) { |
code = i; |
for (j = 0; j < 3; j++) { |
m_group9_table[i][j] = (short) ((code % 9) - 4); |
code /= 9; |
} |
} |
} |
int L2decode_start(MPEG_HEADER* h) |
{ |
int i, j, k, bit_code, limit; |
int abcd_index; |
// compute abcd index for bit allo table selection |
if (h->version == 1) // MPEG-1 |
abcd_index = lookqt[h->mode][h->fr_index][h->br_index]; |
else |
abcd_index = 4; // MPEG-2, MPEG-2.5 |
if (abcd_index < 0) |
return 0; // fail invalid Layer II bit rate index |
for (i = 0; i < 4; i++) { |
m_nbat[i] = look_nbat[abcd_index][i]; |
for (j = 0; j < 16; j++) { |
m_bat[i][j] = look_bat[abcd_index][i][j]; |
} |
} |
m_max_sb = m_nbat[0] + m_nbat[1] + m_nbat[2] + m_nbat[3]; |
// compute nsb_limit |
m_nsb_limit = (m_option.freqLimit * 64L + m_frequency / 2) / m_frequency; |
// caller limit |
// limit = 0.94*(32>>reduction_code); |
limit = (32 >> m_option.reduction); |
if (limit > 8) |
limit--; |
if (m_nsb_limit > limit) |
m_nsb_limit = limit; |
if (m_nsb_limit > m_max_sb) |
m_nsb_limit = m_max_sb; |
if (h->mode != 3) { |
// adjust for 2 channel modes |
for (i = 0; i < 4; i++) |
m_nbat[i] *= 2; |
m_max_sb *= 2; |
m_nsb_limit *= 2; |
} |
// set sbt function |
bit_code = (m_option.convert & 8) ? 1 : 0; |
k = (h->mode == 3) ? 0 : (1 + m_option.convert); |
m_sbt_proc = sbt_table[bit_code][m_option.reduction][k];//[2][3][2] |
// clear sample buffer, unused sub bands must be 0 |
for (i = 0; i < 2304; i++) |
m_sample[i] = 0.0F; |
return 1; |
} |
/programs/media/ac97snd/trunk/mp3dec/l3alias.c |
---|
0,0 → 1,38 |
#include <math.h> //sqrt |
static float csa[8][2]; /* antialias */ |
void alias_init() |
{ |
float Ci[8] = |
{ |
-0.6f, -0.535f, -0.33f, -0.185f, -0.095f, -0.041f, -0.0142f, -0.0037f |
}; |
int i; |
for (i = 0; i < 8; i++) |
{ |
csa[i][0] = (float) (1.0 / sqrt(1.0 + Ci[i] * Ci[i])); |
csa[i][1] = (float) (Ci[i] / sqrt(1.0 + Ci[i] * Ci[i])); |
} |
} |
void antialias(float x[], int n) |
{ |
int i, k; |
float a, b; |
for (k = 0; k < n; k++) |
{ |
for (i = 0; i < 8; i++) |
{ |
a = x[17 - i]; |
b = x[18 + i]; |
x[17 - i] = a * csa[i][0] - b * csa[i][1]; |
x[18 + i] = b * csa[i][0] + a * csa[i][1]; |
} |
x += 18; |
} |
} |
/programs/media/ac97snd/trunk/mp3dec/l3dec.c |
---|
0,0 → 1,350 |
#include "layer3.h" |
#include <string.h> |
#include <math.h> |
#ifndef min |
#define max(a,b) (((a) > (b)) ? (a) : (b)) |
#define min(a,b) (((a) < (b)) ? (a) : (b)) |
#endif |
extern int m_frame_size, m_pcm_size; |
// shared |
SAMPLE m_sample[2][2][576];//- sample union of int/float sample[ch][gr][576] |
int m_nsb_limit; |
SBT_PROC m_sbt_proc; |
XFORM_PROC m_xform_proc; |
int m_channels; //(mode == 3) ? 1 : 2 |
int m_ms_mode, m_is_mode; |
int m_sfBandIndex[2][22];// [long/short][cb] |
int m_nBand[2][22]; |
int m_band_limit; |
int m_band_limit21; // limit for sf band 21 |
int m_band_limit12; // limit for sf band 12 short |
int m_band_limit_nsb; |
int m_ncbl_mixed; |
SIDE_INFO m_side_info; |
SCALE_FACTOR m_scale_fac[2][2]; // [gr][ch] |
CB_INFO m_cb_info[2][2]; // [gr][ch] |
IS_SF_INFO m_is_sf_info; |
#define NBUF (8*1024) |
#define BUF_TRIGGER (NBUF-1500) |
int m_gr; |
int m_main_pos_bit; |
byte m_buf[NBUF]; |
int m_buf_ptr0, m_buf_ptr1; |
int m_nsamp[2][2]; // must start = 0, for m_nsamp[igr_prev] |
float m_yout[576]; // hybrid out, sbt in |
//extern "l3side.c" |
int L3get_side_info1(); |
int L3get_side_info2(int gr); |
//extern "l3sf.c" |
void L3get_scale_factor1(int gr, int ch); |
void L3get_scale_factor2(int gr, int ch); |
void huffman(void *xy, int n, int ntable); |
int huffman_quad(void *vwxy, int n, int nbits, int ntable); |
void dequant(SAMPLE sample[], int gr, int ch); |
void antialias(void *x, int n); |
void ms_process(void *x, int n); |
void is_process1(void *x, SCALE_FACTOR* sf, |
CB_INFO cb_info[2], int nsamp); |
void is_process2(void *x, SCALE_FACTOR * sf, |
CB_INFO cb_info[2], int nsamp); |
//extern "l3hybrid.c" |
int hybrid(void *xin, void *xprev, float *y, |
int btype, int nlong, int ntot, int nprev); |
int hybrid_sum(void *xin, void *xin_left, float *y, |
int btype, int nlong, int ntot); |
void sum_f_bands(void *a, void *b, int n); |
void freq_invert(float *y, int n); /* xform, */ |
void L3decode_main(MPEG_HEADER* h, byte *pcm, int gr); |
void L3decode_reset() |
{ |
m_buf_ptr0 = m_buf_ptr1 = 0; |
} |
void L3decode_frame(MPEG_HEADER* h, byte* mpeg, byte* pcm) |
{ |
int crc_size, side_size; |
int copy_size; |
if (h->mode == 1) { |
m_ms_mode = h->mode_ext >> 1; |
m_is_mode = h->mode_ext & 1; |
} |
else { |
m_ms_mode = 0; |
m_is_mode = 0; |
} |
crc_size = (h->error_prot) ? 2 : 0; |
bitget_init(mpeg + 4 + crc_size); |
if (h->version == 1) |
side_size = L3get_side_info1(); |
else |
side_size = L3get_side_info2(m_gr); |
m_buf_ptr0 = m_buf_ptr1 - m_side_info.main_data_begin;/* decode start point */ |
if (m_buf_ptr1 > BUF_TRIGGER) { /* shift buffer */ |
memmove(m_buf, m_buf + m_buf_ptr0, m_side_info.main_data_begin); |
m_buf_ptr0 = 0; |
m_buf_ptr1 = m_side_info.main_data_begin; |
} |
copy_size = m_frame_size - (4 + crc_size + side_size); |
//24/02/02 X-MaD |
if (copy_size < 0) { copy_size = copy_size * -1; } |
//if (copy_size < 0) { copy_size = 0; } |
//__try { |
memmove(m_buf + m_buf_ptr1, mpeg + (4 + crc_size + side_size), copy_size); |
//} __except(0){ |
// m_buf_ptr1 = 0; |
//} |
m_buf_ptr1 += copy_size; |
//24/02/02 X-MaD |
if (m_buf_ptr0 >= 0) { |
m_main_pos_bit = m_buf_ptr0 << 3; |
if (h->version == 1) { |
L3decode_main(h, pcm, 0); |
L3decode_main(h, pcm + (m_pcm_size / 2), 1); |
} |
else { |
L3decode_main(h, pcm, m_gr); |
m_gr = m_gr ^ 1; |
} |
} |
} |
void L3decode_main(MPEG_HEADER* h, byte *pcm, int gr) |
{ |
int ch; |
int n1, n2, n3, n4, nn2, nn3, nn4; |
int bit0, qbits, m0; |
for (ch = 0; ch < m_channels; ch ++) { |
bitget_init(m_buf + (m_main_pos_bit >> 3)); |
bit0 = (m_main_pos_bit & 7); |
if (bit0) bitget(bit0); |
m_main_pos_bit += m_side_info.gr[gr][ch].part2_3_length; |
bitget_init_end(m_buf + ((m_main_pos_bit + 39) >> 3)); |
// scale factors |
if (h->version == 1) |
L3get_scale_factor1(gr, ch); |
else |
L3get_scale_factor2(gr, ch); |
// huff data |
n1 = m_sfBandIndex[0][m_side_info.gr[gr][ch].region0_count]; |
n2 = m_sfBandIndex[0][m_side_info.gr[gr][ch].region0_count |
+ m_side_info.gr[gr][ch].region1_count + 1]; |
n3 = m_side_info.gr[gr][ch].big_values; |
n3 = n3 + n3; |
if (n3 > m_band_limit) n3 = m_band_limit; |
if (n2 > n3) n2 = n3; |
if (n1 > n3) n1 = n3; |
nn3 = n3 - n2; |
nn2 = n2 - n1; |
huffman(m_sample[ch][gr], n1, m_side_info.gr[gr][ch].table_select[0]); |
huffman(m_sample[ch][gr] + n1, nn2, m_side_info.gr[gr][ch].table_select[1]); |
huffman(m_sample[ch][gr] + n2, nn3, m_side_info.gr[gr][ch].table_select[2]); |
qbits = m_side_info.gr[gr][ch].part2_3_length - (bitget_bits_used() - bit0); |
nn4 = huffman_quad(m_sample[ch][gr] + n3, m_band_limit - n3, qbits, |
m_side_info.gr[gr][ch].count1table_select); |
n4 = n3 + nn4; |
m_nsamp[gr][ch] = n4; |
// limit n4 or allow deqaunt to sf band 22 |
if (m_side_info.gr[gr][ch].block_type == 2) |
n4 = min(n4, m_band_limit12); |
else |
n4 = min(n4, m_band_limit21); |
if (n4 < 576) |
memset(m_sample[ch][gr] + n4, 0, sizeof(SAMPLE) * (576 - n4)); |
if (bitget_overrun()) |
memset(m_sample[ch][gr], 0, sizeof(SAMPLE) * (576)); |
} |
// dequant |
for (ch = 0; ch < m_channels; ch++) { |
dequant(m_sample[ch][gr], gr, ch); |
} |
// ms stereo processing |
if (m_ms_mode) { |
if (m_is_mode == 0) { |
m0 = m_nsamp[gr][0]; // process to longer of left/right |
if (m0 < m_nsamp[gr][1]) |
m0 = m_nsamp[gr][1]; |
} |
else {// process to last cb in right |
m0 = m_sfBandIndex[m_cb_info[gr][1].cbtype][m_cb_info[gr][1].cbmax]; |
} |
ms_process(m_sample[0][gr], m0); |
} |
// is stereo processing |
if (m_is_mode) { |
if (h->version == 1) |
is_process1(m_sample[0][gr], &m_scale_fac[gr][1], |
m_cb_info[gr], m_nsamp[gr][0]); |
else |
is_process2(m_sample[0][gr], &m_scale_fac[gr][1], |
m_cb_info[gr], m_nsamp[gr][0]); |
} |
// adjust ms and is modes to max of left/right |
if (m_ms_mode || m_is_mode) { |
if (m_nsamp[gr][0] < m_nsamp[gr][1]) |
m_nsamp[gr][0] = m_nsamp[gr][1]; |
else |
m_nsamp[gr][1] = m_nsamp[gr][0]; |
} |
// antialias |
for (ch = 0; ch < m_channels; ch ++) { |
if (m_cb_info[gr][ch].ncbl == 0) |
continue; // have no long blocks |
if (m_side_info.gr[gr][ch].mixed_block_flag) |
n1 = 1; // 1 -> 36 samples |
else |
n1 = (m_nsamp[gr][ch] + 7) / 18; |
if (n1 > 31) |
n1 = 31; |
antialias(m_sample[ch][gr], n1); |
n1 = 18 * n1 + 8; // update number of samples |
if (n1 > m_nsamp[gr][ch]) |
m_nsamp[gr][ch] = n1; |
} |
// hybrid + sbt |
m_xform_proc(pcm, gr); |
} |
void xform_mono(void *pcm, int igr) |
{ |
int igr_prev, n1, n2; |
// hybrid + sbt |
n1 = n2 = m_nsamp[igr][0]; // total number bands |
if (m_side_info.gr[igr][0].block_type == 2) { // long bands |
if (m_side_info.gr[igr][0].mixed_block_flag) |
n1 = m_sfBandIndex[0][m_ncbl_mixed - 1]; |
else |
n1 = 0; |
} |
if (n1 > m_band_limit) |
n1 = m_band_limit; |
if (n2 > m_band_limit) |
n2 = m_band_limit; |
igr_prev = igr ^ 1; |
m_nsamp[igr][0] = hybrid(m_sample[0][igr], m_sample[0][igr_prev], |
m_yout, m_side_info.gr[igr][0].block_type, n1, n2, m_nsamp[igr_prev][0]); |
freq_invert(m_yout, m_nsamp[igr][0]); |
m_sbt_proc(m_yout, pcm, 0); |
} |
void xform_dual_right(void *pcm, int igr) |
{ |
int igr_prev, n1, n2; |
// hybrid + sbt |
n1 = n2 = m_nsamp[igr][1]; // total number bands |
if (m_side_info.gr[igr][1].block_type == 2) { // long bands |
if (m_side_info.gr[igr][1].mixed_block_flag) |
n1 = m_sfBandIndex[0][m_ncbl_mixed - 1]; |
else |
n1 = 0; |
} |
if (n1 > m_band_limit) |
n1 = m_band_limit; |
if (n2 > m_band_limit) |
n2 = m_band_limit; |
igr_prev = igr ^ 1; |
m_nsamp[igr][1] = hybrid(m_sample[1][igr], m_sample[1][igr_prev], |
m_yout, m_side_info.gr[igr][1].block_type, n1, n2, m_nsamp[igr_prev][1]); |
freq_invert(m_yout, m_nsamp[igr][1]); |
m_sbt_proc(m_yout, pcm, 0); |
} |
void xform_dual(void *pcm, int igr) |
{ |
int ch; |
int igr_prev, n1, n2; |
// hybrid + sbt |
igr_prev = igr ^ 1; |
for (ch = 0; ch < m_channels; ch++) { |
n1 = n2 = m_nsamp[igr][ch]; // total number bands |
if (m_side_info.gr[igr][ch].block_type == 2) { // long bands |
if (m_side_info.gr[igr][ch].mixed_block_flag) |
n1 = m_sfBandIndex[0][m_ncbl_mixed - 1]; |
else |
n1 = 0; |
} |
if (n1 > m_band_limit) |
n1 = m_band_limit; |
if (n2 > m_band_limit) |
n2 = m_band_limit; |
m_nsamp[igr][ch] = hybrid(m_sample[ch][igr], m_sample[ch][igr_prev], |
m_yout, m_side_info.gr[igr][ch].block_type, n1, n2, m_nsamp[igr_prev][ch]); |
freq_invert(m_yout, m_nsamp[igr][ch]); |
m_sbt_proc(m_yout, pcm, ch); |
} |
} |
void xform_dual_mono(void *pcm, int igr) |
{ |
int igr_prev, n1, n2, n3; |
// hybrid + sbt |
igr_prev = igr ^ 1; |
if ((m_side_info.gr[igr][0].block_type == m_side_info.gr[igr][1].block_type) |
&& (m_side_info.gr[igr][0].mixed_block_flag == 0) |
&& (m_side_info.gr[igr][1].mixed_block_flag == 0)) { |
n2 = m_nsamp[igr][0]; // total number bands max of L R |
if (n2 < m_nsamp[igr][1]) |
n2 = m_nsamp[igr][1]; |
if (n2 > m_band_limit) |
n2 = m_band_limit; |
if (m_side_info.gr[igr][0].block_type == 2) |
n1 = 0; |
else |
n1 = n2; // n1 = number long bands |
sum_f_bands(m_sample[0][igr], m_sample[1][igr], n2); |
n3 = m_nsamp[igr][0] = hybrid(m_sample[0][igr], m_sample[0][igr_prev], |
m_yout, m_side_info.gr[igr][0].block_type, n1, n2, m_nsamp[igr_prev][0]); |
} |
else { // transform and then sum (not tested - never happens in test) |
// left chan |
n1 = n2 = m_nsamp[igr][0]; // total number bands |
if (m_side_info.gr[igr][0].block_type == 2) { // long bands |
if (m_side_info.gr[igr][0].mixed_block_flag) |
n1 = m_sfBandIndex[0][m_ncbl_mixed - 1]; |
else |
n1 = 0; |
} |
n3 = m_nsamp[igr][0] = hybrid(m_sample[0][igr], m_sample[0][igr_prev], |
m_yout, m_side_info.gr[igr][0].block_type, n1, n2, m_nsamp[igr_prev][0]); |
// right chan |
n1 = n2 = m_nsamp[igr][1]; // total number bands |
if (m_side_info.gr[igr][1].block_type == 2) { // long bands |
if (m_side_info.gr[igr][1].mixed_block_flag) |
n1 = m_sfBandIndex[0][m_ncbl_mixed - 1]; |
else |
n1 = 0; |
} |
m_nsamp[igr][1] = hybrid_sum(m_sample[1][igr], m_sample[0][igr], |
m_yout, m_side_info.gr[igr][1].block_type, n1, n2); |
if (n3 < m_nsamp[igr][1]) |
n1 = m_nsamp[igr][1]; |
} |
freq_invert(m_yout, n3); |
m_sbt_proc(m_yout, pcm, 0); |
} |
/programs/media/ac97snd/trunk/mp3dec/l3huff.c |
---|
0,0 → 1,359 |
#include "layer3.h" |
#include "l3huff.h" |
//#ifdef _MSC_VER |
//#pragma warning(disable: 4505) |
//#endif |
/*===============================================================*/ |
/* max bits required for any lookup - change if htable changes */ |
/* quad required 10 bit w/signs must have (MAXBITS+2) >= 10 */ |
#define MAXBITS 9 |
static HUFF_ELEMENT huff_table_0[] = |
{0, 0, 0, 64}; /* dummy must not use */ |
/*-- 6 bit lookup (purgebits, value) --*/ |
static unsigned char quad_table_a[][2] = |
{ |
6, 11, 6, 15, 6, 13, 6, 14, 6, 7, 6, 5, 5, 9, |
5, 9, 5, 6, 5, 6, 5, 3, 5, 3, 5, 10, 5, 10, |
5, 12, 5, 12, 4, 2, 4, 2, 4, 2, 4, 2, 4, 1, |
4, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, |
4, 8, 4, 8, 4, 8, 4, 8, 1, 0, 1, 0, 1, 0, |
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, |
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, |
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, |
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, |
1, 0, |
}; |
typedef struct |
{ |
HUFF_ELEMENT *table; |
int linbits; |
int ncase; |
} |
HUFF_SETUP; |
#define no_bits 0 |
#define one_shot 1 |
#define no_linbits 2 |
#define have_linbits 3 |
#define quad_a 4 |
#define quad_b 5 |
static HUFF_SETUP table_look[] = |
{ |
huff_table_0, 0, no_bits, |
huff_table_1, 0, one_shot, |
huff_table_2, 0, one_shot, |
huff_table_3, 0, one_shot, |
huff_table_0, 0, no_bits, |
huff_table_5, 0, one_shot, |
huff_table_6, 0, one_shot, |
huff_table_7, 0, no_linbits, |
huff_table_8, 0, no_linbits, |
huff_table_9, 0, no_linbits, |
huff_table_10, 0, no_linbits, |
huff_table_11, 0, no_linbits, |
huff_table_12, 0, no_linbits, |
huff_table_13, 0, no_linbits, |
huff_table_0, 0, no_bits, |
huff_table_15, 0, no_linbits, |
huff_table_16, 1, have_linbits, |
huff_table_16, 2, have_linbits, |
huff_table_16, 3, have_linbits, |
huff_table_16, 4, have_linbits, |
huff_table_16, 6, have_linbits, |
huff_table_16, 8, have_linbits, |
huff_table_16, 10, have_linbits, |
huff_table_16, 13, have_linbits, |
huff_table_24, 4, have_linbits, |
huff_table_24, 5, have_linbits, |
huff_table_24, 6, have_linbits, |
huff_table_24, 7, have_linbits, |
huff_table_24, 8, have_linbits, |
huff_table_24, 9, have_linbits, |
huff_table_24, 11, have_linbits, |
huff_table_24, 13, have_linbits, |
huff_table_0, 0, quad_a, |
huff_table_0, 0, quad_b, |
}; |
/*========================================================*/ |
void huffman(int xy[][2], int n, int ntable) |
{ |
int i; |
HUFF_ELEMENT *t; |
HUFF_ELEMENT *t0; |
int linbits; |
int bits; |
int code; |
int x, y; |
if (n <= 0) |
return; |
n = n >> 1; /* huff in pairs */ |
/*-------------*/ |
t0 = table_look[ntable].table; |
linbits = table_look[ntable].linbits; |
switch (table_look[ntable].ncase) |
{ |
default: |
/*------------------------------------------*/ |
case no_bits: |
/*- table 0, no data, x=y=0--*/ |
for (i = 0; i < n; i++) |
{ |
xy[i][0] = 0; |
xy[i][1] = 0; |
} |
return; |
/*------------------------------------------*/ |
case one_shot: |
/*- single lookup, no escapes -*/ |
for (i = 0; i < n; i++) |
{ |
mac_bitget_check((MAXBITS + 2)); |
bits = t0[0].b.signbits; |
code = mac_bitget2(bits); |
mac_bitget_purge(t0[1 + code].b.purgebits); |
x = t0[1 + code].b.x; |
y = t0[1 + code].b.y; |
if (x) |
if (mac_bitget_1bit()) |
x = -x; |
if (y) |
if (mac_bitget_1bit()) |
y = -y; |
xy[i][0] = x; |
xy[i][1] = y; |
if (bitget_overrun()) |
break; // bad data protect |
} |
return; |
/*------------------------------------------*/ |
case no_linbits: |
for (i = 0; i < n; i++) |
{ |
t = t0; |
for (;;) |
{ |
mac_bitget_check((MAXBITS + 2)); |
bits = t[0].b.signbits; |
code = mac_bitget2(bits); |
if (t[1 + code].b.purgebits) |
break; |
t += t[1 + code].ptr; /* ptr include 1+code */ |
mac_bitget_purge(bits); |
} |
mac_bitget_purge(t[1 + code].b.purgebits); |
x = t[1 + code].b.x; |
y = t[1 + code].b.y; |
if (x) |
if (mac_bitget_1bit()) |
x = -x; |
if (y) |
if (mac_bitget_1bit()) |
y = -y; |
xy[i][0] = x; |
xy[i][1] = y; |
if (bitget_overrun()) |
break; // bad data protect |
} |
return; |
/*------------------------------------------*/ |
case have_linbits: |
for (i = 0; i < n; i++) |
{ |
t = t0; |
for (;;) |
{ |
bits = t[0].b.signbits; |
code = bitget2(bits); |
if (t[1 + code].b.purgebits) |
break; |
t += t[1 + code].ptr; /* ptr includes 1+code */ |
mac_bitget_purge(bits); |
} |
mac_bitget_purge(t[1 + code].b.purgebits); |
x = t[1 + code].b.x; |
y = t[1 + code].b.y; |
if (x == 15) |
x += bitget_lb(linbits); |
if (x) |
if (mac_bitget_1bit()) |
x = -x; |
if (y == 15) |
y += bitget_lb(linbits); |
if (y) |
if (mac_bitget_1bit()) |
y = -y; |
xy[i][0] = x; |
xy[i][1] = y; |
if (bitget_overrun()) |
break; // bad data protect |
} |
return; |
} |
/*--- end switch ---*/ |
} |
int huffman_quad(int vwxy[][4], int n, int nbits, int ntable) |
{ |
int i; |
int code; |
int x, y, v, w; |
int tmp; |
int i_non_zero, tmp_nz; |
tmp_nz = 15; |
i_non_zero = -1; |
n = n >> 2; /* huff in quads */ |
if (ntable) |
goto case_quad_b; |
/* case_quad_a: */ |
for (i = 0; i < n; i++) |
{ |
if (nbits <= 0) |
break; |
mac_bitget_check(10); |
code = mac_bitget2(6); |
nbits -= quad_table_a[code][0]; |
mac_bitget_purge(quad_table_a[code][0]); |
tmp = quad_table_a[code][1]; |
if (tmp) |
{ |
i_non_zero = i; |
tmp_nz = tmp; |
} |
v = (tmp >> 3) & 1; |
w = (tmp >> 2) & 1; |
x = (tmp >> 1) & 1; |
y = tmp & 1; |
if (v) |
{ |
if (mac_bitget_1bit()) |
v = -v; |
nbits--; |
} |
if (w) |
{ |
if (mac_bitget_1bit()) |
w = -w; |
nbits--; |
} |
if (x) |
{ |
if (mac_bitget_1bit()) |
x = -x; |
nbits--; |
} |
if (y) |
{ |
if (mac_bitget_1bit()) |
y = -y; |
nbits--; |
} |
vwxy[i][0] = v; |
vwxy[i][1] = w; |
vwxy[i][2] = x; |
vwxy[i][3] = y; |
if (bitget_overrun()) |
break; // bad data protect |
} |
if (nbits < 0) |
{ |
i--; |
vwxy[i][0] = 0; |
vwxy[i][1] = 0; |
vwxy[i][2] = 0; |
vwxy[i][3] = 0; |
} |
i_non_zero = (i_non_zero + 1) << 2; |
if ((tmp_nz & 3) == 0) |
i_non_zero -= 2; |
return i_non_zero; |
/*--------------------*/ |
case_quad_b: |
for (i = 0; i < n; i++) |
{ |
if (nbits < 4) |
break; |
nbits -= 4; |
mac_bitget_check(8); |
tmp = mac_bitget(4) ^ 15; /* one's complement of bitstream */ |
if (tmp) |
{ |
i_non_zero = i; |
tmp_nz = tmp; |
} |
v = (tmp >> 3) & 1; |
w = (tmp >> 2) & 1; |
x = (tmp >> 1) & 1; |
y = tmp & 1; |
if (v) |
{ |
if (mac_bitget_1bit()) |
v = -v; |
nbits--; |
} |
if (w) |
{ |
if (mac_bitget_1bit()) |
w = -w; |
nbits--; |
} |
if (x) |
{ |
if (mac_bitget_1bit()) |
x = -x; |
nbits--; |
} |
if (y) |
{ |
if (mac_bitget_1bit()) |
y = -y; |
nbits--; |
} |
vwxy[i][0] = v; |
vwxy[i][1] = w; |
vwxy[i][2] = x; |
vwxy[i][3] = y; |
if (bitget_overrun()) |
break; // bad data protect |
} |
if (nbits < 0) |
{ |
i--; |
vwxy[i][0] = 0; |
vwxy[i][1] = 0; |
vwxy[i][2] = 0; |
vwxy[i][3] = 0; |
} |
i_non_zero = (i_non_zero + 1) << 2; |
if ((tmp_nz & 3) == 0) |
i_non_zero -= 2; |
return i_non_zero; /* return non-zero sample (to nearest pair) */ |
} |
/programs/media/ac97snd/trunk/mp3dec/l3huff.h |
---|
0,0 → 1,973 |
typedef union |
{ |
int ptr; |
struct |
{ |
unsigned char signbits; |
unsigned char x; |
unsigned char y; |
unsigned char purgebits; // 0 = esc |
} |
b; |
} |
HUFF_ELEMENT; |
/* TABLE 1 4 entries maxbits 3 linbits 0 */ |
static HUFF_ELEMENT huff_table_1[] = |
{ |
0xFF000003, 0x03010102, 0x03010001, 0x02000101, 0x02000101, /* 4 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000,}; |
/* max table bits 3 */ |
/* TABLE 2 9 entries maxbits 6 linbits 0 */ |
static HUFF_ELEMENT huff_table_2[] = |
{ |
0xFF000006, 0x06020202, 0x06020001, 0x05020102, 0x05020102, /* 4 */ |
0x05010202, 0x05010202, 0x05000201, 0x05000201, 0x03010102, /* 9 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 14 */ |
0x03010102, 0x03010102, 0x03010001, 0x03010001, 0x03010001, /* 19 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 24 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 29 */ |
0x03000101, 0x03000101, 0x03000101, 0x01000000, 0x01000000, /* 34 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 39 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 44 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 49 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 54 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 59 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 64 */ }; |
/* max table bits 6 */ |
/* TABLE 3 9 entries maxbits 6 linbits 0 */ |
static HUFF_ELEMENT huff_table_3[] = |
{ |
0xFF000006, 0x06020202, 0x06020001, 0x05020102, 0x05020102, /* 4 */ |
0x05010202, 0x05010202, 0x05000201, 0x05000201, 0x03000101, /* 9 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 14 */ |
0x03000101, 0x03000101, 0x02010102, 0x02010102, 0x02010102, /* 19 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 24 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 29 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010001, 0x02010001, /* 34 */ |
0x02010001, 0x02010001, 0x02010001, 0x02010001, 0x02010001, /* 39 */ |
0x02010001, 0x02010001, 0x02010001, 0x02010001, 0x02010001, /* 44 */ |
0x02010001, 0x02010001, 0x02010001, 0x02010001, 0x02000000, /* 49 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 54 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 59 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 64 */ }; |
/* max table bits 6 */ |
/* NO XING TABLE 4 */ |
/* TABLE 5 16 entries maxbits 8 linbits 0 */ |
static HUFF_ELEMENT huff_table_5[] = |
{ |
0xFF000008, 0x08030302, 0x08030202, 0x07020302, 0x07020302, /* 4 */ |
0x06010302, 0x06010302, 0x06010302, 0x06010302, 0x07030102, /* 9 */ |
0x07030102, 0x07030001, 0x07030001, 0x07000301, 0x07000301, /* 14 */ |
0x07020202, 0x07020202, 0x06020102, 0x06020102, 0x06020102, /* 19 */ |
0x06020102, 0x06010202, 0x06010202, 0x06010202, 0x06010202, /* 24 */ |
0x06020001, 0x06020001, 0x06020001, 0x06020001, 0x06000201, /* 29 */ |
0x06000201, 0x06000201, 0x06000201, 0x03010102, 0x03010102, /* 34 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 39 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 44 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 49 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 54 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 59 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 64 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 69 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 74 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 79 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 84 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 89 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 94 */ |
0x03010001, 0x03010001, 0x03000101, 0x03000101, 0x03000101, /* 99 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 104 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 109 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 114 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 119 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 124 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x01000000, /* 129 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 134 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 139 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 144 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 149 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 154 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 159 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 164 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 169 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 174 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 179 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 184 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 189 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 194 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 199 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 204 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 209 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 214 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 219 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 224 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 229 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 234 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 239 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 244 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 249 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 254 */ |
0x01000000, 0x01000000,}; |
/* max table bits 8 */ |
/* TABLE 6 16 entries maxbits 7 linbits 0 */ |
static HUFF_ELEMENT huff_table_6[] = |
{ |
0xFF000007, 0x07030302, 0x07030001, 0x06030202, 0x06030202, /* 4 */ |
0x06020302, 0x06020302, 0x06000301, 0x06000301, 0x05030102, /* 9 */ |
0x05030102, 0x05030102, 0x05030102, 0x05010302, 0x05010302, /* 14 */ |
0x05010302, 0x05010302, 0x05020202, 0x05020202, 0x05020202, /* 19 */ |
0x05020202, 0x05020001, 0x05020001, 0x05020001, 0x05020001, /* 24 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 29 */ |
0x04020102, 0x04020102, 0x04020102, 0x04010202, 0x04010202, /* 34 */ |
0x04010202, 0x04010202, 0x04010202, 0x04010202, 0x04010202, /* 39 */ |
0x04010202, 0x04000201, 0x04000201, 0x04000201, 0x04000201, /* 44 */ |
0x04000201, 0x04000201, 0x04000201, 0x04000201, 0x03010001, /* 49 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 54 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 59 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 64 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 69 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 74 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 79 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 84 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 89 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 94 */ |
0x02010102, 0x02010102, 0x03000101, 0x03000101, 0x03000101, /* 99 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 104 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 109 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000000, 0x03000000, /* 114 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 119 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 124 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000,}; |
/* max table bits 7 */ |
/* TABLE 7 36 entries maxbits 10 linbits 0 */ |
static HUFF_ELEMENT huff_table_7[] = |
{ |
0xFF000006, 0x00000041, 0x00000052, 0x0000005B, 0x00000060, /* 4 */ |
0x00000063, 0x00000068, 0x0000006B, 0x06020102, 0x05010202, /* 9 */ |
0x05010202, 0x06020001, 0x06000201, 0x04010102, 0x04010102, /* 14 */ |
0x04010102, 0x04010102, 0x03010001, 0x03010001, 0x03010001, /* 19 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 24 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 29 */ |
0x03000101, 0x03000101, 0x03000101, 0x01000000, 0x01000000, /* 34 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 39 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 44 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 49 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 54 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 59 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 64 */ |
0xFF000004, 0x04050502, 0x04050402, 0x04040502, 0x04030502, /* 69 */ |
0x03050302, 0x03050302, 0x03040402, 0x03040402, 0x03050202, /* 74 */ |
0x03050202, 0x03020502, 0x03020502, 0x02050102, 0x02050102, /* 79 */ |
0x02050102, 0x02050102, 0xFF000003, 0x02010502, 0x02010502, /* 84 */ |
0x03050001, 0x03040302, 0x02000501, 0x02000501, 0x03030402, /* 89 */ |
0x03030302, 0xFF000002, 0x02040202, 0x02020402, 0x01040102, /* 94 */ |
0x01040102, 0xFF000001, 0x01010402, 0x01000401, 0xFF000002, /* 99 */ |
0x02040001, 0x02030202, 0x02020302, 0x02030001, 0xFF000001, /* 104 */ |
0x01030102, 0x01010302, 0xFF000001, 0x01000301, 0x01020202, /* 109 */ }; |
/* max table bits 6 */ |
/* TABLE 8 36 entries maxbits 11 linbits 0 */ |
static HUFF_ELEMENT huff_table_8[] = |
{ |
0xFF000008, 0x00000101, 0x0000010A, 0x0000010F, 0x08050102, /* 4 */ |
0x08010502, 0x00000112, 0x00000115, 0x08040202, 0x08020402, /* 9 */ |
0x08040102, 0x07010402, 0x07010402, 0x08040001, 0x08000401, /* 14 */ |
0x08030202, 0x08020302, 0x08030102, 0x08010302, 0x08030001, /* 19 */ |
0x08000301, 0x06020202, 0x06020202, 0x06020202, 0x06020202, /* 24 */ |
0x06020001, 0x06020001, 0x06020001, 0x06020001, 0x06000201, /* 29 */ |
0x06000201, 0x06000201, 0x06000201, 0x04020102, 0x04020102, /* 34 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 39 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 44 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04010202, /* 49 */ |
0x04010202, 0x04010202, 0x04010202, 0x04010202, 0x04010202, /* 54 */ |
0x04010202, 0x04010202, 0x04010202, 0x04010202, 0x04010202, /* 59 */ |
0x04010202, 0x04010202, 0x04010202, 0x04010202, 0x04010202, /* 64 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 69 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 74 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 79 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 84 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 89 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 94 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 99 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 104 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 109 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 114 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 119 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 124 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x03010001, /* 129 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 134 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 139 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 144 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 149 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 154 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 159 */ |
0x03010001, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 164 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 169 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 174 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 179 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 184 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 189 */ |
0x03000101, 0x03000101, 0x03000101, 0x02000000, 0x02000000, /* 194 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 199 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 204 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 209 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 214 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 219 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 224 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 229 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 234 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 239 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 244 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 249 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 254 */ |
0x02000000, 0x02000000, 0xFF000003, 0x03050502, 0x03040502, /* 259 */ |
0x02050402, 0x02050402, 0x01030502, 0x01030502, 0x01030502, /* 264 */ |
0x01030502, 0xFF000002, 0x02050302, 0x02040402, 0x01050202, /* 269 */ |
0x01050202, 0xFF000001, 0x01020502, 0x01050001, 0xFF000001, /* 274 */ |
0x01040302, 0x01030402, 0xFF000001, 0x01000501, 0x01030302, /* 279 */ }; |
/* max table bits 8 */ |
/* TABLE 9 36 entries maxbits 9 linbits 0 */ |
static HUFF_ELEMENT huff_table_9[] = |
{ |
0xFF000006, 0x00000041, 0x0000004A, 0x0000004F, 0x00000052, /* 4 */ |
0x00000057, 0x0000005A, 0x06040102, 0x06010402, 0x06030202, /* 9 */ |
0x06020302, 0x05030102, 0x05030102, 0x05010302, 0x05010302, /* 14 */ |
0x06030001, 0x06000301, 0x05020202, 0x05020202, 0x05020001, /* 19 */ |
0x05020001, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 24 */ |
0x04010202, 0x04010202, 0x04010202, 0x04010202, 0x04000201, /* 29 */ |
0x04000201, 0x04000201, 0x04000201, 0x03010102, 0x03010102, /* 34 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 39 */ |
0x03010102, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 44 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03000101, /* 49 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 54 */ |
0x03000101, 0x03000101, 0x03000000, 0x03000000, 0x03000000, /* 59 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 64 */ |
0xFF000003, 0x03050502, 0x03050402, 0x02050302, 0x02050302, /* 69 */ |
0x02030502, 0x02030502, 0x03040502, 0x03050001, 0xFF000002, /* 74 */ |
0x02040402, 0x02050202, 0x02020502, 0x02050102, 0xFF000001, /* 79 */ |
0x01010502, 0x01040302, 0xFF000002, 0x01030402, 0x01030402, /* 84 */ |
0x02000501, 0x02040001, 0xFF000001, 0x01040202, 0x01020402, /* 89 */ |
0xFF000001, 0x01030302, 0x01000401,}; |
/* max table bits 6 */ |
/* TABLE 10 64 entries maxbits 11 linbits 0 */ |
static HUFF_ELEMENT huff_table_10[] = |
{ |
0xFF000008, 0x00000101, 0x0000010A, 0x0000010F, 0x00000118, /* 4 */ |
0x0000011B, 0x00000120, 0x00000125, 0x08070102, 0x08010702, /* 9 */ |
0x0000012A, 0x0000012D, 0x00000132, 0x08060102, 0x08010602, /* 14 */ |
0x08000601, 0x00000137, 0x0000013A, 0x0000013D, 0x08040102, /* 19 */ |
0x08010402, 0x08000401, 0x08030202, 0x08020302, 0x08030001, /* 24 */ |
0x07030102, 0x07030102, 0x07010302, 0x07010302, 0x07000301, /* 29 */ |
0x07000301, 0x07020202, 0x07020202, 0x06020102, 0x06020102, /* 34 */ |
0x06020102, 0x06020102, 0x06010202, 0x06010202, 0x06010202, /* 39 */ |
0x06010202, 0x06020001, 0x06020001, 0x06020001, 0x06020001, /* 44 */ |
0x06000201, 0x06000201, 0x06000201, 0x06000201, 0x04010102, /* 49 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 54 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 59 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 64 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 69 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 74 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 79 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 84 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 89 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 94 */ |
0x03010001, 0x03010001, 0x03000101, 0x03000101, 0x03000101, /* 99 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 104 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 109 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 114 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 119 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 124 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x01000000, /* 129 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 134 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 139 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 144 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 149 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 154 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 159 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 164 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 169 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 174 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 179 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 184 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 189 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 194 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 199 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 204 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 209 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 214 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 219 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 224 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 229 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 234 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 239 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 244 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 249 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 254 */ |
0x01000000, 0x01000000, 0xFF000003, 0x03070702, 0x03070602, /* 259 */ |
0x03060702, 0x03070502, 0x03050702, 0x03060602, 0x02070402, /* 264 */ |
0x02070402, 0xFF000002, 0x02040702, 0x02060502, 0x02050602, /* 269 */ |
0x02070302, 0xFF000003, 0x02030702, 0x02030702, 0x02060402, /* 274 */ |
0x02060402, 0x03050502, 0x03040502, 0x02030602, 0x02030602, /* 279 */ |
0xFF000001, 0x01070202, 0x01020702, 0xFF000002, 0x02040602, /* 284 */ |
0x02070001, 0x01000701, 0x01000701, 0xFF000002, 0x01020602, /* 289 */ |
0x01020602, 0x02050402, 0x02050302, 0xFF000002, 0x01060001, /* 294 */ |
0x01060001, 0x02030502, 0x02040402, 0xFF000001, 0x01060302, /* 299 */ |
0x01060202, 0xFF000002, 0x02050202, 0x02020502, 0x01050102, /* 304 */ |
0x01050102, 0xFF000002, 0x01010502, 0x01010502, 0x02040302, /* 309 */ |
0x02030402, 0xFF000001, 0x01050001, 0x01000501, 0xFF000001, /* 314 */ |
0x01040202, 0x01020402, 0xFF000001, 0x01030302, 0x01040001, /* 319 */ }; |
/* max table bits 8 */ |
/* TABLE 11 64 entries maxbits 11 linbits 0 */ |
static HUFF_ELEMENT huff_table_11[] = |
{ |
0xFF000008, 0x00000101, 0x00000106, 0x0000010F, 0x00000114, /* 4 */ |
0x00000117, 0x08070202, 0x08020702, 0x0000011C, 0x07010702, /* 9 */ |
0x07010702, 0x08070102, 0x08000701, 0x08060302, 0x08030602, /* 14 */ |
0x08000601, 0x0000011F, 0x00000122, 0x08050102, 0x07020602, /* 19 */ |
0x07020602, 0x08060202, 0x08060001, 0x07060102, 0x07060102, /* 24 */ |
0x07010602, 0x07010602, 0x08010502, 0x08040302, 0x08000501, /* 29 */ |
0x00000125, 0x08040202, 0x08020402, 0x08040102, 0x08010402, /* 34 */ |
0x08040001, 0x08000401, 0x07030202, 0x07030202, 0x07020302, /* 39 */ |
0x07020302, 0x06030102, 0x06030102, 0x06030102, 0x06030102, /* 44 */ |
0x06010302, 0x06010302, 0x06010302, 0x06010302, 0x07030001, /* 49 */ |
0x07030001, 0x07000301, 0x07000301, 0x06020202, 0x06020202, /* 54 */ |
0x06020202, 0x06020202, 0x05010202, 0x05010202, 0x05010202, /* 59 */ |
0x05010202, 0x05010202, 0x05010202, 0x05010202, 0x05010202, /* 64 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 69 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 74 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 79 */ |
0x04020102, 0x05020001, 0x05020001, 0x05020001, 0x05020001, /* 84 */ |
0x05020001, 0x05020001, 0x05020001, 0x05020001, 0x05000201, /* 89 */ |
0x05000201, 0x05000201, 0x05000201, 0x05000201, 0x05000201, /* 94 */ |
0x05000201, 0x05000201, 0x03010102, 0x03010102, 0x03010102, /* 99 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 104 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 109 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 114 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 119 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 124 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010001, /* 129 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 134 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 139 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 144 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 149 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 154 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 159 */ |
0x03010001, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 164 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 169 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 174 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 179 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 184 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 189 */ |
0x03000101, 0x03000101, 0x03000101, 0x02000000, 0x02000000, /* 194 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 199 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 204 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 209 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 214 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 219 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 224 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 229 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 234 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 239 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 244 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 249 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 254 */ |
0x02000000, 0x02000000, 0xFF000002, 0x02070702, 0x02070602, /* 259 */ |
0x02060702, 0x02050702, 0xFF000003, 0x02060602, 0x02060602, /* 264 */ |
0x02070402, 0x02070402, 0x02040702, 0x02040702, 0x03070502, /* 269 */ |
0x03050502, 0xFF000002, 0x02060502, 0x02050602, 0x01070302, /* 274 */ |
0x01070302, 0xFF000001, 0x01030702, 0x01060402, 0xFF000002, /* 279 */ |
0x02050402, 0x02040502, 0x02050302, 0x02030502, 0xFF000001, /* 284 */ |
0x01040602, 0x01070001, 0xFF000001, 0x01040402, 0x01050202, /* 289 */ |
0xFF000001, 0x01020502, 0x01050001, 0xFF000001, 0x01030402, /* 294 */ |
0x01030302,}; |
/* max table bits 8 */ |
/* TABLE 12 64 entries maxbits 10 linbits 0 */ |
static HUFF_ELEMENT huff_table_12[] = |
{ |
0xFF000007, 0x00000081, 0x0000008A, 0x0000008F, 0x00000092, /* 4 */ |
0x00000097, 0x0000009A, 0x0000009D, 0x000000A2, 0x000000A5, /* 9 */ |
0x000000A8, 0x07060202, 0x07020602, 0x07010602, 0x000000AD, /* 14 */ |
0x000000B0, 0x000000B3, 0x07050102, 0x07010502, 0x07040302, /* 19 */ |
0x07030402, 0x000000B6, 0x07040202, 0x07020402, 0x07040102, /* 24 */ |
0x06030302, 0x06030302, 0x06010402, 0x06010402, 0x06030202, /* 29 */ |
0x06030202, 0x06020302, 0x06020302, 0x07000401, 0x07030001, /* 34 */ |
0x06000301, 0x06000301, 0x05030102, 0x05030102, 0x05030102, /* 39 */ |
0x05030102, 0x05010302, 0x05010302, 0x05010302, 0x05010302, /* 44 */ |
0x05020202, 0x05020202, 0x05020202, 0x05020202, 0x04020102, /* 49 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 54 */ |
0x04020102, 0x04020102, 0x04010202, 0x04010202, 0x04010202, /* 59 */ |
0x04010202, 0x04010202, 0x04010202, 0x04010202, 0x04010202, /* 64 */ |
0x05020001, 0x05020001, 0x05020001, 0x05020001, 0x05000201, /* 69 */ |
0x05000201, 0x05000201, 0x05000201, 0x04000000, 0x04000000, /* 74 */ |
0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 79 */ |
0x04000000, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 84 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 89 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 94 */ |
0x03010102, 0x03010102, 0x03010001, 0x03010001, 0x03010001, /* 99 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 104 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 109 */ |
0x03010001, 0x03010001, 0x03010001, 0x03000101, 0x03000101, /* 114 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 119 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 124 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0xFF000003, /* 129 */ |
0x03070702, 0x03070602, 0x02060702, 0x02060702, 0x02070502, /* 134 */ |
0x02070502, 0x02050702, 0x02050702, 0xFF000002, 0x02060602, /* 139 */ |
0x02070402, 0x02040702, 0x02050602, 0xFF000001, 0x01060502, /* 144 */ |
0x01070302, 0xFF000002, 0x02030702, 0x02050502, 0x01070202, /* 149 */ |
0x01070202, 0xFF000001, 0x01020702, 0x01060402, 0xFF000001, /* 154 */ |
0x01040602, 0x01070102, 0xFF000002, 0x01010702, 0x01010702, /* 159 */ |
0x02070001, 0x02000701, 0xFF000001, 0x01060302, 0x01030602, /* 164 */ |
0xFF000001, 0x01050402, 0x01040502, 0xFF000002, 0x01040402, /* 169 */ |
0x01040402, 0x02060001, 0x02050001, 0xFF000001, 0x01060102, /* 174 */ |
0x01000601, 0xFF000001, 0x01050302, 0x01030502, 0xFF000001, /* 179 */ |
0x01050202, 0x01020502, 0xFF000001, 0x01000501, 0x01040001, /* 184 */ }; |
/* max table bits 7 */ |
/* TABLE 13 256 entries maxbits 19 linbits 0 */ |
static HUFF_ELEMENT huff_table_13[] = |
{ |
0xFF000006, 0x00000041, 0x00000082, 0x000000C3, 0x000000E4, /* 4 */ |
0x00000105, 0x00000116, 0x0000011F, 0x00000130, 0x00000139, /* 9 */ |
0x0000013E, 0x00000143, 0x00000146, 0x06020102, 0x06010202, /* 14 */ |
0x06020001, 0x06000201, 0x04010102, 0x04010102, 0x04010102, /* 19 */ |
0x04010102, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 24 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 29 */ |
0x03000101, 0x03000101, 0x03000101, 0x01000000, 0x01000000, /* 34 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 39 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 44 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 49 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 54 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 59 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 64 */ |
0xFF000006, 0x00000108, 0x00000111, 0x0000011A, 0x00000123, /* 69 */ |
0x0000012C, 0x00000131, 0x00000136, 0x0000013F, 0x00000144, /* 74 */ |
0x00000147, 0x0000014C, 0x00000151, 0x00000156, 0x0000015B, /* 79 */ |
0x060F0102, 0x06010F02, 0x06000F01, 0x00000160, 0x00000163, /* 84 */ |
0x00000166, 0x06020E02, 0x00000169, 0x060E0102, 0x06010E02, /* 89 */ |
0x0000016C, 0x0000016F, 0x00000172, 0x00000175, 0x00000178, /* 94 */ |
0x0000017B, 0x06060C02, 0x060D0302, 0x0000017E, 0x060D0202, /* 99 */ |
0x06020D02, 0x060D0102, 0x06070B02, 0x00000181, 0x00000184, /* 104 */ |
0x06030C02, 0x00000187, 0x060B0402, 0x05010D02, 0x05010D02, /* 109 */ |
0x060D0001, 0x06000D01, 0x060A0802, 0x06080A02, 0x060C0402, /* 114 */ |
0x06040C02, 0x060B0602, 0x06060B02, 0x050C0302, 0x050C0302, /* 119 */ |
0x050C0202, 0x050C0202, 0x05020C02, 0x05020C02, 0x050B0502, /* 124 */ |
0x050B0502, 0x06050B02, 0x06090802, 0x050C0102, 0x050C0102, /* 129 */ |
0xFF000006, 0x05010C02, 0x05010C02, 0x06080902, 0x060C0001, /* 134 */ |
0x05000C01, 0x05000C01, 0x06040B02, 0x060A0602, 0x06060A02, /* 139 */ |
0x06090702, 0x050B0302, 0x050B0302, 0x05030B02, 0x05030B02, /* 144 */ |
0x06080802, 0x060A0502, 0x050B0202, 0x050B0202, 0x06050A02, /* 149 */ |
0x06090602, 0x05040A02, 0x05040A02, 0x06080702, 0x06070802, /* 154 */ |
0x05040902, 0x05040902, 0x06070702, 0x06060702, 0x04020B02, /* 159 */ |
0x04020B02, 0x04020B02, 0x04020B02, 0x040B0102, 0x040B0102, /* 164 */ |
0x040B0102, 0x040B0102, 0x04010B02, 0x04010B02, 0x04010B02, /* 169 */ |
0x04010B02, 0x050B0001, 0x050B0001, 0x05000B01, 0x05000B01, /* 174 */ |
0x05060902, 0x05060902, 0x050A0402, 0x050A0402, 0x050A0302, /* 179 */ |
0x050A0302, 0x05030A02, 0x05030A02, 0x05090502, 0x05090502, /* 184 */ |
0x05050902, 0x05050902, 0x040A0202, 0x040A0202, 0x040A0202, /* 189 */ |
0x040A0202, 0x04020A02, 0x04020A02, 0x04020A02, 0x04020A02, /* 194 */ |
0xFF000005, 0x040A0102, 0x040A0102, 0x04010A02, 0x04010A02, /* 199 */ |
0x050A0001, 0x05080602, 0x04000A01, 0x04000A01, 0x05060802, /* 204 */ |
0x05090402, 0x04030902, 0x04030902, 0x05090302, 0x05080502, /* 209 */ |
0x05050802, 0x05070602, 0x04090202, 0x04090202, 0x04020902, /* 214 */ |
0x04020902, 0x05070502, 0x05050702, 0x04080302, 0x04080302, /* 219 */ |
0x04030802, 0x04030802, 0x05060602, 0x05070402, 0x05040702, /* 224 */ |
0x05060502, 0x05050602, 0x05030702, 0xFF000005, 0x03090102, /* 229 */ |
0x03090102, 0x03090102, 0x03090102, 0x03010902, 0x03010902, /* 234 */ |
0x03010902, 0x03010902, 0x04090001, 0x04090001, 0x04000901, /* 239 */ |
0x04000901, 0x04080402, 0x04080402, 0x04040802, 0x04040802, /* 244 */ |
0x04020702, 0x04020702, 0x05060402, 0x05040602, 0x03080202, /* 249 */ |
0x03080202, 0x03080202, 0x03080202, 0x03020802, 0x03020802, /* 254 */ |
0x03020802, 0x03020802, 0x03080102, 0x03080102, 0x03080102, /* 259 */ |
0x03080102, 0xFF000004, 0x04070302, 0x04070202, 0x03070102, /* 264 */ |
0x03070102, 0x03010702, 0x03010702, 0x04050502, 0x04070001, /* 269 */ |
0x04000701, 0x04060302, 0x04030602, 0x04050402, 0x04040502, /* 274 */ |
0x04060202, 0x04020602, 0x04050302, 0xFF000003, 0x02010802, /* 279 */ |
0x02010802, 0x03080001, 0x03000801, 0x03060102, 0x03010602, /* 284 */ |
0x03060001, 0x03000601, 0xFF000004, 0x04030502, 0x04040402, /* 289 */ |
0x03050202, 0x03050202, 0x03020502, 0x03020502, 0x03050001, /* 294 */ |
0x03050001, 0x02050102, 0x02050102, 0x02050102, 0x02050102, /* 299 */ |
0x02010502, 0x02010502, 0x02010502, 0x02010502, 0xFF000003, /* 304 */ |
0x03040302, 0x03030402, 0x03000501, 0x03040202, 0x03020402, /* 309 */ |
0x03030302, 0x02040102, 0x02040102, 0xFF000002, 0x01010402, /* 314 */ |
0x01010402, 0x02040001, 0x02000401, 0xFF000002, 0x02030202, /* 319 */ |
0x02020302, 0x01030102, 0x01030102, 0xFF000001, 0x01010302, /* 324 */ |
0x01030001, 0xFF000001, 0x01000301, 0x01020202, 0xFF000003, /* 329 */ |
0x00000082, 0x0000008B, 0x0000008E, 0x00000091, 0x00000094, /* 334 */ |
0x00000097, 0x030C0E02, 0x030D0D02, 0xFF000003, 0x00000093, /* 339 */ |
0x030E0B02, 0x030B0E02, 0x030F0902, 0x03090F02, 0x030A0E02, /* 344 */ |
0x030D0B02, 0x030B0D02, 0xFF000003, 0x030F0802, 0x03080F02, /* 349 */ |
0x030C0C02, 0x0000008D, 0x030E0802, 0x00000090, 0x02070F02, /* 354 */ |
0x02070F02, 0xFF000003, 0x020A0D02, 0x020A0D02, 0x030D0A02, /* 359 */ |
0x030C0B02, 0x030B0C02, 0x03060F02, 0x020F0602, 0x020F0602, /* 364 */ |
0xFF000002, 0x02080E02, 0x020F0502, 0x020D0902, 0x02090D02, /* 369 */ |
0xFF000002, 0x02050F02, 0x02070E02, 0x020C0A02, 0x020B0B02, /* 374 */ |
0xFF000003, 0x020F0402, 0x020F0402, 0x02040F02, 0x02040F02, /* 379 */ |
0x030A0C02, 0x03060E02, 0x02030F02, 0x02030F02, 0xFF000002, /* 384 */ |
0x010F0302, 0x010F0302, 0x020D0802, 0x02080D02, 0xFF000001, /* 389 */ |
0x010F0202, 0x01020F02, 0xFF000002, 0x020E0602, 0x020C0902, /* 394 */ |
0x010F0001, 0x010F0001, 0xFF000002, 0x02090C02, 0x020E0502, /* 399 */ |
0x010B0A02, 0x010B0A02, 0xFF000002, 0x020D0702, 0x02070D02, /* 404 */ |
0x010E0402, 0x010E0402, 0xFF000002, 0x02080C02, 0x02060D02, /* 409 */ |
0x010E0302, 0x010E0302, 0xFF000002, 0x01090B02, 0x01090B02, /* 414 */ |
0x020B0902, 0x020A0A02, 0xFF000001, 0x010A0B02, 0x01050E02, /* 419 */ |
0xFF000001, 0x01040E02, 0x010C0802, 0xFF000001, 0x010D0602, /* 424 */ |
0x01030E02, 0xFF000001, 0x010E0202, 0x010E0001, 0xFF000001, /* 429 */ |
0x01000E01, 0x010D0502, 0xFF000001, 0x01050D02, 0x010C0702, /* 434 */ |
0xFF000001, 0x01070C02, 0x010D0402, 0xFF000001, 0x010B0802, /* 439 */ |
0x01080B02, 0xFF000001, 0x01040D02, 0x010A0902, 0xFF000001, /* 444 */ |
0x01090A02, 0x010C0602, 0xFF000001, 0x01030D02, 0x010B0702, /* 449 */ |
0xFF000001, 0x010C0502, 0x01050C02, 0xFF000001, 0x01090902, /* 454 */ |
0x010A0702, 0xFF000001, 0x01070A02, 0x01070902, 0xFF000003, /* 459 */ |
0x00000023, 0x030D0F02, 0x020D0E02, 0x020D0E02, 0x010F0F02, /* 464 */ |
0x010F0F02, 0x010F0F02, 0x010F0F02, 0xFF000001, 0x010F0E02, /* 469 */ |
0x010F0D02, 0xFF000001, 0x010E0E02, 0x010F0C02, 0xFF000001, /* 474 */ |
0x010E0D02, 0x010F0B02, 0xFF000001, 0x010B0F02, 0x010E0C02, /* 479 */ |
0xFF000002, 0x010C0D02, 0x010C0D02, 0x020F0A02, 0x02090E02, /* 484 */ |
0xFF000001, 0x010A0F02, 0x010D0C02, 0xFF000001, 0x010E0A02, /* 489 */ |
0x010E0902, 0xFF000001, 0x010F0702, 0x010E0702, 0xFF000001, /* 494 */ |
0x010E0F02, 0x010C0F02,}; |
/* max table bits 6 */ |
/* NO XING TABLE 14 */ |
/* TABLE 15 256 entries maxbits 13 linbits 0 */ |
static HUFF_ELEMENT huff_table_15[] = |
{ |
0xFF000008, 0x00000101, 0x00000122, 0x00000143, 0x00000154, /* 4 */ |
0x00000165, 0x00000176, 0x0000017F, 0x00000188, 0x00000199, /* 9 */ |
0x000001A2, 0x000001AB, 0x000001B4, 0x000001BD, 0x000001C2, /* 14 */ |
0x000001CB, 0x000001D4, 0x000001D9, 0x000001DE, 0x000001E3, /* 19 */ |
0x000001E8, 0x000001ED, 0x000001F2, 0x000001F7, 0x000001FC, /* 24 */ |
0x00000201, 0x00000204, 0x00000207, 0x0000020A, 0x0000020F, /* 29 */ |
0x00000212, 0x00000215, 0x0000021A, 0x0000021D, 0x00000220, /* 34 */ |
0x08010902, 0x00000223, 0x00000226, 0x00000229, 0x0000022C, /* 39 */ |
0x0000022F, 0x08080202, 0x08020802, 0x08080102, 0x08010802, /* 44 */ |
0x00000232, 0x00000235, 0x00000238, 0x0000023B, 0x08070202, /* 49 */ |
0x08020702, 0x08040602, 0x08070102, 0x08050502, 0x08010702, /* 54 */ |
0x0000023E, 0x08060302, 0x08030602, 0x08050402, 0x08040502, /* 59 */ |
0x08060202, 0x08020602, 0x08060102, 0x00000241, 0x08050302, /* 64 */ |
0x07010602, 0x07010602, 0x08030502, 0x08040402, 0x07050202, /* 69 */ |
0x07050202, 0x07020502, 0x07020502, 0x07050102, 0x07050102, /* 74 */ |
0x07010502, 0x07010502, 0x08050001, 0x08000501, 0x07040302, /* 79 */ |
0x07040302, 0x07030402, 0x07030402, 0x07040202, 0x07040202, /* 84 */ |
0x07020402, 0x07020402, 0x07030302, 0x07030302, 0x06010402, /* 89 */ |
0x06010402, 0x06010402, 0x06010402, 0x07040102, 0x07040102, /* 94 */ |
0x07040001, 0x07040001, 0x06030202, 0x06030202, 0x06030202, /* 99 */ |
0x06030202, 0x06020302, 0x06020302, 0x06020302, 0x06020302, /* 104 */ |
0x07000401, 0x07000401, 0x07030001, 0x07030001, 0x06030102, /* 109 */ |
0x06030102, 0x06030102, 0x06030102, 0x06010302, 0x06010302, /* 114 */ |
0x06010302, 0x06010302, 0x06000301, 0x06000301, 0x06000301, /* 119 */ |
0x06000301, 0x05020202, 0x05020202, 0x05020202, 0x05020202, /* 124 */ |
0x05020202, 0x05020202, 0x05020202, 0x05020202, 0x05020102, /* 129 */ |
0x05020102, 0x05020102, 0x05020102, 0x05020102, 0x05020102, /* 134 */ |
0x05020102, 0x05020102, 0x05010202, 0x05010202, 0x05010202, /* 139 */ |
0x05010202, 0x05010202, 0x05010202, 0x05010202, 0x05010202, /* 144 */ |
0x05020001, 0x05020001, 0x05020001, 0x05020001, 0x05020001, /* 149 */ |
0x05020001, 0x05020001, 0x05020001, 0x05000201, 0x05000201, /* 154 */ |
0x05000201, 0x05000201, 0x05000201, 0x05000201, 0x05000201, /* 159 */ |
0x05000201, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 164 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 169 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 174 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 179 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 184 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 189 */ |
0x03010102, 0x03010102, 0x03010102, 0x04010001, 0x04010001, /* 194 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 199 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 204 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04000101, /* 209 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 214 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 219 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 224 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 229 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 234 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 239 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 244 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 249 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 254 */ |
0x03000000, 0x03000000, 0xFF000005, 0x050F0F02, 0x050F0E02, /* 259 */ |
0x050E0F02, 0x050F0D02, 0x040E0E02, 0x040E0E02, 0x050D0F02, /* 264 */ |
0x050F0C02, 0x050C0F02, 0x050E0D02, 0x050D0E02, 0x050F0B02, /* 269 */ |
0x040B0F02, 0x040B0F02, 0x050E0C02, 0x050C0E02, 0x040D0D02, /* 274 */ |
0x040D0D02, 0x040F0A02, 0x040F0A02, 0x040A0F02, 0x040A0F02, /* 279 */ |
0x040E0B02, 0x040E0B02, 0x040B0E02, 0x040B0E02, 0x040D0C02, /* 284 */ |
0x040D0C02, 0x040C0D02, 0x040C0D02, 0x040F0902, 0x040F0902, /* 289 */ |
0xFF000005, 0x04090F02, 0x04090F02, 0x040A0E02, 0x040A0E02, /* 294 */ |
0x040D0B02, 0x040D0B02, 0x040B0D02, 0x040B0D02, 0x040F0802, /* 299 */ |
0x040F0802, 0x04080F02, 0x04080F02, 0x040C0C02, 0x040C0C02, /* 304 */ |
0x040E0902, 0x040E0902, 0x04090E02, 0x04090E02, 0x040F0702, /* 309 */ |
0x040F0702, 0x04070F02, 0x04070F02, 0x040D0A02, 0x040D0A02, /* 314 */ |
0x040A0D02, 0x040A0D02, 0x040C0B02, 0x040C0B02, 0x040F0602, /* 319 */ |
0x040F0602, 0x050E0A02, 0x050F0001, 0xFF000004, 0x030B0C02, /* 324 */ |
0x030B0C02, 0x03060F02, 0x03060F02, 0x040E0802, 0x04080E02, /* 329 */ |
0x040F0502, 0x040D0902, 0x03050F02, 0x03050F02, 0x030E0702, /* 334 */ |
0x030E0702, 0x03070E02, 0x03070E02, 0x030C0A02, 0x030C0A02, /* 339 */ |
0xFF000004, 0x030A0C02, 0x030A0C02, 0x030B0B02, 0x030B0B02, /* 344 */ |
0x04090D02, 0x040D0802, 0x030F0402, 0x030F0402, 0x03040F02, /* 349 */ |
0x03040F02, 0x030F0302, 0x030F0302, 0x03030F02, 0x03030F02, /* 354 */ |
0x03080D02, 0x03080D02, 0xFF000004, 0x03060E02, 0x03060E02, /* 359 */ |
0x030F0202, 0x030F0202, 0x03020F02, 0x03020F02, 0x040E0602, /* 364 */ |
0x04000F01, 0x030F0102, 0x030F0102, 0x03010F02, 0x03010F02, /* 369 */ |
0x030C0902, 0x030C0902, 0x03090C02, 0x03090C02, 0xFF000003, /* 374 */ |
0x030E0502, 0x030B0A02, 0x030A0B02, 0x03050E02, 0x030D0702, /* 379 */ |
0x03070D02, 0x030E0402, 0x03040E02, 0xFF000003, 0x030C0802, /* 384 */ |
0x03080C02, 0x030E0302, 0x030D0602, 0x03060D02, 0x03030E02, /* 389 */ |
0x030B0902, 0x03090B02, 0xFF000004, 0x030E0202, 0x030E0202, /* 394 */ |
0x030A0A02, 0x030A0A02, 0x03020E02, 0x03020E02, 0x030E0102, /* 399 */ |
0x030E0102, 0x03010E02, 0x03010E02, 0x040E0001, 0x04000E01, /* 404 */ |
0x030D0502, 0x030D0502, 0x03050D02, 0x03050D02, 0xFF000003, /* 409 */ |
0x030C0702, 0x03070C02, 0x030D0402, 0x030B0802, 0x02040D02, /* 414 */ |
0x02040D02, 0x03080B02, 0x030A0902, 0xFF000003, 0x03090A02, /* 419 */ |
0x030C0602, 0x03060C02, 0x030D0302, 0x02030D02, 0x02030D02, /* 424 */ |
0x02020D02, 0x02020D02, 0xFF000003, 0x030D0202, 0x030D0001, /* 429 */ |
0x020D0102, 0x020D0102, 0x020B0702, 0x020B0702, 0x02070B02, /* 434 */ |
0x02070B02, 0xFF000003, 0x02010D02, 0x02010D02, 0x030C0502, /* 439 */ |
0x03000D01, 0x02050C02, 0x02050C02, 0x020A0802, 0x020A0802, /* 444 */ |
0xFF000002, 0x02080A02, 0x020C0402, 0x02040C02, 0x020B0602, /* 449 */ |
0xFF000003, 0x02060B02, 0x02060B02, 0x03090902, 0x030C0001, /* 454 */ |
0x020C0302, 0x020C0302, 0x02030C02, 0x02030C02, 0xFF000003, /* 459 */ |
0x020A0702, 0x020A0702, 0x02070A02, 0x02070A02, 0x02060A02, /* 464 */ |
0x02060A02, 0x03000C01, 0x030B0001, 0xFF000002, 0x01020C02, /* 469 */ |
0x01020C02, 0x020C0202, 0x020B0502, 0xFF000002, 0x02050B02, /* 474 */ |
0x020C0102, 0x02090802, 0x02080902, 0xFF000002, 0x02010C02, /* 479 */ |
0x020B0402, 0x02040B02, 0x020A0602, 0xFF000002, 0x020B0302, /* 484 */ |
0x02090702, 0x01030B02, 0x01030B02, 0xFF000002, 0x02070902, /* 489 */ |
0x02080802, 0x020B0202, 0x020A0502, 0xFF000002, 0x01020B02, /* 494 */ |
0x01020B02, 0x02050A02, 0x020B0102, 0xFF000002, 0x01010B02, /* 499 */ |
0x01010B02, 0x02000B01, 0x02090602, 0xFF000002, 0x02060902, /* 504 */ |
0x020A0402, 0x02040A02, 0x02080702, 0xFF000002, 0x02070802, /* 509 */ |
0x020A0302, 0x01030A02, 0x01030A02, 0xFF000001, 0x01090502, /* 514 */ |
0x01050902, 0xFF000001, 0x010A0202, 0x01020A02, 0xFF000001, /* 519 */ |
0x010A0102, 0x01010A02, 0xFF000002, 0x020A0001, 0x02000A01, /* 524 */ |
0x01080602, 0x01080602, 0xFF000001, 0x01060802, 0x01090402, /* 529 */ |
0xFF000001, 0x01040902, 0x01090302, 0xFF000002, 0x01030902, /* 534 */ |
0x01030902, 0x02070702, 0x02090001, 0xFF000001, 0x01080502, /* 539 */ |
0x01050802, 0xFF000001, 0x01090202, 0x01070602, 0xFF000001, /* 544 */ |
0x01060702, 0x01020902, 0xFF000001, 0x01090102, 0x01000901, /* 549 */ |
0xFF000001, 0x01080402, 0x01040802, 0xFF000001, 0x01070502, /* 554 */ |
0x01050702, 0xFF000001, 0x01080302, 0x01030802, 0xFF000001, /* 559 */ |
0x01060602, 0x01070402, 0xFF000001, 0x01040702, 0x01080001, /* 564 */ |
0xFF000001, 0x01000801, 0x01060502, 0xFF000001, 0x01050602, /* 569 */ |
0x01070302, 0xFF000001, 0x01030702, 0x01060402, 0xFF000001, /* 574 */ |
0x01070001, 0x01000701, 0xFF000001, 0x01060001, 0x01000601, /* 579 */ }; |
/* max table bits 8 */ |
/* TABLE 16 256 entries maxbits 17 linbits 0 */ |
static HUFF_ELEMENT huff_table_16[] = |
{ |
0xFF000008, 0x00000101, 0x0000010A, 0x00000113, 0x080F0F02, /* 4 */ |
0x00000118, 0x0000011D, 0x00000120, 0x08020F02, 0x00000131, /* 9 */ |
0x080F0102, 0x08010F02, 0x00000134, 0x00000145, 0x00000156, /* 14 */ |
0x00000167, 0x00000178, 0x00000189, 0x0000019A, 0x000001A3, /* 19 */ |
0x000001AC, 0x000001B5, 0x000001BE, 0x000001C7, 0x000001D0, /* 24 */ |
0x000001D9, 0x000001DE, 0x000001E3, 0x000001E6, 0x000001EB, /* 29 */ |
0x000001F0, 0x08010502, 0x000001F3, 0x000001F6, 0x000001F9, /* 34 */ |
0x000001FC, 0x08040102, 0x08010402, 0x000001FF, 0x08030202, /* 39 */ |
0x08020302, 0x07030102, 0x07030102, 0x07010302, 0x07010302, /* 44 */ |
0x08030001, 0x08000301, 0x07020202, 0x07020202, 0x06020102, /* 49 */ |
0x06020102, 0x06020102, 0x06020102, 0x06010202, 0x06010202, /* 54 */ |
0x06010202, 0x06010202, 0x06020001, 0x06020001, 0x06020001, /* 59 */ |
0x06020001, 0x06000201, 0x06000201, 0x06000201, 0x06000201, /* 64 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 69 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 74 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 79 */ |
0x04010102, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 84 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 89 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 94 */ |
0x04010001, 0x04010001, 0x03000101, 0x03000101, 0x03000101, /* 99 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 104 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 109 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 114 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 119 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 124 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x01000000, /* 129 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 134 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 139 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 144 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 149 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 154 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 159 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 164 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 169 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 174 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 179 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 184 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 189 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 194 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 199 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 204 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 209 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 214 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 219 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 224 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 229 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 234 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 239 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 244 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 249 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 254 */ |
0x01000000, 0x01000000, 0xFF000003, 0x030F0E02, 0x030E0F02, /* 259 */ |
0x030F0D02, 0x030D0F02, 0x030F0C02, 0x030C0F02, 0x030F0B02, /* 264 */ |
0x030B0F02, 0xFF000003, 0x020F0A02, 0x020F0A02, 0x030A0F02, /* 269 */ |
0x030F0902, 0x03090F02, 0x03080F02, 0x020F0802, 0x020F0802, /* 274 */ |
0xFF000002, 0x020F0702, 0x02070F02, 0x020F0602, 0x02060F02, /* 279 */ |
0xFF000002, 0x020F0502, 0x02050F02, 0x010F0402, 0x010F0402, /* 284 */ |
0xFF000001, 0x01040F02, 0x01030F02, 0xFF000004, 0x01000F01, /* 289 */ |
0x01000F01, 0x01000F01, 0x01000F01, 0x01000F01, 0x01000F01, /* 294 */ |
0x01000F01, 0x01000F01, 0x020F0302, 0x020F0302, 0x020F0302, /* 299 */ |
0x020F0302, 0x000000E2, 0x000000F3, 0x000000FC, 0x00000105, /* 304 */ |
0xFF000001, 0x010F0202, 0x010F0001, 0xFF000004, 0x000000FA, /* 309 */ |
0x000000FF, 0x00000104, 0x00000109, 0x0000010C, 0x00000111, /* 314 */ |
0x00000116, 0x00000119, 0x0000011E, 0x00000123, 0x00000128, /* 319 */ |
0x04030E02, 0x0000012D, 0x00000130, 0x00000133, 0x00000136, /* 324 */ |
0xFF000004, 0x00000128, 0x0000012B, 0x0000012E, 0x040D0001, /* 329 */ |
0x00000131, 0x00000134, 0x00000137, 0x040C0302, 0x0000013A, /* 334 */ |
0x040C0102, 0x04000C01, 0x0000013D, 0x03020E02, 0x03020E02, /* 339 */ |
0x040E0202, 0x040E0102, 0xFF000004, 0x04030D02, 0x040D0202, /* 344 */ |
0x04020D02, 0x04010D02, 0x040B0302, 0x0000012F, 0x030D0102, /* 349 */ |
0x030D0102, 0x04040C02, 0x040B0602, 0x04030C02, 0x04070A02, /* 354 */ |
0x030C0202, 0x030C0202, 0x04020C02, 0x04050B02, 0xFF000004, /* 359 */ |
0x04010C02, 0x040C0001, 0x040B0402, 0x04040B02, 0x040A0602, /* 364 */ |
0x04060A02, 0x03030B02, 0x03030B02, 0x040A0502, 0x04050A02, /* 369 */ |
0x030B0202, 0x030B0202, 0x03020B02, 0x03020B02, 0x030B0102, /* 374 */ |
0x030B0102, 0xFF000004, 0x03010B02, 0x03010B02, 0x040B0001, /* 379 */ |
0x04000B01, 0x04090602, 0x04060902, 0x040A0402, 0x04040A02, /* 384 */ |
0x04080702, 0x04070802, 0x03030A02, 0x03030A02, 0x040A0302, /* 389 */ |
0x04090502, 0x030A0202, 0x030A0202, 0xFF000004, 0x04050902, /* 394 */ |
0x04080602, 0x03010A02, 0x03010A02, 0x04060802, 0x04070702, /* 399 */ |
0x03040902, 0x03040902, 0x04090402, 0x04070502, 0x03070602, /* 404 */ |
0x03070602, 0x02020A02, 0x02020A02, 0x02020A02, 0x02020A02, /* 409 */ |
0xFF000003, 0x020A0102, 0x020A0102, 0x030A0001, 0x03000A01, /* 414 */ |
0x03090302, 0x03030902, 0x03080502, 0x03050802, 0xFF000003, /* 419 */ |
0x02090202, 0x02090202, 0x02020902, 0x02020902, 0x03060702, /* 424 */ |
0x03090001, 0x02090102, 0x02090102, 0xFF000003, 0x02010902, /* 429 */ |
0x02010902, 0x03000901, 0x03080402, 0x03040802, 0x03050702, /* 434 */ |
0x03080302, 0x03030802, 0xFF000003, 0x03060602, 0x03080202, /* 439 */ |
0x02020802, 0x02020802, 0x03070402, 0x03040702, 0x02080102, /* 444 */ |
0x02080102, 0xFF000003, 0x02010802, 0x02010802, 0x02000801, /* 449 */ |
0x02000801, 0x03080001, 0x03060502, 0x02070302, 0x02070302, /* 454 */ |
0xFF000003, 0x02030702, 0x02030702, 0x03050602, 0x03060402, /* 459 */ |
0x02070202, 0x02070202, 0x02020702, 0x02020702, 0xFF000003, /* 464 */ |
0x03040602, 0x03050502, 0x02070001, 0x02070001, 0x01070102, /* 469 */ |
0x01070102, 0x01070102, 0x01070102, 0xFF000002, 0x01010702, /* 474 */ |
0x01010702, 0x02000701, 0x02060302, 0xFF000002, 0x02030602, /* 479 */ |
0x02050402, 0x02040502, 0x02060202, 0xFF000001, 0x01020602, /* 484 */ |
0x01060102, 0xFF000002, 0x01010602, 0x01010602, 0x02060001, /* 489 */ |
0x02000601, 0xFF000002, 0x01030502, 0x01030502, 0x02050302, /* 494 */ |
0x02040402, 0xFF000001, 0x01050202, 0x01020502, 0xFF000001, /* 499 */ |
0x01050102, 0x01050001, 0xFF000001, 0x01040302, 0x01030402, /* 504 */ |
0xFF000001, 0x01000501, 0x01040202, 0xFF000001, 0x01020402, /* 509 */ |
0x01030302, 0xFF000001, 0x01040001, 0x01000401, 0xFF000004, /* 514 */ |
0x040E0C02, 0x00000086, 0x030E0D02, 0x030E0D02, 0x03090E02, /* 519 */ |
0x03090E02, 0x040A0E02, 0x04090D02, 0x020E0E02, 0x020E0E02, /* 524 */ |
0x020E0E02, 0x020E0E02, 0x030D0E02, 0x030D0E02, 0x030B0E02, /* 529 */ |
0x030B0E02, 0xFF000003, 0x020E0B02, 0x020E0B02, 0x020D0C02, /* 534 */ |
0x020D0C02, 0x030C0D02, 0x030B0D02, 0x020E0A02, 0x020E0A02, /* 539 */ |
0xFF000003, 0x020C0C02, 0x020C0C02, 0x030D0A02, 0x030A0D02, /* 544 */ |
0x030E0702, 0x030C0A02, 0x020A0C02, 0x020A0C02, 0xFF000003, /* 549 */ |
0x03090C02, 0x030D0702, 0x020E0502, 0x020E0502, 0x010D0B02, /* 554 */ |
0x010D0B02, 0x010D0B02, 0x010D0B02, 0xFF000002, 0x010E0902, /* 559 */ |
0x010E0902, 0x020C0B02, 0x020B0C02, 0xFF000002, 0x020E0802, /* 564 */ |
0x02080E02, 0x020D0902, 0x02070E02, 0xFF000002, 0x020B0B02, /* 569 */ |
0x020D0802, 0x02080D02, 0x020E0602, 0xFF000001, 0x01060E02, /* 574 */ |
0x010C0902, 0xFF000002, 0x020B0A02, 0x020A0B02, 0x02050E02, /* 579 */ |
0x02070D02, 0xFF000002, 0x010E0402, 0x010E0402, 0x02040E02, /* 584 */ |
0x020C0802, 0xFF000001, 0x01080C02, 0x010E0302, 0xFF000002, /* 589 */ |
0x010D0602, 0x010D0602, 0x02060D02, 0x020B0902, 0xFF000002, /* 594 */ |
0x02090B02, 0x020A0A02, 0x01010E02, 0x01010E02, 0xFF000002, /* 599 */ |
0x01040D02, 0x01040D02, 0x02080B02, 0x02090A02, 0xFF000002, /* 604 */ |
0x010B0702, 0x010B0702, 0x02070B02, 0x02000D01, 0xFF000001, /* 609 */ |
0x010E0001, 0x01000E01, 0xFF000001, 0x010D0502, 0x01050D02, /* 614 */ |
0xFF000001, 0x010C0702, 0x01070C02, 0xFF000001, 0x010D0402, /* 619 */ |
0x010B0802, 0xFF000001, 0x010A0902, 0x010C0602, 0xFF000001, /* 624 */ |
0x01060C02, 0x010D0302, 0xFF000001, 0x010C0502, 0x01050C02, /* 629 */ |
0xFF000001, 0x010A0802, 0x01080A02, 0xFF000001, 0x01090902, /* 634 */ |
0x010C0402, 0xFF000001, 0x01060B02, 0x010A0702, 0xFF000001, /* 639 */ |
0x010B0502, 0x01090802, 0xFF000001, 0x01080902, 0x01090702, /* 644 */ |
0xFF000001, 0x01070902, 0x01080802, 0xFF000001, 0x010C0E02, /* 649 */ |
0x010D0D02,}; |
/* max table bits 8 */ |
/* NO XING TABLE 17 */ |
/* NO XING TABLE 18 */ |
/* NO XING TABLE 19 */ |
/* NO XING TABLE 20 */ |
/* NO XING TABLE 21 */ |
/* NO XING TABLE 22 */ |
/* NO XING TABLE 23 */ |
/* TABLE 24 256 entries maxbits 12 linbits 0 */ |
static HUFF_ELEMENT huff_table_24[] = |
{ |
0xFF000009, 0x080F0E02, 0x080F0E02, 0x080E0F02, 0x080E0F02, /* 4 */ |
0x080F0D02, 0x080F0D02, 0x080D0F02, 0x080D0F02, 0x080F0C02, /* 9 */ |
0x080F0C02, 0x080C0F02, 0x080C0F02, 0x080F0B02, 0x080F0B02, /* 14 */ |
0x080B0F02, 0x080B0F02, 0x070A0F02, 0x070A0F02, 0x070A0F02, /* 19 */ |
0x070A0F02, 0x080F0A02, 0x080F0A02, 0x080F0902, 0x080F0902, /* 24 */ |
0x07090F02, 0x07090F02, 0x07090F02, 0x07090F02, 0x07080F02, /* 29 */ |
0x07080F02, 0x07080F02, 0x07080F02, 0x080F0802, 0x080F0802, /* 34 */ |
0x080F0702, 0x080F0702, 0x07070F02, 0x07070F02, 0x07070F02, /* 39 */ |
0x07070F02, 0x070F0602, 0x070F0602, 0x070F0602, 0x070F0602, /* 44 */ |
0x07060F02, 0x07060F02, 0x07060F02, 0x07060F02, 0x070F0502, /* 49 */ |
0x070F0502, 0x070F0502, 0x070F0502, 0x07050F02, 0x07050F02, /* 54 */ |
0x07050F02, 0x07050F02, 0x070F0402, 0x070F0402, 0x070F0402, /* 59 */ |
0x070F0402, 0x07040F02, 0x07040F02, 0x07040F02, 0x07040F02, /* 64 */ |
0x070F0302, 0x070F0302, 0x070F0302, 0x070F0302, 0x07030F02, /* 69 */ |
0x07030F02, 0x07030F02, 0x07030F02, 0x070F0202, 0x070F0202, /* 74 */ |
0x070F0202, 0x070F0202, 0x07020F02, 0x07020F02, 0x07020F02, /* 79 */ |
0x07020F02, 0x07010F02, 0x07010F02, 0x07010F02, 0x07010F02, /* 84 */ |
0x080F0102, 0x080F0102, 0x08000F01, 0x08000F01, 0x090F0001, /* 89 */ |
0x00000201, 0x00000206, 0x0000020B, 0x00000210, 0x00000215, /* 94 */ |
0x0000021A, 0x0000021F, 0x040F0F02, 0x040F0F02, 0x040F0F02, /* 99 */ |
0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, /* 104 */ |
0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, /* 109 */ |
0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, /* 114 */ |
0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, /* 119 */ |
0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, /* 124 */ |
0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, 0x00000224, /* 129 */ |
0x00000229, 0x00000232, 0x00000237, 0x0000023A, 0x0000023F, /* 134 */ |
0x00000242, 0x00000245, 0x0000024A, 0x0000024D, 0x00000250, /* 139 */ |
0x00000253, 0x00000256, 0x00000259, 0x0000025C, 0x0000025F, /* 144 */ |
0x00000262, 0x00000265, 0x00000268, 0x0000026B, 0x0000026E, /* 149 */ |
0x00000271, 0x00000274, 0x00000277, 0x0000027A, 0x0000027D, /* 154 */ |
0x00000280, 0x00000283, 0x00000288, 0x0000028B, 0x0000028E, /* 159 */ |
0x00000291, 0x00000294, 0x00000297, 0x0000029A, 0x0000029F, /* 164 */ |
0x09040B02, 0x000002A4, 0x000002A7, 0x000002AA, 0x09030B02, /* 169 */ |
0x09080802, 0x000002AF, 0x09020B02, 0x000002B2, 0x000002B5, /* 174 */ |
0x09060902, 0x09040A02, 0x000002B8, 0x09070802, 0x090A0302, /* 179 */ |
0x09030A02, 0x09090502, 0x09050902, 0x090A0202, 0x09020A02, /* 184 */ |
0x09010A02, 0x09080602, 0x09060802, 0x09070702, 0x09090402, /* 189 */ |
0x09040902, 0x09090302, 0x09030902, 0x09080502, 0x09050802, /* 194 */ |
0x09090202, 0x09070602, 0x09060702, 0x09020902, 0x09090102, /* 199 */ |
0x09010902, 0x09080402, 0x09040802, 0x09070502, 0x09050702, /* 204 */ |
0x09080302, 0x09030802, 0x09060602, 0x09080202, 0x09020802, /* 209 */ |
0x09080102, 0x09070402, 0x09040702, 0x09010802, 0x000002BB, /* 214 */ |
0x09060502, 0x09050602, 0x09070102, 0x000002BE, 0x08030702, /* 219 */ |
0x08030702, 0x09070302, 0x09070202, 0x08020702, 0x08020702, /* 224 */ |
0x08060402, 0x08060402, 0x08040602, 0x08040602, 0x08050502, /* 229 */ |
0x08050502, 0x08010702, 0x08010702, 0x08060302, 0x08060302, /* 234 */ |
0x08030602, 0x08030602, 0x08050402, 0x08050402, 0x08040502, /* 239 */ |
0x08040502, 0x08060202, 0x08060202, 0x08020602, 0x08020602, /* 244 */ |
0x08060102, 0x08060102, 0x08010602, 0x08010602, 0x09060001, /* 249 */ |
0x09000601, 0x08050302, 0x08050302, 0x08030502, 0x08030502, /* 254 */ |
0x08040402, 0x08040402, 0x08050202, 0x08050202, 0x08020502, /* 259 */ |
0x08020502, 0x08050102, 0x08050102, 0x09050001, 0x09000501, /* 264 */ |
0x07010502, 0x07010502, 0x07010502, 0x07010502, 0x08040302, /* 269 */ |
0x08040302, 0x08030402, 0x08030402, 0x07040202, 0x07040202, /* 274 */ |
0x07040202, 0x07040202, 0x07020402, 0x07020402, 0x07020402, /* 279 */ |
0x07020402, 0x07030302, 0x07030302, 0x07030302, 0x07030302, /* 284 */ |
0x07040102, 0x07040102, 0x07040102, 0x07040102, 0x07010402, /* 289 */ |
0x07010402, 0x07010402, 0x07010402, 0x08040001, 0x08040001, /* 294 */ |
0x08000401, 0x08000401, 0x07030202, 0x07030202, 0x07030202, /* 299 */ |
0x07030202, 0x07020302, 0x07020302, 0x07020302, 0x07020302, /* 304 */ |
0x06030102, 0x06030102, 0x06030102, 0x06030102, 0x06030102, /* 309 */ |
0x06030102, 0x06030102, 0x06030102, 0x06010302, 0x06010302, /* 314 */ |
0x06010302, 0x06010302, 0x06010302, 0x06010302, 0x06010302, /* 319 */ |
0x06010302, 0x07030001, 0x07030001, 0x07030001, 0x07030001, /* 324 */ |
0x07000301, 0x07000301, 0x07000301, 0x07000301, 0x06020202, /* 329 */ |
0x06020202, 0x06020202, 0x06020202, 0x06020202, 0x06020202, /* 334 */ |
0x06020202, 0x06020202, 0x05020102, 0x05020102, 0x05020102, /* 339 */ |
0x05020102, 0x05020102, 0x05020102, 0x05020102, 0x05020102, /* 344 */ |
0x05020102, 0x05020102, 0x05020102, 0x05020102, 0x05020102, /* 349 */ |
0x05020102, 0x05020102, 0x05020102, 0x05010202, 0x05010202, /* 354 */ |
0x05010202, 0x05010202, 0x05010202, 0x05010202, 0x05010202, /* 359 */ |
0x05010202, 0x05010202, 0x05010202, 0x05010202, 0x05010202, /* 364 */ |
0x05010202, 0x05010202, 0x05010202, 0x05010202, 0x06020001, /* 369 */ |
0x06020001, 0x06020001, 0x06020001, 0x06020001, 0x06020001, /* 374 */ |
0x06020001, 0x06020001, 0x06000201, 0x06000201, 0x06000201, /* 379 */ |
0x06000201, 0x06000201, 0x06000201, 0x06000201, 0x06000201, /* 384 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 389 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 394 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 399 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 404 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 409 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 414 */ |
0x04010102, 0x04010102, 0x04010001, 0x04010001, 0x04010001, /* 419 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 424 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 429 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 434 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 439 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 444 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04000101, /* 449 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 454 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 459 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 464 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 469 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 474 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 479 */ |
0x04000101, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 484 */ |
0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 489 */ |
0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 494 */ |
0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 499 */ |
0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 504 */ |
0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 509 */ |
0x04000000, 0x04000000, 0x04000000, 0xFF000002, 0x020E0E02, /* 514 */ |
0x020E0D02, 0x020D0E02, 0x020E0C02, 0xFF000002, 0x020C0E02, /* 519 */ |
0x020D0D02, 0x020E0B02, 0x020B0E02, 0xFF000002, 0x020D0C02, /* 524 */ |
0x020C0D02, 0x020E0A02, 0x020A0E02, 0xFF000002, 0x020D0B02, /* 529 */ |
0x020B0D02, 0x020C0C02, 0x020E0902, 0xFF000002, 0x02090E02, /* 534 */ |
0x020D0A02, 0x020A0D02, 0x020C0B02, 0xFF000002, 0x020B0C02, /* 539 */ |
0x020E0802, 0x02080E02, 0x020D0902, 0xFF000002, 0x02090D02, /* 544 */ |
0x020E0702, 0x02070E02, 0x020C0A02, 0xFF000002, 0x020A0C02, /* 549 */ |
0x020B0B02, 0x020D0802, 0x02080D02, 0xFF000003, 0x030E0001, /* 554 */ |
0x03000E01, 0x020D0001, 0x020D0001, 0x01060E02, 0x01060E02, /* 559 */ |
0x01060E02, 0x01060E02, 0xFF000002, 0x020E0602, 0x020C0902, /* 564 */ |
0x01090C02, 0x01090C02, 0xFF000001, 0x010E0502, 0x010A0B02, /* 569 */ |
0xFF000002, 0x01050E02, 0x01050E02, 0x020B0A02, 0x020D0702, /* 574 */ |
0xFF000001, 0x01070D02, 0x01040E02, 0xFF000001, 0x010C0802, /* 579 */ |
0x01080C02, 0xFF000002, 0x020E0402, 0x020E0202, 0x010E0302, /* 584 */ |
0x010E0302, 0xFF000001, 0x010D0602, 0x01060D02, 0xFF000001, /* 589 */ |
0x01030E02, 0x010B0902, 0xFF000001, 0x01090B02, 0x010A0A02, /* 594 */ |
0xFF000001, 0x01020E02, 0x010E0102, 0xFF000001, 0x01010E02, /* 599 */ |
0x010D0502, 0xFF000001, 0x01050D02, 0x010C0702, 0xFF000001, /* 604 */ |
0x01070C02, 0x010D0402, 0xFF000001, 0x010B0802, 0x01080B02, /* 609 */ |
0xFF000001, 0x01040D02, 0x010A0902, 0xFF000001, 0x01090A02, /* 614 */ |
0x010C0602, 0xFF000001, 0x01060C02, 0x010D0302, 0xFF000001, /* 619 */ |
0x01030D02, 0x010D0202, 0xFF000001, 0x01020D02, 0x010D0102, /* 624 */ |
0xFF000001, 0x010B0702, 0x01070B02, 0xFF000001, 0x01010D02, /* 629 */ |
0x010C0502, 0xFF000001, 0x01050C02, 0x010A0802, 0xFF000001, /* 634 */ |
0x01080A02, 0x01090902, 0xFF000001, 0x010C0402, 0x01040C02, /* 639 */ |
0xFF000001, 0x010B0602, 0x01060B02, 0xFF000002, 0x02000D01, /* 644 */ |
0x020C0001, 0x010C0302, 0x010C0302, 0xFF000001, 0x01030C02, /* 649 */ |
0x010A0702, 0xFF000001, 0x01070A02, 0x010C0202, 0xFF000001, /* 654 */ |
0x01020C02, 0x010B0502, 0xFF000001, 0x01050B02, 0x010C0102, /* 659 */ |
0xFF000001, 0x01090802, 0x01080902, 0xFF000001, 0x01010C02, /* 664 */ |
0x010B0402, 0xFF000002, 0x02000C01, 0x020B0001, 0x010B0302, /* 669 */ |
0x010B0302, 0xFF000002, 0x02000B01, 0x020A0001, 0x010A0102, /* 674 */ |
0x010A0102, 0xFF000001, 0x010A0602, 0x01060A02, 0xFF000001, /* 679 */ |
0x01090702, 0x01070902, 0xFF000002, 0x02000A01, 0x02090001, /* 684 */ |
0x01000901, 0x01000901, 0xFF000001, 0x010B0202, 0x010A0502, /* 689 */ |
0xFF000001, 0x01050A02, 0x010B0102, 0xFF000001, 0x01010B02, /* 694 */ |
0x01090602, 0xFF000001, 0x010A0402, 0x01080702, 0xFF000001, /* 699 */ |
0x01080001, 0x01000801, 0xFF000001, 0x01070001, 0x01000701, /* 704 */ }; |
/* max table bits 9 */ |
/* NO XING TABLE 25 */ |
/* NO XING TABLE 26 */ |
/* NO XING TABLE 27 */ |
/* NO XING TABLE 28 */ |
/* NO XING TABLE 29 */ |
/* NO XING TABLE 30 */ |
/* NO XING TABLE 31 */ |
/* done */ |
/programs/media/ac97snd/trunk/mp3dec/l3hybrid.c |
---|
0,0 → 1,265 |
#include <math.h> |
extern int m_band_limit; |
/* "imdct.c" */ |
void imdct18(float f[]); /* 18 point */ |
void imdct6_3(float f[]); /* 6 point */ |
/*-- windows by block type --*/ |
static float win[4][36]; |
void hwin_init() |
{ |
int i, j; |
double pi; |
pi = 4.0 * atan(1.0); |
/* type 0 */ |
for (i = 0; i < 36; i++) |
win[0][i] = (float) sin(pi / 36 * (i + 0.5)); |
/* type 1 */ |
for (i = 0; i < 18; i++) |
win[1][i] = (float) sin(pi / 36 * (i + 0.5)); |
for (i = 18; i < 24; i++) |
win[1][i] = 1.0F; |
for (i = 24; i < 30; i++) |
win[1][i] = (float) sin(pi / 12 * (i + 0.5 - 18)); |
for (i = 30; i < 36; i++) |
win[1][i] = 0.0F; |
/* type 3 */ |
for (i = 0; i < 6; i++) |
win[3][i] = 0.0F; |
for (i = 6; i < 12; i++) |
win[3][i] = (float) sin(pi / 12 * (i + 0.5 - 6)); |
for (i = 12; i < 18; i++) |
win[3][i] = 1.0F; |
for (i = 18; i < 36; i++) |
win[3][i] = (float) sin(pi / 36 * (i + 0.5)); |
/* type 2 */ |
for (i = 0; i < 12; i++) |
win[2][i] = (float) sin(pi / 12 * (i + 0.5)); |
for (i = 12; i < 36; i++) |
win[2][i] = 0.0F; |
/*--- invert signs by region to match mdct 18pt --> 36pt mapping */ |
for (j = 0; j < 4; j++) |
{ |
if (j == 2) |
continue; |
for (i = 9; i < 36; i++) |
win[j][i] = -win[j][i]; |
} |
/*-- invert signs for short blocks --*/ |
for (i = 3; i < 12; i++) |
win[2][i] = -win[2][i]; |
return; |
} |
/*====================================================================*/ |
int hybrid(float xin[], float xprev[], float y[18][32], |
int btype, int nlong, int ntot, int nprev) |
{ |
int i, j; |
float *x, *x0; |
float xa, xb; |
int n; |
int nout; |
int band_limit_nsb; |
if (btype == 2) |
btype = 0; |
x = xin; |
x0 = xprev; |
/*-- do long blocks (if any) --*/ |
n = (nlong + 17) / 18; /* number of dct's to do */ |
for (i = 0; i < n; i++) |
{ |
imdct18(x); |
for (j = 0; j < 9; j++) |
{ |
y[j][i] = x0[j] + win[btype][j] * x[9 + j]; |
y[9 + j][i] = x0[9 + j] + win[btype][9 + j] * x[17 - j]; |
} |
/* window x for next time x0 */ |
for (j = 0; j < 4; j++) |
{ |
xa = x[j]; |
xb = x[8 - j]; |
x[j] = win[btype][18 + j] * xb; |
x[8 - j] = win[btype][(18 + 8) - j] * xa; |
x[9 + j] = win[btype][(18 + 9) + j] * xa; |
x[17 - j] = win[btype][(18 + 17) - j] * xb; |
} |
xa = x[j]; |
x[j] = win[btype][18 + j] * xa; |
x[9 + j] = win[btype][(18 + 9) + j] * xa; |
x += 18; |
x0 += 18; |
} |
/*-- do short blocks (if any) --*/ |
n = (ntot + 17) / 18; /* number of 6 pt dct's triples to do */ |
for (; i < n; i++) |
{ |
imdct6_3(x); |
for (j = 0; j < 3; j++) |
{ |
y[j][i] = x0[j]; |
y[3 + j][i] = x0[3 + j]; |
y[6 + j][i] = x0[6 + j] + win[2][j] * x[3 + j]; |
y[9 + j][i] = x0[9 + j] + win[2][3 + j] * x[5 - j]; |
y[12 + j][i] = x0[12 + j] + win[2][6 + j] * x[2 - j] + win[2][j] * x[(6 + 3) + j]; |
y[15 + j][i] = x0[15 + j] + win[2][9 + j] * x[j] + win[2][3 + j] * x[(6 + 5) - j]; |
} |
/* window x for next time x0 */ |
for (j = 0; j < 3; j++) |
{ |
x[j] = win[2][6 + j] * x[(6 + 2) - j] + win[2][j] * x[(12 + 3) + j]; |
x[3 + j] = win[2][9 + j] * x[6 + j] + win[2][3 + j] * x[(12 + 5) - j]; |
} |
for (j = 0; j < 3; j++) |
{ |
x[6 + j] = win[2][6 + j] * x[(12 + 2) - j]; |
x[9 + j] = win[2][9 + j] * x[12 + j]; |
} |
for (j = 0; j < 3; j++) |
{ |
x[12 + j] = 0.0f; |
x[15 + j] = 0.0f; |
} |
x += 18; |
x0 += 18; |
} |
/*--- overlap prev if prev longer that current --*/ |
n = (nprev + 17) / 18; |
for (; i < n; i++) |
{ |
for (j = 0; j < 18; j++) |
y[j][i] = x0[j]; |
x0 += 18; |
} |
nout = 18 * i; |
/*--- clear remaining only to band limit --*/ |
band_limit_nsb = (m_band_limit + 17) / 18; /* limit nsb's rounded up */ |
for (; i < band_limit_nsb; i++) |
{ |
for (j = 0; j < 18; j++) |
y[j][i] = 0.0f; |
} |
return nout; |
} |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
/*-- convert to mono, add curr result to y, |
window and add next time to current left */ |
int hybrid_sum(float xin[], float xin_left[], float y[18][32], |
int btype, int nlong, int ntot) |
{ |
int i, j; |
float *x, *x0; |
float xa, xb; |
int n; |
int nout; |
if (btype == 2) |
btype = 0; |
x = xin; |
x0 = xin_left; |
/*-- do long blocks (if any) --*/ |
n = (nlong + 17) / 18; /* number of dct's to do */ |
for (i = 0; i < n; i++) |
{ |
imdct18(x); |
for (j = 0; j < 9; j++) |
{ |
y[j][i] += win[btype][j] * x[9 + j]; |
y[9 + j][i] += win[btype][9 + j] * x[17 - j]; |
} |
/* window x for next time x0 */ |
for (j = 0; j < 4; j++) |
{ |
xa = x[j]; |
xb = x[8 - j]; |
x0[j] += win[btype][18 + j] * xb; |
x0[8 - j] += win[btype][(18 + 8) - j] * xa; |
x0[9 + j] += win[btype][(18 + 9) + j] * xa; |
x0[17 - j] += win[btype][(18 + 17) - j] * xb; |
} |
xa = x[j]; |
x0[j] += win[btype][18 + j] * xa; |
x0[9 + j] += win[btype][(18 + 9) + j] * xa; |
x += 18; |
x0 += 18; |
} |
/*-- do short blocks (if any) --*/ |
n = (ntot + 17) / 18; /* number of 6 pt dct's triples to do */ |
for (; i < n; i++) |
{ |
imdct6_3(x); |
for (j = 0; j < 3; j++) |
{ |
y[6 + j][i] += win[2][j] * x[3 + j]; |
y[9 + j][i] += win[2][3 + j] * x[5 - j]; |
y[12 + j][i] += win[2][6 + j] * x[2 - j] + win[2][j] * x[(6 + 3) + j]; |
y[15 + j][i] += win[2][9 + j] * x[j] + win[2][3 + j] * x[(6 + 5) - j]; |
} |
/* window x for next time */ |
for (j = 0; j < 3; j++) |
{ |
x0[j] += win[2][6 + j] * x[(6 + 2) - j] + win[2][j] * x[(12 + 3) + j]; |
x0[3 + j] += win[2][9 + j] * x[6 + j] + win[2][3 + j] * x[(12 + 5) - j]; |
} |
for (j = 0; j < 3; j++) |
{ |
x0[6 + j] += win[2][6 + j] * x[(12 + 2) - j]; |
x0[9 + j] += win[2][9 + j] * x[12 + j]; |
} |
x += 18; |
x0 += 18; |
} |
nout = 18 * i; |
return nout; |
} |
/*--------------------------------------------------------------------*/ |
void sum_f_bands(float a[], float b[], int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
a[i] += b[i]; |
} |
/*--------------------------------------------------------------------*/ |
void freq_invert(float y[18][32], int n) |
{ |
int i, j; |
n = (n + 17) / 18; |
for (j = 0; j < 18; j += 2) |
{ |
for (i = 0; i < n; i += 2) |
{ |
y[1 + j][1 + i] = -y[1 + j][1 + i]; |
} |
} |
} |
/*--------------------------------------------------------------------*/ |
/programs/media/ac97snd/trunk/mp3dec/l3init.c |
---|
0,0 → 1,212 |
#include "layer3.h" |
extern MPEG_DECODE_OPTION m_option; |
extern SAMPLE m_sample[2][2][576]; |
extern int m_frequency; |
extern SBT_PROC m_sbt_proc; |
extern XFORM_PROC m_xform_proc; |
extern int m_channels; |
extern int m_sfBandIndex[2][22];// [long/short][cb] |
extern int m_nBand[2][22]; |
extern int m_band_limit; |
extern int m_band_limit21; // limit for sf band 21 |
extern int m_band_limit12; // limit for sf band 12 short |
extern int m_band_limit_nsb; |
extern int m_ncbl_mixed; |
extern int m_nsb_limit; |
extern int m_gr; |
extern int m_buf_ptr0, m_buf_ptr1; |
extern float m_yout[576]; |
//extern "l3sbt.c" |
void sbt_mono_L3(float *sample, signed short *pcm, int ch); |
void sbt_dual_L3(float *sample, signed short *pcm, int ch); |
void sbt16_mono_L3(float *sample, signed short *pcm, int ch); |
void sbt16_dual_L3(float *sample, signed short *pcm, int ch); |
void sbt8_mono_L3(float *sample, signed short *pcm, int ch); |
void sbt8_dual_L3(float *sample, signed short *pcm, int ch); |
void sbtB_mono_L3(float *sample, unsigned char *pcm, int ch); |
void sbtB_dual_L3(float *sample, unsigned char *pcm, int ch); |
void sbtB16_mono_L3(float *sample, unsigned char *pcm, int ch); |
void sbtB16_dual_L3(float *sample, unsigned char *pcm, int ch); |
void sbtB8_mono_L3(float *sample, unsigned char *pcm, int ch); |
void sbtB8_dual_L3(float *sample, unsigned char *pcm, int ch); |
//extern "l3dec.c" |
void xform_mono(void *pcm, int igr); |
void xform_dual(void *pcm, int igr); |
void xform_dual_mono(void *pcm, int igr); |
void xform_dual_right(void *pcm, int igr); |
static const SBT_PROC sbt_table[2][3][2] = |
{ |
sbt_mono_L3, |
sbt_dual_L3, |
sbt16_mono_L3, |
sbt16_dual_L3, |
sbt8_mono_L3, |
sbt8_dual_L3, |
// 8 bit output |
sbtB_mono_L3, |
sbtB_dual_L3, |
sbtB16_mono_L3, |
sbtB16_dual_L3, |
sbtB8_mono_L3, |
sbtB8_dual_L3, |
}; |
static const XFORM_PROC xform_table[5] = |
{ |
xform_mono, |
xform_dual, |
xform_dual_mono, |
xform_mono, /* left */ |
xform_dual_right, |
}; |
static const struct { |
int l[23]; |
int s[14]; |
} sfBandTable[3][3] = { |
// MPEG-1 |
{{ |
{0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342, 418, 576}, |
{0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84, 106, 136, 192} |
},{ |
{0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190, 230, 276, 330, 384, 576}, |
{0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80, 100, 126, 192} |
},{ |
{0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240, 296, 364, 448, 550, 576}, |
{0, 4, 8, 12, 16, 22, 30, 42, 58, 78, 104, 138, 180, 192} |
}}, |
// MPEG-2 |
{{ |
{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, |
{0, 4, 8, 12, 18, 24, 32, 42, 56, 74, 100, 132, 174, 192} |
},{ |
{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232, 278, 332, 394, 464, 540, 576}, |
{0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 136, 180, 192} |
},{ |
{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, |
{0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192} |
}}, |
// MPEG-2.5, 11 & 12 KHz seem ok, 8 ok |
{{ |
{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, |
{0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192} |
},{ |
{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, |
{0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192} |
},{ |
// this 8khz table, and only 8khz, from mpeg123) |
{0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400, 476, 566, 568, 570, 572, 574, 576}, |
{0, 8, 16, 24, 36, 52, 72, 96, 124, 160, 162, 164, 166, 192} |
}}, |
}; |
void quant_init(); |
void alias_init(); |
void msis_init(); |
void fdct_init(); |
void imdct_init(); |
void hwin_init(); |
void L3table_init() |
{ |
quant_init(); |
alias_init(); |
msis_init(); |
fdct_init(); |
imdct_init(); |
hwin_init(); |
} |
int L3decode_start(MPEG_HEADER* h) |
{ |
int i, j, k, v; |
int channels, limit; |
int bit_code; |
m_buf_ptr0 = 0; |
m_buf_ptr1 = 0; |
m_gr = 0; |
v = h->version - 1; |
if (h->version == 1) //MPEG-1 |
m_ncbl_mixed = 8; |
else //MPEG-2, MPEG-2.5 |
m_ncbl_mixed = 6; |
// compute nsb_limit |
m_nsb_limit = (m_option.freqLimit * 64L + m_frequency / 2) / m_frequency; |
// caller limit |
limit = (32 >> m_option.reduction); |
if (limit > 8) |
limit--; |
if (m_nsb_limit > limit) |
m_nsb_limit = limit; |
limit = 18 * m_nsb_limit; |
if (h->version == 1) { |
//MPEG-1 |
m_band_limit12 = 3 * sfBandTable[v][h->fr_index].s[13]; |
m_band_limit = m_band_limit21 = sfBandTable[v][h->fr_index].l[22]; |
} |
else { |
//MPEG-2, MPEG-2.5 |
m_band_limit12 = 3 * sfBandTable[v][h->fr_index].s[12]; |
m_band_limit = m_band_limit21 = sfBandTable[v][h->fr_index].l[21]; |
} |
m_band_limit += 8; // allow for antialias |
if (m_band_limit > limit) |
m_band_limit = limit; |
if (m_band_limit21 > m_band_limit) |
m_band_limit21 = m_band_limit; |
if (m_band_limit12 > m_band_limit) |
m_band_limit12 = m_band_limit; |
m_band_limit_nsb = (m_band_limit + 17) / 18; // limit nsb's rounded up |
/* |
gain_adjust = 0; // adjust gain e.g. cvt to mono sum channel |
if ((h->mode != 3) && (m_option.convert == 1)) |
gain_adjust = -4; |
*/ |
m_channels = (h->mode == 3) ? 1 : 2; |
if (m_option.convert) channels = 1; |
else channels = m_channels; |
bit_code = (m_option.convert & 8) ? 1 : 0; |
m_sbt_proc = sbt_table[bit_code][m_option.reduction][channels - 1];//[2][3][2] |
k = (h->mode != 3) ? (1 + m_option.convert) : 0; |
m_xform_proc = xform_table[k];//[5] |
/* |
if (bit_code) |
zero_level_pcm = 128;// 8 bit output |
else |
zero_level_pcm = 0; |
*/ |
// init band tables |
for (i = 0; i < 22; i ++) |
m_sfBandIndex[0][i] = sfBandTable[v][h->fr_index].l[i + 1]; |
for (i = 0; i < 13; i ++) |
m_sfBandIndex[1][i] = 3 * sfBandTable[v][h->fr_index].s[i + 1]; |
for (i = 0; i < 22; i ++) |
m_nBand[0][i] = sfBandTable[v][h->fr_index].l[i + 1] |
- sfBandTable[v][h->fr_index].l[i]; |
for (i = 0; i < 13; i ++) |
m_nBand[1][i] = sfBandTable[v][h->fr_index].s[i + 1] |
- sfBandTable[v][h->fr_index].s[i]; |
// clear buffers |
for (i = 0; i < 576; i++) |
m_yout[i] = 0.0f; |
for (i = 0; i < 2; i ++) |
{ for (j = 0; j < 2; j ++) |
{ for (k = 0; k < 576; k++) |
{ m_sample[i][j][k].x = 0.0f; |
m_sample[i][j][k].s = 0; |
} |
} |
} |
return 1; |
} |
/programs/media/ac97snd/trunk/mp3dec/l3msis.c |
---|
0,0 → 1,332 |
#include "layer3.h" |
#include <math.h> |
//#include <windows.h> |
extern IS_SF_INFO m_is_sf_info; |
extern int m_ms_mode, m_is_mode; |
extern int m_sfBandIndex[2][22];// [long/short][cb] |
extern int m_nBand[2][22]; |
/* intensity stereo */ |
/* if ms mode quant pre-scales all values by 1.0/sqrt(2.0) ms_mode in table |
compensates */ |
/* [ms_mode 0/1][sf][left/right] */ |
static float lr[2][8][2]; |
/* lr2[intensity_scale][ms_mode][sflen_offset+sf][left/right] */ |
static float lr2[2][2][64][2]; |
/*-------*msis_init_addr() |
pi = 4.0*atan(1.0); |
t = pi/12.0; |
for(i=0;i<7;i++) { |
s = sin(i*t); |
c = cos(i*t); |
// ms_mode = 0 |
lr[0][i][0] = (float)(s/(s+c)); |
lr[0][i][1] = (float)(c/(s+c)); |
// ms_mode = 1 |
lr[1][i][0] = (float)(sqrt(2.0)*(s/(s+c))); |
lr[1][i][1] = (float)(sqrt(2.0)*(c/(s+c))); |
} |
//sf = 7 |
//ms_mode = 0 |
lr[0][i][0] = 1.0f; |
lr[0][i][1] = 0.0f; |
// ms_mode = 1, in is bands is routine does ms processing |
lr[1][i][0] = 1.0f; |
lr[1][i][1] = 1.0f; |
------------*/ |
/*===============================================================*/ |
void msis_init1() |
{ |
int i; |
double s, c; |
double pi; |
double t; |
pi = 4.0 * atan(1.0); |
t = pi / 12.0; |
for (i = 0; i < 7; i++) |
{ |
s = sin(i * t); |
c = cos(i * t); |
/* ms_mode = 0 */ |
lr[0][i][0] = (float) (s / (s + c)); |
lr[0][i][1] = (float) (c / (s + c)); |
/* ms_mode = 1 */ |
lr[1][i][0] = (float) (sqrt(2.0) * (s / (s + c))); |
lr[1][i][1] = (float) (sqrt(2.0) * (c / (s + c))); |
} |
/* sf = 7 */ |
/* ms_mode = 0 */ |
lr[0][i][0] = 1.0f; |
lr[0][i][1] = 0.0f; |
/* ms_mode = 1, in is bands is routine does ms processing */ |
lr[1][i][0] = 1.0f; |
lr[1][i][1] = 1.0f; |
/*------- |
for(i=0;i<21;i++) m_nBand[0][i] = |
sfBandTable[sr_index].l[i+1] - sfBandTable[sr_index].l[i]; |
for(i=0;i<12;i++) m_nBand[1][i] = |
sfBandTable[sr_index].s[i+1] - sfBandTable[sr_index].s[i]; |
-------------*/ |
} |
/*===============================================================*/ |
void msis_init2() |
{ |
int k, n; |
double t; |
int intensity_scale, ms_mode, sf, sflen; |
float ms_factor[2]; |
ms_factor[0] = 1.0; |
ms_factor[1] = (float) sqrt(2.0); |
/* intensity stereo MPEG2 */ |
/* lr2[intensity_scale][ms_mode][sflen_offset+sf][left/right] */ |
for (intensity_scale = 0; intensity_scale < 2; intensity_scale++) |
{ |
t = pow_test(2.0, -0.25 * (1 + intensity_scale)); |
for (ms_mode = 0; ms_mode < 2; ms_mode++) |
{ |
n = 1; |
k = 0; |
for (sflen = 0; sflen < 6; sflen++) |
{ |
for (sf = 0; sf < (n - 1); sf++, k++) |
{ |
if (sf == 0) |
{ |
lr2[intensity_scale][ms_mode][k][0] = ms_factor[ms_mode] * 1.0f; |
lr2[intensity_scale][ms_mode][k][1] = ms_factor[ms_mode] * 1.0f; |
} |
else if ((sf & 1)) |
{ |
lr2[intensity_scale][ms_mode][k][0] = |
(float) (ms_factor[ms_mode] * pow_test(t, (sf + 1) / 2)); |
lr2[intensity_scale][ms_mode][k][1] = ms_factor[ms_mode] * 1.0f; |
} |
else |
{ |
lr2[intensity_scale][ms_mode][k][0] = ms_factor[ms_mode] * 1.0f; |
lr2[intensity_scale][ms_mode][k][1] = |
(float) (ms_factor[ms_mode] * pow_test(t, sf / 2)); |
} |
} |
/* illegal is_pos used to do ms processing */ |
if (ms_mode == 0) |
{ /* ms_mode = 0 */ |
lr2[intensity_scale][ms_mode][k][0] = 1.0f; |
lr2[intensity_scale][ms_mode][k][1] = 0.0f; |
} |
else |
{ |
/* ms_mode = 1, in is bands is routine does ms processing */ |
lr2[intensity_scale][ms_mode][k][0] = 1.0f; |
lr2[intensity_scale][ms_mode][k][1] = 1.0f; |
} |
k++; |
n = n + n; |
} |
} |
} |
} |
void msis_init() |
{ |
msis_init1(); |
msis_init2(); |
} |
/*===============================================================*/ |
void ms_process(float x[][1152], int n) /* sum-difference stereo */ |
{ |
int i; |
float xl, xr; |
/*-- note: sqrt(2) done scaling by dequant ---*/ |
for (i = 0; i < n; i++) |
{ |
xl = x[0][i] + x[1][i]; |
xr = x[0][i] - x[1][i]; |
x[0][i] = xl; |
x[1][i] = xr; |
} |
return; |
} |
void is_process1(float x[][1152], /* intensity stereo */ |
SCALE_FACTOR* sf, |
CB_INFO cb_info[2], /* [ch] */ |
int nsamp) |
{ |
int i, j, n, cb, w; |
float fl, fr; |
int m; |
int isf; |
float fls[3], frs[3]; |
int cb0; |
cb0 = cb_info[1].cbmax; /* start at end of right */ |
i = m_sfBandIndex[cb_info[1].cbtype][cb0]; |
cb0++; |
m = nsamp - i; /* process to len of left */ |
if (cb_info[1].cbtype) |
goto short_blocks; |
/*------------------------*/ |
/* long_blocks: */ |
for (cb = cb0; cb < 21; cb++) |
{ |
isf = sf->l[cb]; |
n = m_nBand[0][cb]; |
fl = lr[m_ms_mode][isf][0]; |
fr = lr[m_ms_mode][isf][1]; |
for (j = 0; j < n; j++, i++) |
{ |
if (--m < 0) |
goto exit; |
x[1][i] = fr * x[0][i]; |
x[0][i] = fl * x[0][i]; |
} |
} |
return; |
/*------------------------*/ |
short_blocks: |
for (cb = cb0; cb < 12; cb++) |
{ |
for (w = 0; w < 3; w++) |
{ |
isf = sf->s[w][cb]; |
fls[w] = lr[m_ms_mode][isf][0]; |
frs[w] = lr[m_ms_mode][isf][1]; |
} |
n = m_nBand[1][cb]; |
for (j = 0; j < n; j++) |
{ |
m -= 3; |
if (m < 0) |
goto exit; |
x[1][i] = frs[0] * x[0][i]; |
x[0][i] = fls[0] * x[0][i]; |
x[1][1 + i] = frs[1] * x[0][1 + i]; |
x[0][1 + i] = fls[1] * x[0][1 + i]; |
x[1][2 + i] = frs[2] * x[0][2 + i]; |
x[0][2 + i] = fls[2] * x[0][2 + i]; |
i += 3; |
} |
} |
exit: |
return; |
} |
typedef float ARRAY2[2]; |
void is_process2(float x[][1152], /* intensity stereo */ |
SCALE_FACTOR* sf, |
CB_INFO cb_info[2], /* [ch] */ |
int nsamp) |
{ |
int i, j, k, n, cb, w; |
float fl, fr; |
int m; |
int isf; |
int il[21]; |
int tmp; |
int r; |
ARRAY2 *lr; |
int cb0, cb1; |
lr = lr2[m_is_sf_info.intensity_scale][m_ms_mode]; |
if (cb_info[1].cbtype) |
goto short_blocks; |
/*------------------------*/ |
/* long_blocks: */ |
cb0 = cb_info[1].cbmax; /* start at end of right */ |
i = m_sfBandIndex[0][cb0]; |
m = nsamp - i; /* process to len of left */ |
/* gen sf info */ |
for (k = r = 0; r < 3; r++) |
{ |
tmp = (1 << m_is_sf_info.slen[r]) - 1; |
for (j = 0; j < m_is_sf_info.nr[r]; j++, k++) |
il[k] = tmp; |
} |
for (cb = cb0 + 1; cb < 21; cb++) |
{ |
isf = il[cb] + sf->l[cb]; |
// X-MaD 27-02-02 |
if (isf < 0) { isf = 0; } |
fl = 0; |
fr = 0; |
//try |
//{ |
fl = lr[isf][0]; |
fr = lr[isf][1]; |
n = m_nBand[0][cb]; |
//} |
//catch(...) |
//{ |
// isf = 0; |
//} |
// X-MaD 27-02-02 |
for (j = 0; j < n; j++, i++) |
{ |
if (--m < 0) |
{ |
goto exit; |
} |
x[1][i] = fr * x[0][i]; |
x[0][i] = fl * x[0][i]; |
} |
} |
return; |
/*------------------------*/ |
short_blocks: |
for (k = r = 0; r < 3; r++) |
{ |
tmp = (1 << m_is_sf_info.slen[r]) - 1; |
for (j = 0; j < m_is_sf_info.nr[r]; j++, k++) |
il[k] = tmp; |
} |
for (w = 0; w < 3; w++) |
{ |
cb0 = cb_info[1].cbmax_s[w]; /* start at end of right */ |
i = m_sfBandIndex[1][cb0] + w; |
cb1 = cb_info[0].cbmax_s[w]; /* process to end of left */ |
for (cb = cb0 + 1; cb <= cb1; cb++) |
{ |
isf = il[cb] + sf->s[w][cb]; |
fl = lr[isf][0]; |
fr = lr[isf][1]; |
n = m_nBand[1][cb]; |
for (j = 0; j < n; j++) |
{ |
x[1][i] = fr * x[0][i]; |
x[0][i] = fl * x[0][i]; |
i += 3; |
} |
} |
} |
exit: |
return; |
} |
/programs/media/ac97snd/trunk/mp3dec/l3quant.c |
---|
0,0 → 1,217 |
#include "layer3.h" |
#include <math.h> |
#include <string.h> //memmove |
extern SIDE_INFO m_side_info; |
extern SCALE_FACTOR m_scale_fac[2][2]; // [gr][ch] |
extern CB_INFO m_cb_info[2][2]; // [gr][ch] |
extern int m_nsamp[2][2]; |
extern int m_nBand[2][22]; |
extern int m_ncbl_mixed; |
#define GLOBAL_GAIN_SCALE (4*15) |
static const int pretab[2][22] = |
{ |
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0}, |
}; |
/* 8 bit plus 2 lookup x = pow(2.0, 0.25*(global_gain-210)) */ |
/* two extra slots to do 1/sqrt(2) scaling for ms */ |
/* 4 extra slots to do 1/2 scaling for cvt to mono */ |
static float look_global[256 + 2 + 4]; |
/*-------- scaling lookup |
x = pow(2.0, -0.5*(1+scalefact_scale)*scalefac + preemp) |
look_scale[scalefact_scale][preemp][scalefac] |
-----------------------*/ |
static float look_scale[2][4][32]; |
/*--- iSample**(4/3) lookup, -32<=i<=31 ---*/ |
#define ISMAX 32 |
static float look_pow[2 * ISMAX]; |
/*-- pow(2.0, -0.25*8.0*subblock_gain) --*/ |
static float look_subblock[8]; |
/*-- reorder buffer ---*/ |
static float re_buf[192][3]; |
typedef float ARRAY3[3]; |
void quant_init() |
{ |
int i; |
int scalefact_scale, preemp, scalefac; |
double tmp; |
/* 8 bit plus 2 lookup x = pow(2.0, 0.25*(global_gain-210)) */ |
/* extra 2 for ms scaling by 1/sqrt(2) */ |
/* extra 4 for cvt to mono scaling by 1/2 */ |
for (i = 0; i < 256 + 2 + 4; i++) |
look_global[i] = (float) pow_test(2.0, 0.25 * ((i - (2 + 4)) - 210 + GLOBAL_GAIN_SCALE)); |
/* x = pow(2.0, -0.5*(1+scalefact_scale)*scalefac + preemp) */ |
for (scalefact_scale = 0; scalefact_scale < 2; scalefact_scale++) |
{ |
for (preemp = 0; preemp < 4; preemp++) |
{ |
for (scalefac = 0; scalefac < 32; scalefac++) |
{ |
look_scale[scalefact_scale][preemp][scalefac] = |
(float) pow_test(2.0, -0.5 * (1 + scalefact_scale) * (scalefac + preemp)); |
} |
} |
} |
/*--- iSample**(4/3) lookup, -32<=i<=31 ---*/ |
for (i = 0; i < 64; i++) |
{ |
tmp = i - 32; |
look_pow[i] = (float) (tmp * pow_test(fabs(tmp), (1.0 / 3.0))); |
} |
/*-- pow(2.0, -0.25*8.0*subblock_gain) 3 bits --*/ |
for (i = 0; i < 8; i++) |
{ |
look_subblock[i] = (float) pow_test(2.0, 0.25 * -8.0 * i); |
} |
// quant_init_sf_band(sr_index); replaced by code in sup.c |
} |
void dequant(SAMPLE Sample[], int gr, int ch) |
{ |
SCALE_FACTOR* sf = &m_scale_fac[gr][ch]; |
GR_INFO* gr_info = &m_side_info.gr[gr][ch]; |
CB_INFO* cb_info = &m_cb_info[gr][ch]; |
int* nsamp = &m_nsamp[gr][ch]; |
int i, j; |
int cb, n, w; |
float x0, xs; |
float xsb[3]; |
double tmp; |
int ncbl; |
int cbs0; |
ARRAY3 *buf; /* short block reorder */ |
int nbands; |
int i0; |
int non_zero; |
int cbmax[3]; |
nbands = *nsamp; |
ncbl = 22; /* long block cb end */ |
cbs0 = 12; /* short block cb start */ |
/* ncbl_mixed = 8 or 6 mpeg1 or 2 */ |
if (gr_info->block_type == 2) |
{ |
ncbl = 0; |
cbs0 = 0; |
if (gr_info->mixed_block_flag) |
{ |
ncbl = m_ncbl_mixed; |
cbs0 = 3; |
} |
} |
/* fill in cb_info -- */ |
cb_info->lb_type = gr_info->block_type; |
if (gr_info->block_type == 2) |
cb_info->lb_type; |
cb_info->cbs0 = cbs0; |
cb_info->ncbl = ncbl; |
cbmax[2] = cbmax[1] = cbmax[0] = 0; |
/* global gain pre-adjusted by 2 if ms_mode, 0 otherwise */ |
x0 = look_global[(2 + 4) + gr_info->global_gain]; |
i = 0; |
/*----- long blocks ---*/ |
for (cb = 0; cb < ncbl; cb++) |
{ |
non_zero = 0; |
xs = x0 * look_scale[gr_info->scalefac_scale][pretab[gr_info->preflag][cb]][sf->l[cb]]; |
n = m_nBand[0][cb]; |
for (j = 0; j < n; j++, i++) |
{ |
if (Sample[i].s == 0) |
Sample[i].x = 0.0F; |
else |
{ |
non_zero = 1; |
if ((Sample[i].s >= (-ISMAX)) && (Sample[i].s < ISMAX)) |
Sample[i].x = xs * look_pow[ISMAX + Sample[i].s]; |
else |
{ |
tmp = (double) Sample[i].s; |
Sample[i].x = (float) (xs * tmp * pow_test(fabs(tmp), (1.0 / 3.0))); |
} |
} |
} |
if (non_zero) |
cbmax[0] = cb; |
if (i >= nbands) |
break; |
} |
cb_info->cbmax = cbmax[0]; |
cb_info->cbtype = 0; // type = long |
if (cbs0 >= 12) |
return; |
/*--------------------------- |
block type = 2 short blocks |
----------------------------*/ |
cbmax[2] = cbmax[1] = cbmax[0] = cbs0; |
i0 = i; /* save for reorder */ |
buf = re_buf; |
for (w = 0; w < 3; w++) |
xsb[w] = x0 * look_subblock[gr_info->subblock_gain[w]]; |
for (cb = cbs0; cb < 13; cb++) |
{ |
n = m_nBand[1][cb]; |
for (w = 0; w < 3; w++) |
{ |
non_zero = 0; |
xs = xsb[w] * look_scale[gr_info->scalefac_scale][0][sf->s[w][cb]]; |
for (j = 0; j < n; j++, i++) |
{ |
if (Sample[i].s == 0) |
buf[j][w] = 0.0F; |
else |
{ |
non_zero = 1; |
if ((Sample[i].s >= (-ISMAX)) && (Sample[i].s < ISMAX)) |
buf[j][w] = xs * look_pow[ISMAX + Sample[i].s]; |
else |
{ |
tmp = (double) Sample[i].s; |
buf[j][w] = (float) (xs * tmp * pow_test(fabs(tmp), (1.0 / 3.0))); |
} |
} |
} |
if (non_zero) |
cbmax[w] = cb; |
} |
if (i >= nbands) |
break; |
buf += n; |
} |
memmove(&Sample[i0].x, &re_buf[0][0], sizeof(float) * (i - i0)); |
*nsamp = i; /* update nsamp */ |
cb_info->cbmax_s[0] = cbmax[0]; |
cb_info->cbmax_s[1] = cbmax[1]; |
cb_info->cbmax_s[2] = cbmax[2]; |
if (cbmax[1] > cbmax[0]) |
cbmax[0] = cbmax[1]; |
if (cbmax[2] > cbmax[0]) |
cbmax[0] = cbmax[2]; |
cb_info->cbmax = cbmax[0]; |
cb_info->cbtype = 1; /* type = short */ |
} |
/programs/media/ac97snd/trunk/mp3dec/l3sf.c |
---|
0,0 → 1,353 |
#include "layer3.h" |
extern SIDE_INFO m_side_info; |
extern SCALE_FACTOR m_scale_fac[2][2]; // [gr][ch] |
extern IS_SF_INFO m_is_sf_info; |
extern int m_is_mode; |
static const int slen_table[16][2] = |
{ |
0, 0, 0, 1, |
0, 2, 0, 3, |
3, 0, 1, 1, |
1, 2, 1, 3, |
2, 1, 2, 2, |
2, 3, 3, 1, |
3, 2, 3, 3, |
4, 2, 4, 3, |
}; |
/* nr_table[size+3*is_right][block type 0,1,3 2, 2+mixed][4] */ |
/* for bt=2 nr is count for group of 3 */ |
static const int nr_table[6][3][4] = |
{ |
6, 5, 5, 5, |
3, 3, 3, 3, |
6, 3, 3, 3, |
6, 5, 7, 3, |
3, 3, 4, 2, |
6, 3, 4, 2, |
11, 10, 0, 0, |
6, 6, 0, 0, |
6, 3, 6, 0, /* adjusted *//* 15, 18, 0, 0, */ |
/*-intensity stereo right chan--*/ |
7, 7, 7, 0, |
4, 4, 4, 0, |
6, 5, 4, 0, |
6, 6, 6, 3, |
4, 3, 3, 2, |
6, 4, 3, 2, |
8, 8, 5, 0, |
5, 4, 3, 0, |
6, 6, 3, 0, |
}; |
void L3get_scale_factor1(int gr, int ch) |
{ |
SCALE_FACTOR* sf = &m_scale_fac[gr][ch]; |
GR_INFO* grdat = &m_side_info.gr[gr][ch]; |
int scfsi = m_side_info.scfsi[ch]; |
int sfb; |
int slen0, slen1; |
int block_type, mixed_block_flag, scalefac_compress; |
block_type = grdat->block_type; |
mixed_block_flag = grdat->mixed_block_flag; |
scalefac_compress = grdat->scalefac_compress; |
slen0 = slen_table[scalefac_compress][0]; |
slen1 = slen_table[scalefac_compress][1]; |
if (block_type == 2) { |
if (mixed_block_flag) { /* mixed */ |
for (sfb = 0; sfb < 8; sfb++) |
sf[0].l[sfb] = bitget(slen0); |
for (sfb = 3; sfb < 6; sfb++) { |
sf[0].s[0][sfb] = bitget(slen0); |
sf[0].s[1][sfb] = bitget(slen0); |
sf[0].s[2][sfb] = bitget(slen0); |
} |
for (sfb = 6; sfb < 12; sfb++) { |
sf[0].s[0][sfb] = bitget(slen1); |
sf[0].s[1][sfb] = bitget(slen1); |
sf[0].s[2][sfb] = bitget(slen1); |
} |
return; |
} |
for (sfb = 0; sfb < 6; sfb++) { |
sf[0].s[0][sfb] = bitget(slen0); |
sf[0].s[1][sfb] = bitget(slen0); |
sf[0].s[2][sfb] = bitget(slen0); |
} |
for (; sfb < 12; sfb++) { |
sf[0].s[0][sfb] = bitget(slen1); |
sf[0].s[1][sfb] = bitget(slen1); |
sf[0].s[2][sfb] = bitget(slen1); |
} |
return; |
} |
/* long blocks types 0 1 3, first granule */ |
if (gr == 0) |
{ |
for (sfb = 0; sfb < 11; sfb++) |
sf[0].l[sfb] = bitget(slen0); |
for (; sfb < 21; sfb++) |
sf[0].l[sfb] = bitget(slen1); |
return; |
} |
/* long blocks 0, 1, 3, second granule */ |
sfb = 0; |
if (scfsi & 8) |
for (; sfb < 6; sfb++) |
sf[0].l[sfb] = sf[-2].l[sfb]; |
else |
for (; sfb < 6; sfb++) |
sf[0].l[sfb] = bitget(slen0); |
if (scfsi & 4) |
for (; sfb < 11; sfb++) |
sf[0].l[sfb] = sf[-2].l[sfb]; |
else |
for (; sfb < 11; sfb++) |
sf[0].l[sfb] = bitget(slen0); |
if (scfsi & 2) |
for (; sfb < 16; sfb++) |
sf[0].l[sfb] = sf[-2].l[sfb]; |
else |
for (; sfb < 16; sfb++) |
sf[0].l[sfb] = bitget(slen1); |
if (scfsi & 1) |
for (; sfb < 21; sfb++) |
sf[0].l[sfb] = sf[-2].l[sfb]; |
else |
for (; sfb < 21; sfb++) |
sf[0].l[sfb] = bitget(slen1); |
} |
void L3get_scale_factor2(int gr, int ch) |
{ |
SCALE_FACTOR* sf = &m_scale_fac[gr][ch]; |
GR_INFO* grdat = &m_side_info.gr[gr][ch]; |
int is_and_ch = m_is_mode & ch; |
int sfb; |
int slen1, slen2, slen3, slen4; |
int nr1, nr2, nr3, nr4; |
int i, k; |
int preflag, intensity_scale; |
int block_type, mixed_block_flag, scalefac_compress; |
block_type = grdat->block_type; |
mixed_block_flag = grdat->mixed_block_flag; |
scalefac_compress = grdat->scalefac_compress; |
preflag = 0; |
intensity_scale = 0; /* to avoid compiler warning */ |
if (is_and_ch == 0) |
{ |
if (scalefac_compress < 400) |
{ |
slen2 = scalefac_compress >> 4; |
slen1 = slen2 / 5; |
slen2 = slen2 % 5; |
slen4 = scalefac_compress & 15; |
slen3 = slen4 >> 2; |
slen4 = slen4 & 3; |
k = 0; |
} |
else if (scalefac_compress < 500) |
{ |
scalefac_compress -= 400; |
slen2 = scalefac_compress >> 2; |
slen1 = slen2 / 5; |
slen2 = slen2 % 5; |
slen3 = scalefac_compress & 3; |
slen4 = 0; |
k = 1; |
} |
else |
{ |
scalefac_compress -= 500; |
slen1 = scalefac_compress / 3; |
slen2 = scalefac_compress % 3; |
slen3 = slen4 = 0; |
if (mixed_block_flag) |
{ |
slen3 = slen2; /* adjust for long/short mix logic */ |
slen2 = slen1; |
} |
preflag = 1; |
k = 2; |
} |
} |
else |
{ /* intensity stereo ch = 1 (right) */ |
intensity_scale = scalefac_compress & 1; |
scalefac_compress >>= 1; |
if (scalefac_compress < 180) |
{ |
slen1 = scalefac_compress / 36; |
slen2 = scalefac_compress % 36; |
slen3 = slen2 % 6; |
slen2 = slen2 / 6; |
slen4 = 0; |
k = 3 + 0; |
} |
else if (scalefac_compress < 244) |
{ |
scalefac_compress -= 180; |
slen3 = scalefac_compress & 3; |
scalefac_compress >>= 2; |
slen2 = scalefac_compress & 3; |
slen1 = scalefac_compress >> 2; |
slen4 = 0; |
k = 3 + 1; |
} |
else |
{ |
scalefac_compress -= 244; |
slen1 = scalefac_compress / 3; |
slen2 = scalefac_compress % 3; |
slen3 = slen4 = 0; |
k = 3 + 2; |
} |
} |
i = 0; |
if (block_type == 2) |
i = (mixed_block_flag & 1) + 1; |
nr1 = nr_table[k][i][0]; |
nr2 = nr_table[k][i][1]; |
nr3 = nr_table[k][i][2]; |
nr4 = nr_table[k][i][3]; |
/* return is scale factor info (for right chan is mode) */ |
if (is_and_ch) |
{ |
m_is_sf_info.nr[0] = nr1; |
m_is_sf_info.nr[1] = nr2; |
m_is_sf_info.nr[2] = nr3; |
m_is_sf_info.slen[0] = slen1; |
m_is_sf_info.slen[1] = slen2; |
m_is_sf_info.slen[2] = slen3; |
m_is_sf_info.intensity_scale = intensity_scale; |
} |
grdat->preflag = preflag; /* return preflag */ |
/*--------------------------------------*/ |
if (block_type == 2) |
{ |
if (mixed_block_flag) |
{ /* mixed */ |
if (slen1 != 0) /* long block portion */ |
for (sfb = 0; sfb < 6; sfb++) |
sf[0].l[sfb] = bitget(slen1); |
else |
for (sfb = 0; sfb < 6; sfb++) |
sf[0].l[sfb] = 0; |
sfb = 3; /* start sfb for short */ |
} |
else |
{ /* all short, initial short blocks */ |
sfb = 0; |
if (slen1 != 0) |
for (i = 0; i < nr1; i++, sfb++) |
{ |
sf[0].s[0][sfb] = bitget(slen1); |
sf[0].s[1][sfb] = bitget(slen1); |
sf[0].s[2][sfb] = bitget(slen1); |
} |
else |
for (i = 0; i < nr1; i++, sfb++) |
{ |
sf[0].s[0][sfb] = 0; |
sf[0].s[1][sfb] = 0; |
sf[0].s[2][sfb] = 0; |
} |
} |
/* remaining short blocks */ |
if (slen2 != 0) |
for (i = 0; i < nr2; i++, sfb++) |
{ |
sf[0].s[0][sfb] = bitget(slen2); |
sf[0].s[1][sfb] = bitget(slen2); |
sf[0].s[2][sfb] = bitget(slen2); |
} |
else |
for (i = 0; i < nr2; i++, sfb++) |
{ |
sf[0].s[0][sfb] = 0; |
sf[0].s[1][sfb] = 0; |
sf[0].s[2][sfb] = 0; |
} |
if (slen3 != 0) |
for (i = 0; i < nr3; i++, sfb++) |
{ |
sf[0].s[0][sfb] = bitget(slen3); |
sf[0].s[1][sfb] = bitget(slen3); |
sf[0].s[2][sfb] = bitget(slen3); |
} |
else |
for (i = 0; i < nr3; i++, sfb++) |
{ |
sf[0].s[0][sfb] = 0; |
sf[0].s[1][sfb] = 0; |
sf[0].s[2][sfb] = 0; |
} |
if (slen4 != 0) |
for (i = 0; i < nr4; i++, sfb++) |
{ |
sf[0].s[0][sfb] = bitget(slen4); |
sf[0].s[1][sfb] = bitget(slen4); |
sf[0].s[2][sfb] = bitget(slen4); |
} |
else |
for (i = 0; i < nr4; i++, sfb++) |
{ |
sf[0].s[0][sfb] = 0; |
sf[0].s[1][sfb] = 0; |
sf[0].s[2][sfb] = 0; |
} |
return; |
} |
/* long blocks types 0 1 3 */ |
sfb = 0; |
if (slen1 != 0) |
for (i = 0; i < nr1; i++, sfb++) |
sf[0].l[sfb] = bitget(slen1); |
else |
for (i = 0; i < nr1; i++, sfb++) |
sf[0].l[sfb] = 0; |
if (slen2 != 0) |
for (i = 0; i < nr2; i++, sfb++) |
sf[0].l[sfb] = bitget(slen2); |
else |
for (i = 0; i < nr2; i++, sfb++) |
sf[0].l[sfb] = 0; |
if (slen3 != 0) |
for (i = 0; i < nr3; i++, sfb++) |
sf[0].l[sfb] = bitget(slen3); |
else |
for (i = 0; i < nr3; i++, sfb++) |
sf[0].l[sfb] = 0; |
if (slen4 != 0) |
for (i = 0; i < nr4; i++, sfb++) |
sf[0].l[sfb] = bitget(slen4); |
else |
for (i = 0; i < nr4; i++, sfb++) |
sf[0].l[sfb] = 0; |
} |
/programs/media/ac97snd/trunk/mp3dec/l3side.c |
---|
0,0 → 1,127 |
#include "layer3.h" |
extern int m_channels; |
extern int m_ms_mode, m_is_mode; |
extern SIDE_INFO m_side_info; |
int L3get_side_info1() |
{ |
int gr, ch, size; |
m_side_info.main_data_begin = bitget(9); |
if (m_channels == 1) { |
m_side_info.private_bits = bitget(5); |
size = 17; |
} |
else { |
m_side_info.private_bits = bitget(3); |
size = 32; |
} |
for (ch = 0; ch < m_channels; ch ++) |
m_side_info.scfsi[ch] = bitget(4); |
for (gr = 0; gr < 2; gr ++) { |
for (ch = 0; ch < m_channels; ch ++) { |
GR_INFO* gr_info = &m_side_info.gr[gr][ch]; |
gr_info->part2_3_length = bitget(12); |
gr_info->big_values = bitget(9); |
gr_info->global_gain = bitget(8); |
//gr_info->global_gain += gain_adjust; |
if (m_ms_mode) gr_info->global_gain -= 2; |
gr_info->scalefac_compress = bitget(4); |
gr_info->window_switching_flag = bitget(1); |
if (gr_info->window_switching_flag) { |
gr_info->block_type = bitget(2); |
gr_info->mixed_block_flag = bitget(1); |
gr_info->table_select[0] = bitget(5); |
gr_info->table_select[1] = bitget(5); |
gr_info->subblock_gain[0] = bitget(3); |
gr_info->subblock_gain[1] = bitget(3); |
gr_info->subblock_gain[2] = bitget(3); |
/* region count set in terms of long block cb's/bands */ |
/* r1 set so r0+r1+1 = 21 (lookup produces 576 bands ) */ |
/* if(window_switching_flag) always 36 samples in region0 */ |
gr_info->region0_count = (8 - 1); /* 36 samples */ |
gr_info->region1_count = 20 - (8 - 1); |
} |
else { |
gr_info->mixed_block_flag = 0; |
gr_info->block_type = 0; |
gr_info->table_select[0] = bitget(5); |
gr_info->table_select[1] = bitget(5); |
gr_info->table_select[2] = bitget(5); |
gr_info->region0_count = bitget(4); |
gr_info->region1_count = bitget(3); |
} |
gr_info->preflag = bitget(1); |
gr_info->scalefac_scale = bitget(1); |
gr_info->count1table_select = bitget(1); |
} |
} |
return size; |
} |
int L3get_side_info2(int gr) |
{ |
int ch, size; |
m_side_info.main_data_begin = bitget(8); |
if (m_channels == 1) { |
m_side_info.private_bits = bitget(1); |
size = 9; |
} |
else { |
m_side_info.private_bits = bitget(2); |
size = 17; |
} |
m_side_info.scfsi[0] = 0; |
m_side_info.scfsi[1] = 0; |
for (ch = 0; ch < m_channels; ch ++) { |
m_side_info.gr[gr][ch].part2_3_length = bitget(12); |
m_side_info.gr[gr][ch].big_values = bitget(9); |
m_side_info.gr[gr][ch].global_gain = bitget(8);// + gain_adjust; |
if (m_ms_mode) m_side_info.gr[gr][ch].global_gain -= 2; |
m_side_info.gr[gr][ch].scalefac_compress = bitget(9); |
m_side_info.gr[gr][ch].window_switching_flag = bitget(1); |
if (m_side_info.gr[gr][ch].window_switching_flag) { |
m_side_info.gr[gr][ch].block_type = bitget(2); |
m_side_info.gr[gr][ch].mixed_block_flag = bitget(1); |
m_side_info.gr[gr][ch].table_select[0] = bitget(5); |
m_side_info.gr[gr][ch].table_select[1] = bitget(5); |
m_side_info.gr[gr][ch].subblock_gain[0] = bitget(3); |
m_side_info.gr[gr][ch].subblock_gain[1] = bitget(3); |
m_side_info.gr[gr][ch].subblock_gain[2] = bitget(3); |
/* region count set in terms of long block cb's/bands */ |
/* r1 set so r0+r1+1 = 21 (lookup produces 576 bands ) */ |
/* bt=1 or 3 54 samples */ |
/* bt=2 mixed=0 36 samples */ |
/* bt=2 mixed=1 54 (8 long sf) samples? or maybe 36 */ |
/* region0 discussion says 54 but this would mix long */ |
/* and short in region0 if scale factors switch */ |
/* at band 36 (6 long scale factors) */ |
if ((m_side_info.gr[gr][ch].block_type == 2)) { |
m_side_info.gr[gr][ch].region0_count = (6 - 1); /* 36 samples */ |
m_side_info.gr[gr][ch].region1_count = 20 - (6 - 1); |
} |
else {/* long block type 1 or 3 */ |
m_side_info.gr[gr][ch].region0_count = (8 - 1); /* 54 samples */ |
m_side_info.gr[gr][ch].region1_count = 20 - (8 - 1); |
} |
} |
else { |
m_side_info.gr[gr][ch].mixed_block_flag = 0; |
m_side_info.gr[gr][ch].block_type = 0; |
m_side_info.gr[gr][ch].table_select[0] = bitget(5); |
m_side_info.gr[gr][ch].table_select[1] = bitget(5); |
m_side_info.gr[gr][ch].table_select[2] = bitget(5); |
m_side_info.gr[gr][ch].region0_count = bitget(4); |
m_side_info.gr[gr][ch].region1_count = bitget(3); |
} |
m_side_info.gr[gr][ch].preflag = 0; |
m_side_info.gr[gr][ch].scalefac_scale = bitget(1); |
m_side_info.gr[gr][ch].count1table_select = bitget(1); |
} |
return size; |
} |
/programs/media/ac97snd/trunk/mp3dec/layer3.h |
---|
0,0 → 1,52 |
#include "bstream.h" |
#include "mp3dec.h" |
typedef struct { |
uint part2_3_length; |
uint big_values; |
uint global_gain; |
uint scalefac_compress; |
uint window_switching_flag; |
uint block_type; |
uint mixed_block_flag; |
uint table_select[3]; |
uint subblock_gain[3]; |
uint region0_count; |
uint region1_count; |
uint preflag; |
uint scalefac_scale; |
uint count1table_select; |
} GR_INFO; |
typedef struct { |
uint main_data_begin; |
uint private_bits; |
uint scfsi[2]; /* 4 bit flags [ch] */ |
GR_INFO gr[2][2]; /* [gr][ch] */ |
} SIDE_INFO; |
typedef struct { |
int l[23]; /* [cb] */ |
int s[3][13]; /* [window][cb] */ |
} SCALE_FACTOR; |
typedef struct { |
int cbtype; /* long=0 short=1 */ |
int cbmax; /* max crit band */ |
int lb_type; /* long block type 0 1 3 */ |
int cbs0; /* short band start index 0 3 12 (12=no shorts */ |
int ncbl; /* number long cb's 0 8 21 */ |
int cbmax_s[3]; /* cbmax by individual short blocks */ |
} CB_INFO; |
typedef struct { |
int nr[3]; |
int slen[3]; |
int intensity_scale; |
} IS_SF_INFO; |
typedef union { |
int s; |
float x; |
} SAMPLE; |
/programs/media/ac97snd/trunk/mp3dec/math_private.h |
---|
0,0 → 1,209 |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* from: @(#)fdlibm.h 5.1 93/09/24 |
* $Id: math_private.h,v 1.8 1998/11/27 11:33:46 drepper Exp $ |
*/ |
#ifndef _MATH_PRIVATE_H_ |
#define _MATH_PRIVATE_H_ |
/* The original fdlibm code used statements like: |
n0 = ((*(int*)&one)>>29)^1; * index of high word * |
ix0 = *(n0+(int*)&x); * high word of x * |
ix1 = *((1-n0)+(int*)&x); * low word of x * |
to dig two 32 bit words out of the 64 bit IEEE floating point |
value. That is non-ANSI, and, moreover, the gcc instruction |
scheduler gets it wrong. We instead use the following macros. |
Unlike the original code, we determine the endianness at compile |
time, not at run time; I don't see much benefit to selecting |
endianness at run time. */ |
/* A union which permits us to convert between a double and two 32 bit |
ints. */ |
typedef int int32_t; |
typedef unsigned int u_int32_t; |
typedef union |
{ |
double value; |
struct |
{ |
u_int32_t lsw; |
u_int32_t msw; |
} parts; |
} ieee_double_shape_type; |
/* Get two 32 bit ints from a double. */ |
#define EXTRACT_WORDS(ix0,ix1,d) \ |
do { \ |
ieee_double_shape_type ew_u; \ |
ew_u.value = (d); \ |
(ix0) = ew_u.parts.msw; \ |
(ix1) = ew_u.parts.lsw; \ |
} while (0) |
/* Get the more significant 32 bit int from a double. */ |
#define GET_HIGH_WORD(i,d) \ |
do { \ |
ieee_double_shape_type gh_u; \ |
gh_u.value = (d); \ |
(i) = gh_u.parts.msw; \ |
} while (0) |
/* Get the less significant 32 bit int from a double. */ |
#define GET_LOW_WORD(i,d) \ |
do { \ |
ieee_double_shape_type gl_u; \ |
gl_u.value = (d); \ |
(i) = gl_u.parts.lsw; \ |
} while (0) |
/* Set a double from two 32 bit ints. */ |
#define INSERT_WORDS(d,ix0,ix1) \ |
do { \ |
ieee_double_shape_type iw_u; \ |
iw_u.parts.msw = (ix0); \ |
iw_u.parts.lsw = (ix1); \ |
(d) = iw_u.value; \ |
} while (0) |
/* Set the more significant 32 bits of a double from an int. */ |
#define SET_HIGH_WORD(d,v) \ |
do { \ |
ieee_double_shape_type sh_u; \ |
sh_u.value = (d); \ |
sh_u.parts.msw = (v); \ |
(d) = sh_u.value; \ |
} while (0) |
/* Set the less significant 32 bits of a double from an int. */ |
#define SET_LOW_WORD(d,v) \ |
do { \ |
ieee_double_shape_type sl_u; \ |
sl_u.value = (d); \ |
sl_u.parts.lsw = (v); \ |
(d) = sl_u.value; \ |
} while (0) |
/* A union which permits us to convert between a float and a 32 bit |
int. */ |
typedef union |
{ |
float value; |
u_int32_t word; |
} ieee_float_shape_type; |
/* Get a 32 bit int from a float. */ |
#define GET_FLOAT_WORD(i,d) \ |
do { \ |
ieee_float_shape_type gf_u; \ |
gf_u.value = (d); \ |
(i) = gf_u.word; \ |
} while (0) |
/* Set a float from a 32 bit int. */ |
#define SET_FLOAT_WORD(d,i) \ |
do { \ |
ieee_float_shape_type sf_u; \ |
sf_u.word = (i); \ |
(d) = sf_u.value; \ |
} while (0) |
/* A union which permits us to convert between a long double and |
three 32 bit ints. */ |
typedef union |
{ |
long double value; |
struct |
{ |
u_int32_t lsw; |
u_int32_t msw; |
unsigned int sign_exponent:16; |
unsigned int empty:16; |
} parts; |
} ieee_long_double_shape_type; |
/* Get three 32 bit ints from a double. */ |
#define GET_LDOUBLE_WORDS(exp,ix0,ix1,d) \ |
do { \ |
ieee_long_double_shape_type ew_u; \ |
ew_u.value = (d); \ |
(exp) = ew_u.parts.sign_exponent; \ |
(ix0) = ew_u.parts.msw; \ |
(ix1) = ew_u.parts.lsw; \ |
} while (0) |
/* Set a double from two 32 bit ints. */ |
#define SET_LDOUBLE_WORDS(d,exp,ix0,ix1) \ |
do { \ |
ieee_long_double_shape_type iw_u; \ |
iw_u.parts.sign_exponent = (exp); \ |
iw_u.parts.msw = (ix0); \ |
iw_u.parts.lsw = (ix1); \ |
(d) = iw_u.value; \ |
} while (0) |
/* Get the more significant 32 bits of a long double mantissa. */ |
#define GET_LDOUBLE_MSW(v,d) \ |
do { \ |
ieee_long_double_shape_type sh_u; \ |
sh_u.value = (d); \ |
(v) = sh_u.parts.msw; \ |
} while (0) |
/* Set the more significant 32 bits of a long double mantissa from an int. */ |
#define SET_LDOUBLE_MSW(d,v) \ |
do { \ |
ieee_long_double_shape_type sh_u; \ |
sh_u.value = (d); \ |
sh_u.parts.msw = (v); \ |
(d) = sh_u.value; \ |
} while (0) |
/* Get int from the exponent of a long double. */ |
#define GET_LDOUBLE_EXP(exp,d) \ |
do { \ |
ieee_long_double_shape_type ge_u; \ |
ge_u.value = (d); \ |
(exp) = ge_u.parts.sign_exponent; \ |
} while (0) |
/* Set exponent of a long double from an int. */ |
#define SET_LDOUBLE_EXP(d,exp) \ |
do { \ |
ieee_long_double_shape_type se_u; \ |
se_u.value = (d); \ |
se_u.parts.sign_exponent = (exp); \ |
(d) = se_u.value; \ |
} while (0) |
#endif /* _MATH_PRIVATE_H_ */ |
/programs/media/ac97snd/trunk/mp3dec/mp3dec.c |
---|
0,0 → 1,513 |
#include "mp3dec.h" |
#include <string.h> |
#include <math.h> |
typedef unsigned char byte; |
typedef unsigned int uint; |
typedef unsigned short ushort; |
static const int br_tbl[3][3][16] = { |
{// MPEG-1 |
// Layer1 |
{ 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0 }, |
// Layer2 |
{ 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 0 }, |
// Layer3 |
{ 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0 }, |
}, |
{// MPEG-2 |
// Layer1 |
{ 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0 }, |
// Layer2 |
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, |
// Layer3 |
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, |
}, |
{// MPEG-2.5 |
// Layer1 (not available) |
{ 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0 }, |
// Layer2 (not available) |
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, |
// Layer3 |
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, |
}, |
}; |
static const int fr_tbl[3][4] = { |
// MPEG-1 |
{ 44100, 48000, 32000, 0/*reserved*/ }, |
// MPEG-2 |
{ 22050, 24000, 16000, 0/*reserved*/ }, |
// MPEG-2.5 |
{ 11025, 12000, 8000, 0/*reserved*/ }, |
}; |
/* 1999/11/01í |
static const double ms_p_f_table[3][3] = |
{ |
// Layer1 |
{8.707483f, 8.0f, 12.0f}, |
// Layer2 |
{26.12245f, 24.0f, 36.0f}, |
// Layer3 |
{26.12245f, 24.0f, 36.0f}, |
}; |
*/ |
typedef void (*FRAME_PROC) (MPEG_HEADER* h, byte* mpeg, byte* pcm); |
MPEG_DECODE_OPTION m_option; |
FRAME_PROC m_frame_proc; |
int m_last_error; |
int m_frequency; |
int m_frame_size, m_pcm_size; |
int m_enableEQ; |
float m_equalizer[32]; |
//float m_band_tbl[2][32]; |
void L1table_init(); |
void L2table_init(); |
void L3table_init(); |
void L1decode_start(MPEG_HEADER* h); |
void L2decode_start(MPEG_HEADER* h); |
void L3decode_start(MPEG_HEADER* h); |
void L1decode_frame(MPEG_HEADER* h, byte* mpeg, byte* pcm); |
void L2decode_frame(MPEG_HEADER* h, byte* mpeg, byte* pcm); |
void L3decode_frame(MPEG_HEADER* h, byte* mpeg, byte* pcm); |
void _stdcall debug_out_hex(unsigned int val); |
void debug_out_str(char* str); |
void mp3DecodeInit() |
{ |
// _set_SSE2_enable(0); |
m_option.reduction = 0; |
m_option.convert = 0; |
m_option.freqLimit = 24000; |
L1table_init(); |
L2table_init(); |
L3table_init(); |
} |
int mp3GetHeader(byte* buf, MPEG_HEADER* h) |
{ |
h->version = (buf[1] & 0x08) >> 3; |
h->layer = (buf[1] & 0x06) >> 1; |
h->error_prot = (buf[1] & 0x01); |
h->br_index = (buf[2] & 0xf0) >> 4; |
h->fr_index = (buf[2] & 0x0c) >> 2; |
h->padding = (buf[2] & 0x02) >> 1; |
h->extension = (buf[2] & 0x01); |
h->mode = (buf[3] & 0xc0) >> 6; |
h->mode_ext = (buf[3] & 0x30) >> 4; |
h->copyright = (buf[3] & 0x08) >> 3; |
h->original = (buf[3] & 0x04) >> 2; |
h->emphasis = (buf[3] & 0x03); |
if (buf[0] != 0xFF) {//sync error |
m_last_error = MP3_ERROR_INVALID_SYNC; |
return 0; |
} |
if ((buf[1] & 0xF0) == 0xF0) //MPEG-1, MPEG-2 |
h->version = (h->version) ? 1 : 2; |
else if ((buf[1] & 0xF0) == 0xE0) //MPEG-2.5 |
h->version = 3; |
else { |
m_last_error = MP3_ERROR_INVALID_SYNC; |
return 0; |
} |
if (h->fr_index >= 3 || |
h->br_index == 0 || h->br_index >= 15 || |
h->layer == 0 || h->layer >= 4) { |
m_last_error = MP3_ERROR_INVALID_HEADER; |
return 0; |
} |
h->layer = 4 - h->layer; |
h->error_prot = (h->error_prot) ? 0 : 1; |
return 1; |
} |
int mp3GetLastError() |
{ |
return m_last_error; |
} |
int mp3FindSync(byte* buf, int size, int* sync) |
{ |
int i; |
*sync = 0; |
size -= 3; |
if (size <= 0) { |
m_last_error = MP3_ERROR_OUT_OF_BUFFER; |
return 0; |
} |
for (i = 0; i < size; i ++) { |
if (buf[i] == 0xFF) { |
if ((buf[i + 1] & 0xF0) == 0xF0) { |
break; |
} |
else if ((buf[i + 1] & 0xF0) == 0xE0) { |
break; |
} |
} |
} |
if (i == size) { |
m_last_error = MP3_ERROR_OUT_OF_BUFFER; |
return 0; |
} |
*sync = i; |
return 1; |
} |
void mp3GetDecodeOption(MPEG_DECODE_OPTION* option) |
{ |
*option = m_option; |
} |
int mp3SetDecodeOption(MPEG_DECODE_OPTION* option) |
{ |
m_option = *option; |
return 1; |
} |
int mp3SetEqualizer(int* value) |
{ |
int i; |
if (value == (void*)0) { |
m_enableEQ = 0; |
return 1; |
} |
m_enableEQ = 1; |
//60, 170, 310, 600, 1K, 3K |
for (i = 0; i < 6; i ++) { |
m_equalizer[i] = (float)pow_test(10,(double)value[i]/200); |
} |
//6K |
m_equalizer[6] = (float)pow_test(10,(double)value[6]/200); |
m_equalizer[7] = m_equalizer[6]; |
//12K |
m_equalizer[8] = (float)pow_test(10,(double)value[7]/200); |
m_equalizer[9] = m_equalizer[8]; |
m_equalizer[10] = m_equalizer[8]; |
m_equalizer[11] = m_equalizer[8]; |
//14K |
m_equalizer[12] = (float)pow_test(10,(double)value[8]/200); |
m_equalizer[13] = m_equalizer[12]; |
m_equalizer[14] = m_equalizer[12]; |
m_equalizer[15] = m_equalizer[12]; |
m_equalizer[16] = m_equalizer[12]; |
m_equalizer[17] = m_equalizer[12]; |
m_equalizer[18] = m_equalizer[12]; |
m_equalizer[19] = m_equalizer[12]; |
//16K |
m_equalizer[20] = (float)pow_test(10,(double)value[9]/200); |
m_equalizer[21] = m_equalizer[20]; |
m_equalizer[22] = m_equalizer[20]; |
m_equalizer[23] = m_equalizer[20]; |
m_equalizer[24] = m_equalizer[20]; |
m_equalizer[25] = m_equalizer[20]; |
m_equalizer[26] = m_equalizer[20]; |
m_equalizer[27] = m_equalizer[20]; |
m_equalizer[28] = m_equalizer[20]; |
m_equalizer[29] = m_equalizer[20]; |
m_equalizer[30] = m_equalizer[20]; |
m_equalizer[31] = m_equalizer[20]; |
return 1; |
} |
#define VBR_FRAMES_FLAG 0x0001 |
#define VBR_BYTES_FLAG 0x0002 |
#define VBR_TOC_FLAG 0x0004 |
#define VBR_SCALE_FLAG 0x0008 |
static int extractInt4(byte* buf) |
{// big endian extract |
return buf[3] | (buf[2] << 8) | |
(buf[1] << 16) | (buf[0] << 24); |
} |
int mp3GetDecodeInfo(byte* mpeg, int size, MPEG_DECODE_INFO* info, int decFlag) |
{ |
MPEG_HEADER* h = &info->header; |
byte* p = mpeg; |
int vbr; |
uint minBitRate, maxBitRate; |
uint i, j, flags; |
//int bitRate; |
//int frame_size; |
if (size < 156) {//max vbr header size |
m_last_error = MP3_ERROR_OUT_OF_BUFFER; |
return 0; |
} |
if (!mp3GetHeader(p, h)) { |
return 0; |
} |
//check VBR Header |
p += 4;//skip mpeg header |
if (h->error_prot) p += 2;//skip crc |
if (h->layer == 3) {//skip side info |
if (h->version == 1) {//MPEG-1 |
if (h->mode != 3) p += 32; |
else p += 17; |
} |
else {//MPEG-2, MPEG-2.5 |
if (h->mode != 3) p += 17; |
else p += 9; |
} |
} |
info->bitRate = br_tbl[h->version-1][h->layer-1][h->br_index] * 1000; |
info->frequency = fr_tbl[h->version-1][h->fr_index]; |
if (memcmp(p, "Xing", 4) == 0) {//VBR |
p += 4; |
flags = extractInt4(p); |
p += 4; |
if (!(flags & (VBR_FRAMES_FLAG | VBR_BYTES_FLAG))) { |
m_last_error = MP3_ERROR_INVALID_HEADER; |
return 0; |
} |
info->frames = extractInt4(p); |
p += 4; |
info->dataSize = extractInt4(p); |
p += 4; |
if (flags & VBR_TOC_FLAG) p += 100; |
if (flags & VBR_SCALE_FLAG) p += 4; |
/*///////////////////////////////// |
//WVBRÎ |
if ( p[0] == mpeg[0] && p[1] == mpeg[1] ) { |
info->skipSize = (int)(p - mpeg); |
} else { |
info->bitRate = br_tbl[h->version-1][h->layer-1][h->br_index] * 1000; |
switch (h->layer) { |
case 1://layer1 |
m_frame_size = (12 * info->bitRate / fr_tbl[h->version-1][h->fr_index]) * 4;//one slot is 4 bytes long |
if (h->padding) m_frame_size += 4; |
break; |
case 2://layer2 |
m_frame_size = 144 * info->bitRate / fr_tbl[h->version-1][h->fr_index]; |
if (h->padding) m_frame_size ++; |
break; |
case 3://layer3 |
m_frame_size = 144 * info->bitRate / fr_tbl[h->version-1][h->fr_index]; |
if (h->version != 1) //MPEG-2, MPEG-2.5 |
m_frame_size /= 2; |
if (h->padding) m_frame_size; |
break; |
} |
info->skipSize = (int)(m_frame_size); |
} |
info->bitRate = 0; |
/////////////////////////////////*/ |
vbr = 1; |
minBitRate = 0xffffffff; |
maxBitRate = 0; |
for (i = 1; i < 15; i ++) { |
j = br_tbl[h->version-1][h->layer-1][i] * 1000; |
if (j < minBitRate) minBitRate = j; |
if (j > maxBitRate) maxBitRate = j; |
} |
} |
else if (memcmp(p, "VBRI", 4) == 0) {//VBRI |
p += 10; |
info->dataSize = extractInt4(p); |
p += 4; |
info->frames = extractInt4(p); |
p += 4; |
vbr = 1; |
minBitRate = 0xffffffff; |
maxBitRate = 0; |
for (i = 1; i < 15; i ++) { |
j = br_tbl[h->version-1][h->layer-1][i] * 1000; |
if (j < minBitRate) minBitRate = j; |
if (j > maxBitRate) maxBitRate = j; |
} |
} |
else {//not VBR |
vbr = 0; |
info->frames = 0; |
//info->skipSize = 0; |
info->dataSize = 0; |
//info->bitRate = br_tbl[h->version-1][h->layer-1][h->br_index] * 1000; |
} |
// info->frequency = fr_tbl[h->version-1][h->fr_index]; |
// info->msPerFrame = ms_p_f_table[h->layer-1][h->fr_index]; |
// if (h->version == 3) info->msPerFrame *= 2; |
switch (h->layer) { |
case 1://layer1 |
info->outputSize = 384 >> m_option.reduction; |
//if (info->bitRate) { |
if (!vbr) { |
info->skipSize = 0; |
info->minInputSize = (12 * info->bitRate / info->frequency) * 4;//one slot is 4 bytes long |
info->maxInputSize = info->minInputSize + 4; |
} |
else { |
info->skipSize = (12 * info->bitRate / info->frequency + h->padding) * 4; |
info->minInputSize = (12 * minBitRate / info->frequency) * 4; |
info->maxInputSize = (12 * maxBitRate / info->frequency) * 4 + 4; |
} |
break; |
case 2://layer2 |
info->outputSize = 1152 >> m_option.reduction; |
//if (info->bitRate) { |
if (!vbr) { |
info->skipSize = 0; |
info->minInputSize = 144 * info->bitRate / info->frequency; |
info->maxInputSize = info->minInputSize + 1; |
} |
else { |
info->skipSize = 144 * info->bitRate / info->frequency + h->padding; |
info->minInputSize = 144 * minBitRate / info->frequency; |
info->maxInputSize = 144 * maxBitRate / info->frequency + 1; |
} |
break; |
case 3://layer3 |
i = (h->version == 1) ? 1 : 2; |
//info->outputSize = 1152 >> m_option.reduction; |
info->outputSize = (1152 >> m_option.reduction) / i; |
//if (info->bitRate) { |
if (!vbr) { |
info->skipSize = 0; |
info->minInputSize = 144 * info->bitRate / info->frequency / i; |
info->maxInputSize = info->minInputSize + 1; |
} |
else { |
info->skipSize = 144 * info->bitRate / info->frequency / i + h->padding; |
info->minInputSize = 144 * minBitRate / info->frequency / i; |
info->maxInputSize = 144 * maxBitRate / info->frequency / i + 1; |
} |
break; |
/* |
if (h->version != 1) { |
//MPEG-2, MPEG-2.5 |
info->outputSize /= 2; |
info->minInputSize /= 2; |
info->maxInputSize /= 2; |
} |
info->maxInputSize ++; |
break; */ |
} |
if ((h->mode == 3) || (m_option.convert & 3)) |
info->channels = 1; |
else |
info->channels = 2; |
if (m_option.convert & 8) { |
//not available |
info->bitsPerSample = 8; |
info->outputSize *= info->channels; |
} |
else { |
info->bitsPerSample = 16; |
info->outputSize *= info->channels * 2; |
} |
if ( decFlag == 1 ) { |
m_frequency = info->frequency; |
m_pcm_size = info->outputSize; |
} |
info->frequency >>= m_option.reduction; |
if (vbr) info->bitRate = 0; |
return 1; |
} |
void sbt_init(); |
int mp3DecodeStart(byte* mpeg, int size) |
{ |
MPEG_DECODE_INFO info; |
MPEG_HEADER* h = &info.header; |
if (!mp3GetDecodeInfo(mpeg, size, &info, 1)) { |
return 0; |
} |
sbt_init(); |
switch (h->layer) { |
case 1: |
L1decode_start(h); |
m_frame_proc = L1decode_frame; |
break; |
case 2: |
L2decode_start(h); |
m_frame_proc = L2decode_frame; |
break; |
case 3: |
L3decode_start(h); |
m_frame_proc = L3decode_frame; |
break; |
} |
return 1; |
} |
int mp3DecodeFrame(MPEG_DECODE_PARAM* param) |
{ |
MPEG_HEADER* h = ¶m->header; |
if (param->inputSize <= 4) { |
m_last_error = MP3_ERROR_OUT_OF_BUFFER; |
return 0; |
} |
if (!mp3GetHeader(param->inputBuf, h)) { |
return 0; |
} |
param->bitRate = br_tbl[h->version-1][h->layer-1][h->br_index] * 1000; |
switch (h->layer) { |
case 1://layer1 |
m_frame_size = (12 * param->bitRate / m_frequency + h->padding) * 4; |
break; |
case 2://layer2 |
m_frame_size = 144 * param->bitRate / m_frequency + h->padding; |
break; |
case 3://layer3 |
if (h->version == 1) m_frame_size = 144 * param->bitRate / m_frequency + h->padding; |
else m_frame_size = (144 * param->bitRate / m_frequency) / 2 + h->padding; |
break; |
} |
if (param->inputSize < m_frame_size) { |
m_last_error = MP3_ERROR_OUT_OF_BUFFER; |
return 0; |
} |
m_frame_proc(h, param->inputBuf, param->outputBuf); |
param->inputSize = m_frame_size; |
param->outputSize = m_pcm_size; |
return 1; |
} |
void null_frame_proc(MPEG_HEADER* h, byte* mpeg, byte* pcm) {} |
void L3decode_reset(); |
void mp3MuteStart(MPEG_DECODE_PARAM* param) |
{ |
m_frame_proc = null_frame_proc; |
} |
void mp3MuteEnd(MPEG_DECODE_PARAM* param) |
{ |
MPEG_HEADER* h = ¶m->header; |
switch (h->layer) { |
case 1: |
m_frame_proc = L1decode_frame; |
break; |
case 2: |
m_frame_proc = L2decode_frame; |
break; |
case 3: |
L3decode_reset(); |
m_frame_proc = L3decode_frame; |
break; |
} |
} |
/programs/media/ac97snd/trunk/mp3dec/mp3dec.h |
---|
0,0 → 1,76 |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define MP3_ERROR_UNKNOWN 1 |
#define MP3_ERROR_INVALID_PARAMETER 2 |
#define MP3_ERROR_INVALID_SYNC 3 |
#define MP3_ERROR_INVALID_HEADER 4 |
#define MP3_ERROR_OUT_OF_BUFFER 5 |
typedef struct { |
int version; //1:MPEG-1, 2:MPEG-2, 3:MPEG-2.5 |
int layer; //1:Layer1, 2:Layer2, 3:Layer3 |
int error_prot; //1:CRC on, 0:CRC off |
int br_index; |
int fr_index; |
int padding; |
int extension; |
int mode; |
int mode_ext; |
int copyright; |
int original; |
int emphasis; |
} MPEG_HEADER; |
typedef struct { |
int reduction; |
int convert; |
int freqLimit; |
} MPEG_DECODE_OPTION; |
typedef struct { |
MPEG_HEADER header; |
int channels; //oÍ`l |
int bitsPerSample; // |
int frequency; //TvO[giHzj |
int bitRate; //rbg[gibpsj |
int frames; //t[iVBR onlyj |
int skipSize; //iVBR onlyj |
int dataSize; //f[^TCYiVBR onlyj |
int minInputSize; //1t[ÌŬüÍTCY |
int maxInputSize; //1t[ÌÅåüÍTCY |
int outputSize; //1t[ÌoÍTCY |
} MPEG_DECODE_INFO; |
typedef struct { |
MPEG_HEADER header; |
int bitRate; //rbg[gibpsj |
void* inputBuf; |
int inputSize; |
void* outputBuf; |
int outputSize; |
} MPEG_DECODE_PARAM; |
void mp3DecodeInit(); |
int mp3GetLastError(); |
int mp3SetDecodeOption(MPEG_DECODE_OPTION* option); |
void mp3GetDecodeOption(MPEG_DECODE_OPTION* option); |
int mp3SetEqualizer(int* value); |
int mp3FindSync(void* buf, int size, int* sync); |
int mp3GetDecodeInfo(void* mpeg, int size, MPEG_DECODE_INFO* info, int decFlag); |
int mp3DecodeStart(void* buf, int size); |
int mp3DecodeFrame(MPEG_DECODE_PARAM* param); |
void mp3MuteStart(MPEG_DECODE_PARAM* param); |
void mp3MuteEnd(MPEG_DECODE_PARAM* param); |
double pow_test(double, double); |
#ifdef __cplusplus |
} |
#endif |
/programs/media/ac97snd/trunk/mp3dec/mp3dec.vcproj |
---|
0,0 → 1,280 |
<?xml version="1.0" encoding="windows-1251"?> |
<VisualStudioProject |
ProjectType="Visual C++" |
Version="8,00" |
Name="mp3dec" |
ProjectGUID="{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}" |
RootNamespace="mp3dec" |
Keyword="Win32Proj" |
> |
<Platforms> |
<Platform |
Name="Win32" |
/> |
</Platforms> |
<ToolFiles> |
</ToolFiles> |
<Configurations> |
<Configuration |
Name="Debug|Win32" |
OutputDirectory="$(SolutionDir)$(ConfigurationName)" |
IntermediateDirectory="$(ConfigurationName)" |
ConfigurationType="4" |
CharacterSet="1" |
> |
<Tool |
Name="VCPreBuildEventTool" |
/> |
<Tool |
Name="VCCustomBuildTool" |
/> |
<Tool |
Name="VCXMLDataGeneratorTool" |
/> |
<Tool |
Name="VCWebServiceProxyGeneratorTool" |
/> |
<Tool |
Name="VCMIDLTool" |
/> |
<Tool |
Name="VCCLCompilerTool" |
Optimization="0" |
PreprocessorDefinitions="WIN32;_DEBUG;_LIB" |
MinimalRebuild="true" |
BasicRuntimeChecks="3" |
RuntimeLibrary="3" |
UsePrecompiledHeader="0" |
WarningLevel="3" |
Detect64BitPortabilityProblems="true" |
DebugInformationFormat="4" |
/> |
<Tool |
Name="VCManagedResourceCompilerTool" |
/> |
<Tool |
Name="VCResourceCompilerTool" |
/> |
<Tool |
Name="VCPreLinkEventTool" |
/> |
<Tool |
Name="VCLibrarianTool" |
/> |
<Tool |
Name="VCALinkTool" |
/> |
<Tool |
Name="VCXDCMakeTool" |
/> |
<Tool |
Name="VCBscMakeTool" |
/> |
<Tool |
Name="VCFxCopTool" |
/> |
<Tool |
Name="VCPostBuildEventTool" |
/> |
</Configuration> |
<Configuration |
Name="Release|Win32" |
OutputDirectory="$(SolutionDir)$(ConfigurationName)" |
IntermediateDirectory="$(ConfigurationName)" |
ConfigurationType="4" |
CharacterSet="1" |
WholeProgramOptimization="1" |
> |
<Tool |
Name="VCPreBuildEventTool" |
/> |
<Tool |
Name="VCCustomBuildTool" |
/> |
<Tool |
Name="VCXMLDataGeneratorTool" |
/> |
<Tool |
Name="VCWebServiceProxyGeneratorTool" |
/> |
<Tool |
Name="VCMIDLTool" |
/> |
<Tool |
Name="VCCLCompilerTool" |
Optimization="2" |
InlineFunctionExpansion="2" |
EnableIntrinsicFunctions="true" |
FavorSizeOrSpeed="1" |
OmitFramePointers="true" |
PreprocessorDefinitions="WIN32;NDEBUG;_LIB" |
ExceptionHandling="0" |
RuntimeLibrary="0" |
StructMemberAlignment="1" |
BufferSecurityCheck="false" |
FloatingPointModel="2" |
UsePrecompiledHeader="0" |
WarningLevel="3" |
Detect64BitPortabilityProblems="true" |
DebugInformationFormat="3" |
CompileAs="1" |
/> |
<Tool |
Name="VCManagedResourceCompilerTool" |
/> |
<Tool |
Name="VCResourceCompilerTool" |
/> |
<Tool |
Name="VCPreLinkEventTool" |
/> |
<Tool |
Name="VCLibrarianTool" |
/> |
<Tool |
Name="VCALinkTool" |
/> |
<Tool |
Name="VCXDCMakeTool" |
/> |
<Tool |
Name="VCBscMakeTool" |
/> |
<Tool |
Name="VCFxCopTool" |
/> |
<Tool |
Name="VCPostBuildEventTool" |
/> |
</Configuration> |
</Configurations> |
<References> |
</References> |
<Files> |
<Filter |
Name="Source Files" |
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" |
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" |
> |
<File |
RelativePath=".\bstream.c" |
> |
</File> |
<File |
RelativePath=".\e_pow.c" |
> |
</File> |
<File |
RelativePath=".\fdct.c" |
> |
</File> |
<File |
RelativePath=".\imdct.c" |
> |
</File> |
<File |
RelativePath=".\l1dec.c" |
> |
</File> |
<File |
RelativePath=".\l1init.c" |
> |
</File> |
<File |
RelativePath=".\l2dec.c" |
> |
</File> |
<File |
RelativePath=".\l2init.c" |
> |
</File> |
<File |
RelativePath=".\l3alias.c" |
> |
</File> |
<File |
RelativePath=".\l3dec.c" |
> |
</File> |
<File |
RelativePath=".\l3huff.c" |
> |
</File> |
<File |
RelativePath=".\l3hybrid.c" |
> |
</File> |
<File |
RelativePath=".\l3init.c" |
> |
</File> |
<File |
RelativePath=".\l3msis.c" |
> |
</File> |
<File |
RelativePath=".\l3quant.c" |
> |
</File> |
<File |
RelativePath=".\l3sf.c" |
> |
</File> |
<File |
RelativePath=".\l3side.c" |
> |
</File> |
<File |
RelativePath=".\mp3dec.c" |
> |
</File> |
<File |
RelativePath=".\pow.asm" |
> |
<FileConfiguration |
Name="Release|Win32" |
> |
<Tool |
Name="VCCustomBuildTool" |
CommandLine="e:\fasm\fasm.exe $(InputPath) $(TargetDir)\$(InputName).obj
" |
Outputs="$(OutDir)\$(InputName).obj" |
/> |
</FileConfiguration> |
</File> |
<File |
RelativePath=".\sbt.c" |
> |
</File> |
<File |
RelativePath=".\sbtb.c" |
> |
</File> |
<File |
RelativePath=".\window.c" |
> |
</File> |
<File |
RelativePath=".\windowb.c" |
> |
</File> |
</Filter> |
<Filter |
Name="Header Files" |
Filter="h;hpp;hxx;hm;inl;inc;xsd" |
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" |
> |
</Filter> |
<Filter |
Name="Resource Files" |
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" |
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" |
> |
</Filter> |
<File |
RelativePath=".\ReadMe.txt" |
> |
</File> |
</Files> |
<Globals> |
</Globals> |
</VisualStudioProject> |
/programs/media/ac97snd/trunk/mp3dec/pow.asm |
---|
0,0 → 1,355 |
; ix87 specific implementation of pow function. |
; Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. |
; This file is part of the GNU C Library. |
; Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. |
; The GNU C Library is free software; you can redistribute it and/or |
; modify 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. |
; The GNU C Library 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 the GNU C Library; see the file COPYING.LIB. If not, |
; write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
; Boston, MA 02111-1307, USA. */ |
format MS COFF |
include 'proc32.inc' |
section '.text' code readable executable |
;public _pow_test@8 |
public _scalbn |
align 4 |
proc _scalbn |
fild dword [esp+12] |
fld qword [esp+4] |
fscale |
fstp st1 |
ret |
endp |
proc _pow_test@8 stdcall x:dword, y:dword |
fld [x] |
fld [y] |
jmp __CIpow |
__CIpow: |
; fldl 12(%esp) // y |
fxam |
fnstsw ax |
mov dl,ah |
and ah, 0x45 |
cmp ah, 0x40 ; is y == 0 ? |
je .L_11 |
cmp ah, 0x05 ; is y == ±inf ? |
je .L_12 |
cmp ah, 0x01 ; is y == NaN ? |
je .L_30 |
fxch |
sub esp, 8 |
fxam |
fnstsw ax |
mov dh, ah |
and ah, 0x45 |
cmp ah, 0x40 |
je .L_20 ; x is ±0 |
cmp ah, 0x05 |
je .L_15 ; x is ±inf |
fxch ; y : x |
; First see whether `y' is a natural number. In this case we |
; can use a more precise algorithm. */ |
fld st ; y : y : x |
fistp qword [esp] ; y : x |
fild qword [esp] ; int(y) : y : x |
fucomp st1 ; y : x |
fnstsw ax |
sahf |
jne .L_2 |
; OK, we have an integer value for y. */ |
pop eax |
pop edx |
or edx,0 |
fstp st0 ; x |
jns .L_4 ; y >= 0, jump |
fidiv dword [one] ; 1/x (now referred to as x) |
neg eax |
adc edx,0 |
neg edx |
.L_4: |
fld1 ; 1 : x |
fxch |
.L_6: |
shrd edx, eax,1 |
jnc .L_5 |
fxch |
fmul st1,st0 ; x : ST*x |
fxch |
.L_5: |
fmul st0, st0 ; x*x : ST*x |
shr edx,1 |
mov ecx, eax |
or ecx, edx |
jnz .L_6 |
fstp st0 ; ST*x |
.L_30: |
ret |
align 4 |
; y is a real number. */ |
.L_2: |
fxch ; x : y |
fld1 ; 1.0 : x : y |
fld st1 ; x : 1.0 : x : y |
fsub st0,st1 ; x-1 : 1.0 : x : y |
fabs ; |x-1| : 1.0 : x : y |
fcomp qword [limit] ; 1.0 : x : y |
fnstsw ax |
fxch ; x : 1.0 : y |
sahf |
ja .L_7 |
fsub st0, st1 ; x-1 : 1.0 : y |
fyl2xp1 ; log2(x) : y |
jmp .L_8 |
.L_7: |
fyl2x ; log2(x) : y |
.L_8: |
fmul st0,st1 ; y*log2(x) : y |
fst st1 ; y*log2(x) : y*log2(x) |
frndint ; int(y*log2(x)) : y*log2(x) |
fsubr st1, st0 ; int(y*log2(x)) : fract(y*log2(x)) |
fxch ; fract(y*log2(x)) : int(y*log2(x)) |
f2xm1 ; 2^fract(y*log2(x))-1 : int(y*log2(x)) |
fld1 |
faddp ; 2^fract(y*log2(x)) : int(y*log2(x)) |
fscale ; 2^fract(y*log2(x))*2^int(y*log2(x)) : int(y*log2(x)) |
add esp,8 |
fstp st1 ; 2^fract(y*log2(x))*2^int(y*log2(x)) |
ret |
align 4 |
; // pow(x,±0) = 1 |
.L_11: |
fstp st0 ; pop y |
fld1 |
ret |
align 4 |
; y == ±inf |
.L_12: |
fstp st0 ; pop y |
; fld 4(%esp) ; x |
fabs |
fcomp qword [one] ; < 1, == 1, or > 1 |
fnstsw ax |
and ah,0x45 |
cmp ah,0x45 |
je .L_13 ; jump if x is NaN |
cmp ah,0x40 |
je .L_14 ; jump if |x| == 1 |
shl ah, 1 |
xor ah, dl |
and edx, 2 |
fld qword [inf_zero+edx+4] |
ret |
align 4 |
.L_14: |
fld qword [infinity] |
fmul qword [zero] ; raise invalid exception |
ret |
align 4 |
.L_13: |
; //fld 4(%esp) // load x == NaN |
ret |
align 4 |
; // x is ±inf |
.L_15: |
fstp st0 ; y |
test dh, 2 |
jz .L_16 ; jump if x == +inf |
; We must find out whether y is an odd integer. |
fld st ; y : y |
fistp qword [esp] ; y |
fild qword [esp] ; int(y) : y |
fucompp ; <empty> |
fnstsw ax |
sahf |
jne .L_17 |
; OK, the value is an integer, but is the number of bits small |
; enough so that all are coming from the mantissa? |
pop eax |
pop edx |
and al, 1 |
jz .L_18 ;// jump if not odd |
mov eax, edx |
or edx, eax |
jns .L_155 |
neg eax |
.L_155: |
cmp eax, 0x00200000 |
ja .L_18 ;// does not fit in mantissa bits |
; It's an odd integer. |
shr edx, 31 |
fld qword [minf_mzero+edx+8] |
ret |
align 4 |
.L_16: |
fcomp qword [zero] |
add esp, 8 |
fnstsw ax |
shr eax, 5 |
and eax, 8 |
fld qword [inf_zero+eax+1] |
ret |
align 4 |
.L_17: |
shl edx, 30 ;// sign bit for y in right position |
add esp ,8 |
.L_18: |
shr edx, 31 |
fld qword [inf_zero+edx+8] |
ret |
align 4 |
; x is ±0 |
.L_20: |
fstp st0 ; y |
test dl,2 |
jz .L_21 ; y > 0 |
;x is ±0 and y is < 0. We must find out whether y is an odd integer. |
test dh, 2 |
jz .L_25 |
fld st ; y : y |
fistp qword [esp] ; y |
fild qword [esp] ; int(y) : y |
fucompp ; <empty> |
fnstsw ax |
sahf |
jne .L_26 |
;OK, the value is an integer, but is the number of bits small |
;enough so that all are coming from the mantissa? |
pop eax |
pop edx |
and al, 1 |
jz .L_27 ; jump if not odd |
cmp edx,0xffe00000 |
jbe .L_27 ; does not fit in mantissa bits |
; It's an odd integer. |
; Raise divide-by-zero exception and get minus infinity value. |
fld1 |
fdiv qword [zero] |
fchs |
ret |
.L_25: |
fstp st0 |
.L_26: |
add esp,8 |
.L_27: |
;Raise divide-by-zero exception and get infinity value. |
fld1 |
fdiv qword [zero] |
ret |
align 4 |
; x is ±0 and y is > 0. We must find out whether y is an odd integer. |
.L_21: |
test dh,2 |
jz .L_22 |
fld st ; y : y |
fistp qword [esp] ; y |
fild qword [esp] ; int(y) : y |
fucompp ; <empty> |
fnstsw ax |
sahf |
jne .L_23 |
; OK, the value is an integer, but is the number of bits small |
; enough so that all are coming from the mantissa? |
pop eax |
pop edx |
and al,1 |
jz .L_24 ; jump if not odd |
cmp edx,0xffe00000 |
jae .L_24 ; does not fit in mantissa bits |
; It's an odd integer. |
fld qword [mzero] |
ret |
.L_22: |
fstp st0 |
.L_23: |
add esp,8 ; Don't use 2 x pop |
.L_24: |
fldz |
ret |
endp |
align 4 |
inf_zero: |
infinity: |
db 0,0,0,0,0,0,0xf0,0x7f |
zero: dq 0.0 |
minf_mzero: |
minfinity: |
db 0,0,0,0,0,0,0xf0,0xff |
mzero: |
db 0,0,0,0,0,0,0,0x80 |
one: |
dq 1.0 |
limit: |
dq 0.29 |
/programs/media/ac97snd/trunk/mp3dec/sbt.c |
---|
0,0 → 1,394 |
#include <math.h> |
/* "fdct.c" */ |
void fdct32(float *, float *); |
void fdct32_dual(float *, float *); |
void fdct32_dual_mono(float *, float *); |
void fdct16(float *, float *); |
void fdct16_dual(float *, float *); |
void fdct16_dual_mono(float *, float *); |
void fdct8(float *, float *); |
void fdct8_dual(float *, float *); |
void fdct8_dual_mono(float *, float *); |
/* "window.c" */ |
void window(float *vbuf, int vb_ptr, short *pcm); |
void window_dual(float *vbuf, int vb_ptr, short *pcm); |
void window16(float *vbuf, int vb_ptr, short *pcm); |
void window16_dual(float *vbuf, int vb_ptr, short *pcm); |
void window8(float *vbuf, int vb_ptr, short *pcm); |
void window8_dual(float *vbuf, int vb_ptr, short *pcm); |
/* circular window buffers */ |
int vb_ptr; |
int vb2_ptr; |
float vbuf[512]; |
float vbuf2[512]; |
void sbt_init() |
{ |
int i; |
/* clear window vbuf */ |
for (i = 0; i < 512; i++) |
{ |
vbuf[i] = 0.0F; |
vbuf2[i] = 0.0F; |
} |
vb2_ptr = vb_ptr = 0; |
} |
void sbt_mono(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32(sample, vbuf + vb_ptr); |
window(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbt_dual(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32_dual(sample, vbuf + vb_ptr); |
fdct32_dual(sample + 1, vbuf2 + vb_ptr); |
window_dual(vbuf, vb_ptr, pcm); |
window_dual(vbuf2, vb_ptr, pcm + 1); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 64; |
} |
} |
void sbt_dual_mono(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32_dual_mono(sample, vbuf + vb_ptr); |
window(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbt_dual_left(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32_dual(sample, vbuf + vb_ptr); |
window(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbt_dual_right(float *sample, short *pcm, int n) |
{ |
int i; |
sample++; /* point to right chan */ |
for (i = 0; i < n; i++) |
{ |
fdct32_dual(sample, vbuf + vb_ptr); |
window(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbt16_mono(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16(sample, vbuf + vb_ptr); |
window16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbt16_dual(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual(sample, vbuf + vb_ptr); |
fdct16_dual(sample + 1, vbuf2 + vb_ptr); |
window16_dual(vbuf, vb_ptr, pcm); |
window16_dual(vbuf2, vb_ptr, pcm + 1); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 32; |
} |
} |
void sbt16_dual_mono(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual_mono(sample, vbuf + vb_ptr); |
window16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbt16_dual_left(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual(sample, vbuf + vb_ptr); |
window16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbt16_dual_right(float *sample, short *pcm, int n) |
{ |
int i; |
sample++; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual(sample, vbuf + vb_ptr); |
window16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbt8_mono(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8(sample, vbuf + vb_ptr); |
window8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbt8_dual(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual(sample, vbuf + vb_ptr); |
fdct8_dual(sample + 1, vbuf2 + vb_ptr); |
window8_dual(vbuf, vb_ptr, pcm); |
window8_dual(vbuf2, vb_ptr, pcm + 1); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 16; |
} |
} |
void sbt8_dual_mono(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual_mono(sample, vbuf + vb_ptr); |
window8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbt8_dual_left(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual(sample, vbuf + vb_ptr); |
window8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbt8_dual_right(float *sample, short *pcm, int n) |
{ |
int i; |
sample++; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual(sample, vbuf + vb_ptr); |
window8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbt_mono_L3(float *sample, short *pcm, int ch) |
{ |
int i; |
ch = 0; |
for (i = 0; i < 18; i++) |
{ |
fdct32(sample, vbuf + vb_ptr); |
window(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbt_dual_L3(float *sample, short *pcm, int ch) |
{ |
int i; |
if (ch == 0) |
for (i = 0; i < 18; i++) { |
fdct32(sample, vbuf + vb_ptr); |
window_dual(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 64; |
} |
else |
for (i = 0; i < 18; i++) { |
fdct32(sample, vbuf2 + vb2_ptr); |
window_dual(vbuf2, vb2_ptr, pcm + 1); |
sample += 32; |
vb2_ptr = (vb2_ptr - 32) & 511; |
pcm += 64; |
} |
} |
void sbt16_mono_L3(float *sample, short *pcm, int ch) |
{ |
int i; |
ch = 0; |
for (i = 0; i < 18; i++) |
{ |
fdct16(sample, vbuf + vb_ptr); |
window16(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbt16_dual_L3(float *sample, short *pcm, int ch) |
{ |
int i; |
if (ch == 0) |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct16(sample, vbuf + vb_ptr); |
window16_dual(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 32; |
} |
} |
else |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct16(sample, vbuf2 + vb2_ptr); |
window16_dual(vbuf2, vb2_ptr, pcm + 1); |
sample += 32; |
vb2_ptr = (vb2_ptr - 16) & 255; |
pcm += 32; |
} |
} |
} |
void sbt8_mono_L3(float *sample, short *pcm, int ch) |
{ |
int i; |
ch = 0; |
for (i = 0; i < 18; i++) |
{ |
fdct8(sample, vbuf + vb_ptr); |
window8(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbt8_dual_L3(float *sample, short *pcm, int ch) |
{ |
int i; |
if (ch == 0) |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct8(sample, vbuf + vb_ptr); |
window8_dual(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 16; |
} |
} |
else |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct8(sample, vbuf2 + vb2_ptr); |
window8_dual(vbuf2, vb2_ptr, pcm + 1); |
sample += 32; |
vb2_ptr = (vb2_ptr - 8) & 127; |
pcm += 16; |
} |
} |
} |
/programs/media/ac97snd/trunk/mp3dec/sbtb.c |
---|
0,0 → 1,382 |
#include <math.h> |
/* "fdct.c" */ |
void fdct32(float *, float *); |
void fdct32_dual(float *, float *); |
void fdct32_dual_mono(float *, float *); |
void fdct16(float *, float *); |
void fdct16_dual(float *, float *); |
void fdct16_dual_mono(float *, float *); |
void fdct8(float *, float *); |
void fdct8_dual(float *, float *); |
void fdct8_dual_mono(float *, float *); |
/* "windowb.c" */ |
void windowB(float *vbuf, int vb_ptr, unsigned char *pcm); |
void windowB_dual(float *vbuf, int vb_ptr, unsigned char *pcm); |
void windowB16(float *vbuf, int vb_ptr, unsigned char *pcm); |
void windowB16_dual(float *vbuf, int vb_ptr, unsigned char *pcm); |
void windowB8(float *vbuf, int vb_ptr, unsigned char *pcm); |
void windowB8_dual(float *vbuf, int vb_ptr, unsigned char *pcm); |
extern int vb_ptr; |
extern int vb2_ptr; |
extern float vbuf[512]; |
extern float vbuf2[512]; |
void sbtB_mono(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32(sample, vbuf + vb_ptr); |
windowB(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbtB_dual(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32_dual(sample, vbuf + vb_ptr); |
fdct32_dual(sample + 1, vbuf2 + vb_ptr); |
windowB_dual(vbuf, vb_ptr, pcm); |
windowB_dual(vbuf2, vb_ptr, pcm + 1); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 64; |
} |
} |
void sbtB_dual_mono(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32_dual_mono(sample, vbuf + vb_ptr); |
windowB(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbtB_dual_left(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32_dual(sample, vbuf + vb_ptr); |
windowB(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbtB_dual_right(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
sample++; /* point to right chan */ |
for (i = 0; i < n; i++) |
{ |
fdct32_dual(sample, vbuf + vb_ptr); |
windowB(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbtB16_mono(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16(sample, vbuf + vb_ptr); |
windowB16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbtB16_dual(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual(sample, vbuf + vb_ptr); |
fdct16_dual(sample + 1, vbuf2 + vb_ptr); |
windowB16_dual(vbuf, vb_ptr, pcm); |
windowB16_dual(vbuf2, vb_ptr, pcm + 1); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 32; |
} |
} |
void sbtB16_dual_mono(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual_mono(sample, vbuf + vb_ptr); |
windowB16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbtB16_dual_left(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual(sample, vbuf + vb_ptr); |
windowB16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbtB16_dual_right(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
sample++; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual(sample, vbuf + vb_ptr); |
windowB16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbtB8_mono(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8(sample, vbuf + vb_ptr); |
windowB8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbtB8_dual(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual(sample, vbuf + vb_ptr); |
fdct8_dual(sample + 1, vbuf2 + vb_ptr); |
windowB8_dual(vbuf, vb_ptr, pcm); |
windowB8_dual(vbuf2, vb_ptr, pcm + 1); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 16; |
} |
} |
void sbtB8_dual_mono(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual_mono(sample, vbuf + vb_ptr); |
windowB8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbtB8_dual_left(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual(sample, vbuf + vb_ptr); |
windowB8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbtB8_dual_right(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
sample++; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual(sample, vbuf + vb_ptr); |
windowB8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbtB_mono_L3(float *sample, unsigned char *pcm, int ch) |
{ |
int i; |
ch = 0; |
for (i = 0; i < 18; i++) |
{ |
fdct32(sample, vbuf + vb_ptr); |
windowB(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbtB_dual_L3(float *sample, unsigned char *pcm, int ch) |
{ |
int i; |
if (ch == 0) |
for (i = 0; i < 18; i++) |
{ |
fdct32(sample, vbuf + vb_ptr); |
windowB_dual(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 64; |
} |
else |
for (i = 0; i < 18; i++) |
{ |
fdct32(sample, vbuf2 + vb2_ptr); |
windowB_dual(vbuf2, vb2_ptr, pcm + 1); |
sample += 32; |
vb2_ptr = (vb2_ptr - 32) & 511; |
pcm += 64; |
} |
} |
void sbtB16_mono_L3(float *sample, unsigned char *pcm, int ch) |
{ |
int i; |
ch = 0; |
for (i = 0; i < 18; i++) |
{ |
fdct16(sample, vbuf + vb_ptr); |
windowB16(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbtB16_dual_L3(float *sample, unsigned char *pcm, int ch) |
{ |
int i; |
if (ch == 0) |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct16(sample, vbuf + vb_ptr); |
windowB16_dual(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 32; |
} |
} |
else |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct16(sample, vbuf2 + vb2_ptr); |
windowB16_dual(vbuf2, vb2_ptr, pcm + 1); |
sample += 32; |
vb2_ptr = (vb2_ptr - 16) & 255; |
pcm += 32; |
} |
} |
} |
void sbtB8_mono_L3(float *sample, unsigned char *pcm, int ch) |
{ |
int i; |
ch = 0; |
for (i = 0; i < 18; i++) |
{ |
fdct8(sample, vbuf + vb_ptr); |
windowB8(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbtB8_dual_L3(float *sample, unsigned char *pcm, int ch) |
{ |
int i; |
if (ch == 0) |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct8(sample, vbuf + vb_ptr); |
windowB8_dual(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 16; |
} |
} |
else |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct8(sample, vbuf2 + vb2_ptr); |
windowB8_dual(vbuf2, vb2_ptr, pcm + 1); |
sample += 32; |
vb2_ptr = (vb2_ptr - 8) & 127; |
pcm += 16; |
} |
} |
} |
/programs/media/ac97snd/trunk/mp3dec/window.c |
---|
0,0 → 1,503 |
// disable precision loss warning on type conversion |
#ifdef _MSC_VER |
#pragma warning(disable:4244 4056) |
#endif |
float wincoef[264] = |
{ // window coefs |
0.000000000f, 0.000442505f, -0.003250122f, 0.007003784f, |
-0.031082151f, 0.078628540f, -0.100311279f, 0.572036743f, |
-1.144989014f, -0.572036743f, -0.100311279f, -0.078628540f, |
-0.031082151f, -0.007003784f, -0.003250122f, -0.000442505f, |
0.000015259f, 0.000473022f, -0.003326416f, 0.007919312f, |
-0.030517576f, 0.084182739f, -0.090927124f, 0.600219727f, |
-1.144287109f, -0.543823242f, -0.108856201f, -0.073059082f, |
-0.031478882f, -0.006118774f, -0.003173828f, -0.000396729f, |
0.000015259f, 0.000534058f, -0.003387451f, 0.008865356f, |
-0.029785154f, 0.089706421f, -0.080688477f, 0.628295898f, |
-1.142211914f, -0.515609741f, -0.116577141f, -0.067520142f, |
-0.031738281f, -0.005294800f, -0.003082275f, -0.000366211f, |
0.000015259f, 0.000579834f, -0.003433228f, 0.009841919f, |
-0.028884888f, 0.095169067f, -0.069595337f, 0.656219482f, |
-1.138763428f, -0.487472534f, -0.123474121f, -0.061996460f, |
-0.031845093f, -0.004486084f, -0.002990723f, -0.000320435f, |
0.000015259f, 0.000625610f, -0.003463745f, 0.010848999f, |
-0.027801514f, 0.100540161f, -0.057617184f, 0.683914185f, |
-1.133926392f, -0.459472656f, -0.129577637f, -0.056533810f, |
-0.031814575f, -0.003723145f, -0.002899170f, -0.000289917f, |
0.000015259f, 0.000686646f, -0.003479004f, 0.011886597f, |
-0.026535034f, 0.105819702f, -0.044784546f, 0.711318970f, |
-1.127746582f, -0.431655884f, -0.134887695f, -0.051132202f, |
-0.031661987f, -0.003005981f, -0.002792358f, -0.000259399f, |
0.000015259f, 0.000747681f, -0.003479004f, 0.012939452f, |
-0.025085449f, 0.110946655f, -0.031082151f, 0.738372803f, |
-1.120223999f, -0.404083252f, -0.139450073f, -0.045837402f, |
-0.031387329f, -0.002334595f, -0.002685547f, -0.000244141f, |
0.000030518f, 0.000808716f, -0.003463745f, 0.014022826f, |
-0.023422241f, 0.115921021f, -0.016510010f, 0.765029907f, |
-1.111373901f, -0.376800537f, -0.143264771f, -0.040634155f, |
-0.031005858f, -0.001693726f, -0.002578735f, -0.000213623f, |
0.000030518f, 0.000885010f, -0.003417969f, 0.015121460f, |
-0.021575928f, 0.120697014f, -0.001068115f, 0.791213989f, |
-1.101211548f, -0.349868774f, -0.146362305f, -0.035552979f, |
-0.030532837f, -0.001098633f, -0.002456665f, -0.000198364f, |
0.000030518f, 0.000961304f, -0.003372192f, 0.016235352f, |
-0.019531250f, 0.125259399f, 0.015228271f, 0.816864014f, |
-1.089782715f, -0.323318481f, -0.148773193f, -0.030609131f, |
-0.029937742f, -0.000549316f, -0.002349854f, -0.000167847f, |
0.000030518f, 0.001037598f, -0.003280640f, 0.017349243f, |
-0.017257690f, 0.129562378f, 0.032379150f, 0.841949463f, |
-1.077117920f, -0.297210693f, -0.150497437f, -0.025817871f, |
-0.029281614f, -0.000030518f, -0.002243042f, -0.000152588f, |
0.000045776f, 0.001113892f, -0.003173828f, 0.018463135f, |
-0.014801024f, 0.133590698f, 0.050354004f, 0.866363525f, |
-1.063217163f, -0.271591187f, -0.151596069f, -0.021179199f, |
-0.028533936f, 0.000442505f, -0.002120972f, -0.000137329f, |
0.000045776f, 0.001205444f, -0.003051758f, 0.019577026f, |
-0.012115479f, 0.137298584f, 0.069168091f, 0.890090942f, |
-1.048156738f, -0.246505737f, -0.152069092f, -0.016708374f, |
-0.027725220f, 0.000869751f, -0.002014160f, -0.000122070f, |
0.000061035f, 0.001296997f, -0.002883911f, 0.020690918f, |
-0.009231566f, 0.140670776f, 0.088775635f, 0.913055420f, |
-1.031936646f, -0.221984863f, -0.151962280f, -0.012420653f, |
-0.026840210f, 0.001266479f, -0.001907349f, -0.000106812f, |
0.000061035f, 0.001388550f, -0.002700806f, 0.021789551f, |
-0.006134033f, 0.143676758f, 0.109161377f, 0.935195923f, |
-1.014617920f, -0.198059082f, -0.151306152f, -0.008316040f, |
-0.025909424f, 0.001617432f, -0.001785278f, -0.000106812f, |
0.000076294f, 0.001480103f, -0.002487183f, 0.022857666f, |
-0.002822876f, 0.146255493f, 0.130310059f, 0.956481934f, |
-0.996246338f, -0.174789429f, -0.150115967f, -0.004394531f, |
-0.024932859f, 0.001937866f, -0.001693726f, -0.000091553f, |
-0.001586914f, -0.023910521f, -0.148422241f, -0.976852417f, |
0.152206421f, 0.000686646f, -0.002227783f, 0.000076294f, |
}; |
void window(float *vbuf, int vb_ptr, short *pcm) |
{ |
int i, j; |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 16; |
bx = (si + 32) & 511; |
coef = wincoef; |
/*-- first 16 --*/ |
for (i = 0; i < 16; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 64) & 511; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
si++; |
bx--; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
/*-- last 15 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 15; i++) |
{ |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 64) & 511; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
} |
} |
/*------------------------------------------------------------*/ |
void window_dual(float *vbuf, int vb_ptr, short *pcm) |
{ |
int i, j; /* dual window interleaves output */ |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 16; |
bx = (si + 32) & 511; |
coef = wincoef; |
/*-- first 16 --*/ |
for (i = 0; i < 16; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 64) & 511; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
si++; |
bx--; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
/*-- last 15 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 15; i++) |
{ |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 64) & 511; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
} |
} |
/*------------------------------------------------------------*/ |
/*------------------- 16 pt window ------------------------------*/ |
void window16(float *vbuf, int vb_ptr, short *pcm) |
{ |
int i, j; |
unsigned char si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 8; |
bx = si + 16; |
coef = wincoef; |
/*-- first 8 --*/ |
for (i = 0; i < 8; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si += 32; |
sum -= (*coef++) * vbuf[bx]; |
bx += 32; |
} |
si++; |
bx--; |
coef += 16; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
/*-- last 7 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 7; i++) |
{ |
coef -= 16; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si += 32; |
sum += (*coef--) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
} |
} |
/*--------------- 16 pt dual window (interleaved output) -----------------*/ |
void window16_dual(float *vbuf, int vb_ptr, short *pcm) |
{ |
int i, j; |
unsigned char si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 8; |
bx = si + 16; |
coef = wincoef; |
/*-- first 8 --*/ |
for (i = 0; i < 8; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si += 32; |
sum -= (*coef++) * vbuf[bx]; |
bx += 32; |
} |
si++; |
bx--; |
coef += 16; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
/*-- last 7 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 7; i++) |
{ |
coef -= 16; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si += 32; |
sum += (*coef--) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
} |
} |
/*------------------- 8 pt window ------------------------------*/ |
void window8(float *vbuf, int vb_ptr, short *pcm) |
{ |
int i, j; |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 4; |
bx = (si + 8) & 127; |
coef = wincoef; |
/*-- first 4 --*/ |
for (i = 0; i < 4; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 16) & 127; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
si++; |
bx--; |
coef += 48; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
/*-- last 3 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 3; i++) |
{ |
coef -= 48; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 16) & 127; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
} |
} |
/*--------------- 8 pt dual window (interleaved output) -----------------*/ |
void window8_dual(float *vbuf, int vb_ptr, short *pcm) |
{ |
int i, j; |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 4; |
bx = (si + 8) & 127; |
coef = wincoef; |
/*-- first 4 --*/ |
for (i = 0; i < 4; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 16) & 127; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
si++; |
bx--; |
coef += 48; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
/*-- last 3 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 3; i++) |
{ |
coef -= 48; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 16) & 127; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
} |
} |
/programs/media/ac97snd/trunk/mp3dec/windowb.c |
---|
0,0 → 1,427 |
extern float wincoef[264]; |
void windowB(float *vbuf, int vb_ptr, unsigned char *pcm) |
{ |
int i, j; |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 16; |
bx = (si + 32) & 511; |
coef = wincoef; |
/*-- first 16 --*/ |
for (i = 0; i < 16; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 64) & 511; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
si++; |
bx--; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
/*-- last 15 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 15; i++) |
{ |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 64) & 511; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
} |
} |
/*------------------------------------------------------------*/ |
void windowB_dual(float *vbuf, int vb_ptr, unsigned char *pcm) |
{ |
int i, j; /* dual window interleaves output */ |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 16; |
bx = (si + 32) & 511; |
coef = wincoef; |
/*-- first 16 --*/ |
for (i = 0; i < 16; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 64) & 511; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
si++; |
bx--; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
/*-- last 15 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 15; i++) |
{ |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 64) & 511; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
} |
} |
/*------------------------------------------------------------*/ |
/*------------------- 16 pt window ------------------------------*/ |
void windowB16(float *vbuf, int vb_ptr, unsigned char *pcm) |
{ |
int i, j; |
unsigned char si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 8; |
bx = si + 16; |
coef = wincoef; |
/*-- first 8 --*/ |
for (i = 0; i < 8; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si += 32; |
sum -= (*coef++) * vbuf[bx]; |
bx += 32; |
} |
si++; |
bx--; |
coef += 16; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
/*-- last 7 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 7; i++) |
{ |
coef -= 16; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si += 32; |
sum += (*coef--) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
} |
} |
/*--------------- 16 pt dual window (interleaved output) -----------------*/ |
void windowB16_dual(float *vbuf, int vb_ptr, unsigned char *pcm) |
{ |
int i, j; |
unsigned char si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 8; |
bx = si + 16; |
coef = wincoef; |
/*-- first 8 --*/ |
for (i = 0; i < 8; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si += 32; |
sum -= (*coef++) * vbuf[bx]; |
bx += 32; |
} |
si++; |
bx--; |
coef += 16; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
/*-- last 7 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 7; i++) |
{ |
coef -= 16; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si += 32; |
sum += (*coef--) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
} |
} |
/*------------------- 8 pt window ------------------------------*/ |
void windowB8(float *vbuf, int vb_ptr, unsigned char *pcm) |
{ |
int i, j; |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 4; |
bx = (si + 8) & 127; |
coef = wincoef; |
/*-- first 4 --*/ |
for (i = 0; i < 4; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 16) & 127; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
si++; |
bx--; |
coef += 48; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
/*-- last 3 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 3; i++) |
{ |
coef -= 48; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 16) & 127; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
} |
} |
/*--------------- 8 pt dual window (interleaved output) -----------------*/ |
void windowB8_dual(float *vbuf, int vb_ptr, unsigned char *pcm) |
{ |
int i, j; |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 4; |
bx = (si + 8) & 127; |
coef = wincoef; |
/*-- first 4 --*/ |
for (i = 0; i < 4; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 16) & 127; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
si++; |
bx--; |
coef += 48; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
/*-- last 3 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 3; i++) |
{ |
coef -= 48; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 16) & 127; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
} |
} |