Blame src/lib/openjp3d/bio.h

Packit caffb5
/*
Packit caffb5
 * The copyright in this software is being made available under the 2-clauses
Packit caffb5
 * BSD License, included below. This software may be subject to other third
Packit caffb5
 * party and contributor rights, including patent rights, and no such rights
Packit caffb5
 * are granted under this license.
Packit caffb5
 *
Packit caffb5
 * Copyright (c) 2001-2003, David Janssens
Packit caffb5
 * Copyright (c) 2002-2003, Yannick Verschueren
Packit caffb5
 * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
Packit caffb5
 * Copyright (c) 2005, Herve Drolon, FreeImage Team
Packit caffb5
 * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
Packit caffb5
 * All rights reserved.
Packit caffb5
 *
Packit caffb5
 * Redistribution and use in source and binary forms, with or without
Packit caffb5
 * modification, are permitted provided that the following conditions
Packit caffb5
 * are met:
Packit caffb5
 * 1. Redistributions of source code must retain the above copyright
Packit caffb5
 *    notice, this list of conditions and the following disclaimer.
Packit caffb5
 * 2. Redistributions in binary form must reproduce the above copyright
Packit caffb5
 *    notice, this list of conditions and the following disclaimer in the
Packit caffb5
 *    documentation and/or other materials provided with the distribution.
Packit caffb5
 *
Packit caffb5
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
Packit caffb5
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit caffb5
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit caffb5
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
Packit caffb5
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
Packit caffb5
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
Packit caffb5
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Packit caffb5
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Packit caffb5
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
Packit caffb5
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Packit caffb5
 * POSSIBILITY OF SUCH DAMAGE.
Packit caffb5
 */
Packit caffb5
Packit caffb5
#ifndef __BIO_H
Packit caffb5
#define __BIO_H
Packit caffb5
/**
Packit caffb5
@file bio.h
Packit caffb5
@brief Implementation of an individual bit input-output (BIO)
Packit caffb5
Packit caffb5
The functions in BIO.C have for goal to realize an individual bit input - output.
Packit caffb5
*/
Packit caffb5
Packit caffb5
/** @defgroup BIO BIO - Individual bit input-output stream */
Packit caffb5
/*@{*/
Packit caffb5
Packit caffb5
/**
Packit caffb5
Individual bit input-output stream (BIO)
Packit caffb5
*/
Packit caffb5
typedef struct opj_bio {
Packit caffb5
    /** pointer to the start of the buffer */
Packit caffb5
    unsigned char *start;
Packit caffb5
    /** pointer to the end of the buffer */
Packit caffb5
    unsigned char *end;
Packit caffb5
    /** pointer to the present position in the buffer */
Packit caffb5
    unsigned char *bp;
Packit caffb5
    /** temporary place where each byte is read or written */
Packit caffb5
    unsigned int buf;
Packit caffb5
    /** coder : number of bits free to write. decoder : number of bits read */
Packit caffb5
    int ct;
Packit caffb5
} opj_bio_t;
Packit caffb5
Packit caffb5
/** @name Funciones generales */
Packit caffb5
/*@{*/
Packit caffb5
/* ----------------------------------------------------------------------- */
Packit caffb5
/**
Packit caffb5
Create a new BIO handle
Packit caffb5
@return Returns a new BIO handle if successful, returns NULL otherwise
Packit caffb5
*/
Packit caffb5
opj_bio_t* bio_create(void);
Packit caffb5
/**
Packit caffb5
Destroy a previously created BIO handle
Packit caffb5
@param bio BIO handle to destroy
Packit caffb5
*/
Packit caffb5
void bio_destroy(opj_bio_t *bio);
Packit caffb5
/**
Packit caffb5
Number of bytes written.
Packit caffb5
@param bio BIO handle
Packit caffb5
@return Returns the number of bytes written
Packit caffb5
*/
Packit caffb5
int bio_numbytes(opj_bio_t *bio);
Packit caffb5
/**
Packit caffb5
Init encoder
Packit caffb5
@param bio BIO handle
Packit caffb5
@param bp Output buffer
Packit caffb5
@param len Output buffer length
Packit caffb5
*/
Packit caffb5
void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len);
Packit caffb5
/**
Packit caffb5
Init decoder
Packit caffb5
@param bio BIO handle
Packit caffb5
@param bp Input buffer
Packit caffb5
@param len Input buffer length
Packit caffb5
*/
Packit caffb5
void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len);
Packit caffb5
/**
Packit caffb5
Write bits
Packit caffb5
@param bio BIO handle
Packit caffb5
@param v Value of bits
Packit caffb5
@param n Number of bits to write
Packit caffb5
*/
Packit caffb5
void bio_write(opj_bio_t *bio, int v, int n);
Packit caffb5
/**
Packit caffb5
Read bits
Packit caffb5
@param bio BIO handle
Packit caffb5
@param n Number of bits to read
Packit caffb5
@return Returns the corresponding read number
Packit caffb5
*/
Packit caffb5
int bio_read(opj_bio_t *bio, int n);
Packit caffb5
/**
Packit caffb5
Flush bits
Packit caffb5
@param bio BIO handle
Packit caffb5
@return Returns 1 if successful, returns 0 otherwise
Packit caffb5
*/
Packit caffb5
int bio_flush(opj_bio_t *bio);
Packit caffb5
/**
Packit caffb5
Passes the ending bits (coming from flushing)
Packit caffb5
@param bio BIO handle
Packit caffb5
@return Returns 1 if successful, returns 0 otherwise
Packit caffb5
*/
Packit caffb5
int bio_inalign(opj_bio_t *bio);
Packit caffb5
/**
Packit caffb5
Read a bit
Packit caffb5
@param bio BIO handle
Packit caffb5
@return Returns the read bit
Packit caffb5
*/
Packit caffb5
/* MOD antonin */
Packit caffb5
/*int bio_getbit(opj_bio_t *bio);*/
Packit caffb5
/* DOM */
Packit caffb5
/* ----------------------------------------------------------------------- */
Packit caffb5
/*@}*/
Packit caffb5
Packit caffb5
/*@}*/
Packit caffb5
Packit caffb5
#endif /* __BIO_H */
Packit caffb5