1ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/*
2ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * The copyright in this software is being made available under the 2-clauses
3ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * BSD License, included below. This software may be subject to other third
4ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * party and contributor rights, including patent rights, and no such rights
5ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * are granted under this license.
6ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov *
7ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
8ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2002-2014, Professor Benoit Macq
9ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2003-2007, Francois-Olivier Devaux
10ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2003-2014, Antonin Descampe
11ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Copyright (c) 2005, Herve Drolon, FreeImage Team
12ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * All rights reserved.
13ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov *
14ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * Redistribution and use in source and binary forms, with or without
15ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * modification, are permitted provided that the following conditions
16ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * are met:
17ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 1. Redistributions of source code must retain the above copyright
18ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov *    notice, this list of conditions and the following disclaimer.
19ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * 2. Redistributions in binary form must reproduce the above copyright
20ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov *    notice, this list of conditions and the following disclaimer in the
21ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov *    documentation and/or other materials provided with the distribution.
22ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov *
23ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
24ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov * POSSIBILITY OF SUCH DAMAGE.
34ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov */
35ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
36ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifndef __RAW_H
37ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define __RAW_H
38ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/**
39ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov@file raw.h
40ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov@brief Implementation of operations for raw encoding (RAW)
41ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
42ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovThe functions in RAW.C have for goal to realize the operation of raw encoding linked
43ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovwith the corresponding mode switch.
44ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov*/
45ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
46ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** @defgroup RAW RAW - Implementation of operations for raw encoding */
47ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/*@{*/
48ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
49ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/**
50ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovRAW encoding operations
51ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov*/
52ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct opj_raw {
53ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	/** temporary buffer where bits are coded or decoded */
54ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	OPJ_BYTE c;
55ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	/** number of bits already read or free to write */
56ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	OPJ_UINT32 ct;
57ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	/** maximum length to decode */
58ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	OPJ_UINT32 lenmax;
59ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	/** length decoded */
60ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	OPJ_UINT32 len;
61ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	/** pointer to the current position in the buffer */
62ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	OPJ_BYTE *bp;
63ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	/** pointer to the start of the buffer */
64ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	OPJ_BYTE *start;
65ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	/** pointer to the end of the buffer */
66ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov	OPJ_BYTE *end;
67ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} opj_raw_t;
68ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
69ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/** @name Exported functions */
70ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/*@{*/
71ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/* ----------------------------------------------------------------------- */
72ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/**
73ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCreate a new RAW handle
74ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov@return Returns a new RAW handle if successful, returns NULL otherwise
75ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov*/
76ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovopj_raw_t* opj_raw_create(void);
77ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/**
78ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovDestroy a previously created RAW handle
79ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov@param raw RAW handle to destroy
80ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov*/
81ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_raw_destroy(opj_raw_t *raw);
82ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/**
83ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovReturn the number of bytes written/read since initialisation
84ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov@param raw RAW handle to destroy
85ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov@return Returns the number of bytes already encoded
86ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov*/
87ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_UINT32 opj_raw_numbytes(opj_raw_t *raw);
88ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/**
89ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovInitialize the decoder
90ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov@param raw RAW handle
91ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov@param bp Pointer to the start of the buffer from which the bytes will be read
92ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov@param len Length of the input buffer
93ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov*/
94ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovvoid opj_raw_init_dec(opj_raw_t *raw, OPJ_BYTE *bp, OPJ_UINT32 len);
95ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/**
96ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovDecode a symbol using raw-decoder. Cfr p.506 TAUBMAN
97ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov@param raw RAW handle
98ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov@return Returns the decoded symbol (0 or 1)
99ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov*/
100ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovOPJ_UINT32 opj_raw_decode(opj_raw_t *raw);
101ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/* ----------------------------------------------------------------------- */
102ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/*@}*/
103ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
104ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov/*@}*/
105ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
106ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif /* __RAW_H */
107