adpcmenc.c File Reference

ADPCM encoders First version by Francois Revol (revol.nosp@m.@fre.nosp@m.e.fr) Fringe ADPCM codecs (e.g., DK3, DK4, Westwood) by Mike Melanson (melan.nosp@m.son@.nosp@m.pcisy.nosp@m.s.ne.nosp@m.t) More...

#include "avcodec.h"
#include "get_bits.h"
#include "put_bits.h"
#include "bytestream.h"
#include "adpcm.h"
#include "adpcm_data.h"

Go to the source code of this file.

Data Structures

struct  TrellisPath
 
struct  TrellisNode
 
struct  ADPCMEncodeContext
 

Macros

#define FREEZE_INTERVAL   128
 
#define STORE_NODE(NAME, STEP_INDEX)
 
#define LOOP_NODES(NAME, STEP_TABLE, STEP_INDEX)
 
#define ADPCM_ENCODER(id_, name_, long_name_)
 

Typedefs

typedef struct TrellisPath TrellisPath
 
typedef struct TrellisNode TrellisNode
 
typedef struct ADPCMEncodeContext ADPCMEncodeContext
 

Functions

static av_cold int adpcm_encode_init (AVCodecContext *avctx)
 
static av_cold int adpcm_encode_close (AVCodecContext *avctx)
 
static unsigned char adpcm_ima_compress_sample (ADPCMChannelStatus *c, short sample)
 
static unsigned char adpcm_ima_qt_compress_sample (ADPCMChannelStatus *c, short sample)
 
static unsigned char adpcm_ms_compress_sample (ADPCMChannelStatus *c, short sample)
 
static unsigned char adpcm_yamaha_compress_sample (ADPCMChannelStatus *c, short sample)
 
static void adpcm_compress_trellis (AVCodecContext *avctx, const short *samples, uint8_t *dst, ADPCMChannelStatus *c, int n)
 
static int adpcm_encode_frame (AVCodecContext *avctx, unsigned char *frame, int buf_size, void *data)
 
 ADPCM_ENCODER (CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt,"ADPCM IMA QuickTime")
 
 ADPCM_ENCODER (CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav,"ADPCM IMA WAV")
 
 ADPCM_ENCODER (CODEC_ID_ADPCM_MS, adpcm_ms,"ADPCM Microsoft")
 
 ADPCM_ENCODER (CODEC_ID_ADPCM_SWF, adpcm_swf,"ADPCM Shockwave Flash")
 
 ADPCM_ENCODER (CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha,"ADPCM Yamaha")
 

Detailed Description

ADPCM encoders First version by Francois Revol (revol.nosp@m.@fre.nosp@m.e.fr) Fringe ADPCM codecs (e.g., DK3, DK4, Westwood) by Mike Melanson (melan.nosp@m.son@.nosp@m.pcisy.nosp@m.s.ne.nosp@m.t)

See ADPCM decoder reference documents for codec information.

Definition in file adpcmenc.c.

Macro Definition Documentation

#define ADPCM_ENCODER (   id_,
  name_,
  long_name_ 
)
Value:
AVCodec ff_ ## name_ ## _encoder = { \
.name = #name_, \
.type = AVMEDIA_TYPE_AUDIO, \
.id = id_, \
.priv_data_size = sizeof(ADPCMEncodeContext), \
.encode = adpcm_encode_frame, \
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, \
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \
}
static av_cold int adpcm_encode_init(AVCodecContext *avctx)
Definition: adpcmenc.c:61
static av_cold int adpcm_encode_close(AVCodecContext *avctx)
Definition: adpcmenc.c:150
signed 16 bits
Definition: samplefmt.h:30
AVCodec.
Definition: avcodec.h:3189
static int init(AVCodecParserContext *s)
Definition: h264_parser.c:336
static int adpcm_encode_frame(AVCodecContext *avctx, unsigned char *frame, int buf_size, void *data)
Definition: adpcmenc.c:466
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:191
const char * name
Name of the codec implementation.
Definition: avcodec.h:3196
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:327
AVSampleFormat
all in native-endian format
Definition: samplefmt.h:27
struct ADPCMEncodeContext ADPCMEncodeContext

