Blame converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.h

Packit 78deda
/*
Packit 78deda
 * Copyright (c) 1999-2000 Image Power, Inc. and the University of
Packit 78deda
 *   British Columbia.
Packit 78deda
 * Copyright (c) 2001-2002 Michael David Adams.
Packit 78deda
 * All rights reserved.
Packit 78deda
 */
Packit 78deda
Packit 78deda
/* __START_OF_JASPER_LICENSE__
Packit 78deda
 * 
Packit 78deda
 * JasPer Software License
Packit 78deda
 * 
Packit 78deda
 * IMAGE POWER JPEG-2000 PUBLIC LICENSE
Packit 78deda
 * ************************************
Packit 78deda
 * 
Packit 78deda
 * GRANT:
Packit 78deda
 * 
Packit 78deda
 * Permission is hereby granted, free of charge, to any person (the "User")
Packit 78deda
 * obtaining a copy of this software and associated documentation, to deal
Packit 78deda
 * in the JasPer Software without restriction, including without limitation
Packit 78deda
 * the right to use, copy, modify, merge, publish, distribute, sublicense,
Packit 78deda
 * and/or sell copies of the JasPer Software (in source and binary forms),
Packit 78deda
 * and to permit persons to whom the JasPer Software is furnished to do so,
Packit 78deda
 * provided further that the License Conditions below are met.
Packit 78deda
 * 
Packit 78deda
 * License Conditions
Packit 78deda
 * ******************
Packit 78deda
 * 
Packit 78deda
 * A.  Redistributions of source code must retain the above copyright notice,
Packit 78deda
 * and this list of conditions, and the following disclaimer.
Packit 78deda
 * 
Packit 78deda
 * B.  Redistributions in binary form must reproduce the above copyright
Packit 78deda
 * notice, and this list of conditions, and the following disclaimer in
Packit 78deda
 * the documentation and/or other materials provided with the distribution.
Packit 78deda
 * 
Packit 78deda
 * C.  Neither the name of Image Power, Inc. nor any other contributor
Packit 78deda
 * (including, but not limited to, the University of British Columbia and
Packit 78deda
 * Michael David Adams) may be used to endorse or promote products derived
Packit 78deda
 * from this software without specific prior written permission.
Packit 78deda
 * 
Packit 78deda
 * D.  User agrees that it shall not commence any action against Image Power,
Packit 78deda
 * Inc., the University of British Columbia, Michael David Adams, or any
Packit 78deda
 * other contributors (collectively "Licensors") for infringement of any
Packit 78deda
 * intellectual property rights ("IPR") held by the User in respect of any
Packit 78deda
 * technology that User owns or has a right to license or sublicense and
Packit 78deda
 * which is an element required in order to claim compliance with ISO/IEC
Packit 78deda
 * 15444-1 (i.e., JPEG-2000 Part 1).  "IPR" means all intellectual property
Packit 78deda
 * rights worldwide arising under statutory or common law, and whether
Packit 78deda
 * or not perfected, including, without limitation, all (i) patents and
Packit 78deda
 * patent applications owned or licensable by User; (ii) rights associated
Packit 78deda
 * with works of authorship including copyrights, copyright applications,
Packit 78deda
 * copyright registrations, mask work rights, mask work applications,
Packit 78deda
 * mask work registrations; (iii) rights relating to the protection of
Packit 78deda
 * trade secrets and confidential information; (iv) any right analogous
Packit 78deda
 * to those set forth in subsections (i), (ii), or (iii) and any other
Packit 78deda
 * proprietary rights relating to intangible property (other than trademark,
Packit 78deda
 * trade dress, or service mark rights); and (v) divisions, continuations,
Packit 78deda
 * renewals, reissues and extensions of the foregoing (as and to the extent
Packit 78deda
 * applicable) now existing, hereafter filed, issued or acquired.
Packit 78deda
 * 
Packit 78deda
 * E.  If User commences an infringement action against any Licensor(s) then
Packit 78deda
 * such Licensor(s) shall have the right to terminate User's license and
Packit 78deda
 * all sublicenses that have been granted hereunder by User to other parties.
Packit 78deda
 * 
Packit 78deda
 * F.  This software is for use only in hardware or software products that
Packit 78deda
 * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
Packit 78deda
 * or right to this Software is granted for products that do not comply
Packit 78deda
 * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
Packit 78deda
 * from the ISO.
Packit 78deda
 * 
Packit 78deda
 * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
Packit 78deda
 * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
Packit 78deda
 * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
Packit 78deda
 * CONTRIBUTORS UNDER THIS LICENSE ON AN ``AS-IS'' BASIS, WITHOUT WARRANTY
Packit 78deda
 * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION,
Packit 78deda
 * WARRANTIES THAT THE JASPER SOFTWARE IS FREE OF DEFECTS, IS MERCHANTABLE,
Packit 78deda
 * IS FIT FOR A PARTICULAR PURPOSE OR IS NON-INFRINGING.  THOSE INTENDING
Packit 78deda
 * TO USE THE JASPER SOFTWARE OR MODIFICATIONS THEREOF FOR USE IN HARDWARE
Packit 78deda
 * OR SOFTWARE PRODUCTS ARE ADVISED THAT THEIR USE MAY INFRINGE EXISTING
Packit 78deda
 * PATENTS, COPYRIGHTS, TRADEMARKS, OR OTHER INTELLECTUAL PROPERTY RIGHTS.
Packit 78deda
 * THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE JASPER SOFTWARE
Packit 78deda
 * IS WITH THE USER.  SHOULD ANY PART OF THE JASPER SOFTWARE PROVE DEFECTIVE
Packit 78deda
 * IN ANY RESPECT, THE USER (AND NOT THE INITIAL DEVELOPERS, THE UNIVERSITY
Packit 78deda
 * OF BRITISH COLUMBIA, IMAGE POWER, INC., MICHAEL DAVID ADAMS, OR ANY
Packit 78deda
 * OTHER CONTRIBUTOR) SHALL ASSUME THE COST OF ANY NECESSARY SERVICING,
Packit 78deda
 * REPAIR OR CORRECTION.  UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY,
Packit 78deda
 * WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE
Packit 78deda
 * INITIAL DEVELOPER, THE UNIVERSITY OF BRITISH COLUMBIA, IMAGE POWER, INC.,
Packit 78deda
 * MICHAEL DAVID ADAMS, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF THE
Packit 78deda
 * JASPER SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO
Packit 78deda
 * THE USER OR ANY OTHER PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
Packit 78deda
 * CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION,
Packit 78deda
 * DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR
Packit 78deda
 * MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF
Packit 78deda
 * SUCH PARTY HAD BEEN INFORMED, OR OUGHT TO HAVE KNOWN, OF THE POSSIBILITY
Packit 78deda
 * OF SUCH DAMAGES.  THE JASPER SOFTWARE AND UNDERLYING TECHNOLOGY ARE NOT
Packit 78deda
 * FAULT-TOLERANT AND ARE NOT DESIGNED, MANUFACTURED OR INTENDED FOR USE OR
Packit 78deda
 * RESALE AS ON-LINE CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING
Packit 78deda
 * FAIL-SAFE PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES,
Packit 78deda
 * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT
Packit 78deda
 * LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
Packit 78deda
 * JASPER SOFTWARE OR UNDERLYING TECHNOLOGY OR PRODUCT COULD LEAD DIRECTLY
Packit 78deda
 * TO DEATH, PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE
Packit 78deda
 * ("HIGH RISK ACTIVITIES").  LICENSOR SPECIFICALLY DISCLAIMS ANY EXPRESS
Packit 78deda
 * OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.  USER WILL NOT
Packit 78deda
 * KNOWINGLY USE, DISTRIBUTE OR RESELL THE JASPER SOFTWARE OR UNDERLYING
Packit 78deda
 * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
Packit 78deda
 * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
Packit 78deda
 * NOTICE SPECIFIED IN THIS SECTION.
Packit 78deda
 * 
Packit 78deda
 * __END_OF_JASPER_LICENSE__
Packit 78deda
 */
