34 int i, flags1, flags2, block_align;
42 "too many channels: got %i, need %i or fewer\n",
55 "bitrate too low: got %"PRId64
", need 24000 or higher\n",
113 float n = 2.0 * 32768.0 / window_len;
136 float v, *q, max_scale, *q_end;
144 v =
ff_exp10(*exp_param++ *(1.0 / 16.0));
145 max_scale =
FFMAX(max_scale, v);
164 last_exp = *exp_param++;
165 av_assert0(last_exp - 10 >= 0 && last_exp - 10 < 32);
171 int exp = *exp_param++;
172 int code = exp - last_exp + 60;
216 mdct_norm = 1.0 / (float) n4;
218 mdct_norm *= sqrt(n4);
234 float *coefs, *exponents,
mult;
241 coefs = src_coefs[ch];
247 for (i = 0; i < n; i++) {
248 double t = *coefs++ / (exponents[
i] *
mult);
249 if (t < -32768 || t > 32767)
268 for (v = total_gain - 1; v >= 127; v -= 127)
279 for (i = 0; i < n; i++) {
292 if (parse_exponents) {
312 eptr = ptr + nb_coefs[ch];
315 for (; ptr < eptr; ptr++) {
318 int abs_level =
FFABS(level);
320 if (abs_level <= s->
coef_vlcs[tindex]->max_level)
321 if (run < s->
coef_vlcs[tindex]->levels[abs_level - 1])
322 code = run + s->
int_table[tindex][abs_level - 1];
329 if (1 << coef_nb_bits <= abs_level)
352 uint8_t *buf,
int buf_size,
int total_gain)
396 for (i = 64;
i; i >>= 1) {
403 while(total_gain <= 128 && error > 0)
406 av_log(avctx,
AV_LOG_ERROR,
"Invalid input data or requested bitrate too low, cannot encode\n");
427 #if CONFIG_WMAV1_ENCODER 441 #if CONFIG_WMAV2_ENCODER
const struct AVCodec * codec
static void align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
This structure describes decoded (raw) audio or video data.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
int64_t bit_rate
the average bitrate
int next_block_len_bits
log2 of next block length
static float win(SuperEqualizerContext *s, float n, int N)
static av_cold int init(AVCodecContext *avctx)
int block_len
block length in samples
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 uint8_t * huffbits
VLC bit size.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
float exponents[MAX_CHANNELS][BLOCK_MAX_SIZE]
static void error(const char *err)
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.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
float WMACoef
type for decoded coefficients, int16_t would be enough for wma 1/2
void(* vector_fmul)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats and store the result in a vector of floats...
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
const uint8_t ff_aac_scalefactor_bits[121]
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
const uint32_t * huffcodes
VLC bit values.
static int encode_frame(WMACodecContext *s, float(*src_coefs)[BLOCK_MAX_SIZE], uint8_t *buf, int buf_size, int total_gain)
int nb_block_sizes
number of block sizes
int ff_wma_total_gain_to_bits(int total_gain)
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
static void encode_exp_vlc(WMACodecContext *s, int ch, const int *exp_param)
uint16_t exponent_bands[BLOCK_NB_SIZES][25]
uint8_t channel_coded[MAX_CHANNELS]
true if channel is coded
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int initial_padding
Audio only.
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
FFTSample output[BLOCK_MAX_SIZE *2]
static int put_bits_count(PutBitContext *s)
int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE]
int ff_wma_end(AVCodecContext *avctx)
static int16_t mult(Float11 *f1, Float11 *f2)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define MAX_CODED_SUPERFRAME_SIZE
av_cold int ff_wma_init(AVCodecContext *avctx, int flags2)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int version
1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2)
int frame_len
frame length in samples
static void init_exp(WMACodecContext *s, int ch, const int *exp_param)
int frame_size
Number of samples per channel in an audio frame.
int frame_len_bits
frame_len = 1 << frame_len_bits
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
int sample_rate
samples per second
static int apply_window_and_mdct(AVCodecContext *avctx, const AVFrame *frame)
int use_exp_vlc
exponent coding: 0 = lsp, 1 = vlc + delta
main external API structure.
float frame_out[MAX_CHANNELS][BLOCK_MAX_SIZE *2]
int exponent_high_sizes[BLOCK_NB_SIZES]
static int fixed_exp(int x)
int use_noise_coding
true if perceptual noise is added
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
int use_variable_block_len
uint8_t ms_stereo
true if mid/side stereo mode
static av_cold int encode_init(AVCodecContext *avctx)
FFTContext mdct_ctx[BLOCK_NB_SIZES]
const uint32_t ff_aac_scalefactor_code[121]
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
float coefs[MAX_CHANNELS][BLOCK_MAX_SIZE]
int prev_block_len_bits
log2 of prev block length
static int encode_block(WMACodecContext *s, float(*src_coefs)[BLOCK_MAX_SIZE], int total_gain)
int coefs_end[BLOCK_NB_SIZES]
max number of coded coefficients
internal math functions header
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
int channels
number of audio channels
static int parse_exponents(DBEContext *s, DBEChannel *c)
WMACoef coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE]
static const CoefVLCTable coef_vlcs[6]
static enum AVSampleFormat sample_fmts[]
float max_exponent[MAX_CHANNELS]
int coefs_start
first coded coef
static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
int block_len_bits
log2 of current block length
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
uint8_t ** extended_data
pointers to the data planes/channels.
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE]
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
const CoefVLCTable * coef_vlcs[2]
#define AV_NOPTS_VALUE
Undefined timestamp value.
void(* vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats, and store the result in a vector of floats...
const float * windows[BLOCK_NB_SIZES]