From bffb8ce8a4f21f3e20513e7f76a949acb190e14a Mon Sep 17 00:00:00 2001 From: yzrh Date: Sat, 31 Dec 2022 21:17:28 +0000 Subject: Fix JBIG decoder. Signed-off-by: yzrh --- src/jbig.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/jbig.c b/src/jbig.c index 37afb50..c3c501b 100644 --- a/src/jbig.c +++ b/src/jbig.c @@ -209,6 +209,17 @@ _procline(int line, char *a, char *b, char *c) /* The encoder must be erroneous */ uint16_t cx = 0; + if (line > 0) { + cx += (_ret[_width_padded * (_height - line)] & 0x20) << 2; + cx += _ret[_width_padded * (_height - line)] & 0x40; + cx += (_ret[_width_padded * (_height - line)] & 0x80) >> 2; + } + + if (line > 1) { + cx += (_ret[_width_padded * (_height - line + 1)] & 0x40) >> 4; + cx += (_ret[_width_padded * (_height - line + 1)] & 0x80) >> 6; + } + for (int i = 0; i < _width; i++) { _decode(cx); -- cgit v1.2.3