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 __HI_COMM_SVP_H__ 17 #define __HI_COMM_SVP_H__ 18 19 #include "hi_type.h" 20 #include "hi_errno.h" 21 22 #ifdef __cplusplus 23 #if __cplusplus 24 extern "C" { 25 #endif 26 #endif /* __cplusplus */ 27 28 #define HI_SVP_IMG_ADDR_NUM 3 29 #define HI_SVP_IMG_STRIDE_NUM 3 30 31 /* Blob type */ 32 typedef enum hiSVP_BLOB_TYPE_E { 33 SVP_BLOB_TYPE_S32 = 0x0, 34 35 SVP_BLOB_TYPE_U8 = 0x1, 36 37 /* channel is 3 */ 38 SVP_BLOB_TYPE_YVU420SP = 0x2, 39 40 /* channel is 3 */ 41 SVP_BLOB_TYPE_YVU422SP = 0x3, 42 43 SVP_BLOB_TYPE_VEC_S32 = 0x4, 44 45 SVP_BLOB_TYPE_SEQ_S32 = 0x5, 46 47 SVP_BLOB_TYPE_BUTT 48 } SVP_BLOB_TYPE_E; 49 50 /* 51 * Blob struct 52 * In Caffe, the blob contain shape info as the following order: 53 * Image\FeatureMap: N C H W 54 * FC(normal vector): N C 55 * RNN\LSTM(Recurrent) vector: T N D 56 * 57 * The relationship of the following blob struct with Caffe blob is as follows: 58 * Image\FeatureMap: Num Chn Height With 59 * FC(VEC_S32): Num Width 60 * RNN\LSTM(SEQ_S32) vector: Step Num Dim 61 * The stride, which measuring unit is byte, is always algined by the width or 62 * dim direction. 63 */ 64 typedef struct hiSVP_BLOB_S { 65 SVP_BLOB_TYPE_E enType; /* Blob type */ 66 HI_U32 u32Stride; /* Stride, a line bytes num */ 67 68 HI_U64 u64VirAddr; /* virtual addr */ 69 HI_U64 u64PhyAddr; /* physical addr */ 70 71 HI_U32 u32Num; /* N: frame num or sequence num, correspond to caffe blob's n */ 72 union { 73 struct { 74 HI_U32 u32Width; /* W: frame width, correspond to caffe blob's w */ 75 HI_U32 u32Height; /* H: frame height, correspond to caffe blob's h */ 76 HI_U32 u32Chn; /* C: frame channel, correspond to caffe blob's c */ 77 } stWhc; 78 struct { 79 HI_U32 u32Dim; /* D: vecotr dimension */ 80 HI_U64 u64VirAddrStep; /* T: virtual adress of time steps array in each sequence */ 81 } stSeq; 82 } unShape; 83 } SVP_BLOB_S; 84 85 typedef SVP_BLOB_S SVP_SRC_BLOB_S; 86 typedef SVP_BLOB_S SVP_DST_BLOB_S; 87 88 /* Mem information */ 89 typedef struct hiSVP_MEM_INFO_S { 90 HI_U64 u64PhyAddr; /* RW;The physical address of the memory */ 91 HI_U64 u64VirAddr; /* RW;The virtual address of the memory */ 92 HI_U32 u32Size; /* RW;The size of memory */ 93 } SVP_MEM_INFO_S; 94 95 typedef SVP_MEM_INFO_S SVP_SRC_MEM_INFO_S; 96 typedef SVP_MEM_INFO_S SVP_DST_MEM_INFO_S; 97 98 /* Image type */ 99 typedef enum hiSVP_IMAGE_TYPE_E { 100 SVP_IMAGE_TYPE_U8C1 = 0x0, 101 SVP_IMAGE_TYPE_S8C1 = 0x1, 102 103 SVP_IMAGE_TYPE_YUV420SP = 0x2, /* YUV420 SemiPlanar */ 104 SVP_IMAGE_TYPE_YUV422SP = 0x3, /* YUV422 SemiPlanar */ 105 SVP_IMAGE_TYPE_YUV420P = 0x4, /* YUV420 Planar */ 106 SVP_IMAGE_TYPE_YUV422P = 0x5, /* YUV422 planar */ 107 108 SVP_IMAGE_TYPE_S8C2_PACKAGE = 0x6, 109 SVP_IMAGE_TYPE_S8C2_PLANAR = 0x7, 110 111 SVP_IMAGE_TYPE_S16C1 = 0x8, 112 SVP_IMAGE_TYPE_U16C1 = 0x9, 113 114 SVP_IMAGE_TYPE_U8C3_PACKAGE = 0xa, 115 SVP_IMAGE_TYPE_U8C3_PLANAR = 0xb, 116 117 SVP_IMAGE_TYPE_S32C1 = 0xc, 118 SVP_IMAGE_TYPE_U32C1 = 0xd, 119 120 SVP_IMAGE_TYPE_S64C1 = 0xe, 121 SVP_IMAGE_TYPE_U64C1 = 0xf, 122 123 SVP_IMAGE_TYPE_BUTT 124 } SVP_IMAGE_TYPE_E; 125 126 /* Image */ 127 typedef struct hiSVP_IMAGE_S { 128 HI_U64 au64PhyAddr[HI_SVP_IMG_ADDR_NUM]; /* RW;The physical address of the image */ 129 HI_U64 au64VirAddr[HI_SVP_IMG_ADDR_NUM]; /* RW;The virtual address of the image */ 130 HI_U32 au32Stride[HI_SVP_IMG_STRIDE_NUM]; /* RW;The stride of the image */ 131 HI_U32 u32Width; /* RW;The width of the image */ 132 HI_U32 u32Height; /* RW;The height of the image */ 133 SVP_IMAGE_TYPE_E enType; /* RW;The type of the image */ 134 } SVP_IMAGE_S; 135 136 typedef SVP_IMAGE_S SVP_SRC_IMAGE_S; 137 typedef SVP_IMAGE_S SVP_DST_IMAGE_S; 138 139 #ifdef __cplusplus 140 #if __cplusplus 141 } 142 #endif 143 #endif /* __cplusplus */ 144 145 #endif /* __HI_COMM_SVP_H__ */ 146