[test]: Add quiet flag to decoder test log

Change-Id: I9472760ede918a913957b336665d7e0367b661c5
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen
2021-04-29 16:08:21 +08:00
parent cdec28698c
commit dbda66de53
4 changed files with 48 additions and 38 deletions

View File

@@ -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,8 +147,8 @@ 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",
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) {
@@ -187,7 +190,7 @@ 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_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)
@@ -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);

View File

@@ -23,7 +23,6 @@
#include <string.h>
#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,8 +153,8 @@ 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",
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) {
@@ -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_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("decode_get_frame get frame %d\n",
mpp_log_q(quiet, "decode_get_frame get frame %d\n",
data->frame_count);
}
data->frame_count++;
if (data->fp_output && !err_info)

View File

@@ -23,7 +23,6 @@
#include <string.h>
#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,8 +171,8 @@ 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",
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);
/*
@@ -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) {

View File

@@ -19,6 +19,7 @@
#include <stdio.h>
#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