Mercurial > audlegacy-plugins
changeset 622:70f3b14434b2 trunk
[svn] - remove the buggy memoryleaking mpg123 and integrate madplug into the
buildsystem
author | nenolod |
---|---|
date | Thu, 08 Feb 2007 09:10:38 -0800 |
parents | 1b50f674e0b9 |
children | 443de962d0a0 |
files | ChangeLog configure.ac mk/rules.mk.in src/madplug/Makefile src/mpg123/Makefile src/mpg123/README src/mpg123/TODO src/mpg123/common.c src/mpg123/common.h src/mpg123/configure.c src/mpg123/dct64.c src/mpg123/dct64_altivec.c src/mpg123/decode.c src/mpg123/dxhead.c src/mpg123/dxhead.h src/mpg123/fileinfo.c src/mpg123/getbits.c src/mpg123/getbits.h src/mpg123/huffman.h src/mpg123/interface.c src/mpg123/l2tables.h src/mpg123/layer1.c src/mpg123/layer2.c src/mpg123/layer3.c src/mpg123/mp3.xpm src/mpg123/mpg123.c src/mpg123/mpg123.h src/mpg123/paranoia.c src/mpg123/resample.c src/mpg123/rtsp.c src/mpg123/tabinit.c src/mpg123/tag_c_hacked.cxx src/mpg123/tag_c_hacked.h |
diffstat | 33 files changed, 23 insertions(+), 10028 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Feb 08 01:52:27 2007 -0800 +++ b/ChangeLog Thu Feb 08 09:10:38 2007 -0800 @@ -1,3 +1,11 @@ +2007-02-08 09:52:27 +0000 Yoshiki Yazawa <yaz@cc.rim.or.jp> + revision [1328] + - remove ID3_FIELD_TEXTENCODING_UTF_16 case. + + trunk/src/madplug/input.c | 4 ---- + 1 file changed, 4 deletions(-) + + 2007-02-08 09:14:33 +0000 Yoshiki Yazawa <yaz@cc.rim.or.jp> revision [1326] revise input_id3_get_string():
--- a/configure.ac Thu Feb 08 01:52:27 2007 -0800 +++ b/configure.ac Thu Feb 08 09:10:38 2007 -0800 @@ -307,14 +307,16 @@ ) if test "$enable_mp3" = "yes"; then - INPUT_PLUGINS="$INPUT_PLUGINS mpg123" - PKG_CHECK_MODULES(LIBNMS,[libnms >= 0.6.0], - [LIBNMS_SRC=rtsp.c - AC_DEFINE(HAVE_NEMESI,,[Define if rtp/rtsp support is available]) - ],[LIBNMS_SRC=""]) - AC_SUBST(LIBNMS_CFLAGS) - AC_SUBST(LIBNMS_LIBS) - AC_SUBST(LIBNMS_SRC) + PKG_CHECK_MODULES(MAD, [mad id3tag], + [INPUT_PLUGINS="$INPUT_PLUGINS madplug"]) +# XXX rtsp support +# PKG_CHECK_MODULES(LIBNMS,[libnms >= 0.6.0], +# [LIBNMS_SRC=rtsp.c +# AC_DEFINE(HAVE_NEMESI,,[Define if rtp/rtsp support is available]) +# ],[LIBNMS_SRC=""]) +# AC_SUBST(LIBNMS_CFLAGS) +# AC_SUBST(LIBNMS_LIBS) +# AC_SUBST(LIBNMS_SRC) fi dnl *** Rocklight @@ -1209,7 +1211,7 @@ echo echo " Input Plugins" echo " -------------" -echo " MPEG 1/2/3 (mpg123): $enable_mp3" +echo " MPEG 1/2/3 (madplug): $enable_mp3" echo " MPEG 4 Audio (AAC): $enable_aac" echo " Windows Media Audio (wma): $enable_wma" echo " Module decoder (modplug): $have_modplug"
--- a/mk/rules.mk.in Thu Feb 08 01:52:27 2007 -0800 +++ b/mk/rules.mk.in Thu Feb 08 09:10:38 2007 -0800 @@ -349,3 +349,5 @@ LIBPROJECTM_LIBS ?= @LIBPROJECTM_LIBS@ MMS_CFLAGS ?= @MMS_CFLAGS@ MMS_LIBS ?= @MMS_LIBS@ +MAD_CFLAGS ?= @MAD_CFLAGS@ +MAD_LIBS ?= @MAD_LIBS@
--- a/src/madplug/Makefile Thu Feb 08 01:52:27 2007 -0800 +++ b/src/madplug/Makefile Thu Feb 08 09:10:38 2007 -0800 @@ -17,9 +17,8 @@ OBJECTS = ${SOURCES:.c=.o} -CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(TAGLIB_CFLAGS) $(ARCH_DEFINES) $(LIBNMS_CFLAGS) -I../../intl -I../.. -CXXFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(TAGLIB_CFLAGS) $(ARCH_DEFINES) -I../../intl -I../.. +CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(ARCH_DEFINES) $(MAD_CFLAGS) -I../../intl -I../.. -LIBADD = -lmad -lid3tag $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) $(TAGLIB_LIBS) $(LIBNMS_LIBS) +LIBADD = $(MAD_LIBS) $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) include ../../mk/objective.mk
--- a/src/mpg123/Makefile Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -include ../../mk/rules.mk -include ../../mk/init.mk - -OBJECTIVE_LIBS = libmpg123$(SHARED_SUFFIX) - -LIBDIR = $(plugindir)/$(INPUT_PLUGIN_DIR) - -SOURCES = mpg123.c configure.c fileinfo.c common.c \ - resample.c \ - layer1.c layer2.c layer3.c \ - tabinit.c $(LIBNMS_SRC) \ - dxhead.c decode.c $(DCT64) paranoia.c interface.c - -OBJECTS = ${SOURCES:.c=.o} tag_c_hacked.o - -CFLAGS += -UPSYCHO $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(TAGLIB_CFLAGS) $(ARCH_DEFINES) $(LIBNMS_CFLAGS) -I../../intl -I../.. -CXXFLAGS += -UPSYCHO $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(TAGLIB_CFLAGS) $(ARCH_DEFINES) -I../../intl -I../.. - -LIBADD = -ltag_c $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) $(TAGLIB_LIBS) $(LIBNMS_LIBS) - -include ../../mk/objective.mk
--- a/src/mpg123/README Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -libmpgdec - version 1.1 -======================= - -Copyright (c) 2005 - 2006 William Pitcock <nenolod@nenolod.net> -Portions copyright (c) 2001 Rafal Bosak <gyver@fanthom.irc.pl> -Portions copyright (c) 1999 Michael Hipp - -What is libmpgdec? -================== - -libmpgdec is a fully compliant ISO MPEG 1/2 Layer 1/2/3 decoder, -which shares no code with the `dist10' package. Instead, libmpgdec -is an extensively refactored version of the mpg123 sources included -with XMMS, which were released under the GPL. - -Due to the fact that the mpg123 source in XMMS were incomplete, several -components have been recreated and enhanced, including the synthesis -algorithms. - -Unlike it's predecessor, libmpgdec performs band-limited synthesis in order -to try to correct many of the shortcomings of the MPEG format. Also unlike -it's predecessor, useless assembly-based routines have been removed. - -Additionally, libmpgdec 1.1 includes new psychoaccoustic modeling routines -to try to enhance listening experience. - -libmpgdec 1.1 is the first "public" release, i.e. a release seperate from -Audacious with extra portability components added to improve adaptability -in other players and encoders/decoders. Versions of Audacious after 1.1 -will use this library package instead of using a statically linked decoder. - -How do I compile libmpgdec? -=========================== - -./configure -make -make install - -libmpgdec makes use of Autotools, and requires Glib 2.x. - -Why does an MP3 decoder library require Glib? -============================================= - -Simple. Glib lets us conveniently do things we would be able to not as cleanly -do otherwise. - -How do I program with libmpgdec? -================================ - -libmpgdec typically uses it's own thread for decoding. This is usually not a -major issue; however if it is, a lowlevel API (mainly undocumented) is provided -to allow for the implementation of custom event loops. - -libmpgdec and patents -===================== - -While I believe libmpgdec is not patent encumbered by the Huffman patents -(Thomson), and that it is not encumbered by any of the Fraunhofer or -Coding Technologies patents, I do not happen to be a patent lawyer, so -I cannot tell you for sure. I do however, know that the patents (in theory) -only cover linear synthesis-based decoding, and that libmpgdec uses -adaptive decoding. You can draw your own conclusions, there. - -That said, if you are using libmpgdec in a commercial application, it may -be wise for you to go ahead and get patent licences from Fraunhofer. - - -- William Pitcock <nenolod@nenolod.net>, May 30 2006
--- a/src/mpg123/TODO Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -getting from libmpgdec <internal> to libmpgdec <release> --------------------------------------------------------- - -1) All the audacious code needs to be moved out of the core library. - -2) read/seek callbacks need to be added. - -3) interfaces need to be designed -
--- a/src/mpg123/common.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,474 +0,0 @@ -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -#include <signal.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -#include "mpg123.h" - -const int tabsel_123[2][3][16] = { - {{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, - 448,}, - {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,}, - {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,}}, - {{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,}, - {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}, - {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}} -}; - -const int mpgdec_freqs[9] = - { 44100, 48000, 32000, 22050, 24000, 16000, 11025, 12000, 8000 }; - -struct bitstream_info bsi; - -extern gint mpgdec_bitrate, mpgdec_frequency, mpgdec_length; -extern gchar *mpgdec_title, *mpgdec_filename; -extern gboolean mpgdec_stereo; - -static int fsizeold = 0, ssize; -static unsigned char bsspace[2][MAXFRAMESIZE + 512]; /* MAXFRAMESIZE */ -static unsigned char *bsbuf = bsspace[1], *bsbufold; -static int bsnum = 0; - -unsigned char *mpgdec_pcm_sample; -int mpgdec_pcm_point = 0; - -static VFSFile *filept; -static int filept_opened; - -static int get_fileinfo(void); - -static int -fullread(VFSFile * fd, unsigned char *buf, int count) -{ - int ret, cnt = 0; - - while (cnt < count) { - if (fd) - ret = vfs_fread(buf + cnt, 1, count - cnt, fd); - else - switch(mpgdec_info->stream_type) { -#ifdef HAVE_NEMESI - case STREAM_RTSP: - ret = mpgdec_rtsp_read(buf + cnt, count - cnt); - break; -#endif - default: - return -1; - } - if (ret < 0) - return ret; - if (ret == 0) - break; - cnt += ret; - } - return cnt; -} - -static int -stream_init(void) -{ - if (get_fileinfo() < 0) - return -1; - return 0; -} - -void -mpgdec_stream_close(void) -{ - if (filept) - vfs_fclose(filept); - else - switch(mpgdec_info->stream_type) { -#ifdef HAVE_NEMESI - case STREAM_RTSP: - mpgdec_rtsp_close(); - break; -#endif - default: - break; - } -} - -gchar *mpgdec_metadata(const gchar *id) -{ - if (filept == NULL) - return NULL; - - return vfs_get_metadata(filept, id); -} - -/**************************************** - * HACK,HACK,HACK: step back <num> frames - * can only work if the 'stream' isn't a mpgdec_real stream but a file -static int stream_back_bytes(int bytes) -{ - if (vfs_fseek(filept, -bytes, SEEK_CUR) < 0) - return -1; - return 0; -} - */ - -static int -stream_head_read(unsigned long *newhead) -{ - unsigned char hbuf[4]; - - if (fullread(filept, 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(unsigned long *head) -{ - unsigned char hbuf; - - if (fullread(filept, &hbuf, 1) != 1) - return 0; - *head <<= 8; - *head |= hbuf; - *head &= 0xffffffff; - return 1; -} - -static int -stream_mpgdec_read_frame_body(unsigned char *buf, int size) -{ - long l; - - if ((l = fullread(filept, buf, size)) != size) { - if (l <= 0) - return 0; - memset(buf + l, 0, size - l); - } - return 1; -} - -static long -stream_tell(void) -{ - return vfs_ftell(filept); -} - -/* -static void stream_rewind(void) -{ - vfs_fseek(filept, 0, SEEK_SET); -} -*/ - -int -mpgdec_stream_jump_to_frame(InputPlayback *playback, struct frame *fr, - int frame) -{ - if (filept == NULL) - { - unsigned long r; - - r = frame * (fr->framesize + 4); - mpgdec_stream_close(); - mpgdec_open_stream(playback, mpgdec_filename, -1, r); - } - else - { - mpgdec_read_frame_init(); - vfs_fseek(filept, frame * (fr->framesize + 4), SEEK_SET); - mpgdec_read_frame(fr); - } - return 0; -} - -int -mpgdec_stream_jump_to_byte(InputPlayback *playback, struct frame *fr, int byte) -{ - if (filept == NULL) - { - mpgdec_stream_close(); - mpgdec_open_stream(playback, mpgdec_filename, -1, (unsigned long)byte); - } - else - { - vfs_fseek(filept, byte, SEEK_SET); - mpgdec_read_frame(fr); - } - - return 0; -} - -int -mpgdec_stream_check_for_xing_header(struct frame *fr, xing_header_t * xhead) -{ - unsigned char *head_data; - int ret; - - vfs_fseek(filept, -(fr->framesize + 4), SEEK_CUR); - head_data = g_malloc(fr->framesize + 4); - vfs_fread(head_data, 1, fr->framesize + 4, filept); - ret = mpgdec_get_xing_header(xhead, head_data); - g_free(head_data); - return ret; -} - -static int -get_fileinfo(void) -{ - guchar buf[3]; - - if (filept == NULL) - return -1; - if (vfs_fseek(filept, 0, SEEK_END) < 0) { - mpgdec_info->filesize = 0; - return 0; - } - - mpgdec_info->filesize = vfs_ftell(filept); - if (vfs_fseek(filept, -128, SEEK_END) < 0) - return -1; - if (fullread(filept, buf, 3) != 3) - return -1; - if (!strncmp((char *) buf, "TAG", 3)) - mpgdec_info->filesize -= 128; - if (vfs_fseek(filept, 0, SEEK_SET) < 0) - return -1; - - if (mpgdec_info->filesize <= 0) - return -1; - - return mpgdec_info->filesize; -} - -void -mpgdec_read_frame_init(void) -{ - memset(bsspace[0], 0, MAXFRAMESIZE + 512); - memset(bsspace[1], 0, MAXFRAMESIZE + 512); - mpgdec_info->output_audio = FALSE; -} - -int -mpgdec_head_check(unsigned long head) -{ - if ((head & 0xffe00000) != 0xffe00000) - return FALSE; - if (!((head >> 17) & 3)) - return FALSE; - if (((head >> 12) & 0xf) == 0xf) - return FALSE; - if (!((head >> 12) & 0xf)) - return FALSE; - if (((head >> 10) & 0x3) == 0x3) - return FALSE; - if (((head >> 19) & 1) == 1 && - ((head >> 17) & 3) == 3 && ((head >> 16) & 1) == 1) - return FALSE; - if ((head & 0xffff0000) == 0xfffe0000) - return FALSE; - - return TRUE; -} - -/***************************************************************** - * read next frame - */ -int -mpgdec_read_frame(struct frame *fr) -{ - unsigned long newhead; - - fsizeold = fr->framesize; /* for Layer3 */ - - if (!stream_head_read(&newhead)) - return FALSE; - - if (!mpgdec_head_check(newhead) || !mpgdec_decode_header(fr, newhead)) { - int try = 0; - - do { - try++; - if (!stream_head_shift(&newhead)) - return 0; - } - while ((!mpgdec_head_check(newhead) || - !mpgdec_decode_header(fr, newhead)) && try < (1024 * 1024)); - if (try >= (1024 * 1024)) - return FALSE; -#ifdef MPGDEC_INVBITSTREAM_NOTIFY - if (try >= 0) - g_log("mpgdec", G_LOG_LEVEL_WARNING, "mpgdec: illegal bitstream in the middle of the MPEG stream, skipped %d bytes", try); -#endif - if (mpgdec_info->filesize > 0) - mpgdec_info->filesize -= try; - } - /* flip/init buffer for Layer 3 */ - bsbufold = bsbuf; - bsbuf = bsspace[bsnum] + 512; - bsnum = (bsnum + 1) & 1; - - if (!stream_mpgdec_read_frame_body(bsbuf, fr->framesize)) - return 0; - - bsi.bitindex = 0; - bsi.wordpointer = (unsigned char *) bsbuf; - - - return 1; - -} - -/* - * the code a header and write the information - * into the frame structure - */ -int -mpgdec_decode_header(struct frame *fr, unsigned long newhead) -{ - if (newhead & (1 << 20)) { - fr->lsf = (newhead & (1 << 19)) ? 0x0 : 0x1; - fr->mpeg25 = 0; - } - else { - fr->lsf = 1; - fr->mpeg25 = 1; - } - fr->lay = 4 - ((newhead >> 17) & 3); - if (fr->mpeg25) { - fr->sampling_frequency = 6 + ((newhead >> 10) & 0x3); - } - else - fr->sampling_frequency = ((newhead >> 10) & 0x3) + (fr->lsf * 3); - fr->error_protection = ((newhead >> 16) & 0x1) ^ 0x1; - - fr->bitrate_index = ((newhead >> 12) & 0xf); - fr->padding = ((newhead >> 9) & 0x1); - fr->extension = ((newhead >> 8) & 0x1); - fr->mode = ((newhead >> 6) & 0x3); - fr->mode_ext = ((newhead >> 4) & 0x3); - fr->copyright = ((newhead >> 3) & 0x1); - fr->original = ((newhead >> 2) & 0x1); - fr->emphasis = newhead & 0x3; - - fr->stereo = (fr->mode == MPG_MD_MONO) ? 1 : 2; - - ssize = 0; - - if (!fr->bitrate_index) - return (0); - - switch (fr->lay) { - case 1: - fr->do_layer = mpgdec_do_layer1; - /* inits also shared tables with layer1 */ - mpgdec_init_layer2(fr->synth_type == SYNTH_MMX); - fr->framesize = - (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000; - fr->framesize /= mpgdec_freqs[fr->sampling_frequency]; - fr->framesize = ((fr->framesize + fr->padding) << 2) - 4; - break; - case 2: - fr->do_layer = mpgdec_do_layer2; - /* inits also shared tables with layer1 */ - mpgdec_init_layer2(fr->synth_type == SYNTH_MMX); - fr->framesize = - (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000; - fr->framesize /= mpgdec_freqs[fr->sampling_frequency]; - fr->framesize += fr->padding - 4; - break; - case 3: - fr->do_layer = mpgdec_do_layer3; - if (fr->lsf) - ssize = (fr->stereo == 1) ? 9 : 17; - else - ssize = (fr->stereo == 1) ? 17 : 32; - if (fr->error_protection) - ssize += 2; - fr->framesize = - (long) tabsel_123[fr->lsf][2][fr->bitrate_index] * 144000; - fr->framesize /= mpgdec_freqs[fr->sampling_frequency] << (fr->lsf); - fr->framesize = fr->framesize + fr->padding - 4; - break; - default: - return (0); - } - if (fr->framesize > MAXFRAMESIZE) - return 0; - return 1; -} - -void -mpgdec_open_stream(InputPlayback *playback, - char *bs_filenam, int fd, unsigned long range) -{ - filept_opened = 1; - filept = vfs_fopen(bs_filenam, "rb"); - if (filept != NULL) { - if (stream_init() == -1) playback->eof = TRUE; - } else -#ifdef HAVE_NEMESI - if (!strncasecmp(bs_filenam, "rtsp://", 7)) { - filept = NULL; - mpgdec_info->filesize = 0; - mpgdec_info->network_stream = TRUE; - mpgdec_info->stream_type = STREAM_RTSP; - if (mpgdec_rtsp_open(bs_filenam)) playback->eof = TRUE; - } else -#endif - { - playback->eof = TRUE; - } -} - -void -mpgdec_set_pointer(long backstep) -{ - bsi.wordpointer = bsbuf + ssize - backstep; - if (backstep) - memcpy(bsi.wordpointer, bsbufold + fsizeold - backstep, backstep); - bsi.bitindex = 0; -} - -double -mpgdec_compute_bpf(struct frame *fr) -{ - double bpf; - - switch (fr->lay) { - case 1: - bpf = tabsel_123[fr->lsf][0][fr->bitrate_index]; - bpf *= 12000.0 * 4.0; - bpf /= mpgdec_freqs[fr->sampling_frequency] << (fr->lsf); - break; - case 2: - case 3: - bpf = tabsel_123[fr->lsf][fr->lay - 1][fr->bitrate_index]; - bpf *= 144000; - bpf /= mpgdec_freqs[fr->sampling_frequency] << (fr->lsf); - break; - default: - bpf = 1.0; - } - - return bpf; -} - -int -mpgdec_calc_numframes(struct frame *fr) -{ - return (int) (mpgdec_info->filesize / mpgdec_compute_bpf(fr)); -} - -double -mpgdec_relative_pos(void) -{ - if (!filept || !mpgdec_info->filesize) - return 0; - return ((double) stream_tell()) / mpgdec_info->filesize; -}
--- a/src/mpg123/common.h Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -#include "mpg123.h" - -/* - * common.h - */ - -extern void print_id3_tag(unsigned char *buf); -extern unsigned long firsthead; -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 void parse_url(const gchar * url, gchar ** user, gchar ** pass, - gchar ** host, gint * port, gchar ** filename); - -gchar *mpgdec_metadata(const gchar *id);
--- a/src/mpg123/configure.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,294 +0,0 @@ - -#include "mpg123.h" - -#include <glib.h> -#include <audacious/i18n.h> -#include <gtk/gtk.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include <audacious/configdb.h> -#include <audacious/titlestring.h> - - -static GtkWidget *mpgdec_configurewin = NULL; -static GtkWidget *vbox, *notebook; -static GtkWidget *decode_vbox, *decode_hbox1; -static GtkWidget *decode_res_frame, *decode_res_vbox, *decode_res_16, - *decode_res_8; -static GtkWidget *decode_ch_frame, *decode_ch_vbox, *decode_ch_stereo, - *decode_ch_mono; -static GtkWidget *decode_freq_frame, *decode_freq_vbox, *decode_freq_1to1, - *decode_freq_1to2, *decode_freq_1to4; - -static GtkWidget *title_id3_box, *title_tag_desc; -static GtkWidget *title_override, *title_id3_entry, *title_id3v2_disable; - -MPG123Config mpgdec_cfg; - -static void -mpgdec_configurewin_ok(GtkWidget * widget, gpointer data) -{ - ConfigDb *db; - - if (GTK_TOGGLE_BUTTON(decode_res_16)->active) - mpgdec_cfg.resolution = 16; - else if (GTK_TOGGLE_BUTTON(decode_res_8)->active) - mpgdec_cfg.resolution = 8; - - if (GTK_TOGGLE_BUTTON(decode_ch_stereo)->active) - mpgdec_cfg.channels = 2; - else if (GTK_TOGGLE_BUTTON(decode_ch_mono)->active) - mpgdec_cfg.channels = 1; - - if (GTK_TOGGLE_BUTTON(decode_freq_1to1)->active) - mpgdec_cfg.downsample = 0; - else if (GTK_TOGGLE_BUTTON(decode_freq_1to2)->active) - mpgdec_cfg.downsample = 1; - if (GTK_TOGGLE_BUTTON(decode_freq_1to4)->active) - mpgdec_cfg.downsample = 2; - - mpgdec_cfg.title_override = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_override)); - mpgdec_cfg.disable_id3v2 = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_id3v2_disable)); - g_free(mpgdec_cfg.id3_format); - mpgdec_cfg.id3_format = - g_strdup(gtk_entry_get_text(GTK_ENTRY(title_id3_entry))); - - db = bmp_cfg_db_open(); - bmp_cfg_db_set_int(db, "MPG123", "resolution", mpgdec_cfg.resolution); - bmp_cfg_db_set_int(db, "MPG123", "channels", mpgdec_cfg.channels); - bmp_cfg_db_set_int(db, "MPG123", "downsample", mpgdec_cfg.downsample); - bmp_cfg_db_set_int(db, "MPG123", "http_buffer_size", - mpgdec_cfg.http_buffer_size); - bmp_cfg_db_set_int(db, "MPG123", "http_prebuffer", - mpgdec_cfg.http_prebuffer); - bmp_cfg_db_set_bool(db, "MPG123", "save_http_stream", - mpgdec_cfg.save_http_stream); - bmp_cfg_db_set_string(db, "MPG123", "save_http_path", - mpgdec_cfg.save_http_path); - bmp_cfg_db_set_bool(db, "MPG123", "use_udp_channel", - mpgdec_cfg.use_udp_channel); - bmp_cfg_db_set_bool(db, "MPG123", "title_override", - mpgdec_cfg.title_override); - bmp_cfg_db_set_bool(db, "MPG123", "disable_id3v2", - mpgdec_cfg.disable_id3v2); - bmp_cfg_db_set_string(db, "MPG123", "id3_format", mpgdec_cfg.id3_format); - - bmp_cfg_db_close(db); - gtk_widget_destroy(mpgdec_configurewin); -} - -static void -title_override_cb(GtkWidget * w, gpointer data) -{ - gboolean override; - override = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_override)); - gtk_widget_set_sensitive(title_id3_box, override); - gtk_widget_set_sensitive(title_tag_desc, override); -} - -static void -configure_destroy(GtkWidget * w, gpointer data) -{ - // nothing at the moment? -} - -void -mpgdec_configure(void) -{ - GtkWidget *title_frame, *title_id3_vbox, *title_id3_label; - GtkWidget *bbox, *ok, *cancel; - - if (mpgdec_configurewin != NULL) { - gtk_window_present(GTK_WINDOW(mpgdec_configurewin)); - return; - } - mpgdec_configurewin = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_type_hint(GTK_WINDOW(mpgdec_configurewin), - GDK_WINDOW_TYPE_HINT_DIALOG); - gtk_window_set_position(GTK_WINDOW(mpgdec_configurewin), - GTK_WIN_POS_CENTER); - g_signal_connect(G_OBJECT(mpgdec_configurewin), "destroy", - G_CALLBACK(gtk_widget_destroyed), &mpgdec_configurewin); - g_signal_connect(G_OBJECT(mpgdec_configurewin), "destroy", - G_CALLBACK(configure_destroy), &mpgdec_configurewin); - gtk_window_set_title(GTK_WINDOW(mpgdec_configurewin), - _("MPEG Audio Plugin Configuration")); - gtk_window_set_resizable(GTK_WINDOW(mpgdec_configurewin), FALSE); - /* gtk_window_set_position(GTK_WINDOW(mpgdec_configurewin), GTK_WIN_POS_MOUSE); */ - gtk_container_border_width(GTK_CONTAINER(mpgdec_configurewin), 10); - - vbox = gtk_vbox_new(FALSE, 10); - gtk_container_add(GTK_CONTAINER(mpgdec_configurewin), vbox); - - notebook = gtk_notebook_new(); - gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); - - decode_vbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(decode_vbox), 5); - - decode_hbox1 = gtk_hbox_new(TRUE, 5); - gtk_box_pack_start(GTK_BOX(decode_vbox), decode_hbox1, FALSE, FALSE, 0); - - decode_res_frame = gtk_frame_new(_("Resolution:")); - gtk_box_pack_start(GTK_BOX(decode_hbox1), decode_res_frame, TRUE, TRUE, - 0); - - decode_res_vbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(decode_res_vbox), 5); - gtk_container_add(GTK_CONTAINER(decode_res_frame), decode_res_vbox); - - decode_res_16 = gtk_radio_button_new_with_label(NULL, _("16 bit")); - if (mpgdec_cfg.resolution == 16) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_res_16), TRUE); - gtk_box_pack_start(GTK_BOX(decode_res_vbox), decode_res_16, FALSE, - FALSE, 0); - - decode_res_8 = - gtk_radio_button_new_with_label(gtk_radio_button_group - (GTK_RADIO_BUTTON(decode_res_16)), - _("8 bit")); - if (mpgdec_cfg.resolution == 8) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_res_8), TRUE); - - gtk_box_pack_start(GTK_BOX(decode_res_vbox), decode_res_8, FALSE, - FALSE, 0); - - decode_ch_frame = gtk_frame_new(_("Channels:")); - gtk_box_pack_start(GTK_BOX(decode_hbox1), decode_ch_frame, TRUE, TRUE, 0); - - decode_ch_vbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(decode_ch_vbox), 5); - gtk_container_add(GTK_CONTAINER(decode_ch_frame), decode_ch_vbox); - - decode_ch_stereo = - gtk_radio_button_new_with_label(NULL, _("Stereo (if available)")); - if (mpgdec_cfg.channels == 2) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_ch_stereo), - TRUE); - - gtk_box_pack_start(GTK_BOX(decode_ch_vbox), decode_ch_stereo, FALSE, - FALSE, 0); - - decode_ch_mono = - gtk_radio_button_new_with_label(gtk_radio_button_group - (GTK_RADIO_BUTTON - (decode_ch_stereo)), _("Mono")); - if (mpgdec_cfg.channels == 1) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_ch_mono), TRUE); - - gtk_box_pack_start(GTK_BOX(decode_ch_vbox), decode_ch_mono, FALSE, - FALSE, 0); - - decode_freq_frame = gtk_frame_new(_("Down sample:")); - gtk_box_pack_start(GTK_BOX(decode_vbox), decode_freq_frame, FALSE, - FALSE, 0); - - decode_freq_vbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(decode_freq_vbox), 5); - gtk_container_add(GTK_CONTAINER(decode_freq_frame), decode_freq_vbox); - - decode_freq_1to1 = - gtk_radio_button_new_with_label(NULL, _("1:1 (44 kHz)")); - if (mpgdec_cfg.downsample == 0) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_freq_1to1), - TRUE); - gtk_box_pack_start(GTK_BOX(decode_freq_vbox), decode_freq_1to1, FALSE, - FALSE, 0); - - decode_freq_1to2 = - gtk_radio_button_new_with_label(gtk_radio_button_group - (GTK_RADIO_BUTTON - (decode_freq_1to1)), - _("1:2 (22 kHz)")); - if (mpgdec_cfg.downsample == 1) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_freq_1to2), - TRUE); - gtk_box_pack_start(GTK_BOX(decode_freq_vbox), decode_freq_1to2, FALSE, - FALSE, 0); - - decode_freq_1to4 = - gtk_radio_button_new_with_label(gtk_radio_button_group - (GTK_RADIO_BUTTON - (decode_freq_1to1)), - _("1:4 (11 kHz)")); - if (mpgdec_cfg.downsample == 2) - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_freq_1to4), - TRUE); - - gtk_box_pack_start(GTK_BOX(decode_freq_vbox), decode_freq_1to4, FALSE, - FALSE, 0); - - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), decode_vbox, - gtk_label_new(_("Decoder"))); - - title_frame = gtk_frame_new(_("ID3 Tags:")); - gtk_container_border_width(GTK_CONTAINER(title_frame), 5); - - title_id3_vbox = gtk_vbox_new(FALSE, 10); - gtk_container_border_width(GTK_CONTAINER(title_id3_vbox), 5); - gtk_container_add(GTK_CONTAINER(title_frame), title_id3_vbox); - - title_id3v2_disable = - gtk_check_button_new_with_label(_("Disable ID3V2 tags")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(title_id3v2_disable), - mpgdec_cfg.disable_id3v2); - gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_id3v2_disable, FALSE, - FALSE, 0); - - title_override = - gtk_check_button_new_with_label(_("Override generic titles")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(title_override), - mpgdec_cfg.title_override); - g_signal_connect(G_OBJECT(title_override), "clicked", - G_CALLBACK(title_override_cb), NULL); - gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_override, FALSE, - FALSE, 0); - - title_id3_box = gtk_hbox_new(FALSE, 5); - gtk_widget_set_sensitive(title_id3_box, mpgdec_cfg.title_override); - gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_id3_box, FALSE, - FALSE, 0); - - title_id3_label = gtk_label_new(_("ID3 format:")); - gtk_box_pack_start(GTK_BOX(title_id3_box), title_id3_label, FALSE, - FALSE, 0); - - title_id3_entry = gtk_entry_new(); - gtk_entry_set_text(GTK_ENTRY(title_id3_entry), mpgdec_cfg.id3_format); - gtk_box_pack_start(GTK_BOX(title_id3_box), title_id3_entry, TRUE, TRUE, - 0); - - title_tag_desc = xmms_titlestring_descriptions("pafFetnygc", 2); - gtk_widget_set_sensitive(title_tag_desc, mpgdec_cfg.title_override); - gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_tag_desc, FALSE, - FALSE, 0); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), title_frame, - gtk_label_new(_("Title"))); - - bbox = gtk_hbutton_box_new(); - gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); - gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); - gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); - - cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); - g_signal_connect_swapped(G_OBJECT(cancel), "clicked", - G_CALLBACK(gtk_widget_destroy), - GTK_OBJECT(mpgdec_configurewin)); - GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); - gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); - - - ok = gtk_button_new_from_stock(GTK_STOCK_OK); - g_signal_connect(G_OBJECT(ok), "clicked", - G_CALLBACK(mpgdec_configurewin_ok), NULL); - GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT); - gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0); - gtk_widget_grab_default(ok); - - gtk_widget_show_all(mpgdec_configurewin); -}
--- a/src/mpg123/dct64.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,163 +0,0 @@ - -/* - * 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 -mpgdec_dct64(mpgdec_real * out0, mpgdec_real * out1, mpgdec_real * samples) -{ - mpgdec_real bufs[64]; - - { - register int i, j; - register mpgdec_real *b1, *b2, *bs, *costab; - - b1 = samples; - bs = bufs; - costab = mpgdec_pnts[0] + 16; - b2 = b1 + 32; - - for (i = 15; i >= 0; i--) - *bs++ = (*b1++ + *--b2); - for (i = 15; i >= 0; i--) - *bs++ = (*--b2 - *b1++) * *--costab; - - b1 = bufs; - costab = mpgdec_pnts[1] + 8; - b2 = b1 + 16; - - { - for (i = 7; i >= 0; i--) - *bs++ = (*b1++ + *--b2); - for (i = 7; i >= 0; i--) - *bs++ = (*--b2 - *b1++) * *--costab; - b2 += 32; - costab += 8; - for (i = 7; i >= 0; i--) - *bs++ = (*b1++ + *--b2); - for (i = 7; i >= 0; i--) - *bs++ = (*b1++ - *--b2) * *--costab; - b2 += 32; - } - - bs = bufs; - costab = mpgdec_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++ = (*--b2 - *b1++) * costab[i]; - b2 += 16; - for (i = 3; i >= 0; i--) - *bs++ = (*b1++ + *--b2); - for (i = 3; i >= 0; i--) - *bs++ = (*b1++ - *--b2) * costab[i]; - b2 += 16; - } - - b1 = bufs; - costab = mpgdec_pnts[3]; - b2 = b1 + 4; - - for (j = 4; j; j--) { - *bs++ = (*b1++ + *--b2); - *bs++ = (*b1++ + *--b2); - *bs++ = (*--b2 - *b1++) * costab[1]; - *bs++ = (*--b2 - *b1++) * costab[0]; - b2 += 8; - *bs++ = (*b1++ + *--b2); - *bs++ = (*b1++ + *--b2); - *bs++ = (*b1++ - *--b2) * costab[1]; - *bs++ = (*b1++ - *--b2) * costab[0]; - b2 += 8; - } - bs = bufs; - costab = mpgdec_pnts[4]; - - for (j = 8; j; j--) { - mpgdec_real v0, v1; - - v0 = *b1++; - v1 = *b1++; - *bs++ = (v0 + v1); - *bs++ = (v0 - v1) * (*costab); - v0 = *b1++; - v1 = *b1++; - *bs++ = (v0 + v1); - *bs++ = (v1 - v0) * (*costab); - } - - } - - { - register mpgdec_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]; - -}
--- a/src/mpg123/dct64_altivec.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,543 +0,0 @@ - -/* - * Discrete Cosine Tansform (DCT) for Altivec - * Copyright (c) 2004 Romain Dolbeau <romain@dolbeau.org> - * based upon code from "mp3lib/dct64.c" - */ - -#include "mpg123.h" - -#ifdef INTEGER_COMPILE -#error AltiVec acceleration and integer compile are mutually exclusive. -#endif - -#ifdef HAVE_ALTIVEC - -#ifndef SYS_DARWIN -#include <altivec.h> -#endif - -// used to build registers permutation vectors (vcprm) -// the 's' are for words in the _s_econd vector -#define WORD_0 0x00,0x01,0x02,0x03 -#define WORD_1 0x04,0x05,0x06,0x07 -#define WORD_2 0x08,0x09,0x0a,0x0b -#define WORD_3 0x0c,0x0d,0x0e,0x0f -#define WORD_s0 0x10,0x11,0x12,0x13 -#define WORD_s1 0x14,0x15,0x16,0x17 -#define WORD_s2 0x18,0x19,0x1a,0x1b -#define WORD_s3 0x1c,0x1d,0x1e,0x1f - -#ifdef SYS_DARWIN -#define vcprm(a,b,c,d) (const vector unsigned char)(WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d) -#else -#define vcprm(a,b,c,d) (const vector unsigned char){WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d} -#endif - -// vcprmle is used to keep the same index as in the SSE version. -// it's the same as vcprm, with the index inversed -// ('le' is Little Endian) -#define vcprmle(a,b,c,d) vcprm(d,c,b,a) - -// used to build inverse/identity vectors (vcii) -// n is _n_egative, p is _p_ositive -#define FLOAT_n -1. -#define FLOAT_p 1. - -#ifdef SYS_DARWIN -#define vcii(a,b,c,d) (const vector float)(FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d) -#else -#define vcii(a,b,c,d) (const vector float){FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d} -#endif - -#ifdef SYS_DARWIN -#define FOUROF(a) (a) -#else -#define FOUROF(a) {a,a,a,a} -#endif - -void mpgdec_dct64(mpgdec_real *a,mpgdec_real *b,mpgdec_real *c) -{ - mpgdec_real __attribute__ ((aligned(16))) b1[0x20]; - mpgdec_real __attribute__ ((aligned(16))) b2[0x20]; - - mpgdec_real *out0 = a; - mpgdec_real *out1 = b; - mpgdec_real *samples = c; - - const vector float vczero = (const vector float)FOUROF(0.); - const vector unsigned char reverse = (const vector unsigned char)vcprm(3,2,1,0); - - - if (((unsigned long)b1 & 0x0000000F) || - ((unsigned long)b2 & 0x0000000F)) - - { - printf("MISALIGNED:\t%p\t%p\t%p\t%p\t%p\n", - b1, b2, a, b, samples); - } - - -#ifdef ALTIVEC_USE_REFERENCE_C_CODE - - { - register mpgdec_real *costab = mpgdec_pnts[0]; - - b1[0x00] = samples[0x00] + samples[0x1F]; - b1[0x01] = samples[0x01] + samples[0x1E]; - b1[0x02] = samples[0x02] + samples[0x1D]; - b1[0x03] = samples[0x03] + samples[0x1C]; - b1[0x04] = samples[0x04] + samples[0x1B]; - b1[0x05] = samples[0x05] + samples[0x1A]; - b1[0x06] = samples[0x06] + samples[0x19]; - b1[0x07] = samples[0x07] + samples[0x18]; - b1[0x08] = samples[0x08] + samples[0x17]; - b1[0x09] = samples[0x09] + samples[0x16]; - b1[0x0A] = samples[0x0A] + samples[0x15]; - b1[0x0B] = samples[0x0B] + samples[0x14]; - b1[0x0C] = samples[0x0C] + samples[0x13]; - b1[0x0D] = samples[0x0D] + samples[0x12]; - b1[0x0E] = samples[0x0E] + samples[0x11]; - b1[0x0F] = samples[0x0F] + samples[0x10]; - b1[0x10] = (samples[0x0F] - samples[0x10]) * costab[0xF]; - b1[0x11] = (samples[0x0E] - samples[0x11]) * costab[0xE]; - b1[0x12] = (samples[0x0D] - samples[0x12]) * costab[0xD]; - b1[0x13] = (samples[0x0C] - samples[0x13]) * costab[0xC]; - b1[0x14] = (samples[0x0B] - samples[0x14]) * costab[0xB]; - b1[0x15] = (samples[0x0A] - samples[0x15]) * costab[0xA]; - b1[0x16] = (samples[0x09] - samples[0x16]) * costab[0x9]; - b1[0x17] = (samples[0x08] - samples[0x17]) * costab[0x8]; - b1[0x18] = (samples[0x07] - samples[0x18]) * costab[0x7]; - b1[0x19] = (samples[0x06] - samples[0x19]) * costab[0x6]; - b1[0x1A] = (samples[0x05] - samples[0x1A]) * costab[0x5]; - b1[0x1B] = (samples[0x04] - samples[0x1B]) * costab[0x4]; - b1[0x1C] = (samples[0x03] - samples[0x1C]) * costab[0x3]; - b1[0x1D] = (samples[0x02] - samples[0x1D]) * costab[0x2]; - b1[0x1E] = (samples[0x01] - samples[0x1E]) * costab[0x1]; - b1[0x1F] = (samples[0x00] - samples[0x1F]) * costab[0x0]; - - } - { - register mpgdec_real *costab = mpgdec_pnts[1]; - - b2[0x00] = b1[0x00] + b1[0x0F]; - b2[0x01] = b1[0x01] + b1[0x0E]; - b2[0x02] = b1[0x02] + b1[0x0D]; - b2[0x03] = b1[0x03] + b1[0x0C]; - b2[0x04] = b1[0x04] + b1[0x0B]; - b2[0x05] = b1[0x05] + b1[0x0A]; - b2[0x06] = b1[0x06] + b1[0x09]; - b2[0x07] = b1[0x07] + b1[0x08]; - b2[0x08] = (b1[0x07] - b1[0x08]) * costab[7]; - b2[0x09] = (b1[0x06] - b1[0x09]) * costab[6]; - b2[0x0A] = (b1[0x05] - b1[0x0A]) * costab[5]; - b2[0x0B] = (b1[0x04] - b1[0x0B]) * costab[4]; - b2[0x0C] = (b1[0x03] - b1[0x0C]) * costab[3]; - b2[0x0D] = (b1[0x02] - b1[0x0D]) * costab[2]; - b2[0x0E] = (b1[0x01] - b1[0x0E]) * costab[1]; - b2[0x0F] = (b1[0x00] - b1[0x0F]) * costab[0]; - b2[0x10] = b1[0x10] + b1[0x1F]; - b2[0x11] = b1[0x11] + b1[0x1E]; - b2[0x12] = b1[0x12] + b1[0x1D]; - b2[0x13] = b1[0x13] + b1[0x1C]; - b2[0x14] = b1[0x14] + b1[0x1B]; - b2[0x15] = b1[0x15] + b1[0x1A]; - b2[0x16] = b1[0x16] + b1[0x19]; - b2[0x17] = b1[0x17] + b1[0x18]; - b2[0x18] = (b1[0x18] - b1[0x17]) * costab[7]; - b2[0x19] = (b1[0x19] - b1[0x16]) * costab[6]; - b2[0x1A] = (b1[0x1A] - b1[0x15]) * costab[5]; - b2[0x1B] = (b1[0x1B] - b1[0x14]) * costab[4]; - b2[0x1C] = (b1[0x1C] - b1[0x13]) * costab[3]; - b2[0x1D] = (b1[0x1D] - b1[0x12]) * costab[2]; - b2[0x1E] = (b1[0x1E] - b1[0x11]) * costab[1]; - b2[0x1F] = (b1[0x1F] - b1[0x10]) * costab[0]; - - } - - { - register mpgdec_real *costab = mpgdec_pnts[2]; - - b1[0x00] = b2[0x00] + b2[0x07]; - b1[0x01] = b2[0x01] + b2[0x06]; - b1[0x02] = b2[0x02] + b2[0x05]; - b1[0x03] = b2[0x03] + b2[0x04]; - b1[0x04] = (b2[0x03] - b2[0x04]) * costab[3]; - b1[0x05] = (b2[0x02] - b2[0x05]) * costab[2]; - b1[0x06] = (b2[0x01] - b2[0x06]) * costab[1]; - b1[0x07] = (b2[0x00] - b2[0x07]) * costab[0]; - b1[0x08] = b2[0x08] + b2[0x0F]; - b1[0x09] = b2[0x09] + b2[0x0E]; - b1[0x0A] = b2[0x0A] + b2[0x0D]; - b1[0x0B] = b2[0x0B] + b2[0x0C]; - b1[0x0C] = (b2[0x0C] - b2[0x0B]) * costab[3]; - b1[0x0D] = (b2[0x0D] - b2[0x0A]) * costab[2]; - b1[0x0E] = (b2[0x0E] - b2[0x09]) * costab[1]; - b1[0x0F] = (b2[0x0F] - b2[0x08]) * costab[0]; - b1[0x10] = b2[0x10] + b2[0x17]; - b1[0x11] = b2[0x11] + b2[0x16]; - b1[0x12] = b2[0x12] + b2[0x15]; - b1[0x13] = b2[0x13] + b2[0x14]; - b1[0x14] = (b2[0x13] - b2[0x14]) * costab[3]; - b1[0x15] = (b2[0x12] - b2[0x15]) * costab[2]; - b1[0x16] = (b2[0x11] - b2[0x16]) * costab[1]; - b1[0x17] = (b2[0x10] - b2[0x17]) * costab[0]; - b1[0x18] = b2[0x18] + b2[0x1F]; - b1[0x19] = b2[0x19] + b2[0x1E]; - b1[0x1A] = b2[0x1A] + b2[0x1D]; - b1[0x1B] = b2[0x1B] + b2[0x1C]; - b1[0x1C] = (b2[0x1C] - b2[0x1B]) * costab[3]; - b1[0x1D] = (b2[0x1D] - b2[0x1A]) * costab[2]; - b1[0x1E] = (b2[0x1E] - b2[0x19]) * costab[1]; - b1[0x1F] = (b2[0x1F] - b2[0x18]) * costab[0]; - } - -#else /* ALTIVEC_USE_REFERENCE_C_CODE */ - - // How does it work ? - // the first three passes are reproducted in the three block below - // all computations are done on a 4 elements vector - // 'reverse' is a special perumtation vector used to reverse - // the order of the elements inside a vector. - // note that all loads/stores to b1 (b2) between passes 1 and 2 (2 and 3) - // have been removed, all elements are stored inside b1vX (b2vX) - { - register vector float - b1v0, b1v1, b1v2, b1v3, - b1v4, b1v5, b1v6, b1v7; - register vector float - temp1, temp2; - - { - register mpgdec_real *costab = mpgdec_pnts[0]; - - register vector float - samplesv1, samplesv2, samplesv3, samplesv4, - samplesv5, samplesv6, samplesv7, samplesv8, - samplesv9; - register vector unsigned char samples_perm = vec_lvsl(0, samples); - register vector float costabv1, costabv2, costabv3, costabv4, costabv5; - register vector unsigned char costab_perm = vec_lvsl(0, costab); - - samplesv1 = vec_ld(0, samples); - samplesv2 = vec_ld(16, samples); - samplesv1 = vec_perm(samplesv1, samplesv2, samples_perm); - samplesv3 = vec_ld(32, samples); - samplesv2 = vec_perm(samplesv2, samplesv3, samples_perm); - samplesv4 = vec_ld(48, samples); - samplesv3 = vec_perm(samplesv3, samplesv4, samples_perm); - samplesv5 = vec_ld(64, samples); - samplesv4 = vec_perm(samplesv4, samplesv5, samples_perm); - samplesv6 = vec_ld(80, samples); - samplesv5 = vec_perm(samplesv5, samplesv6, samples_perm); - samplesv7 = vec_ld(96, samples); - samplesv6 = vec_perm(samplesv6, samplesv7, samples_perm); - samplesv8 = vec_ld(112, samples); - samplesv7 = vec_perm(samplesv7, samplesv8, samples_perm); - samplesv9 = vec_ld(128, samples); - samplesv8 = vec_perm(samplesv8, samplesv9, samples_perm); - - temp1 = vec_add(samplesv1, - vec_perm(samplesv8, samplesv8, reverse)); - //vec_st(temp1, 0, b1); - b1v0 = temp1; - temp1 = vec_add(samplesv2, - vec_perm(samplesv7, samplesv7, reverse)); - //vec_st(temp1, 16, b1); - b1v1 = temp1; - temp1 = vec_add(samplesv3, - vec_perm(samplesv6, samplesv6, reverse)); - //vec_st(temp1, 32, b1); - b1v2 = temp1; - temp1 = vec_add(samplesv4, - vec_perm(samplesv5, samplesv5, reverse)); - //vec_st(temp1, 48, b1); - b1v3 = temp1; - - costabv1 = vec_ld(0, costab); - costabv2 = vec_ld(16, costab); - costabv1 = vec_perm(costabv1, costabv2, costab_perm); - costabv3 = vec_ld(32, costab); - costabv2 = vec_perm(costabv2, costabv3, costab_perm); - costabv4 = vec_ld(48, costab); - costabv3 = vec_perm(costabv3, costabv4, costab_perm); - costabv5 = vec_ld(64, costab); - costabv4 = vec_perm(costabv4, costabv5, costab_perm); - - temp1 = vec_sub(vec_perm(samplesv4, samplesv4, reverse), - samplesv5); - temp2 = vec_madd(temp1, - vec_perm(costabv4, costabv4, reverse), - vczero); - //vec_st(temp2, 64, b1); - b1v4 = temp2; - - temp1 = vec_sub(vec_perm(samplesv3, samplesv3, reverse), - samplesv6); - temp2 = vec_madd(temp1, - vec_perm(costabv3, costabv3, reverse), - vczero); - //vec_st(temp2, 80, b1); - b1v5 = temp2; - temp1 = vec_sub(vec_perm(samplesv2, samplesv2, reverse), - samplesv7); - temp2 = vec_madd(temp1, - vec_perm(costabv2, costabv2, reverse), - vczero); - //vec_st(temp2, 96, b1); - b1v6 = temp2; - - temp1 = vec_sub(vec_perm(samplesv1, samplesv1, reverse), - samplesv8); - temp2 = vec_madd(temp1, - vec_perm(costabv1, costabv1, reverse), - vczero); - //vec_st(temp2, 112, b1); - b1v7 = temp2; - - } - - { - register vector float - b2v0, b2v1, b2v2, b2v3, - b2v4, b2v5, b2v6, b2v7; - { - register mpgdec_real *costab = mpgdec_pnts[1]; - register vector float costabv1r, costabv2r, costabv1, costabv2, costabv3; - register vector unsigned char costab_perm = vec_lvsl(0, costab); - - costabv1 = vec_ld(0, costab); - costabv2 = vec_ld(16, costab); - costabv1 = vec_perm(costabv1, costabv2, costab_perm); - costabv3 = vec_ld(32, costab); - costabv2 = vec_perm(costabv2, costabv3 , costab_perm); - costabv1r = vec_perm(costabv1, costabv1, reverse); - costabv2r = vec_perm(costabv2, costabv2, reverse); - - temp1 = vec_add(b1v0, vec_perm(b1v3, b1v3, reverse)); - //vec_st(temp1, 0, b2); - b2v0 = temp1; - temp1 = vec_add(b1v1, vec_perm(b1v2, b1v2, reverse)); - //vec_st(temp1, 16, b2); - b2v1 = temp1; - temp2 = vec_sub(vec_perm(b1v1, b1v1, reverse), b1v2); - temp1 = vec_madd(temp2, costabv2r, vczero); - //vec_st(temp1, 32, b2); - b2v2 = temp1; - temp2 = vec_sub(vec_perm(b1v0, b1v0, reverse), b1v3); - temp1 = vec_madd(temp2, costabv1r, vczero); - //vec_st(temp1, 48, b2); - b2v3 = temp1; - temp1 = vec_add(b1v4, vec_perm(b1v7, b1v7, reverse)); - //vec_st(temp1, 64, b2); - b2v4 = temp1; - temp1 = vec_add(b1v5, vec_perm(b1v6, b1v6, reverse)); - //vec_st(temp1, 80, b2); - b2v5 = temp1; - temp2 = vec_sub(b1v6, vec_perm(b1v5, b1v5, reverse)); - temp1 = vec_madd(temp2, costabv2r, vczero); - //vec_st(temp1, 96, b2); - b2v6 = temp1; - temp2 = vec_sub(b1v7, vec_perm(b1v4, b1v4, reverse)); - temp1 = vec_madd(temp2, costabv1r, vczero); - //vec_st(temp1, 112, b2); - b2v7 = temp1; - } - - { - register mpgdec_real *costab = mpgdec_pnts[2]; - - - vector float costabv1r, costabv1, costabv2; - vector unsigned char costab_perm = vec_lvsl(0, costab); - - costabv1 = vec_ld(0, costab); - costabv2 = vec_ld(16, costab); - costabv1 = vec_perm(costabv1, costabv2, costab_perm); - costabv1r = vec_perm(costabv1, costabv1, reverse); - - temp1 = vec_add(b2v0, vec_perm(b2v1, b2v1, reverse)); - vec_st(temp1, 0, b1); - temp2 = vec_sub(vec_perm(b2v0, b2v0, reverse), b2v1); - temp1 = vec_madd(temp2, costabv1r, vczero); - vec_st(temp1, 16, b1); - - temp1 = vec_add(b2v2, vec_perm(b2v3, b2v3, reverse)); - vec_st(temp1, 32, b1); - temp2 = vec_sub(b2v3, vec_perm(b2v2, b2v2, reverse)); - temp1 = vec_madd(temp2, costabv1r, vczero); - vec_st(temp1, 48, b1); - - temp1 = vec_add(b2v4, vec_perm(b2v5, b2v5, reverse)); - vec_st(temp1, 64, b1); - temp2 = vec_sub(vec_perm(b2v4, b2v4, reverse), b2v5); - temp1 = vec_madd(temp2, costabv1r, vczero); - vec_st(temp1, 80, b1); - - temp1 = vec_add(b2v6, vec_perm(b2v7, b2v7, reverse)); - vec_st(temp1, 96, b1); - temp2 = vec_sub(b2v7, vec_perm(b2v6, b2v6, reverse)); - temp1 = vec_madd(temp2, costabv1r, vczero); - vec_st(temp1, 112, b1); - - } - } - } - -#endif /* ALTIVEC_USE_REFERENCE_C_CODE */ - - { - register mpgdec_real const cos0 = mpgdec_pnts[3][0]; - register mpgdec_real const cos1 = mpgdec_pnts[3][1]; - - b2[0x00] = b1[0x00] + b1[0x03]; - b2[0x01] = b1[0x01] + b1[0x02]; - b2[0x02] = (b1[0x01] - b1[0x02]) * cos1; - b2[0x03] = (b1[0x00] - b1[0x03]) * cos0; - b2[0x04] = b1[0x04] + b1[0x07]; - b2[0x05] = b1[0x05] + b1[0x06]; - b2[0x06] = (b1[0x06] - b1[0x05]) * cos1; - b2[0x07] = (b1[0x07] - b1[0x04]) * cos0; - b2[0x08] = b1[0x08] + b1[0x0B]; - b2[0x09] = b1[0x09] + b1[0x0A]; - b2[0x0A] = (b1[0x09] - b1[0x0A]) * cos1; - b2[0x0B] = (b1[0x08] - b1[0x0B]) * cos0; - b2[0x0C] = b1[0x0C] + b1[0x0F]; - b2[0x0D] = b1[0x0D] + b1[0x0E]; - b2[0x0E] = (b1[0x0E] - b1[0x0D]) * cos1; - b2[0x0F] = (b1[0x0F] - b1[0x0C]) * cos0; - b2[0x10] = b1[0x10] + b1[0x13]; - b2[0x11] = b1[0x11] + b1[0x12]; - b2[0x12] = (b1[0x11] - b1[0x12]) * cos1; - b2[0x13] = (b1[0x10] - b1[0x13]) * cos0; - b2[0x14] = b1[0x14] + b1[0x17]; - b2[0x15] = b1[0x15] + b1[0x16]; - b2[0x16] = (b1[0x16] - b1[0x15]) * cos1; - b2[0x17] = (b1[0x17] - b1[0x14]) * cos0; - b2[0x18] = b1[0x18] + b1[0x1B]; - b2[0x19] = b1[0x19] + b1[0x1A]; - b2[0x1A] = (b1[0x19] - b1[0x1A]) * cos1; - b2[0x1B] = (b1[0x18] - b1[0x1B]) * cos0; - b2[0x1C] = b1[0x1C] + b1[0x1F]; - b2[0x1D] = b1[0x1D] + b1[0x1E]; - b2[0x1E] = (b1[0x1E] - b1[0x1D]) * cos1; - b2[0x1F] = (b1[0x1F] - b1[0x1C]) * cos0; - } - - { - register mpgdec_real const cos0 = mpgdec_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]; - - 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]; - - b1[0x18] += b1[0x1C]; - out0[0x10*15] = b1[0x10] + b1[0x18]; - out0[0x10*13] = b1[0x18] + b1[0x14]; - b1[0x1C] += b1[0x1a]; - out0[0x10*11] = b1[0x14] + b1[0x1C]; - out0[0x10* 9] = b1[0x1C] + b1[0x12]; - b1[0x1A] += b1[0x1E]; - out0[0x10* 7] = b1[0x12] + b1[0x1A]; - out0[0x10* 5] = b1[0x1A] + b1[0x16]; - b1[0x1E] += b1[0x19]; - out0[0x10* 3] = b1[0x16] + b1[0x1E]; - out0[0x10* 1] = b1[0x1E] + b1[0x11]; - b1[0x19] += b1[0x1D]; - out1[0x10* 1] = b1[0x11] + b1[0x19]; - out1[0x10* 3] = b1[0x19] + b1[0x15]; - b1[0x1D] += b1[0x1B]; - out1[0x10* 5] = b1[0x15] + b1[0x1D]; - out1[0x10* 7] = b1[0x1D] + b1[0x13]; - b1[0x1B] += b1[0x1F]; - out1[0x10* 9] = b1[0x13] + b1[0x1B]; - out1[0x10*11] = b1[0x1B] + b1[0x17]; - out1[0x10*13] = b1[0x17] + b1[0x1F]; - out1[0x10*15] = b1[0x1F]; -} - -#endif /* HAVE_ALTIVEC */ -
--- a/src/mpg123/decode.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,218 +0,0 @@ -/* - * Mpeg Layer-1,2,3 audio decoder - * ------------------------------ - * copyright (c) 1995,1996,1997 by Michael Hipp, All rights reserved. - * See also 'README' - * - */ - -#include <stdlib.h> -#include <math.h> -#include <string.h> - -#include "mpg123.h" - -#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) = sum; } - -int mpgdec_synth_1to1_8bit(mpgdec_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 = mpgdec_synth_1to1(bandPtr,channel,(unsigned char *) samples_tmp,&pnt1); - samples += channel + *pnt; - - for(i=0;i<32;i++) { - *samples = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - samples += 2; - tmp1 += 2; - } - *pnt += 64; - - return ret; -} - -int mpgdec_synth_1to1_8bit_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[64]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<32;i++) { - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - tmp1 += 2; - } - *pnt += 32; - - return ret; -} - -int mpgdec_synth_1to1_8bit_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[64]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<32;i++) { - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - tmp1 += 2; - } - *pnt += 64; - - return ret; -} - -int mpgdec_synth_1to1_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[64]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_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 mpgdec_synth_1to1_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - int i,ret; - - ret = mpgdec_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; -} - - -int mpgdec_synth_1to1(mpgdec_real *bandPtr,int channel,unsigned char *out,int *pnt) -{ - static mpgdec_real buffs[2][2][0x110]; - static const int step = 2; - static int bo = 1; - short *samples = (short *) (out+*pnt); - - mpgdec_real *b0,(*buf)[0x110]; - int clip = 0; - int bo1; - - if(!channel) { - bo--; - bo &= 0xf; - buf = buffs[0]; - } - else { - samples++; - buf = buffs[1]; - } - - if(bo & 0x1) { - b0 = buf[0]; - bo1 = bo; - mpgdec_dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr); - } - else { - b0 = buf[1]; - bo1 = bo+1; - mpgdec_dct64(buf[0]+bo,buf[1]+bo+1,bandPtr); - } - - - { - register int j; - mpgdec_real *window = mpgdec_decwin + 16 - bo1; - - for (j=16;j;j--,window+=0x10,samples+=step) - { - mpgdec_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); - } - - { - mpgdec_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) - { - mpgdec_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 += 128; - - return clip; -}
--- a/src/mpg123/dxhead.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -/* - * Handle Xing vbr header - */ -#include "config.h" -#include "dxhead.h" -#include <stdlib.h> -#include <float.h> -#include <math.h> -#include <string.h> -#include <glib.h> - -#define GET_INT32BE(b) \ -(i = (b[0] << 24) | (b[1] << 16) | b[2] << 8 | b[3], b += 4, i) - -int -mpgdec_get_xing_header(xing_header_t * xing, unsigned char *buf) -{ - int i, head_flags; - int id, mode; - - memset(xing, 0, sizeof(xing_header_t)); - - /* get selected MPEG header data */ - id = (buf[1] >> 3) & 1; - mode = (buf[3] >> 6) & 3; - buf += 4; - - /* Skip the sub band data */ - if (id) { - /* mpeg1 */ - if (mode != 3) - buf += 32; - else - buf += 17; - } - else { - /* mpeg2 */ - if (mode != 3) - buf += 17; - else - buf += 9; - } - - if (strncmp((char *) buf, "Xing", 4)) - return 0; - buf += 4; - - head_flags = GET_INT32BE(buf); - - if (head_flags & FRAMES_FLAG) - xing->frames = GET_INT32BE(buf); - if (xing->frames < 1) - return 0; - if (head_flags & BYTES_FLAG) - xing->bytes = GET_INT32BE(buf); - - if (head_flags & TOC_FLAG) { - for (i = 0; i < 100; i++) { - xing->toc[i] = buf[i]; - if (i > 0 && xing->toc[i] < xing->toc[i - 1]) - return 0; - } - if (xing->toc[99] == 0) - return 0; - buf += 100; - } - else - for (i = 0; i < 100; i++) - xing->toc[i] = (i * 256) / 100; - -#ifdef XING_DEBUG - for (i = 0; i < 100; i++) { - if ((i % 10) == 0) - fprintf(stderr, "\n"); - fprintf(stderr, " %3d", xing->toc[i]); - } -#endif - - return 1; -} - -int -mpgdec_seek_point(xing_header_t * xing, float percent) -{ - /* interpolate in TOC to get file seek point in bytes */ - int a, seekpoint; - float fa, fb, fx; - - percent = CLAMP(percent, 0, 100); - a = MIN(percent, 99); - - fa = xing->toc[a]; - - if (a < 99) - fb = xing->toc[a + 1]; - else - fb = 256; - - fx = fa + (fb - fa) * (percent - a); - seekpoint = (1.0f / 256.0f) * fx * xing->bytes; - - return seekpoint; -}
--- a/src/mpg123/dxhead.h Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* - * A Xing header may be present in the ancillary - * data field of the first frame of an mp3 bitstream - * The Xing header (optionally) contains - * frames total number of audio frames in the bitstream - * bytes total number of bytes in the bitstream - * toc table of contents - * - * toc (table of contents) gives seek points - * for random access - * the ith entry determines the seek point for - * i-percent duration - * seek point in bytes = (toc[i]/256.0) * total_bitstream_bytes - * e.g. half duration seek point = (toc[50]/256.0) * total_bitstream_bytes - */ - -#define FRAMES_FLAG 0x0001 -#define BYTES_FLAG 0x0002 -#define TOC_FLAG 0x0004 -#define VBR_SCALE_FLAG 0x0008 - -/* - * structure to receive extracted header - */ -typedef struct { - int frames; /* total bit stream frames from Xing header data */ - int bytes; /* total bit stream bytes from Xing header data */ - unsigned char toc[100]; /* "table of contents" */ -} xing_header_t; - -/* - * Returns zero on fail, non-zero on success - * xing structure to receive header data (output) - * buf bitstream input - */ -int mpgdec_get_xing_header(xing_header_t * xing, unsigned char *buf); - - -/* - * Returns seekpoint in bytes (may be at eof if percent=100.0) - * percent: play time percentage of total playtime. May be fractional. - */ -int mpgdec_seek_point(xing_header_t * xing, float percent);
--- a/src/mpg123/fileinfo.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,829 +0,0 @@ -/* BMP - Cross-platform multimedia player - * Copyright (C) 2003-2004 BMP development team. - * - * Based on XMMS: - * Copyright (C) 1998-2003 XMMS development team. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "mpg123.h" - -#include <tag_c.h> -#include "tag_c_hacked.h" - -#include <glib.h> -#include <audacious/i18n.h> -#include <gtk/gtk.h> -#include <gdk/gdkkeysyms.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> - -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> - -#include <audacious/util.h> -#include <audacious/vfs.h> -#include <audacious/strings.h> - -#include "mp3.xpm" - -static GtkWidget *window = NULL; -static GtkWidget *filename_entry, *id3_frame; -static GtkWidget *title_entry, *artist_entry, *album_entry, *year_entry, - *tracknum_entry, *comment_entry; -static GtkWidget *genre_combo; -static GtkWidget *mpeg_level, *mpeg_bitrate, *mpeg_samplerate, *mpeg_flags, - *mpeg_error, *mpeg_copy, *mpeg_orig, *mpeg_emph, *mpeg_filesize; -static GtkWidget *mpeg_level_val, *mpeg_bitrate_val, *mpeg_samplerate_val, - *mpeg_error_val, *mpeg_copy_val, *mpeg_orig_val, *mpeg_emph_val, - *mpeg_filesize_val, *mpeg_flags_val; - -GtkWidget *vbox, *hbox, *left_vbox, *table; -GtkWidget *mpeg_frame, *mpeg_box; -GtkWidget *label, *filename_vbox; -GtkWidget *bbox; -GtkWidget *remove_id3, *cancel, *save; -GtkWidget *boxx; - -VFSFile *fh; -const gchar *emphasis[4]; -const gchar *bool_label[2]; - -static GList *genre_list = NULL; -static gchar *current_filename = NULL; - -extern gchar *mpgdec_filename; -extern gint mpgdec_bitrate, mpgdec_frequency, mpgdec_layer, mpgdec_lsf, - mpgdec_mode; -extern gboolean mpgdec_stereo, mpgdec_mpeg25; - -glong info_rate; - -static TagLib_File *taglib_file; -static TagLib_Tag *taglib_tag; -static const TagLib_AudioProperties *taglib_ap; - -void fill_entries(GtkWidget * w, gpointer data); - -#define MAX_STR_LEN 100 - -static gint -genre_comp_func(gconstpointer a, gconstpointer b) -{ - return strcasecmp(a, b); -} - -static gboolean -fileinfo_keypress_cb(GtkWidget * widget, - GdkEventKey * event, - gpointer data) -{ - if (!event) - return FALSE; - - switch (event->keyval) { - case GDK_Escape: - gtk_widget_destroy(window); - break; - default: - return FALSE; - } - - return TRUE; -} - -static void -save_cb(GtkWidget * w, gpointer data) -{ - int result; - - if (str_has_prefix_nocase(current_filename, "http://")) - return; - -#ifndef USE_CHARDET - taglib_set_strings_unicode(1); -#endif - - /* XXX: Gnome VFS workaround. -nenolod */ - if (str_has_prefix_nocase(current_filename, "file://")) - current_filename += 7; - - taglib_file = taglib_file_new_type(current_filename, TagLib_File_MPEG); - if(taglib_file) { - taglib_tag = taglib_file_tag(taglib_file); - taglib_ap = taglib_file_audioproperties(taglib_file); - } else return; - -#ifndef USE_CHARDET - taglib_set_id3v2_default_text_encoding(); -#endif - taglib_tag_set_title(taglib_tag, gtk_entry_get_text(GTK_ENTRY(title_entry))); - taglib_tag_set_artist(taglib_tag, gtk_entry_get_text(GTK_ENTRY(artist_entry))); - taglib_tag_set_album(taglib_tag, gtk_entry_get_text(GTK_ENTRY(album_entry))); - taglib_tag_set_comment(taglib_tag, gtk_entry_get_text(GTK_ENTRY(comment_entry))); - taglib_tag_set_year(taglib_tag, atoi(gtk_entry_get_text(GTK_ENTRY(year_entry)))); - taglib_tag_set_track(taglib_tag, atoi(gtk_entry_get_text(GTK_ENTRY(tracknum_entry)))); - taglib_tag_set_genre(taglib_tag, gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(genre_combo)->entry))); - gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE); - - result = taglib_file_save(taglib_file); - taglib_file_free(taglib_file); - taglib_tag_free_strings(); -} - -static void -label_set_text(GtkWidget * label, gchar * str, ...) -{ - va_list args; - gchar tempstr[MAX_STR_LEN]; - - va_start(args, str); - g_vsnprintf(tempstr, MAX_STR_LEN, str, args); - va_end(args); - - gtk_label_set_text(GTK_LABEL(label), tempstr); -} - -static void -remove_id3_cb(GtkWidget * w, gpointer data) -{ - int result; - - if (str_has_prefix_nocase(current_filename, "http://")) - return; - - taglib_file = taglib_file_new_type(current_filename, TagLib_File_MPEG); - if(taglib_file) { - taglib_tag = taglib_file_tag(taglib_file); - taglib_ap = taglib_file_audioproperties(taglib_file); - } else return; - - taglib_tag_set_title(taglib_tag, ""); - gtk_entry_set_text(GTK_ENTRY(title_entry), ""); - taglib_tag_set_artist(taglib_tag, ""); - gtk_entry_set_text(GTK_ENTRY(artist_entry), ""); - taglib_tag_set_album(taglib_tag, ""); - gtk_entry_set_text(GTK_ENTRY(album_entry), ""); - taglib_tag_set_comment(taglib_tag, ""); - gtk_entry_set_text(GTK_ENTRY(comment_entry), ""); - taglib_tag_set_year(taglib_tag, 0); - gtk_entry_set_text(GTK_ENTRY(year_entry), ""); - taglib_tag_set_track(taglib_tag, 0); - gtk_entry_set_text(GTK_ENTRY(tracknum_entry), ""); - taglib_tag_set_genre(taglib_tag, ""); - gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), ""); - gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE); - - result = taglib_file_save(taglib_file); - taglib_file_free(taglib_file); - taglib_tag_free_strings(); -} - -static void -set_mpeg_level_label(gboolean mpeg25, gint lsf, gint layer) -{ - if (mpeg25) - label_set_text(mpeg_level_val, "MPEG-2.5 Layer %d", layer); - else - label_set_text(mpeg_level_val, "MPEG-%d Layer %d", lsf + 1, layer); -} - -static const gchar * -channel_mode_name(gint mode) -{ - static const gchar *channel_mode[] = { N_("Stereo"), N_("Joint stereo"), - N_("Dual channel"), N_("Single channel") - }; - if (mode < 0 || mode > 3) - return ""; - - return gettext(channel_mode[mode]); -} - -static void -file_info_http(gchar * filename) -{ - gtk_widget_set_sensitive(id3_frame, FALSE); - if (mpgdec_filename && !strcmp(filename, mpgdec_filename) && - mpgdec_bitrate != 0) { - set_mpeg_level_label(mpgdec_mpeg25, mpgdec_lsf, mpgdec_layer); - label_set_text(mpeg_bitrate_val, _("%d KBit/s"), mpgdec_bitrate); - label_set_text(mpeg_samplerate_val, _("%ld Hz"), mpgdec_frequency); - label_set_text(mpeg_flags, "%s", channel_mode_name(mpgdec_mode)); - } -} - -static void -change_buttons(GtkObject * object) -{ - gtk_widget_set_sensitive(GTK_WIDGET(object), TRUE); -} - -void -mpgdec_file_info_box(gchar * filename) -{ - gint i; - gchar *title, *filename_utf8; - - emphasis[0] = _("None"); - emphasis[1] = _("50/15 ms"); - emphasis[2] = ""; - emphasis[3] = _("CCIT J.17"); - bool_label[0] = _("No"); - bool_label[1] = _("Yes"); - - if (!window) { - GtkWidget *pixmapwid; - GdkPixbuf *pixbuf; - PangoAttrList *attrs; - PangoAttribute *attr; - GtkWidget *test_table = gtk_table_new(2, 11, FALSE); - GtkWidget *urk, *blark; - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_type_hint(GTK_WINDOW(window), - GDK_WINDOW_TYPE_HINT_DIALOG); - gtk_window_set_resizable(GTK_WINDOW(window), FALSE); - gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); - g_signal_connect(G_OBJECT(window), "destroy", - G_CALLBACK(gtk_widget_destroyed), &window); - gtk_container_set_border_width(GTK_CONTAINER(window), 10); - - vbox = gtk_vbox_new(FALSE, 10); - gtk_container_add(GTK_CONTAINER(window), vbox); - - - filename_vbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), filename_vbox, FALSE, TRUE, 0); - - pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **) - gnome_mime_audio_xpm); - pixmapwid = gtk_image_new_from_pixbuf(pixbuf); - g_object_unref(pixbuf); - gtk_misc_set_alignment(GTK_MISC(pixmapwid), 0, 0); - gtk_box_pack_start(GTK_BOX(filename_vbox), pixmapwid, FALSE, FALSE, - 0); - - label = gtk_label_new(NULL); - - attrs = pango_attr_list_new(); - - attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD); - attr->start_index = 0; - attr->end_index = -1; - pango_attr_list_insert(attrs, attr); - - gtk_label_set_attributes(GTK_LABEL(label), attrs); - gtk_label_set_text(GTK_LABEL(label), _("Name:")); - gtk_box_pack_start(GTK_BOX(filename_vbox), label, FALSE, FALSE, 0); - - filename_entry = gtk_entry_new(); - gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE); - gtk_box_pack_start(GTK_BOX(filename_vbox), filename_entry, TRUE, - TRUE, 0); - - hbox = gtk_hbox_new(FALSE, 10); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); - - left_vbox = gtk_table_new(2, 4, FALSE); - gtk_box_pack_start(GTK_BOX(hbox), left_vbox, FALSE, FALSE, 0); - - /* MPEG-Info window */ - - mpeg_frame = gtk_frame_new(_(" MPEG Info ")); - gtk_table_attach(GTK_TABLE(left_vbox), mpeg_frame, 0, 2, 0, 1, - GTK_FILL, GTK_FILL, 0, 4); - - mpeg_box = gtk_vbox_new(FALSE, 5); - gtk_container_add(GTK_CONTAINER(mpeg_frame), mpeg_box); - gtk_container_set_border_width(GTK_CONTAINER(mpeg_box), 10); - gtk_box_set_spacing(GTK_BOX(mpeg_box), 0); - - /* MPEG Layer Info */ - - /* FIXME: Obvious... */ - gtk_container_set_border_width(GTK_CONTAINER(test_table), 0); - gtk_container_add(GTK_CONTAINER(mpeg_box), test_table); - - mpeg_level = gtk_label_new(_("MPEG Level:")); - gtk_misc_set_alignment(GTK_MISC(mpeg_level), 1, 0.5); - gtk_label_set_justify(GTK_LABEL(mpeg_level), GTK_JUSTIFY_RIGHT); - gtk_label_set_attributes(GTK_LABEL(mpeg_level), attrs); - gtk_table_attach(GTK_TABLE(test_table), mpeg_level, 0, 1, 0, 1, - GTK_FILL, GTK_FILL, 5, 2); - - mpeg_level_val = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_level_val), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_level_val), GTK_JUSTIFY_LEFT); - gtk_table_attach(GTK_TABLE(test_table), mpeg_level_val, 1, 2, 0, 1, - GTK_FILL, GTK_FILL, 10, 2); - - mpeg_bitrate = gtk_label_new(_("Bit rate:")); - gtk_misc_set_alignment(GTK_MISC(mpeg_bitrate), 1, 0.5); - gtk_label_set_justify(GTK_LABEL(mpeg_bitrate), GTK_JUSTIFY_RIGHT); - gtk_label_set_attributes(GTK_LABEL(mpeg_bitrate), attrs); - gtk_table_attach(GTK_TABLE(test_table), mpeg_bitrate, 0, 1, 1, 2, - GTK_FILL, GTK_FILL, 5, 2); - - mpeg_bitrate_val = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_bitrate_val), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_bitrate_val), GTK_JUSTIFY_LEFT); - gtk_table_attach(GTK_TABLE(test_table), mpeg_bitrate_val, 1, 2, 1, - 2, GTK_FILL, GTK_FILL, 10, 2); - - mpeg_samplerate = gtk_label_new(_("Sample rate:")); - gtk_misc_set_alignment(GTK_MISC(mpeg_samplerate), 1, 0.5); - gtk_label_set_justify(GTK_LABEL(mpeg_samplerate), GTK_JUSTIFY_RIGHT); - gtk_label_set_attributes(GTK_LABEL(mpeg_samplerate), attrs); - gtk_table_attach(GTK_TABLE(test_table), mpeg_samplerate, 0, 1, 2, - 3, GTK_FILL, GTK_FILL, 5, 2); - - mpeg_samplerate_val = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_samplerate_val), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_samplerate_val), - GTK_JUSTIFY_LEFT); - gtk_table_attach(GTK_TABLE(test_table), mpeg_samplerate_val, 1, 2, - 2, 3, GTK_FILL, GTK_FILL, 10, 2); - - mpeg_filesize = gtk_label_new(_("File size:")); - gtk_misc_set_alignment(GTK_MISC(mpeg_filesize), 1, 0.5); - gtk_label_set_justify(GTK_LABEL(mpeg_filesize), GTK_JUSTIFY_RIGHT); - gtk_label_set_attributes(GTK_LABEL(mpeg_filesize), attrs); - gtk_table_attach(GTK_TABLE(test_table), mpeg_filesize, 0, 1, 4, 5, - GTK_FILL, GTK_FILL, 5, 2); - - mpeg_filesize_val = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_filesize_val), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_filesize_val), GTK_JUSTIFY_LEFT); - gtk_table_attach(GTK_TABLE(test_table), mpeg_filesize_val, 1, 2, 4, - 5, GTK_FILL, GTK_FILL, 10, 2); - - mpeg_flags = gtk_label_new(_("Mode:")); - gtk_misc_set_alignment(GTK_MISC(mpeg_flags), 1, 0.5); - gtk_label_set_justify(GTK_LABEL(mpeg_flags), GTK_JUSTIFY_RIGHT); - gtk_label_set_attributes(GTK_LABEL(mpeg_flags), attrs); - gtk_table_attach(GTK_TABLE(test_table), mpeg_flags, 0, 1, 5, 6, - GTK_FILL, GTK_FILL, 5, 2); - - mpeg_flags_val = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_flags_val), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_flags_val), GTK_JUSTIFY_LEFT); - gtk_table_attach(GTK_TABLE(test_table), mpeg_flags_val, 1, 2, 5, - 6, GTK_FILL, GTK_FILL, 10, 2); - - urk = gtk_label_new(""); - blark = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(urk), 1, 0.5); - gtk_misc_set_alignment(GTK_MISC(blark), 0, 0); - - gtk_table_attach(GTK_TABLE(test_table), urk, 0, 1, 6, 7, GTK_FILL, - GTK_FILL, 5, 5); - gtk_table_attach(GTK_TABLE(test_table), blark, 1, 2, 6, 7, - GTK_FILL, GTK_FILL, 10, 5); - - mpeg_error = gtk_label_new(_("Error Protection:")); - gtk_misc_set_alignment(GTK_MISC(mpeg_error), 1, 0.5); - gtk_label_set_justify(GTK_LABEL(mpeg_error), GTK_JUSTIFY_RIGHT); - gtk_label_set_attributes(GTK_LABEL(mpeg_error), attrs); - gtk_table_attach(GTK_TABLE(test_table), mpeg_error, 0, 1, 7, 8, - GTK_FILL, GTK_FILL, 5, 0); - - mpeg_error_val = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_error_val), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_error_val), GTK_JUSTIFY_LEFT); - gtk_table_attach(GTK_TABLE(test_table), mpeg_error_val, 1, 2, 7, 8, - GTK_FILL, GTK_FILL, 10, 2); - - mpeg_copy = gtk_label_new(_("Copyright:")); - gtk_misc_set_alignment(GTK_MISC(mpeg_copy), 1, 0.5); - gtk_label_set_justify(GTK_LABEL(mpeg_copy), GTK_JUSTIFY_RIGHT); - gtk_label_set_attributes(GTK_LABEL(mpeg_copy), attrs); - gtk_table_attach(GTK_TABLE(test_table), mpeg_copy, 0, 1, 8, 9, - GTK_FILL, GTK_FILL, 5, 2); - - mpeg_copy_val = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_copy_val), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_copy_val), GTK_JUSTIFY_LEFT); - gtk_table_attach(GTK_TABLE(test_table), mpeg_copy_val, 1, 2, 8, 9, - GTK_FILL, GTK_FILL, 10, 2); - - mpeg_orig = gtk_label_new(_("Original:")); - gtk_misc_set_alignment(GTK_MISC(mpeg_orig), 1, 0.5); - gtk_label_set_justify(GTK_LABEL(mpeg_orig), GTK_JUSTIFY_RIGHT); - gtk_label_set_attributes(GTK_LABEL(mpeg_orig), attrs); - gtk_table_attach(GTK_TABLE(test_table), mpeg_orig, 0, 1, 9, 10, - GTK_FILL, GTK_FILL, 5, 2); - - mpeg_orig_val = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_orig_val), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_orig_val), GTK_JUSTIFY_LEFT); - gtk_table_attach(GTK_TABLE(test_table), mpeg_orig_val, 1, 2, 9, 10, - GTK_FILL, GTK_FILL, 10, 2); - - mpeg_emph = gtk_label_new(_("Emphasis:")); - gtk_misc_set_alignment(GTK_MISC(mpeg_emph), 1, 0.5); - gtk_label_set_justify(GTK_LABEL(mpeg_emph), GTK_JUSTIFY_RIGHT); - gtk_label_set_attributes(GTK_LABEL(mpeg_emph), attrs); - gtk_table_attach(GTK_TABLE(test_table), mpeg_emph, 0, 1, 10, 11, - GTK_FILL, GTK_FILL, 5, 2); - - mpeg_emph_val = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_emph_val), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_emph_val), GTK_JUSTIFY_LEFT); - gtk_table_attach(GTK_TABLE(test_table), mpeg_emph_val, 1, 2, 10, 11, - GTK_FILL, GTK_FILL, 10, 2); - - - id3_frame = gtk_frame_new(_(" ID3 Tag ")); - gtk_table_attach(GTK_TABLE(left_vbox), id3_frame, 2, 4, 0, 1, - GTK_FILL, GTK_FILL, 0, 4); - - table = gtk_table_new(7, 5, FALSE); - gtk_container_set_border_width(GTK_CONTAINER(table), 5); - gtk_container_add(GTK_CONTAINER(id3_frame), table); - - label = gtk_label_new(_("Title:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_label_set_attributes(GTK_LABEL(label), attrs); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, - GTK_FILL, 5, 5); - - title_entry = gtk_entry_new(); - gtk_table_attach(GTK_TABLE(table), title_entry, 1, 6, 0, 1, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); - - label = gtk_label_new(_("Artist:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_label_set_attributes(GTK_LABEL(label), attrs); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, - GTK_FILL, 5, 5); - - artist_entry = gtk_entry_new(); - gtk_table_attach(GTK_TABLE(table), artist_entry, 1, 6, 1, 2, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); - - label = gtk_label_new(_("Album:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_label_set_attributes(GTK_LABEL(label), attrs); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, GTK_FILL, - GTK_FILL, 5, 5); - - album_entry = gtk_entry_new(); - gtk_table_attach(GTK_TABLE(table), album_entry, 1, 6, 2, 3, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); - - label = gtk_label_new(_("Comment:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_label_set_attributes(GTK_LABEL(label), attrs); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, GTK_FILL, - GTK_FILL, 5, 5); - - comment_entry = gtk_entry_new(); - gtk_table_attach(GTK_TABLE(table), comment_entry, 1, 6, 3, 4, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); - - label = gtk_label_new(_("Year:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_label_set_attributes(GTK_LABEL(label), attrs); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, GTK_FILL, - GTK_FILL, 5, 5); - - year_entry = gtk_entry_new_with_max_length(4); - gtk_entry_set_width_chars(GTK_ENTRY(year_entry),4); - gtk_table_attach(GTK_TABLE(table), year_entry, 1, 2, 4, 5, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); - - label = gtk_label_new(_("Track number:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_label_set_attributes(GTK_LABEL(label), attrs); - gtk_table_attach(GTK_TABLE(table), label, 2, 3, 4, 5, GTK_FILL, - GTK_FILL, 5, 5); - - tracknum_entry = gtk_entry_new_with_max_length(3); - gtk_widget_set_usize(tracknum_entry, 40, -1); - gtk_table_attach(GTK_TABLE(table), tracknum_entry, 3, 4, 4, 5, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); - - label = gtk_label_new(_("Genre:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_label_set_attributes(GTK_LABEL(label), attrs); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6, GTK_FILL, - GTK_FILL, 5, 5); - - pango_attr_list_unref(attrs); - - genre_combo = gtk_combo_new(); - gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), - FALSE); - if (!genre_list) { - for (i = 0; i < GENRE_MAX; i++) - genre_list = - g_list_prepend(genre_list, - (gchar *) mpgdec_id3_genres[i]); - genre_list = g_list_prepend(genre_list, ""); - genre_list = g_list_sort(genre_list, genre_comp_func); - } - gtk_combo_set_popdown_strings(GTK_COMBO(genre_combo), genre_list); - - gtk_table_attach(GTK_TABLE(table), genre_combo, 1, 6, 5, 6, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); - - boxx = gtk_hbutton_box_new(); - gtk_hbutton_box_set_layout_default(GTK_BUTTONBOX_SPREAD); - - remove_id3 = gtk_button_new_from_stock(GTK_STOCK_DELETE); - gtk_container_add(GTK_CONTAINER(boxx), remove_id3); - - save = gtk_button_new_from_stock(GTK_STOCK_SAVE); - gtk_container_add(GTK_CONTAINER(boxx), save); - - g_signal_connect(G_OBJECT(remove_id3), "clicked", - G_CALLBACK(remove_id3_cb), save); - g_signal_connect(G_OBJECT(save), "clicked", G_CALLBACK(save_cb), - remove_id3); - - gtk_table_attach(GTK_TABLE(table), boxx, 0, 5, 6, 7, GTK_FILL, 0, - 0, 8); - - bbox = gtk_hbutton_box_new(); - gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); - gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); - gtk_table_attach(GTK_TABLE(left_vbox), bbox, 0, 4, 1, 2, GTK_FILL, - 0, 0, 8); - - cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); - g_signal_connect_swapped(G_OBJECT(cancel), "clicked", - G_CALLBACK(gtk_widget_destroy), - G_OBJECT(window)); - GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); - gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0); - gtk_widget_grab_default(cancel); - - - gtk_table_set_col_spacing(GTK_TABLE(left_vbox), 1, 10); - - - g_signal_connect_swapped(G_OBJECT(title_entry), "changed", - G_CALLBACK(change_buttons), save); - g_signal_connect_swapped(G_OBJECT(artist_entry), "changed", - G_CALLBACK(change_buttons), save); - g_signal_connect_swapped(G_OBJECT(album_entry), "changed", - G_CALLBACK(change_buttons), save); - g_signal_connect_swapped(G_OBJECT(year_entry), "changed", - G_CALLBACK(change_buttons), save); - g_signal_connect_swapped(G_OBJECT(comment_entry), "changed", - G_CALLBACK(change_buttons), save); - g_signal_connect_swapped(G_OBJECT(tracknum_entry), "changed", - G_CALLBACK(change_buttons), save); - g_signal_connect_swapped(G_OBJECT(GTK_COMBO(genre_combo)->entry), "changed", - G_CALLBACK(change_buttons), save); - - /* Nonsence, should i remove this altogether? - causes changes to be saved as you type - - makes save /revert buttons pointless - g_signal_connect(G_OBJECT(title_entry), "activate", - G_CALLBACK(press_save), NULL); - g_signal_connect(G_OBJECT(artist_entry), "activate", - G_CALLBACK(press_save), NULL); - g_signal_connect(G_OBJECT(album_entry), "activate", - G_CALLBACK(press_save), NULL); - g_signal_connect(G_OBJECT(year_entry), "activate", - G_CALLBACK(press_save), NULL); - g_signal_connect(G_OBJECT(comment_entry), "activate", - G_CALLBACK(press_save), NULL); - g_signal_connect(G_OBJECT(tracknum_entry), "activate", - G_CALLBACK(press_save), NULL); - */ - g_signal_connect(G_OBJECT(window), "key_press_event", - G_CALLBACK(fileinfo_keypress_cb), NULL); - } - - g_free(current_filename); - current_filename = g_strdup(filename); - - filename_utf8 = filename_to_utf8(filename); - - title = g_strdup_printf(_("%s - Audacious"), g_basename(filename_utf8)); - gtk_window_set_title(GTK_WINDOW(window), title); - g_free(title); - - gtk_entry_set_text(GTK_ENTRY(filename_entry), filename_utf8); - g_free(filename_utf8); - - gtk_editable_set_position(GTK_EDITABLE(filename_entry), -1); - - gtk_entry_set_text(GTK_ENTRY(artist_entry), ""); - gtk_entry_set_text(GTK_ENTRY(album_entry), ""); - gtk_entry_set_text(GTK_ENTRY(year_entry), ""); - gtk_entry_set_text(GTK_ENTRY(tracknum_entry), ""); - gtk_entry_set_text(GTK_ENTRY(comment_entry), ""); - gtk_list_select_item(GTK_LIST(GTK_COMBO(genre_combo)->list), - g_list_index(genre_list, "")); - - gtk_label_set_text(GTK_LABEL(mpeg_level), _("MPEG Level:")); - gtk_label_set_text(GTK_LABEL(mpeg_level_val), _("N/A")); - - gtk_label_set_text(GTK_LABEL(mpeg_bitrate), _("Bit rate:")); - gtk_label_set_text(GTK_LABEL(mpeg_bitrate_val), _("N/A")); - - gtk_label_set_text(GTK_LABEL(mpeg_samplerate), _("Sample rate:")); - gtk_label_set_text(GTK_LABEL(mpeg_samplerate_val), _("N/A")); - - gtk_label_set_text(GTK_LABEL(mpeg_error), _("Error Protection:")); - gtk_label_set_text(GTK_LABEL(mpeg_error_val), _("N/A")); - - gtk_label_set_text(GTK_LABEL(mpeg_copy), _("Copyright:")); - gtk_label_set_text(GTK_LABEL(mpeg_copy_val), _("N/A")); - - gtk_label_set_text(GTK_LABEL(mpeg_orig), _("Original:")); - gtk_label_set_text(GTK_LABEL(mpeg_orig_val), _("N/A")); - - gtk_label_set_text(GTK_LABEL(mpeg_emph), _("Emphasis:")); - gtk_label_set_text(GTK_LABEL(mpeg_emph_val), _("N/A")); - - gtk_label_set_text(GTK_LABEL(mpeg_filesize), _("File size:")); - gtk_label_set_text(GTK_LABEL(mpeg_filesize_val), _("N/A")); - - gtk_label_set_text(GTK_LABEL(mpeg_flags), _("Mode:")); - gtk_label_set_text(GTK_LABEL(mpeg_flags_val), _("N/A")); - - if (str_has_prefix_nocase(filename, "http://")) { - file_info_http(filename); - return; - } - - gtk_widget_set_sensitive(id3_frame, - vfs_is_writeable(filename)); - - fill_entries(NULL, NULL); - - gtk_widget_set_sensitive(GTK_WIDGET(save), FALSE); - gtk_widget_show_all(window); -} - -void -fill_entries(GtkWidget * w, gpointer data) -{ - VFSFile *fh; - gchar *ptr, *ptr2; - guint32 i; - - if (str_has_prefix_nocase(current_filename, "http://")) - return; - -#ifdef USE_CHARDET - taglib_set_strings_unicode(FALSE); -#endif - taglib_file = taglib_file_new_type(current_filename, TagLib_File_MPEG); - if(taglib_file) { - taglib_tag = taglib_file_tag(taglib_file); - taglib_ap = taglib_file_audioproperties(taglib_file); - } else return; - - if (!taglib_tag) - return; - - /* be sane here, taglib_tag results may be NULL --nenolod */ - ptr = taglib_tag_title(taglib_tag); - - if (ptr != NULL) { - ptr2 = str_to_utf8(ptr); - gtk_entry_set_text(GTK_ENTRY(title_entry), ptr2); - g_free(ptr2); - } - - ptr = taglib_tag_artist(taglib_tag); - - if (ptr != NULL) { - ptr2 = str_to_utf8(ptr); - gtk_entry_set_text(GTK_ENTRY(artist_entry), ptr2); - g_free(ptr2); - } - - ptr = taglib_tag_album(taglib_tag); - - if (ptr != NULL) { - ptr2 = str_to_utf8(ptr); - gtk_entry_set_text(GTK_ENTRY(album_entry), ptr2); - g_free(ptr2); - } - - ptr = taglib_tag_comment(taglib_tag); - - if (ptr != NULL) { - ptr2 = str_to_utf8(ptr); - gtk_entry_set_text(GTK_ENTRY(comment_entry), ptr2); - g_free(ptr2); - } - - i = taglib_tag_year(taglib_tag); - - if (i != 0) - { - ptr = g_strdup_printf("%d", i); - gtk_entry_set_text(GTK_ENTRY(year_entry), ptr); - g_free(ptr); - } - - i = taglib_tag_track(taglib_tag); - - if (i != 0) - { - ptr = g_strdup_printf("%d", i); - gtk_entry_set_text(GTK_ENTRY(tracknum_entry), ptr); - g_free(ptr); - } - - i = taglib_audioproperties_samplerate(taglib_ap); - - if (i != 0) - label_set_text(mpeg_samplerate_val, _("%ld Hz"), i); - - i = taglib_audioproperties_bitrate(taglib_ap); - - if (i != 0) - label_set_text(mpeg_bitrate_val, _("%d KBit/s"), i); - - ptr = taglib_tag_genre(taglib_tag); - - if (ptr != NULL) - gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), ptr); - - if (w != NULL) - gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE); - if (data != NULL) - gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE); - - taglib_file_free(taglib_file); - taglib_tag_free_strings(); - gtk_widget_set_sensitive(GTK_WIDGET(remove_id3), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(save), FALSE); - - if ((fh = vfs_fopen(current_filename, "rb")) != NULL) { - guint32 head; - guchar tmp[4]; - struct frame frm; - - if (vfs_fread(tmp, 1, 4, fh) != 4) { - vfs_fclose(fh); - return; - } - head = - ((guint32) tmp[0] << 24) | ((guint32) tmp[1] << 16) | - ((guint32) tmp[2] << 8) | (guint32) tmp[3]; - while (!mpgdec_head_check(head)) { - head <<= 8; - if (vfs_fread(tmp, 1, 1, fh) != 1) { - vfs_fclose(fh); - return; - } - head |= tmp[0]; - } - if (mpgdec_decode_header(&frm, head)) { - guchar *buf; - gint pos; - - buf = g_malloc(frm.framesize + 4); - vfs_fseek(fh, -4, SEEK_CUR); - vfs_fread(buf, 1, frm.framesize + 4, fh); - set_mpeg_level_label(frm.mpeg25, frm.lsf, frm.lay); - pos = vfs_ftell(fh); - vfs_fseek(fh, 0, SEEK_END); - label_set_text(mpeg_error_val, _("%s"), - bool_label[frm.error_protection]); - label_set_text(mpeg_copy_val, _("%s"), bool_label[frm.copyright]); - label_set_text(mpeg_orig_val, _("%s"), bool_label[frm.original]); - label_set_text(mpeg_emph_val, _("%s"), emphasis[frm.emphasis]); - label_set_text(mpeg_filesize_val, _("%lu Bytes"), vfs_ftell(fh)); - label_set_text(mpeg_flags_val, _("%s"), channel_mode_name(frm.mode)); - g_free(buf); - } - vfs_fclose(fh); - } - -}
--- a/src/mpg123/getbits.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -#include "mpg123.h" -#include "common.h" - -void mpgdec_backbits(struct bitstream_info *bitbuf,int number_of_bits) -{ - bitbuf->bitindex -= number_of_bits; - bitbuf->wordpointer += (bitbuf->bitindex>>3); - bitbuf->bitindex &= 0x7; -} - -int mpgdec_getbitoffset(struct bitstream_info *bitbuf) -{ - return (-bitbuf->bitindex)&0x7; -} - -int mpgdec_getbyte(struct bitstream_info *bitbuf) -{ -#ifdef DEBUG_GETBITS - if(bitbuf->bitindex) - fprintf(stderr,"getbyte called unsynched!\n"); -#endif - return *bitbuf->wordpointer++; -} - -unsigned int mpgdec_getbits(struct bitstream_info *bitbuf,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+bitbuf->bitindex); -#endif - - { - rval = bitbuf->wordpointer[0]; - rval <<= 8; - rval |= bitbuf->wordpointer[1]; - rval <<= 8; - rval |= bitbuf->wordpointer[2]; - - rval <<= bitbuf->bitindex; - rval &= 0xffffff; - - bitbuf->bitindex += number_of_bits; - - rval >>= (24-number_of_bits); - - bitbuf->wordpointer += (bitbuf->bitindex>>3); - bitbuf->bitindex &= 7; - } - -#ifdef DEBUG_GETBITS -fprintf(stderr,":%x ",rval); -#endif - - return rval; -} - -unsigned int mpgdec_getbits_fast(struct bitstream_info *bitbuf,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+bitbuf->bitindex); -#endif - - rval = (unsigned char) (bitbuf->wordpointer[0] << bitbuf->bitindex); - rval |= ((unsigned int) bitbuf->wordpointer[1]<<bitbuf->bitindex)>>8; - rval <<= number_of_bits; - rval >>= 8; - - bitbuf->bitindex += number_of_bits; - - bitbuf->wordpointer += (bitbuf->bitindex>>3); - bitbuf->bitindex &= 7; - -#ifdef DEBUG_GETBITS -fprintf(stderr,":%x ",rval); -#endif - return rval; -} - -unsigned int mpgdec_get1bit(struct bitstream_info *bitbuf) -{ - unsigned char rval; - -#ifdef DEBUG_GETBITS -fprintf(stderr,"g%d",1); -#endif - -#if 0 - check_buffer_range(1+bitbuf->bitindex); -#endif - - rval = *(bitbuf->wordpointer) << bitbuf->bitindex; - - bitbuf->bitindex++; - bitbuf->wordpointer += (bitbuf->bitindex>>3); - bitbuf->bitindex &= 7; - -#ifdef DEBUG_GETBITS -fprintf(stderr,":%d ",rval>>7); -#endif - - return rval>>7; -} -
--- a/src/mpg123/getbits.h Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ - -/* that's the same file as getits.c but with defines to - force inlining */ - -unsigned long rval; -unsigned char rval_uc; - -#define mpgdec_backbits(bitbuf,nob) ((void)( \ - (*(bitbuf)).bitindex -= (nob), \ - (*(bitbuf)).wordpointer += ((*(bitbuf)).bitindex>>3), \ - (*(bitbuf)).bitindex &= 0x7 )) - -#define mpgdec_getbitoffset(bitbuf) ((-(*(bitbuf)).bitindex)&0x7) -#define mpgdec_getbyte(bitbuf) (*(*(bitbuf)).wordpointer++) - -#define mpgdec_getbits(bitbuf,nob) ( \ - rval = (*(bitbuf)).wordpointer[0], rval <<= 8, rval |= (*(bitbuf)).wordpointer[1], \ - rval <<= 8, rval |= (*(bitbuf)).wordpointer[2], rval <<= (*(bitbuf)).bitindex, \ - rval &= 0xffffff, (*(bitbuf)).bitindex += (nob), \ - rval >>= (24-(nob)), (*(bitbuf)).wordpointer += ((*(bitbuf)).bitindex>>3), \ - (*(bitbuf)).bitindex &= 7,rval) - -#define mpgdec_getbits_fast(bitbuf,nob) ( \ - rval = (unsigned char) ((*(bitbuf)).wordpointer[0] << (*(bitbuf)).bitindex), \ - rval |= ((unsigned long) (*(bitbuf)).wordpointer[1]<<(*(bitbuf)).bitindex)>>8, \ - rval <<= (nob), rval >>= 8, \ - (*(bitbuf)).bitindex += (nob), (*(bitbuf)).wordpointer += ((*(bitbuf)).bitindex>>3), \ - (*(bitbuf)).bitindex &= 7, rval ) - -#define mpgdec_get1bit(bitbuf) ( \ - rval_uc = *(*(bitbuf)).wordpointer << (*(bitbuf)).bitindex, (*(bitbuf)).bitindex++, \ - (*(bitbuf)).wordpointer += ((*(bitbuf)).bitindex>>3), (*(bitbuf)).bitindex &= 7, rval_uc>>7 ) -
--- a/src/mpg123/huffman.h Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,313 +0,0 @@ - -/* - * huffman tables ... recalcualted to work with my optimzed - * decoder scheme (MH) - * - * probably we could save a few bytes of memory, because the - * smaller tables are often the part of a bigger table - */ - -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} -};
--- a/src/mpg123/interface.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * libmpgdec: An advanced MPEG 1/2/3 decoder engine. - * interface.c: library interfaces - * - * Copyright (c) 2005-2006 William Pitcock <nenolod@nenolod.net> - * Portions copyright (C) 1999 Michael Hipp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "common.h" - -static const long outscale = 32768; - -mpgdec_t *global_ins; - -mpgdec_t *mpgdec_new(void) -{ - mpgdec_t *ins = g_malloc0(sizeof(mpgdec_t)); - - /* yeah i know this is cheating */ - global_ins = ins; - - mpgdec_make_decode_tables(outscale); - psycho_init(); - - return ins; -}
--- a/src/mpg123/l2tables.h Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,997 +0,0 @@ -/* - * Layer 2 Alloc tables .. - * most other tables are calculated on program start (which is (of course) - * not ISO-conform) .. - * Layer-3 huffman table is in huffman.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} -};
--- a/src/mpg123/layer1.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/* - * Mpeg Layer-1 audio decoder - * -------------------------- - * copyright (c) 1995 by Michael Hipp, All rights reserved. See also 'README' - * near unoptimzed ... - * - * may have a few bugs after last optimization ... - * - */ - -#include "audacious/output.h" -#include "mpg123.h" -#include "getbits.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) { - int i; - int jsbound = fr->jsbound; - for (i=0;i<jsbound;i++) { - *ba++ = mpgdec_getbits(&bsi,4); - *ba++ = mpgdec_getbits(&bsi,4); - } - for (i=jsbound;i<SBLIMIT;i++) - *ba++ = mpgdec_getbits(&bsi,4); - - ba = balloc; - - for (i=0;i<jsbound;i++) { - if ((*ba++)) - *sca++ = mpgdec_getbits(&bsi,6); - if ((*ba++)) - *sca++ = mpgdec_getbits(&bsi,6); - } - for (i=jsbound;i<SBLIMIT;i++) - if ((*ba++)) { - *sca++ = mpgdec_getbits(&bsi,6); - *sca++ = mpgdec_getbits(&bsi,6); - } - } - else { - int i; - for (i=0;i<SBLIMIT;i++) - *ba++ = mpgdec_getbits(&bsi,4); - ba = balloc; - for (i=0;i<SBLIMIT;i++) - if ((*ba++)) - *sca++ = mpgdec_getbits(&bsi,6); - } -} - -void I_step_two(mpgdec_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) { - int jsbound = fr->jsbound; - register mpgdec_real *f0 = fraction[0]; - register mpgdec_real *f1 = fraction[1]; - ba = balloc; - for (sample=smpb,i=0;i<jsbound;i++) { - if ((n = *ba++)) - *sample++ = mpgdec_getbits(&bsi,n+1); - if ((n = *ba++)) - *sample++ = mpgdec_getbits(&bsi,n+1); - } - for (i=jsbound;i<SBLIMIT;i++) - if ((n = *ba++)) - *sample++ = mpgdec_getbits(&bsi,n+1); - - ba = balloc; - for (sample=smpb,i=0;i<jsbound;i++) { - if((n=*ba++)) - *f0++ = (mpgdec_real) ( ((-1)<<n) + (*sample++) + 1) * mpgdec_muls[n+1][*sca++]; - else - *f0++ = 0.0; - if((n=*ba++)) - *f1++ = (mpgdec_real) ( ((-1)<<n) + (*sample++) + 1) * mpgdec_muls[n+1][*sca++]; - else - *f1++ = 0.0; - } - for (i=jsbound;i<SBLIMIT;i++) { - if ((n=*ba++)) { - mpgdec_real samp = ( ((-1)<<n) + (*sample++) + 1); - *f0++ = samp * mpgdec_muls[n+1][*sca++]; - *f1++ = samp * mpgdec_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 mpgdec_real *f0 = fraction[0]; - ba = balloc; - for (sample=smpb,i=0;i<SBLIMIT;i++) - if ((n = *ba++)) - *sample++ = mpgdec_getbits(&bsi,n+1); - ba = balloc; - for (sample=smpb,i=0;i<SBLIMIT;i++) { - if((n=*ba++)) - *f0++ = (mpgdec_real) ( ((-1)<<n) + (*sample++) + 1) * mpgdec_muls[n+1][*sca++]; - else - *f0++ = 0.0; - } - for(i=fr->down_sample_sblimit;i<32;i++) - fraction[0][i] = 0.0; - } -} - -int -mpgdec_do_layer1(InputPlayback *playback, struct frame *fr) -{ - int i, stereo = fr->stereo; - unsigned int balloc[2 * SBLIMIT]; - unsigned int scale_index[2][SBLIMIT]; - mpgdec_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) { - (fr->synth_mono) ((mpgdec_real *) fraction[single], mpgdec_pcm_sample, - &mpgdec_pcm_point); - } - else { - int p1 = mpgdec_pcm_point; - - (fr->synth) ((mpgdec_real *) fraction[0], 0, mpgdec_pcm_sample, &p1); - (fr->synth) ((mpgdec_real *) fraction[1], 1, mpgdec_pcm_sample, - &mpgdec_pcm_point); - } -#ifdef PSYCHO - psycho_process(mpgdec_pcm_sample, mpgdec_pcm_point, mpgdec_cfg.channels == 2 ? fr->stereo : 1); -#endif - if (mpgdec_info->output_audio && mpgdec_info->jump_to_time == -1) { - produce_audio(playback->output->written_time(), - mpgdec_cfg.resolution == - 16 ? FMT_S16_NE : FMT_U8, - mpgdec_cfg.channels == - 2 ? fr->stereo : 1, mpgdec_pcm_point, - mpgdec_pcm_sample, &playback->playing); - } - - mpgdec_pcm_point = 0; - } - - return 1; -}
--- a/src/mpg123/layer2.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,346 +0,0 @@ -/* - * Mpeg Layer-2 audio decoder - * -------------------------- - * copyright (c) 1995 by Michael Hipp, All rights reserved. See also 'README' - * - */ - -#include "mpg123.h" -#include "audacious/output.h" -#include "l2tables.h" -#include "getbits.h" - -#include <math.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 */ - -mpgdec_real mpgdec_muls[27][64]; /* also used by layer 1 */ - -void -mpgdec_init_layer2 (gboolean mmx) -{ - 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; - mpgdec_real *table; - static int tablen[3] = { 3, 5, 9 }; - static int *itable, *tables[3] = { grp_3tab, grp_5tab, grp_9tab }; - - for (i = 0; i < 3; i++) - { - itable = tables[i]; - len = tablen[i]; - for (j = 0; j < len; j++) - for (k = 0; k < len; k++) - for (l = 0; l < len; l++) - { - *itable++ = base[i][l]; - *itable++ = base[i][k]; - *itable++ = base[i][j]; - } - } - - for (k = 0; k < 27; k++) - { - double m = mulmul[k]; - table = mpgdec_muls[k]; - for (j = 3, i = 0; i < 63; i++, j--) - *table++ = m * pow (2.0, (double) j / 3.0); - *table++ = 0.0; - } -} - -void -II_step_one (unsigned int *bit_alloc, int *scale, struct frame *fr) -{ - int stereo = fr->stereo - 1; - int sblimit = fr->II_sblimit; - int jsbound = fr->jsbound; - int sblimit2 = fr->II_sblimit << stereo; - struct al_table *alloc1 = fr->alloc; - int i; - static unsigned int scfsi_buf[64]; - unsigned int *scfsi, *bita; - int sc, step; - - bita = bit_alloc; - if (stereo) - { - for (i = jsbound; i > 0; i--, alloc1 += (1 << step)) - { - *bita++ = (char) mpgdec_getbits (&bsi, step = alloc1->bits); - *bita++ = (char) mpgdec_getbits (&bsi, step); - } - for (i = sblimit - jsbound; i > 0; i--, alloc1 += (1 << step)) - { - bita[0] = (char) mpgdec_getbits (&bsi, step = alloc1->bits); - bita[1] = bita[0]; - bita += 2; - } - bita = bit_alloc; - scfsi = scfsi_buf; - for (i = sblimit2; i; i--) - if (*bita++) - *scfsi++ = (char) mpgdec_getbits_fast (&bsi, 2); - } - else - /* mono */ - { - for (i = sblimit; i; i--, alloc1 += (1 << step)) - *bita++ = (char) mpgdec_getbits (&bsi, step = alloc1->bits); - bita = bit_alloc; - scfsi = scfsi_buf; - for (i = sblimit; i; i--) - if (*bita++) - *scfsi++ = (char) mpgdec_getbits_fast (&bsi, 2); - } - - bita = bit_alloc; - scfsi = scfsi_buf; - for (i = sblimit2; i; i--) - if (*bita++) - switch (*scfsi++) - { - case 0: - *scale++ = mpgdec_getbits_fast (&bsi, 6); - *scale++ = mpgdec_getbits_fast (&bsi, 6); - *scale++ = mpgdec_getbits_fast (&bsi, 6); - break; - case 1: - *scale++ = sc = mpgdec_getbits_fast (&bsi, 6); - *scale++ = sc; - *scale++ = mpgdec_getbits_fast (&bsi, 6); - break; - case 2: - *scale++ = sc = mpgdec_getbits_fast (&bsi, 6); - *scale++ = sc; - *scale++ = sc; - break; - default: /* case 3 */ - *scale++ = mpgdec_getbits_fast (&bsi, 6); - *scale++ = sc = mpgdec_getbits_fast (&bsi, 6); - *scale++ = sc; - break; - } - -} - -void -II_step_two (unsigned int *bit_alloc, mpgdec_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) - { - mpgdec_real cm = mpgdec_muls[k][scale[x1]]; - - fraction[j][0][i] = - ((mpgdec_real) ((int) mpgdec_getbits (&bsi, k) + d1)) * cm; - fraction[j][1][i] = - ((mpgdec_real) ((int) mpgdec_getbits (&bsi, k) + d1)) * cm; - fraction[j][2][i] = - ((mpgdec_real) ((int) mpgdec_getbits (&bsi, 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) mpgdec_getbits (&bsi, k); - tab = (unsigned int *) (table[d1] + idx + idx + idx); - fraction[j][0][i] = mpgdec_muls[*tab++][m]; - fraction[j][1][i] = mpgdec_muls[*tab++][m]; - fraction[j][2][i] = mpgdec_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) - { - mpgdec_real cm; - - cm = mpgdec_muls[k][scale[x1 + 3]]; - fraction[1][0][i] = (fraction[0][0][i] = - (mpgdec_real) ((int) mpgdec_getbits (&bsi, k) + - d1)) * cm; - fraction[1][1][i] = (fraction[0][1][i] = - (mpgdec_real) ((int) mpgdec_getbits (&bsi, k) + - d1)) * cm; - fraction[1][2][i] = (fraction[0][2][i] = - (mpgdec_real) ((int) mpgdec_getbits (&bsi, k) + - d1)) * cm; - cm = mpgdec_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) mpgdec_getbits (&bsi, k); - tab = (unsigned int *) (table[d1] + idx + idx + idx); - fraction[0][0][i] = mpgdec_muls[*tab][m1]; - fraction[1][0][i] = mpgdec_muls[*tab++][m2]; - fraction[0][1][i] = mpgdec_muls[*tab][m1]; - fraction[1][1][i] = mpgdec_muls[*tab++][m2]; - fraction[0][2][i] = mpgdec_muls[*tab][m1]; - fraction[1][2][i] = mpgdec_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->lsf) - 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 -mpgdec_do_layer2 (InputPlayback *playback, struct frame *fr) -{ - int i, j; - int stereo = fr->stereo; - mpgdec_real fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */ - unsigned int bit_alloc[64]; - int scale[192]; - int single = fr->single; - - II_select_table (fr); - fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? - (fr->mode_ext << 2) + 4 : fr->II_sblimit; - if (fr->jsbound > fr->II_sblimit) - fr->jsbound = fr->II_sblimit; - - if (stereo == 1 || single == 3) - single = 0; - - II_step_one (bit_alloc, scale, fr); - - for (i = 0; i < SCALE_BLOCK; i++) - { - II_step_two (bit_alloc, fraction, scale, fr, i >> 2); - for (j = 0; j < 3; j++) - { - if (single >= 0) - { - (fr->synth_mono) (fraction[single][j], mpgdec_pcm_sample, - &mpgdec_pcm_point); - } - else - { - int p1 = mpgdec_pcm_point; - - (fr->synth) (fraction[0][j], 0, mpgdec_pcm_sample, &p1); - (fr->synth) (fraction[1][j], 1, mpgdec_pcm_sample, - &mpgdec_pcm_point); - } - - /* if(mpgdec_pcm_point >= audiobufsize) - audio_flush(outmode,ai); */ - } - } -#ifdef PSYCHO - psycho_process(mpgdec_pcm_sample, mpgdec_pcm_point, mpgdec_cfg.channels == 2 ? fr->stereo : 1); -#endif - if (mpgdec_info->output_audio) - { - produce_audio (playback->output->written_time (), - mpgdec_cfg.resolution == 16 ? FMT_S16_NE : FMT_U8, - mpgdec_cfg.channels == 2 ? fr->stereo : 1, - mpgdec_pcm_point, mpgdec_pcm_sample, &mpgdec_pcm_point); - } - mpgdec_pcm_point = 0; - - return 1; -}
--- a/src/mpg123/layer3.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1863 +0,0 @@ -/* - * Mpeg Layer-3 audio decoder - * -------------------------- - * copyright (c) 1995-1999 by Michael Hipp. - * All rights reserved. See also 'README' - * - * Optimize-TODO: put short bands into the band-field without the stride - * of 3 reals - * Length-optimze: unify long and short band code where it is possible - */ - -#if 0 -#define L3_DEBUG 1 -#endif - -#if 0 -#define CUT_HF -#endif - -#include <stdlib.h> -#include <math.h> -#include <glib.h> -#include "audacious/output.h" -#include "mpg123.h" -#include "huffman.h" - -#include "common.h" - -#include "getbits.h" - -static mpgdec_real ispow[8207]; -static mpgdec_real aa_ca[8],aa_cs[8]; -static mpgdec_real COS1[12][6]; -static mpgdec_real win[4][36]; -static mpgdec_real win1[4][36]; -static mpgdec_real gainpow2[256+118+4]; - -/* non static for external 3dnow functions */ -mpgdec_real COS9[9]; -static mpgdec_real COS6_1,COS6_2; -mpgdec_real tfcos36[9]; - -static mpgdec_real tfcos12[3]; - -#ifndef INTEGER_COMPILE -# define NEW_DCT9 -#else -# undef NEW_DCT9 -#endif - -#ifdef NEW_DCT9 -static mpgdec_real cos9[3],cos18[3]; -#endif - -struct bandInfoStruct { - int longIdx[23]; - int longDiff[22]; - int shortIdx[14]; - int shortDiff[13]; -}; - -int longLimit[9][23]; -int shortLimit[9][14]; - -struct bandInfoStruct bandInfo[9] = { - -/* MPEG 1.0 */ - { {0,4,8,12,16,20,24,30,36,44,52,62,74, 90,110,134,162,196,238,288,342,418,576}, - {4,4,4,4,4,4,6,6,8, 8,10,12,16,20,24,28,34,42,50,54, 76,158}, - {0,4*3,8*3,12*3,16*3,22*3,30*3,40*3,52*3,66*3, 84*3,106*3,136*3,192*3}, - {4,4,4,4,6,8,10,12,14,18,22,30,56} } , - - { {0,4,8,12,16,20,24,30,36,42,50,60,72, 88,106,128,156,190,230,276,330,384,576}, - {4,4,4,4,4,4,6,6,6, 8,10,12,16,18,22,28,34,40,46,54, 54,192}, - {0,4*3,8*3,12*3,16*3,22*3,28*3,38*3,50*3,64*3, 80*3,100*3,126*3,192*3}, - {4,4,4,4,6,6,10,12,14,16,20,26,66} } , - - { {0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576} , - {4,4,4,4,4,4,6,6,8,10,12,16,20,24,30,38,46,56,68,84,102, 26} , - {0,4*3,8*3,12*3,16*3,22*3,30*3,42*3,58*3,78*3,104*3,138*3,180*3,192*3} , - {4,4,4,4,6,8,12,16,20,26,34,42,12} } , - -/* MPEG 2.0 */ - { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576}, - {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54 } , - {0,4*3,8*3,12*3,18*3,24*3,32*3,42*3,56*3,74*3,100*3,132*3,174*3,192*3} , - {4,4,4,6,6,8,10,14,18,26,32,42,18 } } , -/* changed 19th value fropm 330 to 332 */ - { {0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,330,394,464,540,576}, - {6,6,6,6,6,6,8,10,12,14,16,18,22,26,32,38,46,54,60,74,76,36 } , - {0,4*3,8*3,12*3,18*3,26*3,36*3,48*3,62*3,80*3,104*3,136*3,180*3,192*3} , - {4,4,4,6,8,10,12,14,18,24,32,44,12 } } , - - { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576}, - {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54 }, - {0,4*3,8*3,12*3,18*3,26*3,36*3,48*3,62*3,80*3,104*3,134*3,174*3,192*3}, - {4,4,4,6,8,10,12,14,18,24,30,40,18 } } , -/* MPEG 2.5 */ - { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576} , - {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54}, - {0,12,24,36,54,78,108,144,186,240,312,402,522,576}, - {4,4,4,6,8,10,12,14,18,24,30,40,18} }, - { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576} , - {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54}, - {0,12,24,36,54,78,108,144,186,240,312,402,522,576}, - {4,4,4,6,8,10,12,14,18,24,30,40,18} }, - { {0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576}, - {12,12,12,12,12,12,16,20,24,28,32,40,48,56,64,76,90,2,2,2,2,2}, - {0, 24, 48, 72,108,156,216,288,372,480,486,492,498,576}, - {8,8,8,12,16,20,24,28,36,2,2,2,26} } , -}; - -static int mapbuf0[9][152]; -static int mapbuf1[9][156]; -static int mapbuf2[9][44]; -static int *map[9][3]; -static int *mapend[9][3]; - -static unsigned int n_slen2[512]; /* MPEG 2.0 slen for 'normal' mode */ -static unsigned int i_slen2[256]; /* MPEG 2.0 slen for intensity stereo */ - -static mpgdec_real tan1_1[16],tan2_1[16],tan1_2[16],tan2_2[16]; -static mpgdec_real pow1_1[2][16],pow2_1[2][16],pow1_2[2][16],pow2_2[2][16]; - -void -mpgdec_init_layer3(int down_sample_sblimit) -{ - int i, j, k, l; - - for (i = -256; i < 118 + 4; i++) - gainpow2[i + 256] = pow((double) 2.0, -0.25 * (double) (i + 210)); - for (i = 0; i < 8207; i++) - ispow[i] = pow((double) i, (double) 4.0 / 3.0); - - for (i = 0; i < 8; i++) { - static double Ci[8] = - { -0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, - -0.0037 - }; - double sq = sqrt(1.0 + Ci[i] * Ci[i]); - - aa_cs[i] = 1.0 / sq; - aa_ca[i] = Ci[i] / sq; - } - - for (i = 0; i < 18; i++) { - win[0][i] = win[1][i] = - 0.5 * sin(M_PI / 72.0 * (double) (2 * (i + 0) + 1)) / - cos(M_PI * (double) (2 * (i + 0) + 19) / 72.0); - win[0][i + 18] = win[3][i + 18] = - 0.5 * sin(M_PI / 72.0 * (double) (2 * (i + 18) + 1)) / - cos(M_PI * (double) (2 * (i + 18) + 19) / 72.0); - } - for (i = 0; i < 6; i++) { - win[1][i + 18] = - 0.5 / cos(M_PI * (double) (2 * (i + 18) + 19) / 72.0); - win[3][i + 12] = - 0.5 / cos(M_PI * (double) (2 * (i + 12) + 19) / 72.0); - win[1][i + 24] = - 0.5 * sin(M_PI / 24.0 * (double) (2 * i + 13)) / cos(M_PI * - (double) - (2 * - (i + - 24) + - 19) / 72.0); - win[1][i + 30] = win[3][i] = 0.0; - win[3][i + 6] = - 0.5 * sin(M_PI / 24.0 * (double) (2 * i + 1)) / cos(M_PI * - (double) (2 - * - (i - + - 6) - + - 19) - / 72.0); - } - - for (i = 0; i < 9; i++) - COS9[i] = cos(M_PI / 18.0 * (double) i); - - for (i = 0; i < 9; i++) - tfcos36[i] = 0.5 / cos(M_PI * (double) (i * 2 + 1) / 36.0); - for (i = 0; i < 3; i++) - tfcos12[i] = 0.5 / cos(M_PI * (double) (i * 2 + 1) / 12.0); - - COS6_1 = cos(M_PI / 6.0 * (double) 1); - COS6_2 = cos(M_PI / 6.0 * (double) 2); - -#ifdef NEW_DCT9 - cos9[0] = cos(1.0 * M_PI / 9.0); - cos9[1] = cos(5.0 * M_PI / 9.0); - cos9[2] = cos(7.0 * M_PI / 9.0); - cos18[0] = cos(1.0 * M_PI / 18.0); - cos18[1] = cos(11.0 * M_PI / 18.0); - cos18[2] = cos(13.0 * M_PI / 18.0); -#endif - - for (i = 0; i < 12; i++) { - win[2][i] = - 0.5 * sin(M_PI / 24.0 * (double) (2 * i + 1)) / cos(M_PI * - (double) (2 - * - i - + 7) - / 24.0); - for (j = 0; j < 6; j++) - COS1[i][j] = - cos(M_PI / 24.0 * (double) ((2 * i + 7) * (2 * j + 1))); - } - - for (j = 0; j < 4; j++) { - static int len[4] = { 36, 36, 12, 36 }; - - for (i = 0; i < len[j]; i += 2) - win1[j][i] = +win[j][i]; - for (i = 1; i < len[j]; i += 2) - win1[j][i] = -win[j][i]; - } - - for (i = 0; i < 16; i++) { - double t = tan((double) i * M_PI / 12.0); - - tan1_1[i] = t / (1.0 + t); - tan2_1[i] = 1.0 / (1.0 + t); - tan1_2[i] = M_SQRT2 * t / (1.0 + t); - tan2_2[i] = M_SQRT2 / (1.0 + t); - - for (j = 0; j < 2; j++) { - double base = pow(2.0, -0.25 * (j + 1.0)); - double p1 = 1.0, p2 = 1.0; - - if (i > 0) { - if (i & 1) - p1 = pow(base, (i + 1.0) * 0.5); - else - p2 = pow(base, i * 0.5); - } - pow1_1[j][i] = p1; - pow2_1[j][i] = p2; - pow1_2[j][i] = M_SQRT2 * p1; - pow2_2[j][i] = M_SQRT2 * p2; - } - } - - for (j = 0; j < 9; j++) { - struct bandInfoStruct *bi = &bandInfo[j]; - int *mp; - int cb, lwin; - int *bdf; - - mp = map[j][0] = mapbuf0[j]; - bdf = bi->longDiff; - for (i = 0, cb = 0; cb < 8; cb++, i += *bdf++) { - *mp++ = (*bdf) >> 1; - *mp++ = i; - *mp++ = 3; - *mp++ = cb; - } - bdf = bi->shortDiff + 3; - for (cb = 3; cb < 13; cb++) { - int l = (*bdf++) >> 1; - - for (lwin = 0; lwin < 3; lwin++) { - *mp++ = l; - *mp++ = i + lwin; - *mp++ = lwin; - *mp++ = cb; - } - i += 6 * l; - } - mapend[j][0] = mp; - - mp = map[j][1] = mapbuf1[j]; - bdf = bi->shortDiff + 0; - for (i = 0, cb = 0; cb < 13; cb++) { - int l = (*bdf++) >> 1; - - for (lwin = 0; lwin < 3; lwin++) { - *mp++ = l; - *mp++ = i + lwin; - *mp++ = lwin; - *mp++ = cb; - } - i += 6 * l; - } - mapend[j][1] = mp; - - mp = map[j][2] = mapbuf2[j]; - bdf = bi->longDiff; - for (cb = 0; cb < 22; cb++) { - *mp++ = (*bdf++) >> 1; - *mp++ = cb; - } - mapend[j][2] = mp; - - } - - for (j = 0; j < 9; j++) { - for (i = 0; i < 23; i++) { - longLimit[j][i] = (bandInfo[j].longIdx[i] - 1 + 8) / 18 + 1; - if (longLimit[j][i] > (down_sample_sblimit)) - longLimit[j][i] = down_sample_sblimit; - } - for (i = 0; i < 14; i++) { - shortLimit[j][i] = (bandInfo[j].shortIdx[i] - 1) / 18 + 1; - if (shortLimit[j][i] > (down_sample_sblimit)) - shortLimit[j][i] = down_sample_sblimit; - } - } - - for (i = 0; i < 5; i++) { - for (j = 0; j < 6; j++) { - for (k = 0; k < 6; k++) { - int n = k + j * 6 + i * 36; - - i_slen2[n] = i | (j << 3) | (k << 6) | (3 << 12); - } - } - } - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - for (k = 0; k < 4; k++) { - int n = k + j * 4 + i * 16; - - i_slen2[n + 180] = i | (j << 3) | (k << 6) | (4 << 12); - } - } - } - for (i = 0; i < 4; i++) { - for (j = 0; j < 3; j++) { - int n = j + i * 3; - - i_slen2[n + 244] = i | (j << 3) | (5 << 12); - n_slen2[n + 500] = i | (j << 3) | (2 << 12) | (1 << 15); - } - } - - for (i = 0; i < 5; i++) { - for (j = 0; j < 5; j++) { - for (k = 0; k < 4; k++) { - for (l = 0; l < 4; l++) { - int n = l + k * 4 + j * 16 + i * 80; - - n_slen2[n] = - i | (j << 3) | (k << 6) | (l << 9) | (0 << 12); - } - } - } - } - for (i = 0; i < 5; i++) { - for (j = 0; j < 5; j++) { - for (k = 0; k < 4; k++) { - int n = k + j * 4 + i * 20; - - n_slen2[n + 400] = i | (j << 3) | (k << 6) | (1 << 12); - } - } - } -} - -/* - * read additional side information (for MPEG 1 and MPEG 2) - */ -static int III_get_side_info(struct III_sideinfo *si,int stereo, - int ms_stereo,long sfreq,int single,int lsf) -{ - int ch, gr; - int powdiff = (single == 3) ? 4 : 0; - - static const int tabs[2][5] = { { 2,9,5,3,4 } , { 1,8,1,2,9 } }; - const int *tab = tabs[lsf]; - - si->main_data_begin = mpgdec_getbits(&bsi,tab[1]); - if (stereo == 1) - si->private_bits = mpgdec_getbits_fast(&bsi,tab[2]); - else - si->private_bits = mpgdec_getbits_fast(&bsi,tab[3]); - - if(!lsf) { - for (ch=0; ch<stereo; ch++) { - si->ch[ch].gr[0].scfsi = -1; - si->ch[ch].gr[1].scfsi = mpgdec_getbits_fast(&bsi,4); - } - } - - for (gr=0; gr<tab[0]; gr++) { - for (ch=0; ch<stereo; ch++) { - register struct gr_info_s *gr_info = &(si->ch[ch].gr[gr]); - - gr_info->part2_3_length = mpgdec_getbits(&bsi,12); - gr_info->big_values = mpgdec_getbits(&bsi,9); - if(gr_info->big_values > 288) { - gr_info->big_values = 288; - } - gr_info->pow2gain = gainpow2+256 - mpgdec_getbits_fast(&bsi,8) + powdiff; - if(ms_stereo) - gr_info->pow2gain += 2; - gr_info->scalefac_compress = mpgdec_getbits(&bsi,tab[4]); - - if(mpgdec_get1bit(&bsi)) { /* window switch flag */ - int i; -#ifdef L3_DEBUG -if(2*gr_info->big_values > bandInfo[sfreq].shortIdx[12]) - fprintf(stderr,"L3: BigValues too large, doesn't make sense %d %d\n",2*gr_info->big_values,bandInfo[sfreq].shortIdx[12]); -#endif - - gr_info->block_type = mpgdec_getbits_fast(&bsi,2); - gr_info->mixed_block_flag = mpgdec_get1bit(&bsi); - gr_info->table_select[0] = mpgdec_getbits_fast(&bsi,5); - gr_info->table_select[1] = mpgdec_getbits_fast(&bsi,5); - /* - * table_select[2] not needed, because there is no region2, - * but to satisfy some verifications tools we set it either. - */ - gr_info->table_select[2] = 0; - for(i=0;i<3;i++) - gr_info->full_gain[i] = gr_info->pow2gain + (mpgdec_getbits_fast(&bsi,3)<<3); - - if(gr_info->block_type == 0) { - return 0; - } - - /* region_count/start parameters are implicit in this case. */ - if(!lsf || gr_info->block_type == 2) - gr_info->region1start = 36>>1; - else { -/* check this again for 2.5 and sfreq=8 */ - if(sfreq == 8) - gr_info->region1start = 108>>1; - else - gr_info->region1start = 54>>1; - } - gr_info->region2start = 576>>1; - } - else { - int i,r0c,r1c; -#ifdef L3_DEBUG -if(2*gr_info->big_values > bandInfo[sfreq].longIdx[21]) - fprintf(stderr,"L3: BigValues too large, doesn't make sense %d %d\n",2*gr_info->big_values,bandInfo[sfreq].longIdx[21]); -#endif - for (i=0; i<3; i++) - gr_info->table_select[i] = mpgdec_getbits_fast(&bsi,5); - r0c = mpgdec_getbits_fast(&bsi,4); - r1c = mpgdec_getbits_fast(&bsi,3); - gr_info->region1start = bandInfo[sfreq].longIdx[r0c+1] >> 1 ; - if(r0c + r1c + 2 > 22) - gr_info->region2start = 576>>1; - else - gr_info->region2start = bandInfo[sfreq].longIdx[r0c+1+r1c+1] >> 1; - gr_info->block_type = 0; - gr_info->mixed_block_flag = 0; - } - if(!lsf) - gr_info->preflag = mpgdec_get1bit(&bsi); - gr_info->scalefac_scale = mpgdec_get1bit(&bsi); - gr_info->count1table_select = mpgdec_get1bit(&bsi); - } - } - - return !0; -} - -/* - * read scalefactors - */ -static int III_get_scale_factors_1(int *scf,struct gr_info_s *gr_info) -{ - static const unsigned char slen[2][16] = { - {0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4}, - {0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3} - }; - int numbits; - int num0 = slen[0][gr_info->scalefac_compress]; - int num1 = slen[1][gr_info->scalefac_compress]; - - if (gr_info->block_type == 2) { - int i=18; - numbits = (num0 + num1) * 18; - - if (gr_info->mixed_block_flag) { - for (i=8;i;i--) - *scf++ = mpgdec_getbits_fast(&bsi,num0); - i = 9; - numbits -= num0; /* num0 * 17 + num1 * 18 */ - } - - for (;i;i--) - *scf++ = mpgdec_getbits_fast(&bsi,num0); - for (i = 18; i; i--) - *scf++ = mpgdec_getbits_fast(&bsi,num1); - *scf++ = 0; *scf++ = 0; *scf++ = 0; /* short[13][0..2] = 0 */ - } - else { - int i; - int scfsi = gr_info->scfsi; - - if(scfsi < 0) { /* scfsi < 0 => granule == 0 */ - for(i=11;i;i--) - *scf++ = mpgdec_getbits_fast(&bsi,num0); - for(i=10;i;i--) - *scf++ = mpgdec_getbits_fast(&bsi,num1); - numbits = (num0 + num1) * 10 + num0; - *scf++ = 0; - } - else { - numbits = 0; - if(!(scfsi & 0x8)) { - for (i=0;i<6;i++) - *scf++ = mpgdec_getbits_fast(&bsi,num0); - numbits += num0 * 6; - } - else { - scf += 6; - } - - if(!(scfsi & 0x4)) { - for (i=0;i<5;i++) - *scf++ = mpgdec_getbits_fast(&bsi,num0); - numbits += num0 * 5; - } - else { - scf += 5; - } - - if(!(scfsi & 0x2)) { - for(i=0;i<5;i++) - *scf++ = mpgdec_getbits_fast(&bsi,num1); - numbits += num1 * 5; - } - else { - scf += 5; - } - - if(!(scfsi & 0x1)) { - for (i=0;i<5;i++) - *scf++ = mpgdec_getbits_fast(&bsi,num1); - numbits += num1 * 5; - } - else { - scf += 5; - } - *scf++ = 0; /* no l[21] in original sources */ - } - } - return numbits; -} - -static int III_get_scale_factors_2(int *scf,struct gr_info_s *gr_info,int i_stereo) -{ - unsigned char *pnt; - int i,j,n=0,numbits=0; - unsigned int slen; - - static unsigned char stab[3][6][4] = { - { { 6, 5, 5,5 } , { 6, 5, 7,3 } , { 11,10,0,0} , - { 7, 7, 7,0 } , { 6, 6, 6,3 } , { 8, 8,5,0} } , - { { 9, 9, 9,9 } , { 9, 9,12,6 } , { 18,18,0,0} , - {12,12,12,0 } , {12, 9, 9,6 } , { 15,12,9,0} } , - { { 6, 9, 9,9 } , { 6, 9,12,6 } , { 15,18,0,0} , - { 6,15,12,0 } , { 6,12, 9,6 } , { 6,18,9,0} } }; - - if(i_stereo) /* i_stereo AND second channel -> do_layer3() checks this */ - slen = i_slen2[gr_info->scalefac_compress>>1]; - else - slen = n_slen2[gr_info->scalefac_compress]; - - gr_info->preflag = (slen>>15) & 0x1; - - n = 0; - if( gr_info->block_type == 2 ) { - n++; - if(gr_info->mixed_block_flag) - n++; - } - - pnt = stab[n][(slen>>12)&0x7]; - - for(i=0;i<4;i++) { - int num = slen & 0x7; - slen >>= 3; - if(num) { - for(j=0;j<(int)(pnt[i]);j++) - *scf++ = mpgdec_getbits_fast(&bsi,num); - numbits += pnt[i] * num; - } - else { - for(j=0;j<(int)(pnt[i]);j++) - *scf++ = 0; - } - } - - n = (n << 1) + 1; - for(i=0;i<n;i++) - *scf++ = 0; - - return numbits; -} - -static int pretab1[22] = {0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0}; -static int pretab2[22] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - -/* - * Dequantize samples (includes huffman decoding) - */ -/* 24 is enough because tab13 has max. a 19 bit huffvector */ -#define BITSHIFT ((sizeof(long)-1)*8) -#define REFRESH_MASK \ - while(num < BITSHIFT) { \ - mask |= ((unsigned long)mpgdec_getbyte(&bsi))<<(BITSHIFT-num); \ - num += 8; \ - part2remain -= 8; } - -static int III_dequantize_sample(mpgdec_real xr[SBLIMIT][SSLIMIT],int *scf, - struct gr_info_s *gr_info,int sfreq,int part2bits) -{ - int shift = 1 + gr_info->scalefac_scale; - mpgdec_real *xrpnt = (mpgdec_real *) xr; - int l[3],l3; - int part2remain = gr_info->part2_3_length - part2bits; - int *me; - - int num = mpgdec_getbitoffset(&bsi); - long mask; - /* we must split this, because for num==0 the shift is undefined if you do it in one step */ - mask = ((unsigned long) mpgdec_getbits(&bsi,num))<<BITSHIFT; - mask <<= 8-num; - part2remain -= num; - - { - int bv = gr_info->big_values; - int region1 = gr_info->region1start; - int region2 = gr_info->region2start; - - l3 = ((576>>1)-bv)>>1; -/* - * we may lose the 'odd' bit here !! - * check this later again - */ - if(bv <= region1) { - l[0] = bv; l[1] = l[2] = 0; - } - else { - l[0] = region1; - if(bv <= region2) { - l[1] = bv - l[0]; l[2] = 0; - } - else { - l[1] = region2 - l[0]; l[2] = bv - region2; - } - } - } - - if(gr_info->block_type == 2) { - /* - * decoding with short or mixed mode BandIndex table - */ - int i,max[4]; - int step=0,lwin=3,cb=0; - register mpgdec_real v = 0.0; - register int *m,mc; - - if(gr_info->mixed_block_flag) { - max[3] = -1; - max[0] = max[1] = max[2] = 2; - m = map[sfreq][0]; - me = mapend[sfreq][0]; - } - else { - max[0] = max[1] = max[2] = max[3] = -1; - /* max[3] not really needed in this case */ - m = map[sfreq][1]; - me = mapend[sfreq][1]; - } - - mc = 0; - for(i=0;i<2;i++) { - int lp = l[i]; - struct newhuff *h = ht+gr_info->table_select[i]; - for(;lp;lp--,mc--) { - register int x,y; - if( (!mc) ) { - mc = *m++; - xrpnt = ((mpgdec_real *) xr) + (*m++); - lwin = *m++; - cb = *m++; - if(lwin == 3) { - v = gr_info->pow2gain[(*scf++) << shift]; - step = 1; - } - else { - v = gr_info->full_gain[lwin][(*scf++) << shift]; - step = 3; - } - } - { - register short *val = h->table; - REFRESH_MASK; - while((y=*val++)<0) { - if (mask < 0) - val -= y; - num--; - mask <<= 1; - } - x = y >> 4; - y &= 0xf; - } - if(x == 15 && h->linbits) { - max[lwin] = cb; - REFRESH_MASK; - x += ((unsigned long) mask) >> (BITSHIFT+8-h->linbits); - num -= h->linbits+1; - mask <<= h->linbits; - if(mask < 0) - *xrpnt = REAL_MUL(-ispow[x], v); - else - *xrpnt = REAL_MUL(ispow[x], v); - mask <<= 1; - } - else if(x) { - max[lwin] = cb; - if(mask < 0) - *xrpnt = REAL_MUL(-ispow[x], v); - else - *xrpnt = REAL_MUL(ispow[x], v); - num--; - mask <<= 1; - } - else - *xrpnt = DOUBLE_TO_REAL(0.0); - xrpnt += step; - if(y == 15 && h->linbits) { - max[lwin] = cb; - REFRESH_MASK; - y += ((unsigned long) mask) >> (BITSHIFT+8-h->linbits); - num -= h->linbits+1; - mask <<= h->linbits; - if(mask < 0) - *xrpnt = REAL_MUL(-ispow[y], v); - else - *xrpnt = REAL_MUL(ispow[y], v); - mask <<= 1; - } - else if(y) { - max[lwin] = cb; - if(mask < 0) - *xrpnt = REAL_MUL(-ispow[y], v); - else - *xrpnt = REAL_MUL(ispow[y], v); - num--; - mask <<= 1; - } - else - *xrpnt = DOUBLE_TO_REAL(0.0); - xrpnt += step; - } - } - - for(;l3 && (part2remain+num > 0);l3--) { - struct newhuff *h = htc+gr_info->count1table_select; - register short *val = h->table,a; - - REFRESH_MASK; - while((a=*val++)<0) { - if (mask < 0) - val -= a; - num--; - mask <<= 1; - } - if(part2remain+num <= 0) { - num -= part2remain+num; - break; - } - - for(i=0;i<4;i++) { - if(!(i & 1)) { - if(!mc) { - mc = *m++; - xrpnt = ((mpgdec_real *) xr) + (*m++); - lwin = *m++; - cb = *m++; - if(lwin == 3) { - v = gr_info->pow2gain[(*scf++) << shift]; - step = 1; - } - else { - v = gr_info->full_gain[lwin][(*scf++) << shift]; - step = 3; - } - } - mc--; - } - if( (a & (0x8>>i)) ) { - max[lwin] = cb; - if(part2remain+num <= 0) { - break; - } - if(mask < 0) - *xrpnt = -v; - else - *xrpnt = v; - num--; - mask <<= 1; - } - else - *xrpnt = DOUBLE_TO_REAL(0.0); - xrpnt += step; - } - } - - if(lwin < 3) { /* short band? */ - while(1) { - for(;mc > 0;mc--) { - *xrpnt = DOUBLE_TO_REAL(0.0); xrpnt += 3; /* short band -> step=3 */ - *xrpnt = DOUBLE_TO_REAL(0.0); xrpnt += 3; - } - if(m >= me) - break; - mc = *m++; - xrpnt = ((mpgdec_real *) xr) + *m++; - if(*m++ == 0) - break; /* optimize: field will be set to zero at the end of the function */ - m++; /* cb */ - } - } - - gr_info->maxband[0] = max[0]+1; - gr_info->maxband[1] = max[1]+1; - gr_info->maxband[2] = max[2]+1; - gr_info->maxbandl = max[3]+1; - - { - int rmax = max[0] > max[1] ? max[0] : max[1]; - rmax = (rmax > max[2] ? rmax : max[2]) + 1; - gr_info->maxb = rmax ? shortLimit[sfreq][rmax] : longLimit[sfreq][max[3]+1]; - } - - } - else { - /* - * decoding with 'long' BandIndex table (block_type != 2) - */ - int *pretab = gr_info->preflag ? pretab1 : pretab2; - int i,max = -1; - int cb = 0; - int *m = map[sfreq][2]; - register mpgdec_real v = 0.0; - int mc = 0; - - /* - * long hash table values - */ - for(i=0;i<3;i++) { - int lp = l[i]; - struct newhuff *h = ht+gr_info->table_select[i]; - - for(;lp;lp--,mc--) { - int x,y; - - if(!mc) { - mc = *m++; - cb = *m++; -#ifdef CUT_HF - if(cb == 21) { - fprintf(stderr,"c"); - v = 0.0; - } - else -#endif - v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift]; - - } - { - register short *val = h->table; - REFRESH_MASK; - while((y=*val++)<0) { - if (mask < 0) - val -= y; - num--; - mask <<= 1; - } - x = y >> 4; - y &= 0xf; - } - - if (x == 15 && h->linbits) { - max = cb; - REFRESH_MASK; - x += ((unsigned long) mask) >> (BITSHIFT+8-h->linbits); - num -= h->linbits+1; - mask <<= h->linbits; - if(mask < 0) - *xrpnt++ = REAL_MUL(-ispow[x], v); - else - *xrpnt++ = REAL_MUL(ispow[x], v); - mask <<= 1; - } - else if(x) { - max = cb; - if(mask < 0) - *xrpnt++ = REAL_MUL(-ispow[x], v); - else - *xrpnt++ = REAL_MUL(ispow[x], v); - num--; - mask <<= 1; - } - else - *xrpnt++ = DOUBLE_TO_REAL(0.0); - - if (y == 15 && h->linbits) { - max = cb; - REFRESH_MASK; - y += ((unsigned long) mask) >> (BITSHIFT+8-h->linbits); - num -= h->linbits+1; - mask <<= h->linbits; - if(mask < 0) - *xrpnt++ = REAL_MUL(-ispow[y], v); - else - *xrpnt++ = REAL_MUL(ispow[y], v); - mask <<= 1; - } - else if(y) { - max = cb; - if(mask < 0) - *xrpnt++ = REAL_MUL(-ispow[y], v); - else - *xrpnt++ = REAL_MUL(ispow[y], v); - num--; - mask <<= 1; - } - else - *xrpnt++ = DOUBLE_TO_REAL(0.0); - } - } - - /* - * short (count1table) values - */ - for(;l3 && (part2remain+num > 0);l3--) { - struct newhuff *h = htc+gr_info->count1table_select; - register short *val = h->table,a; - - REFRESH_MASK; - while((a=*val++)<0) { - if (mask < 0) - val -= a; - num--; - mask <<= 1; - } - if(part2remain+num <= 0) { - num -= part2remain+num; - break; - } - - for(i=0;i<4;i++) { - if(!(i & 1)) { - if(!mc) { - mc = *m++; - cb = *m++; -#ifdef CUT_HF - if(cb == 21) { - fprintf(stderr,"c"); - v = 0.0; - } - else -#endif - v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift]; - } - mc--; - } - if ( (a & (0x8>>i)) ) { - max = cb; - if(part2remain+num <= 0) { - break; - } - if(mask < 0) - *xrpnt++ = -v; - else - *xrpnt++ = v; - num--; - mask <<= 1; - } - else - *xrpnt++ = DOUBLE_TO_REAL(0.0); - } - } - - gr_info->maxbandl = max+1; - gr_info->maxb = longLimit[sfreq][gr_info->maxbandl]; - } - - part2remain += num; - mpgdec_backbits(&bsi,num); - num = 0; - - while(xrpnt < &xr[SBLIMIT][0]) - *xrpnt++ = DOUBLE_TO_REAL(0.0); - - while( part2remain > 16 ) { - mpgdec_getbits(&bsi,16); /* Dismiss stuffing Bits */ - part2remain -= 16; - } - if(part2remain > 0) - mpgdec_getbits(&bsi,part2remain); -#if 0 - else if(part2remain < 0) { - g_warn("Can't rewind stream by %d bits!\n",-part2remain); - } -#endif - return 0; -} - -/* - * III_stereo: calculate mpgdec_real channel values for Joint-I-Stereo-mode - */ -static void III_i_stereo(mpgdec_real xr_buf[2][SBLIMIT][SSLIMIT],int *scalefac, - struct gr_info_s *gr_info,int sfreq,int ms_stereo,int lsf) -{ - mpgdec_real (*xr)[SBLIMIT*SSLIMIT] = (mpgdec_real (*)[SBLIMIT*SSLIMIT] ) xr_buf; - struct bandInfoStruct *bi = &bandInfo[sfreq]; - - const mpgdec_real *tab1,*tab2; - - int tab; - static const mpgdec_real *tabs[3][2][2] = { - { { tan1_1,tan2_1 } , { tan1_2,tan2_2 } }, - { { pow1_1[0],pow2_1[0] } , { pow1_2[0],pow2_2[0] } } , - { { pow1_1[1],pow2_1[1] } , { pow1_2[1],pow2_2[1] } } - }; - - tab = lsf + (gr_info->scalefac_compress & lsf); - tab1 = tabs[tab][ms_stereo][0]; - tab2 = tabs[tab][ms_stereo][1]; -#if 0 - if(lsf) { - int p = gr_info->scalefac_compress & 0x1; - if(ms_stereo) { - tab1 = pow1_2[p]; tab2 = pow2_2[p]; - } - else { - tab1 = pow1_1[p]; tab2 = pow2_1[p]; - } - } - else { - if(ms_stereo) { - tab1 = tan1_2; tab2 = tan2_2; - } - else { - tab1 = tan1_1; tab2 = tan2_1; - } - } -#endif - - if (gr_info->block_type == 2) { - int lwin,do_l = 0; - if( gr_info->mixed_block_flag ) - do_l = 1; - - for (lwin=0;lwin<3;lwin++) { /* process each window */ - /* get first band with zero values */ - int is_p,sb,idx,sfb = gr_info->maxband[lwin]; /* sfb is minimal 3 for mixed mode */ - if(sfb > 3) - do_l = 0; - - for(;sfb<12;sfb++) { - is_p = scalefac[sfb*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */ - if(is_p != 7) { - mpgdec_real t1,t2; - sb = bi->shortDiff[sfb]; - idx = bi->shortIdx[sfb] + lwin; - t1 = tab1[is_p]; t2 = tab2[is_p]; - for (; sb > 0; sb--,idx+=3) { - mpgdec_real v = xr[0][idx]; - xr[0][idx] = REAL_MUL(v, t1); - xr[1][idx] = REAL_MUL(v, t2); - } - } - } - - is_p = scalefac[12*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */ - sb = bi->shortDiff[13]; - idx = bi->shortIdx[13] + lwin; - - if(is_p != 7) { - mpgdec_real t1,t2; - t1 = tab1[is_p]; t2 = tab2[is_p]; - for ( ; sb > 0; sb--,idx+=3 ) { - mpgdec_real v = xr[0][idx]; - xr[0][idx] = REAL_MUL(v, t1); - xr[1][idx] = REAL_MUL(v, t2); - } - } - } /* end for(lwin; .. ; . ) */ - -/* also check l-part, if ALL bands in the three windows are 'empty' - * and mode = mixed_mode - */ - if (do_l) { - int sfb = gr_info->maxbandl; - int idx = bi->longIdx[sfb]; - - for ( ; sfb<8; sfb++ ) { - int sb = bi->longDiff[sfb]; - int is_p = scalefac[sfb]; /* scale: 0-15 */ - if(is_p != 7) { - mpgdec_real t1,t2; - t1 = tab1[is_p]; t2 = tab2[is_p]; - for ( ; sb > 0; sb--,idx++) { - mpgdec_real v = xr[0][idx]; - xr[0][idx] = REAL_MUL(v, t1); - xr[1][idx] = REAL_MUL(v, t2); - } - } - else - idx += sb; - } - } - } - else { /* ((gr_info->block_type != 2)) */ - int sfb = gr_info->maxbandl; - int is_p,idx = bi->longIdx[sfb]; - -/* hmm ... maybe the maxbandl stuff for i-stereo is buggy? */ - if(sfb <= 21) { - for ( ; sfb<21; sfb++) { - int sb = bi->longDiff[sfb]; - is_p = scalefac[sfb]; /* scale: 0-15 */ - if(is_p != 7) { - mpgdec_real t1,t2; - t1 = tab1[is_p]; t2 = tab2[is_p]; - for ( ; sb > 0; sb--,idx++) { - mpgdec_real v = xr[0][idx]; - xr[0][idx] = REAL_MUL(v, t1); - xr[1][idx] = REAL_MUL(v, t2); - } - } - else - idx += sb; - } - - is_p = scalefac[20]; - if(is_p != 7) { /* copy l-band 20 to l-band 21 */ - int sb; - mpgdec_real t1 = tab1[is_p],t2 = tab2[is_p]; - - for ( sb = bi->longDiff[21]; sb > 0; sb--,idx++ ) { - mpgdec_real v = xr[0][idx]; - xr[0][idx] = REAL_MUL(v, t1); - xr[1][idx] = REAL_MUL(v, t2); - } - } - } /* end: if(sfb <= 21) */ - } /* ... */ -} - -static void III_antialias(mpgdec_real xr[SBLIMIT][SSLIMIT],struct gr_info_s *gr_info) { - int sblim; - - if(gr_info->block_type == 2) { - if(!gr_info->mixed_block_flag) - return; - sblim = 1; - } - else { - sblim = gr_info->maxb-1; - } - - /* 31 alias-reduction operations between each pair of sub-bands */ - /* with 8 butterflies between each pair */ - - { - int sb; - mpgdec_real *xr1=(mpgdec_real *) xr[1]; - - for(sb=sblim;sb;sb--,xr1+=10) { - int ss; - mpgdec_real *cs=aa_cs,*ca=aa_ca; - mpgdec_real *xr2 = xr1; - - for(ss=7;ss>=0;ss--) - { /* upper and lower butterfly inputs */ - register mpgdec_real bu = *--xr2,bd = *xr1; - *xr2 = REAL_MUL(bu, *cs) - REAL_MUL(bd, *ca); - *xr1++ = REAL_MUL(bd, *cs++) + REAL_MUL(bu, *ca++); - } - } - } -} - -/* - This is an optimized DCT from Jeff Tsay's maplay 1.2+ package. - Saved one multiplication by doing the 'twiddle factor' stuff - together with the window mul. (MH) - - This uses Byeong Gi Lee's Fast Cosine Transform algorithm, but the - 9 point IDCT needs to be reduced further. Unfortunately, I don't - know how to do that, because 9 is not an even number. - Jeff. - - **************************************************************** - - 9 Point Inverse Discrete Cosine Transform - - This piece of code is Copyright 1997 Mikko Tommila and is freely usable - by anybody. The algorithm itself is of course in the public domain. - - Again derived heuristically from the 9-point WFTA. - - The algorithm is optimized (?) for speed, not for small rounding errors or - good readability. - - 36 additions, 11 multiplications - - Again this is very likely sub-optimal. - - The code is optimized to use a minimum number of temporary variables, - so it should compile quite well even on 8-register Intel x86 processors. - This makes the code quite obfuscated and very difficult to understand. - - References: - [1] S. Winograd: "On Computing the Discrete Fourier Transform", - Mathematics of Computation, Volume 32, Number 141, January 1978, - Pages 175-199 -*/ - -/*------------------------------------------------------------------*/ -/* */ -/* Function: Calculation of the inverse MDCT */ -/* */ -/*------------------------------------------------------------------*/ - -void dct36(mpgdec_real *inbuf,mpgdec_real *o1,mpgdec_real *o2,mpgdec_real *wintab,mpgdec_real *tsbuf) -{ -#ifdef NEW_DCT9 - mpgdec_real tmp[18]; -#endif - - { - register mpgdec_real *in = inbuf; - - in[17]+=in[16]; in[16]+=in[15]; in[15]+=in[14]; - in[14]+=in[13]; in[13]+=in[12]; in[12]+=in[11]; - in[11]+=in[10]; in[10]+=in[9]; in[9] +=in[8]; - in[8] +=in[7]; in[7] +=in[6]; in[6] +=in[5]; - in[5] +=in[4]; in[4] +=in[3]; in[3] +=in[2]; - in[2] +=in[1]; in[1] +=in[0]; - - in[17]+=in[15]; in[15]+=in[13]; in[13]+=in[11]; in[11]+=in[9]; - in[9] +=in[7]; in[7] +=in[5]; in[5] +=in[3]; in[3] +=in[1]; - - -#ifdef NEW_DCT9 -#if 1 - { - mpgdec_real t3; - { - mpgdec_real t0, t1, t2; - - t0 = REAL_MUL(COS6_2, (in[8] + in[16] - in[4])); - t1 = REAL_MUL(COS6_2, in[12]); - - t3 = in[0]; - t2 = t3 - t1 - t1; - tmp[1] = tmp[7] = t2 - t0; - tmp[4] = t2 + t0 + t0; - t3 += t1; - - t2 = REAL_MUL(COS6_1, (in[10] + in[14] - in[2])); - tmp[1] -= t2; - tmp[7] += t2; - } - { - mpgdec_real t0, t1, t2; - - t0 = REAL_MUL(cos9[0], (in[4] + in[8] )); - t1 = REAL_MUL(cos9[1], (in[8] - in[16])); - t2 = REAL_MUL(cos9[2], (in[4] + in[16])); - - tmp[2] = tmp[6] = t3 - t0 - t2; - tmp[0] = tmp[8] = t3 + t0 + t1; - tmp[3] = tmp[5] = t3 - t1 + t2; - } - } - { - mpgdec_real t1, t2, t3; - - t1 = REAL_MUL(cos18[0], (in[2] + in[10])); - t2 = REAL_MUL(cos18[1], (in[10] - in[14])); - t3 = REAL_MUL(COS6_1, in[6]); - - { - mpgdec_real t0 = t1 + t2 + t3; - tmp[0] += t0; - tmp[8] -= t0; - } - - t2 -= t3; - t1 -= t3; - - t3 = REAL_MUL(cos18[2], (in[2] + in[14])); - - t1 += t3; - tmp[3] += t1; - tmp[5] -= t1; - - t2 -= t3; - tmp[2] += t2; - tmp[6] -= t2; - } - -#else - { - mpgdec_real t0, t1, t2, t3, t4, t5, t6, t7; - - t1 = REAL_MUL(COS6_2, in[12]); - t2 = REAL_MUL(COS6_2, (in[8] + in[16] - in[4])); - - t3 = in[0] + t1; - t4 = in[0] - t1 - t1; - t5 = t4 - t2; - tmp[4] = t4 + t2 + t2; - - t0 = REAL_MUL(cos9[0], (in[4] + in[8])); - t1 = REAL_MUL(cos9[1], (in[8] - in[16])); - - t2 = REAL_MUL(cos9[2], (in[4] + in[16])); - - t6 = t3 - t0 - t2; - t0 += t3 + t1; - t3 += t2 - t1; - - t2 = REAL_MUL(cos18[0], (in[2] + in[10])); - t4 = REAL_MUL(cos18[1], (in[10] - in[14])); - t7 = REAL_MUL(COS6_1, in[6]); - - t1 = t2 + t4 + t7; - tmp[0] = t0 + t1; - tmp[8] = t0 - t1; - t1 = REAL_MUL(cos18[2], (in[2] + in[14])); - t2 += t1 - t7; - - tmp[3] = t3 + t2; - t0 = REAL_MUL(COS6_1, (in[10] + in[14] - in[2])); - tmp[5] = t3 - t2; - - t4 -= t1 + t7; - - tmp[1] = t5 - t0; - tmp[7] = t5 + t0; - tmp[2] = t6 + t4; - tmp[6] = t6 - t4; - } -#endif - - { - mpgdec_real t0, t1, t2, t3, t4, t5, t6, t7; - - t1 = REAL_MUL(COS6_2, in[13]); - t2 = REAL_MUL(COS6_2, (in[9] + in[17] - in[5])); - - t3 = in[1] + t1; - t4 = in[1] - t1 - t1; - t5 = t4 - t2; - - t0 = REAL_MUL(cos9[0], (in[5] + in[9])); - t1 = REAL_MUL(cos9[1], (in[9] - in[17])); - - tmp[13] = REAL_MUL((t4 + t2 + t2), tfcos36[17-13]); - t2 = REAL_MUL(cos9[2], (in[5] + in[17])); - - t6 = t3 - t0 - t2; - t0 += t3 + t1; - t3 += t2 - t1; - - t2 = REAL_MUL(cos18[0], (in[3] + in[11])); - t4 = REAL_MUL(cos18[1], (in[11] - in[15])); - t7 = REAL_MUL(COS6_1, in[7]); - - t1 = t2 + t4 + t7; - tmp[17] = REAL_MUL((t0 + t1), tfcos36[17-17]); - tmp[9] = REAL_MUL((t0 - t1), tfcos36[17-9]); - t1 = REAL_MUL(cos18[2], (in[3] + in[15])); - t2 += t1 - t7; - - tmp[14] = REAL_MUL((t3 + t2), tfcos36[17-14]); - t0 = REAL_MUL(COS6_1, (in[11] + in[15] - in[3])); - tmp[12] = REAL_MUL((t3 - t2), tfcos36[17-12]); - - t4 -= t1 + t7; - - tmp[16] = REAL_MUL((t5 - t0), tfcos36[17-16]); - tmp[10] = REAL_MUL((t5 + t0), tfcos36[17-10]); - tmp[15] = REAL_MUL((t6 + t4), tfcos36[17-15]); - tmp[11] = REAL_MUL((t6 - t4), tfcos36[17-11]); - } - -#define MACRO(v) { \ - mpgdec_real tmpval; \ - tmpval = tmp[(v)] + tmp[17-(v)]; \ - out2[9+(v)] = REAL_MUL(tmpval, w[27+(v)]); \ - out2[8-(v)] = REAL_MUL(tmpval, w[26-(v)]); \ - tmpval = tmp[(v)] - tmp[17-(v)]; \ - ts[SBLIMIT*(8-(v))] = out1[8-(v)] + REAL_MUL(tmpval, w[8-(v)]); \ - ts[SBLIMIT*(9+(v))] = out1[9+(v)] + REAL_MUL(tmpval, w[9+(v)]); } - -{ - register mpgdec_real *out2 = o2; - register mpgdec_real *w = wintab; - register mpgdec_real *out1 = o1; - register mpgdec_real *ts = tsbuf; - - MACRO(0); - MACRO(1); - MACRO(2); - MACRO(3); - MACRO(4); - MACRO(5); - MACRO(6); - MACRO(7); - MACRO(8); -} - -#else - - { - -#define MACRO0(v) { \ - mpgdec_real tmp; \ - out2[9+(v)] = REAL_MUL((tmp = sum0 + sum1), w[27+(v)]); \ - out2[8-(v)] = REAL_MUL(tmp, w[26-(v)]); } \ - sum0 -= sum1; \ - ts[SBLIMIT*(8-(v))] = out1[8-(v)] + REAL_MUL(sum0, w[8-(v)]); \ - ts[SBLIMIT*(9+(v))] = out1[9+(v)] + REAL_MUL(sum0, w[9+(v)]); -#define MACRO1(v) { \ - mpgdec_real sum0,sum1; \ - sum0 = tmp1a + tmp2a; \ - sum1 = REAL_MUL((tmp1b + tmp2b), tfcos36[(v)]); \ - MACRO0(v); } -#define MACRO2(v) { \ - mpgdec_real sum0,sum1; \ - sum0 = tmp2a - tmp1a; \ - sum1 = REAL_MUL((tmp2b - tmp1b), tfcos36[(v)]); \ - MACRO0(v); } - - register const mpgdec_real *c = COS9; - register mpgdec_real *out2 = o2; - register mpgdec_real *w = wintab; - register mpgdec_real *out1 = o1; - register mpgdec_real *ts = tsbuf; - - mpgdec_real ta33,ta66,tb33,tb66; - - ta33 = REAL_MUL(in[2*3+0], c[3]); - ta66 = REAL_MUL(in[2*6+0], c[6]); - tb33 = REAL_MUL(in[2*3+1], c[3]); - tb66 = REAL_MUL(in[2*6+1], c[6]); - - { - mpgdec_real tmp1a,tmp2a,tmp1b,tmp2b; - tmp1a = REAL_MUL(in[2*1+0], c[1]) + ta33 + REAL_MUL(in[2*5+0], c[5]) + REAL_MUL(in[2*7+0], c[7]); - tmp1b = REAL_MUL(in[2*1+1], c[1]) + tb33 + REAL_MUL(in[2*5+1], c[5]) + REAL_MUL(in[2*7+1], c[7]); - tmp2a = REAL_MUL(in[2*2+0], c[2]) + REAL_MUL(in[2*4+0], c[4]) + ta66 + REAL_MUL(in[2*8+0], c[8]); - tmp2b = REAL_MUL(in[2*2+1], c[2]) + REAL_MUL(in[2*4+1], c[4]) + tb66 + REAL_MUL(in[2*8+1], c[8]); - - MACRO1(0); - MACRO2(8); - } - - { - mpgdec_real tmp1a,tmp2a,tmp1b,tmp2b; - tmp1a = REAL_MUL(( in[2*1+0] - in[2*5+0] - in[2*7+0] ), c[3]); - tmp1b = REAL_MUL(( in[2*1+1] - in[2*5+1] - in[2*7+1] ), c[3]); - tmp2a = REAL_MUL(( in[2*2+0] - in[2*4+0] - in[2*8+0] ), c[6]) - in[2*6+0] + in[2*0+0]; - tmp2b = REAL_MUL(( in[2*2+1] - in[2*4+1] - in[2*8+1] ), c[6]) - in[2*6+1] + in[2*0+1]; - - MACRO1(1); - MACRO2(7); - } - - { - mpgdec_real tmp1a,tmp2a,tmp1b,tmp2b; - tmp1a = REAL_MUL(in[2*1+0], c[5]) - ta33 - REAL_MUL(in[2*5+0], c[7]) + REAL_MUL(in[2*7+0], c[1]); - tmp1b = REAL_MUL(in[2*1+1], c[5]) - tb33 - REAL_MUL(in[2*5+1], c[7]) + REAL_MUL(in[2*7+1], c[1]); - tmp2a = - REAL_MUL(in[2*2+0], c[8]) - REAL_MUL(in[2*4+0], c[2]) + ta66 + REAL_MUL(in[2*8+0], c[4]); - tmp2b = - REAL_MUL(in[2*2+1], c[8]) - REAL_MUL(in[2*4+1], c[2]) + tb66 + REAL_MUL(in[2*8+1], c[4]); - - MACRO1(2); - MACRO2(6); - } - - { - mpgdec_real tmp1a,tmp2a,tmp1b,tmp2b; - tmp1a = REAL_MUL(in[2*1+0], c[7]) - ta33 + REAL_MUL(in[2*5+0], c[1]) - REAL_MUL(in[2*7+0], c[5]); - tmp1b = REAL_MUL(in[2*1+1], c[7]) - tb33 + REAL_MUL(in[2*5+1], c[1]) - REAL_MUL(in[2*7+1], c[5]); - tmp2a = - REAL_MUL(in[2*2+0], c[4]) + REAL_MUL(in[2*4+0], c[8]) + ta66 - REAL_MUL(in[2*8+0], c[2]); - tmp2b = - REAL_MUL(in[2*2+1], c[4]) + REAL_MUL(in[2*4+1], c[8]) + tb66 - REAL_MUL(in[2*8+1], c[2]); - - MACRO1(3); - MACRO2(5); - } - - { - mpgdec_real sum0,sum1; - sum0 = in[2*0+0] - in[2*2+0] + in[2*4+0] - in[2*6+0] + in[2*8+0]; - sum1 = REAL_MUL((in[2*0+1] - in[2*2+1] + in[2*4+1] - in[2*6+1] + in[2*8+1] ), tfcos36[4]); - MACRO0(4); - } - } -#endif - - } -} - -/* - * new DCT12 - */ -static void dct12(mpgdec_real *in,mpgdec_real *rawout1,mpgdec_real *rawout2,register mpgdec_real *wi,register mpgdec_real *ts) -{ -#define DCT12_PART1 \ - in5 = in[5*3]; \ - in5 += (in4 = in[4*3]); \ - in4 += (in3 = in[3*3]); \ - in3 += (in2 = in[2*3]); \ - in2 += (in1 = in[1*3]); \ - in1 += (in0 = in[0*3]); \ - \ - in5 += in3; in3 += in1; \ - \ - in2 = REAL_MUL(in2, COS6_1); \ - in3 = REAL_MUL(in3, COS6_1); \ - -#define DCT12_PART2 \ - in0 += REAL_MUL(in4, COS6_2); \ - \ - in4 = in0 + in2; \ - in0 -= in2; \ - \ - in1 += REAL_MUL(in5, COS6_2); \ - \ - in5 = REAL_MUL((in1 + in3), tfcos12[0]); \ - in1 = REAL_MUL((in1 - in3), tfcos12[2]); \ - \ - in3 = in4 + in5; \ - in4 -= in5; \ - \ - in2 = in0 + in1; \ - in0 -= in1; - - - { - mpgdec_real in0,in1,in2,in3,in4,in5; - register mpgdec_real *out1 = rawout1; - ts[SBLIMIT*0] = out1[0]; ts[SBLIMIT*1] = out1[1]; ts[SBLIMIT*2] = out1[2]; - ts[SBLIMIT*3] = out1[3]; ts[SBLIMIT*4] = out1[4]; ts[SBLIMIT*5] = out1[5]; - - DCT12_PART1 - - { - mpgdec_real tmp0,tmp1 = (in0 - in4); - { - mpgdec_real tmp2 = REAL_MUL((in1 - in5), tfcos12[1]); - tmp0 = tmp1 + tmp2; - tmp1 -= tmp2; - } - ts[(17-1)*SBLIMIT] = out1[17-1] + REAL_MUL(tmp0, wi[11-1]); - ts[(12+1)*SBLIMIT] = out1[12+1] + REAL_MUL(tmp0, wi[6+1]); - ts[(6 +1)*SBLIMIT] = out1[6 +1] + REAL_MUL(tmp1, wi[1]); - ts[(11-1)*SBLIMIT] = out1[11-1] + REAL_MUL(tmp1, wi[5-1]); - } - - DCT12_PART2 - - ts[(17-0)*SBLIMIT] = out1[17-0] + REAL_MUL(in2, wi[11-0]); - ts[(12+0)*SBLIMIT] = out1[12+0] + REAL_MUL(in2, wi[6+0]); - ts[(12+2)*SBLIMIT] = out1[12+2] + REAL_MUL(in3, wi[6+2]); - ts[(17-2)*SBLIMIT] = out1[17-2] + REAL_MUL(in3, wi[11-2]); - - ts[(6 +0)*SBLIMIT] = out1[6+0] + REAL_MUL(in0, wi[0]); - ts[(11-0)*SBLIMIT] = out1[11-0] + REAL_MUL(in0, wi[5-0]); - ts[(6 +2)*SBLIMIT] = out1[6+2] + REAL_MUL(in4, wi[2]); - ts[(11-2)*SBLIMIT] = out1[11-2] + REAL_MUL(in4, wi[5-2]); - } - - in++; - - { - mpgdec_real in0,in1,in2,in3,in4,in5; - register mpgdec_real *out2 = rawout2; - - DCT12_PART1 - - { - mpgdec_real tmp0,tmp1 = (in0 - in4); - { - mpgdec_real tmp2 = REAL_MUL((in1 - in5), tfcos12[1]); - tmp0 = tmp1 + tmp2; - tmp1 -= tmp2; - } - out2[5-1] = REAL_MUL(tmp0, wi[11-1]); - out2[0+1] = REAL_MUL(tmp0, wi[6+1]); - ts[(12+1)*SBLIMIT] += REAL_MUL(tmp1, wi[1]); - ts[(17-1)*SBLIMIT] += REAL_MUL(tmp1, wi[5-1]); - } - - DCT12_PART2 - - out2[5-0] = REAL_MUL(in2, wi[11-0]); - out2[0+0] = REAL_MUL(in2, wi[6+0]); - out2[0+2] = REAL_MUL(in3, wi[6+2]); - out2[5-2] = REAL_MUL(in3, wi[11-2]); - - ts[(12+0)*SBLIMIT] += REAL_MUL(in0, wi[0]); - ts[(17-0)*SBLIMIT] += REAL_MUL(in0, wi[5-0]); - ts[(12+2)*SBLIMIT] += REAL_MUL(in4, wi[2]); - ts[(17-2)*SBLIMIT] += REAL_MUL(in4, wi[5-2]); - } - - in++; - - { - mpgdec_real in0,in1,in2,in3,in4,in5; - register mpgdec_real *out2 = rawout2; - out2[12]=out2[13]=out2[14]=out2[15]=out2[16]=out2[17]=0.0; - - DCT12_PART1 - - { - mpgdec_real tmp0,tmp1 = (in0 - in4); - { - mpgdec_real tmp2 = REAL_MUL((in1 - in5), tfcos12[1]); - tmp0 = tmp1 + tmp2; - tmp1 -= tmp2; - } - out2[11-1] = REAL_MUL(tmp0, wi[11-1]); - out2[6 +1] = REAL_MUL(tmp0, wi[6+1]); - out2[0+1] += REAL_MUL(tmp1, wi[1]); - out2[5-1] += REAL_MUL(tmp1, wi[5-1]); - } - - DCT12_PART2 - - out2[11-0] = REAL_MUL(in2, wi[11-0]); - out2[6 +0] = REAL_MUL(in2, wi[6+0]); - out2[6 +2] = REAL_MUL(in3, wi[6+2]); - out2[11-2] = REAL_MUL(in3, wi[11-2]); - - out2[0+0] += REAL_MUL(in0, wi[0]); - out2[5-0] += REAL_MUL(in0, wi[5-0]); - out2[0+2] += REAL_MUL(in4, wi[2]); - out2[5-2] += REAL_MUL(in4, wi[5-2]); - } -} - -/* - * III_hybrid - */ -static void -III_hybrid(mpgdec_real fsIn[SBLIMIT][SSLIMIT], - mpgdec_real tsOut[SSLIMIT][SBLIMIT], int ch, - struct gr_info_s *gr_info, struct frame *fr) -{ - static mpgdec_real block[2][2][SBLIMIT * SSLIMIT] = { {{0,}} }; - static int blc[2] = { 0, 0 }; - - mpgdec_real *tspnt = (mpgdec_real *) tsOut; - mpgdec_real *rawout1, *rawout2; - int bt, sb = 0; - - { - int b = blc[ch]; - rawout1 = block[b][ch]; - b = -b + 1; - rawout2 = block[b][ch]; - blc[ch] = b; - } - - if (gr_info->mixed_block_flag) { - sb = 2; - dct36(fsIn[0], rawout1, rawout2, win[0], tspnt); - dct36(fsIn[1], rawout1 + 18, rawout2 + 18, win1[0], tspnt + 1); - rawout1 += 36; - rawout2 += 36; - tspnt += 2; - } - - bt = gr_info->block_type; - if (bt == 2) { - for (; sb < gr_info->maxb; - sb += 2, tspnt += 2, rawout1 += 36, rawout2 += 36) { - dct12(fsIn[sb], rawout1, rawout2, win[2], tspnt); - dct12(fsIn[sb + 1], rawout1 + 18, rawout2 + 18, win1[2], - tspnt + 1); - } - } - else { - for (; sb < gr_info->maxb; - sb += 2, tspnt += 2, rawout1 += 36, rawout2 += 36) { - dct36(fsIn[sb], rawout1, rawout2, win[bt], tspnt); - dct36(fsIn[sb + 1], rawout1 + 18, rawout2 + 18, win1[bt], - tspnt + 1); - } - } - - for (; sb < SBLIMIT; sb++, tspnt++) { - int i; - for (i = 0; i < SSLIMIT; i++) { - tspnt[i * SBLIMIT] = *rawout1++; - *rawout2++ = 0.0; - } - } -} -int -mpgdec_do_layer3(InputPlayback *playback, struct frame *fr) -{ - int gr, ch, ss; - int scalefacs[2][39]; /* max 39 for short[13][3] mode, mixed: 38, long: 22 */ - struct III_sideinfo sideinfo; - int stereo = fr->stereo; - int single = fr->single; - int ms_stereo, i_stereo; - int sfreq = fr->sampling_frequency; - int stereo1, granules; - - if (stereo == 1) { /* stream is mono */ - stereo1 = 1; - single = 0; - } - else if (single >= 0) /* stream is stereo, but force to mono */ - stereo1 = 1; - else - stereo1 = 2; - - if (fr->mode == MPG_MD_JOINT_STEREO) { - ms_stereo = (fr->mode_ext & 0x2) >> 1; - i_stereo = fr->mode_ext & 0x1; - } - else - ms_stereo = i_stereo = 0; - - granules = fr->lsf ? 1 : 2; - if (!III_get_side_info - (&sideinfo, stereo, ms_stereo, sfreq, single, fr->lsf)) - return 0; - - mpgdec_set_pointer(sideinfo.main_data_begin); - - for (gr = 0; gr < granules; gr++) { - mpgdec_real hybridIn[2][SBLIMIT][SSLIMIT]; - mpgdec_real hybridOut[2][SSLIMIT][SBLIMIT]; - - { - struct gr_info_s *gr_info = &(sideinfo.ch[0].gr[gr]); - long part2bits; - - if (fr->lsf) - part2bits = III_get_scale_factors_2(scalefacs[0], gr_info, 0); - else - part2bits = III_get_scale_factors_1(scalefacs[0], gr_info); - - if (III_dequantize_sample - (hybridIn[0], scalefacs[0], gr_info, sfreq, part2bits)) - return 0; - } - - if (stereo == 2) { - struct gr_info_s *gr_info = &(sideinfo.ch[1].gr[gr]); - long part2bits; - - if (fr->lsf) - part2bits = - III_get_scale_factors_2(scalefacs[1], gr_info, i_stereo); - else - part2bits = III_get_scale_factors_1(scalefacs[1], gr_info); - - if (III_dequantize_sample - (hybridIn[1], scalefacs[1], gr_info, sfreq, part2bits)) - return 0; - - if (ms_stereo) { - unsigned int i, maxb = sideinfo.ch[0].gr[gr].maxb; - - if (sideinfo.ch[1].gr[gr].maxb > maxb) - maxb = sideinfo.ch[1].gr[gr].maxb; - for (i = 0; i < SSLIMIT * maxb; i++) { - mpgdec_real tmp0 = ((mpgdec_real *) hybridIn[0])[i]; - mpgdec_real tmp1 = ((mpgdec_real *) hybridIn[1])[i]; - ((mpgdec_real *) hybridIn[0])[i] = tmp0 + tmp1; - ((mpgdec_real *) hybridIn[1])[i] = tmp0 - tmp1; - } - } - - if (i_stereo) - III_i_stereo(hybridIn, scalefacs[1], gr_info, sfreq, - ms_stereo, fr->lsf); - - if (ms_stereo || i_stereo || (single == 3)) { - if (gr_info->maxb > sideinfo.ch[0].gr[gr].maxb) - sideinfo.ch[0].gr[gr].maxb = gr_info->maxb; - else - gr_info->maxb = sideinfo.ch[0].gr[gr].maxb; - } - - switch (single) { - case 3: - { - register unsigned int i; - register mpgdec_real *in0 = (mpgdec_real *) hybridIn[0], - *in1 = (mpgdec_real *) hybridIn[1]; - for (i = 0; i < SSLIMIT * gr_info->maxb; i++, in0++) - *in0 = (*in0 + *in1++); /* *0.5 done by pow-scale */ - } - break; - case 1: - { - register unsigned int i; - register mpgdec_real *in0 = (mpgdec_real *) hybridIn[0], - *in1 = (mpgdec_real *) hybridIn[1]; - for (i = 0; i < SSLIMIT * gr_info->maxb; i++) - *in0++ = *in1++; - } - break; - } - } - - for (ch = 0; ch < stereo1; ch++) { - struct gr_info_s *gr_info = &(sideinfo.ch[ch].gr[gr]); - - III_antialias(hybridIn[ch], gr_info); - if (gr_info->maxb < 1 || gr_info->maxb > SBLIMIT) - return 0; - III_hybrid(hybridIn[ch], hybridOut[ch], ch, gr_info, fr); - } - - for (ss = 0; ss < SSLIMIT; ss++) { - if (single >= 0) { - (fr->synth_mono) (hybridOut[0][ss], mpgdec_pcm_sample, - &mpgdec_pcm_point); - } - else { - int p1 = mpgdec_pcm_point; - - (fr->synth) (hybridOut[0][ss], 0, mpgdec_pcm_sample, &p1); - (fr->synth) (hybridOut[1][ss], 1, mpgdec_pcm_sample, - &mpgdec_pcm_point); - } - } - -#ifdef PSYCHO - psycho_process(mpgdec_pcm_sample, mpgdec_pcm_point, mpgdec_cfg.channels == 2 ? fr->stereo : 1); -#endif - - if (mpgdec_info->output_audio && mpgdec_info->jump_to_time == -1) { - produce_audio(playback->output->written_time(), - mpgdec_cfg.resolution == - 16 ? FMT_S16_NE : FMT_U8, - mpgdec_cfg.channels == - 2 ? fr->stereo : 1, mpgdec_pcm_point, - mpgdec_pcm_sample, &playback->playing); - } - - mpgdec_pcm_point = 0; - } - return 1; -}
--- a/src/mpg123/mp3.xpm Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,963 +0,0 @@ -/* XPM */ -static char * gnome_mime_audio_xpm[] = { -"48 52 908 2", -" c None", -". c #000000", -"+ c #010100", -"@ c #020201", -"# c #030201", -"$ c #232323", -"% c #1F1F1F", -"& c #DADADA", -"* c #FFFFFF", -"= c #F6F6F6", -"- c #CFCFCF", -"; c #707070", -"> c #FFFFFE", -", c #FEFEFE", -"' c #FBFBFB", -") c #EDEDED", -"! c #C0C0C0", -"~ c #FFFEFE", -"{ c #F8F5F2", -"] c #EBE7E1", -"^ c #ECEDE8", -"/ c #ECEFEA", -"( c #E6E9E4", -"_ c #CED0CE", -": c #BCBFBC", -"< c #F0F0EF", -"[ c #FEFEFD", -"} c #F7F7F7", -"| c #D7D7D7", -"1 c #F1F1F1", -"2 c #B7B7B7", -"3 c #EAEDEA", -"4 c #8EA299", -"5 c #697D70", -"6 c #546459", -"7 c #404D44", -"8 c #2C352F", -"9 c #4E5649", -"0 c #D6D8D3", -"a c #D2D2D2", -"b c #AEAEAE", -"c c #070707", -"d c #FCFCFB", -"e c #6D7C75", -"f c #5A5D4C", -"g c #6B735F", -"h c #6E7B63", -"i c #5B6052", -"j c #4A5042", -"k c #CED0CB", -"l c #FEFDFD", -"m c #FDFDFD", -"n c #B8B8B8", -"o c #DCDCDC", -"p c #A4A4A3", -"q c #0E0E0E", -"r c #8A928F", -"s c #6A7F68", -"t c #4D564E", -"u c #4E5950", -"v c #585E57", -"w c #333530", -"x c #9D9C9B", -"y c #FCFDFE", -"z c #FDFEFE", -"A c #FDFDFE", -"B c #F5F5F4", -"C c #B5B5B5", -"D c #F9F9F9", -"E c #FCFCFC", -"F c #CBCBCB", -"G c #A5A5A5", -"H c #CECDCB", -"I c #788976", -"J c #C6BDBB", -"K c #E2E2E2", -"L c #E2E0DF", -"M c #656A65", -"N c #4A4B49", -"O c #EAEDF1", -"P c #CED5DD", -"Q c #DBE0E9", -"R c #DDE1E9", -"S c #D3D7DD", -"T c #D9DCE1", -"U c #F4F4F4", -"V c #ACACAC", -"W c #ECECEC", -"X c #C3C3C3", -"Y c #C2C2C2", -"Z c #C9C9C8", -"` c #A8A8A8", -" . c #F6F8F6", -".. c #A7ADA5", -"+. c #6D7F71", -"@. c #ECECE9", -"#. c #FDFDFC", -"$. c #939C9A", -"%. c #1B2321", -"&. c #FCFBFA", -"*. c #F2F6F9", -"=. c #B4BFCC", -"-. c #7E8A9B", -";. c #515B6F", -">. c #50596A", -",. c #737D8D", -"'. c #BEC6CE", -"). c #C4CBD5", -"!. c #BFC5D1", -"~. c #F1F2F4", -"{. c #F4F4F3", -"]. c #ABABAB", -"^. c #515151", -"/. c #474747", -"(. c #464645", -"_. c #464646", -":. c #5D5D5C", -"<. c #A9A9A9", -"[. c #FAFAF9", -"}. c #EDEFF0", -"|. c #F1F5F5", -"1. c #636E62", -"2. c #636E5F", -"3. c #D4D5D3", -"4. c #FBF7F4", -"5. c #9BA595", -"6. c #657366", -"7. c #001514", -"8. c #FCFAF8", -"9. c #FDFCFC", -"0. c #FBF9F7", -"a. c #E3E6EA", -"b. c #9DACBF", -"c. c #515A6D", -"d. c #111828", -"e. c #131B29", -"f. c #0F1A2B", -"g. c #081125", -"h. c #0D1328", -"i. c #C2C9D1", -"j. c #C5CBD4", -"k. c #A6AEBB", -"l. c #F6F6F7", -"m. c #FAFAFA", -"n. c #F2F2F2", -"o. c #F3F3F3", -"p. c #AAAAAA", -"q. c #A0A09F", -"r. c #8A8A8A", -"s. c #7A7A7A", -"t. c #6C6C6C", -"u. c #454545", -"v. c #ABB3AF", -"w. c #A8B6A3", -"x. c #D0DBD0", -"y. c #F2F3F0", -"z. c #DEE1E0", -"A. c #66736A", -"B. c #354336", -"C. c #556254", -"D. c #C5C7C6", -"E. c #F2EDEA", -"F. c #CADAD9", -"G. c #9BA893", -"H. c #1B3128", -"I. c #FCF4EF", -"J. c #FDFBF9", -"K. c #DDDFE4", -"L. c #97A3B4", -"M. c #374152", -"N. c #0D131C", -"O. c #1C2026", -"P. c #262C3A", -"Q. c #242E43", -"R. c #202D41", -"S. c #172538", -"T. c #121523", -"U. c #BABCC3", -"V. c #9DA6B5", -"W. c #BABEC4", -"X. c #F8F8F7", -"Y. c #E7E7E7", -"Z. c #C6C6C5", -"`. c #BABAB9", -" + c #E7E9E9", -".+ c #63736C", -"++ c #464945", -"@+ c #5F7361", -"#+ c #CED4C3", -"$+ c #DBDEDA", -"%+ c #979999", -"&+ c #404342", -"*+ c #606E6B", -"=+ c #E5E5E3", -"-+ c #4B5F52", -";+ c #455845", -">+ c #2D362F", -",+ c #FCFAF9", -"'+ c #E4E4E7", -")+ c #97A8B9", -"!+ c #343C4A", -"~+ c #13181E", -"{+ c #1B2027", -"]+ c #1D232B", -"^+ c #1F2632", -"/+ c #212A3C", -"(+ c #242F45", -"_+ c #2A374D", -":+ c #121C2F", -"<+ c #525A67", -"[+ c #D9DDE5", -"}+ c #737C8C", -"|+ c #EAEBEB", -"1+ c #F7F7F6", -"2+ c #F6F6F5", -"3+ c #F5F5F5", -"4+ c #EDEDEB", -"5+ c #FBFBFA", -"6+ c #6C8175", -"7+ c #778673", -"8+ c #121613", -"9+ c #4C504A", -"0+ c #8FA695", -"a+ c #E2DCD8", -"b+ c #E5E6E7", -"c+ c #FBFAF9", -"d+ c #CAC6C1", -"e+ c #847F79", -"f+ c #FCFAFA", -"g+ c #ECE9E9", -"h+ c #A6B1C4", -"i+ c #232B37", -"j+ c #12171E", -"k+ c #191F27", -"l+ c #1D222B", -"m+ c #1E242B", -"n+ c #1E252F", -"o+ c #202937", -"p+ c #232F44", -"q+ c #283853", -"r+ c #253046", -"s+ c #0A1526", -"t+ c #D5D7DB", -"u+ c #727D90", -"v+ c #CFD0D2", -"w+ c #B1B1B1", -"x+ c #99A597", -"y+ c #7B9173", -"z+ c #65705D", -"A+ c #1F201B", -"B+ c #58655E", -"C+ c #F3F2F1", -"D+ c #AAB3C1", -"E+ c #525C6D", -"F+ c #0A0F17", -"G+ c #1C2129", -"H+ c #1E242A", -"I+ c #1E242C", -"J+ c #1F232D", -"K+ c #232E41", -"L+ c #2B3855", -"M+ c #2C3B57", -"N+ c #070D1F", -"O+ c #A3ABB6", -"P+ c #828EA0", -"Q+ c #B9BCC2", -"R+ c #F3F3F2", -"S+ c #F1EFEC", -"T+ c #72886D", -"U+ c #4E5849", -"V+ c #748268", -"W+ c #808080", -"X+ c #D6D9DE", -"Y+ c #5E6A7A", -"Z+ c #121621", -"`+ c #161D26", -" @ c #1D242C", -".@ c #1F242B", -"+@ c #1E2427", -"@@ c #212C3F", -"#@ c #283552", -"$@ c #2F405D", -"%@ c #0E162B", -"&@ c #59657B", -"*@ c #8A98AA", -"=@ c #AFB4BC", -"-@ c #F2F2F1", -";@ c #7D9074", -">@ c #494949", -",@ c #676D65", -"'@ c #C8CBC7", -")@ c #818B9B", -"!@ c #1B232F", -"~@ c #0F151F", -"{@ c #1B212B", -"]@ c #1E232D", -"^@ c #20252C", -"/@ c #24272C", -"(@ c #1F2429", -"_@ c #1C2228", -":@ c #1F2A3C", -"<@ c #1F2A40", -"[@ c #25344E", -"}@ c #314464", -"|@ c #15223A", -"1@ c #34445E", -"2@ c #939FB3", -"3@ c #ACB2BC", -"4@ c #F1F1F0", -"5@ c #ECEEEB", -"6@ c #B8BCB7", -"7@ c #647C65", -"8@ c #797E78", -"9@ c #C4C3C2", -"0@ c #919191", -"a@ c #DCE3EA", -"b@ c #242C3D", -"c@ c #0B101C", -"d@ c #1A212A", -"e@ c #1F242C", -"f@ c #21252C", -"g@ c #222629", -"h@ c #1C232A", -"i@ c #212B3D", -"j@ c #33415B", -"k@ c #27344B", -"l@ c #212F47", -"m@ c #374A68", -"n@ c #1A2840", -"o@ c #34445F", -"p@ c #96A3B5", -"q@ c #B3B7C0", -"r@ c #F2F2F0", -"s@ c #F0F0F0", -"t@ c #E2E7E2", -"u@ c #939E92", -"v@ c #50644E", -"w@ c #3D443E", -"x@ c #D4D2CF", -"y@ c #7F8898", -"z@ c #020A14", -"A@ c #171E28", -"B@ c #1C222A", -"C@ c #1E232B", -"D@ c #1F242D", -"E@ c #1F2228", -"F@ c #1D2328", -"G@ c #283449", -"H@ c #4A5C7B", -"I@ c #697D98", -"J@ c #4D5D79", -"K@ c #1F2D45", -"L@ c #394A6B", -"M@ c #1B2943", -"N@ c #425371", -"O@ c #95A3B5", -"P@ c #B8BDC2", -"Q@ c #EFEFEE", -"R@ c #EFEFED", -"S@ c #EDEEED", -"T@ c #EFF0F0", -"U@ c #F7FCF3", -"V@ c #313F30", -"W@ c #1C2120", -"X@ c #C9CBC9", -"Y@ c #F9F9F8", -"Z@ c #E9EEF2", -"`@ c #3C4352", -" # c #0C111D", -".# c #1E232E", -"+# c #1D212A", -"@# c #20242C", -"## c #1B1D20", -"$# c #263043", -"%# c #576886", -"&# c #8396B1", -"*# c #7A8FAD", -"=# c #677B99", -"-# c #28374F", -";# c #384A69", -"># c #182642", -",# c #5D708F", -"'# c #828FA3", -")# c #C5C7CB", -"!# c #F1F1EF", -"~# c #EEEEED", -"{# c #EEEEEC", -"]# c #9DA7A4", -"^# c #2A3B34", -"/# c #222725", -"(# c #80807E", -"_# c #EFEEEC", -":# c #F1F0EF", -"<# c #F4F3F2", -"[# c #F8F8F8", -"}# c #A8AFBB", -"|# c #0D1522", -"1# c #1A212E", -"2# c #1D232C", -"3# c #21252D", -"4# c #1E2327", -"5# c #171B20", -"6# c #637593", -"7# c #95A6BE", -"8# c #6D7F9C", -"9# c #617395", -"0# c #5A6E8B", -"a# c #2A354A", -"b# c #3D4E6D", -"c# c #1C2A46", -"d# c #748DAB", -"e# c #6D798A", -"f# c #DEDFE0", -"g# c #EEEEEE", -"h# c #EDEDEC", -"i# c #ECEAE7", -"j# c #ADB1B0", -"k# c #B5B9BA", -"l# c #F1F0F0", -"m# c #F9F8F8", -"n# c #F7F5F4", -"o# c #A7AAA4", -"p# c #B7BAB4", -"q# c #F7F6F6", -"r# c #ECEFF1", -"s# c #747F8E", -"t# c #0A121E", -"u# c #232C3A", -"v# c #1D232E", -"w# c #222932", -"x# c #1B1D21", -"y# c #1C273E", -"z# c #C1CFE1", -"A# c #8FA1B7", -"B# c #6D81A0", -"C# c #596D93", -"D# c #455674", -"E# c #293343", -"F# c #4A5C7D", -"G# c #304060", -"H# c #7690B8", -"I# c #5D6878", -"J# c #BBC0CC", -"K# c #ECECEB", -"L# c #F6F4F3", -"M# c #F4F1EF", -"N# c #F7F5F3", -"O# c #F9F8F7", -"P# c #BBBDB9", -"Q# c #4D5852", -"R# c #71746D", -"S# c #F0EAE7", -"T# c #DBDEE3", -"U# c #3E495B", -"V# c #1C2435", -"W# c #273041", -"X# c #283040", -"Y# c #293141", -"Z# c #262B38", -"`# c #1D212D", -" $ c #4A5B77", -".$ c #CFDBEB", -"+$ c #7A8FAC", -"@$ c #6C83A5", -"#$ c #4D6389", -"$$ c #35445E", -"%$ c #404D60", -"&$ c #506586", -"*$ c #4F6687", -"=$ c #6983AB", -"-$ c #343E50", -";$ c #4D5F7A", -">$ c #B8C0CC", -",$ c #F7F6F5", -"'$ c #D2D6D3", -")$ c #6C866F", -"!$ c #5A715E", -"~$ c #566758", -"{$ c #B5C1B4", -"]$ c #B2BAC8", -"^$ c #273245", -"/$ c #29354A", -"($ c #323D53", -"_$ c #364258", -":$ c #333F52", -"<$ c #343F52", -"[$ c #28354A", -"}$ c #6D7B92", -"|$ c #ACBDD2", -"1$ c #5B7297", -"2$ c #495F87", -"3$ c #3A4D6B", -"4$ c #252F44", -"5$ c #8292AC", -"6$ c #586E94", -"7$ c #6782A9", -"8$ c #37404D", -"9$ c #394860", -"0$ c #475977", -"a$ c #6E7E99", -"b$ c #EBEBEA", -"c$ c #BEC3BE", -"d$ c #CFD1CE", -"e$ c #F4F2F0", -"f$ c #7D8F84", -"g$ c #6A8667", -"h$ c #D5D8D4", -"i$ c #6B6B6B", -"j$ c #9E9E9F", -"k$ c #7A8EA8", -"l$ c #2B374D", -"m$ c #313E56", -"n$ c #34425B", -"o$ c #36425A", -"p$ c #354257", -"q$ c #39465D", -"r$ c #3B4963", -"s$ c #64738B", -"t$ c #768CAD", -"u$ c #354C72", -"v$ c #2E3D5B", -"w$ c #1D273A", -"x$ c #3D4655", -"y$ c #A7BACE", -"z$ c #607799", -"A$ c #617494", -"B$ c #191B1B", -"C$ c #445675", -"D$ c #3A4A65", -"E$ c #6C7A91", -"F$ c #ECECEA", -"G$ c #EAEAE9", -"H$ c #EAEAE8", -"I$ c #F7F6F4", -"J$ c #B5B9B6", -"K$ c #D7DCD9", -"L$ c #7B8982", -"M$ c #A9AEAD", -"N$ c #517257", -"O$ c #839284", -"P$ c #DEDEDD", -"Q$ c #D8D9D9", -"R$ c #F3F2EE", -"S$ c #51698C", -"T$ c #313F55", -"U$ c #35435B", -"V$ c #36445A", -"W$ c #35425C", -"X$ c #37465D", -"Y$ c #3D4A62", -"Z$ c #516079", -"`$ c #47536A", -" % c #354561", -".% c #212F46", -"+% c #0F1624", -"@% c #1A2231", -"#% c #99A5B7", -"$% c #97A8C3", -"%% c #6A7DA0", -"&% c #394559", -"*% c #1C1D26", -"=% c #35435C", -"-% c #344159", -";% c #8E96A2", -">% c #E9E9E8", -",% c #E9E9E7", -"'% c #F6F5F5", -")% c #70827F", -"!% c #C6D0C3", -"~% c #445344", -"{% c #637161", -"]% c #4B6C4C", -"^% c #CAC8C8", -"/% c #3D5271", -"(% c #3A4863", -"_% c #384862", -":% c #3E4C65", -"<% c #424D67", -"[% c #45536C", -"}% c #4D5A74", -"|% c #66768F", -"1% c #76869D", -"2% c #2A3243", -"3% c #151A27", -"4% c #252C3A", -"5% c #B2BBCE", -"6% c #C3D0E3", -"7% c #7B8CA9", -"8% c #51627E", -"9% c #171C22", -"0% c #141920", -"a% c #242C3A", -"b% c #3F4B60", -"c% c #BDC0C6", -"d% c #EBEBE9", -"e% c #D1D7D3", -"f% c #4F5753", -"g% c #27322D", -"h% c #57655B", -"i% c #7E8B86", -"j% c #F0EFED", -"k% c #3E516C", -"l% c #3F4E68", -"m% c #3C4A64", -"n% c #4C5A74", -"o% c #55637C", -"p% c #5A6881", -"q% c #707D95", -"r% c #8493A6", -"s% c #BFC8D8", -"t% c #D8E4F0", -"u% c #CCD5E4", -"v% c #E2E8F1", -"w% c #D2DAE9", -"x% c #8D9DB7", -"y% c #526380", -"z% c #323E53", -"A% c #080B11", -"B% c #0E1217", -"C% c #272E3A", -"D% c #747D8A", -"E% c #D6D7D8", -"F% c #E8E8E7", -"G% c #E8E8E6", -"H% c #D2D2D0", -"I% c #B3B7B4", -"J% c #BFC1BF", -"K% c #EBE8E7", -"L% c #5A718E", -"M% c #3F4C65", -"N% c #38475F", -"O% c #68768E", -"P% c #6E7C92", -"Q% c #78879B", -"R% c #959FB1", -"S% c #AAB4C1", -"T% c #C4CBD8", -"U% c #D7DCE6", -"V% c #D3D9E1", -"W% c #CCD3DC", -"X% c #8C9CB4", -"Y% c #52627B", -"Z% c #38475E", -"`% c #080E1A", -" & c #060910", -".& c #0E0F14", -"+& c #4F5869", -"@& c #B6B8BC", -"#& c #DDDDDC", -"$& c #E2E2E1", -"%& c #E5E5E4", -"&& c #E6E6E5", -"*& c #F2F1F1", -"=& c #F2F1F0", -"-& c #93A8C2", -";& c #2F3E56", -">& c #6C7A93", -",& c #939EAE", -"'& c #A9B3C0", -")& c #BDC3CB", -"!& c #C8CCD2", -"~& c #CDCFD5", -"{& c #CBD2DB", -"]& c #C7CFDC", -"^& c #A4B2C7", -"/& c #4C576D", -"(& c #262C3C", -"_& c #252D3B", -":& c #232C3D", -"<& c #323B4B", -"[& c #464B5A", -"}& c #959697", -"|& c #BDBDBC", -"1& c #C9C9C9", -"2& c #D6D6D5", -"3& c #E2E2E0", -"4& c #E7E7E6", -"5& c #E6E6E4", -"6& c #C8D6E7", -"7& c #515D76", -"8& c #33415A", -"9& c #66728A", -"0& c #C0C7D2", -"a& c #CACED7", -"b& c #CCCDD2", -"c& c #CBCED1", -"d& c #C8CED3", -"e& c #C2CDDB", -"f& c #A2B1C5", -"g& c #586377", -"h& c #181F27", -"i& c #363B40", -"j& c #575857", -"k& c #626261", -"l& c #656463", -"m& c #787877", -"n& c #929291", -"o& c #9F9F9D", -"p& c #B0B0AE", -"q& c #C3C3C2", -"r& c #D1D1D0", -"s& c #DCDCDB", -"t& c #DFE4EB", -"u& c #5F708B", -"v& c #717E92", -"w& c #4F5E78", -"x& c #8391A4", -"y& c #A9B4C2", -"z& c #B1BBC5", -"A& c #BAC3CE", -"B& c #D5DDE8", -"C& c #9EA7B9", -"D& c #444D63", -"E& c #1F242F", -"F& c #2D2F33", -"G& c #424242", -"H& c #4D4D4D", -"I& c #515150", -"J& c #575756", -"K& c #60605F", -"L& c #747473", -"M& c #838381", -"N& c #989897", -"O& c #B3B3B2", -"P& c #C6C6C4", -"Q& c #D3D3D2", -"R& c #F0EFEE", -"S& c #D0D1D3", -"T& c #959FB4", -"U& c #5B697E", -"V& c #9DA7B7", -"W& c #D8DEE4", -"X& c #D4DAE1", -"Y& c #DBE1E5", -"Z& c #DBDDE3", -"`& c #818894", -" * c #1E293A", -".* c #1B222B", -"+* c #222425", -"@* c #313131", -"#* c #343434", -"$* c #363635", -"%* c #3A3A3A", -"&* c #40403F", -"** c #484847", -"=* c #585858", -"-* c #6B6B6A", -";* c #838382", -">* c #A5A5A3", -",* c #BCBCBA", -"'* c #CFCFCE", -")* c #EFEFEF", -"!* c #E3E3E2", -"~* c #D9D9D8", -"{* c #BCBCBB", -"]* c #9DA0A4", -"^* c #616678", -"/* c #2F3A4F", -"(* c #2C3649", -"_* c #394250", -":* c #111923", -"<* c #010613", -"[* c #0A0F16", -"}* c #1F2225", -"|* c #262628", -"1* c #282828", -"2* c #292828", -"3* c #292929", -"4* c #2D2D2C", -"5* c #2F2F2F", -"6* c #343433", -"7* c #3D3D3C", -"8* c #5C5C5C", -"9* c #A1A1A0", -"0* c #B9B9B8", -"a* c #CECECC", -"b* c #E4E4E2", -"c* c #D7D7D5", -"d* c #989896", -"e* c #717174", -"f* c #464B51", -"g* c #2F353C", -"h* c #23272C", -"i* c #222529", -"j* c #25272A", -"k* c #2E2F31", -"l* c #313030", -"m* c #313130", -"n* c #333332", -"o* c #363636", -"p* c #3C3C3C", -"q* c #545454", -"r* c #686867", -"s* c #848483", -"t* c #A8A8A7", -"u* c #C0C0BE", -"v* c #D3D3D1", -"w* c #D9D9D7", -"x* c #C0C0BF", -"y* c #A3A3A2", -"z* c #888886", -"A* c #6E6D6C", -"B* c #5F6061", -"C* c #585859", -"D* c #525252", -"E* c #A3A3A1", -"F* c #A2A2A0", -"G* c #A2A1A0", -"H* c #A2A2A1", -"I* c #A3A2A1", -"J* c #A4A3A2", -"K* c #A4A4A2", -"L* c #A6A6A4", -"M* c #A9A8A6", -"N* c #ABAAA8", -"O* c #AFAEAB", -"P* c #B3B1AE", -"Q* c #B5B4B1", -"R* c #B8B6B2", -"S* c #BAB8B4", -"T* c #6E6B62", -"U* c #DEDEDC", -"V* c #D1D1CF", -"W* c #BFBFBE", -"X* c #AFAFAF", -"Y* c #9F9F9F", -"Z* c #919190", -"`* c #888888", -" = c #302E28", -".= c #2E2C27", -"+= c #2D2B26", -"@= c #312F29", -"#= c #33312B", -"$= c #36332D", -"%= c #38362F", -"&= c #3D3A33", -"*= c #413E36", -"== c #47433B", -"-= c #4D4940", -";= c #514D44", -">= c #535046", -",= c #565248", -"'= c #23211D", -")= c #EBEAE9", -"!= c #DADAD9", -"~= c #C9C9C7", -"{= c #B6B6B6", -"]= c #B2B0AD", -"^= c #423F37", -"/= c #E3E2E1", -"(= c #4E4B44", -"_= c #403D36", -":= c #413E37", -"<= c #908E8A", -"[= c #46433B", -"}= c #D8D7D5", -"|= c #75726A", -"1= c #ACAAA5", -"2= c #D7D6D3", -"3= c #DBDAD8", -"4= c #86837C", -"5= c #D5D5D4", -"6= c #B6B5B1", -"7= c #4E4A41", -"8= c #D5D4D2", -"9= c #514E46", -"0= c #5E5B52", -"a= c #504D43", -"b= c #545147", -"c= c #8A8780", -"d= c #E3E3E1", -"e= c #D2D1CE", -"f= c #7B7770", -"g= c #58544A", -"h= c #7C7971", -"i= c #E7E7E5", -"j= c #CCCBC8", -"k= c #C4C2BF", -"l= c #C4C3BF", -"m= c #FBFAFA", -"n= c #817E76", -"o= c #D1D0CD", -"p= c #67635A", -"q= c #F5F4F4", -"r= c #67645B", -"s= c #908E87", -"t= c #E5E4E3", -"u= c #6F6C63", -"v= c #8B8881", -"w= c #C0BEBA", -"x= c #8C8982", -"y= c #C8C7C4", -"z= c #656259", -"A= c #77736B", -"B= c #E4E4E3", -"C= c #D3D2CF", -"D= c #76736B", -"E= c #59554B", -"F= c #E7E6E5", -"G= c #AFADA8", -"H= c #DFDFDD", -"I= c #D0CFCC", -"J= c #736F67", -"K= c #A9A9A7", -"L= c #8D8D8D", -"M= c #E1E1DF", -"N= c #9A9A9A", -"O= c #8C8C8C", -" . . . . . . . . . . . . . + @ # + . . . . . . . . . . . . . . . . . $ % ", -". & * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * = - ; . ", -". * * * * * * * * * * * * * * * * * * * > * * , , , , , , , , , , , , ' = ) ! . ", -". * * * * * * ~ * * { ] ^ / ( _ : < * * * , [ [ , , , , , , , , , , , } | * 1 2 . ", -". * * * * * * ~ * * 3 4 5 6 7 8 9 0 * , , , , , , , , , , , , , , , , } a * * ) b c ", -". * * * * * * * * * d e f g h i j k , , , , , l , , , , , , , , , m m = n * m * o p q ", -". * * * * * * * * * * r s t u v w x , , , , , l , , y z A m m m m m m B C * D E * F G . ", -". * * * * * * * * * * H I J K L M N , , , , l m z O P Q R S T ' E E E U V W X F n Y Z ` . ", -". * * * * * * * * m ...+.@., #.$.%., , , , &.*.=.-.;.>.,.'.).!.~.E d {.].^./.(._._.:.<.. ", -". * * * * [. .m * }.|.1.2.3.4.5.6.7.8.m 9.0.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.! p.q.r.s.t.u.. ", -". * * , n.v.w.x.y.z.A.B.C.D.E.F.G.H.I.m J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.D ' } } Y.Z.Z `.s.. ", -". * * , +.+++@+#+$+%+&+*+=+E -+;+>+,+,+'+)+!+~+{+]+^+/+(+_+:+<+[+}+|+} X.1+2+3+3+3+4+<.. ", -". * * , 5+6+7+8+9+0+1 a+b+c+E d+e+` f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+= } 3+3+B B o.o.w+. ", -". * , , 9.x+y+z+A+B+c+E E E E E E d C+D+E+F+G+l+m+H+I+J+K+L+M+N+O+P+Q+B B B U {.o.R+R+C . ", -". * m m m S+T+U+V+W+X.E E d ' ' ' ' X+Y+Z+`+ @I+.@.@+@^+@@#@$@%@&@*@=@o.U {.R+R+R+-@-@C . ", -". * m #.E ' ;@>@,@'@5+' ' ' ' 5+5+m.)@!@~@{@]@^@/@(@_@:@<@[@}@|@1@2@3@{.R+R+n.n.-@4@4@C . ", -". * E ' 5@6@7@8@9@0@} ' 5+5+m.m.m.a@b@c@d@l+e@f@g@h@i@j@k@l@m@n@o@p@q@n.n.-@r@4@4@s@s@C . ", -". * d [.t@u@v@w@x@{.m.m.m.m.m.[.m.y@z@A@B@C@D@E@F@G@H@I@J@K@L@M@N@O@P@-@-@r@s@s@< Q@R@C . ", -". * ' S@T@U@V@W@X@m.m.[.[.[.D Y@Z@`@ #.#+#@#D@##$#%#&#*#=#-#;#>#,#'#)#4@!#< < Q@~#~#{#C . ", -". * 5+3+]#^#/#(#_#[.D :#<#D X.[#}#|#1#2#3#f@4#5#6#7#8#9#0#a#b#c#d#e#f#< < g#g#~#{#h#h#C . ", -". * m.X.i#j#k#l#m#D n#o#p#q#} r#s#t#u#v#w#^@x#y#z#A#B#C#D#E#F#G#H#I#J#|+~#~#{#h#h#W K#C . ", -". * [.L#M#N#[#O#O#1+P#Q#R#S#1+T#U#V#W#X#Y#Z#`# $.$+$@$#$$$%$&$*$=$-$;$>${#h#4+4+K#K#K#C . ", -". * D ,$X.Y@[#[#} '$)$!$~${$3+]$^$/$($_$:$<$[$}$|$1$2$3$4$5$6$7$8$9$0$a$4+4+K#K#b$b$b$C . ", -". * [#[#[#n#c$d$e$f$g$h$i$j${.k$l$m$n$o$p$q$r$s$t$u$v$w$x$y$z$A$B$C$D$E$K#F$b$b$b$G$H$C . ", -". * X.1+I$J$K$L$M$N$O$< P$Q$R$S$T$U$V$W$X$Y$Z$`$ %.%+%@%#%$%%%&%*%=%-%;%b$b$b$G$>%>%,%C . ", -". * = = '%)%!%~%{%]%^%o.R+R+{./%(%_%:%<%[%}%|%1%2%3%4%5%6%7%8%9%0%a%b%c%d%>%>%>%,%,%,%C . ", -". * 2+2+2+e%f%g%h%i%j%R+-@1 -@k%l%m%n%o%p%q%r%s%t%u%v%w%x%y%z%A%B%C%D%E%F%F%>%,%F%F%G%C . ", -". * 3+U {.{.H%I%J%K%-@4@4@4@4@L%M%N%O%P%Q%R%S%T%U%V%W%X%Y%Z%`% &.&+&@&#&$&%&&&F%G%G%G%C . ", -". * {.{.R+n.*&=&=&4@4@4@s@< Q@-&M%;&>&,&'&)&!&~&{&]&^&/&(&_&:&<&[&}&|&1&2&#&3&4&4&4&5&C . ", -". * n.-@-@-@-@4@4@s@< < < ~#b$6&7&8&9&0&a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&4&5&5&%&C . ", -". * -@-@-@4@< < < < < Q@R@G$%&t&u&v&w&x&y&z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&%&%&%&%&C . ", -". * 1 4@< < j%R&Q@Q@R@~#h#&&P$S&T&U&V&W&X&Y&Z&`& *.*+*@*#*$*%*&***=*-*;*>*,*'*%&=+=+=+C . ", -". * < < )*Q@Q@Q@R@~#~#K#G$!*~*{*]*^*/*(*_*:*<*[*}*|*1*2*3*4*5*6*7*>@8*m&9*0*a*=+=+=+b*C . ", -". * Q@Q@Q@Q@R@~#{#K#K#K#>%!*c*,*d*e*f*g*h*i*j*k*l*m*5*@*@*n*o*p*u.q*r*s*t*u*v*=+=+b*b*C . ", -". * Q@Q@~#~#{#K#K#K#K#b$>%!*w*x*y*z*A*B*C*D*E*F*F*F*G*F*H*I*J*K*L*M*N*O*P*Q*R*S*S*S*S*S*S*S*S*T*", -". * ~#~#4+K#K#F$b$b$b$b$H$5&U*V*W*X*Y*N&Z*`*N* =.=+=+=.= =@=#=$=%=&=*===-=;=>=,=,=,=,=,=,=,=,='=", -". * 4+K#F$)=)=)=b$d%d%G$H$G%b*!=H%~=x*{*0*{=]=^=* /=(=_=:=<=* * [=* * * m.}=|=,=1=2=D X.3=4=,='=", -". * F$b$b$b$d%G$G$G$G$H$H$G%5&3&#&~*5=Q&Q&H%6=7=* * 8=9=0={.* * a=* * b=c=* d=,=e=f=g=h=* R+,='=", -". * d%d%G$G$G$G$G$H$H$G%G%G%G%i=i=i=i=i=&&5&S*,=* j=* k=l=j=* * ,=* * ,=g=* m=,=,=,=,=n=* o=,='=", -". * G$G$G$H$H$>%>%F%G%G%G%i=i=i=i=i=5&5&=+=+S*,=* p={.* q=r=* * ,=* * ,=s=* o=,=,=,=* * t=u=,='=", -". * H$>%>%>%>%F%G%G%4&4&i=i=i=i=5&5&=+=+=+=+S*,=* ,=v=w=x=,=* * ,=* * * m#y=z=,=,=,=,=A=* )=,='=", -". * >%>%>%G%4&4&4&4&i=i=i=&&&&5&=+=+=+=+B=B=S*,=* ,=,=,=,=,=* * ,=* * ,=,=,=,=,=C=D=E=4=* F=,='=", -". * ,%4&4&4&4&i=i=i=&&&&&&5&=+=+=+B=B=b*b*b*S*,=* ,=,=,=,=,=* * ,=* * ,=,=,=,=,=G=H=m=q#I=J=,='=", -". * 4&i=i=i=&&&&&&&&5&5&=+B=B=B=b*b*b*b*b*b*S*,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,='=", -". * i=&&&&&&5&5&5&5&B=B=b*b*b*b*b*b*b*b*b*d=T*'='='='='='='='='='='='='='='='='='='='='='='='='=", -". * &&5&5&5&5&%&B=b*b*b*b*b*b*b*b*b*b*d=d=d=d=K=p p p y*y*y*y*E*E*E*E*E*E*E*E*E*E*E*E*L=. ", -". & 5&5&5&=+b*b*b*b*b*b*b*b*b*b*!*d=d=d=d=d=d=d=d=3&3&3&3&M=M=M=M=M=M=M=M=M=M=M=M=M=M=N=. ", -". Y C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C N=O=. ", -" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", -" ", -" ", -" "};
--- a/src/mpg123/mpg123.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1037 +0,0 @@ -#include "mpg123.h" -#include "common.h" - -#include <glib.h> -#include <audacious/i18n.h> -#include <gtk/gtk.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/time.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> - -#include <audacious/util.h> -#include <audacious/configdb.h> -#include <audacious/vfs.h> -#include <audacious/titlestring.h> -#include <audacious/util.h> -#include <audacious/strings.h> -#include <tag_c.h> - -#define BUFSIZE_X 2048 - -static struct frame fr, temp_fr; - -PlayerInfo *mpgdec_info = NULL; -static GThread *decode_thread; - -static gboolean output_opened = FALSE, dopause = FALSE; -gint mpgdec_bitrate, mpgdec_frequency, mpgdec_length, mpgdec_layer, - mpgdec_lsf; -gchar *mpgdec_title = NULL, *mpgdec_filename = NULL; -static int disp_bitrate, skip_frames = 0; -static int cpu_fflags, cpu_efflags; -gboolean mpgdec_stereo, mpgdec_mpeg25; -int mpgdec_mode; - -mpgdec_t *ins; - -gchar **mpgdec_id3_encoding_list = NULL; - -const char *mpgdec_id3_genres[GENRE_MAX] = { - N_("Blues"), N_("Classic Rock"), N_("Country"), N_("Dance"), - N_("Disco"), N_("Funk"), N_("Grunge"), N_("Hip-Hop"), - N_("Jazz"), N_("Metal"), N_("New Age"), N_("Oldies"), - N_("Other"), N_("Pop"), N_("R&B"), N_("Rap"), N_("Reggae"), - N_("Rock"), N_("Techno"), N_("Industrial"), N_("Alternative"), - N_("Ska"), N_("Death Metal"), N_("Pranks"), N_("Soundtrack"), - N_("Euro-Techno"), N_("Ambient"), N_("Trip-Hop"), N_("Vocal"), - N_("Jazz+Funk"), N_("Fusion"), N_("Trance"), N_("Classical"), - N_("Instrumental"), N_("Acid"), N_("House"), N_("Game"), - N_("Sound Clip"), N_("Gospel"), N_("Noise"), N_("AlternRock"), - N_("Bass"), N_("Soul"), N_("Punk"), N_("Space"), - N_("Meditative"), N_("Instrumental Pop"), - N_("Instrumental Rock"), N_("Ethnic"), N_("Gothic"), - N_("Darkwave"), N_("Techno-Industrial"), N_("Electronic"), - N_("Pop-Folk"), N_("Eurodance"), N_("Dream"), - N_("Southern Rock"), N_("Comedy"), N_("Cult"), - N_("Gangsta Rap"), N_("Top 40"), N_("Christian Rap"), - N_("Pop/Funk"), N_("Jungle"), N_("Native American"), - N_("Cabaret"), N_("New Wave"), N_("Psychedelic"), N_("Rave"), - N_("Showtunes"), N_("Trailer"), N_("Lo-Fi"), N_("Tribal"), - N_("Acid Punk"), N_("Acid Jazz"), N_("Polka"), N_("Retro"), - N_("Musical"), N_("Rock & Roll"), N_("Hard Rock"), N_("Folk"), - N_("Folk/Rock"), N_("National Folk"), N_("Swing"), - N_("Fast-Fusion"), N_("Bebob"), N_("Latin"), N_("Revival"), - N_("Celtic"), N_("Bluegrass"), N_("Avantgarde"), - N_("Gothic Rock"), N_("Progressive Rock"), - N_("Psychedelic Rock"), N_("Symphonic Rock"), N_("Slow Rock"), - N_("Big Band"), N_("Chorus"), N_("Easy Listening"), - N_("Acoustic"), N_("Humour"), N_("Speech"), N_("Chanson"), - N_("Opera"), N_("Chamber Music"), N_("Sonata"), N_("Symphony"), - N_("Booty Bass"), N_("Primus"), N_("Porn Groove"), - N_("Satire"), N_("Slow Jam"), N_("Club"), N_("Tango"), - N_("Samba"), N_("Folklore"), N_("Ballad"), N_("Power Ballad"), - N_("Rhythmic Soul"), N_("Freestyle"), N_("Duet"), - N_("Punk Rock"), N_("Drum Solo"), N_("A Cappella"), - N_("Euro-House"), N_("Dance Hall"), N_("Goa"), - N_("Drum & Bass"), N_("Club-House"), N_("Hardcore"), - N_("Terror"), N_("Indie"), N_("BritPop"), N_("Negerpunk"), - N_("Polsk Punk"), N_("Beat"), N_("Christian Gangsta Rap"), - N_("Heavy Metal"), N_("Black Metal"), N_("Crossover"), - N_("Contemporary Christian"), N_("Christian Rock"), - N_("Merengue"), N_("Salsa"), N_("Thrash Metal"), - N_("Anime"), N_("JPop"), N_("Synthpop") -}; - -double -mpgdec_compute_tpf(struct frame *fr) -{ - const int bs[4] = { 0, 384, 1152, 1152 }; - double tpf; - - tpf = bs[fr->lay]; - tpf /= mpgdec_freqs[fr->sampling_frequency] << (fr->lsf); - return tpf; -} - -static void -set_synth_functions(struct frame *fr) -{ - typedef int (*func) (mpgdec_real *, int, unsigned char *, int *); - typedef int (*func_mono) (mpgdec_real *, unsigned char *, int *); - typedef void (*func_dct36) (mpgdec_real *, mpgdec_real *, mpgdec_real *, mpgdec_real *, mpgdec_real *); - - int ds = fr->down_sample; - int p8 = 0; - - static func funcs[2][2] = { - {mpgdec_synth_1to1, - mpgdec_synth_ntom}, - {mpgdec_synth_1to1_8bit, - mpgdec_synth_ntom_8bit} - }; - - static func_mono funcs_mono[2][2] = { - {mpgdec_synth_1to1_mono, - mpgdec_synth_ntom_mono}, - {mpgdec_synth_1to1_8bit_mono, - mpgdec_synth_ntom_8bit_mono} - }; - - /* Compatibility with older configs. */ - if (ds > 1) - ds = 1; - - if (mpgdec_cfg.resolution == 8) - p8 = 1; - fr->synth = funcs[p8][ds]; - fr->synth_mono = funcs_mono[p8][ds]; - fr->synth_type = SYNTH_FPU; - - if (p8) { - mpgdec_make_conv16to8_table(); - } -} - -static void -init(void) -{ - ConfigDb *db; - gchar *tmp = NULL; - - ins = mpgdec_new(); - - memset(&mpgdec_cfg, 0, sizeof(mpgdec_cfg)); - - mpgdec_cfg.resolution = 16; - mpgdec_cfg.channels = 2; - mpgdec_cfg.downsample = 0; - mpgdec_cfg.http_buffer_size = 128; - mpgdec_cfg.http_prebuffer = 25; - mpgdec_cfg.proxy_port = 8080; - mpgdec_cfg.proxy_use_auth = FALSE; - mpgdec_cfg.proxy_user = NULL; - mpgdec_cfg.proxy_pass = NULL; - mpgdec_cfg.use_udp_channel = TRUE; - mpgdec_cfg.title_override = FALSE; - mpgdec_cfg.disable_id3v2 = FALSE; - mpgdec_cfg.default_synth = SYNTH_AUTO; - - mpgdec_cfg.title_encoding_enabled = FALSE; - mpgdec_cfg.title_encoding = NULL; - - db = bmp_cfg_db_open(); - - bmp_cfg_db_get_int(db, "MPG123", "resolution", &mpgdec_cfg.resolution); - bmp_cfg_db_get_int(db, "MPG123", "channels", &mpgdec_cfg.channels); - bmp_cfg_db_get_int(db, "MPG123", "downsample", &mpgdec_cfg.downsample); - bmp_cfg_db_get_int(db, "MPG123", "http_buffer_size", - &mpgdec_cfg.http_buffer_size); - bmp_cfg_db_get_int(db, "MPG123", "http_prebuffer", - &mpgdec_cfg.http_prebuffer); - bmp_cfg_db_get_bool(db, "MPG123", "save_http_stream", - &mpgdec_cfg.save_http_stream); - if (!bmp_cfg_db_get_string - (db, "MPG123", "save_http_path", &mpgdec_cfg.save_http_path)) - mpgdec_cfg.save_http_path = g_strdup(g_get_home_dir()); - - bmp_cfg_db_get_bool(db, "MPG123", "use_udp_channel", - &mpgdec_cfg.use_udp_channel); - - bmp_cfg_db_get_bool(db, "MPG123", "title_override", - &mpgdec_cfg.title_override); - bmp_cfg_db_get_bool(db, "MPG123", "disable_id3v2", - &mpgdec_cfg.disable_id3v2); - if (!bmp_cfg_db_get_string - (db, "MPG123", "id3_format", &mpgdec_cfg.id3_format)) - mpgdec_cfg.id3_format = g_strdup("%p - %t"); - bmp_cfg_db_get_int(db, "MPG123", "default_synth", - &mpgdec_cfg.default_synth); - - bmp_cfg_db_get_bool(db, "MPG123", "title_encoding_enabled", &mpgdec_cfg.title_encoding_enabled); - bmp_cfg_db_get_string(db, "MPG123", "title_encoding", &mpgdec_cfg.title_encoding); - if (mpgdec_cfg.title_encoding_enabled) - mpgdec_id3_encoding_list = g_strsplit_set(mpgdec_cfg.title_encoding, ENCODING_SEPARATOR, 0); - - bmp_cfg_db_get_bool(db, NULL, "use_proxy", &mpgdec_cfg.use_proxy); - bmp_cfg_db_get_string(db, NULL, "proxy_host", &mpgdec_cfg.proxy_host); - bmp_cfg_db_get_string(db, NULL, "proxy_port", &tmp); - - if (tmp != NULL) - mpgdec_cfg.proxy_port = atoi(tmp); - - bmp_cfg_db_get_bool(db, NULL, "proxy_use_auth", &mpgdec_cfg.proxy_use_auth); - bmp_cfg_db_get_string(db, NULL, "proxy_user", &mpgdec_cfg.proxy_user); - bmp_cfg_db_get_string(db, NULL, "proxy_pass", &mpgdec_cfg.proxy_pass); - - bmp_cfg_db_close(db); - - if (mpgdec_cfg.resolution != 16 && mpgdec_cfg.resolution != 8) - mpgdec_cfg.resolution = 16; - - mpgdec_cfg.channels = CLAMP(mpgdec_cfg.channels, 0, 2); - mpgdec_cfg.downsample = CLAMP(mpgdec_cfg.downsample, 0, 2); - mpgdec_getcpuflags(&cpu_fflags, &cpu_efflags); -} - -static void -cleanup(void) -{ - g_free(mpgdec_ip.description); - mpgdec_ip.description = NULL; - - if (mpgdec_cfg.save_http_path) { - free(mpgdec_cfg.save_http_path); - mpgdec_cfg.save_http_path = NULL; - } - - if (mpgdec_cfg.proxy_host) { - free(mpgdec_cfg.proxy_host); - mpgdec_cfg.proxy_host = NULL; - } - - if (mpgdec_cfg.proxy_user) { - free(mpgdec_cfg.proxy_user); - mpgdec_cfg.proxy_user = NULL; - } - - if (mpgdec_cfg.proxy_pass) { - free(mpgdec_cfg.proxy_pass); - mpgdec_cfg.proxy_pass = NULL; - } - - if (mpgdec_cfg.id3_format) { - free(mpgdec_cfg.id3_format); - mpgdec_cfg.id3_format = NULL; - } - - if (mpgdec_cfg.title_encoding) { - free(mpgdec_cfg.title_encoding); - mpgdec_cfg.title_encoding = NULL; - } - - g_strfreev(mpgdec_id3_encoding_list); -} - -static guint32 -convert_to_header(guint8 * buf) -{ - return (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3]; -} - - -#define DET_BUF_SIZE 4096 - -static gboolean -mpgdec_detect_by_content(VFSFile *file) -{ - guchar tmp[4]; - guint32 head; - struct frame fr; - guchar buf[DET_BUF_SIZE]; - int in_buf, i; - gboolean ret = FALSE; - guint cyc = 0; - - if (vfs_fread(tmp, 1, 4, file) != 4) - goto done; - if (!memcmp(tmp, "ID3", 3)) - { - ret = TRUE; - goto done; - } - - if (!memcmp(tmp, "MP+", 3)) - { - ret = FALSE; - goto done; - } - - head = convert_to_header(tmp); - while (!mpgdec_head_check(head)) { - /* - * The mpeg-stream can start anywhere in the file, - * so we check the entire file - * - * Incorrect! We give up past twenty iterations of this - * code for safety's sake. Buffer overflows suck. --nenolod - */ - /* Optimize this */ - in_buf = vfs_fread(buf, 1, DET_BUF_SIZE, file); - if (in_buf == 0) - goto done; - - for (i = 0; i < in_buf; i++) { - head <<= 8; - head |= buf[i]; - if (mpgdec_head_check(head)) { - vfs_fseek(file, i + 1 - in_buf, SEEK_CUR); - break; - } - } - - if (++cyc > 1024) - goto done; - } - if (mpgdec_decode_header(&fr, head)) { - /* - * We found something which looks like a MPEG-header. - * We check the next frame too, to be sure - */ - - if (vfs_fseek(file, fr.framesize, SEEK_CUR) != 0) - goto done; - if (vfs_fread(tmp, 1, 4, file) != 4) - goto done; - head = convert_to_header(tmp); - if (mpgdec_head_check(head) && mpgdec_decode_header(&fr, head)) - ret = TRUE; - } - - done: - return ret; -} - -static int -is_our_fd(char *filename, VFSFile *file) -{ - gchar *ext = strrchr(filename, '.'); - gboolean ret = FALSE; - - if (mpgdec_detect_by_content(file)) - ret = TRUE; - - return ret; -} - -static void -play_frame(InputPlayback *playback, struct frame *fr) -{ - if (fr->error_protection) { - bsi.wordpointer += 2; - /* mpgdec_getbits(16); *//* skip crc */ - } - if (!fr->do_layer(playback, fr)) { - skip_frames = 2; - mpgdec_info->output_audio = FALSE; - } - else { - if (!skip_frames) - mpgdec_info->output_audio = TRUE; - else - skip_frames--; - } -} - -static const char * -get_id3_genre(unsigned char genre_code) -{ - if (genre_code < GENRE_MAX) - return gettext(mpgdec_id3_genres[genre_code]); - - return ""; -} - -guint -mpgdec_strip_spaces(char *src, size_t n) -{ - gchar *space = NULL, /* last space in src */ - *start = src; - - while (n--) - switch (*src++) { - case '\0': - n = 0; /* breaks out of while loop */ - - src--; - break; - case ' ': - if (space == NULL) - space = src - 1; - break; - default: - space = NULL; /* don't terminate intermediate spaces */ - - break; - } - if (space != NULL) { - src = space; - *src = '\0'; - } - return src - start; -} - -/* - * Function extname (filename) - * - * Return pointer within filename to its extenstion, or NULL if - * filename has no extension. - * - */ -static gchar * -extname(const char *filename) -{ - gchar *ext = strrchr(filename, '.'); - - if (ext != NULL) - ++ext; - - return ext; -} - -/* - * Function id3v1_to_id3v2 (v1, v2) - * - * Convert ID3v1 tag `v1' to ID3v2 tag `v2'. - * - */ -void -mpgdec_id3v1_to_id3v2(struct id3v1tag_t *v1, struct id3tag_t *v2) -{ - memset(v2, 0, sizeof(struct id3tag_t)); - strncpy(v2->title, v1->title, 30); - strncpy(v2->artist, v1->artist, 30); - strncpy(v2->album, v1->album, 30); - strncpy(v2->comment, v1->u.v1_0.comment, 30); - strncpy(v2->genre, get_id3_genre(v1->genre), sizeof(v2->genre)); - g_strstrip(v2->title); - g_strstrip(v2->artist); - g_strstrip(v2->album); - g_strstrip(v2->comment); - g_strstrip(v2->genre); - { - char y[5]; - memcpy(y, v1->year, 4); y[4]=0; - v2->year = atoi(y); - } - - /* Check for v1.1 tags. */ - if (v1->u.v1_1.__zero == 0) - v2->track_number = v1->u.v1_1.track_number; - else - v2->track_number = 0; -} - -#define REMOVE_NONEXISTANT_TAG(x) if (!*x) { x = NULL; } - -static long -get_song_length(VFSFile * file) -{ - int len; - char tmp[4]; - - vfs_fseek(file, 0, SEEK_END); - len = vfs_ftell(file); - vfs_fseek(file, -128, SEEK_END); - vfs_fread(tmp, 1, 3, file); - if (!strncmp(tmp, "TAG", 3)) - len -= 128; - return len; -} - - -static guint -get_song_time(VFSFile * file) -{ - guint32 head; - guchar tmp[4], *buf; - struct frame frm; - xing_header_t xing_header; - double tpf, bpf; - guint32 len; - - if (!file) - return -1; - - vfs_fseek(file, 0, SEEK_SET); - if (vfs_fread(tmp, 1, 4, file) != 4) - return 0; - head = convert_to_header(tmp); - while (!mpgdec_head_check(head)) { - head <<= 8; - if (vfs_fread(tmp, 1, 1, file) != 1) - return 0; - head |= tmp[0]; - } - if (mpgdec_decode_header(&frm, head)) { - buf = g_malloc(frm.framesize + 4); - vfs_fseek(file, -4, SEEK_CUR); - vfs_fread(buf, 1, frm.framesize + 4, file); - tpf = mpgdec_compute_tpf(&frm); - if (mpgdec_get_xing_header(&xing_header, buf)) { - g_free(buf); - if (xing_header.bytes == 0) - xing_header.bytes = get_song_length(file); - return (tpf * xing_header.frames * 1000); - } - g_free(buf); - bpf = mpgdec_compute_bpf(&frm); - len = get_song_length(file); - return ((guint) (len / bpf) * tpf * 1000); - } - return 0; -} - -static TitleInput * -get_song_tuple(char *filename) -{ - VFSFile *file; - TitleInput *tuple = NULL; - TagLib_File *taglib_file; - TagLib_Tag *taglib_tag; - - if (str_has_prefix_nocase(filename, "http://")) - return NULL; - -#ifdef USE_CHARDET - taglib_set_strings_unicode(FALSE); -#endif - - if ((file = vfs_fopen(filename, "rb")) != NULL) - { - tuple = bmp_title_input_new(); - - taglib_file = taglib_file_new_type(filename, TagLib_File_MPEG); - taglib_tag = NULL; - - if (taglib_file != NULL) - { - taglib_tag = taglib_file_tag(taglib_file); - } - - if (taglib_tag != NULL) - { - tuple->performer = g_strdup(taglib_tag_artist(taglib_tag)); - tuple->album_name = g_strdup(taglib_tag_album(taglib_tag)); - tuple->track_name = g_strdup(taglib_tag_title(taglib_tag)); - - mpgdec_strip_spaces(tuple->performer, strlen(tuple->performer)); - mpgdec_strip_spaces(tuple->album_name, strlen(tuple->album_name)); - mpgdec_strip_spaces(tuple->track_name, strlen(tuple->track_name)); - - tuple->year = taglib_tag_year(taglib_tag); - tuple->track_number = taglib_tag_track(taglib_tag); - tuple->genre = g_strdup(taglib_tag_genre(taglib_tag)); - tuple->comment = g_strdup(taglib_tag_comment(taglib_tag)); - - /* remove any blank tags, fucking taglib */ - REMOVE_NONEXISTANT_TAG(tuple->performer); - REMOVE_NONEXISTANT_TAG(tuple->album_name); - REMOVE_NONEXISTANT_TAG(tuple->track_name); - REMOVE_NONEXISTANT_TAG(tuple->genre); - REMOVE_NONEXISTANT_TAG(tuple->comment); - } - - if (tuple->performer != NULL) - tuple->performer = str_to_utf8(tuple->performer); - - if (tuple->album_name != NULL) - tuple->album_name = str_to_utf8(tuple->album_name); - - if (tuple->track_name != NULL) - tuple->track_name = str_to_utf8(tuple->track_name); - - if (tuple->comment != NULL) - tuple->comment = str_to_utf8(tuple->comment); - - tuple->file_name = g_path_get_basename(filename); - tuple->file_path = g_path_get_dirname(filename); - tuple->file_ext = extname(filename); - tuple->length = get_song_time(file); - - if (taglib_file != NULL) - taglib_file_free(taglib_file); - - taglib_tag_free_strings(); - vfs_fclose(file); - } - - return tuple; -} - -static gchar * -get_song_title(TitleInput *tuple) -{ - return xmms_get_titlestring(mpgdec_cfg.title_override ? - mpgdec_cfg.id3_format : - xmms_get_gentitle_format(), tuple); -} - -static void -get_song_info(char *filename, char **title_real, int *len_real) -{ - TitleInput *tuple; - - (*len_real) = -1; - (*title_real) = NULL; - - /* - * TODO: Getting song info from http streams. - */ - if (CHECK_STREAM_URI(filename)) - return; - - if ((tuple = get_song_tuple(filename)) != NULL) { - (*len_real) = tuple->length; - (*title_real) = get_song_title(tuple); - } - - bmp_title_input_free(tuple); -} - -static int -open_output(InputPlayback *playback) -{ - int r; - AFormat fmt = mpgdec_cfg.resolution == 16 ? FMT_S16_NE : FMT_U8; -/* int freq = mpgdec_freqs[fr.sampling_frequency] >> mpgdec_cfg.downsample; */ - int freq = mpgdec_frequency; - int channels = mpgdec_cfg.channels == 2 ? fr.stereo : 1; - r = playback->output->open_audio(fmt, freq, channels); - - if (r && dopause) { - playback->output->pause(TRUE); - dopause = FALSE; - } - - return r; -} - - -static int -mpgdec_seek(InputPlayback *playback, struct frame *fr, xing_header_t * xh, - gboolean vbr, int time) -{ - int jumped = -1; - - if (xh) { - int percent = ((double) time * 100.0) / - (mpgdec_info->num_frames * mpgdec_info->tpf); - int byte = mpgdec_seek_point(xh, percent); - jumped = mpgdec_stream_jump_to_byte(playback, fr, byte); - } - else if (vbr && mpgdec_length > 0) { - int byte = ((guint64) time * 1000 * mpgdec_info->filesize) / - mpgdec_length; - jumped = mpgdec_stream_jump_to_byte(playback, fr, byte); - } - else { - int frame = time / mpgdec_info->tpf; - jumped = mpgdec_stream_jump_to_frame(playback, fr, frame); - } - - return jumped; -} - - -static void * -decode_loop(void *arg) -{ - static gchar *old_title = NULL; - gboolean have_xing_header = FALSE, vbr = FALSE; - int disp_count = 0; - InputPlayback *playback = arg; - char *filename = playback->filename; - xing_header_t xing_header; - - /* This is used by fileinfo on http streams */ - mpgdec_bitrate = 0; - - mpgdec_pcm_sample = g_malloc0(32768); - mpgdec_pcm_point = 0; - mpgdec_filename = filename; - - mpgdec_read_frame_init(); - - mpgdec_open_stream(playback, filename, -1, 0); - - if (playback->eof || !mpgdec_read_frame(&fr)) - playback->eof = TRUE; - - if (!playback->eof && playback->playing) { - if (mpgdec_cfg.channels == 2) - fr.single = -1; - else - fr.single = 3; - - fr.down_sample = mpgdec_cfg.downsample; - fr.down_sample_sblimit = SBLIMIT >> mpgdec_cfg.downsample; - set_synth_functions(&fr); - - mpgdec_info->tpf = mpgdec_compute_tpf(&fr); - if (!CHECK_STREAM(filename)) { - if (mpgdec_stream_check_for_xing_header(&fr, &xing_header)) { - mpgdec_info->num_frames = xing_header.frames; - have_xing_header = TRUE; - mpgdec_read_frame(&fr); - } - } - - for (;;) { - memcpy(&temp_fr, &fr, sizeof(struct frame)); - if (!mpgdec_read_frame(&temp_fr)) { - playback->eof = TRUE; - break; - } - if (fr.lay != temp_fr.lay || - fr.sampling_frequency != temp_fr.sampling_frequency || - fr.stereo != temp_fr.stereo || fr.lsf != temp_fr.lsf) - memcpy(&fr, &temp_fr, sizeof(struct frame)); - else - break; - } - - if (!have_xing_header && !CHECK_STREAM(filename)) - mpgdec_info->num_frames = mpgdec_calc_numframes(&fr); - - memcpy(&fr, &temp_fr, sizeof(struct frame)); - mpgdec_bitrate = tabsel_123[fr.lsf][fr.lay - 1][fr.bitrate_index]; - disp_bitrate = mpgdec_bitrate; - mpgdec_frequency = mpgdec_freqs[fr.sampling_frequency]; - mpgdec_stereo = fr.stereo; - mpgdec_layer = fr.lay; - mpgdec_lsf = fr.lsf; - mpgdec_mpeg25 = fr.mpeg25; - mpgdec_mode = fr.mode; - - /* XXX: note that this is temporary, until custom resampling is implemented - * in prefs. - */ - if (fr.down_sample) - { - long n = mpgdec_freqs[fr.sampling_frequency]; - long m = n / (fr.down_sample * 2); - - mpgdec_synth_ntom_set_step(n, m); - - mpgdec_frequency = (gint) m; - } - - mpgdec_length = mpgdec_info->num_frames * mpgdec_info->tpf * 1000; - - if (mpgdec_info->filesize != 0) { - TitleInput *tuple = NULL; - if (!mpgdec_title) - { - tuple = get_song_tuple(filename); - mpgdec_title = get_song_title(tuple); - bmp_title_input_free(tuple); - } - } - else { - gchar *tmp = mpgdec_metadata("stream-name"); - old_title = mpgdec_metadata("track-name"); - - if (old_title != NULL) - { - mpgdec_title = g_strdup_printf("%s (%s)", old_title, tmp); - g_free(tmp); - } - else - mpgdec_title = tmp; - - mpgdec_length = -1; - } - - set_synth_functions(&fr); - mpgdec_init_layer3(fr.down_sample_sblimit); - - mpgdec_ip.set_info(mpgdec_title, mpgdec_length, - mpgdec_bitrate * 1000, - mpgdec_freqs[fr.sampling_frequency], fr.stereo); - - output_opened = TRUE; - - if (!open_output(playback)) { - playback->error = TRUE; - playback->eof = TRUE; - } - else - play_frame(playback, &fr); - } - - mpgdec_info->first_frame = FALSE; - while (playback->playing) { - if (mpgdec_info->jump_to_time != -1) { - void *xp = NULL; - if (have_xing_header) - xp = &xing_header; - if (mpgdec_seek(playback, &fr, xp, vbr, - mpgdec_info->jump_to_time) > -1) { - playback->output->flush(mpgdec_info->jump_to_time * 1000); - playback->eof = FALSE; - } - mpgdec_info->jump_to_time = -1; - } - if (!playback->eof) { - if (mpgdec_read_frame(&fr) != 0) { - if (fr.lay != mpgdec_layer || fr.lsf != mpgdec_lsf) { - memcpy(&temp_fr, &fr, sizeof(struct frame)); - if (mpgdec_read_frame(&temp_fr) != 0) { - if (fr.lay == temp_fr.lay && fr.lsf == temp_fr.lsf) { - mpgdec_layer = fr.lay; - mpgdec_lsf = fr.lsf; - memcpy(&fr, &temp_fr, sizeof(struct frame)); - } - else { - memcpy(&fr, &temp_fr, sizeof(struct frame)); - skip_frames = 2; - mpgdec_info->output_audio = FALSE; - continue; - } - - } - } - - if (tabsel_123[fr.lsf][fr.lay - 1][fr.bitrate_index] != - mpgdec_bitrate) - mpgdec_bitrate = - tabsel_123[fr.lsf][fr.lay - 1][fr.bitrate_index]; - - if (!disp_count) { - disp_count = 20; - if (mpgdec_bitrate != disp_bitrate) { - /* FIXME networks streams */ - disp_bitrate = mpgdec_bitrate; - if (!have_xing_header - && !CHECK_STREAM(filename)) { - double rel = mpgdec_relative_pos(); - if (rel) { - mpgdec_length = - playback->output->written_time() / rel; - vbr = TRUE; - } - - if (rel == 0 || !(mpgdec_length > 0)) { - mpgdec_info->num_frames = - mpgdec_calc_numframes(&fr); - mpgdec_info->tpf = mpgdec_compute_tpf(&fr); - mpgdec_length = - mpgdec_info->num_frames * - mpgdec_info->tpf * 1000; - } - - - } - mpgdec_ip.set_info(mpgdec_title, mpgdec_length, - mpgdec_bitrate * 1000, - mpgdec_frequency, mpgdec_stereo); - } - - } - else - disp_count--; - play_frame(playback, &fr); - - if (mpgdec_info->filesize == 0) - { - gchar *new_title = mpgdec_metadata("track-name"); - gchar *srv_name = mpgdec_metadata("stream-name"); - - if (old_title == NULL || g_strcasecmp(old_title, new_title)) - { - if (mpgdec_title != NULL) - g_free(mpgdec_title); - - if (new_title != NULL) - mpgdec_title = g_strdup_printf("%s (%s)", - new_title, srv_name); - else - mpgdec_title = g_strdup(srv_name); - - if (old_title != NULL) - g_free(old_title); - - old_title = new_title; - - g_free(srv_name); - - mpgdec_ip.set_info(mpgdec_title, mpgdec_length, - mpgdec_bitrate * 1000, - mpgdec_frequency, mpgdec_stereo); - } - } - } - else { - playback->output->buffer_free(); - playback->output->buffer_free(); - playback->eof = TRUE; - g_usleep(10000); - } - } - else { - g_usleep(10000); - } - } - g_free(mpgdec_title); - - if (old_title != NULL) - g_free(old_title); - - old_title = NULL; - mpgdec_title = NULL; - mpgdec_stream_close(); - if (output_opened && !playback->error) - playback->output->close_audio(); - g_free(mpgdec_pcm_sample); - mpgdec_filename = NULL; - - return NULL; -} - -static void -play_file(InputPlayback *playback) -{ - memset(&fr, 0, sizeof(struct frame)); - memset(&temp_fr, 0, sizeof(struct frame)); - - mpgdec_info = g_malloc0(sizeof(PlayerInfo)); - mpgdec_info->playback = playback; - playback->playing = TRUE; - mpgdec_info->first_frame = TRUE; - mpgdec_info->output_audio = TRUE; - mpgdec_info->jump_to_time = -1; - skip_frames = 0; - playback->error = FALSE; - output_opened = FALSE; - dopause = FALSE; - - decode_thread = g_thread_create(decode_loop, playback, TRUE, - NULL); -} - -static void -stop(InputPlayback * playback) -{ - if (mpgdec_info && playback->playing) { - playback->playing = FALSE; - g_thread_join(decode_thread); - g_free(mpgdec_info); - mpgdec_info = NULL; - } -} - -static void -seek(InputPlayback * data, int time) -{ - mpgdec_info->jump_to_time = time; - - while (mpgdec_info->jump_to_time != -1) - g_usleep(10000); -} - -static void -do_pause(InputPlayback * playback, short p) -{ - if (output_opened) - playback->output->pause(p); - else - dopause = p; -} - -static void -aboutbox(void) -{ - static GtkWidget *aboutbox; - - if (aboutbox != NULL) - return; - - aboutbox = xmms_show_message(_("About MPEG Audio Plugin"), - _("Audacious decoding engine by William Pitcock <nenolod@nenolod.net>, derived from:\n" - "mpg123 decoding engine by Michael Hipp <mh@mpg123.de>\n" - "Derived partially from mpg123 0.59s.mc3 as well.\n" - "Based on the original XMMS plugin."), - _("Ok"), - FALSE, NULL, NULL); - - g_signal_connect(G_OBJECT(aboutbox), "destroy", - G_CALLBACK(gtk_widget_destroyed), &aboutbox); -} - -gchar *mpgdec_fmts[] = { "mp3", "mp2", "mpa", "mpg", NULL }; - -InputPlugin mpgdec_ip = { - NULL, - NULL, - NULL, /* Description */ - init, - aboutbox, - mpgdec_configure, - NULL, - NULL, - play_file, - stop, - do_pause, - seek, - NULL, - NULL, - NULL, NULL, - cleanup, - NULL, - NULL, NULL, NULL, - get_song_info, - mpgdec_file_info_box, /* file_info_box */ - NULL, - get_song_tuple, - NULL, - NULL, - is_our_fd, - mpgdec_fmts, -}; - -InputPlugin * -get_iplugin_info(void) -{ - mpgdec_ip.description = g_strdup_printf(_("MPEG Audio Plugin")); - return &mpgdec_ip; -}
--- a/src/mpg123/mpg123.h Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,363 +0,0 @@ -/* - * mpg123 defines - * used source: musicout.h from mpegaudio package - */ - -#ifndef __MPG123_H__ -#define __MPG123_H__ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <glib.h> -#include <tag_c.h> - -#ifdef INTEGER_COMPILE - -typedef long mpgdec_real; - -# 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) - -#else - -typedef float mpgdec_real; - -#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 - -enum { - SYNTH_AUTO, - SYNTH_FPU, - SYNTH_3DNOW, - SYNTH_MMX, -}; - -enum { - DETECT_EXTENSION, - DETECT_CONTENT, - DETECT_BOTH -}; - -enum { - STREAM_FILE, - STREAM_HTTP, - STREAM_RTSP -}; - -#include <gtk/gtk.h> - -#include "audacious/plugin.h" -#include "audacious/vfs.h" -#include "dxhead.h" - -#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 - -#define ENCODING_SEPARATOR " ,:;|/" - -#define MAXFRAMESIZE 4096 - -#ifdef HAVE_NEMESI -int mpgdec_rtsp_open(char *url); -int mpgdec_rtsp_read(gpointer data, gsize length); -void mpgdec_rtsp_close (void); -#define CHECK_STREAM_URI(filename) (!g_strncasecmp(filename, "http://", 7) \ - || !g_strncasecmp(filename, "rtsp://", 7)) -#else -#define CHECK_STREAM_URI(filename) (!g_strncasecmp(filename, "http://", 7)) -#endif - -#define CHECK_STREAM(var_is_deprecated) (mpgdec_info->filesize == 0) - -struct id3v1tag_t { - char tag[3]; /* always "TAG": defines ID3v1 tag 128 bytes before EOF */ - char title[30]; - char artist[30]; - char album[30]; - char year[4]; - union { - struct { - char comment[30]; - } v1_0; - struct { - char comment[28]; - char __zero; - unsigned char track_number; - } v1_1; - } u; - unsigned char genre; -}; - -struct id3tag_t { - char title[64]; - char artist[64]; - char album[64]; - char comment[256]; - char genre[256]; - gint year; - gint track_number; -}; - -typedef struct { - InputPlayback *playback; - int num_frames, jump_to_time, eq_active; - int songtime; - double tpf; - float eq_mul[576]; - gboolean output_audio, first_frame, network_stream; - gint stream_type; - guint32 filesize; /* Filesize without junk */ -} PlayerInfo; - -void mpgdec_set_eq(int on, float preamp, float *band); -void mpgdec_file_info_box(char *); - -extern PlayerInfo *mpgdec_info; -extern InputPlugin mpgdec_ip; - -struct al_table { - short bits; - short d; -}; - -struct frame { - struct al_table *alloc; - int (*synth) (mpgdec_real *, int, unsigned char *, int *); - int (*synth_mono) (mpgdec_real *, unsigned char *, int *); - int stereo; - int jsbound; - int single; - int II_sblimit; - int down_sample_sblimit; - int lsf; - int mpeg25; - int down_sample; - int header_change; - int lay; - int (*do_layer) (InputPlayback * playback, struct frame * fr); - 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 synth_type; -}; - -void mpgdec_configure(void); - -typedef struct { - gint resolution; - gint channels; - gint downsample; - gint http_buffer_size; - gint http_prebuffer; - gboolean use_proxy; - gchar *proxy_host; - gint proxy_port; - gboolean proxy_use_auth; - gchar *proxy_user, *proxy_pass; - gboolean save_http_stream; - gchar *save_http_path; - gboolean use_udp_channel; - gchar *id3_format; - gboolean title_override, disable_id3v2; - gboolean title_encoding_enabled; - gchar *title_encoding; - int detect_by; - int default_synth; -} MPG123Config; - -extern MPG123Config mpgdec_cfg; - -struct mpgdec_instance { - void (*dump_audio)(struct frame *fr); -}; - -struct bitstream_info { - int bitindex; - unsigned char *wordpointer; -}; - -extern struct bitstream_info bsi; - -typedef struct mpgdec_instance mpgdec_t; - -struct mpstr { - int bsize; - int framesize; - int fsizeold; - struct frame fr; - /* int (*do_layer)(struct mpstr *,struct frame *fr,int,struct audio_info_struct *); */ - unsigned char bsspace[2][MAXFRAMESIZE+512]; /* MAXFRAMESIZE */ - mpgdec_real hybrid_block[2][2][SBLIMIT*SSLIMIT]; - int hybrid_blc[2]; - unsigned long header; - int bsnum; - mpgdec_real synth_buffs[2][2][0x110]; - int synth_bo; - - struct bitstream_info bsi; -}; - - -#define AUSHIFT 3 - -/* ------ Declarations from "common.c" ------ */ -extern unsigned int mpgdec_get1bit(void); -extern unsigned int mpgdec_getbits(int); -extern unsigned int mpgdec_getbits_fast(int); - -extern void mpgdec_open_stream(InputPlayback *playback, char *bs_filenam, - int fd, unsigned long range); -extern int mpgdec_head_check(unsigned long); -extern void mpgdec_stream_close(void); - -extern void mpgdec_set_pointer(long); - -extern unsigned char *mpgdec_pcm_sample; -extern int mpgdec_pcm_point; - -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; - mpgdec_real *full_gain[3]; - mpgdec_real *pow2gain; -}; - -struct III_sideinfo { - unsigned main_data_begin; - unsigned private_bits; - struct { - struct gr_info_s gr[2]; - } ch[2]; -}; - -extern void open_stream(char *, int fd); -extern long mpgdec_tell_stream(void); -extern void mpgdec_read_frame_init(void); -extern int mpgdec_read_frame(struct frame *fr); -extern int mpgdec_back_frame(struct frame *fr, int num); -int mpgdec_stream_jump_to_frame(InputPlayback *playback, struct frame *fr, - int frame); -int mpgdec_stream_jump_to_byte(InputPlayback *playback, struct frame *fr, - int byte); -int mpgdec_stream_check_for_xing_header(struct frame *fr, - xing_header_t * xhead); -int mpgdec_calc_numframes(struct frame *fr); - -extern int mpgdec_do_layer3(InputPlayback *playback, struct frame *fr); -extern int mpgdec_do_layer2(InputPlayback *playback, struct frame *fr); -extern int mpgdec_do_layer1(InputPlayback *playback, struct frame *fr); - -extern int mpgdec_synth_1to1(mpgdec_real *, int, unsigned char *, int *); -extern int mpgdec_synth_1to1_8bit(mpgdec_real *, int, unsigned char *, int *); -extern int mpgdec_synth_1to1_mono(mpgdec_real *, unsigned char *, int *); -extern int mpgdec_synth_1to1_mono2stereo(mpgdec_real *, unsigned char *, int *); -extern int mpgdec_synth_1to1_8bit_mono(mpgdec_real *, unsigned char *, int *); -extern int mpgdec_synth_1to1_8bit_mono2stereo(mpgdec_real *, unsigned char *, - int *); - -extern int mpgdec_synth_ntom(mpgdec_real *, int, unsigned char *, int *); -extern int mpgdec_synth_ntom_8bit(mpgdec_real *, int, unsigned char *, int *); -extern int mpgdec_synth_ntom_mono(mpgdec_real *, unsigned char *, int *); -extern int mpgdec_synth_ntom_mono2stereo(mpgdec_real *, unsigned char *, int *); -extern int mpgdec_synth_ntom_8bit_mono(mpgdec_real *, unsigned char *, int *); -extern int mpgdec_synth_ntom_8bit_mono2stereo(mpgdec_real *, unsigned char *, - int *); -extern void mpgdec_synth_ntom_set_step(long, long); - -extern void mpgdec_rewindNbits(int bits); -extern int mpgdec_hsstell(void); -extern void mpgdec_set_pointer(long); -extern void mpgdec_huffman_decoder(int, int *); -extern void mpgdec_huffman_count1(int, int *); -extern int mpgdec_get_songlen(struct frame *fr, int no); - -#define mpgdec_getcpuflags(a, b) \ -do { \ - *(a) = 0; \ - *(b) = 0; \ -} while (0) - -void mpgdec_init_layer3(int); -void mpgdec_init_layer2(gboolean); -void mpgdec_make_decode_tables(long scaleval); -void mpgdec_make_conv16to8_table(void); -void mpgdec_dct64(mpgdec_real *, mpgdec_real *, mpgdec_real *); - -int mpgdec_decode_header(struct frame *fr, unsigned long newhead); -double mpgdec_compute_bpf(struct frame *fr); -double mpgdec_compute_tpf(struct frame *fr); -guint mpgdec_strip_spaces(char *src, size_t n); -double mpgdec_relative_pos(void); - - -extern gchar ** mpgdec_id3_encoding_list; -extern unsigned char *mpgdec_conv16to8; -extern const int mpgdec_freqs[9]; -extern mpgdec_real mpgdec_muls[27][64]; -extern mpgdec_real mpgdec_decwin[512 + 32]; -extern mpgdec_real *mpgdec_pnts[5]; - -#define GENRE_MAX 0x94 -extern const char *mpgdec_id3_genres[GENRE_MAX]; -extern const int tabsel_123[2][3][16]; - -/* psycho.c defines */ -void psycho_init(void); -int psycho_process(void *data, int length, int nch); - -/* interface.c */ -mpgdec_t *mpgdec_new(void); - -#endif
--- a/src/mpg123/paranoia.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,447 +0,0 @@ -/* libmpgdec: An advanced MPEG layer 1/2/3 decoder. - * psycho.c: Psychoaccoustic modeling. - * - * Copyright (C) 2005-2006 William Pitcock <nenolod@nenolod.net> - * Portions copyright (C) 2001 Rafal Bosak <gyver@fanthom.irc.pl> - * Portions copyright (C) 1999 Michael Hipp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - -#include "common.h" - -int bext_level; -int stereo_level; -int filter_level; -int harmonics_level; -int bext_sfactor; -int stereo_sfactor; -int harmonics_sfactor; -int enable_plugin = 1; -int lsine[65536]; -int rsine[65536]; - -/* - * Initialize and configure the psychoaccoustics engine. - */ -void psycho_init(void) -{ - int i, x; - double lsum; - double rsum; - - bext_level = 34; - stereo_level = stereo_sfactor = 16; - filter_level = 3; - harmonics_level = harmonics_sfactor = 43; - - bext_sfactor = (float)(((float)16384 * 10) / (float)(bext_level + 1)) + (float)(102 - bext_level) * 128; - -#define COND 0 - /* calculate sinetables */ - for (i = 0; i < 32768; ++i) - { - lsum = rsum = 0; - if (COND || i < 32768 )lsum+= ((cos((double)i * 3.141592535 / 32768/2 )) + 0) / 2; - if (COND || i < 16384 )rsum-= ((cos((double)i * 3.141592535 / 16384/2 )) + 0) / 4; - rsum = lsum; - - if (COND || i < 8192 ) lsum += ((cos((double)i * 3.141592535 / 8192/2 )) + 0) / 8; - if (COND || i < 5641 ) rsum += ((cos((double)i * 3.141592535 / 5641.333333/2)) + 0) / 8; - - lsine[32768 + i] = (double)(lsum - 0.5) * 32768 * 1.45; - lsine[32768 - i] = lsine[32768 + i]; - rsine[32768 + i] = (double)(rsum - 0.5) * 32768 * 1.45; - rsine[32768 - i] = rsine[32768 + i]; - - x = i; - } -} - -/* - * This routine computes a reverb for the track. - */ - -#define DELAY2 21000 -#define DELAY1 35000 -#define DELAY3 14000 -#define DELAY4 5 - -#define BUF_SIZE DELAY1+DELAY2+DELAY3+DELAY4 - -void echo3d(gint16 *data, int datasize) -{ - int x; - int left, right, dif, left0, right0, left1, right1, left2, right2, left3, right3, left4, right4, leftc, rightc, lsf, rsf; - static int left0p = 0, right0p = 0; - static int rangeErrorsUp = 0; - static int rangeErrorsDown = 0; - gint16 *dataptr; - static int l0, l1, l2, r0, r1, r2, ls, rs, ls1, rs1; - static int ll0, ll1, ll2, rr0, rr1, rr2; - static int lharmb = 0, rharmb = 0, lhfb = 0, rhfb = 0; - int lharm0, rharm0; - static gint16 buf[BUF_SIZE]; - static int bufPos1 = 1 + BUF_SIZE - DELAY1; - static int bufPos2 = 1 + BUF_SIZE - DELAY1 - DELAY2; - static int bufPos3 = 1 + BUF_SIZE - DELAY1 - DELAY2 - DELAY3; - static int bufPos4 = 1 + BUF_SIZE - DELAY1 - DELAY2 - DELAY3 - DELAY4; - dataptr = data; - - for (x = 0; x < datasize; x += 4) { - - // ************ load sample ********** - left0 = dataptr[0]; - right0 = dataptr[1]; - - // ************ slightly expand stereo for direct input ********** - ll0=left0;rr0=right0; - dif = (ll0+ll1+ll2 - rr0-rr1-rr2) * stereo_sfactor / 256; - left0 += dif; - right0 -= dif; - ll2= ll1; ll1= ll0; - rr2= rr1; rr1= rr0; - - // ************ echo from buffer - first echo ********** - // ************ ********** - left1 = buf[bufPos1++]; - if (bufPos1 == BUF_SIZE) - bufPos1 = 0; - right1 = buf[bufPos1++]; - if (bufPos1 == BUF_SIZE) - bufPos1 = 0; - - // ************ highly expand stereo for first echo ********** - dif = (left1 - right1); - left1 = left1 + dif; - right1 = right1 - dif; - - // ************ second echo ********** - left2 = buf[bufPos2++]; - if (bufPos2 == BUF_SIZE) - bufPos2 = 0; - right2 = buf[bufPos2++]; - if (bufPos2 == BUF_SIZE) - bufPos2 = 0; - - // ************ expand stereo for second echo ********** - dif = (left2 - right2); - left2 = left2 - dif; - right2 = right2 - dif; - - // ************ third echo ********** - left3 = buf[bufPos3++]; - if (bufPos3 == BUF_SIZE) - bufPos3 = 0; - right3 = buf[bufPos3++]; - if (bufPos3 == BUF_SIZE) - bufPos3 = 0; - - // ************ fourth echo ********** - left4 = buf[bufPos4++]; - if (bufPos4 == BUF_SIZE) - bufPos4 = 0; - right4 = buf[bufPos4++]; - if (bufPos4 == BUF_SIZE) - bufPos4 = 0; - - left3 = (left4+left3) / 2; - right3 = (right4+right3) / 2; - - // ************ expand stereo for second echo ********** - dif = (left4 - right4); - left3 = left3 - dif; - right3 = right3 - dif; - - // ************ a weighted sum taken from reverb buffer ********** - leftc = left1 / 9 + right2 /8 + left3 / 8; - rightc = right1 / 11 + left2 / 9 + right3 / 10; - - left = left0p; - right = right0p; - - l0 = leftc + left0 / 2; - r0 = rightc + right0 / 2; - - ls = l0 + l1 + l2; // do not reverb high frequencies (filter) - rs = r0 + r1 + r2; // - - // ************ add some extra even harmonics ********** - // ************ or rather specific nonlinearity - - lhfb = lhfb + (ls * 32768 - lhfb) / 32; - rhfb = rhfb + (rs * 32768 - rhfb) / 32; - - lsf = ls - lhfb / 32768; - rsf = rs - rhfb / 32768; - - lharm0 = 0 - + ((lsf + 10000) * ((((lsine[((lsf/4) + 32768 + 65536) % 65536] * harmonics_sfactor)) / 64))) / 32768 - - ((lsine[((lsf/4) + 32768 +65536) % 65536]) * harmonics_sfactor) / 128 - ; - - rharm0 = - + ((rsf + 10000) * ((((lsine[((rsf/4) + 32768 + 65536) % 65536] * harmonics_sfactor)) / 64))) / 32768 - - ((rsine[((rsf/4) + 32768 +65536) % 65536]) * harmonics_sfactor) / 128 - ; - - lharmb = lharmb + (lharm0 * 32768 - lharmb) / 16384; - rharmb = rharmb + (rharm0 * 32768 - rharmb) / 16384; - - // ************ for convolution filters ********** - l2= l1; r2= r1; - l1 = l0; r1 = r0; - ls1 = ls; rs1 = rs; - - left = 0 + lharm0 - lharmb / 32768 + left; - right = 0 + rharm0 - rharmb / 32768 + right; - - left0p = left0; - right0p = right0; - - - // ************ limiter ********** - if (left < -32768) { - left = -32768; // limit - rangeErrorsDown++; - } - else if (left > 32767) { - left = 32767; - rangeErrorsUp++; - } - if (right < -32768) { - right = -32768; - rangeErrorsDown++; - } - else if (right > 32767) { - right = 32767; - rangeErrorsUp++; - } - // ************ store sample ********** - dataptr[0] = left; - dataptr[1] = right; - dataptr += 2; - - } -} - -/* - * simple pith shifter, plays short fragments at 1.5 speed - */ -void pitchShifter(const int lin, const int rin, int *lout, int *rout) -{ -#define SH_BUF_SIZE 100 * 3 - static gint16 shBuf[SH_BUF_SIZE]; - static int shBufPos = SH_BUF_SIZE - 6; - static int shBufPos1 = SH_BUF_SIZE - 6; - static int cond; - - shBuf[shBufPos++] = lin; - shBuf[shBufPos++] = rin; - - if (shBufPos == SH_BUF_SIZE) shBufPos = 0; - - switch (cond){ - case 1: - *lout = (shBuf[shBufPos1 + 0] * 2 + shBuf[shBufPos1 + 2])/4; - *rout = (shBuf[shBufPos1 + 1] * 2 + shBuf[shBufPos1 + 3])/4; - break; - case 0: - *lout = (shBuf[shBufPos1 + 4] * 2 + shBuf[shBufPos1 + 2])/4; - *rout = (shBuf[shBufPos1 + 5] * 2 + shBuf[shBufPos1 + 3])/4; - cond = 2; - shBufPos1 += 6; - if (shBufPos1 == SH_BUF_SIZE) { - shBufPos1 = 0; - } - break; - } - cond--; -} - - -struct Interpolation{ - int acount; // counter - int lval, rval; // value - int sal, sar; // sum - int al, ar; - int a1l, a1r; -}; - -/* - * interpolation routine for ampliude and "energy" - */ -static inline void interpolate(struct Interpolation *s, int l, int r) -{ -#define AMPL_COUNT 64 - int a0l, a0r, dal = 0, dar = 0; - - if (l < 0) l = -l; - if (r < 0) r = -r; - - s->lval += l / 8; - s->rval += r / 8; - - s->lval = (s->lval * 120) / 128; - s->rval = (s->rval * 120) / 128; - - s->sal += s->lval; - s->sar += s->rval; - - s->acount++; - if (s->acount == AMPL_COUNT){ - s->acount = 0; - a0l = s->a1l; - a0r = s->a1r; - s->a1l = s->sal / AMPL_COUNT; - s->a1r = s->sar / AMPL_COUNT; - s->sal = 0; - s->sar = 0; - dal = s->a1l - a0l; - dar = s->a1r - a0r; - s->al = a0l * AMPL_COUNT; - s->ar = a0r * AMPL_COUNT; - } - - s->al += dal; - s->ar += dar; -} - -/* - * calculate scalefactor for mixer - */ -inline int calc_scalefactor(int a, int e) -{ - int x; - - if (a > 8192) a = 8192; - else if (a < 0) a = 0; - - if (e > 8192) e = 8192; - else if (e < 0) e = 0; - - x = ((e+500) * 4096 )/ (a + 300) + e; - - if (x > 16384) x = 16384; - else if (x < 0) x = 0; - return x; -} - -static struct Interpolation bandext_energy; -static struct Interpolation bandext_amplitude; - -/* - * exact bandwidth extender ("exciter") routine - */ -static void bandext(gint16 *data, const int datasize) -{ - - int x; - static int saw; // test stuff - int left, right; - gint16 *dataptr = data; - static int lprev0, rprev0, lprev1, rprev1, lprev2, rprev2; - int left0, right0, left1, right1, left2, right2, left3, right3; - static int lamplUp, lamplDown; - static int ramplUp, ramplDown; - int lampl, rampl; - int tmp; - - for (x = 0; x < datasize; x += 4) { - - // ************ load sample ********** - left0 = dataptr[0]; - right0 = dataptr[1]; - - // ************ highpass filter part 1 ********** - left1 = (left0 - lprev0) * 56880 / 65536; - right1 = (right0 - rprev0) * 56880 / 65536; - - left2 = (left1 - lprev1) * 56880 / 65536; - right2 = (right1 - rprev1) * 56880 / 65536; - - left3 = (left2 - lprev2) * 56880 / 65536; - right3 = (right2 - rprev2) * 56880 / 65536; - - switch (filter_level){ - case 1: - pitchShifter(left1, right1, &left, &right); - break; - case 2: - pitchShifter(left2, right2, &left, &right); - break; - case 3: - pitchShifter(left3, right3, &left, &right); - break; - } - - // ************ amplitude detector ************ - tmp = left1 + lprev1; - if (tmp * 16 > lamplUp ) lamplUp += (tmp - lamplUp ); - else if (tmp * 16 < lamplDown) lamplDown += (tmp - lamplDown); - lamplUp = (lamplUp * 1000) /1024; - lamplDown = (lamplDown * 1000) /1024; - lampl = lamplUp - lamplDown; - - tmp = right1 + rprev1; - if (tmp * 16 > ramplUp ) ramplUp += (tmp - ramplUp ); - else if (tmp * 16 < ramplDown) ramplDown += (tmp - ramplDown); - ramplUp = (ramplUp * 1000) /1024; - ramplDown = (ramplDown * 1000) /1024; - rampl = ramplUp - ramplDown; - - interpolate(&bandext_amplitude, lampl, rampl); - - // ************ "sound energy" detector (approx. spectrum complexity) *********** - interpolate(&bandext_energy, left0 - lprev0, right0 - rprev0); - - // ************ mixer *********** - left = left0 + left * calc_scalefactor(bandext_amplitude.lval, bandext_energy.lval) / bext_sfactor; - right = right0 + right * calc_scalefactor(bandext_amplitude.rval, bandext_energy.rval) / bext_sfactor; //16384 - - saw = (saw + 2048) & 0x7fff; - - lprev0 = left0; - rprev0 = right0; - lprev1 = left1; - rprev1 = right1; - lprev2 = left2; - rprev2 = right2; - - if (left < -32768) left = -32768; - else if (left > 32767) left = 32767; - if (right < -32768) right = -32768; - else if (right > 32767) right = 32767; - - dataptr[0] = left; - dataptr[1] = right; - dataptr += 2; - } -} - -int psycho_process(void *data, int length, int nch) -{ - if (nch != 2) - return length; /* XXX: we cant process mono yet */ - - echo3d((gint16 *)data, length); - bandext((gint16 *)data, length); - return length; -} -
--- a/src/mpg123/resample.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,294 +0,0 @@ -/* libmpgdec: An advanced MPEG layer 1/2/3 decoder. - * resample.c: A dynamic resampler. - * - * Copyright (C) 2005-2006 William Pitcock <nenolod@nenolod.net> - * Portions copyright (C) 1995-1999 Michael Hipp - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdlib.h> -#include <math.h> -#include <string.h> - -#include "mpg123.h" - -#define WRITE_SAMPLE(samples,sum,clip) \ - if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \ - else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \ - else { *(samples) = sum; } - -#define NTOM_MUL (32768) -static unsigned long ntom_val[2] = { NTOM_MUL>>1,NTOM_MUL>>1 }; -static unsigned long ntom_step = NTOM_MUL; - - -void mpgdec_synth_ntom_set_step(long m,long n) -{ - if(n >= 96000 || m >= 96000 || m == 0 || n == 0) { - fprintf(stderr,"resampler: illegal rates\n"); - exit(1); - } - - n *= NTOM_MUL; - ntom_step = n / m; - - if(ntom_step > 8*NTOM_MUL) { - fprintf(stderr,"max. 1:8 conversion allowed!\n"); - exit(1); - } - - ntom_val[0] = ntom_val[1] = NTOM_MUL>>1; -} - -int mpgdec_synth_ntom_8bit(mpgdec_real *bandPtr,int channel,unsigned char *samples,int *pnt) -{ - short samples_tmp[8*64]; - short *tmp1 = samples_tmp + channel; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_ntom(bandPtr,channel,(unsigned char *) samples_tmp,&pnt1); - samples += channel + *pnt; - - for(i=0;i<(pnt1>>2);i++) { - *samples = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - samples += 2; - tmp1 += 2; - } - *pnt += pnt1>>1; - - return ret; -} - -int mpgdec_synth_ntom_8bit_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[8*64]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_ntom(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<(pnt1>>2);i++) { - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - tmp1 += 2; - } - *pnt += pnt1 >> 2; - - return ret; -} - -int mpgdec_synth_ntom_8bit_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[8*64]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_ntom(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<(pnt1>>2);i++) { - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - *samples++ = mpgdec_conv16to8[*tmp1>>AUSHIFT]; - tmp1 += 2; - } - *pnt += pnt1 >> 1; - - return ret; -} - -int mpgdec_synth_ntom_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - short samples_tmp[8*64]; - short *tmp1 = samples_tmp; - int i,ret; - int pnt1 = 0; - - ret = mpgdec_synth_ntom(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); - samples += *pnt; - - for(i=0;i<(pnt1>>2);i++) { - *( (short *)samples) = *tmp1; - samples += 2; - tmp1 += 2; - } - *pnt += pnt1 >> 1; - - return ret; -} - - -int mpgdec_synth_ntom_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) -{ - int i,ret; - int pnt1 = *pnt; - - ret = mpgdec_synth_ntom(bandPtr,0,samples,pnt); - samples += pnt1; - - for(i=0;i<((*pnt-pnt1)>>2);i++) { - ((short *)samples)[1] = ((short *)samples)[0]; - samples+=4; - } - - return ret; -} - - -int mpgdec_synth_ntom(mpgdec_real *bandPtr,int channel,unsigned char *out,int *pnt) -{ - static mpgdec_real buffs[2][2][0x110]; - static const int step = 2; - static int bo = 1; - short *samples = (short *) (out + *pnt); - - mpgdec_real *b0,(*buf)[0x110]; - int clip = 0; - int bo1; - int ntom; - - 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; - mpgdec_dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr); - } - else { - b0 = buf[1]; - bo1 = bo+1; - mpgdec_dct64(buf[0]+bo,buf[1]+bo+1,bandPtr); - } - - - { - register int j; - mpgdec_real *window = mpgdec_decwin + 16 - bo1; - - for (j=16;j;j--,window+=0x10) - { - mpgdec_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) - { - mpgdec_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) - { - mpgdec_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; -} - -
--- a/src/mpg123/rtsp.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* Audacious - Cross-platform multimedia player - * Copyright (C) 2006 Audacious development team. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include <glib.h> -#include <audacious/i18n.h> -#include <gtk/gtk.h> -#include <stdlib.h> -#include <string.h> -#include <stdio.h> - -#include <nemesi/rtp.h> -#include <nemesi/rtsp.h> -#include <audacious/util.h> - -#include "mpg123.h" - -extern gint mpgdec_bitrate, mpgdec_frequency, mpgdec_stereo; -extern gboolean mpgdec_stereo; - -//FIXME that's ugly! -static rtsp_ctrl *ctl; -static rtsp_session *sess; -static rtp_ssrc *ssrc; -static size_t foff; -static rtp_buff conf; -static rtp_frame fr; -static rtp_thread *rtp_th; - -int mpgdec_rtsp_open(char *url) -{ -// nms_verbosity_set(0); - nms_rtsp_hints rtsp_hints = { -1 }; - foff = 0; - - if ( (ctl = rtsp_init(&rtsp_hints))==NULL ) { - fprintf (stderr, "Cannot init rtsp.\n"); - return 1; - } - - if ( rtsp_open( ctl, url) ) - { - fprintf (stderr, "rtsp_open failed.\n"); - // die - return 1; - } - - rtsp_wait(ctl); - - sess = ctl->rtsp_queue; - - if (!sess) { - fprintf (stderr, "No session available.\n"); - return 1; - } -//look for the first mp3 track - rtsp_play(ctl,0.0,0.0); - - rtp_th = rtsp_get_rtp_th(ctl); - - rtp_fill_buffers(rtp_th); - - for (ssrc = rtp_active_ssrc_queue(rtsp_get_rtp_queue(ctl)); - ssrc; ssrc = rtp_next_active_ssrc(ssrc)) { - if (ssrc->rtp_sess->announced_fmts->pt == 14) { - return 0; - } - } - return 1; -} - -int mpgdec_rtsp_read(gpointer data, gsize length) -{ - gint ret = 0, len; - gsize off = 0; - while (length && !ret && !rtp_fill_buffers(rtp_th)){ - if (!foff) - ret = rtp_fill_buffer(ssrc, &fr, &conf); - len = min(length, fr.len - foff); - memcpy((char *)data + off, fr.data + foff, len); - length -= len; - off += len; - foff = (len+foff)%fr.len; - } - return off; -} - -void mpgdec_rtsp_close (void) -{ - foff = 0; - rtsp_close(ctl); - -} -
--- a/src/mpg123/tabinit.c Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,117 +0,0 @@ - -#include <stdlib.h> -#include <math.h> - -#include "mpg123.h" - -mpgdec_real mpgdec_decwin[512 + 32]; -static mpgdec_real cos64[16], cos32[8], cos16[4], cos8[2], cos4[1]; -mpgdec_real *mpgdec_pnts[] = { cos64, cos32, cos16, cos8, cos4 }; - -static unsigned char *mpgdec_conv16to8_buf = NULL; -unsigned char *mpgdec_conv16to8; - -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 mpgdec_make_decode_tables_fpu(long scaleval); -void mpgdec_make_decode_tables_mmx(long scaleval); - -void -mpgdec_make_decode_tables_fpu(long scaleval) -{ - int i, j; - mpgdec_real *table, *costab; - - for (i = 0; i < 5; i++) { - int kr = 0x10 >> i; - int divv = 0x40 >> i; - costab = mpgdec_pnts[i]; - for (j = 0; j < kr; j++) - costab[j] = - 1.0 / (2.0 * - cos(M_PI * ((double) j * 2.0 + 1.0) / (double) divv)); - } - - table = mpgdec_decwin; - scaleval = -scaleval; - for (i = 0, j = 0; i < 256; i++, j++, table += 32) { - if (table < mpgdec_decwin + 512 + 16) - table[16] = table[0] = - (double) intwinbase[j] / 65536.0 * (double) scaleval; - if (i % 32 == 31) - table -= 1023; - if (i % 64 == 63) - scaleval = -scaleval; - } - - for ( /* i=256 */ ; i < 512; i++, j--, table += 32) { - if (table < mpgdec_decwin + 512 + 16) - table[16] = table[0] = - (double) intwinbase[j] / 65536.0 * (double) scaleval; - if (i % 32 == 31) - table -= 1023; - if (i % 64 == 63) - scaleval = -scaleval; - } -} - -void -mpgdec_make_decode_tables_mmx(long scaleval) -{ -} - -void -mpgdec_make_decode_tables(long scaleval) -{ - mpgdec_make_decode_tables_fpu(scaleval); - mpgdec_make_decode_tables_mmx(scaleval); -} - - - - -void -mpgdec_make_conv16to8_table(void) -{ - int i; - - /* - * ????: 8.0 is right but on SB cards '2.0' is a better value ??? - */ - - if (!mpgdec_conv16to8_buf) { - mpgdec_conv16to8_buf = g_malloc(8192); - mpgdec_conv16to8 = mpgdec_conv16to8_buf + 4096; - } - - for (i = -4096; i < 4096; i++) { - mpgdec_conv16to8[i] = (i >> 5) + 128; - } -}
--- a/src/mpg123/tag_c_hacked.cxx Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -#include <tag.h> -#include <id3v2framefactory.h> - -extern "C" -{ -#include "tag_c_hacked.h" -} -using namespace TagLib; -using namespace ID3v2; -void taglib_set_id3v2_default_text_encoding() -{ - TagLib::ID3v2::FrameFactory::instance()->setDefaultTextEncoding(TagLib::String::UTF8); -} -
--- a/src/mpg123/tag_c_hacked.h Thu Feb 08 01:52:27 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -#ifndef TAGLIB_TAG_C_HACKED -#define TAGLIB_TAG_C_HACKED - -#ifdef __cplusplus -extern "C" { -#endif -void taglib_set_id3v2_default_text_encoding(); -#ifdef __cplusplus -} -#endif -#endif