diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj
index 0bbe283bfb..7f006fb156 100644
--- a/Common/Common.vcxproj
+++ b/Common/Common.vcxproj
@@ -394,8 +394,6 @@
-
-
@@ -405,7 +403,6 @@
-
@@ -627,13 +624,11 @@
-
-
diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters
index 8905c36ed2..ceb388fa78 100644
--- a/Common/Common.vcxproj.filters
+++ b/Common/Common.vcxproj.filters
@@ -581,15 +581,9 @@
ext\at3_standalone
-
- ext\at3_standalone
-
ext\at3_standalone
-
- ext\at3_standalone
-
ext\at3_standalone
@@ -623,9 +617,6 @@
ext\at3_standalone
-
- ext\at3_standalone
-
ext\at3_standalone
@@ -1110,9 +1101,6 @@
ext\at3_standalone
-
- ext\at3_standalone
-
ext\at3_standalone
@@ -1128,9 +1116,6 @@
ext\at3_standalone
-
- ext\at3_standalone
-
ext\at3_standalone
diff --git a/Core/HW/Atrac3Standalone.cpp b/Core/HW/Atrac3Standalone.cpp
index ee4596ed1c..11be9105f4 100644
--- a/Core/HW/Atrac3Standalone.cpp
+++ b/Core/HW/Atrac3Standalone.cpp
@@ -26,13 +26,17 @@ public:
} else {
ctx_ = avcodec_alloc_context3(&ff_atrac3_decoder);
}
- frame_ = av_frame_alloc();
+ for (int i = 0; i < 2; i++) {
+ buffers_[i] = new float[4096];
+ }
}
~Atrac3Audio() {
avcodec_close(ctx_);
- av_frame_free(&frame_);
av_freep(&ctx_->extradata);
av_freep(&ctx_);
+ for (int i = 0; i < 2; i++) {
+ delete[] buffers_[i];
+ }
}
bool Decode(const uint8_t *inbuf, int inbytes, uint8_t *outbuf, int *outbytes) override {
@@ -57,27 +61,27 @@ public:
// We just call the decode function directly without going through the whole packet machinery.
int got_frame = 0;
int result;
+ int nb_samples = 0;
if (audioType_ == PSP_CODEC_AT3PLUS) {
- result = atrac3p_decode_frame(ctx_, frame_, &got_frame, inbuf, inbytes);
+ result = atrac3p_decode_frame(ctx_, buffers_, &nb_samples, &got_frame, inbuf, inbytes);
} else {
- result = atrac3_decode_frame(ctx_, frame_, &got_frame, inbuf, inbytes);
+ result = atrac3_decode_frame(ctx_, buffers_, &nb_samples, &got_frame, inbuf, inbytes);
}
if (result < 0) {
*outbytes = 0;
return false;
}
srcPos_ = result;
- outSamples_ = frame_->nb_samples;
- if (frame_->nb_samples > 0) {
- *outbytes = frame_->nb_samples * 2 * 2;
+ outSamples_ = nb_samples;
+ if (nb_samples > 0) {
+ *outbytes = nb_samples * 2 * 2;
// Convert frame to outbuf.
for (int channel = 0; channel < 2; channel++) {
- float **pointers = (float **)frame_->data;
int16_t *output = (int16_t *)outbuf;
- for (int i = 0; i < frame_->nb_samples; i++) {
- output[i * 2] = clamp16(pointers[0][i]);
- output[i * 2 + 1] = clamp16(pointers[1][i]);
+ for (int i = 0; i < nb_samples; i++) {
+ output[i * 2] = clamp16(buffers_[0][i]);
+ output[i * 2 + 1] = clamp16(buffers_[1][i]);
}
}
} else {
@@ -116,10 +120,10 @@ public:
private:
AVCodecContext* ctx_ = nullptr;
- AVFrame *frame_ = nullptr;
int outSamples_ = 0;
int srcPos_ = 0;
+ float *buffers_[2]{};
bool codecOpen_ = false;
diff --git a/ext/at3_standalone/at3_decoders.h b/ext/at3_standalone/at3_decoders.h
index ae48c4c331..4dc6d98329 100644
--- a/ext/at3_standalone/at3_decoders.h
+++ b/ext/at3_standalone/at3_decoders.h
@@ -9,8 +9,8 @@ extern "C" {
#include "avcodec.h"
- int atrac3_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const uint8_t *buf, int buf_size);
- int atrac3p_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const uint8_t *buf, int buf_size);
+ int atrac3_decode_frame(AVCodecContext *avctx, float *out_data[2], int *nb_samples, int *got_frame_ptr, const uint8_t *buf, int buf_size);
+ int atrac3p_decode_frame(AVCodecContext *avctx, float *out_data[2], int *nb_samples, int *got_frame_ptr, const uint8_t *buf, int buf_size);
extern AVCodec ff_atrac3p_decoder;
extern AVCodec ff_atrac3_decoder;
}
diff --git a/ext/at3_standalone/atrac3.c b/ext/at3_standalone/atrac3.c
index 8eaefed212..e40e2f47cc 100644
--- a/ext/at3_standalone/atrac3.c
+++ b/ext/at3_standalone/atrac3.c
@@ -730,7 +730,7 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
return 0;
}
-int atrac3_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const uint8_t *buf, int buf_size)
+int atrac3_decode_frame(AVCodecContext *avctx, float *out_data[2], int *nb_samples, int *got_frame_ptr, const uint8_t *buf, int buf_size)
{
ATRAC3Context *q = avctx->priv_data;
int ret;
@@ -743,9 +743,7 @@ int atrac3_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_pt
}
/* get output buffer */
- frame->nb_samples = SAMPLES_PER_FRAME;
- if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
- return ret;
+ *nb_samples = SAMPLES_PER_FRAME;
/* Check if we need to descramble and what buffer to pass on. */
if (q->scrambled_stream) {
@@ -755,7 +753,7 @@ int atrac3_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_pt
databuf = buf;
}
- ret = decode_frame(avctx, databuf, (float **)frame->extended_data);
+ ret = decode_frame(avctx, databuf, out_data);
if (ret) {
av_log(NULL, AV_LOG_ERROR, "Frame decoding error!\n");
return ret;
@@ -886,8 +884,6 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
if (!q->decoded_bytes_buffer)
return AVERROR(ENOMEM);
- avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
-
/* initialize the MDCT transform */
if ((ret = ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0 / 32768)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n");
diff --git a/ext/at3_standalone/atrac3plusdec.c b/ext/at3_standalone/atrac3plusdec.c
index 1673bd3eed..f6ec7b9ece 100644
--- a/ext/at3_standalone/atrac3plusdec.c
+++ b/ext/at3_standalone/atrac3plusdec.c
@@ -193,8 +193,6 @@ int atrac3p_decode_init(AVCodecContext *avctx)
ctx->ch_units[i].waves_info_prev = &ctx->ch_units[i].wave_synth_hist[1];
}
- avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
-
return 0;
}
@@ -327,16 +325,13 @@ static void reconstruct_frame(ATRAC3PContext *ctx, Atrac3pChanUnitCtx *ch_unit,
FFSWAP(Atrac3pWaveSynthParams *, ch_unit->waves_info, ch_unit->waves_info_prev);
}
-int atrac3p_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const uint8_t *avpkt_data, int avpkt_size)
+int atrac3p_decode_frame(AVCodecContext *avctx, float *out_data[2], int *nb_samples, int *got_frame_ptr, const uint8_t *avpkt_data, int avpkt_size)
{
ATRAC3PContext *ctx = avctx->priv_data;
int i, ret, ch_unit_id, ch_block = 0, out_ch_index = 0, channels_to_process;
- float **samples_p = (float **)frame->extended_data;
-
- frame->nb_samples = ATRAC3P_FRAME_SAMPLES;
- if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
- return ret;
+ float **samples_p = out_data;
+ *nb_samples = ATRAC3P_FRAME_SAMPLES;
if ((ret = init_get_bits8(&ctx->gb, avpkt_data, avpkt_size)) < 0)
return ret;
@@ -388,7 +383,6 @@ int atrac3p_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_p
AVCodec ff_atrac3p_decoder = {
.name = "atrac3plus",
.id = AV_CODEC_ID_ATRAC3P,
- .capabilities = AV_CODEC_CAP_DR1,
.priv_data_size = sizeof(ATRAC3PContext),
.init = atrac3p_decode_init,
.close = atrac3p_decode_close,
diff --git a/ext/at3_standalone/av_buffer.c b/ext/at3_standalone/av_buffer.c
deleted file mode 100644
index 54857d4398..0000000000
--- a/ext/at3_standalone/av_buffer.c
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#undef free
-
-#include
-#include
-
-#include "buffer_internal.h"
-#include "common.h"
-#include "mem.h"
-
-AVBufferRef *av_buffer_create(uint8_t *data, int size,
- void (*free)(void *opaque, uint8_t *data),
- void *opaque, int flags)
-{
- AVBufferRef *ref = NULL;
- AVBuffer *buf = NULL;
-
- buf = av_mallocz(sizeof(*buf));
- if (!buf)
- return NULL;
-
- buf->data = data;
- buf->size = size;
- buf->free = free ? free : av_buffer_default_free;
- buf->opaque = opaque;
- buf->refcount = 1;
-
- if (flags & AV_BUFFER_FLAG_READONLY)
- buf->flags |= BUFFER_FLAG_READONLY;
-
- ref = av_mallocz(sizeof(*ref));
- if (!ref) {
- av_freep(&buf);
- return NULL;
- }
-
- ref->buffer = buf;
- ref->data = data;
- ref->size = size;
-
- return ref;
-}
-
-void av_buffer_default_free(void *opaque, uint8_t *data)
-{
- av_free(data);
-}
-
-AVBufferRef *av_buffer_alloc(int size)
-{
- AVBufferRef *ret = NULL;
- uint8_t *data = NULL;
-
- data = av_malloc(size);
- if (!data)
- return NULL;
-
- ret = av_buffer_create(data, size, av_buffer_default_free, NULL, 0);
- if (!ret)
- av_freep(&data);
-
- return ret;
-}
-
-AVBufferRef *av_buffer_ref(AVBufferRef *buf)
-{
- AVBufferRef *ret = av_mallocz(sizeof(*ret));
-
- if (!ret)
- return NULL;
-
- *ret = *buf;
-
- buf->buffer->refcount++;
-
- return ret;
-}
-
-static void buffer_replace(AVBufferRef **dst, AVBufferRef **src)
-{
- AVBuffer *b;
-
- b = (*dst)->buffer;
-
- if (src) {
- **dst = **src;
- av_freep(src);
- } else
- av_freep(dst);
-
- b->refcount--;
- b->free(b->opaque, b->data);
- av_freep(&b);
-}
-
-void av_buffer_unref(AVBufferRef **buf)
-{
- if (!buf || !*buf)
- return;
-
- buffer_replace(buf, NULL);
-}
-
-int av_buffer_is_writable(const AVBufferRef *buf)
-{
- if (buf->buffer->flags & AV_BUFFER_FLAG_READONLY)
- return 0;
-
- return buf->buffer->refcount == 1;
-}
-
-int av_buffer_get_ref_count(const AVBufferRef *buf)
-{
- return buf->buffer->refcount;
-}
-
-int av_buffer_realloc(AVBufferRef **pbuf, int size)
-{
- AVBufferRef *buf = *pbuf;
- uint8_t *tmp;
-
- if (!buf) {
- /* allocate a new buffer with av_realloc(), so it will be reallocatable
- * later */
- uint8_t *data = av_realloc(NULL, size);
- if (!data)
- return AVERROR(ENOMEM);
-
- buf = av_buffer_create(data, size, av_buffer_default_free, NULL, 0);
- if (!buf) {
- av_freep(&data);
- return AVERROR(ENOMEM);
- }
-
- buf->buffer->flags |= BUFFER_FLAG_REALLOCATABLE;
- *pbuf = buf;
-
- return 0;
- } else if (buf->size == size)
- return 0;
-
- if (!(buf->buffer->flags & BUFFER_FLAG_REALLOCATABLE) ||
- !av_buffer_is_writable(buf)) {
- /* cannot realloc, allocate a new reallocable buffer and copy data */
- AVBufferRef *newb = NULL;
-
- av_buffer_realloc(&newb, size);
- if (!newb)
- return AVERROR(ENOMEM);
-
- memcpy(newb->data, buf->data, FFMIN(size, buf->size));
-
- buffer_replace(pbuf, &newb);
- return 0;
- }
-
- tmp = av_realloc(buf->buffer->data, size);
- if (!tmp)
- return AVERROR(ENOMEM);
-
- buf->buffer->data = buf->data = tmp;
- buf->buffer->size = buf->size = size;
- return 0;
-}
-
-AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size))
-{
- AVBufferPool *pool = av_mallocz(sizeof(*pool));
- if (!pool)
- return NULL;
-
- pool->size = size;
- pool->alloc = alloc ? alloc : av_buffer_alloc;
-
- pool->refcount = 1;
-
- return pool;
-}
-
-/*
- * This function gets called when the pool has been uninited and
- * all the buffers returned to it.
- */
-static void buffer_pool_free(AVBufferPool *pool)
-{
- while (pool->pool) {
- BufferPoolEntry *buf = pool->pool;
- pool->pool = buf->next;
-
- buf->free(buf->opaque, buf->data);
- av_freep(&buf);
- }
- av_freep(&pool);
-}
-
-void av_buffer_pool_uninit(AVBufferPool **ppool)
-{
- AVBufferPool *pool;
-
- if (!ppool || !*ppool)
- return;
- pool = *ppool;
- *ppool = NULL;
-
- pool->refcount--;
- if (!pool->refcount)
- buffer_pool_free(pool);
-}
-
-static void pool_release_buffer(void *opaque, uint8_t *data)
-{
- BufferPoolEntry *buf = opaque;
- AVBufferPool *pool = buf->pool;
-
- buf->next = pool->pool;
- pool->pool = buf;
-
- pool->refcount--;
- if (!pool->refcount)
- buffer_pool_free(pool);
-}
-
-/* allocate a new buffer and override its free() callback so that
- * it is returned to the pool on free */
-static AVBufferRef *pool_alloc_buffer(AVBufferPool *pool)
-{
- BufferPoolEntry *buf;
- AVBufferRef *ret;
-
- ret = pool->alloc(pool->size);
- if (!ret)
- return NULL;
-
- buf = av_mallocz(sizeof(*buf));
- if (!buf) {
- av_buffer_unref(&ret);
- return NULL;
- }
-
- buf->data = ret->buffer->data;
- buf->opaque = ret->buffer->opaque;
- buf->free = ret->buffer->free;
- buf->pool = pool;
-
- ret->buffer->opaque = buf;
- ret->buffer->free = pool_release_buffer;
-
- return ret;
-}
-
-AVBufferRef *av_buffer_pool_get(AVBufferPool *pool)
-{
- AVBufferRef *ret;
- BufferPoolEntry *buf;
-
- buf = pool->pool;
- if (buf) {
- ret = av_buffer_create(buf->data, pool->size, pool_release_buffer,
- buf, 0);
- if (ret) {
- pool->pool = buf->next;
- buf->next = NULL;
- }
- } else {
- ret = pool_alloc_buffer(pool);
- }
-
- if (ret)
- pool->refcount++;
-
- return ret;
-}
diff --git a/ext/at3_standalone/avcodec.h b/ext/at3_standalone/avcodec.h
index ff63f759f7..e35b5e3df0 100644
--- a/ext/at3_standalone/avcodec.h
+++ b/ext/at3_standalone/avcodec.h
@@ -29,10 +29,8 @@
#include
#include "attributes.h"
-#include "buffer.h"
#include "channel_layout.h"
#include "log.h"
-#include "frame.h"
#include "rational.h"
#include "version.h"
@@ -137,16 +135,6 @@ typedef struct AVCodecDescriptor {
*/
#define AV_INPUT_BUFFER_MIN_SIZE 16384
-/**
- * @ingroup lavc_encoding
- */
-typedef struct RcOverride{
- int start_frame;
- int end_frame;
- int qscale; // If this is 0 then quality_factor will be used instead.
- float quality_factor;
-} RcOverride;
-
#if FF_API_MAX_BFRAMES
/**
* @deprecated there is no libavcodec-wide limit on the number of B-frames
@@ -329,37 +317,6 @@ typedef struct RcOverride{
*/
#define AV_GET_BUFFER_FLAG_REF (1 << 0)
-/**
- * This structure stores compressed data. It is typically exported by demuxers
- * and then passed as input to decoders, or received as output from encoders and
- * then passed to muxers.
- *
- * For video, it should typically contain one compressed frame. For audio it may
- * contain several compressed frames. Encoders are allowed to output empty
- * packets, with no compressed data, containing only side data
- * (e.g. to update some stream parameters at the end of encoding).
- *
- * AVPacket is one of the few structs in FFmpeg, whose size is a part of public
- * ABI. Thus it may be allocated on stack and no new fields can be added to it
- * without libavcodec and libavformat major bump.
- *
- * The semantics of data ownership depends on the buf field.
- * If it is set, the packet data is dynamically allocated and is
- * valid indefinitely until a call to av_packet_unref() reduces the
- * reference count to 0.
- *
- * If the buf field is not set av_packet_ref() would make a copy instead
- * of increasing the reference count.
- *
- * The side data is always allocated with av_malloc(), copied by
- * av_packet_ref() and freed by av_packet_unref().
- *
- * @see av_packet_ref
- * @see av_packet_unref
- */
-
-struct AVBufferRef;
-
/**
* @}
*/
@@ -418,21 +375,6 @@ typedef struct AVCodecContext {
void *priv_data;
- /**
- * Private context used for internal data.
- *
- * Unlike priv_data, this is not codec-specific. It is used in general
- * libavcodec functions.
- */
- struct AVCodecInternal *internal;
-
- /**
- * - encoding: Set by user.
- * - decoding: unused
- */
- int compression_level;
-#define FF_COMPRESSION_DEFAULT -1
-
/**
* AV_CODEC_FLAG_*.
* - encoding: Set by user.
@@ -440,13 +382,6 @@ typedef struct AVCodecContext {
*/
int flags;
- /**
- * AV_CODEC_FLAG2_*
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- int flags2;
-
/**
* some codecs need / can use extradata like Huffman tables.
* mjpeg: Huffman tables
@@ -489,13 +424,6 @@ typedef struct AVCodecContext {
int sample_rate; ///< samples per second
int channels; ///< number of audio channels
- /**
- * audio sample format
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- enum AVSampleFormat sample_fmt; ///< sample format
-
/* The following data should not be initialized. */
/**
* Number of samples per channel in an audio frame.
@@ -539,125 +467,6 @@ typedef struct AVCodecContext {
*/
uint64_t channel_layout;
- /**
- * This callback is called at the beginning of each frame to get data
- * buffer(s) for it. There may be one contiguous buffer for all the data or
- * there may be a buffer per each data plane or anything in between. What
- * this means is, you may set however many entries in buf[] you feel necessary.
- * Each buffer must be reference-counted using the AVBuffer API (see description
- * of buf[] below).
- *
- * The following fields will be set in the frame before this callback is
- * called:
- * - format
- * - width, height (video only)
- * - sample_rate, channel_layout, nb_samples (audio only)
- * Their values may differ from the corresponding values in
- * AVCodecContext. This callback must use the frame values, not the codec
- * context values, to calculate the required buffer size.
- *
- * This callback must fill the following fields in the frame:
- * - data[]
- * - linesize[]
- * - extended_data:
- * * if the data is planar audio with more than 8 channels, then this
- * callback must allocate and fill extended_data to contain all pointers
- * to all data planes. data[] must hold as many pointers as it can.
- * extended_data must be allocated with av_malloc() and will be freed in
- * av_frame_unref().
- * * otherwise exended_data must point to data
- * - buf[] must contain one or more pointers to AVBufferRef structures. Each of
- * the frame's data and extended_data pointers must be contained in these. That
- * is, one AVBufferRef for each allocated chunk of memory, not necessarily one
- * AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(),
- * and av_buffer_ref().
- * - extended_buf and nb_extended_buf must be allocated with av_malloc() by
- * this callback and filled with the extra buffers if there are more
- * buffers than buf[] can hold. extended_buf will be freed in
- * av_frame_unref().
- *
- * If AV_CODEC_CAP_DR1 is not set then get_buffer2() must call
- * avcodec_default_get_buffer2() instead of providing buffers allocated by
- * some other means.
- *
- * Each data plane must be aligned to the maximum required by the target
- * CPU.
- *
- * @see avcodec_default_get_buffer2()
- *
- * Video:
- *
- * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused
- * (read and/or written to if it is writable) later by libavcodec.
- *
- * avcodec_align_dimensions2() should be used to find the required width and
- * height, as they normally need to be rounded up to the next multiple of 16.
- *
- * Some decoders do not support linesizes changing between frames.
- *
- * If frame multithreading is used and thread_safe_callbacks is set,
- * this callback may be called from a different thread, but not from more
- * than one at once. Does not need to be reentrant.
- *
- * @see avcodec_align_dimensions2()
- *
- * Audio:
- *
- * Decoders request a buffer of a particular size by setting
- * AVFrame.nb_samples prior to calling get_buffer2(). The decoder may,
- * however, utilize only part of the buffer by setting AVFrame.nb_samples
- * to a smaller value in the output frame.
- *
- * As a convenience, av_samples_get_buffer_size() and
- * av_samples_fill_arrays() in libavutil may be used by custom get_buffer2()
- * functions to find the required data size and to fill data pointers and
- * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
- * since all planes must be the same size.
- *
- * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
- *
- * - encoding: unused
- * - decoding: Set by libavcodec, user can override.
- */
- int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
-
- /**
- * If non-zero, the decoded audio and video frames returned from
- * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted
- * and are valid indefinitely. The caller must free them with
- * av_frame_unref() when they are not needed anymore.
- * Otherwise, the decoded frames must not be freed by the caller and are
- * only valid until the next decode call.
- *
- * - encoding: unused
- * - decoding: set by the caller before avcodec_open2().
- */
- int refcounted_frames;
-
-
-/**
- * Verify checksums embedded in the bitstream (could be of either encoded or
- * decoded data, depending on the codec) and print an error message on mismatch.
- * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the
- * decoder returning an error.
- */
-#define AV_EF_CRCCHECK (1<<0)
-#define AV_EF_BITSTREAM (1<<1) ///< detect bitstream specification deviations
-#define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length
-#define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection
-
-#define AV_EF_IGNORE_ERR (1<<15) ///< ignore errors and continue
-#define AV_EF_CAREFUL (1<<16) ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors
-#define AV_EF_COMPLIANT (1<<17) ///< consider all spec non compliances as errors
-#define AV_EF_AGGRESSIVE (1<<18) ///< consider things that a sane encoder should not do as an error
-
- /**
- * error
- * - encoding: Set by libavcodec if flags & AV_CODEC_FLAG_PSNR.
- * - decoding: unused
- */
- uint64_t error[AV_NUM_DATA_POINTERS];
-
/**
* IDCT algorithm, see FF_IDCT_* below.
* - encoding: Set by user.
@@ -724,12 +533,6 @@ typedef struct AVCodec {
*/
const char *name;
enum AVCodecID id;
- /**
- * Codec capabilities.
- * see AV_CODEC_CAP_*
- */
- int capabilities;
- const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
const AVClass *priv_class; ///< AVClass for the private context
/*****************************************************************
@@ -871,13 +674,6 @@ int avcodec_close(AVCodecContext *avctx);
* @{
*/
-/**
- * The default callback for AVCodecContext.get_buffer2(). It is made public so
- * it can be called by custom get_buffer2() implementations for decoders without
- * AV_CODEC_CAP_DR1 set.
- */
-int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags);
-
typedef struct AVCodecParserContext {
void *priv_data;
struct AVCodecParser *parser;
diff --git a/ext/at3_standalone/buffer.h b/ext/at3_standalone/buffer.h
deleted file mode 100644
index d716c3d729..0000000000
--- a/ext/at3_standalone/buffer.h
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * @ingroup lavu_buffer
- * refcounted data buffer API
- */
-
-#ifndef AVUTIL_BUFFER_H
-#define AVUTIL_BUFFER_H
-
-#include
-
-/**
- * @defgroup lavu_buffer AVBuffer
- * @ingroup lavu_data
- *
- * @{
- * AVBuffer is an API for reference-counted data buffers.
- *
- * There are two core objects in this API -- AVBuffer and AVBufferRef. AVBuffer
- * represents the data buffer itself; it is opaque and not meant to be accessed
- * by the caller directly, but only through AVBufferRef. However, the caller may
- * e.g. compare two AVBuffer pointers to check whether two different references
- * are describing the same data buffer. AVBufferRef represents a single
- * reference to an AVBuffer and it is the object that may be manipulated by the
- * caller directly.
- *
- * There are two functions provided for creating a new AVBuffer with a single
- * reference -- av_buffer_alloc() to just allocate a new buffer, and
- * av_buffer_create() to wrap an existing array in an AVBuffer. From an existing
- * reference, additional references may be created with av_buffer_ref().
- * Use av_buffer_unref() to free a reference (this will automatically free the
- * data once all the references are freed).
- *
- * The convention throughout this API and the rest of FFmpeg is such that the
- * buffer is considered writable if there exists only one reference to it (and
- * it has not been marked as read-only). The av_buffer_is_writable() function is
- * provided to check whether this is true and av_buffer_make_writable() will
- * automatically create a new writable buffer when necessary.
- * Of course nothing prevents the calling code from violating this convention,
- * however that is safe only when all the existing references are under its
- * control.
- *
- * @note Referencing and unreferencing the buffers is thread-safe and thus
- * may be done from multiple threads simultaneously without any need for
- * additional locking.
- *
- * @note Two different references to the same buffer can point to different
- * parts of the buffer (i.e. their AVBufferRef.data will not be equal).
- */
-
-/**
- * A reference counted buffer type. It is opaque and is meant to be used through
- * references (AVBufferRef).
- */
-typedef struct AVBuffer AVBuffer;
-
-/**
- * A reference to a data buffer.
- *
- * The size of this struct is not a part of the public ABI and it is not meant
- * to be allocated directly.
- */
-typedef struct AVBufferRef {
- AVBuffer *buffer;
-
- /**
- * The data buffer. It is considered writable if and only if
- * this is the only reference to the buffer, in which case
- * av_buffer_is_writable() returns 1.
- */
- uint8_t *data;
- /**
- * Size of data in bytes.
- */
- int size;
-} AVBufferRef;
-
-/**
- * Allocate an AVBuffer of the given size using av_malloc().
- *
- * @return an AVBufferRef of given size or NULL when out of memory
- */
-AVBufferRef *av_buffer_alloc(int size);
-
-/**
- * Always treat the buffer as read-only, even when it has only one
- * reference.
- */
-#define AV_BUFFER_FLAG_READONLY (1 << 0)
-
-/**
- * Create an AVBuffer from an existing array.
- *
- * If this function is successful, data is owned by the AVBuffer. The caller may
- * only access data through the returned AVBufferRef and references derived from
- * it.
- * If this function fails, data is left untouched.
- * @param data data array
- * @param size size of data in bytes
- * @param free a callback for freeing this buffer's data
- * @param opaque parameter to be got for processing or passed to free
- * @param flags a combination of AV_BUFFER_FLAG_*
- *
- * @return an AVBufferRef referring to data on success, NULL on failure.
- */
-AVBufferRef *av_buffer_create(uint8_t *data, int size,
- void (*free)(void *opaque, uint8_t *data),
- void *opaque, int flags);
-
-/**
- * Default free callback, which calls av_free() on the buffer data.
- * This function is meant to be passed to av_buffer_create(), not called
- * directly.
- */
-void av_buffer_default_free(void *opaque, uint8_t *data);
-
-/**
- * Create a new reference to an AVBuffer.
- *
- * @return a new AVBufferRef referring to the same AVBuffer as buf or NULL on
- * failure.
- */
-AVBufferRef *av_buffer_ref(AVBufferRef *buf);
-
-/**
- * Free a given reference and automatically free the buffer if there are no more
- * references to it.
- *
- * @param buf the reference to be freed. The pointer is set to NULL on return.
- */
-void av_buffer_unref(AVBufferRef **buf);
-
-/**
- * @return 1 if the caller may write to the data referred to by buf (which is
- * true if and only if buf is the only reference to the underlying AVBuffer).
- * Return 0 otherwise.
- * A positive answer is valid until av_buffer_ref() is called on buf.
- */
-int av_buffer_is_writable(const AVBufferRef *buf);
-
-int av_buffer_get_ref_count(const AVBufferRef *buf);
-
-/**
- * Reallocate a given buffer.
- *
- * @param buf a buffer reference to reallocate. On success, buf will be
- * unreferenced and a new reference with the required size will be
- * written in its place. On failure buf will be left untouched. *buf
- * may be NULL, then a new buffer is allocated.
- * @param size required new buffer size.
- * @return 0 on success, a negative AVERROR on failure.
- *
- * @note the buffer is actually reallocated with av_realloc() only if it was
- * initially allocated through av_buffer_realloc(NULL) and there is only one
- * reference to it (i.e. the one passed to this function). In all other cases
- * a new buffer is allocated and the data is copied.
- */
-int av_buffer_realloc(AVBufferRef **buf, int size);
-
-/**
- * @}
- */
-
-/**
- * @defgroup lavu_bufferpool AVBufferPool
- * @ingroup lavu_data
- *
- * @{
- * AVBufferPool is an API for a lock-free thread-safe pool of AVBuffers.
- *
- * Frequently allocating and freeing large buffers may be slow. AVBufferPool is
- * meant to solve this in cases when the caller needs a set of buffers of the
- * same size (the most obvious use case being buffers for raw video or audio
- * frames).
- *
- * At the beginning, the user must call av_buffer_pool_init() to create the
- * buffer pool. Then whenever a buffer is needed, call av_buffer_pool_get() to
- * get a reference to a new buffer, similar to av_buffer_alloc(). This new
- * reference works in all aspects the same way as the one created by
- * av_buffer_alloc(). However, when the last reference to this buffer is
- * unreferenced, it is returned to the pool instead of being freed and will be
- * reused for subsequent av_buffer_pool_get() calls.
- *
- * When the caller is done with the pool and no longer needs to allocate any new
- * buffers, av_buffer_pool_uninit() must be called to mark the pool as freeable.
- * Once all the buffers are released, it will automatically be freed.
- *
- * Allocating and releasing buffers with this API is thread-safe as long as
- * either the default alloc callback is used, or the user-supplied one is
- * thread-safe.
- */
-
-/**
- * The buffer pool. This structure is opaque and not meant to be accessed
- * directly. It is allocated with av_buffer_pool_init() and freed with
- * av_buffer_pool_uninit().
- */
-typedef struct AVBufferPool AVBufferPool;
-
-/**
- * Allocate and initialize a buffer pool.
- *
- * @param size size of each buffer in this pool
- * @param alloc a function that will be used to allocate new buffers when the
- * pool is empty. May be NULL, then the default allocator will be used
- * (av_buffer_alloc()).
- * @return newly created buffer pool on success, NULL on error.
- */
-AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size));
-
-/**
- * Mark the pool as being available for freeing. It will actually be freed only
- * once all the allocated buffers associated with the pool are released. Thus it
- * is safe to call this function while some of the allocated buffers are still
- * in use.
- *
- * @param pool pointer to the pool to be freed. It will be set to NULL.
- * @see av_buffer_pool_can_uninit()
- */
-void av_buffer_pool_uninit(AVBufferPool **pool);
-
-/**
- * Allocate a new AVBuffer, reusing an old buffer from the pool when available.
- * This function may be called simultaneously from multiple threads.
- *
- * @return a reference to the new buffer on success, NULL on error.
- */
-AVBufferRef *av_buffer_pool_get(AVBufferPool *pool);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_BUFFER_H */
diff --git a/ext/at3_standalone/buffer_internal.h b/ext/at3_standalone/buffer_internal.h
deleted file mode 100644
index 01a40864d4..0000000000
--- a/ext/at3_standalone/buffer_internal.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVUTIL_BUFFER_INTERNAL_H
-#define AVUTIL_BUFFER_INTERNAL_H
-
-#include
-
-#include "buffer.h"
-
-/**
- * The buffer is always treated as read-only.
- */
-#define BUFFER_FLAG_READONLY (1 << 0)
-/**
- * The buffer was av_realloc()ed, so it is reallocatable.
- */
-#define BUFFER_FLAG_REALLOCATABLE (1 << 1)
-
-struct AVBuffer {
- uint8_t *data; /**< data described by this buffer */
- int size; /**< size of data in bytes */
-
- /**
- * number of existing AVBufferRef instances referring to this buffer
- */
- volatile int refcount;
-
- /**
- * a callback for freeing the data
- */
- void (*free)(void *opaque, uint8_t *data);
-
- /**
- * an opaque pointer, to be used by the freeing callback
- */
- void *opaque;
-
- /**
- * A combination of BUFFER_FLAG_*
- */
- int flags;
-};
-
-typedef struct BufferPoolEntry {
- uint8_t *data;
-
- /*
- * Backups of the original opaque/free of the AVBuffer corresponding to
- * data. They will be used to free the buffer when the pool is freed.
- */
- void *opaque;
- void (*free)(void *opaque, uint8_t *data);
-
- AVBufferPool *pool;
- struct BufferPoolEntry *next;
-} BufferPoolEntry;
-
-struct AVBufferPool {
- BufferPoolEntry *pool;
-
- /*
- * This is used to track when the pool is to be freed.
- * The pointer to the pool itself held by the caller is considered to
- * be one reference. Each buffer requested by the caller increases refcount
- * by one, returning the buffer to the pool decreases it by one.
- * refcount reaches zero when the buffer has been uninited AND all the
- * buffers have been released, then it's safe to free the pool and all
- * the buffers in it.
- */
- volatile int refcount;
-
- volatile int nb_allocated;
-
- int size;
- AVBufferRef* (*alloc)(int size);
-};
-
-#endif /* AVUTIL_BUFFER_INTERNAL_H */
diff --git a/ext/at3_standalone/frame.c b/ext/at3_standalone/frame.c
deleted file mode 100644
index 979af30c8d..0000000000
--- a/ext/at3_standalone/frame.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "channel_layout.h"
-#include "buffer.h"
-#include "common.h"
-#include "frame.h"
-#include "util_internal.h"
-#include "mem.h"
-#include "samplefmt.h"
-
-MAKE_ACCESSORS(AVFrame, frame, int64_t, best_effort_timestamp)
-MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_duration)
-MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_pos)
-MAKE_ACCESSORS(AVFrame, frame, int64_t, channel_layout)
-MAKE_ACCESSORS(AVFrame, frame, int, channels)
-MAKE_ACCESSORS(AVFrame, frame, int, sample_rate)
-MAKE_ACCESSORS(AVFrame, frame, int, decode_error_flags)
-MAKE_ACCESSORS(AVFrame, frame, int, pkt_size)
-
-#define CHECK_CHANNELS_CONSISTENCY(frame) \
- av_assert2(!(frame)->channel_layout || \
- (frame)->channels == \
- av_get_channel_layout_nb_channels((frame)->channel_layout))
-
-static void get_frame_defaults(AVFrame *frame)
-{
- if (frame->extended_data != frame->data)
- av_freep(&frame->extended_data);
-
- memset(frame, 0, sizeof(*frame));
-
- av_frame_set_best_effort_timestamp(frame, AV_NOPTS_VALUE);
- av_frame_set_pkt_duration (frame, 0);
- av_frame_set_pkt_pos (frame, -1);
- av_frame_set_pkt_size (frame, -1);
- frame->format = -1; /* unknown */
- frame->extended_data = frame->data;
-}
-
-AVFrame *av_frame_alloc(void)
-{
- AVFrame *frame = av_mallocz(sizeof(*frame));
-
- if (!frame)
- return NULL;
-
- frame->extended_data = NULL;
- get_frame_defaults(frame);
-
- return frame;
-}
-
-void av_frame_free(AVFrame **frame)
-{
- if (!frame || !*frame)
- return;
-
- av_frame_unref(*frame);
- av_freep(frame);
-}
-
-static int get_audio_buffer(AVFrame *frame, int align)
-{
- int channels;
- int planar = av_sample_fmt_is_planar(frame->format);
- int planes;
- int ret, i;
-
- if (!frame->channels)
- frame->channels = av_get_channel_layout_nb_channels(frame->channel_layout);
-
- channels = frame->channels;
- planes = planar ? channels : 1;
-
- CHECK_CHANNELS_CONSISTENCY(frame);
- if (!frame->linesize[0]) {
- ret = av_samples_get_buffer_size(&frame->linesize[0], channels,
- frame->nb_samples, frame->format,
- align);
- if (ret < 0)
- return ret;
- }
-
- if (planes > AV_NUM_DATA_POINTERS) {
- frame->extended_data = av_mallocz_array(planes,
- sizeof(*frame->extended_data));
- frame->extended_buf = av_mallocz_array((planes - AV_NUM_DATA_POINTERS),
- sizeof(*frame->extended_buf));
- if (!frame->extended_data || !frame->extended_buf) {
- av_freep(&frame->extended_data);
- av_freep(&frame->extended_buf);
- return AVERROR(ENOMEM);
- }
- frame->nb_extended_buf = planes - AV_NUM_DATA_POINTERS;
- } else
- frame->extended_data = frame->data;
-
- for (i = 0; i < FFMIN(planes, AV_NUM_DATA_POINTERS); i++) {
- frame->buf[i] = av_buffer_alloc(frame->linesize[0]);
- if (!frame->buf[i]) {
- av_frame_unref(frame);
- return AVERROR(ENOMEM);
- }
- frame->extended_data[i] = frame->data[i] = frame->buf[i]->data;
- }
- for (i = 0; i < planes - AV_NUM_DATA_POINTERS; i++) {
- frame->extended_buf[i] = av_buffer_alloc(frame->linesize[0]);
- if (!frame->extended_buf[i]) {
- av_frame_unref(frame);
- return AVERROR(ENOMEM);
- }
- frame->extended_data[i + AV_NUM_DATA_POINTERS] = frame->extended_buf[i]->data;
- }
- return 0;
-
-}
-
-int av_frame_get_buffer(AVFrame *frame, int align)
-{
- if (frame->format < 0)
- return AVERROR(EINVAL);
-
- else if (frame->nb_samples > 0 && (frame->channel_layout || frame->channels > 0))
- return get_audio_buffer(frame, align);
-
- return AVERROR(EINVAL);
-}
-
-static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy)
-{
- dst->sample_rate = src->sample_rate;
- dst->pkt_pos = src->pkt_pos;
- dst->pkt_size = src->pkt_size;
- dst->pkt_duration = src->pkt_duration;
- dst->quality = src->quality;
- dst->best_effort_timestamp = src->best_effort_timestamp;
- dst->flags = src->flags;
- dst->decode_error_flags = src->decode_error_flags;
-
-#if FF_API_ERROR_FRAME
-FF_DISABLE_DEPRECATION_WARNINGS
- memcpy(dst->error, src->error, sizeof(dst->error));
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
- return 0;
-}
-
-void av_frame_unref(AVFrame *frame)
-{
- int i;
-
- if (!frame)
- return;
-
- for (i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++)
- av_buffer_unref(&frame->buf[i]);
- for (i = 0; i < frame->nb_extended_buf; i++)
- av_buffer_unref(&frame->extended_buf[i]);
- av_freep(&frame->extended_buf);
-
- get_frame_defaults(frame);
-}
diff --git a/ext/at3_standalone/frame.h b/ext/at3_standalone/frame.h
deleted file mode 100644
index 62e4086c74..0000000000
--- a/ext/at3_standalone/frame.h
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * @ingroup lavu_frame
- * reference-counted frame API
- */
-
-#ifndef AVUTIL_FRAME_H
-#define AVUTIL_FRAME_H
-
-#include
-
-#include "avutil.h"
-#include "buffer.h"
-#include "rational.h"
-#include "samplefmt.h"
-#include "version.h"
-
-/**
- * This structure describes decoded (raw) audio or video data.
- *
- * AVFrame must be allocated using av_frame_alloc(). Note that this only
- * allocates the AVFrame itself, the buffers for the data must be managed
- * through other means (see below).
- * AVFrame must be freed with av_frame_free().
- *
- * AVFrame is typically allocated once and then reused multiple times to hold
- * different data (e.g. a single AVFrame to hold frames received from a
- * decoder). In such a case, av_frame_unref() will free any references held by
- * the frame and reset it to its original clean state before it
- * is reused again.
- *
- * The data described by an AVFrame is usually reference counted through the
- * AVBuffer API. The underlying buffer references are stored in AVFrame.buf /
- * AVFrame.extended_buf. An AVFrame is considered to be reference counted if at
- * least one reference is set, i.e. if AVFrame.buf[0] != NULL. In such a case,
- * every single data plane must be contained in one of the buffers in
- * AVFrame.buf or AVFrame.extended_buf.
- * There may be a single buffer for all the data, or one separate buffer for
- * each plane, or anything in between.
- *
- * sizeof(AVFrame) is not a part of the public ABI, so new fields may be added
- * to the end with a minor bump.
- * Similarly fields that are marked as to be only accessed by
- * av_opt_ptr() can be reordered. This allows 2 forks to add fields
- * without breaking compatibility with each other.
- */
-typedef struct AVFrame {
-#define AV_NUM_DATA_POINTERS 8
- /**
- * pointer to the picture/channel planes.
- * This might be different from the first allocated byte
- *
- * Some decoders access areas outside 0,0 - width,height, please
- * see avcodec_align_dimensions2(). Some filters and swscale can read
- * up to 16 bytes beyond the planes, if these filters are to be used,
- * then 16 extra bytes must be allocated.
- */
- uint8_t *data[AV_NUM_DATA_POINTERS];
-
- /**
- * For video, size in bytes of each picture line.
- * For audio, size in bytes of each plane.
- *
- * For audio, only linesize[0] may be set. For planar audio, each channel
- * plane must be the same size.
- *
- * For video the linesizes should be multiples of the CPUs alignment
- * preference, this is 16 or 32 for modern desktop CPUs.
- * Some code requires such alignment other code can be slower without
- * correct alignment, for yet other it makes no difference.
- *
- * @note The linesize may be larger than the size of usable data -- there
- * may be extra padding present for performance reasons.
- */
- int linesize[AV_NUM_DATA_POINTERS];
-
- /**
- * pointers to the data planes/channels.
- *
- * For video, this should simply point to data[].
- *
- * For planar audio, each channel has a separate data pointer, and
- * linesize[0] contains the size of each channel buffer.
- * For packed audio, there is just one data pointer, and linesize[0]
- * contains the total size of the buffer for all channels.
- *
- * Note: Both data and extended_data should always be set in a valid frame,
- * but for planar audio with more channels that can fit in data,
- * extended_data must be used in order to access all channels.
- */
- uint8_t **extended_data;
-
- /**
- * number of audio samples (per channel) described by this frame
- */
- int nb_samples;
-
- /**
- * format of the frame, -1 if unknown or unset
- * Values correspond to enum AVPixelFormat for video frames,
- * enum AVSampleFormat for audio)
- */
- int format;
-
- /**
- * quality (between 1 (good) and FF_LAMBDA_MAX (bad))
- */
- int quality;
-
-#if FF_API_ERROR_FRAME
- /**
- * @deprecated unused
- */
- attribute_deprecated
- uint64_t error[AV_NUM_DATA_POINTERS];
-#endif
-
- /**
- * Sample rate of the audio data.
- */
- int sample_rate;
-
- /**
- * Channel layout of the audio data.
- */
- uint64_t channel_layout;
-
- /**
- * AVBuffer references backing the data for this frame. If all elements of
- * this array are NULL, then this frame is not reference counted. This array
- * must be filled contiguously -- if buf[i] is non-NULL then buf[j] must
- * also be non-NULL for all j < i.
- *
- * There may be at most one AVBuffer per data plane, so for video this array
- * always contains all the references. For planar audio with more than
- * AV_NUM_DATA_POINTERS channels, there may be more buffers than can fit in
- * this array. Then the extra AVBufferRef pointers are stored in the
- * extended_buf array.
- */
- AVBufferRef *buf[AV_NUM_DATA_POINTERS];
-
- /**
- * For planar audio which requires more than AV_NUM_DATA_POINTERS
- * AVBufferRef pointers, this array will hold all the references which
- * cannot fit into AVFrame.buf.
- *
- * Note that this is different from AVFrame.extended_data, which always
- * contains all the pointers. This array only contains the extra pointers,
- * which cannot fit into AVFrame.buf.
- *
- * This array is always allocated using av_malloc() by whoever constructs
- * the frame. It is freed in av_frame_unref().
- */
- AVBufferRef **extended_buf;
- /**
- * Number of elements in extended_buf.
- */
- int nb_extended_buf;
-
-/**
- * @defgroup lavu_frame_flags AV_FRAME_FLAGS
- * Flags describing additional frame properties.
- *
- * @{
- */
-
-/**
- * The frame data may be corrupted, e.g. due to decoding errors.
- */
-#define AV_FRAME_FLAG_CORRUPT (1 << 0)
-/**
- * @}
- */
-
- /**
- * Frame flags, a combination of @ref lavu_frame_flags
- */
- int flags;
-
- /**
- * frame timestamp estimated using various heuristics, in stream time base
- * Code outside libavutil should access this field using:
- * av_frame_get_best_effort_timestamp(frame)
- * - encoding: unused
- * - decoding: set by libavcodec, read by user.
- */
- int64_t best_effort_timestamp;
-
- /**
- * reordered pos from the last AVPacket that has been input into the decoder
- * Code outside libavutil should access this field using:
- * av_frame_get_pkt_pos(frame)
- * - encoding: unused
- * - decoding: Read by user.
- */
- int64_t pkt_pos;
-
- /**
- * duration of the corresponding packet, expressed in
- * AVStream->time_base units, 0 if unknown.
- * Code outside libavutil should access this field using:
- * av_frame_get_pkt_duration(frame)
- * - encoding: unused
- * - decoding: Read by user.
- */
- int64_t pkt_duration;
-
- /**
- * decode error flags of the frame, set to a combination of
- * FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there
- * were errors during the decoding.
- * Code outside libavutil should access this field using:
- * av_frame_get_decode_error_flags(frame)
- * - encoding: unused
- * - decoding: set by libavcodec, read by user.
- */
- int decode_error_flags;
-#define FF_DECODE_ERROR_INVALID_BITSTREAM 1
-#define FF_DECODE_ERROR_MISSING_REFERENCE 2
-
- /**
- * number of audio channels, only used for audio.
- * Code outside libavutil should access this field using:
- * av_frame_get_channels(frame)
- * - encoding: unused
- * - decoding: Read by user.
- */
- int channels;
-
- /**
- * size of the corresponding packet containing the compressed
- * frame. It must be accessed using av_frame_get_pkt_size() and
- * av_frame_set_pkt_size().
- * It is set to a negative value if unknown.
- * - encoding: unused
- * - decoding: set by libavcodec, read by user.
- */
- int pkt_size;
-} AVFrame;
-
-/**
- * Accessors for some AVFrame fields.
- * The position of these field in the structure is not part of the ABI,
- * they should not be accessed directly outside libavutil.
- */
-int64_t av_frame_get_best_effort_timestamp(const AVFrame * frame);
-void av_frame_set_best_effort_timestamp(AVFrame * frame, int64_t val);
-int64_t av_frame_get_pkt_duration(const AVFrame * frame);
-void av_frame_set_pkt_duration(AVFrame * frame, int64_t val);
-int64_t av_frame_get_pkt_pos(const AVFrame * frame);
-void av_frame_set_pkt_pos(AVFrame * frame, int64_t val);
-int64_t av_frame_get_channel_layout(const AVFrame * frame);
-void av_frame_set_channel_layout(AVFrame * frame, int64_t val);
-int av_frame_get_channels(const AVFrame * frame);
-void av_frame_set_channels(AVFrame * frame, int val);
-int av_frame_get_sample_rate(const AVFrame * frame);
-void av_frame_set_sample_rate(AVFrame * frame, int val);
-int av_frame_get_decode_error_flags(const AVFrame * frame);
-void av_frame_set_decode_error_flags(AVFrame * frame, int val);
-int av_frame_get_pkt_size(const AVFrame * frame);
-void av_frame_set_pkt_size(AVFrame * frame, int val);
-
-/**
- * Allocate an AVFrame and set its fields to default values. The resulting
- * struct must be freed using av_frame_free().
- *
- * @return An AVFrame filled with default values or NULL on failure.
- *
- * @note this only allocates the AVFrame itself, not the data buffers. Those
- * must be allocated through other means, e.g. with av_frame_get_buffer() or
- * manually.
- */
-AVFrame *av_frame_alloc(void);
-
-/**
- * Free the frame and any dynamically allocated objects in it,
- * e.g. extended_data. If the frame is reference counted, it will be
- * unreferenced first.
- *
- * @param frame frame to be freed. The pointer will be set to NULL.
- */
-void av_frame_free(AVFrame **frame);
-
-/**
- * Unreference all the buffers referenced by frame and reset the frame fields.
- */
-void av_frame_unref(AVFrame *frame);
-
-/**
- * Allocate new buffer(s) for audio or video data.
- *
- * The following fields must be set on frame before calling this function:
- * - format (pixel format for video, sample format for audio)
- * - width and height for video
- * - nb_samples and channel_layout for audio
- *
- * This function will fill AVFrame.data and AVFrame.buf arrays and, if
- * necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf.
- * For planar formats, one buffer will be allocated for each plane.
- *
- * @param frame frame in which to store the new buffers.
- * @param align required buffer size alignment
- *
- * @return 0 on success, a negative AVERROR on error.
- */
-int av_frame_get_buffer(AVFrame *frame, int align);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_FRAME_H */
diff --git a/ext/at3_standalone/internal.h b/ext/at3_standalone/internal.h
index 426bbed41a..028235896f 100644
--- a/ext/at3_standalone/internal.h
+++ b/ext/at3_standalone/internal.h
@@ -26,129 +26,15 @@
#include
-#include "buffer.h"
#include "channel_layout.h"
#include "mathematics.h"
#include "avcodec.h"
#include "config.h"
-/**
- * The codec allows calling the close function for deallocation even if
- * the init function returned a failure. Without this capability flag, a
- * codec does such cleanup internally when returning failures from the
- * init function and does not expect the close function to be called at
- * all.
- */
-#define FF_CODEC_CAP_INIT_CLEANUP (1 << 1)
-/**
- * Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set
- * AVFrame.pkt_dts manually. If the flag is set, utils.c won't overwrite
- * this field. If it's unset, utils.c tries to guess the pkt_dts field
- * from the input AVPacket.
- */
-#define FF_CODEC_CAP_SETS_PKT_DTS (1 << 2)
-/**
- * The decoder extracts and fills its parameters even if the frame is
- * skipped due to the skip_frame setting.
- */
-#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM (1 << 3)
-
-#ifdef TRACE
-# define ff_tlog(ctx, ...) av_log(ctx, AV_LOG_TRACE, __VA_ARGS__)
-#else
-# define ff_tlog(ctx, ...) do { } while(0)
-#endif
-
-
-#if !FF_API_QUANT_BIAS
-#define FF_DEFAULT_QUANT_BIAS 999999
-#endif
-
#define FF_SANE_NB_CHANNELS 64U
-#define FF_SIGNBIT(x) ((x) >> CHAR_BIT * sizeof(x) - 1)
-
-#if HAVE_AVX
-# define STRIDE_ALIGN 32
-#elif HAVE_SIMD_ALIGN_16
-# define STRIDE_ALIGN 16
-#else
-# define STRIDE_ALIGN 8
-#endif
-
-typedef struct FramePool {
- /**
- * Pools for each data plane. For audio all the planes have the same size,
- * so only pools[0] is used.
- */
- AVBufferPool *pools[4];
-
- /*
- * Pool parameters
- */
- int format;
- int stride_align[AV_NUM_DATA_POINTERS];
- int linesize[4];
- int planes;
- int channels;
- int samples;
-} FramePool;
-
-typedef struct AVCodecInternal {
- /**
- * Whether the parent AVCodecContext is a copy of the context which had
- * init() called on it.
- * This is used by multithreading - shared tables and picture pointers
- * should be freed from the original context only.
- */
- int is_copy;
-
- /**
- * Whether to allocate progress for frame threading.
- *
- * The codec must set it to 1 if it uses ff_thread_await/report_progress(),
- * then progress will be allocated in ff_thread_get_buffer(). The frames
- * then MUST be freed with ff_thread_release_buffer().
- *
- * If the codec does not need to call the progress functions (there are no
- * dependencies between the frames), it should leave this at 0. Then it can
- * decode straight to the user-provided frames (which the user will then
- * free with av_frame_unref()), there is no need to call
- * ff_thread_release_buffer().
- */
- int allocate_progress;
-
- /**
- * An audio frame with less than required samples has been submitted and
- * padded with silence. Reject all subsequent frames.
- */
- int last_audio_frame;
-
- FramePool *pool;
-
- void *thread_ctx;
-
- /**
- * temporary buffer used for encoders to store their bitstream
- */
- uint8_t *byte_buffer;
- unsigned int byte_buffer_size;
-
- void *frame_thread_encoder;
-
- /**
- * Number of audio samples to skip at the start of the next decoded frame
- */
- int skip_samples;
-} AVCodecInternal;
-
extern const uint8_t ff_log2_run[41];
-/**
- * does needed setup of pkt_pts/pos and such for (re)get_buffer();
- */
-int ff_init_buffer_info(AVCodecContext *s, AVFrame *frame);
-
/**
* Maximum size in bytes of extradata.
* This value was chosen such that every bit of the buffer is
@@ -156,11 +42,4 @@ int ff_init_buffer_info(AVCodecContext *s, AVFrame *frame);
*/
#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)
-/**
- * Get a buffer for a frame. This is a wrapper around
- * AVCodecContext.get_buffer() and should be used instead calling get_buffer()
- * directly.
- */
-int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags);
-
#endif /* AVCODEC_INTERNAL_H */
diff --git a/ext/at3_standalone/options.c b/ext/at3_standalone/options.c
index a7e3b0cb6c..67ee1c1816 100644
--- a/ext/at3_standalone/options.c
+++ b/ext/at3_standalone/options.c
@@ -54,9 +54,6 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec)
s->codec_id = codec->id;
}
- s->get_buffer2 = avcodec_default_get_buffer2;
- s->sample_fmt = AV_SAMPLE_FMT_NONE;
-
if(codec && codec->priv_data_size){
if(!s->priv_data){
s->priv_data= av_mallocz(codec->priv_data_size);
diff --git a/ext/at3_standalone/utils.c b/ext/at3_standalone/utils.c
index 2f3522e542..ab55822d50 100644
--- a/ext/at3_standalone/utils.c
+++ b/ext/at3_standalone/utils.c
@@ -30,7 +30,6 @@
#include "avcodec.h"
#include "attributes.h"
#include "channel_layout.h"
-#include "frame.h"
#include "internal.h"
#include "mathematics.h"
#include "samplefmt.h"
@@ -84,137 +83,6 @@ unsigned avcodec_get_edge_width(void)
}
#endif
-static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)
-{
- FramePool *pool = avctx->internal->pool;
- int i, ret;
-
- int ch = av_frame_get_channels(frame); //av_get_channel_layout_nb_channels(frame->channel_layout);
- int planar = av_sample_fmt_is_planar(frame->format);
- int planes = planar ? ch : 1;
-
- if (pool->format == frame->format && pool->planes == planes &&
- pool->channels == ch && frame->nb_samples == pool->samples)
- return 0;
-
- av_buffer_pool_uninit(&pool->pools[0]);
- ret = av_samples_get_buffer_size(&pool->linesize[0], ch,
- frame->nb_samples, frame->format, 0);
- if (ret < 0)
- goto fail;
-
- pool->pools[0] = av_buffer_pool_init(pool->linesize[0], NULL);
- if (!pool->pools[0]) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
-
- pool->format = frame->format;
- pool->planes = planes;
- pool->channels = ch;
- pool->samples = frame->nb_samples;
- return 0;
-fail:
- for (i = 0; i < 4; i++)
- av_buffer_pool_uninit(&pool->pools[i]);
- pool->format = -1;
- pool->planes = pool->channels = pool->samples = 0;
- return ret;
-}
-
-static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
-{
- FramePool *pool = avctx->internal->pool;
- int planes = pool->planes;
- int i;
-
- frame->linesize[0] = pool->linesize[0];
-
- if (planes > AV_NUM_DATA_POINTERS) {
- frame->extended_data = av_mallocz_array(planes, sizeof(*frame->extended_data));
- frame->nb_extended_buf = planes - AV_NUM_DATA_POINTERS;
- frame->extended_buf = av_mallocz_array(frame->nb_extended_buf,
- sizeof(*frame->extended_buf));
- if (!frame->extended_data || !frame->extended_buf) {
- av_freep(&frame->extended_data);
- av_freep(&frame->extended_buf);
- return AVERROR(ENOMEM);
- }
- } else {
- frame->extended_data = frame->data;
- av_assert0(frame->nb_extended_buf == 0);
- }
-
- for (i = 0; i < FFMIN(planes, AV_NUM_DATA_POINTERS); i++) {
- frame->buf[i] = av_buffer_pool_get(pool->pools[0]);
- if (!frame->buf[i])
- goto fail;
- frame->extended_data[i] = frame->data[i] = frame->buf[i]->data;
- }
- for (i = 0; i < frame->nb_extended_buf; i++) {
- frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]);
- if (!frame->extended_buf[i])
- goto fail;
- frame->extended_data[i + AV_NUM_DATA_POINTERS] = frame->extended_buf[i]->data;
- }
-
- return 0;
-fail:
- av_frame_unref(frame);
- return AVERROR(ENOMEM);
-}
-
-int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags)
-{
- int ret;
-
- if ((ret = update_frame_pool(avctx, frame)) < 0)
- return ret;
-
- return audio_get_buffer(avctx, frame);
-}
-
-int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame)
-{
- if (!frame->sample_rate)
- frame->sample_rate = avctx->sample_rate;
- if (frame->format < 0)
- frame->format = avctx->sample_fmt;
- if (!frame->channel_layout) {
- if (avctx->channel_layout) {
- if (av_get_channel_layout_nb_channels(avctx->channel_layout) !=
- avctx->channels) {
- av_log(avctx, AV_LOG_ERROR, "Inconsistent channel "
- "configuration.\n");
- return AVERROR(EINVAL);
- }
-
- frame->channel_layout = avctx->channel_layout;
- } else {
- if (avctx->channels > FF_SANE_NB_CHANNELS) {
- av_log(avctx, AV_LOG_ERROR, "Too many channels: %d.\n",
- avctx->channels);
- return AVERROR(ENOSYS);
- }
- }
- }
- av_frame_set_channels(frame, avctx->channels);
- return 0;
-}
-
-int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
-{
- int override_dimensions = 1;
- int ret;
-
- ret = ff_init_buffer_info(avctx, frame);
- if (ret < 0)
- return ret;
-
- ret = avctx->get_buffer2(avctx, frame, flags);
- return ret;
-}
-
int attribute_align_arg ff_codec_open2_recursive(AVCodecContext *avctx, const AVCodec *codec, void **options)
{
int ret = 0;
@@ -228,9 +96,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
{
int ret = 0;
- if (avcodec_is_open(avctx))
- return 0;
-
if ((codec && avctx->codec && codec != avctx->codec)) {
av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, "
"but %s passed to avcodec_open2()\n", avctx->codec->name, codec->name);
@@ -242,18 +107,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
return AVERROR(EINVAL);
- avctx->internal = av_mallocz(sizeof(AVCodecInternal));
- if (!avctx->internal) {
- ret = AVERROR(ENOMEM);
- goto end;
- }
-
- avctx->internal->pool = av_mallocz(sizeof(*avctx->internal->pool));
- if (!avctx->internal->pool) {
- ret = AVERROR(ENOMEM);
- goto free_and_end;
- }
-
if (codec->priv_data_size > 0) {
if (!avctx->priv_data) {
avctx->priv_data = av_mallocz(codec->priv_data_size);
@@ -334,8 +187,7 @@ end:
return ret;
free_and_end:
- if (avctx->codec &&
- (avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP))
+ if (avctx->codec)
avctx->codec->close(avctx);
#if FF_API_CODED_FRAME
@@ -345,10 +197,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
#endif
av_freep(&avctx->priv_data);
- if (avctx->internal) {
- av_freep(&avctx->internal->pool);
- }
- av_freep(&avctx->internal);
avctx->codec = NULL;
goto end;
}
@@ -360,17 +208,8 @@ av_cold int avcodec_close(AVCodecContext *avctx)
if (!avctx)
return 0;
- if (avcodec_is_open(avctx)) {
- FramePool *pool = avctx->internal->pool;
- if (avctx->codec && avctx->codec->close)
- avctx->codec->close(avctx);
- avctx->internal->byte_buffer_size = 0;
- av_freep(&avctx->internal->byte_buffer);
- for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++)
- av_buffer_pool_uninit(&pool->pools[i]);
- av_freep(&avctx->internal->pool);
- av_freep(&avctx->internal);
- }
+ if (avctx->codec && avctx->codec->close)
+ avctx->codec->close(avctx);
av_freep(&avctx->priv_data);
avctx->codec = NULL;
return 0;
@@ -381,8 +220,3 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
if (avctx->codec->flush)
avctx->codec->flush(avctx);
}
-
-int avcodec_is_open(AVCodecContext *s)
-{
- return !!s->internal;
-}