• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
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 __MPI_ENC_UTILS_H__
17 #define __MPI_ENC_UTILS_H__
18 
19 #include <stdio.h>
20 
21 #include "rk_venc_cmd.h"
22 
23 typedef struct MpiEncTestArgs_t {
24     MppCodingType type;
25     MppFrameFormat format;
26 
27     signed int width;
28     signed int height;
29 } MpiEncTestArgs;
30 
31 typedef struct {
32     // global flow control flag
33     unsigned int frm_eos;
34     unsigned int pkt_eos;
35     signed int frame_count;
36     RK_U64 stream_size;
37 
38     // base flow context
39     MppCtx ctx;
40     MppApi *mpi;
41     MppEncCfg cfg;
42 
43     // input / output
44     MppBufferGroup buf_grp;
45     MppBuffer pkt_buf;
46     MppEncSeiMode sei_mode;
47     MppEncHeaderMode header_mode;
48 
49     // paramter for resource malloc
50     unsigned int width;
51     unsigned int height;
52     unsigned int hor_stride;
53     unsigned int ver_stride;
54     MppFrameFormat fmt;
55     MppCodingType type;
56     signed int num_frames;
57 
58     // resources
59     size_t frame_size;
60 
61     unsigned int split_mode;
62     unsigned int split_arg;
63 
64     // rate control runtime parameter
65 
66     signed int fps_in_flex;
67     signed int fps_in_den;
68     signed int fps_in_num;
69     signed int fps_out_flex;
70     signed int fps_out_den;
71     signed int fps_out_num;
72     signed int bps;
73     signed int bps_max;
74     signed int bps_min;
75     signed int rc_mode;
76     signed int gop_mode;
77     signed int gop_len;
78     signed int vi_len;
79 } MpiEncTestData;
80 
81 int hal_mpp_get_sps(void *ctx, unsigned char *buf, size_t *buf_size);
82 int hal_mpp_encode(void *ctx, int dma_fd, unsigned char *buf, size_t *buf_size);
83 
84 void *hal_mpp_ctx_create(MpiEncTestArgs *args);
85 void hal_mpp_ctx_delete(void *ctx);
86 
87 #endif /* __MPI_ENC_UTILS_H__ */
88