libavcodec/adpcm.c File Reference

ADPCM codecs. More...

#include "avcodec.h"
#include "bitstream.h"
#include "bytestream.h"

Go to the source code of this file.

Data Structures

struct  ADPCMChannelStatus
struct  ADPCMContext

Defines

#define BLKSIZE   1024
#define DK3_GET_NEXT_NIBBLE()
#define ADPCM_ENCODER(id, name, long_name_)
#define ADPCM_DECODER(id, name, long_name_)
#define ADPCM_CODEC(id, name, long_name_)   ADPCM_ENCODER(id,name,long_name_) ADPCM_DECODER(id,name,long_name_)

Functions

static av_cold int adpcm_decode_init (AVCodecContext *avctx)
static short adpcm_ima_expand_nibble (ADPCMChannelStatus *c, char nibble, int shift)
static short adpcm_ms_expand_nibble (ADPCMChannelStatus *c, char nibble)
static short adpcm_ct_expand_nibble (ADPCMChannelStatus *c, char nibble)
static short adpcm_sbpro_expand_nibble (ADPCMChannelStatus *c, char nibble, int size, int shift)
static short adpcm_yamaha_expand_nibble (ADPCMChannelStatus *c, unsigned char nibble)
static void xa_decode (short *out, const unsigned char *in, ADPCMChannelStatus *left, ADPCMChannelStatus *right, int inc)
static int adpcm_decode_frame (AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size)
 ADPCM_DECODER (CODEC_ID_ADPCM_4XM, adpcm_4xm,"ADPCM 4X Movie")
 ADPCM_DECODER (CODEC_ID_ADPCM_CT, adpcm_ct,"ADPCM Creative Technology")
 ADPCM_DECODER (CODEC_ID_ADPCM_EA, adpcm_ea,"ADPCM Electronic Arts")
 ADPCM_DECODER (CODEC_ID_ADPCM_EA_MAXIS_XA, adpcm_ea_maxis_xa,"ADPCM Electronic Arts Maxis CDROM XA")
 ADPCM_DECODER (CODEC_ID_ADPCM_EA_R1, adpcm_ea_r1,"ADPCM Electronic Arts R1")
 ADPCM_DECODER (CODEC_ID_ADPCM_EA_R2, adpcm_ea_r2,"ADPCM Electronic Arts R2")
 ADPCM_DECODER (CODEC_ID_ADPCM_EA_R3, adpcm_ea_r3,"ADPCM Electronic Arts R3")
 ADPCM_DECODER (CODEC_ID_ADPCM_EA_XAS, adpcm_ea_xas,"ADPCM Electronic Arts XAS")
 ADPCM_DECODER (CODEC_ID_ADPCM_IMA_AMV, adpcm_ima_amv,"ADPCM IMA AMV")
 ADPCM_DECODER (CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3,"ADPCM IMA Duck DK3")
 ADPCM_DECODER (CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4,"ADPCM IMA Duck DK4")
 ADPCM_DECODER (CODEC_ID_ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs,"ADPCM IMA Electronic Arts EACS")
 ADPCM_DECODER (CODEC_ID_ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead,"ADPCM IMA Electronic Arts SEAD")
 ADPCM_DECODER (CODEC_ID_ADPCM_IMA_ISS, adpcm_ima_iss,"ADPCM IMA Funcom ISS")
 ADPCM_CODEC (CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt,"ADPCM IMA QuickTime")
 ADPCM_DECODER (CODEC_ID_ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg,"ADPCM IMA Loki SDL MJPEG")
 ADPCM_CODEC (CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav,"ADPCM IMA WAV")
 ADPCM_DECODER (CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws,"ADPCM IMA Westwood")
 ADPCM_CODEC (CODEC_ID_ADPCM_MS, adpcm_ms,"ADPCM Microsoft")
 ADPCM_DECODER (CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2,"ADPCM Sound Blaster Pro 2-bit")
 ADPCM_DECODER (CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3,"ADPCM Sound Blaster Pro 2.6-bit")
 ADPCM_DECODER (CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4,"ADPCM Sound Blaster Pro 4-bit")
 ADPCM_CODEC (CODEC_ID_ADPCM_SWF, adpcm_swf,"ADPCM Shockwave Flash")
 ADPCM_DECODER (CODEC_ID_ADPCM_THP, adpcm_thp,"ADPCM Nintendo Gamecube THP")
 ADPCM_DECODER (CODEC_ID_ADPCM_XA, adpcm_xa,"ADPCM CDROM XA")
 ADPCM_CODEC (CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha,"ADPCM Yamaha")

