User:Robin Cornelius/OpenJPEG 1.3
Jump to navigation
Jump to search
Openjpeg 1.3 requires some patches in order to correctly work with SecondLife/Snowglobe
Patch 1 - Prevent random crash accessing meta data
--- openjpeg-1.3+dfsg.orig/libopenjpeg/image.c 2007-10-18 13:26:11.000000000 +0100
+++ openjpeg/libopenjpeg/image.c 2009-10-29 09:16:32.578125000 +0000
@@ -28,6 +28,7 @@
opj_image_t* opj_image_create0(void) {
opj_image_t *image = (opj_image_t*)opj_malloc(sizeof(opj_image_t));
+ image->comps = NULL;
return image;
}
Patch 2 - Prevent transparent avatars
--- ./libopenjpeg/t1.c 2009-08-16 09:17:53.000000000 +0100
+++ ./libopenjpeg/t1.c 2009-08-16 09:21:42.000000000 +0100
@@ -738,14 +738,27 @@
double stepsize,
int numcomps)
{
- double w1, w2, wmsedec;
+ double w1 = 1, w2, wmsedec;
+
+ // Prevent running an MCT on more than 3 components. NB openjpeg v2.0 will support this via
+ // custom MCT tables that can be passed as encode parameters, 1.3 cannot support this as it
+ // uses a static table of 3 entries and there for can only cope with 3 components with out an
+ // array overflow
+
+ if(numcomps==3) {
+ if (qmfbid == 1) {
+ w1 = (numcomps > 1) ? mct_getnorm(compno) : 1.0;
+ } else {
+ w1 = (numcomps > 1) ? mct_getnorm_real(compno) : 1.0;
+ }
+ }
+
if (qmfbid == 1) {
- w1 = (numcomps > 1) ? mct_getnorm(compno) : 1.0;
w2 = dwt_getnorm(level, orient);
} else { /* if (qmfbid == 0) */
- w1 = (numcomps > 1) ? mct_getnorm_real(compno) : 1.0;
w2 = dwt_getnorm_real(level, orient);
}
+
wmsedec = w1 * w2 * stepsize * (1 << bpno);
wmsedec *= wmsedec * nmsedec / 8192.0;