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 RK_S32 width; 28 RK_S32 height; 29 } MpiEncTestArgs; 30 31 typedef struct { 32 // global flow control flag 33 RK_U32 frm_eos; 34 RK_U32 pkt_eos; 35 RK_S32 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 RK_U32 width; 51 RK_U32 height; 52 RK_U32 hor_stride; 53 RK_U32 ver_stride; 54 MppFrameFormat fmt; 55 MppCodingType type; 56 RK_S32 num_frames; 57 58 // resources 59 size_t frame_size; 60 61 RK_U32 split_mode; 62 RK_U32 split_arg; 63 64 // rate control runtime parameter 65 66 RK_S32 fps_in_flex; 67 RK_S32 fps_in_den; 68 RK_S32 fps_in_num; 69 RK_S32 fps_out_flex; 70 RK_S32 fps_out_den; 71 RK_S32 fps_out_num; 72 RK_S32 bps; 73 RK_S32 bps_max; 74 RK_S32 bps_min; 75 RK_S32 rc_mode; 76 RK_S32 gop_mode; 77 RK_S32 gop_len; 78 RK_S32 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