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