[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,18 +154,21 @@ 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);
frame = NULL;
do {
// send the packet first if packet is not done
if (!pkt_done) {
ret = mpi->decode_put_packet(ctx, packet); ret = mpi->decode_put_packet(ctx, packet);
if (MPP_OK != ret) { if (MPP_OK == ret)
mpp_err("decode_put_packet failed ret %d\n", ret); pkt_done = 1;
goto MPP_TEST_OUT;
} }
msleep(50); // then get all available frame and release
do { do {
RK_S32 get_frm = 0;
ret = mpi->decode_get_frame(ctx, &frame); ret = mpi->decode_get_frame(ctx, &frame);
if (MPP_OK != ret) { if (MPP_OK != ret) {
mpp_err("decode_get_frame failed ret %d\n", ret); mpp_err("decode_get_frame failed ret %d\n", ret);
@@ -179,10 +184,26 @@ int mpi_dec_test(MpiDecTestCmd *cmd)
if (fp_output) if (fp_output)
dump_mpp_frame_to_file(frame, fp_output); dump_mpp_frame_to_file(frame, fp_output);
} }
frm_eos = mpp_frame_get_eos(frame);
mpp_frame_deinit(&frame); mpp_frame_deinit(&frame);
} else { frame = NULL;
break; 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;
} while (1);
if (pkt_done)
break;
msleep(50);
} while (1); } while (1);
} }