Commit fbc978df authored by lu_zero's avatar lu_zero

Cosmetics

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@7564 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent a3a1897b
...@@ -2252,8 +2252,9 @@ int img_crop(AVPicture *dst, const AVPicture *src, ...@@ -2252,8 +2252,9 @@ int img_crop(AVPicture *dst, const AVPicture *src,
/** /**
* Pad image * Pad image
*/ */
int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt, int img_pad(AVPicture *dst, const AVPicture *src, int height, int width,
int padtop, int padbottom, int padleft, int padright, int *color) int pix_fmt, int padtop, int padbottom, int padleft, int padright,
int *color)
{ {
uint8_t *optr, *iptr; uint8_t *optr, *iptr;
int y_shift; int y_shift;
...@@ -2261,30 +2262,34 @@ int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix ...@@ -2261,30 +2262,34 @@ int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix
int yheight; int yheight;
int i, y; int i, y;
if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB || !is_yuv_planar(&pix_fmt_info[pix_fmt])) if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB ||
return -1; !is_yuv_planar(&pix_fmt_info[pix_fmt])) return -1;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
x_shift = i ? pix_fmt_info[pix_fmt].x_chroma_shift : 0; x_shift = i ? pix_fmt_info[pix_fmt].x_chroma_shift : 0;
y_shift = i ? pix_fmt_info[pix_fmt].y_chroma_shift : 0; y_shift = i ? pix_fmt_info[pix_fmt].y_chroma_shift : 0;
if (padtop || padleft) { if (padtop || padleft) {
memset(dst->data[i], color[i], dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift)); memset(dst->data[i], color[i],
dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
} }
if (padleft || padright || src) { if (padleft || padright || src) {
if (src) { /* first line */ if (src) { /* first line */
iptr = src->data[i]; iptr = src->data[i];
optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift); optr = dst->data[i] + dst->linesize[i] * (padtop >> y_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) + (dst->linesize[i] - (padright >> x_shift)); optr = dst->data[i] + dst->linesize[i] * (padtop >> y_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) { if (src) {
memcpy(optr + ((padleft + padright) >> x_shift), iptr, src->linesize[i]); memcpy(optr + ((padleft + padright) >> x_shift), iptr,
src->linesize[i]);
iptr += src->linesize[i]; iptr += src->linesize[i];
} }
optr += dst->linesize[i]; optr += dst->linesize[i];
...@@ -2292,8 +2297,10 @@ int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix ...@@ -2292,8 +2297,10 @@ int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix
} }
if (padbottom || padright) { if (padbottom || padright) {
optr = dst->data[i] + dst->linesize[i] * ((height - padbottom) >> y_shift) - (padright >> x_shift); optr = dst->data[i] + dst->linesize[i] *
memset(optr, color[i], dst->linesize[i] * (padbottom >> y_shift) + (padright >> x_shift)); ((height - padbottom) >> y_shift) - (padright >> x_shift);
memset(optr, color[i],dst->linesize[i] *
(padbottom >> y_shift) + (padright >> x_shift));
} }
} }
return 0; return 0;
......
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