1
0
mirror of http://mpg123.de/trunk/.git synced 2025-10-28 02:55:29 +03:00

One big step of the messy part of libmpg123 merge.

The hard code mixes should be done, easy code mixes to follow... then the fun with the build system.


git-svn-id: svn://scm.orgis.org/mpg123/trunk@1000 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
thor
2007-10-16 00:52:34 +00:00
parent ce45236b84
commit aab65056ca
82 changed files with 1380 additions and 83282 deletions

View File

@@ -6,8 +6,7 @@
initially written by Michael Hipp
*/
#include "mpg123.h"
#include "layer3.h"
#include "mpg123app.h"
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
@@ -126,16 +125,21 @@ static void audio_output_dump(audio_output_t *ao)
#define NUM_ENCODINGS 6
#define NUM_RATES 10
struct audio_format_name audio_val2name[NUM_ENCODINGS+1] = {
{ AUDIO_FORMAT_SIGNED_16 , "signed 16 bit" , "s16 " } ,
{ AUDIO_FORMAT_UNSIGNED_16, "unsigned 16 bit" , "u16 " } ,
{ AUDIO_FORMAT_UNSIGNED_8 , "unsigned 8 bit" , "u8 " } ,
{ AUDIO_FORMAT_SIGNED_8 , "signed 8 bit" , "s8 " } ,
{ AUDIO_FORMAT_ULAW_8 , "mu-law (8 bit)" , "ulaw " } ,
{ AUDIO_FORMAT_ALAW_8 , "a-law (8 bit)" , "alaw " } ,
{ -1 , NULL }
};
/* Safer as function... */
const char* audio_encoding_name(const int encoding, const int longer)
{
const char *name = longer ? "unknown" : "???";
switch(encoding)
{
case MPG123_ENC_SIGNED_16: name = longer ? "signed 16 bit" : "s16 "; break;
case MPG123_ENC_UNSIGNED_16: name = longer ? "unsigned 16 bit" : "u16 "; break;
case MPG123_ENC_UNSIGNED_8: name = longer ? "unsigned 8 bit" : "u8 "; break;
case MPG123_ENC_SIGNED_8: name = longer ? "signed 8 bit" : "s8 "; break;
case MPG123_ENC_ULAW_8: name = longer ? "mu-law (8 bit)" : "ulaw "; break;
case MPG123_ENC_ALAW_8: name = longer ? "a-law (8 bit)" : "alaw "; break;
}
return name;
}
static int channels[NUM_CHANNELS] = { 1 , 2 };
static int rates[NUM_RATES] = {
@@ -154,222 +158,75 @@ static int encodings[NUM_ENCODINGS] = {
AUDIO_FORMAT_ALAW_8
};
static char capabilities[NUM_CHANNELS][NUM_ENCODINGS][NUM_RATES];
static void print_capabilities(audio_output_t *ao)
static void capline(mpg123_handle *mh, int ratei)
{
int j,k,k1=NUM_RATES-1;
if(param.force_rate) {
rates[NUM_RATES-1] = param.force_rate;
k1 = NUM_RATES;
int enci;
fprintf(stderr," %5ld |", ratei >= 0 ? mpg123_rates[ratei] : param.force_rate);
for(enci=0; enci<MPG123_ENCODINGS; ++enci)
{
switch(mpg123_format_support(mh, ratei, enci))
{
case MPG123_MONO: fprintf(stderr, " M |"); break;
case MPG123_STEREO: fprintf(stderr, " S |"); break;
case MPG123_MONO|MPG123_STEREO: fprintf(stderr, " M/S |"); break;
default: fprintf(stderr, " |");
}
}
fprintf(stderr, "\n");
}
void print_capabilities(audio_output_t *ao, mpg123_handle *mh)
{
int r,e;
fprintf(stderr,"\nAudio driver: %s\nAudio device: %s\nAudio capabilities:\n(matrix of [S]tereo or [M]ono support for sample format and rate in Hz)\n |",
ao->module->name, ao->device != NULL ? ao->device : "<none>");
for(j=0;j<NUM_ENCODINGS;j++) {
fprintf(stderr," %5s |",audio_val2name[j].sname);
}
for(e=0;e<MPG123_ENCODINGS;e++) fprintf(stderr," %5s |",audio_encoding_name(mpg123_encodings[e], 0));
fprintf(stderr,"\n --------------------------------------------------------\n");
for(k=0;k<k1;k++) {
fprintf(stderr," %5d |",rates[k]);
for(j=0;j<NUM_ENCODINGS;j++) {
if(capabilities[0][j][k]) {
if(capabilities[1][j][k])
fprintf(stderr," M/S |");
else
fprintf(stderr," M |");
}
else if(capabilities[1][j][k])
fprintf(stderr," S |");
else
fprintf(stderr," |");
}
fprintf(stderr,"\n");
}
for(r=0; r<MPG123_RATES; ++r) capline(mh, r);
if(param.force_rate) capline(mh, -1);
fprintf(stderr,"\n");
}
void audio_capabilities(audio_output_t *ao)
LIB: void audio_capabilities(struct audio_info_struct *ai, mpg123_handle *mh)
{
int fmts;
int i,j,k,k1=NUM_RATES-1;
audio_output_t ao1 = *ao;
int ri;
audio_output_t ao1 = *ao; /* a copy */
if (param.outmode != DECODE_AUDIO) {
memset(capabilities,1,sizeof(capabilities));
if(mpg123_param(mh, MPG123_FORCE_RATE, param.force_rate, 0) != MPG123_OK)
{
error1("Cannot set forced rate (%s)!", mpg123_strerror(mh));
mpg123_format_none(mh);
return;
}
if(param.outmode != DECODE_AUDIO)
{ /* File/stdout writers can take anything. */
mpg123_format_all(mh);
return;
}
memset(capabilities,0,sizeof(capabilities));
if(param.force_rate) {
rates[NUM_RATES-1] = param.force_rate;
k1 = NUM_RATES;
}
mpg123_format_none(mh); /* Start with nothing. */
/* if audio_open fails, the device is just not capable of anything... */
if(ao1.open(&ao1) < 0) {
error("failed to open audio device");
}
/* If audio_open fails, the device is just not capable of anything... */
if(ao1.open(&ao1) < 0) error("failed to open audio device");
else
{
for(i=0;i<NUM_CHANNELS;i++) {
for(j=0;j<NUM_RATES;j++) {
ao1.channels = channels[i];
ao1.rate = rates[j];
for(ao1.channels=1; ao1.channels<=2; ao1.channels++)
for(ri=-1;ri<MPG123_RATES;ri++)
{
ao1.rate = ri >= 0 ? mpg123_rates[ri] : param.force_rate;
fmts = ao1.get_formats(&ao1);
if(fmts < 0)
continue;
for(k=0;k<NUM_ENCODINGS;k++) {
if((fmts & encodings[k]) == encodings[k])
capabilities[i][k][j] = 1;
}
}
if(fmts < 0) continue;
else mpg123_format(mh, ri, ao1.channels, fmts);
}
ao1.close(&ao1);
}
if(param.verbose > 1) print_capabilities(ao);
if(param.verbose > 1) print_capabilities(ao, mh);
}
static int rate2num(int r)
{
int i;
for(i=0;i<NUM_RATES;i++)
if(rates[i] == r)
return i;
return -1;
}
static int audio_fit_cap_helper(audio_output_t *ao,int rn,int f0,int f2,int c)
{
int i;
if(rn >= 0) {
for(i=f0;i<f2;i++) {
if(capabilities[c][i][rn]) {
ao->rate = rates[rn];
ao->format = encodings[i];
ao->channels = channels[c];
return 1;
}
}
}
return 0;
}
/*
* c=num of channels of stream
* r=rate of stream
* return 0 on error
*/
int audio_fit_capabilities(audio_output_t *ao,int c,int r)
{
int rn;
int f0=0;
/* skip the 16bit encodings */
if(param.force_8bit) {
f0 = 2;
}
c--; /* stereo=1 ,mono=0 */
/* force stereo is stronger */
if(param.force_mono) c = 0;
if(param.force_stereo) c = 1;
if(param.force_rate) {
rates[NUM_RATES-1] = param.force_rate; /* To make STDOUT decoding work. */
rn = rate2num(param.force_rate);
/* 16bit encodings */
if(audio_fit_cap_helper(ao,rn,f0,2,c)) return 1;
/* 8bit encodings */
if(audio_fit_cap_helper(ao,rn,2,NUM_ENCODINGS,c)) return 1;
/* try again with different stereoness */
if(c == 1 && !param.force_stereo) c = 0;
else if(c == 0 && !param.force_mono) c = 1;
/* 16bit encodings */
if(audio_fit_cap_helper(ao,rn,f0,2,c)) return 1;
/* 8bit encodings */
if(audio_fit_cap_helper(ao,rn,2,NUM_ENCODINGS,c)) return 1;
error3("Unable to set up output device! Constraints: %s%s%liHz.",
(param.force_stereo ? "stereo, " :
(param.force_mono ? "mono, " : "")),
(param.force_8bit ? "8bit, " : ""),
param.force_rate);
if(param.verbose <= 1) print_capabilities(ao);
return 0;
}
/* try different rates with 16bit */
rn = rate2num(r>>0);
if(audio_fit_cap_helper(ao,rn,f0,2,c))
return 1;
rn = rate2num(r>>1);
if(audio_fit_cap_helper(ao,rn,f0,2,c))
return 1;
rn = rate2num(r>>2);
if(audio_fit_cap_helper(ao,rn,f0,2,c))
return 1;
/* try different rates with 8bit */
rn = rate2num(r>>0);
if(audio_fit_cap_helper(ao,rn,2,NUM_ENCODINGS,c))
return 1;
rn = rate2num(r>>1);
if(audio_fit_cap_helper(ao,rn,2,NUM_ENCODINGS,c))
return 1;
rn = rate2num(r>>2);
if(audio_fit_cap_helper(ao,rn,2,NUM_ENCODINGS,c))
return 1;
/* try agaon with different stereoness */
if(c == 1 && !param.force_stereo) c = 0;
else if(c == 0 && !param.force_mono) c = 1;
/* 16bit */
rn = rate2num(r>>0);
if(audio_fit_cap_helper(ao,rn,f0,2,c)) return 1;
rn = rate2num(r>>1);
if(audio_fit_cap_helper(ao,rn,f0,2,c)) return 1;
rn = rate2num(r>>2);
if(audio_fit_cap_helper(ao,rn,f0,2,c)) return 1;
/* 8bit */
rn = rate2num(r>>0);
if(audio_fit_cap_helper(ao,rn,2,NUM_ENCODINGS,c)) return 1;
rn = rate2num(r>>1);
if(audio_fit_cap_helper(ao,rn,2,NUM_ENCODINGS,c)) return 1;
rn = rate2num(r>>2);
if(audio_fit_cap_helper(ao,rn,2,NUM_ENCODINGS,c)) return 1;
error5("Unable to set up output device! Constraints: %s%s%i, %i or %iHz.",
(param.force_stereo ? "stereo, " :
(param.force_mono ? "mono, " : "")),
(param.force_8bit ? "8bit, " : ""),
r, r>>1, r>>2);
if(param.verbose <= 1) print_capabilities(ao);
return 0;
}
char *audio_encoding_name(int format)
{
int i;
for(i=0;i<NUM_ENCODINGS;i++) {
if(audio_val2name[i].val == format)
return audio_val2name[i].name;
}
return "Unknown";
}
#if !defined(WIN32) && !defined(GENERIC)
#ifndef NOXFERMEM
static void catch_child(void)
@@ -380,17 +237,13 @@ static void catch_child(void)
#endif
/* FIXME: Old output initialization code that needs updating */
int init_output( audio_output_t *ao )
int init_output(audio_output_t *ao)
{
static int init_done = FALSE;
if (init_done) return 0;
if (init_done) return 1;
init_done = TRUE;
#ifndef NOXFERMEM
@@ -405,53 +258,46 @@ int init_output( audio_output_t *ao )
param.usebuffer = 0;
}
if (param.usebuffer) {
if (param.usebuffer)
{
unsigned int bufferbytes;
sigset_t newsigset, oldsigset;
if (param.usebuffer < 32)
param.usebuffer = 32; /* minimum is 32 Kbytes! */
bufferbytes = (param.usebuffer * 1024);
bufferbytes -= bufferbytes % FRAMEBUFUNIT;
/* +1024 for NtoM rounding problems */
xfermem_init (&buffermem, bufferbytes ,0,1024);
pcm_sample = (unsigned char *) buffermem->data;
pcm_point = 0;
if (bufferbytes < bufferblock)
{
bufferbytes = 2*bufferblock;
if(!param.quiet) fprintf(stderr, "Note: raising buffer to minimal size %liKiB\n", (unsigned long) bufferbytes>>10);
}
bufferbytes -= bufferbytes % bufferblock;
/* No +1024 for NtoM rounding problems anymore! */
xfermem_init (&buffermem, bufferbytes ,0,0);
mpg123_replace_buffer(mh, (unsigned char *) buffermem->data, bufferblock);
sigemptyset (&newsigset);
sigaddset (&newsigset, SIGUSR1);
sigprocmask (SIG_BLOCK, &newsigset, &oldsigset);
#if !defined(WIN32) && !defined(GENERIC)
#if !defined(WIN32) && !defined(GENERIC)
catchsignal (SIGCHLD, catch_child);
#endif
switch ((buffer_pid = fork())) {
#endif
switch ((buffer_pid = fork()))
{
case -1: /* error */
perror("fork()");
return 1;
safe_exit(1);
case 0: /* child */
if(rd) rd->close(rd); /* child doesn't need the input stream */
/* oh, is that trouble here? well, buffer should actually be opened before loading tracks IMHO */
mpg123_close(mh); /* child doesn't need the input stream */
xfermem_init_reader (buffermem);
buffer_loop(ao, &oldsigset);
buffer_loop (ao, &oldsigset);
xfermem_done_reader (buffermem);
xfermem_done (buffermem);
exit(0);
default: /* parent */
xfermem_init_writer (buffermem);
param.outmode = DECODE_BUFFER;
break;
}
} else {
#endif
/* + 1024 for NtoM rate converter */
if (!(pcm_sample = (unsigned char *) malloc(audiobufsize * 2 + 1024))) {
perror ("malloc()");
return 1;
#ifndef NOXFERMEM
}
#endif
}
/* Open audio if not decoding to buffer */
switch(param.outmode) {
case DECODE_AUDIO:
if(ao->open(ao) < 0) {
@@ -473,35 +319,29 @@ int init_output( audio_output_t *ao )
return 0;
}
void flush_output(int outmode, audio_output_t *ao)
void flush_output(int outmode, audio_output_t *ao, unsigned char *bytes, size_t count)
{
/* the gapless code is not in effect for buffered mode... as then condition for flush_output is never met */
#ifdef GAPLESS
if(param.gapless) layer3_gapless_buffercheck();
#endif
if(pcm_point)
if(count)
{
switch(outmode)
{
case DECODE_FILE:
write (OutputDescriptor, pcm_sample, pcm_point);
write (OutputDescriptor, bytes, count);
break;
case DECODE_AUDIO:
ao->write(ao, pcm_sample, pcm_point);
ao->write(ao, bytes, count);
break;
case DECODE_BUFFER:
error("The buffer doesn't work like that... I shouldn't ever be getting here.");
write (buffer_fd[1], pcm_sample, pcm_point);
write (buffer_fd[1], bytes, count);
break;
case DECODE_WAV:
case DECODE_CDR:
case DECODE_AU:
wav_write(pcm_sample, pcm_point);
wav_write(bytes, count);
break;
}
pcm_point = 0;
count = 0;
}
}

View File

@@ -89,7 +89,7 @@ extern int audio_fit_capabilities(audio_output_t *ao,int c,int r);
extern char *audio_encoding_name(int format);
extern int init_output( audio_output_t *ao );
extern void flush_output(int mod, audio_output_t *ao );
void flush_output(int outmode, audio_output_t *ao, unsigned char *bytes, size_t count)
extern void close_output(int mod, audio_output_t *ao );

View File

@@ -10,13 +10,14 @@
- dammed night coders;-)
*/
#include "mpg123.h"
#include "mpg123app.h"
#ifndef NOXFERMEM
#include "common.h"
#include <errno.h>
int outburst = MAXOUTBURST;
int outburst = 32768;
static int intflag = FALSE;
static int usr1flag = FALSE;

File diff suppressed because it is too large Load Diff

View File

@@ -9,115 +9,21 @@
#ifndef _MPG123_COMMON_H_
#define _MPG123_COMMON_H_
/* max = 1728 */
#define MAXFRAMESIZE 3456
/*
AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM
A: sync
B: mpeg version
C: layer
D: CRC
E: bitrate
F:sampling rate
G: padding
H: private
I: channel mode
J: mode ext
K: copyright
L: original
M: emphasis
#include "mpg123.h"
old compare mask 0xfffffd00:
11111111 11111111 11111101 00000000
means: everything must match excluding padding and channel mode, ext mode, ...
But a vbr stream's headers will differ in bitrate!
We are already strict in allowing only frames of same type in stream, we should at least watch out for VBR while being strict.
So a better mask is:
11111111 11111111 00001101 00000000
Even more, I'll allow varying crc bit.
11111111 11111110 00001101 00000000
(still unsure about this private bit)
*/
#define HDRCMPMASK 0xfffe0d00
extern unsigned long firsthead;
extern int tabsel_123[2][3][16];
extern double compute_tpf(struct frame *fr);
extern double compute_bpf(struct frame *fr);
extern long compute_buffer_offset(struct frame *fr);
struct bitstream_info {
int bitindex;
unsigned char *wordpointer;
};
extern struct bitstream_info bsi;
/* well, I take that one for granted... at least layer3 */
#define DECODER_DELAY 529
#ifdef GAPLESS
unsigned long samples_to_bytes(unsigned long s, struct frame *fr, audio_output_t* ao);
/* samples per frame ...
Layer I
Layer II
Layer III
MPEG-1
384
1152
1152
MPEG-2 LSF
384
1152
576
MPEG 2.5
384
1152
576
*/
#define spf(fr) (fr->lay == 1 ? 384 : (fr->lay==2 ? 1152 : (fr->lsf || fr->mpeg25 ? 576 : 1152)))
/* still fine-tuning the "real music" window... see read_frame */
#define GAP_SHIFT -1
#endif
void (*catchsignal(int signum, void(*handler)()))();
void print_header(mpg123_handle *);
void print_header_compact(mpg123_handle *);
void print_stat(mpg123_handle *fr, long offset, long buffsize);
void clear_stat();
/* for control_generic */
extern const char* remote_header_help;
void print_remote_header(struct frame* fr);
void generic_sendmsg (const char *fmt, ...);
int position_info(struct frame* fr, unsigned long no, long buffsize, audio_output_t *ao,
unsigned long* frames_left, double* current_seconds, double* seconds_left);
int read_frame_recover(struct frame* fr);
off_t frame_index_find(unsigned long want_frame, unsigned long* get_frame);
void print_frame_index(FILE* out);
int split_dir_file(const char *path, char **dname, char **fname);
extern const char* rva_name[3];
#endif
void print_stat(struct frame *fr,unsigned long no,long buffsize,audio_output_t *ao);
void clear_stat();
/* rva data, used in common.c, set in id3.c */
extern scale_t lastscale;
extern int rva_level[2];
extern float rva_gain[2];
extern float rva_peak[2];
/* adjust volume to current outscale and rva values if wanted */
#define RVA_OFF 0
#define RVA_MIX 1
#define RVA_ALBUM 2
#define RVA_MAX RVA_ALBUM
extern const char* rva_name[3];
void do_rva();
/* wrap over do_rva that prepares outscale */
void do_volume(double factor);
/* positive and negative for offsets... I guess I'll drop the unsigned frame position type anyway */
long time_to_frame(struct frame *fr, double seconds);

View File

@@ -17,16 +17,12 @@
#endif
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include "mpg123.h"
#include "mpg123app.h"
#include "common.h"
#include "buffer.h"
#include "icy.h"
#ifdef GAPLESS
#include "layer3.h"
extern audio_output_t pre_ao;
#endif
#include "genre.h"
#define MODE_STOPPED 0
#define MODE_PLAYING 1
#define MODE_PAUSED 2
@@ -40,6 +36,8 @@ int control_file = STDIN_FILENO;
#define control_file STDIN_FILENO
#endif
FILE *outstream;
static int mode = MODE_STOPPED;
static int init = 0;
void generic_sendmsg (const char *fmt, ...)
{
@@ -51,26 +49,34 @@ void generic_sendmsg (const char *fmt, ...)
fprintf(outstream, "\n");
}
void generic_sendstat (struct frame *fr)
void generic_sendstat (mpg123_handle *fr)
{
unsigned long frames_left;
long current_frame, frames_left;
double current_seconds, seconds_left;
if(!position_info(fr, fr->num, xfermem_get_usedspace(buffermem), &ao, &frames_left, &current_seconds, &seconds_left))
generic_sendmsg("F %li %lu %3.2f %3.2f", fr->num, frames_left, current_seconds, seconds_left);
if(!mpg123_position(fr, 0, xfermem_get_usedspace(buffermem), &current_frame, &frames_left, &current_seconds, &seconds_left))
generic_sendmsg("F %li %li %3.2f %3.2f", current_frame, frames_left, current_seconds, seconds_left);
}
extern char *genre_table[];
extern int genre_count;
void generic_sendinfoid3 (char *buf)
void generic_sendinfoid3(mpg123_handle *mh)
{
char info[200] = "", *c;
char info[125] = "";
int i;
unsigned char genre;
for (i=0, c=buf+3; i<124; i++, c++)
info[i] = *c ? *c : ' ';
mpg123_id3v1 *v1;
mpg123_id3v2 *v2;
if(MPG123_OK != mpg123_id3(mh, &v1, &v2))
{
error1("Cannot get ID3 data: %s", mpg123_strerror(mh));
return;
}
if(v1 == NULL) return;
memcpy(info, v1->title, 30);
memcpy(info+30, v1->artist, 30);
memcpy(info+60, v1->album, 30);
memcpy(info+90, v1->year, 4);
memcpy(info+94, v1->comment, 30);
for(i=0;i<124; ++i) if(info[i] == 0) info[i] = ' ';
info[i] = 0;
genre = *c;
generic_sendmsg("I ID3:%s%s", info, (genre<=genre_count) ? genre_table[genre] : "Unknown");
generic_sendmsg("I ID3:%s%s", info, (v1->genre<=genre_count) ? genre_table[v1->genre] : "Unknown");
}
void generic_sendinfo (char *filename)
@@ -87,18 +93,38 @@ void generic_sendinfo (char *filename)
generic_sendmsg("I %s", s);
}
int control_generic (struct frame *fr)
static void generic_load(mpg123_handle *fr, char *arg, int state)
{
if(mode != MODE_STOPPED)
{
close_track();
mode = MODE_STOPPED;
}
if(!open_track(arg))
{
generic_sendmsg("E Error opening stream: %s", arg);
generic_sendmsg("P 0");
return;
}
if(mpg123_meta_check(fr) & MPG123_NEW_ID3) generic_sendinfoid3(fr);
else generic_sendinfo(arg);
if(htd.icy_name.fill) generic_sendmsg("I ICY-NAME: %s", htd.icy_name.p);
if(htd.icy_url.fill) generic_sendmsg("I ICY-URL: %s", htd.icy_url.p);
mode = state;
init = 1;
generic_sendmsg(mode == MODE_PAUSED ? "P 1" : "P 2");
}
int control_generic (mpg123_handle *fr)
{
struct timeval tv;
fd_set fds;
int n;
int mode = MODE_STOPPED;
int init = 0;
/* ThOr */
char alive = 1;
char silent = 0;
unsigned long frame_before = 0;
/* responses to stderr for frontends needing audio data from stdout */
if (param.remote_err)
@@ -146,35 +172,27 @@ int control_generic (struct frame *fr)
if (mode == MODE_PLAYING) {
n = select(32, &fds, NULL, NULL, &tv);
if (n == 0) {
if (!read_frame(fr)) {
if (!play_frame())
{
mode = MODE_STOPPED;
flush_output(param.outmode, &ao);
rd->close(rd);
close_track();
generic_sendmsg("P 0");
continue;
}
if(!play_frame(init,fr))
{
generic_sendmsg("E play_frame failed");
flush_output(param.outmode, &ao);
rd->close(rd);
mode = MODE_STOPPED;
generic_sendmsg("P 0");
}
if (init) {
print_remote_header(fr);
init = 0;
}
if(!frame_before && (silent == 0))
if(silent == 0)
{
generic_sendstat(fr);
if (icy.changed && icy.data)
if(mpg123_meta_check(fr) & MPG123_NEW_ICY)
{
generic_sendmsg("I ICY-META: %s", icy.data);
icy.changed = 0;
char *meta;
if(mpg123_icy(fr, &meta) == MPG123_OK)
generic_sendmsg("I ICY-META: %s", meta != NULL ? meta : "<nil>");
}
}
if(frame_before) --frame_before;
}
}
else {
@@ -247,7 +265,6 @@ int control_generic (struct frame *fr)
{
if (mode == MODE_PLAYING) {
mode = MODE_PAUSED;
flush_output(param.outmode, &ao);
buffer_stop();
generic_sendmsg("P 1");
} else {
@@ -262,8 +279,7 @@ int control_generic (struct frame *fr)
/* STOP */
if (!strcasecmp(comstr, "S") || !strcasecmp(comstr, "STOP")) {
if (mode != MODE_STOPPED) {
flush_output(param.outmode, &ao);
rd->close(rd);
close_track();
mode = MODE_STOPPED;
generic_sendmsg("P 0");
}
@@ -293,6 +309,7 @@ int control_generic (struct frame *fr)
generic_sendmsg("VOLUME/V <percent>: set volume in % (0..100...); float value");
generic_sendmsg("RVA off|(mix|radio)|(album|audiophile): set rva mode");
generic_sendmsg("EQ/E <channel> <band> <value>: set equalizer value for frequency band on channel");
generic_sendmsg("SEEK/K <sample>|<+offset>|<-offset>: jump to output sample position <samples> or change position by offset");
generic_sendmsg("SEQ <bass> <mid> <treble>: simple eq setting...");
generic_sendmsg("SILENCE: be silent during playback (meaning silence in text form)");
generic_sendmsg("meaning of the @S stream info:");
@@ -310,30 +327,20 @@ int control_generic (struct frame *fr)
{
/* Simple EQ: SEQ <BASS> <MID> <TREBLE> */
if (!strcasecmp(cmd, "SEQ")) {
real b,m,t;
double b,m,t;
int cn;
have_eq_settings = TRUE;
if(sscanf(arg, REAL_SCANF" "REAL_SCANF" "REAL_SCANF, &b, &m, &t) == 3)
if(sscanf(arg, "%lf %lf %lf", &b, &m, &t) == 3)
{
/* very raw line */
/* Consider adding mpg123_seq()... but also, on could define a nicer courve for that. */
if ((t >= 0) && (t <= 3))
for(cn=0; cn < 1; ++cn)
{
equalizer[0][cn] = b;
equalizer[1][cn] = b;
}
for(cn=0; cn < 1; ++cn) mpg123_eq(fr, MPG123_LEFT|MPG123_RIGHT, cn, b);
if ((m >= 0) && (m <= 3))
for(cn=1; cn < 2; ++cn)
{
equalizer[0][cn] = m;
equalizer[1][cn] = m;
}
for(cn=1; cn < 2; ++cn) mpg123_eq(fr, MPG123_LEFT|MPG123_RIGHT, cn, m);
if ((b >= 0) && (b <= 3))
for(cn=2; cn < 32; ++cn)
{
equalizer[0][cn] = t;
equalizer[1][cn] = t;
}
for(cn=2; cn < 32; ++cn) mpg123_eq(fr, MPG123_LEFT|MPG123_RIGHT, cn, t);
generic_sendmsg("bass: %f mid: %f treble: %f", b, m, t);
}
else generic_sendmsg("E invalid arguments for SEQ: %s", arg);
@@ -342,25 +349,41 @@ int control_generic (struct frame *fr)
/* Equalizer control :) (JMG) */
if (!strcasecmp(cmd, "E") || !strcasecmp(cmd, "EQ")) {
real e; /* ThOr: equalizer is of type real... whatever that is */
double e; /* ThOr: equalizer is of type real... whatever that is */
int c, v;
have_eq_settings = TRUE;
/*generic_sendmsg("%s",updown);*/
if(sscanf(arg, "%i %i "REAL_SCANF, &c, &v, &e) == 3)
if(sscanf(arg, "%i %i %lf", &c, &v, &e) == 3)
{
equalizer[c][v] = e;
generic_sendmsg("%i : %i : "REAL_PRINTF, c, v, e);
mpg123_eq(fr, c, v, e);
generic_sendmsg("%i : %i : %f", c, v, e);
}
else generic_sendmsg("E invalid arguments for EQ: %s", arg);
continue;
}
/* SEEK to a sample offset */
if(!strcasecmp(cmd, "K") || !strcasecmp(cmd, "SEEK"))
{
off_t soff;
char *spos = arg;
int whence = SEEK_SET;
if(!spos || (mode == MODE_STOPPED)) continue;
soff = atol(spos);
if(spos[0] == '-' || spos[0] == '+') whence = SEEK_CUR;
if(0 > (soff = mpg123_seek(fr, soff, whence)))
{
generic_sendmsg("E Error while seeking: %s", mpg123_strerror(fr));
mpg123_seek(fr, 0, SEEK_SET);
}
generic_sendmsg("K %li", (long)mpg123_tell(fr));
continue;
}
/* JUMP */
if (!strcasecmp(cmd, "J") || !strcasecmp(cmd, "JUMP")) {
char *spos;
long offset;
off_t offset;
double secs;
flush_output(param.outmode, &ao);
spos = arg;
if (!spos)
@@ -368,39 +391,20 @@ int control_generic (struct frame *fr)
if (mode == MODE_STOPPED)
continue;
if(spos[strlen(spos)-1] == 's' && sscanf(arg, "%lf", &secs) == 1) offset = time_to_frame(fr, secs);
if(spos[strlen(spos)-1] == 's' && sscanf(arg, "%lf", &secs) == 1) offset = mpg123_timeframe(fr, secs);
else offset = atol(spos);
/* totally replaced that stuff - it never fully worked
a bit usure about why +pos -> spos+1 earlier... */
if (spos[0] == '-' || spos[0] == '+')
offset += frame_before;
else
offset -= fr->num;
if (spos[0] == '-' || spos[0] == '+') offset += framenum;
/* ah, this offset stuff is twisted - I want absolute numbers */
#ifdef GAPLESS
if(param.gapless && (fr->lay == 3) && (mode == MODE_PAUSED))
{
if(fr->num+offset > 0)
{
--offset;
frame_before = 1;
if(fr->num+offset > 0)
{
--offset;
++frame_before;
}
}
else frame_before = 0;
}
#endif
if(rd->back_frame(rd, fr, -offset))
if(0 > (framenum = mpg123_seek_frame(fr, offset, SEEK_SET)))
{
generic_sendmsg("E Error while seeking");
rd->rewind(rd);
fr->num = 0;
mpg123_seek_frame(fr, 0, SEEK_SET);
}
if(param.usebuffer) buffer_resync();
<<<<<<< .working
#ifdef GAPLESS
if(param.gapless && (fr->lay == 3))
{
@@ -411,80 +415,38 @@ int control_generic (struct frame *fr)
#endif
generic_sendmsg("J %d", fr->num+frame_before);
=======
generic_sendmsg("J %d", framenum);
>>>>>>> .merge-right.r998
continue;
}
/* VOLUME in percent */
if(!strcasecmp(cmd, "V") || !strcasecmp(cmd, "VOLUME"))
{
do_volume(atof(arg)/100);
generic_sendmsg("V %f%%", outscale / (double) MAXOUTBURST * 100);
double v;
mpg123_volume(fr, atof(arg)/100);
mpg123_getvolume(fr, &v, NULL, NULL); /* Necessary? */
generic_sendmsg("V %f%%", v * 100);
continue;
}
/* RVA mode */
if(!strcasecmp(cmd, "RVA"))
{
if(!strcasecmp(arg, "off")) param.rva = RVA_OFF;
else if(!strcasecmp(arg, "mix") || !strcasecmp(arg, "radio")) param.rva = RVA_MIX;
else if(!strcasecmp(arg, "album") || !strcasecmp(arg, "audiophile")) param.rva = RVA_ALBUM;
do_rva();
if(!strcasecmp(arg, "off")) param.rva = MPG123_RVA_OFF;
else if(!strcasecmp(arg, "mix") || !strcasecmp(arg, "radio")) param.rva = MPG123_RVA_MIX;
else if(!strcasecmp(arg, "album") || !strcasecmp(arg, "audiophile")) param.rva = MPG123_RVA_ALBUM;
mpg123_volume(fr, -1);
generic_sendmsg("RVA %s", rva_name[param.rva]);
continue;
}
/* LOAD - actually play */
if (!strcasecmp(cmd, "L") || !strcasecmp(cmd, "LOAD")) {
#ifdef GAPLESS
frame_before = 0;
#endif
if (mode != MODE_STOPPED) {
rd->close(rd);
mode = MODE_STOPPED;
}
if( open_stream(arg, -1) < 0 ){
generic_sendmsg("E Error opening stream: %s", arg);
generic_sendmsg("P 0");
continue;
}
if (rd && rd->flags & READER_ID3TAG)
generic_sendinfoid3((char *)rd->id3buf);
else
generic_sendinfo(arg);
if (icy.name.fill) generic_sendmsg("I ICY-NAME: %s", icy.name.p);
if (icy.url.fill) generic_sendmsg("I ICY-URL: %s", icy.url.p);
mode = MODE_PLAYING;
init = 1;
read_frame_init(fr);
generic_sendmsg("P 2");
continue;
}
if (!strcasecmp(cmd, "L") || !strcasecmp(cmd, "LOAD")){ generic_load(fr, arg, MODE_PLAYING); continue; }
/* LOADPAUSED */
if (!strcasecmp(cmd, "LP") || !strcasecmp(cmd, "LOADPAUSED")) {
#ifdef GAPLESS
frame_before = 0;
#endif
if (mode != MODE_STOPPED) {
rd->close(rd);
mode = MODE_STOPPED;
}
if( open_stream(arg, -1) < 0 ){
generic_sendmsg("E Error opening stream: %s", arg);
generic_sendmsg("P 0");
continue;
}
if (rd && rd->flags & READER_ID3TAG)
generic_sendinfoid3((char *)rd->id3buf);
else
generic_sendinfo(arg);
mode = MODE_PAUSED;
init = 1;
read_frame_init(fr);
generic_sendmsg("P 1");
continue;
}
if (!strcasecmp(cmd, "LP") || !strcasecmp(cmd, "LOADPAUSED")){ generic_load(fr, arg, MODE_PAUSED); continue; }
/* no command matched */
generic_sendmsg("E Unknown command: %s", cmd); /* unknown command */
@@ -519,11 +481,6 @@ int control_generic (struct frame *fr)
xfermem_done_writer(buffermem);
waitpid(buffer_pid, NULL, 0);
xfermem_done(buffermem);
} else {
#endif
flush_output(param.outmode, &ao);
free(pcm_sample);
#ifndef NOXFERMEM
}
#endif
if (param.outmode == DECODE_AUDIO)

View File

@@ -1,503 +0,0 @@
/*
dct64_3dnow.s: Replacement of dct36() with AMD's 3DNow! SIMD operations 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.org
initially written by Syuuhei Kashiyama
This code based 'dct36_3dnow.s' by Syuuhei Kashiyama
<squash@mb.kcom.ne.jp>,only two types of changes have been made:
- remove PREFETCH instruction for speedup
- change function name for support 3DNow! automatic detect
You can find Kashiyama's original 3dnow! support patch
(for mpg123-0.59o) at
http://user.ecc.u-tokyo.ac.jp/~g810370/linux-simd/ (Japanese).
by KIMURA Takuhiro <kim@hannah.ipc.miyakyo-u.ac.jp> - until 31.Mar.1999
<kim@comtec.co.jp> - after 1.Apr.1999
Replacement of dct36() with AMD's 3DNow! SIMD operations support
Syuuhei Kashiyama <squash@mb.kcom.ne.jp>
The author of this program disclaim whole expressed or implied
warranties with regard to this program, and in no event shall the
author of this program liable to whatever resulted from the use of
this program. Use it at your own risk.
*/
#include "mangle.h"
.globl ASM_NAME(dct36_3dnow)
/* .type ASM_NAME(dct36_3dnow),@function */
ASM_NAME(dct36_3dnow):
pushl %ebp
movl %esp,%ebp
subl $120,%esp
pushl %esi
pushl %ebx
movl 8(%ebp),%eax
movl 12(%ebp),%esi
movl 16(%ebp),%ecx
movl 20(%ebp),%edx
movl 24(%ebp),%ebx
leal -128(%ebp),%esp
femms
movq (%eax),%mm0
movq 4(%eax),%mm1
pfadd %mm1,%mm0
movq %mm0,4(%eax)
psrlq $32,%mm1
movq 12(%eax),%mm2
punpckldq %mm2,%mm1
pfadd %mm2,%mm1
movq %mm1,12(%eax)
psrlq $32,%mm2
movq 20(%eax),%mm3
punpckldq %mm3,%mm2
pfadd %mm3,%mm2
movq %mm2,20(%eax)
psrlq $32,%mm3
movq 28(%eax),%mm4
punpckldq %mm4,%mm3
pfadd %mm4,%mm3
movq %mm3,28(%eax)
psrlq $32,%mm4
movq 36(%eax),%mm5
punpckldq %mm5,%mm4
pfadd %mm5,%mm4
movq %mm4,36(%eax)
psrlq $32,%mm5
movq 44(%eax),%mm6
punpckldq %mm6,%mm5
pfadd %mm6,%mm5
movq %mm5,44(%eax)
psrlq $32,%mm6
movq 52(%eax),%mm7
punpckldq %mm7,%mm6
pfadd %mm7,%mm6
movq %mm6,52(%eax)
psrlq $32,%mm7
movq 60(%eax),%mm0
punpckldq %mm0,%mm7
pfadd %mm0,%mm7
movq %mm7,60(%eax)
psrlq $32,%mm0
movd 68(%eax),%mm1
pfadd %mm1,%mm0
movd %mm0,68(%eax)
movd 4(%eax),%mm0
movd 12(%eax),%mm1
punpckldq %mm1,%mm0
punpckldq 20(%eax),%mm1
pfadd %mm1,%mm0
movd %mm0,12(%eax)
psrlq $32,%mm0
movd %mm0,20(%eax)
psrlq $32,%mm1
movd 28(%eax),%mm2
punpckldq %mm2,%mm1
punpckldq 36(%eax),%mm2
pfadd %mm2,%mm1
movd %mm1,28(%eax)
psrlq $32,%mm1
movd %mm1,36(%eax)
psrlq $32,%mm2
movd 44(%eax),%mm3
punpckldq %mm3,%mm2
punpckldq 52(%eax),%mm3
pfadd %mm3,%mm2
movd %mm2,44(%eax)
psrlq $32,%mm2
movd %mm2,52(%eax)
psrlq $32,%mm3
movd 60(%eax),%mm4
punpckldq %mm4,%mm3
punpckldq 68(%eax),%mm4
pfadd %mm4,%mm3
movd %mm3,60(%eax)
psrlq $32,%mm3
movd %mm3,68(%eax)
movq 24(%eax),%mm0
movq 48(%eax),%mm1
movd ASM_NAME(COS9)+12,%mm2
punpckldq %mm2,%mm2
movd ASM_NAME(COS9)+24,%mm3
punpckldq %mm3,%mm3
pfmul %mm2,%mm0
pfmul %mm3,%mm1
pushl %eax
movl $1,%eax
movd %eax,%mm7
pi2fd %mm7,%mm7
popl %eax
movq 8(%eax),%mm2
movd ASM_NAME(COS9)+4,%mm3
punpckldq %mm3,%mm3
pfmul %mm3,%mm2
pfadd %mm0,%mm2
movq 40(%eax),%mm3
movd ASM_NAME(COS9)+20,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
pfadd %mm3,%mm2
movq 56(%eax),%mm3
movd ASM_NAME(COS9)+28,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
pfadd %mm3,%mm2
movq (%eax),%mm3
movq 16(%eax),%mm4
movd ASM_NAME(COS9)+8,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfadd %mm4,%mm3
movq 32(%eax),%mm4
movd ASM_NAME(COS9)+16,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfadd %mm4,%mm3
pfadd %mm1,%mm3
movq 64(%eax),%mm4
movd ASM_NAME(COS9)+32,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfadd %mm4,%mm3
movq %mm2,%mm4
pfadd %mm3,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+0,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 108(%edx),%mm6
punpckldq 104(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,36(%ecx)
psrlq $32,%mm5
movd %mm5,32(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 32(%edx),%mm6
punpckldq 36(%edx),%mm6
pfmul %mm6,%mm5
movd 32(%esi),%mm6
punpckldq 36(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,1024(%ebx)
psrlq $32,%mm5
movd %mm5,1152(%ebx)
movq %mm3,%mm4
pfsub %mm2,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+32,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 140(%edx),%mm6
punpckldq 72(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,68(%ecx)
psrlq $32,%mm5
movd %mm5,0(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 0(%edx),%mm6
punpckldq 68(%edx),%mm6
pfmul %mm6,%mm5
movd 0(%esi),%mm6
punpckldq 68(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,0(%ebx)
psrlq $32,%mm5
movd %mm5,2176(%ebx)
movq 8(%eax),%mm2
movq 40(%eax),%mm3
pfsub %mm3,%mm2
movq 56(%eax),%mm3
pfsub %mm3,%mm2
movd ASM_NAME(COS9)+12,%mm3
punpckldq %mm3,%mm3
pfmul %mm3,%mm2
movq 16(%eax),%mm3
movq 32(%eax),%mm4
pfsub %mm4,%mm3
movq 64(%eax),%mm4
pfsub %mm4,%mm3
movd ASM_NAME(COS9)+24,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
movq 48(%eax),%mm4
pfsub %mm4,%mm3
movq (%eax),%mm4
pfadd %mm4,%mm3
movq %mm2,%mm4
pfadd %mm3,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+4,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 112(%edx),%mm6
punpckldq 100(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,40(%ecx)
psrlq $32,%mm5
movd %mm5,28(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 28(%edx),%mm6
punpckldq 40(%edx),%mm6
pfmul %mm6,%mm5
movd 28(%esi),%mm6
punpckldq 40(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,896(%ebx)
psrlq $32,%mm5
movd %mm5,1280(%ebx)
movq %mm3,%mm4
pfsub %mm2,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+28,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 136(%edx),%mm6
punpckldq 76(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,64(%ecx)
psrlq $32,%mm5
movd %mm5,4(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 4(%edx),%mm6
punpckldq 64(%edx),%mm6
pfmul %mm6,%mm5
movd 4(%esi),%mm6
punpckldq 64(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,128(%ebx)
psrlq $32,%mm5
movd %mm5,2048(%ebx)
movq 8(%eax),%mm2
movd ASM_NAME(COS9)+20,%mm3
punpckldq %mm3,%mm3
pfmul %mm3,%mm2
pfsub %mm0,%mm2
movq 40(%eax),%mm3
movd ASM_NAME(COS9)+28,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
pfsub %mm3,%mm2
movq 56(%eax),%mm3
movd ASM_NAME(COS9)+4,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
pfadd %mm3,%mm2
movq (%eax),%mm3
movq 16(%eax),%mm4
movd ASM_NAME(COS9)+32,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfsub %mm4,%mm3
movq 32(%eax),%mm4
movd ASM_NAME(COS9)+8,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfsub %mm4,%mm3
pfadd %mm1,%mm3
movq 64(%eax),%mm4
movd ASM_NAME(COS9)+16,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfadd %mm4,%mm3
movq %mm2,%mm4
pfadd %mm3,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+8,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 116(%edx),%mm6
punpckldq 96(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,44(%ecx)
psrlq $32,%mm5
movd %mm5,24(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 24(%edx),%mm6
punpckldq 44(%edx),%mm6
pfmul %mm6,%mm5
movd 24(%esi),%mm6
punpckldq 44(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,768(%ebx)
psrlq $32,%mm5
movd %mm5,1408(%ebx)
movq %mm3,%mm4
pfsub %mm2,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+24,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 132(%edx),%mm6
punpckldq 80(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,60(%ecx)
psrlq $32,%mm5
movd %mm5,8(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 8(%edx),%mm6
punpckldq 60(%edx),%mm6
pfmul %mm6,%mm5
movd 8(%esi),%mm6
punpckldq 60(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,256(%ebx)
psrlq $32,%mm5
movd %mm5,1920(%ebx)
movq 8(%eax),%mm2
movd ASM_NAME(COS9)+28,%mm3
punpckldq %mm3,%mm3
pfmul %mm3,%mm2
pfsub %mm0,%mm2
movq 40(%eax),%mm3
movd ASM_NAME(COS9)+4,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
pfadd %mm3,%mm2
movq 56(%eax),%mm3
movd ASM_NAME(COS9)+20,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
pfsub %mm3,%mm2
movq (%eax),%mm3
movq 16(%eax),%mm4
movd ASM_NAME(COS9)+16,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfsub %mm4,%mm3
movq 32(%eax),%mm4
movd ASM_NAME(COS9)+32,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfadd %mm4,%mm3
pfadd %mm1,%mm3
movq 64(%eax),%mm4
movd ASM_NAME(COS9)+8,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfsub %mm4,%mm3
movq %mm2,%mm4
pfadd %mm3,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+12,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 120(%edx),%mm6
punpckldq 92(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,48(%ecx)
psrlq $32,%mm5
movd %mm5,20(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 20(%edx),%mm6
punpckldq 48(%edx),%mm6
pfmul %mm6,%mm5
movd 20(%esi),%mm6
punpckldq 48(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,640(%ebx)
psrlq $32,%mm5
movd %mm5,1536(%ebx)
movq %mm3,%mm4
pfsub %mm2,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+20,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 128(%edx),%mm6
punpckldq 84(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,56(%ecx)
psrlq $32,%mm5
movd %mm5,12(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 12(%edx),%mm6
punpckldq 56(%edx),%mm6
pfmul %mm6,%mm5
movd 12(%esi),%mm6
punpckldq 56(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,384(%ebx)
psrlq $32,%mm5
movd %mm5,1792(%ebx)
movq (%eax),%mm4
movq 16(%eax),%mm3
pfsub %mm3,%mm4
movq 32(%eax),%mm3
pfadd %mm3,%mm4
movq 48(%eax),%mm3
pfsub %mm3,%mm4
movq 64(%eax),%mm3
pfadd %mm3,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+16,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 124(%edx),%mm6
punpckldq 88(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,52(%ecx)
psrlq $32,%mm5
movd %mm5,16(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 16(%edx),%mm6
punpckldq 52(%edx),%mm6
pfmul %mm6,%mm5
movd 16(%esi),%mm6
punpckldq 52(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,512(%ebx)
psrlq $32,%mm5
movd %mm5,1664(%ebx)
femms
popl %ebx
popl %esi
movl %ebp,%esp
popl %ebp
ret

View File

@@ -1,510 +0,0 @@
/*
dct36_3dnowext: extended 3DNow optimized DCT36
copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
Transformed back into standalone asm, with help of
gcc -S -DHAVE_CONFIG_H -I. -march=k6-3 -O3 -Wall -pedantic -fno-strict-aliasing -DREAL_IS_FLOAT -c -o dct36_3dnowext.{S,c}
MPlayer comment follows.
*/
/*
* dct36_3dnow.c - 3DNow! optimized dct36()
*
* This code based 'dct36_3dnow.s' by Syuuhei Kashiyama
* <squash@mb.kcom.ne.jp>, only two types of changes have been made:
*
* - removed PREFETCH instruction for speedup
* - changed function name for support 3DNow! automatic detection
*
* You can find Kashiyama's original 3dnow! support patch
* (for mpg123-0.59o) at
* http://user.ecc.u-tokyo.ac.jp/~g810370/linux-simd/ (Japanese).
*
* by KIMURA Takuhiro <kim@hannah.ipc.miyakyo-u.ac.jp> - until 31.Mar.1999
* <kim@comtec.co.jp> - after 1.Apr.1999
*
* Modified for use with MPlayer, for details see the changelog at
* http://svn.mplayerhq.hu/mplayer/trunk/
* $Id: dct36_3dnow.c 18786 2006-06-22 13:34:00Z diego $
*
* Original disclaimer:
* The author of this program disclaim whole expressed or implied
* warranties with regard to this program, and in no event shall the
* author of this program liable to whatever resulted from the use of
* this program. Use it at your own risk.
*
* 2003/06/21: Moved to GCC inline assembly - Alex Beregszaszi
*/
#include "mangle.h"
.text
ALIGN32,,31
.globl ASM_NAME(dct36_3dnowext)
/* .type ASM_NAME(dct36_3dnowext), @function */
ASM_NAME(dct36_3dnowext):
pushl %ebp
movl %esp, %ebp
pushl %esi
pushl %ebx
movl 8(%ebp), %eax
movl 12(%ebp), %esi
movl 16(%ebp), %ecx
movl 20(%ebp), %edx
movl 24(%ebp), %ebx
#APP
movq (%eax),%mm0
movq 4(%eax),%mm1
pfadd %mm1,%mm0
movq %mm0,4(%eax)
psrlq $32,%mm1
movq 12(%eax),%mm2
punpckldq %mm2,%mm1
pfadd %mm2,%mm1
movq %mm1,12(%eax)
psrlq $32,%mm2
movq 20(%eax),%mm3
punpckldq %mm3,%mm2
pfadd %mm3,%mm2
movq %mm2,20(%eax)
psrlq $32,%mm3
movq 28(%eax),%mm4
punpckldq %mm4,%mm3
pfadd %mm4,%mm3
movq %mm3,28(%eax)
psrlq $32,%mm4
movq 36(%eax),%mm5
punpckldq %mm5,%mm4
pfadd %mm5,%mm4
movq %mm4,36(%eax)
psrlq $32,%mm5
movq 44(%eax),%mm6
punpckldq %mm6,%mm5
pfadd %mm6,%mm5
movq %mm5,44(%eax)
psrlq $32,%mm6
movq 52(%eax),%mm7
punpckldq %mm7,%mm6
pfadd %mm7,%mm6
movq %mm6,52(%eax)
psrlq $32,%mm7
movq 60(%eax),%mm0
punpckldq %mm0,%mm7
pfadd %mm0,%mm7
movq %mm7,60(%eax)
psrlq $32,%mm0
movd 68(%eax),%mm1
pfadd %mm1,%mm0
movd %mm0,68(%eax)
movd 4(%eax),%mm0
movd 12(%eax),%mm1
punpckldq %mm1,%mm0
punpckldq 20(%eax),%mm1
pfadd %mm1,%mm0
movd %mm0,12(%eax)
psrlq $32,%mm0
movd %mm0,20(%eax)
psrlq $32,%mm1
movd 28(%eax),%mm2
punpckldq %mm2,%mm1
punpckldq 36(%eax),%mm2
pfadd %mm2,%mm1
movd %mm1,28(%eax)
psrlq $32,%mm1
movd %mm1,36(%eax)
psrlq $32,%mm2
movd 44(%eax),%mm3
punpckldq %mm3,%mm2
punpckldq 52(%eax),%mm3
pfadd %mm3,%mm2
movd %mm2,44(%eax)
psrlq $32,%mm2
movd %mm2,52(%eax)
psrlq $32,%mm3
movd 60(%eax),%mm4
punpckldq %mm4,%mm3
punpckldq 68(%eax),%mm4
pfadd %mm4,%mm3
movd %mm3,60(%eax)
psrlq $32,%mm3
movd %mm3,68(%eax)
movq 24(%eax),%mm0
movq 48(%eax),%mm1
movd ASM_NAME(COS9)+12,%mm2
punpckldq %mm2,%mm2
movd ASM_NAME(COS9)+24,%mm3
punpckldq %mm3,%mm3
pfmul %mm2,%mm0
pfmul %mm3,%mm1
pushl %eax
movl $1,%eax
movd %eax,%mm7
pi2fd %mm7,%mm7
popl %eax
movq 8(%eax),%mm2
movd ASM_NAME(COS9)+4,%mm3
punpckldq %mm3,%mm3
pfmul %mm3,%mm2
pfadd %mm0,%mm2
movq 40(%eax),%mm3
movd ASM_NAME(COS9)+20,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
pfadd %mm3,%mm2
movq 56(%eax),%mm3
movd ASM_NAME(COS9)+28,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
pfadd %mm3,%mm2
movq (%eax),%mm3
movq 16(%eax),%mm4
movd ASM_NAME(COS9)+8,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfadd %mm4,%mm3
movq 32(%eax),%mm4
movd ASM_NAME(COS9)+16,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfadd %mm4,%mm3
pfadd %mm1,%mm3
movq 64(%eax),%mm4
movd ASM_NAME(COS9)+32,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfadd %mm4,%mm3
movq %mm2,%mm4
pfadd %mm3,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+0,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 108(%edx),%mm6
punpckldq 104(%edx),%mm6
pfmul %mm6,%mm5
pswapd %mm5,%mm5
movq %mm5,32(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 32(%edx),%mm6
punpckldq 36(%edx),%mm6
pfmul %mm6,%mm5
movd 32(%esi),%mm6
punpckldq 36(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,1024(%ebx)
psrlq $32,%mm5
movd %mm5,1152(%ebx)
movq %mm3,%mm4
pfsub %mm2,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+32,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 140(%edx),%mm6
punpckldq 72(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,68(%ecx)
psrlq $32,%mm5
movd %mm5,0(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 0(%edx),%mm6
punpckldq 68(%edx),%mm6
pfmul %mm6,%mm5
movd 0(%esi),%mm6
punpckldq 68(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,0(%ebx)
psrlq $32,%mm5
movd %mm5,2176(%ebx)
movq 8(%eax),%mm2
movq 40(%eax),%mm3
pfsub %mm3,%mm2
movq 56(%eax),%mm3
pfsub %mm3,%mm2
movd ASM_NAME(COS9)+12,%mm3
punpckldq %mm3,%mm3
pfmul %mm3,%mm2
movq 16(%eax),%mm3
movq 32(%eax),%mm4
pfsub %mm4,%mm3
movq 64(%eax),%mm4
pfsub %mm4,%mm3
movd ASM_NAME(COS9)+24,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
movq 48(%eax),%mm4
pfsub %mm4,%mm3
movq (%eax),%mm4
pfadd %mm4,%mm3
movq %mm2,%mm4
pfadd %mm3,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+4,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 112(%edx),%mm6
punpckldq 100(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,40(%ecx)
psrlq $32,%mm5
movd %mm5,28(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 28(%edx),%mm6
punpckldq 40(%edx),%mm6
pfmul %mm6,%mm5
movd 28(%esi),%mm6
punpckldq 40(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,896(%ebx)
psrlq $32,%mm5
movd %mm5,1280(%ebx)
movq %mm3,%mm4
pfsub %mm2,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+28,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 136(%edx),%mm6
punpckldq 76(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,64(%ecx)
psrlq $32,%mm5
movd %mm5,4(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 4(%edx),%mm6
punpckldq 64(%edx),%mm6
pfmul %mm6,%mm5
movd 4(%esi),%mm6
punpckldq 64(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,128(%ebx)
psrlq $32,%mm5
movd %mm5,2048(%ebx)
movq 8(%eax),%mm2
movd ASM_NAME(COS9)+20,%mm3
punpckldq %mm3,%mm3
pfmul %mm3,%mm2
pfsub %mm0,%mm2
movq 40(%eax),%mm3
movd ASM_NAME(COS9)+28,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
pfsub %mm3,%mm2
movq 56(%eax),%mm3
movd ASM_NAME(COS9)+4,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
pfadd %mm3,%mm2
movq (%eax),%mm3
movq 16(%eax),%mm4
movd ASM_NAME(COS9)+32,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfsub %mm4,%mm3
movq 32(%eax),%mm4
movd ASM_NAME(COS9)+8,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfsub %mm4,%mm3
pfadd %mm1,%mm3
movq 64(%eax),%mm4
movd ASM_NAME(COS9)+16,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfadd %mm4,%mm3
movq %mm2,%mm4
pfadd %mm3,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+8,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 116(%edx),%mm6
punpckldq 96(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,44(%ecx)
psrlq $32,%mm5
movd %mm5,24(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 24(%edx),%mm6
punpckldq 44(%edx),%mm6
pfmul %mm6,%mm5
movd 24(%esi),%mm6
punpckldq 44(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,768(%ebx)
psrlq $32,%mm5
movd %mm5,1408(%ebx)
movq %mm3,%mm4
pfsub %mm2,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+24,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 132(%edx),%mm6
punpckldq 80(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,60(%ecx)
psrlq $32,%mm5
movd %mm5,8(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 8(%edx),%mm6
punpckldq 60(%edx),%mm6
pfmul %mm6,%mm5
movd 8(%esi),%mm6
punpckldq 60(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,256(%ebx)
psrlq $32,%mm5
movd %mm5,1920(%ebx)
movq 8(%eax),%mm2
movd ASM_NAME(COS9)+28,%mm3
punpckldq %mm3,%mm3
pfmul %mm3,%mm2
pfsub %mm0,%mm2
movq 40(%eax),%mm3
movd ASM_NAME(COS9)+4,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
pfadd %mm3,%mm2
movq 56(%eax),%mm3
movd ASM_NAME(COS9)+20,%mm4
punpckldq %mm4,%mm4
pfmul %mm4,%mm3
pfsub %mm3,%mm2
movq (%eax),%mm3
movq 16(%eax),%mm4
movd ASM_NAME(COS9)+16,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfsub %mm4,%mm3
movq 32(%eax),%mm4
movd ASM_NAME(COS9)+32,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfadd %mm4,%mm3
pfadd %mm1,%mm3
movq 64(%eax),%mm4
movd ASM_NAME(COS9)+8,%mm5
punpckldq %mm5,%mm5
pfmul %mm5,%mm4
pfsub %mm4,%mm3
movq %mm2,%mm4
pfadd %mm3,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+12,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 120(%edx),%mm6
punpckldq 92(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,48(%ecx)
psrlq $32,%mm5
movd %mm5,20(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 20(%edx),%mm6
punpckldq 48(%edx),%mm6
pfmul %mm6,%mm5
movd 20(%esi),%mm6
punpckldq 48(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,640(%ebx)
psrlq $32,%mm5
movd %mm5,1536(%ebx)
movq %mm3,%mm4
pfsub %mm2,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+20,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 128(%edx),%mm6
punpckldq 84(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,56(%ecx)
psrlq $32,%mm5
movd %mm5,12(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 12(%edx),%mm6
punpckldq 56(%edx),%mm6
pfmul %mm6,%mm5
movd 12(%esi),%mm6
punpckldq 56(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,384(%ebx)
psrlq $32,%mm5
movd %mm5,1792(%ebx)
movq (%eax),%mm4
movq 16(%eax),%mm3
pfsub %mm3,%mm4
movq 32(%eax),%mm3
pfadd %mm3,%mm4
movq 48(%eax),%mm3
pfsub %mm3,%mm4
movq 64(%eax),%mm3
pfadd %mm3,%mm4
movq %mm7,%mm5
punpckldq ASM_NAME(tfcos36)+16,%mm5
pfmul %mm5,%mm4
movq %mm4,%mm5
pfacc %mm5,%mm5
movd 124(%edx),%mm6
punpckldq 88(%edx),%mm6
pfmul %mm6,%mm5
movd %mm5,52(%ecx)
psrlq $32,%mm5
movd %mm5,16(%ecx)
movq %mm4,%mm6
punpckldq %mm6,%mm5
pfsub %mm6,%mm5
punpckhdq %mm5,%mm5
movd 16(%edx),%mm6
punpckldq 52(%edx),%mm6
pfmul %mm6,%mm5
movd 16(%esi),%mm6
punpckldq 52(%esi),%mm6
pfadd %mm6,%mm5
movd %mm5,512(%ebx)
psrlq $32,%mm5
movd %mm5,1664(%ebx)
femms
#NO_APP
popl %ebx
popl %esi
leave
ret
/* .size ASM_NAME(dct36_3dnowext), .-ASM_NAME(dct36_3dnowext) */

View File

@@ -1,174 +0,0 @@
/*
dct64.c: DCT64, the plain C version
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.org
initially written by Michael Hipp
*/
/*
* Discrete Cosine Tansform (DCT) for subband synthesis
*
* -funroll-loops (for gcc) will remove the loops for better performance
* using loops in the source-code enhances readabillity
*
*
* TODO: write an optimized version for the down-sampling modes
* (in these modes the bands 16-31 (2:1) or 8-31 (4:1) are zero
*/
#include "mpg123.h"
void dct64(real *out0,real *out1,real *samples)
{
real bufs[64];
{
register int i,j;
register real *b1,*b2,*bs,*costab;
b1 = samples;
bs = bufs;
costab = pnts[0]+16;
b2 = b1 + 32;
for(i=15;i>=0;i--)
*bs++ = (*b1++ + *--b2);
for(i=15;i>=0;i--)
*bs++ = REAL_MUL((*--b2 - *b1++), *--costab);
b1 = bufs;
costab = pnts[1]+8;
b2 = b1 + 16;
{
for(i=7;i>=0;i--)
*bs++ = (*b1++ + *--b2);
for(i=7;i>=0;i--)
*bs++ = REAL_MUL((*--b2 - *b1++), *--costab);
b2 += 32;
costab += 8;
for(i=7;i>=0;i--)
*bs++ = (*b1++ + *--b2);
for(i=7;i>=0;i--)
*bs++ = REAL_MUL((*b1++ - *--b2), *--costab);
b2 += 32;
}
bs = bufs;
costab = pnts[2];
b2 = b1 + 8;
for(j=2;j;j--)
{
for(i=3;i>=0;i--)
*bs++ = (*b1++ + *--b2);
for(i=3;i>=0;i--)
*bs++ = REAL_MUL((*--b2 - *b1++), costab[i]);
b2 += 16;
for(i=3;i>=0;i--)
*bs++ = (*b1++ + *--b2);
for(i=3;i>=0;i--)
*bs++ = REAL_MUL((*b1++ - *--b2), costab[i]);
b2 += 16;
}
b1 = bufs;
costab = pnts[3];
b2 = b1 + 4;
for(j=4;j;j--)
{
*bs++ = (*b1++ + *--b2);
*bs++ = (*b1++ + *--b2);
*bs++ = REAL_MUL((*--b2 - *b1++), costab[1]);
*bs++ = REAL_MUL((*--b2 - *b1++), costab[0]);
b2 += 8;
*bs++ = (*b1++ + *--b2);
*bs++ = (*b1++ + *--b2);
*bs++ = REAL_MUL((*b1++ - *--b2), costab[1]);
*bs++ = REAL_MUL((*b1++ - *--b2), costab[0]);
b2 += 8;
}
bs = bufs;
costab = pnts[4];
for(j=8;j;j--)
{
real v0,v1;
v0=*b1++; v1 = *b1++;
*bs++ = (v0 + v1);
*bs++ = REAL_MUL((v0 - v1), (*costab));
v0=*b1++; v1 = *b1++;
*bs++ = (v0 + v1);
*bs++ = REAL_MUL((v1 - v0), (*costab));
}
}
{
register real *b1;
register int i;
for(b1=bufs,i=8;i;i--,b1+=4)
b1[2] += b1[3];
for(b1=bufs,i=4;i;i--,b1+=8)
{
b1[4] += b1[6];
b1[6] += b1[5];
b1[5] += b1[7];
}
for(b1=bufs,i=2;i;i--,b1+=16)
{
b1[8] += b1[12];
b1[12] += b1[10];
b1[10] += b1[14];
b1[14] += b1[9];
b1[9] += b1[13];
b1[13] += b1[11];
b1[11] += b1[15];
}
}
out0[0x10*16] = bufs[0];
out0[0x10*15] = bufs[16+0] + bufs[16+8];
out0[0x10*14] = bufs[8];
out0[0x10*13] = bufs[16+8] + bufs[16+4];
out0[0x10*12] = bufs[4];
out0[0x10*11] = bufs[16+4] + bufs[16+12];
out0[0x10*10] = bufs[12];
out0[0x10* 9] = bufs[16+12] + bufs[16+2];
out0[0x10* 8] = bufs[2];
out0[0x10* 7] = bufs[16+2] + bufs[16+10];
out0[0x10* 6] = bufs[10];
out0[0x10* 5] = bufs[16+10] + bufs[16+6];
out0[0x10* 4] = bufs[6];
out0[0x10* 3] = bufs[16+6] + bufs[16+14];
out0[0x10* 2] = bufs[14];
out0[0x10* 1] = bufs[16+14] + bufs[16+1];
out0[0x10* 0] = bufs[1];
out1[0x10* 0] = bufs[1];
out1[0x10* 1] = bufs[16+1] + bufs[16+9];
out1[0x10* 2] = bufs[9];
out1[0x10* 3] = bufs[16+9] + bufs[16+5];
out1[0x10* 4] = bufs[5];
out1[0x10* 5] = bufs[16+5] + bufs[16+13];
out1[0x10* 6] = bufs[13];
out1[0x10* 7] = bufs[16+13] + bufs[16+3];
out1[0x10* 8] = bufs[3];
out1[0x10* 9] = bufs[16+3] + bufs[16+11];
out1[0x10*10] = bufs[11];
out1[0x10*11] = bufs[16+11] + bufs[16+7];
out1[0x10*12] = bufs[7];
out1[0x10*13] = bufs[16+7] + bufs[16+15];
out1[0x10*14] = bufs[15];
out1[0x10*15] = bufs[16+15];
}

View File

@@ -1,711 +0,0 @@
/*
dct64_3dnow.s: Replacement of dct64() with AMD's 3DNow! SIMD operations 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.org
initially written by Syuuhei Kashiyama
Original "license" statement:
The author of this program disclaim whole expressed or implied
warranties with regard to this program, and in no event shall the
author of this program liable to whatever resulted from the use of
this program. Use it at your own risk.
*/
#include "mangle.h"
.globl ASM_NAME(dct64_3dnow)
/* .type ASM_NAME(dct64_3dnow),@function */
ASM_NAME(dct64_3dnow):
subl $256,%esp
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
leal 16(%esp),%ebx
movl 284(%esp),%edi
movl 276(%esp),%ebp
movl 280(%esp),%edx
leal 128(%ebx),%esi
/* femms */
/* 1 */
movl ASM_NAME(pnts),%eax
movq 0(%edi),%mm0
movq %mm0,%mm1
movd 124(%edi),%mm2
punpckldq 120(%edi),%mm2
movq 0(%eax),%mm3
pfadd %mm2,%mm0
movq %mm0,0(%ebx)
pfsub %mm2,%mm1
pfmul %mm3,%mm1
movd %mm1,124(%ebx)
psrlq $32,%mm1
movd %mm1,120(%ebx)
movq 8(%edi),%mm4
movq %mm4,%mm5
movd 116(%edi),%mm6
punpckldq 112(%edi),%mm6
movq 8(%eax),%mm7
pfadd %mm6,%mm4
movq %mm4,8(%ebx)
pfsub %mm6,%mm5
pfmul %mm7,%mm5
movd %mm5,116(%ebx)
psrlq $32,%mm5
movd %mm5,112(%ebx)
movq 16(%edi),%mm0
movq %mm0,%mm1
movd 108(%edi),%mm2
punpckldq 104(%edi),%mm2
movq 16(%eax),%mm3
pfadd %mm2,%mm0
movq %mm0,16(%ebx)
pfsub %mm2,%mm1
pfmul %mm3,%mm1
movd %mm1,108(%ebx)
psrlq $32,%mm1
movd %mm1,104(%ebx)
movq 24(%edi),%mm4
movq %mm4,%mm5
movd 100(%edi),%mm6
punpckldq 96(%edi),%mm6
movq 24(%eax),%mm7
pfadd %mm6,%mm4
movq %mm4,24(%ebx)
pfsub %mm6,%mm5
pfmul %mm7,%mm5
movd %mm5,100(%ebx)
psrlq $32,%mm5
movd %mm5,96(%ebx)
movq 32(%edi),%mm0
movq %mm0,%mm1
movd 92(%edi),%mm2
punpckldq 88(%edi),%mm2
movq 32(%eax),%mm3
pfadd %mm2,%mm0
movq %mm0,32(%ebx)
pfsub %mm2,%mm1
pfmul %mm3,%mm1
movd %mm1,92(%ebx)
psrlq $32,%mm1
movd %mm1,88(%ebx)
movq 40(%edi),%mm4
movq %mm4,%mm5
movd 84(%edi),%mm6
punpckldq 80(%edi),%mm6
movq 40(%eax),%mm7
pfadd %mm6,%mm4
movq %mm4,40(%ebx)
pfsub %mm6,%mm5
pfmul %mm7,%mm5
movd %mm5,84(%ebx)
psrlq $32,%mm5
movd %mm5,80(%ebx)
movq 48(%edi),%mm0
movq %mm0,%mm1
movd 76(%edi),%mm2
punpckldq 72(%edi),%mm2
movq 48(%eax),%mm3
pfadd %mm2,%mm0
movq %mm0,48(%ebx)
pfsub %mm2,%mm1
pfmul %mm3,%mm1
movd %mm1,76(%ebx)
psrlq $32,%mm1
movd %mm1,72(%ebx)
movq 56(%edi),%mm4
movq %mm4,%mm5
movd 68(%edi),%mm6
punpckldq 64(%edi),%mm6
movq 56(%eax),%mm7
pfadd %mm6,%mm4
movq %mm4,56(%ebx)
pfsub %mm6,%mm5
pfmul %mm7,%mm5
movd %mm5,68(%ebx)
psrlq $32,%mm5
movd %mm5,64(%ebx)
/* 2 */
movl ASM_NAME(pnts)+4,%eax
/* 0,14 */
movq 0(%ebx),%mm0
movq %mm0,%mm1
movd 60(%ebx),%mm2
punpckldq 56(%ebx),%mm2
movq 0(%eax),%mm3
pfadd %mm2,%mm0
movq %mm0,0(%esi)
pfsub %mm2,%mm1
pfmul %mm3,%mm1
movd %mm1,60(%esi)
psrlq $32,%mm1
movd %mm1,56(%esi)
/* 16,30 */
movq 64(%ebx),%mm0
movq %mm0,%mm1
movd 124(%ebx),%mm2
punpckldq 120(%ebx),%mm2
pfadd %mm2,%mm0
movq %mm0,64(%esi)
pfsubr %mm2,%mm1
pfmul %mm3,%mm1
movd %mm1,124(%esi)
psrlq $32,%mm1
movd %mm1,120(%esi)
/* 2,12 */
movq 8(%ebx),%mm4
movq %mm4,%mm5
movd 52(%ebx),%mm6
punpckldq 48(%ebx),%mm6
movq 8(%eax),%mm7
pfadd %mm6,%mm4
movq %mm4,8(%esi)
pfsub %mm6,%mm5
pfmul %mm7,%mm5
movd %mm5,52(%esi)
psrlq $32,%mm5
movd %mm5,48(%esi)
/* 18,28 */
movq 72(%ebx),%mm4
movq %mm4,%mm5
movd 116(%ebx),%mm6
punpckldq 112(%ebx),%mm6
pfadd %mm6,%mm4
movq %mm4,72(%esi)
pfsubr %mm6,%mm5
pfmul %mm7,%mm5
movd %mm5,116(%esi)
psrlq $32,%mm5
movd %mm5,112(%esi)
/* 4,10 */
movq 16(%ebx),%mm0
movq %mm0,%mm1
movd 44(%ebx),%mm2
punpckldq 40(%ebx),%mm2
movq 16(%eax),%mm3
pfadd %mm2,%mm0
movq %mm0,16(%esi)
pfsub %mm2,%mm1
pfmul %mm3,%mm1
movd %mm1,44(%esi)
psrlq $32,%mm1
movd %mm1,40(%esi)
/* 20,26 */
movq 80(%ebx),%mm0
movq %mm0,%mm1
movd 108(%ebx),%mm2
punpckldq 104(%ebx),%mm2
pfadd %mm2,%mm0
movq %mm0,80(%esi)
pfsubr %mm2,%mm1
pfmul %mm3,%mm1
movd %mm1,108(%esi)
psrlq $32,%mm1
movd %mm1,104(%esi)
/* 6,8 */
movq 24(%ebx),%mm4
movq %mm4,%mm5
movd 36(%ebx),%mm6
punpckldq 32(%ebx),%mm6
movq 24(%eax),%mm7
pfadd %mm6,%mm4
movq %mm4,24(%esi)
pfsub %mm6,%mm5
pfmul %mm7,%mm5
movd %mm5,36(%esi)
psrlq $32,%mm5
movd %mm5,32(%esi)
/* 22,24 */
movq 88(%ebx),%mm4
movq %mm4,%mm5
movd 100(%ebx),%mm6
punpckldq 96(%ebx),%mm6
pfadd %mm6,%mm4
movq %mm4,88(%esi)
pfsubr %mm6,%mm5
pfmul %mm7,%mm5
movd %mm5,100(%esi)
psrlq $32,%mm5
movd %mm5,96(%esi)
/* 3 */
movl ASM_NAME(pnts)+8,%eax
movq 0(%eax),%mm0
movq 8(%eax),%mm1
/* 0,6 */
movq 0(%esi),%mm2
movq %mm2,%mm3
movd 28(%esi),%mm4
punpckldq 24(%esi),%mm4
pfadd %mm4,%mm2
pfsub %mm4,%mm3
pfmul %mm0,%mm3
movq %mm2,0(%ebx)
movd %mm3,28(%ebx)
psrlq $32,%mm3
movd %mm3,24(%ebx)
/* 2,4 */
movq 8(%esi),%mm5
movq %mm5,%mm6
movd 20(%esi),%mm7
punpckldq 16(%esi),%mm7
pfadd %mm7,%mm5
pfsub %mm7,%mm6
pfmul %mm1,%mm6
movq %mm5,8(%ebx)
movd %mm6,20(%ebx)
psrlq $32,%mm6
movd %mm6,16(%ebx)
/* 8,14 */
movq 32(%esi),%mm2
movq %mm2,%mm3
movd 60(%esi),%mm4
punpckldq 56(%esi),%mm4
pfadd %mm4,%mm2
pfsubr %mm4,%mm3
pfmul %mm0,%mm3
movq %mm2,32(%ebx)
movd %mm3,60(%ebx)
psrlq $32,%mm3
movd %mm3,56(%ebx)
/* 10,12 */
movq 40(%esi),%mm5
movq %mm5,%mm6
movd 52(%esi),%mm7
punpckldq 48(%esi),%mm7
pfadd %mm7,%mm5
pfsubr %mm7,%mm6
pfmul %mm1,%mm6
movq %mm5,40(%ebx)
movd %mm6,52(%ebx)
psrlq $32,%mm6
movd %mm6,48(%ebx)
/* 16,22 */
movq 64(%esi),%mm2
movq %mm2,%mm3
movd 92(%esi),%mm4
punpckldq 88(%esi),%mm4
pfadd %mm4,%mm2
pfsub %mm4,%mm3
pfmul %mm0,%mm3
movq %mm2,64(%ebx)
movd %mm3,92(%ebx)
psrlq $32,%mm3
movd %mm3,88(%ebx)
/* 18,20 */
movq 72(%esi),%mm5
movq %mm5,%mm6
movd 84(%esi),%mm7
punpckldq 80(%esi),%mm7
pfadd %mm7,%mm5
pfsub %mm7,%mm6
pfmul %mm1,%mm6
movq %mm5,72(%ebx)
movd %mm6,84(%ebx)
psrlq $32,%mm6
movd %mm6,80(%ebx)
/* 24,30 */
movq 96(%esi),%mm2
movq %mm2,%mm3
movd 124(%esi),%mm4
punpckldq 120(%esi),%mm4
pfadd %mm4,%mm2
pfsubr %mm4,%mm3
pfmul %mm0,%mm3
movq %mm2,96(%ebx)
movd %mm3,124(%ebx)
psrlq $32,%mm3
movd %mm3,120(%ebx)
/* 26,28 */
movq 104(%esi),%mm5
movq %mm5,%mm6
movd 116(%esi),%mm7
punpckldq 112(%esi),%mm7
pfadd %mm7,%mm5
pfsubr %mm7,%mm6
pfmul %mm1,%mm6
movq %mm5,104(%ebx)
movd %mm6,116(%ebx)
psrlq $32,%mm6
movd %mm6,112(%ebx)
/* 4 */
movl ASM_NAME(pnts)+12,%eax
movq 0(%eax),%mm0
/* 0 */
movq 0(%ebx),%mm1
movq %mm1,%mm2
movd 12(%ebx),%mm3
punpckldq 8(%ebx),%mm3
pfadd %mm3,%mm1
pfsub %mm3,%mm2
pfmul %mm0,%mm2
movq %mm1,0(%esi)
movd %mm2,12(%esi)
psrlq $32,%mm2
movd %mm2,8(%esi)
/* 4 */
movq 16(%ebx),%mm4
movq %mm4,%mm5
movd 28(%ebx),%mm6
punpckldq 24(%ebx),%mm6
pfadd %mm6,%mm4
pfsubr %mm6,%mm5
pfmul %mm0,%mm5
movq %mm4,16(%esi)
movd %mm5,28(%esi)
psrlq $32,%mm5
movd %mm5,24(%esi)
/* 8 */
movq 32(%ebx),%mm1
movq %mm1,%mm2
movd 44(%ebx),%mm3
punpckldq 40(%ebx),%mm3
pfadd %mm3,%mm1
pfsub %mm3,%mm2
pfmul %mm0,%mm2
movq %mm1,32(%esi)
movd %mm2,44(%esi)
psrlq $32,%mm2
movd %mm2,40(%esi)
/* 12 */
movq 48(%ebx),%mm4
movq %mm4,%mm5
movd 60(%ebx),%mm6
punpckldq 56(%ebx),%mm6
pfadd %mm6,%mm4
pfsubr %mm6,%mm5
pfmul %mm0,%mm5
movq %mm4,48(%esi)
movd %mm5,60(%esi)
psrlq $32,%mm5
movd %mm5,56(%esi)
/* 16 */
movq 64(%ebx),%mm1
movq %mm1,%mm2
movd 76(%ebx),%mm3
punpckldq 72(%ebx),%mm3
pfadd %mm3,%mm1
pfsub %mm3,%mm2
pfmul %mm0,%mm2
movq %mm1,64(%esi)
movd %mm2,76(%esi)
psrlq $32,%mm2
movd %mm2,72(%esi)
/* 20 */
movq 80(%ebx),%mm4
movq %mm4,%mm5
movd 92(%ebx),%mm6
punpckldq 88(%ebx),%mm6
pfadd %mm6,%mm4
pfsubr %mm6,%mm5
pfmul %mm0,%mm5
movq %mm4,80(%esi)
movd %mm5,92(%esi)
psrlq $32,%mm5
movd %mm5,88(%esi)
/* 24 */
movq 96(%ebx),%mm1
movq %mm1,%mm2
movd 108(%ebx),%mm3
punpckldq 104(%ebx),%mm3
pfadd %mm3,%mm1
pfsub %mm3,%mm2
pfmul %mm0,%mm2
movq %mm1,96(%esi)
movd %mm2,108(%esi)
psrlq $32,%mm2
movd %mm2,104(%esi)
/* 28 */
movq 112(%ebx),%mm4
movq %mm4,%mm5
movd 124(%ebx),%mm6
punpckldq 120(%ebx),%mm6
pfadd %mm6,%mm4
pfsubr %mm6,%mm5
pfmul %mm0,%mm5
movq %mm4,112(%esi)
movd %mm5,124(%esi)
psrlq $32,%mm5
movd %mm5,120(%esi)
/* 5 */
movl $-1,%eax
movd %eax,%mm1
movl $1,%eax
/* L | H */
movd %eax,%mm0
punpckldq %mm1,%mm0
/* 1.0 | -1.0 */
pi2fd %mm0,%mm0
movd %eax,%mm1
pi2fd %mm1,%mm1
movl ASM_NAME(pnts)+16,%eax
movd 0(%eax),%mm2
/* 1.0 | cos0 */
punpckldq %mm2,%mm1
/* 0 */
movq 0(%esi),%mm2
movq %mm2,%mm3
pfmul %mm0,%mm3
pfacc %mm3,%mm2
pfmul %mm1,%mm2
movq %mm2,0(%ebx)
movq 8(%esi),%mm4
movq %mm4,%mm5
pfmul %mm0,%mm5
pfacc %mm5,%mm4
pfmul %mm0,%mm4
pfmul %mm1,%mm4
movq %mm4,%mm5
psrlq $32,%mm5
pfacc %mm5,%mm4
movq %mm4,8(%ebx)
/* 4 */
movq 16(%esi),%mm2
movq %mm2,%mm3
pfmul %mm0,%mm3
pfacc %mm3,%mm2
pfmul %mm1,%mm2
movq 24(%esi),%mm4
movq %mm4,%mm5
pfmul %mm0,%mm5
pfacc %mm5,%mm4
pfmul %mm0,%mm4
pfmul %mm1,%mm4
movq %mm4,%mm5
psrlq $32,%mm5
pfacc %mm5,%mm4
movq %mm2,%mm3
psrlq $32,%mm3
pfadd %mm4,%mm2
pfadd %mm3,%mm4
movq %mm2,16(%ebx)
movq %mm4,24(%ebx)
/* 8 */
movq 32(%esi),%mm2
movq %mm2,%mm3
pfmul %mm0,%mm3
pfacc %mm3,%mm2
pfmul %mm1,%mm2
movq %mm2,32(%ebx)
movq 40(%esi),%mm4
movq %mm4,%mm5
pfmul %mm0,%mm5
pfacc %mm5,%mm4
pfmul %mm0,%mm4
pfmul %mm1,%mm4
movq %mm4,%mm5
psrlq $32,%mm5
pfacc %mm5,%mm4
movq %mm4,40(%ebx)
/* 12 */
movq 48(%esi),%mm2
movq %mm2,%mm3
pfmul %mm0,%mm3
pfacc %mm3,%mm2
pfmul %mm1,%mm2
movq 56(%esi),%mm4
movq %mm4,%mm5
pfmul %mm0,%mm5
pfacc %mm5,%mm4
pfmul %mm0,%mm4
pfmul %mm1,%mm4
movq %mm4,%mm5
psrlq $32,%mm5
pfacc %mm5,%mm4
movq %mm2,%mm3
psrlq $32,%mm3
pfadd %mm4,%mm2
pfadd %mm3,%mm4
movq %mm2,48(%ebx)
movq %mm4,56(%ebx)
/* 16 */
movq 64(%esi),%mm2
movq %mm2,%mm3
pfmul %mm0,%mm3
pfacc %mm3,%mm2
pfmul %mm1,%mm2
movq %mm2,64(%ebx)
movq 72(%esi),%mm4
movq %mm4,%mm5
pfmul %mm0,%mm5
pfacc %mm5,%mm4
pfmul %mm0,%mm4
pfmul %mm1,%mm4
movq %mm4,%mm5
psrlq $32,%mm5
pfacc %mm5,%mm4
movq %mm4,72(%ebx)
/* 20 */
movq 80(%esi),%mm2
movq %mm2,%mm3
pfmul %mm0,%mm3
pfacc %mm3,%mm2
pfmul %mm1,%mm2
movq 88(%esi),%mm4
movq %mm4,%mm5
pfmul %mm0,%mm5
pfacc %mm5,%mm4
pfmul %mm0,%mm4
pfmul %mm1,%mm4
movq %mm4,%mm5
psrlq $32,%mm5
pfacc %mm5,%mm4
movq %mm2,%mm3
psrlq $32,%mm3
pfadd %mm4,%mm2
pfadd %mm3,%mm4
movq %mm2,80(%ebx)
movq %mm4,88(%ebx)
/* 24 */
movq 96(%esi),%mm2
movq %mm2,%mm3
pfmul %mm0,%mm3
pfacc %mm3,%mm2
pfmul %mm1,%mm2
movq %mm2,96(%ebx)
movq 104(%esi),%mm4
movq %mm4,%mm5
pfmul %mm0,%mm5
pfacc %mm5,%mm4
pfmul %mm0,%mm4
pfmul %mm1,%mm4
movq %mm4,%mm5
psrlq $32,%mm5
pfacc %mm5,%mm4
movq %mm4,104(%ebx)
/* 28 */
movq 112(%esi),%mm2
movq %mm2,%mm3
pfmul %mm0,%mm3
pfacc %mm3,%mm2
pfmul %mm1,%mm2
movq 120(%esi),%mm4
movq %mm4,%mm5
pfmul %mm0,%mm5
pfacc %mm5,%mm4
pfmul %mm0,%mm4
pfmul %mm1,%mm4
movq %mm4,%mm5
psrlq $32,%mm5
pfacc %mm5,%mm4
movq %mm2,%mm3
psrlq $32,%mm3
pfadd %mm4,%mm2
pfadd %mm3,%mm4
movq %mm2,112(%ebx)
movq %mm4,120(%ebx)
/* Phase6 */
movl 0(%ebx),%eax
movl %eax,1024(%ebp)
movl 4(%ebx),%eax
movl %eax,0(%ebp)
movl %eax,0(%edx)
movl 8(%ebx),%eax
movl %eax,512(%ebp)
movl 12(%ebx),%eax
movl %eax,512(%edx)
movl 16(%ebx),%eax
movl %eax,768(%ebp)
movl 20(%ebx),%eax
movl %eax,256(%edx)
movl 24(%ebx),%eax
movl %eax,256(%ebp)
movl 28(%ebx),%eax
movl %eax,768(%edx)
movq 32(%ebx),%mm0
movq 48(%ebx),%mm1
pfadd %mm1,%mm0
movd %mm0,896(%ebp)
psrlq $32,%mm0
movd %mm0,128(%edx)
movq 40(%ebx),%mm2
pfadd %mm2,%mm1
movd %mm1,640(%ebp)
psrlq $32,%mm1
movd %mm1,384(%edx)
movq 56(%ebx),%mm3
pfadd %mm3,%mm2
movd %mm2,384(%ebp)
psrlq $32,%mm2
movd %mm2,640(%edx)
movd 36(%ebx),%mm4
pfadd %mm4,%mm3
movd %mm3,128(%ebp)
psrlq $32,%mm3
movd %mm3,896(%edx)
movq 96(%ebx),%mm0
movq 64(%ebx),%mm1
movq 112(%ebx),%mm2
pfadd %mm2,%mm0
movq %mm0,%mm3
pfadd %mm1,%mm3
movd %mm3,960(%ebp)
psrlq $32,%mm3
movd %mm3,64(%edx)
movq 80(%ebx),%mm1
pfadd %mm1,%mm0
movd %mm0,832(%ebp)
psrlq $32,%mm0
movd %mm0,192(%edx)
movq 104(%ebx),%mm3
pfadd %mm3,%mm2
movq %mm2,%mm4
pfadd %mm1,%mm4
movd %mm4,704(%ebp)
psrlq $32,%mm4
movd %mm4,320(%edx)
movq 72(%ebx),%mm1
pfadd %mm1,%mm2
movd %mm2,576(%ebp)
psrlq $32,%mm2
movd %mm2,448(%edx)
movq 120(%ebx),%mm4
pfadd %mm4,%mm3
movq %mm3,%mm5
pfadd %mm1,%mm5
movd %mm5,448(%ebp)
psrlq $32,%mm5
movd %mm5,576(%edx)
movq 88(%ebx),%mm1
pfadd %mm1,%mm3
movd %mm3,320(%ebp)
psrlq $32,%mm3
movd %mm3,704(%edx)
movd 100(%ebx),%mm5
pfadd %mm5,%mm4
movq %mm4,%mm6
pfadd %mm1,%mm6
movd %mm6,192(%ebp)
psrlq $32,%mm6
movd %mm6,832(%edx)
movd 68(%ebx),%mm1
pfadd %mm1,%mm4
movd %mm4,64(%ebp)
psrlq $32,%mm4
movd %mm4,960(%edx)
/* femms */
popl %ebx
popl %esi
popl %edi
popl %ebp
addl $256,%esp
ret

View File

@@ -1,712 +0,0 @@
/*
dct64_3dnowext: extended 3DNow optimized DCT64
copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
Transformed back into standalone asm, with help of
gcc -S -DHAVE_CONFIG_H -I. -march=k6-3 -O3 -Wall -pedantic -fno-strict-aliasing -DREAL_IS_FLOAT -c -o dct64_3dnowext.{S,c}
MPlayer comment follows.
*/
/*
* This code was taken from http://www.mpg123.org
* See ChangeLog of mpg123-0.59s-pre.1 for detail
* Applied to mplayer by Nick Kurshev <nickols_k@mail.ru>
* Partial 3dnowex-DSP! optimization by Nick Kurshev
*
* TODO: optimize scalar 3dnow! code
* Warning: Phases 7 & 8 are not tested
*/
#include "mangle.h"
.data
ALIGN4
/* .type plus_1f, @object
.size plus_1f, 4 */
plus_1f:
.long 1065353216
ALIGN8
/* .type x_plus_minus_3dnow, @object
.size x_plus_minus_3dnow, 8 */
x_plus_minus_3dnow:
.long 0
.long -2147483648
.text
ALIGN32,,31
.globl ASM_NAME(dct64_3dnowext)
/* .type ASM_NAME(dct64_3dnowext), @function */
ASM_NAME(dct64_3dnowext):
pushl %ebp
movl %esp, %ebp
pushl %edi
pushl %esi
pushl %ebx
subl $256, %esp
#APP
movl 16(%ebp),%eax
leal 128+-268(%ebp),%edx
movl 8(%ebp),%esi
movl 12(%ebp),%edi
movl $ASM_NAME(costab_mmxsse),%ebx
leal -268(%ebp),%ecx
movq (%eax), %mm0
movq 8(%eax), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 120(%eax), %mm1
pswapd 112(%eax), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, (%edx)
movq %mm4, 8(%edx)
pfsub %mm1, %mm3
pfsub %mm5, %mm7
pfmul (%ebx), %mm3
pfmul 8(%ebx), %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 120(%edx)
movq %mm7, 112(%edx)
movq 16(%eax), %mm0
movq 24(%eax), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 104(%eax), %mm1
pswapd 96(%eax), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, 16(%edx)
movq %mm4, 24(%edx)
pfsub %mm1, %mm3
pfsub %mm5, %mm7
pfmul 16(%ebx), %mm3
pfmul 24(%ebx), %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 104(%edx)
movq %mm7, 96(%edx)
movq 32(%eax), %mm0
movq 40(%eax), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 88(%eax), %mm1
pswapd 80(%eax), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, 32(%edx)
movq %mm4, 40(%edx)
pfsub %mm1, %mm3
pfsub %mm5, %mm7
pfmul 32(%ebx), %mm3
pfmul 40(%ebx), %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 88(%edx)
movq %mm7, 80(%edx)
movq 48(%eax), %mm0
movq 56(%eax), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 72(%eax), %mm1
pswapd 64(%eax), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, 48(%edx)
movq %mm4, 56(%edx)
pfsub %mm1, %mm3
pfsub %mm5, %mm7
pfmul 48(%ebx), %mm3
pfmul 56(%ebx), %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 72(%edx)
movq %mm7, 64(%edx)
movq (%edx), %mm0
movq 8(%edx), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 56(%edx), %mm1
pswapd 48(%edx), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, (%ecx)
movq %mm4, 8(%ecx)
pfsub %mm1, %mm3
pfsub %mm5, %mm7
pfmul 64(%ebx), %mm3
pfmul 72(%ebx), %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 56(%ecx)
movq %mm7, 48(%ecx)
movq 16(%edx), %mm0
movq 24(%edx), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 40(%edx), %mm1
pswapd 32(%edx), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, 16(%ecx)
movq %mm4, 24(%ecx)
pfsub %mm1, %mm3
pfsub %mm5, %mm7
pfmul 80(%ebx), %mm3
pfmul 88(%ebx), %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 40(%ecx)
movq %mm7, 32(%ecx)
movq 64(%edx), %mm0
movq 72(%edx), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 120(%edx), %mm1
pswapd 112(%edx), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, 64(%ecx)
movq %mm4, 72(%ecx)
pfsubr %mm1, %mm3
pfsubr %mm5, %mm7
pfmul 64(%ebx), %mm3
pfmul 72(%ebx), %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 120(%ecx)
movq %mm7, 112(%ecx)
movq 80(%edx), %mm0
movq 88(%edx), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 104(%edx), %mm1
pswapd 96(%edx), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, 80(%ecx)
movq %mm4, 88(%ecx)
pfsubr %mm1, %mm3
pfsubr %mm5, %mm7
pfmul 80(%ebx), %mm3
pfmul 88(%ebx), %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 104(%ecx)
movq %mm7, 96(%ecx)
movq 96(%ebx), %mm2
movq 104(%ebx), %mm6
movq (%ecx), %mm0
movq 8(%ecx), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 24(%ecx), %mm1
pswapd 16(%ecx), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, (%edx)
movq %mm4, 8(%edx)
pfsub %mm1, %mm3
pfsub %mm5, %mm7
pfmul %mm2, %mm3
pfmul %mm6, %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 24(%edx)
movq %mm7, 16(%edx)
movq 32(%ecx), %mm0
movq 40(%ecx), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 56(%ecx), %mm1
pswapd 48(%ecx), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, 32(%edx)
movq %mm4, 40(%edx)
pfsubr %mm1, %mm3
pfsubr %mm5, %mm7
pfmul %mm2, %mm3
pfmul %mm6, %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 56(%edx)
movq %mm7, 48(%edx)
movq 64(%ecx), %mm0
movq 72(%ecx), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 88(%ecx), %mm1
pswapd 80(%ecx), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, 64(%edx)
movq %mm4, 72(%edx)
pfsub %mm1, %mm3
pfsub %mm5, %mm7
pfmul %mm2, %mm3
pfmul %mm6, %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 88(%edx)
movq %mm7, 80(%edx)
movq 96(%ecx), %mm0
movq 104(%ecx), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 120(%ecx), %mm1
pswapd 112(%ecx), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, 96(%edx)
movq %mm4, 104(%edx)
pfsubr %mm1, %mm3
pfsubr %mm5, %mm7
pfmul %mm2, %mm3
pfmul %mm6, %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 120(%edx)
movq %mm7, 112(%edx)
movq 112(%ebx), %mm2
movq (%edx), %mm0
movq 16(%edx), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 8(%edx), %mm1
pswapd 24(%edx), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, (%ecx)
movq %mm4, 16(%ecx)
pfsub %mm1, %mm3
pfsubr %mm5, %mm7
pfmul %mm2, %mm3
pfmul %mm2, %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 8(%ecx)
movq %mm7, 24(%ecx)
movq 32(%edx), %mm0
movq 48(%edx), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 40(%edx), %mm1
pswapd 56(%edx), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, 32(%ecx)
movq %mm4, 48(%ecx)
pfsub %mm1, %mm3
pfsubr %mm5, %mm7
pfmul %mm2, %mm3
pfmul %mm2, %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 40(%ecx)
movq %mm7, 56(%ecx)
movq 64(%edx), %mm0
movq 80(%edx), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 72(%edx), %mm1
pswapd 88(%edx), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, 64(%ecx)
movq %mm4, 80(%ecx)
pfsub %mm1, %mm3
pfsubr %mm5, %mm7
pfmul %mm2, %mm3
pfmul %mm2, %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 72(%ecx)
movq %mm7, 88(%ecx)
movq 96(%edx), %mm0
movq 112(%edx), %mm4
movq %mm0, %mm3
movq %mm4, %mm7
pswapd 104(%edx), %mm1
pswapd 120(%edx), %mm5
pfadd %mm1, %mm0
pfadd %mm5, %mm4
movq %mm0, 96(%ecx)
movq %mm4, 112(%ecx)
pfsub %mm1, %mm3
pfsubr %mm5, %mm7
pfmul %mm2, %mm3
pfmul %mm2, %mm7
pswapd %mm3, %mm3
pswapd %mm7, %mm7
movq %mm3, 104(%ecx)
movq %mm7, 120(%ecx)
movd plus_1f, %mm6
punpckldq 120(%ebx), %mm6
movq x_plus_minus_3dnow, %mm7
movq 32(%ecx), %mm0
movq 64(%ecx), %mm2
movq %mm0, %mm1
movq %mm2, %mm3
pxor %mm7, %mm1
pxor %mm7, %mm3
pfacc %mm1, %mm0
pfacc %mm3, %mm2
pfmul %mm6, %mm0
pfmul %mm6, %mm2
movq %mm0, 32(%edx)
movq %mm2, 64(%edx)
movd 44(%ecx), %mm0
movd 40(%ecx), %mm2
movd 120(%ebx), %mm3
punpckldq 76(%ecx), %mm0
punpckldq 72(%ecx), %mm2
punpckldq %mm3, %mm3
movq %mm0, %mm4
movq %mm2, %mm5
pfsub %mm2, %mm0
pfmul %mm3, %mm0
movq %mm0, %mm1
pfadd %mm5, %mm0
pfadd %mm4, %mm0
movq %mm0, %mm2
punpckldq %mm1, %mm0
punpckhdq %mm1, %mm2
movq %mm0, 40(%edx)
movq %mm2, 72(%edx)
movd 48(%ecx), %mm3
movd 60(%ecx), %mm2
pfsub 52(%ecx), %mm3
pfsub 56(%ecx), %mm2
pfmul 120(%ebx), %mm3
pfmul 120(%ebx), %mm2
movq %mm2, %mm1
pfadd 56(%ecx), %mm1
pfadd 60(%ecx), %mm1
movq %mm1, %mm0
pfadd 48(%ecx), %mm0
pfadd 52(%ecx), %mm0
pfadd %mm3, %mm1
punpckldq %mm2, %mm1
pfadd %mm3, %mm2
punpckldq %mm2, %mm0
movq %mm1, 56(%edx)
movq %mm0, 48(%edx)
movd 92(%ecx), %mm1
pfsub 88(%ecx), %mm1
pfmul 120(%ebx), %mm1
movd %mm1, 92(%edx)
pfadd 92(%ecx), %mm1
pfadd 88(%ecx), %mm1
movq %mm1, %mm0
pfadd 80(%ecx), %mm0
pfadd 84(%ecx), %mm0
movd %mm0, 80(%edx)
movd 80(%ecx), %mm0
pfsub 84(%ecx), %mm0
pfmul 120(%ebx), %mm0
pfadd %mm0, %mm1
pfadd 92(%edx), %mm0
punpckldq %mm1, %mm0
movq %mm0, 84(%edx)
movq 96(%ecx), %mm0
movq %mm0, %mm1
pxor %mm7, %mm1
pfacc %mm1, %mm0
pfmul %mm6, %mm0
movq %mm0, 96(%edx)
movd 108(%ecx), %mm0
pfsub 104(%ecx), %mm0
pfmul 120(%ebx), %mm0
movd %mm0, 108(%edx)
pfadd 104(%ecx), %mm0
pfadd 108(%ecx), %mm0
movd %mm0, 104(%edx)
movd 124(%ecx), %mm1
pfsub 120(%ecx), %mm1
pfmul 120(%ebx), %mm1
movd %mm1, 124(%edx)
pfadd 120(%ecx), %mm1
pfadd 124(%ecx), %mm1
movq %mm1, %mm0
pfadd 112(%ecx), %mm0
pfadd 116(%ecx), %mm0
movd %mm0, 112(%edx)
movd 112(%ecx), %mm0
pfsub 116(%ecx), %mm0
pfmul 120(%ebx), %mm0
pfadd %mm0,%mm1
pfadd 124(%edx), %mm0
punpckldq %mm1, %mm0
movq %mm0, 116(%edx)
jnz .L01
movd (%ecx), %mm0
pfadd 4(%ecx), %mm0
movd %mm0, 1024(%esi)
movd (%ecx), %mm0
pfsub 4(%ecx), %mm0
pfmul 120(%ebx), %mm0
movd %mm0, (%esi)
movd %mm0, (%edi)
movd 12(%ecx), %mm0
pfsub 8(%ecx), %mm0
pfmul 120(%ebx), %mm0
movd %mm0, 512(%edi)
pfadd 12(%ecx), %mm0
pfadd 8(%ecx), %mm0
movd %mm0, 512(%esi)
movd 16(%ecx), %mm0
pfsub 20(%ecx), %mm0
pfmul 120(%ebx), %mm0
movq %mm0, %mm3
movd 28(%ecx), %mm0
pfsub 24(%ecx), %mm0
pfmul 120(%ebx), %mm0
movd %mm0, 768(%edi)
movq %mm0, %mm2
pfadd 24(%ecx), %mm0
pfadd 28(%ecx), %mm0
movq %mm0, %mm1
pfadd 16(%ecx), %mm0
pfadd 20(%ecx), %mm0
movd %mm0, 768(%esi)
pfadd %mm3, %mm1
movd %mm1, 256(%esi)
pfadd %mm3, %mm2
movd %mm2, 256(%edi)
movq 32(%edx), %mm0
movq 48(%edx), %mm1
pfadd 48(%edx), %mm0
pfadd 40(%edx), %mm1
movd %mm0, 896(%esi)
movd %mm1, 640(%esi)
psrlq $32, %mm0
psrlq $32, %mm1
movd %mm0, 128(%edi)
movd %mm1, 384(%edi)
movd 40(%edx), %mm0
pfadd 56(%edx), %mm0
movd %mm0, 384(%esi)
movd 56(%edx), %mm0
pfadd 36(%edx), %mm0
movd %mm0, 128(%esi)
movd 60(%edx), %mm0
movd %mm0, 896(%edi)
pfadd 44(%edx), %mm0
movd %mm0, 640(%edi)
movq 96(%edx), %mm0
movq 112(%edx), %mm2
movq 104(%edx), %mm4
pfadd 112(%edx), %mm0
pfadd 104(%edx), %mm2
pfadd 120(%edx), %mm4
movq %mm0, %mm1
movq %mm2, %mm3
movq %mm4, %mm5
pfadd 64(%edx), %mm0
pfadd 80(%edx), %mm2
pfadd 72(%edx), %mm4
movd %mm0, 960(%esi)
movd %mm2, 704(%esi)
movd %mm4, 448(%esi)
psrlq $32, %mm0
psrlq $32, %mm2
psrlq $32, %mm4
movd %mm0, 64(%edi)
movd %mm2, 320(%edi)
movd %mm4, 576(%edi)
pfadd 80(%edx), %mm1
pfadd 72(%edx), %mm3
pfadd 88(%edx), %mm5
movd %mm1, 832(%esi)
movd %mm3, 576(%esi)
movd %mm5, 320(%esi)
psrlq $32, %mm1
psrlq $32, %mm3
psrlq $32, %mm5
movd %mm1, 192(%edi)
movd %mm3, 448(%edi)
movd %mm5, 704(%edi)
movd 120(%edx), %mm0
pfadd 100(%edx), %mm0
movq %mm0, %mm1
pfadd 88(%edx), %mm0
movd %mm0, 192(%esi)
pfadd 68(%edx), %mm1
movd %mm1, 64(%esi)
movd 124(%edx), %mm0
movd %mm0, 960(%edi)
pfadd 92(%edx), %mm0
movd %mm0, 832(%edi)
jmp .L_bye
.L01:
movq (%ecx), %mm0
movq %mm0, %mm1
pxor %mm7, %mm1
pfacc %mm1, %mm0
pfmul %mm6, %mm0
pf2iw %mm0, %mm0
movd %mm0, %eax
movw %ax, 512(%esi)
psrlq $32, %mm0
movd %mm0, %eax
movw %ax, (%esi)
movd 12(%ecx), %mm0
pfsub 8(%ecx), %mm0
pfmul 120(%ebx), %mm0
pf2iw %mm0, %mm7
movd %mm7, %eax
movw %ax, 256(%edi)
pfadd 12(%ecx), %mm0
pfadd 8(%ecx), %mm0
pf2iw %mm0, %mm0
movd %mm0, %eax
movw %ax, 256(%esi)
movd 16(%ecx), %mm3
pfsub 20(%ecx), %mm3
pfmul 120(%ebx), %mm3
movq %mm3, %mm2
movd 28(%ecx), %mm2
pfsub 24(%ecx), %mm2
pfmul 120(%ebx), %mm2
movq %mm2, %mm1
pf2iw %mm2, %mm7
movd %mm7, %eax
movw %ax, 384(%edi)
pfadd 24(%ecx), %mm1
pfadd 28(%ecx), %mm1
movq %mm1, %mm0
pfadd 16(%ecx), %mm0
pfadd 20(%ecx), %mm0
pf2iw %mm0, %mm0
movd %mm0, %eax
movw %ax, 384(%esi)
pfadd %mm3, %mm1
pf2iw %mm1, %mm1
movd %mm1, %eax
movw %ax, 128(%esi)
pfadd %mm3, %mm2
pf2iw %mm2, %mm2
movd %mm2, %eax
movw %ax, 128(%edi)
movq 32(%edx), %mm0
movq 48(%edx), %mm1
pfadd 48(%edx), %mm0
pfadd 40(%edx), %mm1
pf2iw %mm0, %mm0
pf2iw %mm1, %mm1
movd %mm0, %eax
movd %mm1, %ecx
movw %ax, 448(%esi)
movw %cx, 320(%esi)
psrlq $32, %mm0
psrlq $32, %mm1
movd %mm0, %eax
movd %mm1, %ecx
movw %ax, 64(%edi)
movw %cx, 192(%edi)
movd 40(%edx), %mm3
movd 56(%edx), %mm4
movd 60(%edx), %mm0
movd 44(%edx), %mm2
movd 120(%edx), %mm5
punpckldq %mm4, %mm3
punpckldq 124(%edx), %mm0
pfadd 100(%edx), %mm5
punpckldq 36(%edx), %mm4
punpckldq 92(%edx), %mm2
movq %mm5, %mm6
pfadd %mm4, %mm3
pf2iw %mm0, %mm1
pf2iw %mm3, %mm3
pfadd 88(%edx), %mm5
movd %mm1, %eax
movd %mm3, %ecx
movw %ax, 448(%edi)
movw %cx, 192(%esi)
pf2iw %mm5, %mm5
psrlq $32, %mm1
psrlq $32, %mm3
movd %mm5, %ebx
movd %mm1, %eax
movd %mm3, %ecx
movw %bx, 96(%esi)
movw %ax, 480(%edi)
movw %cx, 64(%esi)
pfadd %mm2, %mm0
pf2iw %mm0, %mm0
movd %mm0, %eax
pfadd 68(%edx), %mm6
movw %ax, 320(%edi)
psrlq $32, %mm0
pf2iw %mm6, %mm6
movd %mm0, %eax
movd %mm6, %ebx
movw %ax, 416(%edi)
movw %bx, 32(%esi)
movq 96(%edx), %mm0
movq 112(%edx), %mm2
movq 104(%edx), %mm4
pfadd %mm2, %mm0
pfadd %mm4, %mm2
pfadd 120(%edx), %mm4
movq %mm0, %mm1
movq %mm2, %mm3
movq %mm4, %mm5
pfadd 64(%edx), %mm0
pfadd 80(%edx), %mm2
pfadd 72(%edx), %mm4
pf2iw %mm0, %mm0
pf2iw %mm2, %mm2
pf2iw %mm4, %mm4
movd %mm0, %eax
movd %mm2, %ecx
movd %mm4, %ebx
movw %ax, 480(%esi)
movw %cx, 352(%esi)
movw %bx, 224(%esi)
psrlq $32, %mm0
psrlq $32, %mm2
psrlq $32, %mm4
movd %mm0, %eax
movd %mm2, %ecx
movd %mm4, %ebx
movw %ax, 32(%edi)
movw %cx, 160(%edi)
movw %bx, 288(%edi)
pfadd 80(%edx), %mm1
pfadd 72(%edx), %mm3
pfadd 88(%edx), %mm5
pf2iw %mm1, %mm1
pf2iw %mm3, %mm3
pf2iw %mm5, %mm5
movd %mm1, %eax
movd %mm3, %ecx
movd %mm5, %ebx
movw %ax, 416(%esi)
movw %cx, 288(%esi)
movw %bx, 160(%esi)
psrlq $32, %mm1
psrlq $32, %mm3
psrlq $32, %mm5
movd %mm1, %eax
movd %mm3, %ecx
movd %mm5, %ebx
movw %ax, 96(%edi)
movw %cx, 224(%edi)
movw %bx, 352(%edi)
movsw
.L_bye:
femms
#NO_APP
addl $256, %esp
popl %ebx
popl %esi
popl %edi
leave
ret
/* .size ASM_NAME(dct64_3dnowext), .-ASM_NAME(dct64_3dnowext) */

View File

@@ -1,325 +0,0 @@
/*
dct64_altivec.c: Discrete Cosine Tansform (DCT) for Altivec
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.org
initially written by Michael Hipp
altivec optimization by tmkk
*/
/*
* Discrete Cosine Tansform (DCT) for subband synthesis
*
* -funroll-loops (for gcc) will remove the loops for better performance
* using loops in the source-code enhances readabillity
*
*
* TODO: write an optimized version for the down-sampling modes
* (in these modes the bands 16-31 (2:1) or 8-31 (4:1) are zero
*/
#include "mpg123.h"
#ifndef __APPLE__
#include <altivec.h>
#endif
void dct64_altivec(real *out0,real *out1,real *samples)
{
ALIGNED(16) real bufs[64];
{
register real *b1,*costab;
vector unsigned char vinvert,vperm1,vperm2,vperm3,vperm4;
vector float v1,v2,v3,v4,v5,v6,v7,v8;
vector float vbs1,vbs2,vbs3,vbs4,vbs5,vbs6,vbs7,vbs8;
vector float vbs9,vbs10,vbs11,vbs12,vbs13,vbs14,vbs15,vbs16;
vector float vzero;
b1 = samples;
costab = pnts[0];
vzero = vec_xor(vzero,vzero);
#ifdef __APPLE__
vinvert = (vector unsigned char)(12,13,14,15,8,9,10,11,4,5,6,7,0,1,2,3);
#else
vinvert = (vector unsigned char){12,13,14,15,8,9,10,11,4,5,6,7,0,1,2,3};
#endif
vperm1 = vec_lvsl(0,b1);
vperm2 = vec_perm(vperm1,vperm1,vinvert);
v1 = vec_ld(0,b1);
v2 = vec_ld(16,b1);
v3 = vec_ld(112,b1);
v4 = vec_ld(127,b1);
v5 = vec_perm(v1,v2,vperm1); /* b1[0,1,2,3] */
v6 = vec_perm(v3,v4,vperm2); /* b1[31,30,29,28] */
vbs1 = vec_add(v5,v6);
vbs8 = vec_sub(v5,v6);
v1 = vec_ld(32,b1);
v4 = vec_ld(96,b1);
v5 = vec_perm(v2,v1,vperm1); /* b1[4,5,6,7] */
v6 = vec_perm(v4,v3,vperm2); /* b1[27,26,25,24] */
vbs2 = vec_add(v5,v6);
vbs7 = vec_sub(v5,v6);
v2 = vec_ld(48,b1);
v3 = vec_ld(80,b1);
v5 = vec_perm(v1,v2,vperm1); /* b1[8,9,10,11] */
v6 = vec_perm(v3,v4,vperm2); /* b1[23,22,21,20] */
vbs3 = vec_add(v5,v6);
vbs6 = vec_sub(v5,v6);
v1 = vec_ld(64,b1);
v5 = vec_perm(v2,v1,vperm1); /* b1[12,13,14,15] */
v6 = vec_perm(v1,v3,vperm2); /* b1[19,18,17,16] */
vbs4 = vec_add(v5,v6);
vbs5 = vec_sub(v5,v6);
v1 = vec_ld(0,costab);
vbs8 = vec_madd(vbs8,v1,vzero);
v2 = vec_ld(16,costab);
vbs7 = vec_madd(vbs7,v2,vzero);
v3 = vec_ld(32,costab);
vbs6 = vec_madd(vbs6,v3,vzero);
v4 = vec_ld(48,costab);
vbs5 = vec_madd(vbs5,v4,vzero);
vbs6 = vec_perm(vbs6,vbs6,vinvert);
vbs5 = vec_perm(vbs5,vbs5,vinvert);
costab = pnts[1];
v1 = vec_perm(vbs4,vbs4,vinvert);
vbs9 = vec_add(vbs1,v1);
v3 = vec_sub(vbs1,v1);
v5 = vec_ld(0,costab);
v2 = vec_perm(vbs3,vbs3,vinvert);
vbs10 = vec_add(vbs2,v2);
v4 = vec_sub(vbs2,v2);
v6 = vec_ld(16,costab);
vbs12 = vec_madd(v3,v5,vzero);
vbs11 = vec_madd(v4,v6,vzero);
v7 = vec_sub(vbs7,vbs6);
v8 = vec_sub(vbs8,vbs5);
vbs13 = vec_add(vbs5,vbs8);
vbs14 = vec_add(vbs6,vbs7);
vbs15 = vec_madd(v7,v6,vzero);
vbs16 = vec_madd(v8,v5,vzero);
costab = pnts[2];
v1 = vec_perm(vbs10,vbs10,vinvert);
v5 = vec_perm(vbs14,vbs14,vinvert);
vbs1 = vec_add(v1,vbs9);
vbs5 = vec_add(v5,vbs13);
v2 = vec_sub(vbs9,v1);
v6 = vec_sub(vbs13,v5);
v3 = vec_ld(0,costab);
vbs11 = vec_perm(vbs11,vbs11,vinvert);
vbs15 = vec_perm(vbs15,vbs15,vinvert);
vbs3 = vec_add(vbs11,vbs12);
vbs7 = vec_add(vbs15,vbs16);
v4 = vec_sub(vbs12,vbs11);
v7 = vec_sub(vbs16,vbs15);
vbs2 = vec_madd(v2,v3,vzero);
vbs4 = vec_madd(v4,v3,vzero);
vbs6 = vec_madd(v6,v3,vzero);
vbs8 = vec_madd(v7,v3,vzero);
vbs2 = vec_perm(vbs2,vbs2,vinvert);
vbs4 = vec_perm(vbs4,vbs4,vinvert);
vbs6 = vec_perm(vbs6,vbs6,vinvert);
vbs8 = vec_perm(vbs8,vbs8,vinvert);
costab = pnts[3];
#ifdef __APPLE__
vperm1 = (vector unsigned char)(0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23);
vperm2 = (vector unsigned char)(12,13,14,15,8,9,10,11,28,29,30,31,24,25,26,27);
vperm3 = (vector unsigned char)(0,1,2,3,4,5,6,7,20,21,22,23,16,17,18,19);
#else
vperm1 = (vector unsigned char){0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23};
vperm2 = (vector unsigned char){12,13,14,15,8,9,10,11,28,29,30,31,24,25,26,27};
vperm3 = (vector unsigned char){0,1,2,3,4,5,6,7,20,21,22,23,16,17,18,19};
#endif
vperm4 = vec_add(vperm3,vec_splat_u8(8));
v1 = vec_ld(0,costab);
v2 = vec_splat(v1,0);
v3 = vec_splat(v1,1);
v1 = vec_mergeh(v2,v3);
v2 = vec_perm(vbs1,vbs3,vperm1);
v3 = vec_perm(vbs2,vbs4,vperm1);
v4 = vec_perm(vbs1,vbs3,vperm2);
v5 = vec_perm(vbs2,vbs4,vperm2);
v6 = vec_sub(v2,v4);
v7 = vec_sub(v3,v5);
v2 = vec_add(v2,v4);
v3 = vec_add(v3,v5);
v4 = vec_madd(v6,v1,vzero);
v5 = vec_nmsub(v7,v1,vzero);
vbs9 = vec_perm(v2,v4,vperm3);
vbs11 = vec_perm(v2,v4,vperm4);
vbs10 = vec_perm(v3,v5,vperm3);
vbs12 = vec_perm(v3,v5,vperm4);
v2 = vec_perm(vbs5,vbs7,vperm1);
v3 = vec_perm(vbs6,vbs8,vperm1);
v4 = vec_perm(vbs5,vbs7,vperm2);
v5 = vec_perm(vbs6,vbs8,vperm2);
v6 = vec_sub(v2,v4);
v7 = vec_sub(v3,v5);
v2 = vec_add(v2,v4);
v3 = vec_add(v3,v5);
v4 = vec_madd(v6,v1,vzero);
v5 = vec_nmsub(v7,v1,vzero);
vbs13 = vec_perm(v2,v4,vperm3);
vbs15 = vec_perm(v2,v4,vperm4);
vbs14 = vec_perm(v3,v5,vperm3);
vbs16 = vec_perm(v3,v5,vperm4);
costab = pnts[4];
v1 = vec_lde(0,costab);
#ifdef __APPLE__
v2 = (vector float)(1.0f,-1.0f,1.0f,-1.0f);
#else
v2 = (vector float){1.0f,-1.0f,1.0f,-1.0f};
#endif
v3 = vec_splat(v1,0);
v1 = vec_madd(v2,v3,vzero);
v2 = vec_mergeh(vbs9,vbs10);
v3 = vec_mergel(vbs9,vbs10);
v4 = vec_mergeh(vbs11,vbs12);
v5 = vec_mergel(vbs11,vbs12);
v6 = vec_mergeh(v2,v3);
v7 = vec_mergel(v2,v3);
v2 = vec_mergeh(v4,v5);
v3 = vec_mergel(v4,v5);
v4 = vec_sub(v6,v7);
v5 = vec_sub(v2,v3);
v6 = vec_add(v6,v7);
v7 = vec_add(v2,v3);
v2 = vec_madd(v4,v1,vzero);
v3 = vec_madd(v5,v1,vzero);
vbs1 = vec_mergeh(v6,v2);
vbs2 = vec_mergel(v6,v2);
vbs3 = vec_mergeh(v7,v3);
vbs4 = vec_mergel(v7,v3);
v2 = vec_mergeh(vbs13,vbs14);
v3 = vec_mergel(vbs13,vbs14);
v4 = vec_mergeh(vbs15,vbs16);
v5 = vec_mergel(vbs15,vbs16);
v6 = vec_mergeh(v2,v3);
v7 = vec_mergel(v2,v3);
v2 = vec_mergeh(v4,v5);
v3 = vec_mergel(v4,v5);
v4 = vec_sub(v6,v7);
v5 = vec_sub(v2,v3);
v6 = vec_add(v6,v7);
v7 = vec_add(v2,v3);
v2 = vec_madd(v4,v1,vzero);
v3 = vec_madd(v5,v1,vzero);
vbs5 = vec_mergeh(v6,v2);
vbs6 = vec_mergel(v6,v2);
vbs7 = vec_mergeh(v7,v3);
vbs8 = vec_mergel(v7,v3);
vec_st(vbs1,0,bufs);
vec_st(vbs2,16,bufs);
vec_st(vbs3,32,bufs);
vec_st(vbs4,48,bufs);
vec_st(vbs5,64,bufs);
vec_st(vbs6,80,bufs);
vec_st(vbs7,96,bufs);
vec_st(vbs8,112,bufs);
vec_st(vbs9,128,bufs);
vec_st(vbs10,144,bufs);
vec_st(vbs11,160,bufs);
vec_st(vbs12,176,bufs);
vec_st(vbs13,192,bufs);
vec_st(vbs14,208,bufs);
vec_st(vbs15,224,bufs);
vec_st(vbs16,240,bufs);
}
{
register real *b1;
register int i;
for(b1=bufs,i=8;i;i--,b1+=4)
b1[2] += b1[3];
for(b1=bufs,i=4;i;i--,b1+=8)
{
b1[4] += b1[6];
b1[6] += b1[5];
b1[5] += b1[7];
}
for(b1=bufs,i=2;i;i--,b1+=16)
{
b1[8] += b1[12];
b1[12] += b1[10];
b1[10] += b1[14];
b1[14] += b1[9];
b1[9] += b1[13];
b1[13] += b1[11];
b1[11] += b1[15];
}
}
out0[0x10*16] = bufs[0];
out0[0x10*15] = bufs[16+0] + bufs[16+8];
out0[0x10*14] = bufs[8];
out0[0x10*13] = bufs[16+8] + bufs[16+4];
out0[0x10*12] = bufs[4];
out0[0x10*11] = bufs[16+4] + bufs[16+12];
out0[0x10*10] = bufs[12];
out0[0x10* 9] = bufs[16+12] + bufs[16+2];
out0[0x10* 8] = bufs[2];
out0[0x10* 7] = bufs[16+2] + bufs[16+10];
out0[0x10* 6] = bufs[10];
out0[0x10* 5] = bufs[16+10] + bufs[16+6];
out0[0x10* 4] = bufs[6];
out0[0x10* 3] = bufs[16+6] + bufs[16+14];
out0[0x10* 2] = bufs[14];
out0[0x10* 1] = bufs[16+14] + bufs[16+1];
out0[0x10* 0] = bufs[1];
out1[0x10* 0] = bufs[1];
out1[0x10* 1] = bufs[16+1] + bufs[16+9];
out1[0x10* 2] = bufs[9];
out1[0x10* 3] = bufs[16+9] + bufs[16+5];
out1[0x10* 4] = bufs[5];
out1[0x10* 5] = bufs[16+5] + bufs[16+13];
out1[0x10* 6] = bufs[13];
out1[0x10* 7] = bufs[16+13] + bufs[16+3];
out1[0x10* 8] = bufs[3];
out1[0x10* 9] = bufs[16+3] + bufs[16+11];
out1[0x10*10] = bufs[11];
out1[0x10*11] = bufs[16+11] + bufs[16+7];
out1[0x10*12] = bufs[7];
out1[0x10*13] = bufs[16+7] + bufs[16+15];
out1[0x10*14] = bufs[15];
out1[0x10*15] = bufs[16+15];
}

View File

@@ -1,336 +0,0 @@
/*
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.org
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 "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_i386(real *a,real *b,real *c)
{
real bufs[0x40];
dct64_1(a,b,bufs,bufs+0x20,c);
}

View File

@@ -1,342 +0,0 @@
/*
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.org
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 long)(a)*(long 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_i486(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);
}

View File

@@ -1,846 +0,0 @@
/*
dct64_mmx.s: MMX optimized DCT64
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.org
initially written by the mysterious higway (apparently)
*/
#include "mangle.h"
.data
ALIGN32
ASM_NAME(costab):
.long 1056974725
.long 1057056395
.long 1057223771
.long 1057485416
.long 1057855544
.long 1058356026
.long 1059019886
.long 1059897405
.long 1061067246
.long 1062657950
.long 1064892987
.long 1066774581
.long 1069414683
.long 1073984175
.long 1079645762
.long 1092815430
.long 1057005197
.long 1057342072
.long 1058087743
.long 1059427869
.long 1061799040
.long 1065862217
.long 1071413542
.long 1084439708
.long 1057128951
.long 1058664893
.long 1063675095
.long 1076102863
.long 1057655764
.long 1067924853
.long 1060439283
.text
ALIGN32
.globl ASM_NAME(dct64_mmx)
ASM_NAME(dct64_mmx):
xorl %ecx,%ecx
.globl ASM_NAME(dct64_MMX)
ASM_NAME(dct64_MMX):
pushl %ebx
pushl %esi
pushl %edi
subl $256,%esp
movl 280(%esp),%eax
flds (%eax)
leal 128(%esp),%edx
fadds 124(%eax)
movl 272(%esp),%esi
fstps (%edx)
movl 276(%esp),%edi
flds 4(%eax)
movl $ASM_NAME(costab),%ebx
fadds 120(%eax)
orl %ecx,%ecx
fstps 4(%edx)
flds (%eax)
movl %esp,%ecx
fsubs 124(%eax)
fmuls (%ebx)
fstps 124(%edx)
flds 4(%eax)
fsubs 120(%eax)
fmuls 4(%ebx)
fstps 120(%edx)
flds 8(%eax)
fadds 116(%eax)
fstps 8(%edx)
flds 12(%eax)
fadds 112(%eax)
fstps 12(%edx)
flds 8(%eax)
fsubs 116(%eax)
fmuls 8(%ebx)
fstps 116(%edx)
flds 12(%eax)
fsubs 112(%eax)
fmuls 12(%ebx)
fstps 112(%edx)
flds 16(%eax)
fadds 108(%eax)
fstps 16(%edx)
flds 20(%eax)
fadds 104(%eax)
fstps 20(%edx)
flds 16(%eax)
fsubs 108(%eax)
fmuls 16(%ebx)
fstps 108(%edx)
flds 20(%eax)
fsubs 104(%eax)
fmuls 20(%ebx)
fstps 104(%edx)
flds 24(%eax)
fadds 100(%eax)
fstps 24(%edx)
flds 28(%eax)
fadds 96(%eax)
fstps 28(%edx)
flds 24(%eax)
fsubs 100(%eax)
fmuls 24(%ebx)
fstps 100(%edx)
flds 28(%eax)
fsubs 96(%eax)
fmuls 28(%ebx)
fstps 96(%edx)
flds 32(%eax)
fadds 92(%eax)
fstps 32(%edx)
flds 36(%eax)
fadds 88(%eax)
fstps 36(%edx)
flds 32(%eax)
fsubs 92(%eax)
fmuls 32(%ebx)
fstps 92(%edx)
flds 36(%eax)
fsubs 88(%eax)
fmuls 36(%ebx)
fstps 88(%edx)
flds 40(%eax)
fadds 84(%eax)
fstps 40(%edx)
flds 44(%eax)
fadds 80(%eax)
fstps 44(%edx)
flds 40(%eax)
fsubs 84(%eax)
fmuls 40(%ebx)
fstps 84(%edx)
flds 44(%eax)
fsubs 80(%eax)
fmuls 44(%ebx)
fstps 80(%edx)
flds 48(%eax)
fadds 76(%eax)
fstps 48(%edx)
flds 52(%eax)
fadds 72(%eax)
fstps 52(%edx)
flds 48(%eax)
fsubs 76(%eax)
fmuls 48(%ebx)
fstps 76(%edx)
flds 52(%eax)
fsubs 72(%eax)
fmuls 52(%ebx)
fstps 72(%edx)
flds 56(%eax)
fadds 68(%eax)
fstps 56(%edx)
flds 60(%eax)
fadds 64(%eax)
fstps 60(%edx)
flds 56(%eax)
fsubs 68(%eax)
fmuls 56(%ebx)
fstps 68(%edx)
flds 60(%eax)
fsubs 64(%eax)
fmuls 60(%ebx)
fstps 64(%edx)
flds (%edx)
fadds 60(%edx)
fstps (%ecx)
flds 4(%edx)
fadds 56(%edx)
fstps 4(%ecx)
flds (%edx)
fsubs 60(%edx)
fmuls 64(%ebx)
fstps 60(%ecx)
flds 4(%edx)
fsubs 56(%edx)
fmuls 68(%ebx)
fstps 56(%ecx)
flds 8(%edx)
fadds 52(%edx)
fstps 8(%ecx)
flds 12(%edx)
fadds 48(%edx)
fstps 12(%ecx)
flds 8(%edx)
fsubs 52(%edx)
fmuls 72(%ebx)
fstps 52(%ecx)
flds 12(%edx)
fsubs 48(%edx)
fmuls 76(%ebx)
fstps 48(%ecx)
flds 16(%edx)
fadds 44(%edx)
fstps 16(%ecx)
flds 20(%edx)
fadds 40(%edx)
fstps 20(%ecx)
flds 16(%edx)
fsubs 44(%edx)
fmuls 80(%ebx)
fstps 44(%ecx)
flds 20(%edx)
fsubs 40(%edx)
fmuls 84(%ebx)
fstps 40(%ecx)
flds 24(%edx)
fadds 36(%edx)
fstps 24(%ecx)
flds 28(%edx)
fadds 32(%edx)
fstps 28(%ecx)
flds 24(%edx)
fsubs 36(%edx)
fmuls 88(%ebx)
fstps 36(%ecx)
flds 28(%edx)
fsubs 32(%edx)
fmuls 92(%ebx)
fstps 32(%ecx)
flds 64(%edx)
fadds 124(%edx)
fstps 64(%ecx)
flds 68(%edx)
fadds 120(%edx)
fstps 68(%ecx)
flds 124(%edx)
fsubs 64(%edx)
fmuls 64(%ebx)
fstps 124(%ecx)
flds 120(%edx)
fsubs 68(%edx)
fmuls 68(%ebx)
fstps 120(%ecx)
flds 72(%edx)
fadds 116(%edx)
fstps 72(%ecx)
flds 76(%edx)
fadds 112(%edx)
fstps 76(%ecx)
flds 116(%edx)
fsubs 72(%edx)
fmuls 72(%ebx)
fstps 116(%ecx)
flds 112(%edx)
fsubs 76(%edx)
fmuls 76(%ebx)
fstps 112(%ecx)
flds 80(%edx)
fadds 108(%edx)
fstps 80(%ecx)
flds 84(%edx)
fadds 104(%edx)
fstps 84(%ecx)
flds 108(%edx)
fsubs 80(%edx)
fmuls 80(%ebx)
fstps 108(%ecx)
flds 104(%edx)
fsubs 84(%edx)
fmuls 84(%ebx)
fstps 104(%ecx)
flds 88(%edx)
fadds 100(%edx)
fstps 88(%ecx)
flds 92(%edx)
fadds 96(%edx)
fstps 92(%ecx)
flds 100(%edx)
fsubs 88(%edx)
fmuls 88(%ebx)
fstps 100(%ecx)
flds 96(%edx)
fsubs 92(%edx)
fmuls 92(%ebx)
fstps 96(%ecx)
flds (%ecx)
fadds 28(%ecx)
fstps (%edx)
flds (%ecx)
fsubs 28(%ecx)
fmuls 96(%ebx)
fstps 28(%edx)
flds 4(%ecx)
fadds 24(%ecx)
fstps 4(%edx)
flds 4(%ecx)
fsubs 24(%ecx)
fmuls 100(%ebx)
fstps 24(%edx)
flds 8(%ecx)
fadds 20(%ecx)
fstps 8(%edx)
flds 8(%ecx)
fsubs 20(%ecx)
fmuls 104(%ebx)
fstps 20(%edx)
flds 12(%ecx)
fadds 16(%ecx)
fstps 12(%edx)
flds 12(%ecx)
fsubs 16(%ecx)
fmuls 108(%ebx)
fstps 16(%edx)
flds 32(%ecx)
fadds 60(%ecx)
fstps 32(%edx)
flds 60(%ecx)
fsubs 32(%ecx)
fmuls 96(%ebx)
fstps 60(%edx)
flds 36(%ecx)
fadds 56(%ecx)
fstps 36(%edx)
flds 56(%ecx)
fsubs 36(%ecx)
fmuls 100(%ebx)
fstps 56(%edx)
flds 40(%ecx)
fadds 52(%ecx)
fstps 40(%edx)
flds 52(%ecx)
fsubs 40(%ecx)
fmuls 104(%ebx)
fstps 52(%edx)
flds 44(%ecx)
fadds 48(%ecx)
fstps 44(%edx)
flds 48(%ecx)
fsubs 44(%ecx)
fmuls 108(%ebx)
fstps 48(%edx)
flds 64(%ecx)
fadds 92(%ecx)
fstps 64(%edx)
flds 64(%ecx)
fsubs 92(%ecx)
fmuls 96(%ebx)
fstps 92(%edx)
flds 68(%ecx)
fadds 88(%ecx)
fstps 68(%edx)
flds 68(%ecx)
fsubs 88(%ecx)
fmuls 100(%ebx)
fstps 88(%edx)
flds 72(%ecx)
fadds 84(%ecx)
fstps 72(%edx)
flds 72(%ecx)
fsubs 84(%ecx)
fmuls 104(%ebx)
fstps 84(%edx)
flds 76(%ecx)
fadds 80(%ecx)
fstps 76(%edx)
flds 76(%ecx)
fsubs 80(%ecx)
fmuls 108(%ebx)
fstps 80(%edx)
flds 96(%ecx)
fadds 124(%ecx)
fstps 96(%edx)
flds 124(%ecx)
fsubs 96(%ecx)
fmuls 96(%ebx)
fstps 124(%edx)
flds 100(%ecx)
fadds 120(%ecx)
fstps 100(%edx)
flds 120(%ecx)
fsubs 100(%ecx)
fmuls 100(%ebx)
fstps 120(%edx)
flds 104(%ecx)
fadds 116(%ecx)
fstps 104(%edx)
flds 116(%ecx)
fsubs 104(%ecx)
fmuls 104(%ebx)
fstps 116(%edx)
flds 108(%ecx)
fadds 112(%ecx)
fstps 108(%edx)
flds 112(%ecx)
fsubs 108(%ecx)
fmuls 108(%ebx)
fstps 112(%edx)
flds (%edx)
fadds 12(%edx)
fstps (%ecx)
flds (%edx)
fsubs 12(%edx)
fmuls 112(%ebx)
fstps 12(%ecx)
flds 4(%edx)
fadds 8(%edx)
fstps 4(%ecx)
flds 4(%edx)
fsubs 8(%edx)
fmuls 116(%ebx)
fstps 8(%ecx)
flds 16(%edx)
fadds 28(%edx)
fstps 16(%ecx)
flds 28(%edx)
fsubs 16(%edx)
fmuls 112(%ebx)
fstps 28(%ecx)
flds 20(%edx)
fadds 24(%edx)
fstps 20(%ecx)
flds 24(%edx)
fsubs 20(%edx)
fmuls 116(%ebx)
fstps 24(%ecx)
flds 32(%edx)
fadds 44(%edx)
fstps 32(%ecx)
flds 32(%edx)
fsubs 44(%edx)
fmuls 112(%ebx)
fstps 44(%ecx)
flds 36(%edx)
fadds 40(%edx)
fstps 36(%ecx)
flds 36(%edx)
fsubs 40(%edx)
fmuls 116(%ebx)
fstps 40(%ecx)
flds 48(%edx)
fadds 60(%edx)
fstps 48(%ecx)
flds 60(%edx)
fsubs 48(%edx)
fmuls 112(%ebx)
fstps 60(%ecx)
flds 52(%edx)
fadds 56(%edx)
fstps 52(%ecx)
flds 56(%edx)
fsubs 52(%edx)
fmuls 116(%ebx)
fstps 56(%ecx)
flds 64(%edx)
fadds 76(%edx)
fstps 64(%ecx)
flds 64(%edx)
fsubs 76(%edx)
fmuls 112(%ebx)
fstps 76(%ecx)
flds 68(%edx)
fadds 72(%edx)
fstps 68(%ecx)
flds 68(%edx)
fsubs 72(%edx)
fmuls 116(%ebx)
fstps 72(%ecx)
flds 80(%edx)
fadds 92(%edx)
fstps 80(%ecx)
flds 92(%edx)
fsubs 80(%edx)
fmuls 112(%ebx)
fstps 92(%ecx)
flds 84(%edx)
fadds 88(%edx)
fstps 84(%ecx)
flds 88(%edx)
fsubs 84(%edx)
fmuls 116(%ebx)
fstps 88(%ecx)
flds 96(%edx)
fadds 108(%edx)
fstps 96(%ecx)
flds 96(%edx)
fsubs 108(%edx)
fmuls 112(%ebx)
fstps 108(%ecx)
flds 100(%edx)
fadds 104(%edx)
fstps 100(%ecx)
flds 100(%edx)
fsubs 104(%edx)
fmuls 116(%ebx)
fstps 104(%ecx)
flds 112(%edx)
fadds 124(%edx)
fstps 112(%ecx)
flds 124(%edx)
fsubs 112(%edx)
fmuls 112(%ebx)
fstps 124(%ecx)
flds 116(%edx)
fadds 120(%edx)
fstps 116(%ecx)
flds 120(%edx)
fsubs 116(%edx)
fmuls 116(%ebx)
fstps 120(%ecx)
flds 32(%ecx)
fadds 36(%ecx)
fstps 32(%edx)
flds 32(%ecx)
fsubs 36(%ecx)
fmuls 120(%ebx)
fstps 36(%edx)
flds 44(%ecx)
fsubs 40(%ecx)
fmuls 120(%ebx)
fsts 44(%edx)
fadds 40(%ecx)
fadds 44(%ecx)
fstps 40(%edx)
flds 48(%ecx)
fsubs 52(%ecx)
fmuls 120(%ebx)
flds 60(%ecx)
fsubs 56(%ecx)
fmuls 120(%ebx)
fld %st(0)
fadds 56(%ecx)
fadds 60(%ecx)
fld %st(0)
fadds 48(%ecx)
fadds 52(%ecx)
fstps 48(%edx)
fadd %st(2)
fstps 56(%edx)
fsts 60(%edx)
faddp %st(1)
fstps 52(%edx)
flds 64(%ecx)
fadds 68(%ecx)
fstps 64(%edx)
flds 64(%ecx)
fsubs 68(%ecx)
fmuls 120(%ebx)
fstps 68(%edx)
flds 76(%ecx)
fsubs 72(%ecx)
fmuls 120(%ebx)
fsts 76(%edx)
fadds 72(%ecx)
fadds 76(%ecx)
fstps 72(%edx)
flds 92(%ecx)
fsubs 88(%ecx)
fmuls 120(%ebx)
fsts 92(%edx)
fadds 92(%ecx)
fadds 88(%ecx)
fld %st(0)
fadds 80(%ecx)
fadds 84(%ecx)
fstps 80(%edx)
flds 80(%ecx)
fsubs 84(%ecx)
fmuls 120(%ebx)
fadd %st(0), %st(1)
fadds 92(%edx)
fstps 84(%edx)
fstps 88(%edx)
flds 96(%ecx)
fadds 100(%ecx)
fstps 96(%edx)
flds 96(%ecx)
fsubs 100(%ecx)
fmuls 120(%ebx)
fstps 100(%edx)
flds 108(%ecx)
fsubs 104(%ecx)
fmuls 120(%ebx)
fsts 108(%edx)
fadds 104(%ecx)
fadds 108(%ecx)
fstps 104(%edx)
flds 124(%ecx)
fsubs 120(%ecx)
fmuls 120(%ebx)
fsts 124(%edx)
fadds 120(%ecx)
fadds 124(%ecx)
fld %st(0)
fadds 112(%ecx)
fadds 116(%ecx)
fstps 112(%edx)
flds 112(%ecx)
fsubs 116(%ecx)
fmuls 120(%ebx)
fadd %st(0),%st(1)
fadds 124(%edx)
fstps 116(%edx)
fstps 120(%edx)
jnz .L01
flds (%ecx)
fadds 4(%ecx)
fstps 1024(%esi)
flds (%ecx)
fsubs 4(%ecx)
fmuls 120(%ebx)
fsts (%esi)
fstps (%edi)
flds 12(%ecx)
fsubs 8(%ecx)
fmuls 120(%ebx)
fsts 512(%edi)
fadds 12(%ecx)
fadds 8(%ecx)
fstps 512(%esi)
flds 16(%ecx)
fsubs 20(%ecx)
fmuls 120(%ebx)
flds 28(%ecx)
fsubs 24(%ecx)
fmuls 120(%ebx)
fsts 768(%edi)
fld %st(0)
fadds 24(%ecx)
fadds 28(%ecx)
fld %st(0)
fadds 16(%ecx)
fadds 20(%ecx)
fstps 768(%esi)
fadd %st(2)
fstps 256(%esi)
faddp %st(1)
fstps 256(%edi)
flds 32(%edx)
fadds 48(%edx)
fstps 896(%esi)
flds 48(%edx)
fadds 40(%edx)
fstps 640(%esi)
flds 40(%edx)
fadds 56(%edx)
fstps 384(%esi)
flds 56(%edx)
fadds 36(%edx)
fstps 128(%esi)
flds 36(%edx)
fadds 52(%edx)
fstps 128(%edi)
flds 52(%edx)
fadds 44(%edx)
fstps 384(%edi)
flds 60(%edx)
fsts 896(%edi)
fadds 44(%edx)
fstps 640(%edi)
flds 96(%edx)
fadds 112(%edx)
fld %st(0)
fadds 64(%edx)
fstps 960(%esi)
fadds 80(%edx)
fstps 832(%esi)
flds 112(%edx)
fadds 104(%edx)
fld %st(0)
fadds 80(%edx)
fstps 704(%esi)
fadds 72(%edx)
fstps 576(%esi)
flds 104(%edx)
fadds 120(%edx)
fld %st(0)
fadds 72(%edx)
fstps 448(%esi)
fadds 88(%edx)
fstps 320(%esi)
flds 120(%edx)
fadds 100(%edx)
fld %st(0)
fadds 88(%edx)
fstps 192(%esi)
fadds 68(%edx)
fstps 64(%esi)
flds 100(%edx)
fadds 116(%edx)
fld %st(0)
fadds 68(%edx)
fstps 64(%edi)
fadds 84(%edx)
fstps 192(%edi)
flds 116(%edx)
fadds 108(%edx)
fld %st(0)
fadds 84(%edx)
fstps 320(%edi)
fadds 76(%edx)
fstps 448(%edi)
flds 108(%edx)
fadds 124(%edx)
fld %st(0)
fadds 76(%edx)
fstps 576(%edi)
fadds 92(%edx)
fstps 704(%edi)
flds 124(%edx)
fsts 960(%edi)
fadds 92(%edx)
fstps 832(%edi)
addl $256,%esp
popl %edi
popl %esi
popl %ebx
ret
.L01:
flds (%ecx)
fadds 4(%ecx)
fistp 512(%esi)
flds (%ecx)
fsubs 4(%ecx)
fmuls 120(%ebx)
fistp (%esi)
flds 12(%ecx)
fsubs 8(%ecx)
fmuls 120(%ebx)
fist 256(%edi)
fadds 12(%ecx)
fadds 8(%ecx)
fistp 256(%esi)
flds 16(%ecx)
fsubs 20(%ecx)
fmuls 120(%ebx)
flds 28(%ecx)
fsubs 24(%ecx)
fmuls 120(%ebx)
fist 384(%edi)
fld %st(0)
fadds 24(%ecx)
fadds 28(%ecx)
fld %st(0)
fadds 16(%ecx)
fadds 20(%ecx)
fistp 384(%esi)
fadd %st(2)
fistp 128(%esi)
faddp %st(1)
fistp 128(%edi)
flds 32(%edx)
fadds 48(%edx)
fistp 448(%esi)
flds 48(%edx)
fadds 40(%edx)
fistp 320(%esi)
flds 40(%edx)
fadds 56(%edx)
fistp 192(%esi)
flds 56(%edx)
fadds 36(%edx)
fistp 64(%esi)
flds 36(%edx)
fadds 52(%edx)
fistp 64(%edi)
flds 52(%edx)
fadds 44(%edx)
fistp 192(%edi)
flds 60(%edx)
fist 448(%edi)
fadds 44(%edx)
fistp 320(%edi)
flds 96(%edx)
fadds 112(%edx)
fld %st(0)
fadds 64(%edx)
fistp 480(%esi)
fadds 80(%edx)
fistp 416(%esi)
flds 112(%edx)
fadds 104(%edx)
fld %st(0)
fadds 80(%edx)
fistp 352(%esi)
fadds 72(%edx)
fistp 288(%esi)
flds 104(%edx)
fadds 120(%edx)
fld %st(0)
fadds 72(%edx)
fistp 224(%esi)
fadds 88(%edx)
fistp 160(%esi)
flds 120(%edx)
fadds 100(%edx)
fld %st(0)
fadds 88(%edx)
fistp 96(%esi)
fadds 68(%edx)
fistp 32(%esi)
flds 100(%edx)
fadds 116(%edx)
fld %st(0)
fadds 68(%edx)
fistp 32(%edi)
fadds 84(%edx)
fistp 96(%edi)
flds 116(%edx)
fadds 108(%edx)
fld %st(0)
fadds 84(%edx)
fistp 160(%edi)
fadds 76(%edx)
fistp 224(%edi)
flds 108(%edx)
fadds 124(%edx)
fld %st(0)
fadds 76(%edx)
fistp 288(%edi)
fadds 92(%edx)
fistp 352(%edi)
flds 124(%edx)
fist 480(%edi)
fadds 92(%edx)
fistp 416(%edi)
movsw
addl $256,%esp
popl %edi
popl %esi
popl %ebx
ret

View File

@@ -1,557 +0,0 @@
/*
dct64_sse: MMX/SSE optimized dct64
copyright 2006-2007 by Zuxy Meng <zuxy.meng@gmail.com> / the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by the mysterious higway for MMX (apparently)
then developed into SSE opt by Zuxy Meng, also building on Romain Dolbeau's AltiVec
Both have agreed to distribution under LGPL 2.1 .
Transformed back into standalone asm, with help of
gcc -S -DHAVE_CONFIG_H -I. -march=pentium3 -O3 -Wall -pedantic -fno-strict-aliasing -DREAL_IS_FLOAT -c -o dct64_sse.{S,c}
Original comment from MPlayer source follows:
*/
/*
* Discrete Cosine Tansform (DCT) for SSE
* based upon code from mp3lib/dct64.c, mp3lib/dct64_altivec.c
* and mp3lib/dct64_MMX.c
*/
#include "mangle.h"
#ifndef __APPLE__
.section .rodata
#else
.data
#endif
ALIGN16
/* .type nnnn, @object
.size nnnn, 16 */
nnnn:
.long -2147483648
.long -2147483648
.long -2147483648
.long -2147483648
ALIGN16
/* .type ppnn, @object
.size ppnn, 16 */
ppnn:
.long 0
.long 0
.long -2147483648
.long -2147483648
ALIGN16
/* .type pnpn, @object
.size pnpn, 16 */
pnpn:
.long 0
.long -2147483648
.long 0
.long -2147483648
ALIGN4
/* .type one.4748, @object
.size one.4748, 4 */
one.4748:
.long 1065353216
/* no .data ? */
/* .local b2.4747 */
ALIGN16
COMM(b2.4747,128,16)
/* .local b1.4746 */
ALIGN16
COMM(b1.4746,128,16)
.text
ALIGN16,,15
.globl ASM_NAME(dct64_sse)
/* .type ASM_NAME(dct64_sse), @function */
ASM_NAME(dct64_sse):
pushl %ebp
movl %esp, %ebp
movl 16(%ebp), %eax
pushl %ebx
movl 8(%ebp), %ecx
#APP
/* for (i = 0; i < 0x20 / 2; i += 4) cycle 1 */
movaps ASM_NAME(costab_mmxsse), %xmm3
shufps $27, %xmm3, %xmm3
MOVUAPS (%eax), %xmm1
movaps %xmm1, %xmm4
MOVUAPS 112(%eax), %xmm2
shufps $27, %xmm4, %xmm4
movaps %xmm2, %xmm0
shufps $27, %xmm0, %xmm0
addps %xmm0, %xmm1
movaps %xmm1, b1.4746
subps %xmm2, %xmm4
mulps %xmm3, %xmm4
movaps %xmm4, b1.4746+112
#NO_APP
movl 12(%ebp), %ebx
#APP
/* for (i = 0; i < 0x20 / 2; i += 4) cycle 2 */
movaps ASM_NAME(costab_mmxsse)+16, %xmm3
shufps $27, %xmm3, %xmm3
MOVUAPS 16(%eax), %xmm1
movaps %xmm1, %xmm4
MOVUAPS 96(%eax), %xmm2
shufps $27, %xmm4, %xmm4
movaps %xmm2, %xmm0
shufps $27, %xmm0, %xmm0
addps %xmm0, %xmm1
movaps %xmm1, b1.4746+16
subps %xmm2, %xmm4
mulps %xmm3, %xmm4
movaps %xmm4, b1.4746+96
/* for (i = 0; i < 0x20 / 2; i += 4) cycle 3 */
movaps ASM_NAME(costab_mmxsse)+32, %xmm3
shufps $27, %xmm3, %xmm3
MOVUAPS 32(%eax), %xmm1
movaps %xmm1, %xmm4
MOVUAPS 80(%eax), %xmm2
shufps $27, %xmm4, %xmm4
movaps %xmm2, %xmm0
shufps $27, %xmm0, %xmm0
addps %xmm0, %xmm1
movaps %xmm1, b1.4746+32
subps %xmm2, %xmm4
mulps %xmm3, %xmm4
movaps %xmm4, b1.4746+80
/* for (i = 0; i < 0x20 / 2; i += 4) cycle 4 */
movaps ASM_NAME(costab_mmxsse)+48, %xmm3
shufps $27, %xmm3, %xmm3
MOVUAPS 48(%eax), %xmm1
movaps %xmm1, %xmm4
MOVUAPS 64(%eax), %xmm2
shufps $27, %xmm4, %xmm4
movaps %xmm2, %xmm0
shufps $27, %xmm0, %xmm0
addps %xmm0, %xmm1
movaps %xmm1, b1.4746+48
subps %xmm2, %xmm4
mulps %xmm3, %xmm4
movaps %xmm4, b1.4746+64
movaps b1.4746, %xmm1
movaps b1.4746+16, %xmm3
movaps b1.4746+32, %xmm4
movaps b1.4746+48, %xmm6
movaps %xmm1, %xmm7
shufps $27, %xmm7, %xmm7
movaps %xmm3, %xmm5
shufps $27, %xmm5, %xmm5
movaps %xmm4, %xmm2
shufps $27, %xmm2, %xmm2
movaps %xmm6, %xmm0
shufps $27, %xmm0, %xmm0
addps %xmm0, %xmm1
movaps %xmm1, b2.4747
addps %xmm2, %xmm3
movaps %xmm3, b2.4747+16
subps %xmm4, %xmm5
movaps %xmm5, b2.4747+32
subps %xmm6, %xmm7
movaps %xmm7, b2.4747+48
movaps b1.4746+64, %xmm1
movaps b1.4746+80, %xmm3
movaps b1.4746+96, %xmm4
movaps b1.4746+112, %xmm6
movaps %xmm1, %xmm7
shufps $27, %xmm7, %xmm7
movaps %xmm3, %xmm5
shufps $27, %xmm5, %xmm5
movaps %xmm4, %xmm2
shufps $27, %xmm2, %xmm2
movaps %xmm6, %xmm0
shufps $27, %xmm0, %xmm0
addps %xmm0, %xmm1
movaps %xmm1, b2.4747+64
addps %xmm2, %xmm3
movaps %xmm3, b2.4747+80
subps %xmm4, %xmm5
movaps %xmm5, b2.4747+96
subps %xmm6, %xmm7
movaps %xmm7, b2.4747+112
movaps b2.4747+32, %xmm0
movaps b2.4747+48, %xmm1
movaps ASM_NAME(costab_mmxsse)+64, %xmm4
xorps %xmm6, %xmm6
shufps $27, %xmm4, %xmm4
mulps %xmm4, %xmm1
movaps ASM_NAME(costab_mmxsse)+80, %xmm2
xorps %xmm7, %xmm7
shufps $27, %xmm2, %xmm2
mulps %xmm2, %xmm0
movaps %xmm0, b2.4747+32
movaps %xmm1, b2.4747+48
movaps b2.4747+96, %xmm3
mulps %xmm2, %xmm3
subps %xmm3, %xmm6
movaps %xmm6, b2.4747+96
movaps b2.4747+112, %xmm5
mulps %xmm4, %xmm5
subps %xmm5, %xmm7
movaps %xmm7, b2.4747+112
movaps ASM_NAME(costab_mmxsse)+96, %xmm0
shufps $27, %xmm0, %xmm0
movaps nnnn, %xmm5
movaps %xmm5, %xmm6
movaps b2.4747, %xmm2
movaps b2.4747+16, %xmm3
movaps %xmm2, %xmm4
xorps %xmm5, %xmm6
shufps $27, %xmm4, %xmm4
movaps %xmm3, %xmm1
shufps $27, %xmm1, %xmm1
addps %xmm1, %xmm2
movaps %xmm2, b1.4746
subps %xmm3, %xmm4
xorps %xmm6, %xmm4
mulps %xmm0, %xmm4
movaps %xmm4, b1.4746+16
movaps b2.4747+32, %xmm2
movaps b2.4747+48, %xmm3
movaps %xmm2, %xmm4
xorps %xmm5, %xmm6
shufps $27, %xmm4, %xmm4
movaps %xmm3, %xmm1
shufps $27, %xmm1, %xmm1
addps %xmm1, %xmm2
movaps %xmm2, b1.4746+32
subps %xmm3, %xmm4
xorps %xmm6, %xmm4
mulps %xmm0, %xmm4
movaps %xmm4, b1.4746+48
movaps b2.4747+64, %xmm2
movaps b2.4747+80, %xmm3
movaps %xmm2, %xmm4
xorps %xmm5, %xmm6
shufps $27, %xmm4, %xmm4
movaps %xmm3, %xmm1
shufps $27, %xmm1, %xmm1
addps %xmm1, %xmm2
movaps %xmm2, b1.4746+64
subps %xmm3, %xmm4
xorps %xmm6, %xmm4
mulps %xmm0, %xmm4
movaps %xmm4, b1.4746+80
movaps b2.4747+96, %xmm2
movaps b2.4747+112, %xmm3
movaps %xmm2, %xmm4
xorps %xmm5, %xmm6
shufps $27, %xmm4, %xmm4
movaps %xmm3, %xmm1
shufps $27, %xmm1, %xmm1
addps %xmm1, %xmm2
movaps %xmm2, b1.4746+96
subps %xmm3, %xmm4
xorps %xmm6, %xmm4
mulps %xmm0, %xmm4
movaps %xmm4, b1.4746+112
movss one.4748, %xmm1
movss ASM_NAME(costab_mmxsse)+112, %xmm0
movaps %xmm1, %xmm3
unpcklps %xmm0, %xmm3
movss ASM_NAME(costab_mmxsse)+116, %xmm2
movaps %xmm1, %xmm0
unpcklps %xmm2, %xmm0
unpcklps %xmm3, %xmm0
movaps ppnn, %xmm2
movaps b1.4746, %xmm3
movaps %xmm3, %xmm4
shufps $20, %xmm4, %xmm4
shufps $235, %xmm3, %xmm3
xorps %xmm2, %xmm3
addps %xmm3, %xmm4
mulps %xmm0, %xmm4
movaps %xmm4, b2.4747
movaps b1.4746+16, %xmm6
movaps %xmm6, %xmm5
shufps $27, %xmm5, %xmm5
xorps %xmm2, %xmm5
addps %xmm5, %xmm6
mulps %xmm0, %xmm6
movaps %xmm6, b2.4747+16
movaps b1.4746+32, %xmm3
movaps %xmm3, %xmm4
shufps $20, %xmm4, %xmm4
shufps $235, %xmm3, %xmm3
xorps %xmm2, %xmm3
addps %xmm3, %xmm4
mulps %xmm0, %xmm4
movaps %xmm4, b2.4747+32
movaps b1.4746+48, %xmm6
movaps %xmm6, %xmm5
shufps $27, %xmm5, %xmm5
xorps %xmm2, %xmm5
addps %xmm5, %xmm6
mulps %xmm0, %xmm6
movaps %xmm6, b2.4747+48
movaps b1.4746+64, %xmm3
movaps %xmm3, %xmm4
shufps $20, %xmm4, %xmm4
shufps $235, %xmm3, %xmm3
xorps %xmm2, %xmm3
addps %xmm3, %xmm4
mulps %xmm0, %xmm4
movaps %xmm4, b2.4747+64
movaps b1.4746+80, %xmm6
movaps %xmm6, %xmm5
shufps $27, %xmm5, %xmm5
xorps %xmm2, %xmm5
addps %xmm5, %xmm6
mulps %xmm0, %xmm6
movaps %xmm6, b2.4747+80
movaps b1.4746+96, %xmm3
movaps %xmm3, %xmm4
shufps $20, %xmm4, %xmm4
shufps $235, %xmm3, %xmm3
xorps %xmm2, %xmm3
addps %xmm3, %xmm4
mulps %xmm0, %xmm4
movaps %xmm4, b2.4747+96
movaps b1.4746+112, %xmm6
movaps %xmm6, %xmm5
shufps $27, %xmm5, %xmm5
xorps %xmm2, %xmm5
addps %xmm5, %xmm6
mulps %xmm0, %xmm6
movaps %xmm6, b2.4747+112
movss ASM_NAME(costab_mmxsse)+120, %xmm0
movaps %xmm1, %xmm2
movaps %xmm0, %xmm7
unpcklps %xmm1, %xmm2
unpcklps %xmm0, %xmm7
movaps pnpn, %xmm0
unpcklps %xmm7, %xmm2
movaps b2.4747+32, %xmm1
movaps %xmm1, %xmm3
shufps $224, %xmm3, %xmm3
shufps $181, %xmm1, %xmm1
xorps %xmm0, %xmm1
addps %xmm1, %xmm3
mulps %xmm2, %xmm3
movaps %xmm3, b1.4746+32
movaps b2.4747+48, %xmm4
movaps %xmm4, %xmm5
shufps $224, %xmm5, %xmm5
shufps $181, %xmm4, %xmm4
xorps %xmm0, %xmm4
addps %xmm4, %xmm5
mulps %xmm2, %xmm5
movaps %xmm5, b1.4746+48
movaps b2.4747+64, %xmm1
movaps %xmm1, %xmm3
shufps $224, %xmm3, %xmm3
shufps $181, %xmm1, %xmm1
xorps %xmm0, %xmm1
addps %xmm1, %xmm3
mulps %xmm2, %xmm3
movaps %xmm3, b1.4746+64
movaps b2.4747+80, %xmm4
movaps %xmm4, %xmm5
shufps $224, %xmm5, %xmm5
shufps $181, %xmm4, %xmm4
xorps %xmm0, %xmm4
addps %xmm4, %xmm5
mulps %xmm2, %xmm5
movaps %xmm5, b1.4746+80
movaps b2.4747+96, %xmm1
movaps %xmm1, %xmm3
shufps $224, %xmm3, %xmm3
shufps $181, %xmm1, %xmm1
xorps %xmm0, %xmm1
addps %xmm1, %xmm3
mulps %xmm2, %xmm3
movaps %xmm3, b1.4746+96
movaps b2.4747+112, %xmm4
movaps %xmm4, %xmm5
shufps $224, %xmm5, %xmm5
shufps $181, %xmm4, %xmm4
xorps %xmm0, %xmm4
addps %xmm4, %xmm5
mulps %xmm2, %xmm5
movaps %xmm5, b1.4746+112
#NO_APP
flds b1.4746+40
movl $b1.4746, %edx
movl $b2.4747, %eax
fadds b1.4746+44
fstps b1.4746+40
flds b1.4746+56
fadds b1.4746+60
flds b1.4746+48
fadd %st(1), %st
fstps b1.4746+48
fadds b1.4746+52
fstps b1.4746+56
flds b1.4746+52
fadds b1.4746+60
fstps b1.4746+52
flds b1.4746+72
fadds b1.4746+76
fstps b1.4746+72
flds b1.4746+88
fadds b1.4746+92
flds b1.4746+80
fadd %st(1), %st
fstps b1.4746+80
fadds b1.4746+84
fstps b1.4746+88
flds b1.4746+84
fadds b1.4746+92
fstps b1.4746+84
flds b1.4746+104
fadds b1.4746+108
fstps b1.4746+104
flds b1.4746+120
fadds b1.4746+124
flds b1.4746+112
fadd %st(1), %st
fstps b1.4746+112
fadds b1.4746+116
fstps b1.4746+120
flds b1.4746+116
fadds b1.4746+124
fstps b1.4746+116
#APP
flds ASM_NAME(costab_mmxsse)+120
flds (%eax)
fadds 4(%eax)
fistp 512(%ecx)
flds (%eax)
fsubs 4(%eax)
fmul %st(1)
fistp (%ecx)
flds 12(%eax)
fsubs 8(%eax)
fmul %st(1)
fist 256(%ebx)
fadds 12(%eax)
fadds 8(%eax)
fistp 256(%ecx)
flds 16(%eax)
fsubs 20(%eax)
fmul %st(1)
flds 28(%eax)
fsubs 24(%eax)
fmul %st(2)
fist 384(%ebx)
fld %st(0)
fadds 24(%eax)
fadds 28(%eax)
fld %st(0)
fadds 16(%eax)
fadds 20(%eax)
fistp 384(%ecx)
fadd %st(2)
fistp 128(%ecx)
faddp %st(1)
fistp 128(%ebx)
flds 32(%edx)
fadds 48(%edx)
fistp 448(%ecx)
flds 48(%edx)
fadds 40(%edx)
fistp 320(%ecx)
flds 40(%edx)
fadds 56(%edx)
fistp 192(%ecx)
flds 56(%edx)
fadds 36(%edx)
fistp 64(%ecx)
flds 36(%edx)
fadds 52(%edx)
fistp 64(%ebx)
flds 52(%edx)
fadds 44(%edx)
fistp 192(%ebx)
flds 60(%edx)
fist 448(%ebx)
fadds 44(%edx)
fistp 320(%ebx)
flds 96(%edx)
fadds 112(%edx)
fld %st(0)
fadds 64(%edx)
fistp 480(%ecx)
fadds 80(%edx)
fistp 416(%ecx)
flds 112(%edx)
fadds 104(%edx)
fld %st(0)
fadds 80(%edx)
fistp 352(%ecx)
fadds 72(%edx)
fistp 288(%ecx)
flds 104(%edx)
fadds 120(%edx)
fld %st(0)
fadds 72(%edx)
fistp 224(%ecx)
fadds 88(%edx)
fistp 160(%ecx)
flds 120(%edx)
fadds 100(%edx)
fld %st(0)
fadds 88(%edx)
fistp 96(%ecx)
fadds 68(%edx)
fistp 32(%ecx)
flds 100(%edx)
fadds 116(%edx)
fld %st(0)
fadds 68(%edx)
fistp 32(%ebx)
fadds 84(%edx)
fistp 96(%ebx)
flds 116(%edx)
fadds 108(%edx)
fld %st(0)
fadds 84(%edx)
fistp 160(%ebx)
fadds 76(%edx)
fistp 224(%ebx)
flds 108(%edx)
fadds 124(%edx)
fld %st(0)
fadds 76(%edx)
fistp 288(%ebx)
fadds 92(%edx)
fistp 352(%ebx)
flds 124(%edx)
fist 480(%ebx)
fadds 92(%edx)
fistp 416(%ebx)
ffreep %st(0)
#NO_APP
movzwl (%ecx), %eax
movw %ax, (%ebx)
popl %ebx
popl %ebp
ret
/* .size ASM_NAME(dct64_sse), .-ASM_NAME(dct64_sse) */

View File

@@ -1,74 +0,0 @@
/*
debug.h:
if DEBUG defined: debugging macro fprintf wrappers
else: macros defined to do nothing
That saves typing #ifdef DEBUG all the time and still preserves
lean code without debugging.
public domain (or LGPL / GPL, if you like that more;-)
generated by debugdef.pl, what was
trivially written by Thomas Orgis <thomas@orgis.org>
*/
/*
I could do that with variadic macros available:
#define sdebug(me, s) fprintf(stderr, "[location] " s "\n")
#define debug(me, s, ...) fprintf(stderr, "[location] " s "}n", __VA_ARGS__)
Variadic macros are a C99 feature...
Now just predefining stuff non-variadic for up to 10 arguments.
It's cumbersome to have them all with different names, though...
*/
#ifdef DEBUG
#include <stdio.h>
#define debug(s) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__)
#define debug1(s, a) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a)
#define debug2(s, a, b) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b)
#define debug3(s, a, b, c) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c)
#define debug4(s, a, b, c, d) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d)
#define debug5(s, a, b, c, d, e) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e)
#define debug6(s, a, b, c, d, e, f) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f)
#define debug7(s, a, b, c, d, e, f, g) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g)
#define debug8(s, a, b, c, d, e, f, g, h) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h)
#define debug9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i)
#define debug10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, "[" __FILE__ ":%i] debug: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j)
#else
#define debug(s)
#define debug1(s, a)
#define debug2(s, a, b)
#define debug3(s, a, b, c)
#define debug4(s, a, b, c, d)
#define debug5(s, a, b, c, d, e)
#define debug6(s, a, b, c, d, e, f)
#define debug7(s, a, b, c, d, e, f, g)
#define debug8(s, a, b, c, d, e, f, g, h)
#define debug9(s, a, b, c, d, e, f, g, h, i)
#define debug10(s, a, b, c, d, e, f, g, h, i, j)
#endif
/* warning macros also here... */
#define warning(s) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__)
#define warning1(s, a) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a)
#define warning2(s, a, b) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b)
#define warning3(s, a, b, c) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c)
#define warning4(s, a, b, c, d) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d)
#define warning5(s, a, b, c, d, e) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e)
#define warning6(s, a, b, c, d, e, f) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f)
#define warning7(s, a, b, c, d, e, f, g) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g)
#define warning8(s, a, b, c, d, e, f, g, h) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h)
#define warning9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i)
#define warning10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, "[" __FILE__ ":%i] warning: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j)
/* error macros also here... */
#define error(s) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__)
#define error1(s, a) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a)
#define error2(s, a, b) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b)
#define error3(s, a, b, c) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c)
#define error4(s, a, b, c, d) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d)
#define error5(s, a, b, c, d, e) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e)
#define error6(s, a, b, c, d, e, f) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f)
#define error7(s, a, b, c, d, e, f, g) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g)
#define error8(s, a, b, c, d, e, f, g, h) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h)
#define error9(s, a, b, c, d, e, f, g, h, i) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i)
#define error10(s, a, b, c, d, e, f, g, h, i, j) fprintf(stderr, "[" __FILE__ ":%i] error: " s "\n", __LINE__, a, b, c, d, e, f, g, h, i, j)

View File

@@ -1,231 +0,0 @@
/*
decode.c: decoding samples...
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.org
initially written by Michael Hipp
*/
#include <math.h>
#include <string.h>
#include "mpg123.h"
#include "decode.h"
/* 8bit functions silenced for FLOATOUT */
int synth_1to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[64];
sample_t *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++) {
#ifdef FLOATOUT
*samples = 0;
#else
*samples = conv16to8[*tmp1>>AUSHIFT];
#endif
samples += 2;
tmp1 += 2;
}
*pnt += 64;
return ret;
}
int synth_1to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[64];
sample_t *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++) {
#ifdef FLOATOUT
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += 32;
return ret;
}
int synth_1to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[64];
sample_t *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++) {
#ifdef FLOATOUT
*samples++ = 0;
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += 64;
return ret;
}
int synth_1to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[64];
sample_t *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++) {
*( (sample_t *)samples) = *tmp1;
samples += sizeof(sample_t);
tmp1 += 2;
}
*pnt += 32*sizeof(sample_t);
return ret;
}
int synth_1to1_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
{
int i,ret;
ret = synth_1to1(bandPtr,0,samples,pnt);
samples = samples + *pnt - 64*sizeof(sample_t);
for(i=0;i<32;i++) {
((sample_t *)samples)[1] = ((sample_t *)samples)[0];
samples+=2*sizeof(sample_t);
}
return ret;
}
int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
{
static real buffs[2][2][0x110];
static const int step = 2;
static int bo = 1;
sample_t *samples = (sample_t *) (out+*pnt);
real *b0,(*buf)[0x110];
int clip = 0;
int bo1;
if(have_eq_settings)
do_equalizer(bandPtr,channel);
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 = opt_decwin + 16 - bo1;
for (j=16;j;j--,window+=0x10,samples+=step)
{
real sum;
sum = REAL_MUL(*window++, *b0++);
sum -= REAL_MUL(*window++, *b0++);
sum += REAL_MUL(*window++, *b0++);
sum -= REAL_MUL(*window++, *b0++);
sum += REAL_MUL(*window++, *b0++);
sum -= REAL_MUL(*window++, *b0++);
sum += REAL_MUL(*window++, *b0++);
sum -= REAL_MUL(*window++, *b0++);
sum += REAL_MUL(*window++, *b0++);
sum -= REAL_MUL(*window++, *b0++);
sum += REAL_MUL(*window++, *b0++);
sum -= REAL_MUL(*window++, *b0++);
sum += REAL_MUL(*window++, *b0++);
sum -= REAL_MUL(*window++, *b0++);
sum += REAL_MUL(*window++, *b0++);
sum -= REAL_MUL(*window++, *b0++);
WRITE_SAMPLE(samples,sum,clip);
}
{
real sum;
sum = REAL_MUL(window[0x0], b0[0x0]);
sum += REAL_MUL(window[0x2], b0[0x2]);
sum += REAL_MUL(window[0x4], b0[0x4]);
sum += REAL_MUL(window[0x6], b0[0x6]);
sum += REAL_MUL(window[0x8], b0[0x8]);
sum += REAL_MUL(window[0xA], b0[0xA]);
sum += REAL_MUL(window[0xC], b0[0xC]);
sum += REAL_MUL(window[0xE], b0[0xE]);
WRITE_SAMPLE(samples,sum,clip);
b0-=0x10,window-=0x20,samples+=step;
}
window += bo1<<1;
for (j=15;j;j--,b0-=0x20,window-=0x10,samples+=step)
{
real sum;
sum = -REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
sum -= REAL_MUL(*(--window), *b0++);
WRITE_SAMPLE(samples,sum,clip);
}
}
*pnt += 64*sizeof(sample_t);
return clip;
}

View File

@@ -1,18 +0,0 @@
/*
decode.h: common definitions for decode functions
copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Thomas Orgis, taking WRITE_SAMPLE from decode.c
*/
#ifdef FLOATOUT
#define WRITE_SAMPLE(samples,sum,clip) *(samples) = sum
#define sample_t float
#else
#define WRITE_SAMPLE(samples,sum,clip) \
if( (sum) > REAL_PLUS_32767) { *(samples) = 0x7fff; (clip)++; } \
else if( (sum) < REAL_MINUS_32768) { *(samples) = -0x8000; (clip)++; } \
else { *(samples) = REAL_TO_SHORT(sum); }
#define sample_t short
#endif

View File

@@ -1,238 +0,0 @@
/*
decode_2to1.c: ...with 2to1 downsampling
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.org
initially written by Michael Hipp
*/
#include <math.h>
#include <string.h>
#include "mpg123.h"
#include "decode.h"
int synth_2to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[32];
sample_t *tmp1 = samples_tmp + channel;
int i,ret;
int pnt1 = 0;
ret = synth_2to1(bandPtr,channel,(unsigned char *) samples_tmp,&pnt1);
samples += channel + *pnt;
for(i=0;i<16;i++) {
#ifdef FLOATOUT
*samples = 0;
#else
*samples = conv16to8[*tmp1>>AUSHIFT];
#endif
samples += 2;
tmp1 += 2;
}
*pnt += 32;
return ret;
}
int synth_2to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[32];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = synth_2to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
samples += *pnt;
for(i=0;i<16;i++) {
#ifdef FLOATOUT
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += 16;
return ret;
}
int synth_2to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[32];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = synth_2to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
samples += *pnt;
for(i=0;i<16;i++) {
#ifdef FLOATOUT
*samples++ = 0;
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += 32;
return ret;
}
int synth_2to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[32];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1=0;
ret = synth_2to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
samples += *pnt;
for(i=0;i<16;i++) {
*( (sample_t *) samples) = *tmp1;
samples += sizeof(sample_t);
tmp1 += 2;
}
*pnt += 16*sizeof(sample_t);
return ret;
}
int synth_2to1_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
{
int i,ret;
ret = synth_2to1(bandPtr,0,samples,pnt);
samples = samples + *pnt - 32*sizeof(sample_t);
for(i=0;i<16;i++) {
((sample_t *)samples)[1] = ((sample_t *)samples)[0];
samples+=2*sizeof(sample_t);
}
return ret;
}
int synth_2to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
{
static real buffs[2][2][0x110];
static const int step = 2;
static int bo = 1;
sample_t *samples = (sample_t *) (out + *pnt);
real *b0,(*buf)[0x110];
int clip = 0;
int bo1;
if(have_eq_settings)
do_equalizer(bandPtr,channel);
if(!channel) {
bo--;
bo &= 0xf;
buf = buffs[0];
}
else {
samples++;
buf = buffs[1];
}
if(bo & 0x1) {
b0 = buf[0];
bo1 = bo;
opt_dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
}
else {
b0 = buf[1];
bo1 = bo+1;
opt_dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
}
{
register int j;
real *window = opt_decwin + 16 - bo1;
for (j=8;j;j--,b0+=0x10,window+=0x30)
{
real sum;
sum = *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
WRITE_SAMPLE(samples,sum,clip); samples += step;
#if 0
WRITE_SAMPLE(samples,sum,clip); samples += step;
#endif
}
{
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); samples += step;
#if 0
WRITE_SAMPLE(samples,sum,clip); samples += step;
#endif
b0-=0x20,window-=0x40;
}
window += bo1<<1;
for (j=7;j;j--,b0-=0x30,window-=0x30)
{
real sum;
sum = -*(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
WRITE_SAMPLE(samples,sum,clip); samples += step;
#if 0
WRITE_SAMPLE(samples,sum,clip); samples += step;
#endif
}
}
*pnt += 32*sizeof(sample_t);
return clip;
}

View File

@@ -1,288 +0,0 @@
/*
decode_3dnow.s - 3DNow! optimized synth_1to1()
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.org
initially written by Syuuhei Kashiyama
This code based 'decode_3dnow.s' by Syuuhei Kashiyama
<squash@mb.kcom.ne.jp>,only two types of changes have been made:
- remove PREFETCH instruction for speedup
- change function name for support 3DNow! automatic detect
- femms moved to before 'call dct64_3dnow'
You can find Kashiyama's original 3dnow! support patch
(for mpg123-0.59o) at
http://user.ecc.u-tokyo.ac.jp/~g810370/linux-simd/ (Japanese).
by KIMURA Takuhiro <kim@hannah.ipc.miyakyo-u.ac.jp> - until 31.Mar.1999
<kim@comtec.co.jp> - after 1.Apr.1999
Replacement of synth_1to1() with AMD's 3DNow! SIMD operations support
Syuuhei Kashiyama <squash@mb.kcom.ne.jp>
The author of this program disclaim whole expressed or implied
warranties with regard to this program, and in no event shall the
author of this program liable to whatever resulted from the use of
this program. Use it at your own risk.
*/
#include "mangle.h"
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__)
.comm buffs.40,4352
#else
.local buffs.40
.comm buffs.40,4352,32
#endif
.data
ALIGN4
/* .type bo.42,@object */
/* .size bo.42,4 */
bo.42:
.long 1
.text
.globl ASM_NAME(synth_1to1_3dnow)
/* .type ASM_NAME(synth_1to1_3dnow),@function */
ASM_NAME(synth_1to1_3dnow):
subl $24,%esp
pushl %ebp
pushl %edi
xorl %ebp,%ebp
pushl %esi
pushl %ebx
movl 56(%esp),%esi
movl 52(%esp),%edi
movl 0(%esi),%esi
movl 48(%esp),%ebx
addl %edi,%esi
movl %esi,16(%esp)
femms
/* fixed by Takuhiro */
cmpl $0,ASM_NAME(equalfile)
je .L25
pushl %ebx
pushl 48(%esp)
call ASM_NAME(do_equalizer_3dnow)
addl $8,%esp
.L25:
testl %ebx,%ebx
jne .L26
decl bo.42
movl $buffs.40,%ecx
andl $15,bo.42
jmp .L27
.L26:
addl $2,16(%esp)
movl $buffs.40+2176,%ecx
.L27:
movl bo.42,%edx
testb $1,%dl
je .L28
movl %edx,36(%esp)
movl %ecx,%ebx
movl 44(%esp),%esi
movl %edx,%edi
pushl %esi
sall $2,%edi
movl %ebx,%eax
movl %edi,24(%esp)
addl %edi,%eax
pushl %eax
movl %edx,%eax
incl %eax
andl $15,%eax
leal 1088(,%eax,4),%eax
addl %ebx,%eax
pushl %eax
call ASM_NAME(dct64_3dnow)
addl $12,%esp
jmp .L29
.L28:
leal 1(%edx),%esi
movl 44(%esp),%edi
movl %esi,36(%esp)
leal 1092(%ecx,%edx,4),%eax
pushl %edi
leal 1088(%ecx),%ebx
pushl %eax
sall $2,%esi
leal (%ecx,%edx,4),%eax
pushl %eax
call ASM_NAME(dct64_3dnow)
addl $12,%esp
movl %esi,20(%esp)
.L29:
movl $ASM_NAME(decwin)+64,%edx
movl $16,%ecx
subl 20(%esp),%edx
movl 16(%esp),%edi
movq (%edx),%mm0
movq (%ebx),%mm1
ALIGN32
.L33:
movq 8(%edx),%mm3
pfmul %mm1,%mm0
movq 8(%ebx),%mm4
movq 16(%edx),%mm5
pfmul %mm4,%mm3
movq 16(%ebx),%mm6
pfadd %mm3,%mm0
movq 24(%edx),%mm1
pfmul %mm6,%mm5
movq 24(%ebx),%mm2
pfadd %mm5,%mm0
movq 32(%edx),%mm3
pfmul %mm2,%mm1
movq 32(%ebx),%mm4
pfadd %mm1,%mm0
movq 40(%edx),%mm5
pfmul %mm4,%mm3
movq 40(%ebx),%mm6
pfadd %mm3,%mm0
movq 48(%edx),%mm1
pfmul %mm6,%mm5
movq 48(%ebx),%mm2
pfadd %mm0,%mm5
movq 56(%edx),%mm3
pfmul %mm1,%mm2
movq 56(%ebx),%mm4
pfadd %mm5,%mm2
addl $64,%ebx
subl $-128,%edx
movq (%edx),%mm0
pfmul %mm4,%mm3
movq (%ebx),%mm1
pfadd %mm3,%mm2
movq %mm2,%mm3
psrlq $32,%mm3
pfsub %mm3,%mm2
incl %ebp
pf2id %mm2,%mm2
packssdw %mm2,%mm2
movd %mm2,%eax
movw %ax,0(%edi)
addl $4,%edi
decl %ecx
jnz .L33
movd (%ebx),%mm0
movd (%edx),%mm1
punpckldq 8(%ebx),%mm0
punpckldq 8(%edx),%mm1
movd 16(%ebx),%mm3
movd 16(%edx),%mm4
pfmul %mm1,%mm0
punpckldq 24(%ebx),%mm3
punpckldq 24(%edx),%mm4
movd 32(%ebx),%mm5
movd 32(%edx),%mm6
pfmul %mm4,%mm3
punpckldq 40(%ebx),%mm5
punpckldq 40(%edx),%mm6
pfadd %mm3,%mm0
movd 48(%ebx),%mm1
movd 48(%edx),%mm2
pfmul %mm6,%mm5
punpckldq 56(%ebx),%mm1
punpckldq 56(%edx),%mm2
pfadd %mm5,%mm0
pfmul %mm2,%mm1
pfadd %mm1,%mm0
pfacc %mm1,%mm0
pf2id %mm0,%mm0
packssdw %mm0,%mm0
movd %mm0,%eax
movw %ax,0(%edi)
incl %ebp
movl 36(%esp),%esi
addl $-64,%ebx
movl $15,%ebp
addl $4,%edi
leal -128(%edx,%esi,8),%edx
movl $15,%ecx
movd (%ebx),%mm0
movd -4(%edx),%mm1
punpckldq 4(%ebx),%mm0
punpckldq -8(%edx),%mm1
ALIGN32
.L46:
movd 8(%ebx),%mm3
movd -12(%edx),%mm4
pfmul %mm1,%mm0
punpckldq 12(%ebx),%mm3
punpckldq -16(%edx),%mm4
movd 16(%ebx),%mm5
movd -20(%edx),%mm6
pfmul %mm4,%mm3
punpckldq 20(%ebx),%mm5
punpckldq -24(%edx),%mm6
pfadd %mm3,%mm0
movd 24(%ebx),%mm1
movd -28(%edx),%mm2
pfmul %mm6,%mm5
punpckldq 28(%ebx),%mm1
punpckldq -32(%edx),%mm2
pfadd %mm5,%mm0
movd 32(%ebx),%mm3
movd -36(%edx),%mm4
pfmul %mm2,%mm1
punpckldq 36(%ebx),%mm3
punpckldq -40(%edx),%mm4
pfadd %mm1,%mm0
movd 40(%ebx),%mm5
movd -44(%edx),%mm6
pfmul %mm4,%mm3
punpckldq 44(%ebx),%mm5
punpckldq -48(%edx),%mm6
pfadd %mm3,%mm0
movd 48(%ebx),%mm1
movd -52(%edx),%mm2
pfmul %mm6,%mm5
punpckldq 52(%ebx),%mm1
punpckldq -56(%edx),%mm2
pfadd %mm0,%mm5
movd 56(%ebx),%mm3
movd -60(%edx),%mm4
pfmul %mm2,%mm1
punpckldq 60(%ebx),%mm3
punpckldq (%edx),%mm4
pfadd %mm1,%mm5
addl $-128,%edx
addl $-64,%ebx
movd (%ebx),%mm0
movd -4(%edx),%mm1
pfmul %mm4,%mm3
punpckldq 4(%ebx),%mm0
punpckldq -8(%edx),%mm1
pfadd %mm5,%mm3
pfacc %mm3,%mm3
incl %ebp
pf2id %mm3,%mm3
movd %mm3,%eax
negl %eax
movd %eax,%mm3
packssdw %mm3,%mm3
movd %mm3,%eax
movw %ax,(%edi)
addl $4,%edi
decl %ecx
jnz .L46
femms
movl 56(%esp),%esi
movl %ebp,%eax
subl $-128,0(%esi)
popl %ebx
popl %esi
popl %edi
popl %ebp
addl $24,%esp
ret

View File

@@ -1,247 +0,0 @@
/*
decode_4to1.c: ...with 4to1 downsampling / decoding of every 4th sample
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.org
initially written by Michael Hipp
dunno why it sounds THIS annoying (maybe we should adapt the window?)
absolutely not optimized for this operation
*/
#include <math.h>
#include <string.h>
#include "mpg123.h"
#include "decode.h"
int synth_4to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[16];
sample_t *tmp1 = samples_tmp + channel;
int i,ret;
int pnt1 = 0;
ret = synth_4to1(bandPtr,channel,(unsigned char *) samples_tmp,&pnt1);
samples += channel + *pnt;
for(i=0;i<8;i++) {
#ifdef FLOATOUT
*samples = 0;
#else
*samples = conv16to8[*tmp1>>AUSHIFT];
#endif
samples += 2;
tmp1 += 2;
}
*pnt += 16;
return ret;
}
int synth_4to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[16];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = synth_4to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
samples += *pnt;
for(i=0;i<8;i++) {
#ifdef FLOATOUT
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += 8;
return ret;
}
int synth_4to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[16];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = synth_4to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
samples += *pnt;
for(i=0;i<8;i++) {
#ifdef FLOATOUT
*samples++ = 0;
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += 16;
return ret;
}
int synth_4to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[16];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = synth_4to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
samples += *pnt;
for(i=0;i<8;i++) {
*( (sample_t *)samples) = *tmp1;
samples += sizeof(sample_t);
tmp1 += 2;
}
*pnt += 8*sizeof(sample_t);
return ret;
}
int synth_4to1_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
{
int i,ret;
ret = synth_4to1(bandPtr,0,samples,pnt);
samples = samples + *pnt - 16*sizeof(sample_t);
for(i=0;i<8;i++) {
((sample_t *)samples)[1] = ((sample_t *)samples)[0];
samples+=2*sizeof(sample_t);
}
return ret;
}
int synth_4to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
{
static real buffs[2][2][0x110];
static const int step = 2;
static int bo = 1;
sample_t *samples = (sample_t *) (out + *pnt);
real *b0,(*buf)[0x110];
int clip = 0;
int bo1;
if(have_eq_settings)
do_equalizer(bandPtr,channel);
if(!channel) {
bo--;
bo &= 0xf;
buf = buffs[0];
}
else {
samples++;
buf = buffs[1];
}
if(bo & 0x1) {
b0 = buf[0];
bo1 = bo;
opt_dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
}
else {
b0 = buf[1];
bo1 = bo+1;
opt_dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
}
{
register int j;
real *window = opt_decwin + 16 - bo1;
for (j=4;j;j--,b0+=0x30,window+=0x70)
{
real sum;
sum = *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
WRITE_SAMPLE(samples,sum,clip); samples += step;
#if 0
WRITE_SAMPLE(samples,sum,clip); samples += step;
WRITE_SAMPLE(samples,sum,clip); samples += step;
WRITE_SAMPLE(samples,sum,clip); samples += step;
#endif
}
{
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); samples += step;
#if 0
WRITE_SAMPLE(samples,sum,clip); samples += step;
WRITE_SAMPLE(samples,sum,clip); samples += step;
WRITE_SAMPLE(samples,sum,clip); samples += step;
#endif
b0-=0x40,window-=0x80;
}
window += bo1<<1;
for (j=3;j;j--,b0-=0x50,window-=0x70)
{
real sum;
sum = -*(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
WRITE_SAMPLE(samples,sum,clip); samples += step;
#if 0
WRITE_SAMPLE(samples,sum,clip); samples += step;
WRITE_SAMPLE(samples,sum,clip); samples += step;
WRITE_SAMPLE(samples,sum,clip); samples += step;
#endif
}
}
*pnt += 16*sizeof(sample_t);
return clip;
}

View File

@@ -1,582 +0,0 @@
/*
decode.c: decoding samples...
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.org
initially written by Michael Hipp
altivec optimization by tmkk
*/
#include <math.h>
#include <string.h>
#include "mpg123.h"
#ifndef __APPLE__
#include <altivec.h>
#endif
#define WRITE_SAMPLE(samples,sum,clip) \
if( (sum) > REAL_PLUS_32767) { *(samples) = 0x7fff; (clip)++; } \
else if( (sum) < REAL_MINUS_32768) { *(samples) = -0x8000; (clip)++; } \
else { *(samples) = REAL_TO_SHORT(sum); }
int synth_1to1_8bit_altivec(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_altivec(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_altivec(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[64];
short *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = synth_1to1_altivec(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_altivec(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[64];
short *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = synth_1to1_altivec(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_altivec(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[64];
short *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = synth_1to1_altivec(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;
}
int synth_1to1_mono2stereo_altivec(real *bandPtr,unsigned char *samples,int *pnt)
{
int i,ret;
ret = synth_1to1_altivec(bandPtr,0,samples,pnt);
samples = samples + *pnt - 128;
for(i=0;i<32;i++) {
((short *)samples)[1] = ((short *)samples)[0];
samples+=4;
}
return ret;
}
int synth_1to1_altivec(real *bandPtr,int channel,unsigned char *out,int *pnt)
{
static ALIGNED(16) real buffs[4][4][0x110];
static const int step = 2;
static int bo = 1;
short *samples = (short *) (out+*pnt);
real *b0,(*buf)[0x110];
int clip = 0;
int bo1;
if(have_eq_settings)
do_equalizer(bandPtr,channel);
if(!channel) {
bo--;
bo &= 0xf;
buf = buffs[0];
}
else {
samples++;
buf = buffs[1];
}
if(bo & 0x1) {
b0 = buf[0];
bo1 = bo;
dct64_altivec(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
}
else {
b0 = buf[1];
bo1 = bo+1;
dct64_altivec(buf[0]+bo,buf[1]+bo+1,bandPtr);
}
{
register int j;
real *window = decwin + 16 - bo1;
ALIGNED(16) int clip_tmp[4];
vector float v1,v2,v3,v4,v5,v6,v7,v8,v9;
vector unsigned char vperm1,vperm2,vperm3,vperm4,vperm5;
vector float vsum,vsum2,vsum3,vsum4,vmin,vmax;
vector signed int vclip;
vector signed short vsample1,vsample2;
vclip = vec_xor(vclip,vclip);
#ifdef __APPLE__
vmax = (vector float)(32767.0f);
vmin = (vector float)(-32768.0f);
vperm5 = (vector unsigned char)(0,1,18,19,2,3,22,23,4,5,26,27,6,7,30,31);
#else
vmax = (vector float){32767.0f,32767.0f,32767.0f,32767.0f};
vmin = (vector float){-32768.0f,-32768.0f,-32768.0f,-32768.0f};
vperm5 = (vector unsigned char){0,1,18,19,2,3,22,23,4,5,26,27,6,7,30,31};
#endif
vperm1 = vec_lvsl(0,window);
vperm3 = vec_lvsl(0,samples);
vperm4 = vec_lvsr(0,samples);
for (j=4;j;j--)
{
vsum = vec_xor(vsum,vsum);
vsum2 = vec_xor(vsum2,vsum2);
vsum3 = vec_xor(vsum3,vsum3);
vsum4 = vec_xor(vsum4,vsum4);
v1 = vec_ld(0,window);
v2 = vec_ld(16,window);
v3 = vec_ld(32,window);
v4 = vec_ld(48,window);
v5 = vec_ld(64,window);
v1 = vec_perm(v1,v2,vperm1);
v6 = vec_ld(0,b0);
v2 = vec_perm(v2,v3,vperm1);
v7 = vec_ld(16,b0);
v3 = vec_perm(v3,v4,vperm1);
v8 = vec_ld(32,b0);
v4 = vec_perm(v4,v5,vperm1);
v9 = vec_ld(48,b0);
vsum = vec_madd(v1,v6,vsum);
vsum = vec_madd(v2,v7,vsum);
vsum = vec_madd(v3,v8,vsum);
vsum = vec_madd(v4,v9,vsum);
window += 32;
b0 += 16;
v1 = vec_ld(0,window);
v2 = vec_ld(16,window);
v3 = vec_ld(32,window);
v4 = vec_ld(48,window);
v5 = vec_ld(64,window);
v1 = vec_perm(v1,v2,vperm1);
v6 = vec_ld(0,b0);
v2 = vec_perm(v2,v3,vperm1);
v7 = vec_ld(16,b0);
v3 = vec_perm(v3,v4,vperm1);
v8 = vec_ld(32,b0);
v4 = vec_perm(v4,v5,vperm1);
v9 = vec_ld(48,b0);
vsum2 = vec_madd(v1,v6,vsum2);
vsum2 = vec_madd(v2,v7,vsum2);
vsum2 = vec_madd(v3,v8,vsum2);
vsum2 = vec_madd(v4,v9,vsum2);
window += 32;
b0 += 16;
v1 = vec_ld(0,window);
v2 = vec_ld(16,window);
v3 = vec_ld(32,window);
v4 = vec_ld(48,window);
v5 = vec_ld(64,window);
v1 = vec_perm(v1,v2,vperm1);
v6 = vec_ld(0,b0);
v2 = vec_perm(v2,v3,vperm1);
v7 = vec_ld(16,b0);
v3 = vec_perm(v3,v4,vperm1);
v8 = vec_ld(32,b0);
v4 = vec_perm(v4,v5,vperm1);
v9 = vec_ld(48,b0);
vsum3 = vec_madd(v1,v6,vsum3);
vsum3 = vec_madd(v2,v7,vsum3);
vsum3 = vec_madd(v3,v8,vsum3);
vsum3 = vec_madd(v4,v9,vsum3);
window += 32;
b0 += 16;
v1 = vec_ld(0,window);
v2 = vec_ld(16,window);
v3 = vec_ld(32,window);
v4 = vec_ld(48,window);
v5 = vec_ld(64,window);
v1 = vec_perm(v1,v2,vperm1);
v6 = vec_ld(0,b0);
v2 = vec_perm(v2,v3,vperm1);
v7 = vec_ld(16,b0);
v3 = vec_perm(v3,v4,vperm1);
v8 = vec_ld(32,b0);
v4 = vec_perm(v4,v5,vperm1);
v9 = vec_ld(48,b0);
vsum4 = vec_madd(v1,v6,vsum4);
vsum4 = vec_madd(v2,v7,vsum4);
vsum4 = vec_madd(v3,v8,vsum4);
vsum4 = vec_madd(v4,v9,vsum4);
window += 32;
b0 += 16;
v1 = vec_mergeh(vsum,vsum3);
v2 = vec_mergeh(vsum2,vsum4);
v3 = vec_mergel(vsum,vsum3);
v4 = vec_mergel(vsum2,vsum4);
v5 = vec_mergeh(v1,v2);
v6 = vec_mergel(v1,v2);
v7 = vec_mergeh(v3,v4);
v8 = vec_mergel(v3,v4);
vsum = vec_sub(v5,v6);
v9 = vec_sub(v7,v8);
vsum = vec_add(vsum,v9);
v3 = (vector float)vec_cts(vsum,0);
v1 = (vector float)vec_cmpgt(vsum,vmax);
v2 = (vector float)vec_cmplt(vsum,vmin);
vsample1 = vec_ld(0,samples);
vsample2 = vec_ld(15,samples);
v3 = (vector float)vec_packs((vector signed int)v3,(vector signed int)v3);
v4 = (vector float)vec_perm(vsample1,vsample2,vperm3);
v5 = (vector float)vec_perm(v3,v4,vperm5);
v6 = (vector float)vec_perm(vsample2,vsample1,vperm3);
v7 = (vector float)vec_perm(v5,v6,vperm4);
v8 = (vector float)vec_perm(v6,v5,vperm4);
vec_st((vector signed short)v7,15,samples);
vec_st((vector signed short)v8,0,samples);
samples += 8;
#ifdef __APPLE__
v1 = (vector float)vec_sr((vector unsigned int)v1,(vector unsigned int)(31));
v2 = (vector float)vec_sr((vector unsigned int)v2,(vector unsigned int)(31));
#else
v1 = (vector float)vec_sr((vector unsigned int)v1,(vector unsigned int){31,31,31,31});
v2 = (vector float)vec_sr((vector unsigned int)v2,(vector unsigned int){31,31,31,31});
#endif
v5 = (vector float)vec_add((vector unsigned int)v1,(vector unsigned int)v2);
vclip = vec_sums((vector signed int)v5,vclip);
}
{
real sum;
sum = REAL_MUL(window[0x0], b0[0x0]);
sum += REAL_MUL(window[0x2], b0[0x2]);
sum += REAL_MUL(window[0x4], b0[0x4]);
sum += REAL_MUL(window[0x6], b0[0x6]);
sum += REAL_MUL(window[0x8], b0[0x8]);
sum += REAL_MUL(window[0xA], b0[0xA]);
sum += REAL_MUL(window[0xC], b0[0xC]);
sum += REAL_MUL(window[0xE], b0[0xE]);
WRITE_SAMPLE(samples,sum,clip);
b0-=0x10,window-=0x20,samples+=step;
}
window += bo1<<1;
vperm1 = vec_lvsl(0,window);
#ifdef __APPLE__
vperm2 = vec_perm(vperm1,vperm1,(vector unsigned char)(12,13,14,15,8,9,10,11,4,5,6,7,0,1,2,3));
#else
vperm2 = vec_perm(vperm1,vperm1,(vector unsigned char){12,13,14,15,8,9,10,11,4,5,6,7,0,1,2,3});
#endif
vperm3 = vec_lvsl(0,samples);
vperm4 = vec_lvsr(0,samples);
for (j=3;j;j--)
{
vsum = vec_xor(vsum,vsum);
vsum2 = vec_xor(vsum2,vsum2);
vsum3 = vec_xor(vsum3,vsum3);
vsum4 = vec_xor(vsum4,vsum4);
v1 = vec_ld(-1,window);
v2 = vec_ld(-16,window);
v3 = vec_ld(-32,window);
v4 = vec_ld(-48,window);
v5 = vec_ld(-64,window);
v1 = vec_perm(v2,v1,vperm2);
v6 = vec_ld(0,b0);
v2 = vec_perm(v3,v2,vperm2);
v7 = vec_ld(16,b0);
v3 = vec_perm(v4,v3,vperm2);
v8 = vec_ld(32,b0);
v4 = vec_perm(v5,v4,vperm2);
v9 = vec_ld(48,b0);
vsum = vec_nmsub(v1,v6,vsum);
vsum = vec_nmsub(v2,v7,vsum);
vsum = vec_nmsub(v3,v8,vsum);
vsum = vec_nmsub(v4,v9,vsum);
window -= 32;
b0 -= 16;
v1 = vec_ld(0,window);
v2 = vec_ld(-16,window);
v3 = vec_ld(-32,window);
v4 = vec_ld(-48,window);
v5 = vec_ld(-64,window);
v1 = vec_perm(v2,v1,vperm2);
v6 = vec_ld(0,b0);
v2 = vec_perm(v3,v2,vperm2);
v7 = vec_ld(16,b0);
v3 = vec_perm(v4,v3,vperm2);
v8 = vec_ld(32,b0);
v4 = vec_perm(v5,v4,vperm2);
v9 = vec_ld(48,b0);
vsum2 = vec_nmsub(v1,v6,vsum2);
vsum2 = vec_nmsub(v2,v7,vsum2);
vsum2 = vec_nmsub(v3,v8,vsum2);
vsum2 = vec_nmsub(v4,v9,vsum2);
window -= 32;
b0 -= 16;
v1 = vec_ld(0,window);
v2 = vec_ld(-16,window);
v3 = vec_ld(-32,window);
v4 = vec_ld(-48,window);
v5 = vec_ld(-64,window);
v1 = vec_perm(v2,v1,vperm2);
v6 = vec_ld(0,b0);
v2 = vec_perm(v3,v2,vperm2);
v7 = vec_ld(16,b0);
v3 = vec_perm(v4,v3,vperm2);
v8 = vec_ld(32,b0);
v4 = vec_perm(v5,v4,vperm2);
v9 = vec_ld(48,b0);
vsum3 = vec_nmsub(v1,v6,vsum3);
vsum3 = vec_nmsub(v2,v7,vsum3);
vsum3 = vec_nmsub(v3,v8,vsum3);
vsum3 = vec_nmsub(v4,v9,vsum3);
window -= 32;
b0 -= 16;
v1 = vec_ld(0,window);
v2 = vec_ld(-16,window);
v3 = vec_ld(-32,window);
v4 = vec_ld(-48,window);
v5 = vec_ld(-64,window);
v1 = vec_perm(v2,v1,vperm2);
v6 = vec_ld(0,b0);
v2 = vec_perm(v3,v2,vperm2);
v7 = vec_ld(16,b0);
v3 = vec_perm(v4,v3,vperm2);
v8 = vec_ld(32,b0);
v4 = vec_perm(v5,v4,vperm2);
v9 = vec_ld(48,b0);
vsum4 = vec_nmsub(v1,v6,vsum4);
vsum4 = vec_nmsub(v2,v7,vsum4);
vsum4 = vec_nmsub(v3,v8,vsum4);
vsum4 = vec_nmsub(v4,v9,vsum4);
window -= 32;
b0 -= 16;
v1 = vec_mergeh(vsum,vsum3);
v2 = vec_mergeh(vsum2,vsum4);
v3 = vec_mergel(vsum,vsum3);
v4 = vec_mergel(vsum2,vsum4);
v5 = vec_mergeh(v1,v2);
v6 = vec_mergel(v1,v2);
v7 = vec_mergeh(v3,v4);
v8 = vec_mergel(v3,v4);
vsum = vec_add(v5,v6);
v9 = vec_add(v7,v8);
vsum = vec_add(vsum,v9);
v3 = (vector float)vec_cts(vsum,0);
v1 = (vector float)vec_cmpgt(vsum,vmax);
v2 = (vector float)vec_cmplt(vsum,vmin);
vsample1 = vec_ld(0,samples);
vsample2 = vec_ld(15,samples);
v3 = (vector float)vec_packs((vector signed int)v3,(vector signed int)v3);
v4 = (vector float)vec_perm(vsample1,vsample2,vperm3);
v5 = (vector float)vec_perm(v3,v4,vperm5);
v6 = (vector float)vec_perm(vsample2,vsample1,vperm3);
v7 = (vector float)vec_perm(v5,v6,vperm4);
v8 = (vector float)vec_perm(v6,v5,vperm4);
vec_st((vector signed short)v7,15,samples);
vec_st((vector signed short)v8,0,samples);
samples += 8;
#ifdef __APPLE__
v1 = (vector float)vec_sr((vector unsigned int)v1,(vector unsigned int)(31));
v2 = (vector float)vec_sr((vector unsigned int)v2,(vector unsigned int)(31));
#else
v1 = (vector float)vec_sr((vector unsigned int)v1,(vector unsigned int){31,31,31,31});
v2 = (vector float)vec_sr((vector unsigned int)v2,(vector unsigned int){31,31,31,31});
#endif
v5 = (vector float)vec_add((vector unsigned int)v1,(vector unsigned int)v2);
vclip = vec_sums((vector signed int)v5,vclip);
}
#ifdef __APPLE__
vperm5 = (vector unsigned char)(0,1,18,19,2,3,22,23,4,5,26,27,28,29,30,31);
#else
vperm5 = (vector unsigned char){0,1,18,19,2,3,22,23,4,5,26,27,28,29,30,31};
#endif
{
vsum = vec_xor(vsum,vsum);
vsum2 = vec_xor(vsum2,vsum2);
vsum3 = vec_xor(vsum3,vsum3);
vsum4 = vec_xor(vsum4,vsum4);
v1 = vec_ld(-1,window);
v2 = vec_ld(-16,window);
v3 = vec_ld(-32,window);
v4 = vec_ld(-48,window);
v5 = vec_ld(-64,window);
v1 = vec_perm(v2,v1,vperm2);
v6 = vec_ld(0,b0);
v2 = vec_perm(v3,v2,vperm2);
v7 = vec_ld(16,b0);
v3 = vec_perm(v4,v3,vperm2);
v8 = vec_ld(32,b0);
v4 = vec_perm(v5,v4,vperm2);
v9 = vec_ld(48,b0);
vsum = vec_nmsub(v1,v6,vsum);
vsum = vec_nmsub(v2,v7,vsum);
vsum = vec_nmsub(v3,v8,vsum);
vsum = vec_nmsub(v4,v9,vsum);
window -= 32;
b0 -= 16;
v1 = vec_ld(0,window);
v2 = vec_ld(-16,window);
v3 = vec_ld(-32,window);
v4 = vec_ld(-48,window);
v5 = vec_ld(-64,window);
v1 = vec_perm(v2,v1,vperm2);
v6 = vec_ld(0,b0);
v2 = vec_perm(v3,v2,vperm2);
v7 = vec_ld(16,b0);
v3 = vec_perm(v4,v3,vperm2);
v8 = vec_ld(32,b0);
v4 = vec_perm(v5,v4,vperm2);
v9 = vec_ld(48,b0);
vsum2 = vec_nmsub(v1,v6,vsum2);
vsum2 = vec_nmsub(v2,v7,vsum2);
vsum2 = vec_nmsub(v3,v8,vsum2);
vsum2 = vec_nmsub(v4,v9,vsum2);
window -= 32;
b0 -= 16;
v1 = vec_ld(0,window);
v2 = vec_ld(-16,window);
v3 = vec_ld(-32,window);
v4 = vec_ld(-48,window);
v5 = vec_ld(-64,window);
v1 = vec_perm(v2,v1,vperm2);
v6 = vec_ld(0,b0);
v2 = vec_perm(v3,v2,vperm2);
v7 = vec_ld(16,b0);
v3 = vec_perm(v4,v3,vperm2);
v8 = vec_ld(32,b0);
v4 = vec_perm(v5,v4,vperm2);
v9 = vec_ld(48,b0);
vsum3 = vec_nmsub(v1,v6,vsum3);
vsum3 = vec_nmsub(v2,v7,vsum3);
vsum3 = vec_nmsub(v3,v8,vsum3);
vsum3 = vec_nmsub(v4,v9,vsum3);
v1 = vec_mergeh(vsum,vsum3);
v2 = vec_mergeh(vsum2,vsum2);
v3 = vec_mergel(vsum,vsum3);
v4 = vec_mergel(vsum2,vsum2);
v5 = vec_mergeh(v1,v2);
v6 = vec_mergel(v1,v2);
v7 = vec_mergeh(v3,v4);
v8 = vec_mergel(v3,v4);
vsum = vec_add(v5,v6);
v9 = vec_add(v7,v8);
vsum = vec_add(vsum,v9);
v3 = (vector float)vec_cts(vsum,0);
v1 = (vector float)vec_cmpgt(vsum,vmax);
v2 = (vector float)vec_cmplt(vsum,vmin);
vsample1 = vec_ld(0,samples);
vsample2 = vec_ld(15,samples);
v3 = (vector float)vec_packs((vector signed int)v3,(vector signed int)v3);
v4 = (vector float)vec_perm(vsample1,vsample2,vperm3);
v5 = (vector float)vec_perm(v3,v4,vperm5);
v6 = (vector float)vec_perm(vsample2,vsample1,vperm3);
v7 = (vector float)vec_perm(v5,v6,vperm4);
v8 = (vector float)vec_perm(v6,v5,vperm4);
vec_st((vector signed short)v7,15,samples);
vec_st((vector signed short)v8,0,samples);
samples += 6;
#ifdef __APPLE__
v1 = (vector float)vec_sr((vector unsigned int)v1,(vector unsigned int)(31,31,31,32));
v2 = (vector float)vec_sr((vector unsigned int)v2,(vector unsigned int)(31,31,31,32));
#else
v1 = (vector float)vec_sr((vector unsigned int)v1,(vector unsigned int){31,31,31,32});
v2 = (vector float)vec_sr((vector unsigned int)v2,(vector unsigned int){31,31,31,32});
#endif
v5 = (vector float)vec_add((vector unsigned int)v1,(vector unsigned int)v2);
vclip = vec_sums((vector signed int)v5,vclip);
vec_st(vclip,0,clip_tmp);
clip += clip_tmp[3];
}
}
*pnt += 128;
return clip;
}

View File

@@ -1,287 +0,0 @@
/*
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.org
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 <math.h>
#include <string.h>
#include "mpg123.h"
#if 1
/* 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
int synth_1to1_8bit_i386(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 = opt_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_i386(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[64];
short *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = opt_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_i386(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[64];
short *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = opt_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_i386(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[64];
short *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = opt_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;
}
int synth_1to1_mono2stereo_i386(real *bandPtr,unsigned char *samples,int *pnt)
{
int i,ret;
ret = opt_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;
}
/* needed for i386, i486 */
#ifdef OPT_I386
int synth_1to1_i386(real *bandPtr,int channel,unsigned char *out,int *pnt)
{
static real buffs[2][2][0x110];
static const int step = 2;
static int bo = 1;
short *samples = (short *) (out + *pnt);
real *b0,(*buf)[0x110];
int clip = 0;
int bo1;
if(have_eq_settings)
do_equalizer(bandPtr,channel);
if(!channel) {
bo--;
bo &= 0xf;
buf = buffs[0];
}
else {
samples++;
buf = buffs[1];
}
if(bo & 0x1) {
b0 = buf[0];
bo1 = bo;
dct64_i386(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
}
else {
b0 = buf[1];
bo1 = bo+1;
dct64_i386(buf[0]+bo,buf[1]+bo+1,bandPtr);
}
{
register int j;
real *window = opt_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;
}
#endif
#ifdef OPT_PENTIUM
int synth_1to1_i586(real *bandPtr,int channel,unsigned char *out,int *pnt)
{
int ret;
if(have_eq_settings) do_equalizer(bandPtr,channel);
/* this is in asm, can be dither or not */
/* uh, is this return from pointer correct? */
ret = (int) opt_synth_1to1_i586_asm(bandPtr,channel,out+*pnt);
*pnt += 128;
return ret;
}
#endif
#ifdef OPT_MMX
/* these are in asm, dct64 called directly there */
extern void dct64_MMX(short *a,short *b,real *c);
extern int synth_1to1_MMX(real *, int, short *, short *, int *);
/* wrapper for da interface */
int synth_1to1_mmx(real *bandPtr,int channel,unsigned char *out,int *pnt)
{
static short buffs[2][2][0x110];
static int bo = 1;
short *samples = (short *) (out + *pnt);
if(have_eq_settings) do_equalizer(bandPtr,channel);
/* in asm */
synth_1to1_MMX(bandPtr, channel, samples, (short *) buffs, &bo);
*pnt += 128;
return 0;
}
#endif
#ifdef OPT_MPLAYER
void synth_1to1_sse_s(real *bandPtr, int channel, short *samples, short *buffs, int *bo);
int synth_1to1_sse(real *bandPtr,int channel,unsigned char *out,int *pnt)
{
static short buffs[2][2][0x110];
static int bo = 1;
short *samples = (short *) (out + *pnt);
if(have_eq_settings) do_equalizer(bandPtr,channel);
synth_1to1_sse_s(bandPtr, channel, samples, (short *) buffs, &bo);
*pnt += 128;
return 0;
}
#endif

View File

@@ -1,254 +0,0 @@
/*
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.org
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 "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_i486(buf[1]+b,buf[0]+b,bandPtr);
} else {
dct64_i486(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;
}

View File

@@ -1,332 +0,0 @@
/*
decode_i586: asm synth
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.org
initially written by Stefan Bieschewski
synth_1to1 works the same way as the c version of this
file. only two types of changes have been made:
- reordered floating point instructions to
prevent pipline stalls
- made WRITE_SAMPLE use integer instead of
(slower) floating point
all kinds of x86 processors should benefit from these
modifications.
useful sources of information on optimizing x86 code include:
Intel Architecture Optimization Manual
http://www.intel.com/design/pentium/manuals/242816.htm
Cyrix 6x86 Instruction Set Summary
ftp://ftp.cyrix.com/6x86/6x-dbch6.pdf
AMD-K5 Processor Software Development
http://www.amd.com/products/cpg/techdocs/appnotes/20007e.pdf
Stefan Bieschewski <stb@acm.org>
$Id: decode_i586.s 1 2004-09-18 13:30:08Z thomas $
*/
#include "mangle.h"
BSS
COMM(buffs,4352,4)
.data
ALIGN4
bo:
.long 1
#ifndef __APPLE__
.section .rodata
#endif
ALIGN8
.LC0:
.long 0x0,0x40dfffc0
ALIGN8
.LC1:
.long 0x0,0xc0e00000
ALIGN8
.text
.globl ASM_NAME(synth_1to1_i586_asm)
ASM_NAME(synth_1to1_i586_asm):
subl $12,%esp
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
movl 32(%esp),%eax
movl 40(%esp),%esi
xorl %edi,%edi
movl bo,%ebp
cmpl %edi,36(%esp)
jne .L48
decl %ebp
andl $15,%ebp
movl %ebp,bo
movl $buffs,%ecx
jmp .L49
.L48:
addl $2,%esi
movl $buffs+2176,%ecx
.L49:
testl $1,%ebp
je .L50
movl %ecx,%ebx
movl %ebp,16(%esp)
pushl %eax
movl 20(%esp),%edx
leal (%ebx,%edx,4),%eax
pushl %eax
movl 24(%esp),%eax
incl %eax
andl $15,%eax
leal 1088(,%eax,4),%eax
addl %ebx,%eax
jmp .L74
.L50:
leal 1088(%ecx),%ebx
leal 1(%ebp),%edx
movl %edx,16(%esp)
pushl %eax
leal 1092(%ecx,%ebp,4),%eax
pushl %eax
leal (%ecx,%ebp,4),%eax
.L74:
pushl %eax
call ASM_NAME(dct64_i386)
addl $12,%esp
movl 16(%esp),%edx
leal 0(,%edx,4),%edx
movl $ASM_NAME(decwin)+64,%eax
movl %eax,%ecx
subl %edx,%ecx
movl $16,%ebp
.L55:
flds (%ecx)
fmuls (%ebx)
flds 4(%ecx)
fmuls 4(%ebx)
fxch %st(1)
flds 8(%ecx)
fmuls 8(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 12(%ecx)
fmuls 12(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 16(%ecx)
fmuls 16(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 20(%ecx)
fmuls 20(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 24(%ecx)
fmuls 24(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 28(%ecx)
fmuls 28(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 32(%ecx)
fmuls 32(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 36(%ecx)
fmuls 36(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 40(%ecx)
fmuls 40(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 44(%ecx)
fmuls 44(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 48(%ecx)
fmuls 48(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 52(%ecx)
fmuls 52(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 56(%ecx)
fmuls 56(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 60(%ecx)
fmuls 60(%ebx)
fxch %st(2)
subl $4,%esp
faddp %st,%st(1)
fxch %st(1)
fsubrp %st,%st(1)
fistpl (%esp)
popl %eax
cmpl $32767,%eax
jg 1f
cmpl $-32768,%eax
jl 2f
movw %ax,(%esi)
jmp 4f
1: movw $32767,(%esi)
jmp 3f
2: movw $-32768,(%esi)
3: incl %edi
4:
.L54:
addl $64,%ebx
subl $-128,%ecx
addl $4,%esi
decl %ebp
jnz .L55
flds (%ecx)
fmuls (%ebx)
flds 8(%ecx)
fmuls 8(%ebx)
flds 16(%ecx)
fmuls 16(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 24(%ecx)
fmuls 24(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 32(%ecx)
fmuls 32(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 40(%ecx)
fmuls 40(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 48(%ecx)
fmuls 48(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 56(%ecx)
fmuls 56(%ebx)
fxch %st(2)
subl $4,%esp
faddp %st,%st(1)
fxch %st(1)
faddp %st,%st(1)
fistpl (%esp)
popl %eax
cmpl $32767,%eax
jg 1f
cmpl $-32768,%eax
jl 2f
movw %ax,(%esi)
jmp 4f
1: movw $32767,(%esi)
jmp 3f
2: movw $-32768,(%esi)
3: incl %edi
4:
.L62:
addl $-64,%ebx
addl $4,%esi
movl 16(%esp),%edx
leal -128(%ecx,%edx,8),%ecx
movl $15,%ebp
.L68:
flds -4(%ecx)
fchs
fmuls (%ebx)
flds -8(%ecx)
fmuls 4(%ebx)
fxch %st(1)
flds -12(%ecx)
fmuls 8(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -16(%ecx)
fmuls 12(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -20(%ecx)
fmuls 16(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -24(%ecx)
fmuls 20(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -28(%ecx)
fmuls 24(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -32(%ecx)
fmuls 28(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -36(%ecx)
fmuls 32(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -40(%ecx)
fmuls 36(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -44(%ecx)
fmuls 40(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -48(%ecx)
fmuls 44(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -52(%ecx)
fmuls 48(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -56(%ecx)
fmuls 52(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -60(%ecx)
fmuls 56(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds (%ecx)
fmuls 60(%ebx)
fxch %st(2)
subl $4,%esp
fsubrp %st,%st(1)
fxch %st(1)
fsubrp %st,%st(1)
fistpl (%esp)
popl %eax
cmpl $32767,%eax
jg 1f
cmpl $-32768,%eax
jl 2f
movw %ax,(%esi)
jmp 4f
1: movw $32767,(%esi)
jmp 3f
2: movw $-32768,(%esi)
3: incl %edi
4:
.L67:
addl $-64,%ebx
addl $-128,%ecx
addl $4,%esi
decl %ebp
jnz .L68
movl %edi,%eax
popl %ebx
popl %esi
popl %edi
popl %ebp
addl $12,%esp
ret

View File

@@ -1,365 +0,0 @@
/*
synth_1to1 works the same way as the c version of this
file. only two types of changes have been made:
- reordered floating point instructions to
prevent pipline stalls
- made WRITE_SAMPLE use integer instead of
(slower) floating point
all kinds of x86 processors should benefit from these
modifications.
useful sources of information on optimizing x86 code include:
Intel Architecture Optimization Manual
http:#/www.intel.com/design/pentium/manuals/242816.htm
Cyrix 6x86 Instruction Set Summary
ftp:#/ftp.cyrix.com/6x86/6x-dbch6.pdf
AMD-K5 Processor Software Development
http:#/www.amd.com/products/cpg/techdocs/appnotes/20007e.pdf
Stefan Bieschewski <stb@acm.org>
You can use this part under GPL.
This version uses "circular" 64k dither noise.
(Patch by Adrian <adrian.bacon@xs4all.nl>)
*/
#include "mangle.h"
BSS
COMM(buffs,4352,4)
COMM(ditherindex.1,4,4)
.data
ALIGN4
bo:
.long 1
#ifndef __APPLE__
.section .rodata
#endif
ALIGN8
.LC0:
.long 0x0,0x40dfffc0
ALIGN8
.LC1:
.long 0x0,0xc0e00000
ALIGN8
.text
.globl ASM_NAME(synth_1to1_i586_asm_dither)
ASM_NAME(synth_1to1_i586_asm_dither):
subl $12,%esp
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
movl 32(%esp),%eax
movl 40(%esp),%esi
xorl %edi,%edi
movl bo,%ebp
cmpl %edi,36(%esp)
jne .L48
decl %ebp
andl $15,%ebp
movl %ebp,bo
movl $buffs,%ecx
jmp .L49
.L48:
/* In stereo mode , "rewind" dither pointer 32 samples , so 2nd channel */
/* has same dither values. Tested OK for mono and stereo MP2 and MP3 */
subl $128,ditherindex.1
andl $0x0003fffc,ditherindex.1
addl $2,%esi
movl $buffs+2176,%ecx
.L49:
/* Now edi is mine, load it with indexpointer */
/* movl $ASM_NAME(dithernoise),%edi */
testl $1,%ebp
je .L50
movl %ecx,%ebx
movl %ebp,16(%esp)
pushl %eax
movl 20(%esp),%edx
leal (%ebx,%edx,4),%eax
pushl %eax
movl 24(%esp),%eax
incl %eax
andl $15,%eax
leal 1088(,%eax,4),%eax
addl %ebx,%eax
jmp .L74
.L50:
leal 1088(%ecx),%ebx
leal 1(%ebp),%edx
movl %edx,16(%esp)
pushl %eax
leal 1092(%ecx,%ebp,4),%eax
pushl %eax
leal (%ecx,%ebp,4),%eax
.L74:
pushl %eax
call ASM_NAME(dct64_i386)
addl $12,%esp
movl 16(%esp),%edx
leal 0(,%edx,4),%edx
movl $ASM_NAME(decwin)+64,%eax
movl %eax,%ecx
subl %edx,%ecx
movl $16,%ebp
.L55:
flds (%ecx)
fmuls (%ebx)
flds 4(%ecx)
fmuls 4(%ebx)
fxch %st(1)
flds 8(%ecx)
fmuls 8(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 12(%ecx)
fmuls 12(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 16(%ecx)
fmuls 16(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 20(%ecx)
fmuls 20(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 24(%ecx)
fmuls 24(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 28(%ecx)
fmuls 28(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 32(%ecx)
fmuls 32(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 36(%ecx)
fmuls 36(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 40(%ecx)
fmuls 40(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 44(%ecx)
fmuls 44(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 48(%ecx)
fmuls 48(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 52(%ecx)
fmuls 52(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 56(%ecx)
fmuls 56(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds 60(%ecx)
fmuls 60(%ebx)
fxch %st(2)
subl $4,%esp
faddp %st,%st(1)
fxch %st(1)
fsubrp %st,%st(1)
addl $4,ditherindex.1
andl $0x0003fffc,ditherindex.1
movl $ASM_NAME(dithernoise),%edi
addl ditherindex.1,%edi
fadd (%edi)
fistpl (%esp)
popl %eax
cmpl $32767,%eax
jg 1f
cmpl $-32768,%eax
jl 2f
movw %ax,(%esi)
jmp 4f
1: movw $32767,(%esi)
jmp 3f
2: movw $-32768,(%esi)
3:
/* incl %edi */
4:
.L54:
addl $64,%ebx
subl $-128,%ecx
addl $4,%esi
decl %ebp
jnz .L55
flds (%ecx)
fmuls (%ebx)
flds 8(%ecx)
fmuls 8(%ebx)
flds 16(%ecx)
fmuls 16(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 24(%ecx)
fmuls 24(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 32(%ecx)
fmuls 32(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 40(%ecx)
fmuls 40(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 48(%ecx)
fmuls 48(%ebx)
fxch %st(2)
faddp %st,%st(1)
flds 56(%ecx)
fmuls 56(%ebx)
fxch %st(2)
subl $4,%esp
faddp %st,%st(1)
fxch %st(1)
faddp %st,%st(1)
addl $4,ditherindex.1
andl $0x0003fffc,ditherindex.1
movl $ASM_NAME(dithernoise),%edi
addl ditherindex.1,%edi
fadd (%edi)
fistpl (%esp)
popl %eax
cmpl $32767,%eax
jg 1f
cmpl $-32768,%eax
jl 2f
movw %ax,(%esi)
jmp 4f
1: movw $32767,(%esi)
jmp 3f
2: movw $-32768,(%esi)
3:
/* incl %edi */
4:
.L62:
addl $-64,%ebx
addl $4,%esi
movl 16(%esp),%edx
leal -128(%ecx,%edx,8),%ecx
movl $15,%ebp
.L68:
flds -4(%ecx)
fchs
fmuls (%ebx)
flds -8(%ecx)
fmuls 4(%ebx)
fxch %st(1)
flds -12(%ecx)
fmuls 8(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -16(%ecx)
fmuls 12(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -20(%ecx)
fmuls 16(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -24(%ecx)
fmuls 20(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -28(%ecx)
fmuls 24(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -32(%ecx)
fmuls 28(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -36(%ecx)
fmuls 32(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -40(%ecx)
fmuls 36(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -44(%ecx)
fmuls 40(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -48(%ecx)
fmuls 44(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -52(%ecx)
fmuls 48(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -56(%ecx)
fmuls 52(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds -60(%ecx)
fmuls 56(%ebx)
fxch %st(2)
fsubrp %st,%st(1)
flds (%ecx)
fmuls 60(%ebx)
fxch %st(2)
subl $4,%esp
fsubrp %st,%st(1)
fxch %st(1)
fsubrp %st,%st(1)
addl $4,ditherindex.1
andl $0x0003fffc,ditherindex.1
movl $ASM_NAME(dithernoise),%edi
addl ditherindex.1,%edi
fadd (%edi)
fistpl (%esp)
popl %eax
cmpl $32767,%eax
jg 1f
cmpl $-32768,%eax
jl 2f
movw %ax,(%esi)
jmp 4f
1: movw $32767,(%esi)
jmp 3f
2: movw $-32768,(%esi)
3:
/* incl %edi */
4:
.L67:
addl $-64,%ebx
addl $-128,%ecx
addl $4,%esi
decl %ebp
jnz .L68
/* return ipv edi 0 in eax */
movl $0,%eax
popl %ebx
popl %esi
popl %edi
popl %ebp
addl $12,%esp
ret

View File

@@ -1,121 +0,0 @@
/*
decode_MMX.s: MMX optimized synth
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.org
initially written by the mysterious higway (apparently)
Thomas' words about a note:
Initially, I found the note "this code comes under GPL" in this file.
After asking Michael about legal status of the MMX files, he said that he got them without any comment and thus I believe that the GPL comment was made by Michael, since he made mpg123 GPL at some time - and marked some files that way, but not all.
Based on that thought, I now consider this file along with the other parts of higway's MMX optimization to be licensed under LGPL 2.1 by Michael's decision.
*/
#include "mangle.h"
.text
.globl ASM_NAME(synth_1to1_MMX)
ASM_NAME(synth_1to1_MMX):
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
movl 24(%esp),%ecx
movl 28(%esp),%edi
movl $15,%ebx
movl 36(%esp),%edx
leal (%edi,%ecx,2),%edi
decl %ecx
movl 32(%esp),%esi
movl (%edx),%eax
jecxz .L1
decl %eax
andl %ebx,%eax
leal 1088(%esi),%esi
movl %eax,(%edx)
.L1:
leal (%esi,%eax,2),%edx
movl %eax,%ebp
incl %eax
pushl 20(%esp)
andl %ebx,%eax
leal 544(%esi,%eax,2),%ecx
incl %ebx
testl $1, %eax
jnz .L2
xchgl %edx,%ecx
incl %ebp
leal 544(%esi),%esi
.L2:
pushl %edx
pushl %ecx
call ASM_NAME(dct64_MMX)
addl $12,%esp
leal 1(%ebx), %ecx
subl %ebp,%ebx
leal ASM_NAME(decwins)(%ebx,%ebx,1), %edx
.L3:
movq (%edx),%mm0
pmaddwd (%esi),%mm0
movq 8(%edx),%mm1
pmaddwd 8(%esi),%mm1
movq 16(%edx),%mm2
pmaddwd 16(%esi),%mm2
movq 24(%edx),%mm3
pmaddwd 24(%esi),%mm3
paddd %mm1,%mm0
paddd %mm2,%mm0
paddd %mm3,%mm0
movq %mm0,%mm1
psrlq $32,%mm1
paddd %mm1,%mm0
psrad $13,%mm0
packssdw %mm0,%mm0
movd %mm0,%eax
movw %ax, (%edi)
leal 32(%esi),%esi
leal 64(%edx),%edx
leal 4(%edi),%edi
loop .L3
subl $64,%esi
movl $15,%ecx
.L4:
movq (%edx),%mm0
pmaddwd (%esi),%mm0
movq 8(%edx),%mm1
pmaddwd 8(%esi),%mm1
movq 16(%edx),%mm2
pmaddwd 16(%esi),%mm2
movq 24(%edx),%mm3
pmaddwd 24(%esi),%mm3
paddd %mm1,%mm0
paddd %mm2,%mm0
paddd %mm3,%mm0
movq %mm0,%mm1
psrlq $32,%mm1
paddd %mm0,%mm1
psrad $13,%mm1
packssdw %mm1,%mm1
psubd %mm0,%mm0
psubsw %mm1,%mm0
movd %mm0,%eax
movw %ax,(%edi)
subl $32,%esi
addl $64,%edx
leal 4(%edi),%edi
loop .L4
emms
popl %ebx
popl %esi
popl %edi
popl %ebp
ret

View File

@@ -1,278 +0,0 @@
/*
decode_mmxsse: Synth for SSE and extended 3DNow (yeah, the name is a relic)
copyright 2006-2007 by Zuxy Meng/the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by the mysterious higway for MMX (apparently)
then developed into SSE opt by Zuxy Meng, also building on Romain Dolbeau's AltiVec
Both have agreed to distribution under LGPL 2.1 .
Transformed back into standalone asm, with help of
gcc -S -DHAVE_CONFIG_H -I. -march=pentium -O3 -Wall -pedantic -fno-strict-aliasing -DREAL_IS_FLOAT -c -o decode_mmxsse.{S,c}
Original comment from MPlayer source follows:
*/
/*
* this code comes under GPL
* This code was taken from http://www.mpg123.org
* See ChangeLog of mpg123-0.59s-pre.1 for detail
* Applied to mplayer by Nick Kurshev <nickols_k@mail.ru>
*
* Local ChangeLog:
* - Partial loops unrolling and removing MOVW insn from loops
*/
#include "mangle.h"
.globl ASM_NAME(costab_mmxsse)
.data
ALIGN16
/* .type ASM_NAME(costab_mmxsse), @object
.size ASM_NAME(costab_mmxsse), 124 */
ASM_NAME(costab_mmxsse):
.long 1056974725
.long 1057056395
.long 1057223771
.long 1057485416
.long 1057855544
.long 1058356026
.long 1059019886
.long 1059897405
.long 1061067246
.long 1062657950
.long 1064892987
.long 1066774581
.long 1069414683
.long 1073984175
.long 1079645762
.long 1092815430
.long 1057005197
.long 1057342072
.long 1058087743
.long 1059427869
.long 1061799040
.long 1065862217
.long 1071413542
.long 1084439708
.long 1057128951
.long 1058664893
.long 1063675095
.long 1076102863
.long 1057655764
.long 1067924853
.long 1060439283
ALIGN8
/* .type one_null, @object
.size one_null, 8 */
one_null:
.long -65536
.long -65536
ALIGN8
/* .type null_one, @object
.size null_one, 8 */
null_one:
.long 65535
.long 65535
/* .local temp */
COMM(temp,4,4)
.text
ALIGN16,,15
/* void synth_1to1_sse_s(real *bandPtr, int channel, short *samples, short *buffs, int *bo) */
.globl ASM_NAME(synth_1to1_sse_s)
/* .type ASM_NAME(synth_1to1_sse_s), @function */
ASM_NAME(synth_1to1_sse_s):
pushl %ebp
movl %esp, %ebp
pushl %edi
pushl %esi
pushl %ebx
#APP
movl 12(%ebp),%ecx
movl 16(%ebp),%edi
movl $15,%ebx
movl 24(%ebp),%edx
leal (%edi,%ecx,2),%edi
decl %ecx
movl 20(%ebp),%esi
movl (%edx),%eax
jecxz .L01
decl %eax
andl %ebx,%eax
leal 1088(%esi),%esi
movl %eax,(%edx)
.L01:
leal (%esi,%eax,2),%edx
movl %eax,temp
incl %eax
andl %ebx,%eax
leal 544(%esi,%eax,2),%ecx
incl %ebx
testl $1, %eax
jnz .L02
xchgl %edx,%ecx
incl temp
leal 544(%esi),%esi
.L02:
emms
pushl 8(%ebp)
pushl %edx
pushl %ecx
call *ASM_NAME(mpl_dct64)
addl $12, %esp
leal 1(%ebx), %ecx
subl temp,%ebx
pushl %ecx
leal ASM_NAME(decwins)(%ebx,%ebx,1), %edx
shrl $1, %ecx
ALIGN16
.L03:
movq (%edx),%mm0
movq 64(%edx),%mm4
pmaddwd (%esi),%mm0
pmaddwd 32(%esi),%mm4
movq 8(%edx),%mm1
movq 72(%edx),%mm5
pmaddwd 8(%esi),%mm1
pmaddwd 40(%esi),%mm5
movq 16(%edx),%mm2
movq 80(%edx),%mm6
pmaddwd 16(%esi),%mm2
pmaddwd 48(%esi),%mm6
movq 24(%edx),%mm3
movq 88(%edx),%mm7
pmaddwd 24(%esi),%mm3
pmaddwd 56(%esi),%mm7
paddd %mm1,%mm0
paddd %mm5,%mm4
paddd %mm2,%mm0
paddd %mm6,%mm4
paddd %mm3,%mm0
paddd %mm7,%mm4
movq %mm0,%mm1
movq %mm4,%mm5
psrlq $32,%mm1
psrlq $32,%mm5
paddd %mm1,%mm0
paddd %mm5,%mm4
psrad $13,%mm0
psrad $13,%mm4
packssdw %mm0,%mm0
packssdw %mm4,%mm4
movq (%edi), %mm1
punpckldq %mm4, %mm0
pand one_null, %mm1
pand null_one, %mm0
por %mm0, %mm1
movq %mm1,(%edi)
leal 64(%esi),%esi
leal 128(%edx),%edx
leal 8(%edi),%edi
decl %ecx
jnz .L03
popl %ecx
andl $1, %ecx
jecxz .next_loop
movq (%edx),%mm0
pmaddwd (%esi),%mm0
movq 8(%edx),%mm1
pmaddwd 8(%esi),%mm1
movq 16(%edx),%mm2
pmaddwd 16(%esi),%mm2
movq 24(%edx),%mm3
pmaddwd 24(%esi),%mm3
paddd %mm1,%mm0
paddd %mm2,%mm0
paddd %mm3,%mm0
movq %mm0,%mm1
psrlq $32,%mm1
paddd %mm1,%mm0
psrad $13,%mm0
packssdw %mm0,%mm0
movd %mm0,%eax
movw %ax, (%edi)
leal 32(%esi),%esi
leal 64(%edx),%edx
leal 4(%edi),%edi
.next_loop:
subl $64,%esi
movl $7,%ecx
ALIGN16
.L04:
movq (%edx),%mm0
movq 64(%edx),%mm4
pmaddwd (%esi),%mm0
pmaddwd -32(%esi),%mm4
movq 8(%edx),%mm1
movq 72(%edx),%mm5
pmaddwd 8(%esi),%mm1
pmaddwd -24(%esi),%mm5
movq 16(%edx),%mm2
movq 80(%edx),%mm6
pmaddwd 16(%esi),%mm2
pmaddwd -16(%esi),%mm6
movq 24(%edx),%mm3
movq 88(%edx),%mm7
pmaddwd 24(%esi),%mm3
pmaddwd -8(%esi),%mm7
paddd %mm1,%mm0
paddd %mm5,%mm4
paddd %mm2,%mm0
paddd %mm6,%mm4
paddd %mm3,%mm0
paddd %mm7,%mm4
movq %mm0,%mm1
movq %mm4,%mm5
psrlq $32,%mm1
psrlq $32,%mm5
paddd %mm0,%mm1
paddd %mm4,%mm5
psrad $13,%mm1
psrad $13,%mm5
packssdw %mm1,%mm1
packssdw %mm5,%mm5
psubd %mm0,%mm0
psubd %mm4,%mm4
psubsw %mm1,%mm0
psubsw %mm5,%mm4
movq (%edi), %mm1
punpckldq %mm4, %mm0
pand one_null, %mm1
pand null_one, %mm0
por %mm0, %mm1
movq %mm1,(%edi)
subl $64,%esi
addl $128,%edx
leal 8(%edi),%edi
decl %ecx
jnz .L04
movq (%edx),%mm0
pmaddwd (%esi),%mm0
movq 8(%edx),%mm1
pmaddwd 8(%esi),%mm1
movq 16(%edx),%mm2
pmaddwd 16(%esi),%mm2
movq 24(%edx),%mm3
pmaddwd 24(%esi),%mm3
paddd %mm1,%mm0
paddd %mm2,%mm0
paddd %mm3,%mm0
movq %mm0,%mm1
psrlq $32,%mm1
paddd %mm0,%mm1
psrad $13,%mm1
packssdw %mm1,%mm1
psubd %mm0,%mm0
psubsw %mm1,%mm0
movd %mm0,%eax
movw %ax,(%edi)
emms
#NO_APP
popl %ebx
popl %esi
popl %edi
popl %ebp
ret
/* .size ASM_NAME(synth_1to1_sse_s), .-ASM_NAME(synth_1to1_sse_s) */

View File

@@ -1,296 +0,0 @@
/*
decode_ntom.c: N->M down/up sampling. Not optimized for speed.
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.org
initially written by Michael Hipp
*/
#include <math.h>
#include <string.h>
#include "mpg123.h"
#include "decode.h"
#define NTOM_MUL (32768)
static unsigned long ntom_val[2] = { NTOM_MUL>>1,NTOM_MUL>>1 };
static unsigned long ntom_step = NTOM_MUL;
int synth_ntom_set_step(long m,long n)
{
if(param.verbose > 1)
fprintf(stderr,"Init rate converter: %ld->%ld\n",m,n);
if(n >= 96000 || m >= 96000 || m == 0 || n == 0) {
error("NtoM converter: illegal rates");
return 0;
}
n *= NTOM_MUL;
ntom_step = n / m;
if(ntom_step > 8*NTOM_MUL) {
error("max. 1:8 conversion allowed!");
return 0;
}
ntom_val[0] = ntom_val[1] = NTOM_MUL>>1;
return 1;
}
int synth_ntom_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[8*64];
sample_t *tmp1 = samples_tmp + channel;
int i,ret;
int pnt1 = 0;
ret = synth_ntom(bandPtr,channel,(unsigned char *) samples_tmp,&pnt1);
samples += channel + *pnt;
for(i=0;i<(pnt1>>2);i++) {
#ifdef FLOATOUT
*samples = 0;
#else
*samples = conv16to8[*tmp1>>AUSHIFT];
#endif
samples += 2;
tmp1 += 2;
}
*pnt += pnt1>>1;
return ret;
}
int synth_ntom_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[8*64];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = synth_ntom(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
samples += *pnt;
for(i=0;i<(pnt1>>2);i++) {
#ifdef FLOATOUT
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += pnt1 >> 2;
return ret;
}
int synth_ntom_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[8*64];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = synth_ntom(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
samples += *pnt;
for(i=0;i<(pnt1>>2);i++) {
#ifdef FLOATOUT
*samples++ = 0;
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += pnt1 >> 1;
return ret;
}
int synth_ntom_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
sample_t samples_tmp[8*64];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = synth_ntom(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
samples += *pnt;
for(i=0;i<(pnt1>>2);i++) {
*( (sample_t *)samples) = *tmp1;
samples += sizeof(sample_t);
tmp1 += 2;
}
*pnt += (pnt1>>2)*sizeof(sample_t);
return ret;
}
int synth_ntom_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
{
int i,ret;
int pnt1 = *pnt;
ret = synth_ntom(bandPtr,0,samples,pnt);
samples += pnt1;
for(i=0;i<((*pnt-pnt1)>>2);i++) {
((sample_t *)samples)[1] = ((sample_t *)samples)[0];
samples+=2*sizeof(sample_t);
}
return ret;
}
int synth_ntom(real *bandPtr,int channel,unsigned char *out,int *pnt)
{
static real buffs[2][2][0x110];
static const int step = 2;
static int bo = 1;
sample_t *samples = (sample_t *) (out + *pnt);
real *b0,(*buf)[0x110];
int clip = 0;
int bo1;
int ntom;
if(have_eq_settings)
do_equalizer(bandPtr,channel);
if(!channel) {
bo--;
bo &= 0xf;
buf = buffs[0];
ntom = ntom_val[1] = ntom_val[0];
}
else {
samples++;
out += 2; /* to compute the right *pnt value */
buf = buffs[1];
ntom = ntom_val[1];
}
if(bo & 0x1) {
b0 = buf[0];
bo1 = bo;
opt_dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
}
else {
b0 = buf[1];
bo1 = bo+1;
opt_dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
}
{
register int j;
real *window = opt_decwin + 16 - bo1;
for (j=16;j;j--,window+=0x10)
{
real sum;
ntom += ntom_step;
if(ntom < NTOM_MUL) {
window += 16;
b0 += 16;
continue;
}
sum = *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
while(ntom >= NTOM_MUL) {
WRITE_SAMPLE(samples,sum,clip);
samples += step;
ntom -= NTOM_MUL;
}
}
ntom += ntom_step;
if(ntom >= NTOM_MUL)
{
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];
while(ntom >= NTOM_MUL) {
WRITE_SAMPLE(samples,sum,clip);
samples += step;
ntom -= NTOM_MUL;
}
}
b0-=0x10,window-=0x20;
window += bo1<<1;
for (j=15;j;j--,b0-=0x20,window-=0x10)
{
real sum;
ntom += ntom_step;
if(ntom < NTOM_MUL) {
window -= 16;
b0 += 16;
continue;
}
sum = -*(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
while(ntom >= NTOM_MUL) {
WRITE_SAMPLE(samples,sum,clip);
samples += step;
ntom -= NTOM_MUL;
}
}
}
ntom_val[channel] = ntom;
*pnt = ((unsigned char *) samples - out);
return clip;
}

65539
src/dnoise.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,42 +0,0 @@
/*
equalizer.c: equalizer settings
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.org
initially written by Michael Hipp
*/
#include "mpg123.h"
real equalizer[2][32];
real equalizer_sum[2][32];
int equalizer_cnt;
real equalizerband[2][SBLIMIT*SSLIMIT];
void do_equalizer(real *bandPtr,int channel)
{
int i;
if(have_eq_settings) {
for(i=0;i<32;i++)
bandPtr[i] = REAL_MUL(bandPtr[i], equalizer[channel][i]);
}
/* if(param.equalizer & 0x2) {
for(i=0;i<32;i++)
equalizer_sum[channel][i] += bandPtr[i];
}
*/
}
void do_equalizerband(real *bandPtr,int channel)
{
int i;
for(i=0;i<576;i++) {
bandPtr[i] = REAL_MUL(bandPtr[i], equalizerband[channel][i]);
}
}

View File

@@ -1,69 +0,0 @@
/*
equalizer_3dnow: 3DNow! optimized do_equalizer()
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.org
initially written by KIMURA Takuhiro
*/
#include "mangle.h"
.text
ALIGN4
.globl ASM_NAME(do_equalizer_3dnow)
/* .type ASM_NAME(do_equalizer_3dnow),@function */
ASM_NAME(do_equalizer_3dnow):
pushl %esi
pushl %ebx
/* bandPtr */
movl 12(%esp),%ebx
cmpl $0,ASM_NAME(equalfile)
je .L5
/* channel */
movl 16(%esp),%ecx
xorl %edx,%edx
movl $ASM_NAME(equalizer),%esi
sall $7,%ecx
ALIGN4
.L9:
movq (%ebx,%edx),%mm0
pfmul (%esi,%ecx),%mm0
movq 8(%ebx,%edx),%mm1
pfmul 8(%esi,%ecx),%mm1
movq %mm0,(%ebx,%edx)
movq 16(%ebx,%edx),%mm0
pfmul 16(%esi,%ecx),%mm0
movq %mm1,8(%ebx,%edx)
movq 24(%ebx,%edx),%mm1
pfmul 24(%esi,%ecx),%mm1
movq %mm0,16(%ebx,%edx)
movq 32(%ebx,%edx),%mm0
pfmul 32(%esi,%ecx),%mm0
movq %mm1,24(%ebx,%edx)
movq 40(%ebx,%edx),%mm1
pfmul 40(%esi,%ecx),%mm1
movq %mm0,32(%ebx,%edx)
movq 48(%ebx,%edx),%mm0
pfmul 48(%esi,%ecx),%mm0
movq %mm1,40(%ebx,%edx)
movq 56(%ebx,%edx),%mm1
pfmul 56(%esi,%ecx),%mm1
movq %mm0,48(%ebx,%edx)
movq %mm1,56(%ebx,%edx)
addl $64,%edx
addl $32,%ecx
cmpl $124,%edx
jle .L9
ALIGN4
.L5:
popl %ebx
popl %esi
ret

View File

@@ -1,135 +0,0 @@
/*
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.org
initially written by Michael Hipp
*/
#include "mpg123.h"
#include "common.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,":%lx ",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;
}

View File

@@ -1,45 +0,0 @@
/*
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.org
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

View File

@@ -1,79 +0,0 @@
/*
getcpucpuflags: get cpuflags for ia32
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.org
initially written by KIMURA Takuhiro (for 3DNow!)
extended for general use by Thomas Orgis
extern int getcpuid(struct cpuflags*)
or just
extern int getcpuid(unsigned int*)
where there is memory for 4 ints
-> the first set of idflags (basic cpu family info)
and the idflags, stdflags, std2flags, extflags written to the parameter
-> 0x00000000 (CPUID instruction not supported)
*/
#include "mangle.h"
.text
ALIGN4
.globl ASM_NAME(getcpuflags)
/* .type ASM_NAME(getcpuflags),@function */
ASM_NAME(getcpuflags):
pushl %ebp
movl %esp,%ebp
pushl %edx
pushl %ecx
pushl %ebx
pushl %esi
/* get the int pointer for storing the flags */
movl 8(%ebp), %esi
/* does that one make sense? */
movl $0x80000000,%eax
/* now save the flags and do a check for cpuid availability */
pushfl
pushfl
popl %eax
movl %eax,%ebx
/* set that bit... */
xorl $0x00200000,%eax
pushl %eax
popfl
/* ...and read back the flags to see if it is understood */
pushfl
popl %eax
popfl
cmpl %ebx,%eax
je .Lnocpuid
/* now get the info, first extended */
movl $0x80000001,%eax
cpuid
movl %edx,12(%esi)
/* then the other ones, called last to get the id flags in %eax for ret */
movl $0x00000001,%eax
cpuid
movl %eax, (%esi)
movl %ecx, 4(%esi)
movl %edx, 8(%esi)
jmp .Lend
ALIGN4
.Lnocpuid:
/* error: set everything to zero */
movl $0, %eax
movl $0, (%esi)
movl $0, 4(%esi)
movl $0, 8(%esi)
movl $0, 12(%esi)
ALIGN4
.Lend:
/* return value are the id flags, still stored in %eax */
popl %esi
popl %ebx
popl %ecx
popl %edx
movl %ebp,%esp
popl %ebp
ret

View File

@@ -1,32 +0,0 @@
/* standard level flags part 1 */
#define FLAG_SSE3 0x00000001
/* standard level flags part 2 */
#define FLAG2_MMX 0x00800000
#define FLAG2_SSE 0x02000000
#define FLAG2_SSE2 0x04000000
#define FLAG2_FPU 0x00000001
/* cpuid extended level 1 (AMD) */
#define XFLAG_MMX 0x00800000
#define XFLAG_3DNOW 0x80000000
#define XFLAG_3DNOWEXT 0x40000000
struct cpuflags
{
unsigned int id;
unsigned int std;
unsigned int std2;
unsigned int ext;
};
unsigned int getcpuflags(struct cpuflags* cf);
/* checks the family */
#define cpu_i586(s) ( ((s.id & 0xf00)>>8) == 0 || ((s.id & 0xf00)>>8) > 4 )
/* checking some flags... */
#define cpu_fpu(s) (FLAG2_FPU & s.std2)
#define cpu_mmx(s) (FLAG2_MMX & s.std2 || XFLAG_MMX & s.ext)
#define cpu_3dnow(s) (XFLAG_3DNOW & s.ext)
#define cpu_3dnowext(s) (XFLAG_3DNOWEXT & s.ext)
#define cpu_sse(s) (FLAG2_SSE & s.std2)
#define cpu_sse2(s) (FLAG2_SSE2 & s.std2)
#define cpu_sse3(s) (FLAG_SSE3 & s.std)

View File

@@ -26,10 +26,28 @@
Funny aspect there is that shoutcast servers do not do HTTP/1.1 chunked transfer but implement some different chunking themselves...
*/
#include "mpg123.h"
#include "mpg123app.h"
#include "httpget.h"
#include "mpg123.h"
char *proxyurl = NULL;
void httpdata_init(struct httpdata *e)
{
mpg123_init_string(&e->content_type);
mpg123_init_string(&e->icy_url);
mpg123_init_string(&e->icy_name);
e->icy_interval = 0;
e->proxyurl = NULL;
e->proxyip = 0;
}
void httpdata_reset(struct httpdata *e)
{
mpg123_free_string(&e->content_type);
mpg123_free_string(&e->icy_url);
mpg123_free_string(&e->icy_name);
e->icy_interval = 0;
/* the other stuff shall persist */
}
#if !defined(WIN32) && !defined(GENERIC)
@@ -45,8 +63,7 @@ char *proxyurl = NULL;
#include <errno.h>
#include <ctype.h>
#include "stringbuf.h"
#include "icy.h"
#include "true.h"
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
@@ -258,7 +275,6 @@ char* get_header_val(const char *hname, char* response, size_t *length)
return tmp;
}
unsigned long proxyip = 0;
unsigned int proxyport;
/* needed for HTTP/1.1 non-pipelining mode */
@@ -266,7 +282,8 @@ unsigned int proxyport;
#define CONN_HEAD ""
/* shoutcsast meta data: 1=on, 0=off */
#define ACCEPT_ICY_META "Icy-MetaData: 1\r\n"
const char *icy_yes = "Icy-MetaData: 1\r\n";
const char *icy_no = "Icy-MetaData: 0\r\n";
char *httpauth = NULL;
char *httpauth1 = NULL;
@@ -293,12 +310,13 @@ static size_t accept_length(void)
return l;
}
int http_open (char* url, char** content_type)
int http_open(char* url, struct httpdata *hd)
{
/* TODO: make sure ulong vs. size_t is really clear! */
/* TODO: change this whole thing until I stop disliking it */
char *purl, *host, *request, *response, *sptr;
char* request_url = NULL;
const char *icy = param.talk_icy ? icy_yes : icy_no;
size_t request_url_size = 0;
size_t purl_size;
size_t linelength, linelengthbase, tmp;
@@ -320,13 +338,13 @@ int http_open (char* url, char** content_type)
purl = NULL;
request = NULL;
response = NULL;
if (!proxyip) {
if (!proxyurl)
if (!(proxyurl = getenv("MP3_HTTP_PROXY")))
if (!(proxyurl = getenv("http_proxy")))
proxyurl = getenv("HTTP_PROXY");
if (proxyurl && proxyurl[0] && strcmp(proxyurl, "none")) {
if (!(url2hostport(proxyurl, &host, &proxyip, &proxyport))) {
if (!hd->proxyip) {
if (!hd->proxyurl)
if (!(hd->proxyurl = getenv("MP3_HTTP_PROXY")))
if (!(hd->proxyurl = getenv("http_proxy")))
hd->proxyurl = getenv("HTTP_PROXY");
if (hd->proxyurl && hd->proxyurl[0] && strcmp(hd->proxyurl, "none")) {
if (!(url2hostport(hd->proxyurl, &host, &hd->proxyip, &proxyport))) {
fprintf (stderr, "Unknown proxy host \"%s\".\n",
host ? host : "");
sock = -1;
@@ -334,7 +352,7 @@ int http_open (char* url, char** content_type)
}
}
else
proxyip = INADDR_NONE;
hd->proxyip = INADDR_NONE;
}
/* The length of purl is upper bound by 3*strlen(url) + 1 if
@@ -399,7 +417,7 @@ int http_open (char* url, char** content_type)
* ... plus the other predefined header lines
*/
linelengthbase = 62 + strlen(PACKAGE_NAME) + strlen(PACKAGE_VERSION)
+ accept_length() + strlen(CONN_HEAD) + strlen(ACCEPT_ICY_META);
+ accept_length() + strlen(CONN_HEAD) + strlen(icy);
if(httpauth) {
tmp = (strlen(httpauth) + 1) * 4;
@@ -445,9 +463,9 @@ int http_open (char* url, char** content_type)
else request_url[0] = '\0';
strcat(request_url, purl);
if (proxyip != INADDR_NONE) {
if (hd->proxyip != INADDR_NONE) {
myport = proxyport;
myip = proxyip;
myip = hd->proxyip;
linelength = linelengthbase + strlen(purl);
if (linelength < linelengthbase) {
@@ -559,7 +577,7 @@ int http_open (char* url, char** content_type)
} */
append_accept(request);
strcat (request, CONN_HEAD);
strcat (request, ACCEPT_ICY_META);
strcat (request, icy);
server.sin_family = AF_INET;
server.sin_port = htons(myport);
server.sin_addr.s_addr = myip;
@@ -706,43 +724,30 @@ int http_open (char* url, char** content_type)
{
char *tmp;
size_t len;
/* watch out for content type */
debug1("searching for header values... %s", response);
/* watch out for content type */
if((tmp = get_header_val("content-type", response, &len)))
{
if(content_type != NULL)
{
if(len)
{
if(*content_type != NULL) free(*content_type);
*content_type = (char*) malloc(len+1);
if(*content_type != NULL)
{
strncpy(*content_type, tmp, len);
(*content_type)[len] = 0;
debug1("got type %s", *content_type);
}
else error("cannot allocate memory for content type!");
}
}
if(mpg123_set_string(&hd->content_type, tmp)) debug1("got content-type %s", hd->content_type.p);
else error1("unable to set content type to %s!", tmp);
}
/* watch out for icy-name */
else if((tmp = get_header_val("icy-name", response, &len)))
if((tmp = get_header_val("icy-name", response, &len)))
{
if(set_stringbuf(&icy.name, tmp)) debug1("got icy-name %s", icy.name.p);
if(mpg123_set_string(&hd->icy_name, tmp)) debug1("got icy-name %s", hd->icy_name.p);
else error1("unable to set icy name to %s!", tmp);
}
/* watch out for icy-url */
else if((tmp = get_header_val("icy-url", response, &len)))
{
if(set_stringbuf(&icy.url, tmp)) debug1("got icy-url %s", icy.name.p);
if(mpg123_set_string(&hd->icy_url, tmp)) debug1("got icy-url %s", hd->icy_name.p);
else error1("unable to set icy url to %s!", tmp);
}
/* watch out for icy-metaint */
else if((tmp = get_header_val("icy-metaint", response, &len)))
{
icy.interval = atoi(tmp);
debug1("got icy-metaint %li", (long int)icy.interval);
hd->icy_interval = (off_t) atol(tmp);
debug1("got icy-metaint %li", (long int)hd->icy_interval);
}
}
} while (response[0] != '\r' && response[0] != '\n');
@@ -763,7 +768,7 @@ exit:
#else /* defined(WIN32) || defined(GENERIC) */
/* stub */
int http_open (char* url, char** content_type)
int http_open (char* url, struct httpdata *hd)
{
return -1;
}

View File

@@ -13,6 +13,21 @@
#ifndef _HTTPGET_H_
#define _HTPPGET_H_
#include "mpg123.h"
struct httpdata
{
mpg123_string content_type;
mpg123_string icy_name;
mpg123_string icy_url;
off_t icy_interval;
char *proxyurl;
unsigned long proxyip;
};
void httpdata_init(struct httpdata *e);
void httpdata_reset(struct httpdata *e);
/* There is a whole lot of MIME types for the same thing.
the function will reduce it to a combination of these flags */
#define IS_FILE 1
@@ -24,7 +39,7 @@ int debunk_mime(const char* mime);
extern char *proxyurl;
extern unsigned long proxyip;
/* takes url and content type string address, opens resource, returns fd for data, allocates and sets content type */
extern int http_open (char* url, char** content_type);
extern int http_open (char* url, struct httpdata *hd);
extern char *httpauth;
#endif

View File

@@ -1,340 +0,0 @@
/*
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.org
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

View File

@@ -1,30 +0,0 @@
#include "icy.h"
#include <stdlib.h>
struct icy_meta icy;
void init_icy()
{
init_stringbuf(&icy.name);
init_stringbuf(&icy.url);
icy.data = NULL;
icy.interval = 0;
icy.next = 0;
icy.changed = 0;
}
void clear_icy()
{
/* if pointers are non-null, they have some memory */
free_stringbuf(&icy.name);
free_stringbuf(&icy.url);
free(icy.data);
init_icy();
}
void set_data(char* new_data)
{
if(icy.data) free(icy.data);
icy.data = new_data;
icy.changed = 1;
}

View File

@@ -1,26 +0,0 @@
/*
icy: support for SHOUTcast ICY meta info, an attempt to keep it organized
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.org
initially written by Thomas Orgis and modelled after patch by Honza
*/
#include <sys/types.h>
#include "stringbuf.h"
struct icy_meta
{
struct stringbuf name;
struct stringbuf url;
char* data;
off_t interval;
off_t next;
int changed;
};
/* bah, just make it global... why bother with all that poiner passing to "methods" when there will be only one? */
extern struct icy_meta icy;
void init_icy();
void clear_icy();

818
src/id3.c
View File

@@ -1,818 +0,0 @@
#include "mpg123.h"
#include "common.h"
#include "stringbuf.h"
#include "genre.h"
#include "id3.h"
struct taginfo
{
unsigned char version; /* 1, 2 */
struct stringbuf title;
struct stringbuf artist;
struct stringbuf album;
struct stringbuf year; /* be ready for 20570! */
struct stringbuf comment;
struct stringbuf genre;
};
struct taginfo id3;
/* UTF support definitions */
typedef int (*text_decoder)(char* dest, unsigned char* source, size_t len);
static int decode_il1(char* dest, unsigned char* source, size_t len);
static int decode_utf16(char* dest, unsigned char* source, size_t len, int str_be);
static int decode_utf16bom(char* dest, unsigned char* source, size_t len);
static int decode_utf16be(char* dest, unsigned char* source, size_t len);
static int decode_utf8(char* dest, unsigned char* source, size_t len);
int wide_bytelen(int width, char* string, size_t string_size);
static text_decoder text_decoders[4] =
{
decode_il1,
decode_utf16bom,
decode_utf16be,
decode_utf8
};
const int encoding_widths[4] = { 1, 2, 2, 1 };
/* the code starts here... */
void init_id3()
{
id3.version = 0; /* nothing there */
init_stringbuf(&id3.title);
init_stringbuf(&id3.artist);
init_stringbuf(&id3.album);
init_stringbuf(&id3.year);
init_stringbuf(&id3.comment);
init_stringbuf(&id3.genre);
}
void exit_id3()
{
free_stringbuf(&id3.title);
free_stringbuf(&id3.artist);
free_stringbuf(&id3.album);
free_stringbuf(&id3.year);
free_stringbuf(&id3.comment);
free_stringbuf(&id3.genre);
}
void reset_id3()
{
id3.version = 0;
id3.title.fill = 0;
id3.artist.fill = 0;
id3.album.fill = 0;
id3.year.fill = 0;
id3.comment.fill = 0;
id3.genre.fill = 0;
}
void store_id3_text(struct stringbuf* sb, char* source, size_t source_size)
{
size_t pos = 1; /* skipping the encoding */
int encoding;
int bwidth;
if(! source_size) return;
encoding = source[0];
debug1("encoding: %i\n", encoding);
if(encoding > 3)
{
warning1("Unknown text encoding %d, assuming ISO8859-1 - I will probably screw a bit up!", encoding);
encoding = 0;
}
bwidth = encoding_widths[encoding];
if((source_size-1) % bwidth)
{
/* Uh. (BTW, the -1 is for the encoding byte.) */
warning2("Weird tag size %d for encoding %d - I will probably trim too early or something but I think the MP3 is broken.", (int)source_size, encoding);
source_size -= (source_size-1) % bwidth;
}
/*
first byte: Text encoding $xx
Text fields store a list of strings terminated by null, whatever that is for the encoding.
That's not funny. Trying to work that by joining them into one string separated by line breaks...
...and assume a series of \0 being the separator for any encoding
*/
while(pos < source_size)
{
size_t l = wide_bytelen(bwidth, source+pos, source_size-pos);
debug2("wide bytelen of %lu: %lu", (unsigned long)(source_size-pos), (unsigned long)l);
/* we need space for the stuff plus the closing zero */
if((sb->size > sb->fill+l) || resize_stringbuf(sb, sb->fill+l+1))
{
/* append with line break - sb is in latin1 mode! */
if(sb->fill) sb->p[sb->fill-1] = '\n';
/* do not include the ending 0 in the conversion */
sb->fill += text_decoders[encoding](sb->p+sb->fill, (unsigned char *) source+pos, l-(source_size==pos+l ? 0 : bwidth));
sb->p[sb->fill++] = 0;
/* advance to beginning of next string */
pos += l;
}
else break;
}
}
/*
trying to parse ID3v2.3 and ID3v2.4 tags...
returns: 0 = read-error
-1 = illegal ID3 header; maybe extended to mean unparseable (to new) header in future
1 = somehow ok...
*/
int parse_new_id3(unsigned long first4bytes, struct reader *rds)
{
#define UNSYNC_FLAG 128
#define EXTHEAD_FLAG 64
#define EXP_FLAG 32
#define FOOTER_FLAG 16
#define UNKNOWN_FLAGS 15 /* 00001111*/
unsigned char buf[6];
unsigned long length=0;
unsigned char flags = 0;
int ret = 1;
unsigned char* tagdata = NULL;
unsigned char major = first4bytes & 0xff;
debug1("ID3v2: major tag version: %i", major);
if(major == 0xff) return -1;
if(!rds->read_frame_body(rds,buf,6)) /* read more header information */
return 0;
if(buf[0] == 0xff) /* major version, will never be 0xff */
return -1;
/* second new byte are some nice flags, if these are invalid skip the whole thing */
flags = buf[1];
debug1("ID3v2: flags 0x%08x", flags);
/* use 4 bytes from buf to construct 28bit uint value and return 1; return 0 if bytes are not synchsafe */
#define synchsafe_to_long(buf,res) \
( \
(((buf)[0]|(buf)[1]|(buf)[2]|(buf)[3]) & 0x80) ? 0 : \
(res = (((unsigned long) (buf)[0]) << 21) \
| (((unsigned long) (buf)[1]) << 14) \
| (((unsigned long) (buf)[2]) << 7) \
| ((unsigned long) (buf)[3]) \
,1) \
)
/* id3v2.3 does not store synchsafe frame sizes, but synchsafe tag size - doh! */
#define bytes_to_long(buf,res) \
( \
major == 3 ? \
(res = (((unsigned long) (buf)[0]) << 24) \
| (((unsigned long) (buf)[1]) << 16) \
| (((unsigned long) (buf)[2]) << 8) \
| ((unsigned long) (buf)[3]) \
,1) : synchsafe_to_long(buf,res) \
)
/* length-10 or length-20 (footer present); 4 synchsafe integers == 28 bit number */
/* we have already read 10 bytes, so left are length or length+10 bytes belonging to tag */
if(!synchsafe_to_long(buf+2,length)) return -1;
debug1("ID3v2: tag data length %lu", length);
if(param.verbose > 1) fprintf(stderr,"Note: ID3v2.%i rev %i tag of %lu bytes\n", major, buf[0], length);
/* skip if unknown version/scary flags, parse otherwise */
if((flags & UNKNOWN_FLAGS) || (major > 4) || (major < 3))
{
/* going to skip because there are unknown flags set */
warning2("ID3v2: Won't parse the ID3v2 tag with major version %u and flags 0x%xu - some extra code may be needed", major, flags);
if(!rds->skip_bytes(rds,length)) /* will not store data in backbuff! */
ret = 0;
}
else
{
id3.version = major;
/* try to interpret that beast */
if((tagdata = (unsigned char*) malloc(length+1)) != NULL)
{
debug("ID3v2: analysing frames...");
if(rds->read_frame_body(rds,tagdata,length))
{
unsigned long tagpos = 0;
debug1("ID3v2: have read at all %lu bytes for the tag now", (unsigned long)length+6);
/* going to apply strlen for strings inside frames, make sure that it doesn't overflow! */
tagdata[length] = 0;
if(flags & EXTHEAD_FLAG)
{
debug("ID3v2: skipping extended header");
if(!bytes_to_long(tagdata, tagpos)) ret = -1;
}
if(ret >= 0)
{
char id[5];
unsigned long framesize;
unsigned long fflags; /* need 16 bits, actually */
id[4] = 0;
/* pos now advanced after ext head, now a frame has to follow */
while(tagpos < length-10) /* I want to read at least a full header */
{
int i = 0;
unsigned long pos = tagpos;
/* level 1,2,3 - 0 is info from lame/info tag! */
/* rva tags with ascending significance, then general frames */
#define KNOWN_FRAMES 8
const char frame_type[KNOWN_FRAMES][5] = { "COMM", "TXXX", "RVA2", "TPE1", "TALB", "TIT2", "TYER", "TCON" };
enum { egal = -1, comment, extra, rva2, artist, album, title, year, genre } tt = egal;
/* we may have entered the padding zone or any other strangeness: check if we have valid frame id characters */
for(; i< 4; ++i) if( !( ((tagdata[tagpos+i] > 47) && (tagdata[tagpos+i] < 58))
|| ((tagdata[tagpos+i] > 64) && (tagdata[tagpos+i] < 91)) ) )
{
debug5("ID3v2: real tag data apparently ended after %lu bytes with 0x%02x%02x%02x%02x", tagpos, tagdata[tagpos], tagdata[tagpos+1], tagdata[tagpos+2], tagdata[tagpos+3]);
ret = -1;
break;
}
if(ret >= 0)
{
/* 4 bytes id */
strncpy(id, (char*) tagdata+pos, 4);
pos += 4;
/* size as 32 bits */
if(!bytes_to_long(tagdata+pos, framesize))
{
ret = -1;
error1("ID3v2: non-syncsafe size of %s frame, skipping the remainder of tag", id);
break;
}
if(param.verbose > 2) fprintf(stderr, "Note: ID3v2 %s frame of size %lu\n", id, framesize);
tagpos += 10 + framesize; /* the important advancement in whole tag */
pos += 4;
fflags = (((unsigned long) tagdata[pos]) << 8) | ((unsigned long) tagdata[pos+1]);
pos += 2;
/* for sanity, after full parsing tagpos should be == pos */
/* debug4("ID3v2: found %s frame, size %lu (as bytes: 0x%08lx), flags 0x%016lx", id, framesize, framesize, fflags); */
/* %0abc0000 %0h00kmnp */
#define BAD_FFLAGS (unsigned long) 36784
#define PRES_TAG_FFLAG 16384
#define PRES_FILE_FFLAG 8192
#define READ_ONLY_FFLAG 4096
#define GROUP_FFLAG 64
#define COMPR_FFLAG 8
#define ENCR_FFLAG 4
#define UNSYNC_FFLAG 2
#define DATLEN_FFLAG 1
/* shall not or want not handle these */
if(fflags & (BAD_FFLAGS | COMPR_FFLAG | ENCR_FFLAG))
{
warning("ID3v2: skipping invalid/unsupported frame");
continue;
}
for(i = 0; i < KNOWN_FRAMES; ++i)
if(!strncmp(frame_type[i], id, 4)){ tt = i; break; }
if(tt != egal)
{
int rva_mode = -1; /* mix / album */
unsigned long realsize = framesize;
unsigned char* realdata = tagdata+pos;
if((flags & UNSYNC_FLAG) || (fflags & UNSYNC_FFLAG))
{
unsigned long ipos = 0;
unsigned long opos = 0;
debug("Id3v2: going to de-unsync the frame data");
/* de-unsync: FF00 -> FF; real FF00 is simply represented as FF0000 ... */
/* damn, that means I have to delete bytes from withing the data block... thus need temporal storage */
/* standard mandates that de-unsync should always be safe if flag is set */
realdata = (unsigned char*) malloc(framesize); /* will need <= bytes */
if(realdata == NULL)
{
error("ID3v2: unable to allocate working buffer for de-unsync");
continue;
}
/* now going byte per byte through the data... */
realdata[0] = tagdata[pos];
opos = 1;
for(ipos = pos+1; ipos < pos+framesize; ++ipos)
{
if(!((tagdata[ipos] == 0) && (tagdata[ipos-1] == 0xff)))
{
realdata[opos++] = tagdata[ipos];
}
}
realsize = opos;
debug2("ID3v2: de-unsync made %lu out of %lu bytes", realsize, framesize);
}
pos = 0; /* now at the beginning again... */
switch(tt)
{
case comment: /* a comment that perhaps is a RVA / RVA_ALBUM/AUDIOPHILE / RVA_MIX/RADIO one */
{
/* Text encoding $xx */
/* Language $xx xx xx */
/* policy about encodings: do not care for now here */
/* if(realdata[0] == 0) */
{
/* don't care about language */
pos = 4;
if( !strcasecmp((char*)realdata+pos, "rva")
|| !strcasecmp((char*)realdata+pos, "rva_mix")
|| !strcasecmp((char*)realdata+pos, "rva_radio"))
rva_mode = 0;
else if( !strcasecmp((char*)realdata+pos, "rva_album")
|| !strcasecmp((char*)realdata+pos, "rva_audiophile")
|| !strcasecmp((char*)realdata+pos, "rva_user"))
rva_mode = 1;
if((rva_mode > -1) && (rva_level[rva_mode] <= tt+1))
{
char* comstr;
size_t comsize = realsize-4-(strlen((char*)realdata+pos)+1);
if(param.verbose > 2) fprintf(stderr, "Note: evaluating %s data for RVA\n", realdata+pos);
if((comstr = (char*) malloc(comsize+1)) != NULL)
{
memcpy(comstr,realdata+realsize-comsize, comsize);
comstr[comsize] = 0;
/* hm, what about utf16 here? */
rva_gain[rva_mode] = atof(comstr);
if(param.verbose > 2) fprintf(stderr, "Note: RVA value %fdB\n", rva_gain[rva_mode]);
rva_peak[rva_mode] = 0;
rva_level[rva_mode] = tt+1;
free(comstr);
}
else error("could not allocate memory for rva comment interpretation");
}
else
{
if(!strcasecmp((char*)realdata+pos, ""))
{
/* only add general comments */
realdata[pos] = realdata[pos-4]; /* the encoding field copied */
store_id3_text(&id3.comment, (char*)realdata+pos, realsize-4);
}
}
}
}
break;
case extra: /* perhaps foobar2000's work */
{
/* Text encoding $xx */
/* unicode would hurt in string comparison... */
if(realdata[0] == 0)
{
int is_peak = 0;
pos = 1;
if(!strncasecmp((char*)realdata+pos, "replaygain_track_",17))
{
debug("ID3v2: track gain/peak");
rva_mode = 0;
if(!strcasecmp((char*)realdata+pos, "replaygain_track_peak")) is_peak = 1;
else if(strcasecmp((char*)realdata+pos, "replaygain_track_gain")) rva_mode = -1;
}
else
if(!strncasecmp((char*)realdata+pos, "replaygain_album_",17))
{
debug("ID3v2: album gain/peak");
rva_mode = 1;
if(!strcasecmp((char*)realdata+pos, "replaygain_album_peak")) is_peak = 1;
else if(strcasecmp((char*)realdata+pos, "replaygain_album_gain")) rva_mode = -1;
}
if((rva_mode > -1) && (rva_level[rva_mode] <= tt+1))
{
char* comstr;
size_t comsize = realsize-1-(strlen((char*)realdata+pos)+1);
if(param.verbose > 2) fprintf(stderr, "Note: evaluating %s data for RVA\n", realdata+pos);
if((comstr = (char*) malloc(comsize+1)) != NULL)
{
memcpy(comstr,realdata+realsize-comsize, comsize);
comstr[comsize] = 0;
if(is_peak)
{
rva_peak[rva_mode] = atof(comstr);
if(param.verbose > 2) fprintf(stderr, "Note: RVA peak %fdB\n", rva_peak[rva_mode]);
}
else
{
rva_gain[rva_mode] = atof(comstr);
if(param.verbose > 2) fprintf(stderr, "Note: RVA gain %fdB\n", rva_gain[rva_mode]);
}
rva_level[rva_mode] = tt+1;
free(comstr);
}
else error("could not allocate memory for rva comment interpretation");
}
}
}
break;
case rva2: /* "the" RVA tag */
{
/* starts with null-terminated identification */
if(param.verbose > 2) fprintf(stderr, "Note: RVA2 identification \"%s\"\n", realdata);
/* default: some individual value, mix mode */
rva_mode = 0;
if( !strncasecmp((char*)realdata, "album", 5)
|| !strncasecmp((char*)realdata, "audiophile", 10)
|| !strncasecmp((char*)realdata, "user", 4))
rva_mode = 1;
if(rva_level[rva_mode] <= tt+1)
{
pos += strlen((char*) realdata) + 1;
if(realdata[pos] == 1)
{
++pos;
/* only handle master channel */
debug("ID3v2: it is for the master channel");
/* two bytes adjustment, one byte for bits representing peak - n bytes for peak */
/* 16 bit signed integer = dB * 512 */
/* we already assume short being 16 bit */
rva_gain[rva_mode] = (float) ((((short) realdata[pos]) << 8) | ((short) realdata[pos+1])) / 512;
pos += 2;
if(param.verbose > 2) fprintf(stderr, "Note: RVA value %fdB\n", rva_gain[rva_mode]);
/* heh, the peak value is represented by a number of bits - but in what manner? Skipping that part */
rva_peak[rva_mode] = 0;
rva_level[rva_mode] = tt+1;
}
}
}
break;
/* non-rva metainfo, simply store... */
case artist:
debug("ID3v2: parsing artist info");
store_id3_text(&id3.artist, (char*) realdata, realsize);
break;
case album:
debug("ID3v2: parsing album info");
store_id3_text(&id3.album, (char*) realdata, realsize);
break;
case title:
debug("ID3v2: parsing title info");
store_id3_text(&id3.title, (char*) realdata, realsize);
break;
case year:
debug("ID3v2: parsing year info");
store_id3_text(&id3.year, (char*) realdata, realsize);
break;
case genre:
debug("ID3v2: parsing genre info");
store_id3_text(&id3.genre, (char*) realdata, realsize);
break;
default: error1("ID3v2: unknown frame type %i", tt);
}
if((flags & UNSYNC_FLAG) || (fflags & UNSYNC_FFLAG)) free(realdata);
}
#undef BAD_FFLAGS
#undef PRES_TAG_FFLAG
#undef PRES_FILE_FFLAG
#undef READ_ONLY_FFLAG
#undef GROUP_FFLAG
#undef COMPR_FFLAG
#undef ENCR_FFLAG
#undef UNSYNC_FFLAG
#undef DATLEN_FFLAG
}
else break;
#undef KNOWN_FRAMES
}
}
}
else
{
error("ID3v2: Duh, not able to read ID3v2 tag data.");
ret = 0;
}
free(tagdata);
}
else
{
error1("ID3v2Arrg! Unable to allocate %lu bytes for interpreting ID3v2 data - trying to skip instead.", length);
if(!rds->skip_bytes(rds,length)) /* will not store data in backbuff! */
ret = 0;
}
}
/* skip footer if present */
if((flags & FOOTER_FLAG) && (!rds->skip_bytes(rds,length))) ret = 0;
return ret;
#undef UNSYNC_FLAG
#undef EXTHEAD_FLAG
#undef EXP_FLAG
#undef FOOTER_FLAG
#undef UNKOWN_FLAGS
}
void print_id3_tag(unsigned char *id3v1buf)
{
char genre_from_v1 = 0;
if(!(id3.version || id3v1buf)) return;
if(id3v1buf != NULL)
{
/* fill gaps in id3v2 info with id3v1 info */
struct id3tag {
char tag[3];
char title[30];
char artist[30];
char album[30];
char year[4];
char comment[30];
unsigned char genre;
};
struct id3tag *tag = (struct id3tag *) id3v1buf;
/* I _could_ skip the recalculation of fill ... */
if(!id3.title.fill)
{
if(id3.title.size >= 31 || resize_stringbuf(&id3.title, 31))
{
strncpy(id3.title.p,tag->title,30);
id3.title.p[30] = 0;
id3.title.fill = strlen(id3.title.p) + 1;
}
}
if(!id3.artist.fill)
{
if(id3.artist.size >= 31 || resize_stringbuf(&id3.artist,31))
{
strncpy(id3.artist.p,tag->artist,30);
id3.artist.p[30] = 0;
id3.artist.fill = strlen(id3.artist.p) + 1;
}
}
if(!id3.album.fill)
{
if(id3.album.size >= 31 || resize_stringbuf(&id3.album,31))
{
strncpy(id3.album.p,tag->album,30);
id3.album.p[30] = 0;
id3.album.fill = strlen(id3.album.p) + 1;
}
}
if(!id3.comment.fill)
{
if(id3.comment.size >= 31 || resize_stringbuf(&id3.comment,31))
{
strncpy(id3.comment.p,tag->comment,30);
id3.comment.p[30] = 0;
id3.comment.fill = strlen(id3.comment.p) + 1;
}
}
if(!id3.year.fill)
{
if(id3.year.size >= 5 || resize_stringbuf(&id3.year,5))
{
strncpy(id3.year.p,tag->year,4);
id3.year.p[4] = 0;
id3.year.fill = strlen(id3.year.p) + 1;
}
}
/*
genre is special... tag->genre holds an index, id3v2 genre may contain indices in textual form and raw textual genres...
*/
if(!id3.genre.fill)
{
if(id3.genre.size >= 31 || resize_stringbuf(&id3.genre,31))
{
if (tag->genre <= genre_count)
{
strncpy(id3.genre.p, genre_table[tag->genre], 30);
}
else
{
strncpy(id3.genre.p,"Unknown",30);
}
id3.genre.p[30] = 0;
id3.genre.fill = strlen(id3.genre.p) + 1;
genre_from_v1 = 1;
}
}
}
if(id3.genre.fill && !genre_from_v1)
{
/*
id3v2.3 says (id)(id)blabla and in case you want ot have (blabla) write ((blabla)
also, there is
(RX) Remix
(CR) Cover
id3v2.4 says
"one or several of the ID3v1 types as numerical strings"
or define your own (write strings), RX and CR
Now I am very sure that I'll encounter hellishly mixed up id3v2 frames, so try to parse both at once.
*/
struct stringbuf tmp;
init_stringbuf(&tmp);
debug1("interpreting genre: %s\n", id3.genre.p);
if(copy_stringbuf(&id3.genre, &tmp))
{
size_t num = 0;
size_t nonum = 0;
size_t i;
enum { nothing, number, outtahere } state = nothing;
id3.genre.fill = 0; /* going to be refilled */
/* number\n -> id3v1 genre */
/* (number) -> id3v1 genre */
/* (( -> ( */
for(i = 0; i < tmp.fill; ++i)
{
debug1("i=%lu", (unsigned long) i);
switch(state)
{
case nothing:
nonum = i;
if(tmp.p[i] == '(')
{
num = i+1; /* number starting as next? */
state = number;
debug1("( before number at %lu?", (unsigned long) num);
}
/* you know an encoding where this doesn't work? */
else if(tmp.p[i] >= '0' && tmp.p[i] <= '9')
{
num = i;
state = number;
debug1("direct number at %lu", (unsigned long) num);
}
else state = outtahere;
break;
case number:
/* fake number alert: (( -> ( */
if(tmp.p[i] == '(')
{
nonum = i;
state = outtahere;
debug("no, it was ((");
}
else if(tmp.p[i] == ')' || tmp.p[i] == '\n' || tmp.p[i] == 0)
{
if(i-num > 0)
{
/* we really have a number */
int gid;
char* genre = "Unknown";
tmp.p[i] = 0;
gid = atoi(tmp.p+num);
/* get that genre */
if (gid >= 0 && gid <= genre_count) genre = genre_table[gid];
debug1("found genre: %s", genre);
if(id3.genre.fill) add_to_stringbuf(&id3.genre, ", ");
add_to_stringbuf(&id3.genre, genre);
nonum = i+1; /* next possible stuff */
state = nothing;
debug1("had a number: %i", gid);
}
else
{
/* wasn't a number, nonum is set */
state = outtahere;
debug("no (num) thing...");
}
}
else if(!(tmp.p[i] >= '0' && tmp.p[i] <= '9'))
{
/* no number at last... */
state = outtahere;
debug("nothing numeric here");
}
else
{
debug("still number...");
}
break;
default: break;
}
if(state == outtahere) break;
}
if(nonum < tmp.fill-1)
{
if(id3.genre.fill) add_to_stringbuf(&id3.genre, ", ");
add_to_stringbuf(&id3.genre, tmp.p+nonum);
}
}
free_stringbuf(&tmp);
}
if(param.long_id3)
{
fprintf(stderr,"\n");
/* print id3v2 */
/* dammed, I use pointers as bool again! It's so convenient... */
fprintf(stderr,"\tTitle: %s\n", id3.title.fill ? id3.title.p : "");
fprintf(stderr,"\tArtist: %s\n", id3.artist.fill ? id3.artist.p : "");
fprintf(stderr,"\tAlbum: %s\n", id3.album.fill ? id3.album.p : "");
fprintf(stderr,"\tYear: %s\n", id3.year.fill ? id3.year.p : "");
fprintf(stderr,"\tGenre: %s\n", id3.genre.fill ? id3.genre.p : "");
fprintf(stderr,"\tComment: %s\n", id3.comment.fill ? id3.comment.p : "");
fprintf(stderr,"\n");
}
else
{
/* We are trying to be smart here and conserve vertical space.
So we will skip tags not set, and try to show them in two parallel columns if they are short, which is by far the most common case. */
/* one _could_ circumvent the strlen calls... */
if(id3.title.fill && id3.artist.fill && strlen(id3.title.p) <= 30 && strlen(id3.title.p) <= 30)
{
fprintf(stderr,"Title: %-30s Artist: %s\n",id3.title.p,id3.artist.p);
}
else
{
if(id3.title.fill) fprintf(stderr,"Title: %s\n", id3.title.p);
if(id3.artist.fill) fprintf(stderr,"Artist: %s\n", id3.artist.p);
}
if (id3.comment.fill && id3.album.fill && strlen(id3.comment.p) <= 30 && strlen(id3.album.p) <= 30)
{
fprintf(stderr,"Comment: %-30s Album: %s\n",id3.comment.p,id3.album.p);
}
else
{
if (id3.comment.fill)
fprintf(stderr,"Comment: %s\n", id3.comment.p);
if (id3.album.fill)
fprintf(stderr,"Album: %s\n", id3.album.p);
}
if (id3.year.fill && id3.genre.fill && strlen(id3.year.p) <= 30 && strlen(id3.genre.p) <= 30)
{
fprintf(stderr,"Year: %-30s Genre: %s\n",id3.year.p,id3.genre.p);
}
else
{
if (id3.year.fill)
fprintf(stderr,"Year: %s\n", id3.year.p);
if (id3.genre.fill)
fprintf(stderr,"Genre: %s\n", id3.genre.p);
}
}
}
/*
Preliminary UTF support routines
Text decoder decodes the ID3 text content from whatever encoding to plain ASCII, substituting unconvertable characters with '*' and returning the final length of decoded string.
TODO: iconv() to whatever locale. But we will want to keep this code anyway for systems w/o iconv(). But we currently assume that it is enough to allocate @len bytes in dest. That might not be true when converting to Unicode encodings.
*/
static int decode_il1(char* dest, unsigned char* source, size_t len)
{
memcpy(dest, source, len);
return len;
}
static int decode_utf16(char* dest, unsigned char* source, size_t len, int str_be)
{
int spos = 0;
int dlen = 0;
len -= len % 2;
/* Just ASCII, we take it easy. */
for (; spos < len; spos += 2)
{
unsigned short word;
if(str_be) word = source[spos] << 8 | source[spos+1];
else word = source[spos] | source[spos+1] << 8;
/* utf16 continuation byte */
if(word & 0xdc00) continue;
/* utf16 out-of-range codepoint */
else if(word > 255) dest[dlen++] = '*';
/* an old-school character */
else dest[dlen++] = word; /* would a cast be good here? */
}
return dlen;
}
static int decode_utf16bom(char* dest, unsigned char* source, size_t len)
{
if(len < 2) return 0;
if(source[0] == 0xFF && source[1] == 0xFE) /* Little-endian */
return decode_utf16(dest, source + 2, len - 2, 0);
else /* Big-endian */
return decode_utf16(dest, source + 2, len - 2, 1);
}
static int decode_utf16be(char* dest, unsigned char* source, size_t len)
{
return decode_utf16(dest, source, len, 1);
}
static int decode_utf8(char* dest, unsigned char* source, size_t len)
{
int spos = 0;
int dlen = 0;
/* Just ASCII, we take it easy. */
for(; spos < len; spos++)
{
/* utf8 continuation byte bo, lead!*/
if((source[spos] & 0xc0) == 0x80) continue;
/* utf8 lead byte, no, cont! */
else if(source[spos] & 0x80) dest[dlen++] = '*';
else dest[dlen++] = source[spos];
}
return dlen;
}
/* determine byte length of string with characters wide @width;
terminating 0 will be included, too, if there is any */
int wide_bytelen(int width, char* string, size_t string_size)
{
size_t l = 0;
while(l < string_size)
{
int b;
for(b = 0; b < width; b++)
if(string[l + b])
break;
l += width;
if(b == width) /* terminating zero */
return l;
}
return l;
}

View File

@@ -1,11 +0,0 @@
#ifndef MPG123_ID3_H
#define MPG123_ID3_H
void init_id3();
void exit_id3();
void reset_id3();
void print_id3_tag(unsigned char *id3v1buf);
int parse_new_id3(unsigned long first4bytes, struct reader *rds);
#endif

286
src/id3print.c Normal file
View File

@@ -0,0 +1,286 @@
#include "mpg123.h"
#include "mpg123app.h"
#include "genre.h"
static void utf8_ascii(mpg123_string *dest, mpg123_string *source);
/* print tags... limiting the UTF-8 to ASCII */
void print_id3_tag(mpg123_handle *mh, int long_id3, FILE *out)
{
char genre_from_v1 = 0;
enum { TITLE=0, ARTIST, ALBUM, COMMENT, YEAR, GENRE, FIELDS } ti;
mpg123_string tag[FIELDS];
mpg123_id3v1 *v1;
mpg123_id3v2 *v2;
/* no memory allocated here, so return is safe */
for(ti=0; ti<FIELDS; ++ti) mpg123_init_string(&tag[ti]);
/* extract the data */
mpg123_id3(mh, &v1, &v2);
/* Only work if something there... */
if(v1 == NULL && v2 == NULL) return;
if(v2 != NULL) /* fill from ID3v2 data */
{
utf8_ascii(&tag[TITLE], &v2->title);
utf8_ascii(&tag[ARTIST], &v2->artist);
utf8_ascii(&tag[ALBUM], &v2->album);
utf8_ascii(&tag[COMMENT], &v2->comment);
utf8_ascii(&tag[YEAR], &v2->year);
utf8_ascii(&tag[GENRE], &v2->genre);
}
if(v1 != NULL) /* fill gaps with ID3v1 data */
{
/* I _could_ skip the recalculation of fill ... */
if(!tag[TITLE].fill)
{
if(tag[TITLE].size >= 31 || mpg123_resize_string(&tag[TITLE], 31))
{
strncpy(tag[TITLE].p,v1->title,30);
tag[TITLE].p[30] = 0;
tag[TITLE].fill = strlen(tag[TITLE].p) + 1;
}
}
if(!tag[ARTIST].fill)
{
if(tag[ARTIST].size >= 31 || mpg123_resize_string(&tag[ARTIST],31))
{
strncpy(tag[ARTIST].p,v1->artist,30);
tag[ARTIST].p[30] = 0;
tag[ARTIST].fill = strlen(tag[ARTIST].p) + 1;
}
}
if(!tag[ALBUM].fill)
{
if(tag[ALBUM].size >= 31 || mpg123_resize_string(&tag[ALBUM],31))
{
strncpy(tag[ALBUM].p,v1->album,30);
tag[ALBUM].p[30] = 0;
tag[ALBUM].fill = strlen(tag[ALBUM].p) + 1;
}
}
if(!tag[COMMENT].fill)
{
if(tag[COMMENT].size >= 31 || mpg123_resize_string(&tag[COMMENT],31))
{
strncpy(tag[COMMENT].p,v1->comment,30);
tag[COMMENT].p[30] = 0;
tag[COMMENT].fill = strlen(tag[COMMENT].p) + 1;
}
}
if(!tag[YEAR].fill)
{
if(tag[YEAR].size >= 5 || mpg123_resize_string(&tag[YEAR],5))
{
strncpy(tag[YEAR].p,v1->year,4);
tag[YEAR].p[4] = 0;
tag[YEAR].fill = strlen(tag[YEAR].p) + 1;
}
}
/*
genre is special... v1->genre holds an index, id3v2 genre may contain indices in textual form and raw textual genres...
*/
if(!tag[GENRE].fill)
{
if(tag[GENRE].size >= 31 || mpg123_resize_string(&tag[GENRE],31))
{
if(v1->genre <= genre_count)
{
strncpy(tag[GENRE].p, genre_table[v1->genre], 30);
}
else
{
strncpy(tag[GENRE].p,"Unknown",30);
}
tag[GENRE].p[30] = 0;
tag[GENRE].fill = strlen(tag[GENRE].p) + 1;
genre_from_v1 = 1;
}
}
}
if(tag[GENRE].fill && !genre_from_v1)
{
/*
id3v2.3 says (id)(id)blabla and in case you want ot have (blabla) write ((blabla)
also, there is
(RX) Remix
(CR) Cover
id3v2.4 says
"one or several of the ID3v1 types as numerical strings"
or define your own (write strings), RX and CR
Now I am very sure that I'll encounter hellishly mixed up id3v2 frames, so try to parse both at once.
*/
mpg123_string tmp;
mpg123_init_string(&tmp);
debug1("interpreting genre: %s\n", tag[GENRE].p);
if(mpg123_copy_string(&tag[GENRE], &tmp))
{
size_t num = 0;
size_t nonum = 0;
size_t i;
enum { nothing, number, outtahere } state = nothing;
tag[GENRE].fill = 0; /* going to be refilled */
/* number\n -> id3v1 genre */
/* (number) -> id3v1 genre */
/* (( -> ( */
for(i = 0; i < tmp.fill; ++i)
{
debug1("i=%lu", (unsigned long) i);
switch(state)
{
case nothing:
nonum = i;
if(tmp.p[i] == '(')
{
num = i+1; /* number starting as next? */
state = number;
debug1("( before number at %lu?", (unsigned long) num);
}
/* you know an encoding where this doesn't work? */
else if(tmp.p[i] >= '0' && tmp.p[i] <= '9')
{
num = i;
state = number;
debug1("direct number at %lu", (unsigned long) num);
}
else state = outtahere;
break;
case number:
/* fake number alert: (( -> ( */
if(tmp.p[i] == '(')
{
nonum = i;
state = outtahere;
debug("no, it was ((");
}
else if(tmp.p[i] == ')' || tmp.p[i] == '\n' || tmp.p[i] == 0)
{
if(i-num > 0)
{
/* we really have a number */
int gid;
char* genre = "Unknown";
tmp.p[i] = 0;
gid = atoi(tmp.p+num);
/* get that genre */
if(gid >= 0 && gid <= genre_count) genre = genre_table[gid];
debug1("found genre: %s", genre);
if(tag[GENRE].fill) mpg123_add_string(&tag[GENRE], ", ");
mpg123_add_string(&tag[GENRE], genre);
nonum = i+1; /* next possible stuff */
state = nothing;
debug1("had a number: %i", gid);
}
else
{
/* wasn't a number, nonum is set */
state = outtahere;
debug("no (num) thing...");
}
}
else if(!(tmp.p[i] >= '0' && tmp.p[i] <= '9'))
{
/* no number at last... */
state = outtahere;
debug("nothing numeric here");
}
else
{
debug("still number...");
}
break;
default: break;
}
if(state == outtahere) break;
}
if(nonum < tmp.fill-1)
{
if(tag[GENRE].fill) mpg123_add_string(&tag[GENRE], ", ");
mpg123_add_string(&tag[GENRE], tmp.p+nonum);
}
}
mpg123_free_string(&tmp);
}
if(long_id3)
{
fprintf(out,"\n");
/* print id3v2 */
/* dammed, I use pointers as bool again! It's so convenient... */
fprintf(out,"\tTitle: %s\n", tag[TITLE].fill ? tag[TITLE].p : "");
fprintf(out,"\tArtist: %s\n", tag[ARTIST].fill ? tag[ARTIST].p : "");
fprintf(out,"\tAlbum: %s\n", tag[ALBUM].fill ? tag[ALBUM].p : "");
fprintf(out,"\tYear: %s\n", tag[YEAR].fill ? tag[YEAR].p : "");
fprintf(out,"\tGenre: %s\n", tag[GENRE].fill ? tag[GENRE].p : "");
fprintf(out,"\tComment: %s\n", tag[COMMENT].fill ? tag[COMMENT].p : "");
fprintf(out,"\n");
}
else
{
/* We are trying to be smart here and conserve vertical space.
So we will skip tags not set, and try to show them in two parallel columns if they are short, which is by far the most common case. */
/* one _could_ circumvent the strlen calls... */
if(tag[TITLE].fill && tag[ARTIST].fill && strlen(tag[TITLE].p) <= 30 && strlen(tag[TITLE].p) <= 30)
{
fprintf(out,"Title: %-30s Artist: %s\n",tag[TITLE].p,tag[ARTIST].p);
}
else
{
if(tag[TITLE].fill) fprintf(out,"Title: %s\n", tag[TITLE].p);
if(tag[ARTIST].fill) fprintf(out,"Artist: %s\n", tag[ARTIST].p);
}
if(tag[COMMENT].fill && tag[ALBUM].fill && strlen(tag[COMMENT].p) <= 30 && strlen(tag[ALBUM].p) <= 30)
{
fprintf(out,"Comment: %-30s Album: %s\n",tag[COMMENT].p,tag[ALBUM].p);
}
else
{
if(tag[COMMENT].fill)
fprintf(out,"Comment: %s\n", tag[COMMENT].p);
if(tag[ALBUM].fill)
fprintf(out,"Album: %s\n", tag[ALBUM].p);
}
if(tag[YEAR].fill && tag[GENRE].fill && strlen(tag[YEAR].p) <= 30 && strlen(tag[GENRE].p) <= 30)
{
fprintf(out,"Year: %-30s Genre: %s\n",tag[YEAR].p,tag[GENRE].p);
}
else
{
if(tag[YEAR].fill)
fprintf(out,"Year: %s\n", tag[YEAR].p);
if(tag[GENRE].fill)
fprintf(out,"Genre: %s\n", tag[GENRE].p);
}
}
for(ti=0; ti<FIELDS; ++ti) mpg123_free_string(&tag[ti]);
}
static void utf8_ascii(mpg123_string *dest, mpg123_string *source)
{
size_t spos = 0;
size_t dlen = 0;
char *p;
/* Find length, continuation bytes don't count. */
for(spos=0; spos < source->fill; ++spos)
if((source->p[spos] & 0xc0) == 0x80) continue;
else ++dlen;
if(!mpg123_resize_string(dest, dlen)){ mpg123_free_string(dest); return; }
/* Just ASCII, we take it easy. */
p = dest->p;
for(spos=0; spos < source->fill; ++spos)
{
*p++ = source->p[spos]; continue;
/* utf8 continuation byte bo, lead!*/
if((source->p[spos] & 0xc0) == 0x80) continue;
/* utf8 lead byte, no, cont! */
else if(source->p[spos] & 0x80) *p = '*';
else *p = source->p[spos];
++p; /* next output char */
}
if(dest->size) dest->p[dest->size-1] = 0;
dest->fill = dest->size; /* The one extra 0 is unaccounted. */
}

8
src/id3print.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef MPG123_ID3PRINT_H
#define MPG123_ID3PRINT_H
#include "mpg123.h"
void print_id3_tag(mpg123_handle *mh, int long_id3, FILE *out);
#endif

View File

@@ -1,164 +0,0 @@
/*
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.org
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

View File

@@ -1,155 +0,0 @@
/*
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.org
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,int outmode,audio_output_t *ao)
{
int clip=0;
int i,stereo = fr->stereo;
unsigned int balloc[2*SBLIMIT];
unsigned int scale_index[2][SBLIMIT];
ALIGNED(16) 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);
}
if(pcm_point >= audiobufsize)
flush_output(outmode,ao);
}
return clip;
}

View File

@@ -1,325 +0,0 @@
/*
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.org
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++)
{
table = opt_init_layer2_table(muls[k], mulmul[k]);
*table++ = 0.0;
}
}
real* init_layer2_table(real *table, double m)
{
int i,j;
for(j=3,i=0;i<63;i++,j--)
*table++ = m * pow(2.0,(double) j / 3.0);
return table;
}
#ifdef OPT_MMXORSSE
real* init_layer2_table_mmx(real *table, double m)
{
int i,j;
if(!param.down_sample)
for(j=3,i=0;i<63;i++,j--)
*table++ = 16384 * m * pow(2.0,(double) j / 3.0);
else
for(j=3,i=0;i<63;i++,j--)
*table++ = m * pow(2.0,(double) j / 3.0);
return table;
}
#endif
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,int outmode,audio_output_t *ao)
{
int clip=0;
int i,j;
int stereo = fr->stereo;
ALIGNED(16) 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) {
fprintf(stderr, "Truncating stereo boundary to sideband limit.\n");
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);
}
if(pcm_point >= audiobufsize)
flush_output(outmode,ao);
}
}
return clip;
}

File diff suppressed because it is too large Load Diff

View File

@@ -26,7 +26,7 @@
void dct64_altivec(real *out0,real *out1,real *samples)
{
real __attribute__ ((aligned (16))) bufs[64];
ALIGNED(16) real bufs[64];
{
register real *b1,*costab;

View File

@@ -133,6 +133,10 @@ int synth_1to1_mono2stereo_altivec(real *bandPtr, mpg123_handle *fr)
int synth_1to1_altivec(real *bandPtr, int channel, mpg123_handle *fr, int final)
{
<<<<<<< .working
=======
static ALIGNED(16) real buffs[4][4][0x110];
>>>>>>> .merge-right.r998
static const int step = 2;
short *samples = (short *) (fr->buffer.data + fr->buffer.fill);
@@ -168,7 +172,7 @@ int synth_1to1_altivec(real *bandPtr, int channel, mpg123_handle *fr, int final)
register int j;
real *window = decwin + 16 - bo1;
int __attribute__ ((aligned (16))) clip_tmp[4];
ALIGNED(16) int clip_tmp[4];
vector float v1,v2,v3,v4,v5,v6,v7,v8,v9;
vector unsigned char vperm1,vperm2,vperm3,vperm4,vperm5;
vector float vsum,vsum2,vsum3,vsum4,vmin,vmax;

View File

@@ -122,7 +122,7 @@ int do_layer1(mpg123_handle *fr)
int i,stereo = fr->stereo;
unsigned int balloc[2*SBLIMIT];
unsigned int scale_index[2][SBLIMIT];
real aligned(16) fraction[2][SBLIMIT];
ALIGNED(16) real fraction[2][SBLIMIT];
int single = fr->single;
fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext<<2)+4 : 32;

View File

@@ -293,7 +293,7 @@ int do_layer2(mpg123_handle *fr)
int clip=0;
int i,j;
int stereo = fr->stereo;
real aligned(16) fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */
ALIGNED(16) real fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */
unsigned int bit_alloc[64];
int scale[192];
int single = fr->single;

View File

@@ -1749,8 +1749,8 @@ int do_layer3(mpg123_handle *fr)
set_pointer(fr,sideinfo.main_data_begin);
for (gr=0;gr<granules;gr++) {
real aligned(16) hybridIn[2][SBLIMIT][SSLIMIT];
real aligned(16) hybridOut[2][SSLIMIT][SBLIMIT];
ALIGNED(16) real hybridIn[2][SBLIMIT][SSLIMIT];
ALIGNED(16) real hybridOut[2][SSLIMIT][SBLIMIT];
{
struct gr_info_s *gr_info = &(sideinfo.ch[0].gr[gr]);

View File

@@ -16,17 +16,11 @@
#define SKIP_JUNK 1
/* should these really be here? */
#ifdef _WIN32 /* Win32 Additions By Tony Million */
# undef MPG123_WIN32
# define MPG122_WIN32
#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif
#ifndef M_SQRT2
# define M_SQRT2 1.41421356237309504880
# ifndef REAL_IS_FLOAT
# define REAL_IS_FLOAT
# endif
# define NEW_DCT9
#endif
#ifdef SUNOS
@@ -113,19 +107,33 @@
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <math.h>
#ifndef WIN32
#include <sys/signal.h>
#include <unistd.h>
#endif
/* want to suport large files in future */
/* Types, types, types. */
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#include <sys/types.h>
#endif
#ifndef off_t
#define off_t long
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifndef SIZE_MAX
#define SIZE_MAX ((size_t)-1)
#endif
#ifndef ULONG_MAX
#define ULONG_MAX ((unsigned long)-1)
#endif
#include <math.h>
typedef unsigned char byte;

View File

@@ -22,9 +22,9 @@
/* this is included in mpg123.h, which includes config.h */
#ifdef CCALIGN
#define aligned(a) __attribute__((aligned(a)))
#define ALIGNED(a) __attribute__((aligned(a)))
#else
#define aligned(a)
#define ALIGNED(a)
#endif
/* the optimizations only cover the synth1to1 mode and the dct36 function */

View File

@@ -6,32 +6,18 @@
initially written by Michael Hipp & Thomas Orgis
*/
#include <ctype.h>
#include <stdlib.h>
#include <signal.h>
#include "mpg123lib_intern.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <math.h>
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <fcntl.h>
#include "mpg123lib_intern.h"
#include "getbits.h"
#ifdef WIN32
#include <winsock.h>
#endif
/* fr is a mpg123_handle* by convention here... */
#define NOQUIET (!(fr->p.flags & MPG123_QUIET))
#define VERBOSE (NOQUIET && fr->p.verbose)
#define VERBOSE2 (NOQUIET && fr->p.verbose > 1)
#define bsbufid(fr) (fr)->bsbuf==(fr)->bsspace[0] ? 0 : ((fr)->bsbuf==fr->bsspace[1] ? 1 : ( (fr)->bsbuf==(fr)->bsspace[0]+512 ? 2 : ((fr)->bsbuf==fr->bsspace[1]+512 ? 3 : -1) ) )
/*
@@ -242,7 +228,7 @@ static int check_lame_tag(mpg123_handle *fr)
{
/*
In theory, one should use that value for skipping...
When I know the exact number of samples I could simply count in audio_flush,
When I know the exact number of samples I could simply count in flush_output,
but that's problematic with seeking and such.
I still miss the real solution for detecting the end.
*/
@@ -594,7 +580,8 @@ init_resync:
}
else if (give_note)
{
fprintf(stderr,"Note: Illegal Audio-MPEG-Header 0x%08lx at offset 0x%lx.\n", newhead,fr->rd->tell(fr)-4);
fprintf(stderr,"Note: Illegal Audio-MPEG-Header 0x%08lx at offset 0x%lx.\n",
newhead, (long unsigned int)fr->rd->tell(fr)-4);
}
if(give_note && (newhead & 0xffffff00) == ('b'<<24)+('m'<<16)+('p'<<8)) fprintf(stderr,"Note: Could be a BMP album art.\n");

View File

@@ -17,6 +17,8 @@ struct reader_data
off_t filepos; /* position in file or position in buffer chain */
int filept;
int flags;
long timeout_sec;
ssize_t (*fdread)(mpg123_handle *, unsigned char *, size_t);
/* variables specific to feed reader */
off_t firstpos; /* the point of return on non-forget() */
struct buffy *buf; /* first in buffer chain */
@@ -54,6 +56,7 @@ off_t feed_set_pos(mpg123_handle *fr, off_t pos); /* Set position (inside availa
#define READER_SEEKABLE 0x4
#define READER_BUFFERED 0x8
#define READER_MICROSEEK 0x10
#define READER_NONBLOCK 0x20
#define READER_STREAM 0
#define READER_ICY_STREAM 1

View File

@@ -10,12 +10,39 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include "mpg123lib_intern.h"
static off_t get_fileinfo(mpg123_handle *);
/* A normal read and a read with timeout. */
static ssize_t plain_read(mpg123_handle *fr, unsigned char *buf, size_t count){ return read(fr->rdat.filept, buf, count); }
#ifndef WIN32
/* Wait for data becoming available, allowing soft-broken network connection to die
This is needed for Shoutcast servers that have forgotten about us while connection was temporarily down. */
static ssize_t timeout_read(mpg123_handle *fr, unsigned char *buf, size_t count)
{
struct timeval tv;
ssize_t ret = 0;
fd_set fds;
tv.tv_sec = rds->timeout_sec;
tv.tv_usec = 0;
FD_ZERO(&fds);
FD_SET(fr->rdat.filept, &fds);
ret = select(fr->rdat.filept+1, &fds, NULL, NULL, &tv);
if(ret > 0) ret = read(fr->rdat.filept, buf, count);
else
{
ret=-1; /* no activity is the error */
if(NOQUIET) error("stream timed out");
}
return ret;
}
#endif
/* stream based operation with icy meta data*/
static ssize_t icy_fullread(mpg123_handle *fr, unsigned char *buf, ssize_t count)
{
@@ -40,7 +67,7 @@ static ssize_t icy_fullread(mpg123_handle *fr, unsigned char *buf, ssize_t count
/* we are near icy-metaint boundary, read up to the boundary */
cut_pos = fr->icy.next - fr->rdat.filepos;
ret = read(fr->rdat.filept,buf,cut_pos);
ret = fr->rdat.fdread(fr,buf,cut_pos);
if(ret < 0) return READER_ERROR;
fr->rdat.filepos += ret;
@@ -49,7 +76,7 @@ static ssize_t icy_fullread(mpg123_handle *fr, unsigned char *buf, ssize_t count
/* now off to read icy data */
/* one byte icy-meta size (must be multiplied by 16 to get icy-meta length) */
ret = read(fr->rdat.filept,&temp_buff,1);
ret = fr->rdat.fdread(fr,&temp_buff,1);
if(ret < 0) return READER_ERROR;
if(ret == 0) break;
@@ -63,7 +90,7 @@ static ssize_t icy_fullread(mpg123_handle *fr, unsigned char *buf, ssize_t count
meta_buff = (char*) malloc(meta_size+1);
if(meta_buff != NULL)
{
ret = read(fr->rdat.filept,meta_buff,meta_size);
ret = fr->rdat.fdread(fr,meta_buff,meta_size);
meta_buff[meta_size] = 0; /* string paranoia */
if(ret < 0) return READER_ERROR;
@@ -83,7 +110,7 @@ static ssize_t icy_fullread(mpg123_handle *fr, unsigned char *buf, ssize_t count
fr->icy.next = fr->rdat.filepos+fr->icy.interval;
}
ret = read(fr->rdat.filept,buf+cnt,count-cnt);
ret = fr->rdat.fdread(fr,buf+cnt,count-cnt);
if(ret < 0) return READER_ERROR;
if(ret == 0) break;
@@ -106,7 +133,7 @@ static ssize_t plain_fullread(mpg123_handle *fr,unsigned char *buf, ssize_t coun
if((fr->rdat.flags & READER_ID3TAG) && fr->rdat.filepos + count > fr->rdat.filelen) count = fr->rdat.filelen - fr->rdat.filepos;
while(cnt < count)
{
ret = read(fr->rdat.filept,buf+cnt,count-cnt);
ret = fr->rdat.fdread(fr,buf+cnt,count-cnt);
if(ret < 0) return READER_ERROR;
if(ret == 0) break;
fr->rdat.filepos += ret;
@@ -126,6 +153,18 @@ static off_t stream_lseek(struct reader_data *rds, off_t pos, int whence)
static int default_init(mpg123_handle *fr)
{
#ifndef WIN32
if(param.timeout > 0)
{
fcntl(fr->rdat.filept, F_SETFL, O_NONBLOCK);
fr->rdat.fdread = timeout_read;
fr->rdat.timeout_sec = param.timeout;
fr->rdat.flags |= READER_NONBLOCK;
}
else
#endif
fr->rdat.fdread = plain_read;
fr->rdat.filelen = get_fileinfo(fr);
fr->rdat.filepos = 0;
if(fr->rdat.filelen >= 0)

View File

@@ -6,8 +6,6 @@
initially written by Michael Hipp
*/
#include <stdlib.h>
#include "mpg123lib_intern.h"
#ifdef OPT_MMXORSSE
@@ -28,11 +26,11 @@ const int aligned(32) costab_mmxsse[] =
#ifndef OPT_MMX_ONLY
/* that altivec alignment part here should not hurt generic code, I hope */
#ifdef OPT_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];
static ALIGNED(16) real cos64[16];
static ALIGNED(16) real cos32[8];
static ALIGNED(16) real cos16[4];
static ALIGNED(16) real cos8[2];
static ALIGNED(16) real cos4[1];
#else
static real cos64[16],cos32[8],cos16[4],cos8[2],cos4[1];
#endif

View File

@@ -1,57 +0,0 @@
/* mangle.h - This file has some CPP macros to deal with different symbol
* mangling across binary formats.
* (c)2002 by Felix Buenemann <atmosfear at users.sourceforge.net>
* File licensed under the GPL, see http://www.fsf.org/ for more info.
*/
/* ThOr: added the plain ASM_NAME
Also this is getting more generic with the align stuff. */
#ifndef __MANGLE_H
#define __MANGLE_H
#include "config.h"
#ifdef CCALIGN
#define MOVUAPS movaps
#else
#define MOVUAPS movups
#endif
#ifdef ASMALIGN_EXP
#define ALIGN4 .align 2
#define ALIGN8 .align 3
#define ALIGN16 .align 4
#define ALIGN32 .align 5
#else
#define ALIGN4 .align 4
#define ALIGN8 .align 8
#define ALIGN16 .align 16
#define ALIGN32 .align 32
#endif
/* Feel free to add more to the list, eg. a.out IMO */
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__OS2__) || \
(defined(__OpenBSD__) && !defined(__ELF__)) || defined(__APPLE__)
#define MANGLE(a) "_" #a
#define ASM_NAME(a) _##a
#define ASM_VALUE(a) $_##a
#else
#define MANGLE(a) #a
#define ASM_NAME(a) a
#define ASM_VALUE(a) "$" #a
#endif
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__)
#define COMM(a,b,c) .comm a,b
#else
#define COMM(a,b,c) .comm a,b,c
#endif
/* more hacks for macosx; no .bss ... */
#ifdef __APPLE__
#define BSS .data
#else
#define BSS .bss
#endif
#endif /* !__MANGLE_H */

View File

@@ -11,7 +11,7 @@
#include <ctype.h>
#include <ltdl.h>
#include "mpg123.h"
#include "mpg123app.h"
#ifndef HAVE_LTDL
#error Cannot build without LTDL library support

File diff suppressed because it is too large Load Diff

View File

@@ -1,439 +0,0 @@
/*
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.org
initially written by Michael Hipp
mpg123 defines
used source: musicout.h from mpegaudio package
*/
#ifndef _MPG123_H_
#define _MPG123_H_
/* everyone needs it */
#include "config.h"
#include "debug.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <math.h>
#ifndef WIN32
#include <sys/signal.h>
#include <unistd.h>
#endif
/* want to suport large files in future */
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
/* More integer stuff, just take what we can get... */
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifndef SIZE_MAX
#define SIZE_MAX ((size_t)-1)
#endif
#ifndef ULONG_MAX
#define ULONG_MAX ((unsigned long)-1)
#endif
typedef unsigned char byte;
#ifdef OS2
#include <float.h>
#endif
#define REMOTE_BUFFER_SIZE 2048
#define SKIP_JUNK 1
#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif
#ifndef M_SQRT2
# define M_SQRT2 1.41421356237309504880
#endif
#include "xfermem.h"
#ifdef SUNOS
#define memmove(dst,src,size) bcopy(src,dst,size)
#endif
#ifdef REAL_IS_FLOAT
# define real float
# define REAL_SCANF "%f"
# define REAL_PRINTF "%f"
#elif defined(REAL_IS_LONG_DOUBLE)
# define real long double
# define REAL_SCANF "%Lf"
# define REAL_PRINTF "%Lf"
#elif defined(REAL_IS_FIXED)
# define real long
# define REAL_RADIX 15
# define REAL_FACTOR (32.0 * 1024.0)
# define REAL_PLUS_32767 ( 32767 << REAL_RADIX )
# define REAL_MINUS_32768 ( -32768 << REAL_RADIX )
# define DOUBLE_TO_REAL(x) ((int)((x) * REAL_FACTOR))
# define REAL_TO_SHORT(x) ((x) >> REAL_RADIX)
# define REAL_MUL(x, y) (((long long)(x) * (long long)(y)) >> REAL_RADIX)
# define REAL_SCANF "%ld"
# define REAL_PRINTF "%ld"
#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
#include "module.h"
#include "audio.h"
/* 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
/* float output only for generic decoder! */
#ifdef FLOATOUT
#define MAXOUTBURST 1.0
#define scale_t double
#else
/* I suspect that 32767 would be a better idea here, but Michael put this in... */
#define MAXOUTBURST 32768
#define scale_t long
#endif
/* Pre Shift fo 16 to 8 bit converter table */
#define AUSHIFT (3)
struct al_table
{
short bits;
short d;
};
struct frame {
struct al_table *alloc;
/* could use types from optimize.h */
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,int,audio_output_t *);
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... */
};
#define FRAMEBUFUNIT (18 * 64 * 4)
#define VERBOSE_MAX 3
#define MONO_LEFT 1
#define MONO_RIGHT 2
#define MONO_MIX 4
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 */
char* output_module; /* audio output module to use */
char* output_device; /* audio output device to use */
int output_flags; /* legacy output destination for AIX/HP/Sun */
#ifdef HAVE_TERMIOS
int term_ctrl;
#endif
int force_mono;
int force_stereo;
int force_8bit;
long force_rate;
int down_sample;
int checkrange;
long doublespeed;
long halfspeed;
int force_reopen;
/* the testing part shared between 3dnow and multi mode */
#ifdef OPT_3DNOW
int stat_3dnow; /* automatic/force/force-off 3DNow! optimized code */
#endif
#ifdef OPT_MULTI
int test_cpu;
#endif
long realtime;
char filename[256];
#ifdef GAPLESS
int gapless; /* (try to) remove silence padding/delay to enable gapless playback */
#endif
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, 1: radio/mix/track 2: album/audiophile */
char* listname; /* name of playlist */
int long_id3;
#ifdef OPT_MULTI
char* cpu; /* chosen optimization, can be NULL/""/"auto"*/
int list_cpu;
#endif
#ifdef FIFO
char* fifo;
#endif
#ifndef WIN32
long timeout; /* timeout for reading in seconds */
#endif
long loop; /* looping of tracks */
};
/* start to use off_t to properly do LFS in future ... used to be long */
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);
off_t (*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;
long timeout_sec;
unsigned char id3buf[128];
};
#define READER_FD_OPENED 0x1
#define READER_ID3TAG 0x2
#define READER_SEEKABLE 0x4
#define READER_NONBLOCK 0x8
extern struct reader *rd,readers[];
extern char *equalfile;
/*ThOr: No fiddling with the pointer in control_generic! */
extern int have_eq_settings;
extern int halfspeed;
extern int buffer_fd[2];
extern txfermem *buffermem;
#ifndef NOXFERMEM
extern void buffer_loop(audio_output_t *ao,sigset_t *oldsigset);
#endif
/* ------ Declarations from "common.c" ------ */
extern void (*catchsignal(int signum, void(*handler)()))();
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 buffer_pid;
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);
extern int read_frame(struct frame *fr);
/* why extern? */
extern void prepare_audioinfo(struct frame *fr, audio_output_t *ao);
extern int play_frame(int init,struct frame *fr);
extern int do_layer3(struct frame *fr,int,audio_output_t *);
extern int do_layer2(struct frame *fr,int,audio_output_t *);
extern int do_layer1(struct frame *fr,int,audio_output_t *);
extern void do_equalizer(real *bandPtr,int channel);
/* synth_1to1 in optimize.h, one should also use opts for these here... */
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 int get_songlen(struct frame *fr,int no);
extern void init_layer3(int);
extern void init_layer2(void);
extern int make_conv16to8_table(int);
extern int synth_ntom_set_step(long,long);
extern int control_generic(struct frame *fr);
extern int cdr_open(audio_output_t *, char *ame);
extern int au_open(audio_output_t *, char *name);
extern int wav_open(audio_output_t *, char *wavfilename);
extern int wav_write(unsigned char *buf,int len);
extern int cdr_close(void);
extern int au_close(void);
extern int wav_close(void);
extern int au_open(audio_output_t *, char *aufilename);
extern int au_close(void);
extern int cdr_open(audio_output_t *, char *cdrfilename);
extern int cdr_close(void);
extern unsigned char *conv16to8;
extern long freqs[9];
extern real muls[27][64];
extern real equalizer[2][32];
extern real equalizer_sum[2][32];
extern int equalizer_cnt;
extern struct audio_format_name audio_val2name[];
extern struct parameter param;
/* avoid the SIGINT in terminal control */
void next_track(void);
extern scale_t outscale;
#include "optimize.h"
void *safe_realloc(void *ptr, size_t size);
#ifndef HAVE_STRERROR
const char *strerror(int errnum);
#endif
#endif

178
src/mpg123app.h Normal file
View File

@@ -0,0 +1,178 @@
/*
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.org
initially written by Michael Hipp
mpg123 defines
used source: musicout.h from mpegaudio package
*/
#ifndef MPG123_H
#define MPG123_H
/* everyone needs it */
#include "config.h"
#include "debug.h"
#include "httpget.h"
#include "mpg123.h"
#include "compat.h"
#define MPG123_REMOTE
#define REMOTE_BUFFER_SIZE 2048
#define MAXOUTBURST 32768
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <math.h>
#ifndef WIN32
#include <sys/signal.h>
#include <unistd.h>
#endif
/* want to suport large files in future */
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
/* More integer stuff, just take what we can get... */
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifndef SIZE_MAX
#define SIZE_MAX ((size_t)-1)
#endif
#ifndef ULONG_MAX
#define ULONG_MAX ((unsigned long)-1)
#endif
#ifdef OS2
#include <float.h>
#endif
typedef unsigned char byte;
#include "xfermem.h"
#ifdef __GNUC__
#define INLINE inline
#else
#define INLINE
#endif
#include "module.h"
#include "audio.h"
extern size_t bufferblock;
#define VERBOSE_MAX 3
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 verbose; /* verbose level */
char* output_module; /* audio output module to use */
char* output_device; /* audio output device to use */
int output_flags; /* legacy output destination for AIX/HP/Sun */
#ifdef HAVE_TERMIOS
int term_ctrl;
#endif
int checkrange;
int force_reopen;
int test_cpu;
long realtime;
char filename[256];
long listentry; /* possibility to choose playback of one entry in playlist (0: off, > 0 : select, < 0; just show list*/
char* listname; /* name of playlist */
int long_id3;
int list_cpu;
char *cpu;
#ifdef FIFO
char* fifo;
#endif
#ifndef WIN32
long timeout; /* timeout for reading in seconds */
#endif
long loop; /* looping of tracks */
/* parameters for mpg123 handle */
int down_sample;
long rva; /* (which) rva to do: 0: nothing, 1: radio/mix/track 2: album/audiophile */
long halfspeed;
long doublespeed;
long start_frame; /* frame offset to begin with */
long frame_number; /* number of frames to decode */
#ifdef FLOATOUT
double outscale;
#else
long outscale;
#endif
int flags;
long force_rate;
int talk_icy;
};
extern char *equalfile;
extern long framenum;
extern struct httpdata htd;
extern int buffer_fd[2];
extern txfermem *buffermem;
extern int buffer_pid;
#ifndef NOXFERMEM
extern void buffer_loop(audio_output_t *ao,sigset_t *oldsigset);
#endif
extern int OutputDescriptor;
#ifdef VARMODESUPPORT
extern int varmode;
extern int playlimit;
#endif
/* why extern? */
extern void prepare_audioinfo(mpg123_handle *mh, audio_output_t *ao);
extern int play_frame(void);
extern int control_generic(mpg123_handle *fr);
/* Eh... I see duplicated definitions. Clean up after merge! */
extern int cdr_open(audio_output_t *, char *ame);
extern int au_open(audio_output_t *, char *name);
extern int wav_open(audio_output_t *, char *wavfilename);
extern int wav_write(unsigned char *buf,int len);
extern int cdr_close(void);
extern int au_close(void);
extern int wav_close(void);
extern int au_open(audio_output_t *, char *aufilename);
extern int au_close(void);
extern int cdr_open(audio_output_t *, char *cdrfilename);
extern int cdr_close(void);
extern struct parameter param;
/* avoid the SIGINT in terminal control */
void next_track(void);
int open_track(char *fname);
void close_track(void);
#endif

View File

@@ -1,326 +0,0 @@
/*
optimize: get a grip on the different optimizations
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.org
initially written by Thomas Orgis, inspired by 3DNow stuff in mpg123.[hc]
Currently, this file contains the struct and function to choose an optimization variant and works only when OPT_MULTI is in effect.
*/
#include "mpg123.h" /* includes optimize.h */
#ifdef OPT_MULTI
struct_opts cpu_opts;
#include "getcpuflags.h"
void list_cpu_opt()
{
printf("CPU options:");
#ifdef OPT_3DNOWEXT
printf(" 3DNowExt");
#endif
#ifdef OPT_SSE
printf(" SSE");
#endif
#ifdef OPT_3DNOW
printf(" 3DNow");
#endif
#ifdef OPT_MMX
printf(" MMX");
#endif
#ifdef OPT_I586
printf(" i586");
#endif
#ifdef OPT_I586_DITHER
printf(" i586_dither");
#endif
#ifdef OPT_I486
printf(" i486");
#endif
#ifdef OPT_I386
printf(" i386");
#endif
#ifdef OPT_ALTIVEC
printf(" AltiVec");
#endif
#ifdef OPT_GENERIC
printf(" generic");
#endif
printf("\n");
}
void test_cpu_flags()
{
#ifdef OPT_X86
struct cpuflags cf;
getcpuflags(&cf);
if(cpu_i586(cf))
{
printf("Supported decoders:");
/* not yet: if(cpu_sse2(cf)) printf(" SSE2");
if(cpu_sse3(cf)) printf(" SSE3"); */
#ifdef OPT_3DNOWEXT
if(cpu_3dnowext(cf)) printf(" 3DNowExt");
#endif
#ifdef OPT_SSE
if(cpu_sse(cf)) printf(" SSE");
#endif
#ifdef OPT_3DNOW
if(cpu_3dnow(cf)) printf(" 3DNow");
#endif
#ifdef OPT_MMX
if(cpu_mmx(cf)) printf(" MMX");
#endif
#ifdef OPT_I586
printf(" i586");
#endif
#ifdef OPT_I586_DITHER
printf(" i586_dither");
#endif
#ifdef OPT_I386
printf(" i386");
#endif
#ifdef OPT_GENERIC
printf(" generic");
#endif
printf("\n");
}
else
{
printf("You have an i386 or i486... or perhaps a non-x86-32bit CPU?\n");
}
#else
printf("I only know x86 cpus...\n");
#endif
}
int set_cpu_opt()
{
#ifdef OPT_X86
struct cpuflags cf;
#endif
char* chosen = ""; /* the chosed decoder opt as string */
int auto_choose = 0;
int done = 0;
if( (param.cpu == NULL)
|| (param.cpu[0] == 0)
|| !strcasecmp(param.cpu, "auto") )
auto_choose = 1;
/* covers any i386+ cpu; they actually differ only in the synth_1to1 function... */
#ifdef OPT_X86
#ifdef OPT_MMXORSSE
cpu_opts.decwin = decwin;
cpu_opts.make_decode_tables = make_decode_tables;
cpu_opts.init_layer3_gainpow2 = init_layer3_gainpow2;
cpu_opts.init_layer2_table = init_layer2_table;
#endif
#ifdef OPT_3DNOW
cpu_opts.dct36 = dct36;
#endif
#ifdef OPT_3DNOWEXT
cpu_opts.dct36 = dct36;
#endif
if(getcpuflags(&cf) && cpu_i586(cf))
{
debug2("standard flags: 0x%08x\textended flags: 0x%08x\n", cf.std, cf.ext);
#ifdef OPT_3DNOWEXT
if( !done && (auto_choose || !strcasecmp(param.cpu, "3dnowext"))
&& cpu_3dnow(cf)
&& cpu_3dnowext(cf)
&& cpu_mmx(cf) )
{
int go = 1;
if(param.force_rate)
{
#if defined(K6_FALLBACK) || defined(PENTIUM_FALLBACK)
if(!auto_choose) error("I refuse to choose 3DNowExt as this will screw up with forced rate!");
else if(param.verbose) fprintf(stderr, "Note: Not choosing 3DNowExt because flexible rate not supported.\n");
go = 0;
#else
error("You will hear some awful sound because of flexible rate being chosen with SSE decoder!");
#endif
}
if(go){ /* temporary hack for flexible rate bug, not going indent this - fix it instead! */
chosen = "3DNowExt";
cpu_opts.dct36 = dct36_3dnowext;
cpu_opts.synth_1to1 = synth_1to1_sse;
cpu_opts.dct64 = dct64_mmx; /* only use the sse version in the synth_1to1_sse */
cpu_opts.decwin = decwin_mmx;
cpu_opts.make_decode_tables = make_decode_tables_mmx;
cpu_opts.init_layer3_gainpow2 = init_layer3_gainpow2_mmx;
cpu_opts.init_layer2_table = init_layer2_table_mmx;
cpu_opts.mpl_dct64 = dct64_3dnowext;
done = 1;
}
}
#endif
#ifdef OPT_SSE
if( !done && (auto_choose || !strcasecmp(param.cpu, "sse"))
&& cpu_sse(cf) && cpu_mmx(cf) )
{
int go = 1;
if(param.force_rate)
{
#ifdef PENTIUM_FALLBACK
if(!auto_choose) error("I refuse to choose SSE as this will screw up with forced rate!");
else if(param.verbose) fprintf(stderr, "Note: Not choosing SSE because flexible rate not supported.\n");
go = 0;
#else
error("You will hear some awful sound because of flexible rate being chosen with SSE decoder!");
#endif
}
if(go){ /* temporary hack for flexible rate bug, not going indent this - fix it instead! */
chosen = "SSE";
cpu_opts.synth_1to1 = synth_1to1_sse;
cpu_opts.dct64 = dct64_mmx; /* only use the sse version in the synth_1to1_sse */
cpu_opts.decwin = decwin_mmx;
cpu_opts.make_decode_tables = make_decode_tables_mmx;
cpu_opts.init_layer3_gainpow2 = init_layer3_gainpow2_mmx;
cpu_opts.init_layer2_table = init_layer2_table_mmx;
cpu_opts.mpl_dct64 = dct64_sse;
done = 1;
}
}
#endif
#ifdef OPT_3DNOW
cpu_opts.dct36 = dct36;
/* TODO: make autodetection for _all_ x86 optimizations (maybe just for i586+ and keep separate 486 build?) */
/* check cpuflags bit 31 (3DNow!) and 23 (MMX) */
if( !done && (auto_choose || !strcasecmp(param.cpu, "3dnow"))
&& (param.stat_3dnow < 2)
&& ((param.stat_3dnow == 1) || (cpu_3dnow(cf) && cpu_mmx(cf))))
{
chosen = "3DNow";
cpu_opts.dct36 = dct36_3dnow; /* 3DNow! optimized dct36() */
cpu_opts.synth_1to1 = synth_1to1_3dnow;
cpu_opts.dct64 = dct64_i386; /* use the 3dnow one? */
done = 1;
}
#endif
#ifdef OPT_MMX
if( !done && (auto_choose || !strcasecmp(param.cpu, "mmx"))
&& cpu_mmx(cf) )
{
int go = 1;
if(param.force_rate)
{
#ifdef PENTIUM_FALLBACK
if(!auto_choose) error("I refuse to choose MMX as this will screw up with forced rate!");
else if(param.verbose) fprintf(stderr, "Note: Not choosing MMX because flexible rate not supported.\n");
go = 0;
#else
error("You will hear some awful sound because of flexible rate being chosen with MMX decoder!");
#endif
}
if(go){ /* temporary hack for flexible rate bug, not going indent this - fix it instead! */
chosen = "MMX";
cpu_opts.synth_1to1 = synth_1to1_mmx;
cpu_opts.dct64 = dct64_mmx;
cpu_opts.decwin = decwin_mmx;
cpu_opts.make_decode_tables = make_decode_tables_mmx;
cpu_opts.init_layer3_gainpow2 = init_layer3_gainpow2_mmx;
cpu_opts.init_layer2_table = init_layer2_table_mmx;
done = 1;
}
}
#endif
#ifdef OPT_I586
if(!done && (auto_choose || !strcasecmp(param.cpu, "i586")))
{
chosen = "i586/pentium";
cpu_opts.synth_1to1 = synth_1to1_i586;
cpu_opts.synth_1to1_i586_asm = synth_1to1_i586_asm;
cpu_opts.dct64 = dct64_i386;
done = 1;
}
#endif
#ifdef OPT_I586_DITHER
if(!done && (auto_choose || !strcasecmp(param.cpu, "i586_dither")))
{
chosen = "dithered i586/pentium";
cpu_opts.synth_1to1 = synth_1to1_i586;
cpu_opts.dct64 = dct64_i386;
cpu_opts.synth_1to1_i586_asm = synth_1to1_i586_asm_dither;
done = 1;
}
#endif
}
#ifdef OPT_I486 /* that won't cooperate nicely in multi opt mode - forcing i486 in layer3.c */
if(!done && (auto_choose || !strcasecmp(param.cpu, "i486")))
{
chosen = "i486";
cpu_opts.synth_1to1 = synth_1to1_i386; /* i486 function is special */
cpu_opts.dct64 = dct64_i386;
done = 1;
}
#endif
#ifdef OPT_I386
if(!done && (auto_choose || !strcasecmp(param.cpu, "i386")))
{
chosen = "i386";
cpu_opts.synth_1to1 = synth_1to1_i386;
cpu_opts.dct64 = dct64_i386;
done = 1;
}
#endif
if(done) /* set common x86 functions */
{
cpu_opts.synth_1to1_mono = synth_1to1_mono_i386;
cpu_opts.synth_1to1_mono2stereo = synth_1to1_mono2stereo_i386;
cpu_opts.synth_1to1_8bit = synth_1to1_8bit_i386;
cpu_opts.synth_1to1_8bit_mono = synth_1to1_8bit_mono_i386;
cpu_opts.synth_1to1_8bit_mono2stereo = synth_1to1_8bit_mono2stereo_i386;
}
#endif /* OPT_X86 */
#ifdef OPT_ALTIVEC
if(!done && (auto_choose || !strcasecmp(param.cpu, "altivec")))
{
chosen = "AltiVec";
cpu_opts.dct64 = dct64_altivec;
cpu_opts.synth_1to1 = synth_1to1_altivec;
cpu_opts.synth_1to1_mono = synth_1to1_mono_altivec;
cpu_opts.synth_1to1_mono2stereo = synth_1to1_mono2stereo_altivec;
cpu_opts.synth_1to1_8bit = synth_1to1_8bit_altivec;
cpu_opts.synth_1to1_8bit_mono = synth_1to1_8bit_mono_altivec;
cpu_opts.synth_1to1_8bit_mono2stereo = synth_1to1_8bit_mono2stereo_altivec;
done = 1;
}
#endif
#ifdef OPT_GENERIC
if(!done && (auto_choose || !strcasecmp(param.cpu, "generic")))
{
chosen = "generic";
cpu_opts.dct64 = dct64;
cpu_opts.synth_1to1 = synth_1to1;
cpu_opts.synth_1to1_mono = synth_1to1_mono;
cpu_opts.synth_1to1_mono2stereo = synth_1to1_mono2stereo;
cpu_opts.synth_1to1_8bit = synth_1to1_8bit;
cpu_opts.synth_1to1_8bit_mono = synth_1to1_8bit_mono;
cpu_opts.synth_1to1_8bit_mono2stereo = synth_1to1_8bit_mono2stereo;
done = 1;
}
#endif
if(done)
{
if(!param.remote && !param.quiet) fprintf(stderr, "decoder: %s\n", chosen);
return 1;
}
else
{
error("Could not set optimization!");
return 0;
}
}
#endif

View File

@@ -1,333 +0,0 @@
/*
optimize: get a grip on the different optimizations
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.org
initially written by Thomas Orgis, taking from mpg123.[hc]
for building mpg123 with one optimization only, you have to choose exclusively between
OPT_GENERIC (generic C code for everyone)
OPT_I386 (Intel i386)
OPT_I486 (...)
OPT_I586 (Intel Pentium)
OPT_I586_DITHER (Intel Pentium with dithering/noise shaping for enhanced quality)
OPT_MMX (Intel Pentium and compatibles with MMX, fast, but not the best accuracy)
OPT_3DNOW (AMD 3DNow!, K6-2/3, Athlon, compatibles...)
OPT_ALTIVEC (Motorola/IBM PPC with AltiVec under MacOSX)
or you define OPT_MULTI and give a combination which makes sense (do not include i486, do not mix altivec and x86).
I still have to examine the dynamics of this here together with REAL_IS_FIXED.
*/
/* this is included in mpg123.h, which includes config.h */
#ifdef CCALIGN
#define ALIGNED(a) __attribute__((aligned(a)))
#else
#define ALIGNED(a)
#endif
/* the optimizations only cover the synth1to1 mode and the dct36 function */
/* the first two types are needed in set_synth_functions regardless of optimizations */
typedef int (*func_synth)(real *,int,unsigned char *,int *);
typedef int (*func_synth_mono)(real *,unsigned char *,int *);
typedef void (*func_dct36)(real *,real *,real *,real *,real *);
typedef void (*func_dct64)(real *,real *,real *);
typedef void (*func_make_decode_tables)(long);
typedef real (*func_init_layer3_gainpow2)(int);
typedef real* (*func_init_layer2_table)(real*, double);
typedef int (*func_synth_pent)(real *,int,unsigned char *);
/* last headaches about getting mmx hardcode out */
real init_layer3_gainpow2(int i);
real* init_layer2_table(real *table, double m);
void make_decode_tables(scale_t scaleval);
/* only 3dnow replaces that one, it's internal to layer3.c otherwise */
void dct36(real *,real *,real *,real *,real *);
#define opt_dct36 dct36
/* only mmx replaces those */
#define opt_make_decode_tables make_decode_tables
#define opt_decwin decwin
#define opt_init_layer3_gainpow2 init_layer3_gainpow2
#define opt_init_layer2_table init_layer2_table
#ifdef OPT_GENERIC
#define PENTIUM_FALLBACK
void dct64(real *,real *,real *);
int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt);
int synth_1to1 (real *,int,unsigned char *,int *);
int synth_1to1_8bit (real *,int,unsigned char *,int *);
int synth_1to1_mono (real *,unsigned char *,int *);
int synth_1to1_mono2stereo (real *,unsigned char *,int *);
int synth_1to1_8bit_mono (real *,unsigned char *,int *);
int synth_1to1_8bit_mono2stereo (real *,unsigned char *,int *);
#ifndef OPT_MULTI
#define opt_dct64 dct64
#define opt_synth_1to1 synth_1to1
#define opt_synth_1to1_mono synth_1to1_mono
#define opt_synth_1to1_mono2stereo synth_1to1_mono2stereo
#define opt_synth_1to1_8bit synth_1to1_8bit
#define opt_synth_1to1_8bit_mono synth_1to1_8bit_mono
#define opt_synth_1to1_8bit_mono2stereo synth_1to1_8bit_mono2stereo
#endif
#endif
/* i486 is special */
#ifdef OPT_I486
#define OPT_I386
#define FIR_BUFFER_SIZE 128
int synth_1to1_486(real *bandPtr,int channel,unsigned char *out,int nb_blocks);
void dct64_i486(int *a,int *b,real *c); /* not used generally */
#endif
#ifdef OPT_I386
#define PENTIUM_FALLBACK
#define OPT_X86
int synth_1to1_i386(real *bandPtr,int channel,unsigned char *out,int *pnt);
#ifndef OPT_MULTI
#define opt_synth_1to1 synth_1to1_i386
#endif
#endif
#ifdef OPT_I586
#define PENTIUM_FALLBACK
#define OPT_PENTIUM
#define OPT_X86
int synth_1to1_i586(real *bandPtr,int channel,unsigned char *out,int *pnt);
int synth_1to1_i586_asm(real *,int,unsigned char *);
#ifndef OPT_MULTI
#define opt_synth_1to1 synth_1to1_i586
#define opt_synth_1to1_i586_asm synth_1to1_i586_asm
#endif
#endif
#ifdef OPT_I586_DITHER
#define PENTIUM_FALLBACK
#define OPT_PENTIUM
#define OPT_X86
int synth_1to1_i586(real *bandPtr,int channel,unsigned char *out,int *pnt);
int synth_1to1_i586_asm_dither(real *,int,unsigned char *);
#ifndef OPT_MULTI
#define opt_synth_1to1 synth_1to1_i586
#define opt_synth_1to1_i586_asm synth_1to1_i586_asm_dither
#endif
#endif
/* That one has by far the most ugly hacks to make it cooperative. */
#ifdef OPT_MMX
#define OPT_MMXORSSE
#define OPT_X86
real init_layer3_gainpow2_mmx(int i);
real* init_layer2_table_mmx(real *table, double m);
/* I think one can optimize storage here with the normal decwin */
extern real decwin_mmx[512+32];
void dct64_mmx(real *,real *,real *);
int synth_1to1_mmx(real *bandPtr,int channel,unsigned char *out,int *pnt);
void make_decode_tables_mmx(long scaleval); /* tabinit_mmx.s */
#ifndef OPT_MULTI
#undef opt_decwin
#define opt_decwin decwin_mmx
#define opt_dct64 dct64_mmx
#define opt_synth_1to1 synth_1to1_mmx
#undef opt_make_decode_tables
#define opt_make_decode_tables make_decode_tables_mmx
#undef opt_init_layer3_gainpow2
#define opt_init_layer3_gainpow2 init_layer3_gainpow2_mmx
#undef opt_init_layer2_table
#define opt_init_layer2_table init_layer2_table_mmx
#define OPT_MMX_ONLY
#endif
#endif
/* first crude hack into our source */
#ifdef OPT_SSE
#define OPT_MMXORSSE
#define OPT_MPLAYER
#define OPT_X86
real init_layer3_gainpow2_mmx(int i);
real* init_layer2_table_mmx(real *table, double m);
/* I think one can optimize storage here with the normal decwin */
extern real decwin_mmx[512+32];
void dct64_mmx(real *,real *,real *);
void dct64_sse(real *,real *,real *);
int synth_1to1_sse(real *bandPtr,int channel,unsigned char *out,int *pnt);
void make_decode_tables_mmx(long scaleval); /* tabinit_mmx.s */
/* ugly! */
extern func_dct64 mpl_dct64;
#ifndef OPT_MULTI
#define opt_mpl_dct64 dct64_sse
#undef opt_decwin
#define opt_decwin decwin_mmx
#define opt_dct64 dct64_mmx /* dct64_sse is silent in downsampling modes */
#define opt_synth_1to1 synth_1to1_sse
#undef opt_make_decode_tables
#define opt_make_decode_tables make_decode_tables_mmx
#undef opt_init_layer3_gainpow2
#define opt_init_layer3_gainpow2 init_layer3_gainpow2_mmx
#undef opt_init_layer2_table
#define opt_init_layer2_table init_layer2_table_mmx
#define OPT_MMX_ONLY /* watch out! */
#endif
#endif
/* first crude hack into our source */
#ifdef OPT_3DNOWEXT
#define OPT_MMXORSSE
#define OPT_MPLAYER
#define OPT_X86
real init_layer3_gainpow2_mmx(int i);
real* init_layer2_table_mmx(real *table, double m);
/* I think one can optimize storage here with the normal decwin */
extern real decwin_mmx[512+32];
void dct64_mmx(real *,real *,real *);
void dct64_3dnowext(real *,real *,real *);
void dct36_3dnowext(real *,real *,real *,real *,real *);
int synth_1to1_sse(real *bandPtr,int channel,unsigned char *out,int *pnt);
void make_decode_tables_mmx(long scaleval); /* tabinit_mmx.s */
/* ugly! */
extern func_dct64 mpl_dct64;
#ifndef OPT_MULTI
#define opt_mpl_dct64 dct64_3dnowext
#undef opt_dct36
#define opt_dct36 dct36_3dnowext
#undef opt_decwin
#define opt_decwin decwin_mmx
#define opt_dct64 dct64_mmx /* dct64_sse is silent in downsampling modes */
#define opt_synth_1to1 synth_1to1_sse
#undef opt_make_decode_tables
#define opt_make_decode_tables make_decode_tables_mmx
#undef opt_init_layer3_gainpow2
#define opt_init_layer3_gainpow2 init_layer3_gainpow2_mmx
#undef opt_init_layer2_table
#define opt_init_layer2_table init_layer2_table_mmx
#define OPT_MMX_ONLY /* watch out! */
#endif
#endif
#ifndef OPT_MMX_ONLY
extern real *pnts[5];
extern real decwin[512+32];
#endif
/* 3dnow used to use synth_1to1_i586 for mono / 8bit conversion - was that intentional? */
/* I'm trying to skip the pentium code here ... until I see that that is indeed a bad idea */
#ifdef OPT_3DNOW
#define K6_FALLBACK /* a fallback for 3DNowExt */
#define OPT_X86
void dct36_3dnow(real *,real *,real *,real *,real *);
int synth_1to1_3dnow(real *,int,unsigned char *,int *);
#ifndef OPT_MULTI
#undef opt_dct36
#define opt_dct36 dct36_3dnow
#define opt_synth_1to1 synth_1to1_3dnow
#endif
#endif
#ifdef OPT_X86
/* these have to be merged back into one! */
unsigned int getcpuid();
unsigned int getextcpuflags();
unsigned int getstdcpuflags();
unsigned int getstd2cpuflags();
void dct64_i386(real *,real *,real *);
int synth_1to1_mono_i386(real *,unsigned char *,int *);
int synth_1to1_mono2stereo_i386(real *,unsigned char *,int *);
int synth_1to1_8bit_i386(real *,int,unsigned char *,int *);
int synth_1to1_8bit_mono_i386(real *,unsigned char *,int *);
int synth_1to1_8bit_mono2stereo_i386(real *,unsigned char *,int *);
#ifndef OPT_MULTI
#ifndef opt_dct64
#define opt_dct64 dct64_i386 /* default one even for 3dnow and i486 in decode_2to1, decode_ntom */
#endif
#define opt_synth_1to1_mono synth_1to1_mono_i386
#define opt_synth_1to1_mono2stereo synth_1to1_mono2stereo_i386
#define opt_synth_1to1_8bit synth_1to1_8bit_i386
#define opt_synth_1to1_8bit_mono synth_1to1_8bit_mono_i386
#define opt_synth_1to1_8bit_mono2stereo synth_1to1_8bit_mono2stereo_i386
#endif
#endif
#ifdef OPT_ALTIVEC
void dct64_altivec(real *out0,real *out1,real *samples);
int synth_1to1_altivec(real *,int,unsigned char *,int *);
int synth_1to1_mono_altivec(real *,unsigned char *,int *);
int synth_1to1_mono2stereo_altivec(real *,unsigned char *,int *);
int synth_1to1_8bit_altivec(real *,int,unsigned char *,int *);
int synth_1to1_8bit_mono_altivec(real *,unsigned char *,int *);
int synth_1to1_8bit_mono2stereo_altivec(real *,unsigned char *,int *);
#ifndef OPT_MULTI
#define opt_dct64 dct64_altivec
#define opt_synth_1to1 synth_1to1_altivec
#define opt_synth_1to1_mono synth_1to1_mono_altivec
#define opt_synth_1to1_mono2stereo synth_1to1_mono2stereo_altivec
#define opt_synth_1to1_8bit synth_1to1_8bit_altivec
#define opt_synth_1to1_8bit_mono synth_1to1_8bit_mono_altivec
#define opt_synth_1to1_8bit_mono2stereo synth_1to1_8bit_mono2stereo_altivec
#endif
#endif
/* used for multi opt mode and the single 3dnow mode to have the old 3dnow test flag still working */
void test_cpu_flags();
void list_cpu_opt();
#ifdef OPT_MULTI
int set_cpu_opt();
/* a simple global struct to hold the decoding function pointers, could be localized later if really wanted */
typedef struct
{
func_synth synth_1to1;
func_synth_mono synth_1to1_mono;
func_synth_mono synth_1to1_mono2stereo;
func_synth synth_1to1_8bit;
func_synth_mono synth_1to1_8bit_mono;
func_synth_mono synth_1to1_8bit_mono2stereo;
#ifdef OPT_PENTIUM
func_synth_pent synth_1to1_i586_asm;
#endif
#ifdef OPT_MMXORSSE
real *decwin; /* ugly... needed to get mmx together with folks*/
func_make_decode_tables make_decode_tables;
func_init_layer3_gainpow2 init_layer3_gainpow2;
func_init_layer2_table init_layer2_table;
#endif
#ifdef OPT_3DNOW
func_dct36 dct36;
#endif
func_dct64 dct64;
#ifdef OPT_MPLAYER
func_dct64 mpl_dct64;
#endif
} struct_opts;
extern struct_opts cpu_opts;
#define opt_synth_1to1 (cpu_opts.synth_1to1)
#define opt_synth_1to1_mono (cpu_opts.synth_1to1_mono)
#define opt_synth_1to1_mono2stereo (cpu_opts.synth_1to1_mono2stereo)
#define opt_synth_1to1_8bit (cpu_opts.synth_1to1_8bit)
#define opt_synth_1to1_8bit_mono (cpu_opts.synth_1to1_8bit_mono)
#define opt_synth_1to1_8bit_mono2stereo (cpu_opts.synth_1to1_8bit_mono2stereo)
#ifdef OPT_PENTIUM
#define opt_synth_1to1_i586_asm (cpu_opts.synth_1to1_i586_asm)
#endif
#ifdef OPT_MMXORSSE
#undef opt_make_decode_tables
#define opt_make_decode_tables (cpu_opts.make_decode_tables)
#undef opt_decwin
#define opt_decwin cpu_opts.decwin
#undef opt_init_layer3_gainpow2
#define opt_init_layer3_gainpow2 (cpu_opts.init_layer3_gainpow2)
#undef opt_init_layer2_table
#define opt_init_layer2_table (cpu_opts.init_layer2_table)
#endif
#ifdef OPT_3DNOW
#undef opt_dct36
#define opt_dct36 (cpu_opts.dct36)
#endif
#define opt_dct64 (cpu_opts.dct64)
#ifdef OPT_MPLAYER
#define opt_mpl_dct64 (cpu_opts.mpl_dct64)
#endif
#endif

View File

@@ -8,7 +8,7 @@
If we officially support Windows again, we should have this reworked to really cope with Windows paths, too.
*/
#include "mpg123.h"
#include "mpg123app.h"
#include "getlopt.h" /* for loptind */
#include "term.h" /* for term_restore */
#include "playlist.h"
@@ -57,8 +57,8 @@ void prepare_playlist(int argc, char** argv)
}
if(param.shuffle == 1) shuffle_playlist();
/* Don't need these anymore, we have copies! */
free_stringbuf(&pl.linebuf);
free_stringbuf(&pl.dir);
mpg123_free_string(&pl.linebuf);
mpg123_free_string(&pl.dir);
}
char *get_next_file()
@@ -86,7 +86,7 @@ char *get_next_file()
/* randomly select files, with repeating */
else newfile = pl.list[ (size_t) rand() % pl.fill ].url;
return newfile;
return (newfile != NULL && strcmp(newfile, "-") && strcmp(newfile, "")) ? newfile : NULL;
}
/* It doesn't really matter on program exit, but anyway...
@@ -107,8 +107,8 @@ void free_playlist()
pl.size = 0;
debug("free()d the playlist");
}
free_stringbuf(&pl.linebuf);
free_stringbuf(&pl.dir);
mpg123_free_string(&pl.linebuf);
mpg123_free_string(&pl.dir);
}
/* the constructor... */
@@ -122,8 +122,8 @@ void init_playlist()
pl.pos = 0;
pl.list = NULL;
pl.alloc_step = 10;
init_stringbuf(&pl.dir);
init_stringbuf(&pl.linebuf);
mpg123_init_string(&pl.dir);
mpg123_init_string(&pl.linebuf);
pl.type = UNKNOWN;
pl.loop = param.loop;
}
@@ -148,7 +148,7 @@ int add_next_file (int argc, char *argv[])
if ((slashpos=strrchr(param.listname, '/')))
{
/* up to and including /, with space for \0 */
if(resize_stringbuf(&pl.dir, 2 + slashpos - param.listname))
if(mpg123_resize_string(&pl.dir, 2 + slashpos - param.listname))
{
memcpy(pl.dir.p, param.listname, pl.dir.size-1);
pl.dir.p[pl.dir.size-1] = 0;
@@ -176,14 +176,15 @@ int add_next_file (int argc, char *argv[])
else if (!strncmp(param.listname, "http://", 7))
{
int fd;
char *listmime = NULL;
fd = http_open(param.listname, &listmime);
debug1("listmime: %p", (void*) listmime);
if(listmime != NULL)
struct httpdata htd;
httpdata_init(&htd);
fd = http_open(param.listname, &htd);
debug1("htd.content_type.p: %p", (void*) htd.content_type.p);
if(htd.content_type.p != NULL)
{
int mimi;
debug1("listmime value: %s", listmime);
mimi = debunk_mime(listmime);
debug1("htd.content_type.p value: %s", htd.content_type.p);
mimi = debunk_mime(htd.content_type.p);
if(mimi & IS_M3U) pl.type = M3U;
else if(mimi & IS_PLS) pl.type = PLS;
@@ -205,10 +206,10 @@ int add_next_file (int argc, char *argv[])
return 1;
}
}
fprintf(stderr, "Error: unknown playlist MIME type %s; maybe "PACKAGE_NAME" can support it in future if you report this to the maintainer.\n", listmime);
fprintf(stderr, "Error: unknown playlist MIME type %s; maybe "PACKAGE_NAME" can support it in future if you report this to the maintainer.\n", htd.content_type.p);
fd = -1;
}
free(listmime);
httpdata_reset(&htd);
}
if(fd < 0)
{
@@ -250,7 +251,7 @@ int add_next_file (int argc, char *argv[])
/* have is the length of the string read, without the closing \0 */
if(pl.linebuf.size <= have+1)
{
if(!resize_stringbuf(&pl.linebuf, pl.linebuf.size+LINEBUF_STEP))
if(!mpg123_resize_string(&pl.linebuf, pl.linebuf.size+LINEBUF_STEP))
{
error("cannot increase line buffer");
break;
@@ -382,7 +383,7 @@ int add_next_file (int argc, char *argv[])
need = pl.dir.size + strlen(pl.linebuf.p+line_offset);
if(pl.linebuf.size < need)
{
if(!resize_stringbuf(&pl.linebuf, need))
if(!mpg123_resize_string(&pl.linebuf, need))
{
error("unable to enlarge linebuf for appending path! skipping");
continue;

View File

@@ -1,14 +1,14 @@
/*
playlist: playlist logic
copyright 1995-2006 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright 1995-2007 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Michael Hipp, outsourced/reorganized by Thomas Orgis
*/
#ifndef MPG123_PLAYLIST_H
#define MPG123_PLAYLIST_H
#include "stringbuf.h"
#include "mpg123.h"
enum playlist_type { UNKNOWN = 0, M3U, PLS, NO_LIST };
@@ -28,8 +28,8 @@ typedef struct playlist_struct
size_t pos;
size_t alloc_step;
struct listitem* list;
struct stringbuf linebuf;
struct stringbuf dir;
mpg123_string linebuf;
mpg123_string dir;
enum playlist_type type;
} playlist_struct;

View File

@@ -1,464 +0,0 @@
/*
readers.c: reading input data
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.org
initially written by Michael Hipp
*/
#include "mpg123.h"
#include "httpget.h"
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include "buffer.h"
#include "common.h"
#include "icy.h"
static off_t get_fileinfo(struct reader *,char *buf);
static ssize_t icy_fullread(struct reader *rds,unsigned char *buf, ssize_t count);
static ssize_t plain_fullread(struct reader *rds,unsigned char *buf, ssize_t count);
ssize_t (*fullread)(struct reader *,unsigned char *, ssize_t) = plain_fullread;
static ssize_t timeout_read(struct reader *rds, void *buf, size_t count);
static ssize_t plain_read(struct reader *rds, void *buf, size_t count);
ssize_t (*fdread)(struct reader *rds, void *buf, size_t count) = plain_read;
static ssize_t plain_read(struct reader *rds, void *buf, size_t count){ return read(rds->filept, buf, count); }
#ifndef WIN32
/* Wait for data becoming available, allowing soft-broken network connection to die
This is needed for Shoutcast servers that have forgotten about us while connection was temporarily down. */
static ssize_t timeout_read(struct reader *rds, void *buf, size_t count)
{
struct timeval tv;
ssize_t ret = 0;
fd_set fds;
tv.tv_sec = rds->timeout_sec;
tv.tv_usec = 0;
FD_ZERO(&fds);
FD_SET(rds->filept, &fds);
ret = select(rds->filept+1, &fds, NULL, NULL, &tv);
if(ret > 0) ret = read(rds->filept, buf, count);
else
{
ret=-1; /* no activity is the error */
error("stream timed out");
}
return ret;
}
#endif
/* stream based operation with icy meta data*/
static ssize_t icy_fullread(struct reader *rds,unsigned char *buf, ssize_t count)
{
ssize_t ret,cnt;
cnt = 0;
/*
We check against READER_ID3TAG instead of rds->filelen >= 0 because if we got the ID3 TAG we know we have the end of the file.
If we don't have an ID3 TAG, then it is possible the file has grown since we started playing, so we want to keep reading from it if possible.
*/
if((rds->flags & READER_ID3TAG) && rds->filepos + count > rds->filelen) count = rds->filelen - rds->filepos;
while(cnt < count)
{
/* all icy code is inside this if block, everything else is the plain fullread we know */
/* debug1("read: %li left", (long) count-cnt); */
if(icy.interval && (rds->filepos+count > icy.next))
{
unsigned char temp_buff;
size_t meta_size;
ssize_t cut_pos;
/* we are near icy-metaint boundary, read up to the boundary */
cut_pos = icy.next-rds->filepos;
ret = fdread(rds,buf,cut_pos);
if(ret < 0) return ret;
rds->filepos += ret;
cnt += ret;
/* now off to read icy data */
/* one byte icy-meta size (must be multiplied by 16 to get icy-meta length) */
ret = fdread(rds,&temp_buff,1);
if(ret < 0) return ret;
if(ret == 0) break;
debug2("got meta-size byte: %u, at filepos %li", temp_buff, (long)rds->filepos );
rds->filepos += ret; /* 1... */
if((meta_size = ((size_t) temp_buff) * 16))
{
/* we have got some metadata */
char *meta_buff;
meta_buff = (char*) malloc(meta_size+1);
if(meta_buff != NULL)
{
ret = fdread(rds,meta_buff,meta_size);
meta_buff[meta_size] = 0; /* string paranoia */
if(ret < 0) return ret;
rds->filepos += ret;
if(icy.data) free(icy.data);
icy.data = meta_buff;
icy.changed = 1;
debug2("icy-meta: %s size: %d bytes", icy.data, (int)meta_size);
}
else
{
error1("cannot allocate memory for meta_buff (%lu bytes) ... trying to skip the metadata!", (unsigned long)meta_size);
rds->skip_bytes(rds, meta_size);
}
}
icy.next = rds->filepos+icy.interval;
}
ret = fdread(rds,buf+cnt,count-cnt);
if(ret < 0) return ret;
if(ret == 0) break;
rds->filepos += ret;
cnt += ret;
}
/* debug1("done reading, got %li", (long)cnt); */
return cnt;
}
/* stream based operation */
static ssize_t plain_fullread(struct reader *rds,unsigned char *buf, ssize_t count)
{
ssize_t ret,cnt=0;
/*
We check against READER_ID3TAG instead of rds->filelen >= 0 because if we got the ID3 TAG we know we have the end of the file.
If we don't have an ID3 TAG, then it is possible the file has grown since we started playing, so we want to keep reading from it if possible.
*/
if((rds->flags & READER_ID3TAG) && rds->filepos + count > rds->filelen) count = rds->filelen - rds->filepos;
while(cnt < count)
{
ret = fdread(rds,buf+cnt,count-cnt);
if(ret < 0) return ret;
if(ret == 0) break;
rds->filepos += ret;
cnt += ret;
}
return cnt;
}
static off_t stream_lseek(struct reader *rds, off_t pos, int whence)
{
off_t ret;
ret = lseek(rds->filept, pos, whence);
if (ret >= 0) rds->filepos = ret;
return ret;
}
static int default_init(struct reader *rds)
{
char buf[128];
#ifndef WIN32
if(param.timeout > 0)
{
fcntl(rds->filept, F_SETFL, O_NONBLOCK);
fdread = timeout_read;
rds->timeout_sec = param.timeout;
rds->flags |= READER_NONBLOCK;
}
else
#endif
fdread = plain_read;
rds->filelen = get_fileinfo(rds,buf);
rds->filepos = 0;
if(rds->filelen >= 0)
{
rds->flags |= READER_SEEKABLE;
if(!strncmp(buf,"TAG",3))
{
rds->flags |= READER_ID3TAG;
memcpy(rds->id3buf,buf,128);
}
}
return 0;
}
void stream_close(struct reader *rds)
{
if (rds->flags & READER_FD_OPENED) close(rds->filept);
}
/****************************************
* HACK,HACK,HACK: step back <num> frames
* can only work if the 'stream' isn't a real stream but a file
* returns 0 on success;
*/
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 defined 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;
}
/* returns reached position... negative ones are bad */
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();
}
/*
* returns length of a file (if filept points to a file)
* reads the last 128 bytes information into buffer
* ... that is not totally safe...
*/
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;
}
/*****************************************************************
* read frame helper
*/
struct reader *rd;
struct reader readers[] =
{
#ifdef READ_SYSTEM
{
system_init,
NULL, /* filled in by system_init() */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
} ,
#endif
{
default_init,
stream_close,
stream_head_read,
stream_head_shift,
stream_skip_bytes,
stream_read_frame_body,
stream_back_bytes,
stream_back_frame,
stream_tell,
stream_rewind
} ,
{
NULL
}
};
/* open the device to read the bit stream from it */
int open_stream(char *bs_filenam,int fd)
{
int i;
int filept_opened = 1;
int filept; /* descriptor of opened file/stream */
clear_icy();
if(!bs_filenam) /* no file to open, got a descriptor (stdin) */
{
if(fd < 0) /* special: read from stdin */
{
filept = 0;
filept_opened = 0; /* and don't try to close it... */
}
else filept = fd;
}
else if (!strncmp(bs_filenam, "http://", 7)) /* http stream */
{
char* mime = NULL;
filept = http_open(bs_filenam, &mime);
/* now check if we got sth. and if we got sth. good */
if((filept >= 0) && (mime != NULL) && strcmp(mime, "audio/mpeg") && strcmp(mime, "audio/x-mpeg"))
{
fprintf(stderr, "Error: unknown mpeg MIME type %s - is it perhaps a playlist (use -@)?\nError: If you know the stream is mpeg1/2 audio, then please report this as "PACKAGE_NAME" bug\n", mime == NULL ? "<nil>" : mime);
filept = -1;
}
if(mime != NULL) free(mime);
if(filept < 0) return filept; /* error... */
}
#ifndef O_BINARY
#define O_BINARY (0)
#endif
else if((filept = open(bs_filenam, O_RDONLY|O_BINARY)) < 0) /* a plain old file to open... */
{
perror(bs_filenam);
return filept; /* error... */
}
/* now we have something behind filept and can init the reader */
rd = NULL;
/* strongly considering removal of that loop...*/
for(i=0;;i++)
{
readers[i].filelen = -1;
readers[i].filept = filept;
readers[i].flags = 0;
if(filept_opened) readers[i].flags |= READER_FD_OPENED;
if(!readers[i].init)
{
error1("no init for reader %i!", i);
return -1;
}
/* now use this reader if it successfully inits */
if(readers[i].init(readers+i) >= 0)
{
rd = &readers[i];
break;
}
}
if(icy.interval)
{
fullread = icy_fullread;
icy.next = icy.interval;
}
else
{
fullread = plain_fullread;
}
/* id3tag printing moved to read_frame */
return filept;
}

View File

@@ -1,90 +0,0 @@
/*
stringbuf: mimicking a bit of C++ to more safely handle strings
copyright 2006-7 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Thomas Orgis
*/
#include "config.h"
#include "debug.h"
#include "stringbuf.h"
#include "mpg123.h" /* actually just for safe_realloc */
void init_stringbuf(struct stringbuf* sb)
{
sb->p = NULL;
sb->size = 0;
sb->fill = 0;
}
void free_stringbuf(struct stringbuf* sb)
{
if(sb->p != NULL)
{
free(sb->p);
init_stringbuf(sb);
}
}
int resize_stringbuf(struct stringbuf* sb, size_t new)
{
debug3("resizing string pointer %p from %lu to %lu", (void*) sb->p, (unsigned long)sb->size, (unsigned long)new);
if(sb->size != new)
{
char* t;
debug("really!");
t = (char*) safe_realloc(sb->p, new*sizeof(char));
debug1("realloc returned %p", (void*) t);
if(t != NULL)
{
sb->p = t;
sb->size = new;
return 1;
}
else return 0;
}
else return 1; /* success */
}
int copy_stringbuf(struct stringbuf* from, struct stringbuf* to)
{
if(resize_stringbuf(to, from->fill))
{
memcpy(to->p, from->p, to->size);
to->fill = to->size;
return 1;
}
else return 0;
}
int add_to_stringbuf(struct stringbuf* sb, char* stuff)
{
size_t addl = strlen(stuff)+1;
debug1("adding %s", stuff);
if(sb->fill)
{
if(sb->size >= sb->fill-1+addl || resize_stringbuf(sb, sb->fill-1+addl))
{
memcpy(sb->p+sb->fill-1, stuff, addl);
sb->fill += addl-1;
}
else return 0;
}
else
{
if(resize_stringbuf(sb, addl))
{
memcpy(sb->p, stuff, addl);
sb->fill = addl;
}
else return 0;
}
return 1;
}
int set_stringbuf(struct stringbuf* sb, char* stuff)
{
sb->fill = 0;
return add_to_stringbuf(sb, stuff);
}

View File

@@ -1,28 +0,0 @@
/*
stringbuf: mimicking a bit of C++ to more safely handle strings
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.org
initially written by Thomas Orgis
*/
#ifndef MPG123_STRINGBUF_H
#define MPG123_STRINGBUF_H
#include <string.h>
struct stringbuf
{
char* p;
size_t size;
size_t fill;
};
void init_stringbuf(struct stringbuf* sb);
void free_stringbuf(struct stringbuf* sb);
/* returning 0 on error, 1 on success */
int resize_stringbuf(struct stringbuf* sb, size_t new);
int copy_stringbuf(struct stringbuf* from, struct stringbuf* to);
int add_to_stringbuf(struct stringbuf* sb, char* stuff);
int set_stringbuf(struct stringbuf* sb, char* stuff);
#endif

View File

@@ -1,493 +0,0 @@
/*
system.c: system stream decoder (standalone)
copyright 1997-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.org
initially written by Michael Hipp
grabs an audio stream inside a video/audio system stream
This Program outputs only the first audio stream to STDOUT
currently this is an external program. You must pipe
your streams file to this program and the output to
the mpg123 player. e.g:
./system < my_system_stream.mpg | mpg123 -
*/
#include <stdio.h>
#include <errno.h>
#include "mpg123.h"
static int filept;
static int verbose = 1;
#define PACKET_START 0x000001ba
#define STREAM_END 0x000001b9
#define SYSTEM_STREAM 0x000001bb
/* the following two types are not supported */
#define AUDIO_STREAM 0x000001b8
#define VIDEO_STREAM 0x000001b9
#define PADDING_STREAM 0x000001be
#define RESERVED_STREAM 0x000001bc
#define PRIVATE_STREAM_1 0x000001bd
#define PRIVATE_STREAM_2 0x000001bf
static int system_back_frame(struct frame *fr,int num);
static int system_head_read(unsigned char *hbuf,unsigned long *newhead);
static int system_head_shift(unsigned char *hbuf,unsigned long *head);
static int system_skip_bytes(int len);
static int system_read_frame_body(int size);
static long system_tell(void);
struct system_info {
unsigned long rate;
int num_audio;
int num_video;
int fixed;
int csps;
int audio_lock;
int video_lock;
};
struct stream_info {
int id;
int id1;
int type;
int size;
int scale;
};
struct packet_info {
int scale;
int size;
unsigned long dts;
unsigned long pts;
};
struct system_info sys_info;
struct stream_info str_info[64];
static int my_read(int f,char *buf,int len)
{
int len1 = 0;
int ret;
while(len1 < len) {
ret = read(f,buf+len1,len-len1);
if(ret < 0)
return -1;
len1 += ret;
}
return len;
}
static int system_raw_read_head(int f,unsigned long *head)
{
unsigned char buf[4];
if(my_read(f,buf,4) != 4) {
perror("read_head");
return -1;
}
*head = (buf[0]<<24) + (buf[1]<<16) + (buf[2]<<8) + buf[3];
if(verbose > 1)
fprintf(stderr,"head: %08lx\n",*head);
return 0;
}
static int system_raw_read_word(int f,int *word)
{
unsigned char buf[2];
if(my_read(f,buf,2) != 2) {
perror("read_word");
return -1;
}
*word = (buf[0]<<8) + buf[1];
return 0;
}
static int system_raw_read(int f,int len,unsigned char *buf)
{
if(my_read(f,buf,len) != len)
return -1;
return 0;
}
static int system_raw_skip(int f,int len)
{
int ret;
int cnt = 0;
ret = lseek(f,len,SEEK_CUR);
if(ret < 0 && errno == ESPIPE) {
cnt = len;
while(cnt) {
char buf[1024];
if(cnt > 1024)
ret = read(f,buf,1024);
else
ret = read(f,buf,cnt);
if(ret < 0)
return -1;
cnt -= ret;
}
ret = len;
}
return ret;
}
static unsigned long system_raw_timer_value(unsigned char *buf)
{
unsigned long val;
if(!(buf[0] & 0x1) || !(buf[2] & 0x1) || !(buf[4] & 0x1)) {
if(verbose)
fprintf(stderr,"Warning: missing marker in time stamp!\n");
}
val = (buf[0] & 0xe) << (29-1);
val |= buf[1] << 21;
val |= (buf[2] & 0xfe) << (14-1);
val |= buf[3] << 7;
val |= buf[4] >> 1;
return val;
}
static int system_raw_read_packet_data(int fd,struct packet_info *pi)
{
static unsigned char buf[16384];
int len;
int pos = 0;
int i;
if(system_raw_read_word(filept,&len) < 0)
return -1;
if(verbose > 1)
fprintf(stderr,"Stream video/audio len: %d\n",len);
if(system_raw_read(fd,len,buf) < 0)
return -1;
for(i=0;i<16;i++,pos++) {
if(buf[pos] != 0xff)
break;
}
if(i == 16) {
fprintf(stderr,"Ouch ... too many stuffing bytes!\n");
return -1;
}
if( (buf[pos] & 0xc0) == 0x40 ) {
pi->scale = (buf[pos] >> 5) & 0x1;
pi->size = (buf[pos] & 0x1f) << 8;
pi->size |= buf[pos+1];
pos += 2;
}
switch( buf[pos] & 0xf0) {
case 0x00:
if(buf[pos] != 0x0f) {
fprintf(stderr,"Ouch ... illegal timer code!\n");
return -1;
}
pos++;
break;
case 0x20:
pi->pts = system_raw_timer_value(buf+pos);
pos += 5;
break;
case 0x30:
pi->pts = system_raw_timer_value(buf+pos);
pos += 5;
if( (buf[pos] & 0xf) != 0x10) {
if(verbose)
fprintf(stderr,"DTS should start with 0x1x!\n");
}
pi->dts = system_raw_timer_value(buf+pos);
pos += 5;
break;
default:
if(verbose)
fprintf(stderr,"Ouch ... illegal timer code!\n");
return -1;
}
#if 1
write(1,buf+pos,len-pos);
#endif
return 0;
}
static int system_raw_read_packet_info(int f,double *clock,unsigned long *rate)
{
unsigned char buf[8];
int i;
if(my_read(f,buf,8) != 8) {
perror("read_packet_info");
return -1;
}
*clock = 0.0;
for(i=0;i<5;i++) {
*clock *= 256.0;
*clock += (double) buf[4-i];
}
*rate = (buf[5]<<16) + (buf[6]<<8) + buf[7];
return 0;
}
static int system_raw_read_system_header(int f,struct system_info *ssi)
{
int rlen,len;
unsigned char buf[6+48*3];
int i,cnt;
if(system_raw_read_word(filept,&len) < 0)
return -1;
if(verbose > 1)
fprintf(stderr,"system len: %d\n",len);
rlen = len;
if(len > 6 + 48 * 3) {
if(verbose)
fprintf(stderr,"Oops .. large System header!\n");
rlen = 6+48*3;
}
if(my_read(f,buf,rlen) != rlen) {
perror("raw_read_system_header");
return -1;
}
if(len - rlen) {
if(system_raw_skip(filept,len-rlen) < 0)
return -1;
}
if(buf[5] != 0xff) {
if(verbose)
fprintf(stderr,"Warning: buf[5] !=0xff \n");
}
ssi->rate = (buf[0]<<16)+(buf[1]<<8)+buf[2];
if( (ssi->rate & 0x800001) != 0x800001) {
if(verbose)
fprintf(stderr,"System Header Byte 0: Missing bits\n");
return -1;
}
ssi->rate >>= 1;
ssi->rate &= 0x7fffff;
ssi->num_audio = buf[3] >> 2;
ssi->num_video = buf[4] & 0x1f;
ssi->fixed = buf[3] & 0x2;
ssi->csps = buf[3] & 0x1;
ssi->audio_lock = buf[4] & 0x80;
ssi->video_lock = buf[4] & 0x40;
if(verbose)
fprintf(stderr,"Audio: %d Video: %d, Lock: %d/%d, fixed: %d, csps: %d\n",
ssi->num_audio,ssi->num_video,ssi->audio_lock?1:0,ssi->video_lock?1:0,
ssi->fixed?1:0,ssi->csps?1:0);
i = 6;
cnt = 0;
while( i < rlen ) {
if( !(buf[i] & 0x80) || ((buf[i+1] & 0xc0) != 0xc0) ) {
fprintf(stderr,"system_raw_read_system_header byte %d,%d: bits not set!\n",i,i+1);
return -1;
}
str_info[cnt].id = buf[i];
if( (str_info[cnt].id & 0xe0) == 0xc0 ) {
str_info[cnt].type = 'A';
str_info[cnt].id1 = str_info[cnt].id & 0x1f;
}
else if((str_info[cnt].id & 0xf0) == 0xe0 ) {
str_info[cnt].type = 'V';
str_info[cnt].id1 = str_info[cnt].id & 0x0f;
}
else {
str_info[cnt].type = 'R';
str_info[cnt].id1 = str_info[cnt].id & 0x3f;
}
str_info[cnt].scale = buf[i+1] & 0x20;
str_info[cnt].size = ((buf[i+1] & 0x1f)<<8)+buf[i+2];
i += 3;
if(verbose)
fprintf(stderr,"ID: %#02x=%c%d, scale: %d, size %d\n",
str_info[cnt].id,str_info[cnt].type,str_info[cnt].id1,str_info[cnt].scale?1:0,str_info[cnt].size);
}
return 0;
}
/***************************************************
* init system layer read functions
*/
int system_init(struct reader *r)
{
unsigned long head;
double clk;
unsigned long rate;
int len;
int err;
r->back_frame = NULL;
r->head_read = system_head_read;
r->head_shift = system_head_shift;
r->skip_bytes = system_skip_bytes;
r->read_frame_body = system_read_frame_body;
r->tell = system_tell;
if(system_raw_read_head(filept,&head) < 0)
return -1;
if(head != PACKET_START) {
fprintf(stderr,"No PACKET_START found!\n");
return -1;
}
if(system_raw_read_packet_info(filept,&clk,&rate) < 0)
return -1;
err = 0;
while(err == 0) {
if(system_raw_read_head(filept,&head) < 0)
return -1;
if((head & 0xffffff00) != 0x00000100)
return -1;
switch(head) {
case PACKET_START:
if(system_raw_read_packet_info(filept,&clk,&rate))
return -1;
if(verbose > 1)
fprintf(stderr,"Packet Start\n");
break;
case STREAM_END:
if(verbose)
fprintf(stderr,"Stream End\n");
break;
case SYSTEM_STREAM:
if(system_raw_read_system_header(filept,&sys_info) < 0)
return -1;
break;
#if 0
case AUDIO_STREAM:
if(system_raw_read_word(filept,&len) < 0)
return -1;
if(verbose > 1)
fprintf(stderr,"STD audio len: %d\n",len);
if(system_raw_skip(filept,len) < 0)
return -1;
break;
case VIDEO_STREAM:
if(system_raw_read_word(filept,&len) < 0)
return -1;
if(verbose > 1)
fprintf(stderr,"STD video len: %d\n",len);
if(system_raw_skip(filept,len) < 0)
return -1;
break;
#endif
default:
if(head >= 0x000001c0 && head < 0x000001f0) {
if(verbose > 1)
fprintf(stderr,"Stream ID %ld\n",head - 0x000001c0);
if( (head - 0x000001c0) == 0x0) {
struct packet_info pi;
if(system_raw_read_packet_data(filept,&pi) < 0 )
return -1;
}
else {
if(system_raw_read_word(filept,&len) < 0)
return -1;
if(system_raw_skip(filept,len) < 0)
return -1;
}
break;
}
else if(head >= 0x000001bd && head < 0x000001c0) {
if(system_raw_read_word(filept,&len) < 0)
return -1;
if(system_raw_skip(filept,len) < 0)
return -1;
break;
}
else {
if(verbose)
fprintf(stderr,"unsupported head %8lx\n",head);
if(system_raw_read_word(filept,&len) < 0)
return -1;
if(verbose)
fprintf(stderr,"Skipping: %d bytes\n",len);
if(system_raw_skip(filept,len) < 0)
return -1;
break;
}
err = 1;
break;
}
}
return 0;
}
static int system_back_frame(struct frame *fr,int num)
{
return 0;
}
static int system_head_read(unsigned char *hbuf,unsigned long *newhead)
{
return 0;
}
static int system_head_shift(unsigned char *hbuf,unsigned long *head)
{
return 0;
}
static int system_skip_bytes(int len)
{
return 0;
}
static int system_read_frame_body(int size)
{
return 0;
}
static long system_tell(void)
{
return 0;
}
struct reader rd1;
void main(void)
{
int ret;
filept = 0;
ret = system_init(&rd1);
fprintf(stderr,"ret: %d\n",ret);
return ret;
}

View File

@@ -1,153 +0,0 @@
/*
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.org
initially written by Michael Hipp
*/
#include "mpg123.h"
static unsigned char *conv16to8_buf = NULL;
unsigned char *conv16to8;
/* All optimizations share this code - with the exception of MMX */
#ifndef OPT_MMX_ONLY
real decwin[512+32]; /* MMX has another one */
/* that altivec alignment part here should not hurt generic code, I hope */
#ifdef OPT_ALTIVEC
static ALIGNED(16) real cos64[16];
static ALIGNED(16) real cos32[8];
static ALIGNED(16) real cos16[4];
static ALIGNED(16) real cos8[2];
static ALIGNED(16) real 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 };
void make_decode_tables(scale_t 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
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;
}

View File

@@ -1,169 +0,0 @@
/*
tabinit_mmx: make_decode_tables_mmx
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.org
initially written by the mysterious higway (apparently)
*/
#include "mangle.h"
BSS
ALIGN32
COMM(ASM_NAME(decwin_mmx),2176,32)
ALIGN32
COMM(ASM_NAME(decwins),2176,32)
.data
ALIGN32
intwinbase:
.value 0, -1, -1, -1, -1, -1, -1, -2
.value -2, -2, -2, -3, -3, -4, -4, -5
.value -5, -6, -7, -7, -8, -9, -10, -11
.value -13, -14, -16, -17, -19, -21, -24, -26
.value -29, -31, -35, -38, -41, -45, -49, -53
.value -58, -63, -68, -73, -79, -85, -91, -97
.value -104, -111, -117, -125, -132, -139, -147, -154
.value -161, -169, -176, -183, -190, -196, -202, -208
.value -213, -218, -222, -225, -227, -228, -228, -227
.value -224, -221, -215, -208, -200, -189, -177, -163
.value -146, -127, -106, -83, -57, -29, 2, 36
.value 72, 111, 153, 197, 244, 294, 347, 401
.value 459, 519, 581, 645, 711, 779, 848, 919
.value 991, 1064, 1137, 1210, 1283, 1356, 1428, 1498
.value 1567, 1634, 1698, 1759, 1817, 1870, 1919, 1962
.value 2001, 2032, 2057, 2075, 2085, 2087, 2080, 2063
.value 2037, 2000, 1952, 1893, 1822, 1739, 1644, 1535
.value 1414, 1280, 1131, 970, 794, 605, 402, 185
.value -45, -288, -545, -814, -1095, -1388, -1692, -2006
.value -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788
.value -5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597
.value -7910, -8209, -8491, -8755, -8998, -9219, -9416, -9585
.value -9727, -9838, -9916, -9959, -9966, -9935, -9863, -9750
.value -9592, -9389, -9139, -8840, -8492, -8092, -7640, -7134
.value -6574, -5959, -5288, -4561, -3776, -2935, -2037, -1082
.value -70, 998, 2122, 3300, 4533, 5818, 7154, 8540
.value 9975, 11455, 12980, 14548, 16155, 17799, 19478, 21189
.value 22929, 24694, 26482, 28289, 30112, 31947,-26209,-24360
.value -22511,-20664,-18824,-16994,-15179,-13383,-11610, -9863
.value -8147, -6466, -4822, -3222, -1667, -162, 1289, 2684
.value 4019, 5290, 6494, 7629, 8692, 9679, 10590, 11420
.value 12169, 12835, 13415, 13908, 14313, 14630, 14856, 14992
.value 15038
intwindiv:
.long 0x47800000 # 65536.0
.text
ALIGN32
.globl ASM_NAME(make_decode_tables_mmx)
ASM_NAME(make_decode_tables_mmx):
pushl %edi
pushl %esi
pushl %ebx
xorl %ecx,%ecx
xorl %ebx,%ebx
movl $32,%esi
movl $intwinbase,%edi
negl 16(%esp) /* scaleval */
pushl $2 /* intwinbase step */
.L00:
cmpl $528,%ecx
jnc .L02
movswl (%edi),%eax
cmpl $intwinbase+444,%edi
jc .L01
addl $60000,%eax
.L01:
pushl %eax
fildl (%esp)
fdivs intwindiv
fimull 24(%esp)
popl %eax
fsts ASM_NAME(decwin_mmx)(,%ecx,4)
fstps ASM_NAME(decwin_mmx)+64(,%ecx,4)
.L02:
leal -1(%esi),%edx
and %ebx,%edx
cmp $31,%edx
jnz .L03
addl $-1023,%ecx
test %esi,%ebx
jz .L03
negl 20(%esp)
.L03:
addl %esi,%ecx
addl (%esp),%edi
incl %ebx
cmpl $intwinbase,%edi
jz .L04
cmp $256,%ebx
jnz .L00
negl (%esp)
jmp .L00
.L04:
popl %eax
xorl %ecx,%ecx
xorl %ebx,%ebx
pushl $2
.L05:
cmpl $528,%ecx
jnc .L11
movswl (%edi),%eax
cmpl $intwinbase+444,%edi
jc .L06
addl $60000,%eax
.L06:
cltd
imull 20(%esp)
shrdl $17,%edx,%eax
cmpl $32767,%eax
movl $1055,%edx
jle .L07
movl $32767,%eax
jmp .L08
.L07:
cmpl $-32767,%eax
jge .L08
movl $-32767,%eax
.L08:
cmpl $512,%ecx
jnc .L09
subl %ecx,%edx
movw %ax,ASM_NAME(decwins)(,%edx,2)
movw %ax,ASM_NAME(decwins)-32(,%edx,2)
.L09:
testl $1,%ecx
jnz .L10
negl %eax
.L10:
movw %ax,ASM_NAME(decwins)(,%ecx,2)
movw %ax,ASM_NAME(decwins)+32(,%ecx,2)
.L11:
leal -1(%esi),%edx
and %ebx,%edx
cmp $31,%edx
jnz .L12
addl $-1023,%ecx
test %esi,%ebx
jz .L12
negl 20(%esp)
.L12:
addl %esi,%ecx
addl (%esp),%edi
incl %ebx
cmpl $intwinbase,%edi
jz .L13
cmp $256,%ebx
jnz .L05
negl (%esp)
jmp .L05
.L13:
popl %eax
popl %ebx
popl %esi
popl %edi
ret

View File

@@ -1,12 +1,12 @@
/*
term: terminal control
copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1
copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
initially written by Michael Hipp
*/
#include "mpg123.h"
#include "mpg123app.h"
#ifdef HAVE_TERMIOS
@@ -70,15 +70,15 @@ void term_init(void)
term_enable = 1;
}
static long term_handle_input(struct frame *,int);
static long term_handle_input(mpg123_handle *,int);
static int stopped = 0;
static int paused = 0;
static int pause_cycle;
long term_control(struct frame *fr, audio_output_t *ao)
off_t term_control(mpg123_handle *fr, audio_output_t *ao)
{
long offset = 0;
off_t offset = 0;
if(!term_enable) return 0;
@@ -86,7 +86,7 @@ long term_control(struct frame *fr, audio_output_t *ao)
{
if(!--pause_cycle)
{
pause_cycle=(int)(LOOP_CYCLES/compute_tpf(fr));
pause_cycle=(int)(LOOP_CYCLES/mpg123_tpf(fr));
offset-=pause_cycle;
if(param.usebuffer)
{
@@ -103,15 +103,15 @@ long term_control(struct frame *fr, audio_output_t *ao)
do
{
offset += term_handle_input(fr, stopped);
if((offset < 0) && (-offset > fr->num)) offset = - fr->num;
if((offset < 0) && (-offset > framenum)) offset = - framenum;
if(param.verbose && offset != 0)
print_stat(fr,fr->num+offset,0,ao);
print_stat(fr,offset,0);
} while (stopped);
return offset;
}
static long term_handle_input(struct frame *fr, int do_delay)
static long term_handle_input(mpg123_handle *fr, int do_delay)
{
int n = 1;
long offset = 0;
@@ -140,7 +140,7 @@ static long term_handle_input(struct frame *fr, int do_delay)
* end up in a deadlock. The only acceptable workaround was to
* resume playing as soon as BACK_KEY is pressed. This is not
* necessary when running non-buffered but I chose to remain
* compatible. [dk]
* compatible. [dk] -- now the resync is explicitly here... [ThOr]
*/
if(stopped) {
stopped = 0;
@@ -148,10 +148,12 @@ static long term_handle_input(struct frame *fr, int do_delay)
buffer_start();
fprintf(stderr, "%s", EMPTY_STRING);
}
if(paused)
pause_cycle=(int)(LOOP_CYCLES/compute_tpf(fr));
rd->rewind(rd);
fr->num=0;
if(paused) pause_cycle=(int)(LOOP_CYCLES/mpg123_tpf(fr));
mpg123_seek_frame(fr, 0, SEEK_SET);
if(param.usebuffer) buffer_resync();
framenum=0;
break;
case NEXT_KEY:
if(!param.usebuffer) ao.flush(&ao);
@@ -166,7 +168,7 @@ static long term_handle_input(struct frame *fr, int do_delay)
case PAUSE_KEY:
paused=1-paused;
if(paused) {
pause_cycle=(int)(LOOP_CYCLES/compute_tpf(fr));
pause_cycle=(int)(LOOP_CYCLES/mpg123_tpf(fr));
offset -= pause_cycle;
}
if(stopped) {
@@ -206,10 +208,10 @@ static long term_handle_input(struct frame *fr, int do_delay)
offset+=50;
break;
case VOL_UP_KEY:
do_volume((double) outscale / MAXOUTBURST + 0.02);
mpg123_volume_change(fr, 0.02);
break;
case VOL_DOWN_KEY:
do_volume((double) outscale / MAXOUTBURST - 0.02);
mpg123_volume_change(fr, -0.02);
break;
case VERBOSE_KEY:
param.verbose++;
@@ -220,16 +222,16 @@ static long term_handle_input(struct frame *fr, int do_delay)
}
break;
case RVA_KEY:
param.rva++;
if(param.rva > RVA_MAX) param.rva = 0;
do_rva();
if(++param.rva > MPG123_RVA_MAX) param.rva = 0;
mpg123_param(fr, MPG123_RVA, param.rva, 0);
mpg123_volume(fr, -1);
break;
case HELP_KEY:
fprintf(stderr,"\n\n -= terminal control keys =-\n[%c] or space bar\t interrupt/restart playback (i.e. 'pause')\n[%c]\t next track\n[%c]\t back to beginning of track\n[%c]\t pause while looping current sound chunk\n[%c]\t forward\n[%c]\t rewind\n[%c]\t fast forward\n[%c]\t fast rewind\n[%c]\t fine forward\n[%c]\t fine rewind\n[%c]\t volume up\n[%c]\t volume down\n[%c]\t RVA switch\n[%c]\t verbose switch\n[%c]\t this help\n[%c]\t quit\n\n",
STOP_KEY, NEXT_KEY, BACK_KEY, PAUSE_KEY, FORWARD_KEY, REWIND_KEY, FAST_FORWARD_KEY, FAST_REWIND_KEY, FINE_FORWARD_KEY, FINE_REWIND_KEY, VOL_UP_KEY, VOL_DOWN_KEY, RVA_KEY, VERBOSE_KEY, HELP_KEY, QUIT_KEY);
break;
case FRAME_INDEX_KEY:
print_frame_index(stderr);
mpg123_print_index(fr, stderr);
break;
default:
;

View File

@@ -57,7 +57,7 @@
#define EMPTY_STRING " \b\b\b\b\b\b\b\b"
void term_init(void);
long term_control(struct frame *fr, audio_output_t *ao);
off_t term_control(mpg123_handle *mh, audio_output_t *ao);
void term_restore(void);
#endif

View File

@@ -1,27 +0,0 @@
#include <stdio.h>
#include "getcpuflags.h"
int main()
{
int family;
struct cpuflags flags;
if(!getcpuflags(&flags)){ printf("CPU won't do cpuid (some old i386 or i486)\n"); return 0; }
family = (flags.id & 0xf00)>>8;
printf("family: %i\n", family);
printf("stdcpuflags: 0x%08x\n", flags.std);
printf("std2cpuflags: 0x%08x\n", flags.std2);
printf("extcpuflags: 0x%08x\n", flags.ext);
if(cpu_i586(flags))
{
printf("A i586 or better cpu with:");
if(cpu_mmx(flags)) printf(" mmx");
if(cpu_3dnow(flags)) printf(" 3dnow");
if(cpu_3dnowext(flags)) printf(" 3dnowext");
if(cpu_sse(flags)) printf(" sse");
if(cpu_sse2(flags)) printf(" sse2");
if(cpu_sse3(flags)) printf(" sse3");
printf("\n");
}
else printf("I guess you have some i486\n");
return 0;
}

View File

@@ -14,7 +14,7 @@
It's not a very clean code ... Fix this!
*/
#include "mpg123.h"
#include "mpg123app.h"
#ifdef FLOATOUT
#define WAVE_FORMAT 3
@@ -178,7 +178,7 @@ int au_open(audio_output_t *ao, char *aufilename)
flipendian = 0;
switch(ao->format) {
case AUDIO_FORMAT_SIGNED_16:
case MPG123_ENC_SIGNED_16:
{
int endiantest = testEndian();
if(endiantest == -1) return -1;
@@ -186,9 +186,9 @@ int au_open(audio_output_t *ao, char *aufilename)
long2bigendian(3,auhead.encoding,sizeof(auhead.encoding));
}
break;
case AUDIO_FORMAT_UNSIGNED_8:
ao->format = AUDIO_FORMAT_ULAW_8;
case AUDIO_FORMAT_ULAW_8:
case MPG123_ENC_UNSIGNED_8:
ao->format = MPG123_ENC_ULAW_8;
case MPG123_ENC_ULAW_8:
long2bigendian(1,auhead.encoding,sizeof(auhead.encoding));
break;
default:
@@ -217,11 +217,11 @@ int cdr_open(audio_output_t *ao, char *cdrfilename)
return -1;
#else
param.force_stereo = 0;
ao->format = AUDIO_FORMAT_SIGNED_16;
ao->format = MPG123_ENC_SIGNED_16;
ao->rate = 44100;
ao->channels = 2;
/*
if(ao->format != AUDIO_FORMAT_SIGNED_16 || ao->rate != 44100 || ao->channels != 2) {
if(ao->format != MPG123_ENC_SIGNED_16 || ao->rate != 44100 || ao->channels != 2) {
fprintf(stderr,"Oops .. not forced to 16 bit, 44kHz?, stereo\n");
exit(1);
}
@@ -248,11 +248,11 @@ int wav_open(audio_output_t *ao, char *wavfilename)
long2littleendian(bps=32,RIFF.WAVE.fmt.BitsPerSample,sizeof(RIFF.WAVE.fmt.BitsPerSample));
flipendian = testEndian();
#else
if(ao->format == AUDIO_FORMAT_SIGNED_16) {
if(ao->format == MPG123_ENC_SIGNED_16) {
long2littleendian(bps=16,RIFF.WAVE.fmt.BitsPerSample,sizeof(RIFF.WAVE.fmt.BitsPerSample));
flipendian = testEndian();
}
else if(ao->format == AUDIO_FORMAT_UNSIGNED_8)
else if(ao->format == MPG123_ENC_UNSIGNED_8)
long2littleendian(bps=8,RIFF.WAVE.fmt.BitsPerSample,sizeof(RIFF.WAVE.fmt.BitsPerSample));
else
{

View File

@@ -12,7 +12,7 @@
#ifndef NOXFERMEM
#include "mpg123.h"
#include "mpg123app.h"
#include <string.h>
#include <errno.h>
#include <sys/time.h>
@@ -25,7 +25,6 @@
#include <sys/select.h>
#endif
#ifndef HAVE_MMAP
#include <sys/ipc.h>
#include <sys/shm.h>
@@ -35,9 +34,9 @@
#define MAP_ANON MAP_ANONYMOUS
#endif
void xfermem_init (txfermem **xf, int bufsize, int msize, int skipbuf)
void xfermem_init (txfermem **xf, size_t bufsize, size_t msize, size_t skipbuf)
{
int regsize = bufsize + msize + skipbuf + sizeof(txfermem);
size_t regsize = bufsize + msize + skipbuf + sizeof(txfermem);
#ifdef HAVE_MMAP
# ifdef MAP_ANON
@@ -116,9 +115,9 @@ void xfermem_init_reader (txfermem *xf)
close (xf->fd[XF_WRITER]);
}
int xfermem_get_freespace (txfermem *xf)
size_t xfermem_get_freespace (txfermem *xf)
{
int freeindex, readindex;
size_t freeindex, readindex;
if(!xf)
return 0;
@@ -132,9 +131,9 @@ int xfermem_get_freespace (txfermem *xf)
return ((xf->size - (freeindex - readindex)) - 1);
}
int xfermem_get_usedspace (txfermem *xf)
size_t xfermem_get_usedspace (txfermem *xf)
{
int freeindex, readindex;
size_t freeindex, readindex;
if(!xf)
return 0;
@@ -221,10 +220,10 @@ int xfermem_block (int readwrite, txfermem *xf)
#else /* stubs for generic / win32 */
#include "mpg123.h"
#include "mpg123app.h"
#include "xfermem.h"
void xfermem_init (txfermem **xf, int bufsize, int msize, int skipbuf)
void xfermem_init (txfermem **xf, size_t bufsize, size_t msize, size_t skipbuf)
{
}
void xfermem_done (txfermem *xf)
@@ -236,11 +235,11 @@ void xfermem_init_writer (txfermem *xf)
void xfermem_init_reader (txfermem *xf)
{
}
int xfermem_get_freespace (txfermem *xf)
size_t xfermem_get_freespace (txfermem *xf)
{
return 0;
}
int xfermem_get_usedspace (txfermem *xf)
size_t xfermem_get_usedspace (txfermem *xf)
{
return 0;
}

View File

@@ -26,14 +26,14 @@
#endif
typedef struct {
int freeindex; /* [W] next free index */
int readindex; /* [R] next index to read */
size_t freeindex; /* [W] next free index */
size_t readindex; /* [R] next index to read */
int fd[2];
int wakeme[2];
byte *data;
byte *metadata;
int size;
int metasize;
size_t size;
size_t metasize;
int buf[3];
} txfermem;
/*
@@ -42,15 +42,12 @@ typedef struct {
* All other entries are initialized once.
*/
void xfermem_init (txfermem **xf, int bufsize, int msize,int skipbuf);
void xfermem_init (txfermem **xf, size_t bufsize, size_t msize, size_t skipbuf);
void xfermem_init_writer (txfermem *xf);
void xfermem_init_reader (txfermem *xf);
int xfermem_write (txfermem *xf, byte *data, int count);
int xfermem_read (txfermem *xf, byte *data, int count);
int xfermem_get_freespace (txfermem *xf);
int xfermem_get_usedspace (txfermem *xf);
size_t xfermem_get_freespace (txfermem *xf);
size_t xfermem_get_usedspace (txfermem *xf);
#define XF_CMD_WAKEUP_INFO 0x04
#define XF_CMD_WAKEUP 0x02
#define XF_CMD_TERMINATE 0x03