Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4758 right-hear 1
/*
2
 * Copyright (c) 2001-2002, David Janssens
3
 * Copyright (c) 2003, Yannick Verschueren
4
 * Copyright (c) 2003,  Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
5
 * All rights reserved.
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
9
 * are met:
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer.
12
 * 2. Redistributions in binary form must reproduce the above copyright
13
 *    notice, this list of conditions and the following disclaimer in the
14
 *    documentation and/or other materials provided with the distribution.
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
17
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
 * POSSIBILITY OF SUCH DAMAGE.
27
 */
28
 
29
#ifndef __TCD_H
30
#define __TCD_H
31
 
32
#include "j2k.h"
33
#include "tgt.h"
34
 
35
typedef struct {
36
    int numpasses;
37
    int len;
38
    unsigned char *data;
39
    int maxpasses;
40
    int numnewpasses;
41
    int newlen;
42
} tcd_seg_t;
43
 
44
typedef struct {
45
    int rate;
46
    double distortiondec;
47
} tcd_pass_t;
48
 
49
typedef struct {
50
    int numpasses;
51
    int len;
52
    unsigned char *data;
53
} tcd_layer_t;
54
 
55
typedef struct {
56
    int x0, y0, x1, y1;
57
    int numbps;
58
    int numlenbits;
59
    int len;
60
    int numpasses;
61
    int numnewpasses;
62
    int numsegs;
63
    tcd_seg_t segs[100];
64
    unsigned char data[8192];
65
    int numpassesinlayers;
66
    tcd_layer_t layers[100];
67
    int totalpasses;
68
    tcd_pass_t passes[100];
69
} tcd_cblk_t;
70
 
71
typedef struct {
72
    int x0, y0, x1, y1;
73
    int cw, ch;
74
    tcd_cblk_t *cblks;
75
    tgt_tree_t *incltree;
76
    tgt_tree_t *imsbtree;
77
} tcd_precinct_t;
78
 
79
typedef struct {
80
    int x0, y0, x1, y1;
81
    int bandno;
82
    tcd_precinct_t *precincts;
83
    int numbps;
84
    int stepsize;
85
} tcd_band_t;
86
 
87
typedef struct {
88
    int x0, y0, x1, y1;
89
  int previous_x0, previous_y0, previous_x1, previous_y1; // usefull for the DWT
90
  int cas_col, cas_row; // usefull for the DWT
91
    int pw, ph;
92
    int numbands;
93
    tcd_band_t bands[3];
94
} tcd_resolution_t;
95
 
96
typedef struct {
97
    int x0, y0, x1, y1;
98
  int previous_row, previous_col; // usefull for the DWT
99
    int numresolutions;
100
    tcd_resolution_t *resolutions;
101
    int *data;
102
} tcd_tilecomp_t;
103
 
104
typedef struct {
105
    int x0, y0, x1, y1;
106
    int numcomps;
107
  //int PPT;
108
  //int len_ppt;
109
    tcd_tilecomp_t *comps;
110
} tcd_tile_t;
111
 
112
typedef struct {
113
    int tw, th;
114
    tcd_tile_t *tiles;
115
} tcd_image_t;
116
 
117
/*
118
 * Initialize the tile coder/decoder
119
 * img: raw image
120
 * cp: coding parameters
121
 * imgg: creation of index file
122
 */
123
 
124
void tcd_init(j2k_image_t *img, j2k_cp_t *cp, info_image_t *imgg);
125
 
126
void tcd_free(j2k_image_t *img, j2k_cp_t *cp);
127
 
128
/*
129
 * Decode a tile from a buffer into a raw image
130
 * src: source buffer
131
 * len: length of the source buffer
132
 * tileno: number that identifies the tile that will be decoded
133
 * imgg : Structure for index file
134
 */
135
int tcd_decode_tile(unsigned char *src, int len, int tileno, info_image_t *imgg);
136
 
137
#endif