HLE: Merge HLE BIOS improvements from upstream
[pcsx_rearmed.git] / deps / flac-1.3.2 / src / libFLAC / include / private / bitwriter.h
CommitLineData
ce188d4d 1/* libFLAC - Free Lossless Audio Codec library
2 * Copyright (C) 2000-2009 Josh Coalson
3 * Copyright (C) 2011-2016 Xiph.Org Foundation
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * - Neither the name of the Xiph.org Foundation nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef FLAC__PRIVATE__BITWRITER_H
34#define FLAC__PRIVATE__BITWRITER_H
35
36#include <stdio.h> /* for FILE */
37#include "FLAC/ordinals.h"
38
39/*
40 * opaque structure definition
41 */
42struct FLAC__BitWriter;
43typedef struct FLAC__BitWriter FLAC__BitWriter;
44
45/*
46 * construction, deletion, initialization, etc functions
47 */
48FLAC__BitWriter *FLAC__bitwriter_new(void);
49void FLAC__bitwriter_delete(FLAC__BitWriter *bw);
50FLAC__bool FLAC__bitwriter_init(FLAC__BitWriter *bw);
51void FLAC__bitwriter_free(FLAC__BitWriter *bw); /* does not 'free(buffer)' */
52void FLAC__bitwriter_clear(FLAC__BitWriter *bw);
53void FLAC__bitwriter_dump(const FLAC__BitWriter *bw, FILE *out);
54
55/*
56 * CRC functions
57 *
58 * non-const *bw because they have to cal FLAC__bitwriter_get_buffer()
59 */
60FLAC__bool FLAC__bitwriter_get_write_crc16(FLAC__BitWriter *bw, FLAC__uint16 *crc);
61FLAC__bool FLAC__bitwriter_get_write_crc8(FLAC__BitWriter *bw, FLAC__byte *crc);
62
63/*
64 * info functions
65 */
66FLAC__bool FLAC__bitwriter_is_byte_aligned(const FLAC__BitWriter *bw);
67unsigned FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw); /* can be called anytime, returns total # of bits unconsumed */
68
69/*
70 * direct buffer access
71 *
72 * there may be no calls on the bitwriter between get and release.
73 * the bitwriter continues to own the returned buffer.
74 * before get, bitwriter MUST be byte aligned: check with FLAC__bitwriter_is_byte_aligned()
75 */
76FLAC__bool FLAC__bitwriter_get_buffer(FLAC__BitWriter *bw, const FLAC__byte **buffer, size_t *bytes);
77void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw);
78
79/*
80 * write functions
81 */
82FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bits);
83FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, unsigned bits);
84FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, unsigned bits);
85FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, unsigned bits);
86FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val); /*only for bits=32*/
87FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], unsigned nvals);
88FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, unsigned val);
89unsigned FLAC__bitwriter_rice_bits(FLAC__int32 val, unsigned parameter);
90#if 0 /* UNUSED */
91unsigned FLAC__bitwriter_golomb_bits_signed(int val, unsigned parameter);
92unsigned FLAC__bitwriter_golomb_bits_unsigned(unsigned val, unsigned parameter);
93#endif
94FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, unsigned parameter);
95FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, unsigned nvals, unsigned parameter);
96#if 0 /* UNUSED */
97FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, unsigned parameter);
98FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, unsigned val, unsigned parameter);
99#endif
100FLAC__bool FLAC__bitwriter_write_utf8_uint32(FLAC__BitWriter *bw, FLAC__uint32 val);
101FLAC__bool FLAC__bitwriter_write_utf8_uint64(FLAC__BitWriter *bw, FLAC__uint64 val);
102FLAC__bool FLAC__bitwriter_zero_pad_to_byte_boundary(FLAC__BitWriter *bw);
103
104#endif