LibGfx/JBIG2+Tests/LibGfx: Add JBIG2 tests for text refinement with custom tables #26394
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There can be up to four custom huffman tables for refinement in
text regions. Text regions also must refer to at least one symbol
dictinary, so customizing all refinement tables means that a text
region refers to five other segments.
That causes issues, especially in other decoders, see #26393.
Also, Acrobat Reader apparently can't handle if the table that stores
refinement data sizes is customized.
So instead of adding a single test that customizes all four tables,
add a bunch of tests, with the goal of most of them decoding in
several other JBIG2 decoders.
Add a file with custom tables for refinement position.
Decodes fine in PDFium, Acrobat Reader.
Decodes mostly fine in Preview.app.
Add a file with custom tables for refinement dimensions.
Decodes fine in PDFium, Acrobat Reader.
Decodes mostly fine in Preview.app.
Add a file with custom tables for refinement data size.
Decodes fine in PDFium.
Decodes mostly fine in Preview.app.
Add a file with custom tables for refinement position and
dimensions. This has 5 referred-to segments.
Decodes fine in Acrobat Reader (and HEAD PDFium).
Decodes mostly fine in Preview.app.
Finally, add one with all customized.
PDFium can decode this as of a few hours ago, but nothing else can.
(Preview.app comes fairly close.) Given that it's just a combination
of tests 1-4 and those all decode fine somewhere, there's some hope
to believe that the test itself is correct.
For the contents of the custom huffman tables, I used the same
contents as in the default huffman tables (B.14 for the first four,
B.1 for the last), but changed them a bit. For B.14, I put the 1-length
symbol in each of the four slots that it isn't in the normal B.14 table,
and for B.1 I swapped the first two entries.
Also, fix a bug in our implementation of writing custom tables that these tests found :^)