• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright 2015 Rockchip Electronics Co., LTD.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __VPU_API_LEGACY_H__
19 #define __VPU_API_LEGACY_H__
20 
21 #include <cstdio>
22 
23 #include "vpu_api.h"
24 #include "rk_mpi.h"
25 #include "rk_venc_cfg.h"
26 
27 #include "vpu_api_mlvec.h"
28 
29 #define OMX_BUFFERFLAG_EOS              0x00000001
30 
31 #define VPU_API_DBG_FUNCTION            (0x00000001)
32 #define VPU_API_DBG_INPUT               (0x00000010)
33 #define VPU_API_DBG_OUTPUT              (0x00000020)
34 #define VPU_API_DBG_CONTROL             (0x00000040)
35 
36 #define vpu_api_dbg(flag, fmt, ...)     _mpp_dbg(vpu_api_debug, flag, fmt, ## __VA_ARGS__)
37 #define vpu_api_dbg_f(flag, fmt, ...)   _mpp_dbg_f(vpu_api_debug, flag, fmt, ## __VA_ARGS__)
38 
39 #define vpu_api_dbg_func(fmt, ...)      vpu_api_dbg_f(VPU_API_DBG_FUNCTION, fmt, ## __VA_ARGS__)
40 #define vpu_api_dbg_input(fmt, ...)     vpu_api_dbg_f(VPU_API_DBG_INPUT, fmt, ## __VA_ARGS__)
41 #define vpu_api_dbg_output(fmt, ...)    vpu_api_dbg_f(VPU_API_DBG_OUTPUT, fmt, ## __VA_ARGS__)
42 #define vpu_api_dbg_ctrl(fmt, ...)      vpu_api_dbg_f(VPU_API_DBG_CONTROL, fmt, ## __VA_ARGS__)
43 
44 extern RK_U32 vpu_api_debug;
45 
46 typedef enum {
47     INPUT_FORMAT_MAP,
48 } PerformCmd;
49 
50 class VpuApiLegacy {
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 private:
71     VPU_GENERIC vpug;
72     MppCtx mpp_ctx;
73     MppApi *mpi;
74     RK_U32 init_ok;
75     RK_U32 frame_count;
76     RK_U32 set_eos;
77 
78     /* encoder parameters */
79     MppBufferGroup memGroup;
80     MppFrameFormat format;
81 
82     RK_S32 fd_input;
83     RK_S32 fd_output;
84 
85     RK_U32 mEosSet;
86 
87     EncParameter_t enc_param;
88     MppEncCfg enc_cfg;
89     MppPacket enc_hdr_pkt;
90     void *enc_hdr_buf;
91     RK_S32 enc_hdr_buf_size;
92 
93     /* for mlvec */
94     VpuApiMlvec mlvec;
95     VpuApiMlvecDynamicCfg mlvec_dy_cfg;
96 };
97 
98 #endif /* __VPU_API_LEGACY_H__ */
99