Skip to content

Commit ad1cef0

Browse files
committed
swscale/swscale_internal: Hoist branch out of loop
Signed-off-by: Andreas Rheinhardt <[email protected]>
1 parent c8549d4 commit ad1cef0

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

libswscale/swscale_internal.h

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,49 +1021,35 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
10211021
static inline void fillPlane16(uint8_t *plane, int stride, int width, int height, int y,
10221022
int alpha, int bits, const int big_endian)
10231023
{
1024-
int i, j;
10251024
uint8_t *ptr = plane + stride * y;
10261025
int v = alpha ? 0xFFFF>>(16-bits) : (1<<(bits-1));
1027-
for (i = 0; i < height; i++) {
1028-
#define FILL(wfunc) \
1029-
for (j = 0; j < width; j++) {\
1030-
wfunc(ptr+2*j, v);\
1031-
}
1032-
if (big_endian) {
1033-
FILL(AV_WB16);
1034-
} else {
1035-
FILL(AV_WL16);
1036-
}
1026+
if (big_endian != HAVE_BIGENDIAN)
1027+
v = av_bswap16(v);
1028+
for (int i = 0; i < height; i++) {
1029+
for (int j = 0; j < width; j++)
1030+
AV_WN16(ptr + 2 * j, v);
10371031
ptr += stride;
10381032
}
1039-
#undef FILL
10401033
}
10411034

10421035
static inline void fillPlane32(uint8_t *plane, int stride, int width, int height, int y,
10431036
int alpha, int bits, const int big_endian, int is_float)
10441037
{
1045-
int i, j;
10461038
uint8_t *ptr = plane + stride * y;
10471039
uint32_t v;
10481040
uint32_t onef32 = 0x3f800000;
10491041
if (is_float)
10501042
v = alpha ? onef32 : 0;
10511043
else
10521044
v = alpha ? 0xFFFFFFFF>>(32-bits) : (1<<(bits-1));
1045+
if (big_endian != HAVE_BIGENDIAN)
1046+
v = av_bswap32(v);
10531047

1054-
for (i = 0; i < height; i++) {
1055-
#define FILL(wfunc) \
1056-
for (j = 0; j < width; j++) {\
1057-
wfunc(ptr+4*j, v);\
1058-
}
1059-
if (big_endian) {
1060-
FILL(AV_WB32);
1061-
} else {
1062-
FILL(AV_WL32);
1063-
}
1048+
for (int i = 0; i < height; i++) {
1049+
for (int j = 0; j < width; j++)
1050+
AV_WN32(ptr + 4 * j, v);
10641051
ptr += stride;
10651052
}
1066-
#undef FILL
10671053
}
10681054

10691055

0 commit comments

Comments
 (0)