• unity解码4k图片过慢,使用turbojpeg加速,使用opencl加速,使用libjpeg,使用v4l2


    、项目需要,要求用unity显示4k摄像头数据。unity自身有现成的摄像头调用方法,但是太粗糙了,很多参数无法设置。例如照片格式,jpeg,yuv,例如亮度色度曝光度。这是第一个问题,

    因为是在linux上使用,考虑用v4l2接口直接获取摄像头数据。v4l2是c语言,unity用c#语言,这是第二个问题。首先考虑获取到数据后用udp在进程间通信(我知道正统的方法是用管道,但是没用过,资料也少),但是发送“hello world”就能成功,发送图片数据就失败,后来反应过来是因为数据太多,超过包长度了(默认1472左右),又不想用tcp,怕速度不够。

     参考资料:

    (原创)基于ZedBoard的Webcam设计(一):USB摄像头(V4L2接口)的图片采集 - 超群天晴 - 博客园

    安卓系统采用v4l2接口打开YUYV和MJPEG摄像头,支持热插拔。_alterli的博客-CSDN博客_v4l2_​​​​​​pix_fmt_yuyv

    第二个问题最后只能c#调用c语言。好在c#对c语言的调用还算完善,在不了解之前还挺害怕,解决了之后发现很方便,很顺利。常见的c#调用c++有很多可以参考的资料,c语言生成dll就可以(linux里是so文件)。主要在意的是两种语言之间怎么传值,特别是byte数组的传值。这里不细说

    参考资料:

    C#调用C++_lishuangquan1987的博客-CSDN博客_c# 调用c++

    https://www.jianshu.com/p/048c7fedbcb4

    将c编译成.so 并调用(ubuntu)_Mihu_Tutu的博客-CSDN博客_c语言编译so

    第三个问题,摄像头只有使用jpeg格式才能以30fps的速度拍摄。但是4k的图片赋值给texture需要先解码,unity的解码方法写的很烂,被好多人吐槽。大家提到的方法就是用turbojpeg做解码。据说最开始是用libjpeg解码,但是libjpeg速度不够,turbojpeg利用的处理器的特性,有2-6倍的提速。

    如何接入turbojpeg就成了第四个问题。turbojpeg是开源的,用cmake编译还算容易。考虑到c语言效率更高,turbojpeg也只能用c语言,干脆接在摄像头调用后面,返回值从jpeg格式变成原始格式(注意,原始格式和bmp格式还有一点区别)。jpeg是压缩文件,长度不固定。原始数据长度就固定了(以4k为例,3840*2160*3)。再用格式转换赋值给texture。说起来容易做起来难,也解决了,不细说。

    参考资料:

    通过libjpeg-turbo实现对jpeg图像的解码_fengbingchun的博客-CSDN博客_libjpeg-turbo

    Jpeg编码4-6倍性能提升_洛克希德马丁的博客-CSDN博客_jpeg解码速度

    又遇到一个专属于我的问题,异步调用Texture2D.LoadImage【unity3d吧】_百度贴吧

    1. internal static void recvPicCallback(IntPtr intPtr, int len)
    2. {
    3. Marshal.Copy(intPtr, buffer, 0, len);
    4. //Debug.Log("callbackFinish:"+len);
    5. lock (textureColors)
    6. {
    7. for (int y = 0; y < height; y++)
    8. {
    9. for (int x = 0; x < width; x++)
    10. {
    11. textureColors[x + (height - y - 1) * width] = new Color(buffer[(x + y * width) * 3 + 0] / 255.0f, buffer[(x + y * width) * 3 + 1] / 255.0f, buffer[(x + y * width) * 3 + 2] / 255.0f);
    12. }
    13. }
    14. }
    15. }
    1. void Update()
    2. {
    3. try
    4. {
    5. //Debug.Log(System.Text.Encoding.Default.GetString(buffer));
    6. lock (textureColors)
    7. {
    8. playTexture.SetPixels(textureColors);
    9. }
    10. long t3 = DateTime.Now.ToFileTime();
    11. playTexture.Apply();
    12. rawImage.texture = playTexture;
    13. long t4 = DateTime.Now.ToFileTime();
    14. }
    15. catch (Exception e)
    16. {
    17. text.text = e.ToString();
    18. }
    19. }
    1. void GetPic()
    2. {
    3. while(true)
    4. {
    5. long t1 = DateTime.Now.ToFileTime();
    6. v4l2Grab(recvPicCallback);
    7. long t2 = DateTime.Now.ToFileTime();
    8. Debug.Log("t1:" + (t2 - t1));
    9. }
    10. }

    至此,可以用了,比原生摄像头快,可惜仍然非常卡。查看log,发现获取图片加解码耗时0.14ms,SetPixels耗时0.026ms,apply耗时0.012ms。没加解码之前的获取图片耗时我也看了,很快。基本确定仍然是图片解码耗时最多。

     第五个问题,本文最重要的问题,什么方法解码更快,turbojpeg是利用的cpu的特殊指令集进行加速,libjpeg速度据说一般。更快的我认为需要用gpu加速,查了资料,显卡没有专门的jpeg硬解码功能,但是nvidia有专门的nvjpeg库(资料太少,没用明白)。opencl也是专门的调用gpu的方法,刚好找到了对应的资料。又学opencl。

    参考资料:

    Jpeg 库的解码OpenCL优化_weixin_34014277的博客-CSDN博客

    第六个问题,opencl学习,先安装cuda,然后,按常规方法添加目录引用和库引用。例程很快就跑起来了,可惜跑上面的opencl解码程序还是出了问题。上面的代码调用了libjpeg库,只是自己替换了一个函数。所以还得自己编译libjpeg。

    参考资料:

    基于CUDA的OpenCL开发环境搭建与入门程序示例_Johnson Lu的博客-CSDN博客

    第七个问题,libjpeg编译。简单查了一下资料,费了不少劲,没成功。最开始看到turbojpeg里边有libjpeg的编译,寻思直接用,然后发现turbojpeg有自己的修改,两边版本不对应,只能用原版。用原版也不行,出现的问题如下。

    1. E:\platform_external_jpeg-master> nmake /f makefile.vc nodebug=1
    2. Microsoft (R) 程序维护实用工具 14.29.30040.0
    3. 版权所有 (C) Microsoft Corporation。 保留所有权利。
    4. makefile.vc(11) : fatal error U1052: 未找到文件“win32.mak”
    5. Stop.
    1. E:\platform_external_jpeg-master> nmake /f makefile.vc nodebug=1
    2. Microsoft (R) 程序维护实用工具 14.29.30040.0
    3. 版权所有 (C) Microsoft Corporation。 保留所有权利。
    4. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jcapimin.c
    5. jcapimin.c
    6. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jcapistd.c
    7. jcapistd.c
    8. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jctrans.c
    9. jctrans.c
    10. jctrans.c(278): warning C4100: “input_buf”: 未引用的形参
    11. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jcparam.c
    12. jcparam.c
    13. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jdatadst.c
    14. jdatadst.c
    15. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jcinit.c
    16. jcinit.c
    17. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jcmaster.c
    18. jcmaster.c
    19. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jcmarker.c
    20. jcmarker.c
    21. jcmarker.c(222): warning C4100: “cinfo”: 未引用的形参
    22. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jcmainct.c
    23. jcmainct.c
    24. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jcprepct.c
    25. jcprepct.c
    26. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jccoefct.c
    27. jccoefct.c
    28. jccoefct.c(341): warning C4100: “input_buf”: 未引用的形参
    29. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jccolor.c
    30. jccolor.c
    31. jccolor.c(354): warning C4456: “inptr”的声明隐藏了上一个本地声明
    32. jccolor.c(345): note: 参见“inptr”的声明
    33. jccolor.c(359): warning C4456: “col”的声明隐藏了上一个本地声明
    34. jccolor.c(347): note: 参见“col”的声明
    35. jccolor.c(386): warning C4102: “SLOW”: 未引用的标签
    36. jccolor.c(409): warning C4100: “cinfo”: 未引用的形参
    37. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jcsample.c
    38. jcsample.c
    39. jcsample.c(75): warning C4100: “cinfo”: 未引用的形参
    40. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jchuff.c
    41. jchuff.c
    42. jchuff.c(302): warning C4431: 缺少类型说明符 - 假定为 int。注意: C 不再支持默认 int
    43. jchuff.c(302): error C2054: 在“__inline__”之后应输入“(”
    44. jchuff.c(304): error C2085: “emit_bits”: 不在形参表中
    45. jchuff.c(304): error C2143: 语法错误: 缺少“;”(在“{”的前面)
    46. jchuff.c(342): warning C4013: “emit_bits”未定义;假设外部返回 int
    47. NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX64\x64\cl.EXE"”: 返回代码“0x2”
    48. Stop.
    49. E:\platform_external_jpeg-master>
    1. E:\platform_external_jpeg-master> nmake /f makefile.vc nodebug=1
    2. Microsoft (R) 程序维护实用工具 14.29.30040.0
    3. 版权所有 (C) Microsoft Corporation。 保留所有权利。
    4. cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -W4 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x05000000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -Ox -DNDEBUG -D_MT -MT -I. jchuff.c
    5. jchuff.c
    6. jchuff.c(302): warning C4431: 缺少类型说明符 - 假定为 int。注意: C 不再支持默认 int
    7. jchuff.c(302): error C2054: 在“__inline__”之后应输入“(”
    8. jchuff.c(304): error C2085: “emit_bits”: 不在形参表中
    9. jchuff.c(304): error C2143: 语法错误: 缺少“;”(在“{”的前面)
    10. jchuff.c(342): warning C4013: “emit_bits”未定义;假设外部返回 int
    11. NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX64\x64\cl.EXE"”: 返回代码“0x2
    12. Stop.
    13. E:\platform_external_jpeg-master>

    以上错误是本文想说的重点,查了好多资料都没找到办法。最后只能硬着头皮读源码,现在看来问题都在inline语句上,inline的具体功能我都不记得,查了资料越看越懵,只知道不同平台支持程度不一样。干脆所有inline都注释掉,然后居然就编译通过了。

    参考资料:

    LibJpeg编译_此间的年少的博客-CSDN博客_libjpeg编译

    Win10+VS2019编译Jpeg源码时缺少win32.mak文件的内容_Alexabc3000的博客-CSDN博客_win32.mak

    libjpeg 编译 使用_baidu_32526299的博客-CSDN博客_libjpeg

    C中__inline__的含义及作用-Typhony-ChinaUnix博客

    还有第八个问题,生成了lib文件,叫静态库,还得生成动态库(其实不生成好像也没问题,我因为代码跑不起来,在这个方向试了一下),反正动态库有需要的可以参考。

    修改makefile.vc文件的第100行开始的部分,改成如下内容(全是自己摸索的,没有资料),就ok了。

    1. all: libjpeg.lib libjpeg.dll cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe
    2. libjpeg.lib: $(LIBOBJECTS)
    3. $(RM) libjpeg.lib
    4. lib -out:libjpeg.lib $(LIBOBJECTS)
    5. libjpeg.dll: $(LIBOBJECTS)
    6. link -dll -out:libjpeg.dll $(LIBOBJECTS)
    7. cjpeg.exe: $(COBJECTS) libjpeg.lib
    8. $(link) $(LDFLAGS) -out:cjpeg.exe $(COBJECTS) libjpeg.lib $(LDLIBS)

    参考资料:

    LibJpeg编译_此间的年少的博客-CSDN博客_libjpeg编译

    最后,opencl解码jpeg的问题还没解决,后面还解决了一些问题,代码往后跑了一点点,最后一个错误日志如下,根据前面犯错学到的知识,错误代码是11,类型是 CL_BUILD_PROGRAM_FAILURE ,

    参考OpenCL错误码和说明_Javen_ManWJ的博客-CSDN博客_opencl 错误代码

    估计是cl语句有问题,可是cl语句完全不会啊,继续查资料,学习了一点点,感觉现有代码没有啥大问题,那只能系统的学,太浪费时间,搞不定了。以后再说

        con->context = clCreateContextFromType(contextProperties, flags, NULL, NULL, &errNum);
    cl_program program = clCreateProgramWithSource(c->context, 1, &sourcecode, sourcesize, &errercode);
    1. Platform Numbers: 1
    2. Platform Name: NVIDIA CUDA
    3. Platform Vendor: NVIDIA Corporation
    4. Platform Version: OpenCL 3.0 CUDA 11.6.127
    5. Platform Full Profile or Embeded Profile?: FULL_PROFILE
    6. Build log is :4:177: error: __kernel function cannot have argument whose type is, or contains, type size_t
    7. __kernel void idct_float(__global short* input, __global unsigned char* output, __global const float* dequantilize_table, __global const int* order, int blocks_per_mcu, size_t totalblocks)
    8. ^
    9. :24:33: error: unexpected type name 'float8': expected expression
    10. tmp12 = (tmp1 - tmp3) * float8(1.414213562) - tmp13; /* 2*c4 */
    11. ^
    12. :42:31: error: unexpected type name 'float8': expected expression
    13. tmp11 = (z11 - z13) * float8(1.414213562); /* 2*c4 */
    14. ^
    15. :44:28: error: unexpected type name 'float8': expected expression
    16. z5 = (z10 + z12) * float8(1.847759065); /* 2*c2 */
    17. ^
    18. :45:17: error: unexpected type name 'float8': expected expression
    19. tmp10 = float8(1.082392200) * z12 - z5; /* 2*(c2-c6) */
    20. ^
    21. :46:17: error: unexpected type name 'float8': expected expression
    22. tmp12 = float8(-2.613125930) * z10 + z5; /* -2*(c2+c6) */
    23. ^
    24. :53:23: error: unexpected type name 'float8': expected expression
    25. tmp7 = tmp0 - float8(2)*tmp7;
    26. ^
    27. :55:23: error: unexpected type name 'float8': expected expression
    28. tmp6 = tmp1 - float8(2)*tmp6;
    29. ^
    30. :57:23: error: unexpected type name 'float8': expected expression
    31. tmp5 = tmp2 - float8(2)*tmp5;
    32. ^
    33. :59:16: error: unexpected type name 'float8': expected expression
    34. tmp3 = float8(2)*tmp3 - tmp4;
    35. ^
    36. :76:29: error: unexpected type name 'float8': expected expression
    37. tmp12 = (w2 - w6) * float8(1.414213562) - tmp13;
    38. ^
    39. :89:31: error: unexpected type name 'float8': expected expression
    40. tmp11 = (z11 - z13) * float8(1.414213562);
    41. ^
    42. :91:28: error: unexpected type name 'float8': expected expression
    43. z5 = (z10 + z12) * float8(1.847759065); /* 2*c2 */
    44. ^
    45. :92:17: error: unexpected type name 'float8': expected expression
    46. tmp10 = float8(1.082392200) * z12 - z5; /* 2*(c2-c6) */
    47. ^
    48. :93:17: error: unexpected type name 'float8': expected expression
    49. tmp12 = float8(-2.613125930) * z10 + z5; /* -2*(c2+c6) */
    50. ^
    51. :100:23: error: unexpected type name 'float8': expected expression
    52. tmp7 = tmp0 - float8(2)*tmp7;
    53. ^
    54. :102:23: error: unexpected type name 'float8': expected expression
    55. tmp6 = tmp1 - float8(2)*tmp6;
    56. ^
    57. :104:23: error: unexpected type name 'float8': expected expression
    58. tmp5 = tmp2 - float8(2)*tmp5;
    59. ^
    60. :106:16: error: unexpected type name 'float8': expected expression
    61. tmp3 = float8(2)*tmp3 - tmp4;
    62. ^
    63. :120:17: error: unexpected type name 'float8': expected expression
    64. vstore8(RESULT(w0), 0, outptr);
    65. ^
    66. :119:44: note: expanded from macro 'RESULT'
    67. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    68. ^
    69. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    70. #define convert_uchar8(x) convert_uchar(x)
    71. ^
    72. :120:17: error: unexpected type name 'float8': expected expression
    73. :119:54: note: expanded from macro 'RESULT'
    74. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    75. ^
    76. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    77. #define convert_uchar8(x) convert_uchar(x)
    78. ^
    79. :121:17: error: unexpected type name 'float8': expected expression
    80. vstore8(RESULT(w7), 7, outptr);
    81. ^
    82. :119:44: note: expanded from macro 'RESULT'
    83. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    84. ^
    85. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    86. #define convert_uchar8(x) convert_uchar(x)
    87. ^
    88. :121:17: error: unexpected type name 'float8': expected expression
    89. :119:54: note: expanded from macro 'RESULT'
    90. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    91. ^
    92. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    93. #define convert_uchar8(x) convert_uchar(x)
    94. ^
    95. :122:17: error: unexpected type name 'float8': expected expression
    96. vstore8(RESULT(w1), 1, outptr);
    97. ^
    98. :119:44: note: expanded from macro 'RESULT'
    99. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    100. ^
    101. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    102. #define convert_uchar8(x) convert_uchar(x)
    103. ^
    104. :122:17: error: unexpected type name 'float8': expected expression
    105. :119:54: note: expanded from macro 'RESULT'
    106. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    107. ^
    108. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    109. #define convert_uchar8(x) convert_uchar(x)
    110. ^
    111. :123:17: error: unexpected type name 'float8': expected expression
    112. vstore8(RESULT(w6), 6, outptr);
    113. ^
    114. :119:44: note: expanded from macro 'RESULT'
    115. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    116. ^
    117. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    118. #define convert_uchar8(x) convert_uchar(x)
    119. ^
    120. :123:17: error: unexpected type name 'float8': expected expression
    121. :119:54: note: expanded from macro 'RESULT'
    122. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    123. ^
    124. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    125. #define convert_uchar8(x) convert_uchar(x)
    126. ^
    127. :124:17: error: unexpected type name 'float8': expected expression
    128. vstore8(RESULT(w2), 2, outptr);
    129. ^
    130. :119:44: note: expanded from macro 'RESULT'
    131. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    132. ^
    133. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    134. #define convert_uchar8(x) convert_uchar(x)
    135. ^
    136. :124:17: error: unexpected type name 'float8': expected expression
    137. :119:54: note: expanded from macro 'RESULT'
    138. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    139. ^
    140. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    141. #define convert_uchar8(x) convert_uchar(x)
    142. ^
    143. :125:17: error: unexpected type name 'float8': expected expression
    144. vstore8(RESULT(w5), 5, outptr);
    145. ^
    146. :119:44: note: expanded from macro 'RESULT'
    147. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    148. ^
    149. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    150. #define convert_uchar8(x) convert_uchar(x)
    151. ^
    152. :125:17: error: unexpected type name 'float8': expected expression
    153. :119:54: note: expanded from macro 'RESULT'
    154. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    155. ^
    156. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    157. #define convert_uchar8(x) convert_uchar(x)
    158. ^
    159. :126:17: error: unexpected type name 'float8': expected expression
    160. vstore8(RESULT(w4), 4, outptr);
    161. ^
    162. :119:44: note: expanded from macro 'RESULT'
    163. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    164. ^
    165. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    166. #define convert_uchar8(x) convert_uchar(x)
    167. ^
    168. :126:17: error: unexpected type name 'float8': expected expression
    169. :119:54: note: expanded from macro 'RESULT'
    170. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    171. ^
    172. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    173. #define convert_uchar8(x) convert_uchar(x)
    174. ^
    175. :127:17: error: unexpected type name 'float8': expected expression
    176. vstore8(RESULT(w3), 3, outptr);
    177. ^
    178. :119:44: note: expanded from macro 'RESULT'
    179. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    180. ^
    181. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    182. #define convert_uchar8(x) convert_uchar(x)
    183. ^
    184. :127:17: error: unexpected type name 'float8': expected expression
    185. :119:54: note: expanded from macro 'RESULT'
    186. #define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
    187. ^
    188. cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
    189. #define convert_uchar8(x) convert_uchar(x)
    190. ^
    191. Assertion failed: CL_SUCCESS == errercode, file D:\code2022.5\Test\testOpenCLJpegDecoder\testOpenCLJpegDecoder\opencl_package.c, line 134
    192. D:\code2022.5\Test\testOpenCLJpegDecoder\x64\Debug\testOpenCLJpegDecoder.exe (进程 10520)已退出,代码为 3
    193. 要在调试停止时自动关闭控制台,请启用“工具”->“选项”->“调试”->“调试停止时自动关闭控制台”。
    194. 按任意键关闭此窗口. . .
    1. /* Error Codes */
    2. #define CL_SUCCESS 0
    3. #define CL_DEVICE_NOT_FOUND -1
    4. #define CL_DEVICE_NOT_AVAILABLE -2
    5. #define CL_COMPILER_NOT_AVAILABLE -3
    6. #define CL_MEM_OBJECT_ALLOCATION_FAILURE -4
    7. #define CL_OUT_OF_RESOURCES -5
    8. #define CL_OUT_OF_HOST_MEMORY -6
    9. #define CL_PROFILING_INFO_NOT_AVAILABLE -7
    10. #define CL_MEM_COPY_OVERLAP -8
    11. #define CL_IMAGE_FORMAT_MISMATCH -9
    12. #define CL_IMAGE_FORMAT_NOT_SUPPORTED -10
    13. #define CL_BUILD_PROGRAM_FAILURE -11
    14. #define CL_MAP_FAILURE -12
    15. #define CL_MISALIGNED_SUB_BUFFER_OFFSET -13
    16. #define CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST -14
    17. #define CL_COMPILE_PROGRAM_FAILURE -15
    18. #define CL_LINKER_NOT_AVAILABLE -16
    19. #define CL_LINK_PROGRAM_FAILURE -17
    20. #define CL_DEVICE_PARTITION_FAILED -18
    21. #define CL_KERNEL_ARG_INFO_NOT_AVAILABLE -19

  • 相关阅读:
    云原生丨MLOps与DevOps的区别
    Vue3:组件的生命周期函数
    dynamic-datasource-spring-boot-starter
    硬件描述语言(HDL)基础——层次结构
    鸿蒙HarmonyOS实战-ArkUI组件(mediaquery)
    机器学习第八次课
    Git 之 push 代码后,如何回退/回滚到之前的版本的方法
    在CentOS 7上安装JDK 17
    leetcode19-删除链表的倒数第n个结点
    什么是JUC
  • 原文地址:https://blog.csdn.net/u010752777/article/details/126367229