Unity の 4K 画像のデコードが遅すぎる、高速化するにはturbojpeg を使用、高速化するには opencl を使用、libjpeg を使用、v4l2 を使用

追記:

案の定、libjpeg はどの記事に最新バージョンが 1996 年であると書かれていたのか覚えておらず、1996 年以来更新されていないいわゆる公式 Web サイトさえ提供していました。 . 私が使ったのは新しいもので、正しいアドレスを見つけて簡単にコンパイルできました。私の記事全体が覆されたので、以下は読まないでください。libjpeg-turbo を自分でコンパイルしないでください。既製のバージョンをダウンロードするとパフォーマンスが向上するようです。

libjpegのダウンロードアドレス:

/file のディレクトリリスト

libjpeg-turbo ダウンロード アドレス:

libjpeg-turbo - SourceForge.net でファイルを参照する

以下は機能しませんでした:

, プロジェクトでは 4k カメラのデータを表示するために Unity を使用する必要があります。Unity自体には既製のカメラ呼び出し方法がありますが、あまりにも大雑把すぎて設定できないパラメータも多くあります。写真形式、jpeg、yuv、明るさ、彩度、露出など。これが最初の質問ですが、

Linux で使用されるため、v4l2 インターフェイスを使用してカメラ データを直接取得することを検討してください。v4l2 は C 言語、Unity は C# 言語を使用します、これは 2 番目の質問です。データ取得後のプロセス間の通信にまずudpを使うことを検討します(オーソドックスな方法はパイプを使うのは知っていますが、使ったことがなく、資料が少ない)が、「hello world」の送信は成功するが、画像データの送信は失敗します、そして、データが多すぎてパケット長(デフォルトでは約1472)を超え、速度が十分でないことを恐れてtcpを使いたくなかったため、ここに来ましたと応答します。

 参考文献:

(オリジナル) ZedBoard ベースの Web カメラ設計 (1): USB カメラ (V4L2 インターフェイス) 画像コレクション - Chaoqun Tianqing - 博客园

Android システムは v4l2 インターフェイスを使用して YUYV カメラと MJPEG カメラを開き、ホットプラグをサポートします。_alterli のブログ-CSDN ブログ_v4l2_ pix_fmt_yuyv

2つ目の問題は、最終的にC言語を呼び出せるのはC#だけだということです。幸いなことに、C# の C 言語呼び出しは非常に完璧で、理解できない前はかなり怖かったですが、解決してみると、非常に便利でスムーズであることがわかりました。C++ を呼び出す一般的な C# に関する参考資料が多数あり、C 言語は DLL (Linux では so ファイル) を生成できます。主な関心事は、2 つの言語間で値を転送する方法、特にバイト配列の値を転送する方法です。ここでは詳細には触れません

参考文献:

C# が C++ を呼び出す_lishuangquan1987 のブログ - CSDN blog_c# が C++ を呼び出す

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

c を .so にコンパイルし、(ubuntu)_Mihu_Tutu のブログ - CSDN blog_c 言語コンパイルを呼び出します。

3 番目の問題は、カメラが jpeg 形式で 30fps でしか撮影できないことです。ただし、4K 画像をテクスチャに割り当てるには、最初にデコードする必要があり、Unity のデコード方法の記述が不十分であり、多くの人から不満の声が上がっています。あなたが言及した方法は、デコードにturbojpegを使用することです。当初はデコードにlibjpegを使用していたと言われていますが、libjpegでは速度が足りず、turbojpegが使用するプロセッサの特性により2~6倍の高速化が見られます。

Turbojpeg にアクセスする方法が 4 番目の質問になります。turbojpeg はオープンソースであり、cmake を使用してコンパイルするのは比較的簡単です。C 言語の方が効率的であることを考慮すると、turbojpeg は C 言語でのみ使用でき、単純にカメラ呼び出しに接続され、戻り値が jpeg 形式から独自の形式に変わります (オリジナルとは少し異なることに注意してください)形式と bmp 形式)。jpegは圧縮ファイルなので長さは固定されていません。元のデータ長は固定です (4k を例にとると、3840*2160*3)。次にフォーマット変換を使用してテクスチャに割り当てます。言うは易く行うは難しですが、解決するものでもあり、複雑ではありません。

