Hello,
I would like to create a build (Win 7 x64) of Firefox that support JPEG with arithmetic compression. I added the defines in libjpeg-turbo and changed ABI to 80 and also added the 3 source files to the makefile, it compiles fine, but still no difference when I load a JPEG with arithmetic compression I still get the same error message "The image "xy.jpg" cannot be displayed because it contains errors" (it always gets the correct resolution).
I also tried to to replace with latest version (1.3.0) of libjpeg-turbo, again no difference.
I assume that mozilla somewhere before it calls libjpeg analyzes the JPEG and creates an error because it assumes arithmetic coding is not supported. Any ideas how to enable it?
Regards
Stefan
How to enable arithmetic coding in JPEG?
- LoudNoise
- New Member
- Posts: 39900
- Joined: October 18th, 2007, 1:45 pm
- Location: Next door to the west
Re: How to enable arithmetic coding in JPEG?
Moving to Third Party builds.
Post wrangler
"Choose between the Food Select Feature or other Functions. If no food or function is chosen, Toast is the default."
"Choose between the Food Select Feature or other Functions. If no food or function is chosen, Toast is the default."
-
- Posts: 311
- Joined: June 20th, 2011, 10:37 am
Re: How to enable arithmetic coding in JPEG?
It depends on how you modified the source code and Makefile.
From your limited information, I can't know what is wrong with your method.
Maybe it needs some compiler macro to enable it?
From your limited information, I can't know what is wrong with your method.
Maybe it needs some compiler macro to enable it?
-
- Posts: 6
- Joined: July 18th, 2013, 4:45 pm
Re: How to enable arithmetic coding in JPEG?
Ok, that´s what I have done, in media/libjpeg/makefile.in:
changed in media/libjpeg/jconfig.h:
added in media/libjpeg/jmorecfg.h:
I also added #error in the parts of the code that get´s only compiled if it´s without arithmetic support, since it compiled without any errors I expect that the macros work.
I also tried libjpeg-turbo 1.3.0, but no difference. Any ideas?
Code: Select all
...
CSRCS = \
jaricom.c \
jdarith.c \
...
CSRCS += \
jcarith.c \
...
changed in media/libjpeg/jconfig.h:
Code: Select all
#define JPEG_LIB_VERSION 80
added in media/libjpeg/jmorecfg.h:
Code: Select all
#define C_ARITH_CODING_SUPPORTED
#define D_ARITH_CODING_SUPPORTED
I also added #error in the parts of the code that get´s only compiled if it´s without arithmetic support, since it compiled without any errors I expect that the macros work.
I also tried libjpeg-turbo 1.3.0, but no difference. Any ideas?
-
- Posts: 311
- Joined: June 20th, 2011, 10:37 am
Re: How to enable arithmetic coding in JPEG?
It seems the process is right.
Maybe you can reply to https://bugzilla.mozilla.org/show_bug.cgi?id=680385
Maybe you can reply to https://bugzilla.mozilla.org/show_bug.cgi?id=680385
-
- Posts: 6
- Joined: July 18th, 2013, 4:45 pm
Re: How to enable arithmetic coding in JPEG?
Found the problem, unfortunately no solution:
The arithmetic decoder in libjpeg does not support suspension. That´s how I understood it: Firefox calls libjpeg to decode everything it can with the available data (libjpeg request data via callback function). Problem is that the arithmetic decoder needs all data and cannot be suspended. In case firefox tells libjpeg no data, arithmetic decoder fails.
Small images with arithmetic coding - saved locally - work.
Basically the problem is libjpeg. The question is now, why is libjpeg calling the arithmetic decoder without checking if all data is available? Is it a bug introduced by me, a bug in libjpeg, or a difficult to implement feature? Any other ideas?
Note: libjpeg and libjpeg-turbo do not differ in that aspect, the arithmetic decoder is the same
The arithmetic decoder in libjpeg does not support suspension. That´s how I understood it: Firefox calls libjpeg to decode everything it can with the available data (libjpeg request data via callback function). Problem is that the arithmetic decoder needs all data and cannot be suspended. In case firefox tells libjpeg no data, arithmetic decoder fails.
Small images with arithmetic coding - saved locally - work.
Basically the problem is libjpeg. The question is now, why is libjpeg calling the arithmetic decoder without checking if all data is available? Is it a bug introduced by me, a bug in libjpeg, or a difficult to implement feature? Any other ideas?
Note: libjpeg and libjpeg-turbo do not differ in that aspect, the arithmetic decoder is the same
-
- Posts: 6
- Joined: July 18th, 2013, 4:45 pm
Re: How to enable arithmetic coding in JPEG?
The answer is: It´s a not that easy to implement feature in libjpeg. I created a internal buffer for the entropy data in the arithmetic decoder that restores all data to the state before the function was called, while at the same time keeping the input data that was read.
Sequential arithmetic works, progressive arithmetic images not yet correctly (only first layer is fine). After I finish that, what should I do to get that into Firefox?
Sequential arithmetic works, progressive arithmetic images not yet correctly (only first layer is fine). After I finish that, what should I do to get that into Firefox?
-
- Posts: 311
- Joined: June 20th, 2011, 10:37 am
Re: How to enable arithmetic coding in JPEG?
I suggest you file a new bug at bugzilla to post your patches : https://bugzilla.mozilla.org/
-
- Posts: 19
- Joined: May 17th, 2014, 10:24 am
Re: How to enable arithmetic coding in JPEG?
Is this problem still exist? Maybe it is better to create a ticket about it in the jpeg-turbo bug tracker?stefan_o wrote:The arithmetic decoder in libjpeg does not support suspension.
BTW, tickets about arithmetic JPEG support in the Mozilla, Chromium and Microsoft's trackers:
https://bugzilla.mozilla.org/show_bug.cgi?id=680385
https://bugs.chromium.org/p/chromium/is ... ?id=669501
https://wpdev.uservoice.com/forums/2578 ... eg-which-s
As jpeg-turbo supports arithmetic coded JPEGs, and jpeg-turbo is used by the Firefox and Chrome, maybe they will decide to enable it some day.