diff mbox

[FFmpeg-devel] lavu: add calling convention for OpenCL callback.

Message ID 1528299104-26785-1-git-send-email-ruiling.song@intel.com
State Accepted
Commit e4006a474f689ef9534448d3382d220c62b413b6
Headers show

Commit Message

Ruiling Song June 6, 2018, 3:31 p.m. UTC
This fix a build error on Windows:
C2440: connot convert from 'void (__cdecl *) (...)' to 'void (__stdcall *)(...)'.

Signed-off-by: Ruiling Song <ruiling.song@intel.com>
---
 libavutil/hwcontext_opencl.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Mark Thompson June 6, 2018, 10:21 p.m. UTC | #1
On 06/06/18 16:31, Ruiling Song wrote:
> This fix a build error on Windows:
> C2440: connot convert from 'void (__cdecl *) (...)' to 'void (__stdcall *)(...)'.
> 
> Signed-off-by: Ruiling Song <ruiling.song@intel.com>
> ---
>  libavutil/hwcontext_opencl.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
> index 43b5c5a..e08d7bc 100644
> --- a/libavutil/hwcontext_opencl.c
> +++ b/libavutil/hwcontext_opencl.c
> @@ -141,9 +141,10 @@ typedef struct OpenCLFramesContext {
>  } OpenCLFramesContext;
>  
>  
> -static void opencl_error_callback(const char *errinfo,
> -                                  const void *private_info, size_t cb,
> -                                  void *user_data)
> +static void CL_CALLBACK opencl_error_callback(const char *errinfo,
> +                                              const void *private_info,
> +                                              size_t cb,
> +                                              void *user_data)
>  {
>      AVHWDeviceContext *ctx = user_data;
>      av_log(ctx, AV_LOG_ERROR, "OpenCL error: %s\n", errinfo);
> 

Yep, applied.

Is this visible in any MSVC build, or does it have to be 32-bit?  (All my testing on Windows has been done with MinGW-w64, where __stdcall/__cdecl have no effect and this goes unnoticed.)

Thanks,

- Mark
Hendrik Leppkes June 6, 2018, 10:30 p.m. UTC | #2
On Thu, Jun 7, 2018 at 12:21 AM, Mark Thompson <sw@jkqxz.net> wrote:
> On 06/06/18 16:31, Ruiling Song wrote:
>> This fix a build error on Windows:
>> C2440: connot convert from 'void (__cdecl *) (...)' to 'void (__stdcall *)(...)'.
>>
>> Signed-off-by: Ruiling Song <ruiling.song@intel.com>
>> ---
>>  libavutil/hwcontext_opencl.c | 7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
>> index 43b5c5a..e08d7bc 100644
>> --- a/libavutil/hwcontext_opencl.c
>> +++ b/libavutil/hwcontext_opencl.c
>> @@ -141,9 +141,10 @@ typedef struct OpenCLFramesContext {
>>  } OpenCLFramesContext;
>>
>>
>> -static void opencl_error_callback(const char *errinfo,
>> -                                  const void *private_info, size_t cb,
>> -                                  void *user_data)
>> +static void CL_CALLBACK opencl_error_callback(const char *errinfo,
>> +                                              const void *private_info,
>> +                                              size_t cb,
>> +                                              void *user_data)
>>  {
>>      AVHWDeviceContext *ctx = user_data;
>>      av_log(ctx, AV_LOG_ERROR, "OpenCL error: %s\n", errinfo);
>>
>
> Yep, applied.
>
> Is this visible in any MSVC build, or does it have to be 32-bit?  (All my testing on Windows has been done with MinGW-w64, where __stdcall/__cdecl have no effect and this goes unnoticed.)
>

Should be 32-bit only, there are no different calling conventions on 64-bit.

- Hendrik
Ruiling Song June 7, 2018, 3:42 p.m. UTC | #3
> -----Original Message-----

> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of

> Mark Thompson

> Sent: Thursday, June 7, 2018 6:21 AM

> To: ffmpeg-devel@ffmpeg.org

> Subject: Re: [FFmpeg-devel] [PATCH] lavu: add calling convention for OpenCL

> callback.

> 

> On 06/06/18 16:31, Ruiling Song wrote:

> > This fix a build error on Windows:

> > C2440: connot convert from 'void (__cdecl *) (...)' to 'void (__stdcall *)(...)'.

> >

> > Signed-off-by: Ruiling Song <ruiling.song@intel.com>

> > ---

> >  libavutil/hwcontext_opencl.c | 7 ++++---

> >  1 file changed, 4 insertions(+), 3 deletions(-)

> >

> > diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c

> > index 43b5c5a..e08d7bc 100644

> > --- a/libavutil/hwcontext_opencl.c

> > +++ b/libavutil/hwcontext_opencl.c

> > @@ -141,9 +141,10 @@ typedef struct OpenCLFramesContext {

> >  } OpenCLFramesContext;

> >

> >

> > -static void opencl_error_callback(const char *errinfo,

> > -                                  const void *private_info, size_t cb,

> > -                                  void *user_data)

> > +static void CL_CALLBACK opencl_error_callback(const char *errinfo,

> > +                                              const void *private_info,

> > +                                              size_t cb,

> > +                                              void *user_data)

> >  {

> >      AVHWDeviceContext *ctx = user_data;

> >      av_log(ctx, AV_LOG_ERROR, "OpenCL error: %s\n", errinfo);

> >

> 

> Yep, applied.

> 

> Is this visible in any MSVC build, or does it have to be 32-bit?  (All my testing on

> Windows has been done with MinGW-w64, where __stdcall/__cdecl have no

> effect and this goes unnoticed.)

Yes, I think this should only occur on 32bit. In fact, I am not intentionally trying to build 32bit.
I am basically follow the steps in: https://pracucci.com/compile-ffmpeg-on-windows-with-visual-studio-compiler.html
I installed VS 2017 and msys2-x86_64 (http://www.msys2.org)
Then I launch mingw64 in vs2017 command prompt through 'msys2_shell.cmd -mingw64 -use-full-path'.
I installed Intel OpenCL SDK, and modify INCLUDE and LIB to point to it.
The Intel OpenCL SDK provides both x86 and x64 OpenCL.lib.
I first use x64 version OpenCL.lib. then I configure FFmpeg like:
./configure --toolchain=msvc --enable-yasm --arch=x86_x64 --enable-asm --enable-opencl.
But the configure failed with below error log. Seems it still tries to build WIN32. I am not sure what's wrong.
I just didn't have enough time to look into this. so I switched to x86 version OpenCL.lib, then I met the bug.

cl -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_WIN32_WINNT=0x0600 -nologo -c -Fo./ffconf.EeohdeiF/test.o ./ffconf.EeohdeiF/test.c
test.c
./compat/windows/mslink -nologo -LARGEADDRESSAWARE -out:./ffconf.EeohdeiF/test.exe ./ffconf.EeohdeiF/test.o OpenCL.lib
test.o : error LNK2019: unresolved external symbol _clEnqueueNDRangeKernel@36 referenced in function _check_clEnqueueNDRangeKernel
C:\Program Files (x86)\Intel\OpenCL SDK\6.3\lib\x64\OpenCL.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'

Thanks!
Ruiling
> 

> Thanks,

> 

> - Mark

> _______________________________________________

> ffmpeg-devel mailing list

> ffmpeg-devel@ffmpeg.org

> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
diff mbox

Patch

diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index 43b5c5a..e08d7bc 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -141,9 +141,10 @@  typedef struct OpenCLFramesContext {
 } OpenCLFramesContext;
 
 
-static void opencl_error_callback(const char *errinfo,
-                                  const void *private_info, size_t cb,
-                                  void *user_data)
+static void CL_CALLBACK opencl_error_callback(const char *errinfo,
+                                              const void *private_info,
+                                              size_t cb,
+                                              void *user_data)
 {
     AVHWDeviceContext *ctx = user_data;
     av_log(ctx, AV_LOG_ERROR, "OpenCL error: %s\n", errinfo);