chromium/third_party/flac/src/libFLAC/format.c

/* libFLAC - Free Lossless Audio Codec library
 * Copyright (C) 2000-2009  Josh Coalson
 * Copyright (C) 2011-2022  Xiph.Org Foundation
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * - Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *
 * - Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 *
 * - Neither the name of the Xiph.org Foundation nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h> /* for qsort() */
#include <string.h> /* for memset() */
#include "FLAC/assert.h"
#include "FLAC/format.h"
#include "share/alloc.h"
#include "share/compat.h"
#include "private/format.h"
#include "private/macros.h"

#if (defined GIT_COMMIT_HASH && defined GIT_COMMIT_DATE)
# ifdef GIT_COMMIT_TAG
FLAC_API const char *FLAC__VERSION_STRING = GIT_COMMIT_TAG;
FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " GIT_COMMIT_TAG " " GIT_COMMIT_DATE;
# else
FLAC_API const char *FLAC__VERSION_STRING = "git-" GIT_COMMIT_HASH " " GIT_COMMIT_DATE;
FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC git-" GIT_COMMIT_HASH " " GIT_COMMIT_DATE;
# endif
#else
/* PACKAGE_VERSION should come from configure */
FLAC_API const char *FLAC__VERSION_STRING =;
FLAC_API const char *FLAC__VENDOR_STRING =;
#endif

FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4] =;
FLAC_API const uint32_t FLAC__STREAM_SYNC =;
FLAC_API const uint32_t FLAC__STREAM_SYNC_LEN =; /* bits */

FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN =; /* bits */

FLAC_API const uint32_t FLAC__STREAM_METADATA_APPLICATION_ID_LEN =; /* bits */

FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN =; /* bits */

FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER =0xffffffffffffffff);

FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN =; /* bits */

FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN =; /* bits */

FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN =; /* bit */
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN =; /* bit */
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN =; /* bits */

FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN =; /* bit */
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN =; /* bits */

FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_TYPE_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_COLORS_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN =; /* bits */

FLAC_API const uint32_t FLAC__STREAM_METADATA_IS_LAST_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_TYPE_LEN =; /* bits */
FLAC_API const uint32_t FLAC__STREAM_METADATA_LENGTH_LEN =; /* bits */

FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC =;
FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC_LEN =; /* bits */
FLAC_API const uint32_t FLAC__FRAME_HEADER_RESERVED_LEN =; /* bits */
FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN =; /* bits */
FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCK_SIZE_LEN =; /* bits */
FLAC_API const uint32_t FLAC__FRAME_HEADER_SAMPLE_RATE_LEN =; /* bits */
FLAC_API const uint32_t FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN =; /* bits */
FLAC_API const uint32_t FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN =; /* bits */
FLAC_API const uint32_t FLAC__FRAME_HEADER_ZERO_PAD_LEN =; /* bits */
FLAC_API const uint32_t FLAC__FRAME_HEADER_CRC_LEN =; /* bits */

FLAC_API const uint32_t FLAC__FRAME_FOOTER_CRC_LEN =; /* bits */

FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_TYPE_LEN =; /* bits */
FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN =; /* bits */
FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN =; /* bits */
FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN =; /* bits */
FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN =; /* bits */

FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER =; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */
FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER =; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */

FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[] =;

FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN =; /* bits */
FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN =; /* bits */

FLAC_API const uint32_t FLAC__SUBFRAME_ZERO_PAD_LEN =; /* bits */
FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LEN =; /* bits */
FLAC_API const uint32_t FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN =; /* bits */

FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK =;
FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK =;
FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK =;
FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK =;

FLAC_API const char * const FLAC__SubframeTypeString[] =;

FLAC_API const char * const FLAC__ChannelAssignmentString[] =;

FLAC_API const char * const FLAC__FrameNumberTypeString[] =;

FLAC_API const char * const FLAC__MetadataTypeString[] =;

FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[] =;

FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(uint32_t sample_rate)
{}

FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(uint32_t blocksize, uint32_t sample_rate)
{}

FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(uint32_t sample_rate)
{}

/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table)
{}

/* used as the sort predicate for qsort() */
static int seekpoint_compare_(const FLAC__StreamMetadata_SeekPoint *l, const FLAC__StreamMetadata_SeekPoint *r)
{}

/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
FLAC_API uint32_t FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table)
{}

/*
 * also disallows non-shortest-form encodings, c.f.
 *   http://www.unicode.org/versions/corrigendum1.html
 * and a more clear explanation at the end of this section:
 *   http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 */
static uint32_t utf8len_(const FLAC__byte *utf8)
{}

FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name)
{}

FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, uint32_t length)
{}

FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, uint32_t length)
{}

/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation)
{}

/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation)
{}

/*
 * These routines are private to libFLAC
 */
uint32_t FLAC__format_get_max_rice_partition_order(uint32_t blocksize, uint32_t predictor_order)
{}

uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize(uint32_t blocksize)
{}

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)
{}

void FLAC__format_entropy_coding_method_partitioned_rice_contents_init(FLAC__EntropyCodingMethod_PartitionedRiceContents *object)
{}

void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__EntropyCodingMethod_PartitionedRiceContents *object)
{}

#if defined(_MSC_VER)
// silence three MSVC warnings 'result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)'
#pragma warning ( disable : 4334 )
#endif

FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, uint32_t max_partition_order)
{}

#if defined(_MSC_VER)
#pragma warning ( default : 4334 )
#endif