code:
/*!
**************************************************
**********************
* \brief
* Allocate memory for mv
* \par Input:
* Image Parameters struct img_par *img \n
* int****** mv
* \return memory size in bytes
**************************************************
**********************
*/
int get_mem_mv (short ******* mv)
{
int i, j, k, l, m;
if ((*mv = (short******)calloc(4,sizeof(short*****))) == NULL)
no_mem_exit ("get_mem_mv: mv");
for (i=0; i<4; i++)
{
if (((*mv)[i] = (short*****)calloc(4,sizeof(short****))) == NULL)
no_mem_exit ("get_mem_mv: mv");
for (j=0; j<4; j++)
{
if (((*mv)[i][j] = (short****)calloc(2,sizeof(short***))) == NULL)
no_mem_exit ("get_mem_mv: mv");
for (k=0; k<2; k++)
{
if (((*mv)[i][j][k] = (short***)calloc(img->max_num_references,sizeof(short**))) == NULL)
no_mem_exit ("get_mem_mv: mv");
for (l=0; l<img->max_num_references; l++)
{
if (((*mv)[i][j][k][l] = (short**)calloc(9,sizeof(short*))) == NULL)
no_mem_exit ("get_mem_mv: mv");
if (((*mv)[i][j][k][l][0] = (short*)calloc(2*9,sizeof(short))) == NULL)
no_mem_exit ("get_mem_mv: mv");
for (m=1; m<9; m++)
(*mv)[i][j][k][l][m] = (*mv)[i][j][k][l][m - 1] + 2;
}
}
}
}
return 4*4*img->max_num_references*9*2*sizeof(short);
}