summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libcook/cook.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libcook/cook.h')
-rw-r--r--lib/rbcodec/codecs/libcook/cook.h131
1 files changed, 131 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libcook/cook.h b/lib/rbcodec/codecs/libcook/cook.h
new file mode 100644
index 0000000000..fcb437a0e1
--- /dev/null
+++ b/lib/rbcodec/codecs/libcook/cook.h
@@ -0,0 +1,131 @@
1/*
2 * COOK compatible decoder
3 * Copyright (c) 2003 Sascha Sommer
4 * Copyright (c) 2005 Benjamin Larsson
5 *
6 * This file is taken from FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22#ifndef _COOK_H
23#define _COOK_H
24
25#include <inttypes.h>
26#include "ffmpeg_get_bits.h"
27#include "../librm/rm.h"
28#include "cookdata_fixpoint.h"
29
30#include "codeclib.h"
31
32#if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || (CONFIG_CPU == MCF5250)
33/* PP5022/24, MCF5250 have large IRAM */
34#define IBSS_ATTR_COOK_LARGE_IRAM IBSS_ATTR
35#define ICODE_ATTR_COOK_LARGE_IRAM ICODE_ATTR
36#define ICONST_ATTR_COOK_LARGE_IRAM ICONST_ATTR
37#define IBSS_ATTR_COOK_VLCBUF
38#define ICODE_ATTR_COOK_DECODE
39
40#elif defined(CPU_S5L870X)
41/* S5L870X have even larger IRAM and it is faster to use ICODE_ATTR. */
42#define IBSS_ATTR_COOK_LARGE_IRAM IBSS_ATTR
43#define ICODE_ATTR_COOK_LARGE_IRAM ICODE_ATTR
44#define ICONST_ATTR_COOK_LARGE_IRAM ICONST_ATTR
45#define IBSS_ATTR_COOK_VLCBUF IBSS_ATTR
46#define ICODE_ATTR_COOK_DECODE ICODE_ATTR
47
48#else
49/* other CPUs IRAM is not large enough */
50#define IBSS_ATTR_COOK_LARGE_IRAM
51#define ICODE_ATTR_COOK_LARGE_IRAM
52#define ICONST_ATTR_COOK_LARGE_IRAM
53#define IBSS_ATTR_COOK_VLCBUF
54#define ICODE_ATTR_COOK_DECODE
55
56#endif
57
58typedef struct {
59 int *now;
60 int *previous;
61} cook_gains;
62
63typedef struct cook {
64 /*
65 * The following 2 functions provide the lowlevel arithmetic on
66 * the internal audio buffers.
67 */
68 void (* scalar_dequant)(struct cook *q, int index, int quant_index,
69 int* subband_coef_index, int* subband_coef_sign,
70 REAL_T* mlt_p);
71
72 void (* interpolate) (struct cook *q, REAL_T* buffer,
73 int gain_index, int gain_index_next);
74
75 GetBitContext gb;
76 int frame_number;
77 int block_align;
78 int extradata_size;
79 /* stream data */
80 int nb_channels;
81 int joint_stereo;
82 int bit_rate;
83 int sample_rate;
84 int samples_per_channel;
85 int samples_per_frame;
86 int subbands;
87 int log2_numvector_size;
88 int numvector_size; //1 << log2_numvector_size;
89 int js_subband_start;
90 int total_subbands;
91 int num_vectors;
92 int bits_per_subpacket;
93 int cookversion;
94 int mdct_nbits; /* is this the same as one of above? */
95 /* states */
96 int random_state;
97
98 /* gain buffers */
99 cook_gains gains1;
100 cook_gains gains2;
101 int gain_1[9];
102 int gain_2[9];
103 int gain_3[9];
104 int gain_4[9];
105
106 /* VLC data */
107 int js_vlc_bits;
108 VLC envelope_quant_index[13];
109 VLC sqvh[7]; //scalar quantization
110 VLC ccpl; //channel coupling
111
112 /* generatable tables and related variables */
113 int gain_size_factor;
114
115 /* data buffers */
116
117 uint8_t decoded_bytes_buffer[1024] MEM_ALIGN_ATTR;
118 REAL_T mono_mdct_output[2048] MEM_ALIGN_ATTR;
119 REAL_T mono_previous_buffer1[1024] MEM_ALIGN_ATTR;
120 REAL_T mono_previous_buffer2[1024] MEM_ALIGN_ATTR;
121 REAL_T decode_buffer_1[1024] MEM_ALIGN_ATTR;
122 REAL_T decode_buffer_2[1024] MEM_ALIGN_ATTR;
123 /* static allocation for joint decode */
124 REAL_T decode_buffer_0[1060] MEM_ALIGN_ATTR;
125} COOKContext;
126
127int cook_decode_init(RMContext *rmctx, COOKContext *q);
128int cook_decode_frame(RMContext *rmctx,COOKContext *q,
129 int32_t *outbuffer, int *data_size,
130 const uint8_t *inbuffer, int buf_size);
131#endif /*_COOK_H */