FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
twinvq.h
Go to the documentation of this file.
1 /*
2  * TwinVQ decoder
3  * Copyright (c) 2009 Vitor Sessak
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVCODEC_TWINVQ_H
23 #define AVCODEC_TWINVQ_H
24 
25 #include <math.h>
26 #include <stdint.h>
27 
28 #include "libavutil/common.h"
29 #include "libavutil/float_dsp.h"
30 #include "avcodec.h"
31 #include "fft.h"
32 #include "internal.h"
33 
37 };
38 
40  TWINVQ_FT_SHORT = 0, ///< Short frame (divided in n sub-blocks)
41  TWINVQ_FT_MEDIUM, ///< Medium frame (divided in m<n sub-blocks)
42  TWINVQ_FT_LONG, ///< Long frame (single sub-block + PPC)
43  TWINVQ_FT_PPC, ///< Periodic Peak Component (part of the long frame)
44 };
45 
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
60 
61 #define TWINVQ_MAX_FRAMES_PER_PACKET 2
62 
63 /**
64  * Parameters and tables that are different for each frame type
65  */
67  uint8_t sub; ///< Number subblocks in each frame
68  const uint16_t *bark_tab;
69 
70  /** number of distinct bark scale envelope values */
72 
73  const int16_t *bark_cb; ///< codebook for the bark scale envelope (BSE)
74  uint8_t bark_n_coef;///< number of BSE CB coefficients to read
75  uint8_t bark_n_bit; ///< number of bits of the BSE coefs
76 
77  //@{
78  /** main codebooks for spectrum data */
79  const int16_t *cb0;
80  const int16_t *cb1;
81  //@}
82 
83  uint8_t cb_len_read; ///< number of spectrum coefficients to read
84 };
85 
86 typedef struct TwinVQFrameData {
89 
92 
95 
98 
102 
106 
107 /**
108  * Parameters and tables that are different for every combination of
109  * bitrate/sample rate
110  */
111 typedef struct TwinVQModeTab {
112  struct TwinVQFrameMode fmode[3]; ///< frame type-dependent parameters
113 
114  uint16_t size; ///< frame size in samples
115  uint8_t n_lsp; ///< number of lsp coefficients
116  const float *lspcodebook;
117 
118  /* number of bits of the different LSP CB coefficients */
122 
123  uint8_t lsp_split; ///< number of CB entries for the LSP decoding
124  const int16_t *ppc_shape_cb; ///< PPC shape CB
125 
126  /** number of the bits for the PPC period value */
128 
129  uint8_t ppc_shape_bit; ///< number of bits of the PPC shape CB coeffs
130  uint8_t ppc_shape_len; ///< size of PPC shape CB
131  uint8_t pgain_bit; ///< bits for PPC gain
132 
133  /** constant for peak period to peak width conversion */
134  uint16_t peak_per2wid;
135 } TwinVQModeTab;
136 
137 typedef struct TwinVQContext {
141 
143 
144  int is_6kbps;
145 
146  // history
147  float lsp_hist[2][20]; ///< LSP coefficients of the last frame
148  float bark_hist[3][2][40]; ///< BSE coefficients of last frame
149 
150  // bitstream parameters
151  int16_t permut[4][4096];
152  uint8_t length[4][2]; ///< main codebook stride
154  uint8_t bits_main_spec[2][4][2]; ///< bits for the main codebook
156  int n_div[4];
157 
158  float *spectrum;
159  float *curr_frame; ///< non-interleaved output
160  float *prev_frame; ///< non-interleaved previous frame
163 
164  float *cos_tabs[3];
165 
166  // scratch buffers
167  float *tmp_buf;
168 
171 
173 
175  const uint8_t *buf, int buf_size);
176  void (*dec_bark_env)(struct TwinVQContext *tctx, const uint8_t *in,
177  int use_hist, int ch, float *out, float gain,
178  enum TwinVQFrameType ftype);
179  void (*decode_ppc)(struct TwinVQContext *tctx, int period_coef, int g_coef,
180  const float *shape, float *speech);
181 } TwinVQContext;
182 
184 
185 /** @note not speed critical, hence not optimized */
186 static inline void twinvq_memset_float(float *buf, float val, int size)
187 {
188  while (size--)
189  *buf++ = val;
190 }
191 
192 static inline float twinvq_mulawinv(float y, float clip, float mu)
193 {
194  y = av_clipf(y / clip, -1, 1);
195  return clip * FFSIGN(y) * (exp(log(1 + mu) * fabs(y)) - 1) / mu;
196 }
197 
199  int *got_frame_ptr, AVPacket *avpkt);
202 
203 #endif /* AVCODEC_TWINVQ_H */
const char const char void * val
Definition: avisynth_c.h:771
uint8_t bark_n_bit
number of bits of the BSE coefs
Definition: twinvq.h:75
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
uint8_t length_change[4]
Definition: twinvq.h:153
int discarded_packets
Definition: twinvq.h:162
int window_type
Definition: twinvq.h:87
uint8_t ppc_coeffs[TWINVQ_PPC_SHAPE_LEN_MAX]
Definition: twinvq.h:91
int bits_main_spec_change[4]
Definition: twinvq.h:155
const TwinVQModeTab * mtab
Definition: twinvq.h:142
TwinVQFrameData bits[TWINVQ_MAX_FRAMES_PER_PACKET]
Definition: twinvq.h:170
int p_coef[TWINVQ_CHANNELS_MAX]
Definition: twinvq.h:103
uint8_t cb_len_read
number of spectrum coefficients to read
Definition: twinvq.h:83
Medium frame (divided in m<n sub-blocks)
Definition: twinvq.h:41
uint8_t bark_n_coef
number of BSE CB coefficients to read
Definition: twinvq.h:74
uint16_t size
frame size in samples
Definition: twinvq.h:114
enum TwinVQFrameType ff_twinvq_wtype_to_ftype_table[]
Definition: twinvq.c:470
int ff_twinvq_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: twinvq.c:476
uint8_t lsp_bit0
Definition: twinvq.h:119
uint8_t bark_use_hist[TWINVQ_CHANNELS_MAX][TWINVQ_SUBBLOCKS_MAX]
Definition: twinvq.h:97
TwinVQCodec
Definition: twinvq.h:34
uint8_t lpc_idx1[TWINVQ_CHANNELS_MAX]
Definition: twinvq.h:99
uint8_t sub_gain_bits[TWINVQ_CHANNELS_MAX *TWINVQ_SUBBLOCKS_MAX]
Definition: twinvq.h:94
Short frame (divided in n sub-blocks)
Definition: twinvq.h:40
uint8_t lpc_idx2[TWINVQ_CHANNELS_MAX][TWINVQ_LSP_SPLIT_MAX]
Definition: twinvq.h:100
uint8_t
const int16_t * ppc_shape_cb
PPC shape CB.
Definition: twinvq.h:124
int g_coef[TWINVQ_CHANNELS_MAX]
Definition: twinvq.h:104
uint8_t ppc_period_bit
number of the bits for the PPC period value
Definition: twinvq.h:127
uint8_t gain_bits[TWINVQ_CHANNELS_MAX]
Definition: twinvq.h:93
#define TWINVQ_SUBBLOCKS_MAX
Definition: twinvq.h:58
TwinVQFrameType
Definition: twinvq.h:39
int last_block_pos[2]
Definition: twinvq.h:161
Parameters and tables that are different for every combination of bitrate/sample rate.
Definition: twinvq.h:111
uint8_t lpc_hist_idx[TWINVQ_CHANNELS_MAX]
Definition: twinvq.h:101
ptrdiff_t size
Definition: opengl_enc.c:101
int cur_frame
Definition: twinvq.h:169
Long frame (single sub-block + PPC)
Definition: twinvq.h:42
uint8_t bark_env_size
number of distinct bark scale envelope values
Definition: twinvq.h:71
static float twinvq_mulawinv(float y, float clip, float mu)
Definition: twinvq.h:192
int frame_size
Definition: twinvq.h:169
float * tmp_buf
Definition: twinvq.h:167
uint8_t main_coeffs[1024]
Definition: twinvq.h:90
#define TWINVQ_MAX_FRAMES_PER_PACKET
Definition: twinvq.h:61
float * cos_tabs[3]
Definition: twinvq.h:164
GLsizei GLsizei * length
Definition: opengl_enc.c:115
float * spectrum
Definition: twinvq.h:158
int(* read_bitstream)(AVCodecContext *avctx, struct TwinVQContext *tctx, const uint8_t *buf, int buf_size)
Definition: twinvq.h:174
int8_t exp
Definition: eval.c:65
void(* decode_ppc)(struct TwinVQContext *tctx, int period_coef, int g_coef, const float *shape, float *speech)
Definition: twinvq.h:179
void(* dec_bark_env)(struct TwinVQContext *tctx, const uint8_t *in, int use_hist, int ch, float *out, float gain, enum TwinVQFrameType ftype)
Definition: twinvq.h:176
const int16_t * cb0
main codebooks for spectrum data
Definition: twinvq.h:79
int ff_twinvq_decode_init(AVCodecContext *avctx)
Definition: twinvq.c:770
Definition: fft.h:88
uint8_t sub
Number subblocks in each frame.
Definition: twinvq.h:67
uint16_t peak_per2wid
constant for peak period to peak width conversion
Definition: twinvq.h:134
#define FFSIGN(a)
Definition: common.h:73
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
uint8_t bits_main_spec[2][4][2]
bits for the main codebook
Definition: twinvq.h:154
static void twinvq_memset_float(float *buf, float val, int size)
Definition: twinvq.h:186
uint8_t n_lsp
number of lsp coefficients
Definition: twinvq.h:115
int is_6kbps
Definition: twinvq.h:144
int n_div[4]
Definition: twinvq.h:156
uint8_t ppc_shape_bit
number of bits of the PPC shape CB coeffs
Definition: twinvq.h:129
int ff_twinvq_decode_close(AVCodecContext *avctx)
Definition: twinvq.c:751
Libavcodec external API header.
float bark_hist[3][2][40]
BSE coefficients of last frame.
Definition: twinvq.h:148
Periodic Peak Component (part of the long frame)
Definition: twinvq.h:43
main external API structure.
Definition: avcodec.h:1732
const uint16_t * bark_tab
Definition: twinvq.h:68
AVFloatDSPContext * fdsp
Definition: twinvq.h:139
enum TwinVQFrameType ftype
Definition: twinvq.h:88
int frames_per_packet
Definition: twinvq.h:169
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-> in
const int16_t * bark_cb
codebook for the bark scale envelope (BSE)
Definition: twinvq.h:73
void * buf
Definition: avisynth_c.h:690
const int16_t * cb1
Definition: twinvq.h:80
struct TwinVQFrameMode fmode[3]
frame type-dependent parameters
Definition: twinvq.h:112
int16_t permut[4][4096]
Definition: twinvq.h:151
#define TWINVQ_PPC_SHAPE_LEN_MAX
Definition: twinvq.h:47
#define TWINVQ_LSP_SPLIT_MAX
Definition: twinvq.h:56
float * prev_frame
non-interleaved previous frame
Definition: twinvq.h:160
uint8_t pgain_bit
bits for PPC gain
Definition: twinvq.h:131
const float * lspcodebook
Definition: twinvq.h:116
uint8_t lsp_bit1
Definition: twinvq.h:120
#define TWINVQ_BARK_N_COEF_MAX
Definition: twinvq.h:59
enum TwinVQCodec codec
Definition: twinvq.h:172
int
float lsp_hist[2][20]
LSP coefficients of the last frame.
Definition: twinvq.h:147
common internal api header.
common internal and external API header
static double clip(void *opaque, double val)
Clip value val in the minval - maxval range.
Definition: vf_lut.c:157
uint8_t ppc_shape_len
size of PPC shape CB
Definition: twinvq.h:130
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_YASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
Definition: audioconvert.c:56
Parameters and tables that are different for each frame type.
Definition: twinvq.h:66
FILE * out
Definition: movenc.c:54
FFTContext mdct_ctx[3]
Definition: twinvq.h:140
float * curr_frame
non-interleaved output
Definition: twinvq.h:159
#define TWINVQ_CHANNELS_MAX
Definition: twinvq.h:57
This structure stores compressed data.
Definition: avcodec.h:1634
AVCodecContext * avctx
Definition: twinvq.h:138
uint8_t lsp_bit2
Definition: twinvq.h:121
uint8_t lsp_split
number of CB entries for the LSP decoding
Definition: twinvq.h:123
uint8_t bark1[TWINVQ_CHANNELS_MAX][TWINVQ_SUBBLOCKS_MAX][TWINVQ_BARK_N_COEF_MAX]
Definition: twinvq.h:96