Variables

static const int index_table [16]
static const int step_table [89]
 This is the step table.
static const int AdaptationTable []
static const uint8_t AdaptCoeff1 []
static const int8_t AdaptCoeff2 []
static const int xa_adpcm_table [5][2]
static const int ea_adpcm_table []
static const int swf_index_tables [4][16]
static const int yamaha_indexscale []
static const int yamaha_difflookup []


Detailed Description

ADPCM codecs.

First version by Francois Revol (revol@free.fr) Fringe ADPCM codecs (e.g., DK3, DK4, Westwood) by Mike Melanson (melanson@pcisys.net) CD-ROM XA ADPCM codec by BERO EA ADPCM decoder by Robin Kay (komadori@myrealbox.com) EA ADPCM R1/R2/R3 decoder by Peter Ross (pross@xvid.org) EA IMA EACS decoder by Peter Ross (pross@xvid.org) EA IMA SEAD decoder by Peter Ross (pross@xvid.org) EA ADPCM XAS decoder by Peter Ross (pross@xvid.org) MAXIS EA ADPCM decoder by Robert Marston (rmarston@gmail.com) THP ADPCM decoder by Marco Gerards (mgerards@xs4all.nl)

Features and limitations:

Reference documents: http://www.pcisys.net/~melanson/codecs/simpleaudio.html http://www.geocities.com/SiliconValley/8682/aud3.txt http://openquicktime.sourceforge.net/plugins.htm XAnim sources (xa_codec.c) http://www.rasnaimaging.com/people/lapus/download.html http://www.cs.ucla.edu/~leec/mediabench/applications.html SoX source code http://home.sprynet.com/~cbagwell/sox.html

CD-ROM XA: http://ku-www.ss.titech.ac.jp/~yatsushi/xaadpcm.html vagpack & depack http://homepages.compuserve.de/bITmASTER32/psx-index.html readstr http://www.geocities.co.jp/Playtown/2004/

Definition in file adpcm.c.


Define Documentation

#define ADPCM_CODEC ( id,
name,
long_name_   )     ADPCM_ENCODER(id,name,long_name_) ADPCM_DECODER(id,name,long_name_)

Definition at line 1661 of file adpcm.c.

#define ADPCM_DECODER ( id,
name,
long_name_   ) 

Definition at line 1658 of file adpcm.c.

#define ADPCM_ENCODER ( id,
name,
long_name_   ) 

Definition at line 1641 of file adpcm.c.

#define BLKSIZE   1024

Definition at line 56 of file adpcm.c.

 
#define DK3_GET_NEXT_NIBBLE (  ) 

Value:

if (decode_top_nibble_next) \
    { \
        nibble = last_byte >> 4; \
        decode_top_nibble_next = 0; \
    } \
    else \
    { \
        last_byte = *src++; \
        if (src >= buf + buf_size) break; \
        nibble = last_byte & 0x0F; \
        decode_top_nibble_next = 1; \
    }

Definition at line 870 of file adpcm.c.

Referenced by adpcm_decode_frame().


Function Documentation

ADPCM_CODEC ( CODEC_ID_ADPCM_YAMAHA  ,
adpcm_yamaha  ,
"ADPCM Yamaha"   
)

