Go to the documentation of this file.
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) {
141 input_buf_size = buf_size;
143 if (
s->bitstream_index > 0 &&
s->bitstream_size > 0) {
144 memmove(
s->bitstream, &
s->bitstream[
s->bitstream_index],
s->bitstream_size);
145 s->bitstream_index = 0;
148 if (
s->bitstream_index +
s->bitstream_size + buf_size >
s->max_framesize) {
152 sizeof(*
s->bitstream));
155 s->max_framesize =
s->bitstream_index +
s->bitstream_size + buf_size;
158 memcpy(&
s->bitstream[
s->bitstream_index +
s->bitstream_size],
pkt->
data, buf_size);
159 buf = &
s->bitstream[
s->bitstream_index];
160 buf_size +=
s->bitstream_size;
161 s->bitstream_size = buf_size;
164 frame->nb_samples =
s->bitstream_size * 16 * 8;
175 for (
int ch =
s->cur_ch; ch < avctx->ch_layout.nb_channels; ch++) {
177 int16_t *dst16 = (int16_t *)
c->block;
178 uint8_t *dst8 = (uint8_t *)
c->block;
191 if (
c->block_length <= 0)
194 if (
c->bit_length < 0 ||
195 c->bit_length > 17) {
197 s->bitstream_index = 0;
198 s->bitstream_size = 0;
212 for (
int i = 0;
i <
c->block_length;
i++) {
238 nb_samples =
frame->nb_samples;
242 frame->nb_samples = nb_samples;
251 if (nb_samples > 0 ||
pkt->
size)
254 if (
s->bitstream_size > 0) {
255 s->bitstream_index += n;
256 s->bitstream_size -= n;
257 return input_buf_size;
273 AV_CODEC_CAP_SUBFRAMES |
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int av_audio_fifo_write(AVAudioFifo *af, void *const *data, int nb_samples)
Write data to an AVAudioFifo.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_bits_count(const GetBitContext *s)
This structure describes decoded (raw) audio or video data.
int nb_channels
Number of channels in this layout.
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Context for an Audio FIFO Buffer.
AVCodec p
The public AVCodec.
AVChannelLayout ch_layout
Audio channel layout.
static double val(void *priv, double ch)
static int get_code(ChContext *c, GetBitContext *gb)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define av_realloc_f(p, o, n)
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
static unsigned int get_bits1(GetBitContext *s)
static av_cold int apac_init(AVCodecContext *avctx)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
@ AV_SAMPLE_FMT_U8P
unsigned 8 bits, planar
enum AVSampleFormat sample_fmt
audio sample format
int av_audio_fifo_read(AVAudioFifo *af, void *const *data, int nb_samples)
Read data from an AVAudioFifo.
const FFCodec ff_apac_decoder
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define i(width, name, range_min, range_max)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
AVSampleFormat
Audio sample formats.
const char * name
Name of the codec implementation.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define AV_INPUT_BUFFER_PADDING_SIZE
main external API structure.
static av_cold int apac_close(AVCodecContext *avctx)
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Filter the word “frame” indicates either a video frame or a group of audio samples
This structure stores compressed data.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int apac_decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *pkt)