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
47
48 /** decoder context */
52
53 /* buffer used to store the whole first packet.
54 data is only sent as one large packet */
59
60 static const int8_t
fibonacci[16] = { -34, -21, -13, -8, -5, -3, -2, -1, 0, 1, 2, 3, 5, 8, 13, 21 };
61 static const int8_t
exponential[16] = { -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64 };
62
63 #define MAX_FRAME_SIZE 2048
64
65 /**
66 * Delta decode the compressed values in src, and put the resulting
67 * decoded samples in dst.
68 *
69 * @param[in,out] state starting value. it is saved for use in the next call.
70 * @param table delta sequence table
71 */
74 {
76
77 while (src_size--) {
83 }
84
86 }
87
88 /** decode a frame */
91 {
94 int buf_size;
96 int hdr_size = 2;
97
98 /* decode and interleave the first packet */
99 if (!esc->
data[0] && avpkt) {
101
104 }
108 }
109
112 esc->
fib_acc[1] = avpkt->
data[2+chan_size+1] + 128;
113
122 }
123 }
124 memcpy(esc->
data[0], &avpkt->
data[hdr_size], chan_size);
126 memcpy(esc->
data[1], &avpkt->
data[2*hdr_size+chan_size], chan_size);
127 }
131 }
132
133 /* decode next piece of data from the buffer */
135 if (buf_size <= 0) {
136 *got_frame_ptr = 0;
138 }
139
140 /* get output buffer */
144
148 }
149
151
152 *got_frame_ptr = 1;
153
155 }
156
158 {
160
164 }
165
169 default:
171 }
173
174 return 0;
175 }
176
178 {
180
185
186 return 0;
187 }
188
189 #if CONFIG_EIGHTSVX_FIB_DECODER
191 .
p.
name =
"8svx_fib",
202 };
203 #endif
204 #if CONFIG_EIGHTSVX_EXP_DECODER
206 .
p.
name =
"8svx_exp",
217 };
218 #endif