📄 kdu_compressed.h
字号:
/*****************************************************************************/// File: kdu_compressed.h [scope = CORESYS/COMMON]// Version: Kakadu, V2.2// Author: David Taubman// Last Revised: 20 June, 2001/*****************************************************************************/// Copyright 2001, David Taubman, The University of New South Wales (UNSW)// The copyright owner is Unisearch Ltd, Australia (commercial arm of UNSW)// Neither this copyright statement, nor the licensing details below// may be removed from this file or dissociated from its contents./*****************************************************************************/// Licensee: Book Owner// License number: 99999// The Licensee has been granted a NON-COMMERCIAL license to the contents of// this source file, said Licensee being the owner of a copy of the book,// "JPEG2000: Image Compression Fundamentals, Standards and Practice," by// Taubman and Marcellin (Kluwer Academic Publishers, 2001). A brief summary// of the license appears below. This summary is not to be relied upon in// preference to the full text of the license agreement, which was accepted// upon breaking the seal of the compact disc accompanying the above-mentioned// book.// 1. The Licensee has the right to Non-Commercial Use of the Kakadu software,// Version 2.2, including distribution of one or more Applications built// using the software, provided such distribution is not for financial// return.// 2. The Licensee has the right to personal use of the Kakadu software,// Version 2.2.// 3. The Licensee has the right to distribute Reusable Code (including// source code and dynamically or statically linked libraries) to a Third// Party, provided the Third Party possesses a license to use the Kakadu// software, Version 2.2, and provided such distribution is not for// financial return./******************************************************************************Description: This file provides the key interfaces between the Kakadu frameworkand an application which uses its services. In particular, it defines theservices required to create a codestream interface object and to access thevarious sub-ordinate elements: tiles, tile-components, resolutions, subbandsand code-blocks. It provides high level interfaces which isolate theapplication from the actual machinery used to incrementally read, write andtransform JPEG2000 code-streams. The key data processing objects attach toone or more of these code-stream interfaces. You are strongly encouraged to use the services provided here as-is andnot to meddle with the internal machinery. Most services which you shouldrequire for compression, decompression, transcoding and interactiveapplications are provided. One notable exception is that there is currentlyno direct access to precincts (and hence the packet data which they embody).Direct access to precincts may be of interest to client-server applications.The corresponding objects exist in the internal machinery and will be exposedthrough appropriate interfaces at a later date.******************************************************************************/#ifndef KDU_COMPRESSED_H#define KDU_COMPRESSED_H#include <time.h>#include <iostream>#include "kdu_params.h"// Defined here:struct kdu_coords;struct kdu_dims;class kdu_compressed_source;class kdu_compressed_target;class kdu_codestream;class kdu_tile;class kdu_tile_comp;class kdu_resolution;class kdu_subband;struct kdu_block;// Referenced here, defined inside the private implementationstruct kd_codestream;struct kd_tile;struct kd_tile_comp;struct kd_resolution;struct kd_subband;struct kd_precinct;/* ========================================================================= *//* Marker Codes *//* ========================================================================= */#define KDU_SOC ((kdu_uint16) 0xFF4F) // Delimiting marker -- processed in "codestream.cpp"#define KDU_SOT ((kdu_uint16) 0xFF90) // Delimiting marker segment -- processed in "compressed.cpp"#define KDU_SOD ((kdu_uint16) 0xFF93) // Delimiting marker -- processed in "compressed.cpp"#define KDU_SOP ((kdu_uint16) 0xFF91) // In-pack-stream marker -- processed in "compressed.cpp"#define KDU_EPH ((kdu_uint16) 0xFF92) // In-pack-stream marker -- processed in "compressed.cpp"#define KDU_EOC ((kdu_uint16) 0xFFD9) // Delimiting marker -- processed in "codestream.cpp"#define KDU_SIZ ((kdu_uint16) 0xFF51) // Parameter marker segment -- processed in "params.cpp"#define KDU_COD ((kdu_uint16) 0xFF52) // Parameter marker segment -- processed in "params.cpp"#define KDU_COC ((kdu_uint16) 0xFF53) // Parameter marker segment -- processed in "params.cpp"#define KDU_QCD ((kdu_uint16) 0xFF5C) // Parameter marker segment -- processed in "params.cpp"#define KDU_QCC ((kdu_uint16) 0xFF5D) // Parameter marker segment -- processed in "params.cpp"#define KDU_RGN ((kdu_uint16) 0xFF5E) // Parameter marker segment -- processed in "params.cpp"#define KDU_POC ((kdu_uint16) 0xFF5F) // Parameter marker segment -- processed in "params.cpp"#define KDU_CRG ((kdu_uint16) 0xFF63) // Parameter marker segment -- processed in "params.cpp"#define KDU_COM ((kdu_uint16) 0xFF64) // Packet headers in advance -- processed in "compressed.cpp"#define KDU_TLM ((kdu_uint16) 0xFF55) // Packet headers in advance -- processed in "compressed.cpp"#define KDU_PLM ((kdu_uint16) 0xFF57) // Comment marker -- can safely ignore these#define KDU_PLT ((kdu_uint16) 0xFF58) // Comment marker -- can safely ignore these#define KDU_PPM ((kdu_uint16) 0xFF60) // Comment marker -- can safely ignore these#define KDU_PPT ((kdu_uint16) 0xFF61) // Comment marker -- can safely ignore these/* ========================================================================= *//* Class and Structure Definitions *//* ========================================================================= *//*****************************************************************************//* kdu_coords *//*****************************************************************************/struct kdu_coords { public: // Data int y, x; public: // Convenience functions kdu_coords() {} kdu_coords(int x, int y) {this->x=x; this->y=y; } void transpose() {int tmp=y; y=x; x=tmp; } kdu_coords operator+(kdu_coords &rhs) { kdu_coords result; result.x=x+rhs.x; result.y=y+rhs.y; return result; } kdu_coords operator-(kdu_coords &rhs) { kdu_coords result; result.x=x-rhs.x; result.y=y-rhs.y; return result; } kdu_coords operator+=(kdu_coords &rhs) { x+=rhs.x; y+=rhs.y; return *this; } kdu_coords operator-=(kdu_coords &rhs) { x-=rhs.x; y-=rhs.y; return *this; } bool operator==(kdu_coords &rhs) { return (x==rhs.x) && (y==rhs.y); } bool operator!=(kdu_coords &rhs) { return (x!=rhs.x) || (y!=rhs.y); } };/*****************************************************************************//* kdu_dims *//*****************************************************************************/struct kdu_dims { public: // Data kdu_coords pos; kdu_coords size; public: // Convenience functions int area() { return size.x*size.y; } void transpose() { size.transpose(); pos.transpose(); } kdu_dims operator&(kdu_dims &rhs) // Intersects region with RHS. { kdu_dims result = *this; result &= rhs; return result; } kdu_dims operator&=(kdu_dims &rhs) // Returns intersection of operands { kdu_coords lim = pos+size; kdu_coords rhs_lim = rhs.pos + rhs.size; if (lim.x > rhs_lim.x) lim.x = rhs_lim.x; if (lim.y > rhs_lim.y) lim.y = rhs_lim.y; if (pos.x < rhs.pos.x) pos.x = rhs.pos.x; if (pos.y < rhs.pos.y) pos.y = rhs.pos.y; size = lim-pos; if (size.x < 0) size.x = 0; if (size.y < 0) size.y = 0; return *this; } bool operator!() { return ((size.x>0)&&(size.y>0))?false:true; } bool operator==(kdu_dims &rhs) { return (pos==rhs.pos) && (size==rhs.size); } bool operator!=(kdu_dims &rhs) { return (pos!=rhs.pos) || (size!=rhs.size); } }; /* Generic structure for holding location and size information for various partitions on the canvas. The `size' coordinates identify the dimensions of the specific tile, tile-component, precinct, code-block, etc., while the `pos' coordinates identify its position. When used to describe generic partitions, the nominal partition size is maintained by `size', while `pos' holds the anchor point. *//*****************************************************************************//* kdu_compressed_source *//*****************************************************************************/#define KDU_SOURCE_CAP_SEQUENTIAL 0x0001#define KDU_SOURCE_CAP_SEEKABLE 0x0002#define KDU_SOURCE_CAP_TILES 0x0004#define KDU_SOURCE_CAP_PRECINCTS 0x0008class kdu_compressed_source { /* Abstract base class must be derived to create a real compressed data source with which to construct an input `kdu_codestream' object. Supports everything from simple file reading sources to caching sources for use in sophisticated client-server applications. Currently, none of the read scoping functions are implemented by any
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -