📄 iupini.ch
字号:
/*-- grouped 5 level lookup table 7 bit token --*/
for (i = 0; i < 128; i++)
{
code = i;
for (j = 0; j < 3; j++)
{
group5_table[i][j] = (char) ((code % 5) - 2);
code /= 5;
}
}
/*-- grouped 9 level lookup table 10 bit token --*/
for (i = 0; i < 1024; i++)
{
code = i;
for (j = 0; j < 3; j++)
{
group9_table[i][j] = (short) ((code % 9) - 4);
code /= 9;
}
}
}
/*---------------------------------------------------------*/
int i_audio_decode_initL1(MPEG_HEAD * h, int framebytes_arg,
int reduction_code, int transform_code, int convert_code,
int freq_limit);
void i_sbt_init();
/*---------------------------------------------------------*/
/* mpeg_head defined in mhead.h frame bytes is without pad */
int i_audio_decode_init(MPEG_HEAD * h, int framebytes_arg,
int reduction_code, int transform_code, int convert_code,
int freq_limit)
{
int i, j, k;
static int first_pass = 1;
int abcd_index;
long samprate;
int limit;
int bit_code;
if (first_pass)
{
table_init();
first_pass = 0;
}
/* check if code handles */
if (h->option == 3) /* layer I */
return i_audio_decode_initL1(h, framebytes_arg,
reduction_code, transform_code, convert_code, freq_limit);
if (h->option != 2)
return 0; /* layer II only */
unpack_routine = unpack;
transform_code = transform_code; /* not used, asm compatability */
bit_code = 0;
if (convert_code & 8)
bit_code = 1;
convert_code = convert_code & 3; /* higher bits used by dec8 freq cvt */
if (reduction_code < 0)
reduction_code = 0;
if (reduction_code > 2)
reduction_code = 2;
if (freq_limit < 1000)
freq_limit = 1000;
framebytes = framebytes_arg;
/* compute abcd index for bit allo table selection */
if (h->id) /* mpeg 1 */
abcd_index = lookqt[h->mode][h->sr_index][h->br_index];
else
abcd_index = 4; /* mpeg 2 */
for (i = 0; i < 4; i++)
for (j = 0; j < 16; j++)
bat[i][j] = look_bat[abcd_index][i][j];
for (i = 0; i < 4; i++)
nbat[i] = look_nbat[abcd_index][i];
max_sb = nbat[0] + nbat[1] + nbat[2] + nbat[3];
/*----- compute nsb_limit --------*/
samprate = sr_table[4 * h->id + h->sr_index];
nsb_limit = (freq_limit * 64L + samprate / 2) / samprate;
/*- caller limit -*/
/*---- limit = 0.94*(32>>reduction_code); ----*/
limit = (32 >> reduction_code);
if (limit > 8)
limit--;
if (nsb_limit > limit)
nsb_limit = limit;
if (nsb_limit > max_sb)
nsb_limit = max_sb;
outvalues = 1152 >> reduction_code;
if (h->mode != 3)
{ /* adjust for 2 channel modes */
for (i = 0; i < 4; i++)
nbat[i] *= 2;
max_sb *= 2;
nsb_limit *= 2;
}
/* set sbt function */
nsbt = 36;
k = 1 + convert_code;
if (h->mode == 3)
{
k = 0;
}
sbt = sbt_table[bit_code][reduction_code][k];
outvalues *= out_chans[k];
if (bit_code != 0)
outbytes = outvalues;
else
#if __TMS320C55X__ || _TMS320C5XX || _TMS320C27XX
outbytes = 2 * outvalues;
#else
outbytes = sizeof(short) * outvalues;
#endif
decinfo.channels = out_chans[k];
decinfo.outvalues = outvalues;
decinfo.samprate = samprate >> reduction_code;
if (bit_code != 0)
decinfo.bits = 8;
else
#if __TMS320C55X__ || _TMS320C5XX || _TMS320C27XX
decinfo.bits = 2 * 8;
#else
decinfo.bits = sizeof(short) * 8;
#endif
decinfo.framebytes = framebytes;
decinfo.type = 0;
/* clear sample buffer, unused sub bands must be 0 */
for (i = 0; i < 2304; i++)
sample[i] = 0;
/* init sub-band transform */
i_sbt_init();
return 1;
}
/*---------------------------------------------------------*/
void i_audio_decode_info(DEC_INFO * info)
{
*info = decinfo; /* info return, call after init */
}
/*---------------------------------------------------------*/
/* ***********************************************************
* THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
* REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
* INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
* COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
* TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
* POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
* INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
* YOUR USE OF THE PROGRAM.
*
* IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
* CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
* THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
* OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
* EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
* REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
* OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
* USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
* AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
* YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
* (U.S.$500).
*
* Unless otherwise stated, the Program written and copyrighted
* by Texas Instruments is distributed as "freeware". You may,
* only under TI's copyright in the Program, use and modify the
* Program without any charge or restriction. You may
* distribute to third parties, provided that you transfer a
* copy of this license to the third party and the third party
* agrees to these terms by its first use of the Program. You
* must reproduce the copyright notice and any other legend of
* ownership on each copy or partial copy, of the Program.
*
* You acknowledge and agree that the Program contains
* copyrighted material, trade secrets and other TI proprietary
* information and is protected by copyright laws,
* international copyright treaties, and trade secret laws, as
* well as other intellectual property laws. To protect TI's
* rights in the Program, you agree not to decompile, reverse
* engineer, disassemble or otherwise translate any object code
* versions of the Program to a human-readable form. You agree
* that in no event will you alter, remove or destroy any
* copyright notice included in the Program. TI reserves all
* rights not specifically granted under this license. Except
* as specifically provided herein, nothing in this agreement
* shall be construed as conferring by implication, estoppel,
* or otherwise, upon you, any license or other right under any
* TI patents, copyrights or trade secrets.
*
* You may not use the Program in non-TI devices.
* ********************************************************* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -