49 for (i = 0, j = 0; j < 32; i += channels, j++) {
63 if (max == 0 && min == 0) {
68 if (max / 7 > -min / 8)
80 put_sbits(&pb, 4, av_clip(data[i] / scale, -8, 7));
84 #define HEADER_SIZE 36
93 bytestream_put_be16(&buf, 0x8000);
95 bytestream_put_byte(&buf, 3);
97 bytestream_put_byte(&buf, 4);
98 bytestream_put_byte(&buf, avctx->
channels);
100 bytestream_put_be32(&buf, 0);
101 bytestream_put_be16(&buf, c->
cutoff);
102 bytestream_put_byte(&buf, 3);
103 bytestream_put_byte(&buf, 0);
104 bytestream_put_be32(&buf, 0);
105 bytestream_put_be32(&buf, 0);
106 bytestream_put_be16(&buf, 0);
138 int buf_size,
void *
data)
142 uint8_t *dst = frame;
155 if (buf_size < BLOCK_SIZE * avctx->channels) {
160 for (ch = 0; ch < avctx->
channels; ch++) {
static void put_sbits(PutBitContext *pb, int n, int32_t value)
AVFrame * coded_frame
the picture in the bitstream
static av_cold int adx_encode_close(AVCodecContext *avctx)
static void adx_encode(ADXContext *c, uint8_t *adx, const int16_t *wav, ADXChannelState *prev, int channels)
void ff_adx_calculate_coeffs(int cutoff, int sample_rate, int bits, int *coeff)
Calculate LPC coefficients based on cutoff frequency and sample rate.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int init(AVCodecParserContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
AVFrame * avcodec_alloc_frame(void)
Allocate an AVFrame and set its fields to default values.
AVCodec ff_adpcm_adx_encoder
int frame_size
Samples per packet, initialized when calling 'init'.
int sample_rate
samples per second
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t scale[4]
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
AVSampleFormat
all in native-endian format
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static av_cold int adx_encode_init(AVCodecContext *avctx)
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
static int adx_encode_header(AVCodecContext *avctx, uint8_t *buf, int bufsize)
int channels
number of audio channels
static int adx_encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, void *data)