Initial community commit
This commit is contained in:
parent
537bcbc862
commit
fc06254474
16440 changed files with 4239995 additions and 2 deletions
16
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/AUTHORS
vendored
Normal file
16
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/AUTHORS
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
Michael Hipp <mh@mpg123.de> Author of orignal mpglib version 0.2a.
|
||||
|
||||
Albert L. Faber <afaber@users.sf.net>
|
||||
Aleksander Korzynski <olcios@users.sf.net>
|
||||
Alexander Leidinger <aleidinger@users.sf.net>
|
||||
Frank Klemm <pfk@users.sf.net>
|
||||
Gabriel Bouvigne <bouvigne@users.sf.net>
|
||||
Leigh Smith <leighsmith@users.sf.net>
|
||||
Mark Taylor <markt@users.sf.net>
|
||||
Myers Carpenter <myers@users.sf.net>
|
||||
Naoki Shibata <shibatch@users.sf.net>
|
||||
Robert Hegemann <robert@users.sf.net>
|
||||
Sigbjorn Skjaeret <cisc@users.sf.net>
|
||||
Stefan Bellon <sbellon@users.sf.net>
|
||||
Steve Lhomme <robux4@users.sf.net>
|
||||
Takehiro TOMINAGA <takehiro@users.sf.net>
|
364
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/common.c
vendored
Normal file
364
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/common.c
vendored
Normal file
|
@ -0,0 +1,364 @@
|
|||
/*
|
||||
* common.c: some common bitstream operations
|
||||
*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: common.c,v 1.42 2017/08/19 14:20:27 robert Exp $ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef macintosh
|
||||
#include <types.h>
|
||||
#include <stat.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef WITH_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
#endif
|
||||
|
||||
/* In C++ the array first must be prototyped, why ? */
|
||||
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
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 long freqs[9] = { 44100, 48000, 32000,
|
||||
22050, 24000, 16000,
|
||||
11025, 12000, 8000 };
|
||||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
|
||||
real muls[27][64];
|
||||
|
||||
#if 0
|
||||
static void
|
||||
get_II_stuff(struct frame *fr)
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
static const int translate [3] [2] [16] = /* char ? */
|
||||
{ { { 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 } } };
|
||||
/* *INDENT-ON* */
|
||||
|
||||
int table, sblim;
|
||||
static const struct al_table2 *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;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define HDRCMPMASK 0xfffffd00
|
||||
|
||||
#define MAX_INPUT_FRAMESIZE 4096
|
||||
|
||||
int
|
||||
head_check(unsigned long head, int check_layer)
|
||||
{
|
||||
/*
|
||||
look for a valid header.
|
||||
if check_layer > 0, then require that
|
||||
nLayer = check_layer.
|
||||
*/
|
||||
|
||||
/* bits 13-14 = layer 3 */
|
||||
int nLayer = 4 - ((head >> 17) & 3);
|
||||
|
||||
if ((head & 0xffe00000) != 0xffe00000) {
|
||||
/* syncword */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (nLayer == 4)
|
||||
return FALSE;
|
||||
|
||||
if (check_layer > 0 && nLayer != check_layer)
|
||||
return FALSE;
|
||||
|
||||
if (((head >> 12) & 0xf) == 0xf) {
|
||||
/* bits 16,17,18,19 = 1111 invalid bitrate */
|
||||
return FALSE;
|
||||
}
|
||||
if (((head >> 10) & 0x3) == 0x3) {
|
||||
/* bits 20,21 = 11 invalid sampling freq */
|
||||
return FALSE;
|
||||
}
|
||||
if ((head & 0x3) == 0x2)
|
||||
/* invalid emphasis */
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static void
|
||||
print_header(PMPSTR mp, struct frame *fr)
|
||||
{
|
||||
static const char *modes[4] = { "Stereo", "Joint-Stereo", "Dual-Channel", "Single-Channel" };
|
||||
static const char *layers[4] = { "Unknown", "I", "II", "III" };
|
||||
|
||||
lame_report_fnc(mp->report_msg, "MPEG %s, Layer: %s, Freq: %ld, mode: %s, modext: %d, BPF : %d\n",
|
||||
fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
|
||||
layers[fr->lay], freqs[fr->sampling_frequency],
|
||||
modes[fr->mode], fr->mode_ext, fr->framesize + 4);
|
||||
lame_report_fnc(mp->report_msg, "Channels: %d, copyright: %s, original: %s, CRC: %s, emphasis: %d.\n",
|
||||
fr->stereo, fr->copyright ? "Yes" : "No",
|
||||
fr->original ? "Yes" : "No", fr->error_protection ? "Yes" : "No", fr->emphasis);
|
||||
lame_report_fnc(mp->report_msg, "Bitrate: %d Kbits/s, Extension value: %d\n",
|
||||
tabsel_123[fr->lsf][fr->lay - 1][fr->bitrate_index], fr->extension);
|
||||
}
|
||||
|
||||
static void
|
||||
print_header_compact(PMPSTR mp, struct frame *fr)
|
||||
{
|
||||
static const char *modes[4] = { "stereo", "joint-stereo", "dual-channel", "mono" };
|
||||
static const char *layers[4] = { "Unknown", "I", "II", "III" };
|
||||
|
||||
lame_report_fnc(mp->report_err, "MPEG %s layer %s, %d kbit/s, %ld Hz %s\n",
|
||||
fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
|
||||
layers[fr->lay],
|
||||
tabsel_123[fr->lsf][fr->lay - 1][fr->bitrate_index],
|
||||
freqs[fr->sampling_frequency], modes[fr->mode]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* decode a header and write the information
|
||||
* into the frame structure
|
||||
*/
|
||||
int
|
||||
decode_header(PMPSTR mp, 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->lay != 3 && fr->mpeg25) {
|
||||
lame_report_fnc(mp->report_err, "MPEG-2.5 is supported by Layer3 only\n");
|
||||
return 0;
|
||||
}
|
||||
if (((newhead >> 10) & 0x3) == 0x3) {
|
||||
lame_report_fnc(mp->report_err, "Stream error\n");
|
||||
return 0;
|
||||
}
|
||||
if (fr->mpeg25) {
|
||||
fr->sampling_frequency = 6 + ((newhead >> 10) & 0x3);
|
||||
}
|
||||
else
|
||||
fr->sampling_frequency = ((newhead >> 10) & 0x3) + (fr->lsf * 3);
|
||||
|
||||
fr->error_protection = ((newhead >> 16) & 0x1) ^ 0x1;
|
||||
|
||||
if (fr->mpeg25) /* allow Bitrate change for 2.5 ... */
|
||||
fr->bitrate_index = ((newhead >> 12) & 0xf);
|
||||
|
||||
fr->bitrate_index = ((newhead >> 12) & 0xf);
|
||||
fr->padding = ((newhead >> 9) & 0x1);
|
||||
fr->extension = ((newhead >> 8) & 0x1);
|
||||
fr->mode = ((newhead >> 6) & 0x3);
|
||||
fr->mode_ext = ((newhead >> 4) & 0x3);
|
||||
fr->copyright = ((newhead >> 3) & 0x1);
|
||||
fr->original = ((newhead >> 2) & 0x1);
|
||||
fr->emphasis = newhead & 0x3;
|
||||
|
||||
fr->stereo = (fr->mode == MPG_MD_MONO) ? 1 : 2;
|
||||
|
||||
switch (fr->lay) {
|
||||
case 1:
|
||||
fr->framesize = (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000;
|
||||
fr->framesize /= freqs[fr->sampling_frequency];
|
||||
fr->framesize = ((fr->framesize + fr->padding) << 2) - 4;
|
||||
fr->down_sample = 0;
|
||||
fr->down_sample_sblimit = SBLIMIT >> (fr->down_sample);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
fr->framesize = (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000;
|
||||
fr->framesize /= freqs[fr->sampling_frequency];
|
||||
fr->framesize += fr->padding - 4;
|
||||
fr->down_sample = 0;
|
||||
fr->down_sample_sblimit = SBLIMIT >> (fr->down_sample);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
#if 0
|
||||
fr->do_layer = do_layer3;
|
||||
if (fr->lsf)
|
||||
ssize = (fr->stereo == 1) ? 9 : 17;
|
||||
else
|
||||
ssize = (fr->stereo == 1) ? 17 : 32;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (fr->error_protection)
|
||||
ssize += 2;
|
||||
#endif
|
||||
if (fr->framesize > MAX_INPUT_FRAMESIZE) {
|
||||
lame_report_fnc(mp->report_err, "Frame size too big.\n");
|
||||
fr->framesize = MAX_INPUT_FRAMESIZE;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
if (fr->bitrate_index == 0)
|
||||
fr->framesize = 0;
|
||||
else {
|
||||
fr->framesize = (long) tabsel_123[fr->lsf][2][fr->bitrate_index] * 144000;
|
||||
fr->framesize /= freqs[fr->sampling_frequency] << (fr->lsf);
|
||||
fr->framesize = fr->framesize + fr->padding - 4;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
lame_report_fnc(mp->report_err, "Sorry, layer %d not supported\n", fr->lay);
|
||||
return (0);
|
||||
}
|
||||
/* print_header(mp, fr); */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
getbits(PMPSTR mp, int number_of_bits)
|
||||
{
|
||||
unsigned long rval;
|
||||
|
||||
if (number_of_bits <= 0 || !mp->wordpointer)
|
||||
return 0;
|
||||
|
||||
{
|
||||
rval = mp->wordpointer[0];
|
||||
rval <<= 8;
|
||||
rval |= mp->wordpointer[1];
|
||||
rval <<= 8;
|
||||
rval |= mp->wordpointer[2];
|
||||
rval <<= mp->bitindex;
|
||||
rval &= 0xffffff;
|
||||
|
||||
mp->bitindex += number_of_bits;
|
||||
|
||||
rval >>= (24 - number_of_bits);
|
||||
|
||||
mp->wordpointer += (mp->bitindex >> 3);
|
||||
mp->bitindex &= 7;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
getbits_fast(PMPSTR mp, int number_of_bits)
|
||||
{
|
||||
unsigned long rval;
|
||||
|
||||
{
|
||||
rval = mp->wordpointer[0];
|
||||
rval <<= 8;
|
||||
rval |= mp->wordpointer[1];
|
||||
rval <<= mp->bitindex;
|
||||
rval &= 0xffff;
|
||||
mp->bitindex += number_of_bits;
|
||||
|
||||
rval >>= (16 - number_of_bits);
|
||||
|
||||
mp->wordpointer += (mp->bitindex >> 3);
|
||||
mp->bitindex &= 7;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
get_leq_8_bits(PMPSTR mp, unsigned int number_of_bits)
|
||||
{
|
||||
assert(number_of_bits <= 8);
|
||||
return (unsigned char) getbits_fast(mp, number_of_bits);
|
||||
}
|
||||
|
||||
unsigned short
|
||||
get_leq_16_bits(PMPSTR mp, unsigned int number_of_bits)
|
||||
{
|
||||
assert(number_of_bits <= 16);
|
||||
return (unsigned short) getbits_fast(mp, number_of_bits);
|
||||
}
|
||||
|
||||
int
|
||||
set_pointer(PMPSTR mp, long backstep)
|
||||
{
|
||||
unsigned char *bsbufold;
|
||||
|
||||
if (mp->fsizeold < 0 && backstep > 0) {
|
||||
lame_report_fnc(mp->report_err, "hip: Can't step back %ld bytes!\n", backstep);
|
||||
return MP3_ERR;
|
||||
}
|
||||
bsbufold = mp->bsspace[1 - mp->bsnum] + 512;
|
||||
mp->wordpointer -= backstep;
|
||||
if (backstep)
|
||||
memcpy(mp->wordpointer, bsbufold + mp->fsizeold - backstep, (size_t) backstep);
|
||||
mp->bitindex = 0;
|
||||
return MP3_OK;
|
||||
}
|
43
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/common.h
vendored
Normal file
43
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/common.h
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef COMMON_H_INCLUDED
|
||||
#define COMMON_H_INCLUDED
|
||||
|
||||
#include "mpg123.h"
|
||||
#include "mpglib.h"
|
||||
|
||||
extern const int tabsel_123[2][3][16];
|
||||
extern const long freqs[9];
|
||||
|
||||
extern real muls[27][64];
|
||||
|
||||
|
||||
int head_check(unsigned long head, int check_layer);
|
||||
int decode_header(PMPSTR mp, struct frame *fr, unsigned long newhead);
|
||||
unsigned int getbits(PMPSTR mp, int number_of_bits);
|
||||
unsigned int getbits_fast(PMPSTR mp, int number_of_bits);
|
||||
unsigned char get_leq_8_bits(PMPSTR mp, unsigned int number_of_bits);
|
||||
unsigned short get_leq_16_bits(PMPSTR mp, unsigned int number_of_bits);
|
||||
int set_pointer(PMPSTR mp, long backstep);
|
||||
|
||||
#endif
|
348
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/dct64_i386.c
vendored
Normal file
348
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/dct64_i386.c
vendored
Normal file
|
@ -0,0 +1,348 @@
|
|||
/*
|
||||
* dct64_i368.c
|
||||
*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*
|
||||
* Discrete Cosine Tansform (DCT) for subband synthesis
|
||||
* optimized for machines with no auto-increment.
|
||||
* The performance is highly compiler dependend. Maybe
|
||||
* the dct64.c version for 'normal' processor may be faster
|
||||
* even for Intel processors.
|
||||
*/
|
||||
|
||||
/* $Id: dct64_i386.c,v 1.14 2010/03/22 14:30:19 robert Exp $ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "dct64_i386.h"
|
||||
#include "tabinit.h"
|
||||
|
||||
#ifdef WITH_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
dct64_1(real * out0, real * out1, real * b1, real * b2, real * samples)
|
||||
{
|
||||
|
||||
{
|
||||
real *costab = pnts[0];
|
||||
|
||||
b1[0x00] = samples[0x00] + samples[0x1F];
|
||||
b1[0x1F] = (samples[0x00] - samples[0x1F]) * costab[0x0];
|
||||
|
||||
b1[0x01] = samples[0x01] + samples[0x1E];
|
||||
b1[0x1E] = (samples[0x01] - samples[0x1E]) * costab[0x1];
|
||||
|
||||
b1[0x02] = samples[0x02] + samples[0x1D];
|
||||
b1[0x1D] = (samples[0x02] - samples[0x1D]) * costab[0x2];
|
||||
|
||||
b1[0x03] = samples[0x03] + samples[0x1C];
|
||||
b1[0x1C] = (samples[0x03] - samples[0x1C]) * costab[0x3];
|
||||
|
||||
b1[0x04] = samples[0x04] + samples[0x1B];
|
||||
b1[0x1B] = (samples[0x04] - samples[0x1B]) * costab[0x4];
|
||||
|
||||
b1[0x05] = samples[0x05] + samples[0x1A];
|
||||
b1[0x1A] = (samples[0x05] - samples[0x1A]) * costab[0x5];
|
||||
|
||||
b1[0x06] = samples[0x06] + samples[0x19];
|
||||
b1[0x19] = (samples[0x06] - samples[0x19]) * costab[0x6];
|
||||
|
||||
b1[0x07] = samples[0x07] + samples[0x18];
|
||||
b1[0x18] = (samples[0x07] - samples[0x18]) * costab[0x7];
|
||||
|
||||
b1[0x08] = samples[0x08] + samples[0x17];
|
||||
b1[0x17] = (samples[0x08] - samples[0x17]) * costab[0x8];
|
||||
|
||||
b1[0x09] = samples[0x09] + samples[0x16];
|
||||
b1[0x16] = (samples[0x09] - samples[0x16]) * costab[0x9];
|
||||
|
||||
b1[0x0A] = samples[0x0A] + samples[0x15];
|
||||
b1[0x15] = (samples[0x0A] - samples[0x15]) * costab[0xA];
|
||||
|
||||
b1[0x0B] = samples[0x0B] + samples[0x14];
|
||||
b1[0x14] = (samples[0x0B] - samples[0x14]) * costab[0xB];
|
||||
|
||||
b1[0x0C] = samples[0x0C] + samples[0x13];
|
||||
b1[0x13] = (samples[0x0C] - samples[0x13]) * costab[0xC];
|
||||
|
||||
b1[0x0D] = samples[0x0D] + samples[0x12];
|
||||
b1[0x12] = (samples[0x0D] - samples[0x12]) * costab[0xD];
|
||||
|
||||
b1[0x0E] = samples[0x0E] + samples[0x11];
|
||||
b1[0x11] = (samples[0x0E] - samples[0x11]) * costab[0xE];
|
||||
|
||||
b1[0x0F] = samples[0x0F] + samples[0x10];
|
||||
b1[0x10] = (samples[0x0F] - samples[0x10]) * costab[0xF];
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
real *costab = pnts[1];
|
||||
|
||||
b2[0x00] = b1[0x00] + b1[0x0F];
|
||||
b2[0x0F] = (b1[0x00] - b1[0x0F]) * costab[0];
|
||||
b2[0x01] = b1[0x01] + b1[0x0E];
|
||||
b2[0x0E] = (b1[0x01] - b1[0x0E]) * costab[1];
|
||||
b2[0x02] = b1[0x02] + b1[0x0D];
|
||||
b2[0x0D] = (b1[0x02] - b1[0x0D]) * costab[2];
|
||||
b2[0x03] = b1[0x03] + b1[0x0C];
|
||||
b2[0x0C] = (b1[0x03] - b1[0x0C]) * costab[3];
|
||||
b2[0x04] = b1[0x04] + b1[0x0B];
|
||||
b2[0x0B] = (b1[0x04] - b1[0x0B]) * costab[4];
|
||||
b2[0x05] = b1[0x05] + b1[0x0A];
|
||||
b2[0x0A] = (b1[0x05] - b1[0x0A]) * costab[5];
|
||||
b2[0x06] = b1[0x06] + b1[0x09];
|
||||
b2[0x09] = (b1[0x06] - b1[0x09]) * costab[6];
|
||||
b2[0x07] = b1[0x07] + b1[0x08];
|
||||
b2[0x08] = (b1[0x07] - b1[0x08]) * costab[7];
|
||||
|
||||
b2[0x10] = b1[0x10] + b1[0x1F];
|
||||
b2[0x1F] = (b1[0x1F] - b1[0x10]) * costab[0];
|
||||
b2[0x11] = b1[0x11] + b1[0x1E];
|
||||
b2[0x1E] = (b1[0x1E] - b1[0x11]) * costab[1];
|
||||
b2[0x12] = b1[0x12] + b1[0x1D];
|
||||
b2[0x1D] = (b1[0x1D] - b1[0x12]) * costab[2];
|
||||
b2[0x13] = b1[0x13] + b1[0x1C];
|
||||
b2[0x1C] = (b1[0x1C] - b1[0x13]) * costab[3];
|
||||
b2[0x14] = b1[0x14] + b1[0x1B];
|
||||
b2[0x1B] = (b1[0x1B] - b1[0x14]) * costab[4];
|
||||
b2[0x15] = b1[0x15] + b1[0x1A];
|
||||
b2[0x1A] = (b1[0x1A] - b1[0x15]) * costab[5];
|
||||
b2[0x16] = b1[0x16] + b1[0x19];
|
||||
b2[0x19] = (b1[0x19] - b1[0x16]) * costab[6];
|
||||
b2[0x17] = b1[0x17] + b1[0x18];
|
||||
b2[0x18] = (b1[0x18] - b1[0x17]) * costab[7];
|
||||
}
|
||||
|
||||
{
|
||||
real *costab = pnts[2];
|
||||
|
||||
b1[0x00] = b2[0x00] + b2[0x07];
|
||||
b1[0x07] = (b2[0x00] - b2[0x07]) * costab[0];
|
||||
b1[0x01] = b2[0x01] + b2[0x06];
|
||||
b1[0x06] = (b2[0x01] - b2[0x06]) * costab[1];
|
||||
b1[0x02] = b2[0x02] + b2[0x05];
|
||||
b1[0x05] = (b2[0x02] - b2[0x05]) * costab[2];
|
||||
b1[0x03] = b2[0x03] + b2[0x04];
|
||||
b1[0x04] = (b2[0x03] - b2[0x04]) * costab[3];
|
||||
|
||||
b1[0x08] = b2[0x08] + b2[0x0F];
|
||||
b1[0x0F] = (b2[0x0F] - b2[0x08]) * costab[0];
|
||||
b1[0x09] = b2[0x09] + b2[0x0E];
|
||||
b1[0x0E] = (b2[0x0E] - b2[0x09]) * costab[1];
|
||||
b1[0x0A] = b2[0x0A] + b2[0x0D];
|
||||
b1[0x0D] = (b2[0x0D] - b2[0x0A]) * costab[2];
|
||||
b1[0x0B] = b2[0x0B] + b2[0x0C];
|
||||
b1[0x0C] = (b2[0x0C] - b2[0x0B]) * costab[3];
|
||||
|
||||
b1[0x10] = b2[0x10] + b2[0x17];
|
||||
b1[0x17] = (b2[0x10] - b2[0x17]) * costab[0];
|
||||
b1[0x11] = b2[0x11] + b2[0x16];
|
||||
b1[0x16] = (b2[0x11] - b2[0x16]) * costab[1];
|
||||
b1[0x12] = b2[0x12] + b2[0x15];
|
||||
b1[0x15] = (b2[0x12] - b2[0x15]) * costab[2];
|
||||
b1[0x13] = b2[0x13] + b2[0x14];
|
||||
b1[0x14] = (b2[0x13] - b2[0x14]) * costab[3];
|
||||
|
||||
b1[0x18] = b2[0x18] + b2[0x1F];
|
||||
b1[0x1F] = (b2[0x1F] - b2[0x18]) * costab[0];
|
||||
b1[0x19] = b2[0x19] + b2[0x1E];
|
||||
b1[0x1E] = (b2[0x1E] - b2[0x19]) * costab[1];
|
||||
b1[0x1A] = b2[0x1A] + b2[0x1D];
|
||||
b1[0x1D] = (b2[0x1D] - b2[0x1A]) * costab[2];
|
||||
b1[0x1B] = b2[0x1B] + b2[0x1C];
|
||||
b1[0x1C] = (b2[0x1C] - b2[0x1B]) * costab[3];
|
||||
}
|
||||
|
||||
{
|
||||
real const cos0 = pnts[3][0];
|
||||
real const cos1 = pnts[3][1];
|
||||
|
||||
b2[0x00] = b1[0x00] + b1[0x03];
|
||||
b2[0x03] = (b1[0x00] - b1[0x03]) * cos0;
|
||||
b2[0x01] = b1[0x01] + b1[0x02];
|
||||
b2[0x02] = (b1[0x01] - b1[0x02]) * cos1;
|
||||
|
||||
b2[0x04] = b1[0x04] + b1[0x07];
|
||||
b2[0x07] = (b1[0x07] - b1[0x04]) * cos0;
|
||||
b2[0x05] = b1[0x05] + b1[0x06];
|
||||
b2[0x06] = (b1[0x06] - b1[0x05]) * cos1;
|
||||
|
||||
b2[0x08] = b1[0x08] + b1[0x0B];
|
||||
b2[0x0B] = (b1[0x08] - b1[0x0B]) * cos0;
|
||||
b2[0x09] = b1[0x09] + b1[0x0A];
|
||||
b2[0x0A] = (b1[0x09] - b1[0x0A]) * cos1;
|
||||
|
||||
b2[0x0C] = b1[0x0C] + b1[0x0F];
|
||||
b2[0x0F] = (b1[0x0F] - b1[0x0C]) * cos0;
|
||||
b2[0x0D] = b1[0x0D] + b1[0x0E];
|
||||
b2[0x0E] = (b1[0x0E] - b1[0x0D]) * cos1;
|
||||
|
||||
b2[0x10] = b1[0x10] + b1[0x13];
|
||||
b2[0x13] = (b1[0x10] - b1[0x13]) * cos0;
|
||||
b2[0x11] = b1[0x11] + b1[0x12];
|
||||
b2[0x12] = (b1[0x11] - b1[0x12]) * cos1;
|
||||
|
||||
b2[0x14] = b1[0x14] + b1[0x17];
|
||||
b2[0x17] = (b1[0x17] - b1[0x14]) * cos0;
|
||||
b2[0x15] = b1[0x15] + b1[0x16];
|
||||
b2[0x16] = (b1[0x16] - b1[0x15]) * cos1;
|
||||
|
||||
b2[0x18] = b1[0x18] + b1[0x1B];
|
||||
b2[0x1B] = (b1[0x18] - b1[0x1B]) * cos0;
|
||||
b2[0x19] = b1[0x19] + b1[0x1A];
|
||||
b2[0x1A] = (b1[0x19] - b1[0x1A]) * cos1;
|
||||
|
||||
b2[0x1C] = b1[0x1C] + b1[0x1F];
|
||||
b2[0x1F] = (b1[0x1F] - b1[0x1C]) * cos0;
|
||||
b2[0x1D] = b1[0x1D] + b1[0x1E];
|
||||
b2[0x1E] = (b1[0x1E] - b1[0x1D]) * cos1;
|
||||
}
|
||||
|
||||
{
|
||||
real const cos0 = pnts[4][0];
|
||||
|
||||
b1[0x00] = b2[0x00] + b2[0x01];
|
||||
b1[0x01] = (b2[0x00] - b2[0x01]) * cos0;
|
||||
b1[0x02] = b2[0x02] + b2[0x03];
|
||||
b1[0x03] = (b2[0x03] - b2[0x02]) * cos0;
|
||||
b1[0x02] += b1[0x03];
|
||||
|
||||
b1[0x04] = b2[0x04] + b2[0x05];
|
||||
b1[0x05] = (b2[0x04] - b2[0x05]) * cos0;
|
||||
b1[0x06] = b2[0x06] + b2[0x07];
|
||||
b1[0x07] = (b2[0x07] - b2[0x06]) * cos0;
|
||||
b1[0x06] += b1[0x07];
|
||||
b1[0x04] += b1[0x06];
|
||||
b1[0x06] += b1[0x05];
|
||||
b1[0x05] += b1[0x07];
|
||||
|
||||
b1[0x08] = b2[0x08] + b2[0x09];
|
||||
b1[0x09] = (b2[0x08] - b2[0x09]) * cos0;
|
||||
b1[0x0A] = b2[0x0A] + b2[0x0B];
|
||||
b1[0x0B] = (b2[0x0B] - b2[0x0A]) * cos0;
|
||||
b1[0x0A] += b1[0x0B];
|
||||
|
||||
b1[0x0C] = b2[0x0C] + b2[0x0D];
|
||||
b1[0x0D] = (b2[0x0C] - b2[0x0D]) * cos0;
|
||||
b1[0x0E] = b2[0x0E] + b2[0x0F];
|
||||
b1[0x0F] = (b2[0x0F] - b2[0x0E]) * cos0;
|
||||
b1[0x0E] += b1[0x0F];
|
||||
b1[0x0C] += b1[0x0E];
|
||||
b1[0x0E] += b1[0x0D];
|
||||
b1[0x0D] += b1[0x0F];
|
||||
|
||||
b1[0x10] = b2[0x10] + b2[0x11];
|
||||
b1[0x11] = (b2[0x10] - b2[0x11]) * cos0;
|
||||
b1[0x12] = b2[0x12] + b2[0x13];
|
||||
b1[0x13] = (b2[0x13] - b2[0x12]) * cos0;
|
||||
b1[0x12] += b1[0x13];
|
||||
|
||||
b1[0x14] = b2[0x14] + b2[0x15];
|
||||
b1[0x15] = (b2[0x14] - b2[0x15]) * cos0;
|
||||
b1[0x16] = b2[0x16] + b2[0x17];
|
||||
b1[0x17] = (b2[0x17] - b2[0x16]) * cos0;
|
||||
b1[0x16] += b1[0x17];
|
||||
b1[0x14] += b1[0x16];
|
||||
b1[0x16] += b1[0x15];
|
||||
b1[0x15] += b1[0x17];
|
||||
|
||||
b1[0x18] = b2[0x18] + b2[0x19];
|
||||
b1[0x19] = (b2[0x18] - b2[0x19]) * cos0;
|
||||
b1[0x1A] = b2[0x1A] + b2[0x1B];
|
||||
b1[0x1B] = (b2[0x1B] - b2[0x1A]) * cos0;
|
||||
b1[0x1A] += b1[0x1B];
|
||||
|
||||
b1[0x1C] = b2[0x1C] + b2[0x1D];
|
||||
b1[0x1D] = (b2[0x1C] - b2[0x1D]) * cos0;
|
||||
b1[0x1E] = b2[0x1E] + b2[0x1F];
|
||||
b1[0x1F] = (b2[0x1F] - b2[0x1E]) * cos0;
|
||||
b1[0x1E] += b1[0x1F];
|
||||
b1[0x1C] += b1[0x1E];
|
||||
b1[0x1E] += b1[0x1D];
|
||||
b1[0x1D] += b1[0x1F];
|
||||
}
|
||||
|
||||
out0[0x10 * 16] = b1[0x00];
|
||||
out0[0x10 * 12] = b1[0x04];
|
||||
out0[0x10 * 8] = b1[0x02];
|
||||
out0[0x10 * 4] = b1[0x06];
|
||||
out0[0x10 * 0] = b1[0x01];
|
||||
out1[0x10 * 0] = b1[0x01];
|
||||
out1[0x10 * 4] = b1[0x05];
|
||||
out1[0x10 * 8] = b1[0x03];
|
||||
out1[0x10 * 12] = b1[0x07];
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
/*
|
||||
* the call via dct64 is a trick to force GCC to use
|
||||
* (new) registers for the b1,b2 pointer to the bufs[xx] field
|
||||
*/
|
||||
void
|
||||
dct64(real * a, real * b, real * c)
|
||||
{
|
||||
real bufs[0x40];
|
||||
dct64_1(a, b, bufs, bufs + 0x20, c);
|
||||
}
|
30
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/dct64_i386.h
vendored
Normal file
30
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/dct64_i386.h
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef MPGLIB_DCT64_I386_H_INCLUDED
|
||||
#define MPGLIB_DCT64_I386_H_INCLUDED
|
||||
|
||||
#include "common.h"
|
||||
|
||||
void dct64(real * a, real * b, real * c);
|
||||
|
||||
|
||||
#endif
|
224
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/decode_i386.c
vendored
Normal file
224
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/decode_i386.c
vendored
Normal file
|
@ -0,0 +1,224 @@
|
|||
/*
|
||||
* decode_i396.c: Mpeg Layer-1,2,3 audio decoder
|
||||
*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*
|
||||
* Slighlty optimized for machines without autoincrement/decrement.
|
||||
* The performance is highly compiler dependend. Maybe
|
||||
* the decode.c version for 'normal' processor may be faster
|
||||
* even for Intel processors.
|
||||
*/
|
||||
|
||||
/* $Id: decode_i386.c,v 1.22 2010/03/22 14:30:19 robert Exp $ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#else
|
||||
# ifndef HAVE_STRCHR
|
||||
# define strchr index
|
||||
# define strrchr rindex
|
||||
# endif
|
||||
char *strchr(), *strrchr();
|
||||
# ifndef HAVE_MEMCPY
|
||||
# define memcpy(d, s, n) bcopy ((s), (d), (n))
|
||||
# define memmove(d, s, n) bcopy ((s), (d), (n))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__riscos__) && defined(FPA10)
|
||||
#include "ymath.h"
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#include "decode_i386.h"
|
||||
#include "dct64_i386.h"
|
||||
#include "tabinit.h"
|
||||
|
||||
#ifdef WITH_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* old WRITE_SAMPLE_CLIPPED */
|
||||
#define WRITE_SAMPLE_CLIPPED(TYPE,samples,sum,clip) \
|
||||
if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
|
||||
else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
|
||||
else { *(samples) = (TYPE)((sum)>0 ? (sum)+0.5 : (sum)-0.5) ; }
|
||||
|
||||
#define WRITE_SAMPLE_UNCLIPPED(TYPE,samples,sum,clip) \
|
||||
*samples = (TYPE)sum;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
/* versions: clipped (when TYPE == short) and unclipped (when TYPE == real) of synth_1to1_mono* functions */
|
||||
#define SYNTH_1TO1_MONO_CLIPCHOICE(TYPE,SYNTH_1TO1) \
|
||||
TYPE samples_tmp[64]; \
|
||||
TYPE *tmp1 = samples_tmp; \
|
||||
int i,ret; \
|
||||
int pnt1 = 0; \
|
||||
\
|
||||
ret = SYNTH_1TO1 (mp,bandPtr,0,(unsigned char *) samples_tmp,&pnt1); \
|
||||
out += *pnt; \
|
||||
\
|
||||
for(i=0;i<32;i++) { \
|
||||
*( (TYPE *) out) = *tmp1; \
|
||||
out += sizeof(TYPE); \
|
||||
tmp1 += 2; \
|
||||
} \
|
||||
*pnt += 32*sizeof(TYPE); \
|
||||
\
|
||||
return ret;
|
||||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
|
||||
int
|
||||
synth_1to1_mono(PMPSTR mp, real * bandPtr, unsigned char *out, int *pnt)
|
||||
{
|
||||
SYNTH_1TO1_MONO_CLIPCHOICE(short, synth_1to1)
|
||||
} int
|
||||
synth_1to1_mono_unclipped(PMPSTR mp, real * bandPtr, unsigned char *out, int *pnt)
|
||||
{
|
||||
SYNTH_1TO1_MONO_CLIPCHOICE(real, synth_1to1_unclipped)
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
/* versions: clipped (when TYPE == short) and unclipped (when TYPE == real) of synth_1to1* functions */
|
||||
#define SYNTH_1TO1_CLIPCHOICE(TYPE,WRITE_SAMPLE) \
|
||||
static const int step = 2; \
|
||||
int bo; \
|
||||
TYPE *samples = (TYPE *) (out + *pnt); \
|
||||
\
|
||||
real *b0,(*buf)[0x110]; \
|
||||
int clip = 0; \
|
||||
int bo1; \
|
||||
\
|
||||
bo = mp->synth_bo; \
|
||||
\
|
||||
if(!channel) { \
|
||||
bo--; \
|
||||
bo &= 0xf; \
|
||||
buf = mp->synth_buffs[0]; \
|
||||
} \
|
||||
else { \
|
||||
samples++; \
|
||||
buf = mp->synth_buffs[1]; \
|
||||
} \
|
||||
\
|
||||
if(bo & 0x1) { \
|
||||
b0 = buf[0]; \
|
||||
bo1 = bo; \
|
||||
dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr); \
|
||||
} \
|
||||
else { \
|
||||
b0 = buf[1]; \
|
||||
bo1 = bo+1; \
|
||||
dct64(buf[0]+bo,buf[1]+bo+1,bandPtr); \
|
||||
} \
|
||||
\
|
||||
mp->synth_bo = bo; \
|
||||
\
|
||||
{ \
|
||||
int j; \
|
||||
real *window = decwin + 16 - bo1; \
|
||||
\
|
||||
for (j=16;j;j--,b0+=0x10,window+=0x20,samples+=step) \
|
||||
{ \
|
||||
real sum; \
|
||||
sum = window[0x0] * b0[0x0]; \
|
||||
sum -= window[0x1] * b0[0x1]; \
|
||||
sum += window[0x2] * b0[0x2]; \
|
||||
sum -= window[0x3] * b0[0x3]; \
|
||||
sum += window[0x4] * b0[0x4]; \
|
||||
sum -= window[0x5] * b0[0x5]; \
|
||||
sum += window[0x6] * b0[0x6]; \
|
||||
sum -= window[0x7] * b0[0x7]; \
|
||||
sum += window[0x8] * b0[0x8]; \
|
||||
sum -= window[0x9] * b0[0x9]; \
|
||||
sum += window[0xA] * b0[0xA]; \
|
||||
sum -= window[0xB] * b0[0xB]; \
|
||||
sum += window[0xC] * b0[0xC]; \
|
||||
sum -= window[0xD] * b0[0xD]; \
|
||||
sum += window[0xE] * b0[0xE]; \
|
||||
sum -= window[0xF] * b0[0xF]; \
|
||||
\
|
||||
WRITE_SAMPLE (TYPE,samples,sum,clip); \
|
||||
} \
|
||||
\
|
||||
{ \
|
||||
real sum; \
|
||||
sum = window[0x0] * b0[0x0]; \
|
||||
sum += window[0x2] * b0[0x2]; \
|
||||
sum += window[0x4] * b0[0x4]; \
|
||||
sum += window[0x6] * b0[0x6]; \
|
||||
sum += window[0x8] * b0[0x8]; \
|
||||
sum += window[0xA] * b0[0xA]; \
|
||||
sum += window[0xC] * b0[0xC]; \
|
||||
sum += window[0xE] * b0[0xE]; \
|
||||
WRITE_SAMPLE (TYPE,samples,sum,clip); \
|
||||
b0-=0x10,window-=0x20,samples+=step; \
|
||||
} \
|
||||
window += bo1<<1; \
|
||||
\
|
||||
for (j=15;j;j--,b0-=0x10,window-=0x20,samples+=step) \
|
||||
{ \
|
||||
real sum; \
|
||||
sum = -window[-0x1] * b0[0x0]; \
|
||||
sum -= window[-0x2] * b0[0x1]; \
|
||||
sum -= window[-0x3] * b0[0x2]; \
|
||||
sum -= window[-0x4] * b0[0x3]; \
|
||||
sum -= window[-0x5] * b0[0x4]; \
|
||||
sum -= window[-0x6] * b0[0x5]; \
|
||||
sum -= window[-0x7] * b0[0x6]; \
|
||||
sum -= window[-0x8] * b0[0x7]; \
|
||||
sum -= window[-0x9] * b0[0x8]; \
|
||||
sum -= window[-0xA] * b0[0x9]; \
|
||||
sum -= window[-0xB] * b0[0xA]; \
|
||||
sum -= window[-0xC] * b0[0xB]; \
|
||||
sum -= window[-0xD] * b0[0xC]; \
|
||||
sum -= window[-0xE] * b0[0xD]; \
|
||||
sum -= window[-0xF] * b0[0xE]; \
|
||||
sum -= window[-0x0] * b0[0xF]; \
|
||||
\
|
||||
WRITE_SAMPLE (TYPE,samples,sum,clip); \
|
||||
} \
|
||||
} \
|
||||
*pnt += 64*sizeof(TYPE); \
|
||||
\
|
||||
return clip;
|
||||
/* *INDENT-ON* */
|
||||
|
||||
|
||||
int
|
||||
synth_1to1(PMPSTR mp, real * bandPtr, int channel, unsigned char *out, int *pnt)
|
||||
{
|
||||
SYNTH_1TO1_CLIPCHOICE(short, WRITE_SAMPLE_CLIPPED)
|
||||
} int
|
||||
synth_1to1_unclipped(PMPSTR mp, real * bandPtr, int channel, unsigned char *out, int *pnt)
|
||||
{
|
||||
SYNTH_1TO1_CLIPCHOICE(real, WRITE_SAMPLE_UNCLIPPED)
|
||||
}
|
33
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/decode_i386.h
vendored
Normal file
33
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/decode_i386.h
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef DECODE_I386_H_INCLUDED
|
||||
#define DECODE_I386_H_INCLUDED
|
||||
|
||||
#include "common.h"
|
||||
|
||||
int synth_1to1_mono(PMPSTR mp, real * bandPtr, unsigned char *out, int *pnt);
|
||||
int synth_1to1(PMPSTR mp, real * bandPtr, int channel, unsigned char *out, int *pnt);
|
||||
|
||||
int synth_1to1_mono_unclipped(PMPSTR mp, real * bandPtr, unsigned char *out, int *pnt);
|
||||
int synth_1to1_unclipped(PMPSTR mp, real * bandPtr, int channel, unsigned char *out, int *pnt);
|
||||
|
||||
#endif
|
353
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/huffman.h
vendored
Normal file
353
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/huffman.h
vendored
Normal file
|
@ -0,0 +1,353 @@
|
|||
/*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
|
||||
struct newhuff
|
||||
{
|
||||
const unsigned int linbits;
|
||||
const short * const table;
|
||||
};
|
||||
|
||||
static const short tab0[] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
static const short tab1[] =
|
||||
{
|
||||
-5, -3, -1, 17, 1, 16, 0
|
||||
};
|
||||
|
||||
static const short tab2[] =
|
||||
{
|
||||
-15, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 17, -1, 1, 16, 0
|
||||
};
|
||||
|
||||
static const short tab3[] =
|
||||
{
|
||||
-13, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 16, 17, -1,
|
||||
1, 0
|
||||
};
|
||||
|
||||
static const 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 const 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 const 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 const 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 const 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 const 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 const 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 const 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 const 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 const 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 const 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 const 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 const 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 const 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 const 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 const struct newhuff htc[] =
|
||||
{
|
||||
{ /* 1 , 1 , */ 0 , tab_c0 } ,
|
||||
{ /* 1 , 1 , */ 0 , tab_c1 }
|
||||
};
|
||||
|
||||
/* *INDENT-ON* */
|
718
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/interface.c
vendored
Normal file
718
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/interface.c
vendored
Normal file
|
@ -0,0 +1,718 @@
|
|||
/*
|
||||
* interface.c
|
||||
*
|
||||
* Copyright (C) 1999-2012 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/* $Id: interface.c,v 1.69 2017/09/06 15:07:30 robert Exp $ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "interface.h"
|
||||
#include "tabinit.h"
|
||||
#include "layer3.h"
|
||||
#include "lame.h"
|
||||
#include "machine.h"
|
||||
#include "VbrTag.h"
|
||||
#include "decode_i386.h"
|
||||
|
||||
#include "layer1.h"
|
||||
#include "layer2.h"
|
||||
|
||||
#ifdef WITH_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
#endif
|
||||
|
||||
extern void lame_report_def(const char* format, va_list args);
|
||||
|
||||
/* #define HIP_DEBUG */
|
||||
|
||||
int
|
||||
InitMP3(PMPSTR mp)
|
||||
{
|
||||
hip_init_tables_layer1();
|
||||
hip_init_tables_layer2();
|
||||
hip_init_tables_layer3();
|
||||
|
||||
if (mp) {
|
||||
memset(mp, 0, sizeof(MPSTR));
|
||||
|
||||
mp->framesize = 0;
|
||||
mp->num_frames = 0;
|
||||
mp->enc_delay = -1;
|
||||
mp->enc_padding = -1;
|
||||
mp->vbr_header = 0;
|
||||
mp->header_parsed = 0;
|
||||
mp->side_parsed = 0;
|
||||
mp->data_parsed = 0;
|
||||
mp->free_format = 0;
|
||||
mp->old_free_format = 0;
|
||||
mp->ssize = 0;
|
||||
mp->dsize = 0;
|
||||
mp->fsizeold = -1;
|
||||
mp->bsize = 0;
|
||||
mp->head = mp->tail = NULL;
|
||||
mp->fr.single = -1;
|
||||
mp->bsnum = 0;
|
||||
mp->wordpointer = mp->bsspace[mp->bsnum] + 512;
|
||||
mp->bitindex = 0;
|
||||
mp->synth_bo = 1;
|
||||
mp->sync_bitstream = 1;
|
||||
|
||||
mp->report_dbg = &lame_report_def;
|
||||
mp->report_err = &lame_report_def;
|
||||
mp->report_msg = &lame_report_def;
|
||||
}
|
||||
make_decode_tables(32767);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
ExitMP3(PMPSTR mp)
|
||||
{
|
||||
if (mp) {
|
||||
struct buf *b, *bn;
|
||||
|
||||
b = mp->tail;
|
||||
while (b) {
|
||||
free(b->pnt);
|
||||
bn = b->next;
|
||||
free(b);
|
||||
b = bn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct buf *
|
||||
addbuf(PMPSTR mp, unsigned char *buf, int size)
|
||||
{
|
||||
struct buf *nbuf;
|
||||
|
||||
nbuf = (struct buf *) malloc(sizeof(struct buf));
|
||||
if (!nbuf) {
|
||||
lame_report_fnc(mp->report_err, "hip: addbuf() Out of memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
nbuf->pnt = (unsigned char *) malloc((size_t) size);
|
||||
if (!nbuf->pnt) {
|
||||
free(nbuf);
|
||||
return NULL;
|
||||
}
|
||||
nbuf->size = size;
|
||||
memcpy(nbuf->pnt, buf, (size_t) size);
|
||||
nbuf->next = NULL;
|
||||
nbuf->prev = mp->head;
|
||||
nbuf->pos = 0;
|
||||
|
||||
if (!mp->tail) {
|
||||
mp->tail = nbuf;
|
||||
}
|
||||
else {
|
||||
mp->head->next = nbuf;
|
||||
}
|
||||
|
||||
mp->head = nbuf;
|
||||
mp->bsize += size;
|
||||
|
||||
return nbuf;
|
||||
}
|
||||
|
||||
void
|
||||
remove_buf(PMPSTR mp)
|
||||
{
|
||||
struct buf *buf = mp->tail;
|
||||
|
||||
mp->tail = buf->next;
|
||||
if (mp->tail)
|
||||
mp->tail->prev = NULL;
|
||||
else {
|
||||
mp->tail = mp->head = NULL;
|
||||
}
|
||||
|
||||
free(buf->pnt);
|
||||
free(buf);
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
read_buf_byte(PMPSTR mp)
|
||||
{
|
||||
unsigned int b;
|
||||
|
||||
int pos;
|
||||
|
||||
|
||||
pos = mp->tail->pos;
|
||||
while (pos >= mp->tail->size) {
|
||||
remove_buf(mp);
|
||||
if (!mp->tail) {
|
||||
lame_report_fnc(mp->report_err, "hip: Fatal error! tried to read past mp buffer\n");
|
||||
exit(1);
|
||||
}
|
||||
pos = mp->tail->pos;
|
||||
}
|
||||
|
||||
b = mp->tail->pnt[pos];
|
||||
mp->bsize--;
|
||||
mp->tail->pos++;
|
||||
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
read_head(PMPSTR mp)
|
||||
{
|
||||
unsigned long head;
|
||||
|
||||
head = read_buf_byte(mp);
|
||||
head <<= 8;
|
||||
head |= read_buf_byte(mp);
|
||||
head <<= 8;
|
||||
head |= read_buf_byte(mp);
|
||||
head <<= 8;
|
||||
head |= read_buf_byte(mp);
|
||||
|
||||
mp->header = head;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
copy_mp(PMPSTR mp, int size, unsigned char *ptr)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
while (len < size && mp->tail) {
|
||||
int nlen;
|
||||
int blen = mp->tail->size - mp->tail->pos;
|
||||
if ((size - len) <= blen) {
|
||||
nlen = size - len;
|
||||
}
|
||||
else {
|
||||
nlen = blen;
|
||||
}
|
||||
memcpy(ptr + len, mp->tail->pnt + mp->tail->pos, (size_t) nlen);
|
||||
len += nlen;
|
||||
mp->tail->pos += nlen;
|
||||
mp->bsize -= nlen;
|
||||
if (mp->tail->pos == mp->tail->size) {
|
||||
remove_buf(mp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* number of bytes needed by GetVbrTag to parse header */
|
||||
#define XING_HEADER_SIZE 194
|
||||
|
||||
/*
|
||||
traverse mp data structure without changing it
|
||||
(just like sync_buffer)
|
||||
pull out Xing bytes
|
||||
call vbr header check code from LAME
|
||||
if we find a header, parse it and also compute the VBR header size
|
||||
if no header, do nothing.
|
||||
|
||||
bytes = number of bytes before MPEG header. skip this many bytes
|
||||
before starting to read
|
||||
return value: number of bytes in VBR header, including syncword
|
||||
*/
|
||||
static int
|
||||
check_vbr_header(PMPSTR mp, int bytes)
|
||||
{
|
||||
int i, pos;
|
||||
struct buf *buf = mp->tail;
|
||||
unsigned char xing[XING_HEADER_SIZE];
|
||||
VBRTAGDATA pTagData;
|
||||
|
||||
pos = buf->pos;
|
||||
/* skip to valid header */
|
||||
for (i = 0; i < bytes; ++i) {
|
||||
while (pos >= buf->size) {
|
||||
buf = buf->next;
|
||||
if (!buf)
|
||||
return -1; /* fatal error */
|
||||
pos = buf->pos;
|
||||
}
|
||||
++pos;
|
||||
}
|
||||
/* now read header */
|
||||
for (i = 0; i < XING_HEADER_SIZE; ++i) {
|
||||
while (pos >= buf->size) {
|
||||
buf = buf->next;
|
||||
if (!buf)
|
||||
return -1; /* fatal error */
|
||||
pos = buf->pos;
|
||||
}
|
||||
xing[i] = buf->pnt[pos];
|
||||
++pos;
|
||||
}
|
||||
|
||||
/* check first bytes for Xing header */
|
||||
mp->vbr_header = GetVbrTag(&pTagData, xing);
|
||||
if (mp->vbr_header) {
|
||||
mp->num_frames = pTagData.frames;
|
||||
mp->enc_delay = pTagData.enc_delay;
|
||||
mp->enc_padding = pTagData.enc_padding;
|
||||
|
||||
/* lame_report_fnc(mp->report_msg,"hip: delays: %i %i \n",mp->enc_delay,mp->enc_padding); */
|
||||
/* lame_report_fnc(mp->report_msg,"hip: Xing VBR header dectected. MP3 file has %i frames\n", pTagData.frames); */
|
||||
if (pTagData.headersize < 1)
|
||||
return 1;
|
||||
return pTagData.headersize;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int
|
||||
sync_buffer(PMPSTR mp, int free_match)
|
||||
{
|
||||
/* traverse mp structure without modifying pointers, looking
|
||||
* for a frame valid header.
|
||||
* if free_format, valid header must also have the same
|
||||
* samplerate.
|
||||
* return number of bytes in mp, before the header
|
||||
* return -1 if header is not found
|
||||
*/
|
||||
unsigned int b[4] = { 0, 0, 0, 0 };
|
||||
int i, h, pos;
|
||||
struct buf *buf = mp->tail;
|
||||
if (!buf)
|
||||
return -1;
|
||||
|
||||
pos = buf->pos;
|
||||
for (i = 0; i < mp->bsize; i++) {
|
||||
/* get 4 bytes */
|
||||
|
||||
b[0] = b[1];
|
||||
b[1] = b[2];
|
||||
b[2] = b[3];
|
||||
while (pos >= buf->size) {
|
||||
buf = buf->next;
|
||||
if (!buf) {
|
||||
return -1;
|
||||
/* not enough data to read 4 bytes */
|
||||
}
|
||||
pos = buf->pos;
|
||||
}
|
||||
b[3] = buf->pnt[pos];
|
||||
++pos;
|
||||
|
||||
if (i >= 3) {
|
||||
struct frame *fr = &mp->fr;
|
||||
unsigned long head;
|
||||
|
||||
head = b[0];
|
||||
head <<= 8;
|
||||
head |= b[1];
|
||||
head <<= 8;
|
||||
head |= b[2];
|
||||
head <<= 8;
|
||||
head |= b[3];
|
||||
h = head_check(head, fr->lay);
|
||||
|
||||
if (h && free_match) {
|
||||
/* just to be even more thorough, match the sample rate */
|
||||
int mode, stereo, sampling_frequency, mpeg25, lsf;
|
||||
|
||||
if (head & (1 << 20)) {
|
||||
lsf = (head & (1 << 19)) ? 0x0 : 0x1;
|
||||
mpeg25 = 0;
|
||||
}
|
||||
else {
|
||||
lsf = 1;
|
||||
mpeg25 = 1;
|
||||
}
|
||||
|
||||
mode = ((head >> 6) & 0x3);
|
||||
stereo = (mode == MPG_MD_MONO) ? 1 : 2;
|
||||
|
||||
if (mpeg25)
|
||||
sampling_frequency = 6 + ((head >> 10) & 0x3);
|
||||
else
|
||||
sampling_frequency = ((head >> 10) & 0x3) + (lsf * 3);
|
||||
h = ((stereo == fr->stereo) && (lsf == fr->lsf) && (mpeg25 == fr->mpeg25) &&
|
||||
(sampling_frequency == fr->sampling_frequency));
|
||||
}
|
||||
|
||||
if (h) {
|
||||
return i - 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
decode_reset(PMPSTR mp)
|
||||
{
|
||||
#if 0
|
||||
remove_buf(mp);
|
||||
/* start looking for next frame */
|
||||
/* mp->fsizeold = mp->framesize; */
|
||||
mp->fsizeold = -1;
|
||||
mp->old_free_format = mp->free_format;
|
||||
mp->framesize = 0;
|
||||
mp->header_parsed = 0;
|
||||
mp->side_parsed = 0;
|
||||
mp->data_parsed = 0;
|
||||
mp->sync_bitstream = 1; /* TODO check if this is right */
|
||||
#else
|
||||
InitMP3(mp); /* Less error prone to just to reinitialise. */
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
audiodata_precedesframes(PMPSTR mp)
|
||||
{
|
||||
if (mp->fr.lay == 3)
|
||||
return layer3_audiodata_precedesframes(mp);
|
||||
else
|
||||
return 0; /* For Layer 1 & 2 the audio data starts at the frame that describes it, so no audio data precedes. */
|
||||
}
|
||||
|
||||
static int
|
||||
decodeMP3_clipchoice(PMPSTR mp, unsigned char *in, int isize, char *out, int *done,
|
||||
int (*synth_1to1_mono_ptr) (PMPSTR, real *, unsigned char *, int *),
|
||||
int (*synth_1to1_ptr) (PMPSTR, real *, int, unsigned char *, int *))
|
||||
{
|
||||
int i, iret, bits, bytes;
|
||||
|
||||
if (in && isize && addbuf(mp, in, isize) == NULL)
|
||||
return MP3_ERR;
|
||||
|
||||
/* First decode header */
|
||||
if (!mp->header_parsed) {
|
||||
|
||||
if (mp->fsizeold == -1 || mp->sync_bitstream) {
|
||||
int vbrbytes;
|
||||
mp->sync_bitstream = 0;
|
||||
|
||||
/* This is the very first call. sync with anything */
|
||||
/* bytes= number of bytes before header */
|
||||
bytes = sync_buffer(mp, 0);
|
||||
|
||||
/* now look for Xing VBR header */
|
||||
if (mp->bsize >= bytes + XING_HEADER_SIZE) {
|
||||
/* vbrbytes = number of bytes in entire vbr header */
|
||||
vbrbytes = check_vbr_header(mp, bytes);
|
||||
}
|
||||
else {
|
||||
/* not enough data to look for Xing header */
|
||||
#ifdef HIP_DEBUG
|
||||
lame_report_fnc(mp->report_dbg, "hip: not enough data to look for Xing header\n");
|
||||
#endif
|
||||
return MP3_NEED_MORE;
|
||||
}
|
||||
|
||||
if (mp->vbr_header) {
|
||||
/* do we have enough data to parse entire Xing header? */
|
||||
if (bytes + vbrbytes > mp->bsize) {
|
||||
/* lame_report_fnc(mp->report_err,"hip: not enough data to parse entire Xing header\n"); */
|
||||
return MP3_NEED_MORE;
|
||||
}
|
||||
|
||||
/* read in Xing header. Buffer data in case it
|
||||
* is used by a non zero main_data_begin for the next
|
||||
* frame, but otherwise dont decode Xing header */
|
||||
#ifdef HIP_DEBUG
|
||||
lame_report_fnc(mp->report_dbg, "hip: found xing header, skipping %i bytes\n", vbrbytes + bytes);
|
||||
#endif
|
||||
for (i = 0; i < vbrbytes + bytes; ++i)
|
||||
read_buf_byte(mp);
|
||||
/* now we need to find another syncword */
|
||||
/* just return and make user send in more data */
|
||||
|
||||
return MP3_NEED_MORE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* match channels, samplerate, etc, when syncing */
|
||||
bytes = sync_buffer(mp, 1);
|
||||
}
|
||||
|
||||
/* buffer now synchronized */
|
||||
if (bytes < 0) {
|
||||
/* lame_report_fnc(mp->report_err,"hip: need more bytes %d\n", bytes); */
|
||||
return MP3_NEED_MORE;
|
||||
}
|
||||
if (bytes > 0) {
|
||||
/* there were some extra bytes in front of header.
|
||||
* bitstream problem, but we are now resynced
|
||||
* should try to buffer previous data in case new
|
||||
* frame has nonzero main_data_begin, but we need
|
||||
* to make sure we do not overflow buffer
|
||||
*/
|
||||
int size;
|
||||
if (mp->fsizeold != -1) {
|
||||
lame_report_fnc(mp->report_err, "hip: bitstream problem, resyncing skipping %d bytes...\n", bytes);
|
||||
}
|
||||
mp->old_free_format = 0;
|
||||
#if 1
|
||||
/* FIXME: correct ??? */
|
||||
mp->sync_bitstream = 1;
|
||||
#endif
|
||||
/* skip some bytes, buffer the rest */
|
||||
size = (int) (mp->wordpointer - (mp->bsspace[mp->bsnum] + 512));
|
||||
|
||||
if (size > MAXFRAMESIZE) {
|
||||
/* wordpointer buffer is trashed. probably cant recover, but try anyway */
|
||||
lame_report_fnc(mp->report_err, "hip: wordpointer trashed. size=%i (%i) bytes=%i \n",
|
||||
size, MAXFRAMESIZE, bytes);
|
||||
size = 0;
|
||||
mp->wordpointer = mp->bsspace[mp->bsnum] + 512;
|
||||
}
|
||||
|
||||
/* buffer contains 'size' data right now
|
||||
we want to add 'bytes' worth of data, but do not
|
||||
exceed MAXFRAMESIZE, so we through away 'i' bytes */
|
||||
i = (size + bytes) - MAXFRAMESIZE;
|
||||
for (; i > 0; --i) {
|
||||
--bytes;
|
||||
read_buf_byte(mp);
|
||||
}
|
||||
|
||||
copy_mp(mp, bytes, mp->wordpointer);
|
||||
mp->fsizeold += bytes;
|
||||
}
|
||||
|
||||
read_head(mp);
|
||||
if (!decode_header(mp, &mp->fr, mp->header))
|
||||
return MP3_ERR;
|
||||
mp->header_parsed = 1;
|
||||
mp->framesize = mp->fr.framesize;
|
||||
mp->free_format = (mp->framesize == 0);
|
||||
|
||||
if (mp->fr.lsf)
|
||||
mp->ssize = (mp->fr.stereo == 1) ? 9 : 17;
|
||||
else
|
||||
mp->ssize = (mp->fr.stereo == 1) ? 17 : 32;
|
||||
if (mp->fr.error_protection)
|
||||
mp->ssize += 2;
|
||||
|
||||
mp->bsnum = 1 - mp->bsnum; /* toggle buffer */
|
||||
mp->wordpointer = mp->bsspace[mp->bsnum] + 512;
|
||||
mp->bitindex = 0;
|
||||
|
||||
/* for very first header, never parse rest of data */
|
||||
if (mp->fsizeold == -1) {
|
||||
#ifdef HIP_DEBUG
|
||||
lame_report_fnc(mp->report_dbg, "hip: not parsing the rest of the data of the first header\n");
|
||||
#endif
|
||||
return MP3_NEED_MORE;
|
||||
}
|
||||
} /* end of header parsing block */
|
||||
|
||||
/* now decode side information */
|
||||
if (!mp->side_parsed) {
|
||||
|
||||
/* Layer 3 only */
|
||||
if (mp->fr.lay == 3) {
|
||||
if (mp->bsize < mp->ssize)
|
||||
return MP3_NEED_MORE;
|
||||
|
||||
copy_mp(mp, mp->ssize, mp->wordpointer);
|
||||
|
||||
if (mp->fr.error_protection)
|
||||
getbits(mp, 16);
|
||||
bits = decode_layer3_sideinfo(mp);
|
||||
/* bits = actual number of bits needed to parse this frame */
|
||||
/* can be negative, if all bits needed are in the reservoir */
|
||||
if (bits < 0)
|
||||
bits = 0;
|
||||
|
||||
/* read just as many bytes as necessary before decoding */
|
||||
mp->dsize = (bits + 7) / 8;
|
||||
|
||||
if (!mp->free_format) {
|
||||
/* do not read more than framsize data */
|
||||
int framesize = mp->fr.framesize - mp->ssize;
|
||||
if (mp->dsize > framesize) {
|
||||
lame_report_fnc(mp->report_err,
|
||||
"hip: error audio data exceeds framesize by %d bytes\n",
|
||||
mp->dsize - framesize);
|
||||
mp->dsize = framesize;
|
||||
}
|
||||
}
|
||||
#ifdef HIP_DEBUG
|
||||
lame_report_fnc(mp->report_dbg,
|
||||
"hip: %d bits needed to parse layer III frame, number of bytes to read before decoding dsize = %d\n",
|
||||
bits, mp->dsize);
|
||||
#endif
|
||||
|
||||
/* this will force mpglib to read entire frame before decoding */
|
||||
/* mp->dsize= mp->framesize - mp->ssize; */
|
||||
|
||||
}
|
||||
else {
|
||||
/* Layers 1 and 2 */
|
||||
|
||||
/* check if there is enough input data */
|
||||
if (mp->fr.framesize > mp->bsize)
|
||||
return MP3_NEED_MORE;
|
||||
|
||||
/* takes care that the right amount of data is copied into wordpointer */
|
||||
mp->dsize = mp->fr.framesize;
|
||||
mp->ssize = 0;
|
||||
}
|
||||
|
||||
mp->side_parsed = 1;
|
||||
}
|
||||
|
||||
/* now decode main data */
|
||||
iret = MP3_NEED_MORE;
|
||||
if (!mp->data_parsed) {
|
||||
if (mp->dsize > mp->bsize) {
|
||||
return MP3_NEED_MORE;
|
||||
}
|
||||
|
||||
copy_mp(mp, mp->dsize, mp->wordpointer);
|
||||
|
||||
*done = 0;
|
||||
|
||||
/*do_layer3(&mp->fr,(unsigned char *) out,done); */
|
||||
switch (mp->fr.lay) {
|
||||
case 1:
|
||||
if (mp->fr.error_protection)
|
||||
getbits(mp, 16);
|
||||
|
||||
if (decode_layer1_frame(mp, (unsigned char *) out, done) < 0)
|
||||
return MP3_ERR;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (mp->fr.error_protection)
|
||||
getbits(mp, 16);
|
||||
|
||||
decode_layer2_frame(mp, (unsigned char *) out, done);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
decode_layer3_frame(mp, (unsigned char *) out, done, synth_1to1_mono_ptr, synth_1to1_ptr);
|
||||
break;
|
||||
default:
|
||||
lame_report_fnc(mp->report_err, "hip: invalid layer %d\n", mp->fr.lay);
|
||||
}
|
||||
|
||||
mp->wordpointer = mp->bsspace[mp->bsnum] + 512 + mp->ssize + mp->dsize;
|
||||
|
||||
mp->data_parsed = 1;
|
||||
iret = MP3_OK;
|
||||
}
|
||||
|
||||
|
||||
/* remaining bits are ancillary data, or reservoir for next frame
|
||||
* If free format, scan stream looking for next frame to determine
|
||||
* mp->framesize */
|
||||
if (mp->free_format) {
|
||||
if (mp->old_free_format) {
|
||||
/* free format. bitrate must not vary */
|
||||
mp->framesize = mp->fsizeold_nopadding + (mp->fr.padding);
|
||||
}
|
||||
else {
|
||||
bytes = sync_buffer(mp, 1);
|
||||
if (bytes < 0)
|
||||
return iret;
|
||||
mp->framesize = bytes + mp->ssize + mp->dsize;
|
||||
mp->fsizeold_nopadding = mp->framesize - mp->fr.padding;
|
||||
#if 0
|
||||
lame_report_fnc(mp->report_dbg,"hip: freeformat bitstream: estimated bitrate=%ikbs \n",
|
||||
8*(4+mp->framesize)*freqs[mp->fr.sampling_frequency]/
|
||||
(1000*576*(2-mp->fr.lsf)));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* buffer the ancillary data and reservoir for next frame */
|
||||
bytes = mp->framesize - (mp->ssize + mp->dsize);
|
||||
if (bytes > mp->bsize) {
|
||||
return iret;
|
||||
}
|
||||
|
||||
if (bytes > 0) {
|
||||
int size;
|
||||
#if 1
|
||||
/* FIXME: while loop OK ??? */
|
||||
while (bytes > 512) {
|
||||
read_buf_byte(mp);
|
||||
bytes--;
|
||||
mp->framesize--;
|
||||
}
|
||||
#endif
|
||||
copy_mp(mp, bytes, mp->wordpointer);
|
||||
mp->wordpointer += bytes;
|
||||
|
||||
size = (int) (mp->wordpointer - (mp->bsspace[mp->bsnum] + 512));
|
||||
if (size > MAXFRAMESIZE) {
|
||||
lame_report_fnc(mp->report_err, "hip: fatal error. MAXFRAMESIZE not large enough.\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* the above frame is completely parsed. start looking for next frame */
|
||||
mp->fsizeold = mp->framesize;
|
||||
mp->old_free_format = mp->free_format;
|
||||
mp->framesize = 0;
|
||||
mp->header_parsed = 0;
|
||||
mp->side_parsed = 0;
|
||||
mp->data_parsed = 0;
|
||||
|
||||
return iret;
|
||||
}
|
||||
|
||||
int
|
||||
decodeMP3(PMPSTR mp, unsigned char *in, int isize, char *out, int osize, int *done)
|
||||
{
|
||||
if (osize < 4608) {
|
||||
lame_report_fnc(mp->report_err, "hip: Insufficient memory for decoding buffer %d\n", osize);
|
||||
return MP3_ERR;
|
||||
}
|
||||
|
||||
/* passing pointers to the functions which clip the samples */
|
||||
return decodeMP3_clipchoice(mp, in, isize, out, done, synth_1to1_mono, synth_1to1);
|
||||
}
|
||||
|
||||
int
|
||||
decodeMP3_unclipped(PMPSTR mp, unsigned char *in, int isize, char *out, int osize, int *done)
|
||||
{
|
||||
/* we forbid input with more than 1152 samples per channel for output in unclipped mode */
|
||||
if (osize < (int) (1152 * 2 * sizeof(real))) {
|
||||
lame_report_fnc(mp->report_err, "hip: out space too small for unclipped mode\n");
|
||||
return MP3_ERR;
|
||||
}
|
||||
|
||||
/* passing pointers to the functions which don't clip the samples */
|
||||
return decodeMP3_clipchoice(mp, in, isize, out, done, synth_1to1_mono_unclipped,
|
||||
synth_1to1_unclipped);
|
||||
}
|
56
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/interface.h
vendored
Normal file
56
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/interface.h
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef INTERFACE_H_INCLUDED
|
||||
#define INTERFACE_H_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
|
||||
int InitMP3(PMPSTR mp);
|
||||
int decodeMP3(PMPSTR mp, unsigned char *inmemory, int inmemsize, char *outmemory,
|
||||
int outmemsize, int *done);
|
||||
void ExitMP3(PMPSTR mp);
|
||||
|
||||
/* added decodeMP3_unclipped to support returning raw floating-point values of samples. The representation
|
||||
of the floating-point numbers is defined in mpg123.h as #define real. It is 64-bit double by default.
|
||||
No more than 1152 samples per channel are allowed. */
|
||||
int decodeMP3_unclipped(PMPSTR mp, unsigned char *inmemory, int inmemsize, char *outmemory,
|
||||
int outmemsize, int *done);
|
||||
|
||||
/* added remove_buf to support mpglib seeking */
|
||||
void remove_buf(PMPSTR mp);
|
||||
|
||||
/* added audiodata_precedesframes to return the number of bitstream frames the audio data will precede the
|
||||
current frame by for Layer 3 data. Aids seeking.
|
||||
*/
|
||||
int audiodata_precedesframes(PMPSTR mp);
|
||||
|
||||
/* Resets decoding. Aids seeking. */
|
||||
void decode_reset(PMPSTR mp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
183
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/l2tables.h
vendored
Normal file
183
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/l2tables.h
vendored
Normal file
|
@ -0,0 +1,183 @@
|
|||
/*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
const struct al_table2 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}
|
||||
};
|
||||
|
||||
const struct al_table2 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}
|
||||
};
|
||||
|
||||
const struct al_table2 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}
|
||||
};
|
||||
|
||||
const struct al_table2 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}
|
||||
};
|
||||
|
||||
const struct al_table2 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}
|
||||
};
|
232
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/layer1.c
vendored
Normal file
232
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/layer1.c
vendored
Normal file
|
@ -0,0 +1,232 @@
|
|||
/*
|
||||
* layer1.c: Mpeg Layer-1 audio decoder
|
||||
*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: layer1.c,v 1.31 2017/08/23 13:22:23 robert Exp $ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include "common.h"
|
||||
#include "decode_i386.h"
|
||||
|
||||
#ifdef WITH_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
#endif
|
||||
|
||||
#include "layer1.h"
|
||||
|
||||
static int gd_are_hip_tables_layer1_initialized = 0;
|
||||
|
||||
void
|
||||
hip_init_tables_layer1(void)
|
||||
{
|
||||
if (gd_are_hip_tables_layer1_initialized) {
|
||||
return;
|
||||
}
|
||||
gd_are_hip_tables_layer1_initialized = 1;
|
||||
}
|
||||
|
||||
typedef struct sideinfo_layer_I_struct
|
||||
{
|
||||
unsigned char allocation[SBLIMIT][2];
|
||||
unsigned char scalefactor[SBLIMIT][2];
|
||||
} sideinfo_layer_I;
|
||||
|
||||
static int
|
||||
I_step_one(PMPSTR mp, sideinfo_layer_I* si)
|
||||
{
|
||||
struct frame *fr = &(mp->fr);
|
||||
int jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : 32;
|
||||
int i;
|
||||
int illegal_value_detected = 0;
|
||||
unsigned char const ba15 = 15; /* bit pattern not allowed, looks like sync(?) */
|
||||
memset(si, 0, sizeof(*si));
|
||||
assert(fr->stereo == 1 || fr->stereo == 2);
|
||||
|
||||
if (fr->stereo == 2) {
|
||||
for (i = 0; i < jsbound; i++) {
|
||||
unsigned char b0 = get_leq_8_bits(mp, 4); /* values 0-15 */
|
||||
unsigned char b1 = get_leq_8_bits(mp, 4); /* values 0-15 */
|
||||
si->allocation[i][0] = b0;
|
||||
si->allocation[i][1] = b1;
|
||||
if (b0 == ba15 || b1 == ba15)
|
||||
illegal_value_detected = 1;
|
||||
}
|
||||
for (i = jsbound; i < SBLIMIT; i++) {
|
||||
unsigned char b = get_leq_8_bits(mp, 4); /* values 0-15 */
|
||||
si->allocation[i][0] = b;
|
||||
si->allocation[i][1] = b;
|
||||
if (b == ba15)
|
||||
illegal_value_detected = 1;
|
||||
}
|
||||
for (i = 0; i < SBLIMIT; i++) {
|
||||
unsigned char n0 = si->allocation[i][0];
|
||||
unsigned char n1 = si->allocation[i][1];
|
||||
unsigned char b0 = n0 ? get_leq_8_bits(mp, 6) : 0; /* values 0-63 */
|
||||
unsigned char b1 = n1 ? get_leq_8_bits(mp, 6) : 0; /* values 0-63 */
|
||||
si->scalefactor[i][0] = b0;
|
||||
si->scalefactor[i][1] = b1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < SBLIMIT; i++) {
|
||||
unsigned char b0 = get_leq_8_bits(mp, 4); /* values 0-15 */
|
||||
si->allocation[i][0] = b0;
|
||||
if (b0 == ba15)
|
||||
illegal_value_detected = 1;
|
||||
}
|
||||
for (i = 0; i < SBLIMIT; i++) {
|
||||
unsigned char n0 = si->allocation[i][0];
|
||||
unsigned char b0 = n0 ? get_leq_8_bits(mp, 6) : 0; /* values 0-63 */
|
||||
si->scalefactor[i][0] = b0;
|
||||
}
|
||||
}
|
||||
return illegal_value_detected;
|
||||
}
|
||||
|
||||
static void
|
||||
I_step_two(PMPSTR mp, sideinfo_layer_I *si, real fraction[2][SBLIMIT])
|
||||
{
|
||||
double r0, r1;
|
||||
struct frame *fr = &(mp->fr);
|
||||
int ds_limit = fr->down_sample_sblimit;
|
||||
int i;
|
||||
|
||||
assert(fr->stereo == 1 || fr->stereo == 2);
|
||||
if (fr->stereo == 2) {
|
||||
int jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : 32;
|
||||
for (i = 0; i < jsbound; i++) {
|
||||
unsigned char i0 = si->scalefactor[i][0];
|
||||
unsigned char i1 = si->scalefactor[i][1];
|
||||
unsigned char n0 = si->allocation[i][0];
|
||||
unsigned char n1 = si->allocation[i][1];
|
||||
assert( i0 < 64 );
|
||||
assert( i1 < 64 );
|
||||
assert( n0 < 16 );
|
||||
assert( n1 < 16 );
|
||||
if (n0 > 0) {
|
||||
unsigned short v = get_leq_16_bits(mp, n0 + 1); /* 0-65535 */
|
||||
r0 = (((-1) << n0) + v + 1) * muls[n0 + 1][i0];
|
||||
}
|
||||
else {
|
||||
r0 = 0;
|
||||
}
|
||||
if (n1 > 0) {
|
||||
unsigned short v = get_leq_16_bits(mp, n1 + 1); /* 0-65535 */
|
||||
r1 = (((-1) << n1) + v + 1) * muls[n1 + 1][i1];
|
||||
}
|
||||
else {
|
||||
r1 = 0;
|
||||
}
|
||||
fraction[0][i] = (real)r0;
|
||||
fraction[1][i] = (real)r1;
|
||||
}
|
||||
for (i = jsbound; i < SBLIMIT; i++) {
|
||||
unsigned char i0 = si->scalefactor[i][0];
|
||||
unsigned char i1 = si->scalefactor[i][1];
|
||||
unsigned char n = si->allocation[i][0];
|
||||
assert( i0 < 64 );
|
||||
assert( i1 < 64 );
|
||||
assert( n < 16 );
|
||||
if (n > 0) {
|
||||
unsigned short v = get_leq_16_bits(mp, n + 1); /* 0-65535 */
|
||||
unsigned int w = (((-1) << n) + v + 1);
|
||||
r0 = w * muls[n + 1][i0];
|
||||
r1 = w * muls[n + 1][i1];
|
||||
}
|
||||
else {
|
||||
r0 = r1 = 0;
|
||||
}
|
||||
fraction[0][i] = (real)r0;
|
||||
fraction[1][i] = (real)r1;
|
||||
}
|
||||
for (i = ds_limit; i < SBLIMIT; i++) {
|
||||
fraction[0][i] = 0.0;
|
||||
fraction[1][i] = 0.0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < SBLIMIT; i++) {
|
||||
unsigned char n = si->allocation[i][0];
|
||||
unsigned char j = si->scalefactor[i][0];
|
||||
assert( j < 64 );
|
||||
assert( n < 16 );
|
||||
if (n > 0) {
|
||||
unsigned short v = get_leq_16_bits(mp, n + 1);
|
||||
r0 = (((-1) << n) + v + 1) * muls[n + 1][j];
|
||||
}
|
||||
else {
|
||||
r0 = 0;
|
||||
}
|
||||
fraction[0][i] = (real)r0;
|
||||
}
|
||||
for (i = ds_limit; i < SBLIMIT; i++) {
|
||||
fraction[0][i] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
decode_layer1_sideinfo(PMPSTR mp)
|
||||
{
|
||||
(void) mp;
|
||||
/* FIXME: extract side information and check values */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
decode_layer1_frame(PMPSTR mp, unsigned char *pcm_sample, int *pcm_point)
|
||||
{
|
||||
real fraction[2][SBLIMIT]; /* FIXME: change real -> double ? */
|
||||
sideinfo_layer_I si;
|
||||
struct frame *fr = &(mp->fr);
|
||||
int single = fr->single;
|
||||
int i, clip = 0;
|
||||
|
||||
if (I_step_one(mp, &si)) {
|
||||
lame_report_fnc(mp->report_err, "hip: Aborting layer 1 decode, illegal bit allocation value\n");
|
||||
return -1;
|
||||
}
|
||||
if (fr->stereo == 1 || single == 3)
|
||||
single = 0;
|
||||
|
||||
if (single >= 0) {
|
||||
/* decoding one of possibly two channels */
|
||||
for (i = 0; i < SCALE_BLOCK; i++) {
|
||||
I_step_two(mp, &si, fraction);
|
||||
clip += synth_1to1_mono(mp, (real *) fraction[single], pcm_sample, pcm_point);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < SCALE_BLOCK; i++) {
|
||||
int p1 = *pcm_point;
|
||||
I_step_two(mp, &si, fraction);
|
||||
clip += synth_1to1(mp, (real *) fraction[0], 0, pcm_sample, &p1);
|
||||
clip += synth_1to1(mp, (real *) fraction[1], 1, pcm_sample, pcm_point);
|
||||
}
|
||||
}
|
||||
|
||||
return clip;
|
||||
}
|
29
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/layer1.h
vendored
Normal file
29
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/layer1.h
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef LAYER1_H_INCLUDED
|
||||
#define LAYER1_H_INCLUDED
|
||||
|
||||
void hip_init_tables_layer1(void);
|
||||
int decode_layer1_sideinfo(PMPSTR mp);
|
||||
int decode_layer1_frame(PMPSTR mp, unsigned char *pcm_sample, int *pcm_point);
|
||||
|
||||
#endif
|
403
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/layer2.c
vendored
Normal file
403
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/layer2.c
vendored
Normal file
|
@ -0,0 +1,403 @@
|
|||
/*
|
||||
* layer2.c: Mpeg Layer-2 audio decoder
|
||||
*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/* $Id: layer2.c,v 1.34 2017/08/22 23:31:07 robert Exp $ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "layer2.h"
|
||||
#include "l2tables.h"
|
||||
#include "decode_i386.h"
|
||||
|
||||
#ifdef WITH_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
static int gd_are_hip_tables_layer2_initialized = 0;
|
||||
|
||||
static unsigned char grp_3tab[32 * 3] = { 0, }; /* used: 27 */
|
||||
static unsigned char grp_5tab[128 * 3] = { 0, }; /* used: 125 */
|
||||
static unsigned char grp_9tab[1024 * 3] = { 0, }; /* used: 729 */
|
||||
|
||||
|
||||
void
|
||||
hip_init_tables_layer2(void)
|
||||
{
|
||||
static const 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 const unsigned char base[3][9] = {
|
||||
{1, 0, 2,},
|
||||
{17, 18, 0, 19, 20,},
|
||||
{21, 1, 22, 23, 0, 24, 25, 2, 26}
|
||||
};
|
||||
int i, j, k, l, len;
|
||||
real *table;
|
||||
static const int tablen[3] = { 3, 5, 9 };
|
||||
static unsigned char *itable, *tables[3] = { grp_3tab, grp_5tab, grp_9tab };
|
||||
|
||||
if (gd_are_hip_tables_layer2_initialized) {
|
||||
return;
|
||||
}
|
||||
gd_are_hip_tables_layer2_initialized = 1;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
itable = tables[i];
|
||||
len = tablen[i];
|
||||
for (j = 0; j < len; j++)
|
||||
for (k = 0; k < len; k++)
|
||||
for (l = 0; l < len; l++) {
|
||||
*itable++ = base[i][l];
|
||||
*itable++ = base[i][k];
|
||||
*itable++ = base[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
for (k = 0; k < 27; k++) {
|
||||
double m = mulmul[k];
|
||||
table = muls[k];
|
||||
for (j = 3, i = 0; i < 63; i++, j--)
|
||||
*table++ = (real) (m * pow(2.0, (double) j / 3.0));
|
||||
*table++ = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static unsigned char*
|
||||
grp_table_select(short d1, unsigned int idx)
|
||||
{
|
||||
/* RH: it seems to be common, that idx is larger than the table's sizes.
|
||||
is it OK to return a zero vector in this case? FIXME
|
||||
/*/
|
||||
static unsigned char dummy_table[] = { 0,0,0 };
|
||||
unsigned int x;
|
||||
switch (d1) {
|
||||
case 3:
|
||||
x = 3*3*3;
|
||||
idx = idx < x ? idx : x;
|
||||
return &grp_3tab[3 * idx];
|
||||
case 5:
|
||||
x = 5*5*5;
|
||||
idx = idx < x ? idx : x;
|
||||
return &grp_5tab[3 * idx];
|
||||
case 9:
|
||||
x = 9*9*9;
|
||||
idx = idx < x ? idx : x;
|
||||
return &grp_9tab[3 * idx];
|
||||
default:
|
||||
/* fatal error */
|
||||
assert(0);
|
||||
}
|
||||
return &dummy_table[0];
|
||||
}
|
||||
|
||||
typedef struct sideinfo_layer_II_struct
|
||||
{
|
||||
unsigned char allocation[SBLIMIT][2];
|
||||
unsigned char scalefactor[SBLIMIT][2][3]; /* subband / channel / block */
|
||||
} sideinfo_layer_II;
|
||||
|
||||
|
||||
|
||||
static void
|
||||
II_step_one(PMPSTR mp, sideinfo_layer_II *si, struct frame *fr)
|
||||
{
|
||||
int nch = fr->stereo;
|
||||
int sblimit = fr->II_sblimit;
|
||||
int jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : fr->II_sblimit;
|
||||
struct al_table2 const *alloc1 = fr->alloc;
|
||||
unsigned char scfsi[SBLIMIT][2];
|
||||
int i, ch;
|
||||
|
||||
memset(si, 0, sizeof(*si));
|
||||
if (jsbound > sblimit)
|
||||
jsbound = sblimit;
|
||||
if (nch == 2) {
|
||||
for (i = 0; i < jsbound; ++i) {
|
||||
short step = alloc1->bits;
|
||||
unsigned char b0 = get_leq_8_bits(mp, step);
|
||||
unsigned char b1 = get_leq_8_bits(mp, step);
|
||||
alloc1 += ((size_t)1 << step);
|
||||
si->allocation[i][0] = b0;
|
||||
si->allocation[i][1] = b1;
|
||||
}
|
||||
for (i = jsbound; i < sblimit; ++i) {
|
||||
short step = alloc1->bits;
|
||||
unsigned char b0 = get_leq_8_bits(mp, step);
|
||||
alloc1 += ((size_t)1 << step);
|
||||
si->allocation[i][0] = b0;
|
||||
si->allocation[i][1] = b0;
|
||||
}
|
||||
for (i = 0; i < sblimit; ++i) {
|
||||
unsigned char n0 = si->allocation[i][0];
|
||||
unsigned char n1 = si->allocation[i][1];
|
||||
unsigned char b0 = n0 ? get_leq_8_bits(mp, 2) : 0;
|
||||
unsigned char b1 = n1 ? get_leq_8_bits(mp, 2) : 0;
|
||||
scfsi[i][0] = b0;
|
||||
scfsi[i][1] = b1;
|
||||
}
|
||||
}
|
||||
else { /* mono */
|
||||
for (i = 0; i < sblimit; ++i) {
|
||||
short step = alloc1->bits;
|
||||
unsigned char b0 = get_leq_8_bits(mp, step);
|
||||
alloc1 += ((size_t)1 << step);
|
||||
si->allocation[i][0] = b0;
|
||||
}
|
||||
for (i = 0; i < sblimit; ++i) {
|
||||
unsigned char n0 = si->allocation[i][0];
|
||||
unsigned char b0 = n0 ? get_leq_8_bits(mp, 2) : 0;
|
||||
scfsi[i][0] = b0;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < sblimit; ++i) {
|
||||
for (ch = 0; ch < nch; ++ch) {
|
||||
unsigned char s0 = 0, s1 = 0, s2 = 0;
|
||||
if (si->allocation[i][ch]) {
|
||||
switch (scfsi[i][ch]) {
|
||||
case 0:
|
||||
s0 = get_leq_8_bits(mp, 6);
|
||||
s1 = get_leq_8_bits(mp, 6);
|
||||
s2 = get_leq_8_bits(mp, 6);
|
||||
break;
|
||||
case 1:
|
||||
s0 = get_leq_8_bits(mp, 6);
|
||||
s1 = s0;
|
||||
s2 = get_leq_8_bits(mp, 6);
|
||||
break;
|
||||
case 2:
|
||||
s0 = get_leq_8_bits(mp, 6);
|
||||
s1 = s0;
|
||||
s2 = s0;
|
||||
break;
|
||||
case 3:
|
||||
s0 = get_leq_8_bits(mp, 6);
|
||||
s1 = get_leq_8_bits(mp, 6);
|
||||
s2 = s1;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
si->scalefactor[i][ch][0] = s0;
|
||||
si->scalefactor[i][ch][1] = s1;
|
||||
si->scalefactor[i][ch][2] = s2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
II_step_two(PMPSTR mp, sideinfo_layer_II* si, struct frame *fr, int gr, real fraction[2][4][SBLIMIT])
|
||||
{
|
||||
struct al_table2 const *alloc1 = fr->alloc;
|
||||
int sblimit = fr->II_sblimit;
|
||||
int jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : fr->II_sblimit;
|
||||
int i, ch, nch = fr->stereo;
|
||||
double cm, r0, r1, r2;
|
||||
|
||||
if (jsbound > sblimit)
|
||||
jsbound = sblimit;
|
||||
for (i = 0; i < jsbound; ++i) {
|
||||
short step = alloc1->bits;
|
||||
for (ch = 0; ch < nch; ++ch) {
|
||||
unsigned char ba = si->allocation[i][ch];
|
||||
if (ba) {
|
||||
unsigned char x1 = si->scalefactor[i][ch][gr];
|
||||
struct al_table2 const *alloc2 = alloc1 + ba;
|
||||
short k = alloc2->bits;
|
||||
short d1 = alloc2->d;
|
||||
assert( k <= 16 );
|
||||
k = (k <= 16) ? k : 16;
|
||||
assert( x1 < 64 );
|
||||
x1 = (x1 < 64) ? x1 : 63;
|
||||
if (d1 < 0) {
|
||||
int v0 = getbits(mp, k);
|
||||
int v1 = getbits(mp, k);
|
||||
int v2 = getbits(mp, k);
|
||||
cm = muls[k][x1];
|
||||
r0 = (v0 + d1) * cm;
|
||||
r1 = (v1 + d1) * cm;
|
||||
r2 = (v2 + d1) * cm;
|
||||
}
|
||||
else {
|
||||
unsigned int idx = getbits(mp, k);
|
||||
unsigned char *tab = grp_table_select(d1, idx);
|
||||
unsigned char k0 = tab[0];
|
||||
unsigned char k1 = tab[1];
|
||||
unsigned char k2 = tab[2];
|
||||
r0 = muls[k0][x1];
|
||||
r1 = muls[k1][x1];
|
||||
r2 = muls[k2][x1];
|
||||
}
|
||||
fraction[ch][0][i] = (real) r0;
|
||||
fraction[ch][1][i] = (real) r1;
|
||||
fraction[ch][2][i] = (real) r2;
|
||||
}
|
||||
else {
|
||||
fraction[ch][0][i] = fraction[ch][1][i] = fraction[ch][2][i] = 0.0;
|
||||
}
|
||||
}
|
||||
alloc1 += ((size_t)1 << step);
|
||||
}
|
||||
|
||||
for (i = jsbound; i < sblimit; i++) {
|
||||
short step = alloc1->bits;
|
||||
unsigned char ba = si->allocation[i][0];
|
||||
if (ba) {
|
||||
struct al_table2 const *alloc2 = alloc1 + ba;
|
||||
short k = alloc2->bits;
|
||||
short d1 = alloc2->d;
|
||||
assert( k <= 16 );
|
||||
k = (k <= 16) ? k : 16;
|
||||
if (d1 < 0) {
|
||||
int v0 = getbits(mp, k);
|
||||
int v1 = getbits(mp, k);
|
||||
int v2 = getbits(mp, k);
|
||||
for (ch = 0; ch < nch; ++ch) {
|
||||
unsigned char x1 = si->scalefactor[i][ch][gr];
|
||||
assert( x1 < 64 );
|
||||
x1 = (x1 < 64) ? x1 : 63;
|
||||
cm = muls[k][x1];
|
||||
r0 = (v0 + d1) * cm;
|
||||
r1 = (v1 + d1) * cm;
|
||||
r2 = (v2 + d1) * cm;
|
||||
fraction[ch][0][i] = (real) r0;
|
||||
fraction[ch][1][i] = (real) r1;
|
||||
fraction[ch][2][i] = (real) r2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
unsigned int idx = getbits(mp, k);
|
||||
unsigned char *tab = grp_table_select(d1, idx);
|
||||
unsigned char k0 = tab[0];
|
||||
unsigned char k1 = tab[1];
|
||||
unsigned char k2 = tab[2];
|
||||
for (ch = 0; ch < nch; ++ch) {
|
||||
unsigned char x1 = si->scalefactor[i][ch][gr];
|
||||
assert( x1 < 64 );
|
||||
x1 = (x1 < 64) ? x1 : 63;
|
||||
r0 = muls[k0][x1];
|
||||
r1 = muls[k1][x1];
|
||||
r2 = muls[k2][x1];
|
||||
fraction[ch][0][i] = (real) r0;
|
||||
fraction[ch][1][i] = (real) r1;
|
||||
fraction[ch][2][i] = (real) r2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
fraction[0][0][i] = fraction[0][1][i] = fraction[0][2][i] = 0.0;
|
||||
fraction[1][0][i] = fraction[1][1][i] = fraction[1][2][i] = 0.0;
|
||||
}
|
||||
alloc1 += ((size_t)1 << step);
|
||||
}
|
||||
if (sblimit > fr->down_sample_sblimit) {
|
||||
sblimit = fr->down_sample_sblimit;
|
||||
}
|
||||
for (ch = 0; ch < nch; ++ch) {
|
||||
for (i = sblimit; i < SBLIMIT; ++i) {
|
||||
fraction[ch][0][i] = fraction[ch][1][i] = fraction[ch][2][i] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
II_select_table(struct frame *fr)
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
static const 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 } } };
|
||||
/* *INDENT-ON* */
|
||||
|
||||
int table, sblim;
|
||||
static const struct al_table2 *tables[5] = { alloc_0, alloc_1, alloc_2, alloc_3, alloc_4 };
|
||||
static const 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 = (struct al_table2 const *) tables[table];
|
||||
fr->II_sblimit = sblim;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
decode_layer2_sideinfo(PMPSTR mp)
|
||||
{
|
||||
(void) mp;
|
||||
/* FIXME: extract side information and check values */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
decode_layer2_frame(PMPSTR mp, unsigned char *pcm_sample, int *pcm_point)
|
||||
{
|
||||
real fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */
|
||||
sideinfo_layer_II si;
|
||||
struct frame *fr = &(mp->fr);
|
||||
int single = fr->single;
|
||||
int i, j, clip = 0;
|
||||
|
||||
II_select_table(fr);
|
||||
II_step_one(mp, &si, fr);
|
||||
|
||||
if (fr->stereo == 1 || single == 3)
|
||||
single = 0;
|
||||
|
||||
if (single >= 0) {
|
||||
for (i = 0; i < SCALE_BLOCK; i++) {
|
||||
II_step_two(mp, &si, fr, i >> 2, fraction);
|
||||
for (j = 0; j < 3; j++) {
|
||||
clip += synth_1to1_mono(mp, fraction[single][j], pcm_sample, pcm_point);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < SCALE_BLOCK; i++) {
|
||||
II_step_two(mp, &si, fr, i >> 2, fraction);
|
||||
for (j = 0; j < 3; j++) {
|
||||
int p1 = *pcm_point;
|
||||
clip += synth_1to1(mp, fraction[0][j], 0, pcm_sample, &p1);
|
||||
clip += synth_1to1(mp, fraction[1][j], 1, pcm_sample, pcm_point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return clip;
|
||||
}
|
39
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/layer2.h
vendored
Normal file
39
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/layer2.h
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LAYER2_H_INCLUDED
|
||||
#define LAYER2_H_INCLUDED
|
||||
|
||||
|
||||
struct al_table2 {
|
||||
short bits;
|
||||
short d;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void hip_init_tables_layer2(void);
|
||||
int decode_layer2_sideinfo(PMPSTR mp);
|
||||
int decode_layer2_frame(PMPSTR mp, unsigned char *pcm_sample, int *pcm_point);
|
||||
|
||||
|
||||
#endif
|
1969
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/layer3.c
vendored
Normal file
1969
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/layer3.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
32
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/layer3.h
vendored
Normal file
32
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/layer3.h
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef LAYER3_H_INCLUDED
|
||||
#define LAYER3_H_INCLUDED
|
||||
|
||||
void hip_init_tables_layer3(void);
|
||||
int decode_layer3_sideinfo(PMPSTR mp);
|
||||
int decode_layer3_frame(PMPSTR mp, unsigned char *pcm_sample, int *pcm_point,
|
||||
int (*synth_1to1_mono_ptr) (PMPSTR, real *, unsigned char *, int *),
|
||||
int (*synth_1to1_ptr) (PMPSTR, real *, int, unsigned char *, int *));
|
||||
int layer3_audiodata_precedesframes(PMPSTR mp);
|
||||
|
||||
#endif
|
152
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/mpg123.h
vendored
Normal file
152
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/mpg123.h
vendored
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef MPG123_H_INCLUDED
|
||||
#define MPG123_H_INCLUDED
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <string.h>
|
||||
#else
|
||||
# ifndef HAVE_STRCHR
|
||||
# define strchr index
|
||||
# define strrchr rindex
|
||||
# endif
|
||||
char *strchr(), *strrchr();
|
||||
# ifndef HAVE_MEMCPY
|
||||
# define memcpy(d, s, n) bcopy ((s), (d), (n))
|
||||
# define memmove(d, s, n) bcopy ((s), (d), (n))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
#if defined(__riscos__) && defined(FPA10)
|
||||
#include "ymath.h"
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
#ifndef M_SQRT2
|
||||
#define M_SQRT2 1.41421356237309504880
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#undef REAL_IS_FLOAT
|
||||
#define REAL_IS_FLOAT
|
||||
|
||||
#ifdef REAL_IS_FLOAT
|
||||
# define real float
|
||||
#elif defined(REAL_IS_LONG_DOUBLE)
|
||||
# define real long double
|
||||
#else
|
||||
# define real double
|
||||
#endif
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#define SBLIMIT 32
|
||||
#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 MAXFRAMESIZE 2880
|
||||
|
||||
/* AF: ADDED FOR LAYER1/LAYER2 */
|
||||
#define SCALE_BLOCK 12
|
||||
|
||||
|
||||
/* Pre Shift fo 16 to 8 bit converter table */
|
||||
#define AUSHIFT (3)
|
||||
|
||||
struct frame {
|
||||
int stereo;
|
||||
int single; /* single channel (monophonic) */
|
||||
int lsf; /* 0 = MPEG-1, 1 = MPEG-2/2.5 */
|
||||
int mpeg25; /* 1 = MPEG-2.5, 0 = MPEG-1/2 */
|
||||
int header_change;
|
||||
int lay; /* Layer */
|
||||
int error_protection; /* 1 = CRC-16 code following header */
|
||||
int bitrate_index;
|
||||
int sampling_frequency; /* sample rate of decompressed audio in Hz */
|
||||
int padding;
|
||||
int extension;
|
||||
int mode;
|
||||
int mode_ext;
|
||||
int copyright;
|
||||
int original;
|
||||
int emphasis;
|
||||
int framesize; /* computed framesize */
|
||||
|
||||
/* AF: ADDED FOR LAYER1/LAYER2 */
|
||||
int II_sblimit;
|
||||
struct al_table2 const *alloc;
|
||||
int down_sample_sblimit;
|
||||
int down_sample;
|
||||
|
||||
|
||||
};
|
||||
|
||||
struct gr_info_s {
|
||||
int scfsi;
|
||||
unsigned part2_3_length;
|
||||
unsigned big_values;
|
||||
unsigned scalefac_compress;
|
||||
unsigned block_type;
|
||||
unsigned mixed_block_flag;
|
||||
unsigned table_select[3];
|
||||
unsigned subblock_gain[3];
|
||||
unsigned maxband[3];
|
||||
unsigned maxbandl;
|
||||
unsigned maxb;
|
||||
unsigned region1start;
|
||||
unsigned region2start;
|
||||
unsigned preflag;
|
||||
unsigned scalefac_scale;
|
||||
unsigned count1table_select;
|
||||
real *full_gain[3];
|
||||
real *pow2gain;
|
||||
};
|
||||
|
||||
struct III_sideinfo {
|
||||
unsigned main_data_begin;
|
||||
unsigned private_bits;
|
||||
struct {
|
||||
struct gr_info_s gr[2];
|
||||
} ch[2];
|
||||
};
|
||||
|
||||
|
||||
#endif
|
96
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/mpglib.h
vendored
Normal file
96
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/mpglib.h
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _MPGLIB_H_
|
||||
#define _MPGLIB_H_
|
||||
|
||||
#include "lame.h"
|
||||
|
||||
#ifndef plotting_data_defined
|
||||
#define plotting_data_defined
|
||||
struct plotting_data;
|
||||
typedef struct plotting_data plotting_data;
|
||||
#endif
|
||||
|
||||
|
||||
extern void lame_report_fnc(lame_report_function f, const char *format, ...);
|
||||
|
||||
struct buf {
|
||||
unsigned char *pnt;
|
||||
long size;
|
||||
long pos;
|
||||
struct buf *next;
|
||||
struct buf *prev;
|
||||
};
|
||||
|
||||
struct framebuf {
|
||||
struct buf *buf;
|
||||
long pos;
|
||||
struct frame *next;
|
||||
struct frame *prev;
|
||||
};
|
||||
|
||||
typedef struct mpstr_tag {
|
||||
struct buf *head, *tail; /* buffer linked list pointers, tail points to oldest buffer */
|
||||
int vbr_header; /* 1 if valid Xing vbr header detected */
|
||||
int num_frames; /* set if vbr header present */
|
||||
int enc_delay; /* set if vbr header present */
|
||||
int enc_padding; /* set if vbr header present */
|
||||
/* header_parsed, side_parsed and data_parsed must be all set 1
|
||||
before the full frame has been parsed */
|
||||
int header_parsed; /* 1 = header of current frame has been parsed */
|
||||
int side_parsed; /* 1 = header of sideinfo of current frame has been parsed */
|
||||
int data_parsed;
|
||||
int free_format; /* 1 = free format frame */
|
||||
int old_free_format; /* 1 = last frame was free format */
|
||||
int bsize;
|
||||
int framesize;
|
||||
int ssize; /* number of bytes used for side information, including 2 bytes for CRC-16 if present */
|
||||
int dsize;
|
||||
int fsizeold; /* size of previous frame, -1 for first */
|
||||
int fsizeold_nopadding;
|
||||
struct frame fr; /* holds the parameters decoded from the header */
|
||||
struct III_sideinfo sideinfo;
|
||||
unsigned char bsspace[2][MAXFRAMESIZE + 1024]; /* bit stream space used ???? */ /* MAXFRAMESIZE */
|
||||
real hybrid_block[2][2][SBLIMIT * SSLIMIT];
|
||||
int hybrid_blc[2];
|
||||
unsigned long header;
|
||||
int bsnum;
|
||||
real synth_buffs[2][2][0x110];
|
||||
int synth_bo;
|
||||
int sync_bitstream; /* 1 = bitstream is yet to be synchronized */
|
||||
|
||||
int bitindex;
|
||||
unsigned char *wordpointer;
|
||||
plotting_data *pinfo;
|
||||
|
||||
lame_report_function report_msg;
|
||||
lame_report_function report_dbg;
|
||||
lame_report_function report_err;
|
||||
} MPSTR, *PMPSTR;
|
||||
|
||||
|
||||
#define MP3_ERR -1
|
||||
#define MP3_OK 0
|
||||
#define MP3_NEED_MORE 1
|
||||
|
||||
|
||||
|
||||
#endif /* _MPGLIB_H_ */
|
152
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/tabinit.c
vendored
Normal file
152
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/tabinit.c
vendored
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* tabinit.c
|
||||
*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/* $Id: tabinit.c,v 1.17 2017/09/06 15:07:30 robert Exp $ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "tabinit.h"
|
||||
#include "mpg123.h"
|
||||
|
||||
#ifdef WITH_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
#endif
|
||||
|
||||
static int table_init_called = 0;
|
||||
|
||||
real decwin[512 + 32];
|
||||
static real cos64[16], cos32[8], cos16[4], cos8[2], cos4[1];
|
||||
real *pnts[] = { cos64, cos32, cos16, cos8, cos4 };
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
static const double dewin[512] = {
|
||||
0.000000000,-0.000015259,-0.000015259,-0.000015259,
|
||||
-0.000015259,-0.000015259,-0.000015259,-0.000030518,
|
||||
-0.000030518,-0.000030518,-0.000030518,-0.000045776,
|
||||
-0.000045776,-0.000061035,-0.000061035,-0.000076294,
|
||||
-0.000076294,-0.000091553,-0.000106812,-0.000106812,
|
||||
-0.000122070,-0.000137329,-0.000152588,-0.000167847,
|
||||
-0.000198364,-0.000213623,-0.000244141,-0.000259399,
|
||||
-0.000289917,-0.000320435,-0.000366211,-0.000396729,
|
||||
-0.000442505,-0.000473022,-0.000534058,-0.000579834,
|
||||
-0.000625610,-0.000686646,-0.000747681,-0.000808716,
|
||||
-0.000885010,-0.000961304,-0.001037598,-0.001113892,
|
||||
-0.001205444,-0.001296997,-0.001388550,-0.001480103,
|
||||
-0.001586914,-0.001693726,-0.001785278,-0.001907349,
|
||||
-0.002014160,-0.002120972,-0.002243042,-0.002349854,
|
||||
-0.002456665,-0.002578735,-0.002685547,-0.002792358,
|
||||
-0.002899170,-0.002990723,-0.003082275,-0.003173828,
|
||||
-0.003250122,-0.003326416,-0.003387451,-0.003433228,
|
||||
-0.003463745,-0.003479004,-0.003479004,-0.003463745,
|
||||
-0.003417969,-0.003372192,-0.003280640,-0.003173828,
|
||||
-0.003051758,-0.002883911,-0.002700806,-0.002487183,
|
||||
-0.002227783,-0.001937866,-0.001617432,-0.001266479,
|
||||
-0.000869751,-0.000442505, 0.000030518, 0.000549316,
|
||||
0.001098633, 0.001693726, 0.002334595, 0.003005981,
|
||||
0.003723145, 0.004486084, 0.005294800, 0.006118774,
|
||||
0.007003784, 0.007919312, 0.008865356, 0.009841919,
|
||||
0.010848999, 0.011886597, 0.012939453, 0.014022827,
|
||||
0.015121460, 0.016235352, 0.017349243, 0.018463135,
|
||||
0.019577026, 0.020690918, 0.021789551, 0.022857666,
|
||||
0.023910522, 0.024932861, 0.025909424, 0.026840210,
|
||||
0.027725220, 0.028533936, 0.029281616, 0.029937744,
|
||||
0.030532837, 0.031005859, 0.031387329, 0.031661987,
|
||||
0.031814575, 0.031845093, 0.031738281, 0.031478882,
|
||||
0.031082153, 0.030517578, 0.029785156, 0.028884888,
|
||||
0.027801514, 0.026535034, 0.025085449, 0.023422241,
|
||||
0.021575928, 0.019531250, 0.017257690, 0.014801025,
|
||||
0.012115479, 0.009231567, 0.006134033, 0.002822876,
|
||||
-0.000686646,-0.004394531,-0.008316040,-0.012420654,
|
||||
-0.016708374,-0.021179199,-0.025817871,-0.030609131,
|
||||
-0.035552979,-0.040634155,-0.045837402,-0.051132202,
|
||||
-0.056533813,-0.061996460,-0.067520142,-0.073059082,
|
||||
-0.078628540,-0.084182739,-0.089706421,-0.095169067,
|
||||
-0.100540161,-0.105819702,-0.110946655,-0.115921021,
|
||||
-0.120697021,-0.125259399,-0.129562378,-0.133590698,
|
||||
-0.137298584,-0.140670776,-0.143676758,-0.146255493,
|
||||
-0.148422241,-0.150115967,-0.151306152,-0.151962280,
|
||||
-0.152069092,-0.151596069,-0.150497437,-0.148773193,
|
||||
-0.146362305,-0.143264771,-0.139450073,-0.134887695,
|
||||
-0.129577637,-0.123474121,-0.116577148,-0.108856201,
|
||||
-0.100311279,-0.090927124,-0.080688477,-0.069595337,
|
||||
-0.057617187,-0.044784546,-0.031082153,-0.016510010,
|
||||
-0.001068115, 0.015228271, 0.032379150, 0.050354004,
|
||||
0.069168091, 0.088775635, 0.109161377, 0.130310059,
|
||||
0.152206421, 0.174789429, 0.198059082, 0.221984863,
|
||||
0.246505737, 0.271591187, 0.297210693, 0.323318481,
|
||||
0.349868774, 0.376800537, 0.404083252, 0.431655884,
|
||||
0.459472656, 0.487472534, 0.515609741, 0.543823242,
|
||||
0.572036743, 0.600219727, 0.628295898, 0.656219482,
|
||||
0.683914185, 0.711318970, 0.738372803, 0.765029907,
|
||||
0.791213989, 0.816864014, 0.841949463, 0.866363525,
|
||||
0.890090942, 0.913055420, 0.935195923, 0.956481934,
|
||||
0.976852417, 0.996246338, 1.014617920, 1.031936646,
|
||||
1.048156738, 1.063217163, 1.077117920, 1.089782715,
|
||||
1.101211548, 1.111373901, 1.120223999, 1.127746582,
|
||||
1.133926392, 1.138763428, 1.142211914, 1.144287109,
|
||||
1.144989014
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
void
|
||||
make_decode_tables(long scaleval)
|
||||
{
|
||||
int i, j, k, kr, divv;
|
||||
real *table, *costab;
|
||||
|
||||
if (table_init_called)
|
||||
return;
|
||||
|
||||
table_init_called = 1;
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
kr = 0x10 >> i;
|
||||
divv = 0x40 >> i;
|
||||
costab = pnts[i];
|
||||
for (k = 0; k < kr; k++)
|
||||
costab[k] = (real) (1.0 / (2.0 * cos(M_PI * ((double) k * 2.0 + 1.0) / (double) divv)));
|
||||
}
|
||||
|
||||
table = decwin;
|
||||
scaleval = -scaleval;
|
||||
for (i = 0, j = 0; i < 256; i++, j++, table += 32) {
|
||||
if (table < decwin + 512 + 16)
|
||||
table[16] = table[0] = (real) (dewin[j] * scaleval);
|
||||
if (i % 32 == 31)
|
||||
table -= 1023;
|
||||
if (i % 64 == 63)
|
||||
scaleval = -scaleval;
|
||||
}
|
||||
|
||||
for ( /* i=256 */ ; i < 512; i++, j--, table += 32) {
|
||||
if (table < decwin + 512 + 16)
|
||||
table[16] = table[0] = (real) (dewin[j] * scaleval);
|
||||
if (i % 32 == 31)
|
||||
table -= 1023;
|
||||
if (i % 64 == 63)
|
||||
scaleval = -scaleval;
|
||||
}
|
||||
}
|
32
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/tabinit.h
vendored
Normal file
32
Src/external_dependencies/openmpt-trunk/include/lame/mpglib/tabinit.h
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (C) 1999-2010 The L.A.M.E. project
|
||||
*
|
||||
* Initially written by Michael Hipp, see also AUTHORS and README.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef MPGLIB_TABINIT_H_INCLUDED
|
||||
#define MPGLIB_TABINIT_H_INCLUDED
|
||||
|
||||
#include "mpg123.h"
|
||||
|
||||
extern real decwin[512 + 32];
|
||||
extern real *pnts[5];
|
||||
|
||||
void make_decode_tables(long scale);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue