[mpi_dec_test]: update decoder test case

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@1171 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2016-08-07 09:39:36 +00:00
parent 2386b23ddc
commit 0e9872c5ac

View File

@@ -51,14 +51,15 @@ static OptionInfo mpi_dec_cmd[] = {
{"o", "output_file", "output bitstream file, "}, {"o", "output_file", "output bitstream file, "},
{"w", "width", "the width of input bitstream"}, {"w", "width", "the width of input bitstream"},
{"h", "height", "the height of input bitstream"}, {"h", "height", "the height of input bitstream"},
{"f", "type", "input stream coding type"}, {"t", "type", "input stream coding type"},
{"d", "debug", "debug flag"}, {"d", "debug", "debug flag"},
}; };
int mpi_dec_test(MpiDecTestCmd *cmd) int mpi_dec_test(MpiDecTestCmd *cmd)
{ {
MPP_RET ret = MPP_OK; MPP_RET ret = MPP_OK;
RK_U32 found_eos = 0; RK_U32 pkt_eos = 0;
RK_U32 frm_eos = 0;
FILE *fp_input = NULL; FILE *fp_input = NULL;
FILE *fp_output = NULL; FILE *fp_output = NULL;
@@ -140,11 +141,12 @@ int mpi_dec_test(MpiDecTestCmd *cmd)
goto MPP_TEST_OUT; goto MPP_TEST_OUT;
} }
while (!found_eos) { while (!pkt_eos) {
RK_S32 pkt_done = 0;
read_size = fread(buf, 1, packet_size, fp_input); read_size = fread(buf, 1, packet_size, fp_input);
if (read_size != packet_size || feof(fp_input)) { if (read_size != packet_size || feof(fp_input)) {
mpp_log("found last packet\n"); mpp_log("found last packet\n");
found_eos = 1; pkt_eos = 1;
} }
// write data to packet // write data to packet
@@ -152,37 +154,56 @@ int mpi_dec_test(MpiDecTestCmd *cmd)
// reset pos // reset pos
mpp_packet_set_pos(packet, buf); mpp_packet_set_pos(packet, buf);
// setup eos flag // setup eos flag
if (found_eos) if (pkt_eos)
mpp_packet_set_eos(packet); mpp_packet_set_eos(packet);
ret = mpi->decode_put_packet(ctx, packet); frame = NULL;
if (MPP_OK != ret) {
mpp_err("decode_put_packet failed ret %d\n", ret);
goto MPP_TEST_OUT;
}
msleep(50);
do { do {
ret = mpi->decode_get_frame(ctx, &frame); // send the packet first if packet is not done
if (MPP_OK != ret) { if (!pkt_done) {
mpp_err("decode_get_frame failed ret %d\n", ret); ret = mpi->decode_put_packet(ctx, packet);
goto MPP_TEST_OUT; if (MPP_OK == ret)
pkt_done = 1;
} }
if (frame) { // then get all available frame and release
if (mpp_frame_get_info_change(frame)) { do {
mpp_log("decode_get_frame get info changed found\n"); RK_S32 get_frm = 0;
mpi->control(ctx, MPP_DEC_SET_INFO_CHANGE_READY, NULL); ret = mpi->decode_get_frame(ctx, &frame);
} else { if (MPP_OK != ret) {
mpp_log("decode_get_frame get frame %d\n", frame_count++); mpp_err("decode_get_frame failed ret %d\n", ret);
if (fp_output) goto MPP_TEST_OUT;
dump_mpp_frame_to_file(frame, fp_output);
} }
mpp_frame_deinit(&frame);
} else { if (frame) {
if (mpp_frame_get_info_change(frame)) {
mpp_log("decode_get_frame get info changed found\n");
mpi->control(ctx, MPP_DEC_SET_INFO_CHANGE_READY, NULL);
} else {
mpp_log("decode_get_frame get frame %d\n", frame_count++);
if (fp_output)
dump_mpp_frame_to_file(frame, fp_output);
}
frm_eos = mpp_frame_get_eos(frame);
mpp_frame_deinit(&frame);
frame = NULL;
get_frm = 1;
}
// if last packet is send but last frame is not found continue
if (pkt_eos && pkt_done && !frm_eos)
continue;
if (get_frm)
continue;
break; break;
} } while (1);
if (pkt_done)
break;
msleep(50);
} while (1); } while (1);
} }