Esempio n. 1
0
static av_cold int init(AVFilterContext *ctx)
{
    MPTestContext *test = ctx->priv;
#ifdef IDE_COMPILE
	AVRational tmp;
#endif

#ifdef IDE_COMPILE
    tmp.num = 1;
	tmp.den = AV_TIME_BASE;
	test->max_pts = test->duration >= 0 ?
        av_rescale_q(test->duration, tmp, av_inv_q(test->frame_rate)) : -1;
#else
	test->max_pts = test->duration >= 0 ?
        av_rescale_q(test->duration, AV_TIME_BASE_Q, av_inv_q(test->frame_rate)) : -1;
#endif
	test->pts = 0;

    av_log(ctx, AV_LOG_VERBOSE, "rate:%d/%d duration:%f\n",
           test->frame_rate.num, test->frame_rate.den,
           test->duration < 0 ? -1 : test->max_pts * av_q2d(av_inv_q(test->frame_rate)));
    init_idct();

    return 0;
}
Esempio n. 2
0
static av_cold int init(AVFilterContext *ctx)
{
    MPTestContext *test = ctx->priv;

    test->max_pts = test->duration >= 0 ?
                    av_rescale_q(test->duration, AV_TIME_BASE_Q, av_inv_q(test->frame_rate)) : -1;
    test->pts = 0;

    av_log(ctx, AV_LOG_VERBOSE, "rate:%d/%d duration:%f\n",
           test->frame_rate.num, test->frame_rate.den,
           test->duration < 0 ? -1 : test->max_pts * av_q2d(av_inv_q(test->frame_rate)));
    init_idct();

    return 0;
}
Esempio n. 3
0
static av_cold void vp9dsp_itxfm_init_arm(VP9DSPContext *dsp)
{
    int cpu_flags = av_get_cpu_flags();

    if (have_neon(cpu_flags)) {
#define init_itxfm(tx, sz)                                             \
    dsp->itxfm_add[tx][DCT_DCT]   = ff_vp9_idct_idct_##sz##_add_neon;  \
    dsp->itxfm_add[tx][DCT_ADST]  = ff_vp9_iadst_idct_##sz##_add_neon; \
    dsp->itxfm_add[tx][ADST_DCT]  = ff_vp9_idct_iadst_##sz##_add_neon; \
    dsp->itxfm_add[tx][ADST_ADST] = ff_vp9_iadst_iadst_##sz##_add_neon

#define init_idct(tx, nm)           \
    dsp->itxfm_add[tx][DCT_DCT]   = \
    dsp->itxfm_add[tx][ADST_DCT]  = \
    dsp->itxfm_add[tx][DCT_ADST]  = \
    dsp->itxfm_add[tx][ADST_ADST] = ff_vp9_##nm##_add_neon

        init_itxfm(TX_4X4, 4x4);
        init_itxfm(TX_8X8, 8x8);
        init_itxfm(TX_16X16, 16x16);
        init_idct(TX_32X32, idct_idct_32x32);
        init_idct(4, iwht_iwht_4x4);
    }
}
Esempio n. 4
0
int decode_scan(void)
{
#ifdef _JPEG_DEBUG
    printf("%d MCUs in total.\n", iceenv.num_mcu_x * iceenv.num_mcu_y);
    printf("MCU dimension: %dx%d\n", iceenv.max_samp_x << 3, iceenv.max_samp_y << 3);
#endif
    
//    if (iceenv.scan_buffer[iceenv.buf_pos] == 0xFF && iceenv.scan_buffer[iceenv.buf_pos + 1] == 0x00)
//        skip_stuff_byte = 1;
    
    init_idct();
    
    for (iceenv.cur_mcu_x = iceenv.cur_mcu_y = 0;;)
    {
            //printf("Decoding MCU [%d,%d]\n", iceenv.cur_mcu_x, iceenv.cur_mcu_y);
            decode_mcu();
        
            iceenv.cur_mcu_x++;
            if (iceenv.cur_mcu_x == iceenv.num_mcu_x)
            {
                iceenv.cur_mcu_x = 0;
                iceenv.cur_mcu_y++;
                if (iceenv.cur_mcu_y == iceenv.num_mcu_y)
                    break;
            }
        
            if (!iceenv.restart_interval)
                continue;
            
            iceenv.rstcount--;
            if (!iceenv.rstcount)
            {
                int err = process_rst();
                if (err != ERR_OK)
                    return err;
            }
    }
    
    //if (iceenv.cur_byte_remaining > 0)
    iceenv.buf_pos++;
    
    return ERR_OK;
}
Esempio n. 5
0
static av_cold void vp9dsp_itxfm_init_msa(VP9DSPContext *dsp, int bpp)
{
    if (bpp == 8) {
#define init_itxfm(tx, sz)                                         \
    dsp->itxfm_add[tx][DCT_DCT]   = ff_idct_idct_##sz##_add_msa;   \
    dsp->itxfm_add[tx][DCT_ADST]  = ff_iadst_idct_##sz##_add_msa;  \
    dsp->itxfm_add[tx][ADST_DCT]  = ff_idct_iadst_##sz##_add_msa;  \
    dsp->itxfm_add[tx][ADST_ADST] = ff_iadst_iadst_##sz##_add_msa  \

#define init_idct(tx, nm)                        \
    dsp->itxfm_add[tx][DCT_DCT]   =              \
    dsp->itxfm_add[tx][ADST_DCT]  =              \
    dsp->itxfm_add[tx][DCT_ADST]  =              \
    dsp->itxfm_add[tx][ADST_ADST] = nm##_add_msa

    init_itxfm(TX_4X4, 4x4);
    init_itxfm(TX_8X8, 8x8);
    init_itxfm(TX_16X16, 16x16);
    init_idct(TX_32X32, ff_idct_idct_32x32);
#undef init_itxfm
#undef init_idct
    }
}
Esempio n. 6
0
*/
void initdecoder()
{
  int i, cc, size;


  /* clip table */
  if (!(clp=(unsigned char *)malloc(1024)))
    error((char*)"malloc failed\n");

  clp += 384;

  for (i=-384; i<640; i++)
    clp[i] = (i<0) ? 0 : ((i>255) ? 255 : i);

  /* MPEG-1 = TMN parameters */
  matrix_coefficients = 5;


  switch (source_format) 
  {
  
	case (SF_SQCIF):
      horizontal_size = 128;
      vertical_size = 96;
      break;
    case (SF_QCIF):
      horizontal_size = 176;
      vertical_size = 144;
      break;
    case (SF_CIF):
      horizontal_size = 352;
      vertical_size = 288;
      break;
    case (SF_4CIF):
      horizontal_size = 704;
      vertical_size = 576;
      break;
    case (SF_16CIF):
      horizontal_size = 1408;
      vertical_size = 1152;
      break;
    default:
		myLog.WriteLog((char*)"initdecoder",(char*)"ERROR: Illegal input format");
      return;
      break;
  }

	char slog[128];
	sprintf(slog, "H.Size:%d V.Size:%d", horizontal_size, vertical_size);
	myLog.WriteLog((char*)"initdecoder",slog);


  mb_width = horizontal_size/16;
  mb_height = vertical_size/16;
  coded_picture_width = horizontal_size;
  coded_picture_height = vertical_size;
  chrom_width =  coded_picture_width>>1;
  chrom_height = coded_picture_height>>1;
  blk_cnt = 6;
  
  int iSize1, iSize2;
  size = coded_picture_width*coded_picture_height;
  iSize1 = size;
  iSize2 = chrom_width*chrom_height; 
  size += (iSize2*2);

  if (!(refframe[0] = (unsigned char *)malloc(size)))
     error((char*)"malloc failed\n");
  else{
	 unsigned char *p = refframe[0];
	 refframe[1] = p+iSize1;
	 refframe[2] = p+iSize1+iSize2;
  }

  if (!(oldrefframe[0] = (unsigned char *)malloc(size)))
    error((char*)"malloc failed\n");
  else{
  	 unsigned char *p = oldrefframe[0];
	 oldrefframe[1] = p+iSize1;
	 oldrefframe[2] = p+iSize1+iSize2;	
  }

  if (!(bframe[0] = (unsigned char *)malloc(size)))
    error((char*)"malloc failed\n");
  else{
  	 unsigned char *p = bframe[0];
	 bframe[1] = p+iSize1;
	 bframe[2] = p+iSize1+iSize2;	
  }
/*  for (cc=0; cc<3; cc++) 
  
  {
  
	// Find out size...
	 if (cc==0)
      size = coded_picture_width*coded_picture_height;
    else
      size = chrom_width*chrom_height;


	// Allocate memory
    if (!(refframe[cc] = (unsigned char *)malloc(size)))
      error((char*)"malloc failed\n");


    if (!(oldrefframe[cc] = (unsigned char *)malloc(size)))
      error((char*)"malloc failed\n");

    if (!(bframe[cc] = (unsigned char *)malloc(size)))
      error((char*)"malloc failed\n");
  }
*/

  for (cc=0; cc<3; cc++) 
  {
  
	  if (cc==0) 
	  {
		  size = (coded_picture_width+64)*(coded_picture_height+64);
      
		  if (!(edgeframeorig[cc] = (unsigned char *)malloc(size)))
		  error((char*)"malloc failed\n");
      
		  
		  edgeframe[cc] = edgeframeorig[cc] + (coded_picture_width+64) * 32 + 32;
	  }
      else 
	  {
      size = (chrom_width+32)*(chrom_height+32);
      
	  if (!(edgeframeorig[cc] = (unsigned char *)malloc(size)))
      error((char*)"malloc failed\n");
      
	  edgeframe[cc] = edgeframeorig[cc] + (chrom_width+32) * 16 + 16;
	  }
    
  }

  
  /* IDCT */
  if (refidct)
    init_idctref();
  else
    init_idct();
Esempio n. 7
0
/**
*    Initialize decoder
*
*
*/
void initdecoder()
{
  int i, cc, size;


  /* clip table */
  if (!(clp=(unsigned char *)malloc(1024)))
    error("malloc failed\n");

  clp += 384;

  for (i=-384; i<640; i++)
    clp[i] = (i<0) ? 0 : ((i>255) ? 255 : i);

  /* MPEG-1 = TMN parameters */
  matrix_coefficients = 5;


  switch (source_format) 
  {
  
	case (SF_SQCIF):
      horizontal_size = 128;
      vertical_size = 96;
      break;
    case (SF_QCIF):
      horizontal_size = 176;
      vertical_size = 144;
      break;
    case (SF_CIF):
      horizontal_size = 352;
      vertical_size = 288;
      break;
    case (SF_4CIF):
      horizontal_size = 704;
      vertical_size = 576;
      break;
    case (SF_16CIF):
      horizontal_size = 1408;
      vertical_size = 1152;
      break;
    default:
      if(trace)
	  fputs("ERROR: Illegal input format\n",dlog);
      return;
      break;
  }


  mb_width = horizontal_size/16;
  mb_height = vertical_size/16;
  coded_picture_width = horizontal_size;
  coded_picture_height = vertical_size;
  chrom_width =  coded_picture_width>>1;
  chrom_height = coded_picture_height>>1;
  blk_cnt = 6;

  for (cc=0; cc<3; cc++) 
  
  {
  
	// Find out size...
	 if (cc==0)
      size = coded_picture_width*coded_picture_height;
    else
      size = chrom_width*chrom_height;


	// Allocate memory
    if (!(refframe[cc] = (unsigned char *)malloc(size)))
      error("malloc failed\n");


    if (!(oldrefframe[cc] = (unsigned char *)malloc(size)))
      error("malloc failed\n");

    if (!(bframe[cc] = (unsigned char *)malloc(size)))
      error("malloc failed\n");
  }

  for (cc=0; cc<3; cc++) 
  {
  
	  if (cc==0) 
	  {
		  size = (coded_picture_width+64)*(coded_picture_height+64);
      
		  if (!(edgeframeorig[cc] = (unsigned char *)malloc(size)))
		  error("malloc failed\n");
      
		  
		  edgeframe[cc] = edgeframeorig[cc] + (coded_picture_width+64) * 32 + 32;
	  }
      else 
	  {
      size = (chrom_width+32)*(chrom_height+32);
      
	  if (!(edgeframeorig[cc] = (unsigned char *)malloc(size)))
      error("malloc failed\n");
      
	  edgeframe[cc] = edgeframeorig[cc] + (chrom_width+32) * 16 + 16;
	  }
    
  }

  
  /* IDCT */
  if (refidct)
    init_idctref();
  else
    init_idct();
}
struct pipe_video_decoder *
vl_create_mpeg12_decoder(struct pipe_context *context,
                         enum pipe_video_profile profile,
                         enum pipe_video_entrypoint entrypoint,
                         enum pipe_video_chroma_format chroma_format,
                         unsigned width, unsigned height, unsigned max_references,
                         bool expect_chunked_decode)
{
   const unsigned block_size_pixels = VL_BLOCK_WIDTH * VL_BLOCK_HEIGHT;
   const struct format_config *format_config;
   struct vl_mpeg12_decoder *dec;

   assert(u_reduce_video_profile(profile) == PIPE_VIDEO_CODEC_MPEG12);

   dec = CALLOC_STRUCT(vl_mpeg12_decoder);

   if (!dec)
      return NULL;

   dec->base.context = context;
   dec->base.profile = profile;
   dec->base.entrypoint = entrypoint;
   dec->base.chroma_format = chroma_format;
   dec->base.width = width;
   dec->base.height = height;
   dec->base.max_references = max_references;

   dec->base.destroy = vl_mpeg12_destroy;
   dec->base.begin_frame = vl_mpeg12_begin_frame;
   dec->base.decode_macroblock = vl_mpeg12_decode_macroblock;
   dec->base.decode_bitstream = vl_mpeg12_decode_bitstream;
   dec->base.end_frame = vl_mpeg12_end_frame;
   dec->base.flush = vl_mpeg12_flush;

   dec->blocks_per_line = MAX2(util_next_power_of_two(dec->base.width) / block_size_pixels, 4);
   dec->num_blocks = (dec->base.width * dec->base.height) / block_size_pixels;
   dec->width_in_macroblocks = align(dec->base.width, VL_MACROBLOCK_WIDTH) / VL_MACROBLOCK_WIDTH;
   dec->expect_chunked_decode = expect_chunked_decode;

   /* TODO: Implement 422, 444 */
   assert(dec->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420);

   if (dec->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
      dec->chroma_width = dec->base.width / 2;
      dec->chroma_height = dec->base.height / 2;
      dec->num_blocks = dec->num_blocks * 2;
   } else if (dec->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) {
      dec->chroma_width = dec->base.width;
      dec->chroma_height = dec->base.height / 2;
      dec->num_blocks = dec->num_blocks * 2 + dec->num_blocks;
   } else {
      dec->chroma_width = dec->base.width;
      dec->chroma_height = dec->base.height;
      dec->num_blocks = dec->num_blocks * 3;
   }

   dec->quads = vl_vb_upload_quads(dec->base.context);
   dec->pos = vl_vb_upload_pos(
      dec->base.context,
      dec->base.width / VL_MACROBLOCK_WIDTH,
      dec->base.height / VL_MACROBLOCK_HEIGHT
   );

   dec->ves_ycbcr = vl_vb_get_ves_ycbcr(dec->base.context);
   dec->ves_mv = vl_vb_get_ves_mv(dec->base.context);

   switch (entrypoint) {
   case PIPE_VIDEO_ENTRYPOINT_BITSTREAM:
      format_config = find_format_config(dec, bitstream_format_config, num_bitstream_format_configs);
      break;

   case PIPE_VIDEO_ENTRYPOINT_IDCT:
      format_config = find_format_config(dec, idct_format_config, num_idct_format_configs);
      break;

   case PIPE_VIDEO_ENTRYPOINT_MC:
      format_config = find_format_config(dec, mc_format_config, num_mc_format_configs);
      break;

   default:
      assert(0);
      FREE(dec);
      return NULL;
   }

   if (!format_config) {
      FREE(dec);
      return NULL;
   }

   if (!init_zscan(dec, format_config))
      goto error_zscan;

   if (entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT) {
      if (!init_idct(dec, format_config))
         goto error_sources;
   } else {
      if (!init_mc_source_widthout_idct(dec, format_config))
         goto error_sources;
   }

   if (!vl_mc_init(&dec->mc_y, dec->base.context, dec->base.width, dec->base.height,
                   VL_MACROBLOCK_HEIGHT, format_config->mc_scale,
                   mc_vert_shader_callback, mc_frag_shader_callback, dec))
      goto error_mc_y;

   // TODO
   if (!vl_mc_init(&dec->mc_c, dec->base.context, dec->base.width, dec->base.height,
                   VL_BLOCK_HEIGHT, format_config->mc_scale,
                   mc_vert_shader_callback, mc_frag_shader_callback, dec))
      goto error_mc_c;

   if (!init_pipe_state(dec))
      goto error_pipe_state;

   return &dec->base;

error_pipe_state:
   vl_mc_cleanup(&dec->mc_c);

error_mc_c:
   vl_mc_cleanup(&dec->mc_y);

error_mc_y:
   if (entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT) {
      vl_idct_cleanup(&dec->idct_y);
      vl_idct_cleanup(&dec->idct_c);
      dec->idct_source->destroy(dec->idct_source);
   }
   dec->mc_source->destroy(dec->mc_source);

error_sources:
   vl_zscan_cleanup(&dec->zscan_y);
   vl_zscan_cleanup(&dec->zscan_c);

error_zscan:
   FREE(dec);
   return NULL;
}
Esempio n. 9
0
int InitH263Encoder(CParam *params)
{

  Global.pic = (Pict *)malloc(sizeof(Pict));
  
  if(!Global.pic) 
  {
  return -1;
  }

  Global.pic->unrestricted_mv_mode = DEF_UMV_MODE;
  Global.pic->use_gobsync = DEF_INSERT_SYNC;
  Global.pic->PB = 0;
  Global.pic->TR = 0;
  Global.pic->QP_mean = 0.0;

  if(params->format == CPARAM_QCIF) {
    Global.pels = QCIF_YWIDTH;
    Global.lines = QCIF_YHEIGHT;
    Global.cpels = QCIF_YWIDTH/2;
    Global.pic->source_format = SF_QCIF;
  } else if (params->format == CPARAM_CIF) {
    Global.pels = CIF_YWIDTH;
    Global.lines = CIF_YHEIGHT;
    Global.cpels = CIF_YWIDTH/2;
    Global.pic->source_format = SF_CIF;
  } else if (params->format == CPARAM_SQCIF) {
    Global.pels = SQCIF_YWIDTH;
    Global.lines = SQCIF_YHEIGHT;
    Global.cpels = SQCIF_YWIDTH/2;
    Global.pic->source_format = SF_SQCIF;
  } else if (params->format == CPARAM_4CIF) {
    Global.pels = CIF4_YWIDTH;
    Global.lines = CIF4_YHEIGHT;
    Global.cpels = CIF4_YWIDTH/2;
    Global.pic->source_format = SF_4CIF;  
  } else if (params->format == CPARAM_16CIF) {
    Global.pels = CIF16_YWIDTH;
    Global.lines = CIF16_YHEIGHT;
    Global.cpels = CIF16_YWIDTH/2;
    Global.pic->source_format = SF_16CIF;
  } else {
    Global.pels = params->pels;
    Global.lines = params->lines;
    Global.cpels = params->pels / 2;
    Global.pic->source_format = 0;	/* ILLEGAL H.263! Use it only for testing */
  }
  
  Global.mbr = Global.lines / MB_SIZE;
  Global.mbc = Global.pels / MB_SIZE;
  Global.uskip = Global.lines*Global.pels;
  Global.vskip = Global.uskip + Global.lines*Global.pels/4;
  Global.sizeof_frame = (Global.vskip + Global.lines*Global.pels/4)*sizeof(int);


  Global.headerlength = DEF_HEADERLENGTH;
  /* Initalize VLC_tables */
  InitHuff();
  mwinit();

  /* Init motion detection */
  init_motion_detection();


#ifdef VERYFASTIDCT
  init_idct();			/* Do this in case of VERYFASTIDCT */
#elif STANDARDIDCT
  init_idctref();		/* Do this in case of standard IDCT */
#endif
				/* Do nothing for FASTIDCT */

  /* Set internal variables */
  Global.advanced = DEF_ADV_MODE;
  Global.mv_outside_frame = DEF_UMV_MODE || DEF_ADV_MODE;
  Global.long_vectors = DEF_UMV_MODE;
  Global.pb_frames = DEF_PBF_MODE;
  Global.search_p_frames = DEF_SPIRAL_SEARCH;
  Global.trace = DEF_WRITE_TRACE;

  params->half_pixel_searchwindow = CPARAM_DEFAULT_SEARCHWINDOW; 
  params->inter = CPARAM_DEFAULT_INTER;
  params->search_method = CPARAM_DEFAULT_SEARCH_METHOD;
  params->advanced_method = CPARAM_DEFAULT_ADVANCED_METHOD;
  params->Q_inter = CPARAM_DEFAULT_INTER_Q;
  params->Q_intra = CPARAM_DEFAULT_INTRA_Q;

  params->interpolated_lum = (unsigned int*)malloc(Global.pels*Global.lines*4*sizeof(int));

  if(!params->interpolated_lum)
    return -1;

  params->recon =(unsigned int*) malloc(Global.sizeof_frame);
  if(!params->recon) {
    free(params->interpolated_lum);
    free(Global.pic);
    return -1;
  }

  return 0;
}
Esempio n. 10
0
static void init()
{
	int i, n, size;
	static int block_count_tab[3] = {6,8,12};
	int lum_buffer_size, chrom_buffer_size;
	pthread_mutexattr_t mutex_attr;
	pthread_mutexattr_init(&mutex_attr);
	pthread_mutex_init(&test_lock, &mutex_attr);

	bzero(&cur_picture, sizeof(pict_data_s));
	mpeg2_initbits();
	init_fdct();
	init_idct();
	init_motion();
	init_predict_hv();
	init_quantizer_hv();
	init_transform_hv();

/* round picture dimensions to nZearest multiple of 16 or 32 */
	mb_width = (horizontal_size+15)/16;
	mb_height = prog_seq ? 
		(vertical_size + 15) / 16 : 
		2 * ((vertical_size + 31) / 32);
	mb_height2 = fieldpic ? 
		mb_height >> 1 : 
		mb_height; /* for field pictures */
	width = 16 * mb_width;
	height = 16 * mb_height;

	chrom_width = (chroma_format==CHROMA444) ? width : width>>1;
	chrom_height = (chroma_format!=CHROMA420) ? height : height>>1;

	height2 = fieldpic ? height>>1 : height;
	width2 = fieldpic ? width<<1 : width;
	chrom_width2 = fieldpic ? chrom_width<<1 : chrom_width;

	block_count = block_count_tab[chroma_format-1];
	lum_buffer_size = (width*height) + 
					 sizeof(uint8_t) *(width/2)*(height/2) +
					 sizeof(uint8_t) *(width/4)*(height/4+1);
	chrom_buffer_size = chrom_width*chrom_height;

	fsubsample_offset = (width)*(height) * sizeof(uint8_t);
	qsubsample_offset =  fsubsample_offset + (width/2)*(height/2)*sizeof(uint8_t);

	rowsums_offset = 0;
	colsums_offset = 0;

	mb_per_pict = mb_width*mb_height2;

/* clip table */
	if (!(clp = (unsigned char *)malloc(1024)))
      error("malloc failed\n");
	clp+= 384;
	for (i=-384; i<640; i++)
      clp[i] = (i<0) ? 0 : ((i>255) ? 255 : i);


	
	/* Allocate the frame buffer */


	frame_buffers = (uint8_t ***) 
		bufalloc(2*READ_LOOK_AHEAD*sizeof(uint8_t**));
	
	for(n=0;n<2*READ_LOOK_AHEAD;n++)
	{
         frame_buffers[n] = (uint8_t **) bufalloc(3*sizeof(uint8_t*));
		 for (i=0; i<3; i++)
		 {
			 frame_buffers[n][i] = 
				 bufalloc( (i==0) ? lum_buffer_size : chrom_buffer_size );
		 }
	}



	/* TODO: The ref and aux frame buffers are no redundant! */
	for( i = 0 ; i<3; i++)
	{
		int size =  (i==0) ? lum_buffer_size : chrom_buffer_size;
		newrefframe[i] = bufalloc(size);
		oldrefframe[i] = bufalloc(size);
		auxframe[i]    = bufalloc(size);
		predframe[i]   = bufalloc(size);
	}

	cur_picture.qblocks =
		(int16_t (*)[64])bufalloc(mb_per_pict*block_count*sizeof(int16_t [64]));

	/* Initialise current transformed picture data tables
	   These will soon become a buffer for transformed picture data to allow
	   look-ahead for bit allocation etc.
	 */
	cur_picture.mbinfo = (
		struct mbinfo *)bufalloc(mb_per_pict*sizeof(struct mbinfo));

	cur_picture.blocks =
		(int16_t (*)[64])bufalloc(mb_per_pict * block_count * sizeof(int16_t [64]));
  
  
/* open statistics output file */
	if(statname[0]=='-') statfile = stdout;
	else 
	if(!(statfile = fopen(statname,"w")))
	{
      sprintf(errortext,"Couldn't create statistics output file %s",statname);
      error(errortext);
	}

	ratectl = malloc(processors * sizeof(ratectl_t*));
	for(i = 0; i < processors; i++)
		ratectl[i] = calloc(1, sizeof(ratectl_t));
	


/* Start parallel threads */

//printf("init 1\n");
	start_motion_engines();
//printf("init 2\n");
	start_transform_engines();
//printf("init 3\n");
	start_itransform_engines();
//printf("init 4\n");
	start_slice_engines();
//printf("init 5\n");
}