[mpi_enc_test]: add slt testcase

slt verify file:
mpi_enc_test -w 4096 -h 2304 -t 7  -slt enc_xxx.verify -n 5
mpi_dec_test -i <inputfile>  -t 7  -slt dec_xxx.verify -n 5

Change-Id: I528fcd8d1adf8821c1555790cd8482108f219fdc
Signed-off-by: Hongjin Li <vic.hong@rock-chips.com>
This commit is contained in:
Hongjin Li 2022-01-24 14:23:56 +08:00 committed by Herman Chen
parent 986219e2d1
commit 8c13cd93b0
8 changed files with 208 additions and 27 deletions

View file

@ -55,6 +55,8 @@ typedef struct {
float frame_rate;
RK_S64 elapsed_time;
RK_S64 delay;
FILE *fp_verify;
FrmCrc checkcrc;
} MpiDecLoopData;
static int dec_simple(MpiDecLoopData *data)
@ -68,6 +70,7 @@ static int dec_simple(MpiDecLoopData *data)
MppPacket packet = data->packet;
FileBufSlot *slot = NULL;
RK_U32 quiet = data->quiet;
FrmCrc *checkcrc = &data->checkcrc;
// when packet size is valid read the input binary file
ret = reader_read(cmd->reader, &slot);
@ -274,6 +277,11 @@ static int dec_simple(MpiDecLoopData *data)
if (data->fp_output && !err_info)
dump_mpp_frame_to_file(frame, data->fp_output);
if (data->fp_verify) {
calc_frm_crc(frame, checkcrc);
write_frm_crc(data->fp_verify, checkcrc);
}
fps_calc_inc(cmd->fps);
}
frm_eos = mpp_frame_get_eos(frame);
@ -341,6 +349,7 @@ static int dec_advanced(MpiDecLoopData *data)
MppTask task = NULL;
RK_U32 quiet = data->quiet;
FileBufSlot *slot = NULL;
FrmCrc *checkcrc = &data->checkcrc;
ret = reader_index_read(cmd->reader, 0, &slot);
mpp_assert(ret == MPP_OK);
@ -406,6 +415,11 @@ static int dec_advanced(MpiDecLoopData *data)
if (data->fp_output)
dump_mpp_frame_to_file(frame, data->fp_output);
if (data->fp_verify) {
calc_frm_crc(frame, checkcrc);
write_frm_crc(data->fp_verify, checkcrc);
}
mpp_log_q(quiet, "%p decoded frame %d\n", ctx, data->frame_count);
data->frame_count++;
@ -472,6 +486,10 @@ void *thread_decode(void *arg)
MppApi *mpi = data->mpi;
RK_S64 t_s, t_e;
memset(&data->checkcrc, 0, sizeof(data->checkcrc));
data->checkcrc.luma.sum = mpp_malloc(RK_ULONG, 512);
data->checkcrc.chroma.sum = mpp_malloc(RK_ULONG, 512);
t_s = mpp_time();
if (cmd->simple) {
@ -501,6 +519,9 @@ void *thread_decode(void *arg)
data->frame_count, (RK_S64)(data->elapsed_time / 1000),
(RK_S32)(data->delay / 1000), data->frame_rate);
MPP_FREE(data->checkcrc.luma.sum);
MPP_FREE(data->checkcrc.chroma.sum);
return NULL;
}
@ -544,6 +565,12 @@ int dec_decode(MpiDecTestCmd *cmd)
}
}
if (cmd->file_slt) {
data.fp_verify = fopen(cmd->file_slt, "wt");
if (!data.fp_verify)
mpp_err("failed to open verify file %s\n", cmd->file_slt);
}
if (cmd->simple) {
ret = mpp_packet_init(&packet, NULL, 0);
if (ret) {

View file

@ -53,6 +53,7 @@ typedef struct {
// src and dst
FILE *fp_input;
FILE *fp_output;
FILE *fp_verify;
/* encoder config set */
MppEncCfg cfg;
@ -196,6 +197,10 @@ MPP_RET test_ctx_init(MpiEncMultiCtxInfo *info)
}
}
p->fp_verify = fopen(cmd->file_slt, "wt");
if (!p->fp_verify)
mpp_err("failed to open verify file %s\n", cmd->file_slt);
// update resource parameter
switch (p->fmt & MPP_FRAME_FMT_MASK) {
case MPP_FMT_YUV420SP:
@ -489,8 +494,12 @@ MPP_RET test_mpp_run(MpiEncMultiCtxInfo *info)
RK_U32 quiet = cmd->quiet;
RK_S32 chn = info->chn;
RK_U32 cap_num = 0;
DataCrc checkcrc;
MPP_RET ret = MPP_OK;
memset(&checkcrc, 0, sizeof(checkcrc));
checkcrc.sum = mpp_malloc(RK_ULONG, 512);
if (p->type == MPP_VIDEO_CodingAVC || p->type == MPP_VIDEO_CodingHEVC) {
MppPacket packet = NULL;
@ -716,6 +725,12 @@ MPP_RET test_mpp_run(MpiEncMultiCtxInfo *info)
if (p->fp_output)
fwrite(ptr, 1, len, p->fp_output);
if (p->fp_verify && !p->pkt_eos) {
calc_data_crc((RK_U8 *)ptr, (RK_U32)len, &checkcrc);
mpp_log("p->frame_count=%d, len=%d\n", p->frame_count, len);
write_data_crc(p->fp_verify, &checkcrc);
}
log_len += snprintf(log_buf + log_len, log_size - log_len,
"encoded frame %-4d", p->frame_count);
@ -778,6 +793,8 @@ MPP_RET test_mpp_run(MpiEncMultiCtxInfo *info)
break;
}
RET:
MPP_FREE(checkcrc.sum);
return ret;
}