im2d_task.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. /*
  2. * Copyright (C) 2022 Rockchip Electronics Co., Ltd.
  3. * Authors:
  4. * Cerf Yu <cerf.yu@rock-chips.com>
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef _im2d_task_h_
  19. #define _im2d_task_h_
  20. #include "im2d_type.h"
  21. #ifdef __cplusplus
  22. /**
  23. * Create an rga job
  24. *
  25. * @param flags
  26. * Some configuration flags for this job
  27. *
  28. * @returns job handle.
  29. */
  30. IM_API im_job_handle_t imbeginJob(uint64_t flags = 0);
  31. /**
  32. * Submit and run an rga job
  33. *
  34. * @param job_handle
  35. * This is the job handle that will be submitted.
  36. * @param sync_mode
  37. * run mode:
  38. * IM_SYNC
  39. * IM_ASYNC
  40. * @param acquire_fence_fd
  41. * @param release_fence_fd
  42. *
  43. * @returns success or else negative error code.
  44. */
  45. IM_API IM_STATUS imendJob(im_job_handle_t job_handle,
  46. int sync_mode = IM_SYNC,
  47. int acquire_fence_fd = 0, int *release_fence_fd = NULL);
  48. /**
  49. * Cancel and delete an rga job
  50. *
  51. * @param job_handle
  52. * This is the job handle that will be cancelled.
  53. *
  54. * @returns success or else negative error code.
  55. */
  56. IM_API IM_STATUS imcancelJob(im_job_handle_t job_handle);
  57. /**
  58. * Add copy task
  59. *
  60. * @param job_handle
  61. * Insert the task into the job handle.
  62. * @param src
  63. * The input source image.
  64. * @param dst
  65. * The output destination image.
  66. *
  67. * @returns success or else negative error code.
  68. */
  69. IM_API IM_STATUS imcopyTask(im_job_handle_t job_handle, const rga_buffer_t src, rga_buffer_t dst);
  70. /**
  71. * Add resize task
  72. *
  73. * @param job_handle
  74. * Insert the task into the job handle.
  75. * @param src
  76. * The input source image.
  77. * @param dst
  78. * The output destination image.
  79. * @param fx
  80. * X-direction resize factor.
  81. * @param fy
  82. * X-direction resize factor.
  83. * @param interpolation
  84. * Interpolation formula(Only RGA1 support).
  85. *
  86. * @returns success or else negative error code.
  87. */
  88. IM_API IM_STATUS imresizeTask(im_job_handle_t job_handle,
  89. const rga_buffer_t src, rga_buffer_t dst,
  90. double fx = 0, double fy = 0,
  91. int interpolation = 0);
  92. /**
  93. * Add crop task
  94. *
  95. * @param job_handle
  96. * Insert the task into the job handle.
  97. * @param src
  98. * The input source image.
  99. * @param dst
  100. * The output destination image.
  101. * @param rect
  102. * The rectangle on the source image that needs to be cropped.
  103. *
  104. * @returns success or else negative error code.
  105. */
  106. IM_API IM_STATUS imcropTask(im_job_handle_t job_handle,
  107. const rga_buffer_t src, rga_buffer_t dst, im_rect rect);
  108. /**
  109. * Add translate task
  110. *
  111. * @param job_handle
  112. * Insert the task into the job handle.
  113. * @param src
  114. * The input source image.
  115. * @param dst
  116. * The output destination image.
  117. * @param x
  118. * Output the coordinates of the starting point in the X-direction of the destination image.
  119. * @param y
  120. * Output the coordinates of the starting point in the Y-direction of the destination image.
  121. *
  122. * @returns success or else negative error code.
  123. */
  124. IM_API IM_STATUS imtranslateTask(im_job_handle_t job_handle,
  125. const rga_buffer_t src, rga_buffer_t dst, int x, int y);
  126. /**
  127. * Add format convert task
  128. *
  129. * @param job_handle
  130. * Insert the task into the job handle.
  131. * @param src
  132. * The input source image.
  133. * @param dst
  134. * The output destination image.
  135. * @param sfmt
  136. * The source image format.
  137. * @param dfmt
  138. * The destination image format.
  139. * @param mode
  140. * color space mode:
  141. * IM_YUV_TO_RGB_BT601_LIMIT
  142. * IM_YUV_TO_RGB_BT601_FULL
  143. * IM_YUV_TO_RGB_BT709_LIMIT
  144. * IM_RGB_TO_YUV_BT601_FULL
  145. * IM_RGB_TO_YUV_BT601_LIMIT
  146. * IM_RGB_TO_YUV_BT709_LIMIT
  147. *
  148. * @returns success or else negative error code.
  149. */
  150. IM_API IM_STATUS imcvtcolorTask(im_job_handle_t job_handle,
  151. rga_buffer_t src, rga_buffer_t dst,
  152. int sfmt, int dfmt, int mode = IM_COLOR_SPACE_DEFAULT);
  153. /**
  154. * Add rotation task
  155. *
  156. * @param job_handle
  157. * Insert the task into the job handle.
  158. * @param src
  159. * The input source image.
  160. * @param dst
  161. * The output destination image.
  162. * @param rotation
  163. * IM_HAL_TRANSFORM_ROT_90
  164. * IM_HAL_TRANSFORM_ROT_180
  165. * IM_HAL_TRANSFORM_ROT_270
  166. *
  167. * @returns success or else negative error code.
  168. */
  169. IM_API IM_STATUS imrotateTask(im_job_handle_t job_handle,
  170. const rga_buffer_t src, rga_buffer_t dst, int rotation);
  171. /**
  172. * Add flip task
  173. *
  174. * @param job_handle
  175. * Insert the task into the job handle.
  176. * @param src
  177. * The input source image.
  178. * @param dst
  179. * The output destination image.
  180. * @param mode
  181. * IM_HAL_TRANSFORM_FLIP_H
  182. * IM_HAL_TRANSFORM_FLIP_V
  183. *
  184. * @returns success or else negative error code.
  185. */
  186. IM_API IM_STATUS imflipTask(im_job_handle_t job_handle,
  187. const rga_buffer_t src, rga_buffer_t dst, int mode);
  188. /**
  189. * Add blend(SRC + DST -> DST) task
  190. *
  191. * @param job_handle
  192. * Insert the task into the job handle.
  193. * @param fg_image
  194. * The foreground image.
  195. * @param bg_image
  196. * The background image, which is also the output destination image.
  197. * @param mode
  198. * Port-Duff mode:
  199. * IM_ALPHA_BLEND_SRC
  200. * IM_ALPHA_BLEND_DST
  201. * IM_ALPHA_BLEND_SRC_OVER
  202. * IM_ALPHA_BLEND_DST_OVER
  203. *
  204. * @returns success or else negative error code.
  205. */
  206. IM_API IM_STATUS imblendTask(im_job_handle_t job_handle,
  207. const rga_buffer_t fg_image, rga_buffer_t bg_image,
  208. int mode = IM_ALPHA_BLEND_SRC_OVER);
  209. /**
  210. * Add composite(SRCA + SRCB -> DST) task
  211. *
  212. * @param job_handle
  213. * Insert the task into the job handle.
  214. * @param fg_image
  215. * The foreground image.
  216. * @param bg_image
  217. * The background image.
  218. * @param output_image
  219. * The output destination image.
  220. * @param mode
  221. * Port-Duff mode:
  222. * IM_ALPHA_BLEND_SRC
  223. * IM_ALPHA_BLEND_DST
  224. * IM_ALPHA_BLEND_SRC_OVER
  225. * IM_ALPHA_BLEND_DST_OVER
  226. *
  227. * @returns success or else negative error code.
  228. */
  229. IM_API IM_STATUS imcompositeTask(im_job_handle_t job_handle,
  230. const rga_buffer_t fg_image, const rga_buffer_t bg_image,
  231. rga_buffer_t output_image,
  232. int mode = IM_ALPHA_BLEND_SRC_OVER);
  233. /**
  234. * Add color key task
  235. *
  236. * @param job_handle
  237. * Insert the task into the job handle.
  238. * @param fg_image
  239. * The foreground image.
  240. * @param bg_image
  241. * The background image, which is also the output destination image.
  242. * @param colorkey_range
  243. * The range of color key.
  244. *
  245. * @returns success or else negative error code.
  246. */
  247. IM_API IM_STATUS imcolorkeyTask(im_job_handle_t job_handle,
  248. const rga_buffer_t fg_image, rga_buffer_t bg_image,
  249. im_colorkey_range range, int mode = IM_ALPHA_COLORKEY_NORMAL);
  250. /**
  251. * Add OSD task
  252. *
  253. * @param job_handle
  254. * Insert the task into the job handle.
  255. * @param osd
  256. * The osd text block.
  257. * @param dst
  258. * The background image.
  259. * @param osd_rect
  260. * The rectangle on the source image that needs to be OSD.
  261. * @param osd_config
  262. * osd mode configuration.
  263. *
  264. * @returns success or else negative error code.
  265. */
  266. IM_API IM_STATUS imosdTask(im_job_handle_t job_handle,
  267. const rga_buffer_t osd,const rga_buffer_t bg_image,
  268. const im_rect osd_rect, im_osd_t *osd_config);
  269. /**
  270. * Add nn quantize task
  271. *
  272. * @param job_handle
  273. * Insert the task into the job handle.
  274. * @param src
  275. * The input source image.
  276. * @param dst
  277. * The output destination image.
  278. * @param nninfo
  279. * nn configuration
  280. *
  281. * @returns success or else negative error code.
  282. */
  283. IM_API IM_STATUS imquantizeTask(im_job_handle_t job_handle,
  284. const rga_buffer_t src, rga_buffer_t dst, im_nn_t nn_info);
  285. /**
  286. * Add ROP task
  287. *
  288. * @param job_handle
  289. * Insert the task into the job handle.
  290. * @param src
  291. * The input source image.
  292. * @param dst
  293. * The output destination image.
  294. * @param rop_code
  295. * The ROP opcode.
  296. *
  297. * @returns success or else negative error code.
  298. */
  299. IM_API IM_STATUS imropTask(im_job_handle_t job_handle,
  300. const rga_buffer_t src, rga_buffer_t dst, int rop_code);
  301. /**
  302. * Add color fill task
  303. *
  304. * @param job_handle
  305. * Insert the task into the job handle.
  306. * @param dst
  307. * The output destination image.
  308. * @param rect
  309. * The rectangle on the source image that needs to be filled with color.
  310. * @param color
  311. * The fill color value.
  312. *
  313. * @returns success or else negative error code.
  314. */
  315. IM_API IM_STATUS imfillTask(im_job_handle_t job_handle, rga_buffer_t dst, im_rect rect, uint32_t color);
  316. /**
  317. * Add color fill task array
  318. *
  319. * @param job_handle
  320. * Insert the task into the job handle.
  321. * @param dst
  322. * The output destination image.
  323. * @param rect_array
  324. * The rectangle arrays on the source image that needs to be filled with color.
  325. * @param array_size
  326. * The size of rectangular area arrays.
  327. * @param color
  328. * The fill color value.
  329. *
  330. * @returns success or else negative error code.
  331. */
  332. IM_API IM_STATUS imfillTaskArray(im_job_handle_t job_handle,
  333. rga_buffer_t dst,
  334. im_rect *rect_array, int array_size, uint32_t color);
  335. /**
  336. * Add fill rectangle task
  337. *
  338. * @param job_handle
  339. * Insert the task into the job handle.
  340. * @param dst
  341. * The output destination image.
  342. * @param rect
  343. * The rectangle on the source image that needs to be filled with color.
  344. * @param color
  345. * The fill color value.
  346. * @param thickness
  347. * Thickness of lines that make up the rectangle. Negative values, like -1,
  348. * mean that the function has to draw a filled rectangle.
  349. *
  350. * @returns success or else negative error code.
  351. */
  352. IM_API IM_STATUS imrectangleTask(im_job_handle_t job_handle,
  353. rga_buffer_t dst,
  354. im_rect rect,
  355. uint32_t color, int thickness);
  356. /**
  357. * Add fill rectangle task array
  358. *
  359. * @param job_handle
  360. * Insert the task into the job handle.
  361. * @param dst
  362. * The output destination image.
  363. * @param rect_array
  364. * The rectangle arrays on the source image that needs to be filled with color.
  365. * @param array_size
  366. * The size of rectangular area arrays.
  367. * @param color
  368. * The fill color value.
  369. * @param thickness
  370. * Thickness of lines that make up the rectangle. Negative values, like -1,
  371. * mean that the function has to draw a filled rectangle.
  372. *
  373. * @returns success or else negative error code.
  374. */
  375. IM_API IM_STATUS imrectangleTaskArray(im_job_handle_t job_handle,
  376. rga_buffer_t dst,
  377. im_rect *rect_array, int array_size,
  378. uint32_t color, int thickness);
  379. /**
  380. * Add mosaic task
  381. *
  382. * @param job_handle
  383. * Insert the task into the job handle.
  384. * @param image
  385. * The output destination image.
  386. * @param rect
  387. * The rectangle on the source image that needs to be mosaicked.
  388. * @param mosaic_mode
  389. * mosaic block width configuration:
  390. * IM_MOSAIC_8
  391. * IM_MOSAIC_16
  392. * IM_MOSAIC_32
  393. * IM_MOSAIC_64
  394. * IM_MOSAIC_128
  395. *
  396. * @returns success or else negative error code.
  397. */
  398. IM_API IM_STATUS immosaicTask(im_job_handle_t job_handle,
  399. const rga_buffer_t image, im_rect rect, int mosaic_mode);
  400. /**
  401. * Add mosaic task
  402. *
  403. * @param job_handle
  404. * Insert the task into the job handle.
  405. * @param image
  406. * The output destination image.
  407. * @param rect_array
  408. * The rectangle arrays on the source image that needs to be filled with color.
  409. * @param array_size
  410. * The size of rectangular area arrays.
  411. * @param mosaic_mode
  412. * mosaic block width configuration:
  413. * IM_MOSAIC_8
  414. * IM_MOSAIC_16
  415. * IM_MOSAIC_32
  416. * IM_MOSAIC_64
  417. * IM_MOSAIC_128
  418. *
  419. * @returns success or else negative error code.
  420. */
  421. IM_API IM_STATUS immosaicTaskArray(im_job_handle_t job_handle,
  422. const rga_buffer_t image,
  423. im_rect *rect_array, int array_size, int mosaic_mode);
  424. /**
  425. * Add palette task
  426. *
  427. * @param job_handle
  428. * Insert the task into the job handle.
  429. * @param src
  430. * The input source image.
  431. * @param dst
  432. * The output destination image.
  433. * @param lut
  434. * The LUT table.
  435. *
  436. * @returns success or else negative error code.
  437. */
  438. IM_API IM_STATUS impaletteTask(im_job_handle_t job_handle,
  439. rga_buffer_t src, rga_buffer_t dst, rga_buffer_t lut);
  440. /**
  441. * Add process task
  442. *
  443. * @param job_handle
  444. * Insert the task into the job handle.
  445. * @param src
  446. * The input source image and is also the foreground image in blend.
  447. * @param dst
  448. * The output destination image and is also the foreground image in blend.
  449. * @param pat
  450. * The foreground image, or a LUT table.
  451. * @param srect
  452. * The rectangle on the src channel image that needs to be processed.
  453. * @param drect
  454. * The rectangle on the dst channel image that needs to be processed.
  455. * @param prect
  456. * The rectangle on the pat channel image that needs to be processed.
  457. * @param opt
  458. * The image processing options configuration.
  459. * @param usage
  460. * The image processing usage.
  461. *
  462. * @returns success or else negative error code.
  463. */
  464. IM_API IM_STATUS improcessTask(im_job_handle_t job_handle,
  465. rga_buffer_t src, rga_buffer_t dst, rga_buffer_t pat,
  466. im_rect srect, im_rect drect, im_rect prect,
  467. im_opt_t *opt_ptr, int usage);
  468. #endif /* #ifdef __cplusplus */
  469. #endif /* #ifndef _im2d_task_h_ */