Commit c5826804 authored by lu_zero's avatar lu_zero

Avoid branches in the loop and solve a gcc warning

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@7566 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 82a5431b
...@@ -2256,7 +2256,7 @@ int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, ...@@ -2256,7 +2256,7 @@ int img_pad(AVPicture *dst, const AVPicture *src, int height, int width,
int pix_fmt, int padtop, int padbottom, int padleft, int padright, int pix_fmt, int padtop, int padbottom, int padleft, int padright,
int *color) int *color)
{ {
uint8_t *optr, *iptr; uint8_t *optr;
int y_shift; int y_shift;
int x_shift; int x_shift;
int yheight; int yheight;
...@@ -2274,24 +2274,30 @@ int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, ...@@ -2274,24 +2274,30 @@ int img_pad(AVPicture *dst, const AVPicture *src, int height, int width,
dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift)); dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
} }
if (padleft || padright || src) { if (padleft || padright) {
optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
(dst->linesize[i] - (padright >> x_shift));
yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
for (y = 0; y < yheight; y++) {
memset(optr, color[i], (padleft + padright) >> x_shift);
optr += dst->linesize[i];
}
}
if (src) { /* first line */ if (src) { /* first line */
iptr = src->data[i]; uint8_t *iptr = src->data[i];
optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
(padleft >> x_shift); (padleft >> x_shift);
memcpy(optr, iptr, src->linesize[i]); memcpy(optr, iptr, src->linesize[i]);
iptr += src->linesize[i]; iptr += src->linesize[i];
}
optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
(dst->linesize[i] - (padright >> x_shift)); (dst->linesize[i] - (padright >> x_shift));
yheight = (height - 1 - (padtop + padbottom)) >> y_shift; yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
for (y = 0; y < yheight; y++) { for (y = 0; y < yheight; y++) {
memset(optr, color[i], (padleft + padright) >> x_shift); memset(optr, color[i], (padleft + padright) >> x_shift);
if (src) {
memcpy(optr + ((padleft + padright) >> x_shift), iptr, memcpy(optr + ((padleft + padright) >> x_shift), iptr,
src->linesize[i]); src->linesize[i]);
iptr += src->linesize[i]; iptr += src->linesize[i];
}
optr += dst->linesize[i]; optr += dst->linesize[i];
} }
} }
......
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