xref: /OK3568_Linux_fs/external/mpp/mpp/legacy/vpu_api_legacy.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright 2015 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __VPU_API_LEGACY_H__
18 #define __VPU_API_LEGACY_H__
19 
20 #include <stdio.h>
21 
22 #include "vpu_api.h"
23 #include "rk_mpi.h"
24 #include "rk_venc_cfg.h"
25 
26 #include "vpu_api_mlvec.h"
27 
28 #define OMX_BUFFERFLAG_EOS              0x00000001
29 
30 #define VPU_API_DBG_FUNCTION            (0x00000001)
31 #define VPU_API_DBG_INPUT               (0x00000010)
32 #define VPU_API_DBG_OUTPUT              (0x00000020)
33 #define VPU_API_DBG_CONTROL             (0x00000040)
34 
35 #define vpu_api_dbg(flag, fmt, ...)     _mpp_dbg(vpu_api_debug, flag, fmt, ## __VA_ARGS__)
36 #define vpu_api_dbg_f(flag, fmt, ...)   _mpp_dbg_f(vpu_api_debug, flag, fmt, ## __VA_ARGS__)
37 
38 #define vpu_api_dbg_func(fmt, ...)      vpu_api_dbg_f(VPU_API_DBG_FUNCTION, fmt, ## __VA_ARGS__)
39 #define vpu_api_dbg_input(fmt, ...)     vpu_api_dbg_f(VPU_API_DBG_INPUT, fmt, ## __VA_ARGS__)
40 #define vpu_api_dbg_output(fmt, ...)    vpu_api_dbg_f(VPU_API_DBG_OUTPUT, fmt, ## __VA_ARGS__)
41 #define vpu_api_dbg_ctrl(fmt, ...)      vpu_api_dbg_f(VPU_API_DBG_CONTROL, fmt, ## __VA_ARGS__)
42 
43 extern RK_U32 vpu_api_debug;
44 
45 typedef enum {
46     INPUT_FORMAT_MAP,
47 } PerformCmd;
48 
49 class VpuApiLegacy
50 {
51 public:
52     VpuApiLegacy();
53     ~VpuApiLegacy();
54 
55     RK_S32 init(VpuCodecContext *ctx, RK_U8 *extraData, RK_U32 extra_size);
56     RK_S32 flush(VpuCodecContext *ctx);
57 
58     RK_S32 decode(VpuCodecContext *ctx, VideoPacket_t *pkt, DecoderOut_t *aDecOut);
59     RK_S32 decode_sendstream(VideoPacket_t *pkt);
60     RK_S32 decode_getoutframe(DecoderOut_t *aDecOut);
61     RK_S32 preProcessPacket(VpuCodecContext *ctx, VideoPacket_t *pkt);
62 
63     RK_S32 encode(VpuCodecContext *ctx, EncInputStream_t *aEncInStrm, EncoderOut_t *aEncOut);
64     RK_S32 encoder_sendframe(VpuCodecContext *ctx, EncInputStream_t *aEncInStrm);
65     RK_S32 encoder_getstream(VpuCodecContext *ctx, EncoderOut_t *aEncOut);
66 
67     RK_S32 perform(PerformCmd cmd, RK_S32 *data);
68     RK_S32 control(VpuCodecContext *ctx, VPU_API_CMD cmd, void *param);
69 
70 public:
71     FrameRdyCB frm_rdy_cb;
72 
73 private:
74     VPU_GENERIC vpug;
75     MppCtx mpp_ctx;
76     MppApi *mpi;
77     RK_U32 init_ok;
78     RK_U32 frame_count;
79     RK_U32 set_eos;
80 
81     /* encoder parameters */
82     MppBufferGroup memGroup;
83     MppFrameFormat format;
84 
85     RK_U32 mInputTimeOutMs;
86 
87     RK_S32 fd_input;
88     RK_S32 fd_output;
89 
90     RK_U32 mEosSet;
91 
92     EncParameter_t enc_param;
93     MppEncCfg enc_cfg;
94     MppPacket enc_hdr_pkt;
95     void *enc_hdr_buf;
96     RK_S32 enc_hdr_buf_size;
97 
98     /* for mlvec */
99     VpuApiMlvec mlvec;
100     VpuApiMlvecDynamicCfg mlvec_dy_cfg;
101 
102     RK_S32 dec_out_frm_struct_type;
103 };
104 
105 #endif /*__VPU_API_LEGACY_H__*/
106