Commit 8464b3ee authored by ramiro's avatar ramiro

Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label

parameters.


git-svn-id: file:///var/local/repositories/mplayer/trunk/libswscale@29652 b3059339-0415-0410-9bf9-f77b7e298cf2
parent daf1ab6e
......@@ -1451,12 +1451,12 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
#endif
// NOTE: the +1 is for the MMX scaler which reads over the end
CHECKED_ALLOC(*filterPos, (dstW+1)*sizeof(int16_t));
FF_ALLOC_OR_GOTO(NULL, *filterPos, (dstW+1)*sizeof(int16_t), fail);
if (FFABS(xInc - 0x10000) <10) { // unscaled
int i;
filterSize= 1;
CHECKED_ALLOCZ(filter, dstW*sizeof(*filter)*filterSize);
FF_ALLOCZ_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail);
for (i=0; i<dstW; i++) {
filter[i*filterSize]= fone;
......@@ -1467,7 +1467,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
int i;
int xDstInSrc;
filterSize= 1;
CHECKED_ALLOC(filter, dstW*sizeof(*filter)*filterSize);
FF_ALLOC_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail);
xDstInSrc= xInc/2 - 0x8000;
for (i=0; i<dstW; i++) {
......@@ -1481,7 +1481,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
int i;
int xDstInSrc;
filterSize= 2;
CHECKED_ALLOC(filter, dstW*sizeof(*filter)*filterSize);
FF_ALLOC_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail);
xDstInSrc= xInc/2 - 0x8000;
for (i=0; i<dstW; i++) {
......@@ -1520,7 +1520,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
if (filterSize > srcW-2) filterSize=srcW-2;
CHECKED_ALLOC(filter, dstW*sizeof(*filter)*filterSize);
FF_ALLOC_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail);
xDstInSrc= xInc - 0x10000;
for (i=0; i<dstW; i++) {
......@@ -1608,7 +1608,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
if (srcFilter) filter2Size+= srcFilter->length - 1;
if (dstFilter) filter2Size+= dstFilter->length - 1;
assert(filter2Size>0);
CHECKED_ALLOCZ(filter2, filter2Size*dstW*sizeof(*filter2));
FF_ALLOCZ_OR_GOTO(NULL, filter2, filter2Size*dstW*sizeof(*filter2), fail);
for (i=0; i<dstW; i++) {
int j, k;
......@@ -1738,7 +1738,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
// Note the +1 is for the MMX scaler which reads over the end
/* align at 16 for AltiVec (needed by hScale_altivec_real) */
CHECKED_ALLOCZ(*outFilter, *outFilterSize*(dstW+1)*sizeof(int16_t));
FF_ALLOCZ_OR_GOTO(NULL, *outFilter, *outFilterSize*(dstW+1)*sizeof(int16_t), fail);
/* normalize & store in outFilter */
for (i=0; i<dstW; i++) {
......@@ -2599,7 +2599,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
if (!dstFilter) dstFilter= &dummyFilter;
if (!srcFilter) srcFilter= &dummyFilter;
CHECKED_ALLOCZ(c, sizeof(SwsContext));
FF_ALLOCZ_OR_GOTO(NULL, c, sizeof(SwsContext), fail);
c->av_class = &sws_context_class;
c->srcW= srcW;
......@@ -2840,10 +2840,10 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
c->chrMmx2FilterCode = av_malloc(c->chrMmx2FilterCodeSize);
#endif
CHECKED_ALLOCZ(c->lumMmx2Filter , (dstW /8+8)*sizeof(int16_t));
CHECKED_ALLOCZ(c->chrMmx2Filter , (c->chrDstW /4+8)*sizeof(int16_t));
CHECKED_ALLOCZ(c->lumMmx2FilterPos, (dstW /2/8+8)*sizeof(int32_t));
CHECKED_ALLOCZ(c->chrMmx2FilterPos, (c->chrDstW/2/4+8)*sizeof(int32_t));
FF_ALLOCZ_OR_GOTO(c, c->lumMmx2Filter , (dstW /8+8)*sizeof(int16_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->chrMmx2Filter , (c->chrDstW /4+8)*sizeof(int16_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->lumMmx2FilterPos, (dstW /2/8+8)*sizeof(int32_t), fail);
FF_ALLOCZ_OR_GOTO(c, c->chrMmx2FilterPos, (c->chrDstW/2/4+8)*sizeof(int32_t), fail);
initMMX2HScaler( dstW, c->lumXInc, c->lumMmx2FilterCode, c->lumMmx2Filter, c->lumMmx2FilterPos, 8);
initMMX2HScaler(c->chrDstW, c->chrXInc, c->chrMmx2FilterCode, c->chrMmx2Filter, c->chrMmx2FilterPos, 4);
......@@ -2877,8 +2877,8 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
goto fail;
#ifdef COMPILE_ALTIVEC
CHECKED_ALLOC(c->vYCoeffsBank, sizeof (vector signed short)*c->vLumFilterSize*c->dstH);
CHECKED_ALLOC(c->vCCoeffsBank, sizeof (vector signed short)*c->vChrFilterSize*c->chrDstH);
FF_ALLOC_OR_GOTO(c, c->vYCoeffsBank, sizeof (vector signed short)*c->vLumFilterSize*c->dstH, fail);
FF_ALLOC_OR_GOTO(c, c->vCCoeffsBank, sizeof (vector signed short)*c->vChrFilterSize*c->chrDstH, fail);
for (i=0;i<c->vLumFilterSize*c->dstH;i++) {
int j;
......@@ -2914,23 +2914,23 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
// allocate pixbufs (we use dynamic allocation because otherwise we would need to
// allocate several megabytes to handle all possible cases)
CHECKED_ALLOC(c->lumPixBuf, c->vLumBufSize*2*sizeof(int16_t*));
CHECKED_ALLOC(c->chrPixBuf, c->vChrBufSize*2*sizeof(int16_t*));
FF_ALLOC_OR_GOTO(c, c->lumPixBuf, c->vLumBufSize*2*sizeof(int16_t*), fail);
FF_ALLOC_OR_GOTO(c, c->chrPixBuf, c->vChrBufSize*2*sizeof(int16_t*), fail);
if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat))
CHECKED_ALLOCZ(c->alpPixBuf, c->vLumBufSize*2*sizeof(int16_t*));
FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf, c->vLumBufSize*2*sizeof(int16_t*), fail);
//Note we need at least one pixel more at the end because of the MMX code (just in case someone wanna replace the 4000/8000)
/* align at 16 bytes for AltiVec */
for (i=0; i<c->vLumBufSize; i++) {
CHECKED_ALLOCZ(c->lumPixBuf[i+c->vLumBufSize], VOF+1);
FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf[i+c->vLumBufSize], VOF+1, fail);
c->lumPixBuf[i] = c->lumPixBuf[i+c->vLumBufSize];
}
for (i=0; i<c->vChrBufSize; i++) {
CHECKED_ALLOC(c->chrPixBuf[i+c->vChrBufSize], (VOF+1)*2);
FF_ALLOC_OR_GOTO(c, c->chrPixBuf[i+c->vChrBufSize], (VOF+1)*2, fail);
c->chrPixBuf[i] = c->chrPixBuf[i+c->vChrBufSize];
}
if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
for (i=0; i<c->vLumBufSize; i++) {
CHECKED_ALLOCZ(c->alpPixBuf[i+c->vLumBufSize], VOF+1);
FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf[i+c->vLumBufSize], VOF+1, fail);
c->alpPixBuf[i] = c->alpPixBuf[i+c->vLumBufSize];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment