Go to the documentation of this file.
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, *level_table, *int_table;
52 if (!run_table || !level_table || !flevel_table || !int_table) {
64 l = levels_table[k++];
65 for (j = 0; j < l; j++) {
73 *prun_table = run_table;
74 *plevel_table = flevel_table;
75 *pint_table = int_table;
85 float bps1, high_freq;
104 s->next_block_len_bits =
s->frame_len_bits;
105 s->prev_block_len_bits =
s->frame_len_bits;
106 s->block_len_bits =
s->frame_len_bits;
108 s->frame_len = 1 <<
s->frame_len_bits;
109 if (
s->use_variable_block_len) {
111 nb = ((flags2 >> 3) & 3) + 1;
117 s->nb_block_sizes = nb + 1;
119 s->nb_block_sizes = 1;
122 s->use_noise_coding = 1;
127 if (
s->version == 2) {
128 if (sample_rate1 >= 44100)
129 sample_rate1 = 44100;
130 else if (sample_rate1 >= 22050)
131 sample_rate1 = 22050;
132 else if (sample_rate1 >= 16000)
133 sample_rate1 = 16000;
134 else if (sample_rate1 >= 11025)
135 sample_rate1 = 11025;
136 else if (sample_rate1 >= 8000)
142 s->byte_offset_bits =
av_log2((
int) (
bps *
s->frame_len / 8.0 + 0.5)) + 2;
153 if (sample_rate1 == 44100) {
155 s->use_noise_coding = 0;
157 high_freq = high_freq * 0.4;
158 }
else if (sample_rate1 == 22050) {
160 s->use_noise_coding = 0;
161 else if (bps1 >= 0.72)
162 high_freq = high_freq * 0.7;
164 high_freq = high_freq * 0.6;
165 }
else if (sample_rate1 == 16000) {
167 high_freq = high_freq * 0.5;
169 high_freq = high_freq * 0.3;
170 }
else if (sample_rate1 == 11025)
171 high_freq = high_freq * 0.7;
172 else if (sample_rate1 == 8000) {
174 high_freq = high_freq * 0.5;
176 s->use_noise_coding = 0;
178 high_freq = high_freq * 0.65;
181 high_freq = high_freq * 0.75;
183 high_freq = high_freq * 0.6;
185 high_freq = high_freq * 0.5;
187 ff_dlog(
s->avctx,
"flags2=0x%x\n", flags2);
188 ff_dlog(
s->avctx,
"version=%d channels=%d sample_rate=%d bitrate=%"PRId64
" block_align=%d\n",
191 ff_dlog(
s->avctx,
"bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
192 bps, bps1, high_freq,
s->byte_offset_bits);
193 ff_dlog(
s->avctx,
"use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
194 s->use_noise_coding,
s->use_exp_vlc,
s->nb_block_sizes);
198 int a,
b, pos, lpos, k, block_len,
i, j,
n;
205 for (k = 0; k <
s->nb_block_sizes; k++) {
206 block_len =
s->frame_len >> k;
208 if (
s->version == 1) {
210 for (
i = 0;
i < 25;
i++) {
213 pos = ((block_len * 2 *
a) + (
b >> 1)) /
b;
216 s->exponent_bands[0][
i] = pos - lpos;
217 if (pos >= block_len) {
223 s->exponent_sizes[0] =
i;
238 for (
i = 0;
i <
n;
i++)
240 s->exponent_sizes[k] =
n;
244 for (
i = 0;
i < 25;
i++) {
247 pos = ((block_len * 2 *
a) + (
b << 1)) / (4 *
b);
252 s->exponent_bands[k][j++] = pos - lpos;
253 if (pos >= block_len)
257 s->exponent_sizes[k] = j;
262 s->coefs_end[k] = (
s->frame_len - ((
s->frame_len * 9) / 100)) >> k;
264 s->high_band_start[k] = (
int) ((block_len * 2 * high_freq) /
266 n =
s->exponent_sizes[k];
269 for (
i = 0;
i <
n;
i++) {
272 pos +=
s->exponent_bands[k][
i];
274 if (start < s->high_band_start[k])
275 start =
s->high_band_start[k];
276 if (
end >
s->coefs_end[k])
277 end =
s->coefs_end[k];
279 s->exponent_high_bands[k][j++] =
end -
start;
281 s->exponent_high_sizes[k] = j;
288 for (
i = 0;
i <
s->nb_block_sizes;
i++) {
291 s->exponent_sizes[
i]);
292 for (j = 0; j <
s->exponent_sizes[
i]; j++)
293 ff_tlog(
s->avctx,
" %d",
s->exponent_bands[
i][j]);
300 for (
i = 0;
i <
s->nb_block_sizes;
i++) {
302 s->windows[
i] = ff_sine_windows[
s->frame_len_bits -
i];
305 s->reset_block_lengths = 1;
307 if (
s->use_noise_coding) {
310 s->noise_mult = 0.02;
312 s->noise_mult = 0.04;
316 s->noise_table[
i] = 1.0 *
s->noise_mult;
322 norm = (1.0 / (
float) (1LL << 31)) * sqrt(3) *
s->noise_mult;
325 s->noise_table[
i] = (float) ((
int)
seed) * norm;
337 if (avctx->sample_rate >= 32000) {
340 else if (bps1 < 1.16)
343 s->coef_vlcs[0] = &
coef_vlcs[coef_vlc_table * 2];
344 s->coef_vlcs[1] = &
coef_vlcs[coef_vlc_table * 2 + 1];
346 &
s->int_table[0],
s->coef_vlcs[0]);
351 &
s->int_table[1],
s->coef_vlcs[1]);
358 else if (total_gain < 32)
360 else if (total_gain < 40)
362 else if (total_gain < 45)
373 for (
i = 0;
i <
s->nb_block_sizes;
i++)
378 if (
s->use_noise_coding)
380 for (
i = 0;
i < 2;
i++) {
429 VLC *vlc,
const float *level_table,
430 const uint16_t *run_table,
int version,
432 int block_len,
int frame_len_bits,
436 const uint32_t *ilvl = (
const uint32_t *) level_table;
437 uint32_t *iptr = (uint32_t *) ptr;
438 const unsigned int coef_mask = block_len - 1;
445 iptr[
offset & coef_mask] = ilvl[
code] ^ (sign & 0x80000000);
446 }
else if (
code == 1) {
463 "broken escape sequence\n");
478 "overflow (%d > %d) in spectral RLE, ignoring\n",
void AAC_RENAME() ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
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 CoefVLCTable coef_vlcs[6]
int sample_rate
samples per second
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static const uint8_t exponent_band_32000[3][25]
static av_cold int end(AVCodecContext *avctx)
#define init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
static const uint16_t table[]
int n
total number of codes
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
const uint8_t * huffbits
VLC bit size.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 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)
const struct AVCodec * codec
float WMACoef
type for decoded coefficients, int16_t would be enough for wma 1/2
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void ff_free_vlc(VLC *vlc)
const uint16_t ff_wma_critical_freqs[25]
int ff_wma_total_gain_to_bits(int total_gain)
const uint32_t * huffcodes
VLC bit values.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int64_t bit_rate
the average bitrate
static unsigned int get_bits1(GetBitContext *s)
int ff_wma_end(AVCodecContext *avctx)
av_cold int ff_wma_init(AVCodecContext *avctx, int flags2)
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
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
int channels
number of audio channels
#define i(width, name, range_min, range_max)
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
static const uint8_t exponent_band_44100[3][25]
#define av_malloc_array(a, b)
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
main external API structure.
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.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
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.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
static const uint8_t exponent_band_22050[3][25]
const uint16_t * levels
table to build run/level tables
unsigned int ff_wma_get_large_val(GetBitContext *gb)
Decode an uncompressed coefficient.
VLC_TYPE(* table)[2]
code, bits