summaryrefslogtreecommitdiff
path: root/apps/codecs/libcook/cook.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libcook/cook.h')
-rw-r--r--apps/codecs/libcook/cook.h122
1 files changed, 122 insertions, 0 deletions
diff --git a/apps/codecs/libcook/cook.h b/apps/codecs/libcook/cook.h
new file mode 100644
index 0000000000..8d4c078f1a
--- /dev/null
+++ b/apps/codecs/libcook/cook.h
@@ -0,0 +1,122 @@
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
23#ifndef _COOK_H
24#define _COOK_H
25
26#include <stdint.h>
27#include "libavutil/lfg.h"
28#include "bitstream.h"
29#include "dsputil.h"
30#include "bytestream.h"
31#include "rm2wav.h"
32
33typedef struct {
34 int *now;
35 int *previous;
36} cook_gains;
37
38typedef struct cook {
39 /*
40 * The following 5 functions provide the lowlevel arithmetic on
41 * the internal audio buffers.
42 */
43 void (* scalar_dequant)(struct cook *q, int index, int quant_index,
44 int* subband_coef_index, int* subband_coef_sign,
45 float* mlt_p);
46
47 void (* decouple) (struct cook *q,
48 int subband,
49 float f1, float f2,
50 float *decode_buffer,
51 float *mlt_buffer1, float *mlt_buffer2);
52
53 void (* imlt_window) (struct cook *q, float *buffer1,
54 cook_gains *gains_ptr, float *previous_buffer);
55
56 void (* interpolate) (struct cook *q, float* buffer,
57 int gain_index, int gain_index_next);
58
59 void (* saturate_output) (struct cook *q, int chan, int16_t *out);
60
61 GetBitContext gb;
62 int frame_number;
63 int block_align;
64 int extradata_size;
65 /* stream data */
66 int nb_channels;
67 int joint_stereo;
68 int bit_rate;
69 int sample_rate;
70 int samples_per_channel;
71 int samples_per_frame;
72 int subbands;
73 int log2_numvector_size;
74 int numvector_size; //1 << log2_numvector_size;
75 int js_subband_start;
76 int total_subbands;
77 int num_vectors;
78 int bits_per_subpacket;
79 int cookversion;
80 /* states */
81 AVLFG random_state;
82 /* transform data */
83 MDCTContext mdct_ctx;
84 float* mlt_window;
85
86 /* gain buffers */
87 cook_gains gains1;
88 cook_gains gains2;
89 int gain_1[9];
90 int gain_2[9];
91 int gain_3[9];
92 int gain_4[9];
93
94 /* VLC data */
95 int js_vlc_bits;
96 VLC envelope_quant_index[13];
97 VLC sqvh[7]; //scalar quantization
98 VLC ccpl; //channel coupling
99
100 /* generatable tables and related variables */
101 int gain_size_factor;
102 float gain_table[23];
103
104 /* data buffers */
105
106 uint8_t* decoded_bytes_buffer;
107 float mono_mdct_output[2048] __attribute__ ((aligned(16))); //DECLARE_ALIGNED_16(float,mono_mdct_output[2048]);
108 float mono_previous_buffer1[1024];
109 float mono_previous_buffer2[1024];
110 float decode_buffer_1[1024];
111 float decode_buffer_2[1024];
112 float decode_buffer_0[1060]; /* static allocation for joint decode */
113
114 const float *cplscales[5];
115} COOKContext;
116
117av_cold int cook_decode_init(RMContext *rmctx, COOKContext *q);
118int cook_decode_frame(RMContext *rmctx,COOKContext *q,
119 int16_t *outbuffer, int *data_size,
120 const uint8_t *inbuffer, int buf_size);
121av_cold int cook_decode_close(COOKContext *q);
122#endif