mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-04 16:52:40 +08:00
[utils]: Add gop ref config util function
Signed-off-by: Herman Chen <herman.chen@rock-chips.com> Change-Id: I9b82e4a2a6e8451c9e63599329c3d3ddc74ff59c
This commit is contained in:
@@ -209,167 +209,6 @@ MPP_RET test_ctx_deinit(MpiEncTestData **data)
|
|||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_gop_ref(MppEncGopRef *ref, RK_S32 gop_mode)
|
|
||||||
{
|
|
||||||
// rockchip tsvc config
|
|
||||||
MppGopRefInfo *gop = &ref->gop_info[0];
|
|
||||||
|
|
||||||
mpp_log("gop_mode %d", gop_mode);
|
|
||||||
|
|
||||||
ref->change = 1;
|
|
||||||
ref->gop_cfg_enable = 1;
|
|
||||||
|
|
||||||
// default no LTR
|
|
||||||
ref->lt_ref_interval = 0;
|
|
||||||
ref->max_lt_ref_cnt = 0;
|
|
||||||
|
|
||||||
if (gop_mode == 3) {
|
|
||||||
// tsvc4
|
|
||||||
// /-> P1 /-> P3 /-> P5 /-> P7
|
|
||||||
// / / / /
|
|
||||||
// //--------> P2 //--------> P6
|
|
||||||
// // //
|
|
||||||
// ///---------------------> P4
|
|
||||||
// ///
|
|
||||||
// P0 ------------------------------------------------> P8
|
|
||||||
ref->ref_gop_len = 8;
|
|
||||||
ref->layer_weight[0] = 800;
|
|
||||||
ref->layer_weight[1] = 400;
|
|
||||||
ref->layer_weight[2] = 400;
|
|
||||||
ref->layer_weight[3] = 400;
|
|
||||||
|
|
||||||
gop[0].temporal_id = 0;
|
|
||||||
gop[0].ref_idx = 0;
|
|
||||||
gop[0].is_non_ref = 0;
|
|
||||||
gop[0].is_lt_ref = 1;
|
|
||||||
gop[0].lt_idx = 0;
|
|
||||||
|
|
||||||
gop[1].temporal_id = 3;
|
|
||||||
gop[1].ref_idx = 0;
|
|
||||||
gop[1].is_non_ref = 1;
|
|
||||||
gop[1].is_lt_ref = 0;
|
|
||||||
gop[1].lt_idx = 0;
|
|
||||||
|
|
||||||
gop[2].temporal_id = 2;
|
|
||||||
gop[2].ref_idx = 0;
|
|
||||||
gop[2].is_non_ref = 0;
|
|
||||||
gop[2].is_lt_ref = 0;
|
|
||||||
gop[2].lt_idx = 0;
|
|
||||||
|
|
||||||
gop[3].temporal_id = 3;
|
|
||||||
gop[3].ref_idx = 2;
|
|
||||||
gop[3].is_non_ref = 1;
|
|
||||||
gop[3].is_lt_ref = 0;
|
|
||||||
gop[3].lt_idx = 0;
|
|
||||||
|
|
||||||
gop[4].temporal_id = 1;
|
|
||||||
gop[4].ref_idx = 0;
|
|
||||||
gop[4].is_non_ref = 0;
|
|
||||||
gop[4].is_lt_ref = 1;
|
|
||||||
gop[4].lt_idx = 1;
|
|
||||||
|
|
||||||
gop[5].temporal_id = 3;
|
|
||||||
gop[5].ref_idx = 4;
|
|
||||||
gop[5].is_non_ref = 1;
|
|
||||||
gop[5].is_lt_ref = 0;
|
|
||||||
gop[5].lt_idx = 0;
|
|
||||||
|
|
||||||
gop[6].temporal_id = 2;
|
|
||||||
gop[6].ref_idx = 4;
|
|
||||||
gop[6].is_non_ref = 0;
|
|
||||||
gop[6].is_lt_ref = 0;
|
|
||||||
gop[6].lt_idx = 0;
|
|
||||||
|
|
||||||
gop[7].temporal_id = 3;
|
|
||||||
gop[7].ref_idx = 6;
|
|
||||||
gop[7].is_non_ref = 1;
|
|
||||||
gop[7].is_lt_ref = 0;
|
|
||||||
gop[7].lt_idx = 0;
|
|
||||||
|
|
||||||
gop[8].temporal_id = 0;
|
|
||||||
gop[8].ref_idx = 0;
|
|
||||||
gop[8].is_non_ref = 0;
|
|
||||||
gop[8].is_lt_ref = 1;
|
|
||||||
gop[8].lt_idx = 0;
|
|
||||||
|
|
||||||
ref->max_lt_ref_cnt = 2;
|
|
||||||
} else if (gop_mode == 2) {
|
|
||||||
// tsvc3
|
|
||||||
// /-> P1 /-> P3
|
|
||||||
// / /
|
|
||||||
// //--------> P2
|
|
||||||
// //
|
|
||||||
// P0/---------------------> P4
|
|
||||||
ref->ref_gop_len = 4;
|
|
||||||
ref->layer_weight[0] = 1000;
|
|
||||||
ref->layer_weight[1] = 500;
|
|
||||||
ref->layer_weight[2] = 500;
|
|
||||||
ref->layer_weight[3] = 0;
|
|
||||||
|
|
||||||
gop[0].temporal_id = 0;
|
|
||||||
gop[0].ref_idx = 0;
|
|
||||||
gop[0].is_non_ref = 0;
|
|
||||||
gop[0].is_lt_ref = 0;
|
|
||||||
gop[0].lt_idx = 0;
|
|
||||||
|
|
||||||
gop[1].temporal_id = 2;
|
|
||||||
gop[1].ref_idx = 0;
|
|
||||||
gop[1].is_non_ref = 1;
|
|
||||||
gop[1].is_lt_ref = 0;
|
|
||||||
gop[1].lt_idx = 0;
|
|
||||||
|
|
||||||
gop[2].temporal_id = 1;
|
|
||||||
gop[2].ref_idx = 0;
|
|
||||||
gop[2].is_non_ref = 0;
|
|
||||||
gop[2].is_lt_ref = 0;
|
|
||||||
gop[2].lt_idx = 0;
|
|
||||||
|
|
||||||
gop[3].temporal_id = 2;
|
|
||||||
gop[3].ref_idx = 2;
|
|
||||||
gop[3].is_non_ref = 1;
|
|
||||||
gop[3].is_lt_ref = 0;
|
|
||||||
gop[3].lt_idx = 0;
|
|
||||||
|
|
||||||
gop[4].temporal_id = 0;
|
|
||||||
gop[4].ref_idx = 0;
|
|
||||||
gop[4].is_non_ref = 0;
|
|
||||||
gop[4].is_lt_ref = 0;
|
|
||||||
gop[4].lt_idx = 0;
|
|
||||||
|
|
||||||
// set to lt_ref interval with looping LTR idx
|
|
||||||
ref->lt_ref_interval = 10;
|
|
||||||
ref->max_lt_ref_cnt = 3;
|
|
||||||
} else if (gop_mode == 1) {
|
|
||||||
// tsvc2
|
|
||||||
// /-> P1
|
|
||||||
// /
|
|
||||||
// P0--------> P2
|
|
||||||
ref->ref_gop_len = 2;
|
|
||||||
ref->layer_weight[0] = 1400;
|
|
||||||
ref->layer_weight[1] = 600;
|
|
||||||
ref->layer_weight[2] = 0;
|
|
||||||
ref->layer_weight[3] = 0;
|
|
||||||
|
|
||||||
gop[0].temporal_id = 0;
|
|
||||||
gop[0].ref_idx = 0;
|
|
||||||
gop[0].is_non_ref = 0;
|
|
||||||
gop[0].is_lt_ref = 0;
|
|
||||||
gop[0].lt_idx = 0;
|
|
||||||
|
|
||||||
gop[1].temporal_id = 1;
|
|
||||||
gop[1].ref_idx = 0;
|
|
||||||
gop[1].is_non_ref = 1;
|
|
||||||
gop[1].is_lt_ref = 0;
|
|
||||||
gop[1].lt_idx = 0;
|
|
||||||
|
|
||||||
gop[2].temporal_id = 0;
|
|
||||||
gop[2].ref_idx = 0;
|
|
||||||
gop[2].is_non_ref = 0;
|
|
||||||
gop[2].is_lt_ref = 0;
|
|
||||||
gop[2].lt_idx = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MPP_RET test_mpp_setup(MpiEncTestData *p)
|
MPP_RET test_mpp_setup(MpiEncTestData *p)
|
||||||
{
|
{
|
||||||
MPP_RET ret;
|
MPP_RET ret;
|
||||||
@@ -541,7 +380,7 @@ MPP_RET test_mpp_setup(MpiEncTestData *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (p->gop_mode && p->gop_mode < 4) {
|
if (p->gop_mode && p->gop_mode < 4) {
|
||||||
setup_gop_ref(&p->ref, p->gop_mode);
|
mpi_enc_gen_gop_ref(&p->ref, p->gop_mode);
|
||||||
|
|
||||||
mpp_log_f("MPP_ENC_SET_GOPREF start gop mode %d\n", p->gop_mode);
|
mpp_log_f("MPP_ENC_SET_GOPREF start gop mode %d\n", p->gop_mode);
|
||||||
|
|
||||||
|
@@ -229,6 +229,178 @@ MPP_RET mpi_enc_test_cmd_put(MpiEncTestArgs* cmd)
|
|||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MPP_RET mpi_enc_gen_gop_ref(MppEncGopRef *ref, RK_S32 gop_mode)
|
||||||
|
{
|
||||||
|
ref->change = 0;
|
||||||
|
ref->gop_cfg_enable = 0;
|
||||||
|
|
||||||
|
/* error gop and tsvc config */
|
||||||
|
if (gop_mode < 0 || gop_mode > 3)
|
||||||
|
return MPP_NOK;
|
||||||
|
|
||||||
|
// no tsvc config
|
||||||
|
if (gop_mode == 0)
|
||||||
|
return MPP_OK;
|
||||||
|
|
||||||
|
ref->change = 1;
|
||||||
|
ref->gop_cfg_enable = 1;
|
||||||
|
|
||||||
|
// default no LTR
|
||||||
|
ref->lt_ref_interval = 0;
|
||||||
|
ref->max_lt_ref_cnt = 0;
|
||||||
|
|
||||||
|
// rockchip tsvc config
|
||||||
|
MppGopRefInfo *gop = &ref->gop_info[0];
|
||||||
|
|
||||||
|
if (gop_mode == 3) {
|
||||||
|
// tsvc4
|
||||||
|
// /-> P1 /-> P3 /-> P5 /-> P7
|
||||||
|
// / / / /
|
||||||
|
// //--------> P2 //--------> P6
|
||||||
|
// // //
|
||||||
|
// ///---------------------> P4
|
||||||
|
// ///
|
||||||
|
// P0 ------------------------------------------------> P8
|
||||||
|
ref->ref_gop_len = 8;
|
||||||
|
ref->layer_weight[0] = 800;
|
||||||
|
ref->layer_weight[1] = 400;
|
||||||
|
ref->layer_weight[2] = 400;
|
||||||
|
ref->layer_weight[3] = 400;
|
||||||
|
|
||||||
|
gop[0].temporal_id = 0;
|
||||||
|
gop[0].ref_idx = 0;
|
||||||
|
gop[0].is_non_ref = 0;
|
||||||
|
gop[0].is_lt_ref = 1;
|
||||||
|
gop[0].lt_idx = 0;
|
||||||
|
|
||||||
|
gop[1].temporal_id = 3;
|
||||||
|
gop[1].ref_idx = 0;
|
||||||
|
gop[1].is_non_ref = 1;
|
||||||
|
gop[1].is_lt_ref = 0;
|
||||||
|
gop[1].lt_idx = 0;
|
||||||
|
|
||||||
|
gop[2].temporal_id = 2;
|
||||||
|
gop[2].ref_idx = 0;
|
||||||
|
gop[2].is_non_ref = 0;
|
||||||
|
gop[2].is_lt_ref = 0;
|
||||||
|
gop[2].lt_idx = 0;
|
||||||
|
|
||||||
|
gop[3].temporal_id = 3;
|
||||||
|
gop[3].ref_idx = 2;
|
||||||
|
gop[3].is_non_ref = 1;
|
||||||
|
gop[3].is_lt_ref = 0;
|
||||||
|
gop[3].lt_idx = 0;
|
||||||
|
|
||||||
|
gop[4].temporal_id = 1;
|
||||||
|
gop[4].ref_idx = 0;
|
||||||
|
gop[4].is_non_ref = 0;
|
||||||
|
gop[4].is_lt_ref = 1;
|
||||||
|
gop[4].lt_idx = 1;
|
||||||
|
|
||||||
|
gop[5].temporal_id = 3;
|
||||||
|
gop[5].ref_idx = 4;
|
||||||
|
gop[5].is_non_ref = 1;
|
||||||
|
gop[5].is_lt_ref = 0;
|
||||||
|
gop[5].lt_idx = 0;
|
||||||
|
|
||||||
|
gop[6].temporal_id = 2;
|
||||||
|
gop[6].ref_idx = 4;
|
||||||
|
gop[6].is_non_ref = 0;
|
||||||
|
gop[6].is_lt_ref = 0;
|
||||||
|
gop[6].lt_idx = 0;
|
||||||
|
|
||||||
|
gop[7].temporal_id = 3;
|
||||||
|
gop[7].ref_idx = 6;
|
||||||
|
gop[7].is_non_ref = 1;
|
||||||
|
gop[7].is_lt_ref = 0;
|
||||||
|
gop[7].lt_idx = 0;
|
||||||
|
|
||||||
|
gop[8].temporal_id = 0;
|
||||||
|
gop[8].ref_idx = 0;
|
||||||
|
gop[8].is_non_ref = 0;
|
||||||
|
gop[8].is_lt_ref = 1;
|
||||||
|
gop[8].lt_idx = 0;
|
||||||
|
|
||||||
|
ref->max_lt_ref_cnt = 2;
|
||||||
|
} else if (gop_mode == 2) {
|
||||||
|
// tsvc3
|
||||||
|
// /-> P1 /-> P3
|
||||||
|
// / /
|
||||||
|
// //--------> P2
|
||||||
|
// //
|
||||||
|
// P0/---------------------> P4
|
||||||
|
ref->ref_gop_len = 4;
|
||||||
|
ref->layer_weight[0] = 1000;
|
||||||
|
ref->layer_weight[1] = 500;
|
||||||
|
ref->layer_weight[2] = 500;
|
||||||
|
ref->layer_weight[3] = 0;
|
||||||
|
|
||||||
|
gop[0].temporal_id = 0;
|
||||||
|
gop[0].ref_idx = 0;
|
||||||
|
gop[0].is_non_ref = 0;
|
||||||
|
gop[0].is_lt_ref = 0;
|
||||||
|
gop[0].lt_idx = 0;
|
||||||
|
|
||||||
|
gop[1].temporal_id = 2;
|
||||||
|
gop[1].ref_idx = 0;
|
||||||
|
gop[1].is_non_ref = 1;
|
||||||
|
gop[1].is_lt_ref = 0;
|
||||||
|
gop[1].lt_idx = 0;
|
||||||
|
|
||||||
|
gop[2].temporal_id = 1;
|
||||||
|
gop[2].ref_idx = 0;
|
||||||
|
gop[2].is_non_ref = 0;
|
||||||
|
gop[2].is_lt_ref = 0;
|
||||||
|
gop[2].lt_idx = 0;
|
||||||
|
|
||||||
|
gop[3].temporal_id = 2;
|
||||||
|
gop[3].ref_idx = 2;
|
||||||
|
gop[3].is_non_ref = 1;
|
||||||
|
gop[3].is_lt_ref = 0;
|
||||||
|
gop[3].lt_idx = 0;
|
||||||
|
|
||||||
|
gop[4].temporal_id = 0;
|
||||||
|
gop[4].ref_idx = 0;
|
||||||
|
gop[4].is_non_ref = 0;
|
||||||
|
gop[4].is_lt_ref = 0;
|
||||||
|
gop[4].lt_idx = 0;
|
||||||
|
|
||||||
|
// set to lt_ref interval with looping LTR idx
|
||||||
|
ref->lt_ref_interval = 10;
|
||||||
|
ref->max_lt_ref_cnt = 3;
|
||||||
|
} else if (gop_mode == 1) {
|
||||||
|
// tsvc2
|
||||||
|
// /-> P1
|
||||||
|
// /
|
||||||
|
// P0--------> P2
|
||||||
|
ref->ref_gop_len = 2;
|
||||||
|
ref->layer_weight[0] = 1400;
|
||||||
|
ref->layer_weight[1] = 600;
|
||||||
|
ref->layer_weight[2] = 0;
|
||||||
|
ref->layer_weight[3] = 0;
|
||||||
|
|
||||||
|
gop[0].temporal_id = 0;
|
||||||
|
gop[0].ref_idx = 0;
|
||||||
|
gop[0].is_non_ref = 0;
|
||||||
|
gop[0].is_lt_ref = 0;
|
||||||
|
gop[0].lt_idx = 0;
|
||||||
|
|
||||||
|
gop[1].temporal_id = 1;
|
||||||
|
gop[1].ref_idx = 0;
|
||||||
|
gop[1].is_non_ref = 1;
|
||||||
|
gop[1].is_lt_ref = 0;
|
||||||
|
gop[1].lt_idx = 0;
|
||||||
|
|
||||||
|
gop[2].temporal_id = 0;
|
||||||
|
gop[2].ref_idx = 0;
|
||||||
|
gop[2].is_non_ref = 0;
|
||||||
|
gop[2].is_lt_ref = 0;
|
||||||
|
gop[2].lt_idx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MPP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
MPP_RET mpi_enc_gen_osd_data(MppEncOSDData *osd_data, MppBuffer osd_buf, RK_U32 frame_cnt)
|
MPP_RET mpi_enc_gen_osd_data(MppEncOSDData *osd_data, MppBuffer osd_buf, RK_U32 frame_cnt)
|
||||||
{
|
{
|
||||||
RK_U32 k = 0;
|
RK_U32 k = 0;
|
||||||
|
@@ -49,6 +49,7 @@ typedef struct MpiEncTestArgs_t {
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
MPP_RET mpi_enc_gen_gop_ref(MppEncGopRef *ref, RK_S32 gop_mode);
|
||||||
MPP_RET mpi_enc_gen_osd_data(MppEncOSDData *osd_data, MppBuffer osd_buf, RK_U32 frame_cnt);
|
MPP_RET mpi_enc_gen_osd_data(MppEncOSDData *osd_data, MppBuffer osd_buf, RK_U32 frame_cnt);
|
||||||
MPP_RET mpi_enc_gen_osd_plt(MppEncOSDPlt *osd_plt, RK_U32 *table);
|
MPP_RET mpi_enc_gen_osd_plt(MppEncOSDPlt *osd_plt, RK_U32 *table);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user