* commit 'ebc29519d1634bfeb386c20a5d8a52837aae2436': hwaccel: Support specific frame allocators Conflicts: libavcodec/utils.c
Unified · Split
| @@ -3242,6 +3242,11 @@ typedef struct AVHWAccel { · 3241 unmodified lines | |||
| 3242 | */ | 3242 | */ |
| 3243 | struct AVHWAccel *next; | 3243 | struct AVHWAccel *next; |
| 3244 | 3244 | ||
| 3245 | /** | ||
| 3246 | * Allocate a custom buffer | ||
| 3247 | */ | ||
| 3248 | int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame); | ||
| 3249 | |||
| 3245 | /** | 3250 | /** |
| 3246 | * Called at the beginning of each frame or field picture. | 3251 | * Called at the beginning of each frame or field picture. |
| 3247 | * | 3252 | * |
| @@ -850,6 +850,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) · 849 unmodified lines | |||
| 850 | 850 | ||
| 851 | static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags) | 851 | static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags) |
| 852 | { | 852 | { |
| 853 | const AVHWAccel *hwaccel = avctx->hwaccel; | ||
| 853 | int override_dimensions = 1; | 854 | int override_dimensions = 1; |
| 854 | int ret; | 855 | int ret; |
| 855 | 856 | ||
| @@ -872,6 +873,11 @@ static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags) · 16 unmodified lines | |||
| 872 | if ((ret = ff_init_buffer_info(avctx, frame)) < 0) | 873 | if ((ret = ff_init_buffer_info(avctx, frame)) < 0) |
| 873 | return ret; | 874 | return ret; |
| 874 | 875 | ||
| 876 | if (hwaccel && hwaccel->alloc_frame) { | ||
| 877 | ret = hwaccel->alloc_frame(avctx, frame); | ||
| 878 | goto end; | ||
| 879 | } | ||
| 880 | |||
| 875 | #if FF_API_GET_BUFFER | 881 | #if FF_API_GET_BUFFER |
| 876 | FF_DISABLE_DEPRECATION_WARNINGS | 882 | FF_DISABLE_DEPRECATION_WARNINGS |
| 877 | /* | 883 | /* |
| @@ -898,7 +904,7 @@ FF_DISABLE_DEPRECATION_WARNINGS · 20 unmodified lines | |||
| 898 | * avcodec_default_get_buffer | 904 | * avcodec_default_get_buffer |
| 899 | */ | 905 | */ |
| 900 | if (frame->buf[0]) | 906 | if (frame->buf[0]) |
| 901 | goto end; | 907 | goto end0; |
| 902 | 908 | ||
| 903 | priv = av_mallocz(sizeof(*priv)); | 909 | priv = av_mallocz(sizeof(*priv)); |
| 904 | if (!priv) { | 910 | if (!priv) { |
| @@ -974,7 +980,7 @@ do { \ · 69 unmodified lines | |||
| 974 | 980 | ||
| 975 | av_buffer_unref(&dummy_buf); | 981 | av_buffer_unref(&dummy_buf); |
| 976 | 982 | ||
| 977 | end: | 983 | end0: |
| 978 | frame->width = avctx->width; | 984 | frame->width = avctx->width; |
| 979 | frame->height = avctx->height; | 985 | frame->height = avctx->height; |
| 980 | 986 | ||
| @@ -991,6 +997,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 10 unmodified lines | |||
| 991 | 997 | ||
| 992 | ret = avctx->get_buffer2(avctx, frame, flags); | 998 | ret = avctx->get_buffer2(avctx, frame, flags); |
| 993 | 999 | ||
| 1000 | end: | ||
| 994 | if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions) { | 1001 | if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions) { |
| 995 | frame->width = avctx->width; | 1002 | frame->width = avctx->width; |
| 996 | frame->height = avctx->height; | 1003 | frame->height = avctx->height; |