[FFmpeg-devel] [PATCH 1/4] hwcontext_opencl: Allocate a test image in frames_init
Mark Thompson
sw at jkqxz.net
Tue May 22 01:35:08 EEST 2018
This ensures that the format and dimensions are actually valid -
previously this wasn't checked, so we would only fail when the user
actually attempted to allocate an image.
---
libavutil/hwcontext_opencl.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index 43b5c5ae0c..c29a521f07 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -1696,11 +1696,23 @@ static int opencl_frames_init_command_queue(AVHWFramesContext *hwfc)
static int opencl_frames_init(AVHWFramesContext *hwfc)
{
if (!hwfc->pool) {
+ AVBufferRef *test_ref;
+
hwfc->internal->pool_internal =
av_buffer_pool_init2(sizeof(cl_mem), hwfc,
&opencl_pool_alloc, NULL);
if (!hwfc->internal->pool_internal)
return AVERROR(ENOMEM);
+
+ test_ref = av_buffer_pool_get(hwfc->internal->pool_internal);
+ if (!test_ref) {
+ av_log(hwfc, AV_LOG_ERROR, "Unable to create %dx%d images "
+ "with format %s.\n", hwfc->width, hwfc->height,
+ av_get_pix_fmt_name(hwfc->sw_format));
+ return AVERROR(EINVAL);
+ }
+
+ av_buffer_unref(&test_ref);
}
return opencl_frames_init_command_queue(hwfc);
--
2.16.3
More information about the ffmpeg-devel
mailing list