xinxinlx / openjpeg

Automatically exported from code.google.com/p/openjpeg
Other
0 stars 0 forks source link

T1 optimisations jpeg2000 #172

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi all,

Here are some patches to openjpeg 1.5 which speed up the T1 encoding a bit:

http://carlh.net/software/openjpeg

On the plus side, encoding a large (1998x1080) image takes about 75% of the 
time with the patches compared to the release openjpeg (and the result is 
bitwise identical).

Caveats: no speed-up to decoding, and very limited regression testing.

It's a work in progress, so it's a bit rough round the edges.

Comments welcome.

Original issue reported on code.google.com by mathieu.malaterre on 29 Aug 2012 at 6:59

GoogleCodeExporter commented 9 years ago
Attaching as patch directly

Original comment by mathieu.malaterre on 29 Aug 2012 at 7:00

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by mathieu.malaterre on 10 Sep 2012 at 9:30

GoogleCodeExporter commented 9 years ago
The code is not using C90 convention, which makes it hard to apply as-is:

/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c: In 
function 't1_enc_updateflags':
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:400:3: 
error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:402:3: 
error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:410:3: 
error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:412:3: 
error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:428:4: 
error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:441:4: 
error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c: In 
function 't1_enc_sigpass_step':
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:493:2: 
error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c: In 
function 't1_enc_refpass_step':
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:745:2: 
error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c: In 
function 't1_enc_clnpass_step':
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:983:2: 
error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:996:3: 
error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c: In 
function 'allocate_buffers':
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:1330:2: 
error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:1346:11: 
error: pointer targets in initialization differ in signedness 
[-Werror=pointer-sign]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:1346:2: 
error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:1352:4: 
error: pointer targets in assignment differ in signedness [-Werror=pointer-sign]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:1359:5: 
error: pointer targets in assignment differ in signedness [-Werror=pointer-sign]
/home/mathieu/Projects/openjpeg/branches/openjpeg-1.5/libopenjpeg/t1.c:1360:3: 
error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
cc1: all warnings being treated as errors
make[2]: *** 
[applications/mj2/CMakeFiles/frames_to_mj2.dir/__/__/libopenjpeg/t1.c.o] Error 1

Original comment by mathieu.malaterre on 10 Sep 2012 at 9:31

GoogleCodeExporter commented 9 years ago
Attached a new version of the patch with a few tweaks and also C90 
compatibility.

Original comment by c...@carlh.net on 10 Sep 2012 at 10:56

Attachments:

GoogleCodeExporter commented 9 years ago
Also, I just noticed that I didn't put back support for the J2K_CCP_CBLKSTY_VSC 
flag.  Although this doesn't seem to be set anywhere within libopenjpeg; could 
it be removed?

Original comment by c...@carlh.net on 10 Sep 2012 at 10:58

GoogleCodeExporter commented 9 years ago

Original comment by mathieu.malaterre on 14 Mar 2014 at 3:14

GoogleCodeExporter commented 9 years ago
Hi,

I updated the patch for tag 2.1.0, thought I'll share it with everyone.
Still no support J2K_CCP_CBLKSTY_VSC & limited non regression tests (I use a 
custom set of images as I do not have access to external svn proxy at work - 
proxy issues)

Please find some time ratios below (using also updated patch from Issue 220). 
The whole encoding time is taken into account, not only t1 enc. Input images 
are 8bit grayscale images encoded using 9/7 wavelet. Timings include 
8bit->32bit conversion.

0,878843317 (linux x86 gcc4.4)
0,878999168 (linux x64 gcc4.4)
0,906621081 (linux armv7 gcc4.6)
0,924342459 (linux armv5 gcc4.6)
0,878114055 (windows x86 vc7)
0,832016242 (windows x86 vc8)
0,880686491 (windows x64 vc8)
0,829962365 (windows x86 vc10)
0,884205368 (windows x64 vc10)

Regards,
Matthieu

Original comment by m.darb...@gmail.com on 28 May 2014 at 7:07

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Matthieu,

Thanks for the patch. Is there a way to put back support for 
J2K_CCP_CBLKSTY_VSC in the patch ? 

J2K_CCP_CBLKSTY_VSC is actually set through the "parameters->mode" field

Antonin 

Original comment by antonin on 2 Jun 2014 at 9:15

GoogleCodeExporter commented 9 years ago
Hi Antonin,

I do not feel very comfortable doing this. For now, this work has not required 
much understanding of the algorithm, it was only a port from Carl's patch to 
2.1.0 release.
Maybe Carl can lend a hand on this one ?

I'll see what I can do but no promises (& I probably won't have time to start 
digging into this before august)

Original comment by m.darb...@gmail.com on 4 Jun 2014 at 5:48

GoogleCodeExporter commented 9 years ago
+1 for getting this patch into the mainline

Original comment by boxe...@gmail.com on 18 Jul 2014 at 3:44

GoogleCodeExporter commented 9 years ago
Regarding VSC, is this feature used very much? I understand that it leads to 
poorer
compression ratios than default t1 encoding. 

Original comment by boxe...@gmail.com on 18 Jul 2014 at 3:45

GoogleCodeExporter commented 9 years ago

Original comment by antonin on 18 Jul 2014 at 11:07

GoogleCodeExporter commented 9 years ago
For those who may find it useful, I have taken Matthieu's version of the patch 
and created a branch for it in my OpenJPEG mirror:

https://github.com/OpenJPEG/openjpeg/tree/carls-t1-patch

Original comment by boxe...@gmail.com on 15 Sep 2014 at 8:52