Commit c4fe50b9 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'ebc29519'

* commit 'ebc29519':
  hwaccel: Support specific frame allocators

Conflicts:
	libavcodec/utils.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents fa0f7c02 ebc29519
......@@ -3242,6 +3242,11 @@ typedef struct AVHWAccel {
*/
struct AVHWAccel *next;
/**
* Allocate a custom buffer
*/
int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame);
/**
* Called at the beginning of each frame or field picture.
*
......
......@@ -850,6 +850,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
{
const AVHWAccel *hwaccel = avctx->hwaccel;
int override_dimensions = 1;
int ret;
......@@ -872,6 +873,11 @@ static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
if ((ret = ff_init_buffer_info(avctx, frame)) < 0)
return ret;
if (hwaccel && hwaccel->alloc_frame) {
ret = hwaccel->alloc_frame(avctx, frame);
goto end;
}
#if FF_API_GET_BUFFER
FF_DISABLE_DEPRECATION_WARNINGS
/*
......@@ -898,7 +904,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
* avcodec_default_get_buffer
*/
if (frame->buf[0])
goto end;
goto end0;
priv = av_mallocz(sizeof(*priv));
if (!priv) {
......@@ -974,7 +980,7 @@ do { \
av_buffer_unref(&dummy_buf);
end:
end0:
frame->width = avctx->width;
frame->height = avctx->height;
......@@ -991,6 +997,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
ret = avctx->get_buffer2(avctx, frame, flags);
end:
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions) {
frame->width = avctx->width;
frame->height = avctx->height;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment