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_VPSS_H__
17#define __HI_COMM_VPSS_H__
18
19#include "hi_type.h"
20#include "hi_common.h"
21#include "hi_errno.h"
22#include "hi_comm_video.h"
23
24#ifdef __cplusplus
25#if __cplusplus
26extern "C" {
27#endif
28#endif /* __cplusplus */
29
30#define VPSS_SHARPEN_GAIN_NUM        32
31#define VPSS_AUTO_ISO_STRENGTH_NUM   16
32#define VPSS_YUV_SHPLUMA_NUM         32
33#define VPSS_3DNR_MAX_AUTO_PARAM_NUM 16
34
35#define HI_ERR_VPSS_NULL_PTR         HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_NULL_PTR)
36#define HI_ERR_VPSS_NOTREADY         HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_SYS_NOTREADY)
37#define HI_ERR_VPSS_INVALID_DEVID    HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_DEVID)
38#define HI_ERR_VPSS_INVALID_CHNID    HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_CHNID)
39#define HI_ERR_VPSS_EXIST            HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_EXIST)
40#define HI_ERR_VPSS_UNEXIST          HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_UNEXIST)
41#define HI_ERR_VPSS_NOT_SUPPORT      HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_SUPPORT)
42#define HI_ERR_VPSS_NOT_PERM         HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_PERM)
43#define HI_ERR_VPSS_NOMEM            HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_NOMEM)
44#define HI_ERR_VPSS_NOBUF            HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_NOBUF)
45#define HI_ERR_VPSS_SIZE_NOT_ENOUGH  HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_SIZE_NOT_ENOUGH)
46#define HI_ERR_VPSS_ILLEGAL_PARAM    HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_ILLEGAL_PARAM)
47#define HI_ERR_VPSS_BUSY             HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_BUSY)
48#define HI_ERR_VPSS_BUF_EMPTY        HI_DEF_ERR(HI_ID_VPSS, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_EMPTY)
49
50#define VPSS_INVALID_FRMRATE         (-1)
51#define VPSS_CHN0                    0
52#define VPSS_CHN1                    1
53#define VPSS_CHN2                    2
54#define VPSS_CHN3                    3
55#define VPSS_INVALID_CHN             (-1)
56
57typedef enum hiVPSS_NR_TYPE_E {
58    VPSS_NR_TYPE_VIDEO         = 0,
59    VPSS_NR_TYPE_SNAP          = 1,
60    VPSS_NR_TYPE_VIDEO_SPATIAL = 2,
61    VPSS_NR_TYPE_VIDEO_ENHANCE = 3,
62    VPSS_NR_TYPE_BUTT
63} VPSS_NR_TYPE_E;
64
65typedef enum hiNR_MOTION_MODE_E {
66    NR_MOTION_MODE_NORMAL          = 0,        /* normal */
67    NR_MOTION_MODE_COMPENSATE      = 1,        /* motion compensate */
68    NR_MOTION_MODE_BUTT
69} NR_MOTION_MODE_E;
70
71typedef struct hiVPSS_NR_ATTR_S {
72    VPSS_NR_TYPE_E      enNrType;
73    COMPRESS_MODE_E     enCompressMode;   /* RW; Reference frame compress mode */
74    NR_MOTION_MODE_E    enNrMotionMode;   /* RW; NR motion compensate mode. */
75} VPSS_NR_ATTR_S;
76
77typedef struct hiVPSS_GRP_ATTR_S {
78    /* RW; Range: Hi3559AV100 = [64, 16384] | Hi3519AV100 = [64, 8192] | Hi3516CV500 = [64, 2304] |
79        Hi3516AV300 = [64, 3840] | Hi3516DV300 = [64, 2688] | Hi3556V200 = [64, 4608] | Hi3559V200 = [64, 4608] |
80        Hi3516EV200 = [64, 4096]; Width of source image. */
81    HI_U32                     u32MaxW;
82    /* RW; Range: Hi3559AV100 = [64, 16384] | Hi3519AV100 = [64, 8192] | Hi3516CV500 = [64, 2304] |
83        Hi3516AV300 = [64, 3840] | Hi3516DV300 = [64, 2688] | Hi3556V200 = [64, 4608] | Hi3559V200 = [64, 4608] |
84        Hi3516EV200 = [64, 4096]; Height of source image. */
85    HI_U32                     u32MaxH;
86    PIXEL_FORMAT_E             enPixelFormat;     /* RW; Pixel format of source image. */
87    DYNAMIC_RANGE_E            enDynamicRange;    /* RW; DynamicRange of source image. */
88    FRAME_RATE_CTRL_S          stFrameRate;       /* Grp frame rate contrl. */
89    HI_BOOL                    bNrEn;             /* RW;Range: [0, 1];  NR enable. */
90    VPSS_NR_ATTR_S             stNrAttr;          /* RW; NR attr. */
91} VPSS_GRP_ATTR_S;
92
93typedef enum hiVPSS_CHN_MODE_E {
94    VPSS_CHN_MODE_USER  = 0,       /* User mode. */
95    VPSS_CHN_MODE_AUTO  = 1        /* Auto mode. */
96} VPSS_CHN_MODE_E;
97
98typedef struct hiVPSS_CHN_ATTR_S {
99    VPSS_CHN_MODE_E     enChnMode;          /* RW; Vpss channel's work mode. */
100    /* RW; Range: Hi3559AV100 = [64, 16384] | Hi3519AV100 = [64, 8192] | Hi3516CV500 = [64, 8192] |
101        Hi3516AV300 = [64, 8192] | Hi3516DV300 = [64, 8192] | Hi3556V200 = [64, 8192] | Hi3559V200 = [64, 8192] |
102        Hi3516EV200 = [64, 4096]; Width of target image. */
103    HI_U32              u32Width;
104    /* RW; Range: Hi3559AV100 = [64, 16384] | Hi3519AV100 = [64, 8192] | Hi3516CV500 = [64, 8192] |
105        Hi3516AV300 = [64, 8192] | Hi3516DV300 = [64, 8192] | Hi3556V200 = [64, 8192] | Hi3559V200 = [64, 8192] |
106        Hi3516EV200 = [64, 4096]; Height of target image. */
107    HI_U32              u32Height;
108    VIDEO_FORMAT_E      enVideoFormat;      /* RW; Video format of target image. */
109    PIXEL_FORMAT_E      enPixelFormat;      /* RW; Pixel format of target image. */
110    DYNAMIC_RANGE_E     enDynamicRange;     /* RW; DynamicRange of target image. */
111    COMPRESS_MODE_E     enCompressMode;     /* RW; Compression mode of the output. */
112    FRAME_RATE_CTRL_S   stFrameRate;        /* Frame rate control info */
113    HI_BOOL             bMirror;            /* RW; Mirror enable. */
114    HI_BOOL             bFlip;              /* RW; Flip enable. */
115    HI_U32              u32Depth;           /* RW; Range: [0, 8]; User get list depth. */
116    ASPECT_RATIO_S      stAspectRatio;      /* Aspect Ratio info. */
117} VPSS_CHN_ATTR_S;
118
119typedef enum hiVPSS_CROP_COORDINATE_E {
120    VPSS_CROP_RATIO_COOR = 0,   /* Ratio coordinate. */
121    VPSS_CROP_ABS_COOR          /* Absolute coordinate. */
122} VPSS_CROP_COORDINATE_E;
123
124typedef struct hiVPSS_CROP_INFO_S {
125    HI_BOOL                 bEnable;            /* RW; Range: [0, 1];  CROP enable. */
126    VPSS_CROP_COORDINATE_E  enCropCoordinate;   /* RW;  Range: [0, 1]; Coordinate mode of the crop start point. */
127    RECT_S                  stCropRect;         /* CROP rectangular. */
128} VPSS_CROP_INFO_S;
129
130/* Only used for Hi3519AV100/Hi3516CV500/Hi3516AV300/Hi3516DV300/Hi3556V200/Hi3559V200 */
131typedef struct hiVPSS_LDC_ATTR_S {
132    HI_BOOL     bEnable;                        /* RW; Range: [0, 1]; Whether LDC is enbale */
133    LDC_ATTR_S  stAttr;
134} VPSS_LDC_ATTR_S;
135
136/* Only used for Hi3516EV200 */
137typedef struct hiVPSS_LDCV3_ATTR_S {
138    HI_BOOL     bEnable;                        /* RW;Whether LDC is enbale */
139    LDCV3_ATTR_S  stAttr;
140} VPSS_LDCV3_ATTR_S;
141
142typedef struct hiVPSS_ROTATION_EX_ATTR_S {
143    HI_BOOL       bEnable;                      /* Whether ROTATE_EX_S is enbale */
144    ROTATION_EX_S stRotationEx;                 /* Rotate Attribute */
145} VPSS_ROTATION_EX_ATTR_S;
146
147typedef struct hiVPSS_LOW_DELAY_INFO_S {
148    HI_BOOL bEnable;          /* RW; Low delay enable. */
149    HI_U32 u32LineCnt;        /* RW; Range: [16, 16384]; Low delay shoreline. */
150} VPSS_LOW_DELAY_INFO_S;
151
152typedef struct hiVPSS_EXT_CHN_ATTR_S {
153    /* RW; Range: [0, 3]; Channel bind to. */
154    VPSS_CHN           s32BindChn;
155    /* RW; Range: Hi3559AV100 = [64, 16384] | Hi3519AV100 = [64, 8192] | Hi3516CV500 = [64, 8192] |
156        Hi3516AV300 = [64, 8192] | Hi3516DV300 = [64, 8192] | Hi3556V200 = [64, 8192] | Hi3559V200 = [64, 8192] |
157        Hi3516EV200 = [64, 4096]; Width of target image. */
158    HI_U32             u32Width;
159    /* RW; Range: Hi3559AV100 = [64, 16384] | Hi3519AV100 = [64, 8192] | Hi3516CV500 = [64, 8192] |
160        Hi3516AV300 = [64, 8192] | Hi3516DV300 = [64, 8192] | Hi3556V200 = [64, 8192] | Hi3559V200 = [64, 8192] |
161        Hi3516EV200 = [64, 4096]; Height of target image. */
162    HI_U32             u32Height;
163    /* RW; Video format of target image. */
164    VIDEO_FORMAT_E     enVideoFormat;
165    /* RW; Pixel format of target image. */
166    PIXEL_FORMAT_E     enPixelFormat;
167    /* RW; Dynamic range. */
168    DYNAMIC_RANGE_E    enDynamicRange;
169    /* RW; Compression mode of the output. */
170    COMPRESS_MODE_E    enCompressMode;
171    /* RW; Range: [0, 8]; User get list depth. */
172    HI_U32             u32Depth;
173    /* Frame rate control info */
174    FRAME_RATE_CTRL_S  stFrameRate;
175} VPSS_EXT_CHN_ATTR_S;
176
177/* Only used for Hi3559AV100/Hi3519AV100 */
178typedef struct hiVPSS_GRP_SHARPEN_MANUAL_ATTR_S {
179    /* RW; Range: [0, 4095]; Undirectional sharpen strength for texture and detail enhancement */
180    HI_U16 au16TextureStr[VPSS_SHARPEN_GAIN_NUM];
181    /* RW; Range: [0, 4095]; Directional sharpen strength for edge enhancement */
182    HI_U16 au16EdgeStr[VPSS_SHARPEN_GAIN_NUM];
183    /* RW; Range: [0, 4095]; Texture frequency adjustment. Texture and detail will be finer when it increase */
184    HI_U16 u16TextureFreq;
185    /* RW; Range: [0, 4095]; Edge frequency adjustment. Edge will be narrower and thiner when it increase */
186    HI_U16 u16EdgeFreq;
187    /* RW; Range: [0, 127]; u8OvershootAmt */
188    HI_U8  u8OverShoot;
189    /* RW; Range: [0, 127]; u8UndershootAmt */
190    HI_U8  u8UnderShoot;
191    /* RW; Range: [0, 255]; overshoot and undershoot suppression strength,
192        the amplitude and width of shoot will be decrease when shootSupSt increase */
193    HI_U8  u8ShootSupStr;
194    /* RW; Range: [0, 255]; Different sharpen strength for detail and edge.
195        When it is bigger than 128, detail sharpen strength will be stronger than edge. */
196    HI_U8  u8DetailCtrl;
197    /* RW; Range: [0, 63]; Edge smooth strength. */
198    HI_U8  u8EdgeFiltStr;
199    /* RW; Range: [0, 255]; The threshold of DetailCtrl, it is used to distinguish detail and edge. */
200    HI_U8  u8DetailCtrlThr;
201} VPSS_GRP_SHARPEN_MANUAL_ATTR_S;
202
203/* Only used for Hi3559AV100/Hi3519AV100 */
204typedef struct hiVPSS_GRP_SHARPEN_AUTO_ATTR_S {
205    /* RW; Range: [0, 4095]; Undirectional sharpen strength for texture and detail enhancement */
206    HI_U16 au16TextureStr[VPSS_SHARPEN_GAIN_NUM][VPSS_AUTO_ISO_STRENGTH_NUM];
207    /* RW; Range: [0, 4095]; Directional sharpen strength for edge enhancement */
208    HI_U16 au16EdgeStr[VPSS_SHARPEN_GAIN_NUM][VPSS_AUTO_ISO_STRENGTH_NUM];
209    /* RW; Range: [0, 4095]; Texture frequency adjustment. Texture and detail will be finer when it increase */
210    HI_U16 au16TextureFreq[VPSS_AUTO_ISO_STRENGTH_NUM];
211    /* RW; Range: [0, 4095]; Edge frequency adjustment. Edge will be narrower and thiner when it increase */
212    HI_U16 au16EdgeFreq[VPSS_AUTO_ISO_STRENGTH_NUM];
213    /* RW; Range: [0, 127]; u8OvershootAmt */
214    HI_U8  au8OverShoot[VPSS_AUTO_ISO_STRENGTH_NUM];
215    /* RW; Range: [0, 127]; u8UndershootAmt */
216    HI_U8  au8UnderShoot[VPSS_AUTO_ISO_STRENGTH_NUM];
217    /* RW; Range: [0, 255]; overshoot and undershoot suppression strength,
218        the amplitude and width of shoot will be decrease when shootSupSt increase */
219    HI_U8  au8ShootSupStr[VPSS_AUTO_ISO_STRENGTH_NUM];
220    /* RW; Range: [0, 255]; Different sharpen strength for detail and edge.
221        When it is bigger than 128, detail sharpen strength will be stronger than edge. */
222    HI_U8  au8DetailCtrl[VPSS_AUTO_ISO_STRENGTH_NUM];
223    /* RW; Range: [0, 63]; Edge smooth strength. */
224    HI_U8  au8EdgeFiltStr[VPSS_AUTO_ISO_STRENGTH_NUM];
225    /* RW; Range: [0, 255]; The threshold of DetailCtrl, it is used to distinguish detail and edge. */
226    HI_U8  au8DetailCtrlThr[VPSS_AUTO_ISO_STRENGTH_NUM];
227} VPSS_GRP_SHARPEN_AUTO_ATTR_S;
228
229/* Only used for Hi3559AV100/Hi3519AV100 */
230typedef struct hiVPSS_GRP_SHARPEN_ATTR_S {
231    /* RW;  Range: [0, 1];Sharpen enable. */
232    HI_BOOL                         bEnable;
233    /* RW; Sharpen Operation mode. */
234    OPERATION_MODE_E                enOpType;
235    /* RW; Range: [0, 127]; sharpen weight based on loacal luma */
236    HI_U8                           au8LumaWgt[VPSS_YUV_SHPLUMA_NUM];
237    /* RW; Sharpen manual attribute */
238    VPSS_GRP_SHARPEN_MANUAL_ATTR_S  stSharpenManualAttr;
239    /* RW; Sharpen auto attribute */
240    VPSS_GRP_SHARPEN_AUTO_ATTR_S    stSharpenAutoAttr;
241} VPSS_GRP_SHARPEN_ATTR_S;
242
243/* Only used for Hi3519AV100 */
244typedef struct {
245    /* IES0~4 ; Range: [0, 255]; The gains of edge and texture enhancement. 0~3 for different frequency response. */
246    HI_U8  IES0, IES1, IES2, IES3;
247    /* IEDZ   ; Range: [0, 999]; The threshold to control the generated artifacts. */
248    HI_U16 IEDZ : 10, _rb_ : 6;
249} tV56aIEy;
250
251/* Only used for Hi3519AV100 */
252typedef struct {
253    /* SPN6; Range: [0,   4];  The selection of filters to be mixed for NO.6 filter. */
254    /* SFR ; Range: [0,  31];  The relative NR strength to the SFi and SFk filter. */
255    HI_U8  SPN6 : 3, SFR  : 5;
256    /* SBN6; Range: [0,   4];  The selection of filters to be mixed for NO.6 filter. */
257    /* PBR6; Range: [0,  16];  The mix ratio between SPN6 and SBN6. */
258    HI_U8  SBN6 : 3, PBR6 : 5;
259    /* SFS2, SFT2, SBR2; Range: [0, 255];  The NR strength parameters for NO.1 and NO.2 filters. */
260    HI_U8  SFS2, SFT2, SBR2;
261    /* SFS4, SFT4, SBR4; Range: [0, 255];  The NR strength parameters for NO.3 and NO.4 filters. */
262    HI_U8  SFS4, SFT4, SBR4;
263
264    /* STH1~3; Range: [0, 511]; The thresholds for protection of edges from blurring */
265    /* SFN0~3; Range: [0,   6]; Filter selection for different image areas based on STH1~3. */
266    /* NRyEn ; Range: [0,   1]; The NR switches */
267    HI_U16 STH1 : 9,  SFN1 : 3, SFN0  : 3, NRyEn : 1;
268    /* BWSF4 ; Range: [0,   1]; The NR window size for the NO.3 and NO.4 filters.  */
269    /* KMode ; Range: [0,   3]; a. Selection of SFi and SFk type filter. b.
270        The denoise mode based on image brightness. */
271    HI_U16 STH2 : 9,  SFN2 : 3, BWSF4 : 1, kMode : 3;
272    /* tEdge ; Range: [0,   3]; NR strength control mode for the image background */
273    /* Trith ; Range: [0,   1]; The switch to choose 3 STH threshold or 2 STH threshold */
274    HI_U16 STH3 : 9,  SFN3 : 3, tEdge : 2, TriTh : 1, _rb_  : 1;
275} tV56aSFy;
276
277/* Only used for Hi3519AV100 */
278typedef struct {
279    /* MADZ;   Range: [0, 999]; The blending ratio between MAI2 and MAI1 based on image statistics. */
280    /* MAI0~2; Range: [0,   3]; The three blending results between spatial and temporal filtering. */
281    HI_U16 MADZ : 10, MAI0 : 2, MAI1 : 2,  MAI2 : 2;
282    /* MADK;   Range: [0, 255]; The blending ratio between MAI2 and MAI1 based on brightness. (low limit). */
283    /* MABR;   Range: [0, 255]; The blending ratio between MAI2 and MAI1 based on brightness. (high limit). */
284    HI_U8  MADK,      MABR;
285    /* MATH;   Range: [0, 999]; The theshold for motion detection. */
286    /* MATE;   Range: [0,   8]; The motion index for smooth image area. */
287    /* MATW;   Range: [0,   3]; The motion index for prevention of motion ghost. */
288    HI_U16 MATH : 10, MATE : 4, MATW : 2;
289    /* MASW;   Range: [0,  15]; The motion index for low-frequency noises. */
290    /* MABW;   Range: [0,   4]; The window size for motion detection. */
291    /* MAXN;   Range: [0,   1]; Not for tunning. */
292    HI_U8  MASW :  4, MABW : 3, MAXN : 1, _rB_;
293} tV56aMDy;
294
295/* Only used for Hi3519AV100 */
296typedef struct {
297    /* TFS;    Range: [0,  15]; The NR strength for temporal filtering. */
298    /* TDZ;    Range: [0, 999]; Protection of the weak texture area from temporal filtering.  */
299    /* TDX;    Range: [0,   3]; Not for tuning. */
300    HI_U16 TFS : 4,  TDZ : 10, TDX : 2;
301    /* TFR[5]; Range: [0,  31]; The temoproal NR strength control for background (static) area. */
302    /* TSS;    Range: [0,  15]; The ratio for blending spatial NR with the temproal NR results. */
303    /* TSI;    Range: [0,   1]; The selection of blending filter for TSS. */
304    HI_U8  TFR[5],   TSS : 4,  TSI : 1, _rb_ : 2;
305    /* SDZ;    Range: [0, 999]; The threshold of NR control for result MAI1. */
306    /* STR;    Range: [0,  31]; The strength of NR control for result MAI1.  */
307    /* bRef;   Range: [0,   1]; The switch for temproal filtering.  */
308    HI_U16 SDZ : 10, STR : 5,  bRef : 1;
309} tV56aTFy;
310
311/* Only used for Hi3519AV100 */
312typedef struct {
313    /* SFC;    Range: [0, 255]; Spatial NR strength for the first level. */
314    /* TFC;    Range: [0,  63]; Temporal NR strength. */
315    HI_U8  SFC, _rb_ : 2, TFC : 6;
316    /* CSFS;   Range: [0, 999]; Spatial NR strength for the second level. */
317    /* CSFR;   Range: [0,  32]; Spatial NR strength control. */
318    HI_U16 CSFS : 10,    CSFR : 6;
319    /* CTFR;   Range: [0, 999]; Temporal NR strength control. */
320    /* CTFS;   Range: [0,  15]; Temporal NR filtering strength */
321    /* CIIR;   Range: [0,   1]; Spatial NR mode for the first level. */
322    HI_U16 CTFR : 11,    CTFS : 4,    CIIR : 1;
323    /* MODE;    Range: [0,  1]; The switch for new chroma denoise mode. */
324    HI_U8 MODE : 1, _rb1_ : 7;
325    /* PRESFC;    Range: [0,  32]; The strength for chroma pre spatial filter. */
326    HI_U8  PRESFC : 6, _rb2_ : 2;
327} tV56aNRc;
328
329/* Only used for Hi3519AV100 */
330typedef struct {
331    tV56aIEy IEy[2];
332    tV56aSFy SFy[4];
333    tV56aMDy MDy[2];
334    tV56aTFy TFy[2];
335    tV56aNRc NRc;
336
337    /* SBSk2[32], SDSk2[32]; Range [0, 8192];  Spatial NR strength based on brightness. */
338    HI_U16 SBSk2[32], SDSk2[32];
339    /* SBSk3[32], SDSk3[32]; Range [0, 8192];  Spatial NR strength based on brightness. */
340    HI_U16 SBSk3[32], SDSk3[32];
341} VPSS_NRX_V1_S;
342
343/* Only used for Hi3519AV100 */
344typedef struct hiVPSS_NRX_PARAM_MANUAL_V1_S {
345    VPSS_NRX_V1_S stNRXParam;
346} VPSS_NRX_PARAM_MANUAL_V1_S;
347
348/* Only used for Hi3519AV100 */
349typedef struct hiVPSS_NRX_PARAM_AUTO_V1_S {
350    HI_U32 u32ParamNum;
351    HI_U32 *pau32ISO;
352    VPSS_NRX_V1_S *pastNRXParam;
353} VPSS_NRX_PARAM_AUTO_V1_S;
354
355/* Only used for Hi3519AV100 */
356typedef struct hiVPSS_NRX_PARAM_V1_S {
357    OPERATION_MODE_E           enOptMode;           /* RW;Adaptive NR */
358    VPSS_NRX_PARAM_MANUAL_V1_S stNRXManual;         /* RW;NRX V1 param for manual video */
359    VPSS_NRX_PARAM_AUTO_V1_S   stNRXAuto;           /* RW;NRX V1 param for auto video */
360} VPSS_NRX_PARAM_V1_S;
361
362/* Only used for Hi3516CV500/Hi3516AV300/Hi3516DV300/Hi3556V200/Hi3559V200 */
363typedef struct {
364    /* IES0~4 ; Range: [0, 255]; The gains of edge and texture enhancement. 0~3 for different frequency response. */
365    HI_U8  IES0, IES1, IES2, IES3;
366    HI_U16 IEDZ : 10, _rb_ : 6;     /* IEDZ   ; Range: [0, 999]; The threshold to control the generated artifacts. */
367} tV500_VPSS_IEy;
368
369/* Only used for Hi3516CV500/Hi3516AV300/Hi3516DV300/Hi3556V200/Hi3559V200 */
370typedef struct {
371    /* SPN6; Range: [0,   5];  The selection of filters to be mixed for NO.6 filter. */
372    /* SFR ; Range: [0,  31];  The relative NR strength in the SFi and SFk filter. */
373    /* SBN6; Range: [0,   5];  The selection of filters to be mixed for NO.6 filter. */
374    /* PBR6; Range: [0,  16];  The mix ratio between SPN6 and SBN6. */
375    HI_U8  SPN6 : 3, SFR  : 5;
376    HI_U8  SBN6 : 3, PBR6 : 5;
377
378    /* JMODE;      Range: [0,   4]; The selection modes for the blending of spatial filters */
379    /* STR0, STR1; Range: [0,  16]; The blending ratio of different filters. (Used in serial filtering mode (SFM).) */
380    /* DeIdx;      Range: [3,   6]; The selection number of filters that textures and details will be added to. */
381    HI_U16 SRT0 : 5, SRT1 : 5, JMODE : 3,  DeIdx : 3;
382    /* DeRate;     Range: [0, 255]; The enhancement strength for the SFM (When DeRate > 0, the SFM will be activated) */
383    /* SFR6;       Range: [0,  31]; The relative NR strength for NO.6 filter. (Effective when JMODE = 4) */
384    HI_U8  DeRate, SFR6[3];
385
386    /* SFS1, SFT1, SBR1; Range: [0, 255];  The NR strength parameters for NO.1 filter. */
387    /* SFS2, SFT2, SBR2; Range: [0, 255];  The NR strength parameters for NO.2 filter. */
388    /* SFS4, SFT4, SBR4; Range: [0, 255];  The NR strength parameters for NO.3 and NO.4 filters. */
389    HI_U8  SFS1,  SFT1,  SBR1;
390    HI_U8  SFS2,  SFT2,  SBR2;
391    HI_U8  SFS4,  SFT4,  SBR4;
392
393    /* STH1~3; Range: [0, 511]; The thresholds for protection of edges from blurring */
394    /* NRyEn ; Range: [0,   1]; The NR switches */
395    /* SFN0~3; Range: [0,   6]; Filter selection for different image areas based on STH1~3. */
396    /* BWSF4 ; Range: [0,   1]; The NR window size for the NO.3 and NO.4 filters.  */
397    /* KMode ; Range: [0,   3]; The denoise mode based on image brightness. */
398    /* Trith ; Range: [0,   1]; The switch to choose 3 STH threshold or 2 STH threshold */
399    HI_U16 STH1 : 9, SFN1 : 3, SFN0  : 3, NRyEn : 1;
400    HI_U16 STH2 : 9, SFN2 : 3, BWSF4 : 1, kMode : 3;
401    HI_U16 STH3 : 9, SFN3 : 3, TriTh : 1, _rb0_ : 3;
402
403    /* SBSk[32], SDSk[32]; Range [0, 8191];  Spatial NR strength based on brightness. */
404    HI_U16 SBSk[32], SDSk[32];
405} tV500_VPSS_SFy;
406
407/* Only used for Hi3516CV500/Hi3516AV300/Hi3516DV300/Hi3556V200/Hi3559V200 */
408typedef struct {
409    /* MADZ0, MADZ1;     Range: [0, 511]; The blending ratio between MAI2 and MAI1 based on image statistics. */
410    /* MAI00~02,MAI10~12 Range: [0,   3]; The three blending results between spatial and temporal filtering. */
411    /* MABR0, MABR1;  Range: [0, 255]; The blending ratio between MAI2 and MAI1 based on brightness.  */
412    /* biPath;           Range: [0,   1]; The switch for single path or dual path. 0: single path; 1: dual path. */
413    HI_U16 MADZ0   : 9,  MAI00    : 2,  MAI01  : 2,  MAI02    : 2,  biPath  : 1;
414    HI_U16 MADZ1   : 9,  MAI10    : 2,  MAI11  : 2,  MAI12    : 2,  _rb0_ : 1;
415    HI_U8  MABR0, MABR1;
416
417    /* MATH0,MATH1;   Range: [0, 999]; The theshold for motion detection.
418        specially for Hi3556V200/Hi3559V200 Range: [0,  511] */
419    /* MATE0,MATE1;   Range: [0,   8]; The motion index for smooth image area. */
420    /* MATW;   Range: [0,   3]; The motion index for prevention of motion ghost. */
421    HI_U16 MATH0   : 10,  MATE0   : 4,  MATW   : 2;
422    HI_U16 MATH1   : 10,  MATE1   : 4,  _rb1_  : 2;
423
424    /* MASW;   Range: [0,  15]; The motion index for low-frequency noises. */
425    /* MABW0,MABW1;   Range: [0,   9]; The window size for motion detection. */
426    HI_U8  MASW    :  4,  _rb2_   : 4;
427    HI_U8  MABW0   :  4,  MABW1   : 4;
428} tV500_VPSS_MDy;
429
430/* Only used for Hi3516CV500/Hi3516AV300/Hi3516DV300/Hi3556V200/Hi3559V200 */
431typedef struct {
432    /* TFS0,TFS1;        Range: [0,  15]; The NR strength for temporal filtering.
433        specially for Hi3556V200/Hi3559V200 Range: [0,  10] */
434    /* TDZ0,TDZ1;        Range: [0, 999]; Protection of the weak texture area from temporal filtering.  */
435    /* TDX0,TDX1;        Range: [0,   3]; Not for tuning. */
436    HI_U16 TFS0  :  4, TDZ0   : 10, TDX0    : 2;
437    HI_U16 TFS1  :  4, TDZ1   : 10, TDX1    : 2;
438
439    /* SDZ0,SDZ1;        Range: [0, 999]; The threshold of NR control for result MAI1. */
440    /* STR0,STR1;        Range: [0,  31]; The strength of NR control for result MAI1.  */
441    /* DZMode0, DZMode1; Range: [0,   1]; The selection mode for TDZ0 and TDZ1, respectively.  */
442    HI_U16 SDZ0  : 10, STR0   : 5,  DZMode0 : 1;
443    HI_U16 SDZ1  : 10, STR1   : 5,  DZMode1 : 1;
444
445    /* TFR0,TFR1;        Range: [0,  31]; The temoproal NR strength control for background (static) area. */
446    /* TSS0,TSS1;        Range: [0,  15]; The ratio for blending spatial NR with the temproal NR results. */
447    /* TSI0,TSI1;        Range: [0,   1]; The selection of blending filter for TSS. */
448    HI_U8  TFR0[6],    TSS0   : 4,  TSI0    : 4;
449    HI_U8  TFR1[6],    TSS1   : 4,  TSI1    : 4;
450
451    /* tEdge;            Range: [0,   3]; NR strength control mode for the updating background. */
452    /* RFI;              Range: [0,   4]; Reference mode. (used in when NR_MOTION_MODE_COMPENSATE are selected). */
453    /* bRef;             Range: [0,   1]; The Switch for temproal filtering. */
454    HI_U8  RFI   : 3,  tEdge  : 2,  bRef    : 1,  _rb_ : 2;
455} tV500_VPSS_TFy;
456
457/* Only used for Hi3516CV500/Hi3516AV300/Hi3516DV300/Hi3556V200/Hi3559V200 */
458typedef struct {
459    /* advMATH;        Range: [0,   1]; The Switch for advanced motion dection.  */
460    /* RFUI;           Range: [0,   4]; The modes for updating reference for NRy leve 2,
461        (used in when NR_MOTION_MODE_COMPENSATE are selected). */
462    HI_U16 advMATH : 1, RFDZ  : 9,    _rb_ : 6;
463    /* RFDZ;           Rnage: [0, 511]; The threshold for RFI0 and RFI1 mode 3 and 4. */
464    /* RFSLP;          Rnage: [0,  31]; The Strength for RFI0 and RFI1 mode 3 and 4. */
465    HI_U8  RFUI    : 3, RFSLP : 5;
466} tV500_VPSS_RFs;
467
468/* Only used for Hi3516CV500/Hi3516AV300/Hi3516DV300/Hi3556V200/Hi3559V200 */
469typedef struct {
470    tV500_VPSS_IEy  IEy;
471    tV500_VPSS_SFy  SFy;
472    HI_U8 NRcEn : 1, _rb_ : 7;
473} tV500_VPSS_NRc;
474
475/* Only used for Hi3516CV500/Hi3516AV300/Hi3516DV300/Hi3556V200/Hi3559V200 */
476typedef struct {
477    /* SFC;    Range: [0, 255]; Spatial NR strength. */
478    HI_U8  SFC;
479    /* TFC;    Range: [0,  63]; Temporal NR strength relative to Spatial NR. */
480    /* CTFS;   Range: [0,  15]; Absolute temporal NR strength. */
481    HI_U16 CTFS : 4, TFC : 6, _rb_ : 6;
482    /* MODE;    Range: [0,  1]; The switch for new chroma denoise mode. */
483    HI_U8 MODE : 1, _rb1_ : 7;
484    /* PRESFC;    Range: [0,  32]; The strength for chroma pre spatial filter. */
485    HI_U8  PRESFC : 6, _rb2_ : 2;
486} tV500_VPSS_pNRc;
487
488/* Only used for Hi3516CV500/Hi3516AV300/Hi3516DV300/Hi3556V200/Hi3559V200 */
489typedef struct {
490    tV500_VPSS_IEy  IEy[3];
491    tV500_VPSS_SFy  SFy[3];
492    tV500_VPSS_MDy  MDy[2];
493    tV500_VPSS_RFs  RFs;
494    tV500_VPSS_TFy  TFy[2];
495    tV500_VPSS_pNRc pNRc;
496    tV500_VPSS_NRc  NRc;
497} VPSS_NRX_V2_S;
498
499/* Only used for Hi3516CV500/Hi3516AV300/Hi3516DV300/Hi3556V200/Hi3559V200 */
500typedef struct hiVPSS_NRX_PARAM_MANUAL_V2_S {
501    VPSS_NRX_V2_S stNRXParam;
502} VPSS_NRX_PARAM_MANUAL_V2_S;
503
504/* Only used for Hi3516CV500/Hi3516AV300/Hi3516DV300/Hi3556V200/Hi3559V200 */
505typedef struct hiVPSS_NRX_PARAM_AUTO_V2_S {
506    HI_U32 u32ParamNum;
507    HI_U32 *pau32ISO;
508    VPSS_NRX_V2_S *pastNRXParam;
509} VPSS_NRX_PARAM_AUTO_V2_S;
510
511/* Only used for Hi3516CV500/Hi3516AV300/Hi3516DV300/Hi3556V200/Hi3559V200 */
512typedef struct hiVPSS_NRX_PARAM_V2_S {
513    OPERATION_MODE_E           enOptMode;           /* RW;Adaptive NR */
514    VPSS_NRX_PARAM_MANUAL_V2_S stNRXManual;         /* RW;NRX V2 param for manual video */
515    VPSS_NRX_PARAM_AUTO_V2_S   stNRXAuto;           /* RW;NRX V2 param for auto video */
516} VPSS_NRX_PARAM_V2_S;
517
518/* Only used for Hi3516EV200 */
519typedef struct {
520    /* IES0~4 ; Range: [0, 255]; The gains of edge and texture enhancement. 0~3 for different frequency response. */
521    HI_U8  IES0, IES1, IES2, IES3;
522    /* IEDZ   ; Range: [0, 999]; The threshold to control the generated artifacts. */
523    HI_U16  IEDZ : 10, IEEn : 1, _rb_ : 5;
524} tV200_VPSS_IEy;
525
526/* Only used for Hi3516EV200 */
527typedef struct {
528    HI_U8  SPN6 : 3, SFR  : 5;                                      /* SPN6, SBN6:  [0, 5]; */
529
530    HI_U8  SBN6 : 3, PBR6 : 5;                                    /* SFR: [0,31];  PBR6: [0,15]; */
531
532    /* JMODE;      Range: [0,   4]; The selection modes for the blending of spatial filters */
533    /* STR0, STR1; Range: [0,  16]; The blending ratio of different filters. (Used in serial filtering mode (SFM).) */
534    /* DeIdx;      Range: [3,   6]; The selection number of filters that textures and details will be added to. */
535    HI_U16  SRT0 : 5, SRT1 : 5, JMODE : 3, DeIdx : 3;
536
537    /* DeRate;     Range: [0, 255]; The enhancement strength for the SFM (When DeRate > 0, the SFM will be activated) */
538    /* SFR6[4];    Range: [0,  31]; The relative NR strength for NO.6 filter. (Effective when JMODE = 4) */
539    /* SBR6[2];    Range: [0,  15]; The control of overshoot and undershoot. */
540    HI_U8  SFR6[4], SBR6[2], DeRate;
541
542    /* SFS1, SFT1, SBR1; Range: [0, 255];  The NR strength parameters for NO.1 filter. */
543    HI_U8  SFS1,  SFT1,  SBR1;
544    /* SFS2, SFT2, SBR2; Range: [0, 255];  The NR strength parameters for NO.2 filter. */
545    HI_U8  SFS2,  SFT2,  SBR2;
546    /* SFS4, SFT4, SBR4; Range: [0, 255];  The NR strength parameters for NO.3 and NO.4 filters. */
547    HI_U8  SFS4,  SFT4,  SBR4;
548
549    /* STH1, STH2, STHd1, STHd2; Range: [0, 511]; The thresholds for protection of edges from blurring */
550    /* NRyEn;      Range: [0,   1]; The NR switches */
551    /* SFN0~2;     Range: [0,   6]; Filter selection for different image areas based on STH1~3. */
552    /* KMode ;     Range: [0,   3]; The denoise mode based on image brightness. */
553    /* SBSk[32], SDSk[32]; Range [0, 8191];  Spatial NR strength based on brightness. */
554    HI_U16  STH1 : 9,  SFN1 : 3, SFN0  : 3, NRyEn   : 1;
555    HI_U16  STHd1 : 9, _rb0_ : 7;
556    HI_U16  STH2 : 9,  SFN2 : 3, kMode : 3, _rb1_   : 1;
557    HI_U16  STHd2 : 9, _rb2_ : 7;
558    HI_U16  SBSk[32], SDSk[32];
559} tV200_VPSS_SFy;
560
561/* Only used for Hi3516EV200 */
562typedef struct {
563    /* TFS0,TFS1;          Range: [0,  15]; The NR strength for temporal filtering. */
564    /* TDZ0,TDZ1;          Range: [0, 999]; Protection of the weak texture area from temporal filtering.  */
565    /* TDX0,TDX1;          Range: [0,   3]; Not for tuning. */
566    HI_U16  TFS0 : 4,   TDZ0 : 10,  TDX0    : 2;
567    HI_U16  TFS1 : 4,   TDZ1 : 10,  TDX1    : 2;
568
569    /* SDZ0,SDZ1;          Range: [0, 999]; The threshold of NR control for result MAI1. */
570    /* STR0,STR1;          Range: [0,  31]; The strength of NR control for result MAI1.  */
571    /* DZMode0, DZMode1;   Range: [0,   1]; The selection mode for TDZ0 and TDZ1, respectively.  */
572    HI_U16  SDZ0 : 10,  STR0 : 5,   DZMode0 : 1;
573    HI_U16  SDZ1 : 10,  STR1 : 5,   DZMode1 : 1;
574
575    /* TFR0,TFR1;          Range: [0,  31]; The temoproal NR strength control for background (static) area. */
576    /* TSS0,TSS1;          Range: [0,  15]; The ratio for blending spatial NR with the temproal NR results. */
577    /* TSI0,TSI1;          Range: [0,   1]; The selection of blending filter for TSS. */
578    HI_U8  TSS0 : 4,   TSI0 : 4,  TFR0[6];
579    HI_U8  TSS1 : 4,   TSI1 : 4,  TFR1[6];
580
581    /* TED;  Range: [0,   3]; NR strength control mode for the updating background. */
582    /* bRef;   Range: [0,   1]; The Switch for temproal filtering.  */
583    /* TFRS;   Range: [0,  15]; Spatial filtering strength for static area. */
584    HI_U8  TFRS : 4,   TED  : 2,   bRef    : 1,  _rb_ : 1;
585} tV200_VPSS_TFy;
586
587/* Only used for Hi3516EV200 */
588typedef struct {
589    /* PATH0 */
590    /* MADZ0, MADZ1;     Range: [0, 511]; The blending ratio between MAI2 and MAI1 based on image statistics. */
591    /* MAI00~02,MAI10~12 Range: [0,   3]; The three blending results between spatial and temporal filtering. */
592    HI_U16  MADZ0   : 9,   MAI00 : 2,  MAI01  : 2, MAI02 : 2, _rb0_ : 1;
593    HI_U16  MADZ1   : 9,   MAI10 : 2,  MAI11  : 2, MAI12 : 2, _rb1_ : 1;
594    /* MABR0, MABR1;     Range: [0, 255]; The blending ratio between MAI2 and MAI1 based on brightness.  */
595    HI_U8  MABR0, MABR1;
596
597    /* MATH0,MATH1, MATHd0, MATHd1;     Range: [0, 999]; The theshold for motion detection. */
598    /* MATE0,MATE1;   Range: [0,   8]; The motion index for smooth image area. */
599    /* MATW;          Range: [0,   3]; The motion index for prevention of motion ghost. */
600    /* MASW;          Range: [0,  15]; The motion index for low-frequency noises. */
601    /* MABW0,MABW1;   Range: [0,   9]; The window size for motion detection. */
602    HI_U16  MATH0   : 10,  MATE0 : 4,  MATW   : 2;
603    HI_U16  MATHd0  : 10,  _rb2_ : 6;
604    HI_U16  MATH1   : 10,  _rb3_ : 6;
605    HI_U16  MATHd1  : 10,  _rb4_ : 6;
606    HI_U8  MASW    :  4,  MATE1 : 4;
607    HI_U8  MABW0   :  4,  MABW1 : 4;
608
609    /* AdvMATH:  Range: [0, 1]; The switch to active the advanced mode. */
610    /* AdvTH:    Range: [0, 999]; The threshold to control the effects of the AdvMATH. */
611    HI_U16  AdvMATH : 1,   AdvTH : 12, _rb5_  : 3;
612} tV200_VPSS_MDy;
613
614/* Only used for Hi3516EV200 */
615typedef struct {
616    /* SFC;    Range: [0, 255]; Spatial NR strength. */
617    /* TFC;    Range: [0,  32]; Temporal NR strength relative to Spatial NR. */
618    HI_U8  SFC, TFC : 6, _rb0_ : 2;
619    /* TRC;    Range: [0, 255]; Control of color bleeding in */
620    /* TPC;    Range: [0,  32]; Type of temporal NR. */
621    HI_U8  TRC, TPC : 6, _rb1_ : 2;
622    /* MODE;    Range: [0,  1]; The switch for new chroma denoise mode. */
623    HI_U8 MODE : 1, _rb2_ : 7;
624    /* PRESFC;    Range: [0,  32]; The strength for chroma pre spatial filter. */
625    HI_U8  PRESFC : 6, _rb3_ : 2;
626} tV200_VPSS_NRc;
627
628/* Only used for Hi3516EV200 */
629typedef struct {
630    tV200_VPSS_IEy  IEy[5];
631    tV200_VPSS_SFy  SFy[5];
632    tV200_VPSS_MDy  MDy[2];
633    tV200_VPSS_TFy  TFy[3];
634    tV200_VPSS_NRc  NRc;
635} VPSS_NRX_V3_S;
636
637/* Only used for Hi3516EV200 */
638typedef struct hiVPSS_NRX_PARAM_MANUAL_V3_S {
639    VPSS_NRX_V3_S stNRXParam;
640} VPSS_NRX_PARAM_MANUAL_V3_S;
641
642/* Only used for Hi3516EV200 */
643typedef struct hiVPSS_NRX_PARAM_AUTO_V3_S {
644    HI_U32 u32ParamNum;
645    HI_U32 *pau32ISO;
646    VPSS_NRX_V3_S *pastNRXParam;
647} VPSS_NRX_PARAM_AUTO_V3_S;
648
649/* Only used for Hi3516EV200 */
650typedef struct hiVPSS_NRX_PARAM_V3_S {
651    OPERATION_MODE_E           enOptMode;           /* RW;Adaptive NR */
652    VPSS_NRX_PARAM_MANUAL_V3_S stNRXManual;         /* RW;NRX V3 param for manual video */
653    VPSS_NRX_PARAM_AUTO_V3_S   stNRXAuto;           /* RW;NRX V3 param for auto video */
654} VPSS_NRX_PARAM_V3_S;
655
656/* Not support for Hi3559AV100 */
657typedef enum hiVPSS_NR_VER_E {
658    VPSS_NR_V1 = 1,
659    VPSS_NR_V2 = 2,
660    VPSS_NR_V3 = 3,
661    VPSS_NR_V4 = 4,
662    VPSS_NR_BUTT
663} VPSS_NR_VER_E;
664
665/* Not support for Hi3559AV100 */
666typedef struct hiVPSS_GRP_NRX_PARAM_S {
667    VPSS_NR_VER_E enNRVer;
668    union {
669        VPSS_NRX_PARAM_V1_S stNRXParam_V1;   /* interface X V1 for Hi3519AV100 */
670        VPSS_NRX_PARAM_V2_S stNRXParam_V2;   /* interface X V2 for Hi3516CV500 */
671        VPSS_NRX_PARAM_V3_S stNRXParam_V3;   /* interface X V3 for Hi3516EV200 */
672    };
673} VPSS_GRP_NRX_PARAM_S;
674
675typedef struct hiVPSS_CHN_BUF_WRAP_S {
676    HI_BOOL bEnable;
677    HI_U32  u32BufLine;             /* RW; Range: [128, H]; Chn buffer allocated by line. */
678    HI_U32  u32WrapBufferSize; /* RW; Whether to allocate buffer according to compression. */
679} VPSS_CHN_BUF_WRAP_S;
680
681typedef enum hiVPSS_SPLIT_PRIORITY_E {
682    VPSS_SPLIT_PRIORITY_MEMORY = 0,
683    VPSS_SPLIT_PRIORITY_POWER = 1,
684    VPSS_SPLIT_PRIORITY_BUTT
685} VPSS_SPLIT_PRIORITY_E;
686
687typedef struct hiVPSS_PARAM_MOD_S {
688    HI_BOOL bOneBufForLowDelay;
689    HI_U32  u32VpssSplitNodeNum;
690    HI_BOOL bHdrSupport;
691    HI_BOOL bNrQuickStart;
692    VPSS_SPLIT_PRIORITY_E enSplitPriority;
693    HI_BOOL bRotationInputSupport;
694} VPSS_MOD_PARAM_S;
695
696typedef enum hiVPSS_CHN_PROC_MODE_E {
697    VPSS_CHN_PROC_MODE_VIDEO = 0,
698    VPSS_CHN_PROC_MODE_SNAP = 1,
699    VPSS_CHN_PROC_MODE_BUTT
700} VPSS_CHN_PROC_MODE_E;
701
702#ifdef __cplusplus
703#if __cplusplus
704}
705#endif
706#endif /* __cplusplus */
707#endif /* __HI_COMM_VPSS_H__ */
708
709