92 #include "libavutil/intfloat.h"
93 #include "libavutil/intreadwrite.h"
104 #define WMAPRO_MAX_CHANNELS 8
105 #define MAX_SUBFRAMES 32
107 #define MAX_FRAMESIZE 32768
109 #define WMAPRO_BLOCK_MIN_BITS 6
110 #define WMAPRO_BLOCK_MAX_BITS 13
111 #define WMAPRO_BLOCK_MIN_SIZE (1 << WMAPRO_BLOCK_MIN_BITS)
112 #define WMAPRO_BLOCK_MAX_SIZE (1 << WMAPRO_BLOCK_MAX_BITS)
113 #define WMAPRO_BLOCK_SIZES (WMAPRO_BLOCK_MAX_BITS - WMAPRO_BLOCK_MIN_BITS + 1)
117 #define SCALEVLCBITS 8
118 #define VEC4MAXDEPTH ((HUFF_VEC4_MAXBITS+VLCBITS-1)/VLCBITS)
119 #define VEC2MAXDEPTH ((HUFF_VEC2_MAXBITS+VLCBITS-1)/VLCBITS)
120 #define VEC1MAXDEPTH ((HUFF_VEC1_MAXBITS+VLCBITS-1)/VLCBITS)
121 #define SCALEMAXDEPTH ((HUFF_SCALE_MAXBITS+SCALEVLCBITS-1)/SCALEVLCBITS)
122 #define SCALERLMAXDEPTH ((HUFF_SCALE_RL_MAXBITS+VLCBITS-1)/VLCBITS)
241 #define PRINT(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %d\n", a, b);
242 #define PRINT_HEX(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %"PRIx32"\n", a, b);
278 unsigned int channel_mask;
280 int log2_max_num_subframes;
281 int num_possible_block_sizes;
297 channel_mask =
AV_RL32(edata_ptr+2);
326 log2_max_num_subframes = ((s->
decode_flags & 0x38) >> 3);
332 num_possible_block_sizes = log2_max_num_subframes + 1;
364 for (i = 0; i < avctx->
channels; i++)
370 if (channel_mask & 8) {
372 for (mask = 1; mask < 16; mask <<= 1) {
373 if (channel_mask & mask)
408 for (i = 0; i < num_possible_block_sizes; i++) {
432 for (i = 0; i < num_possible_block_sizes; i++) {
434 for (b = 0; b < s->
num_sfb[i]; b++) {
438 for (x = 0; x < num_possible_block_sizes; x++) {
462 for (i = 0; i < num_possible_block_sizes; i++) {
470 for (i = 0; i < 33; i++)
471 sin64[i] = sin(i*M_PI / 64.0);
489 int frame_len_shift = 0;
506 if (subframe_len < s->min_samples_per_subframe ||
540 int fixed_channel_layout = 0;
541 int min_channel_len = 0;
555 fixed_channel_layout = 1;
563 if (num_samples[c] == min_channel_len) {
564 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
566 contains_subframe[c] = 1;
570 contains_subframe[c] = 0;
578 min_channel_len += subframe_len;
582 if (contains_subframe[c]) {
585 "broken frame: num subframes > 31\n");
589 num_samples[c] += subframe_len;
593 "channel len > samples_per_frame\n");
596 }
else if (num_samples[c] <= min_channel_len) {
597 if (num_samples[c] < min_channel_len) {
598 channels_for_cur_subframe = 0;
599 min_channel_len = num_samples[c];
601 ++channels_for_cur_subframe;
604 }
while (min_channel_len < s->samples_per_frame);
644 for (x = 0; x < i; x++) {
646 for (y = 0; y < i + 1; y++) {
649 int n = rotation_offset[offset + x];
655 cosv =
sin64[32 - n];
657 sinv =
sin64[64 - n];
658 cosv = -
sin64[n - 32];
662 (v1 * sinv) - (v2 * cosv);
664 (v1 * cosv) + (v2 * sinv);
691 "Channel transform bit");
703 if (remaining_channels > 2) {
728 "Unknown channel transform type");
755 "Coupled channels > 6");
795 static const uint32_t fval_tab[16] = {
796 0x00000000, 0x3f800000, 0x40000000, 0x40400000,
797 0x40800000, 0x40a00000, 0x40c00000, 0x40e00000,
798 0x41000000, 0x41100000, 0x41200000, 0x41300000,
799 0x41400000, 0x41500000, 0x41600000, 0x41700000,
810 av_dlog(s->
avctx,
"decode coefficients for channel %i\n", c);
813 vlc = &coef_vlc[vlctable];
834 for (i = 0; i < 4; i += 2) {
848 vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF];
853 vals[1] = fval_tab[(symbol_to_vec4[idx] >> 8) & 0xF];
854 vals[2] = fval_tab[(symbol_to_vec4[idx] >> 4) & 0xF];
855 vals[3] = fval_tab[ symbol_to_vec4[idx] & 0xF];
859 for (i = 0; i < 4; i++) {
865 ci->
coeffs[cur_coeff] = 0;
875 if (cur_coeff < s->subframe_len) {
876 memset(&ci->
coeffs[cur_coeff], 0,
879 level, run, 1, ci->
coeffs,
946 sign = (code & 1) - 1;
947 skip = (code & 0x3f) >> 1;
948 }
else if (idx == 1) {
959 "invalid scale factor coding\n");
995 float** ch_end = ch_data + num_channels;
1001 sfb < s->cur_sfb_offsets + s->
num_bands; sfb++) {
1007 const float* data_end = data + num_channels;
1008 float* data_ptr =
data;
1011 for (ch = ch_data; ch < ch_end; ch++)
1012 *data_ptr++ = (*ch)[y];
1014 for (ch = ch_data; ch < ch_end; ch++) {
1017 while (data_ptr < data_end)
1018 sum += *data_ptr++ * *mat++;
1026 ch_data[0] + sfb[0],
1029 ch_data[1] + sfb[0],
1077 int transmit_coeffs = 0;
1078 int cur_subwoofer_cutoff;
1096 "processing subframe with offset %i len %i\n", offset, subframe_len);
1146 if (!(num_fill_bits =
get_bits(&s->
gb, 2))) {
1151 if (num_fill_bits >= 0) {
1175 transmit_coeffs = 1;
1178 if (transmit_coeffs) {
1187 int num_vec_coeffs =
get_bits(&s->
gb, num_bits) << 2;
1203 if (step == -32 || step == 31) {
1204 const int sign = (step == 31) - 1;
1210 quant_step += ((quant +
step) ^ sign) - sign;
1212 if (quant_step < 0) {
1239 av_dlog(s->
avctx,
"BITSTREAM: subframe header length was %i\n",
1253 av_dlog(s->
avctx,
"BITSTREAM: subframe length was %i\n",
1256 if (transmit_coeffs) {
1266 memset(&s->
tmp[cur_subwoofer_cutoff], 0,
sizeof(*s->
tmp) *
1267 (subframe_len - cur_subwoofer_cutoff));
1275 const float quant = pow(10.0, exp / 20.0);
1279 quant, end - start);
1313 int more_frames = 0;
1321 av_dlog(s->
avctx,
"decoding frame with length %x\n", len);
1362 av_dlog(s->
avctx,
"BITSTREAM: frame header length was %i\n",
1367 for (i = 0; i < avctx->
channels; i++) {
1390 for (i = 0; i < avctx->
channels; i++)
1394 for (i = 0; i < avctx->
channels; i++) {
1413 "frame[%"PRIu32
"] would have to skip %i bits\n",
1477 "Cannot append %d bits, only %d bits available.\n",
1489 align =
FFMIN(align, len);
1513 int *got_frame_ptr,
AVPacket* avpkt)
1518 int buf_size = avpkt->
size;
1519 int num_bits_prev_frame;
1520 int packet_sequence_number;
1528 if (buf_size < avctx->block_align) {
1540 packet_sequence_number =
get_bits(gb, 4);
1546 num_bits_prev_frame);
1553 "Packet loss detected! seq %"PRIx8
" vs %x\n",
1558 if (num_bits_prev_frame > 0) {
1560 if (num_bits_prev_frame >= remaining_packet_bits) {
1561 num_bits_prev_frame = remaining_packet_bits;
1567 save_bits(s, gb, num_bits_prev_frame, 1);
1568 av_dlog(avctx,
"accumulated %x bits of frame data\n",
1575 av_dlog(avctx,
"ignoring %x previously saved bits\n",
1635 for (i = 0; i < avctx->
channels; i++)
float * channel_data[WMAPRO_MAX_CHANNELS]
transformation coefficients
uint8_t max_num_subframes
static const uint16_t critical_freq[]
frequencies to divide the frequency spectrum into scale factor bands
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int decode_tilehdr(WMAProDecodeCtx *s)
Decode how the data in the frame is split into subframes.
This structure describes decoded (raw) audio or video data.
int subframe_offset
subframe offset in the bit reservoir
static const uint16_t vec1_huffcodes[HUFF_VEC1_SIZE]
static const float coef0_level[HUFF_COEF0_SIZE]
uint8_t table_idx
index for the num_sfb, sfb_offsets, sf_offsets and subwoofer_cutoffs tables
static const uint32_t scale_rl_huffcodes[HUFF_SCALE_RL_SIZE]
uint16_t num_vec_coeffs
number of vector coded coefficients
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define WMAPRO_BLOCK_MIN_SIZE
minimum block size
uint16_t min_samples_per_subframe
static void skip_bits_long(GetBitContext *s, int n)
AVCodecContext * avctx
codec context for av_log
uint32_t decode_flags
used compression features
uint8_t ** extended_data
pointers to the data planes/channels.
static const uint16_t vec4_huffcodes[HUFF_VEC4_SIZE]
void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
Copy the content of src to the bitstream.
int8_t scale_factor_step
scaling step for the current subframe
#define DECLARE_ALIGNED(n, t, v)
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.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
static const uint8_t scale_huffbits[HUFF_SCALE_SIZE]
uint8_t table_idx
index in sf_offsets for the scale factor reference block
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
int16_t * cur_sfb_offsets
sfb offsets for the current block
WMAProChannelGrp chgroup[WMAPRO_MAX_CHANNELS]
channel group information
PutBitContext pb
context for filling the frame_data buffer
#define WMAPRO_MAX_CHANNELS
current decoder limitations
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
static int get_sbits(GetBitContext *s, int n)
static VLC vec1_vlc
1 coefficient per symbol
static av_cold void dump_context(WMAProDecodeCtx *s)
helper function to print the most important members of the context
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static const uint8_t scale_rl_run[HUFF_SCALE_RL_SIZE]
static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Decode a single WMA packet.
int frame_offset
frame offset in the bit reservoir
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static const float coef1_level[HUFF_COEF1_SIZE]
uint16_t subframe_offset[MAX_SUBFRAMES]
subframe positions in the current frame
enum AVSampleFormat sample_fmt
audio sample format
static void inverse_channel_transform(WMAProDecodeCtx *s)
Reconstruct the individual channel data.
int16_t sfb_offsets[WMAPRO_BLOCK_SIZES][MAX_BANDS]
scale factor band offsets (multiples of 4)
#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)
int8_t num_bands
number of scale factor bands
uint8_t frame_data[MAX_FRAMESIZE+FF_INPUT_BUFFER_PADDING_SIZE]
compressed frame data
const char * name
Name of the codec implementation.
uint8_t packet_sequence_number
current packet number
uint8_t drc_gain
gain for the DRC tool
uint8_t dynamic_range_compression
frame contains DRC data
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static uint8_t * append(uint8_t *buf, const uint8_t *src, int size)
#define MAX_FRAMESIZE
maximum compressed frame size
int16_t prev_block_len
length of the previous block
WMAProChannelCtx channel[WMAPRO_MAX_CHANNELS]
per channel data
GetBitContext gb
bitstream reader context
uint8_t grouped
channel is part of a group
static int get_bits_count(const GetBitContext *s)
#define WMAPRO_BLOCK_MAX_BITS
log2 of max block size
int * scale_factors
pointer to the scale factor values used for decoding
bitstream reader API header.
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
int next_packet_start
start offset of the next wma packet in the demuxer packet
int num_saved_bits
saved number of bits
static const uint16_t scale_huffcodes[HUFF_SCALE_SIZE]
int buf_bit_size
buffer size in bits
static const uint32_t coef1_huffcodes[555]
static VLC vec4_vlc
4 coefficients per symbol
static const uint8_t frame_size[4]
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
Overlap/add with window function.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int decode_subframe(WMAProDecodeCtx *s)
Decode a single subframe (block).
uint8_t packet_loss
set in case of bitstream error
static int put_bits_left(PutBitContext *s)
static const uint16_t mask[17]
#define MAX_SUBFRAMES
max number of subframes per channel
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int8_t channel_indexes_for_cur_subframe[WMAPRO_MAX_CHANNELS]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static const uint8_t coef0_huffbits[666]
static float sin64[33]
sine table for decorrelation
int max_scale_factor
maximum scale factor for the current subframe
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
int8_t channels_for_cur_subframe
number of channels that contain the subframe
AVCodec ff_wmapro_decoder
wmapro decoder
static int decode_subframe_length(WMAProDecodeCtx *s, int offset)
Decode the subframe length.
static const uint8_t coef1_huffbits[555]
Libavcodec external API header.
float out[WMAPRO_BLOCK_MAX_SIZE+WMAPRO_BLOCK_MAX_SIZE/2]
output buffer
int quant_step
quantization step for the current subframe
static const uint16_t coef1_run[HUFF_COEF1_SIZE]
uint64_t channel_layout
Audio channel layout.
frame specific decoder context for a single channel
static VLC sf_vlc
scale factor DPCM vlc
uint8_t bits_per_sample
integer audio sample size for the unscaled IMDCT output (used to scale to [-1.0, 1.0])
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static const uint8_t scale_rl_huffbits[HUFF_SCALE_RL_SIZE]
static void flush(AVCodecContext *avctx)
Clear decoder buffers (for seeking).
static const uint16_t symbol_to_vec4[HUFF_VEC4_SIZE]
static int decode_coeffs(WMAProDecodeCtx *s, int c)
Extract the coefficients from the bitstream.
uint32_t frame_num
current frame number (not used for decoding)
int8_t transform
transform on / off
float tmp[WMAPRO_BLOCK_MAX_SIZE]
IMDCT output buffer.
int8_t sf_offsets[WMAPRO_BLOCK_SIZES][WMAPRO_BLOCK_SIZES][MAX_BANDS]
scale factor resample matrix
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
#define FF_ARRAY_ELEMS(a)
uint16_t decoded_samples
number of already processed samples
static const float *const default_decorrelation[]
default decorrelation matrix offsets
static void save_bits(WMAProDecodeCtx *s, GetBitContext *gb, int len, int append)
Fill the bit reservoir with a (partial) frame.
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
int8_t transmit_num_vec_coeffs
number of vector coded coefficients is part of the bitstream
#define MAX_BANDS
max number of scale factor bands
uint8_t subframe_len_bits
number of bits used for the subframe length
int8_t transform_band[MAX_BANDS]
controls if the transform is enabled for a certain band
if(ac->has_optimized_func)
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
int8_t lfe_channel
lfe channel index
int16_t subwoofer_cutoffs[WMAPRO_BLOCK_SIZES]
subwoofer cutoff values
static VLC vec2_vlc
2 coefficients per symbol
int8_t parsed_all_subframes
all subframes decoded?
channel group for channel transformations
AVSampleFormat
Audio Sample Formats.
int16_t subframe_len
current subframe length
int sample_rate
samples per second
#define WMAPRO_BLOCK_SIZES
possible block sizes
static const uint8_t vec4_huffbits[HUFF_VEC4_SIZE]
main external API structure.
static void close(AVCodecParserContext *s)
static const uint8_t symbol_to_vec2[HUFF_VEC2_SIZE]
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
tables for wmapro decoding
static VLC coef_vlc[2]
coefficient run length vlc codes
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
int8_t reuse_sf
share scale factors between subframes
SINETABLE_CONST float *const ff_sine_windows[14]
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
uint8_t packet_offset
frame offset in the packet
static int decode_scale_factors(WMAProDecodeCtx *s)
Extract scale factors from the bitstream.
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
int saved_scale_factors[2][MAX_BANDS]
resampled and (previously) transmitted scale factor values
uint8_t num_channels
number of channels in the group
static VLC sf_rl_vlc
scale factor run length vlc
float * coeffs
pointer to the subframe decode buffer
float * windows[WMAPRO_BLOCK_SIZES]
windows for the different block sizes
uint8_t cur_subframe
current subframe number
static int remaining_bits(WMAProDecodeCtx *s, GetBitContext *gb)
Calculate remaining input buffer length.
void(* imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
static int decode_channel_transform(WMAProDecodeCtx *s)
Decode channel transformation parameters.
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.
FFTContext mdct_ctx[WMAPRO_BLOCK_SIZES]
MDCT context per block size.
av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
Initialize a float DSP context.
int8_t scale_factor_idx
index for the transmitted scale factor values (used for resampling)
#define WMAPRO_BLOCK_MAX_SIZE
maximum block size
static av_cold int decode_init(AVCodecContext *avctx)
Initialize the decoder.
uint16_t subframe_len[MAX_SUBFRAMES]
subframe length in samples
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_dlog(ac->avr,"%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-> out
#define CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time...
int8_t num_sfb[WMAPRO_BLOCK_SIZES]
scale factor bands per block size
common internal api header.
static void decode_decorrelation_matrix(WMAProDecodeCtx *s, WMAProChannelGrp *chgroup)
Calculate a decorrelation matrix from the bitstream parameters.
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.
static av_cold int init(AVCodecParserContext *s)
static void wmapro_window(WMAProDecodeCtx *s)
Apply sine window and reconstruct the output buffer.
#define WMAPRO_BLOCK_MIN_BITS
log2 of min block size
static const uint8_t scale_rl_level[HUFF_SCALE_RL_SIZE]
GetBitContext pgb
bitstream reader context for the packet
int channels
number of audio channels
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
VLC_TYPE(* table)[2]
code, bits
unsigned int ff_wma_get_large_val(GetBitContext *gb)
Decode an uncompressed coefficient.
static const uint32_t coef0_huffcodes[666]
static int decode_frame(WMAProDecodeCtx *s, AVFrame *frame, int *got_frame_ptr)
Decode one WMA frame.
int frame_number
Frame counter, set by libavcodec.
uint16_t samples_per_frame
number of samples to output
static const uint8_t vec1_huffbits[HUFF_VEC1_SIZE]
static const uint16_t coef0_run[HUFF_COEF0_SIZE]
static const uint16_t vec2_huffcodes[HUFF_VEC2_SIZE]
int8_t esc_len
length of escaped coefficients
uint8_t len_prefix
frame is prefixed with its length
float decorrelation_matrix[WMAPRO_MAX_CHANNELS *WMAPRO_MAX_CHANNELS]
static av_cold int decode_end(AVCodecContext *avctx)
Uninitialize the decoder and free all resources.
This structure stores compressed data.
#define HUFF_SCALE_RL_SIZE
uint8_t max_subframe_len_bit
flag indicating that the subframe is of maximum size when the first subframe length bit is 1 ...
int nb_samples
number of audio samples (per channel) described by this frame
int8_t skip_frame
skip output step
void ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
static const uint8_t vec2_huffbits[HUFF_VEC2_SIZE]
#define FF_DEBUG_BITSTREAM
uint8_t num_chgroups
number of channel groups
uint8_t packet_done
set when a packet is fully decoded