39 #define WMALL_MAX_CHANNELS 8
40 #define MAX_SUBFRAMES 32
42 #define MAX_FRAMESIZE 32768
45 #define WMALL_BLOCK_MIN_BITS 6
46 #define WMALL_BLOCK_MAX_BITS 14
47 #define WMALL_BLOCK_MAX_SIZE (1 << WMALL_BLOCK_MAX_BITS)
48 #define WMALL_BLOCK_SIZES (WMALL_BLOCK_MAX_BITS - WMALL_BLOCK_MIN_BITS + 1)
50 #define WMALL_COEFF_PAD_SIZE 16
178 #define WMASIGN(x) (((x) > 0) - ((x) < 0))
184 unsigned int channel_mask;
185 int i, log2_max_num_subframes;
203 channel_mask =
AV_RL32(edata_ptr + 2);
239 for (i = 0; i < avctx->
channels; i++)
263 if (channel_mask & 8) {
265 for (mask = 1; mask < 16; mask <<= 1)
266 if (channel_mask & mask)
296 int frame_len_ratio, subframe_len,
len;
307 if (subframe_len < s->min_samples_per_subframe ||
341 int fixed_channel_layout = 0;
342 int min_channel_len = 0;
351 fixed_channel_layout = 1;
355 int subframe_len, in_use = 0;
359 if (num_samples[c] == min_channel_len) {
360 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
362 contains_subframe[
c] = 1;
366 in_use |= contains_subframe[
c];
368 contains_subframe[
c] = 0;
373 "Found empty subframe\n");
381 min_channel_len += subframe_len;
385 if (contains_subframe[c]) {
388 "broken frame: num subframes > 31\n");
392 num_samples[
c] += subframe_len;
396 "channel len(%"PRIu16
") > samples_per_frame(%"PRIu16
")\n",
400 }
else if (num_samples[c] <= min_channel_len) {
401 if (num_samples[c] < min_channel_len) {
402 channels_for_cur_subframe = 0;
403 min_channel_len = num_samples[
c];
405 ++channels_for_cur_subframe;
408 }
while (min_channel_len < s->samples_per_frame);
436 int i, send_coef_bits;
438 if (1 << cbits < s->mclms_scaling + 1)
448 for (c = 0; c < i; c++)
465 "Order[%d][%d] %d > max (%d), not supported\n",
482 if (cdlms_send_coef) {
484 int cbits, shift_l, shift_r, j;
514 unsigned int ave_mean;
537 for (; i < tile_size; i++) {
538 int quo = 0, rem, rem_bits, residue;
551 rem_bits = av_ceil_log2(ave_mean);
553 residue = (quo << rem_bits) + rem;
559 residue = (residue >> 1) ^ -(residue & 1);
593 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++) {
613 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++)
625 int i, j, ich, pred_error;
630 for (ich = 0; ich < num_channels; ich++) {
632 if (pred_error > 0) {
633 for (i = 0; i < order * num_channels; i++)
636 for (j = 0; j < ich; j++)
638 }
else if (pred_error < 0) {
639 for (i = 0; i < order * num_channels; i++)
642 for (j = 0; j < ich; j++)
647 for (ich = num_channels - 1; ich >= 0; ich--) {
657 sizeof(
int32_t) * order * num_channels);
660 sizeof(
int32_t) * order * num_channels);
671 for (ich = 0; ich < num_channels; ich++) {
675 for (i = 0; i < order * num_channels; i++)
678 for (i = 0; i < ich; i++)
690 for (icoef = 0; icoef < tile_size; icoef++) {
698 int ilms, recent, icoef;
699 for (ilms = s->
cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
704 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
707 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
716 int ilms, recent, icoef;
717 for (ilms = s->
cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
722 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
731 #define CD_LMS(bits, ROUND) \
732 static void lms_update ## bits (WmallDecodeCtx *s, int ich, int ilms, int input) \
734 int recent = s->cdlms[ich][ilms].recent; \
735 int range = 1 << s->bits_per_sample - 1; \
736 int order = s->cdlms[ich][ilms].order; \
737 int ##bits##_t *prev = (int##bits##_t *)s->cdlms[ich][ilms].lms_prevvalues; \
742 memcpy(prev + order, prev, (bits/8) * order); \
743 memcpy(s->cdlms[ich][ilms].lms_updates + order, \
744 s->cdlms[ich][ilms].lms_updates, \
745 sizeof(*s->cdlms[ich][ilms].lms_updates) * order); \
746 recent = order - 1; \
749 prev[recent] = av_clip(input, -range, range - 1); \
750 s->cdlms[ich][ilms].lms_updates[recent] = WMASIGN(input) * s->update_speed[ich]; \
752 s->cdlms[ich][ilms].lms_updates[recent + (order >> 4)] >>= 2; \
753 s->cdlms[ich][ilms].lms_updates[recent + (order >> 3)] >>= 1; \
754 s->cdlms[ich][ilms].recent = recent; \
755 memset(s->cdlms[ich][ilms].lms_updates + recent + order, 0, \
756 sizeof(s->cdlms[ich][ilms].lms_updates) - \
757 sizeof(*s->cdlms[ich][ilms].lms_updates)*(recent+order)); \
760 static void revert_cdlms ## bits (WmallDecodeCtx *s, int ch, \
761 int coef_begin, int coef_end) \
763 int icoef, pred, ilms, num_lms, residue, input; \
765 num_lms = s->cdlms_ttl[ch]; \
766 for (ilms = num_lms - 1; ilms >= 0; ilms--) { \
767 for (icoef = coef_begin; icoef < coef_end; icoef++) { \
768 int##bits##_t *prevvalues = (int##bits##_t *)s->cdlms[ch][ilms].lms_prevvalues; \
769 pred = 1 << (s->cdlms[ch][ilms].scaling - 1); \
770 residue = s->channel_residues[ch][icoef]; \
771 pred += s->dsp.scalarproduct_and_madd_int## bits (s->cdlms[ch][ilms].coefs, \
772 prevvalues + s->cdlms[ch][ilms].recent, \
773 s->cdlms[ch][ilms].lms_updates + \
774 s->cdlms[ch][ilms].recent, \
775 FFALIGN(s->cdlms[ch][ilms].order, ROUND), \
777 input = residue + (pred >> s->cdlms[ch][ilms].scaling); \
778 lms_update ## bits(s, ch, ilms, input); \
779 s->channel_residues[ch][icoef] = input; \
782 if (bits <= 16) emms_c(); \
790 if (s->num_channels != 2)
792 else if (s->is_channel_coded[0] || s->is_channel_coded[1]) {
794 for (icoef = 0; icoef < tile_size; icoef++) {
795 s->channel_residues[0][icoef] -= s->channel_residues[1][icoef] >> 1;
796 s->channel_residues[1][icoef] += s->channel_residues[0][icoef];
810 for (i = 0; i < order; i++) {
812 for (j = 0; j < order; j++) {
814 pred += filter_coeffs[j] * prevvalues[j - i];
821 for (i = order; i < tile_size; i++) {
823 for (j = 0; j < order; j++)
828 for (j = 0; j < order; j++)
838 int i, j, rawpcm_tile, padding_zeroes, res;
908 "Waiting for seekable tile\n");
927 "inverse LPC filter");
943 "Invalid number of padding bits in raw PCM tile\n");
947 "total %d bits, remain=%d\n", bits,
950 for (j = 0; j < subframe_len; j++)
961 revert_cdlms32(s, i, 0, subframe_len);
963 revert_cdlms16(s, i, 0, subframe_len);
979 for (j = 0; j < subframe_len; j++)
988 for (j = 0; j < subframe_len; j++) {
1018 int more_frames = 0,
len = 0, i, ret;
1095 "frame[%"PRIu32
"] would have to skip %i bits\n",
1161 align =
FFMIN(align, len);
1181 int buf_size = avpkt->
size;
1182 int num_bits_prev_frame, packet_sequence_number, spliced_packet;
1202 packet_sequence_number =
get_bits(gb, 4);
1216 "Packet loss detected! seq %"PRIx8
" vs %x\n",
1221 if (num_bits_prev_frame > 0) {
1223 if (num_bits_prev_frame >= remaining_packet_bits) {
1224 num_bits_prev_frame = remaining_packet_bits;
1230 save_bits(s, gb, num_bits_prev_frame, 1);
1233 if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
1236 ff_dlog(avctx,
"ignoring %x previously saved bits\n",
1320 .
name =
"wmalossless",
static void decode_ac_filter(WmallDecodeCtx *s)
int16_t prev_block_len
length of the previous block
uint8_t subframe_len_bits
number of bits used for the subframe length
uint8_t bits_per_sample
integer audio sample size for the unscaled IMDCT output (used to scale to [-1.0, 1.0])
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
This structure describes decoded (raw) audio or video data.
uint8_t max_subframe_len_bit
flag indicating that the subframe is of maximum size when the first subframe length bit is 1 ...
uint8_t max_num_subframes
ptrdiff_t const GLvoid * data
uint16_t subframe_offsets[MAX_SUBFRAMES]
subframe positions in the current frame
int32_t * samples_32[WMALL_MAX_CHANNELS]
current sample buffer pointer (24-bit)
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.
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static av_cold int init(AVCodecContext *avctx)
uint8_t drc_gain
gain for the DRC tool
int acfilter_prevvalues[WMALL_MAX_CHANNELS][16]
void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
Copy the content of src to the bitstream.
PutBitContext pb
context for filling the frame_data buffer
uint8_t cur_subframe
current subframe number
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
LLAudDSPContext dsp
accelerated DSP functions
static void decode_mclms(WmallDecodeCtx *s)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int cdlms_ttl[WMALL_MAX_CHANNELS]
static int decode_subframe_length(WmallDecodeCtx *s, int offset)
Decode the subframe length.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
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)
int8_t channels_for_cur_subframe
number of channels that contain the subframe
Macro definitions for various function/variable attributes.
static int get_sbits_long(GetBitContext *s, int n)
Read 0-32 bits as a signed integer.
uint8_t packet_sequence_number
current packet number
int max_frame_size
max bitstream size
int32_t mclms_updates[WMALL_MAX_CHANNELS *2 *32]
int16_t subframe_len
current subframe length
uint16_t decoded_samples
number of already processed samples
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
GetBitContext pgb
bitstream reader context for the packet
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int quant_step
quantization step for the current subframe
int16_t coefs[MAX_ORDER+WMALL_COEFF_PAD_SIZE/sizeof(int16_t)]
enum AVSampleFormat sample_fmt
audio sample format
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int16_t acfilter_coeffs[16]
int8_t num_channels
number of channels in the stream (same as AVCodecContext.num_channels)
static void reset_codec(WmallDecodeCtx *s)
Reset filter parameters and transient area at new seekable tile.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int update_speed[WMALL_MAX_CHANNELS]
int is_channel_coded[WMALL_MAX_CHANNELS]
int frame_offset
frame offset in the bit reservoir
static uint8_t * append(uint8_t *buf, const uint8_t *src, int size)
#define WMASIGN(x)
Get sign of integer (1 for positive, -1 for negative and 0 for zero)
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
uint16_t min_samples_per_subframe
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
#define CD_LMS(bits, ROUND)
frame-specific decoder context for a single channel
int8_t lfe_channel
lfe channel index
int buf_bit_size
buffer size in bits
static int get_bits_left(GetBitContext *gb)
int16_t mclms_coeffs[WMALL_MAX_CHANNELS *WMALL_MAX_CHANNELS *32]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_cold int decode_init(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static void mclms_update(WmallDecodeCtx *s, int icoef, int *pred)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
simple assert() macros that are a bit more flexible than ISO C assert().
int8_t channel_indexes_for_cur_subframe[WMALL_MAX_CHANNELS]
const char * name
Name of the codec implementation.
struct WmallDecodeCtx::@192 cdlms[WMALL_MAX_CHANNELS][9]
static int decode_subframe(WmallDecodeCtx *s)
static int decode_cdlms(WmallDecodeCtx *s)
static void revert_acfilter(WmallDecodeCtx *s, int tile_size)
#define WMALL_BLOCK_MAX_SIZE
maximum block size
static const uint8_t offset[127][2]
int channel_residues[WMALL_MAX_CHANNELS][WMALL_BLOCK_MAX_SIZE]
int8_t parsed_all_subframes
all subframes decoded?
uint64_t channel_layout
Audio channel layout.
static int decode_tilehdr(WmallDecodeCtx *s)
Decode how the data in the frame is split into subframes.
int32_t lms_prevvalues[MAX_ORDER *2+WMALL_COEFF_PAD_SIZE/sizeof(int16_t)]
static void use_high_update_speed(WmallDecodeCtx *s, int ich)
#define MAX_SUBFRAMES
max number of subframes per channel
static av_cold int decode_close(AVCodecContext *avctx)
uint8_t packet_loss
set in case of bitstream error
static void mclms_predict(WmallDecodeCtx *s, int icoef, int *pred)
static void clear_codec_buffers(WmallDecodeCtx *s)
uint32_t decode_flags
used compression features
uint8_t * frame_data
compressed frame data
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
static void revert_inter_ch_decorr(WmallDecodeCtx *s, int tile_size)
int8_t skip_frame
skip output step
uint8_t packet_offset
offset to the frame in the packet
av_cold void ff_llauddsp_init(LLAudDSPContext *c)
static int decode_channel_residues(WmallDecodeCtx *s, int ch, int tile_size)
uint8_t packet_done
set when a packet is fully decoded
static void use_normal_update_speed(WmallDecodeCtx *s, int ich)
int16_t mclms_coeffs_cur[WMALL_MAX_CHANNELS *WMALL_MAX_CHANNELS]
uint16_t samples_per_frame
number of samples to output
static const float pred[4]
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
const AVS_VideoInfo int align
int next_packet_start
start offset of the next WMA packet in the demuxer packet
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
int sample_rate
samples per second
#define WMALL_MAX_CHANNELS
current decoder limitations
main external API structure.
int16_t * samples_16[WMALL_MAX_CHANNELS]
current sample buffer pointer (16-bit)
static void decode_lpc(WmallDecodeCtx *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
#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.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int remaining_bits(WmallDecodeCtx *s, GetBitContext *gb)
Calculate remaining input buffer length.
GetBitContext gb
bitstream reader context
uint32_t frame_num
current frame number (not used for decoding)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
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.
uint8_t do_inter_ch_decorr
uint16_t subframe_len[MAX_SUBFRAMES]
subframe length in samples
int ave_sum[WMALL_MAX_CHANNELS]
WmallChannelCtx channel[WMALL_MAX_CHANNELS]
per channel data
#define MAX_FRAMESIZE
maximum compressed frame size
common internal api header.
#define WMALL_COEFF_PAD_SIZE
pad coef buffers with 0 for use with SIMD
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
int dynamic_range_compression
frame contains DRC data
int transient_counter
number of transient samples from the beginning of the transient zone
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 save_bits(WmallDecodeCtx *s, GetBitContext *gb, int len, int append)
Fill the bit reservoir with a (partial) frame.
int transient_pos[WMALL_MAX_CHANNELS]
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int channels
number of audio channels
int16_t lms_updates[MAX_ORDER *2+WMALL_COEFF_PAD_SIZE/sizeof(int16_t)]
AVCodec ff_wmalossless_decoder
static enum AVSampleFormat sample_fmts[]
static void flush(AVCodecContext *avctx)
int len_prefix
frame is prefixed with its length
static int decode_frame(WmallDecodeCtx *s)
Decode one WMA frame.
int transient[WMALL_MAX_CHANNELS]
uint8_t ** extended_data
pointers to the data planes/channels.
int32_t mclms_prevvalues[WMALL_MAX_CHANNELS *2 *32]
int num_saved_bits
saved number of bits
int subframe_offset
subframe offset in the bit reservoir
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
int lpc_coefs[WMALL_MAX_CHANNELS][40]
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_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),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){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) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;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)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_X86ASM &&1) 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);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=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){intplanes=out->planar?out->ch_count:1;unsignedm=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){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
static void revert_mclms(WmallDecodeCtx *s, int tile_size)