• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HiHope Open Source Organization .
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 HDI_MPP_MPI_H
17 #define HDI_MPP_MPI_H
18 #include "rk_mpi.h"
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 // mpp base api
23 typedef MPP_RET (*hdiMppCreate)(MppCtx *, MppApi **);
24 typedef MPP_RET (*hdiMppInit)(MppCtx, MppCtxType, MppCodingType);
25 typedef MPP_RET (*hdiMppStart)(MppCtx);
26 typedef MPP_RET (*hdiMppStop)(MppCtx);
27 typedef MPP_RET (*hdiMppDestroy)(MppCtx);
28 typedef MPP_RET (*hdiMppCheckSupportFormat)(MppCtxType, MppCodingType);
29 typedef void (*hdiMppShowSupportFormat)(void);
30 typedef void (*hdiMppShowColorFormat)(void);
31 // mpp packet api
32 typedef MPP_RET (*hdiMppPacketNew)(MppPacket *);
33 typedef MPP_RET (*hdiMppPacketInit)(MppPacket *, void *, size_t);
34 typedef MPP_RET (*hdiMppPacketInitWithBuffer)(MppPacket *, MppBuffer);
35 typedef MPP_RET (*hdiMppPacketCopyInit)(MppPacket *, const MppPacket);
36 typedef MPP_RET (*hdiMppPacketDeinit)(MppPacket*);
37 typedef RK_U32  (*hdiMppPacketGetEos)(MppPacket);
38 typedef MPP_RET (*hdiMppPacketSetEos)(MppPacket);
39 typedef RK_S64  (*hdiMppPacketGetPts)(const MppPacket);
40 typedef void    (*hdiMppPacketSetPts)(MppPacket, RK_S64);
41 typedef void    (*hdiMppPacketSetData)(MppPacket packet, void *data);
42 typedef void    (*hdiMppPacketSetSize)(MppPacket, size_t);
43 typedef void*   (*hdiMppPacketGetPos)(const MppPacket);
44 typedef void    (*hdiMppPacketSetPos)(MppPacket packet, void *data);
45 typedef void    (*hdiMppPacketSetLength)(MppPacket, size_t);
46 typedef size_t  (*hdiMppPacketGetLength)(const MppPacket);
47 typedef RK_U32  (*hdiMppPacketIsPartition)(const MppPacket);
48 typedef RK_U32  (*hdiMppPacketIsEoi)(const MppPacket);
49 typedef MPP_RET (*hdiMppMetaSetPacket)(MppMeta, MppMetaKey, MppPacket);
50 // mpp frame api
51 typedef MPP_RET (*hdiMppFrameInit)(MppFrame*);
52 typedef MPP_RET (*hdiMppFrameDeinit)(MppFrame*);
53 typedef MppFrame (*hdiMppFrameGetNext)(MppFrame);
54 typedef RK_U32 (*hdiMppFrameGetInfoChange)(MppFrame);
55 typedef RK_U32 (*hdiMppFrameGetWidth)(MppFrame);
56 typedef RK_U32 (*hdiMppFrameGetHeight)(MppFrame);
57 typedef RK_U32 (*hdiMppFrameGetHorStride)(MppFrame);
58 typedef RK_U32 (*hdiMppFrameGetVerStride)(MppFrame);
59 typedef RK_U32 (*hdiMppFrameGetBufferSize)(MppFrame);
60 typedef MppFrameFormat (*hdiMppFrameGetFormat)(MppFrame);
61 typedef RK_U32 (*hdiMppFrameGetErrinfo)(const MppFrame);
62 typedef RK_U32 (*hdiMppFrameGetDiscard)(const MppFrame);
63 typedef MppBuffer (*hdiMppFrameGetBuffer)(const MppFrame);
64 typedef void (*hdiMppFrameSetBuffer)(MppFrame, MppBuffer);
65 typedef RK_U32 (*hdiMppFrameGetEos)(const MppFrame);
66 typedef void (*hdiMppFrameSetEos)(const MppFrame, RK_U32);
67 typedef void (*hdiMppFrameSetFormat)(MppFrame, MppFrameFormat);
68 typedef void (*hdiMppFrameSetWidth)(MppFrame, RK_U32);
69 typedef void (*hdiMppFrameSetHeight)(MppFrame, RK_U32);
70 typedef void (*hdiMppFrameSetHorStride)(MppFrame, RK_U32);
71 typedef void (*hdiMppFrameSetVerStride)(MppFrame, RK_U32);
72 typedef MppMeta (*hdiMppFrameGetMeta)(const MppFrame);
73 // mpp dec config api
74 typedef MPP_RET (*hdiMppDecCfgDeinit)(MppDecCfg *);
75 typedef MPP_RET (*hdiMppDecCfgInit)(MppDecCfg *);
76 typedef MPP_RET (*hdiMppDecCfgSetU32)(MppDecCfg, const char *, RK_U32);
77 // mpp enc config api
78 typedef MPP_RET (*hdiMppEncCfgInit)(MppEncCfg *);
79 typedef MPP_RET (*hdiMppEncCfgDeinit)(MppEncCfg);
80 typedef MPP_RET (*hdiMppEncCfgSetS32)(MppEncCfg, const char *, RK_S32);
81 typedef MPP_RET (*hdiMppEncCfgSetU32)(MppEncCfg, const char *, RK_U32);
82 typedef MPP_RET (*hdiMppEncRefCfgInit)(MppEncRefCfg *);
83 typedef MPP_RET (*hdiMppEncRefCfgDeinit)(MppEncRefCfg *);
84 typedef MPP_RET (*hdiMppEncGenRefCfg)(MppEncRefCfg, RK_U32);
85 typedef MPP_RET (*hdiMppEncGenSmartGopRefCfg)(MppEncRefCfg, RK_U32, RK_S32);
86 // mpp buffer group api
87 typedef MPP_RET (*hdiMppBufferGroupGet)(MppBufferGroup *, MppBufferType,
88     MppBufferMode, const char *, const char *);
89 typedef MPP_RET (*hdiMppBufferGroupPut)(MppBufferGroup);
90 typedef MPP_RET (*hdiMppBufferGroupClear)(MppBufferGroup);
91 typedef MPP_RET (*hdiMppBufferGroupLimitConfig)(MppBufferGroup, size_t, RK_S32);
92 typedef MPP_RET (*hdiMppBufferGetFdWithCaller)(MppBuffer, const char *);
93 typedef MPP_RET (*hdiMppBufferGetWithTag)(MppBufferGroup, MppBuffer *, size_t, const char *, const char *);
94 typedef MPP_RET (*hdiMppBufferWriteWithCaller)(MppBuffer, size_t, void *, size_t, const char *);
95 typedef void *(*hdiMppBufferGetPtrWithCaller)(MppBuffer, const char *);
96 typedef size_t (*hdiMppBufferGetSizeWithCaller)(MppBuffer, const char *);
97 typedef MPP_RET (*hdiMppBufferImportWithTag)(MppBufferGroup, MppBufferInfo *, MppBuffer *, const char *, const char *);
98 typedef size_t (*hdiMppBufferGroupUsage)(MppBufferGroup);
99 typedef MPP_RET (*hdiMppBufferPutWithCaller)(MppBuffer, const char *);
100 // mpp task api
101 typedef MPP_RET (*hdiMppTaskMetaGetPacket)(MppTask task, MppMetaKey key, MppPacket *packet);
102 typedef MPP_RET (*hdiMppTaskMetaGetFrame)(MppTask task, MppMetaKey key, MppFrame *frame);
103 typedef MPP_RET (*hdiMppTaskMetaSetPacket)(MppTask task, MppMetaKey key, MppPacket packet);
104 typedef MPP_RET (*hdiMppTaskMetaSetFrame)(MppTask task, MppMetaKey key, MppFrame frame);
105 // mpp env api
106 typedef RK_S32 (*hdiMppEnvGetU32)(const char *, RK_U32 *, RK_U32);
107 
108 typedef struct {
109     // mpp base api
110     hdiMppCreate HdiMppCreate;
111     hdiMppInit HdiMppInit;
112     hdiMppStart HdiMppStart;
113     hdiMppStop HdiMppStop;
114     hdiMppDestroy HdiMppDestroy;
115     hdiMppCheckSupportFormat HdiMppCheckSupportFormat;
116     hdiMppShowSupportFormat HdiMppShowSupportFormat;
117     hdiMppShowColorFormat HdiMppShowColorFormat;
118     // mpp packet api
119     hdiMppPacketNew HdiMppPacketNew;
120     hdiMppPacketInit HdiMppPacketInit;
121     hdiMppPacketInitWithBuffer HdiMppPacketInitWithBuffer;
122     hdiMppPacketCopyInit HdiMppPacketCopyInit;
123     hdiMppPacketDeinit HdiMppPacketDeinit;
124     hdiMppPacketGetEos HdiMppPacketGetEos;
125     hdiMppPacketSetEos HdiMppPacketSetEos;
126     hdiMppPacketGetPts HdiMppPacketGetPts;
127     hdiMppPacketSetPts HdiMppPacketSetPts;
128     hdiMppPacketSetData HdiMppPacketSetData;
129     hdiMppPacketSetSize HdiMppPacketSetSize;
130     hdiMppPacketGetPos HdiMppPacketGetPos;
131     hdiMppPacketSetPos HdiMppPacketSetPos;
132     hdiMppPacketSetLength HdiMppPacketSetLength;
133     hdiMppPacketGetLength HdiMppPacketGetLength;
134     hdiMppPacketIsPartition HdiMppPacketIsPartition;
135     hdiMppPacketIsEoi HdiMppPacketIsEoi;
136     hdiMppMetaSetPacket HdiMppMetaSetPacket;
137     // mpp frame api
138     hdiMppFrameInit HdiMppFrameInit;
139     hdiMppFrameDeinit HdiMppFrameDeinit;
140     hdiMppFrameGetNext HdiMppFrameGetNext;
141     hdiMppFrameGetInfoChange HdiMppFrameGetInfoChange;
142     hdiMppFrameGetWidth HdiMppFrameGetWidth;
143     hdiMppFrameGetHeight HdiMppFrameGetHeight;
144     hdiMppFrameGetHorStride HdiMppFrameGetHorStride;
145     hdiMppFrameGetVerStride HdiMppFrameGetVerStride;
146     hdiMppFrameGetBufferSize HdiMppFrameGetBufferSize;
147     hdiMppFrameGetFormat HdiMppFrameGetFormat;
148     hdiMppFrameGetErrinfo HdiMppFrameGetErrinfo;
149     hdiMppFrameGetDiscard HdiMppFrameGetDiscard;
150     hdiMppFrameGetBuffer HdiMppFrameGetBuffer;
151     hdiMppFrameSetBuffer HdiMppFrameSetBuffer;
152     hdiMppFrameGetEos HdiMppFrameGetEos;
153     hdiMppFrameSetEos HdiMppFrameSetEos;
154     hdiMppFrameSetFormat HdiMppFrameSetFormat;
155     hdiMppFrameSetWidth HdiMppFrameSetWidth;
156     hdiMppFrameSetHeight HdiMppFrameSetHeight;
157     hdiMppFrameSetHorStride HdiMppFrameSetHorStride;
158     hdiMppFrameSetVerStride HdiMppFrameSetVerStride;
159     hdiMppFrameGetMeta HdiMppFrameGetMeta;
160     // mpp dec config api
161     hdiMppDecCfgDeinit HdiMppDecCfgDeinit;
162     hdiMppDecCfgInit HdiMppDecCfgInit;
163     hdiMppDecCfgSetU32 HdiMppDecCfgSetU32;
164     // mpp enc config api
165     hdiMppEncCfgInit HdiMppEncCfgInit;
166     hdiMppEncCfgDeinit HdiMppEncCfgDeinit;
167     hdiMppEncCfgSetS32 HdiMppEncCfgSetS32;
168     hdiMppEncCfgSetU32 HdiMppEncCfgSetU32;
169     hdiMppEncRefCfgInit HdiMppEncRefCfgInit;
170     hdiMppEncRefCfgDeinit HdiMppEncRefCfgDeinit;
171     hdiMppEncGenRefCfg HdiMppEncGenRefCfg;
172     hdiMppEncGenSmartGopRefCfg HdiMppEncGenSmartGopRefCfg;
173     // mpp buffer group api
174     hdiMppBufferGroupGet HdiMppBufferGroupGet;
175     hdiMppBufferGroupPut HdiMppBufferGroupPut;
176     hdiMppBufferGroupClear HdiMppBufferGroupClear;
177     hdiMppBufferGroupLimitConfig HdiMppBufferGroupLimitConfig;
178     hdiMppBufferGetFdWithCaller HdiMppBufferGetFdWithCaller;
179     hdiMppBufferGetWithTag HdiMppBufferGetWithTag;
180     hdiMppBufferImportWithTag HdiMppBufferImportWithTag;
181     hdiMppBufferWriteWithCaller HdiMppBufferWriteWithCaller;
182     hdiMppBufferGetPtrWithCaller HdiMppBufferGetPtrWithCaller;
183     hdiMppBufferGetSizeWithCaller HdiMppBufferGetSizeWithCaller;
184     hdiMppBufferGroupUsage HdiMppBufferGroupUsage;
185     hdiMppBufferPutWithCaller HdiMppBufferPutWithCaller;
186     // mpp task api
187     hdiMppTaskMetaGetPacket HdiMppTaskMetaGetPacket;
188     hdiMppTaskMetaSetPacket HdiMppTaskMetaSetPacket;
189     hdiMppTaskMetaGetFrame HdiMppTaskMetaGetFrame;
190     hdiMppTaskMetaSetFrame HdiMppTaskMetaSetFrame;
191     // mpp env api
192     hdiMppEnvGetU32 HdiMppEnvGetU32;
193 }RKMppApi;
194 
195 int32_t GetMppApi(RKMppApi **mppApi);
196 void ReleaseMppApi(RKMppApi *mppApi);
197 #ifdef __cplusplus
198 }
199 #endif
200 #endif  // HDI_MPP_MPI_H
201 
202