Пример #1
0
/*!
 ************************************************************************
 * \brief
 *    create structure for storing coding state
 ************************************************************************
 */
CSobj *create_coding_state (InputParameters *p_Inp)
{
  CSobj *cs;

  //=== coding state structure ===
  if ((cs = (CSobj *) calloc (1, sizeof(CSobj))) == NULL)
    no_mem_exit("init_coding_state: cs"); 

  //=== important variables of data partition array ===
  cs->no_part = p_Inp->partition_mode == 0 ? 1 : 3;
  if (p_Inp->symbol_mode == CABAC)
  {
    if ((cs->encenv = (EncodingEnvironment*) calloc (cs->no_part, sizeof(EncodingEnvironment))) == NULL)
      no_mem_exit("init_coding_state: cs->encenv");

    if ((cs->bitstream = (Bitstream*) calloc (cs->no_part, sizeof(Bitstream))) == NULL)
      no_mem_exit("init_coding_state: cs->bitstream");
    //=== context for binary arithmetic coding ===
    cs->mot_ctx = create_contexts_MotionInfo ();
    cs->tex_ctx = create_contexts_TextureInfo();

  }
  else
  {
    cs->encenv = NULL;
    if ((cs->bitstream = (Bitstream*) calloc (cs->no_part, sizeof(Bitstream))) == NULL)
      no_mem_exit("init_coding_state: cs->bitstream");

    cs->mot_ctx = NULL;
    cs->tex_ctx = NULL;
  }
  
  if (p_Inp->ProfileIDC == FREXT_Hi444)
  {
    if ((cs->cbp_bits_8x8 = (int64 *) calloc (3, sizeof(int64))) == NULL)
      no_mem_exit("init_coding_state: cs->cbp_bits_8x8"); 
  }
  else
    cs->cbp_bits_8x8 = NULL;

  return cs;
}
Пример #2
0
/*!
 ************************************************************************
 * \brief
 *    Allocates the slice structure along with its dependent
 *    data structures
 *
 * \par Input:
 *    Input Parameters struct inp_par *inp,  struct img_par *img
 ************************************************************************
 */
void malloc_slice(struct inp_par *inp, struct img_par *img)
{
  Slice *currSlice;

  img->currentSlice = (Slice *) calloc(1, sizeof(Slice));
  if ( (currSlice = img->currentSlice) == NULL)
  {
    snprintf(errortext, ET_SIZE, "Memory allocation for Slice datastruct in NAL-mode %d failed", inp->FileFormat);
    error(errortext,100);
  }
//  img->currentSlice->rmpni_buffer=NULL;
  //! you don't know whether we do CABAC hre, hence initialize CABAC anyway
  // if (inp->symbol_mode == CABAC)
  if (1)
  {
    // create all context models
    currSlice->mot_ctx = create_contexts_MotionInfo();
    currSlice->tex_ctx = create_contexts_TextureInfo();
  }
  currSlice->max_part_nr = 3;  //! assume data partitioning (worst case) for the following mallocs()
  currSlice->partArr = AllocPartition(currSlice->max_part_nr);
}
Пример #3
0
/*!
 ************************************************************************
 * \brief
 *    create structure for storing coding state
 ************************************************************************
 */
CSptr
create_coding_state ()
{
  CSptr cs;

  //=== coding state structure ===
  if ((cs = (CSptr) calloc (1, sizeof(CSobj))) == NULL)
    no_mem_exit("init_coding_state: cs");

  //=== important variables of data partition array ===
  cs->no_part = input->partition_mode==0?1:3;
  if (input->symbol_mode == CABAC)
  {
    if ((cs->encenv = (EncodingEnvironment*) calloc (cs->no_part, sizeof(EncodingEnvironment))) == NULL)
      no_mem_exit("init_coding_state: cs->encenv");
  }
  else
  {
    cs->encenv = NULL;
  }
  if ((cs->bitstream = (Bitstream*) calloc (cs->no_part, sizeof(Bitstream))) == NULL)
    no_mem_exit("init_coding_state: cs->bitstream");

  //=== context for binary arithmetic coding ===
  cs->symbol_mode = input->symbol_mode;
  if (cs->symbol_mode == CABAC)
  {
    cs->mot_ctx = create_contexts_MotionInfo ();
    cs->tex_ctx = create_contexts_TextureInfo();
  }
  else
  {
    cs->mot_ctx = NULL;
    cs->tex_ctx = NULL;
  }

  return cs;
}
Пример #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
 *-----------------------------------------------------------------------			
 *	 Function Argument List Changed [Removing Global Variables] 
 *	 Input parameters added are 
 *			- h264_decoder* dec_params
 *
 *		<*****@*****.**>
 ***********************************************************************
