📄 lencod.c
字号:
free_mem3D(nextP_imgUV,2);
// free multiple ref frame buffers
// number of reference frames increased by one for next P-frame
if(input->successive_Bframe!=0)
{
// free last P-frame buffers for B-frame coding
free_mem3Dint(tmp_fwMV,2);
free_mem3Dint(tmp_bwMV,2);
free_mem3Dint(dfMV,2);
free_mem3Dint(dbMV,2);
free_mem2Dint(fw_refFrArr_frm);
free_mem2Dint(bw_refFrArr_frm);
} // end if B frame
free_mem2Dint(img4Y_tmp); // free temp quarter pel frame buffer
// free mem, allocated in init_img()
// free intra pred mode buffer for blocks
free_mem2Dint(img->ipredmode);
if (input->InterlaceCodingOption != FRAME_CODING)
{
free_mem2D(imgY_com);
// free multiple ref frame buffers
// number of reference frames increased by one for next P-frame
for (i=0;i<4;i++)
free(mref_fld[i]);
#if 0
free(parity_fld);
if(input->successive_Bframe!=0)
{
// free last P-frame buffers for B-frame coding
free_mem2Dint(fw_refFrArr_fld);
free_mem2Dint(bw_refFrArr_fld);
} // end if B frame
free (Refbuf11_fld);
free_mem3Dint(tmp_mv_fld,2);
free_mem2Dint(refFrArr_fld);
#endif
}
/* if (1)//input->InterlaceCodingOption == SMB_CODING)
{
for (i=0; i < (img->width/MB_BLOCK_SIZE) * (img->height/MB_BLOCK_SIZE); i++)
{
free_mem4Dint ((img->mb_data[i].cofAC),6,4);
free_mem4Dint(img->mb_data[i].chromacofAC, 2, 4 );
}
}*/
free(img->mb_data);
// !!
free(allbelta_lum) ;
free(allalpha_lum) ;
//FAST MOTION ESTIMATION. ZHIBO CHEN 2003.3
#ifdef FastME
free_mem_FME();
#endif
}
/*
*************************************************************************
* Function:Allocate memory for mv
* Input:Image Parameters struct img_par *img \n
int****** mv
* Output:
* Return: memory size in bytes
* Attention:
*************************************************************************
*/
int get_mem_mv (int****** mv)
{
int i, j, k, l;
if ((*mv = (int*****)calloc(2,sizeof(int****))) == NULL)
no_mem_exit ("get_mem_mv: mv");
for (i=0; i<2; i++)
{
if (((*mv)[i] = (int****)calloc(2,sizeof(int***))) == NULL)
no_mem_exit ("get_mem_mv: mv");
for (j=0; j<2; j++)
{
if (((*mv)[i][j] = (int***)calloc(img->buf_cycle,sizeof(int**))) == NULL)
no_mem_exit ("get_mem_mv: mv");
for (k=0; k<img->buf_cycle; k++)
{
if (((*mv)[i][j][k] = (int**)calloc(9,sizeof(int*))) == NULL)
no_mem_exit ("get_mem_mv: mv");
for (l=0; l<9; l++)
if (((*mv)[i][j][k][l] = (int*)calloc(2,sizeof(int))) == NULL)
no_mem_exit ("get_mem_mv: mv");
}
}
}
return 2*2*img->buf_cycle*9*2*sizeof(int);
}
/*
*************************************************************************
* Function:Free memory from mv
* Input:int****** mv
* Output:
* Return:
* Attention:
*************************************************************************
*/
void free_mem_mv (int***** mv)
{
int i, j, k, l;
for (i=0; i<2; i++)
{
for (j=0; j<2; j++)
{
for (k=0; k<img->buf_cycle; k++)
{
for (l=0; l<9; l++)
free (mv[i][j][k][l]);
free (mv[i][j][k]);
}
free (mv[i][j]);
}
free (mv[i]);
}
free (mv);
}
/*
*************************************************************************
* Function:
* Input:
* Output:
* Return:
* Attention:
*************************************************************************
*/
int get_direct_mv (int****** mv,int mb_x,int mb_y)
{
int i, j, k, l;
if ((*mv = (int*****)calloc(mb_y,sizeof(int****))) == NULL)
no_mem_exit ("get_mem_mv: mv");
for (i=0; i<mb_y; i++)
{
if (((*mv)[i] = (int****)calloc(mb_x,sizeof(int***))) == NULL)
no_mem_exit ("get_mem_mv: mv");
for (j=0; j<mb_x; j++)
{
if (((*mv)[i][j] = (int***)calloc(2,sizeof(int**))) == NULL)
no_mem_exit ("get_mem_mv: mv");
for (k=0; k<2; k++)
{
if (((*mv)[i][j][k] = (int**)calloc(2,sizeof(int*))) == NULL)
no_mem_exit ("get_mem_mv: mv");
for (l=0; l<2; l++)
if (((*mv)[i][j][k][l] = (int*)calloc(3,sizeof(int))) == NULL)
no_mem_exit ("get_mem_mv: mv");
}
}
}
return mb_x*mb_y*2*2*3*sizeof(int);
}
/*
*************************************************************************
* Function:Free memory from mv
* Input:int****** mv
* Output:
* Return:
* Attention:
*************************************************************************
*/
void free_direct_mv (int***** mv,int mb_x,int mb_y)
{
int i, j, k, l;
for (i=0; i<mb_y; i++)
{
for (j=0; j<mb_x; j++)
{
for (k=0; k<2; k++)
{
for (l=0; l<2; l++)
free (mv[i][j][k][l]);
free (mv[i][j][k]);
}
free (mv[i][j]);
}
free (mv[i]);
}
free (mv);
}
/*
*************************************************************************
* Function:Allocate memory for AC coefficients
* Input:
* Output:
* Return:
* Attention:
*************************************************************************
*/
int get_mem_ACcoeff (int***** cofAC)
{
int i, j, k;
if ((*cofAC = (int****)calloc (6, sizeof(int***))) == NULL) no_mem_exit ("get_mem_ACcoeff: cofAC");
for (k=0; k<6; k++)
{
if (((*cofAC)[k] = (int***)calloc (4, sizeof(int**))) == NULL) no_mem_exit ("get_mem_ACcoeff: cofAC");
for (j=0; j<4; j++)
{
if (((*cofAC)[k][j] = (int**)calloc (2, sizeof(int*))) == NULL) no_mem_exit ("get_mem_ACcoeff: cofAC");
for (i=0; i<2; i++)
{
if (((*cofAC)[k][j][i] = (int*)calloc (65, sizeof(int))) == NULL) no_mem_exit ("get_mem_ACcoeff: cofAC"); // 18->65 for AVS
}
}
}
return 6*4*2*65*sizeof(int);// 18->65 for AVS
}
/*
*************************************************************************
* Function:Allocate memory for DC coefficients
* Input:
* Output:
* Return:
* Attention:
*************************************************************************
*/
int get_mem_DCcoeff (int**** cofDC)
{
int j, k;
if ((*cofDC = (int***)calloc (3, sizeof(int**))) == NULL) no_mem_exit ("get_mem_DCcoeff: cofDC");
for (k=0; k<3; k++)
{
if (((*cofDC)[k] = (int**)calloc (2, sizeof(int*))) == NULL) no_mem_exit ("get_mem_DCcoeff: cofDC");
for (j=0; j<2; j++)
{
if (((*cofDC)[k][j] = (int*)calloc (65, sizeof(int))) == NULL) no_mem_exit ("get_mem_DCcoeff: cofDC"); // 18->65 for AVS
}
}
return 3*2*65*sizeof(int); // 18->65 for AVS
}
/*
*************************************************************************
* Function:Free memory of AC coefficients
* Input:
* Output:
* Return:
* Attention:
*************************************************************************
*/
void free_mem_ACcoeff (int**** cofAC)
{
int i, j, k;
for (k=0; k<6; k++)
{
for (i=0; i<4; i++)
{
for (j=0; j<2; j++)
{
free (cofAC[k][i][j]);
}
free (cofAC[k][i]);
}
free (cofAC[k]);
}
free (cofAC);
}
/*
*************************************************************************
* Function:Free memory of DC coefficients
* Input:
* Output:
* Return:
* Attention:
*************************************************************************
*/
void free_mem_DCcoeff (int*** cofDC)
{
int i, j;
for (j=0; j<3; j++)
{
for (i=0; i<2; i++)
{
free (cofDC[j][i]);
}
free (cofDC[j]);
}
free (cofDC);
}
/*
*************************************************************************
* Function:SetImgType
* Input:
* Output:
* Return:
* Attention:
*************************************************************************
*/
void SetImgType()
{
if (input->intra_period == 0)
{
if (IMG_NUMBER == 0)
{
img->type = INTRA_IMG; // set image type for first image to I-frame
}
else
{
img->type = INTER_IMG; // P-frame
picture_coding_type= 0;
}
}
else
{
if ((IMG_NUMBER%input->intra_period) == 0)
{
img->type = INTRA_IMG;
}
else
{
img->type = INTER_IMG; // P-frame
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -