ADPCM Codecs
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
adpcm_ffmpeg::EncoderADPCM_EA_RX Class Reference

EA R1/R2/R3 encoder. Packet: a 4 byte sample count, one 4 byte offset per channel (relative to the end of that table), then each channel's data in 28 sample blocks of 15 bytes (a header byte with the coefficient index in the high nibble and the shift in the low nibble, then 14 nibble bytes, high nibble first). R1 starts every channel from a 4 byte state stored in the data and does not keep state across packets. R2 and R3 keep the state in the decoder across packets. R3 is big-endian throughout. The 0xEE escape (raw samples) is never emitted; header 0xEE is skipped. More...

#include <ADPCMEncoder.h>

Inheritance diagram for adpcm_ffmpeg::EncoderADPCM_EA_RX:
Inheritance graph
[legend]
Collaboration diagram for adpcm_ffmpeg::EncoderADPCM_EA_RX:
Collaboration graph
[legend]

Public Member Functions

 EncoderADPCM_EA_RX (AVCodecID id)
 
bool begin (int sampleRate, int channels)
 
void end ()
 
AVPacket & encode (int16_t *data, size_t sampleCount)
 
virtual bool isTrellis ()
 
int blockAlign ()
 
AVCodecContext & ctx ()
 
void setCodecID (AVCodecID id)
 
AVCodecID codecID ()
 
void setFrameSize (int fs)
 
virtual void setBlockSize (int size)
 
int blockSize ()
 
int frameSize ()
 
int channels ()
 
bool isPlanar ()
 

Static Public Attributes

static const int FRAME_SIZE = 1008
 
static const int BLOCKS = FRAME_SIZE / 28
 
static const int BLOCK_BYTES = 15
 

Protected Member Functions

int adpcm_encode_init_impl ()
 
int adpcm_encode_frame_impl (AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 
int headerSize ()
 
int channelBytes ()
 
void encodeBlock (const int *x, int *cur, int *prev, uint8_t *out)
 
void encodeDSPSubframe (ADPCMChannelStatus *cs, const int16_t *in, int n, const int16_t *coef1, const int16_t *coef2, int npairs, uint8_t *nibbles_out, int &best_index, int &best_exp)
 
virtual int packetSize (const AVFrame *frame)
 
virtual int adpcm_encode_init ()
 
int adpcm_encode_close ()
 
uint8_t adpcm_ima_compress_sample (ADPCMChannelStatus *c, int16_t sample)
 
uint8_t adpcm_ima_quantize (ADPCMChannelStatus *cs, int target, int shift)
 
uint8_t adpcm_ima_qt_compress_sample (ADPCMChannelStatus *c, int16_t sample)
 
uint8_t adpcm_yamaha_compress_sample (ADPCMChannelStatus *c, int16_t sample)
 
virtual int adpcm_encode_frame (AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 
int av_get_bits_per_sample ()
 
int ff_get_encode_buffer (AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
 
int ff_get_buffer (AVCodecContext *avctx, AVFrame *frame, int flags)
 
void avpriv_request_sample (void *avc, const char *msg,...)
 

Static Protected Member Functions

static void put32 (uint8_t *p, uint32_t v, bool be)
 

Protected Attributes

AVCodecID variant_
 
AVPacket result
 
AVFrame frame
 
int16_t * extended_data [ADPCM_MAX_CHANNELS] = {0}
 
ADPCMVector< uint8_t > av_packet_data
 
ADPCMVector< ADPCMVector< int16_t > > frame_extended_data_vectors
 
int st
 
int pkt_size
 
int ret
 
const int16_t * samples
 
const int16_t *const * samples_p
 
uint8_t * dst
 
ADPCMEncodeContext * c
 
ADPCMEncodeContext * s
 
AVCodecContext avctx
 
ADPCMEncodeContext enc_ctx
 
ADPCMVector< AVSampleFormat > sample_formats {0}
 

Detailed Description

EA R1/R2/R3 encoder. Packet: a 4 byte sample count, one 4 byte offset per channel (relative to the end of that table), then each channel's data in 28 sample blocks of 15 bytes (a header byte with the coefficient index in the high nibble and the shift in the low nibble, then 14 nibble bytes, high nibble first). R1 starts every channel from a 4 byte state stored in the data and does not keep state across packets. R2 and R3 keep the state in the decoder across packets. R3 is big-endian throughout. The 0xEE escape (raw samples) is never emitted; header 0xEE is skipped.

Member Function Documentation

◆ adpcm_encode_frame_impl()

int adpcm_ffmpeg::EncoderADPCM_EA_RX::adpcm_encode_frame_impl ( AVPacket *  avpkt,
const AVFrame *  frame,
int *  got_packet_ptr 
)
inlineprotectedvirtual

◆ adpcm_encode_init_impl()

int adpcm_ffmpeg::EncoderADPCM_EA_RX::adpcm_encode_init_impl ( )
inlineprotectedvirtual

◆ adpcm_ima_quantize()

uint8_t adpcm_ffmpeg::ADPCMEncoder::adpcm_ima_quantize ( ADPCMChannelStatus *  cs,
int  target,
int  shift 
)
inlineprotectedinherited

Picks the IMA nibble closest to target and advances the state exactly as the decoder's adpcm_ima_expand_nibble(cs, nibble, shift) does.

◆ encodeDSPSubframe()

void adpcm_ffmpeg::ADPCMEncoder::encodeDSPSubframe ( ADPCMChannelStatus *  cs,
const int16_t *  in,
int  n,
const int16_t *  coef1,
const int16_t *  coef2,
int  npairs,
uint8_t *  nibbles_out,
int &  best_index,
int &  best_exp 
)
inlineprotectedinherited

Quantizes one subframe of n samples for the GameCube style DSP ADPCM family (AFC, THP). Each coefficient pair (coef1[i], coef2[i]) and scale exponent is tried, the one with the lowest error wins, and the history of cs is advanced to the values the decoder will reconstruct. Nibbles are written high nibble first, two per byte.

◆ packetSize()

virtual int adpcm_ffmpeg::ADPCMEncoder::packetSize ( const AVFrame *  frame)
inlineprotectedvirtualinherited

size of the packet produced for frame; codecs whose packets differ in size (e.g. a first packet with extra data) override this

Reimplemented in adpcm_ffmpeg::EncoderADPCM_SBPRO_X.


The documentation for this class was generated from the following file: