aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2015-09-05 16:59:23 +0200
committerHendrik Leppkes <h.leppkes@gmail.com>2015-09-05 16:59:23 +0200
commit4eb86b83a407faef20e9b243f341daa4e88728ef (patch)
tree5f293a944dc2855180d74824fa1b485be26944e8
parent83a5df54eae6dddea7c453fd25c45c7b9c148925 (diff)
parent9f90b24877016e7140b9b14e4b1acee663bb6d8a (diff)
downloadffmpeg-4eb86b83a407faef20e9b243f341daa4e88728ef.tar.gz
Merge commit '9f90b24877016e7140b9b14e4b1acee663bb6d8a'
* commit '9f90b24877016e7140b9b14e4b1acee663bb6d8a': lavc: Drop deprecated get_buffer related functions Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
-rw-r--r--libavcodec/avcodec.h114
-rw-r--r--libavcodec/pthread_frame.c41
-rw-r--r--libavcodec/utils.c180
-rw-r--r--libavcodec/vda_h264_dec.c10
-rw-r--r--libavcodec/version.h3
5 files changed, 3 insertions, 345 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index fae48a8ed7..ba50bff31f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1198,18 +1198,6 @@ typedef struct AVPanScan{
#define FF_QSCALE_TYPE_VP56 3
#endif
-#if FF_API_GET_BUFFER
-#define FF_BUFFER_TYPE_INTERNAL 1
-#define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
-#define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
-#define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
-
-#define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
-#define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
-#define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
-#define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
-#endif
-
/**
* The decoder will keep a reference to the frame and may reuse it later.
*/
@@ -2329,102 +2317,6 @@ typedef struct AVCodecContext {
*/
enum AVSampleFormat request_sample_fmt;
-#if FF_API_GET_BUFFER
- /**
- * Called at the beginning of each frame to get a buffer for it.
- *
- * The function will set AVFrame.data[], AVFrame.linesize[].
- * AVFrame.extended_data[] must also be set, but it should be the same as
- * AVFrame.data[] except for planar audio with more channels than can fit
- * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as
- * many data pointers as it can hold.
- *
- * if CODEC_CAP_DR1 is not set then get_buffer() must call
- * avcodec_default_get_buffer() instead of providing buffers allocated by
- * some other means.
- *
- * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't
- * need it. avcodec_default_get_buffer() aligns the output buffer properly,
- * but if get_buffer() is overridden then alignment considerations should
- * be taken into account.
- *
- * @see avcodec_default_get_buffer()
- *
- * Video:
- *
- * If pic.reference is set then the frame will be read 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.
- *
- * If frame multithreading is used and thread_safe_callbacks is set,
- * it may be called from a different thread, but not from more than one at
- * once. Does not need to be reentrant.
- *
- * @see release_buffer(), reget_buffer()
- * @see avcodec_align_dimensions2()
- *
- * Audio:
- *
- * Decoders request a buffer of a particular size by setting
- * AVFrame.nb_samples prior to calling get_buffer(). The decoder may,
- * however, utilize only part of the buffer by setting AVFrame.nb_samples
- * to a smaller value in the output frame.
- *
- * Decoders cannot use the buffer after returning from
- * avcodec_decode_audio4(), so they will not call release_buffer(), as it
- * is assumed to be released immediately upon return. In some rare cases,
- * a decoder may need to call get_buffer() more than once in a single
- * call to avcodec_decode_audio4(). In that case, when get_buffer() is
- * called again after it has already been called once, the previously
- * acquired buffer is assumed to be released at that time and may not be
- * reused by the decoder.
- *
- * As a convenience, av_samples_get_buffer_size() and
- * av_samples_fill_arrays() in libavutil may be used by custom get_buffer()
- * 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.
- *
- * @deprecated use get_buffer2()
- */
- attribute_deprecated
- int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
-
- /**
- * Called to release buffers which were allocated with get_buffer.
- * A released buffer can be reused in get_buffer().
- * pic.data[*] must be set to NULL.
- * May be called from a different thread if frame multithreading is used,
- * but not by more than one thread at once, so does not need to be reentrant.
- * - encoding: unused
- * - decoding: Set by libavcodec, user can override.
- *
- * @deprecated custom freeing callbacks should be set from get_buffer2()
- */
- attribute_deprecated
- void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
-
- /**
- * Called at the beginning of a frame to get cr buffer for it.
- * Buffer type (size, hints) must be the same. libavcodec won't check it.
- * libavcodec will pass previous buffer in pic, function should return
- * same buffer or new buffer with old frame "painted" into it.
- * If pic.data[0] == NULL must behave like get_buffer().
- * if CODEC_CAP_DR1 is not set then reget_buffer() must call
- * avcodec_default_reget_buffer() instead of providing buffers allocated by
- * some other means.
- * - encoding: unused
- * - decoding: Set by libavcodec, user can override.
- */
- attribute_deprecated
- int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
-#endif
-
/**
* 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
@@ -4239,12 +4131,6 @@ AVCodec *avcodec_find_decoder(enum AVCodecID id);
*/
AVCodec *avcodec_find_decoder_by_name(const char *name);
-#if FF_API_GET_BUFFER
-attribute_deprecated int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
-attribute_deprecated void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
-attribute_deprecated int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
-#endif
-
/**
* The default callback for AVCodecContext.get_buffer2(). It is made public so
* it can be called by custom get_buffer2() implementations for decoders without
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index a63210c209..c89b4ca2e0 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -122,13 +122,8 @@ typedef struct FrameThreadContext {
int die; ///< Set when threads should exit.
} FrameThreadContext;
-#if FF_API_GET_BUFFER
-#define THREAD_SAFE_CALLBACKS(avctx) \
-((avctx)->thread_safe_callbacks || (!(avctx)->get_buffer && (avctx)->get_buffer2 == avcodec_default_get_buffer2))
-#else
#define THREAD_SAFE_CALLBACKS(avctx) \
((avctx)->thread_safe_callbacks || (avctx)->get_buffer2 == avcodec_default_get_buffer2)
-#endif
/**
* Codec worker thread.
@@ -151,10 +146,8 @@ static attribute_align_arg void *frame_worker_thread(void *arg)
if (fctx->die) break;
-FF_DISABLE_DEPRECATION_WARNINGS
if (!codec->update_thread_context && THREAD_SAFE_CALLBACKS(avctx))
ff_thread_finish_setup(avctx);
-FF_ENABLE_DEPRECATION_WARNINGS
av_frame_unref(p->frame);
p->got_frame = 0;
@@ -271,12 +264,6 @@ static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
dst->draw_horiz_band= src->draw_horiz_band;
dst->get_buffer2 = src->get_buffer2;
-#if FF_API_GET_BUFFER
-FF_DISABLE_DEPRECATION_WARNINGS
- dst->get_buffer = src->get_buffer;
- dst->release_buffer = src->release_buffer;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
dst->opaque = src->opaque;
dst->debug = src->debug;
@@ -369,14 +356,9 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
* and it calls back to the client here.
*/
-FF_DISABLE_DEPRECATION_WARNINGS
if (!p->avctx->thread_safe_callbacks && (
p->avctx->get_format != avcodec_default_get_format ||
-#if FF_API_GET_BUFFER
- p->avctx->get_buffer ||
-#endif
p->avctx->get_buffer2 != avcodec_default_get_buffer2)) {
-FF_ENABLE_DEPRECATION_WARNINGS
while (p->state != STATE_SETUP_FINISHED && p->state != STATE_INPUT_READY) {
int call_done = 1;
pthread_mutex_lock(&p->progress_mutex);
@@ -773,10 +755,8 @@ void ff_thread_flush(AVCodecContext *avctx)
int ff_thread_can_start_frame(AVCodecContext *avctx)
{
PerThreadContext *p = avctx->internal->thread_ctx;
-FF_DISABLE_DEPRECATION_WARNINGS
if ((avctx->active_thread_type&FF_THREAD_FRAME) && p->state != STATE_SETTING_UP &&
(avctx->codec->update_thread_context || !THREAD_SAFE_CALLBACKS(avctx))) {
-FF_ENABLE_DEPRECATION_WARNINGS
return 0;
}
return 1;
@@ -794,10 +774,8 @@ static int thread_get_buffer_internal(AVCodecContext *avctx, ThreadFrame *f, int
if (!(avctx->active_thread_type & FF_THREAD_FRAME))
return ff_get_buffer(avctx, f->f, flags);
-FF_DISABLE_DEPRECATION_WARNINGS
if (p->state != STATE_SETTING_UP &&
(avctx->codec->update_thread_context || !THREAD_SAFE_CALLBACKS(avctx))) {
-FF_ENABLE_DEPRECATION_WARNINGS
av_log(avctx, AV_LOG_ERROR, "get_buffer() cannot be called after ff_thread_finish_setup()\n");
return -1;
}
@@ -814,13 +792,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
pthread_mutex_lock(&p->parent->buffer_mutex);
-FF_DISABLE_DEPRECATION_WARNINGS
- if (avctx->thread_safe_callbacks || (
-#if FF_API_GET_BUFFER
- !avctx->get_buffer &&
-#endif
- avctx->get_buffer2 == avcodec_default_get_buffer2)) {
-FF_ENABLE_DEPRECATION_WARNINGS
+ if (avctx->thread_safe_callbacks ||
+ avctx->get_buffer2 == avcodec_default_get_buffer2) {
err = ff_get_buffer(avctx, f->f, flags);
} else {
pthread_mutex_lock(&p->progress_mutex);
@@ -837,10 +810,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
pthread_mutex_unlock(&p->progress_mutex);
}
-FF_DISABLE_DEPRECATION_WARNINGS
if (!THREAD_SAFE_CALLBACKS(avctx) && !avctx->codec->update_thread_context)
ff_thread_finish_setup(avctx);
-FF_ENABLE_DEPRECATION_WARNINGS
if (err)
av_buffer_unref(&f->progress);
@@ -888,15 +859,9 @@ void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
PerThreadContext *p = avctx->internal->thread_ctx;
FrameThreadContext *fctx;
AVFrame *dst, *tmp;
-FF_DISABLE_DEPRECATION_WARNINGS
int can_direct_free = !(avctx->active_thread_type & FF_THREAD_FRAME) ||
avctx->thread_safe_callbacks ||
- (
-#if FF_API_GET_BUFFER
- !avctx->get_buffer &&
-#endif
- avctx->get_buffer2 == avcodec_default_get_buffer2);
-FF_ENABLE_DEPRECATION_WARNINGS
+ avctx->get_buffer2 == avcodec_default_get_buffer2;
if (!f->f || !f->f->buf[0])
return;
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 03a4a5e1c2..18d86e3385 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -717,12 +717,6 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags
if ((ret = update_frame_pool(avctx, frame)) < 0)
return ret;
-#if FF_API_GET_BUFFER
-FF_DISABLE_DEPRECATION_WARNINGS
- frame->type = FF_BUFFER_TYPE_INTERNAL;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
switch (avctx->codec_type) {
case AVMEDIA_TYPE_VIDEO:
return video_get_buffer(avctx, frame);
@@ -843,35 +837,6 @@ int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame)
return 0;
}
-#if FF_API_GET_BUFFER
-FF_DISABLE_DEPRECATION_WARNINGS
-int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame)
-{
- return avcodec_default_get_buffer2(avctx, frame, 0);
-}
-
-typedef struct CompatReleaseBufPriv {
- AVCodecContext avctx;
- AVFrame frame;
- uint8_t avframe_padding[1024]; // hack to allow linking to a avutil with larger AVFrame
-} CompatReleaseBufPriv;
-
-static void compat_free_buffer(void *opaque, uint8_t *data)
-{
- CompatReleaseBufPriv *priv = opaque;
- if (priv->avctx.release_buffer)
- priv->avctx.release_buffer(&priv->avctx, &priv->frame);
- av_freep(&priv);
-}
-
-static void compat_release_buffer(void *opaque, uint8_t *data)
-{
- AVBufferRef *buf = opaque;
- av_buffer_unref(&buf);
-}
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
{
return ff_init_buffer_info(avctx, frame);
@@ -908,124 +873,6 @@ static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
} else
avctx->sw_pix_fmt = avctx->pix_fmt;
-#if FF_API_GET_BUFFER
-FF_DISABLE_DEPRECATION_WARNINGS
- /*
- * Wrap an old get_buffer()-allocated buffer in a bunch of AVBuffers.
- * We wrap each plane in its own AVBuffer. Each of those has a reference to
- * a dummy AVBuffer as its private data, unreffing it on free.
- * When all the planes are freed, the dummy buffer's free callback calls
- * release_buffer().
- */
- if (avctx->get_buffer) {
- CompatReleaseBufPriv *priv = NULL;
- AVBufferRef *dummy_buf = NULL;
- int planes, i, ret;
-
- if (flags & AV_GET_BUFFER_FLAG_REF)
- frame->reference = 1;
-
- ret = avctx->get_buffer(avctx, frame);
- if (ret < 0)
- return ret;
-
- /* return if the buffers are already set up
- * this would happen e.g. when a custom get_buffer() calls
- * avcodec_default_get_buffer
- */
- if (frame->buf[0])
- goto end0;
-
- priv = av_mallocz(sizeof(*priv));
- if (!priv) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
- priv->avctx = *avctx;
- priv->frame = *frame;
-
- dummy_buf = av_buffer_create(NULL, 0, compat_free_buffer, priv, 0);
- if (!dummy_buf) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
-
-#define WRAP_PLANE(ref_out, data, data_size) \
-do { \
- AVBufferRef *dummy_ref = av_buffer_ref(dummy_buf); \
- if (!dummy_ref) { \
- ret = AVERROR(ENOMEM); \
- goto fail; \
- } \
- ref_out = av_buffer_create(data, data_size, compat_release_buffer, \
- dummy_ref, 0); \
- if (!ref_out) { \
- av_buffer_unref(&dummy_ref); \
- av_frame_unref(frame); \
- ret = AVERROR(ENOMEM); \
- goto fail; \
- } \
-} while (0)
-
- if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
-
- planes = av_pix_fmt_count_planes(frame->format);
- /* workaround for AVHWAccel plane count of 0, buf[0] is used as
- check for allocated buffers: make libavcodec happy */
- if (desc && desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
- planes = 1;
- if (!desc || planes <= 0) {
- ret = AVERROR(EINVAL);
- goto fail;
- }
-
- for (i = 0; i < planes; i++) {
- int v_shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
- int plane_size = (frame->height >> v_shift) * frame->linesize[i];
-
- WRAP_PLANE(frame->buf[i], frame->data[i], plane_size);
- }
- } else {
- int planar = av_sample_fmt_is_planar(frame->format);
- planes = planar ? avctx->channels : 1;
-
- if (planes > FF_ARRAY_ELEMS(frame->buf)) {
- frame->nb_extended_buf = planes - FF_ARRAY_ELEMS(frame->buf);
- frame->extended_buf = av_malloc_array(sizeof(*frame->extended_buf),
- frame->nb_extended_buf);
- if (!frame->extended_buf) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
- }
-
- for (i = 0; i < FFMIN(planes, FF_ARRAY_ELEMS(frame->buf)); i++)
- WRAP_PLANE(frame->buf[i], frame->extended_data[i], frame->linesize[0]);
-
- for (i = 0; i < frame->nb_extended_buf; i++)
- WRAP_PLANE(frame->extended_buf[i],
- frame->extended_data[i + FF_ARRAY_ELEMS(frame->buf)],
- frame->linesize[0]);
- }
-
- av_buffer_unref(&dummy_buf);
-
-end0:
- frame->width = avctx->width;
- frame->height = avctx->height;
-
- return 0;
-
-fail:
- avctx->release_buffer(avctx, frame);
- av_freep(&priv);
- av_buffer_unref(&dummy_buf);
- return ret;
- }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
ret = avctx->get_buffer2(avctx, frame, flags);
end:
@@ -1092,21 +939,6 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
return ret;
}
-#if FF_API_GET_BUFFER
-void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic)
-{
- av_assert0(s->codec_type == AVMEDIA_TYPE_VIDEO);
-
- av_frame_unref(pic);
-}
-
-int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic)
-{
- av_assert0(0);
- return AVERROR_BUG;
-}
-#endif
-
int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
{
int i;
@@ -2483,18 +2315,6 @@ int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *sa
if (!frame)
return AVERROR(ENOMEM);
-#if FF_API_GET_BUFFER
-FF_DISABLE_DEPRECATION_WARNINGS
- if (avctx->get_buffer != avcodec_default_get_buffer) {
- av_log(avctx, AV_LOG_ERROR, "Custom get_buffer() for use with"
- "avcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer\n");
- av_log(avctx, AV_LOG_ERROR, "Please port your application to "
- "avcodec_decode_audio4()\n");
- avctx->get_buffer = avcodec_default_get_buffer;
- avctx->release_buffer = avcodec_default_release_buffer;
- }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
ret = avcodec_decode_audio4(avctx, frame, &got_frame, avpkt);
diff --git a/libavcodec/vda_h264_dec.c b/libavcodec/vda_h264_dec.c
index 6935e18684..a092693dbc 100644
--- a/libavcodec/vda_h264_dec.c
+++ b/libavcodec/vda_h264_dec.c
@@ -62,9 +62,6 @@ typedef struct {
void *hwaccel_context;
enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
-#if FF_API_GET_BUFFER
- int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
-#endif
} VDADecoderContext;
static enum AVPixelFormat get_format(struct AVCodecContext *avctx,
@@ -108,10 +105,6 @@ static inline void set_context(AVCodecContext *avctx)
avctx->get_format = get_format;
ctx->get_buffer2 = avctx->get_buffer2;
avctx->get_buffer2 = get_buffer2;
-#if FF_API_GET_BUFFER
- ctx->get_buffer = avctx->get_buffer;
- avctx->get_buffer = NULL;
-#endif
}
static inline void restore_context(AVCodecContext *avctx)
@@ -120,9 +113,6 @@ static inline void restore_context(AVCodecContext *avctx)
avctx->hwaccel_context = ctx->hwaccel_context;
avctx->get_format = ctx->get_format;
avctx->get_buffer2 = ctx->get_buffer2;
-#if FF_API_GET_BUFFER
- avctx->get_buffer = ctx->get_buffer;
-#endif
}
static int vdadec_decode(AVCodecContext *avctx,
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 7a1c633204..6109946a3f 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -76,9 +76,6 @@
#ifndef FF_API_DEINTERLACE
#define FF_API_DEINTERLACE (LIBAVCODEC_VERSION_MAJOR < 57)
#endif
-#ifndef FF_API_GET_BUFFER
-#define FF_API_GET_BUFFER (LIBAVCODEC_VERSION_MAJOR < 57)
-#endif
#ifndef FF_API_MISSING_SAMPLE
#define FF_API_MISSING_SAMPLE (LIBAVCODEC_VERSION_MAJOR < 57)
#endif