mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-14 19:25:01 +00:00
hwaccel: Support specific frame allocators
It would reduce the boilerplate code users have to write.
This commit is contained in:
parent
a871ef0cc9
commit
ebc29519d1
@ -2946,6 +2946,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.
|
||||
*
|
||||
|
@ -604,6 +604,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
|
||||
|
||||
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
|
||||
{
|
||||
const AVHWAccel *hwaccel = avctx->hwaccel;
|
||||
int override_dimensions = 1;
|
||||
int ret;
|
||||
|
||||
@ -657,6 +658,11 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
|
||||
if (ret < 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
|
||||
/*
|
||||
@ -775,6 +781,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;
|
||||
|
Loading…
Reference in New Issue
Block a user