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

swscale/output: Assert that yalpha and uvalpha are within their expected range

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2016-01-14 18:36:02 +01:00
parent fe6372bb61
commit b99f498716

View File

@ -385,6 +385,7 @@ yuv2mono_2_c_template(SwsContext *c, const int16_t *buf[2],
const uint8_t * const d128 = ff_dither_8x8_220[y & 7];
int yalpha1 = 4096 - yalpha;
int i;
av_assert2(yalpha <= 4096U);
if (c->dither == SWS_DITHER_ED) {
int err = 0;
@ -590,6 +591,8 @@ yuv2422_2_c_template(SwsContext *c, const int16_t *buf[2],
int yalpha1 = 4096 - yalpha;
int uvalpha1 = 4096 - uvalpha;
int i;
av_assert2(yalpha <= 4096U);
av_assert2(uvalpha <= 4096U);
for (i = 0; i < ((dstW + 1) >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
@ -777,6 +780,9 @@ yuv2rgba64_2_c_template(SwsContext *c, const int32_t *buf[2],
int i;
int A1 = 0xffff<<14, A2 = 0xffff<<14;
av_assert2(yalpha <= 4096U);
av_assert2(uvalpha <= 4096U);
for (i = 0; i < ((dstW + 1) >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14;
int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14;
@ -1006,6 +1012,9 @@ yuv2rgba64_full_2_c_template(SwsContext *c, const int32_t *buf[2],
int i;
int A = 0xffff<<14;
av_assert2(yalpha <= 4096U);
av_assert2(uvalpha <= 4096U);
for (i = 0; i < dstW; i++) {
int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 14;
int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14;
@ -1387,6 +1396,8 @@ yuv2rgb_2_c_template(SwsContext *c, const int16_t *buf[2],
int yalpha1 = 4096 - yalpha;
int uvalpha1 = 4096 - uvalpha;
int i;
av_assert2(yalpha <= 4096U);
av_assert2(uvalpha <= 4096U);
for (i = 0; i < ((dstW + 1) >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
@ -1729,6 +1740,9 @@ yuv2rgb_full_2_c_template(SwsContext *c, const int16_t *buf[2],
int err[4] = {0};
int A = 0; // init to silcene warning
av_assert2(yalpha <= 4096U);
av_assert2(uvalpha <= 4096U);
if( target == AV_PIX_FMT_BGR4_BYTE || target == AV_PIX_FMT_RGB4_BYTE
|| target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8)
step = 1;
@ -1956,6 +1970,8 @@ yuv2ya8_2_c(SwsContext *c, const int16_t *buf[2],
int yalpha1 = 4096 - yalpha;
int i;
av_assert2(yalpha <= 4096U);
for (i = 0; i < dstW; i++) {
int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19;
int A;