diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2007-01-17 11:02:07 +0000 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2007-01-17 11:02:07 +0000 |
commit | 79acfb0e133317c3a38c55b73c3b80f3212af2f9 (patch) | |
tree | 52e2de5b31635e1968822de884453078d22a817c /libavcodec/imgconvert.c | |
parent | b90ba24b9a0975c410409116e00c67410a4091a5 (diff) | |
download | ffmpeg-79acfb0e133317c3a38c55b73c3b80f3212af2f9.tar.gz |
Avoid branches in the loop and solve a gcc warning
Originally committed as revision 7566 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/imgconvert.c')
-rw-r--r-- | libavcodec/imgconvert.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 2f9d6908a1..b2305cd639 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -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 *color) { - uint8_t *optr, *iptr; + uint8_t *optr; int y_shift; int x_shift; int yheight; @@ -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)); } - if (padleft || padright || src) { - if (src) { /* first line */ - iptr = src->data[i]; - optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + - (padleft >> x_shift); - memcpy(optr, iptr, src->linesize[i]); - iptr += src->linesize[i]; + 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 */ + uint8_t *iptr = src->data[i]; + optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + + (padleft >> x_shift); + memcpy(optr, iptr, src->linesize[i]); + iptr += src->linesize[i]; 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); - if (src) { - memcpy(optr + ((padleft + padright) >> x_shift), iptr, - src->linesize[i]); - iptr += src->linesize[i]; - } + memcpy(optr + ((padleft + padright) >> x_shift), iptr, + src->linesize[i]); + iptr += src->linesize[i]; optr += dst->linesize[i]; } } |