mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-06 01:26:49 +08:00
chore[test]: Use put/get in mpi_dec_test for jpeg
Signed-off-by: Herman Chen <herman.chen@rock-chips.com> Change-Id: I967c74815450461cfdd4fca6d1ee640a83783961
This commit is contained in:
@@ -419,6 +419,11 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
mpi_dec_test_cmd_options(cmd);
|
mpi_dec_test_cmd_options(cmd);
|
||||||
|
|
||||||
|
if (cmd->type == MPP_VIDEO_CodingMJPEG) {
|
||||||
|
mpp_log("mpi_dec_mt_test not support mjpeg yet\n");
|
||||||
|
goto RET;
|
||||||
|
}
|
||||||
|
|
||||||
ret = mt_dec_decode(cmd);
|
ret = mt_dec_decode(cmd);
|
||||||
if (MPP_OK == ret)
|
if (MPP_OK == ret)
|
||||||
mpp_log("test success\n");
|
mpp_log("test success\n");
|
||||||
@@ -430,4 +435,3 @@ RET:
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -265,8 +265,10 @@ static int dec_advanced(MpiDecLoopData *data)
|
|||||||
MppCtx ctx = data->ctx;
|
MppCtx ctx = data->ctx;
|
||||||
MppApi *mpi = data->mpi;
|
MppApi *mpi = data->mpi;
|
||||||
MppPacket packet = NULL;
|
MppPacket packet = NULL;
|
||||||
MppFrame frame = data->frame;
|
MppPacket packet_ret = NULL;
|
||||||
MppTask task = NULL;
|
MppFrame frame = data->frame;
|
||||||
|
MppFrame frame_ret = NULL;
|
||||||
|
MppMeta meta = NULL;
|
||||||
RK_U32 quiet = data->quiet;
|
RK_U32 quiet = data->quiet;
|
||||||
FileBufSlot *slot = NULL;
|
FileBufSlot *slot = NULL;
|
||||||
FrmCrc *checkcrc = &data->checkcrc;
|
FrmCrc *checkcrc = &data->checkcrc;
|
||||||
@@ -281,120 +283,74 @@ static int dec_advanced(MpiDecLoopData *data)
|
|||||||
if (slot->eos)
|
if (slot->eos)
|
||||||
mpp_packet_set_eos(packet);
|
mpp_packet_set_eos(packet);
|
||||||
|
|
||||||
ret = mpi->poll(ctx, MPP_PORT_INPUT, MPP_POLL_BLOCK);
|
/* use the MppFrame with prealloced buffer and do not release */
|
||||||
|
meta = mpp_packet_get_meta(packet);
|
||||||
|
if (meta)
|
||||||
|
mpp_meta_set_frame(meta, KEY_OUTPUT_FRAME, frame);
|
||||||
|
|
||||||
|
ret = mpi->decode_put_packet(ctx, packet);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
mpp_err("%p mpp input poll failed\n", ctx);
|
mpp_err("%p mpp decode put packet failed ret %d\n", ctx, ret);
|
||||||
return ret;
|
data->loop_end = 1;
|
||||||
}
|
goto DONE;
|
||||||
|
|
||||||
ret = mpi->dequeue(ctx, MPP_PORT_INPUT, &task); /* input queue */
|
|
||||||
if (ret) {
|
|
||||||
mpp_err("%p mpp task input dequeue failed\n", ctx);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
mpp_assert(task);
|
|
||||||
|
|
||||||
mpp_task_meta_set_packet(task, KEY_INPUT_PACKET, packet);
|
|
||||||
mpp_task_meta_set_frame (task, KEY_OUTPUT_FRAME, frame);
|
|
||||||
|
|
||||||
ret = mpi->enqueue(ctx, MPP_PORT_INPUT, task); /* input queue */
|
|
||||||
if (ret) {
|
|
||||||
mpp_err("%p mpp task input enqueue failed\n", ctx);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data->first_pkt)
|
if (!data->first_pkt)
|
||||||
data->first_pkt = mpp_time();
|
data->first_pkt = mpp_time();
|
||||||
|
|
||||||
/* poll and wait here */
|
ret = mpi->decode_get_frame(ctx, &frame_ret);
|
||||||
ret = mpi->poll(ctx, MPP_PORT_OUTPUT, MPP_POLL_BLOCK);
|
if (ret || !frame_ret) {
|
||||||
if (ret) {
|
mpp_err("%p mpp decode get frame failed ret %d frame %p\n", ctx, ret, frame_ret);
|
||||||
mpp_err("%p mpp output poll failed\n", ctx);
|
data->loop_end = 1;
|
||||||
return ret;
|
goto DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mpi->dequeue(ctx, MPP_PORT_OUTPUT, &task); /* output queue */
|
if (!data->first_frm)
|
||||||
if (ret) {
|
data->first_frm = mpp_time();
|
||||||
mpp_err("%p mpp task output dequeue failed\n", ctx);
|
|
||||||
return ret;
|
if (frame_ret != frame)
|
||||||
|
mpp_err_f("mismatch frame %p -> %p\n", frame_ret, frame);
|
||||||
|
|
||||||
|
/* write frame to file here */
|
||||||
|
if (data->fp_output)
|
||||||
|
dump_mpp_frame_to_file(frame_ret, data->fp_output);
|
||||||
|
|
||||||
|
if (data->fp_verify) {
|
||||||
|
calc_frm_crc(frame_ret, checkcrc);
|
||||||
|
write_frm_crc(data->fp_verify, checkcrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
mpp_assert(task);
|
mpp_log_q(quiet, "%p decoded frame %d\n", ctx, data->frame_count);
|
||||||
|
data->frame_count++;
|
||||||
|
|
||||||
if (task) {
|
if (mpp_frame_get_eos(frame_ret))
|
||||||
MppFrame frame_out = NULL;
|
mpp_log_q(quiet, "%p found eos frame\n", ctx);
|
||||||
|
|
||||||
mpp_task_meta_get_frame(task, KEY_OUTPUT_FRAME, &frame_out);
|
fps_calc_inc(cmd->fps);
|
||||||
|
|
||||||
if (frame) {
|
meta = mpp_frame_get_meta(frame);
|
||||||
if (!data->first_frm)
|
if (meta) {
|
||||||
data->first_frm = mpp_time();
|
ret = mpp_meta_get_packet(meta, KEY_INPUT_PACKET, &packet_ret);
|
||||||
|
if (ret || !packet_ret) {
|
||||||
/* write frame to file here */
|
mpp_err("%p mpp meta get packet failed ret %d\n", ctx, ret);
|
||||||
if (data->fp_output)
|
goto DONE;
|
||||||
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++;
|
|
||||||
|
|
||||||
if (mpp_frame_get_eos(frame_out)) {
|
|
||||||
mpp_log_q(quiet, "%p found eos frame\n", ctx);
|
|
||||||
}
|
|
||||||
fps_calc_inc(cmd->fps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->frame_num > 0) {
|
if (packet_ret != packet)
|
||||||
if (data->frame_count >= data->frame_num)
|
mpp_err_f("mismatch packet %p -> %p\n", packet, packet_ret);
|
||||||
data->loop_end = 1;
|
|
||||||
} else if (data->frame_num == 0) {
|
|
||||||
if (slot->eos)
|
|
||||||
data->loop_end = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* output queue */
|
|
||||||
ret = mpi->enqueue(ctx, MPP_PORT_OUTPUT, task);
|
|
||||||
if (ret)
|
|
||||||
mpp_err("%p mpp task output enqueue failed\n", ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (data->frame_num > 0) {
|
||||||
* The following input port task dequeue and enqueue is to make sure that
|
if (data->frame_count >= data->frame_num)
|
||||||
* the input packet can be released. We can directly deinit the input packet
|
data->loop_end = 1;
|
||||||
* after frame output in most cases.
|
} else if (data->frame_num == 0) {
|
||||||
*/
|
if (slot->eos)
|
||||||
if (0) {
|
data->loop_end = 1;
|
||||||
mpp_packet_deinit(&packet);
|
|
||||||
} else {
|
|
||||||
ret = mpi->dequeue(ctx, MPP_PORT_INPUT, &task); /* input queue */
|
|
||||||
if (ret) {
|
|
||||||
mpp_err("%p mpp task input dequeue failed\n", ctx);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
mpp_assert(task);
|
|
||||||
if (task) {
|
|
||||||
MppPacket packet_out = NULL;
|
|
||||||
|
|
||||||
mpp_task_meta_get_packet(task, KEY_INPUT_PACKET, &packet_out);
|
|
||||||
|
|
||||||
if (!packet_out || packet_out != packet)
|
|
||||||
mpp_err_f("mismatch packet %p -> %p\n", packet, packet_out);
|
|
||||||
|
|
||||||
mpp_packet_deinit(&packet_out);
|
|
||||||
|
|
||||||
/* input empty task back to mpp to maintain task status */
|
|
||||||
ret = mpi->enqueue(ctx, MPP_PORT_INPUT, task);
|
|
||||||
if (ret)
|
|
||||||
mpp_err("%p mpp task input enqueue failed\n", ctx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DONE:
|
||||||
|
mpp_packet_deinit(&packet);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user