1# RGA IM2D API Instruction 2 3ID: RK-KF-YF-403 4 5Release Version: V2.2.2 6 7Release Date: 2023-06-28 8 9Security Level: □Top-Secret □Secret □Internal ■Public 10 11**DISCLAIMER** 12 13THIS DOCUMENT IS PROVIDED “AS IS”. ROCKCHIP ELECTRONICS CO., LTD.(“ROCKCHIP”)DOES NOT PROVIDE ANY WARRANTY OF ANY KIND, EXPRESSED, IMPLIED OR OTHERWISE, WITH RESPECT TO THE ACCURACY, RELIABILITY, COMPLETENESS,MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE OR NON-INFRINGEMENT OF ANY REPRESENTATION, INFORMATION AND CONTENT IN THIS DOCUMENT. THIS DOCUMENT IS FOR REFERENCE ONLY. THIS DOCUMENT MAY BE UPDATED OR CHANGED WITHOUT ANY NOTICE AT ANY TIME DUE TO THE UPGRADES OF THE PRODUCT OR ANY OTHER REASONS. 14 15**Trademark Statement** 16 17"Rockchip", "瑞芯微", "瑞芯" shall be Rockchip’s registered trademarks and owned by Rockchip. All the other trademarks or registered trademarks mentioned in this document shall be owned by their respective owners. 18 19**All rights reserved. ©2022. Rockchip Electronics Co., Ltd.** 20 21Beyond the scope of fair use, neither any entity nor individual shall extract, copy, or distribute this document in any form in whole or in part without the written approval of Rockchip. 22 23Rockchip Electronics Co., Ltd. 24 25No.18 Building, A District, No.89, software Boulevard Fuzhou, Fujian,PRC 26 27Website: [www.rock-chips.com](http://www.rock-chips.com) 28 29Customer service Tel: +86-4007-700-590 30 31Customer service Fax: +86-591-83951833 32 33Customer service e-Mail: [fae@rock-chips.com](mailto:fae@rock-chips.com) 34 35--- 36 37**Intended Audience** 38 39This document (this guide) is mainly intended for: 40 41- Technical support engineers 42- Software development engineers 43 44**Revision History** 45 46| **Date** | **Version** | **Author** | **Revision Description** | 47| ---------- | -------- | ------------------ | ------------------------------------------------------------ | 48| 2020/06/24 | 1.0.0 | Chen Cheng, Li Huang | Initial version. | 49| 2020/10/16 | 1.0.1 | Chen Cheng, Li Huang, Yu Qiaowei | Update part of the APIs. | 50| 2021/12/07 | 2.0.0 | Chen Cheng, Li Huang, Yu Qiaowei | Add RGA3 related support. | 51| 2022/01/20 | 2.1.0 | Chen Cheng, Li Huang, Yu Qiaowei | - Update im2d api description.<br/>- Updated hardware index description and alignment restrictions.<br/>- Add data structure description. | 52| 2022/01/20 | 2.1.1 | Chen Cheng, Li Huang, Yu Qiaowei | Supplemental formatting support/alignment instructions. | 53| 2022/09/15 | 2.2.0 | Chen Cheng, Li Huang, Yu Qiaowei | - Supplementary default value description<br/>- New array api<br/>- New task api<br/>- New rectangle border drawing api | 54| 2023/02/09 | 2.2.1 | Yu Qiaowei | Format document. | 55| 2022/06/28 | 2.2.2 | Yu Qiaowei | - Add chip RK3562 introduction<br/>- Improve the precautions for grayscale images | 56 57--- 58 59**Contents** 60 61[TOC] 62 63--- 64 65## Introductions 66 67RGA (Raster Graphic Acceleration Unit) is an independent 2D hardware accelerator that can be used to speed up point/line drawing, perform image resizing, rotation, bitBlt, alpha blending and other common 2D graphics operations. 68 69 70 71### Design Index 72 73<table> 74 <tr> 75 <td rowspan="2">Version</td> 76 <td rowspan="2">Codename</td> 77 <td rowspan="2">Chip</td> 78 <td rowspan="1" colspan="2">Source</td> 79 <td rowspan="1" colspan="2">Destination</td> 80 <td rowspan="2">Function</td> 81 <td rowspan="2">Pixels/Cycle</td> 82 </tr> 83 <tr> 84 <td>min</td> 85 <td>max</td> 86 <td>min</td> 87 <td>max</td> 88 </tr> 89 <tr> 90 <td rowspan="4">RGA1</td> 91 <td>Pagani</td> 92 <td>RK3066</td> 93 <td rowspan="4">2x2</td> 94 <td rowspan="4">8192x8192</td> 95 <td rowspan="4">2x2</td> 96 <td rowspan="4">2048x2048</td> 97 <td rowspan="4">90/180/270 Rotate<br/>X/Y Mirror<br/>Crop<br/>1/2~8 scale<br/>Alpha blend<br/>Color key<br/>Color fill<br/>ROP<br/>IOMMU(32bit)</td> 98 <td rowspan="4">1</td> 99 </tr> 100 <tr> 101 <td>Jaguar Plus</td> 102 <td>RK3188</td> 103 </tr> 104 <tr> 105 <td>Beetles</td> 106 <td>RK2926/2928</td> 107 </tr> 108 <tr> 109 <td>Beetles Plus</td> 110 <td>RK3026/3028</td> 111 </tr> 112 <tr> 113 <td rowspan="2">RGA1_plus</td> 114 <td>Audi</td> 115 <td>RK3128</td> 116 <td rowspan="2">2x2</td> 117 <td rowspan="2">8192x8192</td> 118 <td rowspan="2">2x2</td> 119 <td rowspan="2">2048x2048</td> 120 <td rowspan="2">90/180/270 Rotate<br/>X/Y Mirror<br/>Crop<br/>1/2~8 scale<br/>Alpha blend<br/>Color key<br/>Color fill<br/>Color palette<br/>IOMMU(32bit)</td> 121 <td rowspan="2">1</td> 122 </tr> 123 <tr> 124 <td>Granite</td> 125 <td>Sofia 3gr</td> 126 </tr> 127 <tr> 128 <td rowspan="2">RGA2</td> 129 <td>Lincoln</td> 130 <td>RK3288/3288w</td> 131 <td rowspan="2">2x2</td> 132 <td rowspan="2">8192x8192</td> 133 <td rowspan="2">2x2</td> 134 <td rowspan="2">4096x4096</td> 135 <td rowspan="2">90/180/270 Rotate<br/>X/Y Mirror<br/>Crop<br/>1/16~16 scale<br/>Alpha blend<br/>Color key<br/>Color fill<br/>Color palette<br/>ROP<br/>IOMMU(32bit)</td> 136 <td rowspan="2">2</td> 137 </tr> 138 <tr> 139 <td>Capricorn</td> 140 <td>RK3190</td> 141 </tr> 142 <tr> 143 <td rowspan="2">RGA2-Lite0</td> 144 <td>Maybach</td> 145 <td>RK3368</td> 146 <td rowspan="2">2x2</td> 147 <td rowspan="2">8192x8192</td> 148 <td rowspan="2">2x2</td> 149 <td rowspan="2">4096x4096</td> 150 <td rowspan="2">90/180/270 Rotate<br/>X/Y Mirror<br/>Crop<br/>1/8~8 scale<br/>Alpha blend<br/>Color key<br/>Color fill<br/>Color palette<br/>ROP<br/>IOMMU(32bit)</td> 151 <td rowspan="2">2</td> 152 </tr> 153 <tr> 154 <td>BMW</td> 155 <td>RK3366</td> 156 </tr> 157 <tr> 158 <td rowspan="4">RGA2-Lite1</td> 159 <td>Benz</td> 160 <td>RK3228</td> 161 <td rowspan="4">2x2</td> 162 <td rowspan="4">8192x8192</td> 163 <td rowspan="4">2x2</td> 164 <td rowspan="4">4096x4096</td> 165 <td rowspan="4">90/180/270 Rotate<br/>X/Y Mirror<br/>Crop<br/>1/8~8 scale<br/>Alpha blend<br/>Color key<br/>Color fill<br/>Color palette<br/>IOMMU(32bit)</td> 166 <td rowspan="4">2</td> 167 </tr> 168 <tr> 169 <td>Infiniti</td> 170 <td>RK3228H</td> 171 </tr> 172 <tr> 173 <td>Gemini</td> 174 <td>RK3326</td> 175 </tr> 176 <tr> 177 <td>Lion</td> 178 <td>RK1808</td> 179 </tr> 180 <tr> 181 <td rowspan="8">RGA2-Enhance</td> 182 <td>Mclaren</td> 183 <td>RK3399</td> 184 <td rowspan="8">2x2</td> 185 <td rowspan="8">8192x8192</td> 186 <td rowspan="8">2x2</td> 187 <td rowspan="8">4096x4096</td> 188 <td rowspan="8">90/180/270 Rotate<br/>X/Y Mirror<br/>Crop<br/>1/16~16 scale<br/>Alpha blend<br/>Color key<br/>Color fill<br/>Color palette<br/>ROP(NA for 1108/1109)<br/>NN quantize(NA for 3399/1108)<br/>osd(only 1106/1103)<br/>IOMMU(32bit, RK3528/RK3562 is 40bit,NA for RV1106/1103)</td> 189 <td rowspan="8">2</td> 190 </tr> 191 <tr> 192 <td>Mercury</td> 193 <td>RK1108</td> 194 </tr> 195 <tr> 196 <td>Puma</td> 197 <td>RV1126/RV1109</td> 198 </tr> 199 <tr> 200 <td>skylarkV2</td> 201 <td>RK3566/RK3568</td> 202 </tr> 203 <tr> 204 <td>Orion</td> 205 <td>RK3588</td> 206 </tr> 207 <tr> 208 <td>Otter</td> 209 <td>RV1106/1103</td> 210 </tr> 211 <tr> 212 <td>Bull</td> 213 <td>RK3528</td> 214 </tr> 215 <tr> 216 <td>Snipe</td> 217 <td>RK3562</td> 218 </tr> 219 <tr> 220 <td rowspan="1">RGA3</td> 221 <td>Orion</td> 222 <td>RK3588</td> 223 <td rowspan="1">68x2</td> 224 <td rowspan="1">8176x8176</td> 225 <td rowspan="1">68x2</td> 226 <td rowspan="1">8128x8128</td> 227 <td rowspan="4">90/180/270 Rotate<br/>X/Y Mirror<br/>Crop<br/>1/8~8 scale<br/>Alpha blend<br/>Color key<br/>FBC<br/>IOMMU(40bit)</td> 228 <td rowspan="1">3 (by pass)<br/>2 (scale)</td> 229 </tr> 230</table> 231 232 233 234> Note: 235> 236> 1). The capabilities of Pixels/cycle are theoretical data, and the actual operating performance is related to bandwidth, hardware frequency, etc. The list data is for reference only. 237> 238> 2). In addition to the minimum input resolution limit, the x, y, width, and height parameters of the actual operation rectangle that can be set for each channel must be greater than or equal to 2. 239> 240> 3). The addressing capability of RGA is related to the number of bits of IOMMU. For example, the actual physical addressing capability of RGA equipped with 32bit IOMMU only supports 0~4G memory space. 241 242 243 244 245### Image Format Supported 246 247- Pixel Format conversion, BT.601/BT.709/BT.2020(only RGA3) 248- Dither operation 249 250<table> 251 <tr> 252 <td>Version</td> 253 <td>Codename</td> 254 <td>Chip</td> 255 <td>Input Data Format</td> 256 <td>Output Data Format</td> 257 </tr> 258 <tr> 259 <td rowspan="4">RGA1</td> 260 <td>Pagani</td> 261 <td>RK3066</td> 262 <td rowspan="4"> RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P<br/>RK_FORMAT_BPP1<br/>RK_FORMAT_BPP2<br/>RK_FORMAT_BPP4<br/>RK_FORMAT_BPP8 263 </td> 264 <td rowspan="4"> 265RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP (only for Blur/sharpness)<br/>RK_FORMAT_YCrCbr_420_SP (only for Blur/sharpness)<br/>RK_FORMAT_YCbCr_422_SP (only for Blur/sharpness)<br/>RK_FORMAT_YCrCbr_422_SP (only for Blur/sharpness)<br/>RK_FORMAT_YCbCr_420_P (only for Blur/sharpness)<br/>RK_FORMAT_YCrCbr_420_P (only for Blur/sharpness)<br/>RK_FORMAT_YCbCr_422_P (only for Blur/sharpness)<br/>RK_FORMAT_YCrCbr_422_P (only for Blur/sharpness) 266 </td> 267 </tr> 268 <tr> 269 <td>Jaguar Plus</td> 270 <td>RK3188</td> 271 </tr> 272 <tr> 273 <td>Beetles</td> 274 <td>RK2926/2928</td> 275 </tr> 276 <tr> 277 <td>Beetles Plus</td> 278 <td>RK3026/3028</td> 279 </tr> 280 <tr> 281 <td rowspan="2">RGA1_plus</td> 282 <td>Audi</td> 283 <td>RK3128</td> 284 <td rowspan="2"> RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P<br/>RK_FORMAT_BPP1<br/>RK_FORMAT_BPP2<br/>RK_FORMAT_BPP4<br/>RK_FORMAT_BPP8 285 </td> 286 <td rowspan="2"> 287RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP (only for normal Bitblt without alpha)<br/>RK_FORMAT_YCrCbr_420_SP (only for normal Bitblt without alpha)<br/>RK_FORMAT_YCbCr_422_SP (only for normal Bitblt without alpha)<br/>RK_FORMAT_YCrCbr_422_SP (only for normal Bitblt without alpha)<br/>RK_FORMAT_YCbCr_420_P (only for normal Bitblt without alpha)<br/>RK_FORMAT_YCrCbr_420_P (only for normal Bitblt without alpha)<br/>RK_FORMAT_YCbCr_422_P (only for normal Bitblt without alpha)<br/>RK_FORMAT_YCrCbr_422_P (only for normal Bitblt without alpha) 288 </td> 289 </tr> 290 <tr> 291 <td>Granite</td> 292 <td>Sofia 3gr</td> 293 </tr> 294 <tr> 295 <td rowspan="2">RGA2</td> 296 <td>Lincoln</td> 297 <td>RK3288/3288w</td> 298 <td rowspan="2"> RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P<br/>RK_FORMAT_BPP1 (only for color palette)<br/>RK_FORMAT_BPP2 (only for color palette)<br/>RK_FORMAT_BPP4 (only for color palette)<br/>RK_FORMAT_BPP8 (only for color palette) 299 </td> 300 <td rowspan="2"> RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P 301 </td> 302 </tr> 303 <tr> 304 <td>Capricorn</td> 305 <td>RK3190</td> 306 </tr> 307 <tr> 308 <td rowspan="2">RGA2-Lite0</td> 309 <td>Maybach</td> 310 <td>RK3368</td> 311 <td rowspan="2"> RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P<br/>RK_FORMAT_BPP1 (only for color palette)<br/>RK_FORMAT_BPP2 (only for color palette)<br/>RK_FORMAT_BPP4 (only for color palette)<br/>RK_FORMAT_BPP8 (only for color palette) 312 </td> 313 <td rowspan="2"> RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P 314 </td> 315 </tr> 316 <tr> 317 <td>BMW</td> 318 <td>RK3366</td> 319 </tr> 320 <tr> 321 <td rowspan="4">RGA2-Lite1</td> 322 <td>Benz</td> 323 <td>RK3228</td> 324 <td rowspan="4"> RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P<br/>RK_FORMAT_YCbCr_420_SP_10B<br/>RK_FORMAT_YCrCb_420_SP_10B<br/>RK_FORMAT_YCbCr_422_SP_10B<br/>RK_FORMAT_YCrCb_422_SP_10B<br/>RK_FORMAT_BPP1 (only for color palette)<br/>RK_FORMAT_BPP2 (only for color palette)<br/>RK_FORMAT_BPP4 (only for color palette)<br/>RK_FORMAT_BPP8 (only for color palette) 325 </td> 326 <td rowspan="4"> RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P 327 </td> 328 </tr> 329 <tr> 330 <td>Infiniti</td> 331 <td>RK3228H</td> 332 </tr> 333 <tr> 334 <td>Gemini</td> 335 <td>RK3326</td> 336 </tr> 337 <tr> 338 <td>Lion</td> 339 <td>RK1808</td> 340 </tr> 341 <tr> 342 <td rowspan="6">RGA2-Enhance</td> 343 <td>Mclaren</td> 344 <td>RK3399</td> 345 <td rowspan="2"> RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P<br/>RK_FORMAT_YCbCr_420_SP_10B<br/>RK_FORMAT_YCrCb_420_SP_10B<br/>RK_FORMAT_YCbCr_422_SP_10B<br/>RK_FORMAT_YCrCb_422_SP_10B<br/>RK_FORMAT_BPP1 (only for color palette)<br/>RK_FORMAT_BPP2 (only for color palette)<br/>RK_FORMAT_BPP4 (only for color palette)<br/>RK_FORMAT_BPP8 (only for color palette) 346 </td> 347 <td rowspan="2"> RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P<br/>RK_FORMAT_YUYV_422<br/>RK_FORMAT_YVYU_422<br/>RK_FORMAT_UYVY_422<br/>RK_FORMAT_VYUY_422<br/>RK_FORMAT_YUYV_420<br/>RK_FORMAT_YVYU_420<br/>RK_FORMAT_UYVY_420<br/>RK_FORMAT_VYUY_420 348 </td> 349 </tr> 350 <tr> 351 <td>Mercury</td> 352 <td>RK1108</td> 353 </tr> 354 <tr> 355 <td>Puma</td> 356 <td>RV1126/ RV1109</td> 357 <td rowspan="4"> RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P<br/>RK_FORMAT_YUYV_422<br/>RK_FORMAT_YVYU_422<br/>RK_FORMAT_UYVY_422<br/>RK_FORMAT_VYUY_422<br/>RK_FORMAT_YCbCr_400<br/>RK_FORMAT_YCbCr_420_SP_10B<br/>RK_FORMAT_YCrCb_420_SP_10B<br/>RK_FORMAT_YCbCr_422_SP_10B<br/>RK_FORMAT_YCrCb_422_SP_10B<br/>RK_FORMAT_BPP1 (only for color palette)<br/>RK_FORMAT_BPP2 (only for color palette)<br/>RK_FORMAT_BPP4 (only for color palette)<br/>RK_FORMAT_BPP8 (only for color palette) 358 </td> 359 <td rowspan="4"> 360RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P<br/>RK_FORMAT_YUYV_422<br/>RK_FORMAT_YVYU_422<br/>RK_FORMAT_UYVY_422<br/>RK_FORMAT_VYUY_422<br/>RK_FORMAT_YUYV_420<br/>RK_FORMAT_YVYU_420<br/>RK_FORMAT_UYVY_420<br/>RK_FORMAT_VYUY_420<br/>RK_FORMAT_YCbCr_400<br/>RK_FORMAT_Y4 361 </td> 362 </tr> 363 <tr> 364 <td>skylarkV2</td> 365 <td>RK3566/RK3568</td> 366 </tr> 367 <tr> 368 <td>Orion</td> 369 <td>RK3588</td> 370 </tr> 371 <tr> 372 <td>Otter</td> 373 <td>RV1106/1103</td> 374 </tr> 375 <tr> 376 <td rowspan="1">RGA3</td> 377 <td>Orion</td> 378 <td>RK3588</td> 379 <td rowspan="1"> 380RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YUYV_422<br/>RK_FORMAT_YVYU_422<br/>RK_FORMAT_UYVY_422<br/>RK_FORMAT_VYUY_422<br/>RK_FORMAT_YCbCr_420_SP_10B<br/>RK_FORMAT_YCrCb_420_SP_10B<br/>RK_FORMAT_YCbCr_422_SP_10B<br/>RK_FORMAT_YCrCb_422_SP_10B 381 </td> 382 <td rowspan="1"> 383RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565<br>RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YUYV_422<br/>RK_FORMAT_YVYU_422<br/>RK_FORMAT_UYVY_422<br/>RK_FORMAT_VYUY_422<br/>RK_FORMAT_YCbCr_420_SP_10B<br/>RK_FORMAT_YCrCb_420_SP_10B<br/>RK_FORMAT_YCbCr_422_SP_10B<br/>RK_FORMAT_YCrCb_422_SP_10B 384 </td> 385 </tr> 386</table> 387 388 389> Note: 390> 391> 1). The "RK_FORMAT_YCbCr_400" format means that the YUV format only takes the Y channel, and is often used in 256 (2 to the 8th power) grayscale images. Here, it should be noted that since the YUV format exists in the RGB/YUV color space conversion, you need to pay attention to the color space configuration , for example, a full 256-level grayscale image needs to be configured as full range during conversion. 392> 393> 2). The "RK_FORMAT_Y4" format means that the YUV format only takes the Y channel and dithers to 4 bits. It is often used in 16 (2 to the 4th power) grayscale images. The precautions involved in the configuration of the color space conversion are the same as “RK_FORMAT_YCbCr_400”. 394 395 396 397### Image Format Alignment Instructions 398 399<table> 400 <tr> 401 <td>Version</td> 402 <td>Byte_stride</td> 403 <td>Format</td> 404 <td>Alignment</td> 405 </tr> 406 <tr> 407 <td rowspan="4">RGA1<br/>RGA1_Plus</td> 408 <td rowspan="4">4</td> 409 <td> 410RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888 411 </td> 412 <td>width stride does not require alignment</td> 413 </tr> 414 <tr> 415 <td> 416RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565 417 </td> 418 <td>width stride must be 2-aligned</td> 419 </tr> 420 <tr> 421 <td> 422RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888 423 </td> 424 <td>width stride must be 4-aligned</td> 425 </tr> 426 <tr> 427 <td> 428RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P 429 </td> 430 <td>width stride must be 4-aligned,x_offset、y_offset、width、height、height stride must be 2-aligned</td> 431 </tr> 432 <tr> 433 <td rowspan="6">RGA2<br/>RGA2_Lite0<br/>RGA2_Lite1<br/>RGA2_Enhance</td> 434 <td rowspan="6">4</td> 435 <td> 436RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888 437 </td> 438 <td>width stride does not require alignment</td> 439 </tr> 440 <tr> 441 <td> 442RK_FORMAT_RGBA_4444<br/>RK_FORMAT_BGRA_4444<br/>RK_FORMAT_ARGB_4444<br/>RK_FORMAT_ABGR_4444<br/>RK_FORMAT_RGBA_5551<br/>RK_FORMAT_BGRA_5551<br/>RK_FORMAT_ARGB_5551<br/>RK_FORMAT_ABGR_5551<br/>RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565 443 </td> 444 <td>width stride must be 2-aligned</td> 445 </tr> 446 <tr> 447 <td> 448RK_FORMAT_YUYV_422<br/>RK_FORMAT_YVYU_422<br/>RK_FORMAT_UYVY_422<br/>RK_FORMAT_VYUY_422<br/>RK_FORMAT_YUYV_420<br/>RK_FORMAT_YVYU_420<br/>RK_FORMAT_UYVY_420<br/>RK_FORMAT_VYUY_420 449 </td> 450 <td>width stride must be 2-aligned,x_offset、y_offset、width、height、height stride must be 2-aligned</td> 451 </tr> 452 <tr> 453 <td> 454RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888 455 </td> 456 <td>width stride must be 4-aligned</td> 457 </tr> 458 <tr> 459 <td> 460RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP<br/>RK_FORMAT_YCbCr_420_P<br/>RK_FORMAT_YCrCbr_420_P<br/>RK_FORMAT_YCbCr_422_P<br/>RK_FORMAT_YCrCbr_422_P<br/>RK_FORMAT_YCbCr_400<br/>RK_FORMAT_Y4 461 </td> 462 <td>width stride must be 4-aligned,x_offset、y_offset、width、height、height stride must be 2-aligned</td> 463 </tr> 464 <tr> 465 <td> 466RK_FORMAT_YCbCr_420_SP_10B<br/>RK_FORMAT_YCrCb_420_SP_10B<br/>RK_FORMAT_YCbCr_422_SP_10B<br/>RK_FORMAT_YCrCb_422_SP_10B 467 </td> 468 <td>width stride must be 16-aligned,x_offset、y_offset、width、height、height stride must be 2-aligned</td> 469 </tr> 470 <tr> 471 <td rowspan="8">RGA3</td> 472 <td rowspan="8">16</td> 473 <td> 474RK_FORMAT_RGBA_8888<br/>RK_FORMAT_BGRA_8888<br/>RK_FORMAT_ARGB_8888<br/>RK_FORMAT_ABGR_8888<br/>RK_FORMAT_RGBX_8888<br/>RK_FORMAT_BGRX_8888<br/>RK_FORMAT_XRGB_8888<br/>RK_FORMAT_XBGR_8888 475 </td> 476 <td>width stride must be 4-aligned</td> 477 </tr> 478 <tr> 479 <td> 480RK_FORMAT_RGB_565<br/>RK_FORMAT_BGR_565 481 </td> 482 <td>width stride must be 8-aligned</td> 483 </tr> 484 <tr> 485 <td> 486RK_FORMAT_YUYV_422<br/>RK_FORMAT_YVYU_422<br/>RK_FORMAT_UYVY_422<br/>RK_FORMAT_VYUY_422 487 </td> 488 <td>width stride must be 8-aligned,x_offset、y_offset、width、height、height stride must be 2-aligned</td> 489 </tr> 490 <tr> 491 <td> 492RK_FORMAT_RGB_888<br/>RK_FORMAT_BGR_888 493 </td> 494 <td>width stride must be 16-aligned</td> 495 </tr> 496 <tr> 497 <td> 498RK_FORMAT_YCbCr_420_SP<br/>RK_FORMAT_YCrCbr_420_SP<br/>RK_FORMAT_YCbCr_422_SP<br/>RK_FORMAT_YCrCbr_422_SP 499 </td> 500 <td>width stride must be 16-aligned,x_offset、y_offset、width、height、height stride must be 2-aligned</td> 501 </tr> 502 <tr> 503 <td> 504RK_FORMAT_YCbCr_420_SP_10B<br/>RK_FORMAT_YCrCb_420_SP_10B<br/>RK_FORMAT_YCbCr_422_SP_10B<br/>RK_FORMAT_YCrCb_422_SP_10B 505 </td> 506 <td>width stride must be 64-aligned,x_offset、y_offset、width、height、height stride must be 2-aligned</td> 507 </tr> 508 <tr> 509 <td>FBC mode</td> 510 <td>In addition to the format alignment requirements above,width stride、height stride must be 16-aligned</td> 511 </tr> 512 <tr> 513 <td>TILE8*8 mode</td> 514 <td>In addition to the format alignment requirements above,width、height must be 8-aligned,input channel width stride、height stride must be 16-aligned。</td> 515 </tr> 516</table> 517 518 519> Note: 520> 521> 1). Alignment requirement formula: lcm(bpp,byte_stride * 8) / pixel_stride. 522> 523> 2). When loaded with multiple versions of hardware, chip platform constraints according to the most strict alignment requirements. 524 525 526 527--- 528 529## Version Description 530 531RGA's support library librga.so updates the version number according to certain rules, indicating the submission of new features, compatibility, and bug fixes, and provides several ways to query the version number, so that developers can clearly determine whether the current library version is suitable for the current development environment when using librga.so. Detailed version update logs can be found in **CHANGLOG.md** in the root directory of source code. 532 533### librga API Version Description 534 535#### Version Number Format and Update Rule 536 537##### Version Number Format 538 539``` 540major.minor.revision_[build] 541``` 542 543example: 544 545> 1.0.0_[0] 546 547 548 549##### Update Rule 550 551| Name | Rule | 552| -------- | ------------------------------------------------------ | 553| major | Major version number, when submitting a version that is not backward compatible. | 554| minor | Minor version number, when the functional API with backward compatibility is added. | 555| revision | Revision version number, when submitting backward compatible feature additions or fatal bug fixes. | 556| build | Compile version number, when backward compatibility issue is fixed. | 557 558 559 560#### Version Number Query 561 562##### Query by Strings 563 564Take Android R 64bit as example: 565 566```shell 567:/# strings vendor/lib64/librga.so |grep rga_api |grep version 568rga_api version 1.0.0_[0] 569``` 570 571 572 573##### Log Print 574 575Version number is printed when each process first calls RGA API. 576 577``` 578rockchiprga: rga_api version 1.0.0_[0] 579``` 580 581 582 583##### Query by API 584 585Call the following API to query the code version number, compilation version number, and RGA hardware version information. For details, see **API Description**. 586 587``` 588querystring(RGA_VERSION); 589``` 590 591> String format is as follows: 592> 593> RGA_api version : v1.0.0_[0] 594> RGA version : RGA_2_Enhance 595 596 597 598##### Query by Property 599 600This method is supported only by Android system, and the property takes effect only after an existing process calls RGA. 601 602```shell 603:/# getprop |grep rga 604[vendor.rga_api.version]: [1.0.0_[0]] 605``` 606 607 608 609### Driver Version Description 610 611librga calls the RGA hardware based on the driver, it must be ensured that the driver version is within the supported range of the used librga library. 612 613#### Version Number Format and Update Rule 614 615##### Version Number Format 616 617``` 618<driver_name>: v major.minor.revision 619``` 620 621example: 622 623> RGA2 Device Driver: v2.1.0 624> 625> RGA multicore Device Driver: v1.2.23 626 627 628 629##### Update Rule 630 631| Name | Rule | 632| -------- | ------------------------------------------------------------ | 633| major | Major version number, when submitting a version that is not backward compatible. | 634| minor | Minor version number, when the functional API with backward compatibility is added. | 635| revision | Revision version number, when submitting backward compatible feature additions or fatal bug fixes. | 636 637 638 639#### Version Number Query 640 641##### Boot log query: 642 643Use the following command to query the RGA driver initialization log after booting. Some early drivers do not print the version number, and this method is only applicable to some drivers. 644 645``` 646 dmesg |grep rga 647``` 648 649example: 650 651> [ 2.382393] rga3_core0 fdb60000.rga: Adding to iommu group 2 652> [ 2.382651] rga: rga3_core0, irq = 33, match scheduler 653> [ 2.383058] rga: rga3_core0 hardware loaded successfully, hw_version:3.0.76831. 654> [ 2.383121] rga: rga3_core0 probe successfully 655> [ 2.383687] rga3_core1 fdb70000.rga: Adding to iommu group 3 656> [ 2.383917] rga: rga3_core1, irq = 34, match scheduler 657> [ 2.384313] rga: rga3_core1 hardware loaded successfully, hw_version:3.0.76831. 658> [ 2.384412] rga: rga3_core1 probe successfully 659> [ 2.384893] rga: rga2, irq = 35, match scheduler 660> [ 2.385238] rga: rga2 hardware loaded successfully, hw_version:3.2.63318. 661> [ 2.385257] rga: rga2 probe successfully 662> [ 2.385455] rga_iommu: IOMMU binding successfully, default mapping core[0x1] 663> [ 2.385586] rga: Module initialized. v1.2.23 664 665Among them, “v1.2.23” is the driver version number. 666 667 668 669##### debug node query 670 671The version number can be queried through the driver debugging node. If there is no following node, it means that the driver version that does not support query is currently running. 672 673- Use the kernel with the CONFIG_ROCKCHIP_RGA_DEBUG_FS compile config enabled by default. 674 675```shell 676cat /sys/kernel/debug/rkrga/driver_version 677``` 678 679- Use the kernel with the CONFIG_ROCKCHIP_RGA_PROC_FS compile config enabled. 680 681```shell 682cat /proc/rkrga/driver_version 683``` 684 685example: 686 687> cat /sys/kernel/debug/rkrga/driver_version 688> RGA multicore Device Driver: v1.2.23 689 690Here "RGA multicore Device Driver" means that the driver name is RGA multicore Device Driver, and "v1.2.23" means that the version is 1.2.23, which means that the current driver is the RGA multicore Device Driver(usually referred to as multi_rga driver) of version 1.2.23 . 691 692> cat /sys/kernel/debug/rkrga/driver_version 693> RGA2 Device Driver: v2.1.0 694 695Here "RGA2 Device Driver" means that the driver name is RGA2 Device Driver, and "v2.1.0" means that the version number is 2.1.0, which means that the current driver is the RGA2 Device Driver (usually referred to as rga2 driver) of version 2.1.0. 696 697 698 699### Correspondence between versions 700 701When using RGA, you need to confirm that the current operating environment can work normally. The following table shows the correspondence between commonly used librga and driver versions. 702 703| librga version | driver version | hardware | 704| ----------------- | ------------------------------------------------------------ | ---------------- | 705| no version number | Drivers in the SDK | RGA1、RGA2 | 706| 1.0.0 ~ 1.3.2 | RGA Device Driver(kernel - 4.4 and above)<br/>RGA2 Device Driver(no version number or v2.1.0) | RGA1、RGA2 | 707| > 1.4.0 | RGA multicore Device Driver(v1.2.0and above) | RGA2、RGA3 | 708| > 1.9.0 | RGA Device Driver(kernel-4.4 and above)<br/>RGA2 Device Driver(no version number or v2.1.0)<br/>RGA multicore Device Driver(v1.2.0and above) | RGA1、RGA2、RGA3 | 709 710 711 712--- 713 714## API Description 715 716RGA library librga.so realizes 2D graphics operations through the image buffer structure rga_info configuration. In order to obtain a better development experience, the common 2D image operation API is further encapsulated. The new API mainly contains the following features: 717- API definitions refer to common 2D graphics API definitions in opencv/matlab, reducing the learning cost of secondary development. 718- To eliminate compatibility problems caused by RGA hardware version differences, RGA query is added. Query mainly includes version information, large resolution and image format support. 719- Add improcess API for 2D image compound operations. Compound operations are performed by passing in a set of predefined usage. 720- Before performing image operation, the input and output image buffers need to be processed. The wrapbuffer_T API is called to pass the input and output image information to rga_buffer_t, which contains information such as resolution and image format. 721- It supports to bind the image composite operation that cannot be completed in a single time as an RGA image task, and submit it to the driver and execute it one by one. 722 723 724 725### Overview 726 727The software support library provides the following API, asynchronous mode only supports C++ implementation. 728 729- **querystring**: Query information about the RGA hardware version and supported functions of chip platform, return a string. 730- **imcheckHeader**: Verify the difference between the currently used header file version and the librga version. 731- **importbuffer_T**: Import external buffer into RGA driver to achieve hardware fast access to discontinuous physical addresses (dma_fd, virtual address). 732- **releasebuffer_handle**: Remove reference and map of the external buffer from inside the RGA driver. 733- **wrapbuffer_handle** Quickly encapsulate the image buffer structure (rga_buffer_t). 734- **imbeginJob**:Create an RGA image processing job. 735- **imendJob**: Submit and execute RGA image processing job. 736- **imcancelJob**: Cancel and delete the RGA image processing job. 737- **imcopy**: Call RGA for fast image copy. 738- **imcopyTask**: Added fast image copy operation to RGA image job. 739- **imresize**: Call RGA for fast image resize. 740- **imresizeTask**: Added fast image resize operation to RGA image job. 741- **impyramind**: Call RGA for fast image pyramid. 742- **imcrop**: Call RGA for fast image cropping. 743- **imcropTask**: Added fast image cropping operation to RGA image job. 744- **imtranslate**: Call RGA for fast image translation. 745- **imtranslateTask**: Added fast image translation operation to RGA image job. 746- **imcvtcolor**: Call RGA for fast image format conversion. 747- **imcvtcolorTask**: Added fast image format conversion operation to RGA image job. 748- **imrotate**: Call RGA for fast image rotation. 749- **imrotateTask**: Added fast image rotation operation to RGA image job. 750- **imflip**: Call RGA for fast image flipping. 751- **imflipTask**: Added fast image flipping operation to RGA image job. 752- **imblend**: Call RGA for double channel fast image blending. 753- **imblendTask**: Added double channel fast image blending operation to RGA image job. 754- **imcomposite**: Call RGA for three-channel fast image composite. 755- **imcompositeTask**: Added three-channel fast image composite operation to RGA image job. 756- **imcolorkey**: Call RGA for fast image color key. 757- **imcolorkeyTask**: Added fast image color key operation to RGA image job. 758- **imosd**: Call RGA for fast image OSD. 759- **imosdTask**:Added fast image OSD operation to RGA image job. 760- **imquantize**: Call RGA for fast image operation point preprocessing (quantization). 761- **imquantizeTask**: Added fast image operation point preprocessing (quantization) operation to RGA image job. 762- **imrop**: Call RGA for fast image ROP. 763- **imropTask**: Added fast image ROP operation to RGA image job. 764- **imfill**: Call RGA for fast image filling. 765- **imfillArray**: Call RGA to implement multiple groups of fast image filling. 766- **imfillTask**: Added fast image filling operation to RGA image job. 767- **imfillTaskArray**: Added multiple groups of fast image filling operation to RGA image job. 768- **imrectangle**: Call RGA for fast drawing operation of equidistant rectangle border. 769- **imrectangleArray**: Call RGA for multiple groups of fast drawing operation of equidistant rectangle border. 770- **imrectangleTask**: Added fast drawing operation of equidistant rectangle border operation to RGA image job. 771- **imrectangleTaskArray**: Added multiple groups of fast drawing operation of equidistant rectangle border operation to RGA image job. 772- **immakeBorder**: Call RGA for fast drawing operation of the border. 773- **immosaic**: call RGA for fast mosaic masking. 774- **immosaicArray**: call RGA for fast multiple groups of mosaic masking. 775- **immosaicTask**:Added fast mosaic masking operation to RGA image job. 776- **immosaicTaskArray**:Added fast multiple groups of mosaic masking operation to RGA image job. 777- **improcess**: Call RGA for fast image compound processing. 778- **improcessTask**: Added fast image compound processing operation to RGA image job. 779- **imcheck**: Verify whether the parameters are valid and whether the current hardware supports the operation. 780- **imsync**: Synchronize task completion status in asynchronous mode. 781- **imconfig**: Add default configuration to current thread context. 782 783 784 785### Obtain RGA Version and Support Information 786 787#### querystring 788 789```C++ 790const char* querystring(int name); 791``` 792 793> Query RGA basic information and resolution format. 794 795| **Parameters** | **Description** | 796| -------------- | ------------------------------------------------------------ | 797| name | RGA_VENDOR - vendor information<br/>RGA_VERSION - RGA version<br/>RGA_MAX_INPUT - max input resolution<br/>RGA_MAX_OUTPUT - max output resolution<br/>RGA_BYTE_STRIDE - stride alignment requirements<br/>RGA_SCALE_LIMIT - scale limit<br/>RGA_INPUT_FORMAT - input formats supported<br/>RGA_OUTPUT_FORMAT - output formats supported<br/>RGA_EXPECTED - expected performance<br/>RGA_ALL - print all information | 798 799 **Returns** a string describing properties of RGA. 800 801 802 803### header version check 804 805#### imcheckHeader 806 807```C++ 808IM_API IM_STATUS imcheckHeader(im_api_version_t header_version = RGA_CURRENT_API_HEADER_VERSION); 809``` 810 811> Verify the difference between the currently used header file version and the librga version. 812 813| **Parameters** | **Description** | 814| -------------- | ------------------------------------------------------------ | 815| header_version | Header file version, usually use the macro RGA_CURRENT_API_HEADER_VERSION. | 816 817**Return** IM_STATUS_SUCCESS on success or else negative error code. 818 819 820 821### Image Buffer Preprocessing 822 823#### importbuffer_T 824 825> For external memory that requires RGA processing, you can use importbuffer_T to map physical address of buffer to RGA driver and obtain the corresponding address of buffer, facilitating the subsequent stable and fast RGA call to complete the work. 826 827| **Parameters(T)** | Data Type | Description | 828| -------------------- | --------------- | ------------------------------------------------------------ | 829| virtual address | void * | image buffer virtual address | 830| physical address | uint64_t | contiguous physical address of image buffer | 831| fd | int | image buffer DMA file descriptor | 832| GraphicBuffer handle | buffer_handle_t | image buffer handle, containing buffer address, file descriptor, resolution and format | 833| GraphicBuffer | GraphicBuffer | android graphic buffer | 834| AHardwareBuffer | AHardwareBuffer | chunks of memory that can be accessed by various hardware components in the system. https://developer.android.com/ndk/reference/group/a-hardware-buffer | 835 836> Performance varies when different buffer types call RGA, and the performance order is shown below: 837> 838> physical address > fd > virtual address 839> 840> The recommended buffer type is fd. 841 842```c++ 843IM_API rga_buffer_handle_t importbuffer_fd(int fd, int size); 844IM_API rga_buffer_handle_t importbuffer_virtualaddr(void *va, int size); 845IM_API rga_buffer_handle_t importbuffer_physicaladdr(uint64_t pa, int size); 846``` 847 848| Parameter | **Description** | 849| --------- | ------------------------------ | 850| fd/va/pa | **[required]** external buffer | 851| size | **[required]** memory size | 852 853```c++ 854IM_API rga_buffer_handle_t importbuffer_fd(int fd, int width, int height, int format); 855IM_API rga_buffer_handle_t importbuffer_virtualaddr(void *va, int width, int height, int format); 856IM_API rga_buffer_handle_t importbuffer_physicaladdr(uint64_t pa, int width, int height, int format); 857``` 858 859| Parameter | **Description** | 860| --------- | ------------------------------------------------------ | 861| fd/va/pa | **[required]** external buffer | 862| width | **[required]** pixel width stride of the image buffer | 863| height | **[required]** pixel height stride of the image buffer | 864| format | **[required]** pixel format of the image buffer | 865 866```c++ 867IM_API rga_buffer_handle_t importbuffer_fd(int fd, im_handle_param_t *param); 868IM_API rga_buffer_handle_t importbuffer_virtualaddr(void *va, im_handle_param_t *param); 869IM_API rga_buffer_handle_t importbuffer_physicaladdr(uint64_t pa, im_handle_param_t *param); 870``` 871 872| Parameter | **Description** | 873| --------- | ------------------------------------------ | 874| fd/va/pa | **[required]** external buffer | 875| param | **[required]** configure buffer parameters | 876 877```c++ 878IM_API rga_buffer_handle_t importbuffer_GraphicBuffer_handle(buffer_handle_t hnd); 879IM_API rga_buffer_handle_t importbuffer_GraphicBuffer(sp<GraphicBuffer> buf); 880IM_API rga_buffer_handle_t importbuffer_AHardwareBuffer(AHardwareBuffer *buf); 881``` 882 883| Parameter | **Description** | 884| --------- | ------------------------------ | 885| hnd/buf | **[required]** external buffer | 886 887**Returns** rga_buffer_handle_t to describe the memory handle. 888 889 890 891#### releasebuffer_handle 892 893> After finishing calling RGA using external memory, you need to call releasebuffer_handle through memory handle to remove the mapping and binding between buffer and RGA driver, and release the resource inside RGA driver. 894 895```c++ 896IM_API IM_STATUS releasebuffer_handle(rga_buffer_handle_t handle); 897``` 898 899**Return** IM_STATUS_SUCCESS on success or else negative error code. 900 901 902 903#### wrapbuffer_handle 904 905> In IM2D library API parameters, input image and output image should support multiple types, which mainly include memory, image format, image width and height. Before performing corresponding image operation, you need to call wrapbuffer_handle to convert the input and output image parameters into rga_buffer_t structure as the input parameter of user API. 906 907```C++ 908rga_buffer_t wrapbuffer_handle(rga_buffer_handle_t handle, 909 int width, 910 int height, 911 int format, 912 int wstride = width, 913 int hstride = height); 914``` 915| Parameter | **Description** | 916| --------- | ------------------------------------------------------------ | 917| handle | **[required]** RGA buffer handle | 918| width | **[required]** pixel width of the image that needs to be processed | 919| height | **[required]** pixel height of the image that needs to be processed | 920| format | **[required]** pixel format | 921| wtride | **[optional]** pixel width stride of the image | 922| hstride | **[optional]** pixel width stride of the image | 923 924 **Returns** a rga_buffer_t to desribe image information. 925 926 927 928### Image processing job create 929 930#### imbeginJob 931 932```c++ 933IM_API im_job_handle_t imbeginJob(uint64_t flags = 0); 934``` 935 936> Create an RGA image processing job, which will return a job handle, job_handle can be used to add/remove RGA image operations, submit/execute the job. 937 938| Parameter | **Description** | 939| --------- | ------------------------ | 940| flags | **[optional]** job flags | 941 942**Returns** im_job_handle_t to describe the job handle. 943 944 945 946### Image processing job submit 947 948#### imendJob 949 950```c++ 951IM_API IM_STATUS imendJob(im_job_handle_t job_handle, 952 int sync_mode = IM_SYNC, 953 int acquire_fence_fd = 0, 954 int *release_fence_fd = NULL); 955``` 956 957> Submit and execute RGA image processing job. When the job is complete, the currently completed RGA image processing job resource is deleted. 958 959| Parameter | **Description** | 960| ---------------- | ------------------------------------------------------------ | 961| job_handle | **[required]** job handle | 962| sync_mode | **[optional]** wait until operation complete | 963| acquire_fence_fd | **[optional]** Used in async mode, run the job after waiting foracquire_fence signal | 964| release_fence_fd | **[optional]** Used in async mode, as a parameter of imsync() | 965 966**Return** IM_STATUS_SUCCESS on success or else negative error code. 967 968 969 970### Image processing job cancel 971 972#### imcancelJob 973 974```c++ 975IM_API IM_STATUS imcancelJob(im_job_handle_t job_handle); 976``` 977 978> cancel and delete RGA image processing job. 979 980| Parameter | **Description** | 981| ---------- | ------------------------- | 982| job_handle | **[required]** job handle | 983 984**Return** IM_STATUS_SUCCESS on success or else negative error code. 985 986 987 988### Image Copy 989 990#### imcopy 991 992```C++ 993IM_STATUS imcopy(const rga_buffer_t src, 994 rga_buffer_t dst, 995 int sync = 1), 996 int *release_fence_fd = NULL); 997``` 998 999> Copy the image, RGA basic operation. Its function is similar to memcpy. 1000 1001| Parameter | **Description** | 1002| ---------------- | ------------------------------------------------------------ | 1003| src | **[required]** input image | 1004| dst | **[required]** output image | 1005| sync | **[optional]** wait until operation complete | 1006| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1007 1008**Return** IM_STATUS_SUCCESS on success or else negative error code. 1009 1010 1011 1012#### imcopyTask 1013 1014```C++ 1015IM_API IM_STATUS imcopyTask(im_job_handle_t job_handle, 1016 const rga_buffer_t src, 1017 rga_buffer_t dst); 1018``` 1019 1020> Add an image copy operation to the specified job through job_handle. The configuration parameters are the same as imcopy. 1021 1022| Parameter | **Description** | 1023| ---------- | --------------------------- | 1024| job_handle | **[required]** job handle | 1025| src | **[required]** input image | 1026| dst | **[required]** output image | 1027 1028**Return** IM_STATUS_SUCCESS on success or else negative error code. 1029 1030 1031 1032### Image Resizing and Image Pyramid 1033 1034#### imresize 1035 1036```C++ 1037IM_STATUS 1038imresize(const rga_buffer_t src, 1039 rga_buffer_t dst, 1040 double fx = 0, 1041 double fy = 0, 1042 int interpolation = INTER_LINEAR, 1043 int sync = 1, 1044 int *release_fence_fd = NULL); 1045``` 1046 1047> According to different scenario, you can choose to configure dst to describe the output image size of resizing, or configure the scale factor fx/fy to resize at a specified ratio. When dst and fx/fy are configured at the same time, the calculated result of fx/fy is used as the output image size. 1048> 1049> Only hardware version RGA1/RGA1 plus supports interpolation configuration. 1050> 1051> Note: When resizing with fx/fy, format such as YUV that requires width and height alignment will force downward alignment to meet the requirements. Using this feature may affect the expected resizing effect. 1052 1053| Parameters | Description | 1054| ---------------- | ------------------------------------------------------------ | 1055| src | **[required]** input image | 1056| dst | **[required]** output image; it has the size dsize (when it is non-zero) or the size computed from src.size(), fx, and fy; the type of dst is the same as of src. | 1057| fx | **[optional]** scale factor along the horizontal axis; when it equals 0, it is computed as:<br/>fx = (double) dst.width / src.width | 1058| fy | **[optional]** scale factor along the vertical axis; when it equals 0, it is computed as:<br/>fy = (double) dst.height / src.height | 1059| interpolation | **[optional]** interpolation method:<br/>INTER_NEAREST - a nearest-neighbor interpolation<br/>INTER_LINEAR - a bilinear interpolation (used by default)<br/>INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood | 1060| sync | **[optional]** wait until operation complete | 1061| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1062 1063**Return** IM_STATUS_SUCCESS on success or else negative error code. 1064 1065 1066 1067#### impyramid 1068 1069```C++ 1070IM_STATUS impyramid (const rga_buffer_t src, 1071 rga_buffer_t dst, 1072 IM_SCALE direction) 1073``` 1074 1075> Pyramid scaling. Scale by 1/2 or twice, depending on the direction width and height. 1076 1077| Parameters | Description | 1078| ---------------- | ------------------------------------------------------------ | 1079| src | **[required]** input image | 1080| dst | **[required]** output image; | 1081| direction | **[required]** scale mode<br/>IM_UP_SCALE —— up scale <br/>IM_DOWN_SCALE —— down scale | 1082| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1083 1084**Return** IM_STATUS_SUCCESS on success or else negative error code. 1085 1086 1087 1088#### imresizeTask 1089 1090```C++ 1091IM_API IM_STATUS imresizeTask(im_job_handle_t job_handle, 1092 const rga_buffer_t src, 1093 rga_buffer_t dst, 1094 double fx = 0, 1095 double fy = 0, 1096 int interpolation = 0); 1097``` 1098 1099> Add an image resize operation to the specified job through job_handle. The configuration parameters are the same as imresize. 1100 1101| Parameters | Description | 1102| ------------- | ------------------------------------------------------------ | 1103| job_handle | **[required]** job handle | 1104| src | **[required]** input image | 1105| dst | **[required]** output image; it has the size dsize (when it is non-zero) or the size computed from src.size(), fx, and fy; the type of dst is the same as of src. | 1106| fx | **[optional]** scale factor along the horizontal axis; when it equals 0, it is computed as:<br/>fx = (double) dst.width / src.width | 1107| fy | **[optional]** scale factor along the vertical axis; when it equals 0, it is computed as:<br/>fy = (double) dst.height / src.height | 1108| interpolation | **[optional]** interpolation method:<br/>INTER_NEAREST - a nearest-neighbor interpolation<br/>INTER_LINEAR - a bilinear interpolation (used by default)<br/>INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood | 1109 1110**Return** IM_STATUS_SUCCESS on success or else negative error code. 1111 1112 1113 1114### Image Cropping 1115 1116#### imcrop 1117 1118```C++ 1119IM_STATUS imcrop(const rga_buffer_t src, 1120 rga_buffer_t dst, 1121 im_rect rect, 1122 int sync = 1, 1123 int *release_fence_fd = NULL); 1124``` 1125 1126> Perform image clipping by specifying the size of the region. 1127 1128| Parameter | Description | 1129| ---------------- | ------------------------------------------------------------ | 1130| src | **[required] **input image | 1131| dst | **[required]** output image | 1132| rect | **[required]** crop region<br/>x - upper-left x coordinate<br/>y - upper-left y coordinate<br/>width - region width<br/>height - region height | 1133| sync | **[optional]** wait until operation complete | 1134| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1135 1136**Return** IM_STATUS_SUCCESS on success or else negative error code. 1137 1138 1139 1140#### imcropTask 1141 1142```C++ 1143IM_API IM_STATUS imcropTask(im_job_handle_t job_handle, 1144 const rga_buffer_t src, 1145 rga_buffer_t dst, 1146 im_rect rect); 1147``` 1148 1149> Add an image crop operation to the specified job through job_handle. The configuration parameters are the same as imcrop. 1150 1151| Parameter | Description | 1152| ---------- | ------------------------------------------------------------ | 1153| job_handle | **[required]** job handle | 1154| src | **[required] **input image | 1155| dst | **[required]** output image | 1156| rect | **[required]** crop region<br/>x - upper-left x coordinate<br/>y - upper-left y coordinate<br/>width - region width<br/>height - region height | 1157 1158**Return** IM_STATUS_SUCCESS on success or else negative error code. 1159 1160 1161 1162### Image Translation 1163 1164#### imtranslate 1165 1166```C++ 1167IM_STATUS imtranslate(const rga_buffer_t src, 1168 rga_buffer_t dst, 1169 int x, 1170 int y, 1171 int sync = 1, 1172 int *release_fence_fd = NULL); 1173``` 1174 1175> Image translation. Move to (x, y) position, the width and height of src and dst must be the same, the excess part will be clipped. 1176 1177| Parameter | Description | 1178| ---------------- | ------------------------------------------------------------ | 1179| src | **[required]**input image | 1180| dst | **[required]** output image | 1181| x | **[optional]** horizontal translation | 1182| y | **[optional]** vertical translation | 1183| sync | **[optional]** wait until operation complete | 1184| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1185 1186**Return** IM_STATUS_SUCCESS on success or else negative error code. 1187 1188 1189 1190#### imtranslateTask 1191 1192```C++ 1193IM_API IM_STATUS imtranslateTask(im_job_handle_t job_handle, 1194 const rga_buffer_t src, 1195 rga_buffer_t dst, 1196 int x, 1197 int y); 1198``` 1199 1200> Add an image translation operation to the specified job through job_handle. The configuration parameters are the same as imtranslate. 1201 1202| Parameter | Description | 1203| ---------- | ------------------------------------- | 1204| job_handle | **[required]** job handle | 1205| src | **[required]**input image | 1206| dst | **[required]** output image | 1207| x | **[required]** horizontal translation | 1208| y | **[required]** vertical translation | 1209 1210**Return** IM_STATUS_SUCCESS on success or else negative error code. 1211 1212 1213 1214### Image Format Conversion 1215 1216#### imcvtcolor 1217 1218```C++ 1219IM_STATUS imcvtcolor(rga_buffer_t src, 1220 rga_buffer_t dst, 1221 int sfmt, 1222 int dfmt, 1223 int mode = IM_COLOR_SPACE_DEFAULT, 1224 int sync = 1, 1225 int *release_fence_fd = NULL); 1226``` 1227 1228> Image format conversion,specific format support varies according to soc, please refer to the **Image Format Supported** section. 1229> 1230> The format can be set by rga_buffer_t, or configure the input image and output image formats respectively by sfmt/dfmt. When it comes to YUV/RGB color gamut conversion, you can configure the converted color gamut through mode, and the conversion is performed according to the BT.601 limit range by default. 1231 1232| parameter | Description | 1233| ---------------- | ------------------------------------------------------------ | 1234| src | **[required]** input image | 1235| dst | **[required]** output image | 1236| sfmt | **[optional]** source image format | 1237| dfmt | **[optional]** destination image format | 1238| Mode | **[optional]** color space mode:<br/>IM_YUV_TO_RGB_BT601_LIMIT<br/>IM_YUV_TO_RGB_BT601_FULL<br/>IM_YUV_TO_RGB_BT709_LIMIT<br/>IM_RGB_TO_YUV_BT601_LIMIT<br/>IM_RGB_TO_YUV_BT601_FULL<br/>IM_RGB_TO_YUV_BT709_LIMIT | 1239| sync | **[optional]** wait until operation complete | 1240| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1241 1242**Return** IM_STATUS_SUCCESS on success or else negative error code. 1243 1244 1245 1246#### imcvtcolorTask 1247 1248```C++ 1249IM_API IM_STATUS imcvtcolorTask(im_job_handle_t job_handle, 1250 rga_buffer_t src, 1251 rga_buffer_t dst, 1252 int sfmt, 1253 int dfmt, 1254 int mode = IM_COLOR_SPACE_DEFAULT); 1255``` 1256 1257> Add an image format conversion operation to the specified job through job_handle. The configuration parameters are the same as imcvtcolor. 1258 1259| parameter | Description | 1260| ---------- | ------------------------------------------------------------ | 1261| job_handle | **[required]** job handle | 1262| src | **[required]** input image | 1263| dst | **[required]** output image | 1264| sfmt | **[optional]** source image format | 1265| dfmt | **[optional]** destination image format | 1266| Mode | **[optional]** color space mode:<br/>IM_YUV_TO_RGB_BT601_LIMIT<br/>IM_YUV_TO_RGB_BT601_FULL<br/>IM_YUV_TO_RGB_BT709_LIMIT<br/>IM_RGB_TO_YUV_BT601_LIMIT<br/>IM_RGB_TO_YUV_BT601_FULL<br/>IM_RGB_TO_YUV_BT709_LIMIT | 1267 1268**Return** IM_STATUS_SUCCESS on success or else negative error code. 1269 1270 1271 1272### Image Rotation 1273 1274#### imrotate 1275 1276```c++ 1277IM_STATUS imrotate(const rga_buffer_t src, 1278 rga_buffer_t dst, 1279 int rotation, 1280 int sync = 1, 1281 int *release_fence_fd = NULL); 1282``` 1283 1284 1285> Support image rotation 90,180,270 degrees. 1286 1287| Parameter | Description | 1288| ---------------- | ------------------------------------------------------------ | 1289| src | **[required]** input image | 1290| dst | **[required]** output image | 1291| rotation | **[required]** rotation angle:<br/>0<br/>IM_HAL_TRANSFORM_ROT_90<br/>IM_HAL_TRANSFORM_ROT_180<br/>IM_HAL_TRANSFORM_ROT_270 | 1292| sync | **[optional]** wait until operation complete | 1293| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1294 1295**Return** IM_STATUS_SUCCESS on success or else negative error code. 1296 1297 1298 1299#### imrotateTask 1300 1301```c++ 1302IM_API IM_STATUS imrotateTask(im_job_handle_t job_handle, 1303 const rga_buffer_t src, 1304 rga_buffer_t dst, 1305 int rotation); 1306``` 1307 1308>Add an image rotation operation to the specified job through job_handle. The configuration parameters are the same as imrotate. 1309 1310| Parameter | Description | 1311| ---------- | ------------------------------------------------------------ | 1312| job_handle | **[required]** job handle | 1313| src | **[required]** input image | 1314| dst | **[required]** output image | 1315| rotation | **[required]** rotation angle:<br/>IM_HAL_TRANSFORM_ROT_90<br/>IM_HAL_TRANSFORM_ROT_180<br/>IM_HAL_TRANSFORM_ROT_270 | 1316 1317**Return** IM_STATUS_SUCCESS on success or else negative error code. 1318 1319 1320 1321### Image Mirror Flip 1322 1323#### imfilp 1324 1325```c++ 1326IM_STATUS imflip (const rga_buffer_t src, 1327 rga_buffer_t dst, 1328 int mode, 1329 int sync = 1, 1330 int *release_fence_fd = NULL); 1331``` 1332 1333> Support image to do horizontal, vertical mirror flip. 1334 1335| Parameter | Description | 1336| ---------------- | ------------------------------------------------------------ | 1337| src | **[required]** input image | 1338| dst | **[required]** output image | 1339| mode | **[optional]** flip mode:<br/>0<br/>IM_HAL_TRANSFORM_FLIP_H<br/>IM_HAL_TRANSFORM_FLIP_V<br/> | 1340| sync | **[optional]** wait until operation complete | 1341| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1342 1343**Return** IM_STATUS_SUCCESS on success or else negative error code. 1344 1345 1346 1347#### imflipTask 1348 1349```c++ 1350IM_API IM_STATUS imflipTask(im_job_handle_t job_handle, 1351 const rga_buffer_t src, 1352 rga_buffer_t dst, 1353 int mode); 1354``` 1355 1356> Add an image flip operation to the specified job through job_handle. The configuration parameters are the same as imflip. 1357 1358| Parameter | Description | 1359| ---------- | ------------------------------------------------------------ | 1360| job_handle | **[required]** job handle | 1361| src | **[required]** input image | 1362| dst | **[required]** output image | 1363| mode | **[required]** flip mode:<br/>IM_HAL_TRANSFORM_FLIP_H_V<br/>IM_HAL_TRANSFORM_FLIP_H<br/>IM_HAL_TRANSFORM_FLIP_V | 1364 1365**Return** IM_STATUS_SUCCESS on success or else negative error code. 1366 1367 1368 1369### Image Blending 1370 1371#### imblend/imcomposite 1372 1373```c++ 1374IM_STATUS imblend(const rga_buffer_t srcA, 1375 rga_buffer_t dst, 1376 int mode = IM_ALPHA_BLEND_SRC_OVER, 1377 int sync = 1, 1378 int *release_fence_fd = NULL); 1379``` 1380 1381> RGA uses A+B -> B image two-channel blending mode to perform Alpha superposition for foreground image (srcA channel) and background image (dst channel) according to the configured blending model, and output the blending result to dst channel. When no mode is configured, it is set to src-over mode by default. 1382 1383```c++ 1384IM_STATUS imcomposite(const rga_buffer_t srcA, 1385 const rga_buffer_t srcB, 1386 rga_buffer_t dst, 1387 int mode = IM_ALPHA_BLEND_SRC_OVER, 1388 int sync = 1, 1389 int *release_fence_fd = NULL); 1390``` 1391 1392> RGA uses A+B -> C image three-channel blending mode to perform Alpha superposition for foreground image (srcA channel) and background image (srcB channel) according to the configured blending model, and output the blending result to dst channel. 1393 1394mode in the two image blending modes can be configured with different **Porter-Duff blending model**: 1395 1396> Before describing the Porter-Duff blending model, give the following definitions: 1397> 1398> - S -**Marks the source image in two blended images**,namely the foreground image, short for source. 1399> - D -**Marks the destination image in two blended images**,namely the background image, short for destination. 1400> - R -**Marks the result of two images blending**,short for result. 1401> - c -**Marks the color of the pixel**,the RGB part of RGBA, which describes the color of the image itself, short for color.(**Note**,Color values (RGB) in the Porter-Duff blending model are all left-multiplied results, that is, the product of original color and transparency. If the color values are not left-multiplied, pre-multiplied operations(Xc = Xc * Xa) are required.) 1402> - a -**Marks the Alpha of the pixel**,Namely the A part of RGBA, describe the transparency of the image itself, short for Alpha. 1403> - f -**Marks factors acting on C or A**,short for factor. 1404> 1405> The core formula of Porter-Duff blending model is as follows: 1406> 1407> Rc = Sc * Sf + Dc * Df; 1408> 1409> that is: result color = source color * source factor + destination color * destination factor. 1410> 1411> Ra = Sa * Sf + Da * Df; 1412> 1413> that is: result Alpha = source Alpha * source factor + destination Alpha * destination factor. 1414 1415RGA supports following blending models: 1416 1417> SRC: 1418> 1419> Sf = 1, Df = 0; 1420> 1421> [Rc,Ra] = [Sc,Sa]; 1422> 1423> DST: 1424> 1425> Sf = 0, Df = 1; 1426> 1427> [Rc,Ra] = [Dc,Da]; 1428> 1429> SRC_OVER: 1430> 1431> Sf = 1, Df = (1 - Sa); 1432> 1433> [Rc,Ra] = [ Sc + (1 - Sa) * Dc, Sa + (1 - Sa) * Da ]; 1434> 1435> DST_OVER: 1436> 1437> Sf = (1 - Da) , Df = 1; 1438> 1439> [Rc,Ra] = [ Sc * (1 - Da) + Dc, Sa * (1 - Da) + Da ] ; 1440 1441【Note】Image blending model does not support the YUV format image blending, the YUV format is not support in dst image of imblend , the YUV format is not support in srcB image of imcomposite. 1442 1443| Parameter | Description | 1444| ---------------- | ------------------------------------------------------------ | 1445| srcA | **[required]** input image A | 1446| srcB | **[required]** input image B | 1447| dst | **[required]** output image | 1448| mode | **[optional]** blending mode:<br/>IM_ALPHA_BLEND_SRC —— SRC mode<br/>IM_ALPHA_BLEND_DST —— DST mode <br/>IM_ALPHA_BLEND_SRC_OVER —— SRC OVER mode<br/>IM_ALPHA_BLEND_DST_OVER —— DST OVER mode<br />IM_ALPHA_BLEND_PRE_MUL —— Enable premultipling. When premultipling is required, this identifier must be processed with other mode identifiers, then assign to mode | 1449| sync | **[optional]** wait until operation complete | 1450| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1451 1452**Return** IM_STATUS_SUCCESS on success or else negative error code. 1453 1454 1455 1456#### imblendTask/imcompositeTask 1457 1458```c++ 1459IM_API IM_STATUS imblendTask(im_job_handle_t job_handle, 1460 const rga_buffer_t fg_image, 1461 rga_buffer_t bg_image, 1462 int mode = IM_ALPHA_BLEND_SRC_OVER); 1463``` 1464 1465> Add an A+B -> B image two-channel blending operation to the specified job through job_handle. The configuration parameters are the same as imblend. When no mode is configured, it is set to src-over mode by default. 1466 1467```c++ 1468IM_API IM_STATUS imcompositeTask(im_job_handle_t job_handle, 1469 const rga_buffer_t fg_image, 1470 const rga_buffer_t bg_image, 1471 rga_buffer_t output_image, 1472 int mode = IM_ALPHA_BLEND_SRC_OVER); 1473``` 1474 1475> Add an A+B -> C image three-channel blending operation to the specified job through job_handle. The configuration parameters are the same as imcomposite. 1476 1477【Note】Image blending model does not support the YUV format image blending, the YUV format is not support in dst image of imblend , the YUV format is not support in srcB image of imcomposite. 1478 1479| Parameter | Description | 1480| ------------ | ------------------------------------------------------------ | 1481| job_handle | **[required]** job handle | 1482| fg_image | **[required]** foreground image | 1483| bg_image | **[required]** background image, when A+B->B it is also the output destination image. | 1484| output_image | **[required]** output destination image. | 1485| mode | **[optional]** blending mode:<br/>IM_ALPHA_BLEND_SRC —— SRC mode<br/>IM_ALPHA_BLEND_DST —— DST mode <br/>IM_ALPHA_BLEND_SRC_OVER —— SRC OVER mode<br/>IM_ALPHA_BLEND_DST_OVER —— DST OVER mode<br />IM_ALPHA_BLEND_PRE_MUL —— Enable premultipling. When premultipling is required, this identifier must be processed with other mode identifiers, then assign to mode | 1486 1487**Return** IM_STATUS_SUCCESS on success or else negative error code. 1488 1489 1490 1491### Color Key 1492 1493#### imcolorkey 1494 1495```C++ 1496IM_STATUS imcolorkey(const rga_buffer_t src, 1497 rga_buffer_t dst, 1498 im_colorkey_range range, 1499 int mode = IM_ALPHA_COLORKEY_NORMAL, 1500 int sync = 1, 1501 int *release_fence_fd = NULL); 1502``` 1503 1504> Color Key is to preprocesses the source image, zeros the alpha component of pixels that meet the Color Key filtering conditions, wherein the Color Key filtering conditions are non-transparent color values, and performs the alpha blending mode between the preprocessed source image and the destination image. 1505> 1506> This mode only supports the Color Key operation on the source image (src) region of the image for the set Color range, and overlays on the destination image (dst) region. 1507 1508> IM_ALPHA_COLORKEY_NORMAL is the normal mode, that is, the colors in the set color range are used as the filtering condition. The Alpha components of pixels in this color range are set zero; IM_ALPHA_COLORKEY_INVERTED is inverted. When no mode is configured, it is set to IM_ALPHA_COLORKEY_NORMAL mode by default. 1509 1510| **Parameters** | **Range** | **Description** | 1511| -------------- | ---------------- | ----------------------------------------- | 1512| max | 0x0 ~ 0xFFFFFFFF | The max color range to cancel/scratch, arranged as ABGR | 1513| min | 0x0 ~ 0xFFFFFFFF | The min color range to cancel/scratch, arranged as ABGR | 1514 1515| parameter | Description | 1516| ---------------- | ------------------------------------------------------------ | 1517| src | **[required]** input image | 1518| dst | **[required]** output image | 1519| range | **[required]** Target color range<br/>typedef struct im_colorkey_range {<br/> int max;<br/> int min;<br/>} im_colorkey_value; | 1520| Mode | **[required]** Color Key mode:<br/>IM_ALPHA_COLORKEY_NORMAL<br/>IM_ALPHA_COLORKEY_INVERTED | 1521| sync | **[optional]** wait until operation complete | 1522| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1523 1524**Return** IM_STATUS_SUCCESS on success or else negative error code. 1525 1526 1527 1528#### imcolorkeyTask 1529 1530```C++ 1531IM_API IM_STATUS imcolorkeyTask(im_job_handle_t job_handle, 1532 const rga_buffer_t fg_image, 1533 rga_buffer_t bg_image, 1534 im_colorkey_range range, 1535 int mode = IM_ALPHA_COLORKEY_NORMAL); 1536``` 1537 1538> Add an image Color Key operation to the specified job through job_handle. The configuration parameters are the same as imcolorkey. 1539 1540| **Parameters** | **Range** | **Description** | 1541| -------------- | ---------------- | ------------------------------------------------------- | 1542| max | 0x0 ~ 0xFFFFFFFF | The max color range to cancel/scratch, arranged as ABGR | 1543| min | 0x0 ~ 0xFFFFFFFF | The min color range to cancel/scratch, arranged as ABGR | 1544 1545| parameter | Description | 1546| ---------- | ------------------------------------------------------------ | 1547| job_handle | **[required]** job handle | 1548| src | **[required]** input image | 1549| dst | **[required]** output image | 1550| range | **[required]** Target color range<br/>typedef struct im_colorkey_range {<br/> int max;<br/> int min;<br/>} im_colorkey_value; | 1551| Mode | **[required]** Color Key mode:<br/>IM_ALPHA_COLORKEY_NORMAL<br/>IM_ALPHA_COLORKEY_INVERTED | 1552 1553**Return** IM_STATUS_SUCCESS on success or else negative error code. 1554 1555 1556 1557### OSD 1558 1559#### imosd 1560 1561```c++ 1562IM_API IM_STATUS imosd(const rga_buffer_t osd, 1563 const rga_buffer_t bg_image, 1564 const im_rect osd_rect, 1565 im_osd_t *osd_config, 1566 int sync = 1, 1567 int *release_fence_fd = NULL); 1568``` 1569 1570> OSD (On-Screen-Display), can superimpose text information on video pictures, and perform brightness statistics and automatic color inversion functions for fonts. 1571 1572| parameter | Description | 1573| ---------------- | ------------------------------------------------------------ | 1574| OSD | **[required]** osd block image | 1575| bg_image | **[required]** output image | 1576| osd_rect | **[required]** image region to OSD | 1577| osd_config | **[required]** OSD function config | 1578| sync | **[optional]** wait until operation complete | 1579| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1580 1581**Return** IM_STATUS_SUCCESS on success or else negative error code. 1582 1583 1584 1585#### imosdTask 1586 1587```c++ 1588IM_API IM_STATUS imosdTask(im_job_handle_t job_handle, 1589 const rga_buffer_t osd, 1590 const rga_buffer_t bg_image, 1591 const im_rect osd_rect, 1592 im_osd_t *osd_config); 1593``` 1594 1595> Add an OSD operation to the specified job through job_handle. The configuration parameters are the same as imosd. 1596 1597| parameter | Description | 1598| ---------- | ---------------------------------- | 1599| job_handle | **[required]** job handle | 1600| OSD | **[required]** osd block image | 1601| dst | **[required]** output image | 1602| osd_rect | **[required]** image region to OSD | 1603| osd_config | **[required]** OSD function config | 1604 1605**Return** IM_STATUS_SUCCESS on success or else negative error code. 1606 1607 1608 1609### Pre-processing of NN Operation Points (Quantization) 1610 1611#### imquantize 1612 1613```c++ 1614IM_STATUS imquantize(const rga_buffer_t src, 1615 rga_buffer_t dst, 1616 rga_nn_t nn_info, 1617 int sync = 1, 1618 int *release_fence_fd = NULL); 1619``` 1620 1621> Currently supported only on RV1126 / RV1109. NN operation point pre-processing, three channels of RGB of image can be separately configured with offset and scale. 1622 1623Formula: 1624 1625``` 1626dst = 【(src + offset) * scale 】 1627``` 1628 1629Parameters range: 1630 1631| **Parameters** | **Range** | **Description** | 1632| -------------- | ---------- | ------------------------------------------------------------ | 1633| **scale** | 0 ~ 3.99 | 10bit,From left to right, the highest 2 bits indicate the integer part and the lowest 8 bits indicate the decimal part | 1634| **offset** | -255 ~ 255 | 9bit,From left to right, the high indicates the sign bit, and the low indicates the offset from 0 to 255 | 1635 1636| Parameter | Description | 1637| ---------------- | ------------------------------------------------------------ | 1638| src | **[required]** input image | 1639| dst | **[required]** output image | 1640| nn_info | **[required]** rga_nn_t struct configures the offset and scale of the three RGB channels respectively<br />typedef struct rga_nn { <br/> int nn_flag;<br/> int scale_r;<br/> int scale_g;<br/> int scale_b;<br/> int offset_r;<br/> int offset_g;<br/> int offset_b;<br/>} rga_nn_t; | 1641| sync | **[optional]** wait until operation complete | 1642| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1643 1644**Return** IM_STATUS_SUCCESS on success or else negative error code. 1645 1646 1647 1648#### imquantizeTask 1649 1650```c++ 1651IM_API IM_STATUS imquantizeTask(im_job_handle_t job_handle, 1652 const rga_buffer_t src, 1653 rga_buffer_t dst, 1654 im_nn_t nn_info); 1655``` 1656 1657> Add an image quantization conversion operation to the specified job through job_handle. The configuration parameters are the same as imquantize. 1658 1659| parameter | Description | 1660| ---------- | ------------------------------------------------------------ | 1661| job_handle | **[required]** job handle | 1662| src | **[required]** input image | 1663| dst | **[required]** output image | 1664| nn_info | **[required]** rga_nn_t结构体对RGB三个通道offset及scale进行单独配置<br />typedef struct rga_nn { <br/> int nn_flag;<br/> int scale_r;<br/> int scale_g;<br/> int scale_b;<br/> int offset_r;<br/> int offset_g;<br/> int offset_b;<br/>} rga_nn_t; | 1665 1666**Return** IM_STATUS_SUCCESS on success or else negative error code. 1667 1668 1669 1670### Image ROP 1671 1672#### imrop 1673 1674```C++ 1675IM_STATUS imrop(const rga_buffer_t src, 1676 rga_buffer_t dst, 1677 int rop_code, 1678 int sync = 1, 1679 int *release_fence_fd = NULL); 1680``` 1681 1682> Perform ROP, and, or, not operations on two images 1683 1684| Parameter | Description | 1685| ---------------- | ------------------------------------------------------------ | 1686| src | **[required]** input image | 1687| dst | **[required]** output image | 1688| rop_code | **[required]** rop code mode <br /><br/> IM_ROP_AND : dst = dst **AND** src;<br/> IM_ROP_OR : dst = dst **OR** src <br/> IM_ROP_NOT_DST : dst = **NOT** dst<br/> IM_ROP_NOT_SRC : dst = **NOT** src<br/> IM_ROP_XOR : dst = dst **XOR** src<br/> IM_ROP_NOT_XOR : dst = **NOT** (dst **XOR** src)<br/> | 1689| sync | **[optional]** wait until operation complete | 1690| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1691 1692**Return** IM_STATUS_SUCCESS on success or else negative error code 1693 1694 1695 1696#### imropTask 1697 1698```C++ 1699IM_API IM_STATUS imropTask(im_job_handle_t job_handle, 1700 const rga_buffer_t src, 1701 rga_buffer_t dst, 1702 int rop_code); 1703``` 1704 1705> Add an image ROP conversion operation to the specified job through job_handle. The configuration parameters are the same as imrop. 1706 1707| parameter | Description | 1708| ---------- | ------------------------------------------------------------ | 1709| job_handle | **[required]** job handle | 1710| src | **[required]** input image | 1711| dst | **[required]** output image | 1712| rop_code | **[required]** rop code mode <br /><br/> IM_ROP_AND : dst = dst **AND** src;<br/> IM_ROP_OR : dst = dst **OR** src <br/> IM_ROP_NOT_DST : dst = **NOT** dst<br/> IM_ROP_NOT_SRC : dst = **NOT** src<br/> IM_ROP_XOR : dst = dst **XOR** src<br/> IM_ROP_NOT_XOR : dst = **NOT** (dst **XOR** src) | 1713 1714**Return** IM_STATUS_SUCCESS on success or else negative error code. 1715 1716 1717 1718### Image Color Filling 1719 1720#### imfill 1721 1722```C++ 1723IM_STATUS imfill(rga_buffer_t buf, 1724 im_rect rect, 1725 int color = 0x00000000, 1726 int sync = 1); 1727``` 1728 1729> Color fills the specified area rect of the image. 1730> 1731> Color parameters from high to low are respectively R,G,B,A. For example, red: color = 0xff000000. 1732 1733【 Note 】 The width and height of the rect must be greater than or equal to 2 1734 1735| Parameter | Description | 1736| ---------------- | ------------------------------------------------------------ | 1737| src | **[required]** input image | 1738| dst | **[required]** output image | 1739| rect | **[required]** image region to fill specified color<br/>width and height of rect must be greater than or equal to 2 | 1740| color | **[required]** fill with color, default=0x00000000 | 1741| sync | **[optional]** wait until operation complete | 1742| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1743 1744**Return** IM_STATUS_SUCCESS on success or else negative error code. 1745 1746 1747 1748#### imfillArray 1749 1750```C++ 1751IM_API IM_STATUS imfillArray(rga_buffer_t dst, 1752 im_rect *rect_array, 1753 int array_size, 1754 uint32_t color, 1755 int sync = 1, 1756 int *release_fence_fd = NULL); 1757``` 1758 1759> Color fills multiple areas of the image one by one. 1760> 1761> Color parameters from high to low are respectively R,G,B,A. For example, red: color = 0xff000000. 1762 1763【 Note 】 The width and height of the rect must be greater than or equal to 2 1764 1765| Parameter | Description | 1766| ---------------- | ------------------------------------------------------------ | 1767| dst | **[required]** target image | 1768| rect_array | **[required]** image region array_ptr to fill specified color<br/>width and height of rect must be greater than or equal to 2 | 1769| array_size | **[required]** size of region arrays. | 1770| color | **[required]** fill with color | 1771| sync | **[optional]** wait until operation complete | 1772| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1773 1774**Return** IM_STATUS_SUCCESS on success or else negative error code. 1775 1776 1777 1778#### imfillTask 1779 1780```C++ 1781IM_API IM_STATUS imfillTask(im_job_handle_t job_handle, 1782 rga_buffer_t dst, 1783 im_rect rect, 1784 uint32_t color); 1785``` 1786 1787> Add an image color fill operation to the specified job through job_handle. The configuration parameters are the same as imfill. 1788 1789【 Note 】 The width and height of the rect must be greater than or equal to 2 1790 1791| Parameter | Description | 1792| ---------- | ------------------------------------------------------------ | 1793| job_handle | **[required]** job handle | 1794| dst | **[required]** target image | 1795| rect | **[required]** image region to fill specified color<br/>width and height of rect must be greater than or equal to 2 | 1796| color | **[required]** fill with color | 1797 1798**Return** IM_STATUS_SUCCESS on success or else negative error code. 1799 1800 1801 1802#### imfillTaskArray 1803 1804```C++ 1805IM_API IM_STATUS imfillTaskArray(im_job_handle_t job_handle, 1806 rga_buffer_t dst, 1807 im_rect *rect_array, 1808 int array_size, 1809 uint32_t color); 1810``` 1811 1812> Add an image color fill multiple areas operation to the specified job through job_handle. The configuration parameters are the same as imfillArray. 1813 1814【 Note 】 The width and height of the rect must be greater than or equal to 2 1815 1816| Parameter | Description | 1817| ---------- | ------------------------------------------------------------ | 1818| job_handle | **[required]** job handle | 1819| dst | **[required]** target image | 1820| rect_array | **[required]** image region array_ptr to fill specified color<br/>width and height of rect must be greater than or equal to 2 | 1821| array_size | **[required]** size of region arrays. | 1822| color | **[required]** fill with color | 1823 1824**Return** IM_STATUS_SUCCESS on success or else negative error code. 1825 1826 1827 1828#### imrectangle 1829 1830```C++ 1831IM_API IM_STATUS imrectangle(rga_buffer_t dst, 1832 im_rect rect, 1833 uint32_t color, 1834 int thickness, 1835 int sync = 1, 1836 int *release_fence_fd = NULL); 1837``` 1838 1839> Draw a border with a thickness of "thickness" to the specified area rect of the image (described as the outer diameter of the border) according to the specified color by "color", and fill a solid rectangle when the thickness is negative. 1840> 1841> Color parameters from high to low are respectively R,G,B,A. For example, red: color = 0xff000000. 1842 1843【 Note 】 The width and height of the rect must be greater than or equal to 2 1844 1845| Parameter | Description | 1846| ---------------- | ------------------------------------------------------------ | 1847| dst | **[required]** target image | 1848| rect | **[required]** image region to fill specified color<br/>width and height of rect must be greater than or equal to 2 | 1849| color | **[required]** fill with color | 1850| thickness | **[required]** Thickness of lines that make up the rectangle.<br/>Negative values, like -1, mean that the function has to draw a filled rectangle. | 1851| sync | **[optional]** wait until operation complete | 1852| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1853 1854**Return** IM_STATUS_SUCCESS on success or else negative error code. 1855 1856 1857 1858#### imrectangleArray 1859 1860```C++ 1861IM_API IM_STATUS imrectangleArray(rga_buffer_t dst, 1862 im_rect *rect_array, 1863 int array_size, 1864 uint32_t color, 1865 int thickness, 1866 int sync = 1, 1867 int *release_fence_fd = NULL); 1868``` 1869 1870> Draw multiple border with a thickness of "thickness" to the specified area rect of the image (described as the outer diameter of the border) according to the specified color by "color", and fill a solid rectangle when the thickness is negative. 1871> 1872> Color parameters from high to low are respectively R,G,B,A. For example, red: color = 0xff000000. 1873 1874【 Note 】 The width and height of the rect must be greater than or equal to 2 1875 1876| Parameter | Description | 1877| ---------------- | ------------------------------------------------------------ | 1878| dst | **[required]** target image | 1879| rect_array | **[required]** image region array_ptr to fill specified color<br/>width and height of rect must be greater than or equal to 2 | 1880| array_size | **[required]** size of region arrays. | 1881| color | **[required]** fill with color | 1882| thickness | **[required]** Thickness of lines that make up the rectangle.<br/>Negative values, like -1, mean that the function has to draw a filled rectangle. | 1883| sync | **[optional]** wait until operation complete | 1884| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 1885 1886**Return** IM_STATUS_SUCCESS on success or else negative error code. 1887 1888 1889 1890#### imrectangleTask 1891 1892```C++ 1893IM_API IM_STATUS imrectangleTask(im_job_handle_t job_handle, 1894 rga_buffer_t dst, 1895 im_rect rect, 1896 uint32_t color, 1897 int thickness); 1898``` 1899 1900> Add an Draw border operation to the specified job through job_handle. The configuration parameters are the same as imrectangle. 1901 1902【 Note 】 The width and height of the rect must be greater than or equal to 2 1903 1904| Parameter | Description | 1905| ---------- | ------------------------------------------------------------ | 1906| job_handle | **[required]** job handle | 1907| dst | **[required]** target image | 1908| rect | **[required]** image region to fill specified color<br/>width and height of rect must be greater than or equal to 2 | 1909| color | **[required]** fill with color | 1910| thickness | **[required]** Thickness of lines that make up the rectangle.<br/>Negative values, like -1, mean that the function has to draw a filled rectangle. | 1911 1912**Return** IM_STATUS_SUCCESS on success or else negative error code. 1913 1914 1915 1916#### imrectangleTaskArray 1917 1918```C++ 1919IM_API IM_STATUS imrectangleTaskArray(im_job_handle_t job_handle, 1920 rga_buffer_t dst, 1921 im_rect *rect_array, 1922 int array_size, 1923 uint32_t color, 1924 int thickness); 1925``` 1926 1927> Add an Draw multiple border operation to the specified job through job_handle. The configuration parameters are the same as imrectangleArray. 1928 1929【 Note 】 The width and height of the rect must be greater than or equal to 2 1930 1931| Parameter | Description | 1932| ---------- | ------------------------------------------------------------ | 1933| job_handle | **[required]** job handle | 1934| dst | **[required]** target image | 1935| rect_array | **[required]** image region array_ptr to fill specified color<br/>width and height of rect must be greater than or equal to 2 | 1936| array_size | **[required]** size of region arrays. | 1937| color | **[required]** fill with color | 1938| thickness | **[required]** Thickness of lines that make up the rectangle.<br/>Negative values, like -1, mean that the function has to draw a filled rectangle. | 1939 1940**Return** IM_STATUS_SUCCESS on success or else negative error code. 1941 1942 1943 1944#### immakeBorder 1945 1946```C++ 1947IM_API IM_STATUS immakeBorder(rga_buffer_t src, 1948 rga_buffer_t dst, 1949 int top, 1950 int bottom, 1951 int left, 1952 int right, 1953 int border_type, 1954 int value = 0, 1955 int sync = 1, 1956 int acquir_fence_fd = -1, 1957 int *release_fence_fd = NULL); 1958``` 1959 1960> According to the configured top/bottom/left/right pixels, draw a border to the input image and output it to the output target image buffer. 1961 1962【 Note 】 The width and height of the rect must be greater than or equal to 2 1963 1964| Parameter | Description | 1965| ---------------- | ------------------------------------------------------------ | 1966| src | **[required]** input source image | 1967| dst | **[required]** output target image | 1968| top | **[required]** number of top pixels | 1969| bottom | **[required]** number of bottom pixels | 1970| left | **[required]** number of left pixels | 1971| right | **[required] **number of right pixels | 1972| border_type | **[required]** Border type<br/>IM_BORDER_CONSTANT // iiiiii abcdefgh iiiiiii with some specified value 'i' <br/>IM_BORDER_REFLECT //fedcba abcdefgh hgfedcb<br/>IM_BORDER_WRAP //cdefgh abcdefgh abcdefg | 1973| value | **[optional]** the pixel value at which the border is filled | 1974| sync | **[optional]** wait until operation complete | 1975| acquire_fence_fd | **[required]** used in async mode, run the job after waiting foracquire_fence signal | 1976| release_fence_fd | **[required]** used in async mode, as a parameter of imsync() | 1977 1978**Return** IM_STATUS_SUCCESS on success or else negative error code. 1979 1980 1981 1982### Image Mosaic 1983 1984#### immosaic 1985 1986```c++ 1987IM_API IM_STATUS immosaic(const rga_buffer_t image, 1988 im_rect rect, 1989 int mosaic_mode, 1990 int sync = 1, 1991 int *release_fence_fd = NULL); 1992``` 1993 1994> Mosaic masking the specified area of the image. 1995 1996| Parameter | Description | 1997| ---------------- | ------------------------------------------------------------ | 1998| image | **[required]** souce image | 1999| rect | **[required]** image region to mosaic | 2000| mosaic_mode | **[required]** set mosaic mode<br /> IM_MOSAIC_8<br/> IM_MOSAIC_16<br/> IM_MOSAIC_32<br/> IM_MOSAIC_64<br/> IM_MOSAIC_128 | 2001| sync | **[optional]** wait until operation complete | 2002| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 2003 2004**Return** IM_STATUS_SUCCESS on success or else negative error code. 2005 2006 2007 2008#### immosaicArray 2009 2010```c++ 2011IM_API IM_STATUS immosaicArray(const rga_buffer_t image, 2012 im_rect *rect_array, 2013 int array_size, 2014 int mosaic_mode, 2015 int sync = 1, 2016 int *release_fence_fd = NULL); 2017``` 2018 2019> Mosaic masking the specified multiple area of the image. 2020 2021| Parameter | Description | 2022| ---------------- | ------------------------------------------------------------ | 2023| image | **[required]** target image | 2024| rect_array | **[required]** image region array_ptr to mosaic | 2025| array_size | **[required]** size of region arrays. | 2026| mosaic_mode | **[required]** set mosaic mode<br /> IM_MOSAIC_8<br/> IM_MOSAIC_16<br/> IM_MOSAIC_32<br/> IM_MOSAIC_64<br/> IM_MOSAIC_128 | 2027| sync | **[optional]** wait until operation complete | 2028| release_fence_fd | **[optional]**Used in async mode, as a parameter of imsync() | 2029 2030**Return** IM_STATUS_SUCCESS on success or else negative error code. 2031 2032 2033 2034#### immosaicTask 2035 2036```c++ 2037IM_API IM_STATUS immosaicTask(im_job_handle_t job_handle, 2038 const rga_buffer_t image, 2039 im_rect rect, 2040 int mosaic_mode); 2041``` 2042 2043> Add an image mosaic masking operation to the specified job through job_handle. The configuration parameters are the same as immosaic. 2044 2045| Parameter | Description | 2046| ----------- | ------------------------------------------------------------ | 2047| job_handle | **[required]** job handle | 2048| image | **[required]** target image | 2049| rect | **[required]** image region to mosaic | 2050| mosaic_mode | **[required]** set mosaic mode<br /> IM_MOSAIC_8<br/> IM_MOSAIC_16<br/> IM_MOSAIC_32<br/> IM_MOSAIC_64<br/> IM_MOSAIC_128 | 2051 2052**Return** IM_STATUS_SUCCESS on success or else negative error code. 2053 2054 2055 2056#### immosaicTaskArray 2057 2058```c++ 2059IM_API IM_STATUS immosaicTaskArray(im_job_handle_t job_handle, 2060 const rga_buffer_t image, 2061 im_rect *rect_array, 2062 int array_size, 2063 int mosaic_mode); 2064``` 2065 2066> Add multiple image mosaic masking operation to the specified job through job_handle. The configuration parameters are the same as immosaicArray. 2067 2068| Parameter | Description | 2069| ----------- | ------------------------------------------------------------ | 2070| job_handle | **[required]** job handle | 2071| image | **[required]** target image | 2072| rect_array | **[required]** image region array_ptr to mosaic | 2073| array_size | **[required]** size of region arrays. | 2074| mosaic_mode | **[required]** set mosaic mode<br /> IM_MOSAIC_8<br/> IM_MOSAIC_16<br/> IM_MOSAIC_32<br/> IM_MOSAIC_64<br/> IM_MOSAIC_128 | 2075 2076**Return** IM_STATUS_SUCCESS on success or else negative error code. 2077 2078 2079 2080### Image Process 2081 2082#### improcess 2083 2084```C++ 2085IM_STATUS improcess(rga_buffer_t src, 2086 rga_buffer_t dst, 2087 rga_buffer_t pat, 2088 im_rect srect, 2089 im_rect drect, 2090 im_rect prect, 2091 int acquire_fence_fd, 2092 int *release_fence_fd, 2093 im_opt_t *opt, 2094 int usage); 2095``` 2096 2097> RGA image compound operation. Other APIs are developed based on this API, improcess can achieve more complex compound operations. 2098> 2099> Image processes are configured by usage. 2100 2101usage definitions: 2102 2103```c++ 2104typedef enum { 2105 /* Rotation */ 2106 IM_HAL_TRANSFORM_ROT_90 = 1 << 0, 2107 IM_HAL_TRANSFORM_ROT_180 = 1 << 1, 2108 IM_HAL_TRANSFORM_ROT_270 = 1 << 2, 2109 IM_HAL_TRANSFORM_FLIP_H = 1 << 3, 2110 IM_HAL_TRANSFORM_FLIP_V = 1 << 4, 2111 IM_HAL_TRANSFORM_FLIP_H_V = 1 << 5, 2112 IM_HAL_TRANSFORM_MASK = 0x3f, 2113 2114 /* 2115 * Blend 2116 * Additional blend usage, can be used with both source and target configs. 2117 * If none of the below is set, the default "SRC over DST" is applied. 2118 */ 2119 IM_ALPHA_BLEND_SRC_OVER = 1 << 6, /* Default, Porter-Duff "SRC over DST" */ 2120 IM_ALPHA_BLEND_SRC = 1 << 7, /* Porter-Duff "SRC" */ 2121 IM_ALPHA_BLEND_DST = 1 << 8, /* Porter-Duff "DST" */ 2122 IM_ALPHA_BLEND_SRC_IN = 1 << 9, /* Porter-Duff "SRC in DST" */ 2123 IM_ALPHA_BLEND_DST_IN = 1 << 10, /* Porter-Duff "DST in SRC" */ 2124 IM_ALPHA_BLEND_SRC_OUT = 1 << 11, /* Porter-Duff "SRC out DST" */ 2125 IM_ALPHA_BLEND_DST_OUT = 1 << 12, /* Porter-Duff "DST out SRC" */ 2126 IM_ALPHA_BLEND_DST_OVER = 1 << 13, /* Porter-Duff "DST over SRC" */ 2127 IM_ALPHA_BLEND_SRC_ATOP = 1 << 14, /* Porter-Duff "SRC ATOP" */ 2128 IM_ALPHA_BLEND_DST_ATOP = 1 << 15, /* Porter-Duff "DST ATOP" */ 2129 IM_ALPHA_BLEND_XOR = 1 << 16, /* Xor */ 2130 IM_ALPHA_BLEND_MASK = 0x1ffc0, 2131 2132 IM_ALPHA_COLORKEY_NORMAL = 1 << 17, 2133 IM_ALPHA_COLORKEY_INVERTED = 1 << 18, 2134 IM_ALPHA_COLORKEY_MASK = 0x60000, 2135 2136 IM_SYNC = 1 << 19, 2137 IM_ASYNC = 1 << 26, 2138 IM_CROP = 1 << 20, /* Unused */ 2139 IM_COLOR_FILL = 1 << 21, 2140 IM_COLOR_PALETTE = 1 << 22, 2141 IM_NN_QUANTIZE = 1 << 23, 2142 IM_ROP = 1 << 24, 2143 IM_ALPHA_BLEND_PRE_MUL = 1 << 25, 2144} IM_USAGE; 2145``` 2146 2147| Parameter | Description | 2148| ---------------- | ------------------------------------------------------------ | 2149| src | **[required]** input imageA | 2150| dst | **[required]** output image | 2151| pat | **[required]** input imageB | 2152| srect | **[required]** src crop region | 2153| drect | **[required]** dst crop region | 2154| prect | **[required]** pat crop region | 2155| acquire_fence_fd | **[required]** Used in async mode, run the job after waiting foracquire_fence signal | 2156| release_fence_fd | **[required]** Used in async mode, as a parameter of imsync() | 2157| opt | **[required]** operation options<br/>typedef struct im_opt {<br/> int color;<br/> im_colorkey_range colorkey_range; <br/> im_nn_t nn;<br/> int rop_code;<br/> <br/> int priority;<br/> int core;<br/>} im_opt_t; | 2158| usage | **[required]** image operation usage | 2159 2160**Return** IM_STATUS_SUCCESS on success or else negative error code. 2161 2162 2163 2164#### improcessTask 2165 2166```C++ 2167IM_API IM_STATUS improcessTask(im_job_handle_t job_handle, 2168 rga_buffer_t src, 2169 rga_buffer_t dst, 2170 rga_buffer_t pat, 2171 im_rect srect, 2172 im_rect drect, 2173 im_rect prect, 2174 im_opt_t *opt_ptr, 2175 int usage); 2176``` 2177 2178> Add an image compound operation to the specified job through job_handle. The configuration parameters are the same as improcess. 2179 2180| Parameter | Description | 2181| ---------------- | ------------------------------------------------------------ | 2182| job_handle | **[required]** job handle | 2183| src | **[required]** input imageA | 2184| dst | **[required]** output image | 2185| pat | **[required]** input imageB | 2186| srect | **[required]** src crop region | 2187| drect | **[required]** dst crop region | 2188| prect | **[required]** pat crop region | 2189| acquire_fence_fd | **[required]** Used in async mode, run the job after waiting foracquire_fence signal | 2190| release_fence_fd | **[required]** Used in async mode, as a parameter of imsync() | 2191| opt | **[required]** operation options<br/>typedef struct im_opt {<br/> int color;<br/> im_colorkey_range colorkey_range; <br/> im_nn_t nn;<br/> int rop_code;<br/> <br/> int priority;<br/> int core;<br/>} im_opt_t; | 2192| usage | **[required]** image operation usage | 2193 2194**Return** IM_STATUS_SUCCESS on success or else negative error code. 2195 2196 2197 2198### Parameter Check 2199 2200#### imcheck 2201 2202```c++ 2203IM_API IM_STATUS imcheck(const rga_buffer_t src, const rga_buffer_t dst, 2204 const im_rect src_rect, const im_rect dst_rect, 2205 const int mode_usage); 2206IM_API IM_STATUS imcheck_composite(const rga_buffer_t src, const rga_buffer_t dst, const rga_buffer_t pat, 2207 const im_rect src_rect, const im_rect dst_rect, const im_rect pat_rect, 2208 const int mode_usage); 2209``` 2210 2211> After RGA parameters are configured, users can use this API to verify whether the current parameters are valid and determine whether the hardware supports them based on the current hardware conditions. 2212> 2213> Users are advised to use this API only during development and debugging to avoid performance loss caused by multiple verification. 2214 2215| Parameter | Description | 2216| --------- | ------------------------------------ | 2217| src | **[required]** input imageA | 2218| dst | **[required]** output image | 2219| pat | **[optional]** input imageB | 2220| srect | **[required]** src crop region | 2221| drect | **[required]** dst crop region | 2222| prect | **[optional]** pat crop region | 2223| usage | **[optional]** image operation usage | 2224 2225**Return** IM_STATUS_NOERROR on success or else negative error code. 2226 2227 2228 2229### Synchronous operation 2230 2231#### imsync 2232 2233```C++ 2234IM_STATUS imsync(int fence_fd); 2235``` 2236 2237> RGA asynchronous mode requires this API to be called, passing the returned release_fence_fd as parameter. 2238> 2239> Other API enable asynchronous call mode when sync is set to 0, which is equivalent to glFlush in opengl. Further calls to imsync is equivalent to glFinish. 2240 2241| Parameter | Description | 2242| --------- | ------------------------------- | 2243| fence_fd | **[required]** fence_fd to wait | 2244 2245**Return** IM_STATUS_SUCCESS on success or else negative error code. 2246 2247 2248 2249### Thread Context Configuration 2250 2251#### imconfig 2252 2253```C++ 2254IM_STATUS imconfig(IM_CONFIG_NAME name, uint64_t value); 2255``` 2256 2257> The context for the current thread is configured through different configuration name, which will be the default configuration for the thread. 2258> 2259> The thread context configuration has a lower priority than the parameter configuration of the API. If no related parameters are configured for API, the local call uses the default context configuration. If related parameters are configured for API, the call uses the API parameter configuration. 2260 2261| Parameter | Description | 2262| --------- | ------------------------------------------------------------ | 2263| name | **[required]** context config name:<br/>IM_CONFIG_SCHEDULER_CORE —— Specify the task processing core<br/>IM_CONFIG_PRIORITY —— Specify the task priority<br/>IM_CHECK_CONFIG —— Check enable | 2264| value | **[required]** config value<br/> IM_CONFIG_SCHEDULER_CORE :<br/> IM_SCHEDULER_RGA3_CORE0<br/> IM_SCHEDULER_RGA3_CORE1<br/> IM_SCHEDULER_RGA2_CORE0<br/> IM_SCHEDULER_RGA3_DEFAULT<br/> IM_SCHEDULER_RGA2_DEFAULT<br/>IM_CONFIG_PRIORITY:<br/> 0 ~ 6<br/>IM_CHECK_CONFIG:<br/> TRUE<br/> FALSE | 2265 2266> Note:Permissions of priority and core are very high. Improper operations may cause system crash or deadlock. Therefore, users are advised to configure them only during development and debugging. Users are not advised to perform this configuration in actual product 2267 2268**Return** IM_STATUS_SUCCESS on success or else negative error code 2269 2270 2271 2272--- 2273 2274## Data Structure 2275 2276This section describes the data structures involved in API in detail. 2277 2278### Overview 2279 2280| Data structure | Description | 2281| ------------------- | ------------------------ | 2282| rga_buffer_t | image buffer information | 2283| im_rect | the actual operating area of the image | 2284| im_opt_t | image manipulation options | 2285| im_job_handle_t | RGA job handle | 2286| rga_buffer_handle_t | RGA driver image buffer handle | 2287| im_handle_param_t | buffer parameters of image to be imported | 2288| im_context_t | default context for the current thread | 2289| im_nn_t | operation point preprocessing parameters | 2290| im_colorkey_range | Colorkey range | 2291 2292 2293 2294### Detailed Descriptions 2295 2296#### rga_buffer_t 2297 2298- **descriptions** 2299 2300Buffer information of image with single channel. 2301 2302- **path** 2303 2304im2d_api/im2d_type.h 2305 2306- **definitions** 2307 2308```c++ 2309typedef struct { 2310 void* vir_addr; /* virtual address */ 2311 void* phy_addr; /* physical address */ 2312 int fd; /* shared fd */ 2313 rga_buffer_handle_t handle; /* buffer handle */ 2314 2315 int width; /* width */ 2316 int height; /* height */ 2317 int wstride; /* wstride */ 2318 int hstride; /* hstride */ 2319 int format; /* format */ 2320 2321 int color_space_mode; /* color_space_mode */ 2322 int global_alpha; /* global_alpha */ 2323 int rd_mode; 2324} rga_buffer_t; 2325``` 2326 2327| Parameter | Description | 2328| ---------------- | --------------------------------------- | 2329| vir_addr | Virtual address of image buffer. | 2330| phy_addr | Contiguous physical address of the image buffer. | 2331| fd | File descriptor of image buffer DMA. | 2332| handle | Import handle corresponding to the image buffer of the RGA driver. | 2333| width | The width of the actual operating area of image,in pixels. | 2334| height | The height of the actual operating area of image,in pixels. | 2335| wstride | The stride of the image width, in pixels. | 2336| hstride | The stride of the image height, in pixels. | 2337| format | Image format. | 2338| color_space_mode | Image color space mode. | 2339| global_alpha | Global Alpha configuration. | 2340| rd_mode | The mode in which the current channel reads data. | 2341 2342- **Note** 2343 2344Simply selects either one of vir_addr、phy_addr、fd、handle as the description of image buffer, if multiple values are assigned, only one of them is selected as the image buffer description according to the default priority, which is as follows:handle > phy_addr > fd > vir_addr. 2345 2346 2347 2348#### im_rect 2349 2350- **descriptions** 2351 2352Describes the actual operation area of image with single channel. 2353 2354- **path** 2355 2356im2d_api/im2d_type.h 2357 2358- **definitions** 2359 2360```c++ 2361typedef struct { 2362 int x; /* upper-left x */ 2363 int y; /* upper-left y */ 2364 int width; /* width */ 2365 int height; /* height */ 2366} im_rect; 2367``` 2368 2369| Parameters | Description | 2370| -------- | -------------------------------------------- | 2371| x | The starting abscissa of the actual operation area of the image, in pixels.| 2372| y | The starting ordinate of the actual operating area of an image, in pixels. | 2373| width | The width of the actual operating area of the image, in pixels. | 2374| height | The height of the actual operating area of the image, in pixels. | 2375 2376- **Note** 2377 2378The actual operating area cannot exceed the image size, i.e(x + width)<= wstride, (y + height) <= hstride。 2379 2380 2381 2382#### im_opt_t 2383 2384- **description** 2385 2386Describes operation options of current image. 2387 2388- **path** 2389 2390im2d_api/im2d_type.h 2391 2392- **definitions** 2393 2394```c++ 2395typedef struct im_opt { 2396 int color; /* color, used by color fill */ 2397 im_colorkey_range colorkey_range; /* range value of color key */ 2398 im_nn_t nn; 2399 int rop_code; 2400 2401 int priority; 2402 int core; 2403} im_opt_t; 2404``` 2405 2406| Parameter | Description | 2407| -------------- | -------------------------- | 2408| color | Image color-fill configuration. | 2409| colorkey_range | Colorkey range configuration. | 2410| nn | Operation point preprocessing (quantization) configuration. | 2411| rop_code | ROP operation code configuration. | 2412| priority | Current task priority configuration. | 2413| core | Specify the hardware core of current task. | 2414 2415- **Note** 2416 2417Permissions of priority and core are very high. Improper operations may cause system crash or deadlock. Therefore, users are advised to configure them only during development and debugging.Users are not advised to perform this configuration in actual product. 2418 2419 2420 2421#### im_job_handle_t 2422 2423- **说明** 2424 2425RGA jobhandle, used to identify the currently configured RGA job. 2426 2427- **路径** 2428 2429im2d_api/im2d_type.h 2430 2431- **定义** 2432 2433```c++ 2434typedef uint32_t im_job_handle_t; 2435``` 2436 2437- **注意事项** 2438 2439After the configuration fails, imcancelJob must be used to release the current task handle to avoid memory leaks. 2440 2441 2442 2443#### rga_buffer_handle_t 2444 2445- **description** 2446 2447RGA driver image buffer handle. 2448 2449- **path** 2450 2451im2d_api/im2d_type.h 2452 2453- **definitions** 2454 2455```c++ 2456typedef int rga_buffer_handle_t; 2457``` 2458 2459- **Note** 2460 2461When the buffer is used up, releasebuffer_handle must be used to release the memory to avoid memory leaks. 2462 2463 2464 2465#### im_handle_param_t 2466 2467- **description** 2468 2469Describe parameters of the image buffer to be imported. 2470 2471- **path** 2472 2473im2d_api/im2d_type.h 2474 2475- **definitions** 2476 2477```c++ 2478typedef struct rga_memory_parm im_handle_param_t; 2479 2480struct rga_memory_parm { 2481 uint32_t width_stride; 2482 uint32_t height_stride; 2483 uint32_t format; 2484}; 2485``` 2486 2487| Parameter | Description | 2488| ------------- | -------------------------------------------------- | 2489| width_stride | Describes the horizontal stride of the image buffer to be imported, in pixels. | 2490| height_stride | Describes the vertical stride of the image buffer to be imported, in pixels. | 2491| format | Describes the format of the buffer of the image to be imported. | 2492 2493- **Note** 2494 2495If the actual size of buffer memory is smaller than the configured size, the importbuffer_T API error occurs. 2496 2497 2498 2499#### im_nn_t 2500 2501- **description** 2502 2503Parameter of operation point preprocessing (quantization). 2504 2505- **path** 2506 2507im2d_api/im2d_type.h 2508 2509- **definitions** 2510 2511```c++ 2512typedef struct im_nn { 2513 int scale_r; /* scaling factor on R channal */ 2514 int scale_g; /* scaling factor on G channal */ 2515 int scale_b; /* scaling factor on B channal */ 2516 int offset_r; /* offset on R channal */ 2517 int offset_g; /* offset on G channal */ 2518 int offset_b; /* offset on B channal */ 2519} im_nn_t; 2520``` 2521 2522| Parameter | Description | 2523| -------- | ------------------- | 2524| scale_r | Scaling factor on red channel. | 2525| scale_g | Scaling factor on green channel. | 2526| scale_b | Scaling factor on blue channel. | 2527| offset_r | Offset on red channel. | 2528| offset_g | Offset on green channel. | 2529| offset_b | Offset on blue channel. | 2530 2531- **Note** 2532 2533null 2534 2535 2536 2537#### im_colorkey_range 2538 2539- **description** 2540 2541Colorkey range. 2542 2543- **path** 2544 2545im2d_api/im2d_type.h 2546 2547- **definitions** 2548 2549```c++ 2550typedef struct { 2551 int max; /* The Maximum value of the color key */ 2552 int min; /* The minimum value of the color key */ 2553} im_colorkey_range; 2554``` 2555 2556| Parameter | Description | 2557| -------- | ------------------ | 2558| max | The Maximum value of the color key. | 2559| min | The minimum value of the color key. | 2560 2561- **Note** 2562 2563null 2564 2565 2566 2567--- 2568 2569## Test Cases and Debugging Methods 2570 2571> In order to make developers get started with the above new API more quickly, here by running demo and parsing the source code to help developers to understand and use the API. 2572 2573 2574 2575### Test File Description 2576 2577> Input and output binary file for testing should be prepared in advance. The default source image file in RGBA8888 format is stored in directory /sample/sample_file. 2578> 2579> In Android system, the source image should be stored in /data/ directory of device,in Linux system, the source image should be stored in/usr/data directory of device. The file naming rules are as follows: 2580 2581``` 2582in%dw%d-h%d-%s.bin 2583out%dw%d-h%d-%s.bin 2584 2585Example: 25861280×720 RGBA8888 input image: in0w1280-h720-rgba8888.bin 25871280×720 RGBA8888 output image: out0w1280-h720-rgba8888.bin 2588``` 2589 2590Parameter descriptions: 2591 2592> The input is in ,the output is out. 2593> --->The first%d is the index of files, usually 0, used to distinguish files of the same format, width and height. 2594> --->The second%d is width, usually indicates virtual width. 2595> --->The third%d is height, usually indicates virtual height. 2596> --->The fourth%s is the name of format. 2597> 2598> Some common image formats for preset tests are as follows. You can view names of other formats in rgaUtils.cpp: 2599 2600| format(Android) | format(Linux) | name | 2601| :-------------------------------- | -------------------------- | ----------- | 2602| HAL_PIXEL_FORMAT_RGB_565 | RK_FORMAT_RGB_565 | "rgb565" | 2603| HAL_PIXEL_FORMAT_RGB_888 | RK_FORMAT_RGB_888 | "rgb888" | 2604| HAL_PIXEL_FORMAT_RGBA_8888 | RK_FORMAT_RGBA_8888 | "rgba8888" | 2605| HAL_PIXEL_FORMAT_RGBX_8888 | RK_FORMAT_RGBX_8888 | "rgbx8888" | 2606| HAL_PIXEL_FORMAT_BGRA_8888 | RK_FORMAT_BGRA_8888 | "bgra8888" | 2607| HAL_PIXEL_FORMAT_YCrCb_420_SP | RK_FORMAT_YCrCb_420_SP | "crcb420sp" | 2608| HAL_PIXEL_FORMAT_YCrCb_NV12 | RK_FORMAT_YCbCr_420_SP | "nv12" | 2609| HAL_PIXEL_FORMAT_YCrCb_NV12_VIDEO | / | "nv12" | 2610| HAL_PIXEL_FORMAT_YCrCb_NV12_10 | RK_FORMAT_YCbCr_420_SP_10B | "nv12_10" | 2611 2612>The default resolution of input image of demo is 1280x720, format is RGBA8888, in0w1280-h720-rgba8888.bin source image should be prepared in advance in the /data or /usr/data directory, in1w1280-h720-rgba8888.bin source image should be additionally prepared in advance in the /data or /usr/data directory in image blending mode. 2613 2614 2615 2616### Debugging Method Description 2617 2618> After running demo, print log as follows (in image copying, for example): 2619> 2620> Log is printed in Android system as follows: 2621 2622```C++ 2623# rgaImDemo --copy 2624 2625librga:RGA_GET_VERSION:3.02,3.020000 //RGA version 2626ctx=0x7ba35c1520,ctx->rgaFd=3 //RGA context 2627Start selecting mode 2628im2d copy .. //RGA running mode 2629GraphicBuffer check ok 2630GraphicBuffer check ok 2631lock buffer ok 2632open file ok //src file status, if there is no corresponding file in /data/ directory, an error will be reported here 2633unlock buffer ok 2634lock buffer ok 2635unlock buffer ok 2636copying .... successfully //indicates successful running 2637open /data/out0w1280-h720-rgba8888.bin and write ok //output filename and directory 2638``` 2639 2640> Log is printed in Linux system as follows: 2641 2642```C++ 2643# rgaImDemo --copy 2644 2645librga:RGA_GET_VERSION:3.02,3.020000 //RGA version 2646ctx=0x2b070,ctx->rgaFd=3 //RGA context 2647Rga built version:version:1.00 2648Start selecting mode 2649im2d copy .. //RGA running mode 2650open file //src file status, if there is no corresponding file in /usr/data/ directory, an error will be reported here 2651copying .... Run successfully //indicates successful running 2652open /usr/data/out0w1280-h720-rgba8888.bin and write ok //output filename and directory 2653``` 2654 2655> To view more detailed logs of RGA running, the Android system can enable RGA configuration log print by setting vendor.rga.log (Android 8 and below is sys.rga.log): 2656 2657``` 2658setprop vendor.rga.log 1 enable RGA log print 2659logcat -s librga enable and filter log print 2660setprop vendor.rga.log 0 cancel RGA log print 2661``` 2662 2663> In Linux system, you should open core/NormalRgaContext.h, set __DEBUG to 1 and recompile. 2664 2665``` 2666#ifdef LINUX 2667 2668-#define __DEBUG 0 2669+#define __DEBUG 1 2670``` 2671 2672> Generally, the printed log is as follows, which can be uploaded to RedMine for analysis by relevant engineers of RK: 2673> 2674> Log is printed in Android system as follows: 2675 2676``` 2677 D librga : <<<<-------- print rgaLog -------->>>> 2678 D librga : src->hnd = 0x0 , dst->hnd = 0x0 2679 D librga : srcFd = 11 , phyAddr = 0x0 , virAddr = 0x0 2680 D librga : dstFd = 15 , phyAddr = 0x0 , virAddr = 0x0 2681 D librga : srcBuf = 0x0 , dstBuf = 0x0 2682 D librga : blend = 0 , perpixelAlpha = 1 2683 D librga : scaleMode = 0 , stretch = 0; 2684 D librga : rgaVersion = 3.020000 , ditherEn =0 2685 D librga : srcMmuFlag = 1 , dstMmuFlag = 1 , rotateMode = 0 2686 D librga : <<<<-------- rgaReg -------->>>> 2687 D librga : render_mode=0 rotate_mode=0 2688 D librga : src:[b,0,e1000],x-y[0,0],w-h[1280,720],vw-vh[1280,720],f=0 2689 D librga : dst:[f,0,e1000],x-y[0,0],w-h[1280,720],vw-vh[1280,720],f=0 2690 D librga : pat:[0,0,0],x-y[0,0],w-h[0,0],vw-vh[0,0],f=0 2691 D librga : ROP:[0,0,0],LUT[0] 2692 D librga : color:[0,0,0,0,0] 2693 D librga : MMU:[1,0,80000521] 2694 D librga : mode[0,0,0,0] 2695``` 2696 2697> Log is printed in Linux system as follows: 2698 2699```C++ 2700render_mode=0 rotate_mode=0 2701src:[0,a681a008,a68fb008],x-y[0,0],w-h[1280,720],vw-vh[1280,720],f=0 2702dst:[0,a6495008,a6576008],x-y[0,0],w-h[1280,720],vw-vh[1280,720],f=0 2703pat:[0,0,0],x-y[0,0],w-h[0,0],vw-vh[0,0],f=0 2704ROP:[0,0,0],LUT[0] 2705color:[0,0,0,0,0] 2706MMU:[1,0,80000521] 2707mode[0,0,0,0,0] 2708gr_color_x [0, 0, 0] 2709gr_color_x [0, 0, 0] 2710``` 2711 2712 2713 2714### Test Case Descriptions 2715 2716- The test path is sample/im2d_API_demo. Developers can modify the demo configuration as required. It is recommended to use the default configuration when running demo for the first time. 2717- The compilation of test cases varies on different platforms. On the Android platform, the 'mm' command can be used to compile the test cases. On the Linux platform, when librga.so is compiled using cmake, the corresponding test cases will be generated in the same directory 2718 2719- Import the executable file generated by compiling the corresponding test case into the device through adb, add the execution permission, execute demo, and check the printed log. 2720- Check the output file to see if it matches your expectations. 2721 2722 2723 2724#### Apply for Image Buffer 2725 2726> The demo provides two types of buffer for RGA synthesis: Graphicbuffer and AHardwareBuffer. The two buffers are distinguished by the macro USE_AHARDWAREBUFFER. 2727 2728```c++ 2729Directory:librga/samples/im2d_api_demo/Android.mk 2730(line +15) 2731 2732ifeq (1,$(strip $(shell expr $(PLATFORM_SDK_VERSION) \> 25))) 2733/*if USE_AHARDWAREBUFFER is set to 1 then use AHardwareBuffer, if USE_AHARDWAREBUFFER is set to 0 then use Graphicbuffer*/ 2734LOCAL_CFLAGS += -DUSE_AHARDWAREBUFFER=1 2735endif 2736``` 2737 2738 2739 2740##### Graphicbuffer 2741 2742> Graphicbuffer is initialized, filled/emptied, and filling rga_buffer_t structure through three functions. 2743 2744```c++ 2745 /*Passing in width, height, and image formats of src/dst and initialize Graphicbuffer*/ 2746 src_buf = GraphicBuffer_Init(SRC_WIDTH, SRC_HEIGHT, SRC_FORMAT); 2747 dst_buf = GraphicBuffer_Init(DST_WIDTH, DST_HEIGHT, DST_FORMAT); 2748 2749 /*Fill/empty Graphicbuffer by enumerating FILL_BUFF/EMPTY_BUFF*/ 2750 GraphicBuffer_Fill(src_buf, FILL_BUFF, 0); 2751 if(MODE == MODE_BLEND) 2752 GraphicBuffer_Fill(dst_buf, FILL_BUFF, 1); 2753 else 2754 GraphicBuffer_Fill(dst_buf, EMPTY_BUFF, 1); 2755 2756 /*Fill rga_buffer_t structure: src、dst*/ 2757 src = wrapbuffer_GraphicBuffer(src_buf); 2758 dst = wrapbuffer_GraphicBuffer(dst_buf); 2759``` 2760 2761 2762 2763##### AHardwareBuffer 2764 2765> AHardwareBuffer is initialized, filled/emptied, and filling rga_buffer_t structure through three functions. 2766 2767```c++ 2768 /*Passing in width, height, and image formats of src/dst and initialize AHardwareBuffer*/ 2769 AHardwareBuffer_Init(SRC_WIDTH, SRC_HEIGHT, SRC_FORMAT, &src_buf); 2770 AHardwareBuffer_Init(DST_WIDTH, DST_HEIGHT, DST_FORMAT, &dst_buf); 2771 2772 /*Fill/empty AHardwareBuffer by enumerating FILL_BUFF/EMPTY_BUFF*/ 2773 AHardwareBuffer_Fill(&src_buf, FILL_BUFF, 0); 2774 if(MODE == MODE_BLEND) 2775 AHardwareBuffer_Fill(&dst_buf, FILL_BUFF, 1); 2776 else 2777 AHardwareBuffer_Fill(&dst_buf, EMPTY_BUFF, 1); 2778 2779 /*Fill rga_buffer_t structure: src、dst*/ 2780 src = wrapbuffer_AHardwareBuffer(src_buf); 2781 dst = wrapbuffer_AHardwareBuffer(dst_buf); 2782``` 2783 2784 2785 2786#### Viewing Help Information 2787 2788> Run the following command to obtain the help information about the test case: 2789 2790``` 2791rgaImDemo -h 2792rgaImDemo --help 2793rgaImDemo 2794``` 2795 2796> You can use demo according to the help information. The following information is printed: 2797 2798``` 2799rk3399_Android10:/ # rgaImDemo 2800librga:RGA_GET_VERSION:3.02,3.020000 2801ctx=0x7864d7c520,ctx->rgaFd=3 2802 2803============================================================================================= 2804 usage: rgaImDemo [--help/-h] [--while/-w=(time)] [--querystring/--querystring=<options>] 2805 [--copy] [--resize=<up/down>] [--crop] [--rotate=90/180/270] 2806 [--flip=H/V] [--translate] [--blend] [--cvtcolor] 2807 [--fill=blue/green/red] 2808 --help/-h Call help 2809 --while/w Set the loop mode. Users can set the number of cycles by themselves. 2810 --querystring You can print the version or support information corresponding to the current version of RGA according to the options. 2811 If there is no input options, all versions and support information of the current version of RGA will be printed. 2812 <options>: 2813 vendor Print vendor information. 2814 version Print RGA version, and librga/im2d_api version. 2815 maxinput Print max input resolution. 2816 maxoutput Print max output resolution. 2817 scalelimit Print scale limit. 2818 inputformat Print supported input formats. 2819 outputformat Print supported output formats. 2820 expected Print expected performance. 2821 all Print all information. 2822 --copy Copy the image by RGA.The default is 720p to 720p. 2823 --resize resize the image by RGA.You can choose to up(720p->1080p) or down(720p->480p). 2824 --crop Crop the image by RGA.By default, a picture of 300*300 size is cropped from (100,100). 2825 --rotate Rotate the image by RGA.You can choose to rotate 90/180/270 degrees. 2826 2827 --flip Flip the image by RGA.You can choice of horizontal flip or vertical flip. 2828 --translate Translate the image by RGA.Default translation (300,300). 2829 --blend Blend the image by RGA.Default, Porter-Duff 'SRC over DST'. 2830 --cvtcolor Modify the image format and color space by RGA.The default is RGBA8888 to NV12. 2831 --fill Fill the image by RGA to blue, green, red, when you set the option to the corresponding color. 2832============================================================================================= 2833``` 2834 2835> Parameter parsing is in the directory /librga/demo/im2d_api_demo/args.cpp. 2836 2837 2838 2839#### Executing Demo in Loop 2840 2841> Run the following command to loop demo. The loop command must precede all parameters. The number of cycles are of the type int and the default interval is 200ms. 2842 2843``` 2844rgaImDemo -w6 --copy 2845rgaImDemo --while=6 --copy 2846``` 2847 2848 2849 2850#### Obtain RGA Version and Support Information 2851 2852> Run the following command to obtain the version and support information: 2853 2854``` 2855rgaImDemo --querystring 2856rgaImDemo --querystring=<options> 2857``` 2858 2859> If there is no input options, all versions and support information of current version of RGA will be printed. 2860 2861``` 2862options: 2863 =vendor Print vendor information. 2864 =version Print RGA version, and librga/im2d_api version. 2865 =maxinput Print max input resolution. 2866 =maxoutput Print max output resolution. 2867 =scalelimit Print scale limit. 2868 =inputformat Print supported input formats. 2869 =outputformat Print supported output formats. 2870 =expected Print expected performance. 2871 =all Print all information. 2872``` 2873 2874##### Code Parsing 2875 2876> According to parameters of main() to print different information. 2877 2878```c++ 2879 /*Convert the parameters of main() into QUERYSTRING_INFO enumeration values*/ 2880 IM_INFO = (QUERYSTRING_INFO)parm_data[MODE_QUERYSTRING]; 2881 /*Print the string returned by querystring(), which is the required information*/ 2882 printf("\n%s\n", querystring(IM_INFO)); 2883``` 2884 2885 2886 2887#### Image Resizing 2888 2889> Use the following command to test image resizing. 2890 2891``` 2892rgaImDemo --resize=up 2893rgaImDemo --resize=down 2894``` 2895 2896> This function must be filled withoptions as follows: 2897 2898``` 2899options: 2900 =up image resolution scale up to 1920x1080 2901 =down image resolution scale down to 720x480 2902``` 2903 2904##### Code Parsing 2905 2906> According to the parameters (up/down) of main() to choose to up(720p->1080p) or down(720p->480p), that is, for different scenarios, the buffer is re-initialized, emptied, or fills rga_buffer_t structure, and the rga_buffer_t structure that stores src and dst image data is passed to imresize(). 2907 2908```c++ 2909 switch(parm_data[MODE_RESIZE]) 2910 { 2911 /*scale up the image*/ 2912 case IM_UP_SCALE : 2913 /*re-initialize Graphicbuffer to corresponding resolution 1920x1080*/ 2914 dst_buf = GraphicBuffer_Init(1920, 1080, DST_FORMAT); 2915 /*empty the buffer*/ 2916 GraphicBuffer_Fill(dst_buf, EMPTY_BUFF, 1); 2917 /*refill rga_buffer_t structure that stores dst data*/ 2918 dst = wrapbuffer_GraphicBuffer(dst_buf); 2919 break; 2920 2921 case IM_DOWN_SCALE : 2922 /*re-initialize Graphicbuffer to corresponding resolution 720x480**/ 2923 dst_buf = GraphicBuffer_Init(720, 480, DST_FORMAT); 2924 /*empty the buffer*/ 2925 GraphicBuffer_Fill(dst_buf, EMPTY_BUFF, 1); 2926 /*refill rga_buffer_t structure that stores dst data*/ 2927 dst = wrapbuffer_GraphicBuffer(dst_buf); 2928 break; 2929 } 2930 /*pass src and dst of rga_buffer_t structure to imresize()*/ 2931 STATUS = imresize(src, dst); 2932 /*print running status according to IM_STATUS enumeration values*/ 2933 printf("resizing .... %s\n", imStrError(STATUS)); 2934``` 2935 2936 2937 2938#### Image Cropping 2939 2940> Test image cropping using the following command. 2941 2942``` 2943rgaImDemo --crop 2944``` 2945 2946> Options are not available for this feature. By default, crop the image within the coordinate LT(100,100),RT(400,100),LB(100,400),RB(400,400). 2947 2948##### Code Parsing 2949 2950> Assign the size of clipped area in the im_rect structure that stores the src rectangle data, and pass the rga_buffer_t structure that stores the src and dst image data to imcrop(). 2951 2952```c++ 2953 /*The coordinates of the clipped vertex are determined by x and y,the size of the clipped area is determined by width and height*/ 2954 src_rect.x = 100; 2955 src_rect.y = 100; 2956 src_rect.width = 300; 2957 src_rect.height = 300; 2958 2959 /*pass src and dst of src_rect structure and rga_buffer_t structure format to imcrop()*/ 2960 STATUS = imcrop(src, dst, src_rect); 2961 /*print the running status according to the returned IM_STATUS enumeration values*/ 2962 printf("cropping .... %s\n", imStrError(STATUS)); 2963``` 2964 2965 2966 2967#### Image Rotation 2968 2969> Test image rotation using the following command. 2970 2971``` 2972rgaImDemo --rotate=90 2973rgaImDemo --rotate=180 2974rgaImDemo --rotate=270 2975``` 2976 2977> This function must be filled with options, which are as follows: 2978 2979``` 2980options: 2981 =90 Image rotation by 90°, exchange the width and height of output image resolution. 2982 =180 Image rotation by 180°, output image resolution unchanged. 2983 =270 Image rotation by 270°, exchange the width and height of output image resolution. 2984``` 2985 2986##### Code Parsing 2987 2988> According to the arguments (up/down) of main() to choose the rotation degrees(90/180/270). IM_USAGE enumeration transformed from arguments values, together with the rga_buffer_t structure that stores src and dst image data is passed to imrotate(). 2989 2990```c++ 2991 /*convert the parameters of main() into IM_USAGE enumeration values*/ 2992 ROTATE = (IM_USAGE)parm_data[MODE_ROTATE]; 2993 2994 /*pass both IM_USAGE enumeration value that identifies the rotation degrees and src and dst of rga_buffer_t structure format to imrotate()*/ 2995 STATUS = imrotate(src, dst, ROTATE); 2996 /*print the running status according to the returned IM_STATUS enumeration values*/ 2997 printf("rotating .... %s\n", imStrError(STATUS)); 2998``` 2999 3000 3001 3002#### Image Mirror Flip 3003 3004> Use the following command to test mirror flipping 3005 3006``` 3007rgaImDemo --flip=H 3008rgaImDemo --flip=V 3009``` 3010 3011> This function must be filled with options, which are as follows: 3012 3013``` 3014options: 3015 =H Image horizontal mirror flip. 3016 =V Image vertical mirror flip. 3017``` 3018 3019##### Code Parsing 3020 3021> According to the arguments (H/V) of main() to choose the flipped direction, transform the arguments to IM_USAGE enumeration values, and the rga_buffer_t structure that stores src and dst image data is passed to imflip(). 3022 3023```c++ 3024 /*convert the parameters of main() into IM_USAGE enumeration values*/ 3025 FLIP = (IM_USAGE)parm_data[MODE_FLIP]; 3026 3027 /*pass both IM_USAGE enumeration value that identifies the flipped direction and src and dst of rga_buffer_t structure format to imflip()*/ 3028 STATUS = imflip(src, dst, FLIP); 3029 /*print the running status according to the returned IM_STATUS enumeration value*/ 3030 printf("flipping .... %s\n", imStrError(STATUS)); 3031``` 3032 3033 3034 3035#### Image Color Fill 3036 3037> Use the following command to test the color fill. 3038 3039``` 3040rgaImDemo --fill=blue 3041rgaImDemo --fill=green 3042rgaImDemo --fill=red 3043``` 3044 3045This function must be filled with options. By default, fill the color of image within the coordinate LT(100,100),RT(400,100),LB(100,400),RB(400,400), options are as follows: 3046 3047``` 3048options: 3049 =blue Fill the image color as blue. 3050 =green Fill the image color as green. 3051 =red Fill the image color as red. 3052``` 3053 3054##### Code Parsing 3055 3056> The filled color is determined according to the (blue/green/red) parameters of main(), and the size to be filled is assigned to the im_rect structure that stores the dst rectangle data, and the passed parameter is converted to the hexadecimal number of the corresponding color, which is passed to imfill() along with rga_buffer_t that stores the dst image data. 3057 3058```c++ 3059 /*Convert parameter of main() to hexadecimal number of the corresponding color*/ 3060 COLOR = parm_data[MODE_FILL]; 3061 3062 /*The coordinates of clipping vertex are determined by x and y, and size of color-filled area is determined by width and height*/ 3063 dst_rect.x = 100; 3064 dst_rect.y = 100; 3065 dst_rect.width = 300; 3066 dst_rect.height = 300; 3067 3068 /*Pass dst_rect of im_rect format and hexadecimal number of the corresponding color together with src and dst of rga_buffer_t format to imfill().*/ 3069 STATUS = imfill(dst, dst_rect, COLOR); 3070 /*print the running status according to the returned IM_STATUS enumeration value*/ 3071 printf("filling .... %s\n", imStrError(STATUS)); 3072``` 3073 3074 3075 3076#### Image Translation 3077 3078> Use the following command to test image translation. 3079 3080``` 3081rgaImDemo --translate 3082``` 3083 3084> This feature has no options. By default, the vertex (upper-left coordinate) is shifted to (300,300), that is, shifted 300 pixels to the right and 300 pixels down. 3085 3086##### Code Parsing 3087 3088> Assign the offset of translation to the im_rect that stores the src rectangle data, and pass the rga_buffer_t structure that stores the src and dst image data to imtranslate(). 3089 3090```c++ 3091 /*The coordinates of vertices of translated image are determined by x and y*/ 3092 src_rect.x = 300; 3093 src_rect.y = 300; 3094 3095 /*pass the src_rect of im_rect format along with src and dst of rga_buffer_t format into imtranslate()*/ 3096 STATUS = imtranslate(src, dst, src_rect.x, src_rect.y); 3097 /*print the running status according to the returned IM_STATUS enumeration value*/ 3098 printf("translating .... %s\n", imStrError(STATUS)); 3099``` 3100 3101 3102 3103#### Image Copying 3104 3105> Use the following command to test image copying. 3106 3107``` 3108rgaImDemo --copy 3109``` 3110 3111> This feature has no options. The default copy resolution is 1280x720 and the format is RGBA8888. 3112 3113##### Code Parsing 3114 3115> Passing rga_buffer_t that stores src and dst image data to imcopy(). 3116 3117```c++ 3118 /*passing src and dst of rga_buffer_t format to imcopy()*/ 3119 STATUS = imcopy(src, dst); 3120 /*print the running status according to the returned IM_STATUS enumeration value*/ 3121 printf("copying .... %s\n", imStrError(STATUS)); 3122``` 3123 3124 3125 3126#### Image Blending 3127 3128> Use the following command to test image blending. 3129 3130``` 3131rgaImDemo --blend 3132``` 3133 3134> This feature has no options. By default, the blending mode is IM_ALPHA_BLEND_DST. 3135 3136##### Code Parsing 3137 3138> Passing rga_buffer_t that stores src and dst image data to imblend(). 3139 3140```c++ 3141 /*passing src and dst of rga_buffer_t format to imblend()*/ 3142 STATUS = imblend(src, dst); 3143 /*print the running status according to the returned IM_STATUS enumeration value*/ 3144 printf("blending .... %s\n", imStrError(STATUS)); 3145``` 3146 3147 3148 3149#### Image Format Conversion 3150 3151> Use the following command to test image format conversion. 3152 3153``` 3154rgaImDemo --cvtcolor 3155``` 3156 3157> This feature has no options. By default, images with resolution of 1280x720 will be converted from RGBA8888 to NV12. 3158 3159##### Code Parsing 3160 3161Assign the format to be converted in the format variable member of rga_buffer_t, and pass the rga_buffer_t structure that stores src and dst image data to imcvtcolor(). 3162 3163```c++ 3164 /*Assign the format in the format variable member*/ 3165 src.format = HAL_PIXEL_FORMAT_RGBA_8888; 3166 dst.format = HAL_PIXEL_FORMAT_YCrCb_NV12; 3167 3168 /*passing the format to be converted and src and dst of rga_buffer_t format to imcvtcolor()*/ 3169 STATUS = imcvtcolor(src, dst, src.format, dst.format); 3170 /*print the running status according to the returned IM_STATUS enumeration value*/ 3171 printf("cvtcolor .... %s\n", imStrError(STATUS)); 3172``` 3173