参考文献:

libjpeg-turbo_fengbingchun のブログ - CSDN blog_libjpeg-turbo を介して jpeg 画像をデコードする

Jpeg エンコードのパフォーマンスが 4 ~ 6 倍向上_Lockheed Martin のブログ - CSDN ブログ_jpeg デコード速度

また、Texture2D.LoadImage を非同期的に呼び出すという、私に属する問題にも遭遇しました [unity3d bar]_Baidu Post Bar

internal static void recvPicCallback(IntPtr intPtr, int len)
    {
        Marshal.Copy(intPtr, buffer, 0, len);
        //Debug.Log("callbackFinish:"+len);
        lock (textureColors)
        {
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    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);
                }
            }
        }
    }
void Update()
    {
        try
        {
            //Debug.Log(System.Text.Encoding.Default.GetString(buffer));
            lock (textureColors)
            {
                playTexture.SetPixels(textureColors);
            }
            long t3 = DateTime.Now.ToFileTime();
            playTexture.Apply();
            rawImage.texture = playTexture;
            long t4 = DateTime.Now.ToFileTime();
            
        }
        catch (Exception e)
        {
            text.text = e.ToString();
        }
    }
void GetPic()
    {
        while(true)
        {
            long t1 = DateTime.Now.ToFileTime();           
            v4l2Grab(recvPicCallback);
            long t2 = DateTime.Now.ToFileTime();
            Debug.Log("t1:" + (t2 - t1));
        }
    }

これまでのところ、元のカメラよりも高速に使用できますが、残念ながらまだ非常に行き詰まっています。ログを確認すると、画像の取得とデコードに 0.14 ミリ秒、SetPixels に 0.026 ミリ秒、適用に 0.012 ミリ秒かかっていることがわかります。デコード前の画像の取得に時間がかかることも確認しましたが、非常に高速でした。基本的には、画像のデコードが依然として最も時間がかかると判断されます。

 5 番目の質問は、この記事で最も重要な質問で、どの方法でデコードするのが速いかということです。turbojpeg は CPU の特別な命令セットを使用して高速化します。libjpeg の速度は平均的であると言われています。速い方はgpuで高速化する必要があると思いますが、情報を確認したところ、グラフィックカードには特別なjpegハードデコード機能はありませんが、nvidiaには特別なnvjpegライブラリがあります(情報が少なすぎて理解するのに役に立ちません)。Opencl も GPU を呼び出す特別なメソッドであり、対応する情報を見つけたところです。openclをもう一度学びましょう。

参考文献:

Jpeg ライブラリの OpenCL 最適化のデコード - Weixin_34014277 のブログ - CSDN ブログ

6 番目の質問、opencl の学習では、まず cuda をインストールし、次に通常の方法でディレクトリ参照とライブラリ参照を追加します。ルーチンはすぐに実行されましたが、残念なことに、上記の opencl デコード プログラムにはまだ問題がありました。上記のコードは libjpeg ライブラリを呼び出しますが、関数をそれ自体で置き換えます。したがって、libjpeg を自分でコンパイルする必要があります。

参考文献:

CUDAベースのOpenCL開発環境構築とエントリープログラム例_Johnson Luのブログ-CSDNブログ

7問目、libjpegのコンパイル。情報を確認しただけで、かなりの労力を費やしましたが、失敗しました。最初、turbojpeg にコンパイルされた libjpeg があるのを見て、それを直接使おうと思ったのですが、turbojpeg には独自の修正が加えられており、バージョンが対応していないため、オリジナルのバージョンしか使用できないことがわかりました。オリジナルバージョンでは動作しません。問題は次のとおりです。

E:\platform_external_jpeg-master> nmake /f makefile.vc nodebug=1

Microsoft (R) 程序维护实用工具 14.29.30040.0 版
版权所有 (C) Microsoft Corporation。  保留所有权利。

makefile.vc(11) : fatal error U1052: 未找到文件“win32.mak”
Stop.
E:\platform_external_jpeg-master> nmake /f makefile.vc nodebug=1

Microsoft (R) 程序维护实用工具 14.29.30040.0 版
版权所有 (C) Microsoft Corporation。  保留所有权利。

        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
