35 float **plevel_table, uint16_t **pint_table,
40 const uint32_t *table_codes = vlc_table->
huffcodes;
41 const uint16_t *levels_table = vlc_table->
levels;
42 uint16_t *run_table, *int_table;
51 if (!run_table || !flevel_table || !int_table) {
62 l = levels_table[k++];
63 for (j = 0; j < l; j++) {
70 *prun_table = run_table;
71 *plevel_table = flevel_table;
72 *pint_table = int_table;
81 float bps1, high_freq;
107 nb = ((flags2 >> 3) & 3) + 1;
124 if (sample_rate1 >= 44100)
125 sample_rate1 = 44100;
126 else if (sample_rate1 >= 22050)
127 sample_rate1 = 22050;
128 else if (sample_rate1 >= 16000)
129 sample_rate1 = 16000;
130 else if (sample_rate1 >= 11025)
131 sample_rate1 = 11025;
132 else if (sample_rate1 >= 8000)
149 if (sample_rate1 == 44100) {
153 high_freq = high_freq * 0.4;
154 }
else if (sample_rate1 == 22050) {
157 else if (bps1 >= 0.72)
158 high_freq = high_freq * 0.7;
160 high_freq = high_freq * 0.6;
161 }
else if (sample_rate1 == 16000) {
163 high_freq = high_freq * 0.5;
165 high_freq = high_freq * 0.3;
166 }
else if (sample_rate1 == 11025)
167 high_freq = high_freq * 0.7;
168 else if (sample_rate1 == 8000) {
170 high_freq = high_freq * 0.5;
174 high_freq = high_freq * 0.65;
177 high_freq = high_freq * 0.75;
179 high_freq = high_freq * 0.6;
181 high_freq = high_freq * 0.5;
184 ff_dlog(s->
avctx,
"version=%d channels=%d sample_rate=%d bitrate=%"PRId64
" block_align=%d\n",
187 ff_dlog(s->
avctx,
"bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
189 ff_dlog(s->
avctx,
"use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
194 int a,
b,
pos, lpos, k, block_len,
i, j, n;
206 for (i = 0; i < 25; i++) {
209 pos = ((block_len * 2 *
a) + (b >> 1)) / b;
213 if (pos >= block_len) {
234 for (i = 0; i < n; i++)
240 for (i = 0; i < 25; i++) {
243 pos = ((block_len * 2 *
a) + (b << 1)) / (4 * b);
249 if (pos >= block_len)
265 for (i = 0; i < n; i++) {
270 if (start < s->high_band_start[k])
318 norm = (1.0 / (
float) (1LL << 31)) * sqrt(3) * s->
noise_mult;
333 if (avctx->sample_rate >= 32000) {
336 else if (bps1 < 1.16)
339 s->coef_vlcs[0] = &
coef_vlcs[coef_vlc_table * 2];
340 s->coef_vlcs[1] = &
coef_vlcs[coef_vlc_table * 2 + 1];
342 &
s->int_table[0],
s->coef_vlcs[0]);
347 &
s->int_table[1],
s->coef_vlcs[1]);
354 else if (total_gain < 32)
356 else if (total_gain < 40)
358 else if (total_gain < 45)
376 for (i = 0; i < 2; i++) {
425 VLC *vlc,
const float *level_table,
426 const uint16_t *run_table,
int version,
428 int block_len,
int frame_len_bits,
432 const uint32_t *ilvl = (
const uint32_t *) level_table;
433 uint32_t *iptr = (uint32_t *) ptr;
434 const unsigned int coef_mask = block_len - 1;
435 for (; offset < num_coefs; offset++) {
439 offset += run_table[
code];
441 iptr[offset & coef_mask] = ilvl[
code] ^ (sign & 0x80000000);
442 }
else if (code == 1) {
451 offset +=
get_bits(gb, frame_len_bits);
459 "broken escape sequence\n");
462 offset +=
get_bits(gb, frame_len_bits) + 4;
468 ptr[offset & coef_mask] = (level ^ sign) - sign;
472 if (offset > num_coefs) {
474 "overflow (%d > %d) in spectral RLE, ignoring\n",
const struct AVCodec * codec
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
int64_t bit_rate
the average bitrate
int next_block_len_bits
log2 of next block length
int ff_wma_run_level_decode(AVCodecContext *avctx, GetBitContext *gb, VLC *vlc, const float *level_table, const uint16_t *run_table, int version, WMACoef *ptr, int offset, int num_coefs, int block_len, int frame_len_bits, int coef_nb_bits)
Decode run level compressed coefficients.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
const uint16_t ff_wma_critical_freqs[25]
const uint8_t * huffbits
VLC bit size.
int n
total number of codes
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
Macro definitions for various function/variable attributes.
SINETABLE_CONST float *const ff_sine_windows[]
int high_band_start[BLOCK_NB_SIZES]
index of first coef in high band
int exponent_sizes[BLOCK_NB_SIZES]
float WMACoef
type for decoded coefficients, int16_t would be enough for wma 1/2
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
const uint32_t * huffcodes
VLC bit values.
static const uint16_t table[]
int nb_block_sizes
number of block sizes
int ff_wma_total_gain_to_bits(int total_gain)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
uint16_t exponent_bands[BLOCK_NB_SIZES][25]
int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE]
int ff_wma_end(AVCodecContext *avctx)
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
static const uint8_t exponent_band_44100[3][25]
av_cold int ff_wma_init(AVCodecContext *avctx, int flags2)
int version
1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
int frame_len
frame length in samples
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int frame_len_bits
frame_len = 1 << frame_len_bits
Libavcodec external API header.
int sample_rate
samples per second
int use_exp_vlc
exponent coding: 0 = lsp, 1 = vlc + delta
main external API structure.
int exponent_high_sizes[BLOCK_NB_SIZES]
static unsigned int get_bits1(GetBitContext *s)
int use_noise_coding
true if perceptual noise is added
int use_variable_block_len
FFTContext mdct_ctx[BLOCK_NB_SIZES]
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
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 it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
av_cold int ff_wma_get_frame_len_bits(int sample_rate, int version, unsigned int decode_flags)
Get the samples per frame for this stream.
int prev_block_len_bits
log2 of prev block length
int coefs_end[BLOCK_NB_SIZES]
max number of coded coefficients
common internal api header.
int channels
number of audio channels
VLC_TYPE(* table)[2]
code, bits
static av_cold int init_coef_vlc(VLC *vlc, uint16_t **prun_table, float **plevel_table, uint16_t **pint_table, const CoefVLCTable *vlc_table)
unsigned int ff_wma_get_large_val(GetBitContext *gb)
Decode an uncompressed coefficient.
static const CoefVLCTable coef_vlcs[6]
int coefs_start
first coded coef
int block_len_bits
log2 of current block length
#define av_malloc_array(a, b)
static const uint8_t exponent_band_22050[3][25]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
static const uint8_t exponent_band_32000[3][25]
void ff_free_vlc(VLC *vlc)
void ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
float noise_table[NOISE_TAB_SIZE]
const uint16_t * levels
table to build run/level tables
const float * windows[BLOCK_NB_SIZES]