Ejemplo n.º 1
0
Archivo: fast_me.c Proyecto: VVer/JM86
int get_mem_FME()
{
  int memory_size = 0;
  memory_size += get_mem2Dint(&McostState, 2*input->search_range+1, 2*input->search_range+1);
  memory_size += get_mem_mincost (&(all_mincost));
  memory_size += get_mem_bwmincost(&(all_bwmincost));
  memory_size += get_mem2D(&SearchState,7,7);
  
  return memory_size;
}
Ejemplo n.º 2
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);
}
Ejemplo n.º 3
0
// same change as in get_mem2Dint
int get_mem3Dint(int ****array3D, int frames, int rows, int columns)
{
  int  j;

  if(((*array3D) = (int***)calloc(frames,sizeof(int**))) == NULL)
    no_mem_exit("get_mem3Dint: array3D");

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

  return frames*rows*columns*sizeof(int);
}
Ejemplo n.º 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;

  if (global_init_done)
  {
    free_global_buffers();
  }

  // allocate memory for reference frame in find_snr
  memory_size += get_mem2D(&imgY_ref, img->height, img->width);
  memory_size += get_mem3D(&imgUV_ref, 2, img->height_cr, img->width_cr);

  // 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, 6);

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

  global_init_done = 1;

  img->oldFrameSizeInMbs = img->FrameSizeInMbs;

  return (memory_size);
}
Ejemplo n.º 5
0
// same change as in get_mem2Dint
int get_mem3Dint(int ****array3D, int frames, int rows, int columns)
{
  int  j;
  
  if(((*array3D) = (int***) h264_malloc(frames*sizeof(int**))) == NULL)
  {
    printf("get_mem3Dint: array3D");
	exit(0);
  }
  for(j=0;j<frames;j++)
  {
    get_mem2Dint( (*array3D)+j, rows, columns) ;
  }
  return frames*rows*columns*sizeof(int);
}
Ejemplo n.º 6
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(struct inp_par *inp, struct img_par *img)
{
  int memory_size=0;

  if (global_init_done)
  {
    free_global_buffers(inp, img);
  }

  if (img->structure != FRAME)
  {
    img->height *= 2;         // set height to frame (twice of field) for normal variables
    img->height_cr *= 2;      // set height to frame (twice of field) for normal variables
  }

  // allocate memory for reference frame in find_snr
  memory_size += get_mem2D(&imgY_ref, img->height, img->width);
  memory_size += get_mem3D(&imgUV_ref, 2, img->height_cr, img->width_cr);

  // allocate memory in structure img

#ifndef STATIC_ALLOC
  if(((img->mb_data) = (Macroblock *) calloc((img->width/MB_BLOCK_SIZE) * (img->height/MB_BLOCK_SIZE),sizeof(Macroblock))) == NULL)
    no_mem_exit("init_global_buffers: img->mb_data");

  if(((img->intra_block) = (int*)calloc((img->width/MB_BLOCK_SIZE) * (img->height/MB_BLOCK_SIZE),sizeof(int))) == NULL)
    no_mem_exit("init_global_buffers: img->intra_block");

  memory_size += get_mem2Dint(&(img->ipredmode),img->width/BLOCK_SIZE , img->height/BLOCK_SIZE);

  // CAVLC mem
  memory_size += get_mem3Dint(&(img->nz_coeff), img->FrameSizeInMbs, 4, 6);
  memory_size += get_mem2Dint(&(img->siblock),img->width/MB_BLOCK_SIZE  , img->height/MB_BLOCK_SIZE);
#else
  // ipredmode
  memory_size += (1920/BLOCK_SIZE) * (1088/BLOCK_SIZE) * sizeof(int);
  
  // CAVLC mem
  // nz_coeff
  memory_size += (1920/MB_BLOCK_SIZE) * (1088/MB_BLOCK_SIZE) * 4 * 6 * sizeof(int);
  // siblock
  memory_size += (176/MB_BLOCK_SIZE) * (144/MB_BLOCK_SIZE) * sizeof(int);
#endif


 
  memory_size += get_mem2Dint(&(img->field_anchor),img->height/BLOCK_SIZE,img->width/BLOCK_SIZE);

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





  if (img->structure != FRAME)
  {
    img->height /= 2;      // reset height for normal variables
    img->height_cr /= 2;   // reset height for normal variables
  }
  
  global_init_done = 1;

  return (memory_size);
}
Ejemplo n.º 7
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);
}