51 int bufsize,
int *header_size,
int *
coeff)
67 if (buf[4] != 3 || buf[5] != 18 || buf[6] != 4) {
105 int ret, header_size;
115 c->header_parsed = 1;
131 const uint8_t *in,
int ch)
161 int *got_frame_ptr,
AVPacket *avpkt)
163 int buf_size = avpkt->
size;
167 const uint8_t *buf = avpkt->
data;
168 const uint8_t *buf_end = buf + avpkt->
size;
169 int num_blocks, ch, ret;
170 size_t new_extradata_size;
171 uint8_t *new_extradata;
174 &new_extradata_size);
175 if (new_extradata && new_extradata_size > 0) {
176 int old_channels =
c->channels;
179 new_extradata_size, &header_size,
186 c->header_parsed = 1;
187 if (old_channels !=
c->channels)
188 memset(
c->prev, 0,
sizeof(
c->prev));
197 if (!
c->header_parsed && buf_size >= 2 &&
AV_RB16(buf) == 0x8000) {
205 c->header_parsed = 1;
206 if (buf_size < header_size)
209 buf_size -= header_size;
211 if (!
c->header_parsed)
215 num_blocks = buf_size / (
BLOCK_SIZE *
c->channels);
219 if (!num_blocks || buf_size % (
BLOCK_SIZE *
c->channels)) {
220 if (buf_size >= 4 && (
AV_RB16(buf) & 0x8000)) {
232 samples = (int16_t **)
frame->extended_data;
235 while (num_blocks--) {
236 for (ch = 0; ch <
c->channels; ch++) {
249 frame->nb_samples = samples_offset;
252 return buf - avpkt->
data;
258 memset(
c->prev, 0,
sizeof(
c->prev));
263 .p.name =
"adpcm_adx",
void ff_adx_calculate_coeffs(int cutoff, int sample_rate, int bits, int *coeff)
Calculate LPC coefficients based on cutoff frequency and sample rate.
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
bitstream reader API header.
static int get_sbits(GetBitContext *s, int n)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static av_cold void adx_decode_flush(AVCodecContext *avctx)
static int adx_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
const FFCodec ff_adpcm_adx_decoder
static int adx_decode_header(AVCodecContext *avctx, const uint8_t *buf, int bufsize, int *header_size, int *coeff)
Decode ADX stream header.
static int adx_decode(ADXContext *c, int16_t *out, int offset, const uint8_t *in, int ch)
Decode 32 samples from 18 bytes.
static av_cold int adx_decode_init(AVCodecContext *avctx)
Macro definitions for various function/variable attributes.
enum AVChannelOrder order
Channel order used in this layout.
int nb_channels
Number of channels in this layout.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int64_t bit_rate
the average bitrate
int sample_rate
samples per second
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
#define avpriv_request_sample(...)
static const double coeff[2][5]