Go to the documentation of this file.
88 case 16:
s->align *= 2;
94 case MKTAG(
'0',
'C',
'P',
'Y'):
98 case MKTAG(
'1',
'D',
'I',
'F'):
102 case MKTAG(
'2',
'S',
'L',
'P'):
103 case MKTAG(
'3',
'N',
'L',
'P'):
104 case MKTAG(
'4',
'A',
'L',
'P'):
105 case MKTAG(
'5',
'E',
'L',
'P'):
113 s->max_framesize =
s->nb_samples * 16;
125 unsigned z = (x << k) | y;
134 return (z & 1) ? ~((
int)(z >> 1)) : z >> 1;
139 const int nb_samples =
s->nb_samples;
140 const int shift =
s->shift;
144 for (
int n = 0; n <
len; n++) {
145 s->samples[0][n] =
s->samples[0][nb_samples + n] >>
shift;
146 s->samples[1][n] =
s->pred[1][n] >>
shift;
149 for (
int n = 0; n <
len; n++) {
150 s->samples[0][n] =
s->samples[0][nb_samples + n] >>
shift;
151 s->samples[1][n] =
s->pred[0][n] >>
shift;
156 for (
int n = 0; n < nb_samples; n++)
157 s->samples[1][n +
len] += (
unsigned)
s->samples[0][n +
len];
159 for (
int n = 0; n <
len; n++) {
160 s->pred[0][n] =
s->samples[1][nb_samples + n];
161 s->pred[1][n] =
s->pred[0][n] - (unsigned)
s->samples[0][nb_samples + n];
169 const int bits =
s->align * 8;
175 for (
int n = 0; n <
s->nb_samples; n++) {
177 s->samples[ch][n] =
get_bits(gb, 8) - 0x80;
181 for (
int n = 0; n <
s->nb_samples; n++) {
193 int ch, finished, fill, correlated;
205 if (block_type < 4 && block_type >= 0) {
212 switch (block_type) {
221 if ((
unsigned)
s->shift > 31) {
235 for (
int n = 0; n <
s->nb_samples; n++)
240 for (
int n = 0; n <
s->nb_samples; n++)
245 for (
int n = 0; n <
s->nb_samples; n++)
251 for (
int n = 0; n <
s->nb_samples; n++)
256 for (
int n = 0; n <
s->nb_samples; n++)
261 for (
int n = 0; n <
s->nb_samples; n++)
279 for (
int n = 0; n < 4; n++)
280 s->samples[0][n] =
s->samples[0][
s->nb_samples + n];
289 int ch, finished, fill, correlated, order;
301 if (block_type < 5 && block_type >= 0) {
308 switch (block_type) {
314 if (
s->nb_samples > 570
U) {
321 if ((
unsigned)
s->shift > 31) {
335 for (
int n = 0; n <
s->nb_samples; n++)
340 for (
int n = 0; n <
s->nb_samples; n++)
345 for (
int n = 0; n <
s->nb_samples; n++)
351 for (
int n = 0; n <
s->nb_samples; n++)
356 for (
int n = 0; n <
s->nb_samples; n++)
361 for (
int n = 0; n <
s->nb_samples; n++)
369 for (
int o = 0; o < order; o++)
371 for (
int n = 0; n <
s->nb_samples; n++) {
374 for (
int o = 0; o < order; o++)
375 sum +=
s->filter[ch][o] * (
unsigned)
samples[n + 70 - o - 1];
395 for (
int n = 0; n < 70; n++)
396 s->samples[0][n] =
s->samples[0][
s->nb_samples + n];
406 s->ac_high = 0xffff
u;
409 s->freq_range =
s->freqs[256];
417 return ((
s->freq_range - 1) + (
s->ac_value -
s->ac_low) * (
unsigned)
s->freq_range) /
418 ((
s->ac_high -
s->ac_low) + 1
U);
425 while (prob < s->freqs[idx])
428 s->range_high =
s->freqs[idx + 1];
429 s->range_low =
s->freqs[idx];
438 if (
s->ac_high <
s->ac_low)
441 range = (
s->ac_high -
s->ac_low) + 1;
442 s->ac_high = (
range * (unsigned)
s->range_high) /
s->freq_range +
s->ac_low - 1;
443 s->ac_low += (
range * (unsigned)
s->range_low) /
s->freq_range;
445 if (
s->ac_high <
s->ac_low)
449 if ((
s->ac_high & 0x8000) != (
s->ac_low & 0x8000)) {
450 if (((
s->ac_low & 0x4000) == 0) || ((
s->ac_high & 0x4000) != 0))
452 s->ac_value ^= 0x4000;
454 s->ac_high |= 0x4000;
457 s->ac_low =
s->ac_low * 2;
458 s->ac_high =
s->ac_high * 2 | 1;
459 if (
s->ac_high <
s->ac_low)
468 if (
s->ac_low >
s->ac_value ||
s->ac_high <
s->ac_value)
479 memset(
s->freqs, 0,
sizeof(
s->freqs));
481 for (
int n = 0; n < 256; n++)
482 s->freqs[n+1] =
s->model[n] +
s->freqs[n];
491 memset(
s->model, 0,
sizeof(
s->model));
497 while (start <= end) {
521 int ch, finished, fill, correlated, order = 0;
527 int *ac_pred =
s->ac_pred;
528 int *ac_out =
s->ac_out;
534 memset(
s->ac_out, 0,
sizeof(
s->ac_out));
539 if (block_type >= 0 && block_type <= 7) {
546 if (block_type <= 2 || block_type == 6 || block_type == 13 ||
547 block_type == 14 || block_type == 15 || block_type == 19) {
551 for (
int o = 0; o < order; o++)
555 if (block_type >= 0 && block_type <= 7) {
556 for (
int n = 0; n <
s->nb_samples; n++)
559 for (
int n = 0; n <
s->nb_samples; n++)
563 if (block_type >= 13 && block_type <= 20) {
564 const int ac_size =
get_bits(gb, 12);
582 for (
int n = 0; n <
s->nb_samples; n++) {
585 ac_out[n] = ac - 0x80;
596 switch (block_type) {
602 if (
s->nb_samples > 570
U) {
609 if ((
unsigned)
s->shift > 31) {
623 for (
int n = 0; n <
s->nb_samples; n++)
628 for (
int n = 0; n <
s->nb_samples; n++)
634 for (
int n = 0; n <
s->nb_samples; n++)
640 for (
int n = 0; n < 70; n++) {
645 for (
int n = 0; n <
s->nb_samples; n++) {
648 for (
int o = 0; o < order; o++)
649 sum +=
s->filter[ch][o] * (
unsigned)
samples[n + 70 - o - 1];
651 samples[n + 70] += ac_out[n] + (unsigned)(sum >> 4);
654 for (
int n = 0; n < 70; n++)
657 for (
int n = 0; n <
s->nb_samples; n++)
664 for (
int n = 0; n <
s->nb_samples; n++)
670 for (
int n = 0; n <
s->nb_samples; n++)
676 for (
int n = 0; n <
s->nb_samples; n++)
682 for (
int n = 0; n < 70; n++) {
687 for (
int n = 0; n <
s->nb_samples; n++) {
690 for (
int o = 0; o < order; o++)
691 sum +=
s->filter[ch][o] * (
unsigned)
samples[n + 70 - o - 1];
693 samples[n + 70] += ac_out[n] + (sum >> 4);
696 for (
int n = 0; n < 70; n++)
699 for (
int n = 0; n <
s->nb_samples; n++)
706 for (
int n = 0; n < 70; n++) {
711 for (
int n = 0; n <
s->nb_samples; n++) {
714 for (
int o = 0; o < order; o++)
715 sum +=
s->filter[ch][o] * (
unsigned)
samples[n + 70 - o - 1];
717 samples[n + 70] += (unsigned)ac_out[n] + (sum >> 4);
720 for (
int n = 0; n < 70; n++)
723 for (
int n = 0; n <
s->nb_samples; n++)
730 for (
int n = 0; n <
s->nb_samples; n++) {
733 for (
int o = 0; o < order; o++)
734 sum +=
s->filter[ch][o] * (
unsigned)
samples[n + 70 - o - 1];
736 samples[n + 70] += (unsigned)ac_out[n] + (sum >> 4);
754 for (
int n = 0; n < 70; n++)
755 s->samples[0][n] =
s->samples[0][
s->nb_samples + n];
766 int buf_size, input_buf_size;
770 if ((!
pkt->
size && !
s->bitstream_size) ||
s->nb_samples == 0 ||
s->eof) {
775 buf_size =
FFMIN(
pkt->
size,
s->max_framesize -
s->bitstream_size);
776 input_buf_size = buf_size;
778 memmove(
s->bitstream, &
s->bitstream[
s->bitstream_index],
s->bitstream_size);
779 s->bitstream_index = 0;
782 memcpy(&
s->bitstream[
s->bitstream_index +
s->bitstream_size],
pkt->
data, buf_size);
783 buf = &
s->bitstream[
s->bitstream_index];
784 buf_size +=
s->bitstream_size;
785 s->bitstream_size = buf_size;
786 if (buf_size < s->max_framesize &&
pkt->
data) {
788 return input_buf_size;
796 case MKTAG(
'0',
'C',
'P',
'Y'):
799 case MKTAG(
'1',
'D',
'I',
'F'):
802 case MKTAG(
'2',
'S',
'L',
'P'):
803 case MKTAG(
'3',
'N',
'L',
'P'):
804 case MKTAG(
'4',
'A',
'L',
'P'):
807 case MKTAG(
'5',
'E',
'L',
'P'):
822 s->bitstream_size = 0;
823 s->bitstream_index = 0;
837 const int *
src =
s->samples[ch] +
s->offset;
840 dst[n] =
src[n] * (1
U <<
s->shift) + 0x80
U;
846 const int *
src =
s->samples[ch] +
s->offset;
849 dst[n] =
src[n] * (1
U <<
s->shift);
856 if (
s->bitstream_size) {
857 s->bitstream_index += n;
858 s->bitstream_size -= n;
859 return input_buf_size;
870 s->bitstream_size = 0;
886 AV_CODEC_CAP_SUBFRAMES |
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static int get_bits_left(GetBitContext *gb)
static int get_srice(GetBitContext *gb, int k)
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
int sample_rate
samples per second
#define u(width, name, range_min, range_max)
#define AVERROR_EOF
End of file.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_bits_count(const GetBitContext *s)
This structure describes decoded (raw) audio or video data.
static uint8_t ac_map_symbol(WavArcContext *s, uint16_t prob)
int nb_channels
Number of channels in this layout.
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVCodec p
The public AVCodec.
static uint16_t ac_get_prob(WavArcContext *s)
AVChannelLayout ch_layout
Audio channel layout.
static int wavarc_decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *pkt)
static void do_stereo(WavArcContext *s, int ch, int correlated, int len)
static int decode_0cpy(AVCodecContext *avctx, WavArcContext *s, GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define FF_CODEC_DECODE_CB(func)
int(* init)(AVBSFContext *ctx)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
static int decode_5elp(AVCodecContext *avctx, WavArcContext *s, GetBitContext *gb)
#define CODEC_LONG_NAME(str)
Describe the class of an AVClass context structure.
static unsigned int get_bits1(GetBitContext *s)
static void ac_init_model(WavArcContext *s)
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
@ AV_SAMPLE_FMT_U8P
unsigned 8 bits, planar
static int shift(int a, int b)
enum AVSampleFormat sample_fmt
audio sample format
static int ac_read_model(AVCodecContext *avctx, WavArcContext *s, GetBitContext *gb)
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
const FFCodec ff_wavarc_decoder
static int decode_1dif(AVCodecContext *avctx, WavArcContext *s, GetBitContext *gb)
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
uint8_t ** extended_data
pointers to the data planes/channels.
AVSampleFormat
Audio sample formats.
const char * name
Name of the codec implementation.
void * av_calloc(size_t nmemb, size_t size)
static av_cold int wavarc_close(AVCodecContext *avctx)
#define prob(name, subs,...)
#define AV_INPUT_BUFFER_PADDING_SIZE
static int ac_normalize(AVCodecContext *avctx, WavArcContext *s, GetBitContext *gb)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
main external API structure.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
static av_const int sign_extend(int val, unsigned bits)
static int decode_2slp(AVCodecContext *avctx, WavArcContext *s, GetBitContext *gb)
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Filter the word “frame” indicates either a video frame or a group of audio samples
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
This structure stores compressed data.
static unsigned get_urice(GetBitContext *gb, int k)
static av_cold int wavarc_init(AVCodecContext *avctx)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
static int ac_init(AVCodecContext *avctx, WavArcContext *s, GetBitContext *gb)