xref: /OK3568_Linux_fs/external/mpp/mpp/base/inc/mpp_enc_refs.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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_PSKIP         (0x00000002)
36 #define ENC_FORCE_NONREF        (0x00000004)
37 #define ENC_FORCE_LT_REF_IDX    (0x00000008)
38 #define ENC_FORCE_TEMPORAL_ID   (0x00000010)
39 #define ENC_FORCE_REF_MODE      (0x00000020)
40 
41 typedef struct MppEncRefFrmForceCfg_t {
42     RK_U32              force_flag;
43     RK_S32              force_idr;
44     RK_S32              force_pskip;
45     RK_S32              force_nonref;
46     RK_S32              force_lt_idx;
47     RK_S32              force_temporal_id;
48     MppEncRefMode       force_ref_mode;
49     RK_S32              force_ref_arg;
50 } MppEncRefFrmUsrCfg;
51 
52 typedef void* MppEncRefs;
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 MPP_RET mpp_enc_refs_init(MppEncRefs *refs);
59 MPP_RET mpp_enc_refs_deinit(MppEncRefs *refs);
60 
61 MPP_RET mpp_enc_refs_set_cfg(MppEncRefs refs, MppEncRefCfg ref_cfg);
62 MPP_RET mpp_enc_refs_set_usr_cfg(MppEncRefs refs, MppEncRefFrmUsrCfg *force);
63 MPP_RET mpp_enc_refs_set_rc_igop(MppEncRefs refs, RK_S32 igop);
64 MPP_RET mpp_enc_refs_set_refresh_length(MppEncRefs refs, RK_S32 len);
65 
66 /* return hdr need update or not */
67 RK_S32  mpp_enc_refs_update_hdr(MppEncRefs refs);
68 
69 /* get dpb size */
70 MPP_RET mpp_enc_refs_get_cpb_info(MppEncRefs refs, MppEncCpbInfo *info);
71 /* get status for next frame */
72 MPP_RET mpp_enc_refs_get_cpb(MppEncRefs refs, EncCpbStatus *status);
73 /* dryrun and check all configure */
74 MPP_RET mpp_enc_refs_dryrun(MppEncRefs refs);
75 
76 MPP_RET mpp_enc_refs_stash(MppEncRefs refs);
77 MPP_RET mpp_enc_refs_rollback(MppEncRefs refs);
78 
79 /* two-pass encoding functions */
80 /* check next frame is intra or not */
81 RK_S32  mpp_enc_refs_next_frm_is_intra(MppEncRefs refs);
82 MPP_RET mpp_enc_refs_get_cpb_pass1(MppEncRefs refs, EncCpbStatus *status);
83 
84 #define dump_frm(frm)   _dump_frm(frm, __FUNCTION__, __LINE__)
85 
86 void _dump_frm(EncFrmStatus *frm, const char *func, RK_S32 line);
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif /*__MPP_ENC_REFS_H__*/
93