On 19/02/17 22:05, Luca Barbato wrote:
> On 19/02/2017 19:46, Mark Thompson wrote:
>> +#define CL_FUNC(name, desc, failure) do {                       \
>> +        ctx->name = clGetExtensionFunctionAddressForPlatform(   \
>> +            hwctx->platform_id, #name);                         \
>> +        if (!ctx->name) {                                       \
>> +            av_log(hwdev, AV_LOG_VERBOSE,                       \
>> +                   desc " function not found (%s).\n", #name);  \
>> +            goto failure;                                       \
>> +        } else {                                                \
>> +            av_log(hwdev, AV_LOG_VERBOSE,                       \
>> +                   desc " function found (%s).\n", #name);      \
>> +        }                                                       \
>> +    } while (0)
>> +
>> +#if HAVE_INTEL_OPENCL_VAAPI
>> +    {
>> +        CL_FUNC(clGetMemObjectFdIntel,
>> +                "Intel OpenCL to DRM mapping", no_vaapi);
>> +        CL_FUNC(clCreateBufferFromFdINTEL,
>> +                "Intel DRM to OpenCL buffer mapping", no_vaapi);
>> +        CL_FUNC(clCreateImageFromFdINTEL,
>> +                "Intel DRM to OpenCL image mapping", no_vaapi);
>> +
>> +        ctx->vaapi_enabled = 1;
>> +        if (0) {
>> +        no_vaapi:
>> +            av_log(hwdev, AV_LOG_ERROR, "VAAPI to OpenCL mapping "
>> +                   "not usable.\n");
>> +            ctx->vaapi_enabled = 0;
>> +        }
>> +    }
> 
> What about
> 
> +#define CL_FUNC(name, desc, failure) do {
> if (!fail) {
> ...
>      if (!ctx->name) {
>          fail = 1;
> 
>      }
> }
> } while (0)
> 
> {
>     int fail = 0;
>     CL_FUNC(clGetMemObjectFdIntel, "Intel OpenCL to DRM mapping");
> ...
> 
>     if (fail) {
> 
>     } else {
> 
>     }
> }
> 
> and we spare a slightly surprising goto?

Yeah, that's a nicer way to do it.  Changed.

Thanks,

- Mark
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to