diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-05-12 00:06:35 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-05-12 00:06:35 +0200 |
commit | c4fe50b954a0490c54efca19682cfae00eba3145 (patch) | |
tree | cb22437d8ba280f221417ed8638b5a0b26413b75 | |
parent | fa0f7c024e90a5337892cbc3b78e936ba5d25cf3 (diff) | |
parent | ebc29519d1634bfeb386c20a5d8a52837aae2436 (diff) | |
download | ffmpeg-c4fe50b954a0490c54efca19682cfae00eba3145.tar.gz |
Merge commit 'ebc29519d1634bfeb386c20a5d8a52837aae2436'
* commit 'ebc29519d1634bfeb386c20a5d8a52837aae2436':
hwaccel: Support specific frame allocators
Conflicts:
libavcodec/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/avcodec.h | 5 | ||||
-rw-r--r-- | libavcodec/utils.c | 11 |
2 files changed, 14 insertions, 2 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 70747ee0f0..431e0eab56 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3243,6 +3243,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. * * Meaningful frame information (codec specific) is guaranteed to diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 04ca363610..925c26ed83 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -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; |