hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*
 * Copyright 2021 Rockchip Electronics Co. LTD
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
 
#ifndef INCLUDE_RT_MPI_RK_COMM_RGN_H__
#define INCLUDE_RT_MPI_RK_COMM_RGN_H__
 
#include "rk_common.h"
#include "rk_comm_video.h"
#include "rk_errno.h"
 
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* End of #ifdef __cplusplus */
 
typedef RK_U32 RGN_HANDLE;
 
#define RGN_CLUT_NUM                   256
#define RGN_MAX_BUF_NUM                2
 
#define RGN_MIN_WIDTH                  16
#define RGN_MIN_HEIGHT                 16
 
#define RGN_COVER_MIN_X                0
#define RGN_COVER_MIN_Y                0
#define RGN_COVER_MAX_X                8192
#define RGN_COVER_MAX_Y                8192
#define RGN_COVER_MAX_WIDTH            8192
#define RGN_COVER_MAX_HEIGHT           8192
 
#define RGN_OVERLAY_MIN_X              0
#define RGN_OVERLAY_MIN_Y              0
#define RGN_OVERLAY_MAX_X              8192
#define RGN_OVERLAY_MAX_Y              8192
#define RGN_OVERLAY_MAX_WIDTH          8192
#define RGN_OVERLAY_MAX_HEIGHT         8192
 
#define RGN_MOSAIC_MIN_X               0
#define RGN_MOSAIC_MIN_Y               0
#define RGN_MOSAIC_MAX_X               8192
#define RGN_MOSAIC_MAX_Y               8192
#define RGN_MOSAIC_MIN_WIDTH           32
#define RGN_MOSAIC_MIN_HEIGHT          32
#define RGN_MOSAIC_MAX_WIDTH           8192
#define RGN_MOSAIC_MAX_HEIGHT          8192
 
/* type of video regions */
typedef enum rkRGN_TYPE_E {
    OVERLAY_RGN = 0,     /* video overlay region */
    COVER_RGN,
    MOSAIC_RGN,
    RGN_BUTT
} RGN_TYPE_E;
 
/* overlay regions qp info (only support to venc) */
typedef struct rkOVERLAY_QP_INFO {
    /* qp protect is enable */
    RK_BOOL bEnable;
    /* is abs qp, RK_TRUE: overlay regions set to the qp; RK_FALSE: regions set around the qp. */
    RK_BOOL bAbsQp;
    /* flag of forced intra macroblock */
    RK_BOOL bForceIntra;
    /* absolute / relative qp of macroblock */
    RK_S32 s32Qp;
} OVERLAY_QP_INFO_S;
 
typedef struct rkOVERLAY_ATTR_S {
    /* bitmap pixel format,now only support BGRA5551 or ARGB8888 */
    PIXEL_FORMAT_E enPixelFmt;
    /* region size,W:[16,RGN_OVERLAY_MAX_WIDTH],align:16,H:[16,RGN_OVERLAY_MAX_HEIGHT],align:16 */
    SIZE_S stSize;
    RK_U32 u32CanvasNum; /* canvas number, default 2. */
    /* color loop up table number, default 0. range:[0, RGN_CLUT_NUM) */
    RK_U32 u32ClutNum;
    /* color loop up table, only support BGRA8888 format now. */
    RK_U32 u32Clut[RGN_CLUT_NUM];
} OVERLAY_ATTR_S;
 
typedef struct rkOVERLAY_CHN_ATTR_S {
    /* X:[0,OVERLAY_MAX_X_VENC],align:16,Y:[0,OVERLAY_MAX_Y_VENC],align:16 */
    POINT_S stPoint;
 
    /* background an foreground transparence when pixel format is BGRA5551
      * the pixel format is BGRA5551,when the alpha bit is 1 this alpha is value!
      * range:[0,255]
      */
    RK_U32 u32FgAlpha;
 
    /* background an foreground transparence when pixel format is BGRA5551
      * the pixel format is BGRA5551,when the alpha bit is 0 this alpha is value!
      * range:[0,255]
      */
    RK_U32 u32BgAlpha;
 
    RK_U32 u32Layer;   /* OVERLAY region layer range:[0,7]*/
 
    /* overlay regions qp info (only support to venc) */
    OVERLAY_QP_INFO_S stQpInfo;
} OVERLAY_CHN_ATTR_S;
 
typedef enum rkRGN_COORDINATE_E {
    RGN_ABS_COOR = 0,   /*Absolute coordinate*/
    RGN_RATIO_COOR      /*Ratio coordinate*/
} RGN_COORDINATE_E;
 
typedef struct rkCOVER_CHN_ATTR_S {
    RECT_S stRect;                          /* config of rect */
    RK_U32 u32Color;                        /* RGB888 format */
    RK_U32 u32Layer;                        /* COVER region layer */
    RGN_COORDINATE_E enCoordinate;          /* ratio coordiante or abs coordinate */
} COVER_CHN_ATTR_S;
 
