summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-04-15 16:59:19 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-04-28 01:28:10 +0200
commit84a80ac15de802dfea32d83206deafadbd1947cb (patch)
tree59bc88485ca6eca6d614ec1a9b65f7a998e2da46 /libavcodec
parente4a26a64a875d4376cd78f77905a58c4f0238d85 (diff)
avcodec/pgxdec: Hoist branch out of loop
Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/pgxdec.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/libavcodec/pgxdec.c b/libavcodec/pgxdec.c
index 30895b51ee..29de103167 100644
--- a/libavcodec/pgxdec.c
+++ b/libavcodec/pgxdec.c
@@ -95,16 +95,13 @@ error:
static inline void write_frame_ ##D(AVFrame *frame, GetByteContext *g, \
int width, int height, int sign, int depth) \
{ \
+ const unsigned offset = sign ? (1 << (D - 1)) : 0; \
int i, j; \
for (i = 0; i < height; i++) { \
PIXEL *line = (PIXEL*)(frame->data[0] + i * frame->linesize[0]); \
for (j = 0; j < width; j++) { \
- unsigned val; \
- if (sign) \
- val = (PIXEL)bytestream2_get_ ##suffix##u(g) + (1 << (depth - 1)); \
- else \
- val = bytestream2_get_ ##suffix##u(g); \
- val <<= (D - depth); \
+ unsigned val = bytestream2_get_ ##suffix##u(g) << (D - depth); \
+ val ^= offset; \
*(line + j) = val; \
} \
} \