diff --git a/test/mpi_dec_mt_test.c b/test/mpi_dec_mt_test.c index 04b685fc..a46765eb 100644 --- a/test/mpi_dec_mt_test.c +++ b/test/mpi_dec_mt_test.c @@ -25,7 +25,6 @@ #include "rk_mpi.h" -#include "mpp_log.h" #include "mpp_mem.h" #include "mpp_env.h" #include "mpp_time.h" @@ -54,6 +53,9 @@ typedef struct { RK_U64 frame_count; RK_S32 frame_num; FileReader reader; + + /* runtime flag */ + RK_U32 quiet; } MpiDecLoopData; void *thread_input(void *arg) @@ -112,6 +114,7 @@ void *thread_output(void *arg) MppCtx ctx = data->ctx; MppApi *mpi = data->mpi; MppFrame frame = NULL; + RK_U32 quiet = data->quiet; mpp_log("get frame thread start\n"); @@ -144,9 +147,9 @@ void *thread_output(void *arg) RK_U32 ver_stride = mpp_frame_get_ver_stride(frame); RK_U32 buf_size = mpp_frame_get_buf_size(frame); - mpp_log("decode_get_frame get info changed found\n"); - mpp_log("decoder require buffer w:h [%d:%d] stride [%d:%d] size %d\n", - width, height, hor_stride, ver_stride, buf_size); + mpp_log_q(quiet, "decode_get_frame get info changed found\n"); + mpp_log_q(quiet, "decoder require buffer w:h [%d:%d] stride [%d:%d] size %d\n", + width, height, hor_stride, ver_stride, buf_size); if (NULL == data->frm_grp) { /* If buffer group is not set create one and limit it */ @@ -187,8 +190,8 @@ void *thread_output(void *arg) // found normal output frame RK_U32 err_info = mpp_frame_get_errinfo(frame) | mpp_frame_get_discard(frame); if (err_info) - mpp_log("decoder_get_frame get err info:%d discard:%d.\n", - mpp_frame_get_errinfo(frame), mpp_frame_get_discard(frame)); + mpp_log_q(quiet, "decoder_get_frame get err info:%d discard:%d.\n", + mpp_frame_get_errinfo(frame), mpp_frame_get_discard(frame)); if (data->fp_output && !err_info) dump_mpp_frame_to_file(frame, data->fp_output); @@ -220,7 +223,7 @@ void *thread_output(void *arg) } if (mpp_frame_get_eos(frame)) { - mpp_log("found last frame loop again\n"); + mpp_log_q(quiet, "found last frame loop again\n"); // when get a eos status mpp need a reset to restart decoding ret = mpi->reset(ctx); if (MPP_OK != ret) @@ -352,6 +355,7 @@ int mt_dec_decode(MpiDecTestCmd *cmd) data.frame_count = 0; data.frame_num = cmd->frame_num; data.reader = reader; + data.quiet = cmd->quiet; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); diff --git a/test/mpi_dec_multi_test.c b/test/mpi_dec_multi_test.c index f7acfaeb..4bc1b1c2 100644 --- a/test/mpi_dec_multi_test.c +++ b/test/mpi_dec_multi_test.c @@ -23,7 +23,6 @@ #include #include "rk_mpi.h" -#include "mpp_log.h" #include "mpp_mem.h" #include "mpp_env.h" #include "mpp_time.h" @@ -92,16 +91,16 @@ static int multi_dec_simple(MpiDecCtx *data) MppFrame frame = NULL; FileReader reader = data->reader; size_t read_size = 0; + RK_U32 quiet = data->quiet; data->eos = pkt_eos = reader_read(reader, &buf, &read_size); if (pkt_eos) { if (data->frame_num < 0) { - if (!data->quiet) - mpp_log("%p loop again\n", ctx); + mpp_log_q(quiet, "%p loop again\n", ctx); reader_rewind(reader); data->eos = pkt_eos = 0; } else { - mpp_log("%p found last packet\n", ctx); + mpp_log_q(quiet, "%p found last packet\n", ctx); } } @@ -154,9 +153,9 @@ static int multi_dec_simple(MpiDecCtx *data) RK_U32 ver_stride = mpp_frame_get_ver_stride(frame); RK_U32 buf_size = mpp_frame_get_buf_size(frame); - mpp_log("decode_get_frame get info changed found\n"); - mpp_log("decoder require buffer w:h [%d:%d] stride [%d:%d] buf_size %d", - width, height, hor_stride, ver_stride, buf_size); + mpp_log_q(quiet, "decode_get_frame get info changed found\n"); + mpp_log_q(quiet, "decoder require buffer w:h [%d:%d] stride [%d:%d] buf_size %d", + width, height, hor_stride, ver_stride, buf_size); if (NULL == data->frm_grp) { /* If buffer group is not set create one and limit it */ @@ -201,17 +200,15 @@ static int multi_dec_simple(MpiDecCtx *data) if (!data->first_frm) data->first_frm = mpp_time(); - if (!data->quiet) { - err_info = mpp_frame_get_errinfo(frame) | - mpp_frame_get_discard(frame); - if (err_info) { - mpp_log("decoder_get_frame get err info:%d discard:%d.\n", - mpp_frame_get_errinfo(frame), - mpp_frame_get_discard(frame)); - } - mpp_log("decode_get_frame get frame %d\n", - data->frame_count); + err_info = mpp_frame_get_errinfo(frame) | + mpp_frame_get_discard(frame); + if (err_info) { + mpp_log_q(quiet, "decoder_get_frame get err info:%d discard:%d.\n", + mpp_frame_get_errinfo(frame), + mpp_frame_get_discard(frame)); } + mpp_log_q(quiet, "decode_get_frame get frame %d\n", + data->frame_count); data->frame_count++; if (data->fp_output && !err_info) diff --git a/test/mpi_dec_test.c b/test/mpi_dec_test.c index 7968b100..61e06e2a 100644 --- a/test/mpi_dec_test.c +++ b/test/mpi_dec_test.c @@ -23,7 +23,6 @@ #include #include "rk_mpi.h" -#include "mpp_log.h" #include "mpp_mem.h" #include "mpp_env.h" #include "mpp_time.h" @@ -34,6 +33,7 @@ typedef struct { MppCtx ctx; MppApi *mpi; + RK_U32 quiet; /* end of stream flag when set quit the loop */ RK_U32 eos; @@ -70,6 +70,7 @@ static int dec_simple(MpiDecLoopData *data) size_t read_size = 0; size_t packet_size = data->packet_size; FileReader reader = data->reader; + RK_U32 quiet = data->quiet; do { if (data->fp_config) { @@ -109,7 +110,7 @@ static int dec_simple(MpiDecLoopData *data) if (pkt_eos) { if (data->frame_num < 0) { - mpp_log("%p loop again\n", ctx); + mpp_log_q(quiet, "%p loop again\n", ctx); reader_rewind(reader); if (data->fp_config) { clearerr(data->fp_config); @@ -117,7 +118,7 @@ static int dec_simple(MpiDecLoopData *data) } data->eos = pkt_eos = 0; } else { - mpp_log("%p found last packet\n", ctx); + mpp_log_q(quiet, "%p found last packet\n", ctx); break; } } @@ -170,9 +171,9 @@ static int dec_simple(MpiDecLoopData *data) RK_U32 ver_stride = mpp_frame_get_ver_stride(frame); RK_U32 buf_size = mpp_frame_get_buf_size(frame); - mpp_log("%p decode_get_frame get info changed found\n", ctx); - mpp_log("%p decoder require buffer w:h [%d:%d] stride [%d:%d] buf_size %d", - ctx, width, height, hor_stride, ver_stride, buf_size); + mpp_log_q(quiet, "%p decode_get_frame get info changed found\n", ctx); + mpp_log_q(quiet, "%p decoder require buffer w:h [%d:%d] stride [%d:%d] buf_size %d", + ctx, width, height, hor_stride, ver_stride, buf_size); /* * NOTE: We can choose decoder's buffer mode here. @@ -297,7 +298,7 @@ static int dec_simple(MpiDecLoopData *data) log_len += snprintf(log_buf + log_len, log_size - log_len, " err %x discard %x", err_info, discard); } - mpp_log("%p %s\n", ctx, log_buf); + mpp_log_q(quiet, "%p %s\n", ctx, log_buf); data->frame_count++; if (data->fp_output && !err_info) @@ -323,7 +324,7 @@ static int dec_simple(MpiDecLoopData *data) } if (frm_eos) { - mpp_log("%p found last packet\n", ctx); + mpp_log_q(quiet, "%p found last packet\n", ctx); break; } @@ -339,7 +340,7 @@ static int dec_simple(MpiDecLoopData *data) if (data->frame_num > 0 && data->frame_count >= data->frame_num) { data->eos = 1; - mpp_log("%p reach max frame number %d\n", ctx, data->frame_count); + mpp_log_q(quiet, "%p reach max frame number %d\n", ctx, data->frame_count); break; } @@ -370,13 +371,14 @@ static int dec_advanced(MpiDecLoopData *data) MppFrame frame = data->frame; MppTask task = NULL; size_t read_size = fread(buf, 1, data->packet_size, data->fp_input); + RK_U32 quiet = data->quiet; if (read_size != data->packet_size || feof(data->fp_input)) { if (data->frame_num < 0) { clearerr(data->fp_input); rewind(data->fp_input); } else { - mpp_log("%p found last packet\n", ctx); + mpp_log_q(quiet, "%p found last packet\n", ctx); // setup eos flag data->eos = pkt_eos = 1; } @@ -437,11 +439,12 @@ static int dec_advanced(MpiDecLoopData *data) if (data->fp_output) dump_mpp_frame_to_file(frame, data->fp_output); - mpp_log("%p decoded frame %d\n", ctx, data->frame_count); + 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("%p found eos frame\n", ctx); + if (mpp_frame_get_eos(frame_out)) { + mpp_log_q(quiet, "%p found eos frame\n", ctx); + } } if (data->frame_num > 0 && data->frame_count < data->frame_num) { data->eos = 0; @@ -651,6 +654,7 @@ int dec_decode(MpiDecTestCmd *cmd) data.frame_count = 0; data.frame_num = cmd->frame_num; data.reader = reader; + data.quiet = cmd->quiet; if (cmd->simple) { while (!data.eos) { diff --git a/utils/utils.h b/utils/utils.h index 3585b1dc..51a20b23 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -19,6 +19,7 @@ #include +#include "mpp_log.h" #include "mpp_frame.h" typedef struct OptionInfo_t { @@ -38,12 +39,16 @@ typedef struct frame_crc_t { DataCrc chroma; } FrmCrc; - #define show_options(opt) \ do { \ _show_options(sizeof(opt)/sizeof(OptionInfo), opt); \ } while (0) +#define mpp_log_q(quiet, fmt, ...) \ + do { \ + if (!quiet) mpp_log(fmt, ## __VA_ARGS__); \ + } while (0) + #ifdef __cplusplus extern "C" { #endif