FFmpeg
Data Structures | Macros | Functions | Variables
shorten.c File Reference
#include <limits.h>
#include "libavutil/mem.h"
#include "avcodec.h"
#include "bswapdsp.h"
#include "bytestream.h"
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"
#include "golomb.h"

Go to the source code of this file.

Data Structures

struct  ShortenContext
 

Macros

#define MAX_CHANNELS   8
 
#define MAX_BLOCKSIZE   65535
 
#define OUT_BUFFER_SIZE   16384
 
#define ULONGSIZE   2
 
#define WAVE_FORMAT_PCM   0x0001
 
#define DEFAULT_BLOCK_SIZE   256
 
#define TYPESIZE   4
 
#define CHANSIZE   0
 
#define LPCQSIZE   2
 
#define ENERGYSIZE   3
 
#define BITSHIFTSIZE   2
 
#define TYPE_S8   1
 
#define TYPE_U8   2
 
#define TYPE_S16HL   3
 
#define TYPE_U16HL   4
 
#define TYPE_S16LH   5
 
#define TYPE_U16LH   6
 
#define NWRAP   3
 
#define NSKIPSIZE   1
 
#define LPCQUANT   5
 
#define V2LPCQOFFSET   (1 << LPCQUANT)
 
#define FNSIZE   2
 
#define FN_DIFF0   0
 
#define FN_DIFF1   1
 
#define FN_DIFF2   2
 
#define FN_DIFF3   3
 
#define FN_QUIT   4
 
#define FN_BLOCKSIZE   5
 
#define FN_BITSHIFT   6
 
#define FN_QLPC   7
 
#define FN_ZERO   8
 
#define FN_VERBATIM   9
 
#define VERBATIM_CKSIZE_SIZE   5
 
#define VERBATIM_BYTE_SIZE   8
 
#define CANONICAL_HEADER_SIZE   44
 

Functions

static av_cold int shorten_decode_init (AVCodecContext *avctx)
 
static int allocate_buffers (ShortenContext *s)
 
static unsigned int get_uint (ShortenContext *s, int k)
 
static void fix_bitshift (ShortenContext *s, int32_t *buffer)
 
static int init_offset (ShortenContext *s)
 
static int decode_aiff_header (AVCodecContext *avctx, const uint8_t *header, int header_size)
 
static int decode_wave_header (AVCodecContext *avctx, const uint8_t *header, int header_size)
 
static int decode_subframe_lpc (ShortenContext *s, int command, int channel, int residual_size, int32_t coffset)
 
static int read_header (ShortenContext *s)
 
static int shorten_decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
 
static av_cold int shorten_decode_close (AVCodecContext *avctx)
 

Variables

static const uint8_t is_audio_command [10] = { 1, 1, 1, 1, 0, 0, 0, 1, 1, 0 }
 indicates if the FN_* command is audio or non-audio More...
 
static const int fixed_coeffs [][3]
 
const FFCodec ff_shorten_decoder
 

Detailed Description

Shorten decoder

Author
Jeff Muizelaar

Definition in file shorten.c.

Macro Definition Documentation

◆ MAX_CHANNELS

#define MAX_CHANNELS   8

Definition at line 38 of file shorten.c.

◆ MAX_BLOCKSIZE

#define MAX_BLOCKSIZE   65535

Definition at line 39 of file shorten.c.

◆ OUT_BUFFER_SIZE

#define OUT_BUFFER_SIZE   16384

Definition at line 41 of file shorten.c.

◆ ULONGSIZE

#define ULONGSIZE   2

Definition at line 43 of file shorten.c.

◆ WAVE_FORMAT_PCM

#define WAVE_FORMAT_PCM   0x0001

Definition at line 45 of file shorten.c.

◆ DEFAULT_BLOCK_SIZE

#define DEFAULT_BLOCK_SIZE   256

Definition at line 47 of file shorten.c.

◆ TYPESIZE

#define TYPESIZE   4

Definition at line 49 of file shorten.c.

◆ CHANSIZE

#define CHANSIZE   0

Definition at line 50 of file shorten.c.

◆ LPCQSIZE

#define LPCQSIZE   2

Definition at line 51 of file shorten.c.

◆ ENERGYSIZE

#define ENERGYSIZE   3

Definition at line 52 of file shorten.c.

◆ BITSHIFTSIZE

#define BITSHIFTSIZE   2

Definition at line 53 of file shorten.c.

◆ TYPE_S8

#define TYPE_S8   1

Definition at line 55 of file shorten.c.

◆ TYPE_U8

#define TYPE_U8   2

Definition at line 56 of file shorten.c.

◆ TYPE_S16HL

#define TYPE_S16HL   3

Definition at line 57 of file shorten.c.

◆ TYPE_U16HL

#define TYPE_U16HL   4

Definition at line 58 of file shorten.c.

◆ TYPE_S16LH

#define TYPE_S16LH   5

Definition at line 59 of file shorten.c.

◆ TYPE_U16LH

#define TYPE_U16LH   6

Definition at line 60 of file shorten.c.

◆ NWRAP

#define NWRAP   3

Definition at line 62 of file shorten.c.

◆ NSKIPSIZE

#define NSKIPSIZE   1

Definition at line 63 of file shorten.c.

◆ LPCQUANT

#define LPCQUANT   5

Definition at line 65 of file shorten.c.

◆ V2LPCQOFFSET

#define V2LPCQOFFSET   (1 << LPCQUANT)

Definition at line 66 of file shorten.c.

◆ FNSIZE

#define FNSIZE   2

