@@ -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);