jcapimin.c
        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
jcapistd.c
        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
jctrans.c
jctrans.c(278): warning C4100: “input_buf”: 未引用的形参
        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
jcparam.c
        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
jdatadst.c
        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
jcinit.c
        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
jcmaster.c
        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
jcmarker.c
jcmarker.c(222): warning C4100: “cinfo”: 未引用的形参
        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
jcmainct.c
        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
jcprepct.c
        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
jccoefct.c
jccoefct.c(341): warning C4100: “input_buf”: 未引用的形参
        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
jccolor.c
jccolor.c(354): warning C4456: “inptr”的声明隐藏了上一个本地声明
jccolor.c(345): note: 参见“inptr”的声明
jccolor.c(359): warning C4456: “col”的声明隐藏了上一个本地声明
jccolor.c(347): note: 参见“col”的声明
jccolor.c(386): warning C4102: “SLOW”: 未引用的标签
jccolor.c(409): warning C4100: “cinfo”: 未引用的形参
        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
jcsample.c
jcsample.c(75): warning C4100: “cinfo”: 未引用的形参
        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
jchuff.c
jchuff.c(302): warning C4431: 缺少类型说明符 - 假定为 int。注意: C 不再支持默认 int
jchuff.c(302): error C2054: 在“__inline__”之后应输入“(”
jchuff.c(304): error C2085: “emit_bits”: 不在形参表中
jchuff.c(304): error C2143: 语法错误: 缺少“;”(在“{”的前面)
jchuff.c(342): warning C4013: “emit_bits”未定义;假设外部返回 int
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”
Stop.

E:\platform_external_jpeg-master>
E:\platform_external_jpeg-master> nmake /f makefile.vc nodebug=1

Microsoft (R) 程序维护实用工具 14.29.30040.0 版
版权所有 (C) Microsoft Corporation。  保留所有权利。

        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
jchuff.c
jchuff.c(302): warning C4431: 缺少类型说明符 - 假定为 int。注意: C 不再支持默认 int
jchuff.c(302): error C2054: 在“__inline__”之后应输入“(”
jchuff.c(304): error C2085: “emit_bits”: 不在形参表中
jchuff.c(304): error C2143: 语法错误: 缺少“;”(在“{”的前面)
jchuff.c(342): warning C4013: “emit_bits”未定义;假设外部返回 int
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”
Stop.

E:\platform_external_jpeg-master>

上記のエラーがこの記事の焦点であり、多くの情報を確認しましたが、解決策が見つかりません。結局、ソースコードを噛み砕いて読むことしかできませんでしたが、問題は inline ステートメントにあるようです。inline の具体的な機能は覚えていません。すべてのインラインをコメントアウトするだけで、コンパイルは成功します。

参考文献:

LibJpegをコンパイルする

Win10+VS2019 には、Jpeg ソース コードをコンパイルするときに win32.mak ファイルのコンテンツがありません_Alexabc3000 のブログ - CSDN blog_win32.mak

libjpeg は、_baidu_32526299 のブログ CSDN blog_libjpeg を使用してコンパイルされました

C-Typhony-ChinaUnix ブログの __inline__ の意味と機能

8番目の問題もあって、静的ライブラリと呼ばれるlibファイルが生成されるのですが、動的ライブラリを生成する必要があります(実際には生成されなくても問題ないようです。)で試してみました。コードが実行できなかったので指示)とにかくダイナミックライブラリが必要です。

makefile.vcファイルの100行目以降を修正して以下の内容に変更すればOKです(全て自分で、情報無し)。

all: libjpeg.lib libjpeg.dll cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe

libjpeg.lib: $(LIBOBJECTS)
	$(RM) libjpeg.lib
	lib -out:libjpeg.lib  $(LIBOBJECTS)

libjpeg.dll: $(LIBOBJECTS)
	link -dll -out:libjpeg.dll $(LIBOBJECTS)

cjpeg.exe: $(COBJECTS) libjpeg.lib
	$(link) $(LDFLAGS) -out:cjpeg.exe $(COBJECTS) libjpeg.lib $(LDLIBS)

参考文献:

LibJpegをコンパイルする

最後に、opencl による jpeg のデコードの問題は解決されておらず、後でいくつかの問題が解決されました。コードは少し後に実行され、最後のエラー ログは次のとおりです。以前の間違いから学んだ知識によると、エラーは次のとおりです。コードは 11、タイプは CL_BUILD_PROGRAM_FAILURE です。

OpenCL エラー コードと説明を参照してください_Javen_ManWJ のブログ-CSDN blog_opencl エラー コード

cl文に問題があると推測されますが、cl文が全然ダメです情報を確認し続けて少し勉強してみましたが、既存のコードに大きな問題は無いような気がします。体系的に覚えないと時間がかかりすぎて理解できません。それについては後で話してください

    con->context = clCreateContextFromType(contextProperties, flags, NULL, NULL, &errNum);
cl_program program = clCreateProgramWithSource(c->context, 1, &sourcecode, sourcesize, &errercode);
Platform Numbers: 1
Platform Name: NVIDIA CUDA
Platform Vendor: NVIDIA Corporation
Platform Version: OpenCL 3.0 CUDA 11.6.127
Platform Full Profile or Embeded Profile?: FULL_PROFILE
Build log is <kernel>:4:177: error: __kernel function cannot have argument whose type is, or contains, type size_t
__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)
                                                                                                                                                                                ^
<kernel>:24:33: error: unexpected type name 'float8': expected expression
        tmp12 = (tmp1 - tmp3) * float8(1.414213562) - tmp13; /* 2*c4 */
                                ^
<kernel>:42:31: error: unexpected type name 'float8': expected expression
        tmp11 = (z11 - z13) * float8(1.414213562); /* 2*c4 */
                              ^
<kernel>:44:28: error: unexpected type name 'float8': expected expression
        z5 = (z10 + z12) * float8(1.847759065); /* 2*c2 */
                           ^
<kernel>:45:17: error: unexpected type name 'float8': expected expression
        tmp10 = float8(1.082392200) * z12 - z5; /* 2*(c2-c6) */
                ^
<kernel>:46:17: error: unexpected type name 'float8': expected expression
        tmp12 = float8(-2.613125930) * z10 + z5; /* -2*(c2+c6) */
                ^
<kernel>:53:23: error: unexpected type name 'float8': expected expression
        tmp7 = tmp0 - float8(2)*tmp7;
                      ^
<kernel>:55:23: error: unexpected type name 'float8': expected expression
        tmp6 = tmp1 - float8(2)*tmp6;
                      ^
<kernel>:57:23: error: unexpected type name 'float8': expected expression
        tmp5 = tmp2 - float8(2)*tmp5;
                      ^
<kernel>:59:16: error: unexpected type name 'float8': expected expression
        tmp3 = float8(2)*tmp3 - tmp4;
               ^
<kernel>:76:29: error: unexpected type name 'float8': expected expression
        tmp12 = (w2 - w6) * float8(1.414213562) - tmp13;
                            ^
<kernel>:89:31: error: unexpected type name 'float8': expected expression
        tmp11 = (z11 - z13) * float8(1.414213562);
                              ^
<kernel>:91:28: error: unexpected type name 'float8': expected expression
        z5 = (z10 + z12) * float8(1.847759065); /* 2*c2 */
                           ^
<kernel>:92:17: error: unexpected type name 'float8': expected expression
        tmp10 = float8(1.082392200) * z12 - z5; /* 2*(c2-c6) */
                ^
<kernel>:93:17: error: unexpected type name 'float8': expected expression
        tmp12 = float8(-2.613125930) * z10 + z5; /* -2*(c2+c6) */
                ^
<kernel>:100:23: error: unexpected type name 'float8': expected expression
        tmp7 = tmp0 - float8(2)*tmp7;
                      ^
<kernel>:102:23: error: unexpected type name 'float8': expected expression
        tmp6 = tmp1 - float8(2)*tmp6;
                      ^
<kernel>:104:23: error: unexpected type name 'float8': expected expression
        tmp5 = tmp2 - float8(2)*tmp5;
                      ^
<kernel>:106:16: error: unexpected type name 'float8': expected expression
        tmp3 = float8(2)*tmp3 - tmp4;
               ^
<kernel>:120:17: error: unexpected type name 'float8': expected expression
        vstore8(RESULT(w0), 0, outptr);
                ^
<kernel>:119:44: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                           ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:120:17: error: unexpected type name 'float8': expected expression
<kernel>:119:54: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                                     ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:121:17: error: unexpected type name 'float8': expected expression
        vstore8(RESULT(w7), 7, outptr);
                ^
<kernel>:119:44: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                           ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:121:17: error: unexpected type name 'float8': expected expression
<kernel>:119:54: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                                     ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:122:17: error: unexpected type name 'float8': expected expression
        vstore8(RESULT(w1), 1, outptr);
                ^
<kernel>:119:44: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                           ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:122:17: error: unexpected type name 'float8': expected expression
<kernel>:119:54: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                                     ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:123:17: error: unexpected type name 'float8': expected expression
        vstore8(RESULT(w6), 6, outptr);
                ^
<kernel>:119:44: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                           ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:123:17: error: unexpected type name 'float8': expected expression
<kernel>:119:54: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                                     ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:124:17: error: unexpected type name 'float8': expected expression
        vstore8(RESULT(w2), 2, outptr);
                ^
<kernel>:119:44: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                           ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:124:17: error: unexpected type name 'float8': expected expression
<kernel>:119:54: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                                     ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:125:17: error: unexpected type name 'float8': expected expression
        vstore8(RESULT(w5), 5, outptr);
                ^
<kernel>:119:44: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                           ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:125:17: error: unexpected type name 'float8': expected expression
<kernel>:119:54: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                                     ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:126:17: error: unexpected type name 'float8': expected expression
        vstore8(RESULT(w4), 4, outptr);
                ^
<kernel>:119:44: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                           ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:126:17: error: unexpected type name 'float8': expected expression
<kernel>:119:54: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                                     ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:127:17: error: unexpected type name 'float8': expected expression
        vstore8(RESULT(w3), 3, outptr);
                ^
<kernel>:119:44: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                           ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^
<kernel>:127:17: error: unexpected type name 'float8': expected expression
<kernel>:119:54: note: expanded from macro 'RESULT'
#define RESULT(t) convert_uchar8(clamp((t)/float8(8)+float8(128), float8(0), float8(255)))
                                                     ^
cl_kernel.h:8252:41: note: expanded from macro 'convert_uchar8'
#define convert_uchar8(x) convert_uchar(x)
                                        ^

Assertion failed: CL_SUCCESS == errercode, file D:\code2022.5\Test\testOpenCLJpegDecoder\testOpenCLJpegDecoder\opencl_package.c, line 134

D:\code2022.5\Test\testOpenCLJpegDecoder\x64\Debug\testOpenCLJpegDecoder.exe (进程 10520)已退出,代码为 3。
要在调试停止时自动关闭控制台,请启用“工具”->“选项”->“调试”->“调试停止时自动关闭控制台”。
按任意键关闭此窗口. . .
/* Error Codes */
#define CL_SUCCESS                                  0
#define CL_DEVICE_NOT_FOUND                         -1
#define CL_DEVICE_NOT_AVAILABLE                     -2
#define CL_COMPILER_NOT_AVAILABLE                   -3
#define CL_MEM_OBJECT_ALLOCATION_FAILURE            -4
#define CL_OUT_OF_RESOURCES                         -5
#define CL_OUT_OF_HOST_MEMORY                       -6
#define CL_PROFILING_INFO_NOT_AVAILABLE             -7
#define CL_MEM_COPY_OVERLAP                         -8
#define CL_IMAGE_FORMAT_MISMATCH                    -9
#define CL_IMAGE_FORMAT_NOT_SUPPORTED               -10
#define CL_BUILD_PROGRAM_FAILURE                    -11
#define CL_MAP_FAILURE                              -12
#define CL_MISALIGNED_SUB_BUFFER_OFFSET             -13
#define CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST -14
#define CL_COMPILE_PROGRAM_FAILURE                  -15
#define CL_LINKER_NOT_AVAILABLE                     -16
#define CL_LINK_PROGRAM_FAILURE                     -17
#define CL_DEVICE_PARTITION_FAILED                  -18
#define CL_KERNEL_ARG_INFO_NOT_AVAILABLE            -19

おすすめ

転載: blog.csdn.net/u010752777/article/details/126367229