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

swscale: fix invalid memory accesses in yuvpacked1() functions.

This commit is contained in:
Ronald S. Bultje 2012-02-12 15:47:14 -08:00
parent 0bf184e59c
commit 1ca7dc60d2

View File

@ -629,20 +629,20 @@ yuv2422_1_c_template(SwsContext *c, const int16_t *buf0,
const int16_t *abuf0, uint8_t *dest, int dstW, const int16_t *abuf0, uint8_t *dest, int dstW,
int uvalpha, int y, enum PixelFormat target) int uvalpha, int y, enum PixelFormat target)
{ {
const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
int i; int i;
if (uvalpha < 2048) { if (uvalpha < 2048) {
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < (dstW >> 1); i++) {
int Y1 = buf0[i * 2] >> 7; int Y1 = buf0[i * 2] >> 7;
int Y2 = buf0[i * 2 + 1] >> 7; int Y2 = buf0[i * 2 + 1] >> 7;
int U = ubuf1[i] >> 7; int U = ubuf0[i] >> 7;
int V = vbuf1[i] >> 7; int V = vbuf0[i] >> 7;
output_pixels(i * 4, Y1, U, Y2, V); output_pixels(i * 4, Y1, U, Y2, V);
} }
} else { } else {
const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < (dstW >> 1); i++) {
int Y1 = buf0[i * 2] >> 7; int Y1 = buf0[i * 2] >> 7;
int Y2 = buf0[i * 2 + 1] >> 7; int Y2 = buf0[i * 2 + 1] >> 7;
@ -775,8 +775,7 @@ yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0,
const int32_t *abuf0, uint16_t *dest, int dstW, const int32_t *abuf0, uint16_t *dest, int dstW,
int uvalpha, int y, enum PixelFormat target) int uvalpha, int y, enum PixelFormat target)
{ {
const int32_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
int i; int i;
if (uvalpha < 2048) { if (uvalpha < 2048) {
@ -807,6 +806,7 @@ yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0,
dest += 6; dest += 6;
} }
} else { } else {
const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < (dstW >> 1); i++) {
int Y1 = (buf0[i * 2] ) >> 2; int Y1 = (buf0[i * 2] ) >> 2;
int Y2 = (buf0[i * 2 + 1]) >> 2; int Y2 = (buf0[i * 2 + 1]) >> 2;
@ -1070,16 +1070,15 @@ yuv2rgb_1_c_template(SwsContext *c, const int16_t *buf0,
int uvalpha, int y, enum PixelFormat target, int uvalpha, int y, enum PixelFormat target,
int hasAlpha) int hasAlpha)
{ {
const int16_t *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
int i; int i;
if (uvalpha < 2048) { if (uvalpha < 2048) {
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < (dstW >> 1); i++) {
int Y1 = buf0[i * 2] >> 7; int Y1 = buf0[i * 2] >> 7;
int Y2 = buf0[i * 2 + 1] >> 7; int Y2 = buf0[i * 2 + 1] >> 7;
int U = ubuf1[i] >> 7; int U = ubuf0[i] >> 7;
int V = vbuf1[i] >> 7; int V = vbuf0[i] >> 7;
int A1, A2; int A1, A2;
const void *r = c->table_rV[V], const void *r = c->table_rV[V],
*g = (c->table_gU[U] + c->table_gV[V]), *g = (c->table_gU[U] + c->table_gV[V]),
@ -1094,6 +1093,7 @@ yuv2rgb_1_c_template(SwsContext *c, const int16_t *buf0,
r, g, b, y, target, hasAlpha); r, g, b, y, target, hasAlpha);
} }
} else { } else {
const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < (dstW >> 1); i++) {
int Y1 = buf0[i * 2] >> 7; int Y1 = buf0[i * 2] >> 7;
int Y2 = buf0[i * 2 + 1] >> 7; int Y2 = buf0[i * 2 + 1] >> 7;