36 #define MAX_CHANNELS 8
37 #define MAX_BLOCKSIZE 65535
39 #define OUT_BUFFER_SIZE 16384
43 #define WAVE_FORMAT_PCM 0x0001
45 #define DEFAULT_BLOCK_SIZE 256
51 #define BITSHIFTSIZE 2
60 #define V2LPCQOFFSET (1 << LPCQUANT)
68 #define FN_BLOCKSIZE 5
77 #define VERBATIM_CKSIZE_SIZE 5
78 #define VERBATIM_BYTE_SIZE 8
79 #define CANONICAL_HEADER_SIZE 44
130 for (chan = 0; chan < s->
channels; chan++) {
138 "s->blocksize + s->nwrap too large\n");
146 s->
offset[chan] = tmp_ptr;
153 for (i = 0; i < s->
nwrap; i++)
198 for (chan = 0; chan < s->
channels; chan++)
199 for (i = 0; i < nblock; i++)
200 s->
offset[chan][i] = mean;
213 if (bytestream2_get_le32(&gb) !=
MKTAG(
'R',
'I',
'F',
'F')) {
220 if (bytestream2_get_le32(&gb) !=
MKTAG(
'W',
'A',
'V',
'E')) {
225 while (bytestream2_get_le32(&gb) !=
MKTAG(
'f',
'm',
't',
' ')) {
226 len = bytestream2_get_le32(&gb);
233 len = bytestream2_get_le32(&gb);
240 wave_format = bytestream2_get_le16(&gb);
242 switch (wave_format) {
272 for (ch = 0; ch < nchan; ch++) {
274 int16_t *out = samples[ch];
275 for (i = 0; i < blocksize; i++)
276 out[i] = av_clip_int16(in[i]);
288 int residual_size,
int32_t coffset)
290 int pred_order, sum, qshift, init_sum, i, j;
296 if (pred_order > s->
nwrap) {
302 for (i = 0; i < pred_order; i++)
309 pred_order = command;
320 if (command ==
FN_QLPC && coffset)
321 for (i = -pred_order; i < 0; i++)
322 s->
decoded[channel][i] -= coffset;
328 for (j = 0; j < pred_order; j++)
329 sum += coeffs[j] * s->
decoded[channel][i - j - 1];
335 if (command ==
FN_QLPC && coffset)
337 s->
decoded[channel][i] += coffset;
378 "invalid or unsupported block size: %d\n",
388 for (i = 0; i < skip_bytes; i++)
404 "missing verbatim section at beginning of stream\n");
431 int *got_frame_ptr,
AVPacket *avpkt)
434 int buf_size = avpkt->
size;
436 int i, input_buf_size = 0;
455 input_buf_size = buf_size;
472 if (buf_size < s->max_framesize && avpkt->
data) {
474 return input_buf_size;
528 "Increasing block size is not supported\n");
533 "block size: %d\n", blocksize);
549 int residual_size = 0;
564 coffset = s->
offset[channel][0];
568 sum += s->
offset[channel][i];
569 coffset = sum / s->
nmean;
580 residual_size, coffset)) < 0)
600 for (i = -s->
nwrap; i < 0; i++)
640 return input_buf_size;
static const int16_t coeffs[28]
This structure describes decoded (raw) audio or video data.
#define VERBATIM_CKSIZE_SIZE
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int init_offset(ShortenContext *s)
AVFrame * coded_frame
the picture in the bitstream
unsigned int allocated_bitstream_size
int32_t * decoded[MAX_CHANNELS]
static const int fixed_coeffs[][3]
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static int finish_frame(AVCodecContext *avctx, AVFrame *pict)
AVCodec ff_shorten_decoder
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static av_cold int shorten_decode_init(AVCodecContext *avctx)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
enum AVSampleFormat sample_fmt
audio sample format
static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header, int header_size)
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
#define MKTAG(a, b, c, d)
struct ShortenContext ShortenContext
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int32_t * decoded_base[MAX_CHANNELS]
static int init(AVCodecParserContext *s)
static int get_bits_left(GetBitContext *gb)
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given block if it is not large enough, otherwise do nothing.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static void output_buffer(int16_t **samples, int nchan, int blocksize, int32_t **buffer)
static int allocate_buffers(ShortenContext *s)
static void fix_bitshift(ShortenContext *s, int32_t *buffer)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
Get a buffer for a frame.
#define VERBATIM_BYTE_SIZE
int sample_rate
samples per second
uint8_t header[OUT_BUFFER_SIZE]
#define CANONICAL_HEADER_SIZE
main external API structure.
static void close(AVCodecParserContext *s)
static av_cold int shorten_decode_close(AVCodecContext *avctx)
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
static void skip_bits(GetBitContext *s, int n)
#define FF_ARRAY_ELEMS(a)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static int decode_subframe_lpc(ShortenContext *s, int command, int channel, int residual_size, int32_t coffset)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static unsigned int get_uint(ShortenContext *s, int k)
#define DEFAULT_BLOCK_SIZE
static int shorten_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
common internal api header.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
#define AVERROR_INVALIDDATA
AVSampleFormat
Audio Sample Formats.
#define AVERROR_PATCHWELCOME
int32_t * offset[MAX_CHANNELS]
int channels
number of audio channels
static const uint8_t is_audio_command[10]
indicates if the FN_* command is audio or non-audio
static int read_header(ShortenContext *s)
uint8_t ** extended_data
pointers to the data planes/channels.
static unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k)
read unsigned golomb rice code (shorten).
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
static int get_sr_golomb_shorten(GetBitContext *gb, int k)
read signed golomb rice code (shorten).
if(!(ptr_align%ac->ptr_align)&&samples_align >=aligned_len)