I would like a command line executable written in C++, and the same written in Objective C, that will decode JBIG2 images in a particular way. It must do ALL of the following:
1. The decoder may be based on jbig2dec or other open-source decoders, or it may be written from scratch.
2. The decoder must be able to decode standard JBIG2s and JBIG2s which use a shared glyph encoding.
3. The decoder must output as both PNG, PBM and TIF (which can be specified).
4. The C++ version must also be a command-line executable, while the Objective C version should be able to be used inside a iOS application (the iOS application is not to be written, only the code so it can be integrated).
5. The decoder must be able to be given multiple images for one page (which can be a combination of standard JBIG2 and JBIG2 with glyph encoding) which it will produce into one image, i.e. it will output a single image with all the black parts put on top of each other. It is also possible that the different images to make up one page will be of different resolution, but this will always be in the ratio 1:2 (one of the images may be twice the resolution of another) and in this case the smaller images are scaled up to match the higher resolution image in the final output.
6. The final output image (PNG or PMN) can be downsampled. E.g. the JBIG2s may be 1000x600 but I can specify a downsampling of 0.5 to get 500x300 as the output image.
7. Most current JBIG2 decoders re-parse the shared glyph file each time when decoding multiple glyph-encoded JBIG2s, this is very inefficient. It is very important that this decoder does not do this and only parses the shared glyph file once when decoding multiple pages using the same glyphs. This means that I want to be able to decode several pages at the same time using the same shared glyph file.
8. Expanding on (5) and (7): Since there can be images per page, and multiple JBIG2s with shared glyphs to be decoded all at the same time, I must be able to specify: which shared glyph file to use, the number of pages, each JBIG2 image per page, and whether each JBIG2 image uses glyph encoding or not.
Example: I may have 5 pages which consist of 10 JBIG2 files and 1 JBIG2 shared header. This means 2 JBIG2 images per page, and one of them could be twice the resolution of another. One of the images could also be glyph encoded while the other is not. The output would be 5 files in either PNG, PBM or TIF format (up to me.)
It is very important that this all done properly and efficiently. The speed of the decoding is very important. The entire thing must be written in C++ and also in Objective C without calling on any dependencies (with the exception of libpng or libtif). I do NOT want a wrapper that just uses currently available apps to do this because that would be slow and this needs to be as fast and efficient as possible.