typedef enum rkMOSAIC_BLK_SIZE_E {
    MOSAIC_BLK_SIZE_8 = 0,    /*block size 8*8 of MOSAIC*/
    MOSAIC_BLK_SIZE_16,       /*block size 16*16 of MOSAIC*/
    MOSAIC_BLK_SIZE_32,       /*block size 32*32 of MOSAIC*/
    MOSAIC_BLK_SIZE_64,       /*block size 64*64 of MOSAIC*/
    MOSAIC_BLK_SIZE_BUTT
} MOSAIC_BLK_SIZE_E;
 
typedef struct rkMOSAIC_CHN_ATTR_S {
    RECT_S stRect;                 /*location of MOSAIC*/
    MOSAIC_BLK_SIZE_E enBlkSize;   /*block size of MOSAIC*/
    RK_U32 u32Layer;               /*MOSAIC region layer range:[0,3] */
} MOSAIC_CHN_ATTR_S;
 
typedef union rkRGN_ATTR_U {
    OVERLAY_ATTR_S      stOverlay;      /* attribute of overlay region */
} RGN_ATTR_U;
 
typedef union rkRGN_CHN_ATTR_U {
    OVERLAY_CHN_ATTR_S      stOverlayChn;      /* attribute of overlay region */
    COVER_CHN_ATTR_S        stCoverChn;        /* attribute of cover region */
    MOSAIC_CHN_ATTR_S       stMosaicChn;       /* attribute of mosic region */
} RGN_CHN_ATTR_U;
 
/* attribute of a region */
typedef struct rkRGN_ATTR_S {
    RGN_TYPE_E enType;  /* region type */
    RGN_ATTR_U unAttr;  /* region attribute */
} RGN_ATTR_S;
 
/* attribute of a region */
typedef struct rkRGN_CHN_ATTR_S {
    RK_BOOL           bShow;
    RGN_TYPE_E        enType;     /* region type */
    RGN_CHN_ATTR_U    unChnAttr;  /* region attribute */
} RGN_CHN_ATTR_S;
 
typedef struct rkRGN_CANVAS_INFO_S {
    MB_BLK canvasBlk;
    RK_U64 u64VirAddr;
    SIZE_S stSize;
    RK_U32 u32VirWidth;
    RK_U32 u32VirHeight;
    PIXEL_FORMAT_E enPixelFmt;
} RGN_CANVAS_INFO_S;
 
/* PingPong buffer change when set attr, it needs to remap memory in mpi interface */
#define RK_NOTICE_RGN_BUFFER_CHANGE  RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_NOTICE, RK_SUCCESS)
 
/* invlalid device ID */
#define RK_ERR_RGN_INVALID_DEVID     RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_INVALID_DEVID)
/* invlalid channel ID */
#define RK_ERR_RGN_INVALID_CHNID     RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_INVALID_CHNID)
/* at lease one parameter is illagal ,eg, an illegal enumeration value  */
#define RK_ERR_RGN_ILLEGAL_PARAM     RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_ILLEGAL_PARAM)
/* channel exists */
#define RK_ERR_RGN_EXIST             RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_EXIST)
/*UN exist*/
#define RK_ERR_RGN_UNEXIST           RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_UNEXIST)
/* using a NULL point */
#define RK_ERR_RGN_NULL_PTR          RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_NULL_PTR)
/* try to enable or initialize system,device or channel, before configing attribute */
#define RK_ERR_RGN_NOT_CONFIG        RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_CONFIG)
/* operation is not supported by NOW */
#define RK_ERR_RGN_NOT_SUPPORT       RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_SUPPORT)
/* operation is not permitted ,eg, try to change stati attribute */
#define RK_ERR_RGN_NOT_PERM          RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_PERM)
/* failure caused by malloc memory */
#define RK_ERR_RGN_NOMEM             RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_NOMEM)
/* failure caused by malloc buffer */
#define RK_ERR_RGN_NOBUF             RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_NOBUF)
/* no data in buffer */
#define RK_ERR_RGN_BUF_EMPTY         RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_BUF_EMPTY)
/* no buffer for new data */
#define RK_ERR_RGN_BUF_FULL          RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_BUF_FULL)
/* bad address, eg. used for copy_from_user & copy_to_user */
#define RK_ERR_RGN_BADADDR           RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_BADADDR)
/* resource is busy, eg. destroy a venc chn without unregistering it */
#define RK_ERR_RGN_BUSY              RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_BUSY)
/* System is not ready,maybe not initialed or loaded.
 * Returning the error code when opening a device file failed.
 */
#define RK_ERR_RGN_NOTREADY          RK_DEF_ERR(RK_ID_RGN, RK_ERR_LEVEL_ERROR, RK_ERR_NOTREADY)
 
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
 
#endif /* INCLUDE_RT_MPI_RK_COMM_RGN_H__ */