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 __MPP_ENC_REFS_H__ 18 #define __MPP_ENC_REFS_H__ 19 20 #include "mpp_enc_cfg.h" 21 #include "mpp_enc_ref.h" 22 23 /* 24 * MppEncRefs has two runtime mode: 25 * 26 * 1. dryrun mode 27 * This mode is for estimating the dpb size and configure check. 28 * 29 * 2. runtime mode 30 * Thie mode is for real dpb loop in real encoder workflow. 31 * 32 * When encoder is running user can change the frame property by MppEncRefFrmUsrCfg. 33 */ 34 #define ENC_FORCE_IDR (0x00000001) 35 #define ENC_FORCE_NONREF (0x00000002) 36 #define ENC_FORCE_LT_REF_IDX (0x00000004) 37 #define ENC_FORCE_TEMPORAL_ID (0x00000008) 38 #define ENC_FORCE_REF_MODE (0x00000010) 39 #define ENC_FORCE_PSKIP_IS_REF (0x00000020) 40 #define ENC_FORCE_PSKIP_NON_REF (0x00000040) 41 42 typedef struct MppEncRefFrmForceCfg_t { 43 RK_U32 force_flag; 44 RK_S32 force_idr; 45 RK_S32 force_pskip; 46 RK_S32 force_nonref; 47 RK_S32 force_lt_idx; 48 RK_S32 force_temporal_id; 49 MppEncRefMode force_ref_mode; 50 RK_S32 force_ref_arg; 51 } MppEncRefFrmUsrCfg; 52 53 typedef void* MppEncRefs; 54 55 #ifdef __cplusplus 56 extern "C" { 57 #endif 58 59 MPP_RET mpp_enc_refs_init(MppEncRefs *refs); 60 MPP_RET mpp_enc_refs_deinit(MppEncRefs *refs); 61 62 MPP_RET mpp_enc_refs_set_cfg(MppEncRefs refs, MppEncRefCfg ref_cfg); 63 MPP_RET mpp_enc_refs_set_usr_cfg(MppEncRefs refs, MppEncRefFrmUsrCfg *force); 64 MPP_RET mpp_enc_refs_set_rc_igop(MppEncRefs refs, RK_S32 igop); 65 MPP_RET mpp_enc_refs_set_refresh_length(MppEncRefs refs, RK_S32 len); 66 67 /* return hdr need update or not */ 68 RK_S32 mpp_enc_refs_update_hdr(MppEncRefs refs); 69 70 /* get dpb size */ 71 MPP_RET mpp_enc_refs_get_cpb_info(MppEncRefs refs, MppEncCpbInfo *info); 72 /* get status for next frame */ 73 MPP_RET mpp_enc_refs_get_cpb(MppEncRefs refs, EncCpbStatus *status); 74 /* dryrun and check all configure */ 75 MPP_RET mpp_enc_refs_dryrun(MppEncRefs refs); 76 77 MPP_RET mpp_enc_refs_stash(MppEncRefs refs); 78 MPP_RET mpp_enc_refs_rollback(MppEncRefs refs); 79 80 /* two-pass encoding functions */ 81 /* check next frame is intra or not */ 82 RK_S32 mpp_enc_refs_next_frm_is_intra(MppEncRefs refs); 83 MPP_RET mpp_enc_refs_get_cpb_pass1(MppEncRefs refs, EncCpbStatus *status); 84 85 #define dump_frm(frm) _dump_frm(frm, __FUNCTION__, __LINE__) 86 87 void _dump_frm(EncFrmStatus *frm, const char *func, RK_S32 line); 88 89 #ifdef __cplusplus 90 } 91 #endif 92 93 #endif /*__MPP_ENC_REFS_H__*/ 94