色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁(yè) > 新品快遞 > G2D圖像處理硬件調(diào)用和測(cè)試-基于米爾-全志T113-i國(guó)產(chǎn)開(kāi)發(fā)板

          G2D圖像處理硬件調(diào)用和測(cè)試-基于米爾-全志T113-i國(guó)產(chǎn)開(kāi)發(fā)板

          作者: 時(shí)間:2024-04-10 來(lái)源:EEPW 收藏


          本文引用地址:http://cafeforensic.com/article/202404/457413.htm

          概述:

          MYC-YT113i

          真正的國(guó)產(chǎn),100%國(guó)產(chǎn)物料認(rèn)證

          國(guó)產(chǎn)T113-i處理器配備2*Cortex-A7@1.2GHz ,RISC-V

          外置DDR3接口、支持視頻編解碼器、HiFi4 DSP

          接口豐富:視頻采集接口、顯示器接口、USB2.0 接口、CAN 接口、千兆以太網(wǎng)接口

          工業(yè)級(jí):-40℃~+85℃、尺寸37mm*39mm

          郵票孔+LGA,140+50PIN

          1712761829259072.png

          -全志T113-i國(guó)產(chǎn)

          1712761916489747.png

          -全志T113-i國(guó)產(chǎn)

          全志T113-i 2D圖形加速硬件支持情況

          Supports layer size up to 2048 x 2048 pixels

          Supports pre-multiply alpha image data

          Supports color key

          Supports two pipes Porter-Duff alpha blending

          Supports multiple video formats 4:2:0, 4:2:2, 4:1:1 and multiple pixel formats (8/16/24/32 bits graphicslayer)

          Supports memory scan order option

          Supports any format convert function

          Supports 1/16× to 32× resize ratio

          Supports 32-phase 8-tap horizontal anti-alias filter and 32-phase 4-tap vertical anti-alias filter

          Supports window clip

          Supports FillRectangle, BitBlit, StretchBlit and MaskBlit

          Supports horizontal and vertical flip, clockwise 0/90/180/270 degree rotate for normal buffer

          Supports horizontal flip, clockwise 0/90/270 degree rotate for LBC buffer

          可以看到 g2d 硬件支持相當(dāng)多的2D圖像處理,包括顏色空間轉(zhuǎn)換,分辨率縮放,圖層疊加,旋轉(zhuǎn)等。

          1712761961613096.png

          備注:本文不具體介紹代碼,代碼參見(jiàn):

          1.開(kāi)發(fā)環(huán)境配置

          基礎(chǔ)開(kāi)發(fā)環(huán)境搭建參考上上上一篇

          除了工具鏈外,我們使用 opencv-mobile 加載輸入圖片和保存結(jié)果,用來(lái)查看顏色轉(zhuǎn)換是否正常

          g2d硬件直接采用標(biāo)準(zhǔn)的 Linux ioctl 操縱,只需要引入相關(guān)結(jié)構(gòu)體定義即可,無(wú)需鏈接so

          此外,g2d的輸入和輸出數(shù)據(jù)必須在dmaion buffer上,因此還需要dmaion.h頭文件,用來(lái)分配和釋放dmaion buffer

          2.基于C語(yǔ)言實(shí)現(xiàn)的YUV轉(zhuǎn)RGB

          這里復(fù)用之前T113-i JPG解碼的函數(shù)

          3.基于ARM neon指令集優(yōu)化的YUV轉(zhuǎn)RGB

          考慮到armv7編譯器的自動(dòng)neon優(yōu)化能力較差,這里針對(duì)性的編寫 arm neon inline assembly 實(shí)現(xiàn)YUV2RGB內(nèi)核部分,達(dá)到最優(yōu)化的性能,榨干cpu性能。

          4.基于G2D圖形硬件的YUV轉(zhuǎn)RGB

          我們先實(shí)現(xiàn) dmaion buffer 管理器,參考

          這里貼的代碼省略了異常錯(cuò)誤處理的邏輯,有個(gè)坑是 linux-4.9 和 linux-5.4 用法不一樣,電子的這個(gè)T113-i系統(tǒng)是linux-5.4,所以不兼容4.9內(nèi)核的ioctl用法習(xí)慣。

          5.然后再實(shí)現(xiàn) G2D圖形硬件 YUV轉(zhuǎn)RGB 的轉(zhuǎn)換器

          1.提前分配好YUV和RGB的dmaion buffer

          2.將YUV數(shù)據(jù)拷貝到dmaion buffer,flush cache完成同步

          3.配置轉(zhuǎn)換參數(shù),ioctl調(diào)用G2D_CMD_BITBLT_H完成轉(zhuǎn)換

          4.flush cache完成同步,從dmaion buffer拷貝出RGB數(shù)據(jù)

          5.釋放dmaion buffer

          6.G2D圖像硬件YUV轉(zhuǎn)RGB測(cè)試

          考慮到dmaion buffer分配和釋放都比較耗時(shí),我們提前做好,循環(huán)調(diào)用步驟3的G2D轉(zhuǎn)換,統(tǒng)計(jì)耗時(shí),并在top工具中查看CPU占用率

          sh-4.4# LD_LIBRARY_PATH=. ./g2dtest

          INFO   : cedarc <CedarPluginVDInit:84>: register mjpeg decoder success!

          this device is not whitelisted for jpeg decoder cvi

          this device is not whitelisted for jpeg decoder cvi

          this device is not whitelisted for jpeg decoder cvi

          this device is not whitelisted for jpeg encoder rkmpp

          INFO   : cedarc <log_set_level:43>: Set log level to 5 from /vendor/etc/cedarc.conf

          ERROR  : cedarc <DebugCheckConfig:316>: now cedarc log level:5

          ERROR  : cedarc <VideoEncCreate:241>: now cedarc log level:5

          yuv420sp2rgb 46.61

          yuv420sp2rgb 42.04

          yuv420sp2rgb 41.32

          yuv420sp2rgb 42.06

          yuv420sp2rgb 41.69

          yuv420sp2rgb 42.05

          yuv420sp2rgb 41.29

          yuv420sp2rgb 41.30

          yuv420sp2rgb 42.14

          yuv420sp2rgb 41.33

          yuv420sp2rgb_neon 10.57

          yuv420sp2rgb_neon 7.21

          yuv420sp2rgb_neon 6.77

          yuv420sp2rgb_neon 8.31

          yuv420sp2rgb_neon 7.60

          yuv420sp2rgb_neon 6.80

          yuv420sp2rgb_neon 6.77

          yuv420sp2rgb_neon 7.01

          yuv420sp2rgb_neon 7.11

          yuv420sp2rgb_neon 7.06

          yuv420sp2rgb_g2d 4.32

          yuv420sp2rgb_g2d 4.69

          yuv420sp2rgb_g2d 4.56

          yuv420sp2rgb_g2d 4.57

          yuv420sp2rgb_g2d 4.52

          yuv420sp2rgb_g2d 4.54

          yuv420sp2rgb_g2d 4.52

          yuv420sp2rgb_g2d 4.58

          yuv420sp2rgb_g2d 4.60

          yuv420sp2rgb_g2d 4.67

          可以看到 ARM neon 的優(yōu)化效果非常明顯,而使用G2D圖形硬件能獲得進(jìn)一步加速,并且能顯著降低CPU占用率!

          image.png

          1712762020682852.png

          7.轉(zhuǎn)換結(jié)果對(duì)比和分析

          C和neon的轉(zhuǎn)換結(jié)果完全一致,但是g2d轉(zhuǎn)換后的圖片有明顯的色差

          1712762082599321.png

          1712762126200592.png

          G2D圖形硬件只支持 G2D_BT601,G2D_BT709,G2D_BT2020 3種YUV系數(shù),而JPG所使用的YUV系數(shù)是改版BT601,因此產(chǎn)生了色差

          從g2d內(nèi)核驅(qū)動(dòng)中也可以得知,暫時(shí)沒(méi)有方法為g2d設(shè)置自定義的YUV系數(shù),g2d不適合用于JPG的編解碼,但依然適合攝像頭和視頻編解碼的顏色空間轉(zhuǎn)換



          評(píng)論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