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 64 #define V2LPCQOFFSET (1 << LPCQUANT) 72 #define FN_BLOCKSIZE 5 81 #define VERBATIM_CKSIZE_SIZE 5 82 #define VERBATIM_BYTE_SIZE 8 83 #define CANONICAL_HEADER_SIZE 44 131 for (chan = 0; chan < s->
channels; chan++) {
138 "s->blocksize + s->nwrap too large\n");
150 for (i = 0; i < s->
nwrap; i++)
204 for (chan = 0; chan < s->
channels; chan++)
205 for (i = 0; i < nblock; i++)
206 s->
offset[chan][i] = mean;
221 if (bytestream2_get_le32(&gb) !=
MKTAG(
'F',
'O',
'R',
'M')) {
228 tag = bytestream2_get_le32(&gb);
229 if (tag !=
MKTAG(
'A',
'I',
'F',
'F') &&
230 tag !=
MKTAG(
'A',
'I',
'F',
'C')) {
235 while (bytestream2_get_le32(&gb) !=
MKTAG(
'C',
'O',
'M',
'M')) {
236 len = bytestream2_get_be32(&gb);
243 len = bytestream2_get_be32(&gb);
251 bps = bytestream2_get_be16(&gb);
254 s->
swap = tag ==
MKTAG(
'A',
'I',
'F',
'C');
256 if (bps != 16 && bps != 8) {
261 exp = bytestream2_get_be16(&gb) - 16383 - 63;
262 val = bytestream2_get_be64(&gb);
263 if (exp < -63 || exp > 63) {
270 avctx->
sample_rate = (val + (1ULL<<(-exp-1))) >> -exp;
287 if (bytestream2_get_le32(&gb) !=
MKTAG(
'R',
'I',
'F',
'F')) {
294 if (bytestream2_get_le32(&gb) !=
MKTAG(
'W',
'A',
'V',
'E')) {
299 while (bytestream2_get_le32(&gb) !=
MKTAG(
'f',
'm',
't',
' ')) {
300 len = bytestream2_get_le32(&gb);
307 len = bytestream2_get_le32(&gb);
314 wave_format = bytestream2_get_le16(&gb);
316 switch (wave_format) {
328 bps = bytestream2_get_le16(&gb);
331 if (bps != 16 && bps != 8) {
351 int residual_size,
int32_t coffset)
353 int pred_order, sum, qshift, init_sum,
i, j;
359 if ((
unsigned)pred_order > s->
nwrap) {
365 for (i = 0; i < pred_order; i++)
383 if (command ==
FN_QLPC && coffset)
384 for (i = -pred_order; i < 0; i++)
385 s->
decoded[channel][i] -= (
unsigned)coffset;
391 for (j = 0; j < pred_order; j++)
394 (unsigned)(sum >> qshift);
398 if (command ==
FN_QLPC && coffset)
400 s->
decoded[channel][i] += (
unsigned)coffset;
441 "invalid or unsupported block size: %d\n",
448 if (maxnlpc > 1024
U) {
477 "missing verbatim section at beginning of stream\n");
521 int *got_frame_ptr,
AVPacket *avpkt)
525 int buf_size = avpkt->
size;
527 int i, input_buf_size = 0;
547 input_buf_size = buf_size;
566 return input_buf_size;
648 "Increasing block size");
653 "block size: %d\n", blocksize);
667 int residual_size = 0;
678 if (residual_size > 30
U) {
691 coffset = sum / s->
nmean;
702 residual_size, coffset)) < 0)
722 for (i = -s->
nwrap; i < 0; i++)
733 int16_t *samples_s16;
741 for (chan = 0; chan < s->
channels; chan++) {
781 return input_buf_size;
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
void(* bswap16_buf)(uint16_t *dst, const uint16_t *src, int len)
ptrdiff_t const GLvoid * data
#define VERBATIM_CKSIZE_SIZE
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int init_offset(ShortenContext *s)
static av_cold int init(AVCodecContext *avctx)
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)
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
#define FF_ARRAY_ELEMS(a)
static int finish_frame(AVCodecContext *avctx, AVFrame *pict)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
AVCodec ff_shorten_decoder
static av_cold int shorten_decode_init(AVCodecContext *avctx)
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
enum AVSampleFormat sample_fmt
audio sample format
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
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.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static av_unused const uint8_t * skip_bytes(CABACContext *c, int n)
Skip n bytes and reset the decoder.
int32_t * decoded_base[MAX_CHANNELS]
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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 int decode_aiff_header(AVCodecContext *avctx, const uint8_t *header, int header_size)
const char * name
Name of the codec implementation.
static float mean(const float *input, int size)
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array through a pointer to a pointer.
static int allocate_buffers(ShortenContext *s)
static void fix_bitshift(ShortenContext *s, int32_t *buffer)
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 VERBATIM_BYTE_SIZE
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AV_LOG_INFO
Standard information.
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
int sample_rate
samples per second
uint8_t header[OUT_BUFFER_SIZE]
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define CANONICAL_HEADER_SIZE
main external API structure.
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static av_cold int shorten_decode_close(AVCodecContext *avctx)
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 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.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
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.
channel
Use these values when setting the channel map with ebur128_set_channel().
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
int32_t * offset[MAX_CHANNELS]
int channels
number of audio channels
static enum AVSampleFormat sample_fmts[]
static const uint8_t is_audio_command[10]
indicates if the FN_* command is audio or non-audio
static int read_header(ShortenContext *s)
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
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).
#define MKTAG(a, b, c, d)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
static double val(void *priv, double ch)
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators...
static int get_sr_golomb_shorten(GetBitContext *gb, int k)
read signed golomb rice code (shorten).