Trect* TimgFilterSharpen::init(TffRect *rect,int full)
{
 Trect *r=TimgFilter::init(rect,full);
 if (!Ymin)
  {
   Ymin=(unsigned char*)xvid_malloc(strideY*dyY*2,MCACHE_LINE);
   Ymax=(unsigned char*)xvid_malloc(strideY*dyY,MCACHE_LINE);
  }
 return r;
}
Trect* TimgFilterTimesmooth::init(TffRect *rect,int full)
{
 Trect *r=TimgFilter::init(rect,full);
 if (!accumY)
  {
   accumY=(unsigned char*)xvid_malloc(dxY *dyY *KERNEL,MCACHE_LINE);memset(accumY,  0,dxY *dyY *KERNEL);
   accumU=(unsigned char*)xvid_malloc(dxUV*dyUV*KERNEL,MCACHE_LINE);memset(accumU,128,dxUV*dyUV*KERNEL);
   accumV=(unsigned char*)xvid_malloc(dxUV*dyUV*KERNEL,MCACHE_LINE);memset(accumV,128,dxUV*dyUV*KERNEL);
  }
 return r;
}
Exemple #3
0
/* memory alloc */
void *av_malloc(int size)
{
    void *ptr = xvid_malloc(size,64);
    if (!ptr) return NULL;
    memset(ptr, 0, size);
    return ptr;
}
void *xvid_calloc(size_t size1, size_t size2, uint8_t alignment)
{
 unsigned int size=size1*size2;
 uint8_t *ret=xvid_malloc(size,alignment);
 if (ret)
  memset(ret,0,size);
 return ret;
}
Exemple #5
0
int32_t
image_create(IMAGE * image,
			 uint32_t edged_width,
			 uint32_t edged_height)
{
	const uint32_t edged_width2 = edged_width / 2;
	const uint32_t edged_height2 = edged_height / 2;

	image->y =
		xvid_malloc(edged_width * (edged_height + 1) + SAFETY, CACHE_LINE);
	if (image->y == NULL) {
		return -1;
	}
	memset(image->y, 0, edged_width * (edged_height + 1) + SAFETY);

	image->u = xvid_malloc(edged_width2 * edged_height2 + SAFETY, CACHE_LINE);
	if (image->u == NULL) {
		xvid_free(image->y);
		image->y = NULL;
		return -1;
	}
	memset(image->u, 0, edged_width2 * edged_height2 + SAFETY);

	image->v = xvid_malloc(edged_width2 * edged_height2 + SAFETY, CACHE_LINE);
	if (image->v == NULL) {
		xvid_free(image->u);
		image->u = NULL;
		xvid_free(image->y);
		image->y = NULL;
		return -1;
	}
	memset(image->v, 0, edged_width2 * edged_height2 + SAFETY);

	image->y += EDGE_SIZE * edged_width + EDGE_SIZE;
	image->u += EDGE_SIZE2 * edged_width2 + EDGE_SIZE2;
	image->v += EDGE_SIZE2 * edged_width2 + EDGE_SIZE2;

	return 0;
}
Exemple #6
0
/* memory alloc */
void *av_mallocz(int size)
{
    void *ptr;
#if defined ( ARCH_X86 ) && defined ( HAVE_MEMALIGN )
    ptr = memalign(64,size);
    /* Why 64? 
       Indeed, we should align it:
         on 4 for 386
         on 16 for 486
	 on 32 for 586, PPro - k6-III
	 on 64 for K7 (maybe for P3 too).
       Because L1 and L2 caches are aligned on those values.
       But I don't want to code such logic here!
     */
#else
    ptr = xvid_malloc(size,64);
#endif
    if (!ptr)
        return NULL;
    memset(ptr, 0, size);
    return ptr;
}
Exemple #7
0
xint
m4v_init_decoder(DEC_CTRL * param, uint8 * video_header,
                 xint header_size)
{
    DECODER *dec;

    dec = xvid_malloc(sizeof(DECODER), CACHE_LINE);
    if (dec == NULL)
    {
        return XVID_ERR_MEMORY;
    }
    param->handle = dec;

    /* decode video header for frame width & height */
    m4v_decode_header(dec, video_header, header_size);
    param->width = dec->width;
    param->height = dec->height;

    dec->mb_width = (dec->width + 15) / 16;
    dec->mb_height = (dec->height + 15) / 16;
    dec->num_mb = dec->mb_height * dec->mb_width;
    dec->nbits_mba = log2bin(dec->num_mb - 1);

    dec->edged_width = 16 * dec->mb_width + 2 * EDGE_SIZE;
    dec->edged_height = 16 * dec->mb_height + 2 * EDGE_SIZE;

    dec->decoder_clock = 0;

    dec->slice =
        xvid_malloc(sizeof(xint) * (dec->mb_width + 1) *
                    (dec->mb_height + 1), CACHE_LINE);
    if (dec->slice == NULL)
        return XVID_ERR_MEMORY;

    if (image_create(&dec->cur, dec->edged_width, dec->edged_height))
    {
        xvid_free(dec);
        return XVID_ERR_MEMORY;
    }

    if (image_create(&dec->refn, dec->edged_width, dec->edged_height))
    {
        image_destroy(&dec->cur, dec->edged_width, dec->edged_height);
        xvid_free(dec);
        return XVID_ERR_MEMORY;
    }

    dec->mbs =
        xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height,
                    CACHE_LINE);
    if (dec->mbs == NULL)
    {
        image_destroy(&dec->refn, dec->edged_width, dec->edged_height);
        image_destroy(&dec->cur, dec->edged_width, dec->edged_height);
        xvid_free(dec);
        return XVID_ERR_MEMORY;
    }

    init_timer();

    init_vlc_tables();
    return XVID_ERR_OK;
}