| 1 | /* libFLAC - Free Lossless Audio Codec library |
| 2 | * Copyright (C) 2000-2009 Josh Coalson |
| 3 | * Copyright (C) 2011-2025 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 | //ppgb #ifdef HAVE_CONFIG_H |
| 34 | #include "flac_config.h"cxx . . $ `<file>/external/flac/flac_config.h`/ |
| 35 | //ppgb #endif |
| 36 | |
| 37 | #include <stdlib.h> |
| 38 | #include <string.h> |
| 39 | #include "flac_private_bitwriter.h"cxx . . $ `<file>/external/flac/flac_private_bitwriter.h`/ |
| 40 | #include "flac_private_crc.h"cxx . . $ `<file>/external/flac/flac_private_crc.h`/ |
| 41 | #include "flac_private_format.h"cxx . . $ `<file>/external/flac/flac_private_format.h`/ |
| 42 | #include "flac_private_macros.h"cxx . . $ `<file>/external/flac/flac_private_macros.h`/ |
| 43 | #include "flac_private_stream_encoder.h"cxx . . $ `<file>/external/flac/flac_private_stream_encoder.h`/ |
| 44 | #include "flac_FLAC_assert.h"cxx . . $ `<file>/external/flac/flac_FLAC_assert.h`/ |
| 45 | #include "flac_share_alloc.h"cxx . . $ `<file>/external/flac/flac_share_alloc.h`/ |
| 46 | #include "flac_share_compat.h"cxx . . $ `<file>/external/flac/flac_share_compat.h`/ |
| 47 | #include "flac_share_endswap.h"cxx . . $ `<file>/external/flac/flac_share_endswap.h`/ |
| 48 | |
| 49 | /* Things should be fastest when this matches the machine word size */ |
| 50 | /* WATCHOUT: if you change this you must also change the following #defines down to SWAP_BE_WORD_TO_HOST below to match */ |
| 51 | /* WATCHOUT: there are a few places where the code will not work unless bwword is >= 32 bits wide */ |
| 52 | |
| 53 | #if (ENABLE_64_BIT_WORDS == 0) |
| 54 | |
| 55 | typedef FLAC__uint32cxx . . $ FLAC__uint32# bwwordcxx . . $ bwword#; |
| 56 | typedef FLAC__uint64cxx . . $ FLAC__uint64# FLAC__bwtempcxx . . $ FLAC__bwtemp#; |
| 57 | #define FLAC__BYTES_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:57:9`! 4 /* sizeof bwword */ |
| 58 | #define FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`! 32 |
| 59 | #define FLAC__TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:59:9`! 64 |
| 60 | #define FLAC__HALF_TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:60:9`! 32 |
| 61 | /* SWAP_BE_WORD_TO_HOST swaps bytes in a bwword (which is always big-endian) if necessary to match host byte order */ |
| 62 | #if __BYTE_ORDER__cxx . . $ `<built-in>:48:9`! == __ORDER_BIG_ENDIAN__cxx . . $ `<built-in>:46:9`! |
| 63 | #define SWAP_BE_WORD_TO_HOST(x) (x) |
| 64 | #else |
| 65 | #define SWAP_BE_WORD_TO_HOSTcxx . . $ `external/flac/flac_bitwriter.c:65:9`!(x) ENDSWAP_32cxx . . $ `external/flac/flac_share_endswap.h:67:9`!(x) |
| 66 | #endif |
| 67 | |
| 68 | #else |
| 69 | |
| 70 | typedef FLAC__uint64 bwword; |
| 71 | typedef FLAC__uint64 FLAC__bwtemp; |
| 72 | #define FLAC__BYTES_PER_WORD 8 /* sizeof bwword */ |
| 73 | #define FLAC__BITS_PER_WORD 64 |
| 74 | #define FLAC__TEMP_BITS 64 |
| 75 | #define FLAC__HALF_TEMP_BITS 32 |
| 76 | /* SWAP_BE_WORD_TO_HOST swaps bytes in a bwword (which is always big-endian) if necessary to match host byte order */ |
| 77 | #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
| 78 | #define SWAP_BE_WORD_TO_HOST(x) (x) |
| 79 | #else |
| 80 | #define SWAP_BE_WORD_TO_HOST(x) ENDSWAP_64(x) |
| 81 | #endif |
| 82 | |
| 83 | #endif |
| 84 | |
| 85 | /* |
| 86 | * The default capacity here doesn't matter too much. The buffer always grows |
| 87 | * to hold whatever is written to it. Usually the encoder will stop adding at |
| 88 | * a frame or metadata block, then write that out and clear the buffer for the |
| 89 | * next one. |
| 90 | */ |
| 91 | static const uint32_tcxx . . $ uint32_t# FLAC__BITWRITER_DEFAULT_CAPACITYcxx . . $ FLAC__BITWRITER_DEFAULT_CAPACITY. = 32768u / sizeof(bwwordcxx . . $ bwword#); /* size in words */ |
| 92 | /* When growing, increment with 1/4th at a time */ |
| 93 | static const uint32_tcxx . . $ uint32_t# FLAC__BITWRITER_DEFAULT_GROW_FRACTIONcxx . . $ FLAC__BITWRITER_DEFAULT_GROW_FRACTION. = 2; /* means grow by >> 2 (1/4th) of current size */ |
| 94 | |
| 95 | #define FLAC__WORDS_TO_BITScxx . . $ `external/flac/flac_bitwriter.c:95:9`!(words) ((words) * FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`!) |
| 96 | #define FLAC__TOTAL_BITScxx . . $ `external/flac/flac_bitwriter.c:96:9`!(bw) (FLAC__WORDS_TO_BITScxx . . $ `external/flac/flac_bitwriter.c:95:9`!((bw)->words) + (bw)->bits) |
| 97 | |
| 98 | struct FLAC__BitWritercxx . . $ FLAC__BitWriter# { |
| 99 | bwwordcxx . . $ bwword# *buffercxx . . $ FLAC__BitWriter#buffer.; |
| 100 | bwwordcxx . . $ bwword# accumcxx . . $ FLAC__BitWriter#accum.; /* accumulator; bits are right-justified; when full, accum is appended to buffer */ |
| 101 | uint32_tcxx . . $ uint32_t# capacitycxx . . $ FLAC__BitWriter#capacity.; /* capacity of buffer in words */ |
| 102 | uint32_tcxx . . $ uint32_t# wordscxx . . $ FLAC__BitWriter#words.; /* # of complete words in buffer */ |
| 103 | uint32_tcxx . . $ uint32_t# bitscxx . . $ FLAC__BitWriter#bits.; /* # of used bits in accum */ |
| 104 | }; |
| 105 | |
| 106 | /* * WATCHOUT: The current implementation only grows the buffer. */ |
| 107 | #ifndef __SUNPRO_C |
| 108 | static |
| 109 | #endif |
| 110 | FLAC__boolcxx . . $ FLAC__bool# bitwriter_grow_cxx . . $ bitwriter_grow_(40f5a9d2c07215ed).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, uint32_tcxx . . $ uint32_t# bits_to_add) |
| 111 | { |
| 112 | uint32_tcxx . . $ uint32_t# new_capacity; |
| 113 | bwwordcxx . . $ bwword# *new_buffer; |
| 114 | |
| 115 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != bw); |
| 116 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != bw->buffer); |
| 117 | |
| 118 | /* calculate total words needed to store 'bits_to_add' additional bits */ |
| 119 | new_capacity = bw->wordscxx . . $ FLAC__BitWriter#words. + ((bw->bitscxx . . $ FLAC__BitWriter#bits. + bits_to_add + FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`! - 1) / FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`!); |
| 120 | |
| 121 | /* it's possible (due to pessimism in the growth estimation that |
| 122 | * leads to this call) that we don't actually need to grow |
| 123 | */ |
| 124 | if(bw->capacitycxx . . $ FLAC__BitWriter#capacity. >= new_capacity) |
| 125 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 126 | |
| 127 | if(new_capacity * sizeof(bwwordcxx . . $ bwword#) > (1u << FLAC__STREAM_METADATA_LENGTH_LENcxx . . $ FLAC__STREAM_METADATA_LENGTH_LEN.)) |
| 128 | /* Requested new capacity is larger than the largest possible metadata block, |
| 129 | * which is also larger than the largest sane framesize. That means something |
| 130 | * went very wrong somewhere and previous checks failed. |
| 131 | * To prevent chrashing, give up */ |
| 132 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 133 | |
| 134 | /* As reallocation can be quite expensive, grow exponentially */ |
| 135 | if((new_capacity - bw->capacitycxx . . $ FLAC__BitWriter#capacity.) < (bw->capacitycxx . . $ FLAC__BitWriter#capacity. >> FLAC__BITWRITER_DEFAULT_GROW_FRACTIONcxx . . $ FLAC__BITWRITER_DEFAULT_GROW_FRACTION.)) |
| 136 | new_capacity = bw->capacitycxx . . $ FLAC__BitWriter#capacity. + (bw->capacitycxx . . $ FLAC__BitWriter#capacity. >> FLAC__BITWRITER_DEFAULT_GROW_FRACTIONcxx . . $ FLAC__BITWRITER_DEFAULT_GROW_FRACTION.); |
| 137 | |
| 138 | /* make sure we got everything right */ |
| 139 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(new_capacity > bw->capacity); |
| 140 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(new_capacity >= bw->words + ((bw->bits + bits_to_add + FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`! - 1) / FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`!)); |
| 141 | |
| 142 | new_buffer = safe_realloc_nofree_mul_2op_cxx . . $ safe_realloc_nofree_mul_2op_(dfa4a9ebc9436eff).(bw->buffercxx . . $ FLAC__BitWriter#buffer., sizeof(bwwordcxx . . $ bwword#), /*times*/new_capacity); |
| 143 | if(new_buffer == 0) |
| 144 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 145 | bw->buffercxx . . $ FLAC__BitWriter#buffer. = new_buffer; |
| 146 | bw->capacitycxx . . $ FLAC__BitWriter#capacity. = new_capacity; |
| 147 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 148 | } |
| 149 | |
| 150 | |
| 151 | /*********************************************************************** |
| 152 | * |
| 153 | * Class constructor/destructor |
| 154 | * |
| 155 | ***********************************************************************/ |
| 156 | |
| 157 | FLAC__BitWritercxx . . $ FLAC__BitWriter# *FLAC__bitwriter_newcxx . . $ FLAC__bitwriter_new(33f3f35c0ce6697a).(void) |
| 158 | { |
| 159 | FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(FLAC__BitWritercxx . . $ FLAC__BitWriter#)); |
| 160 | /* note that calloc() sets all members to 0 for us */ |
| 161 | return bw; |
| 162 | } |
| 163 | |
| 164 | void FLAC__bitwriter_deletecxx . . $ FLAC__bitwriter_delete(3d16a9ed52dcdfb4).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw) |
| 165 | { |
| 166 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != bw); |
| 167 | |
| 168 | FLAC__bitwriter_freecxx . . $ FLAC__bitwriter_free(3d16a9ed52dcdfb4).(bw); |
| 169 | freecxx . . $ free(5d22bdacc48458e8).(bw); |
| 170 | } |
| 171 | |
| 172 | /*********************************************************************** |
| 173 | * |
| 174 | * Public class methods |
| 175 | * |
| 176 | ***********************************************************************/ |
| 177 | |
| 178 | FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_initcxx . . $ FLAC__bitwriter_init(e78cf1f479cd0e1c).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw) |
| 179 | { |
| 180 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != bw); |
| 181 | |
| 182 | bw->wordscxx . . $ FLAC__BitWriter#words. = bw->bitscxx . . $ FLAC__BitWriter#bits. = 0; |
| 183 | bw->capacitycxx . . $ FLAC__BitWriter#capacity. = FLAC__BITWRITER_DEFAULT_CAPACITYcxx . . $ FLAC__BITWRITER_DEFAULT_CAPACITY.; |
| 184 | bw->buffercxx . . $ FLAC__BitWriter#buffer. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(bwwordcxx . . $ bwword#) * bw->capacitycxx . . $ FLAC__BitWriter#capacity.); |
| 185 | if(bw->buffercxx . . $ FLAC__BitWriter#buffer. == 0) |
| 186 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 187 | |
| 188 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 189 | } |
| 190 | |
| 191 | void FLAC__bitwriter_freecxx . . $ FLAC__bitwriter_free(3d16a9ed52dcdfb4).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw) |
| 192 | { |
| 193 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != bw); |
| 194 | |
| 195 | if(0 != bw->buffercxx . . $ FLAC__BitWriter#buffer.) |
| 196 | freecxx . . $ free(5d22bdacc48458e8).(bw->buffercxx . . $ FLAC__BitWriter#buffer.); |
| 197 | bw->buffercxx . . $ FLAC__BitWriter#buffer. = 0; |
| 198 | bw->capacitycxx . . $ FLAC__BitWriter#capacity. = 0; |
| 199 | bw->wordscxx . . $ FLAC__BitWriter#words. = bw->bitscxx . . $ FLAC__BitWriter#bits. = 0; |
| 200 | } |
| 201 | |
| 202 | void FLAC__bitwriter_clearcxx . . $ FLAC__bitwriter_clear(3d16a9ed52dcdfb4).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw) |
| 203 | { |
| 204 | bw->wordscxx . . $ FLAC__BitWriter#words. = bw->bitscxx . . $ FLAC__BitWriter#bits. = 0; |
| 205 | } |
| 206 | |
| 207 | FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_get_write_crc16cxx . . $ FLAC__bitwriter_get_write_crc16(ee8826eb0429e7aa).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__uint16cxx . . $ FLAC__uint16# *crc) |
| 208 | { |
| 209 | const FLAC__bytecxx . . $ FLAC__byte# *buffer; |
| 210 | size_t bytes; |
| 211 | |
| 212 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!((bw->bits & 7) == 0); /* assert that we're byte-aligned */ |
| 213 | |
| 214 | if(!FLAC__bitwriter_get_buffercxx . . $ FLAC__bitwriter_get_buffer(3184c6b917e6cfb9).(bw, &buffer, &bytes)) |
| 215 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 216 | |
| 217 | *crc = (FLAC__uint16cxx . . $ FLAC__uint16#)FLAC__crc16cxx . . $ FLAC__crc16(40c2c8286b3b77b).(buffer, bytes); |
| 218 | FLAC__bitwriter_release_buffercxx . . $ FLAC__bitwriter_release_buffer(3d16a9ed52dcdfb4).(bw); |
| 219 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 220 | } |
| 221 | |
| 222 | FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_get_write_crc8cxx . . $ FLAC__bitwriter_get_write_crc8(8bb2cc255f5b18a6).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__bytecxx . . $ FLAC__byte# *crc) |
| 223 | { |
| 224 | const FLAC__bytecxx . . $ FLAC__byte# *buffer; |
| 225 | size_t bytes; |
| 226 | |
| 227 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!((bw->bits & 7) == 0); /* assert that we're byte-aligned */ |
| 228 | |
| 229 | if(!FLAC__bitwriter_get_buffercxx . . $ FLAC__bitwriter_get_buffer(3184c6b917e6cfb9).(bw, &buffer, &bytes)) |
| 230 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 231 | |
| 232 | *crc = FLAC__crc8cxx . . $ FLAC__crc8(c16a37015b73edb5).(buffer, bytes); |
| 233 | FLAC__bitwriter_release_buffercxx . . $ FLAC__bitwriter_release_buffer(3d16a9ed52dcdfb4).(bw); |
| 234 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 235 | } |
| 236 | |
| 237 | FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_is_byte_alignedcxx . . $ FLAC__bitwriter_is_byte_aligned(699ed0237db8a578).(const FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw) |
| 238 | { |
| 239 | return ((bw->bitscxx . . $ FLAC__BitWriter#bits. & 7) == 0); |
| 240 | } |
| 241 | |
| 242 | uint32_tcxx . . $ uint32_t# FLAC__bitwriter_get_input_bits_unconsumedcxx . . $ FLAC__bitwriter_get_input_bits_unconsumed(a85bce63af5da0e3).(const FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw) |
| 243 | { |
| 244 | return FLAC__TOTAL_BITScxx . . $ `external/flac/flac_bitwriter.c:96:9`!(bw); |
| 245 | } |
| 246 | |
| 247 | FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_get_buffercxx . . $ FLAC__bitwriter_get_buffer(3184c6b917e6cfb9).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, const FLAC__bytecxx . . $ FLAC__byte# **buffer, size_t *bytes) |
| 248 | { |
| 249 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!((bw->bits & 7) == 0); |
| 250 | /* double protection */ |
| 251 | if(bw->bitscxx . . $ FLAC__BitWriter#bits. & 7) |
| 252 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 253 | /* if we have bits in the accumulator we have to flush those to the buffer first */ |
| 254 | if(bw->bitscxx . . $ FLAC__BitWriter#bits.) { |
| 255 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(bw->words <= bw->capacity); |
| 256 | if(bw->wordscxx . . $ FLAC__BitWriter#words. == bw->capacitycxx . . $ FLAC__BitWriter#capacity. && !bitwriter_grow_cxx . . $ bitwriter_grow_(40f5a9d2c07215ed).(bw, FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`!)) |
| 257 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 258 | /* append bits as complete word to buffer, but don't change bw->accum or bw->bits */ |
| 259 | bw->buffercxx . . $ FLAC__BitWriter#buffer.[bw->wordscxx . . $ FLAC__BitWriter#words.] = SWAP_BE_WORD_TO_HOSTcxx . . $ `external/flac/flac_bitwriter.c:65:9`!(bw->accum << (FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`!-bw->bits)); |
| 260 | } |
| 261 | /* now we can just return what we have */ |
| 262 | *buffer = (FLAC__bytecxx . . $ FLAC__byte#*)bw->buffercxx . . $ FLAC__BitWriter#buffer.; |
| 263 | *bytes = (FLAC__BYTES_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:57:9`! * bw->wordscxx . . $ FLAC__BitWriter#words.) + (bw->bitscxx . . $ FLAC__BitWriter#bits. >> 3); |
| 264 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 265 | } |
| 266 | |
| 267 | void FLAC__bitwriter_release_buffercxx . . $ FLAC__bitwriter_release_buffer(3d16a9ed52dcdfb4).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw) |
| 268 | { |
| 269 | /* nothing to do. in the future, strict checking of a 'writer-is-in- |
| 270 | * get-mode' flag could be added everywhere and then cleared here |
| 271 | */ |
| 272 | (void)bw; |
| 273 | } |
| 274 | |
| 275 | inline FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_zeroescxx . . $ FLAC__bitwriter_write_zeroes(40f5a9d2c07215ed).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, uint32_tcxx . . $ uint32_t# bits) |
| 276 | { |
| 277 | uint32_tcxx . . $ uint32_t# n; |
| 278 | |
| 279 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != bw); |
| 280 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != bw->buffer); |
| 281 | |
| 282 | if(bits == 0) |
| 283 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 284 | /* slightly pessimistic size check but faster than "<= bw->words + (bw->bits+bits+FLAC__BITS_PER_WORD-1)/FLAC__BITS_PER_WORD" */ |
| 285 | if(bw->capacitycxx . . $ FLAC__BitWriter#capacity. <= bw->wordscxx . . $ FLAC__BitWriter#words. + bits && !bitwriter_grow_cxx . . $ bitwriter_grow_(40f5a9d2c07215ed).(bw, bits)) |
| 286 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 287 | /* first part gets to word alignment */ |
| 288 | if(bw->bitscxx . . $ FLAC__BitWriter#bits.) { |
| 289 | n = flac_mincxx . . $ `external/flac/flac_private_macros.h:67:9`!(FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`! - bw->bits, bits); |
| 290 | bw->accumcxx . . $ FLAC__BitWriter#accum. <<= n; |
| 291 | bits -= n; |
| 292 | bw->bitscxx . . $ FLAC__BitWriter#bits. += n; |
| 293 | if(bw->bitscxx . . $ FLAC__BitWriter#bits. == FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`!) { |
| 294 | bw->buffercxx . . $ FLAC__BitWriter#buffer.[bw->wordscxx . . $ FLAC__BitWriter#words.++] = SWAP_BE_WORD_TO_HOSTcxx . . $ `external/flac/flac_bitwriter.c:65:9`!(bw->accum); |
| 295 | bw->bitscxx . . $ FLAC__BitWriter#bits. = 0; |
| 296 | } |
| 297 | else |
| 298 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 299 | } |
| 300 | /* do whole words */ |
| 301 | while(bits >= FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`!) { |
| 302 | bw->buffercxx . . $ FLAC__BitWriter#buffer.[bw->wordscxx . . $ FLAC__BitWriter#words.++] = 0; |
| 303 | bits -= FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`!; |
| 304 | } |
| 305 | /* do any leftovers */ |
| 306 | if(bits > 0) { |
| 307 | bw->accumcxx . . $ FLAC__BitWriter#accum. = 0; |
| 308 | bw->bitscxx . . $ FLAC__BitWriter#bits. = bits; |
| 309 | } |
| 310 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 311 | } |
| 312 | |
| 313 | static inline FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__uint32cxx . . $ FLAC__uint32# val, uint32_tcxx . . $ uint32_t# bits) |
| 314 | { |
| 315 | register uint32_tcxx . . $ uint32_t# left; |
| 316 | |
| 317 | /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */ |
| 318 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`! >= 32); |
| 319 | |
| 320 | if(bw == 0 || bw->buffercxx . . $ FLAC__BitWriter#buffer. == 0) |
| 321 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 322 | |
| 323 | if (bits > 32) |
| 324 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 325 | |
| 326 | if(bits == 0) |
| 327 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 328 | |
| 329 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!((bits == 32) || (val>>bits == 0)); |
| 330 | |
| 331 | /* slightly pessimistic size check but faster than "<= bw->words + (bw->bits+bits+FLAC__BITS_PER_WORD-1)/FLAC__BITS_PER_WORD" */ |
| 332 | if(bw->capacitycxx . . $ FLAC__BitWriter#capacity. <= bw->wordscxx . . $ FLAC__BitWriter#words. + bits && !bitwriter_grow_cxx . . $ bitwriter_grow_(40f5a9d2c07215ed).(bw, bits)) |
| 333 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 334 | |
| 335 | left = FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`! - bw->bitscxx . . $ FLAC__BitWriter#bits.; |
| 336 | if(bits < left) { |
| 337 | bw->accumcxx . . $ FLAC__BitWriter#accum. <<= bits; |
| 338 | bw->accumcxx . . $ FLAC__BitWriter#accum. |= val; |
| 339 | bw->bitscxx . . $ FLAC__BitWriter#bits. += bits; |
| 340 | } |
| 341 | else if(bw->bitscxx . . $ FLAC__BitWriter#bits.) { /* WATCHOUT: if bw->bits == 0, left==FLAC__BITS_PER_WORD and bw->accum<<=left is a NOP instead of setting to 0 */ |
| 342 | bw->accumcxx . . $ FLAC__BitWriter#accum. <<= left; |
| 343 | bw->accumcxx . . $ FLAC__BitWriter#accum. |= val >> (bw->bitscxx . . $ FLAC__BitWriter#bits. = bits - left); |
| 344 | bw->buffercxx . . $ FLAC__BitWriter#buffer.[bw->wordscxx . . $ FLAC__BitWriter#words.++] = SWAP_BE_WORD_TO_HOSTcxx . . $ `external/flac/flac_bitwriter.c:65:9`!(bw->accum); |
| 345 | bw->accumcxx . . $ FLAC__BitWriter#accum. = val; /* unused top bits can contain garbage */ |
| 346 | } |
| 347 | else { /* at this point bits == FLAC__BITS_PER_WORD == 32 and bw->bits == 0 */ |
| 348 | bw->buffercxx . . $ FLAC__BitWriter#buffer.[bw->wordscxx . . $ FLAC__BitWriter#words.++] = SWAP_BE_WORD_TO_HOSTcxx . . $ `external/flac/flac_bitwriter.c:65:9`!((bwword)val); |
| 349 | } |
| 350 | |
| 351 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 352 | } |
| 353 | |
| 354 | inline FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_raw_uint32cxx . . $ FLAC__bitwriter_write_raw_uint32(33e8736f9674f0cb).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__uint32cxx . . $ FLAC__uint32# val, uint32_tcxx . . $ uint32_t# bits) |
| 355 | { |
| 356 | /* check that unused bits are unset */ |
| 357 | if((bits < 32) && (val>>bits != 0)) |
| 358 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 359 | |
| 360 | return FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, val, bits); |
| 361 | } |
| 362 | |
| 363 | inline FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_raw_int32cxx . . $ FLAC__bitwriter_write_raw_int32(5caf381933d64f7c).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__int32cxx . . $ FLAC__int32# val, uint32_tcxx . . $ uint32_t# bits) |
| 364 | { |
| 365 | /* zero-out unused bits */ |
| 366 | if(bits < 32) |
| 367 | val &= (~(0xffffffff << bits)); |
| 368 | |
| 369 | return FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, (FLAC__uint32cxx . . $ FLAC__uint32#)val, bits); |
| 370 | } |
| 371 | |
| 372 | inline FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_raw_uint64cxx . . $ FLAC__bitwriter_write_raw_uint64(977811ccf2c01f47).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__uint64cxx . . $ FLAC__uint64# val, uint32_tcxx . . $ uint32_t# bits) |
| 373 | { |
| 374 | /* this could be a little faster but it's not used for much */ |
| 375 | if(bits > 32) { |
| 376 | return |
| 377 | FLAC__bitwriter_write_raw_uint32cxx . . $ FLAC__bitwriter_write_raw_uint32(33e8736f9674f0cb).(bw, (FLAC__uint32cxx . . $ FLAC__uint32#)(val>>32), bits-32) && |
| 378 | FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, (FLAC__uint32cxx . . $ FLAC__uint32#)val, 32); |
| 379 | } |
| 380 | else |
| 381 | return FLAC__bitwriter_write_raw_uint32cxx . . $ FLAC__bitwriter_write_raw_uint32(33e8736f9674f0cb).(bw, (FLAC__uint32cxx . . $ FLAC__uint32#)val, bits); |
| 382 | } |
| 383 | |
| 384 | inline FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_raw_int64cxx . . $ FLAC__bitwriter_write_raw_int64(19e8c2443226c8fa).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__int64cxx . . $ FLAC__int64# val, uint32_tcxx . . $ uint32_t# bits) |
| 385 | { |
| 386 | FLAC__uint64cxx . . $ FLAC__uint64# uval = val; |
| 387 | /* zero-out unused bits */ |
| 388 | if(bits < 64) |
| 389 | uval &= (~(UINT64_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:119:10`! << bits)); |
| 390 | return FLAC__bitwriter_write_raw_uint64cxx . . $ FLAC__bitwriter_write_raw_uint64(977811ccf2c01f47).(bw, uval, bits); |
| 391 | } |
| 392 | |
| 393 | inline FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_raw_uint32_little_endiancxx . . $ FLAC__bitwriter_write_raw_uint32_little_endian(40f5a9d2c07215ed).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__uint32cxx . . $ FLAC__uint32# val) |
| 394 | { |
| 395 | /* this doesn't need to be that fast as currently it is only used for vorbis comments */ |
| 396 | |
| 397 | if(!FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, val & 0xff, 8)) |
| 398 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 399 | if(!FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, (val>>8) & 0xff, 8)) |
| 400 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 401 | if(!FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, (val>>16) & 0xff, 8)) |
| 402 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 403 | if(!FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, val>>24, 8)) |
| 404 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 405 | |
| 406 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 407 | } |
| 408 | |
| 409 | inline FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_byte_blockcxx . . $ FLAC__bitwriter_write_byte_block(1e830db26c8bfe86).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, const FLAC__bytecxx . . $ FLAC__byte# vals[], uint32_tcxx . . $ uint32_t# nvals) |
| 410 | { |
| 411 | uint32_tcxx . . $ uint32_t# i; |
| 412 | |
| 413 | /* grow capacity upfront to prevent constant reallocation during writes */ |
| 414 | if(bw->capacitycxx . . $ FLAC__BitWriter#capacity. <= bw->wordscxx . . $ FLAC__BitWriter#words. + nvals / (FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`! / 8) + 1 && !bitwriter_grow_cxx . . $ bitwriter_grow_(40f5a9d2c07215ed).(bw, nvals * 8)) |
| 415 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 416 | |
| 417 | /* this could be faster but currently we don't need it to be since it's only used for writing metadata */ |
| 418 | for(i = 0; i < nvals; i++) { |
| 419 | if(!FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, (FLAC__uint32cxx . . $ FLAC__uint32#)(vals[i]), 8)) |
| 420 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 421 | } |
| 422 | |
| 423 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 424 | } |
| 425 | |
| 426 | FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_unary_unsignedcxx . . $ FLAC__bitwriter_write_unary_unsigned(40f5a9d2c07215ed).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, uint32_tcxx . . $ uint32_t# val) |
| 427 | { |
| 428 | if(val < 32) |
| 429 | return FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 1, ++val); |
| 430 | else |
| 431 | return |
| 432 | FLAC__bitwriter_write_zeroescxx . . $ FLAC__bitwriter_write_zeroes(40f5a9d2c07215ed).(bw, val) && |
| 433 | FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 1, 1); |
| 434 | } |
| 435 | |
| 436 | #if 0 /* UNUSED */ |
| 437 | uint32_t FLAC__bitwriter_rice_bits(FLAC__int32 val, uint32_t parameter) |
| 438 | { |
| 439 | FLAC__uint32 uval; |
| 440 | |
| 441 | FLAC__ASSERT(parameter < 32); |
| 442 | |
| 443 | /* fold signed to uint32_t; actual formula is: negative(v)? -2v-1 : 2v */ |
| 444 | uval = val; |
| 445 | uval <<= 1; |
| 446 | uval ^= (val>>31); |
| 447 | |
| 448 | return 1 + parameter + (uval >> parameter); |
| 449 | } |
| 450 | |
| 451 | uint32_t FLAC__bitwriter_golomb_bits_signed(int val, uint32_t parameter) |
| 452 | { |
| 453 | uint32_t bits, msbs, uval; |
| 454 | uint32_t k; |
| 455 | |
| 456 | FLAC__ASSERT(parameter > 0); |
| 457 | |
| 458 | /* fold signed to uint32_t */ |
| 459 | if(val < 0) |
| 460 | uval = (uint32_t)(((-(++val)) << 1) + 1); |
| 461 | else |
| 462 | uval = (uint32_t)(val << 1); |
| 463 | |
| 464 | k = FLAC__bitmath_ilog2(parameter); |
| 465 | if(parameter == 1u<<k) { |
| 466 | FLAC__ASSERT(k <= 30); |
| 467 | |
| 468 | msbs = uval >> k; |
| 469 | bits = 1 + k + msbs; |
| 470 | } |
| 471 | else { |
| 472 | uint32_t q, r, d; |
| 473 | |
| 474 | d = (1 << (k+1)) - parameter; |
| 475 | q = uval / parameter; |
| 476 | r = uval - (q * parameter); |
| 477 | |
| 478 | bits = 1 + q + k; |
| 479 | if(r >= d) |
| 480 | bits++; |
| 481 | } |
| 482 | return bits; |
| 483 | } |
| 484 | |
| 485 | uint32_t FLAC__bitwriter_golomb_bits_unsigned(uint32_t uval, uint32_t parameter) |
| 486 | { |
| 487 | uint32_t bits, msbs; |
| 488 | uint32_t k; |
| 489 | |
| 490 | FLAC__ASSERT(parameter > 0); |
| 491 | |
| 492 | k = FLAC__bitmath_ilog2(parameter); |
| 493 | if(parameter == 1u<<k) { |
| 494 | FLAC__ASSERT(k <= 30); |
| 495 | |
| 496 | msbs = uval >> k; |
| 497 | bits = 1 + k + msbs; |
| 498 | } |
| 499 | else { |
| 500 | uint32_t q, r, d; |
| 501 | |
| 502 | d = (1 << (k+1)) - parameter; |
| 503 | q = uval / parameter; |
| 504 | r = uval - (q * parameter); |
| 505 | |
| 506 | bits = 1 + q + k; |
| 507 | if(r >= d) |
| 508 | bits++; |
| 509 | } |
| 510 | return bits; |
| 511 | } |
| 512 | |
| 513 | FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t parameter) |
| 514 | { |
| 515 | uint32_t total_bits, interesting_bits, msbs; |
| 516 | FLAC__uint32 uval, pattern; |
| 517 | |
| 518 | FLAC__ASSERT(0 != bw); |
| 519 | FLAC__ASSERT(0 != bw->buffer); |
| 520 | FLAC__ASSERT(parameter < 32); |
| 521 | |
| 522 | /* fold signed to uint32_t; actual formula is: negative(v)? -2v-1 : 2v */ |
| 523 | uval = val; |
| 524 | uval <<= 1; |
| 525 | uval ^= (val>>31); |
| 526 | |
| 527 | msbs = uval >> parameter; |
| 528 | interesting_bits = 1 + parameter; |
| 529 | total_bits = interesting_bits + msbs; |
| 530 | pattern = 1 << parameter; /* the unary end bit */ |
| 531 | pattern |= (uval & ((1<<parameter)-1)); /* the binary LSBs */ |
| 532 | |
| 533 | if(total_bits <= 32) |
| 534 | return FLAC__bitwriter_write_raw_uint32(bw, pattern, total_bits); |
| 535 | else |
| 536 | return |
| 537 | FLAC__bitwriter_write_zeroes(bw, msbs) && /* write the unary MSBs */ |
| 538 | FLAC__bitwriter_write_raw_uint32(bw, pattern, interesting_bits); /* write the unary end bit and binary LSBs */ |
| 539 | } |
| 540 | #endif /* UNUSED */ |
| 541 | |
| 542 | #if (ENABLE_64_BIT_WORDS == 0) |
| 543 | |
| 544 | #define WIDE_ACCUM_TO_BWcxx . . $ `external/flac/flac_bitwriter.c:544:9`! { \ |
| 545 | bw->accum = wide_accum >> FLAC__HALF_TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:60:9`!; \ |
| 546 | bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOSTcxx . . $ `external/flac/flac_bitwriter.c:65:9`!(bw->accum); \ |
| 547 | wide_accum <<= FLAC__HALF_TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:60:9`!; \ |
| 548 | bitpointer += FLAC__HALF_TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:60:9`!; \ |
| 549 | } |
| 550 | |
| 551 | #else |
| 552 | |
| 553 | #define WIDE_ACCUM_TO_BW { \ |
| 554 | FLAC__ASSERT(bw->bits % FLAC__HALF_TEMP_BITS == 0); \ |
| 555 | if(bw->bits == 0) { \ |
| 556 | bw->accum = wide_accum >> FLAC__HALF_TEMP_BITS; \ |
| 557 | wide_accum <<= FLAC__HALF_TEMP_BITS; \ |
| 558 | bw->bits = FLAC__HALF_TEMP_BITS; \ |
| 559 | } \ |
| 560 | else { \ |
| 561 | bw->accum <<= FLAC__HALF_TEMP_BITS; \ |
| 562 | bw->accum += wide_accum >> FLAC__HALF_TEMP_BITS; \ |
| 563 | bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(bw->accum); \ |
| 564 | wide_accum <<= FLAC__HALF_TEMP_BITS; \ |
| 565 | bw->bits = 0; \ |
| 566 | } \ |
| 567 | bitpointer += FLAC__HALF_TEMP_BITS; \ |
| 568 | } |
| 569 | |
| 570 | #endif |
| 571 | |
| 572 | FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_rice_signed_blockcxx . . $ FLAC__bitwriter_write_rice_signed_block(e3774ed2d39e4fe4).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, const FLAC__int32cxx . . $ FLAC__int32# *vals, uint32_tcxx . . $ uint32_t# nvals, uint32_tcxx . . $ uint32_t# parameter) |
| 573 | { |
| 574 | const FLAC__uint32cxx . . $ FLAC__uint32# mask1 = (FLAC__uint32cxx . . $ FLAC__uint32#)0xffffffff << parameter; /* we val|=mask1 to set the stop bit above it... */ |
| 575 | const FLAC__uint32cxx . . $ FLAC__uint32# mask2 = (FLAC__uint32cxx . . $ FLAC__uint32#)0xffffffff >> (31-parameter); /* ...then mask off the bits above the stop bit with val&=mask2 */ |
| 576 | FLAC__uint32cxx . . $ FLAC__uint32# uval; |
| 577 | const uint32_tcxx . . $ uint32_t# lsbits = 1 + parameter; |
| 578 | uint32_tcxx . . $ uint32_t# msbits, total_bits; |
| 579 | FLAC__bwtempcxx . . $ FLAC__bwtemp# wide_accum = 0; |
| 580 | FLAC__uint32cxx . . $ FLAC__uint32# bitpointer = FLAC__TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:59:9`!; |
| 581 | |
| 582 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != bw); |
| 583 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != bw->buffer); |
| 584 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(parameter < 31); |
| 585 | /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */ |
| 586 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`! >= 32); |
| 587 | #if (ENABLE_64_BIT_WORDS == 0) |
| 588 | if(bw->bitscxx . . $ FLAC__BitWriter#bits. > 0) { |
| 589 | bitpointer -= bw->bitscxx . . $ FLAC__BitWriter#bits.; |
| 590 | wide_accum = (FLAC__bwtempcxx . . $ FLAC__bwtemp#)(bw->accumcxx . . $ FLAC__BitWriter#accum.) << bitpointer; |
| 591 | bw->bitscxx . . $ FLAC__BitWriter#bits. = 0; |
| 592 | } |
| 593 | #else |
| 594 | if(bw->bits > 0 && bw->bits < FLAC__HALF_TEMP_BITS) { |
| 595 | bitpointer -= bw->bits; |
| 596 | wide_accum = bw->accum << bitpointer; |
| 597 | bw->bits = 0; |
| 598 | } |
| 599 | else if(bw->bits > FLAC__HALF_TEMP_BITS) { |
| 600 | bitpointer -= (bw->bits - FLAC__HALF_TEMP_BITS); |
| 601 | wide_accum = bw->accum << bitpointer; |
| 602 | bw->accum >>= (bw->bits - FLAC__HALF_TEMP_BITS); |
| 603 | bw->bits = FLAC__HALF_TEMP_BITS; |
| 604 | } |
| 605 | #endif |
| 606 | |
| 607 | /* Reserve one FLAC__TEMP_BITS per symbol, so checks for space are only necessary when very large symbols are encountered |
| 608 | * this might be considered wasteful, but is only at most 8kB more than necessary for a blocksize of 4096 */ |
| 609 | if(bw->capacitycxx . . $ FLAC__BitWriter#capacity. * FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`! <= bw->wordscxx . . $ FLAC__BitWriter#words. * FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`! + nvals * FLAC__TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:59:9`! + bw->bitscxx . . $ FLAC__BitWriter#bits. && !bitwriter_grow_cxx . . $ bitwriter_grow_(40f5a9d2c07215ed).(bw, nvals * FLAC__TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:59:9`!)) |
| 610 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 611 | |
| 612 | while(nvals) { |
| 613 | /* fold signed to uint32_t; actual formula is: negative(v)? -2v-1 : 2v */ |
| 614 | uval = *vals; |
| 615 | uval <<= 1; |
| 616 | uval ^= (*vals>>31); |
| 617 | |
| 618 | msbits = uval >> parameter; |
| 619 | total_bits = lsbits + msbits; |
| 620 | |
| 621 | uval |= mask1; /* set stop bit */ |
| 622 | uval &= mask2; /* mask off unused top bits */ |
| 623 | |
| 624 | |
| 625 | if(total_bits <= bitpointer) { |
| 626 | /* There is room enough to store the symbol whole at once */ |
| 627 | wide_accum |= (FLAC__bwtempcxx . . $ FLAC__bwtemp#)(uval) << (bitpointer - total_bits); |
| 628 | bitpointer -= total_bits; |
| 629 | if(bitpointer <= FLAC__HALF_TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:60:9`!) { |
| 630 | /* A word is finished, copy the upper 32 bits of the wide_accum */ |
| 631 | WIDE_ACCUM_TO_BWcxx . . $ `external/flac/flac_bitwriter.c:544:9`! |
| 632 | } |
| 633 | } |
| 634 | else { |
| 635 | /* The symbol needs to be split. This code isn't used often */ |
| 636 | /* First check for space in the bitwriter */ |
| 637 | if(total_bits > FLAC__TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:59:9`!) { |
| 638 | FLAC__uint32cxx . . $ FLAC__uint32# oversize_in_bits = total_bits - FLAC__TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:59:9`!; |
| 639 | FLAC__uint32cxx . . $ FLAC__uint32# capacity_needed = bw->wordscxx . . $ FLAC__BitWriter#words. * FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`! + bw->bitscxx . . $ FLAC__BitWriter#bits. + nvals * FLAC__TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:59:9`! + oversize_in_bits; |
| 640 | if(bw->capacitycxx . . $ FLAC__BitWriter#capacity. * FLAC__BITS_PER_WORDcxx . . $ `external/flac/flac_bitwriter.c:58:9`! <= capacity_needed && !bitwriter_grow_cxx . . $ bitwriter_grow_(40f5a9d2c07215ed).(bw, nvals * FLAC__TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:59:9`! + oversize_in_bits)) |
| 641 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 642 | } |
| 643 | if(msbits > bitpointer) { |
| 644 | /* We have a lot of 0 bits to write, first align with bitwriter word */ |
| 645 | msbits -= bitpointer - FLAC__HALF_TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:60:9`!; |
| 646 | bitpointer = FLAC__HALF_TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:60:9`!; |
| 647 | WIDE_ACCUM_TO_BWcxx . . $ `external/flac/flac_bitwriter.c:544:9`! |
| 648 | while(msbits > bitpointer) { |
| 649 | /* As the accumulator is already zero, we only need to |
| 650 | * assign zeroes to the bitbuffer */ |
| 651 | WIDE_ACCUM_TO_BWcxx . . $ `external/flac/flac_bitwriter.c:544:9`! |
| 652 | bitpointer -= FLAC__HALF_TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:60:9`!; |
| 653 | msbits -= FLAC__HALF_TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:60:9`!; |
| 654 | } |
| 655 | /* The remaining bits are zero, and the accumulator already is zero, |
| 656 | * so just subtract the number of bits from bitpointer. When storing, |
| 657 | * we can also just store 0 */ |
| 658 | bitpointer -= msbits; |
| 659 | if(bitpointer <= FLAC__HALF_TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:60:9`!) |
| 660 | WIDE_ACCUM_TO_BWcxx . . $ `external/flac/flac_bitwriter.c:544:9`! |
| 661 | } |
| 662 | else { |
| 663 | bitpointer -= msbits; |
| 664 | if(bitpointer <= FLAC__HALF_TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:60:9`!) |
| 665 | WIDE_ACCUM_TO_BWcxx . . $ `external/flac/flac_bitwriter.c:544:9`! |
| 666 | } |
| 667 | /* The lsbs + stop bit always fit 32 bit, so this code mirrors the code above */ |
| 668 | wide_accum |= (FLAC__bwtempcxx . . $ FLAC__bwtemp#)(uval) << (bitpointer - lsbits); |
| 669 | bitpointer -= lsbits; |
| 670 | if(bitpointer <= FLAC__HALF_TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:60:9`!) { |
| 671 | /* A word is finished, copy the upper 32 bits of the wide_accum */ |
| 672 | WIDE_ACCUM_TO_BWcxx . . $ `external/flac/flac_bitwriter.c:544:9`! |
| 673 | } |
| 674 | } |
| 675 | vals++; |
| 676 | nvals--; |
| 677 | } |
| 678 | /* Now fixup remainder of wide_accum */ |
| 679 | #if (ENABLE_64_BIT_WORDS == 0) |
| 680 | if(bitpointer < FLAC__TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:59:9`!) { |
| 681 | bw->accumcxx . . $ FLAC__BitWriter#accum. = wide_accum >> bitpointer; |
| 682 | bw->bitscxx . . $ FLAC__BitWriter#bits. = FLAC__TEMP_BITScxx . . $ `external/flac/flac_bitwriter.c:59:9`! - bitpointer; |
| 683 | } |
| 684 | #else |
| 685 | if(bitpointer < FLAC__TEMP_BITS) { |
| 686 | if(bw->bits == 0) { |
| 687 | bw->accum = wide_accum >> bitpointer; |
| 688 | bw->bits = FLAC__TEMP_BITS - bitpointer; |
| 689 | } |
| 690 | else if (bw->bits == FLAC__HALF_TEMP_BITS) { |
| 691 | bw->accum <<= FLAC__TEMP_BITS - bitpointer; |
| 692 | bw->accum |= (wide_accum >> bitpointer); |
| 693 | bw->bits = FLAC__HALF_TEMP_BITS + FLAC__TEMP_BITS - bitpointer; |
| 694 | } |
| 695 | else { |
| 696 | FLAC__ASSERT(0); |
| 697 | } |
| 698 | } |
| 699 | #endif |
| 700 | |
| 701 | |
| 702 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 703 | } |
| 704 | |
| 705 | #if 0 /* UNUSED */ |
| 706 | FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, uint32_t parameter) |
| 707 | { |
| 708 | uint32_t total_bits, msbs, uval; |
| 709 | uint32_t k; |
| 710 | |
| 711 | FLAC__ASSERT(0 != bw); |
| 712 | FLAC__ASSERT(0 != bw->buffer); |
| 713 | FLAC__ASSERT(parameter > 0); |
| 714 | |
| 715 | /* fold signed to uint32_t */ |
| 716 | if(val < 0) |
| 717 | uval = (uint32_t)(((-(++val)) << 1) + 1); |
| 718 | else |
| 719 | uval = (uint32_t)(val << 1); |
| 720 | |
| 721 | k = FLAC__bitmath_ilog2(parameter); |
| 722 | if(parameter == 1u<<k) { |
| 723 | uint32_t pattern; |
| 724 | |
| 725 | FLAC__ASSERT(k <= 30); |
| 726 | |
| 727 | msbs = uval >> k; |
| 728 | total_bits = 1 + k + msbs; |
| 729 | pattern = 1 << k; /* the unary end bit */ |
| 730 | pattern |= (uval & ((1u<<k)-1)); /* the binary LSBs */ |
| 731 | |
| 732 | if(total_bits <= 32) { |
| 733 | if(!FLAC__bitwriter_write_raw_uint32(bw, pattern, total_bits)) |
| 734 | return false; |
| 735 | } |
| 736 | else { |
| 737 | /* write the unary MSBs */ |
| 738 | if(!FLAC__bitwriter_write_zeroes(bw, msbs)) |
| 739 | return false; |
| 740 | /* write the unary end bit and binary LSBs */ |
| 741 | if(!FLAC__bitwriter_write_raw_uint32(bw, pattern, k+1)) |
| 742 | return false; |
| 743 | } |
| 744 | } |
| 745 | else { |
| 746 | uint32_t q, r, d; |
| 747 | |
| 748 | d = (1 << (k+1)) - parameter; |
| 749 | q = uval / parameter; |
| 750 | r = uval - (q * parameter); |
| 751 | /* write the unary MSBs */ |
| 752 | if(!FLAC__bitwriter_write_zeroes(bw, q)) |
| 753 | return false; |
| 754 | /* write the unary end bit */ |
| 755 | if(!FLAC__bitwriter_write_raw_uint32(bw, 1, 1)) |
| 756 | return false; |
| 757 | /* write the binary LSBs */ |
| 758 | if(r >= d) { |
| 759 | if(!FLAC__bitwriter_write_raw_uint32(bw, r+d, k+1)) |
| 760 | return false; |
| 761 | } |
| 762 | else { |
| 763 | if(!FLAC__bitwriter_write_raw_uint32(bw, r, k)) |
| 764 | return false; |
| 765 | } |
| 766 | } |
| 767 | return true; |
| 768 | } |
| 769 | |
| 770 | FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, uint32_t uval, uint32_t parameter) |
| 771 | { |
| 772 | uint32_t total_bits, msbs; |
| 773 | uint32_t k; |
| 774 | |
| 775 | FLAC__ASSERT(0 != bw); |
| 776 | FLAC__ASSERT(0 != bw->buffer); |
| 777 | FLAC__ASSERT(parameter > 0); |
| 778 | |
| 779 | k = FLAC__bitmath_ilog2(parameter); |
| 780 | if(parameter == 1u<<k) { |
| 781 | uint32_t pattern; |
| 782 | |
| 783 | FLAC__ASSERT(k <= 30); |
| 784 | |
| 785 | msbs = uval >> k; |
| 786 | total_bits = 1 + k + msbs; |
| 787 | pattern = 1 << k; /* the unary end bit */ |
| 788 | pattern |= (uval & ((1u<<k)-1)); /* the binary LSBs */ |
| 789 | |
| 790 | if(total_bits <= 32) { |
| 791 | if(!FLAC__bitwriter_write_raw_uint32(bw, pattern, total_bits)) |
| 792 | return false; |
| 793 | } |
| 794 | else { |
| 795 | /* write the unary MSBs */ |
| 796 | if(!FLAC__bitwriter_write_zeroes(bw, msbs)) |
| 797 | return false; |
| 798 | /* write the unary end bit and binary LSBs */ |
| 799 | if(!FLAC__bitwriter_write_raw_uint32(bw, pattern, k+1)) |
| 800 | return false; |
| 801 | } |
| 802 | } |
| 803 | else { |
| 804 | uint32_t q, r, d; |
| 805 | |
| 806 | d = (1 << (k+1)) - parameter; |
| 807 | q = uval / parameter; |
| 808 | r = uval - (q * parameter); |
| 809 | /* write the unary MSBs */ |
| 810 | if(!FLAC__bitwriter_write_zeroes(bw, q)) |
| 811 | return false; |
| 812 | /* write the unary end bit */ |
| 813 | if(!FLAC__bitwriter_write_raw_uint32(bw, 1, 1)) |
| 814 | return false; |
| 815 | /* write the binary LSBs */ |
| 816 | if(r >= d) { |
| 817 | if(!FLAC__bitwriter_write_raw_uint32(bw, r+d, k+1)) |
| 818 | return false; |
| 819 | } |
| 820 | else { |
| 821 | if(!FLAC__bitwriter_write_raw_uint32(bw, r, k)) |
| 822 | return false; |
| 823 | } |
| 824 | } |
| 825 | return true; |
| 826 | } |
| 827 | #endif /* UNUSED */ |
| 828 | |
| 829 | FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_utf8_uint32cxx . . $ FLAC__bitwriter_write_utf8_uint32(40f5a9d2c07215ed).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__uint32cxx . . $ FLAC__uint32# val) |
| 830 | { |
| 831 | FLAC__boolcxx . . $ FLAC__bool# ok = 1; |
| 832 | |
| 833 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != bw); |
| 834 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != bw->buffer); |
| 835 | |
| 836 | if((val & 0x80000000) != 0) /* this version only handles 31 bits */ |
| 837 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 838 | |
| 839 | if(val < 0x80) { |
| 840 | return FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, val, 8); |
| 841 | } |
| 842 | else if(val < 0x800) { |
| 843 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0xC0 | (val>>6), 8); |
| 844 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (val&0x3F), 8); |
| 845 | } |
| 846 | else if(val < 0x10000) { |
| 847 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0xE0 | (val>>12), 8); |
| 848 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | ((val>>6)&0x3F), 8); |
| 849 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (val&0x3F), 8); |
| 850 | } |
| 851 | else if(val < 0x200000) { |
| 852 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0xF0 | (val>>18), 8); |
| 853 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | ((val>>12)&0x3F), 8); |
| 854 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | ((val>>6)&0x3F), 8); |
| 855 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (val&0x3F), 8); |
| 856 | } |
| 857 | else if(val < 0x4000000) { |
| 858 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0xF8 | (val>>24), 8); |
| 859 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | ((val>>18)&0x3F), 8); |
| 860 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | ((val>>12)&0x3F), 8); |
| 861 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | ((val>>6)&0x3F), 8); |
| 862 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (val&0x3F), 8); |
| 863 | } |
| 864 | else { |
| 865 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0xFC | (val>>30), 8); |
| 866 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | ((val>>24)&0x3F), 8); |
| 867 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | ((val>>18)&0x3F), 8); |
| 868 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | ((val>>12)&0x3F), 8); |
| 869 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | ((val>>6)&0x3F), 8); |
| 870 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (val&0x3F), 8); |
| 871 | } |
| 872 | |
| 873 | return ok; |
| 874 | } |
| 875 | |
| 876 | FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_utf8_uint64cxx . . $ FLAC__bitwriter_write_utf8_uint64(ccc3c33ea6abe49f).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__uint64cxx . . $ FLAC__uint64# val) |
| 877 | { |
| 878 | FLAC__boolcxx . . $ FLAC__bool# ok = 1; |
| 879 | |
| 880 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != bw); |
| 881 | FLAC__ASSERTcxx . . $ `external/flac/flac_FLAC_assert.h:43:9`!(0 != bw->buffer); |
| 882 | |
| 883 | if((val & FLAC__U64Lcxx . . $ `external/flac/flac_share_compat.h:102:9`!(0xFFFFFFF000000000)) != 0) /* this version only handles 36 bits */ |
| 884 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 885 | |
| 886 | if(val < 0x80) { |
| 887 | return FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, (FLAC__uint32cxx . . $ FLAC__uint32#)val, 8); |
| 888 | } |
| 889 | else if(val < 0x800) { |
| 890 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0xC0 | (FLAC__uint32cxx . . $ FLAC__uint32#)(val>>6), 8); |
| 891 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)(val&0x3F), 8); |
| 892 | } |
| 893 | else if(val < 0x10000) { |
| 894 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0xE0 | (FLAC__uint32cxx . . $ FLAC__uint32#)(val>>12), 8); |
| 895 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>6)&0x3F), 8); |
| 896 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)(val&0x3F), 8); |
| 897 | } |
| 898 | else if(val < 0x200000) { |
| 899 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0xF0 | (FLAC__uint32cxx . . $ FLAC__uint32#)(val>>18), 8); |
| 900 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>12)&0x3F), 8); |
| 901 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>6)&0x3F), 8); |
| 902 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)(val&0x3F), 8); |
| 903 | } |
| 904 | else if(val < 0x4000000) { |
| 905 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0xF8 | (FLAC__uint32cxx . . $ FLAC__uint32#)(val>>24), 8); |
| 906 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>18)&0x3F), 8); |
| 907 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>12)&0x3F), 8); |
| 908 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>6)&0x3F), 8); |
| 909 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)(val&0x3F), 8); |
| 910 | } |
| 911 | else if(val < 0x80000000) { |
| 912 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0xFC | (FLAC__uint32cxx . . $ FLAC__uint32#)(val>>30), 8); |
| 913 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>24)&0x3F), 8); |
| 914 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>18)&0x3F), 8); |
| 915 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>12)&0x3F), 8); |
| 916 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>6)&0x3F), 8); |
| 917 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)(val&0x3F), 8); |
| 918 | } |
| 919 | else { |
| 920 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0xFE, 8); |
| 921 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>30)&0x3F), 8); |
| 922 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>24)&0x3F), 8); |
| 923 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>18)&0x3F), 8); |
| 924 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>12)&0x3F), 8); |
| 925 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)((val>>6)&0x3F), 8); |
| 926 | ok &= FLAC__bitwriter_write_raw_uint32_nocheckcxx . . $ FLAC__bitwriter_write_raw_uint32_nocheck(33e8736f9674f0cb).(bw, 0x80 | (FLAC__uint32cxx . . $ FLAC__uint32#)(val&0x3F), 8); |
| 927 | } |
| 928 | |
| 929 | return ok; |
| 930 | } |
| 931 | |
| 932 | FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_zero_pad_to_byte_boundarycxx . . $ FLAC__bitwriter_zero_pad_to_byte_boundary(e78cf1f479cd0e1c).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw) |
| 933 | { |
| 934 | /* 0-pad to byte boundary */ |
| 935 | if(bw->bitscxx . . $ FLAC__BitWriter#bits. & 7u) |
| 936 | return FLAC__bitwriter_write_zeroescxx . . $ FLAC__bitwriter_write_zeroes(40f5a9d2c07215ed).(bw, 8 - (bw->bitscxx . . $ FLAC__BitWriter#bits. & 7u)); |
| 937 | else |
| 938 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 939 | } |
| 940 | |
| 941 | /* These functions are declared inline in this file but are also callable as |
| 942 | * externs from elsewhere. |
| 943 | * According to the C99 spec, section 6.7.4, simply providing a function |
| 944 | * prototype in a header file without 'inline' and making the function inline |
| 945 | * in this file should be sufficient. |
| 946 | * Unfortunately, the Microsoft VS compiler doesn't pick them up externally. To |
| 947 | * fix that we add extern declarations here. |
| 948 | */ |
| 949 | extern FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_zeroescxx . . $ FLAC__bitwriter_write_zeroes(40f5a9d2c07215ed).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, uint32_tcxx . . $ uint32_t# bits); |
| 950 | extern FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_raw_uint32cxx . . $ FLAC__bitwriter_write_raw_uint32(33e8736f9674f0cb).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__uint32cxx . . $ FLAC__uint32# val, uint32_tcxx . . $ uint32_t# bits); |
| 951 | extern FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_raw_int32cxx . . $ FLAC__bitwriter_write_raw_int32(5caf381933d64f7c).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__int32cxx . . $ FLAC__int32# val, uint32_tcxx . . $ uint32_t# bits); |
| 952 | extern FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_raw_uint64cxx . . $ FLAC__bitwriter_write_raw_uint64(977811ccf2c01f47).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__uint64cxx . . $ FLAC__uint64# val, uint32_tcxx . . $ uint32_t# bits); |
| 953 | extern FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_raw_int64cxx . . $ FLAC__bitwriter_write_raw_int64(19e8c2443226c8fa).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__int64cxx . . $ FLAC__int64# val, uint32_tcxx . . $ uint32_t# bits); |
| 954 | extern FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_raw_uint32_little_endiancxx . . $ FLAC__bitwriter_write_raw_uint32_little_endian(40f5a9d2c07215ed).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, FLAC__uint32cxx . . $ FLAC__uint32# val); |
| 955 | extern FLAC__boolcxx . . $ FLAC__bool# FLAC__bitwriter_write_byte_blockcxx . . $ FLAC__bitwriter_write_byte_block(1e830db26c8bfe86).(FLAC__BitWritercxx . . $ FLAC__BitWriter# *bw, const FLAC__bytecxx . . $ FLAC__byte# vals[], uint32_tcxx . . $ uint32_t# nvals); |