【VC开源代码栏目提醒】:网学会员在VC开源代码频道为大家收集整理了wvtpezw_tree_encode.cpp提供大家参考,希望对大家有所帮助!
/****************************************************************************/
/* MPEG4 Visual Texture Coding (VTC) Mode Software */
/* */
/* This software was jointly developed by the following participants: */
/* */
/* Single-quant, multi-quant and flow control */
/* are provided by Sarnoff Corporation */
/* Iraj Sodagar (iraj@sarnoff.com) */
/* Hung-Ju Lee (hjlee@sarnoff.com) */
/* Paul Hatrack (hatrack@sarnoff.com) */
/* Shipeng Li (shipeng@sarnoff.com) */
/* Bing-Bing Chai (bchai@sarnoff.com) */
/* B.S. Srinivas (bsrinivas@sarnoff.com) */
/* */
/* Bi-level is provided by Texas Instruments */
/* Jie Liang (liang@ti.com) */
/* */
/* Shape Coding is provided by OKI Electric Industry Co., Ltd. */
/* Zhixiong Wu (sgo@hlabs.oki.co.jp) */
/* Yoshihiro Ueda (yueda@hlabs.oki.co.jp) */
/* Toshifumi Kanamaru (kanamaru@hlabs.oki.co.jp) */
/* */
/* OKI, Sharp, Sarnoff, TI and Microsoft contributed to bitstream */
/* exchange and bug fixing. */
/* */
/* */
/* In the course of development of the MPEG-4 standard, this software */
/* module is an implementation of a part of one or more MPEG-4 tools as */
/* specified by the MPEG-4 standard. */
/* */
/* The copyright of this software belongs to ISO/IEC. ISO/IEC gives use */
/* of the MPEG-4 standard free license to use this software module or */
/* modifications thereof for hardware or software products claiming */
/* conformance to the MPEG-4 standard. */
/* */
/* Those intending to use this software module in hardware or software */
/* products are advised that use may infringe existing patents. The */
/* original developers of this software module and their companies, the */
/* subsequent editors and their companies, and ISO/IEC have no liability */
/* and ISO/IEC have no liability for use of this software module or */
/* modification thereof in an implementation. */
/* */
/* Per
mission is granted to MPEG members to use, copy, modify, */
/* and distribute the software modules ( or portions thereof ) */
/* for standardization activity within ISO/IEC JTC1/SC29/WG11. */
/* */
/* Copyright 1995, 1996, 1997, 1998 ISO/IEC */
/****************************************************************************/
/****************************************************************************/
/* Texas Instruments Predictive Embedded Zerotree (PEZW) Image Codec */
/* Developed by Jie Liang (liang@ti.com) */
/* */
/* Copyright 1996, 1997, 1998 Texas Instruments */
/****************************************************************************/
/****************************************************************************
File name: wvtpezw_tree_encode.c
Author: Jie Liang (liang@ti.com)
Functions: Core functions for encoding the tree blocks of coeffs.
Revisions: v1.0 (10/04/98)
*****************************************************************************/
#include "wvtPEZW.hpp"
#include "PEZW_zerotree.hpp"
#include "wvtpezw_tree_codec.hpp"
#include "PEZW_functions.hpp"
/* encode a block of wavelet coefficients */
void PEZW_encode_block (WINT **coeffsBlk,int width, int height)
{
Int dc_hsize, dc_vsize;
Int i,j,k,band, hpos, vpos;
int pos;
int hpos_start, hpos_end;
int vpos_start, vpos_end;
Int lev, npix;
Int hstart, vstart,start, end;
Int x,y;
Int levels;
#ifdef DEBUG_FILE
Int NumTree=0;
#endif
levels = tree_depth;
dc_hsize = width>>levels;
dc_vsize = height>>levels;
/* encode the AC coefficients:
loop over all zerotrees */
for(i=0;i<dc_vsize;i++)
for (j=0;j<dc_hsize;j++)
for(band=0;band<3;band++)
{
/* copy the data into the wavelet tree */
if(band==0) { /* HL band */
hpos = j+dc_hsize;
vpos = i;
}
else if (band==1) { /* LH band */
hpos = j;
vpos = i+dc_vsize;
}
else{
hpos = j+dc_hsize;
vpos = i+dc_vsize;
}
y=vpos;x=hpos;
/* quantization and copy */
the_wvt_tree[0]=coeffsBlk[y][x];
for (lev=1;lev<levels;lev++)
{
npix=1<<(2*(lev-1));
pos = level_pos[lev];
hstart=hpos*(1<<(lev-1));
vstart=vpos*(1<<(lev-1));
start=level_pos[lev-1];
end=level_pos[lev];
for(k=start;k<end;k++)
{
hpos_start = (hstart+hloc_map[k])<<1;
hpos_end = hpos_start+2;
vpos_start = (vstart+vloc_map[k])<<1;
vpos_end = vpos_start+2;
for(y=vpos_start;y<vpos_end;y++)
for(x=hpos_start;x<hpos_end;x++){
/* quantization and copy */
the_wvt_tree[pos]=coeffsBlk[y][x];
pos++;
}
} /* end of k */
} /* end of for(lev) */
/* determin weighting */
for (lev=0;lev<le