From f67641c52cda261755bf242d629bcdf80a3e5a6c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 17 Sep 2017 18:36:55 +0200 Subject: [PATCH] (libchdr) Can't have C++ comments (config.params.sh) Have to disable FLAC for now; still doesn't compile for Windows due to fseeko/ftello errors --- libretro-common/formats/libchdr/bitstream.c | 7 ++- libretro-common/formats/libchdr/cdrom.c | 42 +++++++------ libretro-common/formats/libchdr/cdrom.h | 4 +- libretro-common/formats/libchdr/flac.c | 12 ++-- libretro-common/formats/libchdr/flac.h | 47 ++++++++------- libretro-common/formats/libchdr/huffman.c | 2 +- libretro-common/formats/libchdr/huffman.h | 66 +++++++++++---------- qb/config.params.sh | 2 +- 8 files changed, 97 insertions(+), 85 deletions(-) diff --git a/libretro-common/formats/libchdr/bitstream.c b/libretro-common/formats/libchdr/bitstream.c index 922d8aa323..d0878fe42d 100644 --- a/libretro-common/formats/libchdr/bitstream.c +++ b/libretro-common/formats/libchdr/bitstream.c @@ -108,9 +108,10 @@ uint32_t bitstream_read_offset(struct bitstream* bitstream) } -//------------------------------------------------- -// flush - flush to the nearest byte -//------------------------------------------------- +/*------------------------------------------------- + * flush - flush to the nearest byte + *------------------------------------------------- + */ uint32_t bitstream_flush(struct bitstream* bitstream) { diff --git a/libretro-common/formats/libchdr/cdrom.c b/libretro-common/formats/libchdr/cdrom.c index 9c68be0794..15b49ef791 100644 --- a/libretro-common/formats/libchdr/cdrom.c +++ b/libretro-common/formats/libchdr/cdrom.c @@ -1,5 +1,7 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles +/* license:BSD-3-Clause + * + * copyright-holders:Aaron Giles + */ /*************************************************************************** cdrom.c @@ -302,15 +304,16 @@ static const uint16_t qoffsets[ECC_Q_NUM_BYTES][ECC_Q_COMP] = }; -//------------------------------------------------- -// ecc_source_byte - return data from the sector -// at the given offset, masking anything -// particular to a mode -//------------------------------------------------- +/*------------------------------------------------- + * ecc_source_byte - return data from the sector + * at the given offset, masking anything + * particular to a mode + *------------------------------------------------- + */ -static inline uint8_t ecc_source_byte(const uint8_t *sector, uint32_t offset) +static INLINE uint8_t ecc_source_byte(const uint8_t *sector, uint32_t offset) { - // in mode 2 always treat these as 0 bytes + /* in mode 2 always treat these as 0 bytes */ return (sector[MODE_OFFSET] == 2 && offset < 4) ? 0x00 : sector[SYNC_OFFSET + SYNC_NUM_BYTES + offset]; } @@ -330,8 +333,9 @@ static inline uint8_t ecc_source_byte(const uint8_t *sector, uint32_t offset) void ecc_compute_bytes(const uint8_t *sector, const uint16_t *row, int rowlen, uint8_t *val1, uint8_t *val2) { + int component; *val1 = *val2 = 0; - for (int component = 0; component < rowlen; component++) + for (component = 0; component < rowlen; component++) { *val1 ^= ecc_source_byte(sector, row[component]); *val2 ^= ecc_source_byte(sector, row[component]); @@ -355,8 +359,9 @@ void ecc_compute_bytes(const uint8_t *sector, const uint16_t *row, int rowlen, u int ecc_verify(const uint8_t *sector) { - // first verify P bytes - for (int byte = 0; byte < ECC_P_NUM_BYTES; byte++) + int byte; + /* first verify P bytes */ + for (byte = 0; byte < ECC_P_NUM_BYTES; byte++) { uint8_t val1, val2; ecc_compute_bytes(sector, poffsets[byte], ECC_P_COMP, &val1, &val2); @@ -364,8 +369,8 @@ int ecc_verify(const uint8_t *sector) return 0; } - // then verify Q bytes - for (int byte = 0; byte < ECC_Q_NUM_BYTES; byte++) + /* then verify Q bytes */ + for (byte = 0; byte < ECC_Q_NUM_BYTES; byte++) { uint8_t val1, val2; ecc_compute_bytes(sector, qoffsets[byte], ECC_Q_COMP, &val1, &val2); @@ -388,12 +393,13 @@ int ecc_verify(const uint8_t *sector) void ecc_generate(uint8_t *sector) { - // first verify P bytes - for (int byte = 0; byte < ECC_P_NUM_BYTES; byte++) + int byte; + /* first verify P bytes */ + for (byte = 0; byte < ECC_P_NUM_BYTES; byte++) ecc_compute_bytes(sector, poffsets[byte], ECC_P_COMP, §or[ECC_P_OFFSET + byte], §or[ECC_P_OFFSET + ECC_P_NUM_BYTES + byte]); - // then verify Q bytes - for (int byte = 0; byte < ECC_Q_NUM_BYTES; byte++) + /* then verify Q bytes */ + for (byte = 0; byte < ECC_Q_NUM_BYTES; byte++) ecc_compute_bytes(sector, qoffsets[byte], ECC_Q_COMP, §or[ECC_Q_OFFSET + byte], §or[ECC_Q_OFFSET + ECC_Q_NUM_BYTES + byte]); } diff --git a/libretro-common/formats/libchdr/cdrom.h b/libretro-common/formats/libchdr/cdrom.h index dc0a042172..84ff775103 100644 --- a/libretro-common/formats/libchdr/cdrom.h +++ b/libretro-common/formats/libchdr/cdrom.h @@ -53,8 +53,8 @@ enum CD_SUB_NONE /* no subcode data stored */ }; -#define CD_FLAG_GDROM 0x00000001 // disc is a GD-ROM, all tracks should be stored with GD-ROM metadata -#define CD_FLAG_GDROMLE 0x00000002 // legacy GD-ROM, with little-endian CDDA data +#define CD_FLAG_GDROM 0x00000001 /* disc is a GD-ROM, all tracks should be stored with GD-ROM metadata */ +#define CD_FLAG_GDROMLE 0x00000002 /* legacy GD-ROM, with little-endian CDDA data */ /*************************************************************************** FUNCTION PROTOTYPES diff --git a/libretro-common/formats/libchdr/flac.c b/libretro-common/formats/libchdr/flac.c index dfde00a2ee..5373eeb387 100644 --- a/libretro-common/formats/libchdr/flac.c +++ b/libretro-common/formats/libchdr/flac.c @@ -1,5 +1,6 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles +/* license:BSD-3-Clause + * copyright-holders:Aaron Giles + */ /*************************************************************************** flac.c @@ -12,9 +13,10 @@ #include #include "flac.h" -//************************************************************************** -// FLAC DECODER -//************************************************************************** +/*************************************************************************** + * FLAC DECODER + *************************************************************************** + */ static FLAC__StreamDecoderReadStatus flac_decoder_read_callback_static(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); FLAC__StreamDecoderReadStatus flac_decoder_read_callback(void* client_data, FLAC__byte buffer[], size_t *bytes); diff --git a/libretro-common/formats/libchdr/flac.h b/libretro-common/formats/libchdr/flac.h index dbb83584e1..b2b8e8f3c6 100644 --- a/libretro-common/formats/libchdr/flac.h +++ b/libretro-common/formats/libchdr/flac.h @@ -1,6 +1,6 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles -/*************************************************************************** +/* license:BSD-3-Clause + * copyright-holders:Aaron Giles + *************************************************************************** flac.h @@ -17,30 +17,31 @@ #include "FLAC/ordinals.h" #include "FLAC/stream_decoder.h" -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** +/*************************************************************************** + * TYPE DEFINITIONS + *************************************************************************** + */ typedef struct _flac_decoder flac_decoder; struct _flac_decoder { - // output state - FLAC__StreamDecoder* decoder; // actual encoder - uint32_t sample_rate; // decoded sample rate - uint8_t channels; // decoded number of channels - uint8_t bits_per_sample; // decoded bits per sample - uint32_t compressed_offset; // current offset in compressed data - const FLAC__byte * compressed_start; // start of compressed data - uint32_t compressed_length; // length of compressed data - const FLAC__byte * compressed2_start; // start of compressed data - uint32_t compressed2_length; // length of compressed data - int16_t * uncompressed_start[8]; // pointer to start of uncompressed data (up to 8 streams) - uint32_t uncompressed_offset; // current position in uncompressed data - uint32_t uncompressed_length; // length of uncompressed data - int uncompressed_swap; // swap uncompressed sample data - uint8_t custom_header[0x2a]; // custom header + /* output state */ + FLAC__StreamDecoder* decoder; /* actual encoder */ + uint32_t sample_rate; /* decoded sample rate */ + uint8_t channels; /* decoded number of channels */ + uint8_t bits_per_sample; /* decoded bits per sample */ + uint32_t compressed_offset; /* current offset in compressed data */ + const FLAC__byte * compressed_start; /* start of compressed data */ + uint32_t compressed_length; /* length of compressed data */ + const FLAC__byte * compressed2_start; /* start of compressed data */ + uint32_t compressed2_length; /* length of compressed data */ + int16_t * uncompressed_start[8]; /* pointer to start of uncompressed data (up to 8 streams) */ + uint32_t uncompressed_offset; /* current position in uncompressed data */ + uint32_t uncompressed_length; /* length of uncompressed data */ + int uncompressed_swap; /* swap uncompressed sample data */ + uint8_t custom_header[0x2a]; /* custom header */ }; -// ======================> flac_decoder +/* ======================> flac_decoder */ void flac_decoder_init(flac_decoder* decoder); void flac_decoder_free(flac_decoder* decoder); @@ -48,4 +49,4 @@ int flac_decoder_reset(flac_decoder* decoder, uint32_t sample_rate, uint8_t nu int flac_decoder_decode_interleaved(flac_decoder* decoder, int16_t *samples, uint32_t num_samples, int swap_endian); uint32_t flac_decoder_finish(flac_decoder* decoder); -#endif // __FLAC_H__ +#endif /* __FLAC_H__ */ diff --git a/libretro-common/formats/libchdr/huffman.c b/libretro-common/formats/libchdr/huffman.c index 861ae959db..932d45b281 100644 --- a/libretro-common/formats/libchdr/huffman.c +++ b/libretro-common/formats/libchdr/huffman.c @@ -453,7 +453,7 @@ int huffman_build_tree(struct huffman_decoder* decoder, uint32_t totaldata, uint node->numbits = 0; node->bits = 0; - // if we have a non-zero weight, compute the number of bits + /* if we have a non-zero weight, compute the number of bits */ if (node->weight > 0) { /* determine the number of bits for this node */ diff --git a/libretro-common/formats/libchdr/huffman.h b/libretro-common/formats/libchdr/huffman.h index 67467d5323..1d378421dc 100644 --- a/libretro-common/formats/libchdr/huffman.h +++ b/libretro-common/formats/libchdr/huffman.h @@ -1,6 +1,6 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles -/*************************************************************************** +/* license:BSD-3-Clause + * copyright-holders:Aaron Giles + *************************************************************************** huffman.h @@ -16,9 +16,10 @@ #include "bitstream.h" -//************************************************************************** -// CONSTANTS -//************************************************************************** +/*************************************************************************** + * CONSTANTS + *************************************************************************** + */ enum huffman_error { @@ -31,49 +32,50 @@ enum huffman_error HUFFERR_TOO_MANY_CONTEXTS }; - - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** +/*************************************************************************** + * TYPE DEFINITIONS + *************************************************************************** + */ typedef uint16_t lookup_value; -// a node in the huffman tree +/* a node in the huffman tree */ struct node_t { - struct node_t* parent; // pointer to parent node - uint32_t count; // number of hits on this node - uint32_t weight; // assigned weight of this node - uint32_t bits; // bits used to encode the node - uint8_t numbits; // number of bits needed for this node + struct node_t* parent; /* pointer to parent node */ + uint32_t count; /* number of hits on this node */ + uint32_t weight; /* assigned weight of this node */ + uint32_t bits; /* bits used to encode the node */ + uint8_t numbits; /* number of bits needed for this node */ }; -// ======================> huffman_context_base +/* ======================> huffman_context_base */ -// context class for decoding +/* context class for decoding */ struct huffman_decoder { - // internal state - uint32_t numcodes; // number of total codes being processed - uint8_t maxbits; // maximum bits per code - uint8_t prevdata; // value of the previous data (for delta-RLE encoding) - int rleremaining; // number of RLE bytes remaining (for delta-RLE encoding) - lookup_value * lookup; // pointer to the lookup table - struct node_t * huffnode; // array of nodes - uint32_t * datahisto; // histogram of data values + /* internal state */ + uint32_t numcodes; /* number of total codes being processed */ + uint8_t maxbits; /* maximum bits per code */ + uint8_t prevdata; /* value of the previous data (for delta-RLE encoding) */ + int rleremaining; /* number of RLE bytes remaining (for delta-RLE encoding) */ + lookup_value * lookup; /* pointer to the lookup table */ + struct node_t * huffnode; /* array of nodes */ + uint32_t * datahisto; /* histogram of data values */ - // array versions of the info we need - //node_t* huffnode_array; //[_NumCodes]; - //lookup_value* lookup_array; //[1 << _MaxBits]; + /* array versions of the info we need */ +#if 0 + node_t* huffnode_array; /* [_NumCodes]; */ + lookup_value* lookup_array; /* [1 << _MaxBits]; */ +#endif }; -// ======================> huffman_decoder +/* ======================> huffman_decoder */ struct huffman_decoder* create_huffman_decoder(int numcodes, int maxbits); void delete_huffman_decoder(struct huffman_decoder* decoder); -// single item operations +/* single item operations */ uint32_t huffman_decode_one(struct huffman_decoder* decoder, struct bitstream* bitbuf); enum huffman_error huffman_import_tree_rle(struct huffman_decoder* decoder, struct bitstream* bitbuf); diff --git a/qb/config.params.sh b/qb/config.params.sh index d255318482..76c0ff935a 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -82,7 +82,7 @@ HAVE_SSE=no # x86 SSE optimizations (SSE, SSE2) HAVE_FLOATHARD=no # Force hard float ABI (for ARM) HAVE_FLOATSOFTFP=no # Force soft float ABI (for ARM) HAVE_7ZIP=yes # Compile in 7z support -HAVE_FLAC=yes # Compile in flac support +HAVE_FLAC=no # Compile in flac support HAVE_UPDATE_ASSETS=yes # Disable downloading assets with online updater HAVE_PRESERVE_DYLIB=no # Enable dlclose() for Valgrind support HAVE_PARPORT=auto # Parallel port joypad support