• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef HI_GO_ENCODER_H
16 #define HI_GO_ENCODER_H
17 
18 #include "hi_go_comm.h"
19 
20 #ifdef __cplusplus
21 #if __cplusplus
22 extern "C" {
23 #endif  /* __cplusplus */
24 #endif  /* __cplusplus */
25 
26 /* Encoder attributes */
27 typedef struct {
28     HIGO_IMGTYPE_E ExpectType; /*
29                                 * Type of the encoded picture
30                                 *
31                                 */
32     HI_U32 QualityLevel;       /*
33                                 * The quality level ranges from 1 to 99. The higher the level, the better the quality,
34                                 * and the greater the encoded picture or occupied memory. The QualityLevel parameter
35                                 * is valid for .jpeg pictures only.
36                                 *
37                                 */
38 } HIGO_ENC_ATTR_S;
39 
40 /*
41  * \brief Initializes the encoder.
42  * \attention \n
43  * When ::HI_GO_Init is called, this application programming interface (API) is also called.
44  *
45  * \param  N/A
46  * \retval ::HI_SUCCESS
47  * \retval ::HI_FAILURE
48  * \retval ::HIGO_ERR_DEPEND_TDE
49  * \see \n
50  * ::HI_GO_Init \n
51  * ::HI_GO_DeinitDecoder
52  */
53 HI_S32 HI_GO_InitEncoder(HI_VOID);
54 
55 /*
56  * \brief Deinitializes the encoder.
57  * \attention \n
58  * When ::HI_GO_Deinit is called, this API is also called.
59  *
60  * \param  N/A
61  * \retval ::HI_SUCCESS
62  * \retval ::HIGO_ERR_NOTINIT
63  * \see \n
64  * ::HI_GO_Deinit \n
65  * ::HI_GO_InitDecoder
66  */
67 HI_S32 HI_GO_DeinitEncoder(HI_VOID);
68 
69 /*
70  * \brief Encodes a surface in a specified format, and saves the encoded surface in a file.
71  *
72  * \attention \n
73  * The .bmp encoding format is supported.
74  * The hardware platform determines whether the .jpeg encoding format is supported.
75  *
76  * (Ƿֱ֧JPEG,ȡӲƽ̨) CNend
77  * \param[in] hSurface Surface to be encoded.
78  * \param[in] pFile  Name of the encoded file. This parameter can be empty. If this parameter is not set, the 2nd file
79  *                   is named [year]-[month]-[date]-[hour]-[minute]-[second].
80  *
81  * \param[in] pAttr  Encoding attributes. This parameter cannot be empty.
82  * \retval ::HI_SUCCESS Success.
83  * \retval ::HI_FAILURE
84  * \retval ::HIGO_ERR_NULLPTR
85  * \retval ::HIGO_ERR_INVHANDLE
86  * \retval ::HIGO_ERR_UNSUPPORTED
87  * \retval ::HIGO_ERR_NOMEM
88  * \retval ::HIGO_ERR_INVFILE
89  * \retval ::HIGO_ERR_INVSRCTYPE
90  * \retval ::HIGO_ERR_INVIMAGETYPE
91  * \retval ::HIGO_ERR_INVPARAM
92  * \retval ::HIGO_ERR_INVMIRRORTYPE
93  * \retval ::HIGO_ERR_INVROTATETYPE
94  * \retval ::HIGO_ERR_INVCKEYTYPE
95  * \retval ::HIGO_ERR_INVROPTYPE
96  * \retval ::HIGO_ERR_NOCOLORKEY
97  * \retval ::HIGO_ERR_INVPIXELFMT
98  * \retval ::HIGO_ERR_INVHANDLE
99  * \retval ::HIGO_ERR_INVCOMPTYPE
100  * \retval ::HIGO_ERR_LOCKED
101  * \retval ::HIGO_ERR_DEPEND_TDE
102  * \retval ::HIGO_ERR_EMPTYRECT
103  * \retval ::HIGO_ERR_OUTOFBOUNDS
104  * \retval ::HIGO_ERR_INTERNAL
105  * \retval ::HIGO_ERR_DEPEND_JPGE
106  * \see \n
107  */
108 HI_S32 HI_GO_EncodeToFile(HI_HANDLE hSurface, const HI_CHAR* pFile, const HIGO_ENC_ATTR_S* pAttr);
109 
110 /*
111  * \brief Encodes a surface in a specified picture format and saves it in a memory.
112  *  Ensure that the memory is sufficient.
113  *
114  * \attention \n
115  * The data can be encoded as .bmp data, and saved in a specified memory.
116  * The hardware platform determines whether the .jpeg encoding format is supported.
117  *
118  * (Ƿֱ֧JPEG,ȡӲƽ̨) CNend
119  * \param[in] hSurface  Surface to be encoded.
120  * \param[in] pMem      Start address of the memory for storing the encoded pictures.
121  *                      ʼַ CNend
122  * \param[in] MemLen    Size of a specified memory.
123  * \param[out] pOutLen  Actual size of the used memory, indicating the length of encoded data. Ensure that the value of
124  *                      pOutLen is smaller than or equal to the value of MemLen.
125  *
126  * \param[in] pAttr     Encoding attributes. This parameter cannot be empty.
127  * \retval ::HI_SUCCESS
128  * \retval ::HI_FAILURE
129  * \retval ::HIGO_ERR_NULLPTR
130  * \retval ::HIGO_ERR_INVHANDLE
131  * \retval ::HIGO_ERR_UNSUPPORTED
132  * \retval ::HIGO_ERR_NOMEM
133  * \retval ::HIGO_ERR_INVFILE
134  * \retval ::HIGO_ERR_INVSRCTYPE
135  * \retval ::HIGO_ERR_INVFILE
136  * \retval ::HIGO_ERR_INVIMAGETY
137  * \retval ::HIGO_ERR_INVIMAGETYPE
138  * \retval ::HIGO_ERR_INVPARAM
139  * \retval ::HIGO_ERR_INVMIRRORTYPE
140  * \retval ::HIGO_ERR_INVROTATETYPE
141  * \retval ::HIGO_ERR_INVCKEYTYPE
142  * \retval ::HIGO_ERR_INVROPTYPE
143  * \retval ::HIGO_ERR_NOCOLORKEY
144  * \retval ::HIGO_ERR_INVPIXELFMT
145  * \retval ::HIGO_ERR_INTERNAL
146  * \retval ::HIGO_ERR_INVHANDLE
147  * \retval ::HIGO_ERR_INVCOMPTYPE
148  * \retval ::HIGO_ERR_LOCKED
149  * \retval ::HIGO_ERR_DEPEND_TDE
150  * \retval ::HIGO_ERR_EMPTYRECT
151  * \retval ::HIGO_ERR_OUTOFBOUNDS
152  * \retval ::HIGO_ERR_DEPEND_JPGE
153  * \see \n
154  */
155 HI_S32 HI_GO_EncodeToMem(HI_HANDLE hSurface, HI_U8* pMem, HI_U32 MemLen, HI_U32* pOutLen, const HIGO_ENC_ATTR_S* pAttr);
156 
157 #ifdef __cplusplus
158 #if __cplusplus
159 }
160 #endif  /* __cplusplus */
161 #endif  /* __cplusplus */
162 
163 #endif /* HI_GO_ENCODER_H */
164