Commit 9206ac80 authored by Ronald S. Bultje's avatar Ronald S. Bultje

swscale: handle last pixel if lines have an odd width.

Fixes bug 270.
parent f5be7958
...@@ -466,7 +466,7 @@ yuv2422_X_c_template(SwsContext *c, const int16_t *lumFilter, ...@@ -466,7 +466,7 @@ yuv2422_X_c_template(SwsContext *c, const int16_t *lumFilter,
{ {
int i; int i;
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < ((dstW + 1) >> 1); i++) {
int j; int j;
int Y1 = 1 << 18; int Y1 = 1 << 18;
int Y2 = 1 << 18; int Y2 = 1 << 18;
...@@ -509,7 +509,7 @@ yuv2422_2_c_template(SwsContext *c, const int16_t *buf[2], ...@@ -509,7 +509,7 @@ yuv2422_2_c_template(SwsContext *c, const int16_t *buf[2],
int uvalpha1 = 4095 - uvalpha; int uvalpha1 = 4095 - uvalpha;
int i; int i;
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < ((dstW + 1) >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19; int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19; int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19; int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
...@@ -534,7 +534,7 @@ yuv2422_1_c_template(SwsContext *c, const int16_t *buf0, ...@@ -534,7 +534,7 @@ yuv2422_1_c_template(SwsContext *c, const int16_t *buf0,
int i; int i;
if (uvalpha < 2048) { if (uvalpha < 2048) {
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < ((dstW + 1) >> 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 = ubuf0[i] >> 7; int U = ubuf0[i] >> 7;
...@@ -549,7 +549,7 @@ yuv2422_1_c_template(SwsContext *c, const int16_t *buf0, ...@@ -549,7 +549,7 @@ yuv2422_1_c_template(SwsContext *c, const int16_t *buf0,
} }
} else { } else {
const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1]; const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < ((dstW + 1) >> 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 = (ubuf0[i] + ubuf1[i]) >> 8; int U = (ubuf0[i] + ubuf1[i]) >> 8;
...@@ -589,7 +589,7 @@ yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter, ...@@ -589,7 +589,7 @@ yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter,
{ {
int i; int i;
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < ((dstW + 1) >> 1); i++) {
int j; int j;
int Y1 = -0x40000000; int Y1 = -0x40000000;
int Y2 = -0x40000000; int Y2 = -0x40000000;
...@@ -652,7 +652,7 @@ yuv2rgb48_2_c_template(SwsContext *c, const int32_t *buf[2], ...@@ -652,7 +652,7 @@ yuv2rgb48_2_c_template(SwsContext *c, const int32_t *buf[2],
int uvalpha1 = 4095 - uvalpha; int uvalpha1 = 4095 - uvalpha;
int i; int i;
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < ((dstW + 1) >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14; int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14;
int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14; int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14;
int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14; int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14;
...@@ -690,7 +690,7 @@ yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0, ...@@ -690,7 +690,7 @@ yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0,
int i; int i;
if (uvalpha < 2048) { if (uvalpha < 2048) {
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < ((dstW + 1) >> 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;
int U = (ubuf0[i] + (-128 << 11)) >> 2; int U = (ubuf0[i] + (-128 << 11)) >> 2;
...@@ -718,7 +718,7 @@ yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0, ...@@ -718,7 +718,7 @@ yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0,
} }
} else { } else {
const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1]; const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < ((dstW + 1) >> 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;
int U = (ubuf0[i] + ubuf1[i] + (-128 << 12)) >> 3; int U = (ubuf0[i] + ubuf1[i] + (-128 << 12)) >> 3;
...@@ -932,7 +932,7 @@ yuv2rgb_X_c_template(SwsContext *c, const int16_t *lumFilter, ...@@ -932,7 +932,7 @@ yuv2rgb_X_c_template(SwsContext *c, const int16_t *lumFilter,
{ {
int i; int i;
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < ((dstW + 1) >> 1); i++) {
int j, A1, A2; int j, A1, A2;
int Y1 = 1 << 18; int Y1 = 1 << 18;
int Y2 = 1 << 18; int Y2 = 1 << 18;
...@@ -999,7 +999,7 @@ yuv2rgb_2_c_template(SwsContext *c, const int16_t *buf[2], ...@@ -999,7 +999,7 @@ yuv2rgb_2_c_template(SwsContext *c, const int16_t *buf[2],
int uvalpha1 = 4095 - uvalpha; int uvalpha1 = 4095 - uvalpha;
int i; int i;
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < ((dstW + 1) >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19; int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19; int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19; int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
...@@ -1037,7 +1037,7 @@ yuv2rgb_1_c_template(SwsContext *c, const int16_t *buf0, ...@@ -1037,7 +1037,7 @@ yuv2rgb_1_c_template(SwsContext *c, const int16_t *buf0,
int i; int i;
if (uvalpha < 2048) { if (uvalpha < 2048) {
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < ((dstW + 1) >> 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 = ubuf0[i] >> 7; int U = ubuf0[i] >> 7;
...@@ -1064,7 +1064,7 @@ yuv2rgb_1_c_template(SwsContext *c, const int16_t *buf0, ...@@ -1064,7 +1064,7 @@ yuv2rgb_1_c_template(SwsContext *c, const int16_t *buf0,
} }
} else { } else {
const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1]; const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
for (i = 0; i < (dstW >> 1); i++) { for (i = 0; i < ((dstW + 1) >> 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 = (ubuf0[i] + ubuf1[i]) >> 8; int U = (ubuf0[i] + ubuf1[i]) >> 8;
......
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