ADPCM_CODEC ( CODEC_ID_ADPCM_SWF  ,
adpcm_swf  ,
"ADPCM Shockwave Flash"   
)

ADPCM_CODEC ( CODEC_ID_ADPCM_MS  ,
adpcm_ms  ,
"ADPCM Microsoft"   
)

ADPCM_CODEC ( CODEC_ID_ADPCM_IMA_WAV  ,
adpcm_ima_wav  ,
"ADPCM IMA WAV"   
)

ADPCM_CODEC ( CODEC_ID_ADPCM_IMA_QT  ,
adpcm_ima_qt  ,
"ADPCM IMA QuickTime"   
)

static short adpcm_ct_expand_nibble ( ADPCMChannelStatus c,
char  nibble 
) [inline, static]

Definition at line 748 of file adpcm.c.

Referenced by adpcm_decode_frame().

static int adpcm_decode_frame ( AVCodecContext avctx,
void *  data,
int *  data_size,
const uint8_t *  buf,
int  buf_size 
) [static]

Definition at line 884 of file adpcm.c.

static av_cold int adpcm_decode_init ( AVCodecContext avctx  )  [static]

Definition at line 667 of file adpcm.c.

ADPCM_DECODER ( CODEC_ID_ADPCM_XA  ,
adpcm_xa  ,
"ADPCM CDROM XA"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_THP  ,
adpcm_thp  ,
"ADPCM Nintendo Gamecube THP"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_SBPRO_4  ,
adpcm_sbpro_4  ,
"ADPCM Sound Blaster Pro 4-bit"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_SBPRO_3  ,
adpcm_sbpro_3  ,
"ADPCM Sound Blaster Pro 2.6-bit"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_SBPRO_2  ,
adpcm_sbpro_2  ,
"ADPCM Sound Blaster Pro 2-bit"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_IMA_WS  ,
adpcm_ima_ws  ,
"ADPCM IMA Westwood"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_IMA_SMJPEG  ,
adpcm_ima_smjpeg  ,
"ADPCM IMA Loki SDL MJPEG"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_IMA_ISS  ,
adpcm_ima_iss  ,
"ADPCM IMA Funcom ISS"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_IMA_EA_SEAD  ,
adpcm_ima_ea_sead  ,
"ADPCM IMA Electronic Arts SEAD"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_IMA_EA_EACS  ,
adpcm_ima_ea_eacs  ,
"ADPCM IMA Electronic Arts EACS"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_IMA_DK4  ,
adpcm_ima_dk4  ,
"ADPCM IMA Duck DK4"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_IMA_DK3  ,
adpcm_ima_dk3  ,
"ADPCM IMA Duck DK3"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_IMA_AMV  ,
adpcm_ima_amv  ,
"ADPCM IMA AMV"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_EA_XAS  ,
adpcm_ea_xas  ,
"ADPCM Electronic Arts XAS"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_EA_R3  ,
adpcm_ea_r3  ,
"ADPCM Electronic Arts R3"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_EA_R2  ,
adpcm_ea_r2  ,
"ADPCM Electronic Arts R2"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_EA_R1  ,
adpcm_ea_r1  ,
"ADPCM Electronic Arts R1"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_EA_MAXIS_XA  ,
adpcm_ea_maxis_xa  ,
"ADPCM Electronic Arts Maxis CDROM XA"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_EA  ,
adpcm_ea  ,
"ADPCM Electronic Arts"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_CT  ,
adpcm_ct  ,
"ADPCM Creative Technology"   
)

ADPCM_DECODER ( CODEC_ID_ADPCM_4XM  ,
adpcm_4xm  ,
"ADPCM 4X Movie"   
)

static short adpcm_ima_expand_nibble ( ADPCMChannelStatus c,
char  nibble,
int  shift 
) [inline, static]

Definition at line 706 of file adpcm.c.

Referenced by adpcm_decode_frame().

