/*
* Copyright (c) 2001-2002, David Janssens
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "tcd.h"
#include "int.h"
#include "t1.h"
#include "t2.h"
#include "dwt.h"
#include "mct.h"
#include <setjmp.h>
#include <float.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <stdlib.h>
#include <memory.h>
tcd_image_t tcd_image;
j2k_image_t *tcd_img;
j2k_cp_t *tcd_cp;
tcd_tile_t *tcd_tile;
j2k_tcp_t *tcd_tcp;
int tcd_tileno;
extern jmp_buf j2k_error;
#if J2K_DUMP_ENABLED
void tcd_dump(tcd_image_t *img) {
int tileno, compno, resno, bandno, precno, cblkno;
fprintf(stderr, "image {\n");
fprintf(stderr, " tw=%d, th=%d\n", img->tw, img->th);
for (tileno=0; tileno<img->tw*img->th; tileno++) {
tcd_tile_t *tile=&tcd_image.tiles[tileno];
fprintf(stderr, " tile {\n");
fprintf(stderr, " x0=%d, y0=%d, x1=%d, y1=%d, numcomps=%d\n", tile->x0, tile->y0, tile->x1, tile->y1, tile->numcomps);
for (compno=0; compno<tile->numcomps; compno++) {
tcd_tilecomp_t *tilec=&tile->comps[compno];
fprintf(stderr, " tilec {\n");
fprintf(stderr, " x0=%d, y0=%d, x1=%d, y1=%d, numresolutions=%d\n", tilec->x0, tilec->y0, tilec->x1, tilec->y1, tilec->numresolutions);
for (resno=0; resno<tilec->numresolutions; resno++) {
tcd_resolution_t *res=&tilec->resolutions[resno];
fprintf(stderr, " res {\n");
fprintf(stderr, " x0=%d, y0=%d, x1=%d, y1=%d, pw=%d, ph=%d, numbands=%d\n", res->x0, res->y0, res->x1, res->y1, res->pw, res->ph, res->numbands);
for (bandno=0; bandno<res->numbands; bandno++) {
tcd_band_t *band=&res->bands[bandno];
fprintf(stderr, " band {\n");
fprintf(stderr, " x0=%d, y0=%d, x1=%d, y1=%d, stepsize=%d, numbps=%d\n", band->x0, band->y0, band->x1, band->y1, band->stepsize, band->numbps);
for (precno=0; precno<res->pw*res->ph; precno++) {
tcd_precinct_t *prec=&band->precincts[precno];
fprintf(stderr, " prec {\n");
fprintf(stderr, " x0=%d, y0=%d, x1=%d, y1=%d, cw=%d, ch=%d\n", prec->x0, prec->y0, prec->x1, prec->y1, prec->cw, prec->ch);
for (cblkno=0; cblkno<prec->cw*prec->ch; cblkno++) {
tcd_cblk_t *cblk=&prec->cblks[cblkno];
fprintf(stderr, " cblk {\n");
fprintf(stderr, " x0=%d, y0=%d, x1=%d, y1=%d\n", cblk->x0, cblk->y0, cblk->x1, cblk->y1);
fprintf(stderr, " }\n");
}
fprintf(stderr, " }\n");
}
fprintf(stderr, " }\n");
}
fprintf(stderr, " }\n");
}
fprintf(stderr, " }\n");
}
fprintf(stderr, " }\n");
}
fprintf(stderr, "}\n");
}
#endif //J2K_DUMP_ENABLED
void tcd_init(j2k_image_t *img, j2k_cp_t *cp) {
int tileno, compno, resno, bandno, precno, cblkno;
tcd_img=img;
tcd_cp=cp;
tcd_image.tw=cp->tw;
tcd_image.th=cp->th;
tcd_image.tiles=(tcd_tile_t*)malloc(cp->tw*cp->th*sizeof(tcd_tile_t));
for (tileno=0; tileno<cp->tw*cp->th; tileno++) {
j2k_tcp_t *tcp=&cp->tcps[tileno];
tcd_tile_t *tile=&tcd_image.tiles[tileno];
int p=tileno%cp->tw;
int q=tileno/cp->tw;
tile->x0=int_max(cp->tx0+p*cp->tdx, img->x0);
tile->y0=int_max(cp->ty0+q*cp->tdy, img->y0);
tile->x1=int_min(cp->tx0+(p+1)*cp->tdx, img->x1);
tile->y1=int_min(cp->ty0+(q+1)*cp->tdy, img->y1);
tile->numcomps=img->numcomps;
tile->comps=(tcd_tilecomp_t*)malloc(img->numcomps*sizeof(tcd_tilecomp_t));
for (compno=0; compno<tile->numcomps; compno++) {
j2k_tccp_t *tccp=&tcp->tccps[compno];
tcd_tilecomp_t *tilec=&tile->comps[compno];
tilec->x0=int_ceildiv(tile->x0, img->comps[compno].dx);
tilec->y0=int_ceildiv(tile->y0, img->comps[compno].dy);
tilec->x1=int_ceildiv(tile->x1, img->comps[compno].dx);
tilec->y1=int_ceildiv(tile->y1, img->comps[compno].dy);
tilec->data=(int*)malloc(sizeof(int)*(tilec->x1-tilec->x0)*(tilec->y1-tilec->y0));
tilec->numresolutions=tccp->numresolutions;
tilec->resolutions=(tcd_resolution_t*)malloc(tilec->numresolutions*sizeof(tcd_resolution_t));
for (resno=0; resno<tilec->numresolutions; resno++) {
int pdx, pdy;
int levelno=tilec->numresolutions-1-resno;
int tlprcxstart, tlprcystart, brprcxend, brprcyend;
int tlcbgxstart, tlcbgystart, brcbgxend, brcbgyend;
int cbgwidthexpn, cbgheightexpn;
int cblkwidthexpn, cblkheightexpn;
tcd_resolution_t *res=&tilec->resolutions[resno];
res->x0=int_ceildivpow2(tilec->x0, levelno);
res->y0=int_ceildivpow2(tilec->y0, levelno);
res->x1=int_ceildivpow2(tilec->x1, levelno);
res->y1=int_ceildivpow2(tilec->y1, levelno);
res->numbands=resno==0?1:3;
if (tccp->csty&J2K_CCP_CSTY_PRT) {
pdx=tccp->prcw[resno];
pdy=tccp->prch[resno];
} else {
pdx=15;
pdy=15;
}
tlprcxstart=int_floordivpow2(res->x0, pdx)<<pdx;
tlprcystart=int_floordivpow2(res->y0, pdy)<<pdy;
brprcxend=int_ceildivpow2(res->x1, pdx)<<pdx;
brprcyend=int_ceildivpow2(res->y1, pdy)<<pdy;
res->pw=(brprcxend-tlprcxstart)>>pdx;
res->ph=(brprcyend-tlprcystart)>>pdy;
if (resno==0) {
tlcbgxstart=tlprcxstart;
tlcbgystart=tlprcystart;
brcbgxend=brprcxend;
brcbgyend=brprcyend;
cbgwidthexpn=pdx;
cbgheightexpn=pdy;
} else {
tlcbgxstart=int_ceildivpow2(tlprcxstart, 1);
tlcbgystart=int_ceildivpow2(tlprcystart, 1);
brcbgxend=int_ceildivpow2(brprcxend, 1);
brcbgyend=int_ceildivpow2(brprcyend, 1);
cbgwidthexpn=pdx-1;
cbgheightexpn=pdy-1;
}
cblkwidthexpn=int_min(tccp->cblkw, cbgwidthexpn);
没有合适的资源?快使用搜索试试~ 我知道了~
j2k.lib在cximage600生成动态库时用到
共43个文件
h:13个
obj:13个
c:13个
5星 · 超过95%的资源 需积分: 15 64 下载量 110 浏览量
2011-08-26
16:30:02
上传
评论
收藏 113KB RAR 举报
温馨提示
vc6.0 编译cximage600生成cximagecrtu.dll时要用到,编译时注意加入link项:kernel32.lib user32.lib gdi32.lib wininet.lib ../../png/Unicode_Release/png.lib ../../jpeg/Unicode_Release/jpeg.lib ../../zlib/Unicode_Release/zlib.lib ../../tiff/Unicode_Release/tiff.lib ../../jbig/Unicode_Release/jbig.lib ../../jasper/Unicode_Release/jasper.lib ../../mng/Unicode_Release/mng.lib ../../raw/Unicode_Release/libdcr.lib ../../cximage/Unicode_Release/cximage.lib
资源推荐
资源详情
资源评论
收起资源包目录
j2k.lib.rar (43个子文件)
j2k
mqc.c 11KB
cio.c 3KB
tgt.h 2KB
tcd.c 26KB
mct.c 3KB
bio.c 4KB
t2.h 2KB
dwt.c 7KB
fix.c 2KB
int.h 2KB
j2k.dsp 6KB
t1.c 24KB
fix.h 1KB
t2.c 10KB
tgt.c 5KB
mqc.h 2KB
j2k.h 5KB
dwt.h 2KB
mct.h 2KB
pi.c 14KB
cio.h 2KB
pi.h 2KB
j2k.dsw 529B
bio.h 2KB
t1.h 2KB
tcd.h 3KB
j2k.c 22KB
int.c 2KB
Unicode_Release
tcd.obj 10KB
mqc.obj 10KB
j2k.lib 99KB
mct.obj 2KB
vc60.idb 49KB
fix.obj 486B
j2k.obj 18KB
cio.obj 3KB
tgt.obj 2KB
t2.obj 6KB
int.obj 2KB
t1.obj 17KB
dwt.obj 8KB
pi.obj 6KB
bio.obj 4KB
共 43 条
- 1
saveme100
- 粉丝: 0
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页