2 * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
\r
3 * Copyright (c) 2005, Hervé Drolon, FreeImage Team
\r
4 * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
\r
5 * All rights reserved.
\r
7 * Redistribution and use in source and binary forms, with or without
\r
8 * modification, are permitted provided that the following conditions
\r
10 * 1. Redistributions of source code must retain the above copyright
\r
11 * notice, this list of conditions and the following disclaimer.
\r
12 * 2. Redistributions in binary form must reproduce the above copyright
\r
13 * notice, this list of conditions and the following disclaimer in the
\r
14 * documentation and/or other materials provided with the distribution.
\r
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
\r
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
\r
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
\r
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
\r
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
\r
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
\r
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
26 * POSSIBILITY OF SUCH DAMAGE.
\r
29 #include "opj_includes.h"
\r
32 ==========================================================
\r
34 ==========================================================
\r
39 ==========================================================
\r
40 RAW encoding interface
\r
41 ==========================================================
\r
44 opj_raw_t* raw_create() {
\r
45 opj_raw_t *raw = (opj_raw_t*)opj_malloc(sizeof(opj_raw_t));
\r
49 void raw_destroy(opj_raw_t *raw) {
\r
55 int raw_numbytes(opj_raw_t *raw) {
\r
56 return raw->bp - raw->start;
\r
59 void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len) {
\r
67 int raw_decode(opj_raw_t *raw) {
\r
71 if (raw->len == raw->lenmax) {
\r
74 if (raw->c == 0xff) {
\r
77 raw->c = *(raw->start + raw->len);
\r
82 d = (raw->c >> raw->ct) & 0x01;
\r