Changes proposed by Mathieu Malaterre from the GDCM project... Thanks a lot Mathieu
- '//' replaced by '/* */' - inclusion of int.h in int.c - inclusion of j2k.h in int.h in order to export symbols - adding (void) var when a variable is declared but not used - some explicit cast - CLOCKS_PER_SEC is declared as float in bcc55, so there is a need to cast it to int for the modulo operation - some variables changed from float -> double
This commit is contained in:
parent
18a9bcb882
commit
8f3bd54c3d
|
@ -55,8 +55,6 @@
|
|||
#include "fix.h"
|
||||
#include "tcd.h"
|
||||
#include <stdlib.h>
|
||||
//#include <stdio.h>
|
||||
//#include <math.h>
|
||||
|
||||
#define S(i) a[(i)*2]
|
||||
#define D(i) a[(1+(i)*2)]
|
||||
|
@ -110,8 +108,8 @@ void dwt_deinterleave_v(int *a, int *b, int dn, int sn, int x, int cas) {
|
|||
/* </summary> */
|
||||
void dwt_interleave_h(int *a, int *b, int dn, int sn, int cas) {
|
||||
int i;
|
||||
// for (i=0; i<sn; i++) b[2*i+cas]=a[i];
|
||||
// for (i=0; i<dn; i++) b[2*i+1-cas]=a[(sn+i)];
|
||||
/* for (i=0; i<sn; i++) b[2*i+cas]=a[i];*/
|
||||
/* for (i=0; i<dn; i++) b[2*i+1-cas]=a[(sn+i)];*/
|
||||
int* ai;
|
||||
int* bi;
|
||||
ai=a;
|
||||
|
@ -131,8 +129,8 @@ void dwt_interleave_h(int *a, int *b, int dn, int sn, int cas) {
|
|||
/* </summary> */
|
||||
void dwt_interleave_v(int *a, int *b, int dn, int sn, int x, int cas) {
|
||||
int i;
|
||||
// for (i=0; i<sn; i++) b[2*i+cas]=a[i*x];
|
||||
// for (i=0; i<dn; i++) b[2*i+1-cas]=a[(sn+i)*x];
|
||||
/* for (i=0; i<sn; i++) b[2*i+cas]=a[i*x];*/
|
||||
/* for (i=0; i<dn; i++) b[2*i+1-cas]=a[(sn+i)*x];*/
|
||||
int* ai;
|
||||
int* bi;
|
||||
ai=a;
|
||||
|
@ -529,6 +527,7 @@ void dwt_decode_real(tcd_tilecomp_t * tilec, int stop)
|
|||
/* </summary> */
|
||||
int dwt_getgain_real(int orient)
|
||||
{
|
||||
(void)orient;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "fix.h"
|
||||
#include <math.h> //Add Antonin : multbug1
|
||||
#include <math.h> /*Add Antonin : multbug1*/
|
||||
|
||||
#ifdef WIN32
|
||||
#define int64 __int64
|
||||
|
@ -37,13 +37,13 @@
|
|||
* Multiply two fixed-precision rational numbers.
|
||||
*/
|
||||
|
||||
//int fix_mul(int a, int b)
|
||||
//{
|
||||
// return (int) ((int64) a * (int64) b >> 13);
|
||||
//}
|
||||
/*int fix_mul(int a, int b)
|
||||
{
|
||||
return (int) ((int64) a * (int64) b >> 13);
|
||||
}*/
|
||||
|
||||
|
||||
//Mod Antonin : multbug1
|
||||
/*Mod Antonin : multbug1*/
|
||||
/*
|
||||
int fix_mul(int a, int b)
|
||||
{
|
||||
|
@ -53,9 +53,9 @@ int fix_mul(int a, int b)
|
|||
return (int) v;
|
||||
}
|
||||
*/
|
||||
//doM
|
||||
/*doM*/
|
||||
|
||||
int fix_mul(int a, int b) // Luke Lee optimized : 11/16/2004
|
||||
int fix_mul(int a, int b) /* Luke Lee optimized : 11/16/2004*/
|
||||
{
|
||||
int64 temp = (int64) a * (int64) b >> 12;
|
||||
return (int) ((temp >> 1) + (temp & 1)) ;
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "int.h"
|
||||
|
||||
/*
|
||||
* Get the minimum of two integers.
|
||||
*
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "j2k.h"
|
||||
|
||||
#ifndef __INT_H
|
||||
#define __INT_H
|
||||
|
||||
|
@ -67,14 +69,14 @@ int int_ceildiv(int a, int b);
|
|||
*
|
||||
* a divided by 2^b
|
||||
*/
|
||||
int int_ceildivpow2(int a, int b);
|
||||
LIBJ2K_API int int_ceildivpow2(int a, int b);
|
||||
|
||||
/*
|
||||
* Divide an integer by a power of 2 and round downwards.
|
||||
*
|
||||
* a divided by 2^b
|
||||
*/
|
||||
int int_floordivpow2(int a, int b);
|
||||
LIBJ2K_API int int_floordivpow2(int a, int b);
|
||||
|
||||
/*
|
||||
* Get logarithm of an integer and round downwards.
|
||||
|
|
|
@ -348,7 +348,7 @@ void j2k_read_cox(int compno)
|
|||
J2K_STATE_TPH ? &j2k_cp->tcps[j2k_curtileno] : &j2k_default_tcp;
|
||||
tccp = &tcp->tccps[compno];
|
||||
tccp->numresolutions = cio_read(1) + 1; /* SPcox (D) */
|
||||
//Check the reduce value
|
||||
/*Check the reduce value*/
|
||||
j2k_cp->reduce=int_min((tccp->numresolutions)-1,j2k_cp->reduce);
|
||||
tccp->cblkw = cio_read(1) + 2; /* SPcox (E) */
|
||||
tccp->cblkh = cio_read(1) + 2; /* SPcox (F) */
|
||||
|
@ -588,7 +588,7 @@ void j2k_write_poc()
|
|||
len = 2 + (5 + 2 * (j2k_img->numcomps <= 256 ? 1 : 2)) * numpchgs;
|
||||
cio_write(len, 2); /* Lpoc */
|
||||
for (i = 0; i < numpchgs; i++) {
|
||||
// MODIF
|
||||
/* MODIF*/
|
||||
j2k_poc_t *poc;
|
||||
poc = &tcp->pocs[i];
|
||||
cio_write(poc->resno0, 1); /* RSpoc_i */
|
||||
|
@ -725,7 +725,7 @@ void j2k_read_ppm()
|
|||
(unsigned char *) calloc(N_ppm, sizeof(unsigned char));
|
||||
j2k_cp->ppm_data_first = j2k_cp->ppm_data;
|
||||
|
||||
j2k_cp->ppm_len = N_ppm; //Add antonin : ppmbug1
|
||||
j2k_cp->ppm_len = N_ppm; /*Add antonin : ppmbug1*/
|
||||
|
||||
} else { /* NON-first PPM marker */
|
||||
j2k_cp->ppm_data =
|
||||
|
@ -735,7 +735,7 @@ void j2k_read_ppm()
|
|||
sizeof(unsigned char));
|
||||
j2k_cp->ppm_data_first = j2k_cp->ppm_data;
|
||||
|
||||
j2k_cp->ppm_len = N_ppm + j2k_cp->ppm_store; //Add antonin : ppmbug1
|
||||
j2k_cp->ppm_len = N_ppm + j2k_cp->ppm_store; /*Add antonin : ppmbug1*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -767,7 +767,7 @@ void j2k_read_ppt()
|
|||
tcp->ppt_data_first = tcp->ppt_data;
|
||||
tcp->ppt_store = 0;
|
||||
|
||||
tcp->ppt_len = len - 3; //Add antonin : ppmbug1
|
||||
tcp->ppt_len = len - 3; /*Add antonin : ppmbug1*/
|
||||
} else { /* NON-first PPT marker */
|
||||
tcp->ppt_data =
|
||||
(unsigned char *) realloc(tcp->ppt_data,
|
||||
|
@ -775,7 +775,7 @@ void j2k_read_ppt()
|
|||
tcp->ppt_store) * sizeof(unsigned char));
|
||||
tcp->ppt_data_first = tcp->ppt_data;
|
||||
|
||||
tcp->ppt_len = len - 3 + tcp->ppt_store; //Add antonin : ppmbug1
|
||||
tcp->ppt_len = len - 3 + tcp->ppt_store; /*Add antonin : ppmbug1*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -880,7 +880,7 @@ void j2k_write_sod()
|
|||
|
||||
tcp = &j2k_cp->tcps[j2k_curtileno];
|
||||
for (layno = 0; layno < tcp->numlayers; layno++) {
|
||||
tcp->rates[layno] -= tcp->rates[layno] ? (j2k_sod_start / (j2k_cp->th * j2k_cp->tw)) : 0; //Mod antonin losslessbug
|
||||
tcp->rates[layno] -= tcp->rates[layno] ? (j2k_sod_start / (j2k_cp->th * j2k_cp->tw)) : 0; /*Mod antonin losslessbug*/
|
||||
}
|
||||
|
||||
info_IM.num = 0;
|
||||
|
@ -1173,7 +1173,7 @@ j2k_encode(j2k_image_t * img, j2k_cp_t * cp, char *output,
|
|||
|
||||
for (resno = info_IM.Decomposition; resno >= 0; resno--) {
|
||||
|
||||
fprintf(INDEX, "[%d,%d] ", (1 << info_IM.tile[0].pdx[resno]), (1 << info_IM.tile[0].pdx[resno])); //based on tile 0
|
||||
fprintf(INDEX, "[%d,%d] ", (1 << info_IM.tile[0].pdx[resno]), (1 << info_IM.tile[0].pdx[resno])); /*based on tile 0*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -1208,7 +1208,7 @@ j2k_encode(j2k_image_t * img, j2k_cp_t * cp, char *output,
|
|||
"pkno tileno layerno resno compno precno start_pos end_pos deltaSE \n"); */
|
||||
|
||||
if (info_IM.Prog == 0) { /* LRCP */
|
||||
//fprintf(INDEX, "pack_nb tileno layno resno compno precno start_pos end_pos disto");
|
||||
/*fprintf(INDEX, "pack_nb tileno layno resno compno precno start_pos end_pos disto");*/
|
||||
for (layno = 0; layno < info_IM.Layer; layno++) {
|
||||
for (resno = 0; resno < info_IM.Decomposition + 1; resno++) {
|
||||
for (compno = 0; compno < info_IM.Comp; compno++) {
|
||||
|
@ -1229,7 +1229,7 @@ j2k_encode(j2k_image_t * img, j2k_cp_t * cp, char *output,
|
|||
}
|
||||
}
|
||||
} else if (info_IM.Prog == 1) { /* RLCP */
|
||||
//fprintf(INDEX, "pack_nb tileno resno layno compno precno start_pos end_pos disto");
|
||||
/*fprintf(INDEX, "pack_nb tileno resno layno compno precno start_pos end_pos disto");*/
|
||||
for (resno = 0; resno < info_IM.Decomposition + 1; resno++) {
|
||||
for (layno = 0; layno < info_IM.Layer; layno++) {
|
||||
for (compno = 0; compno < info_IM.Comp; compno++) {
|
||||
|
@ -1247,7 +1247,7 @@ j2k_encode(j2k_image_t * img, j2k_cp_t * cp, char *output,
|
|||
}
|
||||
}
|
||||
} else if (info_IM.Prog == 2) { /* RPCL */
|
||||
//fprintf(INDEX, "\npack_nb tileno resno precno compno layno start_pos end_pos disto\n");
|
||||
/*fprintf(INDEX, "\npack_nb tileno resno precno compno layno start_pos end_pos disto\n"); */
|
||||
for (resno = 0; resno < info_IM.Decomposition + 1; resno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = info_IM.Tile_Ox + tileno - (int)floor( tileno/info_IM.tw ) * info_IM.tw * info_IM.Tile_x;
|
||||
|
@ -1284,13 +1284,13 @@ j2k_encode(j2k_image_t * img, j2k_cp_t * cp, char *output,
|
|||
}
|
||||
}
|
||||
} else if (info_IM.Prog == 3) { /* PCRL */
|
||||
// I suppose components have same XRsiz, YRsiz
|
||||
/* I suppose components have same XRsiz, YRsiz*/
|
||||
int x0 = info_IM.Tile_Ox + tileno - (int)floor( tileno/info_IM.tw ) * info_IM.tw * info_IM.Tile_x;
|
||||
int y0 = info_IM.Tile_Ox + (int)floor( tileno/info_IM.tw ) * info_IM.Tile_y;
|
||||
int x1 = x0 + info_IM.Tile_x;
|
||||
int y1 = y0 + info_IM.Tile_y;
|
||||
|
||||
//fprintf(INDEX, "\npack_nb tileno precno compno resno layno start_pos end_pos disto\n");
|
||||
/*fprintf(INDEX, "\npack_nb tileno precno compno resno layno start_pos end_pos disto\n"); */
|
||||
for (y=y0; y<y1; y++) {
|
||||
for (x=x0; x<x1; x++) {
|
||||
for (compno = 0; compno < info_IM.Comp; compno++) {
|
||||
|
@ -1322,7 +1322,7 @@ j2k_encode(j2k_image_t * img, j2k_cp_t * cp, char *output,
|
|||
}
|
||||
}
|
||||
} else { /* CPRL */
|
||||
//fprintf(INDEX, "\npack_nb tileno compno precno resno layno start_pos end_pos disto\n");
|
||||
/*fprintf(INDEX, "\npack_nb tileno compno precno resno layno start_pos end_pos disto\n"); */
|
||||
for (compno = 0; compno < info_IM.Comp; compno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = info_IM.Tile_Ox + tileno - (int)floor( tileno/info_IM.tw ) * info_IM.tw * info_IM.Tile_x;
|
||||
|
@ -1360,9 +1360,9 @@ j2k_encode(j2k_image_t * img, j2k_cp_t * cp, char *output,
|
|||
}
|
||||
}
|
||||
|
||||
fprintf(INDEX, "%8e\n", info_IM.D_max); //SE max
|
||||
fprintf(INDEX, "%8e\n", info_IM.D_max); /*SE max*/
|
||||
|
||||
fprintf(INDEX, "%.8e\n", DistoTotal); // SE totale
|
||||
fprintf(INDEX, "%.8e\n", DistoTotal); /* SE totale*/
|
||||
|
||||
fclose(INDEX);
|
||||
|
||||
|
@ -1554,7 +1554,7 @@ void j2k_dec_release()
|
|||
|
||||
|
||||
|
||||
//tcd_dec_release();
|
||||
/*tcd_dec_release();*/
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -28,15 +28,20 @@
|
|||
|
||||
#define VERSION "0.0.8"
|
||||
|
||||
#ifdef DAVID_WIN32
|
||||
#ifdef LIBJ2K_EXPORTS
|
||||
#if defined(_WIN32) && defined (OPENJPEGDLL)
|
||||
#ifdef gdcmopenjpeg_EXPORTS /*LIBJ2K_EXPORTS*/
|
||||
#define LIBJ2K_API __declspec(dllexport)
|
||||
#else
|
||||
#define LIBJ2K_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#ifdef OPENJPEGSTATIC
|
||||
#define LIBJ2K_API extern
|
||||
#else
|
||||
#define LIBJ2K_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __J2K_H
|
||||
#define __J2K_H
|
||||
|
@ -231,6 +236,6 @@ LIBJ2K_API int j2k_decode(unsigned char *src, int len, j2k_image_t * img,
|
|||
int j2k_decode_jpt_stream(unsigned char *src, int len, j2k_image_t * img,
|
||||
j2k_cp_t * cp);
|
||||
|
||||
void j2k_dec_release();//antonin
|
||||
LIBJ2K_API void j2k_dec_release();/*antonin*/
|
||||
|
||||
#endif
|
||||
|
|
|
@ -82,8 +82,8 @@ int jp2_init_stdjp2(jp2_struct_t * jp2_struct)
|
|||
jp2_struct->comps =
|
||||
(jp2_comps_t *) malloc(jp2_struct->numcomps * sizeof(jp2_comps_t));
|
||||
|
||||
jp2_struct->precedence = 0; // PRECEDENCE
|
||||
jp2_struct->approx = 0; // APPROX
|
||||
jp2_struct->precedence = 0; /* PRECEDENCE*/
|
||||
jp2_struct->approx = 0; /* APPROX*/
|
||||
|
||||
jp2_struct->brand = JP2_JP2; /* BR */
|
||||
jp2_struct->minversion = 0; /* MinV */
|
||||
|
@ -91,9 +91,9 @@ int jp2_init_stdjp2(jp2_struct_t * jp2_struct)
|
|||
jp2_struct->cl = (int *) malloc(jp2_struct->numcl * sizeof(int));
|
||||
jp2_struct->cl[0] = JP2_JP2; /* CL0 : JP2 */
|
||||
|
||||
jp2_struct->C = 7; // C : Always 7
|
||||
jp2_struct->UnkC = 0; // UnkC, colorspace specified in colr box
|
||||
jp2_struct->IPR = 0; // IPR, no intellectual property
|
||||
jp2_struct->C = 7; /* C : Always 7*/
|
||||
jp2_struct->UnkC = 0; /* UnkC, colorspace specified in colr box*/
|
||||
jp2_struct->IPR = 0; /* IPR, no intellectual property*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -110,9 +110,9 @@ void jp2_write_url(char *Idx_file)
|
|||
|
||||
box.init_pos = cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_URL, 4); // DBTL
|
||||
cio_write(0, 1); // VERS
|
||||
cio_write(0, 3); // FLAG
|
||||
cio_write(JP2_URL, 4); /* DBTL*/
|
||||
cio_write(0, 1); /* VERS*/
|
||||
cio_write(0, 3); /* FLAG*/
|
||||
|
||||
for (i = 0; i < strlen(str); i++) {
|
||||
cio_write(str[i], 1);
|
||||
|
@ -140,15 +140,15 @@ int jp2_read_ihdr(jp2_struct_t * jp2_struct)
|
|||
return 1;
|
||||
}
|
||||
|
||||
jp2_struct->h = cio_read(4); // HEIGHT
|
||||
jp2_struct->w = cio_read(4); // WIDTH
|
||||
jp2_struct->numcomps = cio_read(2); // NC
|
||||
jp2_struct->h = cio_read(4); /* HEIGHT*/
|
||||
jp2_struct->w = cio_read(4); /* WIDTH*/
|
||||
jp2_struct->numcomps = cio_read(2); /* NC*/
|
||||
|
||||
jp2_struct->bpc = cio_read(1); // BPC
|
||||
jp2_struct->bpc = cio_read(1); /* BPC*/
|
||||
|
||||
jp2_struct->C = cio_read(1); // C
|
||||
jp2_struct->UnkC = cio_read(1); // UnkC
|
||||
jp2_struct->IPR = cio_read(1); // IPR
|
||||
jp2_struct->C = cio_read(1); /* C */
|
||||
jp2_struct->UnkC = cio_read(1); /* UnkC*/
|
||||
jp2_struct->IPR = cio_read(1); /* IPR*/
|
||||
|
||||
if (cio_tell() - box.init_pos != box.length) {
|
||||
fprintf(stderr, "Error with IHDR Box\n");
|
||||
|
@ -163,17 +163,17 @@ void jp2_write_ihdr(jp2_struct_t * jp2_struct)
|
|||
|
||||
box.init_pos = cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_IHDR, 4); // IHDR
|
||||
cio_write(JP2_IHDR, 4); /* IHDR*/
|
||||
|
||||
cio_write(jp2_struct->h, 4); // HEIGHT
|
||||
cio_write(jp2_struct->w, 4); // WIDTH
|
||||
cio_write(jp2_struct->numcomps, 2); // NC
|
||||
cio_write(jp2_struct->h, 4); /* HEIGHT*/
|
||||
cio_write(jp2_struct->w, 4); /* WIDTH*/
|
||||
cio_write(jp2_struct->numcomps, 2); /* NC*/
|
||||
|
||||
cio_write(jp2_struct->bpc, 1); // BPC
|
||||
cio_write(jp2_struct->bpc, 1); /* BPC */
|
||||
|
||||
cio_write(jp2_struct->C, 1); // C : Always 7
|
||||
cio_write(jp2_struct->UnkC, 1); // UnkC, colorspace unknow
|
||||
cio_write(jp2_struct->IPR, 1); // IPR, no intellectual property
|
||||
cio_write(jp2_struct->C, 1); /* C : Always 7*/
|
||||
cio_write(jp2_struct->UnkC, 1); /* UnkC, colorspace unknow*/
|
||||
cio_write(jp2_struct->IPR, 1); /* IPR, no intellectual property*/
|
||||
|
||||
box.length = cio_tell() - box.init_pos;
|
||||
cio_seek(box.init_pos);
|
||||
|
@ -189,7 +189,7 @@ void jp2_write_bpcc(jp2_struct_t * jp2_struct)
|
|||
|
||||
box.init_pos = cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_BPCC, 4); // BPCC
|
||||
cio_write(JP2_BPCC, 4); /* BPCC*/
|
||||
|
||||
for (i = 0; i < jp2_struct->numcomps; i++)
|
||||
cio_write(jp2_struct->comps[i].bpcc, 1);
|
||||
|
@ -228,16 +228,16 @@ void jp2_write_colr(jp2_struct_t * jp2_struct)
|
|||
|
||||
box.init_pos = cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_COLR, 4); // COLR
|
||||
cio_write(JP2_COLR, 4); /* COLR*/
|
||||
|
||||
cio_write(jp2_struct->meth, 1); // METH
|
||||
cio_write(jp2_struct->precedence, 1); // PRECEDENCE
|
||||
cio_write(jp2_struct->approx, 1); // APPROX
|
||||
cio_write(jp2_struct->meth, 1); /* METH*/
|
||||
cio_write(jp2_struct->precedence, 1); /* PRECEDENCE*/
|
||||
cio_write(jp2_struct->approx, 1); /* APPROX*/
|
||||
|
||||
if (jp2_struct->meth == 1)
|
||||
cio_write(jp2_struct->enumcs, 4); // EnumCS
|
||||
cio_write(jp2_struct->enumcs, 4); /* EnumCS*/
|
||||
else
|
||||
cio_write(0, 1); // PROFILE (??)
|
||||
cio_write(0, 1); /* PROFILE (??)*/
|
||||
|
||||
box.length = cio_tell() - box.init_pos;
|
||||
cio_seek(box.init_pos);
|
||||
|
@ -258,14 +258,14 @@ int jp2_read_colr(jp2_struct_t * jp2_struct)
|
|||
}
|
||||
} while (JP2_COLR != box.type);
|
||||
|
||||
jp2_struct->meth = cio_read(1); // METH
|
||||
jp2_struct->precedence = cio_read(1); // PRECEDENCE
|
||||
jp2_struct->approx = cio_read(1); // APPROX
|
||||
jp2_struct->meth = cio_read(1); /* METH*/
|
||||
jp2_struct->precedence = cio_read(1); /* PRECEDENCE*/
|
||||
jp2_struct->approx = cio_read(1); /* APPROX*/
|
||||
|
||||
if (jp2_struct->meth == 1)
|
||||
jp2_struct->enumcs = cio_read(4); // EnumCS
|
||||
jp2_struct->enumcs = cio_read(4); /* EnumCS*/
|
||||
else {
|
||||
// SKIP PROFILE
|
||||
/* SKIP PROFILE */
|
||||
skip_len = box.init_pos + box.length - cio_tell();
|
||||
if (skip_len < 0) {
|
||||
fprintf(stderr, "Error with JP2H box size\n");
|
||||
|
@ -420,7 +420,7 @@ int jp2_write_jp2c(int j2k_codestream_len, int *j2k_codestream_offset,
|
|||
|
||||
box.init_pos = cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_JP2C, 4); // JP2C
|
||||
cio_write(JP2_JP2C, 4); /* JP2C*/
|
||||
|
||||
*j2k_codestream_offset = cio_tell();
|
||||
memcpy(cio_getbp(), j2k_codestream, j2k_codestream_len);
|
||||
|
@ -459,7 +459,7 @@ void jp2_write_jp()
|
|||
|
||||
box.init_pos = cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_JP, 4); // JP
|
||||
cio_write(JP2_JP, 4); /* JP*/
|
||||
cio_write(0x0d0a870a, 4);
|
||||
|
||||
box.length = cio_tell() - box.init_pos;
|
||||
|
@ -517,6 +517,7 @@ int jp2_read_struct(unsigned char *src, jp2_struct_t * jp2_struct, int len)
|
|||
int jp2_wrap_j2k(jp2_struct_t * jp2_struct, char *j2k_codestream,
|
||||
char *output)
|
||||
{
|
||||
(void)output;
|
||||
jp2_write_jp();
|
||||
jp2_write_ftyp(jp2_struct);
|
||||
jp2_write_jp2h(jp2_struct);
|
||||
|
|
|
@ -536,10 +536,10 @@ void mqc_init_dec(unsigned char *bp, int len)
|
|||
mqc_start = bp;
|
||||
mqc_end = bp + len;
|
||||
mqc_bp = bp;
|
||||
//add antonin initbug1
|
||||
/*add antonin initbug1*/
|
||||
if (len==0) mqc_c = 0xff << 16;
|
||||
else mqc_c = *mqc_bp << 16;
|
||||
//dda
|
||||
/*dda*/
|
||||
mqc_bytein();
|
||||
mqc_c <<= 7;
|
||||
mqc_ct -= 7;
|
||||
|
|
|
@ -97,8 +97,8 @@ pi_iterator_t *pi_create(j2k_image_t * img, j2k_cp_t * cp, int tileno)
|
|||
py0 = int_floordivpow2(ry0, res->pdy) << res->pdy;
|
||||
px1 = int_ceildivpow2(rx1, res->pdx) << res->pdx;
|
||||
py1 = int_ceildivpow2(ry1, res->pdy) << res->pdy;
|
||||
res->pw = (rx0==rx1)?0:((px1 - px0) >> res->pdx); //Mod Antonin : sizebug1
|
||||
res->ph = (ry0==ry1)?0:((py1 - py0) >> res->pdy); //Mod Antonin : sizebug1
|
||||
res->pw = (rx0==rx1)?0:((px1 - px0) >> res->pdx); /*Mod Antonin : sizebug1*/
|
||||
res->ph = (ry0==ry1)?0:((py1 - py0) >> res->pdy); /*Mod Antonin : sizebug1*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ int pi_next_rpcl(pi_iterator_t * pi)
|
|||
pi->compno < pi->poc.compno1; pi->compno++) {
|
||||
int levelno;
|
||||
int trx0, try0;
|
||||
int trx1, try1;// Add antonin pcrl
|
||||
int trx1, try1;/* Add antonin pcrl*/
|
||||
int rpx, rpy;
|
||||
int prci, prcj;
|
||||
comp = &pi->comps[pi->compno];
|
||||
|
@ -280,8 +280,8 @@ int pi_next_rpcl(pi_iterator_t * pi)
|
|||
levelno = comp->numresolutions - 1 - pi->resno;
|
||||
trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
|
||||
try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
|
||||
trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);// Add antonin pcrl
|
||||
try1 = int_ceildiv(pi->ty1, comp->dy << levelno);// Add antonin pcrl
|
||||
trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);/* Add antonin pcrl*/
|
||||
try1 = int_ceildiv(pi->ty1, comp->dy << levelno);/* Add antonin pcrl*/
|
||||
rpx = res->pdx + levelno;
|
||||
rpy = res->pdy + levelno;
|
||||
if (!
|
||||
|
@ -295,13 +295,13 @@ int pi_next_rpcl(pi_iterator_t * pi)
|
|||
continue;
|
||||
}
|
||||
|
||||
//Add Antonin : sizebug1
|
||||
/*Add Antonin : sizebug1*/
|
||||
if ((res->pw==0)||(res->pw==0)) continue;
|
||||
//ddA
|
||||
/*ddA*/
|
||||
|
||||
//Add Antonin : pcrl
|
||||
/*Add Antonin : pcrl*/
|
||||
if ((trx0==trx1)||(try0==try1)) continue;
|
||||
//ddA
|
||||
/*ddA*/
|
||||
|
||||
prci =
|
||||
int_floordivpow2(int_ceildiv
|
||||
|
@ -376,15 +376,15 @@ int pi_next_pcrl(pi_iterator_t * pi)
|
|||
comp->numresolutions); pi->resno++) {
|
||||
int levelno;
|
||||
int trx0, try0;
|
||||
int trx1, try1;// Add antonin pcrl
|
||||
int trx1, try1;/* Add antonin pcrl*/
|
||||
int rpx, rpy;
|
||||
int prci, prcj;
|
||||
res = &comp->resolutions[pi->resno];
|
||||
levelno = comp->numresolutions - 1 - pi->resno;
|
||||
trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
|
||||
try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
|
||||
trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);// Add antonin pcrl
|
||||
try1 = int_ceildiv(pi->ty1, comp->dy << levelno);// Add antonin pcrl
|
||||
trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);/* Add antonin pcrl*/
|
||||
try1 = int_ceildiv(pi->ty1, comp->dy << levelno);/* Add antonin pcrl*/
|
||||
rpx = res->pdx + levelno;
|
||||
rpy = res->pdy + levelno;
|
||||
if (!
|
||||
|
@ -398,13 +398,13 @@ int pi_next_pcrl(pi_iterator_t * pi)
|
|||
continue;
|
||||
}
|
||||
|
||||
//Add Antonin : sizebug1
|
||||
/*Add Antonin : sizebug1*/
|
||||
if ((res->pw==0)||(res->pw==0)) continue;
|
||||
//ddA
|
||||
/*ddA*/
|
||||
|
||||
//Add Antonin : pcrl
|
||||
/*Add Antonin : pcrl*/
|
||||
if ((trx0==trx1)||(try0==try1)) continue;
|
||||
//ddA
|
||||
/*ddA*/
|
||||
|
||||
prci =
|
||||
int_floordivpow2(int_ceildiv
|
||||
|
@ -474,15 +474,15 @@ int pi_next_cprl(pi_iterator_t * pi)
|
|||
comp->numresolutions); pi->resno++) {
|
||||
int levelno;
|
||||
int trx0, try0;
|
||||
int trx1, try1;// Add antonin pcrl
|
||||
int trx1, try1;/* Add antonin pcrl*/
|
||||
int rpx, rpy;
|
||||
int prci, prcj;
|
||||
res = &comp->resolutions[pi->resno];
|
||||
levelno = comp->numresolutions - 1 - pi->resno;
|
||||
trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
|
||||
try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
|
||||
trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);// Add antonin pcrl
|
||||
try1 = int_ceildiv(pi->ty1, comp->dy << levelno);// Add antonin pcrl
|
||||
trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);/* Add antonin pcrl*/
|
||||
try1 = int_ceildiv(pi->ty1, comp->dy << levelno);/* Add antonin pcrl*/
|
||||
rpx = res->pdx + levelno;
|
||||
rpy = res->pdy + levelno;
|
||||
if (!
|
||||
|
@ -496,13 +496,13 @@ int pi_next_cprl(pi_iterator_t * pi)
|
|||
continue;
|
||||
}
|
||||
|
||||
//Add Antonin : sizebug1
|
||||
/*Add Antonin : sizebug1*/
|
||||
if ((res->pw==0)||(res->pw==0)) continue;
|
||||
//ddA
|
||||
/*ddA*/
|
||||
|
||||
//Add Antonin : pcrl
|
||||
/*Add Antonin : pcrl*/
|
||||
if ((trx0==trx1)||(try0==try1)) continue;
|
||||
//ddA
|
||||
/*ddA*/
|
||||
|
||||
prci =
|
||||
int_floordivpow2(int_ceildiv
|
||||
|
|
|
@ -535,7 +535,7 @@ void t1_dec_clnpass(int w, int h, int bpno, int orient, int cblksty)
|
|||
}
|
||||
} /* VSC and BYPASS by Antonin */
|
||||
|
||||
double t1_getwmsedec(int nmsedec, int compno, int level, int orient, int bpno, int qmfbid, float stepsize, int numcomps) //mod fixed_quality
|
||||
double t1_getwmsedec(int nmsedec, int compno, int level, int orient, int bpno, int qmfbid, float stepsize, int numcomps) /*mod fixed_quality*/
|
||||
{
|
||||
double w1, w2, wmsedec;
|
||||
if (qmfbid == 1) {
|
||||
|
@ -550,7 +550,7 @@ double t1_getwmsedec(int nmsedec, int compno, int level, int orient, int bpno, i
|
|||
return wmsedec;
|
||||
}
|
||||
|
||||
void t1_encode_cblk(tcd_cblk_t * cblk, int orient, int compno, int level, int qmfbid, float stepsize, int cblksty, int numcomps, tcd_tile_t * tile) //mod fixed_quality
|
||||
void t1_encode_cblk(tcd_cblk_t * cblk, int orient, int compno, int level, int qmfbid, float stepsize, int cblksty, int numcomps, tcd_tile_t * tile) /*mod fixed_quality*/
|
||||
{
|
||||
int i, j;
|
||||
int w, h;
|
||||
|
@ -610,8 +610,8 @@ void t1_encode_cblk(tcd_cblk_t * cblk, int orient, int compno, int level, int qm
|
|||
break;
|
||||
}
|
||||
|
||||
cumwmsedec += t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps); //mod fixed_quality
|
||||
tile->distotile += t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps); //add antonin quality
|
||||
cumwmsedec += t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps); /*mod fixed_quality*/
|
||||
tile->distotile += t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps); /*add antonin quality*/
|
||||
|
||||
|
||||
/* Code switch "RESTART" (i.e. TERMALL) */
|
||||
|
@ -684,7 +684,7 @@ void t1_decode_cblk(tcd_cblk_t * cblk, int orient, int roishift,
|
|||
int i, j, w, h;
|
||||
int bpno, passtype;
|
||||
int segno, passno;
|
||||
char type = T1_TYPE_MQ; //BYPASS mode
|
||||
char type = T1_TYPE_MQ; /*BYPASS mode*/
|
||||
|
||||
w = cblk->x1 - cblk->x0;
|
||||
h = cblk->y1 - cblk->y0;
|
||||
|
@ -714,7 +714,7 @@ void t1_decode_cblk(tcd_cblk_t * cblk, int orient, int roishift,
|
|||
for (segno = 0; segno < cblk->numsegs; segno++) {
|
||||
tcd_seg_t *seg = &cblk->segs[segno];
|
||||
|
||||
// Add BYPASS mode
|
||||
/* Add BYPASS mode */
|
||||
type = ((bpno <= (cblk->numbps - 1) - 4) && (passtype < 2)
|
||||
&& (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW :
|
||||
T1_TYPE_MQ;
|
||||
|
@ -722,7 +722,7 @@ void t1_decode_cblk(tcd_cblk_t * cblk, int orient, int roishift,
|
|||
raw_init_dec(seg->data, seg->len);
|
||||
else
|
||||
mqc_init_dec(seg->data, seg->len);
|
||||
// ddA
|
||||
/* ddA */
|
||||
|
||||
for (passno = 0; passno < seg->numpasses; passno++) {
|
||||
switch (passtype) {
|
||||
|
@ -766,7 +766,7 @@ void t1_encode_cblks(tcd_tile_t * tile, j2k_tcp_t * tcp)
|
|||
tcd_precinct_t *prc;
|
||||
tcd_cblk_t *cblk;
|
||||
|
||||
tile->distotile = 0; //add fixed_quality
|
||||
tile->distotile = 0; /*add fixed_quality*/
|
||||
|
||||
for (compno = 0; compno < tile->numcomps; compno++) {
|
||||
tilec = &tile->comps[compno];
|
||||
|
@ -827,7 +827,7 @@ void t1_encode_cblks(tcd_tile_t * tile, j2k_tcp_t * tcp)
|
|||
} else if (orient == 1) {
|
||||
orient = 2;
|
||||
}
|
||||
t1_encode_cblk(cblk, orient, compno, tilec->numresolutions - 1 - resno, tcp->tccps[compno].qmfbid, band->stepsize, tcp->tccps[compno].cblksty, tile->numcomps, tile); //mod fixed_quality
|
||||
t1_encode_cblk(cblk, orient, compno, tilec->numresolutions - 1 - resno, tcp->tccps[compno].qmfbid, band->stepsize, tcp->tccps[compno].cblksty, tile->numcomps, tile); /*mod fixed_quality*/
|
||||
} /* cblkno */
|
||||
} /* precno */
|
||||
} /* bandno */
|
||||
|
@ -903,7 +903,7 @@ void t1_decode_cblks(tcd_tile_t * tile, j2k_tcp_t * tcp)
|
|||
|
||||
for (j = 0; j < cblk->y1 - cblk->y0; j++) {
|
||||
for (i = 0; i < cblk->x1 - cblk->x0; i++) {
|
||||
float tmp=t1_data[j][i] * band->stepsize * 4096.0;
|
||||
double tmp=t1_data[j][i] * band->stepsize * 4096.0;
|
||||
int tmp2;
|
||||
if (t1_data[j][i]>>1 == 0) {
|
||||
tilec->data[x + i + (y + j) * (tilec->x1 - tilec->x0)] = 0;
|
||||
|
|
|
@ -314,11 +314,11 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
|
|||
|
||||
|
||||
|
||||
//Add Antonin : sizebug1
|
||||
/*Add Antonin : sizebug1*/
|
||||
|
||||
if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)) continue;
|
||||
|
||||
//ddA
|
||||
/*ddA*/
|
||||
|
||||
|
||||
tgt_reset(prc->incltree);
|
||||
|
@ -332,7 +332,7 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
|
|||
|
||||
|
||||
|
||||
// SOP markers
|
||||
/* SOP markers*/
|
||||
|
||||
if (tcp->csty & J2K_CP_CSTY_SOP) {
|
||||
|
||||
|
@ -346,7 +346,7 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
|
|||
|
||||
}
|
||||
|
||||
//TODO : check the Nsop value
|
||||
/*TODO : check the Nsop value*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -358,10 +358,10 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
|
|||
|
||||
if (cp->ppm == 1) { /* PPM */
|
||||
hd = cp->ppm_data;
|
||||
bio_init_dec(hd, cp->ppm_len); //Mod Antonin : ppmbug1
|
||||
bio_init_dec(hd, cp->ppm_len); /*Mod Antonin : ppmbug1*/
|
||||
} else if (tcp->ppt == 1) { /* PPT */
|
||||
hd = tcp->ppt_data;
|
||||
bio_init_dec(hd, tcp->ppt_len); //Mod Antonin : ppmbug1
|
||||
bio_init_dec(hd, tcp->ppt_len); /*Mod Antonin : ppmbug1*/
|
||||
} else { /* Normal Case */
|
||||
|
||||
hd = c;
|
||||
|
@ -379,7 +379,7 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
|
|||
|
||||
|
||||
|
||||
// EPH markers
|
||||
/* EPH markers*/
|
||||
|
||||
if (tcp->csty & J2K_CP_CSTY_EPH) {
|
||||
|
||||
|
@ -419,11 +419,11 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
|
|||
|
||||
|
||||
|
||||
//Add Antonin : sizebug1
|
||||
/*Add Antonin : sizebug1*/
|
||||
|
||||
if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)) continue;
|
||||
|
||||
//ddA
|
||||
/*ddA*/
|
||||
|
||||
|
||||
for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
|
||||
|
@ -484,7 +484,7 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
|
|||
hd += bio_numbytes();
|
||||
|
||||
|
||||
// EPH markers
|
||||
/* EPH markers*/
|
||||
if (tcp->csty & J2K_CP_CSTY_EPH) {
|
||||
if ((*hd) != 0xff || (*(hd + 1) != 0x92)) {
|
||||
fprintf(stderr,"Error : expected EPH marker\n");
|
||||
|
@ -520,11 +520,11 @@ int t2_decode_packet(unsigned char *src, int len, tcd_tile_t * tile,
|
|||
|
||||
|
||||
|
||||
//Add Antonin : sizebug1
|
||||
/*Add Antonin : sizebug1*/
|
||||
|
||||
if ((band->x1-band->x0 == 0)||(band->y1-band->y0 == 0)) continue;
|
||||
|
||||
//ddA
|
||||
/*ddA*/
|
||||
|
||||
|
||||
for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
|
||||
|
|
|
@ -61,6 +61,7 @@ extern jmp_buf j2k_error;
|
|||
void tcd_dump(tcd_image_t * img, int curtileno)
|
||||
{
|
||||
int tileno, compno, resno, bandno, precno, cblkno;
|
||||
(void)curtileno;
|
||||
fprintf(stdout, "image {\n");
|
||||
fprintf(stdout, " tw=%d, th=%d x0=%d x1=%d y0=%d y1=%d\n", img->tw,
|
||||
img->th, tcd_img->x0, tcd_img->x1, tcd_img->y0, tcd_img->y1);
|
||||
|
@ -144,7 +145,7 @@ void tcd_malloc_encode(j2k_image_t * img, j2k_cp_t * cp, int curtileno)
|
|||
/* tile->PPT=img->PPT; */
|
||||
/* Modification of the RATE >> */
|
||||
for (j = 0; j < tcp->numlayers; j++) {
|
||||
tcp->rates[j] = tcp->rates[j] ? int_ceildiv(tile->numcomps * (tile->x1 - tile->x0) * (tile->y1 - tile->y0) * img->comps[0].prec, (tcp->rates[j] * 8 * img->comps[0].dx * img->comps[0].dy)) : 0; //Mod antonin losslessbug
|
||||
tcp->rates[j] = tcp->rates[j] ? int_ceildiv(tile->numcomps * (tile->x1 - tile->x0) * (tile->y1 - tile->y0) * img->comps[0].prec, (tcp->rates[j] * 8 * img->comps[0].dx * img->comps[0].dy)) : 0; /*Mod antonin losslessbug*/
|
||||
if (tcp->rates[j]) {
|
||||
if (j && tcp->rates[j] < tcp->rates[j - 1] + 10) {
|
||||
tcp->rates[j] = tcp->rates[j - 1] + 20;
|
||||
|
@ -270,7 +271,7 @@ void tcd_malloc_encode(j2k_image_t * img, j2k_cp_t * cp, int curtileno)
|
|||
tccp->qmfbid ==
|
||||
0 ? dwt_getgain_real(band->bandno) : dwt_getgain(band->bandno);
|
||||
numbps = img->comps[compno].prec + gain;
|
||||
band->stepsize = (1.0 + ss->mant / 2048.0) * pow(2.0, numbps - ss->expn);
|
||||
band->stepsize = (float)((1.0 + ss->mant / 2048.0) * pow(2.0, numbps - ss->expn));
|
||||
band->numbps = ss->expn + tccp->numgbits - 1; /* WHY -1 ? */
|
||||
|
||||
band->precincts =
|
||||
|
@ -341,6 +342,7 @@ void tcd_malloc_encode(j2k_image_t * img, j2k_cp_t * cp, int curtileno)
|
|||
void tcd_free_encode(j2k_image_t * img, j2k_cp_t * cp, int curtileno)
|
||||
{
|
||||
int tileno, compno, resno, bandno, precno;
|
||||
(void)curtileno;
|
||||
tcd_img = img;
|
||||
tcd_cp = cp;
|
||||
tcd_image.tw = cp->tw;
|
||||
|
@ -380,7 +382,7 @@ void tcd_init_encode(j2k_image_t * img, j2k_cp_t * cp, int curtileno)
|
|||
for (tileno = 0; tileno < 1; tileno++) {
|
||||
j2k_tcp_t *tcp = &cp->tcps[curtileno];
|
||||
int j;
|
||||
// int previous_x0, previous_x1, previous_y0, previous_y1;
|
||||
/* int previous_x0, previous_x1, previous_y0, previous_y1;*/
|
||||
/* cfr p59 ISO/IEC FDIS15444-1 : 2000 (18 august 2000) */
|
||||
int p = curtileno % cp->tw;
|
||||
int q = curtileno / cp->tw;
|
||||
|
@ -396,7 +398,7 @@ void tcd_init_encode(j2k_image_t * img, j2k_cp_t * cp, int curtileno)
|
|||
/* tile->PPT=img->PPT; */
|
||||
/* Modification of the RATE >> */
|
||||
for (j = 0; j < tcp->numlayers; j++) {
|
||||
tcp->rates[j] = tcp->rates[j] ? int_ceildiv(tile->numcomps * (tile->x1 - tile->x0) * (tile->y1 - tile->y0) * img->comps[0].prec, (tcp->rates[j] * 8 * img->comps[0].dx * img->comps[0].dy)) : 0; //Mod antonin losslessbug
|
||||
tcp->rates[j] = tcp->rates[j] ? int_ceildiv(tile->numcomps * (tile->x1 - tile->x0) * (tile->y1 - tile->y0) * img->comps[0].prec, (tcp->rates[j] * 8 * img->comps[0].dx * img->comps[0].dy)) : 0; /*Mod antonin losslessbug*/
|
||||
if (tcp->rates[j]) {
|
||||
if (j && tcp->rates[j] < tcp->rates[j - 1] + 10) {
|
||||
tcp->rates[j] = tcp->rates[j - 1] + 20;
|
||||
|
@ -512,7 +514,7 @@ void tcd_init_encode(j2k_image_t * img, j2k_cp_t * cp, int curtileno)
|
|||
tccp->qmfbid ==
|
||||
0 ? dwt_getgain_real(band->bandno) : dwt_getgain(band->bandno);
|
||||
numbps = img->comps[compno].prec + gain;
|
||||
band->stepsize = (1.0 + ss->mant / 2048.0) * pow(2.0, numbps - ss->expn);
|
||||
band->stepsize = (float)((1.0 + ss->mant / 2048.0) * pow(2.0, numbps - ss->expn));
|
||||
band->numbps = ss->expn + tccp->numgbits - 1; /* WHY -1 ? */
|
||||
|
||||
for (precno = 0; precno < res->pw * res->ph; precno++) {
|
||||
|
@ -600,7 +602,7 @@ void tcd_init(j2k_image_t * img, j2k_cp_t * cp)
|
|||
tileno = cp->tileno[i];
|
||||
|
||||
|
||||
// int previous_x0, previous_x1, previous_y0, previous_y1;
|
||||
/* int previous_x0, previous_x1, previous_y0, previous_y1;*/
|
||||
/* cfr p59 ISO/IEC FDIS15444-1 : 2000 (18 august 2000) */
|
||||
p = tileno % cp->tw; /* si numerotation matricielle .. */
|
||||
q = tileno / cp->tw; /* .. coordonnees de la tile (q,p) q pour ligne et p pour colonne */
|
||||
|
@ -659,8 +661,8 @@ void tcd_init(j2k_image_t * img, j2k_cp_t * cp)
|
|||
tlprcystart = int_floordivpow2(res->y0, pdy) << pdy;
|
||||
brprcxend = int_ceildivpow2(res->x1, pdx) << pdx;
|
||||
brprcyend = int_ceildivpow2(res->y1, pdy) << pdy;
|
||||
res->pw = (res->x0 == res->x1) ? 0 : ((brprcxend - tlprcxstart) >> pdx); // Mod Antonin : sizebug1
|
||||
res->ph = (res->y0 == res->y1) ? 0 : ((brprcyend - tlprcystart) >> pdy); // Mod Antonin : sizebug1
|
||||
res->pw = (res->x0 == res->x1) ? 0 : ((brprcxend - tlprcxstart) >> pdx); /* Mod Antonin : sizebug1*/
|
||||
res->ph = (res->y0 == res->y1) ? 0 : ((brprcyend - tlprcystart) >> pdy); /* Mod Antonin : sizebug1*/
|
||||
|
||||
if (resno == 0) {
|
||||
tlcbgxstart = tlprcxstart;
|
||||
|
@ -718,7 +720,7 @@ void tcd_init(j2k_image_t * img, j2k_cp_t * cp)
|
|||
tccp->qmfbid ==
|
||||
0 ? dwt_getgain_real(band->bandno) : dwt_getgain(band->bandno);
|
||||
numbps = img->comps[compno].prec + gain;
|
||||
band->stepsize = (1.0 + ss->mant / 2048.0) * pow(2.0, numbps - ss->expn);
|
||||
band->stepsize = (float)((1.0 + ss->mant / 2048.0) * pow(2.0, numbps - ss->expn));
|
||||
band->numbps = ss->expn + tccp->numgbits - 1; /* WHY -1 ? */
|
||||
|
||||
band->precincts =
|
||||
|
@ -777,7 +779,7 @@ void tcd_init(j2k_image_t * img, j2k_cp_t * cp)
|
|||
}
|
||||
}
|
||||
}
|
||||
//tcd_dump(&tcd_image,0);
|
||||
/*tcd_dump(&tcd_image,0);*/
|
||||
|
||||
|
||||
/* Allocate place to store the data decoded = final image */
|
||||
|
@ -834,7 +836,7 @@ void tcd_init(j2k_image_t * img, j2k_cp_t * cp)
|
|||
void tcd_makelayer_fixed(int layno, int final)
|
||||
{
|
||||
int compno, resno, bandno, precno, cblkno;
|
||||
int value; //, matrice[tcd_tcp->numlayers][tcd_tile->comps[0].numresolutions][3];
|
||||
int value; /*, matrice[tcd_tcp->numlayers][tcd_tile->comps[0].numresolutions][3];*/
|
||||
int matrice[10][10][3];
|
||||
int i, j, k;
|
||||
|
||||
|
@ -933,7 +935,7 @@ void tcd_makelayer(int layno, double thresh, int final)
|
|||
{
|
||||
int compno, resno, bandno, precno, cblkno, passno;
|
||||
|
||||
tcd_tile->distolayer[layno] = 0; //add fixed_quality
|
||||
tcd_tile->distolayer[layno] = 0; /*add fixed_quality*/
|
||||
|
||||
for (compno = 0; compno < tcd_tile->numcomps; compno++) {
|
||||
tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
|
||||
|
@ -996,7 +998,7 @@ void tcd_makelayer(int layno, double thresh, int final)
|
|||
cblk->passes[cblk->numpassesinlayers - 1].distortiondec;
|
||||
}
|
||||
|
||||
tcd_tile->distolayer[layno] += layer->disto; //add fixed_quality
|
||||
tcd_tile->distolayer[layno] += layer->disto; /*add fixed_quality*/
|
||||
|
||||
if (final)
|
||||
cblk->numpassesinlayers = n;
|
||||
|
@ -1011,14 +1013,14 @@ void tcd_rateallocate(unsigned char *dest, int len, info_image * info_IM)
|
|||
{
|
||||
int compno, resno, bandno, precno, cblkno, passno, layno;
|
||||
double min, max;
|
||||
double cumdisto[100]; //add fixed_quality
|
||||
const double K = 1; // 1.1; //add fixed_quality
|
||||
double cumdisto[100]; /*add fixed_quality*/
|
||||
const double K = 1; /* 1.1; //add fixed_quality*/
|
||||
|
||||
double maxSE = 0;
|
||||
min = DBL_MAX;
|
||||
max = 0;
|
||||
|
||||
tcd_tile->nbpix = 0; //add fixed_quality
|
||||
tcd_tile->nbpix = 0; /*add fixed_quality*/
|
||||
|
||||
for (compno = 0; compno < tcd_tile->numcomps; compno++) {
|
||||
tcd_tilecomp_t *tilec = &tcd_tile->comps[compno];
|
||||
|
@ -1058,9 +1060,9 @@ void tcd_rateallocate(unsigned char *dest, int len, info_image * info_IM)
|
|||
}
|
||||
} /* passno */
|
||||
|
||||
tcd_tile->nbpix += ((cblk->x1 - cblk->x0) * (cblk->y1 - cblk->y0)); //add fixed_quality
|
||||
tcd_tile->nbpix += ((cblk->x1 - cblk->x0) * (cblk->y1 - cblk->y0)); /*add fixed_quality*/
|
||||
|
||||
tilec->nbpix += ((cblk->x1 - cblk->x0) * (cblk->y1 - cblk->y0)); //add fixed_quality
|
||||
tilec->nbpix += ((cblk->x1 - cblk->x0) * (cblk->y1 - cblk->y0)); /*add fixed_quality*/
|
||||
|
||||
} /* cbklno */
|
||||
} /* precno */
|
||||
|
@ -1083,22 +1085,22 @@ void tcd_rateallocate(unsigned char *dest, int len, info_image * info_IM)
|
|||
volatile double lo = min;
|
||||
volatile double hi = max;
|
||||
volatile int success = 0;
|
||||
volatile int maxlen = tcd_tcp->rates[layno] ? int_min(tcd_tcp->rates[layno], len) : len; //Mod antonin losslessbug
|
||||
volatile int maxlen = tcd_tcp->rates[layno] ? int_min(tcd_tcp->rates[layno], len) : len; /*Mod antonin losslessbug*/
|
||||
volatile double goodthresh;
|
||||
volatile int i;
|
||||
double distotarget; //add fixed_quality
|
||||
double distotarget; /*add fixed_quality*/
|
||||
|
||||
distotarget = tcd_tile->distotile - ((K * maxSE) / pow(10, tcd_tcp->distoratio[layno] / 10)); // add fixed_quality
|
||||
distotarget = tcd_tile->distotile - ((K * maxSE) / pow(10, tcd_tcp->distoratio[layno] / 10)); /* add fixed_quality*/
|
||||
|
||||
if ((tcd_tcp->rates[layno]) || (tcd_cp->disto_alloc==0)) {
|
||||
for (i = 0; i < 32; i++) {
|
||||
volatile double thresh = (lo + hi) / 2;
|
||||
int l = 0;
|
||||
double distoachieved = 0; // add fixed_quality
|
||||
double distoachieved = 0; /* add fixed_quality*/
|
||||
|
||||
tcd_makelayer(layno, thresh, 0);
|
||||
|
||||
if (tcd_cp->fixed_quality) { // add fixed_quality
|
||||
if (tcd_cp->fixed_quality) { /* add fixed_quality*/
|
||||
distoachieved =
|
||||
layno ==
|
||||
0 ? tcd_tile->distolayer[0] : cumdisto[layno - 1] +
|
||||
|
@ -1137,7 +1139,7 @@ void tcd_rateallocate(unsigned char *dest, int len, info_image * info_IM)
|
|||
}
|
||||
tcd_makelayer(layno, goodthresh, 1);
|
||||
|
||||
cumdisto[layno] = layno == 0 ? tcd_tile->distolayer[0] : cumdisto[layno - 1] + tcd_tile->distolayer[layno]; // add fixed_quality
|
||||
cumdisto[layno] = layno == 0 ? tcd_tile->distolayer[0] : cumdisto[layno - 1] + tcd_tile->distolayer[layno]; /* add fixed_quality*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1158,7 +1160,7 @@ tcd_encode_tile_pxm(int tileno, unsigned char *dest, int len,
|
|||
tile = tcd_tile;
|
||||
/* INDEX >> "Precinct_nb_X et Precinct_nb_Y" */
|
||||
if (info_IM->index_on) {
|
||||
tcd_tilecomp_t *tilec_idx = &tile->comps[0]; //Based on Component 0
|
||||
tcd_tilecomp_t *tilec_idx = &tile->comps[0]; /*Based on Component 0*/
|
||||
|
||||
for (i = 0; i < tilec_idx->numresolutions; i++) {
|
||||
|
||||
|
@ -1251,7 +1253,7 @@ tcd_encode_tile_pxm(int tileno, unsigned char *dest, int len,
|
|||
}
|
||||
/*----------------DWT---------------------*/
|
||||
|
||||
// mod Ive
|
||||
/* mod Ive*/
|
||||
for (compno = 0; compno < tile->numcomps; compno++) {
|
||||
tcd_tilecomp_t *tilec = &tile->comps[compno];
|
||||
if (tcd_tcp->tccps[compno].qmfbid == 1) {
|
||||
|
@ -1260,7 +1262,7 @@ for (compno = 0; compno < tile->numcomps; compno++) {
|
|||
dwt_encode_real(tilec);
|
||||
}
|
||||
}
|
||||
// /mod Ive
|
||||
/* /mod Ive*/
|
||||
/*------------------TIER1-----------------*/
|
||||
|
||||
t1_init_luts();
|
||||
|
@ -1269,7 +1271,7 @@ for (compno = 0; compno < tile->numcomps; compno++) {
|
|||
/*-----------RATE-ALLOCATE------------------*/
|
||||
info_IM->index_write = 0; /* INDEX */
|
||||
|
||||
if (tcd_cp->disto_alloc || tcd_cp->fixed_quality) // mod fixed_quality
|
||||
if (tcd_cp->disto_alloc || tcd_cp->fixed_quality) /* mod fixed_quality*/
|
||||
/* Normal Rate/distortion allocation */
|
||||
tcd_rateallocate(dest, len, info_IM);
|
||||
else
|
||||
|
@ -1284,7 +1286,7 @@ for (compno = 0; compno < tile->numcomps; compno++) {
|
|||
|
||||
time7 = clock() - time7;
|
||||
fprintf(stdout,"total: %ld.%.3ld s\n", time7 / CLOCKS_PER_SEC,
|
||||
(time7 % CLOCKS_PER_SEC) * 1000 / CLOCKS_PER_SEC);
|
||||
(time7 % (int)CLOCKS_PER_SEC) * 1000 / CLOCKS_PER_SEC);
|
||||
|
||||
/* cleaning memory */
|
||||
for (compno = 0; compno < tile->numcomps; compno++) {
|
||||
|
@ -1312,7 +1314,7 @@ tcd_encode_tile_pgx(int tileno, unsigned char *dest, int len,
|
|||
tile = tcd_tile;
|
||||
/* INDEX >> "Precinct_nb_X et Precinct_nb_Y" */
|
||||
if (info_IM->index_on) {
|
||||
tcd_tilecomp_t *tilec_idx = &tile->comps[0]; //Based on Component 0
|
||||
tcd_tilecomp_t *tilec_idx = &tile->comps[0]; /*Based on Component 0*/
|
||||
|
||||
for (i = 0; i < tilec_idx->numresolutions; i++) {
|
||||
|
||||
|
@ -1403,7 +1405,7 @@ tcd_encode_tile_pgx(int tileno, unsigned char *dest, int len,
|
|||
|
||||
/*----------------DWT---------------------*/
|
||||
|
||||
// mod Ive
|
||||
/* mod Ive*/
|
||||
for (compno = 0; compno < tile->numcomps; compno++) {
|
||||
tcd_tilecomp_t *tilec = &tile->comps[compno];
|
||||
if (tcd_tcp->tccps[compno].qmfbid == 1) {
|
||||
|
@ -1412,7 +1414,7 @@ for (compno = 0; compno < tile->numcomps; compno++) {
|
|||
dwt_encode_real(tilec);
|
||||
}
|
||||
}
|
||||
// /mod Ive
|
||||
/* /mod Ive*/
|
||||
|
||||
/*------------------TIER1-----------------*/
|
||||
|
||||
|
@ -1423,7 +1425,7 @@ for (compno = 0; compno < tile->numcomps; compno++) {
|
|||
|
||||
info_IM->index_write = 0; /* INDEX */
|
||||
|
||||
if (tcd_cp->disto_alloc || tcd_cp->fixed_quality) // mod fixed_quality
|
||||
if (tcd_cp->disto_alloc || tcd_cp->fixed_quality) /* mod fixed_quality*/
|
||||
|
||||
/* Normal Rate/distortion allocation */
|
||||
|
||||
|
@ -1443,7 +1445,7 @@ for (compno = 0; compno < tile->numcomps; compno++) {
|
|||
/*---------------CLEAN-------------------*/
|
||||
time = clock() - time;
|
||||
fprintf(stdout,"total: %ld.%.3ld s\n", time / CLOCKS_PER_SEC,
|
||||
(time % CLOCKS_PER_SEC) * 1000 / CLOCKS_PER_SEC);
|
||||
(time % (int)CLOCKS_PER_SEC) * 1000 / CLOCKS_PER_SEC);
|
||||
|
||||
for (compno = 0; compno < tile->numcomps; compno++) {
|
||||
tilec = &tile->comps[compno];
|
||||
|
@ -1495,7 +1497,7 @@ int tcd_decode_tile(unsigned char *src, int len, int tileno)
|
|||
}
|
||||
|
||||
|
||||
// mod Ive
|
||||
/* mod Ive */
|
||||
if (tcd_tcp->tccps[compno].qmfbid == 1) {
|
||||
dwt_decode(tilec,
|
||||
tilec->numresolutions - 1 -
|
||||
|
@ -1505,7 +1507,7 @@ int tcd_decode_tile(unsigned char *src, int len, int tileno)
|
|||
tilec->numresolutions - 1 -
|
||||
tcd_img->comps[compno].resno_decoded);
|
||||
}
|
||||
// /mod Ive
|
||||
/* /mod Ive*/
|
||||
|
||||
if (tile->comps[compno].numresolutions > 0)
|
||||
tcd_img->comps[compno].factor =
|
||||
|
@ -1561,7 +1563,7 @@ int tcd_decode_tile(unsigned char *src, int len, int tileno)
|
|||
for (i = res->x0; i < res->x1; i++) {
|
||||
|
||||
int v;
|
||||
float tmp = (tilec->data[i - res->x0 + (j - res->y0) * tw])/8192.0;
|
||||
double tmp = (tilec->data[i - res->x0 + (j - res->y0) * tw])/8192.0;
|
||||
int tmp2;
|
||||
|
||||
if (tcd_tcp->tccps[compno].qmfbid == 1) {
|
||||
|
@ -1582,7 +1584,7 @@ int tcd_decode_tile(unsigned char *src, int len, int tileno)
|
|||
|
||||
time = clock() - time;
|
||||
fprintf(stdout, "%ld.%.3ld s\n", time / CLOCKS_PER_SEC,
|
||||
(time % CLOCKS_PER_SEC) * 1000 / CLOCKS_PER_SEC);
|
||||
(time % (int)CLOCKS_PER_SEC) * 1000 / CLOCKS_PER_SEC);
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue