[FFmpeg-cvslog] avcodec/pgxdec: Hoist branch out of loop
Andreas Rheinhardt
git at videolan.org
Thu Apr 28 02:57:02 EEST 2022
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Apr 15 16:59:19 2022 +0200| [84a80ac15de802dfea32d83206deafadbd1947cb] | committer: Andreas Rheinhardt
avcodec/pgxdec: Hoist branch out of loop
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=84a80ac15de802dfea32d83206deafadbd1947cb
---
libavcodec/pgxdec.c | 9 +++------
1 file 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; \
} \
} \
More information about the ffmpeg-cvslog
mailing list