remove an .orig file
authorOzkan Sezer <sezeroz@gmail.com>
Sun, 17 Nov 2019 01:10:02 +0300
changeset 9724e24cc4bcf1e
parent 971 6ba23d9d5409
child 973 e5b4ff96668b
remove an .orig file
external/flac-1.3.3/src/libFLAC/format.c.orig
     1.1 --- a/external/flac-1.3.3/src/libFLAC/format.c.orig	Thu Nov 14 10:11:02 2019 +0300
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,589 +0,0 @@
     1.4 -/* libFLAC - Free Lossless Audio Codec library
     1.5 - * Copyright (C) 2000-2009  Josh Coalson
     1.6 - * Copyright (C) 2011-2016  Xiph.Org Foundation
     1.7 - *
     1.8 - * Redistribution and use in source and binary forms, with or without
     1.9 - * modification, are permitted provided that the following conditions
    1.10 - * are met:
    1.11 - *
    1.12 - * - Redistributions of source code must retain the above copyright
    1.13 - * notice, this list of conditions and the following disclaimer.
    1.14 - *
    1.15 - * - Redistributions in binary form must reproduce the above copyright
    1.16 - * notice, this list of conditions and the following disclaimer in the
    1.17 - * documentation and/or other materials provided with the distribution.
    1.18 - *
    1.19 - * - Neither the name of the Xiph.org Foundation nor the names of its
    1.20 - * contributors may be used to endorse or promote products derived from
    1.21 - * this software without specific prior written permission.
    1.22 - *
    1.23 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.24 - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    1.25 - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.26 - * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
    1.27 - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    1.28 - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    1.29 - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    1.30 - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    1.31 - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    1.32 - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    1.33 - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.34 - */
    1.35 -
    1.36 -#ifdef HAVE_CONFIG_H
    1.37 -#  include <config.h>
    1.38 -#endif
    1.39 -
    1.40 -#include <stdio.h>
    1.41 -#include <stdlib.h> /* for qsort() */
    1.42 -#include <string.h> /* for memset() */
    1.43 -#include "FLAC/assert.h"
    1.44 -#include "FLAC/format.h"
    1.45 -#include "share/alloc.h"
    1.46 -#include "share/compat.h"
    1.47 -#include "private/format.h"
    1.48 -#include "private/macros.h"
    1.49 -
    1.50 -/* PACKAGE_VERSION should come from configure */
    1.51 -FLAC_API const char *FLAC__VERSION_STRING = PACKAGE_VERSION;
    1.52 -
    1.53 -FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " PACKAGE_VERSION " 20190804";
    1.54 -
    1.55 -FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' };
    1.56 -FLAC_API const uint32_t FLAC__STREAM_SYNC = 0x664C6143;
    1.57 -FLAC_API const uint32_t FLAC__STREAM_SYNC_LEN = 32; /* bits */
    1.58 -
    1.59 -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN = 16; /* bits */
    1.60 -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN = 16; /* bits */
    1.61 -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN = 24; /* bits */
    1.62 -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN = 24; /* bits */
    1.63 -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN = 20; /* bits */
    1.64 -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN = 3; /* bits */
    1.65 -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN = 5; /* bits */
    1.66 -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN = 36; /* bits */
    1.67 -FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN = 128; /* bits */
    1.68 -
    1.69 -FLAC_API const uint32_t FLAC__STREAM_METADATA_APPLICATION_ID_LEN = 32; /* bits */
    1.70 -
    1.71 -FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN = 64; /* bits */
    1.72 -FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN = 64; /* bits */
    1.73 -FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN = 16; /* bits */
    1.74 -
    1.75 -FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER = FLAC__U64L(0xffffffffffffffff);
    1.76 -
    1.77 -FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN = 32; /* bits */
    1.78 -FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN = 32; /* bits */
    1.79 -
    1.80 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN = 64; /* bits */
    1.81 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN = 8; /* bits */
    1.82 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN = 3*8; /* bits */
    1.83 -
    1.84 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN = 64; /* bits */
    1.85 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN = 8; /* bits */
    1.86 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN = 12*8; /* bits */
    1.87 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN = 1; /* bit */
    1.88 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN = 1; /* bit */
    1.89 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN = 6+13*8; /* bits */
    1.90 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN = 8; /* bits */
    1.91 -
    1.92 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN = 128*8; /* bits */
    1.93 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN = 64; /* bits */
    1.94 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN = 1; /* bit */
    1.95 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN = 7+258*8; /* bits */
    1.96 -FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN = 8; /* bits */
    1.97 -
    1.98 -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_TYPE_LEN = 32; /* bits */
    1.99 -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN = 32; /* bits */
   1.100 -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN = 32; /* bits */
   1.101 -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN = 32; /* bits */
   1.102 -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN = 32; /* bits */
   1.103 -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN = 32; /* bits */
   1.104 -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_COLORS_LEN = 32; /* bits */
   1.105 -FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN = 32; /* bits */
   1.106 -
   1.107 -FLAC_API const uint32_t FLAC__STREAM_METADATA_IS_LAST_LEN = 1; /* bits */
   1.108 -FLAC_API const uint32_t FLAC__STREAM_METADATA_TYPE_LEN = 7; /* bits */
   1.109 -FLAC_API const uint32_t FLAC__STREAM_METADATA_LENGTH_LEN = 24; /* bits */
   1.110 -
   1.111 -FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC = 0x3ffe;
   1.112 -FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC_LEN = 14; /* bits */
   1.113 -FLAC_API const uint32_t FLAC__FRAME_HEADER_RESERVED_LEN = 1; /* bits */
   1.114 -FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN = 1; /* bits */
   1.115 -FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCK_SIZE_LEN = 4; /* bits */
   1.116 -FLAC_API const uint32_t FLAC__FRAME_HEADER_SAMPLE_RATE_LEN = 4; /* bits */
   1.117 -FLAC_API const uint32_t FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN = 4; /* bits */
   1.118 -FLAC_API const uint32_t FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN = 3; /* bits */
   1.119 -FLAC_API const uint32_t FLAC__FRAME_HEADER_ZERO_PAD_LEN = 1; /* bits */
   1.120 -FLAC_API const uint32_t FLAC__FRAME_HEADER_CRC_LEN = 8; /* bits */
   1.121 -
   1.122 -FLAC_API const uint32_t FLAC__FRAME_FOOTER_CRC_LEN = 16; /* bits */
   1.123 -
   1.124 -FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_TYPE_LEN = 2; /* bits */
   1.125 -FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN = 4; /* bits */
   1.126 -FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN = 4; /* bits */
   1.127 -FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN = 5; /* bits */
   1.128 -FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN = 5; /* bits */
   1.129 -
   1.130 -FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER = 15; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */
   1.131 -FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER = 31; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */
   1.132 -
   1.133 -FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[] = {
   1.134 -	"PARTITIONED_RICE",
   1.135 -	"PARTITIONED_RICE2"
   1.136 -};
   1.137 -
   1.138 -FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN = 4; /* bits */
   1.139 -FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN = 5; /* bits */
   1.140 -
   1.141 -FLAC_API const uint32_t FLAC__SUBFRAME_ZERO_PAD_LEN = 1; /* bits */
   1.142 -FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LEN = 6; /* bits */
   1.143 -FLAC_API const uint32_t FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN = 1; /* bits */
   1.144 -
   1.145 -FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK = 0x00;
   1.146 -FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK = 0x02;
   1.147 -FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK = 0x10;
   1.148 -FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK = 0x40;
   1.149 -
   1.150 -FLAC_API const char * const FLAC__SubframeTypeString[] = {
   1.151 -	"CONSTANT",
   1.152 -	"VERBATIM",
   1.153 -	"FIXED",
   1.154 -	"LPC"
   1.155 -};
   1.156 -
   1.157 -FLAC_API const char * const FLAC__ChannelAssignmentString[] = {
   1.158 -	"INDEPENDENT",
   1.159 -	"LEFT_SIDE",
   1.160 -	"RIGHT_SIDE",
   1.161 -	"MID_SIDE"
   1.162 -};
   1.163 -
   1.164 -FLAC_API const char * const FLAC__FrameNumberTypeString[] = {
   1.165 -	"FRAME_NUMBER_TYPE_FRAME_NUMBER",
   1.166 -	"FRAME_NUMBER_TYPE_SAMPLE_NUMBER"
   1.167 -};
   1.168 -
   1.169 -FLAC_API const char * const FLAC__MetadataTypeString[] = {
   1.170 -	"STREAMINFO",
   1.171 -	"PADDING",
   1.172 -	"APPLICATION",
   1.173 -	"SEEKTABLE",
   1.174 -	"VORBIS_COMMENT",
   1.175 -	"CUESHEET",
   1.176 -	"PICTURE"
   1.177 -};
   1.178 -
   1.179 -FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[] = {
   1.180 -	"Other",
   1.181 -	"32x32 pixels 'file icon' (PNG only)",
   1.182 -	"Other file icon",
   1.183 -	"Cover (front)",
   1.184 -	"Cover (back)",
   1.185 -	"Leaflet page",
   1.186 -	"Media (e.g. label side of CD)",
   1.187 -	"Lead artist/lead performer/soloist",
   1.188 -	"Artist/performer",
   1.189 -	"Conductor",
   1.190 -	"Band/Orchestra",
   1.191 -	"Composer",
   1.192 -	"Lyricist/text writer",
   1.193 -	"Recording Location",
   1.194 -	"During recording",
   1.195 -	"During performance",
   1.196 -	"Movie/video screen capture",
   1.197 -	"A bright coloured fish",
   1.198 -	"Illustration",
   1.199 -	"Band/artist logotype",
   1.200 -	"Publisher/Studio logotype"
   1.201 -};
   1.202 -
   1.203 -FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(uint32_t sample_rate)
   1.204 -{
   1.205 -	if(sample_rate == 0 || sample_rate > FLAC__MAX_SAMPLE_RATE) {
   1.206 -		return false;
   1.207 -	}
   1.208 -	else
   1.209 -		return true;
   1.210 -}
   1.211 -
   1.212 -FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(uint32_t blocksize, uint32_t sample_rate)
   1.213 -{
   1.214 -	if(blocksize > 16384)
   1.215 -		return false;
   1.216 -	else if(sample_rate <= 48000 && blocksize > 4608)
   1.217 -		return false;
   1.218 -	else
   1.219 -		return true;
   1.220 -}
   1.221 -
   1.222 -FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(uint32_t sample_rate)
   1.223 -{
   1.224 -	if(
   1.225 -		!FLAC__format_sample_rate_is_valid(sample_rate) ||
   1.226 -		(
   1.227 -			sample_rate >= (1u << 16) &&
   1.228 -			!(sample_rate % 1000 == 0 || sample_rate % 10 == 0)
   1.229 -		)
   1.230 -	) {
   1.231 -		return false;
   1.232 -	}
   1.233 -	else
   1.234 -		return true;
   1.235 -}
   1.236 -
   1.237 -/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
   1.238 -FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table)
   1.239 -{
   1.240 -	uint32_t i;
   1.241 -	FLAC__uint64 prev_sample_number = 0;
   1.242 -	FLAC__bool got_prev = false;
   1.243 -
   1.244 -	FLAC__ASSERT(0 != seek_table);
   1.245 -
   1.246 -	for(i = 0; i < seek_table->num_points; i++) {
   1.247 -		if(got_prev) {
   1.248 -			if(
   1.249 -				seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER &&
   1.250 -				seek_table->points[i].sample_number <= prev_sample_number
   1.251 -			)
   1.252 -				return false;
   1.253 -		}
   1.254 -		prev_sample_number = seek_table->points[i].sample_number;
   1.255 -		got_prev = true;
   1.256 -	}
   1.257 -
   1.258 -	return true;
   1.259 -}
   1.260 -
   1.261 -/* used as the sort predicate for qsort() */
   1.262 -static int seekpoint_compare_(const FLAC__StreamMetadata_SeekPoint *l, const FLAC__StreamMetadata_SeekPoint *r)
   1.263 -{
   1.264 -	/* we don't just 'return l->sample_number - r->sample_number' since the result (FLAC__int64) might overflow an 'int' */
   1.265 -	if(l->sample_number == r->sample_number)
   1.266 -		return 0;
   1.267 -	else if(l->sample_number < r->sample_number)
   1.268 -		return -1;
   1.269 -	else
   1.270 -		return 1;
   1.271 -}
   1.272 -
   1.273 -/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
   1.274 -FLAC_API uint32_t FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table)
   1.275 -{
   1.276 -	uint32_t i, j;
   1.277 -	FLAC__bool first;
   1.278 -
   1.279 -	FLAC__ASSERT(0 != seek_table);
   1.280 -
   1.281 -	if (seek_table->num_points == 0)
   1.282 -		return 0;
   1.283 -
   1.284 -	/* sort the seekpoints */
   1.285 -	qsort(seek_table->points, seek_table->num_points, sizeof(FLAC__StreamMetadata_SeekPoint), (int (*)(const void *, const void *))seekpoint_compare_);
   1.286 -
   1.287 -	/* uniquify the seekpoints */
   1.288 -	first = true;
   1.289 -	for(i = j = 0; i < seek_table->num_points; i++) {
   1.290 -		if(seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) {
   1.291 -			if(!first) {
   1.292 -				if(seek_table->points[i].sample_number == seek_table->points[j-1].sample_number)
   1.293 -					continue;
   1.294 -			}
   1.295 -		}
   1.296 -		first = false;
   1.297 -		seek_table->points[j++] = seek_table->points[i];
   1.298 -	}
   1.299 -
   1.300 -	for(i = j; i < seek_table->num_points; i++) {
   1.301 -		seek_table->points[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
   1.302 -		seek_table->points[i].stream_offset = 0;
   1.303 -		seek_table->points[i].frame_samples = 0;
   1.304 -	}
   1.305 -
   1.306 -	return j;
   1.307 -}
   1.308 -
   1.309 -/*
   1.310 - * also disallows non-shortest-form encodings, c.f.
   1.311 - *   http://www.unicode.org/versions/corrigendum1.html
   1.312 - * and a more clear explanation at the end of this section:
   1.313 - *   http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
   1.314 - */
   1.315 -static uint32_t utf8len_(const FLAC__byte *utf8)
   1.316 -{
   1.317 -	FLAC__ASSERT(0 != utf8);
   1.318 -	if ((utf8[0] & 0x80) == 0) {
   1.319 -		return 1;
   1.320 -	}
   1.321 -	else if ((utf8[0] & 0xE0) == 0xC0 && (utf8[1] & 0xC0) == 0x80) {
   1.322 -		if ((utf8[0] & 0xFE) == 0xC0) /* overlong sequence check */
   1.323 -			return 0;
   1.324 -		return 2;
   1.325 -	}
   1.326 -	else if ((utf8[0] & 0xF0) == 0xE0 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80) {
   1.327 -		if (utf8[0] == 0xE0 && (utf8[1] & 0xE0) == 0x80) /* overlong sequence check */
   1.328 -			return 0;
   1.329 -		/* illegal surrogates check (U+D800...U+DFFF and U+FFFE...U+FFFF) */
   1.330 -		if (utf8[0] == 0xED && (utf8[1] & 0xE0) == 0xA0) /* D800-DFFF */
   1.331 -			return 0;
   1.332 -		if (utf8[0] == 0xEF && utf8[1] == 0xBF && (utf8[2] & 0xFE) == 0xBE) /* FFFE-FFFF */
   1.333 -			return 0;
   1.334 -		return 3;
   1.335 -	}
   1.336 -	else if ((utf8[0] & 0xF8) == 0xF0 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80) {
   1.337 -		if (utf8[0] == 0xF0 && (utf8[1] & 0xF0) == 0x80) /* overlong sequence check */
   1.338 -			return 0;
   1.339 -		return 4;
   1.340 -	}
   1.341 -	else if ((utf8[0] & 0xFC) == 0xF8 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80 && (utf8[4] & 0xC0) == 0x80) {
   1.342 -		if (utf8[0] == 0xF8 && (utf8[1] & 0xF8) == 0x80) /* overlong sequence check */
   1.343 -			return 0;
   1.344 -		return 5;
   1.345 -	}
   1.346 -	else if ((utf8[0] & 0xFE) == 0xFC && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80 && (utf8[4] & 0xC0) == 0x80 && (utf8[5] & 0xC0) == 0x80) {
   1.347 -		if (utf8[0] == 0xFC && (utf8[1] & 0xFC) == 0x80) /* overlong sequence check */
   1.348 -			return 0;
   1.349 -		return 6;
   1.350 -	}
   1.351 -	else {
   1.352 -		return 0;
   1.353 -	}
   1.354 -}
   1.355 -
   1.356 -FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name)
   1.357 -{
   1.358 -	char c;
   1.359 -	for(c = *name; c; c = *(++name))
   1.360 -		if(c < 0x20 || c == 0x3d || c > 0x7d)
   1.361 -			return false;
   1.362 -	return true;
   1.363 -}
   1.364 -
   1.365 -FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, uint32_t length)
   1.366 -{
   1.367 -	if(length == (uint32_t)(-1)) {
   1.368 -		while(*value) {
   1.369 -			uint32_t n = utf8len_(value);
   1.370 -			if(n == 0)
   1.371 -				return false;
   1.372 -			value += n;
   1.373 -		}
   1.374 -	}
   1.375 -	else {
   1.376 -		const FLAC__byte *end = value + length;
   1.377 -		while(value < end) {
   1.378 -			uint32_t n = utf8len_(value);
   1.379 -			if(n == 0)
   1.380 -				return false;
   1.381 -			value += n;
   1.382 -		}
   1.383 -		if(value != end)
   1.384 -			return false;
   1.385 -	}
   1.386 -	return true;
   1.387 -}
   1.388 -
   1.389 -FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, uint32_t length)
   1.390 -{
   1.391 -	const FLAC__byte *s, *end;
   1.392 -
   1.393 -	for(s = entry, end = s + length; s < end && *s != '='; s++) {
   1.394 -		if(*s < 0x20 || *s > 0x7D)
   1.395 -			return false;
   1.396 -	}
   1.397 -	if(s == end)
   1.398 -		return false;
   1.399 -
   1.400 -	s++; /* skip '=' */
   1.401 -
   1.402 -	while(s < end) {
   1.403 -		uint32_t n = utf8len_(s);
   1.404 -		if(n == 0)
   1.405 -			return false;
   1.406 -		s += n;
   1.407 -	}
   1.408 -	if(s != end)
   1.409 -		return false;
   1.410 -
   1.411 -	return true;
   1.412 -}
   1.413 -
   1.414 -/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
   1.415 -FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation)
   1.416 -{
   1.417 -	uint32_t i, j;
   1.418 -
   1.419 -	if(check_cd_da_subset) {
   1.420 -		if(cue_sheet->lead_in < 2 * 44100) {
   1.421 -			if(violation) *violation = "CD-DA cue sheet must have a lead-in length of at least 2 seconds";
   1.422 -			return false;
   1.423 -		}
   1.424 -		if(cue_sheet->lead_in % 588 != 0) {
   1.425 -			if(violation) *violation = "CD-DA cue sheet lead-in length must be evenly divisible by 588 samples";
   1.426 -			return false;
   1.427 -		}
   1.428 -	}
   1.429 -
   1.430 -	if(cue_sheet->num_tracks == 0) {
   1.431 -		if(violation) *violation = "cue sheet must have at least one track (the lead-out)";
   1.432 -		return false;
   1.433 -	}
   1.434 -
   1.435 -	if(check_cd_da_subset && cue_sheet->tracks[cue_sheet->num_tracks-1].number != 170) {
   1.436 -		if(violation) *violation = "CD-DA cue sheet must have a lead-out track number 170 (0xAA)";
   1.437 -		return false;
   1.438 -	}
   1.439 -
   1.440 -	for(i = 0; i < cue_sheet->num_tracks; i++) {
   1.441 -		if(cue_sheet->tracks[i].number == 0) {
   1.442 -			if(violation) *violation = "cue sheet may not have a track number 0";
   1.443 -			return false;
   1.444 -		}
   1.445 -
   1.446 -		if(check_cd_da_subset) {
   1.447 -			if(!((cue_sheet->tracks[i].number >= 1 && cue_sheet->tracks[i].number <= 99) || cue_sheet->tracks[i].number == 170)) {
   1.448 -				if(violation) *violation = "CD-DA cue sheet track number must be 1-99 or 170";
   1.449 -				return false;
   1.450 -			}
   1.451 -		}
   1.452 -
   1.453 -		if(check_cd_da_subset && cue_sheet->tracks[i].offset % 588 != 0) {
   1.454 -			if(violation) {
   1.455 -				if(i == cue_sheet->num_tracks-1) /* the lead-out track... */
   1.456 -					*violation = "CD-DA cue sheet lead-out offset must be evenly divisible by 588 samples";
   1.457 -				else
   1.458 -					*violation = "CD-DA cue sheet track offset must be evenly divisible by 588 samples";
   1.459 -			}
   1.460 -			return false;
   1.461 -		}
   1.462 -
   1.463 -		if(i < cue_sheet->num_tracks - 1) {
   1.464 -			if(cue_sheet->tracks[i].num_indices == 0) {
   1.465 -				if(violation) *violation = "cue sheet track must have at least one index point";
   1.466 -				return false;
   1.467 -			}
   1.468 -
   1.469 -			if(cue_sheet->tracks[i].indices[0].number > 1) {
   1.470 -				if(violation) *violation = "cue sheet track's first index number must be 0 or 1";
   1.471 -				return false;
   1.472 -			}
   1.473 -		}
   1.474 -
   1.475 -		for(j = 0; j < cue_sheet->tracks[i].num_indices; j++) {
   1.476 -			if(check_cd_da_subset && cue_sheet->tracks[i].indices[j].offset % 588 != 0) {
   1.477 -				if(violation) *violation = "CD-DA cue sheet track index offset must be evenly divisible by 588 samples";
   1.478 -				return false;
   1.479 -			}
   1.480 -
   1.481 -			if(j > 0) {
   1.482 -				if(cue_sheet->tracks[i].indices[j].number != cue_sheet->tracks[i].indices[j-1].number + 1) {
   1.483 -					if(violation) *violation = "cue sheet track index numbers must increase by 1";
   1.484 -					return false;
   1.485 -				}
   1.486 -			}
   1.487 -		}
   1.488 -	}
   1.489 -
   1.490 -	return true;
   1.491 -}
   1.492 -
   1.493 -/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
   1.494 -FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation)
   1.495 -{
   1.496 -	char *p;
   1.497 -	FLAC__byte *b;
   1.498 -
   1.499 -	for(p = picture->mime_type; *p; p++) {
   1.500 -		if(*p < 0x20 || *p > 0x7e) {
   1.501 -			if(violation) *violation = "MIME type string must contain only printable ASCII characters (0x20-0x7e)";
   1.502 -			return false;
   1.503 -		}
   1.504 -	}
   1.505 -
   1.506 -	for(b = picture->description; *b; ) {
   1.507 -		uint32_t n = utf8len_(b);
   1.508 -		if(n == 0) {
   1.509 -			if(violation) *violation = "description string must be valid UTF-8";
   1.510 -			return false;
   1.511 -		}
   1.512 -		b += n;
   1.513 -	}
   1.514 -
   1.515 -	return true;
   1.516 -}
   1.517 -
   1.518 -/*
   1.519 - * These routines are private to libFLAC
   1.520 - */
   1.521 -uint32_t FLAC__format_get_max_rice_partition_order(uint32_t blocksize, uint32_t predictor_order)
   1.522 -{
   1.523 -	return
   1.524 -		FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(
   1.525 -			FLAC__format_get_max_rice_partition_order_from_blocksize(blocksize),
   1.526 -			blocksize,
   1.527 -			predictor_order
   1.528 -		);
   1.529 -}
   1.530 -
   1.531 -uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize(uint32_t blocksize)
   1.532 -{
   1.533 -	uint32_t max_rice_partition_order = 0;
   1.534 -	while(!(blocksize & 1)) {
   1.535 -		max_rice_partition_order++;
   1.536 -		blocksize >>= 1;
   1.537 -	}
   1.538 -	return flac_min(FLAC__MAX_RICE_PARTITION_ORDER, max_rice_partition_order);
   1.539 -}
   1.540 -
   1.541 -uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(uint32_t limit, uint32_t blocksize, uint32_t predictor_order)
   1.542 -{
   1.543 -	uint32_t max_rice_partition_order = limit;
   1.544 -
   1.545 -	while(max_rice_partition_order > 0 && (blocksize >> max_rice_partition_order) <= predictor_order)
   1.546 -		max_rice_partition_order--;
   1.547 -
   1.548 -	FLAC__ASSERT(
   1.549 -		(max_rice_partition_order == 0 && blocksize >= predictor_order) ||
   1.550 -		(max_rice_partition_order > 0 && blocksize >> max_rice_partition_order > predictor_order)
   1.551 -	);
   1.552 -
   1.553 -	return max_rice_partition_order;
   1.554 -}
   1.555 -
   1.556 -void FLAC__format_entropy_coding_method_partitioned_rice_contents_init(FLAC__EntropyCodingMethod_PartitionedRiceContents *object)
   1.557 -{
   1.558 -	FLAC__ASSERT(0 != object);
   1.559 -
   1.560 -	object->parameters = 0;
   1.561 -	object->raw_bits = 0;
   1.562 -	object->capacity_by_order = 0;
   1.563 -}
   1.564 -
   1.565 -void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__EntropyCodingMethod_PartitionedRiceContents *object)
   1.566 -{
   1.567 -	FLAC__ASSERT(0 != object);
   1.568 -
   1.569 -	if(0 != object->parameters)
   1.570 -		free(object->parameters);
   1.571 -	if(0 != object->raw_bits)
   1.572 -		free(object->raw_bits);
   1.573 -	FLAC__format_entropy_coding_method_partitioned_rice_contents_init(object);
   1.574 -}
   1.575 -
   1.576 -FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, uint32_t max_partition_order)
   1.577 -{
   1.578 -	FLAC__ASSERT(0 != object);
   1.579 -
   1.580 -	FLAC__ASSERT(object->capacity_by_order > 0 || (0 == object->parameters && 0 == object->raw_bits));
   1.581 -
   1.582 -	if(object->capacity_by_order < max_partition_order) {
   1.583 -		if(0 == (object->parameters = safe_realloc_(object->parameters, sizeof(uint32_t)*(1 << max_partition_order))))
   1.584 -			return false;
   1.585 -		if(0 == (object->raw_bits = safe_realloc_(object->raw_bits, sizeof(uint32_t)*(1 << max_partition_order))))
   1.586 -			return false;
   1.587 -		memset(object->raw_bits, 0, sizeof(uint32_t)*(1 << max_partition_order));
   1.588 -		object->capacity_by_order = max_partition_order;
   1.589 -	}
   1.590 -
   1.591 -	return true;
   1.592 -}