Definition at line 698 of file adpcmenc.c.

#define FREEZE_INTERVAL   128

Definition at line 59 of file adpcmenc.c.

Referenced by adpcm_compress_trellis(), and adpcm_encode_init().

#define LOOP_NODES (   NAME,
  STEP_TABLE,
  STEP_INDEX 
)
Value:
const int predictor = nodes[j]->sample1;\
const int div = (sample - predictor) * 4 / STEP_TABLE;\
int nmin = av_clip(div - range, -7, 6);\
int nmax = av_clip(div + range, -6, 7);\
if (nmin <= 0)\
nmin--; /* distinguish -0 from +0 */\
if (nmax < 0)\
nmax--;\
for (nidx = nmin; nidx <= nmax; nidx++) {\
const int nibble = nidx < 0 ? 7 - nidx : nidx;\
int dec_sample = predictor +\
(STEP_TABLE *\
STORE_NODE(NAME, STEP_INDEX);\
}
#define STORE_NODE(NAME, STEP_INDEX)
const int8_t ff_adpcm_yamaha_difflookup[]
Definition: adpcm_data.c:75
for(j=16;j >0;--j)

Referenced by adpcm_compress_trellis().

#define STORE_NODE (   NAME,
  STEP_INDEX 
)

Referenced by adpcm_compress_trellis().

Typedef Documentation

typedef struct TrellisNode TrellisNode
typedef struct TrellisPath TrellisPath

Function Documentation

static void adpcm_compress_trellis ( AVCodecContext avctx,
const short *  samples,
uint8_t *  dst,
ADPCMChannelStatus c,
int  n 
)
static

Definition at line 261 of file adpcmenc.c.

Referenced by adpcm_encode_frame().

static av_cold int adpcm_encode_close ( AVCodecContext avctx)
static

Definition at line 150 of file adpcmenc.c.

static int adpcm_encode_frame ( AVCodecContext avctx,
unsigned char *  frame,
int  buf_size,
void data 
)
static

Definition at line 466 of file adpcmenc.c.

static av_cold int adpcm_encode_init ( AVCodecContext avctx)
static

Definition at line 61 of file adpcmenc.c.

ADPCM_ENCODER ( CODEC_ID_ADPCM_IMA_QT  ,
adpcm_ima_qt  ,
"ADPCM IMA QuickTime"   
)
ADPCM_ENCODER ( CODEC_ID_ADPCM_IMA_WAV  ,
adpcm_ima_wav  ,
"ADPCM IMA WAV"   
)
ADPCM_ENCODER ( CODEC_ID_ADPCM_MS  ,
adpcm_ms  ,
"ADPCM Microsoft"   
)
ADPCM_ENCODER ( CODEC_ID_ADPCM_SWF  ,
adpcm_swf  ,
"ADPCM Shockwave Flash"   
)
ADPCM_ENCODER ( CODEC_ID_ADPCM_YAMAHA  ,
adpcm_yamaha  ,
"ADPCM Yamaha"   
)
static unsigned char adpcm_ima_compress_sample ( ADPCMChannelStatus c,
short  sample 
)
inlinestatic

Definition at line 163 of file adpcmenc.c.

Referenced by adpcm_encode_frame().

static unsigned char adpcm_ima_qt_compress_sample ( ADPCMChannelStatus c,
short  sample 
)
inlinestatic

Definition at line 176 of file adpcmenc.c.

Referenced by adpcm_encode_frame().

static unsigned char adpcm_ms_compress_sample ( ADPCMChannelStatus c,
short  sample 
)
inlinestatic

Definition at line 210 of file adpcmenc.c.

Referenced by adpcm_encode_frame().

static unsigned char adpcm_yamaha_compress_sample ( ADPCMChannelStatus c,
short  sample 
)
inlinestatic

Definition at line 239 of file adpcmenc.c.

Referenced by adpcm_encode_frame().