105 #define WMAPRO_MAX_CHANNELS 8 106 #define MAX_SUBFRAMES 32
108 #define MAX_FRAMESIZE 32768
109 #define XMA_MAX_STREAMS 8
110 #define XMA_MAX_CHANNELS_STREAM 2 111 #define XMA_MAX_CHANNELS (XMA_MAX_STREAMS * XMA_MAX_CHANNELS_STREAM) 113 #define WMAPRO_BLOCK_MIN_BITS 6 114 #define WMAPRO_BLOCK_MAX_BITS 13
115 #define WMAPRO_BLOCK_MIN_SIZE (1 << WMAPRO_BLOCK_MIN_BITS)
116 #define WMAPRO_BLOCK_MAX_SIZE (1 << WMAPRO_BLOCK_MAX_BITS)
117 #define WMAPRO_BLOCK_SIZES (WMAPRO_BLOCK_MAX_BITS - WMAPRO_BLOCK_MIN_BITS + 1)
121 #define SCALEVLCBITS 8 122 #define VEC4MAXDEPTH ((HUFF_VEC4_MAXBITS+VLCBITS-1)/VLCBITS) 123 #define VEC2MAXDEPTH ((HUFF_VEC2_MAXBITS+VLCBITS-1)/VLCBITS) 124 #define VEC1MAXDEPTH ((HUFF_VEC1_MAXBITS+VLCBITS-1)/VLCBITS) 125 #define SCALEMAXDEPTH ((HUFF_SCALE_MAXBITS+SCALEVLCBITS-1)/SCALEVLCBITS) 126 #define SCALERLMAXDEPTH ((HUFF_SCALE_RL_MAXBITS+VLCBITS-1)/VLCBITS) 256 #define PRINT(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %d\n", a, b); 257 #define PRINT_HEX(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %"PRIx32"\n", a, b); 317 unsigned int channel_mask;
319 int log2_max_num_subframes;
320 int num_possible_block_sizes;
354 s->
nb_channels = edata_ptr[32 + ((edata_ptr[0]==3)?0:8) + 4*num_stream + 0];
359 s->
nb_channels = edata_ptr[8 + 20*num_stream + 17];
362 channel_mask =
AV_RL32(edata_ptr+2);
404 log2_max_num_subframes = ((s->
decode_flags & 0x38) >> 3);
410 num_possible_block_sizes = log2_max_num_subframes + 1;
452 if (channel_mask & 8) {
454 for (mask = 1; mask < 16; mask <<= 1) {
455 if (channel_mask & mask)
490 for (i = 0; i < num_possible_block_sizes; i++) {
504 if (offset >= subframe_len)
521 for (i = 0; i < num_possible_block_sizes; i++) {
523 for (b = 0; b < s->
num_sfb[i]; b++) {
527 for (x = 0; x < num_possible_block_sizes; x++) {
552 s->
windows[WMAPRO_BLOCK_SIZES - i - 1] = ff_sine_windows[win_idx];
556 for (i = 0; i < num_possible_block_sizes; i++) {
564 for (i = 0; i < 33; i++)
595 int frame_len_shift = 0;
615 if (subframe_len < s->min_samples_per_subframe ||
649 int fixed_channel_layout = 0;
650 int min_channel_len = 0;
664 fixed_channel_layout = 1;
672 if (num_samples[c] == min_channel_len) {
673 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
675 contains_subframe[
c] = 1;
679 contains_subframe[
c] = 0;
691 if (contains_subframe[c]) {
694 "broken frame: num subframes > 31\n");
702 "channel len > samples_per_frame\n");
705 }
else if (num_samples[c] <= min_channel_len) {
706 if (num_samples[c] < min_channel_len) {
707 channels_for_cur_subframe = 0;
708 min_channel_len = num_samples[
c];
710 ++channels_for_cur_subframe;
713 }
while (min_channel_len < s->samples_per_frame);
719 ff_dlog(s->
avctx,
"frame[%"PRIu32
"] channel[%i] subframe[%i]" 753 for (x = 0; x < i; x++) {
755 for (y = 0; y < i + 1; y++) {
758 int n = rotation_offset[offset + x];
767 cosv = -
sin64[n - 32];
771 (v1 * sinv) - (v2 * cosv);
773 (v1 * cosv) + (v2 * sinv);
800 "Channel transform bit");
812 if (remaining_channels > 2) {
837 "Unknown channel transform type");
864 "Coupled channels > 6");
904 static const uint32_t fval_tab[16] = {
905 0x00000000, 0x3f800000, 0x40000000, 0x40400000,
906 0x40800000, 0x40a00000, 0x40c00000, 0x40e00000,
907 0x41000000, 0x41100000, 0x41200000, 0x41300000,
908 0x41400000, 0x41500000, 0x41600000, 0x41700000,
919 ff_dlog(s->
avctx,
"decode coefficients for channel %i\n", c);
922 vlc = &coef_vlc[vlctable];
943 for (i = 0; i < 4; i += 2) {
957 vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF];
962 vals[1] = fval_tab[(symbol_to_vec4[idx] >> 8) & 0xF];
963 vals[2] = fval_tab[(symbol_to_vec4[idx] >> 4) & 0xF];
964 vals[3] = fval_tab[ symbol_to_vec4[idx] & 0xF];
968 for (i = 0; i < 4; i++) {
974 ci->
coeffs[cur_coeff] = 0;
985 memset(&ci->
coeffs[cur_coeff], 0,
988 level, run, 1, ci->
coeffs,
1055 sign = (code & 1) - 1;
1056 skip = (code & 0x3f) >> 1;
1057 }
else if (idx == 1) {
1068 "invalid scale factor coding\n");
1104 float** ch_end = ch_data + num_channels;
1110 sfb < s->cur_sfb_offsets + s->
num_bands; sfb++) {
1116 const float* data_end = data + num_channels;
1117 float* data_ptr =
data;
1120 for (ch = ch_data; ch < ch_end; ch++)
1121 *data_ptr++ = (*ch)[y];
1123 for (ch = ch_data; ch < ch_end; ch++) {
1126 while (data_ptr < data_end)
1127 sum += *data_ptr++ * *mat++;
1135 ch_data[0] + sfb[0],
1138 ch_data[1] + sfb[0],
1186 int transmit_coeffs = 0;
1187 int cur_subwoofer_cutoff;
1205 "processing subframe with offset %i len %i\n", offset, subframe_len);
1255 if (!(num_fill_bits =
get_bits(&s->
gb, 2))) {
1260 if (num_fill_bits >= 0) {
1284 transmit_coeffs = 1;
1288 if (transmit_coeffs) {
1314 if (step == -32 || step == 31) {
1315 const int sign = (step == 31) - 1;
1321 quant_step += ((quant + step) ^ sign) - sign;
1323 if (quant_step < 0) {
1350 ff_dlog(s->
avctx,
"BITSTREAM: subframe header length was %i\n",
1364 ff_dlog(s->
avctx,
"BITSTREAM: subframe length was %i\n",
1367 if (transmit_coeffs) {
1377 memset(&s->
tmp[cur_subwoofer_cutoff], 0,
sizeof(*s->
tmp) *
1378 (subframe_len - cur_subwoofer_cutoff));
1390 quant, end - start);
1423 int more_frames = 0;
1431 ff_dlog(s->
avctx,
"decoding frame with length %x\n", len);
1472 ff_dlog(s->
avctx,
"BITSTREAM: frame header length was %i\n",
1515 "frame[%"PRIu32
"] would have to skip %i bits\n",
1585 align =
FFMIN(align, len);
1606 int buf_size = avpkt->
size;
1607 int num_bits_prev_frame;
1608 int packet_sequence_number;
1634 packet_sequence_number =
get_bits(gb, 4);
1639 packet_sequence_number = 0;
1651 num_bits_prev_frame);
1658 "Packet loss detected! seq %"PRIx8
" vs %x\n",
1663 if (num_bits_prev_frame > 0) {
1665 if (num_bits_prev_frame >= remaining_packet_bits) {
1666 num_bits_prev_frame = remaining_packet_bits;
1672 save_bits(s, gb, num_bits_prev_frame, 1);
1673 ff_dlog(avctx,
"accumulated %x bits of frame data\n",
1680 ff_dlog(avctx,
"ignoring %x previously saved bits\n",
1744 int *got_frame_ptr,
AVPacket *avpkt)
1761 int *got_frame_ptr,
AVPacket *avpkt)
1764 int got_stream_frame_ptr = 0;
1766 int i, ret,
offset = INT_MAX;
1770 &got_stream_frame_ptr, avpkt);
1773 if (got_stream_frame_ptr) {
1781 }
else if (ret < 0) {
1851 int i, ret, start_channels = 0;
float * channel_data[WMAPRO_MAX_CHANNELS]
transformation coefficients
uint8_t max_num_subframes
const char const char void * val
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.
#define XMA_MAX_CHANNELS_STREAM
This structure describes decoded (raw) audio or video data.
float samples[XMA_MAX_CHANNELS][512 *64]
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 void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
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)
Skips the specified number of bits.
static av_cold int init(AVCodecContext *avctx)
AVCodecContext * avctx
codec context for av_log
int offset[XMA_MAX_STREAMS]
#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)
uint32_t decode_flags
used compression features
int start_channel[XMA_MAX_STREAMS]
#define FF_DEBUG_BITSTREAM
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_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), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { 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) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;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)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&HAVE_MMX) 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);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=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) { int planes=out->planar ? out->ch_count :1;unsigned m=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){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
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
static void wmapro_flush(AVCodecContext *avctx)
Clear decoder buffers (for seeking).
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.
static const uint8_t scale_huffbits[HUFF_SCALE_SIZE]
uint8_t table_idx
index in sf_offsets for the scale factor reference block
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 void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
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
static av_cold int xma_decode_init(AVCodecContext *avctx)
static const uint8_t scale_rl_run[HUFF_SCALE_RL_SIZE]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int frame_offset
frame offset in the bit reservoir
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)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int8_t num_bands
number of scale factor bands
static av_cold int end(AVCodecContext *avctx)
static av_cold int xma_decode_end(AVCodecContext *avctx)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
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
static uint8_t * append(uint8_t *buf, const uint8_t *src, int size)
#define MAX_FRAMESIZE
maximum compressed frame size
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
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 av_cold int wmapro_decode_end(AVCodecContext *avctx)
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.
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 int get_bits_left(GetBitContext *gb)
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
Overlap/add with window function.
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 int decode_subframe(WMAProDecodeCtx *s)
Decode a single subframe (block).
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
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
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_cold int decode_end(WMAProDecodeCtx *s)
Uninitialize the decoder and free all resources.
#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.
int flags
AV_CODEC_FLAG_*.
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
const char * name
Name of the codec implementation.
int8_t channels_for_cur_subframe
number of channels that contain the subframe
static const uint8_t offset[127][2]
AVCodec ff_wmapro_decoder
wmapro decoder
static int decode_subframe_length(WMAProDecodeCtx *s, int offset)
Decode the subframe length.
int8_t nb_channels
number of channels in stream (XMA1/2)
static const uint8_t coef1_huffbits[555]
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 int put_bits_count(PutBitContext *s)
static int decode_packet(AVCodecContext *avctx, WMAProDecodeCtx *s, void *data, int *got_frame_ptr, AVPacket *avpkt)
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])
static const uint8_t scale_rl_huffbits[HUFF_SCALE_RL_SIZE]
static const uint16_t symbol_to_vec4[HUFF_VEC4_SIZE]
static SDL_Window * window
static int decode_coeffs(WMAProDecodeCtx *s, int c)
Extract the coefficients from the bitstream.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
uint8_t skip_packets
packets to skip to find next packet in a stream (XMA1/2)
uint32_t frame_num
current frame number (not used for decoding)
static void xma_flush(AVCodecContext *avctx)
static void flush(WMAProDecodeCtx *s)
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 av_cold int decode_init(WMAProDecodeCtx *s, AVCodecContext *avctx, int num_stream)
Initialize the decoder.
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
uint16_t decoded_samples
number of already processed samples
AVFrame * frames[XMA_MAX_STREAMS]
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
const float * windows[WMAPRO_BLOCK_SIZES]
windows for the different block sizes
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
#define FF_ARRAY_ELEMS(a)
uint8_t frame_data[MAX_FRAMESIZE+AV_INPUT_BUFFER_PADDING_SIZE]
compressed frame data
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
const AVS_VideoInfo int align
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?
Libavcodec external API header.
channel group for channel transformations
AVSampleFormat
Audio sample formats.
static av_cold int wmapro_decode_init(AVCodecContext *avctx)
Initialize the decoder.
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 const uint8_t symbol_to_vec2[HUFF_VEC2_SIZE]
tables for wmapro decoding
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
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
#define AV_CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time...
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 av_cold int get_rate(AVCodecContext *avctx)
static VLC sf_rl_vlc
scale factor run length vlc
float * coeffs
pointer to the subframe decode buffer
uint8_t cur_subframe
current subframe number
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
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.
int8_t scale_factor_idx
index for the transmitted scale factor values (used for resampling)
#define WMAPRO_BLOCK_MAX_SIZE
maximum block size
uint16_t subframe_len[MAX_SUBFRAMES]
subframe length in samples
internal math functions header
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.
channel
Use these values when setting the channel map with ebur128_set_channel().
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext 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
#define AV_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_level[HUFF_SCALE_RL_SIZE]
GetBitContext pgb
bitstream reader context for the packet
int channels
number of audio channels
VLC_TYPE(* table)[2]
code, bits
WMAProDecodeCtx xma[XMA_MAX_STREAMS]
unsigned int ff_wma_get_large_val(GetBitContext *gb)
Decode an uncompressed coefficient.
static const uint32_t coef0_huffcodes[666]
static enum AVSampleFormat sample_fmts[]
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 int wmapro_decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Decode a single WMA packet.
uint8_t ** extended_data
pointers to the data planes/channels.
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
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int8_t skip_frame
skip output step
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
void AAC_RENAME() ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
static const uint8_t vec2_huffbits[HUFF_VEC2_SIZE]
uint8_t num_chgroups
number of channel groups
uint8_t packet_done
set when a packet is fully decoded
static int xma_decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)