Go to the documentation of this file.
22 #ifndef AVCODEC_TWINVQ_H
23 #define AVCODEC_TWINVQ_H
46 #define TWINVQ_PPC_SHAPE_CB_SIZE 64
47 #define TWINVQ_PPC_SHAPE_LEN_MAX 60
48 #define TWINVQ_SUB_AMP_MAX 4500.0
49 #define TWINVQ_MULAW_MU 100.0
50 #define TWINVQ_GAIN_BITS 8
51 #define TWINVQ_AMP_MAX 13000.0
52 #define TWINVQ_SUB_GAIN_BITS 5
53 #define TWINVQ_WINDOW_TYPE_BITS 4
54 #define TWINVQ_PGAIN_MU 200
55 #define TWINVQ_LSP_COEFS_MAX 20
56 #define TWINVQ_LSP_SPLIT_MAX 4
57 #define TWINVQ_CHANNELS_MAX 2
58 #define TWINVQ_SUBBLOCKS_MAX 16
59 #define TWINVQ_BARK_N_COEF_MAX 4
61 #define TWINVQ_MAX_FRAMES_PER_PACKET 2
175 const uint8_t *buf,
int buf_size);
177 int use_hist,
int ch,
float *
out,
float gain,
180 const float *shape,
float *speech);
199 int *got_frame_ptr,
AVPacket *avpkt);
const float * lspcodebook
const TwinVQModeTab * mtab
uint8_t sub
Number subblocks in each frame.
uint8_t bits_main_spec[2][4][2]
bits for the main codebook
uint8_t bark1[TWINVQ_CHANNELS_MAX][TWINVQ_SUBBLOCKS_MAX][TWINVQ_BARK_N_COEF_MAX]
uint8_t lpc_idx2[TWINVQ_CHANNELS_MAX][TWINVQ_LSP_SPLIT_MAX]
float * curr_frame
non-interleaved output
uint8_t bark_use_hist[TWINVQ_CHANNELS_MAX][TWINVQ_SUBBLOCKS_MAX]
TwinVQFrameData bits[TWINVQ_MAX_FRAMES_PER_PACKET]
uint8_t ppc_shape_len
size of PPC shape CB
uint8_t pgain_bit
bits for PPC gain
uint8_t ppc_coeffs[TWINVQ_PPC_SHAPE_LEN_MAX]
const int16_t * cb0
main codebooks for spectrum data
uint8_t bark_n_coef
number of BSE CB coefficients to read
uint8_t sub_gain_bits[TWINVQ_CHANNELS_MAX *TWINVQ_SUBBLOCKS_MAX]
static double val(void *priv, double ch)
uint16_t size
frame size in samples
static float twinvq_mulawinv(float y, float clip, float mu)
void(* dec_bark_env)(struct TwinVQContext *tctx, const uint8_t *in, int use_hist, int ch, float *out, float gain, enum TwinVQFrameType ftype)
void(* decode_ppc)(struct TwinVQContext *tctx, int period_coef, int g_coef, const float *shape, float *speech)
int g_coef[TWINVQ_CHANNELS_MAX]
int ff_twinvq_decode_init(AVCodecContext *avctx)
float lsp_hist[2][20]
LSP coefficients of the last frame.
uint8_t ppc_shape_bit
number of bits of the PPC shape CB coeffs
uint8_t lpc_idx1[TWINVQ_CHANNELS_MAX]
#define TWINVQ_BARK_N_COEF_MAX
uint8_t lpc_hist_idx[TWINVQ_CHANNELS_MAX]
@ TWINVQ_FT_MEDIUM
Medium frame (divided in m<n sub-blocks)
Parameters and tables that are different for each frame type.
Parameters and tables that are different for every combination of bitrate/sample rate.
const uint16_t * bark_tab
static void twinvq_memset_float(float *buf, float val, int size)
float * prev_frame
non-interleaved previous frame
@ TWINVQ_FT_PPC
Periodic Peak Component (part of the long frame)
const int16_t * bark_cb
codebook for the bark scale envelope (BSE)
uint8_t length[4][2]
main codebook stride
uint8_t gain_bits[TWINVQ_CHANNELS_MAX]
static __device__ float fabs(float a)
uint8_t main_coeffs[1024]
@ TWINVQ_FT_LONG
Long frame (single sub-block + PPC)
uint8_t bark_n_bit
number of bits of the BSE coefs
uint8_t ppc_period_bit
number of the bits for the PPC period value
int bits_main_spec_change[4]
#define TWINVQ_PPC_SHAPE_LEN_MAX
#define TWINVQ_CHANNELS_MAX
const int16_t * ppc_shape_cb
PPC shape CB.
uint16_t peak_per2wid
constant for peak period to peak width conversion
int(* read_bitstream)(AVCodecContext *avctx, struct TwinVQContext *tctx, const uint8_t *buf, int buf_size)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
float bark_hist[3][2][40]
BSE coefficients of last frame.
int ff_twinvq_decode_close(AVCodecContext *avctx)
@ TWINVQ_FT_SHORT
Short frame (divided in n sub-blocks)
main external API structure.
uint8_t cb_len_read
number of spectrum coefficients to read
enum TwinVQFrameType ftype
int ff_twinvq_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
This structure stores compressed data.
#define TWINVQ_SUBBLOCKS_MAX
#define TWINVQ_MAX_FRAMES_PER_PACKET
enum TwinVQFrameType ff_twinvq_wtype_to_ftype_table[]
int p_coef[TWINVQ_CHANNELS_MAX]
#define TWINVQ_LSP_SPLIT_MAX
uint8_t lsp_split
number of CB entries for the LSP decoding
static double clip(void *opaque, double val)
Clip value val in the minval - maxval range.
struct TwinVQFrameMode fmode[3]
frame type-dependent parameters
uint8_t bark_env_size
number of distinct bark scale envelope values
uint8_t n_lsp
number of lsp coefficients