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