1c74663799493f2b1e6123c18def94295d0afab7Kenny Root/* libFLAC - Free Lossless Audio Codec library
2c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007  Josh Coalson
3c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
4c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Redistribution and use in source and binary forms, with or without
5c74663799493f2b1e6123c18def94295d0afab7Kenny Root * modification, are permitted provided that the following conditions
6c74663799493f2b1e6123c18def94295d0afab7Kenny Root * are met:
7c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
8c74663799493f2b1e6123c18def94295d0afab7Kenny Root * - Redistributions of source code must retain the above copyright
9c74663799493f2b1e6123c18def94295d0afab7Kenny Root * notice, this list of conditions and the following disclaimer.
10c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
11c74663799493f2b1e6123c18def94295d0afab7Kenny Root * - Redistributions in binary form must reproduce the above copyright
12c74663799493f2b1e6123c18def94295d0afab7Kenny Root * notice, this list of conditions and the following disclaimer in the
13c74663799493f2b1e6123c18def94295d0afab7Kenny Root * documentation and/or other materials provided with the distribution.
14c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
15c74663799493f2b1e6123c18def94295d0afab7Kenny Root * - Neither the name of the Xiph.org Foundation nor the names of its
16c74663799493f2b1e6123c18def94295d0afab7Kenny Root * contributors may be used to endorse or promote products derived from
17c74663799493f2b1e6123c18def94295d0afab7Kenny Root * this software without specific prior written permission.
18c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
19c74663799493f2b1e6123c18def94295d0afab7Kenny Root * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20c74663799493f2b1e6123c18def94295d0afab7Kenny Root * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21c74663799493f2b1e6123c18def94295d0afab7Kenny Root * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22c74663799493f2b1e6123c18def94295d0afab7Kenny Root * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
23c74663799493f2b1e6123c18def94295d0afab7Kenny Root * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24c74663799493f2b1e6123c18def94295d0afab7Kenny Root * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25c74663799493f2b1e6123c18def94295d0afab7Kenny Root * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26c74663799493f2b1e6123c18def94295d0afab7Kenny Root * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27c74663799493f2b1e6123c18def94295d0afab7Kenny Root * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28c74663799493f2b1e6123c18def94295d0afab7Kenny Root * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29c74663799493f2b1e6123c18def94295d0afab7Kenny Root * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
31c74663799493f2b1e6123c18def94295d0afab7Kenny Root
32c74663799493f2b1e6123c18def94295d0afab7Kenny Root#ifndef FLAC__PRIVATE__BITREADER_H
33c74663799493f2b1e6123c18def94295d0afab7Kenny Root#define FLAC__PRIVATE__BITREADER_H
34c74663799493f2b1e6123c18def94295d0afab7Kenny Root
35c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include <stdio.h> /* for FILE */
36c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include "FLAC/ordinals.h"
37c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include "cpu.h"
38c74663799493f2b1e6123c18def94295d0afab7Kenny Root
39c74663799493f2b1e6123c18def94295d0afab7Kenny Root/*
40c74663799493f2b1e6123c18def94295d0afab7Kenny Root * opaque structure definition
41c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
42c74663799493f2b1e6123c18def94295d0afab7Kenny Rootstruct FLAC__BitReader;
43c74663799493f2b1e6123c18def94295d0afab7Kenny Roottypedef struct FLAC__BitReader FLAC__BitReader;
44c74663799493f2b1e6123c18def94295d0afab7Kenny Root
45c74663799493f2b1e6123c18def94295d0afab7Kenny Roottypedef FLAC__bool (*FLAC__BitReaderReadCallback)(FLAC__byte buffer[], size_t *bytes, void *client_data);
46c74663799493f2b1e6123c18def94295d0afab7Kenny Root
47c74663799493f2b1e6123c18def94295d0afab7Kenny Root/*
48c74663799493f2b1e6123c18def94295d0afab7Kenny Root * construction, deletion, initialization, etc functions
49c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
50c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__BitReader *FLAC__bitreader_new(void);
51c74663799493f2b1e6123c18def94295d0afab7Kenny Rootvoid FLAC__bitreader_delete(FLAC__BitReader *br);
52c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_init(FLAC__BitReader *br, FLAC__CPUInfo cpu, FLAC__BitReaderReadCallback rcb, void *cd);
53c74663799493f2b1e6123c18def94295d0afab7Kenny Rootvoid FLAC__bitreader_free(FLAC__BitReader *br); /* does not 'free(br)' */
54c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_clear(FLAC__BitReader *br);
55c74663799493f2b1e6123c18def94295d0afab7Kenny Rootvoid FLAC__bitreader_dump(const FLAC__BitReader *br, FILE *out);
56c74663799493f2b1e6123c18def94295d0afab7Kenny Root
57c74663799493f2b1e6123c18def94295d0afab7Kenny Root/*
58c74663799493f2b1e6123c18def94295d0afab7Kenny Root * CRC functions
59c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
60c74663799493f2b1e6123c18def94295d0afab7Kenny Rootvoid FLAC__bitreader_reset_read_crc16(FLAC__BitReader *br, FLAC__uint16 seed);
61c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br);
62c74663799493f2b1e6123c18def94295d0afab7Kenny Root
63c74663799493f2b1e6123c18def94295d0afab7Kenny Root/*
64c74663799493f2b1e6123c18def94295d0afab7Kenny Root * info functions
65c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
66c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br);
67c74663799493f2b1e6123c18def94295d0afab7Kenny Rootunsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br);
68c74663799493f2b1e6123c18def94295d0afab7Kenny Rootunsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br);
69c74663799493f2b1e6123c18def94295d0afab7Kenny Root
70c74663799493f2b1e6123c18def94295d0afab7Kenny Root/*
71c74663799493f2b1e6123c18def94295d0afab7Kenny Root * read functions
72c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
73c74663799493f2b1e6123c18def94295d0afab7Kenny Root
74c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, unsigned bits);
75c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, unsigned bits);
76c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, unsigned bits);
77c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val); /*only for bits=32*/
78c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits); /* WATCHOUT: does not CRC the skipped data! */ /*@@@@ add to unit tests */
79c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, unsigned nvals); /* WATCHOUT: does not CRC the read data! */
80c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, unsigned nvals); /* WATCHOUT: does not CRC the read data! */
81c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *val);
82c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, unsigned parameter);
83c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter);
84c74663799493f2b1e6123c18def94295d0afab7Kenny Root#ifndef FLAC__NO_ASM
85c74663799493f2b1e6123c18def94295d0afab7Kenny Root#  ifdef FLAC__CPU_IA32
86c74663799493f2b1e6123c18def94295d0afab7Kenny Root#    ifdef FLAC__HAS_NASM
87c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_read_rice_signed_block_asm_ia32_bswap(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter);
88c74663799493f2b1e6123c18def94295d0afab7Kenny Root#    endif
89c74663799493f2b1e6123c18def94295d0afab7Kenny Root#  endif
90c74663799493f2b1e6123c18def94295d0afab7Kenny Root#endif
91c74663799493f2b1e6123c18def94295d0afab7Kenny Root#if 0 /* UNUSED */
92c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, unsigned parameter);
93c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, unsigned *val, unsigned parameter);
94c74663799493f2b1e6123c18def94295d0afab7Kenny Root#endif
95c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, unsigned *rawlen);
96c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, unsigned *rawlen);
97c74663799493f2b1e6123c18def94295d0afab7Kenny Root
98c74663799493f2b1e6123c18def94295d0afab7Kenny RootFLAC__bool bitreader_read_from_client_(FLAC__BitReader *br);
99c74663799493f2b1e6123c18def94295d0afab7Kenny Root#endif
100