fz_error fz_newlzwe(fz_filter **fp, fz_obj *params) { FZ_NEWFILTER(fz_lzwe, lzw, lzwe); lzw->earlychange = 0; if (params) { fz_obj *obj; obj = fz_dictgets(params, "EarlyChange"); if (obj) lzw->earlychange = fz_toint(obj) != 0; } lzw->bidx = 0; lzw->bsave = 0; lzw->resume = 0; lzw->code = -1; lzw->hcode = -1; lzw->fcode = -1; lzw->codebits = MINBITS; lzw->nextcode = LZW_FIRST; lzw->oldcode = -1; /* generates LZW_CLEAR */ clearhash(lzw); return fz_okay; }
fz_error fz_newjpxd(fz_filter **fp, fz_obj *params) { int err; FZ_NEWFILTER(fz_jpxd, d, jpxd); err = jas_init(); if (err) { fz_free(d); return fz_throw("jasper error: jas_init()"); } d->stream = jas_stream_memopen(nil, 0); if (!d->stream) { fz_free(d); return fz_throw("jasper error: jas_stream_memopen()"); } d->image = nil; d->offset = 0; d->stage = 0; return fz_okay; }
fz_error * fz_newa85e(fz_filter **fp, fz_obj *params) { FZ_NEWFILTER(fz_a85e, f, a85e); f->c = 0; return fz_okay; }
fz_filter * fz_newaesdfilter(unsigned char *key, unsigned keylen) { FZ_NEWFILTER(fz_aesd, f, aesdfilter); aes_setkey_dec(&f->aes, key, keylen * 8); f->ivcount = 0; return (fz_filter *)f; }
fz_error fz_newaesdfilter(fz_filter **fp, unsigned char *key, unsigned keylen) { FZ_NEWFILTER(fz_aesd, f, aesdfilter); aes_setkey_dec(&f->aes, key, keylen * 8); f->ivcount = 0; return fz_okay; }
fz_error * fz_newnullfilter(fz_filter **fp, int len) { FZ_NEWFILTER(fz_nullfilter, f, nullfilter); f->len = len; f->cur = 0; return fz_okay; }
fz_error * fz_newa85d(fz_filter **fp, fz_obj *params) { FZ_NEWFILTER(fz_a85d, f, a85d); f->word = 0; f->count = 0; return nil; }
fz_error * fz_newjbig2d(fz_filter **fp, fz_obj *params) { FZ_NEWFILTER(fz_jbig2d, d, jbig2d); d->ctx = jbig2_ctx_new(nil, JBIG2_OPTIONS_EMBEDDED, nil, nil, nil); d->page = nil; d->idx = 0; return fz_okay; }
fz_error * fz_chainpipeline(fz_filter **fp, fz_filter *head, fz_filter *tail, fz_buffer *buf) { FZ_NEWFILTER(fz_pipeline, p, pipeline); p->head = fz_keepfilter(head); p->tail = fz_keepfilter(tail); p->tailneedsin = 1; p->buffer = fz_keepbuffer(buf); return nil; }
fz_filter * fz_newpredictd(fz_obj *params) { fz_obj *obj; FZ_NEWFILTER(fz_predict, p, predict); p->predictor = 1; p->columns = 1; p->colors = 1; p->bpc = 8; obj = fz_dictgets(params, "Predictor"); if (obj) p->predictor = fz_toint(obj); if (p->predictor != 1 && p->predictor != 2 && p->predictor != 10 && p->predictor != 11 && p->predictor != 12 && p->predictor != 13 && p->predictor != 14 && p->predictor != 15) { fz_warn("invalid predictor: %d", p->predictor); p->predictor = 1; } obj = fz_dictgets(params, "Columns"); if (obj) p->columns = fz_toint(obj); obj = fz_dictgets(params, "Colors"); if (obj) p->colors = fz_toint(obj); obj = fz_dictgets(params, "BitsPerComponent"); if (obj) p->bpc = fz_toint(obj); p->stride = (p->bpc * p->colors * p->columns + 7) / 8; p->bpp = (p->bpc * p->colors + 7) / 8; if (p->predictor >= 10) { p->ref = fz_malloc(p->stride); memset(p->ref, 0, p->stride); } else { p->ref = nil; } return (fz_filter*)p; }
fz_error * fz_newpipeline(fz_filter **fp, fz_filter *head, fz_filter *tail) { fz_error *error; FZ_NEWFILTER(fz_pipeline, p, pipeline); p->head = fz_keepfilter(head); p->tail = fz_keepfilter(tail); p->tailneedsin = 1; error = fz_newbuffer(&p->buffer, FZ_BUFSIZE); if (error) { fz_free(p); return error; } return nil; }
fz_filter * fz_newdctd(fz_obj *params) { fz_obj *obj; int colortransform; FZ_NEWFILTER(fz_dctd, d, dctd); colortransform = -1; /* "unset" */ if (params) { obj = fz_dictgets(params, "ColorTransform"); if (obj) colortransform = fz_toint(obj); } d->colortransform = colortransform; d->stage = 0; /* setup error callback first thing */ myiniterr(&d->err); d->cinfo.err = (struct jpeg_error_mgr*) &d->err; if (setjmp(d->err.jb)) fz_warn("cannot initialise jpeg: %s", d->err.msg); /* create decompression object. this zeroes cinfo except for err. */ jpeg_create_decompress(&d->cinfo); /* prepare source manager */ d->cinfo.src = (struct jpeg_source_mgr *)&d->src; d->src.super.init_source = myinitsource; d->src.super.fill_input_buffer = myfillinput; d->src.super.skip_input_data = myskipinput; d->src.super.resync_to_restart = jpeg_resync_to_restart; d->src.super.term_source = mytermsource; d->src.super.bytes_in_buffer = 0; d->src.super.next_input_byte = nil; d->src.skip = 0; /* speed up jpeg decoding a bit */ d->cinfo.dct_method = JDCT_FASTEST; d->cinfo.do_fancy_upsampling = FALSE; return (fz_filter *)d; }
fz_error fz_newlzwd(fz_filter **fp, fz_obj *params) { int i; FZ_NEWFILTER(fz_lzwd, lzw, lzwd); lzw->earlychange = 0; if (params) { fz_obj *obj; obj = fz_dictgets(params, "EarlyChange"); if (obj) lzw->earlychange = fz_toint(obj) != 0; } lzw->bidx = 32; lzw->word = 0; for (i = 0; i < 256; i++) { lzw->table[i].value = i; lzw->table[i].firstchar = i; lzw->table[i].length = 1; lzw->table[i].prev = -1; } for (i = 256; i < NUMCODES; i++) { lzw->table[i].value = 0; lzw->table[i].firstchar = 0; lzw->table[i].length = 0; lzw->table[i].prev = -1; } lzw->codebits = MINBITS; lzw->code = -1; lzw->nextcode = LZW_FIRST; lzw->oldcode = -1; lzw->resume = 0; return fz_okay; }
fz_error * fz_newpredict(fz_filter **fp, fz_obj *params, int encode) { fz_obj *obj; FZ_NEWFILTER(fz_predict, p, predict); p->encode = encode; p->predictor = 1; p->columns = 1; p->colors = 1; p->bpc = 8; obj = fz_dictgets(params, "Predictor"); if (obj) p->predictor = fz_toint(obj); obj = fz_dictgets(params, "Columns"); if (obj) p->columns = fz_toint(obj); obj = fz_dictgets(params, "Colors"); if (obj) p->colors = fz_toint(obj); obj = fz_dictgets(params, "BitsPerComponent"); if (obj) p->bpc = fz_toint(obj); p->stride = (p->bpc * p->colors * p->columns + 7) / 8; p->bpp = (p->bpc * p->colors + 7) / 8; if (p->predictor >= 10) { p->ref = fz_malloc(p->stride); if (!p->ref) { fz_free(p); return fz_throw("outofmem: predictor reference buffer"); } memset(p->ref, 0, p->stride); } else { p->ref = nil; } return fz_okay; }
fz_error fz_newcopyfilter(fz_filter **fp) { FZ_NEWFILTER(fz_copyfilter, f, copyfilter); return fz_okay; }
fz_error fz_newrld(fz_filter **fp, fz_obj *params) { FZ_NEWFILTER(fz_filter, f, rld); return fz_okay; }