1 /*
2 * Copyright (C) 2008 Jaikrishnan Menon
3 * Copyright (C) 2011 Stefano Sabatini
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * 8svx audio decoder
25 * @author Jaikrishnan Menon
26 *
27 * supports: fibonacci delta encoding
28 * : exponential encoding
29 *
30 * For more information about the 8SVX format:
31 * http://netghost.narod.ru/gff/vendspec/iff/iff.txt
32 * http://sox.sourceforge.net/AudioFormats-11.html
33 * http://aminet.net/package/mus/misc/wavepak
34 * http://amigan.1emu.net/reg/8SVX.txt
35 *
36 * Samples can be found here:
37 * http://aminet.net/mods/smpl/
38 */
39
40 #include "config_components.h"
41
48
49 /** decoder context */
53
54 /* buffer used to store the whole first packet.
55 data is only sent as one large packet */
60
61 static const int8_t
fibonacci[16] = { -34, -21, -13, -8, -5, -3, -2, -1, 0, 1, 2, 3, 5, 8, 13, 21 };
62 static const int8_t
exponential[16] = { -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64 };
63
64 #define MAX_FRAME_SIZE 2048
65
66 /**
67 * Delta decode the compressed values in src, and put the resulting
68 * decoded samples in dst.
69 *
70 * @param[in,out] state starting value. it is saved for use in the next call.
71 * @param table delta sequence table
72 */
75 {
77
78 while (src_size--) {
84 }
85
87 }
88
89 /** decode a frame */
92 {
95 int buf_size;
97 int hdr_size = 2;
98
99 /* decode and interleave the first packet */
100 if (!esc->
data[0] && avpkt) {
102
105 }
109 }
110
113 esc->
fib_acc[1] = avpkt->
data[2+chan_size+1] + 128;
114
123 }
124 }
125 memcpy(esc->
data[0], &avpkt->
data[hdr_size], chan_size);
127 memcpy(esc->
data[1], &avpkt->
data[2*hdr_size+chan_size], chan_size);
128 }
132 }
133
134 /* decode next piece of data from the buffer */
136 if (buf_size <= 0) {
137 *got_frame_ptr = 0;
139 }
140
141 /* get output buffer */
142 frame->nb_samples = buf_size * 2;
145
149 }
150
152
153 *got_frame_ptr = 1;
154
156 }
157
159 {
161
165 }
166
170 default:
172 }
174
175 return 0;
176 }
177
179 {
181
186
187 return 0;
188 }
189
190 #if CONFIG_EIGHTSVX_FIB_DECODER
192 .
p.
name =
"8svx_fib",
202 };
203 #endif
204 #if CONFIG_EIGHTSVX_EXP_DECODER
206 .
p.
name =
"8svx_exp",
216 };
217 #endif