56 s->bitstream_size = 0;
58 for (
int ch = 0; ch < 2; ch++) {
94 s->max_framesize = 1024;
131 int ret, n, buf_size, input_buf_size;
135 if (!
pkt->size &&
s->bitstream_size <= 0) {
140 buf_size =
pkt->size;
141 input_buf_size = buf_size;
143 if ((
int64_t)
s->bitstream_size + buf_size > INT_MAX / (16 * 8))
146 if (
s->bitstream_index > 0 &&
s->bitstream_size > 0) {
147 memmove(
s->bitstream, &
s->bitstream[
s->bitstream_index],
s->bitstream_size);
148 s->bitstream_index = 0;
151 if (
s->bitstream_index +
s->bitstream_size + buf_size >
s->max_framesize) {
155 sizeof(*
s->bitstream));
158 s->max_framesize =
s->bitstream_index +
s->bitstream_size + buf_size;
161 memcpy(&
s->bitstream[
s->bitstream_index +
s->bitstream_size],
pkt->data, buf_size);
162 buf = &
s->bitstream[
s->bitstream_index];
163 buf_size +=
s->bitstream_size;
164 s->bitstream_size = buf_size;
167 frame->nb_samples =
s->bitstream_size * 16 * 8;
178 for (
int ch =
s->cur_ch; ch < avctx->ch_layout.nb_channels; ch++) {
180 int16_t *dst16 = (int16_t *)
c->block;
181 uint8_t *dst8 = (uint8_t *)
c->block;
184 samples[0] = &
c->block[0];
194 if (
c->block_length <= 0)
197 if (
c->bit_length < 0 ||
198 c->bit_length > 17) {
200 s->bitstream_index = 0;
201 s->bitstream_size = 0;
215 for (
int i = 0;
i <
c->block_length;
i++) {
241 nb_samples =
frame->nb_samples;
245 frame->nb_samples = nb_samples;
247 void *samples[1] = {
frame->extended_data[ch] };
254 if (nb_samples > 0 ||
pkt->size)
257 if (
s->bitstream_size > 0) {
258 s->bitstream_index += n;
259 s->bitstream_size -= n;
260 return input_buf_size;
static double val(void *priv, double ch)
const FFCodec ff_apac_decoder
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
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 unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_bits_left(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
int av_audio_fifo_write(AVAudioFifo *af, void *const *data, int nb_samples)
Write data to an AVAudioFifo.
int av_audio_fifo_read(AVAudioFifo *af, void *const *data, int nb_samples)
Read data from an AVAudioFifo.
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_U8P
unsigned 8 bits, planar
static av_cold int apac_close(AVCodecContext *avctx)
static int get_code(ChContext *c, GetBitContext *gb)
static av_cold int apac_init(AVCodecContext *avctx)
static int apac_decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *pkt)
Memory handling functions.
Context for an Audio FIFO Buffer.
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
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
#define av_realloc_f(p, o, n)