131 for(i = 0; i < 8; i++){
133 memcpy(tmp, dec->
cvector, i *
sizeof(*tmp));
134 for(j = 0; j < i; j++)
136 (dec->
cvector[j] << 15) + 0x4000) >> 15;
140 for(i = 0; i < 8; i++)
151 for(i = 0; i < 8; i++){
156 for(i = 0; i < 8; i++){
161 for(i = 0; i < 8; i++){
169 int16_t tmp[146 + 60], *ptr0, *ptr1;
178 for(i = 0; i < 146; i++)
180 off = (t / 25) + dec->
offset1[quart >> 1] + 18;
181 off = av_clip(off, 0, 145);
182 ptr0 = tmp + 145 - off;
185 for(i = 0; i < 60; i++){
186 t = (ptr0[0] * filter[0] + ptr0[1] * filter[1] + 0x2000) >> 14;
201 memset(out, 0, 60 *
sizeof(*out));
202 for(i = 0; i < 7; i++) {
211 for(i = 0, j = 3; (i < 30) && (j > 0); i++){
221 coef = dec->
pulsepos[quart] & 0x7FFF;
223 for(i = 30, j = 4; (i < 60) && (j > 0); i++){
241 for(i = 0; i < 60; i++){
251 int16_t *ptr0, *ptr1;
254 ptr1 = dec->
filters + quart * 8;
255 for(i = 0; i < 60; i++){
257 for(k = 0; k < 8; k++)
258 sum += ptr0[k] * ptr1[k];
259 sum = (sum + (out[i] << 12) + 0x800) >> 12;
260 out[i] = av_clip(sum, -0x7FFE, 0x7FFE);
261 for(k = 7; k > 0; k--)
262 ptr0[k] = ptr0[k - 1];
266 for(i = 0; i < 8; i++)
270 for(i = 0; i < 60; i++){
272 for(k = 0; k < 8; k++)
273 sum += ptr0[k] * t[k];
274 for(k = 7; k > 0; k--)
275 ptr0[k] = ptr0[k - 1];
277 out[i] = ((out[i] << 12) - sum) >> 12;
280 for(i = 0; i < 8; i++)
284 for(i = 0; i < 60; i++){
285 int sum = out[i] << 12;
286 for(k = 0; k < 8; k++)
287 sum += ptr0[k] * t[k];
288 for(k = 7; k > 0; k--)
289 ptr0[k] = ptr0[k - 1];
290 ptr0[0] = av_clip((sum + 0x800) >> 12, -0x7FFE, 0x7FFE);
292 sum = ((ptr0[1] * (dec->
filtval - (dec->
filtval >> 2))) >> 4) + sum;
293 sum = sum - (sum >> 3);
294 out[i] = av_clip((sum + 0x800) >> 12, -0x7FFE, 0x7FFE);
302 for(i = 0; i < 8; i++)
307 int *got_frame_ptr,
AVPacket *avpkt)
311 int buf_size = avpkt->
size;
318 iterations = buf_size / 32;
322 "Too small input buffer (%d bytes), need at least 32 bytes\n", buf_size);
330 samples = (int16_t *)frame->
data[0];
332 memset(samples, 0, iterations * 240 *
sizeof(*samples));
334 for(j = 0; j < iterations; j++) {
341 for(i = 0; i < 4; i++) {
358 .
name =
"truespeech",
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
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)
static void truespeech_filters_merge(TSContext *dec)
#define DECLARE_ALIGNED(n, t, v)
static void truespeech_read_frame(TSContext *dec, const uint8_t *input)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
enum AVSampleFormat sample_fmt
audio sample format
static av_cold int truespeech_decode_init(AVCodecContext *avctx)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
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.
#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]
Libavcodec external API header.
uint64_t channel_layout
Audio channel layout.
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
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
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
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.
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.
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
int pulseoff[4]
4-bit offset of pulse values block
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
common internal api header.
static const int16_t ts_decay_35_64[8]
int flag
1-bit flag, shows how to choose filters
int channels
number of audio channels
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
static void truespeech_place_pulses(TSContext *dec, int16_t *out, int quart)
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
static void truespeech_save_prevvec(TSContext *c)