⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 output.c

📁 tcpmp.src.0.72RC1 优秀的多媒体播放器TCPMP的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com**** This program is free software; you can redistribute it and/or modify** it under the terms of the GNU General Public License as published by** the Free Software Foundation; either version 2 of the License, or** (at your option) any later version.**** This program is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the** GNU General Public License for more details.**** You should have received a copy of the GNU General Public License** along with this program; if not, write to the Free Software** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.**** Any non-GPL usage of this software or parts of this software is strictly** forbidden.**** Commercial non-GPL licensing of this software is possible.** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.**** $Id: output.c,v 1.42 2004/09/04 14:56:28 menno Exp $**/#include "common.h"#include "structs.h"#include "output.h"#include "decoder.h"#ifndef FIXED_POINT#define FLOAT_SCALE (1.0f/(1<<15))#define DM_MUL REAL_CONST(0.3203772410170407) // 1/(1+sqrt(2) + 1/sqrt(2))#define RSQRT2 REAL_CONST(0.7071067811865475244) // 1/sqrt(2)static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample,                                uint8_t down_matrix, uint8_t *internal_channel){    if (!down_matrix)        return input[internal_channel[channel]][sample];    if (channel == 0)    {        return DM_MUL * (input[internal_channel[1]][sample] +            input[internal_channel[0]][sample] * RSQRT2 +            input[internal_channel[3]][sample] * RSQRT2);    } else {        return DM_MUL * (input[internal_channel[2]][sample] +            input[internal_channel[0]][sample] * RSQRT2 +            input[internal_channel[4]][sample] * RSQRT2);    }}#ifndef HAS_LRINTF#define CLIP(sample, max, min) \if (sample >= 0.0f)            \{                              \    sample += 0.5f;            \    if (sample >= max)         \        sample = max;          \} else {                       \    sample += -0.5f;           \    if (sample <= min)         \        sample = min;          \}#else#define CLIP(sample, max, min) \if (sample >= 0.0f)            \{                              \    if (sample >= max)         \        sample = max;          \} else {                       \    if (sample <= min)         \        sample = min;          \}#endif#define CONV(a,b) ((a<<1)|(b&0x1))static void to_PCM_16bit(NeAACDecHandle hDecoder, real_t **input,                         uint8_t channels, uint16_t frame_len,                         int16_t **sample_buffer){    uint8_t ch, ch1;    uint16_t i;    switch (CONV(channels,hDecoder->downMatrix))    {    case CONV(1,0):    case CONV(1,1):        for(i = 0; i < frame_len; i++)        {            real_t inp = input[hDecoder->internal_channel[0]][i];            CLIP(inp, 32767.0f, -32768.0f);            (*sample_buffer)[i] = (int16_t)lrintf(inp);        }        break;    case CONV(2,0):        if (hDecoder->upMatrix)        {            ch  = hDecoder->internal_channel[0];            for(i = 0; i < frame_len; i++)            {                real_t inp0 = input[ch][i];                CLIP(inp0, 32767.0f, -32768.0f);                (*sample_buffer)[(i*2)+0] = (int16_t)lrintf(inp0);                (*sample_buffer)[(i*2)+1] = (int16_t)lrintf(inp0);            }        } else {            ch  = hDecoder->internal_channel[0];            ch1 = hDecoder->internal_channel[1];            for(i = 0; i < frame_len; i++)            {                real_t inp0 = input[ch ][i];                real_t inp1 = input[ch1][i];                CLIP(inp0, 32767.0f, -32768.0f);                CLIP(inp1, 32767.0f, -32768.0f);                (*sample_buffer)[(i*2)+0] = (int16_t)lrintf(inp0);                (*sample_buffer)[(i*2)+1] = (int16_t)lrintf(inp1);            }        }        break;    default:        for (ch = 0; ch < channels; ch++)        {            for(i = 0; i < frame_len; i++)            {                real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);                CLIP(inp, 32767.0f, -32768.0f);                (*sample_buffer)[(i*channels)+ch] = (int16_t)lrintf(inp);            }        }        break;    }}static void to_PCM_24bit(NeAACDecHandle hDecoder, real_t **input,                         uint8_t channels, uint16_t frame_len,                         int32_t **sample_buffer){    uint8_t ch, ch1;    uint16_t i;    switch (CONV(channels,hDecoder->downMatrix))    {    case CONV(1,0):    case CONV(1,1):        for(i = 0; i < frame_len; i++)        {            real_t inp = input[hDecoder->internal_channel[0]][i];            inp *= 256.0f;            CLIP(inp, 8388607.0f, -8388608.0f);            (*sample_buffer)[i] = (int32_t)lrintf(inp);        }        break;    case CONV(2,0):        if (hDecoder->upMatrix)        {            ch = hDecoder->internal_channel[0];            for(i = 0; i < frame_len; i++)            {                real_t inp0 = input[ch][i];                inp0 *= 256.0f;                CLIP(inp0, 8388607.0f, -8388608.0f);                (*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0);                (*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp0);            }        } else {            ch  = hDecoder->internal_channel[0];            ch1 = hDecoder->internal_channel[1];            for(i = 0; i < frame_len; i++)            {                real_t inp0 = input[ch ][i];                real_t inp1 = input[ch1][i];                inp0 *= 256.0f;                inp1 *= 256.0f;                CLIP(inp0, 8388607.0f, -8388608.0f);                CLIP(inp1, 8388607.0f, -8388608.0f);                (*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0);                (*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp1);            }        }        break;    default:        for (ch = 0; ch < channels; ch++)        {            for(i = 0; i < frame_len; i++)            {                real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);                inp *= 256.0f;                CLIP(inp, 8388607.0f, -8388608.0f);                (*sample_buffer)[(i*channels)+ch] = (int32_t)lrintf(inp);            }        }        break;    }}static void to_PCM_32bit(NeAACDecHandle hDecoder, real_t **input,                         uint8_t channels, uint16_t frame_len,                         int32_t **sample_buffer){    uint8_t ch, ch1;    uint16_t i;    switch (CONV(channels,hDecoder->downMatrix))    {    case CONV(1,0):    case CONV(1,1):        for(i = 0; i < frame_len; i++)        {            real_t inp = input[hDecoder->internal_channel[0]][i];            inp *= 65536.0f;            CLIP(inp, 2147483647.0f, -2147483648.0f);            (*sample_buffer)[i] = (int32_t)lrintf(inp);        }        break;    case CONV(2,0):        if (hDecoder->upMatrix)        {            ch = hDecoder->internal_channel[0];            for(i = 0; i < frame_len; i++)            {                real_t inp0 = input[ch][i];                inp0 *= 65536.0f;                CLIP(inp0, 2147483647.0f, -2147483648.0f);                (*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0);                (*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp0);            }        } else {            ch  = hDecoder->internal_channel[0];            ch1 = hDecoder->internal_channel[1];            for(i = 0; i < frame_len; i++)            {                real_t inp0 = input[ch ][i];                real_t inp1 = input[ch1][i];                inp0 *= 65536.0f;                inp1 *= 65536.0f;                CLIP(inp0, 2147483647.0f, -2147483648.0f);                CLIP(inp1, 2147483647.0f, -2147483648.0f);                (*sample_buffer)[(i*2)+0] = (int32_t)lrintf(inp0);                (*sample_buffer)[(i*2)+1] = (int32_t)lrintf(inp1);            }        }        break;    default:        for (ch = 0; ch < channels; ch++)        {            for(i = 0; i < frame_len; i++)            {                real_t inp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);                inp *= 65536.0f;                CLIP(inp, 2147483647.0f, -2147483648.0f);                (*sample_buffer)[(i*channels)+ch] = (int32_t)lrintf(inp);            }        }        break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -