133 for(i = 0; i < 8; i++){
135 memcpy(tmp, dec->
cvector, i *
sizeof(*tmp));
136 for(j = 0; j <
i; j++)
137 dec->
cvector[j] += (tmp[i - j - 1] * dec->
vector[i] + 0x4000) >> 15;
141 for(i = 0; i < 8; i++)
152 for(i = 0; i < 8; i++){
157 for(i = 0; i < 8; i++){
162 for(i = 0; i < 8; i++){
170 int16_t
tmp[146 + 60], *ptr0, *ptr1;
179 for(i = 0; i < 146; i++)
181 off = (t / 25) + dec->
offset1[quart >> 1] + 18;
183 ptr0 = tmp + 145 - off;
186 for(i = 0; i < 60; i++){
187 t = (ptr0[0] * filter[0] + ptr0[1] * filter[1] + 0x2000) >> 14;
202 memset(out, 0, 60 *
sizeof(*out));
203 for(i = 0; i < 7; i++) {
212 for(i = 0, j = 3; (i < 30) && (j > 0); i++){
222 coef = dec->
pulsepos[quart] & 0x7FFF;
224 for(i = 30, j = 4; (i < 60) && (j > 0); i++){
242 for(i = 0; i < 60; i++){
252 int16_t *ptr0, *ptr1;
255 ptr1 = dec->
filters + quart * 8;
256 for(i = 0; i < 60; i++){
258 for(k = 0; k < 8; k++)
259 sum += ptr0[k] * (
unsigned)ptr1[k];
260 sum = out[
i] + ((
int)(sum + 0x800U) >> 12);
261 out[
i] =
av_clip(sum, -0x7FFE, 0x7FFE);
262 for(k = 7; k > 0; k--)
263 ptr0[k] = ptr0[k - 1];
267 for(i = 0; i < 8; i++)
271 for(i = 0; i < 60; i++){
273 for(k = 0; k < 8; k++)
274 sum += ptr0[k] * t[k];
275 for(k = 7; k > 0; k--)
276 ptr0[k] = ptr0[k - 1];
278 out[
i] += (- sum) >> 12;
281 for(i = 0; i < 8; i++)
285 for(i = 0; i < 60; i++){
286 int sum = out[
i] * (1 << 12);
287 for(k = 0; k < 8; k++)
288 sum += ptr0[k] * t[k];
289 for(k = 7; k > 0; k--)
290 ptr0[k] = ptr0[k - 1];
291 ptr0[0] =
av_clip((sum + 0x800) >> 12, -0x7FFE, 0x7FFE);
293 sum = ((ptr0[1] * (dec->
filtval - (dec->
filtval >> 2))) >> 4) + sum;
294 sum = sum - (sum >> 3);
295 out[
i] =
av_clip((sum + 0x800) >> 12, -0x7FFE, 0x7FFE);
303 for(i = 0; i < 8; i++)
308 int *got_frame_ptr,
AVPacket *avpkt)
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);
331 samples = (int16_t *)frame->
data[0];
333 memset(samples, 0, iterations * 240 *
sizeof(*samples));
335 for(j = 0; j < iterations; j++) {
342 for(i = 0; i < 4; i++) {
359 .
name =
"truespeech",
int pulseval[4]
7x2-bit pulse values
static const int16_t ts_decay_994_1000[8]
This structure describes decoded (raw) audio or video data.
static void truespeech_update_filters(TSContext *dec, int16_t *out, int quart)
ptrdiff_t const GLvoid * data
static int truespeech_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static void truespeech_correlate_filter(TSContext *dec)
AVCodec ff_truespeech_decoder
static void truespeech_apply_twopoint_filter(TSContext *dec, int quart)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_cold int init(AVCodecContext *avctx)
#define avpriv_request_sample(...)
static void truespeech_filters_merge(TSContext *dec)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static void truespeech_read_frame(TSContext *dec, const uint8_t *input)
enum AVSampleFormat sample_fmt
audio sample format
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static av_cold int truespeech_decode_init(AVCodecContext *avctx)
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
bitstream reader API header.
static const int16_t *const ts_codebook[8]
static const int16_t ts_order2_coeffs[25 *2]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const char * name
Name of the codec implementation.
static const int16_t ts_pulse_values[120]
uint64_t channel_layout
Audio channel layout.
int pulsepos[4]
27-bit variable, encodes 7 pulse positions
int16_t vector[8]
input vector: 5/5/4/4/4/3/3/3
audio channel layout utility functions
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
TrueSpeech decoder context.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int offset2[4]
7-bit value, encodes offsets for copying and for two-point filter
Libavcodec external API header.
static const int16_t ts_decay_3_4[8]
main external API structure.
int offset1[2]
8-bit value, used in one copying offset
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static unsigned int get_bits1(GetBitContext *s)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static void truespeech_synth(TSContext *dec, int16_t *out, int quart)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int pulseoff[4]
4-bit offset of pulse values block
common internal api header.
static const int16_t ts_decay_35_64[8]
int flag
1-bit flag, shows how to choose filters
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
int channels
number of audio channels
static void truespeech_place_pulses(TSContext *dec, int16_t *out, int quart)
Filter the word “frame” indicates either a video frame or a group of audio samples
static const int16_t ts_pulse_scales[64]
#define AV_CH_LAYOUT_MONO
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static void truespeech_save_prevvec(TSContext *c)