📄 h.264
字号:
}
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,"| Date | Time | Sequence |#Img|Quant1|QuantN|Format|Hadamard|Search r|#Ref | Freq |Intra upd|SNRY 1|SNRU 1|SNRV 1|SNRY N|SNRU N|SNRV N|#Bitr P|#Bitr B|\n");
fprintf(p_log," ----------------------------------------------------------------------------------------------------------------------------------------------------------------- \n");
}
}
else
{
fclose (p_log);
if ((p_log=fopen("log.dat","a"))==NULL) // File exist,just open for appending
{
snprintf(errortext, ET_SIZE, "Error open file %s \n","log.dat");
error(errortext, 500);
}
}
#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<20;i++)
name[i]=input->infile[i+max(0,strlen(input->infile)-20)]; // write last part of path, max 20 chars
fprintf(p_log,"%20.20s|",name);
fprintf(p_log,"%3d |",input->no_frames);
fprintf(p_log," %2d |",input->qp0);
fprintf(p_log," %2d |",input->qpN);
fprintf(p_log,"%dx%d|",input->img_width,input->img_height);
if (input->hadamard==1)
fprintf(p_log," ON |");
else
fprintf(p_log," OFF |");
fprintf(p_log," %2d |",input->search_range );
fprintf(p_log," %2d |",input->num_reference_frames);
fprintf(p_log," %2d |",img->framerate/(input->jumpd+1));
if (input->intra_upd==1)
fprintf(p_log," ON |");
else
fprintf(p_log," OFF |");
fprintf(p_log,"%5.3f|",snr->snr_y1);
fprintf(p_log,"%5.3f|",snr->snr_u1);
fprintf(p_log,"%5.3f|",snr->snr_v1);
fprintf(p_log,"%5.3f|",snr->snr_ya);
fprintf(p_log,"%5.3f|",snr->snr_ua);
fprintf(p_log,"%5.3f|",snr->snr_va);
if(input->successive_Bframe != 0)
{
fprintf(p_log,"%7.0f|",stat->bitrate_P);
fprintf(p_log,"%7.0f|\n",stat->bitrate_B);
}
else
{
fprintf(p_log,"%7.0f|",stat->bitrate);
fprintf(p_log,"%7.0f|\n",0.0);
}
fclose(p_log);
p_log=fopen("data.txt","a");
if(input->successive_Bframe != 0 && Bframe_ctr != 0) // B picture used
{
fprintf(p_log, "%3d %2d %2d %2.2f %2.2f %2.2f %5d "
"%2.2f %2.2f %2.2f %5d "
"%2.2f %2.2f %2.2f %5d %5d %.3f\n",
input->no_frames, input->qp0, input->qpN,
snr->snr_y1,
snr->snr_u1,
snr->snr_v1,
stat->bit_ctr_0,
0.0,
0.0,
0.0,
0,
snr->snr_ya,
snr->snr_ua,
snr->snr_va,
(stat->bit_ctr_0+stat->bit_ctr)/(input->no_frames+Bframe_ctr),
stat->bit_ctr_B/Bframe_ctr,
(double)0.001*tot_time/(input->no_frames+Bframe_ctr));
}
else
{
fprintf(p_log, "%3d %2d %2d %2.2f %2.2f %2.2f %5d "
"%2.2f %2.2f %2.2f %5d "
"%2.2f %2.2f %2.2f %5d %5d %.3f\n",
input->no_frames, input->qp0, input->qpN,
snr->snr_y1,
snr->snr_u1,
snr->snr_v1,
stat->bit_ctr_0,
0.0,
0.0,
0.0,
0,
snr->snr_ya,
snr->snr_ua,
snr->snr_va,
(stat->bit_ctr_0+stat->bit_ctr)/input->no_frames,
0,
(double)0.001*tot_time/input->no_frames);
}
fclose(p_log);
// free(stat->mode_use_Bframe);
// free(stat->bit_use_mode_Bframe);
}
/*!
************************************************************************
* \brief
* Prints the header of the protocol.
* \par Input:
* struct inp_par *inp
* \par Output:
* none
************************************************************************
*/
void information_init()
{
printf("--------------------------------------------------------------------------\n");
printf(" Input YUV file : %s \n",input->infile);
printf(" Output H.26L bitstream : %s \n",input->outfile);
if (p_dec != NULL)
printf(" Output YUV file : %s \n",input->ReconFile);
printf(" Output log file : log.dat \n");
printf(" Output statistics file : stat.dat \n");
printf("--------------------------------------------------------------------------\n");
printf(" Frame Bit/pic QP SnrY SnrU SnrV Time(ms) Frm/Fld IntraMBs\n");
}
/*!
************************************************************************
* \brief
* Dynamic memory allocation of frame size related global buffers
* buffers are defined in global.h, allocated memory must be freed in
* void free_global_buffers()
* \par Input:
* Input Parameters struct inp_par *inp, \n
* Image Parameters struct img_par *img
* \return Number of allocated bytes
************************************************************************
*/
int init_global_buffers()
{
int j,memory_size=0;
int height_field = img->height/2;
#ifdef _ADAPT_LAST_GROUP_
extern int *last_P_no_frm;
extern int *last_P_no_fld;
if ((last_P_no_frm = (int*)malloc(2*img->buf_cycle*sizeof(int))) == NULL)
no_mem_exit("init_global_buffers: last_P_no");
if(input->InterlaceCodingOption != FRAME_CODING)
if ((last_P_no_fld = (int*)malloc(4*img->buf_cycle*sizeof(int))) == NULL)
no_mem_exit("init_global_buffers: last_P_no");
#endif
if(input->InterlaceCodingOption >= MB_CODING)
memory_size += get_mem2Dint(&field_mb, img->height/MB_BLOCK_SIZE, img->width/MB_BLOCK_SIZE);
// allocate memory for encoding frame buffers: imgY, imgUV
// allocate memory for reference frame buffers: imgY_org, imgUV_org
// byte imgY_org[288][352];
// byte imgUV_org[2][144][176];
memory_size += get_mem2D(&imgY_org_frm, img->height, img->width);
memory_size += get_mem3D(&imgUV_org_frm, 2, img->height_cr, img->width_cr);
// allocate memory for temp P and B-frame motion vector buffer: tmp_mv, temp_mv_block
// int tmp_mv[2][72][92]; ([2][72][88] should be enough)
memory_size += get_mem3Dint(&tmp_mv_frm, 2, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE+4);
// allocate memory for reference frames of each block: refFrArr
// int refFrArr[72][88];
memory_size += get_mem2Dint(&refFrArr_frm, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE);
memory_size += get_mem2Dint(&abp_type_FrArr, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE);
memory_size += get_mem2Dint(&(img->field_anchor),img->height/BLOCK_SIZE,img->width/BLOCK_SIZE);
if(input->successive_Bframe!=0 || input->StoredBPictures > 0)
{
// allocate memory for temp B-frame motion vector buffer: fw_refFrArr, bw_refFrArr
// int ...refFrArr[72][88];
memory_size += get_mem2Dint(&fw_refFrArr_frm, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE);
memory_size += get_mem2Dint(&bw_refFrArr_frm, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE);
// allocate memory for temp B-frame direct ref-frame buffer: fwdir_refFrArr, bwdir_refFrArr
// int ...refFrArr[72][88];
if(input->direct_type == DIR_SPATIAL)
{
memory_size += get_mem2Dint(&fwdir_refFrArr, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE);
memory_size += get_mem2Dint(&bwdir_refFrArr, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE);
// allocate memory for collocated motion stationarity - int could be replaced with boolean
memory_size += get_mem2Dint(&moving_block_frm, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE);
}
if(input->InterlaceCodingOption >= MB_CODING)
{
memory_size += get_mem3Dint(&tmp_fwMV_top, 2, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE+4);
memory_size += get_mem3Dint(&tmp_fwMV_bot, 2, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE+4);
memory_size += get_mem3Dint(&tmp_bwMV_top, 2, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE+4);
memory_size += get_mem3Dint(&tmp_bwMV_bot, 2, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE+4);
}
}
if(input->successive_Bframe!=0 || input->StoredBPictures > 0)
{
// allocate memory for temp B-frame motion vector buffer: tmp_fwMV, tmp_bwMV, dfMV, dbMV
// int ...MV[2][72][92]; ([2][72][88] should be enough)
memory_size += get_mem3Dint(&tmp_fwMV, 2, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE+4);
memory_size += get_mem3Dint(&tmp_bwMV, 2, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE+4);
memory_size += get_mem3Dint(&dfMV, 2, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE+4);
memory_size += get_mem3Dint(&dbMV, 2, img->height/BLOCK_SIZE, img->width/BLOCK_SIZE+4);
}
// allocate memory for temp quarter pel luma frame buffer: img4Y_tmp
// int img4Y_tmp[576][704]; (previously int imgY_tmp in global.h)
memory_size += get_mem2Dint(&img4Y_tmp, img->height+2*IMG_PAD_SIZE, (img->width+2*IMG_PAD_SIZE)*4);
if (input->rdopt==2)
{
memory_size += get_mem2Dint(&decs->resY, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
if ((decs->decref = (byte****) calloc(input->NoOfDecoders,sizeof(byte***))) == NULL)
no_mem_exit("init_global_buffers: decref");
for (j=0 ; j<input->NoOfDecoders; j++)
{
memory_size += get_mem3D(&decs->decref[j], img->buf_cycle+1, img->height, img->width);
}
memory_size += get_mem2D(&decs->RefBlock, BLOCK_SIZE,BLOCK_SIZE);
memory_size += get_mem3D(&decs->decY, input->NoOfDecoders, img->height, img->width);
memory_size += get_mem3D(&decs->decY_best, input->NoOfDecoders, img->height, img->width);
memory_size += get_mem2D(&decs->status_map, img->height/MB_BLOCK_SIZE,img->width/MB_BLOCK_SIZE);
memory_size += get_mem2D(&decs->dec_mb_mode, img->width/MB_BLOCK_SIZE,img->height/MB_BLOCK_SIZE);
}
if (input->RestrictRef)
{
memory_size += get_mem2D(&pixel_map, img->height,img->width);
memory_size += get_mem2D(&refresh_map, img->height/8,img->width/8);
}
if(input->InterlaceCodingOption != FRAME_CODING)
{
// allocate memory for encoding frame buffers: imgY, imgUV
// byte imgY[288][352];
// byte imgUV[2][144][176];
memory_size += get_mem2D(&imgY_com, img->height, img->width);
memory_size += get_mem3D(&imgUV_com, 2, img->height/2, img->width_cr);
// allocate memory for reference frame buffers: imgY_org, imgUV_org
// byte imgY_org[288][352];
// byte imgUV_org[2][144][176];
memory_size += get_mem2D(&imgY_org_top, height_field, img->width);
memory_size += get_mem3D(&imgUV_org_top, 2, height_field/2, img->width_cr);
memory_size += get_mem2D(&imgY_org_bot, height_field, img->width);
memory_size += get_mem3D(&imgUV_org_bot, 2, height_field/2, img->width_cr);
if(input->successive_Bframe!=0 || input->StoredBPictures > 0)
{
// allocate memory for temp B-frame motion vector buffer: fw_refFrArr, bw_refFrArr
// int ...refFrArr[72][88];
memory_size += get_mem2Dint(&fw_refFrArr_top, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE);
memory_size += get_mem2Dint(&bw_refFrArr_top, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE);
memory_size += get_mem2Dint(&fw_refFrArr_bot, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE);
memory_size += get_mem2Dint(&bw_refFrArr_bot, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE);
if(input->direct_type == DIR_SPATIAL)
{
// allocate memory for collocated motion stationarity - int could be replaced with boolean
memory_size += get_mem2Dint(&moving_block_top, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE);
memory_size += get_mem2Dint(&moving_block_bot, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE);
}
}
// allocate memory for temp P and B-frame motion vector buffer: tmp_mv, temp_mv_block
// int tmp_mv[2][72][92]; ([2][72][88] should be enough)
memory_size += get_mem3Dint(&tmp_mv_top, 2, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE+4);
memory_size += get_mem3Dint(&tmp_mv_bot, 2, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE+4);
// allocate memory for reference frames of each block: refFrArr
// int refFrArr[72][88];
memory_size += get_mem2Dint(&refFrArr_top, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE);
memory_size += get_mem2Dint(&refFrArr_bot, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE);
memory_size += get_mem2Dint(&abp_type_FrArr_top, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE);
memory_size += get_mem2Dint(&abp_type_FrArr_bot, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE);
if(input->InterlaceCodingOption >= MB_CODING)
{
// memory_size += get_mem3Dint(&tmp_mv_top_save, 2, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE+4);
// memory_size += get_mem3Dint(&tmp_mv_bot_save, 2, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE+4);
// memory_size += get_mem2Dint(&refFrArr_top_save, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE);
// memory_size += get_mem2Dint(&refFrArr_bot_save, height_field/BLOCK_SIZE, img->width/BLOCK_SIZE);
}
}
return (memory_size);
}
/*!
************************************************************************
* \brief
* Free allocated memory of frame size related global buffers
* buffers are defined in global.h, allocated memory is allocated in
* int get_mem4global_buffers()
* \par Input:
* Input Parameters struct inp_par *inp, \n
* Image Parameters struct img_par *img
* \par Output:
* none
************************************************************************
*/
void free_global_buffers()
{
int i,j;
#ifdef _ADAPT_LAST_GROUP_
extern int *last_P_no_frm;
extern int *last_P_no_fld;
free (last_P_no_frm);
free (last_P_no_fld);
#endif
free_mem2D(imgY_org_frm); // free ref frame buffers
free_mem3D(imgUV_org_frm,2);
free_mem3Dint(tmp_mv_frm,2);
free_mem2Dint(refFrArr_frm);
// free multiple ref frame buffers
// number of reference frames increased by one for next P-frame
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -