[test]: Add infinite loop mode for mpi_enc_test

Change-Id: Ibf459034f89682ec2accf5c79cf437bc34804808
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen
2020-05-29 17:09:23 +08:00
parent a26d0fadd7
commit 439fce52b0
2 changed files with 13 additions and 9 deletions

View File

@@ -36,7 +36,7 @@ typedef struct {
// global flow control flag
RK_U32 frm_eos;
RK_U32 pkt_eos;
RK_U32 frame_count;
RK_S32 frame_count;
RK_U64 stream_size;
// src and dst
@@ -71,7 +71,8 @@ typedef struct {
RK_U32 ver_stride;
MppFrameFormat fmt;
MppCodingType type;
RK_U32 num_frames;
RK_S32 num_frames;
RK_S32 loop_times;
// resources
size_t header_size;
@@ -685,8 +686,16 @@ MPP_RET test_mpp_run(MpiEncTestData *p)
ret = read_image(buf, p->fp_input, p->width, p->height,
p->hor_stride, p->ver_stride, p->fmt);
if (ret == MPP_NOK || feof(p->fp_input)) {
mpp_log("found last frame. feof %d\n", feof(p->fp_input));
p->frm_eos = 1;
if (p->num_frames < 0 || p->frame_count < p->num_frames) {
clearerr(p->fp_input);
rewind(p->fp_input);
p->frm_eos = 0;
mpp_log("loop times %d\n", ++p->loop_times);
continue;
}
mpp_log("found last frame. feof %d\n", feof(p->fp_input));
} else if (ret == MPP_ERR_VALUE)
goto RET;
} else {
@@ -815,7 +824,7 @@ MPP_RET test_mpp_run(MpiEncTestData *p)
}
}
if (p->num_frames && p->frame_count >= p->num_frames) {
if (p->num_frames > 0 && p->frame_count >= p->num_frames) {
mpp_log_f("encode max %d frames", p->frame_count);
break;
}

View File

@@ -320,7 +320,6 @@ MPP_RET read_image(RK_U8 *buf, FILE *fp, RK_U32 width, RK_U32 height,
for (row = 0; row < height; row++) {
read_size = fread(buf_y + row * hor_stride, 1, width, fp);
if (read_size != width) {
mpp_err_f("read ori yuv file luma failed");
ret = MPP_NOK;
goto err;
}
@@ -329,7 +328,6 @@ MPP_RET read_image(RK_U8 *buf, FILE *fp, RK_U32 width, RK_U32 height,
for (row = 0; row < height / 2; row++) {
read_size = fread(buf_u + row * hor_stride, 1, width, fp);
if (read_size != width) {
mpp_err_f("read ori yuv file cb failed");
ret = MPP_NOK;
goto err;
}
@@ -339,7 +337,6 @@ MPP_RET read_image(RK_U8 *buf, FILE *fp, RK_U32 width, RK_U32 height,
for (row = 0; row < height; row++) {
read_size = fread(buf_y + row * hor_stride, 1, width, fp);
if (read_size != width) {
mpp_err_f("read ori yuv file luma failed");
ret = MPP_NOK;
goto err;
}
@@ -348,7 +345,6 @@ MPP_RET read_image(RK_U8 *buf, FILE *fp, RK_U32 width, RK_U32 height,
for (row = 0; row < height / 2; row++) {
read_size = fread(buf_u + row * hor_stride / 2, 1, width / 2, fp);
if (read_size != width / 2) {
mpp_err_f("read ori yuv file cb failed");
ret = MPP_NOK;
goto err;
}
@@ -357,7 +353,6 @@ MPP_RET read_image(RK_U8 *buf, FILE *fp, RK_U32 width, RK_U32 height,
for (row = 0; row < height / 2; row++) {
read_size = fread(buf_v + row * hor_stride / 2, 1, width / 2, fp);
if (read_size != width / 2) {
mpp_err_f("read ori yuv file cr failed");
ret = MPP_NOK;
goto err;
}