Go to the documentation of this file.
87 case 16:
s->align *= 2;
93 case MKTAG(
'0',
'C',
'P',
'Y'):
97 case MKTAG(
'1',
'D',
'I',
'F'):
101 case MKTAG(
'2',
'S',
'L',
'P'):
102 case MKTAG(
'3',
'N',
'L',
'P'):
103 case MKTAG(
'4',
'A',
'L',
'P'):
104 case MKTAG(
'5',
'E',
'L',
'P'):
112 s->max_framesize =
s->nb_samples * 16;
124 unsigned z = (x << k) | y;
133 return (z & 1) ? ~((int)(z >> 1)) : z >> 1;
138 const int nb_samples =
s->nb_samples;
139 const int shift =
s->shift;
143 for (
int n = 0; n <
len; n++) {
144 s->samples[0][n] =
s->samples[0][nb_samples + n] >>
shift;
145 s->samples[1][n] =
s->pred[1][n] >>
shift;
148 for (
int n = 0; n <
len; n++) {
149 s->samples[0][n] =
s->samples[0][nb_samples + n] >>
shift;
150 s->samples[1][n] =
s->pred[0][n] >>
shift;
155 for (
int n = 0; n < nb_samples; n++)
156 s->samples[1][n +
len] += (
unsigned)
s->samples[0][n +
len];
158 for (
int n = 0; n <
len; n++) {
159 s->pred[0][n] =
s->samples[1][nb_samples + n];
160 s->pred[1][n] =
s->pred[0][n] - (unsigned)
s->samples[0][nb_samples + n];
168 const int bits =
s->align * 8;
174 for (
int n = 0; n <
s->nb_samples; n++) {
176 s->samples[ch][n] =
get_bits(gb, 8) - 0x80;
180 for (
int n = 0; n <
s->nb_samples; n++) {
192 int ch, finished, fill, correlated;
204 if (block_type < 4 && block_type >= 0) {
211 switch (block_type) {
220 if ((
unsigned)
s->shift > 31) {
234 for (
int n = 0; n <
s->nb_samples; n++)
239 for (
int n = 0; n <
s->nb_samples; n++)
244 for (
int n = 0; n <
s->nb_samples; n++)
250 for (
int n = 0; n <
s->nb_samples; n++)
255 for (
int n = 0; n <
s->nb_samples; n++)
260 for (
int n = 0; n <
s->nb_samples; n++)
278 for (
int n = 0; n < 4; n++)
279 s->samples[0][n] =
s->samples[0][
s->nb_samples + n];
288 int ch, finished, fill, correlated, order;
300 if (block_type < 5 && block_type >= 0) {
307 switch (block_type) {
313 if (
s->nb_samples > 570
U) {
320 if ((
unsigned)
s->shift > 31) {
334 for (
int n = 0; n <
s->nb_samples; n++)
339 for (
int n = 0; n <
s->nb_samples; n++)
344 for (
int n = 0; n <
s->nb_samples; n++)
350 for (
int n = 0; n <
s->nb_samples; n++)
355 for (
int n = 0; n <
s->nb_samples; n++)
360 for (
int n = 0; n <
s->nb_samples; n++)
368 for (
int o = 0; o < order; o++)
370 for (
int n = 0; n <
s->nb_samples; n++) {
373 for (
int o = 0; o < order; o++)
374 sum +=
s->filter[ch][o] * (
unsigned)
samples[n + 70 - o - 1];
394 for (
int n = 0; n < 70; n++)
395 s->samples[0][n] =
s->samples[0][
s->nb_samples + n];
405 s->ac_high = 0xffff
u;
408 s->freq_range =
s->freqs[256];
416 return ((
s->freq_range - 1) + (
s->ac_value -
s->ac_low) * (
unsigned)
s->freq_range) /
417 ((
s->ac_high -
s->ac_low) + 1
U);
424 while (prob < s->freqs[idx])
427 s->range_high =
s->freqs[idx + 1];
428 s->range_low =
s->freqs[idx];
437 if (
s->ac_high <
s->ac_low)
440 range = (
s->ac_high -
s->ac_low) + 1;
441 s->ac_high = (
range * (unsigned)
s->range_high) /
s->freq_range +
s->ac_low - 1;
442 s->ac_low += (
range * (unsigned)
s->range_low) /
s->freq_range;
444 if (
s->ac_high <
s->ac_low)
448 if ((
s->ac_high & 0x8000) != (
s->ac_low & 0x8000)) {
449 if (((
s->ac_low & 0x4000) == 0) || ((
s->ac_high & 0x4000) != 0))
451 s->ac_value ^= 0x4000;
453 s->ac_high |= 0x4000;
456 s->ac_low =
s->ac_low * 2;
457 s->ac_high =
s->ac_high * 2 | 1;
458 if (
s->ac_high <
s->ac_low)
467 if (
s->ac_low >
s->ac_value ||
s->ac_high <
s->ac_value)
478 memset(
s->freqs, 0,
sizeof(
s->freqs));
480 for (
int n = 0; n < 256; n++)
481 s->freqs[n+1] =
s->model[n] +
s->freqs[n];
490 memset(
s->model, 0,
sizeof(
s->model));
496 while (start <= end) {
520 int ch, finished, fill, correlated, order = 0;
526 int *ac_pred =
s->ac_pred;
527 int *ac_out =
s->ac_out;
533 memset(
s->ac_out, 0,
sizeof(
s->ac_out));
538 if (block_type >= 0 && block_type <= 7) {
545 if (block_type <= 2 || block_type == 6 || block_type == 13 ||
546 block_type == 14 || block_type == 15 || block_type == 19) {
550 for (
int o = 0; o < order; o++)
554 if (block_type >= 0 && block_type <= 7) {
555 for (
int n = 0; n <
s->nb_samples; n++)
558 for (
int n = 0; n <
s->nb_samples; n++)
562 if (block_type >= 13 && block_type <= 20) {
563 const int ac_size =
get_bits(gb, 12);
581 for (
int n = 0; n <
s->nb_samples; n++) {
584 ac_out[n] = ac - 0x80;
595 switch (block_type) {
601 if (
s->nb_samples > 570
U) {
608 if ((
unsigned)
s->shift > 31) {
622 for (
int n = 0; n <
s->nb_samples; n++)
627 for (
int n = 0; n <
s->nb_samples; n++)
633 for (
int n = 0; n <
s->nb_samples; n++)
639 for (
int n = 0; n < 70; n++) {
644 for (
int n = 0; n <
s->nb_samples; n++) {
647 for (
int o = 0; o < order; o++)
648 sum +=
s->filter[ch][o] * (
unsigned)
samples[n + 70 - o - 1];
650 samples[n + 70] += ac_out[n] + (unsigned)(sum >> 4);
653 for (
int n = 0; n < 70; n++)
656 for (
int n = 0; n <
s->nb_samples; n++)
663 for (
int n = 0; n <
s->nb_samples; n++)
669 for (
int n = 0; n <
s->nb_samples; n++)
675 for (
int n = 0; n <
s->nb_samples; n++)
681 for (
int n = 0; n < 70; n++) {
686 for (
int n = 0; n <
s->nb_samples; n++) {
689 for (
int o = 0; o < order; o++)
690 sum +=
s->filter[ch][o] * (
unsigned)
samples[n + 70 - o - 1];
692 samples[n + 70] += ac_out[n] + (unsigned)(sum >> 4);
695 for (
int n = 0; n < 70; n++)
698 for (
int n = 0; n <
s->nb_samples; n++)
705 for (
int n = 0; n < 70; n++) {
710 for (
int n = 0; n <
s->nb_samples; n++) {
713 for (
int o = 0; o < order; o++)
714 sum +=
s->filter[ch][o] * (
unsigned)
samples[n + 70 - o - 1];
716 samples[n + 70] += (unsigned)ac_out[n] + (sum >> 4);
719 for (
int n = 0; n < 70; n++)
722 for (
int n = 0; n <
s->nb_samples; n++)
729 for (
int n = 0; n <
s->nb_samples; n++) {
732 for (
int o = 0; o < order; o++)
733 sum +=
s->filter[ch][o] * (
unsigned)
samples[n + 70 - o - 1];
735 samples[n + 70] += (unsigned)ac_out[n] + (sum >> 4);
753 for (
int n = 0; n < 70; n++)
754 s->samples[0][n] =
s->samples[0][
s->nb_samples + n];
765 int buf_size, input_buf_size;
769 if ((!
pkt->
size && !
s->bitstream_size) ||
s->nb_samples == 0 ||
s->eof) {
774 buf_size =
FFMIN(
pkt->
size,
s->max_framesize -
s->bitstream_size);
775 input_buf_size = buf_size;
777 memmove(
s->bitstream, &
s->bitstream[
s->bitstream_index],
s->bitstream_size);
778 s->bitstream_index = 0;
781 memcpy(&
s->bitstream[
s->bitstream_index +
s->bitstream_size],
pkt->
data, buf_size);
782 buf = &
s->bitstream[
s->bitstream_index];
783 buf_size +=
s->bitstream_size;
784 s->bitstream_size = buf_size;
785 if (buf_size < s->max_framesize &&
pkt->
data) {
787 return input_buf_size;
795 case MKTAG(
'0',
'C',
'P',
'Y'):
798 case MKTAG(
'1',
'D',
'I',
'F'):
801 case MKTAG(
'2',
'S',
'L',
'P'):
802 case MKTAG(
'3',
'N',
'L',
'P'):
803 case MKTAG(
'4',
'A',
'L',
'P'):
806 case MKTAG(
'5',
'E',
'L',
'P'):
821 s->bitstream_size = 0;
822 s->bitstream_index = 0;
828 frame->nb_samples =
s->nb_samples;
835 uint8_t *
dst = (uint8_t *)
frame->extended_data[ch];
836 const int *
src =
s->samples[ch] +
s->offset;
838 for (
int n = 0; n <
frame->nb_samples; n++)
839 dst[n] =
src[n] * (1
U <<
s->shift) + 0x80
U;
844 int16_t *
dst = (int16_t *)
frame->extended_data[ch];
845 const int *
src =
s->samples[ch] +
s->offset;
847 for (
int n = 0; n <
frame->nb_samples; n++)
855 if (
s->bitstream_size) {
856 s->bitstream_index += n;
857 s->bitstream_size -= n;
858 return input_buf_size;
869 s->bitstream_size = 0;
885 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)
#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.
int(* init)(AVBSFContext *ctx)
#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)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
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.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
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)
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 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)