It would reduce the boilerplate code users have to write.
Unified · Split
| @@ -2946,6 +2946,11 @@ typedef struct AVHWAccel { · 2945 unmodified lines | |||
| 2946 | */ | 2946 | */ |
| 2947 | struct AVHWAccel *next; | 2947 | struct AVHWAccel *next; |
| 2948 | 2948 | ||
| 2949 | /** | ||
| 2950 | * Allocate a custom buffer | ||
| 2951 | */ | ||
| 2952 | int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame); | ||
| 2953 | |||
| 2949 | /** | 2954 | /** |
| 2950 | * Called at the beginning of each frame or field picture. | 2955 | * Called at the beginning of each frame or field picture. |
| 2951 | * | 2956 | * |
| @@ -604,6 +604,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) · 603 unmodified lines | |||
| 604 | 604 | ||
| 605 | int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) | 605 | int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) |
| 606 | { | 606 | { |
| 607 | const AVHWAccel *hwaccel = avctx->hwaccel; | ||
| 607 | int override_dimensions = 1; | 608 | int override_dimensions = 1; |
| 608 | int ret; | 609 | int ret; |
| 609 | 610 | ||
| @@ -657,6 +658,11 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) · 47 unmodified lines | |||
| 657 | if (ret < 0) | 658 | if (ret < 0) |
| 658 | return ret; | 659 | return ret; |
| 659 | 660 | ||
| 661 | if (hwaccel && hwaccel->alloc_frame) { | ||
| 662 | ret = hwaccel->alloc_frame(avctx, frame); | ||
| 663 | goto end; | ||
| 664 | } | ||
| 665 | |||
| 660 | #if FF_API_GET_BUFFER | 666 | #if FF_API_GET_BUFFER |
| 661 | FF_DISABLE_DEPRECATION_WARNINGS | 667 | FF_DISABLE_DEPRECATION_WARNINGS |
| 662 | /* | 668 | /* |
| @@ -775,6 +781,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 112 unmodified lines | |||
| 775 | 781 | ||
| 776 | ret = avctx->get_buffer2(avctx, frame, flags); | 782 | ret = avctx->get_buffer2(avctx, frame, flags); |
| 777 | 783 | ||
| 784 | end: | ||
| 778 | if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions) { | 785 | if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions) { |
| 779 | frame->width = avctx->width; | 786 | frame->width = avctx->width; |
| 780 | frame->height = avctx->height; | 787 | frame->height = avctx->height; |