57
59
* @param[in,out] state starting value. it is saved for use in the next call.
59
61
static void delta_decode(uint8_t *dst, const uint8_t *src, int src_size,
60
uint8_t *state, const int8_t *table, int channels)
62
uint8_t *state, const int8_t *table)
62
64
uint8_t val = *state;
64
66
while (src_size--) {
65
67
uint8_t d = *src++;
66
68
val = av_clip_uint8(val + table[d & 0xF]);
69
70
val = av_clip_uint8(val + table[d >> 4]);
77
static void raw_decode(uint8_t *dst, const int8_t *src, int src_size,
77
static void raw_decode(uint8_t *dst, const int8_t *src, int src_size)
80
*dst++ = *src++ + 128;
86
83
/** decode a frame */
142
138
/* get output buffer */
143
139
esc->frame.nb_samples = buf_size * (is_compr + 1);
144
if ((ret = avctx->get_buffer(avctx, &esc->frame)) < 0) {
140
if ((ret = ff_get_buffer(avctx, &esc->frame)) < 0) {
145
141
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
148
out_data = esc->frame.data[0];
151
delta_decode(out_data, &esc->data[0][esc->data_idx], buf_size,
152
&esc->fib_acc[0], esc->table, avctx->channels);
153
if (avctx->channels == 2) {
154
delta_decode(&out_data[1], &esc->data[1][esc->data_idx], buf_size,
155
&esc->fib_acc[1], esc->table, avctx->channels);
159
for (ch = 0; ch < avctx->channels; ch++) {
160
raw_decode((int8_t *)&out_data[ch], &esc->data[ch][esc->data_idx],
161
buf_size, avctx->channels);
145
for (ch = 0; ch < avctx->channels; ch++) {
147
delta_decode(esc->frame.data[ch], &esc->data[ch][esc->data_idx],
148
buf_size, &esc->fib_acc[ch], esc->table);
150
raw_decode(esc->frame.data[ch], &esc->data[ch][esc->data_idx],
164
155
esc->data_idx += buf_size;
166
157
*got_frame_ptr = 1;
182
173
switch(avctx->codec->id) {
183
case CODEC_ID_8SVX_FIB:
174
case AV_CODEC_ID_8SVX_FIB:
184
175
esc->table = fibonacci;
186
case CODEC_ID_8SVX_EXP:
177
case AV_CODEC_ID_8SVX_EXP:
187
178
esc->table = exponential;
189
case CODEC_ID_PCM_S8_PLANAR:
180
case AV_CODEC_ID_PCM_S8_PLANAR:
194
avctx->sample_fmt = AV_SAMPLE_FMT_U8;
185
avctx->sample_fmt = AV_SAMPLE_FMT_U8P;
196
187
avcodec_get_frame_defaults(&esc->frame);
197
188
avctx->coded_frame = &esc->frame;
212
203
AVCodec ff_eightsvx_fib_decoder = {
213
204
.name = "8svx_fib",
214
205
.type = AVMEDIA_TYPE_AUDIO,
215
.id = CODEC_ID_8SVX_FIB,
206
.id = AV_CODEC_ID_8SVX_FIB,
216
207
.priv_data_size = sizeof (EightSvxContext),
217
208
.init = eightsvx_decode_init,
218
209
.close = eightsvx_decode_close,
219
210
.decode = eightsvx_decode_frame,
220
211
.capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1,
221
212
.long_name = NULL_IF_CONFIG_SMALL("8SVX fibonacci"),
213
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P,
214
AV_SAMPLE_FMT_NONE },
224
217
AVCodec ff_eightsvx_exp_decoder = {
225
218
.name = "8svx_exp",
226
219
.type = AVMEDIA_TYPE_AUDIO,
227
.id = CODEC_ID_8SVX_EXP,
220
.id = AV_CODEC_ID_8SVX_EXP,
228
221
.priv_data_size = sizeof (EightSvxContext),
229
222
.init = eightsvx_decode_init,
230
223
.close = eightsvx_decode_close,
231
224
.decode = eightsvx_decode_frame,
232
225
.capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1,
233
226
.long_name = NULL_IF_CONFIG_SMALL("8SVX exponential"),
227
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P,
228
AV_SAMPLE_FMT_NONE },
236
231
AVCodec ff_pcm_s8_planar_decoder = {
237
232
.name = "pcm_s8_planar",
238
233
.type = AVMEDIA_TYPE_AUDIO,
239
.id = CODEC_ID_PCM_S8_PLANAR,
234
.id = AV_CODEC_ID_PCM_S8_PLANAR,
240
235
.priv_data_size = sizeof(EightSvxContext),
241
236
.init = eightsvx_decode_init,
242
237
.close = eightsvx_decode_close,
243
238
.decode = eightsvx_decode_frame,
244
239
.capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1,
245
240
.long_name = NULL_IF_CONFIG_SMALL("PCM signed 8-bit planar"),
241
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P,
242
AV_SAMPLE_FMT_NONE },