Definition at line 68 of file shorten.c.

◆ FN_DIFF0

#define FN_DIFF0   0

Definition at line 69 of file shorten.c.

◆ FN_DIFF1

#define FN_DIFF1   1

Definition at line 70 of file shorten.c.

◆ FN_DIFF2

#define FN_DIFF2   2

Definition at line 71 of file shorten.c.

◆ FN_DIFF3

#define FN_DIFF3   3

Definition at line 72 of file shorten.c.

◆ FN_QUIT

#define FN_QUIT   4

Definition at line 73 of file shorten.c.

◆ FN_BLOCKSIZE

#define FN_BLOCKSIZE   5

Definition at line 74 of file shorten.c.

◆ FN_BITSHIFT

#define FN_BITSHIFT   6

Definition at line 75 of file shorten.c.

◆ FN_QLPC

#define FN_QLPC   7

Definition at line 76 of file shorten.c.

◆ FN_ZERO

#define FN_ZERO   8

Definition at line 77 of file shorten.c.

◆ FN_VERBATIM

#define FN_VERBATIM   9

Definition at line 78 of file shorten.c.

◆ VERBATIM_CKSIZE_SIZE

#define VERBATIM_CKSIZE_SIZE   5

Definition at line 83 of file shorten.c.

◆ VERBATIM_BYTE_SIZE

#define VERBATIM_BYTE_SIZE   8

Definition at line 84 of file shorten.c.

◆ CANONICAL_HEADER_SIZE

#define CANONICAL_HEADER_SIZE   44

Definition at line 85 of file shorten.c.

Function Documentation

◆ shorten_decode_init()

static av_cold int shorten_decode_init ( AVCodecContext avctx)
static

Definition at line 119 of file shorten.c.

◆ allocate_buffers()

static int allocate_buffers ( ShortenContext s)
static

Definition at line 129 of file shorten.c.

Referenced by read_header().

◆ get_uint()

static unsigned int get_uint ( ShortenContext s,
int  k 
)
inlinestatic

Definition at line 163 of file shorten.c.

Referenced by read_header(), and shorten_decode_frame().

◆ fix_bitshift()

static void fix_bitshift ( ShortenContext s,
int32_t buffer 
)
static

Definition at line 173 of file shorten.c.

Referenced by shorten_decode_frame().

◆ init_offset()

static int init_offset ( ShortenContext s)
static

Definition at line 186 of file shorten.c.

Referenced by read_header().

◆ decode_aiff_header()

static int decode_aiff_header ( AVCodecContext avctx,
const uint8_t *  header,
int  header_size 
)
static

Definition at line 212 of file shorten.c.

Referenced by read_header().

◆ decode_wave_header()

static int decode_wave_header ( AVCodecContext avctx,
const uint8_t *  header,
int  header_size 
)
static

Definition at line 280 of file shorten.c.

Referenced by read_header().

◆ decode_subframe_lpc()

static int decode_subframe_lpc ( ShortenContext s,
int  command,
int  channel,
int  residual_size,
int32_t  coffset 
)
static

Definition at line 352 of file shorten.c.

Referenced by shorten_decode_frame().

◆ read_header()

static int read_header ( ShortenContext s)
static

Definition at line 407 of file shorten.c.

Referenced by shorten_decode_frame().

◆ shorten_decode_frame()

static int shorten_decode_frame ( AVCodecContext avctx,
AVFrame frame,
int *  got_frame_ptr,
AVPacket avpkt 
)
static

Definition at line 526 of file shorten.c.

◆ shorten_decode_close()

static av_cold int shorten_decode_close ( AVCodecContext avctx)
static

Definition at line 793 of file shorten.c.

Variable Documentation

◆ is_audio_command

const uint8_t is_audio_command[10] = { 1, 1, 1, 1, 0, 0, 0, 1, 1, 0 }
static

indicates if the FN_* command is audio or non-audio

Definition at line 81 of file shorten.c.

Referenced by shorten_decode_frame().

◆ fixed_coeffs

const int fixed_coeffs[][3]
static
Initial value:
= {
{ 0, 0, 0 },
{ 1, 0, 0 },
{ 2, -1, 0 },
{ 3, -3, 1 }
}

Definition at line 345 of file shorten.c.

Referenced by decode_subframe_lpc().

◆ ff_shorten_decoder

const FFCodec ff_shorten_decoder
Initial value:
= {
.p.name = "shorten",
CODEC_LONG_NAME("Shorten"),
.p.type = AVMEDIA_TYPE_AUDIO,
.priv_data_size = sizeof(ShortenContext),
.p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
AV_CODEC_CAP_SUBFRAMES |
.p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
}

Definition at line 809 of file shorten.c.

shorten_decode_init
static av_cold int shorten_decode_init(AVCodecContext *avctx)
Definition: shorten.c:119
shorten_decode_frame
static int shorten_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition: shorten.c:526
ShortenContext
Definition: shorten.c:87
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:311
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
AV_CODEC_CAP_CHANNEL_CONF
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:106
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AV_SAMPLE_FMT_U8P
@ AV_SAMPLE_FMT_U8P
unsigned 8 bits, planar
Definition: samplefmt.h:63
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
AV_SAMPLE_FMT_S16P
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition: samplefmt.h:64
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
shorten_decode_close
static av_cold int shorten_decode_close(AVCodecContext *avctx)
Definition: shorten.c:793
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:76
AV_CODEC_ID_SHORTEN
@ AV_CODEC_ID_SHORTEN
Definition: codec_id.h:462