static short adpcm_ms_expand_nibble ( ADPCMChannelStatus c,
char  nibble 
) [inline, static]

Definition at line 733 of file adpcm.c.

Referenced by adpcm_decode_frame().

static short adpcm_sbpro_expand_nibble ( ADPCMChannelStatus c,
char  nibble,
int  size,
int  shift 
) [inline, static]

Definition at line 769 of file adpcm.c.

Referenced by adpcm_decode_frame().

static short adpcm_yamaha_expand_nibble ( ADPCMChannelStatus c,
unsigned char  nibble 
) [inline, static]

Definition at line 789 of file adpcm.c.

Referenced by adpcm_decode_frame().

static void xa_decode ( short *  out,
const unsigned char *  in,
ADPCMChannelStatus left,
ADPCMChannelStatus right,
int  inc 
) [static]

Definition at line 803 of file adpcm.c.

Referenced by adpcm_decode_frame().


Variable Documentation

const int AdaptationTable[] [static]

Initial value:

 {
        230, 230, 230, 230, 307, 409, 512, 614,
        768, 614, 512, 409, 307, 230, 230, 230
}

Definition at line 83 of file adpcm.c.

Referenced by adpcm_ct_expand_nibble(), and adpcm_ms_expand_nibble().

const uint8_t AdaptCoeff1[] [static]

Initial value:

 {
        64, 128, 0, 48, 60, 115, 98
}

Definition at line 88 of file adpcm.c.

Referenced by adpcm_decode_frame().

const int8_t AdaptCoeff2[] [static]

Initial value:

 {
        0, -64, 0, 16, 0, -52, -58
}

Definition at line 92 of file adpcm.c.

Referenced by adpcm_decode_frame().

const int ea_adpcm_table[] [static]

Initial value:

 {
    0, 240, 460, 392, 0, 0, -208, -220, 0, 1,
    3, 4, 7, 8, 10, 11, 0, -1, -3, -4
}

Definition at line 105 of file adpcm.c.

Referenced by adpcm_decode_frame().

const int index_table[16] [static]

Initial value:

 {
    -1, -1, -1, -1, 2, 4, 6, 8,
    -1, -1, -1, -1, 2, 4, 6, 8,
}

Definition at line 60 of file adpcm.c.

Referenced by adpcm_ima_expand_nibble().

const int step_table[89] [static]

Initial value:

 {
    7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
    19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
    50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
    130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
    337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
    876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
    2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
    5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
    15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
}
This is the step table.

Note that many programs use slight deviations from this table, but such deviations are negligible:

Definition at line 69 of file adpcm.c.

Referenced by adpcm_decode_frame(), and adpcm_ima_expand_nibble().

const int swf_index_tables[4][16] [static]

Initial value:

 {
     { -1, 2 },
     { -1, -1, 2, 4 },
     { -1, -1, -1, -1, 2, 4, 6, 8 },
     { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 }
}

Definition at line 111 of file adpcm.c.

Referenced by adpcm_decode_frame().

const int xa_adpcm_table[5][2] [static]

Initial value:

 {
   {   0,   0 },
   {  60,   0 },
   { 115, -52 },
   {  98, -55 },
   { 122, -60 }
}

Definition at line 97 of file adpcm.c.

Referenced by xa_decode().

const int yamaha_difflookup[] [static]

Initial value:

 {
    1, 3, 5, 7, 9, 11, 13, 15,
    -1, -3, -5, -7, -9, -11, -13, -15
}

Definition at line 123 of file adpcm.c.

Referenced by adpcm_yamaha_expand_nibble().

const int yamaha_indexscale[] [static]

Initial value:

 {
    230, 230, 230, 230, 307, 409, 512, 614,
    230, 230, 230, 230, 307, 409, 512, 614
}

Definition at line 118 of file adpcm.c.

Referenced by adpcm_yamaha_expand_nibble().


Generated on Fri Oct 26 02:35:42 2012 for FFmpeg by  doxygen 1.5.8