1 /* 2 * 3 * Copyright 2020 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_MLVEC_H__ 19 #define __VPU_API_MLVEC_H__ 20 21 #include "rk_mpi.h" 22 23 #define MLVEC_MAGIC 'M' 24 #define MLVEC_VERSION '0' 25 26 #define VPU_API_ENC_MAX_TID_UPDATED (0x00000001) 27 #define VPU_API_ENC_MARK_LTR_UPDATED (0x00000002) 28 #define VPU_API_ENC_USE_LTR_UPDATED (0x00000004) 29 #define VPU_API_ENC_FRAME_QP_UPDATED (0x00000008) 30 #define VPU_API_ENC_BASE_PID_UPDATED (0x00000010) 31 32 typedef struct VpuApiMlvecStaticCfg_t { 33 RK_S16 width; 34 RK_S16 sar_width; 35 RK_S16 height; 36 RK_S16 sar_height; 37 RK_S32 rc_mode; /* 0 - CQP mode; 1 - CBR mode; */ 38 RK_S32 bitRate; /* target bitrate */ 39 RK_S32 framerate; 40 RK_S32 qp; 41 RK_S32 enableCabac; 42 RK_S32 cabacInitIdc; 43 RK_S32 format; 44 RK_S32 intraPicRate; 45 RK_S32 framerateout; 46 RK_S32 profileIdc; 47 RK_S32 levelIdc; 48 49 RK_S32 magic; /* MLVEC magic word */ 50 /* static configure */ 51 RK_S32 max_tid : 8; /* max temporal layer id */ 52 RK_S32 ltr_frames : 8; /* max long-term reference frame count */ 53 RK_S32 hdr_on_idr : 8; /* sps/pps header with IDR frame */ 54 RK_S32 add_prefix : 8; /* add prefix before each frame */ 55 RK_S32 slice_mbs : 16; /* macroblock row count for each slice */ 56 RK_S32 reserved : 16; 57 } VpuApiMlvecStaticCfg; 58 59 typedef struct VpuApiMlvecDynamicCfg_t { 60 /* dynamic configure */ 61 RK_U32 updated; 62 RK_S32 max_tid; 63 RK_S32 mark_ltr; 64 RK_S32 use_ltr; 65 RK_S32 frame_qp; 66 RK_S32 base_layer_pid; 67 } VpuApiMlvecDynamicCfg; 68 69 typedef void* VpuApiMlvec; 70 71 #ifdef __cplusplus 72 extern "C" { 73 #endif 74 75 MPP_RET vpu_api_mlvec_init(VpuApiMlvec *ctx); 76 MPP_RET vpu_api_mlvec_deinit(VpuApiMlvec ctx); 77 78 /* setup basic mpp info in vpu_api */ 79 MPP_RET vpu_api_mlvec_setup(VpuApiMlvec ctx, MppCtx mpp, MppApi *mpi, MppEncCfg enc_cfg); 80 /* check the input encoder parameter is mlvec configure or not */ 81 MPP_RET vpu_api_mlvec_check_cfg(void *p); 82 83 /* setup mlvec static configure */ 84 MPP_RET vpu_api_mlvec_set_st_cfg(VpuApiMlvec ctx, VpuApiMlvecStaticCfg *cfg); 85 /* setup mlvec dynamic configure and setup MppMeta in MppFrame */ 86 MPP_RET vpu_api_mlvec_set_dy_cfg(VpuApiMlvec ctx, VpuApiMlvecDynamicCfg *cfg, MppMeta meta); 87 /* setup mlvec max temporal layer count dynamic configure */ 88 MPP_RET vpu_api_mlvec_set_dy_max_tid(VpuApiMlvec ctx, RK_S32 max_tid); 89 90 #ifdef __cplusplus 91 } 92 #endif 93 94 #endif /* __VPU_API_MLVEC_H__ */ 95