Packit 78deda
Packit 78deda
/*
Packit 78deda
 * Quadrature Mirror-Image Filter Bank (QMFB) Routines
Packit 78deda
 *
Packit 78deda
 * $Id$
Packit 78deda
 */
Packit 78deda
Packit 78deda
#ifndef JPC_QMFB_H
Packit 78deda
#define JPC_QMFB_H
Packit 78deda
Packit 78deda
/******************************************************************************\
Packit 78deda
* Includes.
Packit 78deda
\******************************************************************************/
Packit 78deda
Packit 78deda
#include "jasper/jas_seq.h"
Packit 78deda
Packit 78deda
/******************************************************************************\
Packit 78deda
* Constants.
Packit 78deda
\******************************************************************************/
Packit 78deda
Packit 78deda
/* The maximum number of channels for a QMF bank. */
Packit 78deda
#define	JPC_QMFB1D_MAXCHANS	2
Packit 78deda
Packit 78deda
/* Select reversible integer-to-integer mode. */
Packit 78deda
#define	JPC_QMFB1D_RITIMODE	1
Packit 78deda
Packit 78deda
/* Vertical filtering. */
Packit 78deda
#define	JPC_QMFB1D_VERT	0x10000
Packit 78deda
Packit 78deda
/* QMFB IDs. */
Packit 78deda
#define	JPC_QMFB1D_FT	1	/* 5/3 */
Packit 78deda
#define	JPC_QMFB1D_NS	2	/* 9/7 */
Packit 78deda
Packit 78deda
/******************************************************************************\
Packit 78deda
* Types.
Packit 78deda
\******************************************************************************/
Packit 78deda
Packit 78deda
/* Forward declaration. */
Packit 78deda
struct jpc_qmfb1dops_s;
Packit 78deda
Packit 78deda
/* Band information. */
Packit 78deda
Packit 78deda
typedef struct {
Packit 78deda
Packit 78deda
	/* The starting index for the band in the downsampled domain. */
Packit 78deda
	int start;
Packit 78deda
Packit 78deda
	/* The ending index for the band in the downsampled domain. */
Packit 78deda
	int end;
Packit 78deda
Packit 78deda
	/* The location of the start of the band. */
Packit 78deda
	int locstart;
Packit 78deda
Packit 78deda
	/* The location of the end of the band. */
Packit 78deda
	int locend;
Packit 78deda
Packit 78deda
} jpc_qmfb1dband_t;
Packit 78deda
Packit 78deda
/* QMF bank */
Packit 78deda
Packit 78deda
typedef struct {
Packit 78deda
Packit 78deda
	/* The operations for this QMFB. */
Packit 78deda
	struct jpc_qmfb1dops_s *ops;
Packit 78deda
Packit 78deda
} jpc_qmfb1d_t;
Packit 78deda
Packit 78deda
/* QMFB operations. */
Packit 78deda
Packit 78deda
typedef struct jpc_qmfb1dops_s {
Packit 78deda
Packit 78deda
	/* The number of channels in the QMFB. */
Packit 78deda
	int (*getnumchans)(jpc_qmfb1d_t *qmfb);
Packit 78deda
Packit 78deda
	/* Get the analysis filters for this QMFB. */
Packit 78deda
	int (*getanalfilters)(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters);
Packit 78deda
Packit 78deda
	/* Get the synthesis filters for this QMFB. */
Packit 78deda
	int (*getsynfilters)(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters);
Packit 78deda
Packit 78deda
	/* Do analysis. */
Packit 78deda
	void (*analyze)(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x);
Packit 78deda
Packit 78deda
	/* Do synthesis. */
Packit 78deda
	void (*synthesize)(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x);
Packit 78deda
Packit 78deda
} jpc_qmfb1dops_t;
Packit 78deda
Packit 78deda
/******************************************************************************\
Packit 78deda
* Functions.
Packit 78deda
\******************************************************************************/
Packit 78deda
Packit 78deda
/* Create a QMFB from a QMFB ID. */
Packit 78deda
jpc_qmfb1d_t *jpc_qmfb1d_make(int qmfbid);
Packit 78deda
Packit 78deda
/* Create a copy of a QMFB. */
Packit 78deda
jpc_qmfb1d_t *jpc_qmfb1d_copy(jpc_qmfb1d_t *qmfb);
Packit 78deda
Packit 78deda
/* Destroy a QMFB. */
Packit 78deda
void jpc_qmfb1d_destroy(jpc_qmfb1d_t *qmfb);
Packit 78deda
Packit 78deda
/* Get the number of channels for a QMFB. */
Packit 78deda
int jpc_qmfb1d_getnumchans(jpc_qmfb1d_t *qmfb);
Packit 78deda
Packit 78deda
/* Get the analysis filters for a QMFB. */
Packit 78deda
int jpc_qmfb1d_getanalfilters(jpc_qmfb1d_t *qmfb, int len,
Packit 78deda
  jas_seq2d_t **filters);
Packit 78deda
Packit 78deda
/* Get the synthesis filters for a QMFB. */
Packit 78deda
int jpc_qmfb1d_getsynfilters(jpc_qmfb1d_t *qmfb, int len,
Packit 78deda
  jas_seq2d_t **filters);
Packit 78deda
Packit 78deda
/* Get the bands for a QMFB. */
Packit 78deda
void jpc_qmfb1d_getbands(jpc_qmfb1d_t *qmfb, int flags, uint_fast32_t xstart,
Packit 78deda
  uint_fast32_t ystart, uint_fast32_t xend, uint_fast32_t yend, int maxbands,
Packit 78deda
  int *numbandsptr, jpc_qmfb1dband_t *bands);
Packit 78deda
Packit 78deda
/* Perform analysis. */
Packit 78deda
void jpc_qmfb1d_analyze(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x);
Packit 78deda
Packit 78deda
/* Perform synthesis. */
Packit 78deda
void jpc_qmfb1d_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x);
Packit 78deda
Packit 78deda
#endif