134 for(
i = 0;
i < 8;
i++){
137 for(j = 0; j <
i; j++)
142 for(
i = 0;
i < 8;
i++)
153 for(
i = 0;
i < 8;
i++){
158 for(
i = 0;
i < 8;
i++){
163 for(
i = 0;
i < 8;
i++){
171 int16_t
tmp[146 + 60], *ptr0, *ptr1;
180 for(
i = 0;
i < 146;
i++)
182 off = (t / 25) + dec->
offset1[quart >> 1] + 18;
184 ptr0 =
tmp + 145 - off;
187 for(
i = 0;
i < 60;
i++){
188 t = (ptr0[0] *
filter[0] + ptr0[1] *
filter[1] + 0x2000) >> 14;
203 memset(
out, 0, 60 *
sizeof(*
out));
204 for(
i = 0;
i < 7;
i++) {
213 for(
i = 0, j = 3; (
i < 30) && (j > 0);
i++){
223 coef = dec->
pulsepos[quart] & 0x7FFF;
225 for(
i = 30, j = 4; (
i < 60) && (j > 0);
i++){
243 for(
i = 0;
i < 60;
i++){
253 int16_t *ptr0, *ptr1;
256 ptr1 = dec->
filters + quart * 8;
257 for(
i = 0;
i < 60;
i++){
259 for(k = 0; k < 8; k++)
260 sum += ptr0[k] * (
unsigned)ptr1[k];
261 sum =
out[
i] + ((int)(sum + 0x800U) >> 12);
263 for(k = 7; k > 0; k--)
264 ptr0[k] = ptr0[k - 1];
268 for(
i = 0;
i < 8;
i++)
272 for(
i = 0;
i < 60;
i++){
274 for(k = 0; k < 8; k++)
275 sum += ptr0[k] * t[k];
276 for(k = 7; k > 0; k--)
277 ptr0[k] = ptr0[k - 1];
279 out[
i] += (- sum) >> 12;
282 for(
i = 0;
i < 8;
i++)
286 for(
i = 0;
i < 60;
i++){
287 int sum =
out[
i] * (1 << 12);
288 for(k = 0; k < 8; k++)
289 sum += ptr0[k] * t[k];
290 for(k = 7; k > 0; k--)
291 ptr0[k] = ptr0[k - 1];
292 ptr0[0] =
av_clip((sum + 0x800) >> 12, -0x7FFE, 0x7FFE);
294 sum = ((ptr0[1] * (dec->
filtval - (dec->
filtval >> 2))) >> 4) + sum;
295 sum = sum - (sum >> 3);
296 out[
i] =
av_clip((sum + 0x800) >> 12, -0x7FFE, 0x7FFE);
304 for(
i = 0;
i < 8;
i++)
305 c->prevfilt[
i] =
c->cvector[
i];
309 int *got_frame_ptr,
AVPacket *avpkt)
311 const uint8_t *buf = avpkt->
data;
312 int buf_size = avpkt->
size;
319 iterations = buf_size / 32;
323 "Too small input buffer (%d bytes), need at least 32 bytes\n", buf_size);
326 if (iterations > INT_MAX / 240) {
328 "Too large input buffer (%d bytes); per-block sample count overflows\n", buf_size);
333 frame->nb_samples = iterations * 240;
336 samples = (int16_t *)
frame->data[0];
338 memset(samples, 0, iterations * 240 *
sizeof(*samples));
340 for(j = 0; j < iterations; j++) {
347 for(
i = 0;
i < 4;
i++) {
364 .p.name =
"truespeech",
const FFCodec ff_truespeech_decoder
Libavcodec external API header.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
bitstream reader API header.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static unsigned int get_bits1(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CHANNEL_LAYOUT_MONO
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_SAMPLE_FMT_S16
signed 16 bits
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
TrueSpeech decoder context.
int offset1[2]
8-bit value, used in one copying offset
int offset2[4]
7-bit value, encodes offsets for copying and for two-point filter
int flag
1-bit flag, shows how to choose filters
int pulseval[4]
7x2-bit pulse values
int pulseoff[4]
4-bit offset of pulse values block
int16_t vector[8]
input vector: 5/5/4/4/4/3/3/3
int pulsepos[4]
27-bit variable, encodes 7 pulse positions
#define avpriv_request_sample(...)
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
static int truespeech_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
static void truespeech_apply_twopoint_filter(TSContext *dec, int quart)
static av_cold int truespeech_decode_init(AVCodecContext *avctx)
static void truespeech_save_prevvec(TSContext *c)
static void truespeech_place_pulses(TSContext *dec, int16_t *out, int quart)
static void truespeech_correlate_filter(TSContext *dec)
static void truespeech_synth(TSContext *dec, int16_t *out, int quart)
static void truespeech_read_frame(TSContext *dec, const uint8_t *input)
static void truespeech_filters_merge(TSContext *dec)
static void truespeech_update_filters(TSContext *dec, int16_t *out, int quart)
static const int16_t ts_order2_coeffs[25 *2]
static const int16_t *const ts_codebook[8]
static const int16_t ts_decay_35_64[8]
static const int16_t ts_pulse_values[120]
static const int16_t ts_decay_3_4[8]
static const int16_t ts_pulse_scales[64]
static const int16_t ts_decay_994_1000[8]