ref: 6d2612e1503c37990bba44b409e5402d9dbd5c19
dir: /f_jbig2.c/
#include <u.h> #include <libc.h> #include "pdf.h" /* 7.4.7 JBIG2Decode filter */ static u8int bh[] = { /* id string */ 0x97, 0x4a, 0x42, 0x32, 0x0d, 0x0a, 0x1a, 0x0a, /* sequential */ 0x01, /* one page */ 0x00, 0x00, 0x00, 0x01, }; static int flreadall(void *aux, Buffer *bi, Buffer *bo) { Stream *s; s = aux; bufput(bo, bh, sizeof(bh)); if(s != nil) bufput(bo, s->buf.b, s->buf.sz); bufput(bo, bi->b, bi->sz); bi->off = bi->sz; return 0; } static int flopen(Filter *f, Object *o) { Object *parms, *so; Stream *s; parms = dictget(o, "DecodeParms"); s = nil; if((so = dictget(parms, "JBIG2Globals")) != &null && (s = Sopen(so)) == nil) return -1; f->aux = s; return 0; } static void flclose(Filter *f) { Sclose(f->aux); } Filter filterJBIG2 = { .name = "JBIG2Decode", .readall = flreadall, .open = flopen, .close = flclose, };