1 /* 2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef IVE_IMG_H 17 #define IVE_IMG_H 18 19 #include <stdbool.h> 20 #include <stdint.h> 21 22 #include "hi_common.h" 23 #include "hi_comm_ive.h" 24 #include "hi_comm_video.h" 25 #include "hi_comm_venc.h" 26 #include "hi_ive.h" 27 #include "mpi_ive.h" 28 #include "ai_infer_process.h" 29 30 #if __cplusplus 31 extern "C" { 32 #endif 33 34 /* 35 * 常量 36 * Constant 37 */ 38 #define IMG_FULL_CHN 3 // Full channel / three channel, for YUV444, RGB888 39 #define IMG_HALF_CHN 2 // Half channel, for YUV420/422 40 #define THREE_TIMES 3 41 #define TWO_TIMES 2 42 43 /* 44 * 字节对齐计算 45 * Byte alignment calculation 46 */ 47 HI_U32 HiAlign16(HI_U32 num); 48 HI_U32 HiAlign32(HI_U32 num); 49 50 /* 51 * 对齐类型 52 * Alignment type 53 */ 54 typedef enum AlignType { 55 ALIGN_TYPE_2 = 2, // Align by 2 bytes 56 ALIGN_TYPE_16 = 16, // Align by 16 bytes 57 ALIGN_TYPE_32 = 32, // Align by 32 bytes 58 } AlignType; 59 60 /* 61 * 根据类型和大小创建缓存 62 * Create ive image buffer based on type and size 63 */ 64 int IveImgCreate(IVE_IMAGE_S* img, 65 IVE_IMAGE_TYPE_E enType, uint32_t width, uint32_t height); 66 67 /* 68 * VIDEO_FRAME_INFO_S格式转换成IVE_IMAGE_S格式 69 * 复制数据指针,不复制数据 70 * 71 * video frame to ive image. 72 * Copy the data pointer, do not copy the data. 73 */ 74 int FrmToOrigImg(const VIDEO_FRAME_INFO_S* frm, IVE_IMAGE_S *img); 75 76 /* 77 * 对yuv格式进行裁剪 78 * yuv file crop 79 */ 80 int ImgYuvCrop(const IVE_IMAGE_S *src, IVE_IMAGE_S *dst, const RectBox* origBox); 81 82 /* 83 * 销毁ive image 84 * Destory ive image 85 */ 86 void IveImgDestroy(IVE_IMAGE_S* img); 87 88 int OrigImgToFrm(const IVE_IMAGE_S *img, VIDEO_FRAME_INFO_S* frm); 89 90 #ifdef __cplusplus 91 } 92 #endif 93 #endif 94