mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-03 08:16:23 +08:00
[mpi_enc_test]: add slt testcase
slt verify file: mpi_enc_test -w 4096 -h 2304 -t 7 -slt enc_xxx.verify -n 5 mpi_dec_test -i <inputfile> -t 7 -slt dec_xxx.verify -n 5 Change-Id: I528fcd8d1adf8821c1555790cd8482108f219fdc Signed-off-by: Hongjin Li <vic.hong@rock-chips.com>
This commit is contained in:
@@ -55,6 +55,8 @@ typedef struct {
|
|||||||
float frame_rate;
|
float frame_rate;
|
||||||
RK_S64 elapsed_time;
|
RK_S64 elapsed_time;
|
||||||
RK_S64 delay;
|
RK_S64 delay;
|
||||||
|
FILE *fp_verify;
|
||||||
|
FrmCrc checkcrc;
|
||||||
} MpiDecLoopData;
|
} MpiDecLoopData;
|
||||||
|
|
||||||
static int dec_simple(MpiDecLoopData *data)
|
static int dec_simple(MpiDecLoopData *data)
|
||||||
@@ -68,6 +70,7 @@ static int dec_simple(MpiDecLoopData *data)
|
|||||||
MppPacket packet = data->packet;
|
MppPacket packet = data->packet;
|
||||||
FileBufSlot *slot = NULL;
|
FileBufSlot *slot = NULL;
|
||||||
RK_U32 quiet = data->quiet;
|
RK_U32 quiet = data->quiet;
|
||||||
|
FrmCrc *checkcrc = &data->checkcrc;
|
||||||
|
|
||||||
// when packet size is valid read the input binary file
|
// when packet size is valid read the input binary file
|
||||||
ret = reader_read(cmd->reader, &slot);
|
ret = reader_read(cmd->reader, &slot);
|
||||||
@@ -274,6 +277,11 @@ static int dec_simple(MpiDecLoopData *data)
|
|||||||
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);
|
||||||
|
|
||||||
|
if (data->fp_verify) {
|
||||||
|
calc_frm_crc(frame, checkcrc);
|
||||||
|
write_frm_crc(data->fp_verify, checkcrc);
|
||||||
|
}
|
||||||
|
|
||||||
fps_calc_inc(cmd->fps);
|
fps_calc_inc(cmd->fps);
|
||||||
}
|
}
|
||||||
frm_eos = mpp_frame_get_eos(frame);
|
frm_eos = mpp_frame_get_eos(frame);
|
||||||
@@ -341,6 +349,7 @@ static int dec_advanced(MpiDecLoopData *data)
|
|||||||
MppTask task = NULL;
|
MppTask task = NULL;
|
||||||
RK_U32 quiet = data->quiet;
|
RK_U32 quiet = data->quiet;
|
||||||
FileBufSlot *slot = NULL;
|
FileBufSlot *slot = NULL;
|
||||||
|
FrmCrc *checkcrc = &data->checkcrc;
|
||||||
|
|
||||||
ret = reader_index_read(cmd->reader, 0, &slot);
|
ret = reader_index_read(cmd->reader, 0, &slot);
|
||||||
mpp_assert(ret == MPP_OK);
|
mpp_assert(ret == MPP_OK);
|
||||||
@@ -406,6 +415,11 @@ 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);
|
||||||
|
|
||||||
|
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);
|
mpp_log_q(quiet, "%p decoded frame %d\n", ctx, data->frame_count);
|
||||||
data->frame_count++;
|
data->frame_count++;
|
||||||
|
|
||||||
@@ -472,6 +486,10 @@ void *thread_decode(void *arg)
|
|||||||
MppApi *mpi = data->mpi;
|
MppApi *mpi = data->mpi;
|
||||||
RK_S64 t_s, t_e;
|
RK_S64 t_s, t_e;
|
||||||
|
|
||||||
|
memset(&data->checkcrc, 0, sizeof(data->checkcrc));
|
||||||
|
data->checkcrc.luma.sum = mpp_malloc(RK_ULONG, 512);
|
||||||
|
data->checkcrc.chroma.sum = mpp_malloc(RK_ULONG, 512);
|
||||||
|
|
||||||
t_s = mpp_time();
|
t_s = mpp_time();
|
||||||
|
|
||||||
if (cmd->simple) {
|
if (cmd->simple) {
|
||||||
@@ -501,6 +519,9 @@ void *thread_decode(void *arg)
|
|||||||
data->frame_count, (RK_S64)(data->elapsed_time / 1000),
|
data->frame_count, (RK_S64)(data->elapsed_time / 1000),
|
||||||
(RK_S32)(data->delay / 1000), data->frame_rate);
|
(RK_S32)(data->delay / 1000), data->frame_rate);
|
||||||
|
|
||||||
|
MPP_FREE(data->checkcrc.luma.sum);
|
||||||
|
MPP_FREE(data->checkcrc.chroma.sum);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,6 +565,12 @@ int dec_decode(MpiDecTestCmd *cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmd->file_slt) {
|
||||||
|
data.fp_verify = fopen(cmd->file_slt, "wt");
|
||||||
|
if (!data.fp_verify)
|
||||||
|
mpp_err("failed to open verify file %s\n", cmd->file_slt);
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd->simple) {
|
if (cmd->simple) {
|
||||||
ret = mpp_packet_init(&packet, NULL, 0);
|
ret = mpp_packet_init(&packet, NULL, 0);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@@ -53,6 +53,7 @@ typedef struct {
|
|||||||
// src and dst
|
// src and dst
|
||||||
FILE *fp_input;
|
FILE *fp_input;
|
||||||
FILE *fp_output;
|
FILE *fp_output;
|
||||||
|
FILE *fp_verify;
|
||||||
|
|
||||||
/* encoder config set */
|
/* encoder config set */
|
||||||
MppEncCfg cfg;
|
MppEncCfg cfg;
|
||||||
@@ -196,6 +197,10 @@ MPP_RET test_ctx_init(MpiEncMultiCtxInfo *info)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->fp_verify = fopen(cmd->file_slt, "wt");
|
||||||
|
if (!p->fp_verify)
|
||||||
|
mpp_err("failed to open verify file %s\n", cmd->file_slt);
|
||||||
|
|
||||||
// update resource parameter
|
// update resource parameter
|
||||||
switch (p->fmt & MPP_FRAME_FMT_MASK) {
|
switch (p->fmt & MPP_FRAME_FMT_MASK) {
|
||||||
case MPP_FMT_YUV420SP:
|
case MPP_FMT_YUV420SP:
|
||||||
@@ -489,8 +494,12 @@ MPP_RET test_mpp_run(MpiEncMultiCtxInfo *info)
|
|||||||
RK_U32 quiet = cmd->quiet;
|
RK_U32 quiet = cmd->quiet;
|
||||||
RK_S32 chn = info->chn;
|
RK_S32 chn = info->chn;
|
||||||
RK_U32 cap_num = 0;
|
RK_U32 cap_num = 0;
|
||||||
|
DataCrc checkcrc;
|
||||||
MPP_RET ret = MPP_OK;
|
MPP_RET ret = MPP_OK;
|
||||||
|
|
||||||
|
memset(&checkcrc, 0, sizeof(checkcrc));
|
||||||
|
checkcrc.sum = mpp_malloc(RK_ULONG, 512);
|
||||||
|
|
||||||
if (p->type == MPP_VIDEO_CodingAVC || p->type == MPP_VIDEO_CodingHEVC) {
|
if (p->type == MPP_VIDEO_CodingAVC || p->type == MPP_VIDEO_CodingHEVC) {
|
||||||
MppPacket packet = NULL;
|
MppPacket packet = NULL;
|
||||||
|
|
||||||
@@ -716,6 +725,12 @@ MPP_RET test_mpp_run(MpiEncMultiCtxInfo *info)
|
|||||||
if (p->fp_output)
|
if (p->fp_output)
|
||||||
fwrite(ptr, 1, len, p->fp_output);
|
fwrite(ptr, 1, len, p->fp_output);
|
||||||
|
|
||||||
|
if (p->fp_verify && !p->pkt_eos) {
|
||||||
|
calc_data_crc((RK_U8 *)ptr, (RK_U32)len, &checkcrc);
|
||||||
|
mpp_log("p->frame_count=%d, len=%d\n", p->frame_count, len);
|
||||||
|
write_data_crc(p->fp_verify, &checkcrc);
|
||||||
|
}
|
||||||
|
|
||||||
log_len += snprintf(log_buf + log_len, log_size - log_len,
|
log_len += snprintf(log_buf + log_len, log_size - log_len,
|
||||||
"encoded frame %-4d", p->frame_count);
|
"encoded frame %-4d", p->frame_count);
|
||||||
|
|
||||||
@@ -778,6 +793,8 @@ MPP_RET test_mpp_run(MpiEncMultiCtxInfo *info)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
RET:
|
RET:
|
||||||
|
MPP_FREE(checkcrc.sum);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -86,6 +86,7 @@ OptionInfo mpi_dec_cmd[] = {
|
|||||||
{"n", "frame_number", "max output frame number"},
|
{"n", "frame_number", "max output frame number"},
|
||||||
{"s", "instance_nb", "number of instances"},
|
{"s", "instance_nb", "number of instances"},
|
||||||
{"v", "trace", "q - quiet f - show fps"},
|
{"v", "trace", "q - quiet f - show fps"},
|
||||||
|
{"c", "verify_file", "verify file for slt check"},
|
||||||
{NULL},
|
{NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -573,6 +574,24 @@ RK_S32 mpi_dec_opt_v(void *ctx, const char *next)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RK_S32 mpi_dec_opt_slt(void *ctx, const char *next)
|
||||||
|
{
|
||||||
|
MpiDecTestCmd *cmd = (MpiDecTestCmd *)ctx;
|
||||||
|
|
||||||
|
if (next) {
|
||||||
|
size_t len = strnlen(next, MAX_FILE_NAME_LENGTH);
|
||||||
|
if (len) {
|
||||||
|
cmd->file_slt = mpp_calloc(char, len + 1);
|
||||||
|
strncpy(cmd->file_slt, next, len);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mpp_err("input slt verify file is invalid\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
RK_S32 mpi_dec_opt_help(void *ctx, const char *next)
|
RK_S32 mpi_dec_opt_help(void *ctx, const char *next)
|
||||||
{
|
{
|
||||||
(void)ctx;
|
(void)ctx;
|
||||||
@@ -591,6 +610,7 @@ static MppOptInfo dec_opts[] = {
|
|||||||
{"n", "frame_number", "max output frame number", mpi_dec_opt_n},
|
{"n", "frame_number", "max output frame number", mpi_dec_opt_n},
|
||||||
{"s", "instance_nb", "number of instances", mpi_dec_opt_s},
|
{"s", "instance_nb", "number of instances", mpi_dec_opt_s},
|
||||||
{"v", "trace option", "q - quiet f - show fps", mpi_dec_opt_v},
|
{"v", "trace option", "q - quiet f - show fps", mpi_dec_opt_v},
|
||||||
|
{"slt", "slt file", "slt verify data file", mpi_dec_opt_slt},
|
||||||
{"help", "help", "show help", mpi_dec_opt_help},
|
{"help", "help", "show help", mpi_dec_opt_help},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -695,6 +715,8 @@ RK_S32 mpi_dec_test_cmd_deinit(MpiDecTestCmd* cmd)
|
|||||||
cmd->reader = NULL;
|
cmd->reader = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MPP_FREE(cmd->file_slt);
|
||||||
|
|
||||||
if (cmd->fps) {
|
if (cmd->fps) {
|
||||||
fps_calc_deinit(cmd->fps);
|
fps_calc_deinit(cmd->fps);
|
||||||
cmd->fps = NULL;
|
cmd->fps = NULL;
|
||||||
@@ -715,4 +737,5 @@ void mpi_dec_test_cmd_options(MpiDecTestCmd* cmd)
|
|||||||
mpp_log("height : %4d\n", cmd->height);
|
mpp_log("height : %4d\n", cmd->height);
|
||||||
mpp_log("type : %4d\n", cmd->type);
|
mpp_log("type : %4d\n", cmd->type);
|
||||||
mpp_log("max frames : %4d\n", cmd->frame_num);
|
mpp_log("max frames : %4d\n", cmd->frame_num);
|
||||||
|
mpp_log("verify : %s\n", cmd->file_slt);
|
||||||
}
|
}
|
||||||
|
@@ -63,6 +63,7 @@ typedef struct MpiDecTestCmd_t {
|
|||||||
/* runtime log flag */
|
/* runtime log flag */
|
||||||
RK_U32 quiet;
|
RK_U32 quiet;
|
||||||
RK_U32 trace_fps;
|
RK_U32 trace_fps;
|
||||||
|
char *file_slt;
|
||||||
} MpiDecTestCmd;
|
} MpiDecTestCmd;
|
||||||
|
|
||||||
extern OptionInfo mpi_dec_cmd[];
|
extern OptionInfo mpi_dec_cmd[];
|
||||||
|
@@ -418,6 +418,24 @@ RK_S32 mpi_enc_opt_ini(void *ctx, const char *next)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RK_S32 mpi_enc_opt_slt(void *ctx, const char *next)
|
||||||
|
{
|
||||||
|
MpiEncTestArgs *cmd = (MpiEncTestArgs *)ctx;
|
||||||
|
|
||||||
|
if (next) {
|
||||||
|
size_t len = strnlen(next, MAX_FILE_NAME_LENGTH);
|
||||||
|
if (len) {
|
||||||
|
cmd->file_slt = mpp_calloc(char, len + 1);
|
||||||
|
strncpy(cmd->file_slt, next, len);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mpp_err("input slt verify file is invalid\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
RK_S32 mpi_enc_opt_help(void *ctx, const char *next)
|
RK_S32 mpi_enc_opt_help(void *ctx, const char *next)
|
||||||
{
|
{
|
||||||
(void)ctx;
|
(void)ctx;
|
||||||
@@ -443,6 +461,7 @@ static MppOptInfo enc_opts[] = {
|
|||||||
{"v", "trace option", "q - quiet f - show fps", mpi_enc_opt_v},
|
{"v", "trace option", "q - quiet f - show fps", mpi_enc_opt_v},
|
||||||
{"l", "loop count", "loop encoding times for each frame", mpi_enc_opt_l},
|
{"l", "loop count", "loop encoding times for each frame", mpi_enc_opt_l},
|
||||||
{"ini", "ini file", "encoder extra ini config file", mpi_enc_opt_ini},
|
{"ini", "ini file", "encoder extra ini config file", mpi_enc_opt_ini},
|
||||||
|
{"slt", "slt file", "slt verify data file", mpi_enc_opt_slt},
|
||||||
};
|
};
|
||||||
|
|
||||||
static RK_U32 enc_opt_cnt = MPP_ARRAY_ELEMS(enc_opts);
|
static RK_U32 enc_opt_cnt = MPP_ARRAY_ELEMS(enc_opts);
|
||||||
@@ -578,6 +597,7 @@ MPP_RET mpi_enc_test_cmd_put(MpiEncTestArgs* cmd)
|
|||||||
MPP_FREE(cmd->file_input);
|
MPP_FREE(cmd->file_input);
|
||||||
MPP_FREE(cmd->file_output);
|
MPP_FREE(cmd->file_output);
|
||||||
MPP_FREE(cmd->file_cfg);
|
MPP_FREE(cmd->file_cfg);
|
||||||
|
MPP_FREE(cmd->file_slt);
|
||||||
MPP_FREE(cmd);
|
MPP_FREE(cmd);
|
||||||
|
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
@@ -932,6 +952,7 @@ MPP_RET mpi_enc_test_cmd_show_opt(MpiEncTestArgs* cmd)
|
|||||||
mpp_log("height : %d\n", cmd->height);
|
mpp_log("height : %d\n", cmd->height);
|
||||||
mpp_log("format : %d\n", cmd->format);
|
mpp_log("format : %d\n", cmd->format);
|
||||||
mpp_log("type : %d\n", cmd->type);
|
mpp_log("type : %d\n", cmd->type);
|
||||||
|
mpp_log("verify : %s\n", cmd->file_slt);
|
||||||
|
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
@@ -66,6 +66,7 @@ typedef struct MpiEncTestArgs_t {
|
|||||||
FpsCalc fps;
|
FpsCalc fps;
|
||||||
RK_U32 psnr_en;
|
RK_U32 psnr_en;
|
||||||
RK_U32 ssim_en;
|
RK_U32 ssim_en;
|
||||||
|
char *file_slt;
|
||||||
} MpiEncTestArgs;
|
} MpiEncTestArgs;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
142
utils/utils.c
142
utils/utils.c
@@ -26,6 +26,10 @@
|
|||||||
#include "mpp_common.h"
|
#include "mpp_common.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#define MAX_HALF_WORD_SUM_CNT \
|
||||||
|
((RK_ULONG)((0-1) / ((1UL << ((__SIZEOF_POINTER__ * 8) / 2)) - 1)))
|
||||||
|
#define CAL_BYTE (__SIZEOF_POINTER__ >> 1)
|
||||||
|
|
||||||
void _show_options(int count, OptionInfo *options)
|
void _show_options(int count, OptionInfo *options)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -187,17 +191,45 @@ void dump_mpp_frame_to_file(MppFrame frame, FILE *fp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wide_bit_sum(RK_U8 *data, RK_U32 len, RK_ULONG *sum)
|
||||||
|
{
|
||||||
|
RK_U8 *data8 = NULL;
|
||||||
|
RK_U32 loop;
|
||||||
|
data8 = data;
|
||||||
|
#if __WORDSIZE == 32
|
||||||
|
RK_U16 *data_rk = NULL;
|
||||||
|
data_rk = (RK_U16 *)data;
|
||||||
|
#elif __WORDSIZE == 64
|
||||||
|
RK_U32 *data_rk = NULL;
|
||||||
|
data_rk = (RK_U32 *)data;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (loop = 0; loop < len / CAL_BYTE; loop++) {
|
||||||
|
*sum += data_rk[loop];
|
||||||
|
}
|
||||||
|
for (loop = len / CAL_BYTE * CAL_BYTE; loop < len; loop++) {
|
||||||
|
*sum += data8[loop];
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void calc_data_crc(RK_U8 *dat, RK_U32 len, DataCrc *crc)
|
void calc_data_crc(RK_U8 *dat, RK_U32 len, DataCrc *crc)
|
||||||
{
|
{
|
||||||
RK_U32 i = 0;
|
RK_ULONG data_grp_byte_cnt = MAX_HALF_WORD_SUM_CNT * CAL_BYTE;
|
||||||
|
RK_U32 i = 0, grp_loop = 0;
|
||||||
RK_U8 *dat8 = NULL;
|
RK_U8 *dat8 = NULL;
|
||||||
RK_U32 *dat32 = NULL;
|
RK_U32 *dat32 = NULL;
|
||||||
RK_U32 sum = 0, xor = 0;
|
RK_U32 xor = 0;
|
||||||
|
|
||||||
/*calc sum */
|
/*calc sum */
|
||||||
dat8 = dat;
|
crc->sum_cnt = (len + data_grp_byte_cnt - 1) / data_grp_byte_cnt;
|
||||||
for (i = 0; i < len; i++)
|
for (grp_loop = 0; grp_loop < len / data_grp_byte_cnt; grp_loop++) {
|
||||||
sum += dat8[i];
|
wide_bit_sum(&dat[grp_loop * data_grp_byte_cnt], data_grp_byte_cnt, &crc->sum[grp_loop]);
|
||||||
|
}
|
||||||
|
if (len % data_grp_byte_cnt) {
|
||||||
|
wide_bit_sum(&dat[grp_loop * data_grp_byte_cnt], len % data_grp_byte_cnt, &crc->sum[grp_loop]);
|
||||||
|
}
|
||||||
|
|
||||||
/*calc xor */
|
/*calc xor */
|
||||||
dat32 = (RK_U32 *)dat;
|
dat32 = (RK_U32 *)dat;
|
||||||
@@ -213,23 +245,34 @@ void calc_data_crc(RK_U8 *dat, RK_U32 len, DataCrc *crc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
crc->len = len;
|
crc->len = len;
|
||||||
crc->sum = sum;
|
|
||||||
crc->vor = xor;
|
crc->vor = xor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_data_crc(FILE *fp, DataCrc *crc)
|
void write_data_crc(FILE *fp, DataCrc *crc)
|
||||||
{
|
{
|
||||||
|
RK_U32 loop = 0;
|
||||||
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fprintf(fp, "%d, %08x, %08x\n", crc->len, crc->sum, crc->vor);
|
fprintf(fp, "%08d,", crc->len);
|
||||||
|
for (loop = 0; loop < crc->sum_cnt; loop++) {
|
||||||
|
fprintf(fp, " %lx,", crc->sum[loop]);
|
||||||
|
}
|
||||||
|
fprintf(fp, " %08x\n", crc->vor);
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_data_crc(FILE *fp, DataCrc *crc)
|
void read_data_crc(FILE *fp, DataCrc *crc)
|
||||||
{
|
{
|
||||||
|
RK_U32 loop = 0;
|
||||||
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
RK_S32 ret = 0;
|
RK_S32 ret = 0;
|
||||||
ret = fscanf(fp, "%d, %08x, %08x\n", &crc->len, &crc->sum, &crc->vor);
|
ret = fscanf(fp, "%8d", &crc->len);
|
||||||
|
for (loop = 0; loop < crc->sum_cnt; loop++) {
|
||||||
|
ret |= fscanf(fp, "%lx", &crc->sum[loop]);
|
||||||
|
}
|
||||||
|
ret |= fscanf(fp, "%08x", &crc->vor);
|
||||||
if (ret == EOF)
|
if (ret == EOF)
|
||||||
mpp_err_f("unexpected EOF found\n");
|
mpp_err_f("unexpected EOF found\n");
|
||||||
}
|
}
|
||||||
@@ -237,64 +280,111 @@ void read_data_crc(FILE *fp, DataCrc *crc)
|
|||||||
|
|
||||||
void calc_frm_crc(MppFrame frame, FrmCrc *crc)
|
void calc_frm_crc(MppFrame frame, FrmCrc *crc)
|
||||||
{
|
{
|
||||||
|
RK_ULONG data_grp_byte_cnt = MAX_HALF_WORD_SUM_CNT * CAL_BYTE;
|
||||||
|
RK_U32 grp_line_cnt = 0;
|
||||||
|
RK_U32 grp_cnt = 0;
|
||||||
|
|
||||||
RK_U32 y = 0, x = 0;
|
RK_U32 y = 0, x = 0;
|
||||||
RK_U8 *dat8 = NULL;
|
RK_U8 *dat8 = NULL;
|
||||||
RK_U32 *dat32 = NULL;
|
RK_U32 *dat32 = NULL;
|
||||||
RK_U32 sum = 0, xor = 0;
|
RK_U32 xor = 0;
|
||||||
|
|
||||||
RK_U32 width = mpp_frame_get_width(frame);
|
RK_U32 width = mpp_frame_get_width(frame);
|
||||||
RK_U32 height = mpp_frame_get_height(frame);
|
RK_U32 height = mpp_frame_get_height(frame);
|
||||||
RK_U32 stride = mpp_frame_get_hor_stride(frame);
|
RK_U32 stride = mpp_frame_get_hor_stride(frame);
|
||||||
RK_U8 *buf = (RK_U8 *)mpp_buffer_get_ptr(mpp_frame_get_buffer(frame));
|
RK_U8 *buf = (RK_U8 *)mpp_buffer_get_ptr(mpp_frame_get_buffer(frame));
|
||||||
|
|
||||||
/* luma */
|
grp_line_cnt = data_grp_byte_cnt / ((width + CAL_BYTE - 1) / CAL_BYTE * CAL_BYTE);
|
||||||
dat8 = buf;
|
|
||||||
for (y = 0; y < height; y++)
|
|
||||||
for (x = 0; x < width; x++)
|
|
||||||
sum += dat8[y * stride + x];
|
|
||||||
|
|
||||||
|
/* luma */
|
||||||
|
grp_cnt = (height + grp_line_cnt - 1) / grp_line_cnt;
|
||||||
|
crc->luma.sum_cnt = grp_cnt;
|
||||||
|
|
||||||
|
dat8 = buf;
|
||||||
|
for (y = 0; y < height / grp_line_cnt * grp_line_cnt; y++) {
|
||||||
|
wide_bit_sum(&dat8[y * stride], width, &crc->luma.sum[y / grp_line_cnt]);
|
||||||
|
}
|
||||||
|
if (height % grp_line_cnt) {
|
||||||
|
for (y = height / grp_line_cnt * grp_line_cnt; y < height; y++) {
|
||||||
|
wide_bit_sum(&dat8[y * stride], width, &crc->luma.sum[y / grp_line_cnt]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dat8 = buf;
|
||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
dat32 = (RK_U32 *)&dat8[y * stride];
|
dat32 = (RK_U32 *)&dat8[y * stride];
|
||||||
for (x = 0; x < width / 4; x++)
|
for (x = 0; x < width / 4; x++)
|
||||||
xor ^= dat32[x];
|
xor ^= dat32[x];
|
||||||
}
|
}
|
||||||
crc->luma.len = height * width;
|
crc->luma.len = height * width;
|
||||||
crc->luma.sum = sum;
|
|
||||||
crc->luma.vor = xor;
|
crc->luma.vor = xor;
|
||||||
|
|
||||||
/* chroma */
|
/* chroma */
|
||||||
dat8 = buf + height * stride;
|
grp_cnt = (height / 2 + grp_line_cnt - 1) / grp_line_cnt;
|
||||||
for (y = 0; y < height / 2; y++)
|
crc->chroma.sum_cnt = grp_cnt;
|
||||||
for (x = 0; x < width; x++)
|
|
||||||
sum += dat8[y * stride + x];
|
|
||||||
|
|
||||||
|
dat8 = buf + height * stride;
|
||||||
|
for (y = 0; y < height / 2 / grp_line_cnt * grp_line_cnt; y++) {
|
||||||
|
wide_bit_sum(&dat8[y * stride], width, &crc->chroma.sum[y / grp_line_cnt]);
|
||||||
|
}
|
||||||
|
if (height / 2 % grp_line_cnt) {
|
||||||
|
for (y = height / 2 / grp_line_cnt * grp_line_cnt; y < height / 2; y++) {
|
||||||
|
wide_bit_sum(&dat8[y * stride], width, &crc->chroma.sum[y / grp_line_cnt]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dat8 = buf + height * stride;
|
||||||
for (y = 0; y < height / 2; y++) {
|
for (y = 0; y < height / 2; y++) {
|
||||||
dat32 = (RK_U32 *)&dat8[y * stride];
|
dat32 = (RK_U32 *)&dat8[y * stride];
|
||||||
for (x = 0; x < width / 4; x++)
|
for (x = 0; x < width / 4; x++)
|
||||||
xor ^= dat32[x];
|
xor ^= dat32[x];
|
||||||
}
|
}
|
||||||
crc->chroma.len = height * width / 2;
|
crc->chroma.len = height * width / 2;
|
||||||
crc->chroma.sum = sum;
|
|
||||||
crc->chroma.vor = xor;
|
crc->chroma.vor = xor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_frm_crc(FILE *fp, FrmCrc *crc)
|
void write_frm_crc(FILE *fp, FrmCrc *crc)
|
||||||
{
|
{
|
||||||
|
RK_U32 loop = 0;
|
||||||
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fprintf(fp, "%d, %08x, %08x, %d, %08x, %08x\n",
|
// luma
|
||||||
crc->luma.len, crc->luma.sum, crc->luma.vor,
|
fprintf(fp, "%d,", crc->luma.len);
|
||||||
crc->chroma.len, crc->chroma.sum, crc->chroma.vor);
|
for (loop = 0; loop < crc->luma.sum_cnt; loop++) {
|
||||||
|
fprintf(fp, " %lx,", crc->luma.sum[loop]);
|
||||||
|
}
|
||||||
|
fprintf(fp, " %08x,", crc->luma.vor);
|
||||||
|
|
||||||
|
// chroma
|
||||||
|
fprintf(fp, " %d,", crc->chroma.len);
|
||||||
|
for (loop = 0; loop < crc->chroma.sum_cnt; loop++) {
|
||||||
|
fprintf(fp, " %lx,", crc->chroma.sum[loop]);
|
||||||
|
}
|
||||||
|
fprintf(fp, " %08x\n", crc->chroma.vor);
|
||||||
|
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_frm_crc(FILE *fp, FrmCrc *crc)
|
void read_frm_crc(FILE *fp, FrmCrc *crc)
|
||||||
{
|
{
|
||||||
|
RK_U32 loop = 0;
|
||||||
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
RK_S32 ret = 0;
|
RK_S32 ret = 0;
|
||||||
ret = fscanf(fp, "%d, %08x, %08x, %d, %08x, %08x\n",
|
// luma
|
||||||
&crc->luma.len, &crc->luma.sum, &crc->luma.vor,
|
ret = fscanf(fp, "%d", &crc->luma.len);
|
||||||
&crc->chroma.len, &crc->chroma.sum, &crc->chroma.vor);
|
for (loop = 0; loop < crc->luma.sum_cnt; loop++) {
|
||||||
|
ret |= fscanf(fp, "%lx", &crc->luma.sum[loop]);
|
||||||
|
}
|
||||||
|
ret |= fscanf(fp, "%08x", &crc->luma.vor);
|
||||||
|
|
||||||
|
// chroma
|
||||||
|
ret |= fscanf(fp, "%d", &crc->chroma.len);
|
||||||
|
for (loop = 0; loop < crc->chroma.sum_cnt; loop++) {
|
||||||
|
ret |= fscanf(fp, "%lx", &crc->chroma.sum[loop]);
|
||||||
|
}
|
||||||
|
ret |= fscanf(fp, "%08x", &crc->chroma.vor);
|
||||||
if (ret == EOF)
|
if (ret == EOF)
|
||||||
mpp_err_f("unexpected EOF found\n");
|
mpp_err_f("unexpected EOF found\n");
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,8 @@ typedef struct OptionInfo_t {
|
|||||||
|
|
||||||
typedef struct data_crc_t {
|
typedef struct data_crc_t {
|
||||||
RK_U32 len;
|
RK_U32 len;
|
||||||
RK_U32 sum;
|
RK_U32 sum_cnt;
|
||||||
|
RK_ULONG *sum;
|
||||||
RK_U32 vor; // value of the xor
|
RK_U32 vor; // value of the xor
|
||||||
} DataCrc;
|
} DataCrc;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user