* DSP Group TrueSpeech compatible decoder
* Copyright (c) 2005 Konstantin Shishkov
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "truespeech_data.h"
/**
- * @file truespeech.c
+ * @file
* TrueSpeech decoder.
*/
{
// TSContext *c = avctx->priv_data;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
dec->cvector[i] = (8 - dec->vector[i]) >> 3;
}
for(i = 0; i < 8; i++)
- dec->cvector[i] = (dec->cvector[i] * ts_230[i]) >> 15;
+ dec->cvector[i] = (dec->cvector[i] * ts_decay_994_1000[i]) >> 15;
dec->filtval = dec->vector[0];
}
off = (t / 25) + dec->offset1[quart >> 1] + 18;
ptr0 = tmp + 145 - off;
ptr1 = tmp + 146;
- filter = (const int16_t*)ts_240 + (t % 25) * 2;
+ filter = (const int16_t*)ts_order2_coeffs + (t % 25) * 2;
for(i = 0; i < 60; i++){
t = (ptr0[0] * filter[0] + ptr0[1] * filter[1] + 0x2000) >> 14;
ptr0++;
for(i = 0; i < 7; i++) {
t = dec->pulseval[quart] & 3;
dec->pulseval[quart] >>= 2;
- tmp[6 - i] = ts_562[dec->pulseoff[quart] * 4 + t];
+ tmp[6 - i] = ts_pulse_scales[dec->pulseoff[quart] * 4 + t];
}
coef = dec->pulsepos[quart] >> 15;
- ptr1 = (const int16_t*)ts_140 + 30;
+ ptr1 = (const int16_t*)ts_pulse_values + 30;
ptr2 = tmp;
for(i = 0, j = 3; (i < 30) && (j > 0); i++){
t = *ptr1++;
}
}
coef = dec->pulsepos[quart] & 0x7FFF;
- ptr1 = (const int16_t*)ts_140;
+ ptr1 = (const int16_t*)ts_pulse_values;
for(i = 30, j = 4; (i < 60) && (j > 0); i++){
t = *ptr1++;
if(coef >= t)
}
for(i = 0; i < 8; i++)
- t[i] = (ts_5E2[i] * ptr1[i]) >> 15;
+ t[i] = (ts_decay_35_64[i] * ptr1[i]) >> 15;
ptr0 = dec->tmp2;
for(i = 0; i < 60; i++){
}
for(i = 0; i < 8; i++)
- t[i] = (ts_5F2[i] * ptr1[i]) >> 15;
+ t[i] = (ts_decay_3_4[i] * ptr1[i]) >> 15;
ptr0 = dec->tmp3;
for(i = 0; i < 60; i++){
static int truespeech_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- const uint8_t *buf, int buf_size)
+ AVPacket *avpkt)
{
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
TSContext *c = avctx->priv_data;
int i, j;
if (!buf_size)
return 0;
+ if (buf_size < 32) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Too small input buffer (%d bytes), need at least 32 bytes\n", buf_size);
+ return -1;
+ }
iterations = FFMIN(buf_size / 32, *data_size / 480);
for(j = 0; j < iterations; j++) {
truespeech_read_frame(c, buf + consumed);
return consumed;
}
-AVCodec truespeech_decoder = {
+AVCodec ff_truespeech_decoder = {
"truespeech",
- CODEC_TYPE_AUDIO,
+ AVMEDIA_TYPE_AUDIO,
CODEC_ID_TRUESPEECH,
sizeof(TSContext),
truespeech_decode_init,