Пример #1
0
int allocate_pred_mem(Slice *currSlice)
{
  int alloc_size = 0;
  alloc_size += get_mem2Dpel(&currSlice->tmp_block_l0, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
  alloc_size += get_mem2Dpel(&currSlice->tmp_block_l1, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
  alloc_size += get_mem2Dpel(&currSlice->tmp_block_l2, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
  alloc_size += get_mem2Dpel(&currSlice->tmp_block_l3, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
  alloc_size += get_mem2Dint(&currSlice->tmp_res, MB_BLOCK_SIZE + 5, MB_BLOCK_SIZE + 5);
  return (alloc_size);
}
Пример #2
0
int create_RGB_memory(ImageParameters *p_Img)
{
  int memory_size = 0;
  int j;
  for( j = 0; j < 3; j++ )
  {
    memory_size += get_mem2Dpel (&p_Img->imgRGB_src.data[j], p_Img->height, p_Img->width);
  }
  for( j = 0; j < 3; j++ )
  {
    memory_size += get_mem2Dpel (&p_Img->imgRGB_ref.data[j], p_Img->height, p_Img->width);
  }
  
  return memory_size;
}
Пример #3
0
/*!
 ************************************************************************
 * \brief
 *    Allocate 3D memory array -> imgpel array3D[frames][rows][columns]
 *
 * \par Output:
 *    memory size in bytes
 ************************************************************************
 */
int get_mem3Dpel(imgpel ****array3D, int frames, int rows, int columns)
{
  int  j;

  if(((*array3D) = (imgpel***)calloc(frames,sizeof(imgpel**))) == NULL)
    no_mem_exit("get_mem3Dpel: array3D");

  for(j=0;j<frames;j++)
    get_mem2Dpel( (*array3D)+j, rows, columns ) ;

  return frames*rows*columns*sizeof(imgpel);
}
Пример #4
0
/*!
************************************************************************
* \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, Image Parameters struct img_par *img
*
*  \par Output:
*     Number of allocated bytes
***********************************************************************
*/
int init_global_buffers()
{
    int memory_size=0;
    int quad_range, i;

    if (global_init_done)
    {
        free_global_buffers();
    }

    // allocate memory for reference frame in find_snr
    memory_size += get_mem2Dpel(&imgY_ref, img->height, img->width);

    if (active_sps->chroma_format_idc != YUV400)
        memory_size += get_mem3Dpel(&imgUV_ref, 2, img->height_cr, img->width_cr);
    else
        imgUV_ref=NULL;

    // allocate memory in structure img
    if(((img->mb_data) = (Macroblock *) calloc(img->FrameSizeInMbs, sizeof(Macroblock))) == NULL)
        no_mem_exit("init_global_buffers: img->mb_data");

    if(((img->intra_block) = (int*)calloc(img->FrameSizeInMbs, sizeof(int))) == NULL)
        no_mem_exit("init_global_buffers: img->intra_block");

    memory_size += get_mem2Dint(&(img->ipredmode), 4*img->PicWidthInMbs , 4*img->FrameHeightInMbs);

    memory_size += get_mem2Dint(&(img->field_anchor),4*img->FrameHeightInMbs, 4*img->PicWidthInMbs);

    memory_size += get_mem3Dint(&(img->wp_weight), 2, MAX_REFERENCE_PICTURES, 3);
    memory_size += get_mem3Dint(&(img->wp_offset), 6, MAX_REFERENCE_PICTURES, 3);
    memory_size += get_mem4Dint(&(img->wbp_weight), 6, MAX_REFERENCE_PICTURES, MAX_REFERENCE_PICTURES, 3);

    // CAVLC mem
    memory_size += get_mem3Dint(&(img->nz_coeff), img->FrameSizeInMbs, 4, 4 + img->num_blk8x8_uv);

    memory_size += get_mem2Dint(&(img->siblock),img->PicWidthInMbs  , img->FrameHeightInMbs);

    if(img->max_imgpel_value > img->max_imgpel_value_uv || active_sps->chroma_format_idc == YUV400)
        quad_range = (img->max_imgpel_value + 1) * 2;
    else
        quad_range = (img->max_imgpel_value_uv + 1) * 2;

    if ((img->quad = (int*)calloc (quad_range, sizeof(int))) == NULL)
        no_mem_exit ("init_img: img->quad");

    for (i=0; i < quad_range/2; ++i)
    {
        img->quad[i]=i*i;
    }

#ifdef ADAPTIVE_FILTER
    memory_size += get_mem2Ddouble (&tmp_coef, 21, 16);
#endif

#ifdef ADAPTIVE_LOOP_FILTER
    memory_size += InitALFGlobalBuffers();
#endif

    global_init_done = 1;

    img->oldFrameSizeInMbs = img->FrameSizeInMbs;

    return (memory_size);
}