*/
int init_global_buffers_baseline( h264_decoder* dec_params )
{
	ImageParameters* img = dec_params->img;
	int memory_size=0;
	int quad_range, i;
	
	if (dec_params->global_init_done)
	{
		free_global_buffers_baseline( dec_params );
	}
	
	if(((img->slice_nr) = (char *) h264_malloc(img->FrameSizeInMbs * sizeof(char))) == NULL)
	{
		printf("init_global_buffers: img->slice_nr");
		exit(0);
	}
	if(((img->ei_flag) = (char *) h264_malloc(img->FrameSizeInMbs * sizeof(char))) == NULL)
	{
		printf("init_global_buffers: img->ei_flag");
		exit(0);
	}

	///////////////////////////////////////////////////////////////////////////////////
	// Initializations for the new mb_data structure inside the ImageParam structure //
	///////////////////////////////////////////////////////////////////////////////////
	if((img->mb_data1.cbp_blk = (short*) h264_malloc(img->FrameSizeInMbs*sizeof(short))) == NULL)
	{
		printf("init_global_buffers: img->mb_data1->cbp_blk");
		exit(0);
	}

	if((img->mb_data1.LFAlphaC0Offset = (char*) h264_malloc(img->FrameSizeInMbs*sizeof(char))) == NULL)
	{
		printf("init_global_buffers: img->mb_data1.LFAlphaC0Offset");
		exit(0);
	}

	if((img->mb_data1.LFBetaOffset = (char*) h264_malloc(img->FrameSizeInMbs*sizeof(char))) == NULL)
	{
		printf("init_global_buffers: img->mb_data1.LFBetaC0Offset");
		exit(0);
	}

	if((img->mb_data1.LFDisableIdc = (char*) h264_malloc(img->FrameSizeInMbs*sizeof(char))) == NULL)
	{
		printf("init_global_buffers: img->mb_data1.LFDisableIdc");
		exit(0);
	}

	if((img->mb_data1.mb_type = (char*) h264_malloc(img->FrameSizeInMbs*sizeof(char))) == NULL)
	{
		printf("init_global_buffers: img->mb_data1.mb_type");
		exit(0);
	}

	if((img->mb_data1.partition = (char*) h264_malloc(img->FrameSizeInMbs*sizeof(char))) == NULL)
	{
		printf("init_global_buffers: img->mb_data1.partition");
		exit(0);
	}

	if((img->mb_data1.mbAvailA = (char*) h264_malloc(img->FrameSizeInMbs*sizeof(char))) == NULL)
	{
		printf("init_global_buffers: img->mb_data1.mbAvailA");
		exit(0);
	}

	if((img->mb_data1.mbAvailB = (char*) h264_malloc(img->FrameSizeInMbs*sizeof(char))) == NULL)
	{
		printf("init_global_buffers: img->mb_data1.mbAvailB");
		exit(0);
	}

	if((img->mb_data1.NoMbPartLessThan8x8Flag = (char*) h264_malloc(img->FrameSizeInMbs*sizeof(char))) == NULL)
	{
		printf("init_global_buffers: img->mb_data1.NoMbPartLessThan8x8Flag");
		exit(0);
	}

	if((img->mb_data1.qp = (char*) h264_malloc(img->FrameSizeInMbs*sizeof(char))) == NULL)
	{
		printf("init_global_buffers: img->mb_data1.qp");
		exit(0);
	}
	///////////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////

	if(((dec_params->img->intra_block) = (int*)h264_malloc(dec_params->img->FrameSizeInMbs * sizeof(int))) == NULL)
	{
		printf("init_global_buffers: img->intra_block");
		exit(0);
	}
	
	memory_size += get_mem2D(&(dec_params->img->ipredmode), dec_params->img->FrameWidthInMbs<<2 , dec_params->img->FrameHeightInMbs<<2);

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

//	dec_params->img->nz_coeff = h264_malloc ((dec_params->img->FrameSizeInMbs<<5)*sizeof(char));

	dec_params->img->nz_coeff1 = (char *)h264_malloc ((dec_params->img->FrameSizeInMbs*24)*sizeof(char));
//	dec_params->img->nz_coeff1[1] = dec_params->img->nz_coeff1[0] + dec_params->img->FrameSizeInMbs*16;
//	dec_params->img->nz_coeff1[2] = dec_params->img->nz_coeff1[1] + dec_params->img->FrameSizeInMbs*4;

	memory_size += (dec_params->img->FrameSizeInMbs<<5)*sizeof(char);

	
	quad_range = (MAX_IMGPEL_VALUE + 1) <<1;
	
	//if ((dec_params->img->quad = (int*)calloc (quad_range, sizeof(int))) == NULL)
/*	if ((dec_params->img->quad = (int*) h264_malloc (quad_range * sizeof(int))) == NULL)
	{
		printf("init_img: img->quad");
		exit(0);
	}
	
	for (i=0; i < quad_range>>1; ++i)
	{
		dec_params->img->quad[i]=i*i;
	}
*/	
    // create all context models
    dec_params->mot_ctx = (MotionInfoContexts *)create_contexts_MotionInfo();
    dec_params->tex_ctx = (TextureInfoContexts *)create_contexts_TextureInfo();
	dec_params->global_init_done = 1;
	
//	dec_params->img->oldFrameSizeInMbs = dec_params->img->FrameSizeInMbs;
	
	return (memory_size);
}