report.c
来自「the newest JM software by h.264 JVT offi」· C语言 代码 · 共 1,204 行 · 第 1/5 页
C
1,204 行
else // Create header for new log file
{
fprintf(p_log," ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ \n");
fprintf(p_log,"| Encoder statistics. This file is generated during first encoding session, new sessions will be appended |\n");
fprintf(p_log," ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ \n");
fprintf(p_log,"| ver | Date | Time | Sequence | #Img |P/MbInt| QPI| QPP| QPB| Format |Iperiod| #B | FMES | Hdmd | S.R |#Ref | Freq |Coding|RD-opt|Intra upd|8x8Tr| SNRY 1| SNRU 1| SNRV 1| SNRY N| SNRU N| SNRV N|#Bitr I|#Bitr P|#Bitr B|#Bitr IPB| Total Time | Me Time |\n");
fprintf(p_log," ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ \n");
}
}
else
{
fclose (p_log);
if ((p_log = fopen("log.dat", "a")) == NULL) // File exists, just open for appending
{
snprintf(errortext, ET_SIZE, "Error open file %s \n", "log.dat");
error(errortext, 500);
}
}
fprintf(p_log,"|%5s/%-5s", VERSION, EXT_VERSION);
#ifdef WIN32
_strdate( timebuf );
fprintf(p_log,"| %1.5s |", timebuf );
_strtime( timebuf);
fprintf(p_log," % 1.5s |", timebuf);
#else
now = time ((time_t *) NULL); // Get the system time and put it into 'now' as 'calender time'
time (&now);
l_time = localtime (&now);
strftime (string, sizeof string, "%d-%b-%Y", l_time);
fprintf(p_log,"| %1.5s |", string );
strftime (string, sizeof string, "%H:%M:%S", l_time);
fprintf(p_log," %1.5s |", string );
#endif
for (i=0; i < 40; i++)
name[i] = params->input_file1.fname[i + imax(0, ((int) strlen(params->input_file1.fname)) - 40)]; // write last part of path, max 40 chars
fprintf(p_log,"%40.40s|",name);
fprintf(p_log,"%5d | %d/%d |", params->no_frames, params->PicInterlace, params->MbInterlace);
fprintf(p_log," %-3d| %-3d| %-3d|", params->qp[0][I_SLICE], params->qp[0][P_SLICE], params->qp[0][B_SLICE]);
fprintf(p_log,"%4dx%-4d|", params->output.width, params->output.height);
fprintf(p_log," %3d |%3d |", params->intra_period, stats->NumberBFrames);
switch( params->SearchMode )
{
case UM_HEX:
fprintf(p_log," HEX |");
break;
case UM_HEX_SIMPLE:
fprintf(p_log," SHEX |");
break;
case EPZS:
fprintf(p_log," EPZS |");
break;
case FAST_FULL_SEARCH:
fprintf(p_log," FFS |");
break;
default:
fprintf(p_log," FS |");
break;
}
fprintf(p_log," %1d%1d%1d |", params->MEErrorMetric[F_PEL], params->MEErrorMetric[H_PEL], params->MEErrorMetric[Q_PEL]);
fprintf(p_log," %3d | %2d |", params->search_range, params->num_ref_frames );
fprintf(p_log," %5.2f|", img->framerate);
if (params->symbol_mode == CAVLC)
fprintf(p_log," CAVLC|");
else
fprintf(p_log," CABAC|");
fprintf(p_log," %d |", params->rdopt);
if (params->intra_upd == 1)
fprintf(p_log," ON |");
else
fprintf(p_log," OFF |");
fprintf(p_log," %d |", params->Transform8x8Mode);
fprintf(p_log,"%7.3f|%7.3f|%7.3f|",
dist->metric[PSNR].avslice[I_SLICE][0],
dist->metric[PSNR].avslice[I_SLICE][1],
dist->metric[PSNR].avslice[I_SLICE][2]);
fprintf(p_log,"%7.3f|%7.3f|%7.3f|", dist->metric[PSNR].average[0],dist->metric[PSNR].average[1],dist->metric[PSNR].average[2]);
/*
fprintf(p_log,"%-5.3f|%-5.3f|%-5.3f|", dist->metric[PSNR].avslice[I_SLICE][0], dist->metric[PSNR].avslice[I_SLICE][1], dist->metric[PSNR].avslice[I_SLICE][2]);
fprintf(p_log,"%-5.3f|%-5.3f|%-5.3f|", dist->metric[PSNR].avslice[P_SLICE][0], dist->metric[PSNR].avslice[P_SLICE][1], dist->metric[PSNR].avslice[P_SLICE][2]);
fprintf(p_log,"%-5.3f|%-5.3f|%-5.3f|", dist->metric[PSNR].avslice[B_SLICE][0], dist->metric[PSNR].avslice[B_SLICE][1], dist->metric[PSNR].avslice[B_SLICE][2]);
*/
fprintf(p_log,"%7.0f|%7.0f|%7.0f|%9.0f|", stats->bitrate_st[I_SLICE],stats->bitrate_st[P_SLICE],stats->bitrate_st[B_SLICE], stats->bitrate);
fprintf(p_log," %12d | %12d |", (int)tot_time,(int)me_tot_time);
fprintf(p_log,"\n");
fclose(p_log);
p_log = fopen("data.txt", "a");
if ((stats->NumberBFrames != 0) && (stats->frame_ctr[B_SLICE] != 0)) // B picture used
{
fprintf(p_log, "%3d %2d %2d %2.2f %2.2f %2.2f %5" FORMAT_OFF_T " "
"%2.2f %2.2f %2.2f %5d "
"%2.2f %2.2f %2.2f %5" FORMAT_OFF_T " %5" FORMAT_OFF_T " %.3f\n",
stats->frame_counter, params->qp[0][I_SLICE], params->qp[0][P_SLICE],
dist->metric[PSNR].avslice[I_SLICE][0],
dist->metric[PSNR].avslice[I_SLICE][1],
dist->metric[PSNR].avslice[I_SLICE][2],
stats->bit_counter[I_SLICE],
0.0,
0.0,
0.0,
0,
dist->metric[PSNR].average[0],
dist->metric[PSNR].average[1],
dist->metric[PSNR].average[2],
(stats->bit_counter[I_SLICE] + stats->bit_ctr) / stats->frame_counter,
stats->bit_counter[B_SLICE] / stats->frame_ctr[B_SLICE],
(double) 0.001 * tot_time / (stats->frame_counter));
}
else
{
if (params->no_frames != 0)
fprintf(p_log, "%3d %2d %2d %2.2f %2.2f %2.2f %5" FORMAT_OFF_T " "
"%2.2f %2.2f %2.2f %5d "
"%2.2f %2.2f %2.2f %5" FORMAT_OFF_T " %5d %.3f\n",
stats->frame_counter, params->qp[0][I_SLICE], params->qp[0][P_SLICE],
dist->metric[PSNR].avslice[I_SLICE][0],
dist->metric[PSNR].avslice[I_SLICE][1],
dist->metric[PSNR].avslice[I_SLICE][2],
stats->bit_counter[I_SLICE],
0.0,
0.0,
0.0,
0,
dist->metric[PSNR].average[0],
dist->metric[PSNR].average[1],
dist->metric[PSNR].average[2],
(stats->bit_counter[I_SLICE] + stats->bit_ctr)/ stats->frame_counter,
0,
(double)0.001 * tot_time / stats->frame_counter);
}
fclose(p_log);
}
/*!
************************************************************************
* \brief
* Reports the gathered information to appropriate outputs
* \par Input:
* struct inp_par *inp, \n
* ImageParameters *img, \n
* struct stat_par *stats, \n
*
* \par Output:
* None
************************************************************************
*/
void report( ImageParameters *img, InputParameters *params, StatParameters *stats)
{
int64 bit_use[NUM_SLICE_TYPES][2];
int i,j;
int64 total_bits;
bit_use[ I_SLICE][0] = stats->frame_ctr[I_SLICE];
bit_use[ P_SLICE][0] = imax(stats->frame_ctr[P_SLICE ] + stats->frame_ctr[SP_SLICE], 1);
bit_use[ B_SLICE][0] = imax(stats->frame_ctr[B_SLICE ], 1);
bit_use[SP_SLICE][0] = imax(stats->frame_ctr[SP_SLICE], 1);
// normalize time stats
tot_time = timenorm(tot_time);
me_tot_time = timenorm(me_tot_time);
// Accumulate bit usage for inter and intra frames
for (j=0; j < NUM_SLICE_TYPES; j++)
{
bit_use[j][1] = 0;
}
for (j=0; j < NUM_SLICE_TYPES; j++)
{
for(i=0; i < MAXMODE; i++)
bit_use[j][1] += stats->bit_use_mode[j][i];
bit_use[j][1] += stats->bit_use_mb_type[j];
bit_use[j][1] += stats->bit_use_header[j];
bit_use[j][1] += stats->tmp_bit_use_cbp[j];
bit_use[j][1] += stats->bit_use_coeffC[j];
bit_use[j][1] += stats->bit_use_coeff[0][j];
bit_use[j][1] += stats->bit_use_coeff[1][j];
bit_use[j][1] += stats->bit_use_coeff[2][j];
bit_use[j][1] += stats->bit_use_delta_quant[j];
bit_use[j][1] += stats->bit_use_stuffingBits[j];
}
//! Currently adding NVB bits on P rate. Maybe additional stats info should be created instead and added in log file
stats->bitrate_st[ I_SLICE] = (stats->bit_counter[ I_SLICE]) * (float) (params->output.frame_rate) / (float) (stats->frame_counter);
stats->bitrate_st[ P_SLICE] = (stats->bit_counter[ P_SLICE]) * (float) (params->output.frame_rate) / (float) (stats->frame_counter);
stats->bitrate_st[ B_SLICE] = (stats->bit_counter[ B_SLICE]) * (float) (params->output.frame_rate) / (float) (stats->frame_counter);
stats->bitrate_st[SP_SLICE] = (stats->bit_counter[SP_SLICE]) * (float) (params->output.frame_rate) / (float) (stats->frame_counter);
switch (params->Verbose)
{
case 0:
case 1:
default:
fprintf(stdout,"------------------ Average data all frames -----------------------------------\n\n");
break;
case 2:
fprintf(stdout,"------------------------------------ Average data all frames ---------------------------------\n\n");
break;
case 3:
fprintf(stdout,"--------------------------------------- Average data all frames -------------------------------------\n\n");
break;
}
if (params->Verbose != 0)
{
DistMetric *snr = &dist->metric[PSNR ];
DistMetric *sse = &dist->metric[SSE ];
DistMetric *snr_rgb = &dist->metric[PSNR_RGB];
DistMetric *sse_rgb = &dist->metric[SSE_RGB ];
int impix = params->output.size_cmp[0];
int impix_cr = params->output.size_cmp[1];
float csnr_y = psnr(img->max_imgpel_value_comp_sq[0], impix , sse->average[0]);
float csnr_u = psnr(img->max_imgpel_value_comp_sq[1], impix_cr, sse->average[1]);
float csnr_v = psnr(img->max_imgpel_value_comp_sq[2], impix_cr, sse->average[2]);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?