1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

swscale/utils: use FF_ALLOC(Z)_ARRAY_OR_GOTO() and av_malloc(z)_array()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-05-04 19:49:06 +02:00
parent beecfa81ac
commit 656fe7ecce

View File

@ -312,13 +312,13 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
emms_c(); // FIXME should not be required but IS (even for non-MMX versions) emms_c(); // FIXME should not be required but IS (even for non-MMX versions)
// NOTE: the +3 is for the MMX(+1) / SSE(+3) scaler which reads over the end // NOTE: the +3 is for the MMX(+1) / SSE(+3) scaler which reads over the end
FF_ALLOC_OR_GOTO(NULL, *filterPos, (dstW + 3) * sizeof(**filterPos), fail); FF_ALLOC_ARRAY_OR_GOTO(NULL, *filterPos, (dstW + 3), sizeof(**filterPos), fail);
if (FFABS(xInc - 0x10000) < 10 && srcPos == dstPos) { // unscaled if (FFABS(xInc - 0x10000) < 10 && srcPos == dstPos) { // unscaled
int i; int i;
filterSize = 1; filterSize = 1;
FF_ALLOCZ_OR_GOTO(NULL, filter, FF_ALLOCZ_ARRAY_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail); dstW, sizeof(*filter) * filterSize, fail);
for (i = 0; i < dstW; i++) { for (i = 0; i < dstW; i++) {
filter[i * filterSize] = fone; filter[i * filterSize] = fone;
@ -328,8 +328,8 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
int i; int i;
int64_t xDstInSrc; int64_t xDstInSrc;
filterSize = 1; filterSize = 1;
FF_ALLOC_OR_GOTO(NULL, filter, FF_ALLOC_ARRAY_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail); dstW, sizeof(*filter) * filterSize, fail);
xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7); xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7);
for (i = 0; i < dstW; i++) { for (i = 0; i < dstW; i++) {
@ -344,8 +344,8 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
int i; int i;
int64_t xDstInSrc; int64_t xDstInSrc;
filterSize = 2; filterSize = 2;
FF_ALLOC_OR_GOTO(NULL, filter, FF_ALLOC_ARRAY_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail); dstW, sizeof(*filter) * filterSize, fail);
xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7); xDstInSrc = ((dstPos*(int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7);
for (i = 0; i < dstW; i++) { for (i = 0; i < dstW; i++) {
@ -385,8 +385,8 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
filterSize = FFMIN(filterSize, srcW - 2); filterSize = FFMIN(filterSize, srcW - 2);
filterSize = FFMAX(filterSize, 1); filterSize = FFMAX(filterSize, 1);
FF_ALLOC_OR_GOTO(NULL, filter, FF_ALLOC_ARRAY_OR_GOTO(NULL, filter,
dstW * sizeof(*filter) * filterSize, fail); dstW, sizeof(*filter) * filterSize, fail);
xDstInSrc = ((dstPos*(int64_t)xInc)>>7) - ((srcPos*0x10000LL)>>7); xDstInSrc = ((dstPos*(int64_t)xInc)>>7) - ((srcPos*0x10000LL)>>7);
for (i = 0; i < dstW; i++) { for (i = 0; i < dstW; i++) {
@ -493,7 +493,7 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
if (dstFilter) if (dstFilter)
filter2Size += dstFilter->length - 1; filter2Size += dstFilter->length - 1;
av_assert0(filter2Size > 0); av_assert0(filter2Size > 0);
FF_ALLOCZ_OR_GOTO(NULL, filter2, filter2Size * dstW * sizeof(*filter2), fail); FF_ALLOCZ_ARRAY_OR_GOTO(NULL, filter2, dstW, filter2Size * sizeof(*filter2), fail);
for (i = 0; i < dstW; i++) { for (i = 0; i < dstW; i++) {
int j, k; int j, k;
@ -577,7 +577,7 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
av_assert0(minFilterSize > 0); av_assert0(minFilterSize > 0);
filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1)); filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1));
av_assert0(filterSize > 0); av_assert0(filterSize > 0);
filter = av_malloc(filterSize * dstW * sizeof(*filter)); filter = av_malloc_array(dstW, filterSize * sizeof(*filter));
if (!filter) if (!filter)
goto fail; goto fail;
if (filterSize >= MAX_FILTER_SIZE * 16 / if (filterSize >= MAX_FILTER_SIZE * 16 /
@ -635,8 +635,8 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
// Note the +1 is for the MMX scaler which reads over the end // Note the +1 is for the MMX scaler which reads over the end
/* align at 16 for AltiVec (needed by hScale_altivec_real) */ /* align at 16 for AltiVec (needed by hScale_altivec_real) */
FF_ALLOCZ_OR_GOTO(NULL, *outFilter, FF_ALLOCZ_ARRAY_OR_GOTO(NULL, *outFilter,
*outFilterSize * (dstW + 3) * sizeof(int16_t), fail); (dstW + 3), *outFilterSize * sizeof(int16_t), fail);
/* normalize & store in outFilter */ /* normalize & store in outFilter */
for (i = 0; i < dstW; i++) { for (i = 0; i < dstW; i++) {