summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2016-10-22 13:13:17 +0200
committer Miodrag Milanovic <mmicko@gmail.com>2016-10-22 13:13:17 +0200
commitddb290d5f615019c33c42b8d94e5a5254cabcf33 (patch)
treea70f688b0df3acd19da7b1151e5902e3c6af3fa5 /src/lib/util
parent333bff8de64dfaeb98134000412796b4fdef970b (diff)
NOTICE (TYPE NAME CONSOLIDATION)
Use standard uint64_t, uint32_t, uint16_t or uint8_t instead of UINT64, UINT32, UINT16 or UINT8 also use standard int64_t, int32_t, int16_t or int8_t instead of INT64, INT32, INT16 or INT8
Diffstat (limited to 'src/lib/util')
-rw-r--r--src/lib/util/avhuff.cpp194
-rw-r--r--src/lib/util/avhuff.h46
-rw-r--r--src/lib/util/bitmap.cpp74
-rw-r--r--src/lib/util/bitmap.h150
-rw-r--r--src/lib/util/bitstream.h56
-rw-r--r--src/lib/util/cdrom.cpp124
-rw-r--r--src/lib/util/cdrom.h68
-rw-r--r--src/lib/util/chd.cpp430
-rw-r--r--src/lib/util/chd.h322
-rw-r--r--src/lib/util/chdcd.cpp72
-rw-r--r--src/lib/util/chdcd.h6
-rw-r--r--src/lib/util/chdcodec.cpp266
-rw-r--r--src/lib/util/chdcodec.h32
-rw-r--r--src/lib/util/corefile.cpp4
-rw-r--r--src/lib/util/corefile.h2
-rw-r--r--src/lib/util/corestr.cpp12
-rw-r--r--src/lib/util/coreutil.cpp18
-rw-r--r--src/lib/util/coreutil.h6
-rw-r--r--src/lib/util/flac.cpp54
-rw-r--r--src/lib/util/flac.h68
-rw-r--r--src/lib/util/harddisk.cpp12
-rw-r--r--src/lib/util/harddisk.h12
-rw-r--r--src/lib/util/hash.cpp2
-rw-r--r--src/lib/util/hash.h8
-rw-r--r--src/lib/util/hashing.cpp12
-rw-r--r--src/lib/util/hashing.h36
-rw-r--r--src/lib/util/huffman.cpp52
-rw-r--r--src/lib/util/huffman.h42
-rw-r--r--src/lib/util/jedparse.cpp42
-rw-r--r--src/lib/util/jedparse.h8
-rw-r--r--src/lib/util/options.cpp14
-rw-r--r--src/lib/util/options.h24
-rw-r--r--src/lib/util/palette.cpp82
-rw-r--r--src/lib/util/palette.h130
-rw-r--r--src/lib/util/plaparse.cpp30
-rw-r--r--src/lib/util/png.cpp110
-rw-r--r--src/lib/util/png.h30
-rw-r--r--src/lib/util/pool.cpp2
-rw-r--r--src/lib/util/pool.h2
-rw-r--r--src/lib/util/sha1.cpp36
-rw-r--r--src/lib/util/sha1.h10
-rw-r--r--src/lib/util/vbiparse.cpp36
-rw-r--r--src/lib/util/vbiparse.h20
-rw-r--r--src/lib/util/wavwrite.cpp26
-rw-r--r--src/lib/util/wavwrite.h8
-rw-r--r--src/lib/util/xmlfile.cpp14
-rw-r--r--src/lib/util/xmlfile.h2
-rw-r--r--src/lib/util/zippath.cpp4
-rw-r--r--src/lib/util/zippath.h2
49 files changed, 1406 insertions, 1406 deletions
diff --git a/src/lib/util/avhuff.cpp b/src/lib/util/avhuff.cpp
index dbec214076a..9975287f4c1 100644
--- a/src/lib/util/avhuff.cpp
+++ b/src/lib/util/avhuff.cpp
@@ -123,7 +123,7 @@ inline int rlecount_to_code(int rlecount)
// encode_one - encode data
//-------------------------------------------------
-inline void avhuff_encoder::deltarle_encoder::encode_one(bitstream_out &bitbuf, UINT16 *&rleptr)
+inline void avhuff_encoder::deltarle_encoder::encode_one(bitstream_out &bitbuf, uint16_t *&rleptr)
{
// return RLE data if we still have some
if (m_rlecount != 0)
@@ -133,7 +133,7 @@ inline void avhuff_encoder::deltarle_encoder::encode_one(bitstream_out &bitbuf,
}
// fetch the data and process
- UINT16 data = *rleptr++;
+ uint16_t data = *rleptr++;
m_encoder.encode_one(bitbuf, data);
if (data >= 0x100)
m_rlecount = code_to_rlecount(data) - 1;
@@ -143,7 +143,7 @@ inline void avhuff_encoder::deltarle_encoder::encode_one(bitstream_out &bitbuf,
//-------------------------------------------------
// decode_one - decode data
//-------------------------------------------------
-inline UINT32 avhuff_decoder::deltarle_decoder::decode_one(bitstream_in &bitbuf)
+inline uint32_t avhuff_decoder::deltarle_decoder::decode_one(bitstream_in &bitbuf)
{
// return RLE data if we still have some
if (m_rlecount != 0)
@@ -156,7 +156,7 @@ inline UINT32 avhuff_decoder::deltarle_decoder::decode_one(bitstream_in &bitbuf)
int data = m_decoder.decode_one(bitbuf);
if (data < 0x100)
{
- m_prevdata += UINT8(data);
+ m_prevdata += uint8_t(data);
return m_prevdata;
}
else
@@ -189,7 +189,7 @@ m_flac_encoder.set_strip_metadata(true);
}
/**
- * @fn avhuff_error avhuff_encoder::encode_data(const UINT8 *source, UINT8 *dest, UINT32 &complength)
+ * @fn avhuff_error avhuff_encoder::encode_data(const uint8_t *source, uint8_t *dest, uint32_t &complength)
*
* @brief -------------------------------------------------
* encode_data - encode a block of data into a compressed data stream
@@ -202,18 +202,18 @@ m_flac_encoder.set_strip_metadata(true);
* @return An avhuff_error.
*/
-avhuff_error avhuff_encoder::encode_data(const UINT8 *source, UINT8 *dest, UINT32 &complength)
+avhuff_error avhuff_encoder::encode_data(const uint8_t *source, uint8_t *dest, uint32_t &complength)
{
// validate the header
if (source[0] != 'c' || source[1] != 'h' || source[2] != 'a' || source[3] != 'v')
return AVHERR_INVALID_DATA;
// extract info from the header
- UINT32 metasize = source[4];
- UINT32 channels = source[5];
- UINT32 samples = (source[6] << 8) + source[7];
- UINT32 width = (source[8] << 8) + source[9];
- UINT32 height = (source[10] << 8) + source[11];
+ uint32_t metasize = source[4];
+ uint32_t channels = source[5];
+ uint32_t samples = (source[6] << 8) + source[7];
+ uint32_t width = (source[8] << 8) + source[9];
+ uint32_t height = (source[10] << 8) + source[11];
source += 12;
// write the basics to the new header
@@ -227,7 +227,7 @@ avhuff_error avhuff_encoder::encode_data(const UINT8 *source, UINT8 *dest, UINT3
dest[7] = height;
// starting offsets
- UINT32 dstoffs = 10 + 2 * channels;
+ uint32_t dstoffs = 10 + 2 * channels;
// copy the metadata first
if (metasize > 0)
@@ -247,7 +247,7 @@ avhuff_error avhuff_encoder::encode_data(const UINT8 *source, UINT8 *dest, UINT3
return err;
// advance the pointers past the data
- UINT16 treesize = (dest[8] << 8) + dest[9];
+ uint16_t treesize = (dest[8] << 8) + dest[9];
if (treesize != 0xffff)
dstoffs += treesize;
for (int chnum = 0; chnum < channels; chnum++)
@@ -263,7 +263,7 @@ avhuff_error avhuff_encoder::encode_data(const UINT8 *source, UINT8 *dest, UINT3
if (width > 0 && height > 0)
{
// encode the video
- UINT32 vidlength = 0;
+ uint32_t vidlength = 0;
avhuff_error err = encode_video(source, width, height, dest + dstoffs, vidlength);
if (err != AVHERR_NONE)
return err;
@@ -278,7 +278,7 @@ avhuff_error avhuff_encoder::encode_data(const UINT8 *source, UINT8 *dest, UINT3
}
/**
- * @fn UINT32 avhuff_encoder::raw_data_size(const UINT8 *data)
+ * @fn uint32_t avhuff_encoder::raw_data_size(const uint8_t *data)
*
* @brief -------------------------------------------------
* raw_data_size - return the raw data size of a raw stream based on the header
@@ -286,10 +286,10 @@ avhuff_error avhuff_encoder::encode_data(const UINT8 *source, UINT8 *dest, UINT3
*
* @param data The data.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-UINT32 avhuff_encoder::raw_data_size(const UINT8 *data)
+uint32_t avhuff_encoder::raw_data_size(const uint8_t *data)
{
// make sure we have a correct header
int size = 0;
@@ -308,7 +308,7 @@ UINT32 avhuff_encoder::raw_data_size(const UINT8 *data)
}
/**
- * @fn avhuff_error avhuff_encoder::assemble_data(std::vector<UINT8> &buffer, bitmap_yuy16 &bitmap, UINT8 channels, UINT32 numsamples, INT16 **samples, UINT8 *metadata, UINT32 metadatasize)
+ * @fn avhuff_error avhuff_encoder::assemble_data(std::vector<uint8_t> &buffer, bitmap_yuy16 &bitmap, uint8_t channels, uint32_t numsamples, int16_t **samples, uint8_t *metadata, uint32_t metadatasize)
*
* @brief -------------------------------------------------
* assemble_data - assemble a datastream from raw bits
@@ -325,7 +325,7 @@ UINT32 avhuff_encoder::raw_data_size(const UINT8 *data)
* @return An avhuff_error.
*/
-avhuff_error avhuff_encoder::assemble_data(std::vector<UINT8> &buffer, bitmap_yuy16 &bitmap, UINT8 channels, UINT32 numsamples, INT16 **samples, UINT8 *metadata, UINT32 metadatasize)
+avhuff_error avhuff_encoder::assemble_data(std::vector<uint8_t> &buffer, bitmap_yuy16 &bitmap, uint8_t channels, uint32_t numsamples, int16_t **samples, uint8_t *metadata, uint32_t metadatasize)
{
// sanity check the inputs
if (metadatasize > 255)
@@ -337,7 +337,7 @@ avhuff_error avhuff_encoder::assemble_data(std::vector<UINT8> &buffer, bitmap_yu
// fill in the header
buffer.resize(12 + metadatasize + numsamples * channels * 2 + bitmap.width() * bitmap.height() * 2);
- UINT8 *dest = &buffer[0];
+ uint8_t *dest = &buffer[0];
*dest++ = 'c';
*dest++ = 'h';
*dest++ = 'a';
@@ -357,18 +357,18 @@ avhuff_error avhuff_encoder::assemble_data(std::vector<UINT8> &buffer, bitmap_yu
dest += metadatasize;
// copy the audio streams
- for (UINT8 curchan = 0; curchan < channels; curchan++)
- for (UINT32 cursamp = 0; cursamp < numsamples; cursamp++)
+ for (uint8_t curchan = 0; curchan < channels; curchan++)
+ for (uint32_t cursamp = 0; cursamp < numsamples; cursamp++)
{
*dest++ = samples[curchan][cursamp] >> 8;
*dest++ = samples[curchan][cursamp] & 0xff;
}
// copy the video data
- for (INT32 y = 0; y < bitmap.height(); y++)
+ for (int32_t y = 0; y < bitmap.height(); y++)
{
- UINT16 *src = &bitmap.pix(y);
- for (INT32 x = 0; x < bitmap.width(); x++)
+ uint16_t *src = &bitmap.pix(y);
+ for (int32_t x = 0; x < bitmap.width(); x++)
{
*dest++ = src[x] >> 8;
*dest++ = src[x] & 0xff;
@@ -378,7 +378,7 @@ avhuff_error avhuff_encoder::assemble_data(std::vector<UINT8> &buffer, bitmap_yu
}
/**
- * @fn avhuff_error avhuff_encoder::encode_audio(const UINT8 *source, int channels, int samples, UINT8 *dest, UINT8 *sizes)
+ * @fn avhuff_error avhuff_encoder::encode_audio(const uint8_t *source, int channels, int samples, uint8_t *dest, uint8_t *sizes)
*
* @brief -------------------------------------------------
* encode_audio - encode raw audio data to the destination
@@ -393,13 +393,13 @@ avhuff_error avhuff_encoder::assemble_data(std::vector<UINT8> &buffer, bitmap_yu
* @return An avhuff_error.
*/
-avhuff_error avhuff_encoder::encode_audio(const UINT8 *source, int channels, int samples, UINT8 *dest, UINT8 *sizes)
+avhuff_error avhuff_encoder::encode_audio(const uint8_t *source, int channels, int samples, uint8_t *dest, uint8_t *sizes)
{
#if AVHUFF_USE_FLAC
// input data is big-endian; determine our platform endianness
- UINT16 be_test = 0;
- *(UINT8 *)&be_test = 1;
+ uint16_t be_test = 0;
+ *(uint8_t *)&be_test = 1;
bool swap_endian = (be_test == 1);
// set huffman tree size to 0xffff to indicate FLAC
@@ -412,11 +412,11 @@ avhuff_error avhuff_encoder::encode_audio(const UINT8 *source, int channels, int
{
// encode the data
m_flac_encoder.reset(dest, samples * 2);
- if (!m_flac_encoder.encode_interleaved(reinterpret_cast<const INT16 *>(source) + chnum * samples, samples, swap_endian))
+ if (!m_flac_encoder.encode_interleaved(reinterpret_cast<const int16_t *>(source) + chnum * samples, samples, swap_endian))
return AVHERR_COMPRESSION_ERROR;
// set the size for this channel
- UINT32 cursize = m_flac_encoder.finish();
+ uint32_t cursize = m_flac_encoder.finish();
sizes[chnum * 2 + 2] = cursize >> 8;
sizes[chnum * 2 + 3] = cursize;
dest += cursize;
@@ -426,7 +426,7 @@ avhuff_error avhuff_encoder::encode_audio(const UINT8 *source, int channels, int
// expand the delta buffer if needed
m_audiobuffer.resize(channels * samples * 2);
- UINT8 *deltabuf = m_audiobuffer;
+ uint8_t *deltabuf = m_audiobuffer;
// iterate over channels to compute deltas
m_audiohi_encoder.histo_reset();
@@ -434,13 +434,13 @@ avhuff_error avhuff_encoder::encode_audio(const UINT8 *source, int channels, int
for (int chnum = 0; chnum < channels; chnum++)
{
// extract audio data into hi and lo deltas stored in big-endian order
- INT16 prevsample = 0;
+ int16_t prevsample = 0;
for (int sampnum = 0; sampnum < samples; sampnum++)
{
- INT16 newsample = (source[0] << 8) | source[1];
+ int16_t newsample = (source[0] << 8) | source[1];
source += 2;
- INT16 delta = newsample - prevsample;
+ int16_t delta = newsample - prevsample;
prevsample = newsample;
m_audiohi_encoder.histo_one(*deltabuf++ = delta >> 8);
m_audiolo_encoder.histo_one(*deltabuf++ = delta);
@@ -466,17 +466,17 @@ avhuff_error avhuff_encoder::encode_audio(const UINT8 *source, int channels, int
return AVHERR_COMPRESSION_ERROR;
// note the size of the two trees
- UINT32 huffsize = bitbuf.flush();
+ uint32_t huffsize = bitbuf.flush();
sizes[0] = huffsize >> 8;
sizes[1] = huffsize;
// iterate over channels
- UINT32 totalsize = huffsize;
+ uint32_t totalsize = huffsize;
int chnum;
for (chnum = 0; chnum < channels; chnum++)
{
// encode the data
- const UINT8 *input = m_audiobuffer + chnum * samples * 2;
+ const uint8_t *input = m_audiobuffer + chnum * samples * 2;
for (int sampnum = 0; sampnum < samples; sampnum++)
{
m_audiohi_encoder.encode_one(bitbuf, *input++);
@@ -484,7 +484,7 @@ avhuff_error avhuff_encoder::encode_audio(const UINT8 *source, int channels, int
}
// store the size of this stream
- UINT32 cursize = bitbuf.flush() - totalsize;
+ uint32_t cursize = bitbuf.flush() - totalsize;
totalsize += cursize;
if (totalsize >= channels * samples * 2)
break;
@@ -496,7 +496,7 @@ avhuff_error avhuff_encoder::encode_audio(const UINT8 *source, int channels, int
if (chnum < channels)
{
memcpy(dest, m_audiobuffer, channels * samples * 2);
- UINT32 size = samples * 2;
+ uint32_t size = samples * 2;
sizes[0] = sizes[1] = 0;
for (chnum = 0; chnum < channels; chnum++)
{
@@ -511,7 +511,7 @@ avhuff_error avhuff_encoder::encode_audio(const UINT8 *source, int channels, int
}
/**
- * @fn avhuff_error avhuff_encoder::encode_video(const UINT8 *source, int width, int height, UINT8 *dest, UINT32 &complength)
+ * @fn avhuff_error avhuff_encoder::encode_video(const uint8_t *source, int width, int height, uint8_t *dest, uint32_t &complength)
*
* @brief -------------------------------------------------
* encode_video - encode raw video data to the destination
@@ -526,14 +526,14 @@ avhuff_error avhuff_encoder::encode_audio(const UINT8 *source, int channels, int
* @return An avhuff_error.
*/
-avhuff_error avhuff_encoder::encode_video(const UINT8 *source, int width, int height, UINT8 *dest, UINT32 &complength)
+avhuff_error avhuff_encoder::encode_video(const uint8_t *source, int width, int height, uint8_t *dest, uint32_t &complength)
{
// only lossless supported at this time
return encode_video_lossless(source, width, height, dest, complength);
}
/**
- * @fn avhuff_error avhuff_encoder::encode_video_lossless(const UINT8 *source, int width, int height, UINT8 *dest, UINT32 &complength)
+ * @fn avhuff_error avhuff_encoder::encode_video_lossless(const uint8_t *source, int width, int height, uint8_t *dest, uint32_t &complength)
*
* @brief -------------------------------------------------
* encode_video_lossless - do a lossless video encoding using deltas and huffman
@@ -549,16 +549,16 @@ avhuff_error avhuff_encoder::encode_video(const UINT8 *source, int width, int he
* @return An avhuff_error.
*/
-avhuff_error avhuff_encoder::encode_video_lossless(const UINT8 *source, int width, int height, UINT8 *dest, UINT32 &complength)
+avhuff_error avhuff_encoder::encode_video_lossless(const uint8_t *source, int width, int height, uint8_t *dest, uint32_t &complength)
{
// set up the output; first byte is 0x80 to indicate lossless encoding
bitstream_out bitbuf(dest, width * height * 2);
bitbuf.write(0x80, 8);
// compute the histograms for the data
- UINT16 *yrle = m_ycontext.rle_and_histo_bitmap(source + 0, width, 2, height);
- UINT16 *cbrle = m_cbcontext.rle_and_histo_bitmap(source + 1, width / 2, 4, height);
- UINT16 *crrle = m_crcontext.rle_and_histo_bitmap(source + 3, width / 2, 4, height);
+ uint16_t *yrle = m_ycontext.rle_and_histo_bitmap(source + 0, width, 2, height);
+ uint16_t *cbrle = m_cbcontext.rle_and_histo_bitmap(source + 1, width / 2, 4, height);
+ uint16_t *crrle = m_crcontext.rle_and_histo_bitmap(source + 3, width / 2, 4, height);
// export the trees to the data stream
huffman_error hufferr = m_ycontext.export_tree_rle(bitbuf);
@@ -575,12 +575,12 @@ avhuff_error avhuff_encoder::encode_video_lossless(const UINT8 *source, int widt
bitbuf.flush();
// encode the data using the trees
- for (UINT32 sy = 0; sy < height; sy++)
+ for (uint32_t sy = 0; sy < height; sy++)
{
m_ycontext.flush_rle();
m_cbcontext.flush_rle();
m_crcontext.flush_rle();
- for (UINT32 sx = 0; sx < width / 2; sx++)
+ for (uint32_t sx = 0; sx < width / 2; sx++)
{
m_ycontext.encode_one(bitbuf, yrle);
m_cbcontext.encode_one(bitbuf, cbrle);
@@ -601,7 +601,7 @@ avhuff_error avhuff_encoder::encode_video_lossless(const UINT8 *source, int widt
//**************************************************************************
/**
- * @fn UINT16 *avhuff_encoder::deltarle_encoder::rle_and_histo_bitmap(const UINT8 *source, UINT32 items_per_row, UINT32 item_advance, UINT32 row_count)
+ * @fn uint16_t *avhuff_encoder::deltarle_encoder::rle_and_histo_bitmap(const uint8_t *source, uint32_t items_per_row, uint32_t item_advance, uint32_t row_count)
*
* @brief -------------------------------------------------
* rle_and_histo_bitmap - RLE compress and histogram a bitmap's worth of data
@@ -612,25 +612,25 @@ avhuff_error avhuff_encoder::encode_video_lossless(const UINT8 *source, int widt
* @param item_advance The item advance.
* @param row_count Number of rows.
*
- * @return null if it fails, else an UINT16*.
+ * @return null if it fails, else an uint16_t*.
*/
-UINT16 *avhuff_encoder::deltarle_encoder::rle_and_histo_bitmap(const UINT8 *source, UINT32 items_per_row, UINT32 item_advance, UINT32 row_count)
+uint16_t *avhuff_encoder::deltarle_encoder::rle_and_histo_bitmap(const uint8_t *source, uint32_t items_per_row, uint32_t item_advance, uint32_t row_count)
{
// resize our RLE buffer
m_rlebuffer.resize(items_per_row * row_count);
- UINT16 *dest = &m_rlebuffer[0];
+ uint16_t *dest = &m_rlebuffer[0];
// iterate over rows
m_encoder.histo_reset();
- UINT8 prevdata = 0;
- for (UINT32 row = 0; row < row_count; row++)
+ uint8_t prevdata = 0;
+ for (uint32_t row = 0; row < row_count; row++)
{
- const UINT8 *end = source + items_per_row * item_advance;
+ const uint8_t *end = source + items_per_row * item_advance;
for ( ; source < end; source += item_advance)
{
// fetch current data
- UINT8 curdelta = *source - prevdata;
+ uint8_t curdelta = *source - prevdata;
prevdata = *source;
// 0 deltas scan forward for a count
@@ -639,7 +639,7 @@ UINT16 *avhuff_encoder::deltarle_encoder::rle_and_histo_bitmap(const UINT8 *sour
int zerocount = 1;
// count the number of consecutive values
- const UINT8 *scandata;
+ const uint8_t *scandata;
for (scandata = source + item_advance; scandata < end; scandata += item_advance)
if (*scandata == prevdata)
zerocount++;
@@ -712,7 +712,7 @@ void avhuff_decoder::configure(const avhuff_decompress_config &config)
}
/**
- * @fn avhuff_error avhuff_decoder::decode_data(const UINT8 *source, UINT32 complength, UINT8 *dest)
+ * @fn avhuff_error avhuff_decoder::decode_data(const uint8_t *source, uint32_t complength, uint8_t *dest)
*
* @brief -------------------------------------------------
* decode_data - decode both audio and video from a raw data stream
@@ -725,22 +725,22 @@ void avhuff_decoder::configure(const avhuff_decompress_config &config)
* @return An avhuff_error.
*/
-avhuff_error avhuff_decoder::decode_data(const UINT8 *source, UINT32 complength, UINT8 *dest)
+avhuff_error avhuff_decoder::decode_data(const uint8_t *source, uint32_t complength, uint8_t *dest)
{
// extract info from the header
if (complength < 8)
return AVHERR_INVALID_DATA;
- UINT32 metasize = source[0];
- UINT32 channels = source[1];
- UINT32 samples = (source[2] << 8) + source[3];
- UINT32 width = (source[4] << 8) + source[5];
- UINT32 height = (source[6] << 8) + source[7];
+ uint32_t metasize = source[0];
+ uint32_t channels = source[1];
+ uint32_t samples = (source[2] << 8) + source[3];
+ uint32_t width = (source[4] << 8) + source[5];
+ uint32_t height = (source[6] << 8) + source[7];
// validate that the sizes make sense
if (complength < 10 + 2 * channels)
return AVHERR_INVALID_DATA;
- UINT32 totalsize = 10 + 2 * channels;
- UINT32 treesize = (source[8] << 8) | source[9];
+ uint32_t totalsize = 10 + 2 * channels;
+ uint32_t treesize = (source[8] << 8) | source[9];
if (treesize != 0xffff)
totalsize += treesize;
for (int chnum = 0; chnum < channels; chnum++)
@@ -749,11 +749,11 @@ avhuff_error avhuff_decoder::decode_data(const UINT8 *source, UINT32 complength,
return AVHERR_INVALID_DATA;
// starting offsets
- UINT32 srcoffs = 10 + 2 * channels;
+ uint32_t srcoffs = 10 + 2 * channels;
// if we are decoding raw, set up the output parameters
- UINT8 *metastart, *videostart, *audiostart[16];
- UINT32 audioxor, videoxor, videostride;
+ uint8_t *metastart, *videostart, *audiostart[16];
+ uint32_t audioxor, videoxor, videostride;
if (dest != nullptr)
{
// create a header
@@ -792,13 +792,13 @@ avhuff_error avhuff_decoder::decode_data(const UINT8 *source, UINT32 complength,
// determine the start of each piece of data
metastart = m_config.metadata;
for (int chnum = 0; chnum < channels; chnum++)
- audiostart[chnum] = (UINT8 *)m_config.audio[chnum];
- videostart = (m_config.video.valid()) ? reinterpret_cast<UINT8 *>(&m_config.video.pix(0)) : nullptr;
+ audiostart[chnum] = (uint8_t *)m_config.audio[chnum];
+ videostart = (m_config.video.valid()) ? reinterpret_cast<uint8_t *>(&m_config.video.pix(0)) : nullptr;
videostride = (m_config.video.valid()) ? m_config.video.rowpixels() * 2 : 0;
// data is assumed to be native-endian
- UINT16 betest = 0;
- *(UINT8 *)&betest = 1;
+ uint16_t betest = 0;
+ *(uint8_t *)&betest = 1;
audioxor = videoxor = (betest == 1) ? 1 : 0;
// verify against sizes
@@ -853,7 +853,7 @@ avhuff_error avhuff_decoder::decode_data(const UINT8 *source, UINT32 complength,
}
/**
- * @fn avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8 *source, UINT8 **dest, UINT32 dxor, const UINT8 *sizes)
+ * @fn avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const uint8_t *source, uint8_t **dest, uint32_t dxor, const uint8_t *sizes)
*
* @brief -------------------------------------------------
* decode_audio - decode audio from a compressed data stream
@@ -872,10 +872,10 @@ avhuff_error avhuff_decoder::decode_data(const UINT8 *source, UINT32 complength,
* @return An avhuff_error.
*/
-avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8 *source, UINT8 **dest, UINT32 dxor, const UINT8 *sizes)
+avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const uint8_t *source, uint8_t **dest, uint32_t dxor, const uint8_t *sizes)
{
// extract the huffman trees
- UINT16 treesize = (sizes[0] << 8) | sizes[1];
+ uint16_t treesize = (sizes[0] << 8) | sizes[1];
#if AVHUFF_USE_FLAC
@@ -883,8 +883,8 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8
if (treesize == 0xffff)
{
// output data is big-endian; determine our platform endianness
- UINT16 be_test = 0;
- *(UINT8 *)&be_test = 1;
+ uint16_t be_test = 0;
+ *(uint8_t *)&be_test = 1;
bool swap_endian = (be_test == 1);
if (dxor != 0)
swap_endian = !swap_endian;
@@ -893,16 +893,16 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8
for (int chnum = 0; chnum < channels; chnum++)
{
// extract the size of this channel
- UINT16 size = (sizes[chnum * 2 + 2] << 8) | sizes[chnum * 2 + 3];
+ uint16_t size = (sizes[chnum * 2 + 2] << 8) | sizes[chnum * 2 + 3];
// only process if the data is requested
- UINT8 *curdest = dest[chnum];
+ uint8_t *curdest = dest[chnum];
if (curdest != nullptr)
{
// reset and decode
if (!m_flac_decoder.reset(48000, 1, samples, source, size))
throw CHDERR_DECOMPRESSION_ERROR;
- if (!m_flac_decoder.decode_interleaved(reinterpret_cast<INT16 *>(curdest), samples, swap_endian))
+ if (!m_flac_decoder.decode_interleaved(reinterpret_cast<int16_t *>(curdest), samples, swap_endian))
throw CHDERR_DECOMPRESSION_ERROR;
// finish up
@@ -937,24 +937,24 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8
for (int chnum = 0; chnum < channels; chnum++)
{
// extract the size of this channel
- UINT16 size = (sizes[chnum * 2 + 2] << 8) | sizes[chnum * 2 + 3];
+ uint16_t size = (sizes[chnum * 2 + 2] << 8) | sizes[chnum * 2 + 3];
// only process if the data is requested
- UINT8 *curdest = dest[chnum];
+ uint8_t *curdest = dest[chnum];
if (curdest != nullptr)
{
- INT16 prevsample = 0;
+ int16_t prevsample = 0;
// if no huffman length, just copy the data
if (treesize == 0)
{
- const UINT8 *cursource = source;
+ const uint8_t *cursource = source;
for (int sampnum = 0; sampnum < samples; sampnum++)
{
- INT16 delta = (cursource[0] << 8) | cursource[1];
+ int16_t delta = (cursource[0] << 8) | cursource[1];
cursource += 2;
- INT16 newsample = prevsample + delta;
+ int16_t newsample = prevsample + delta;
prevsample = newsample;
curdest[0 ^ dxor] = newsample >> 8;
@@ -969,10 +969,10 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8
bitstream_in bitbuf(source, size);
for (int sampnum = 0; sampnum < samples; sampnum++)
{
- INT16 delta = m_audiohi_decoder.decode_one(bitbuf) << 8;
+ int16_t delta = m_audiohi_decoder.decode_one(bitbuf) << 8;
delta |= m_audiolo_decoder.decode_one(bitbuf);
- INT16 newsample = prevsample + delta;
+ int16_t newsample = prevsample + delta;
prevsample = newsample;
curdest[0 ^ dxor] = newsample >> 8;
@@ -991,7 +991,7 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8
}
/**
- * @fn avhuff_error avhuff_decoder::decode_video(int width, int height, const UINT8 *source, UINT32 complength, UINT8 *dest, UINT32 dstride, UINT32 dxor)
+ * @fn avhuff_error avhuff_decoder::decode_video(int width, int height, const uint8_t *source, uint32_t complength, uint8_t *dest, uint32_t dstride, uint32_t dxor)
*
* @brief -------------------------------------------------
* decode_video - decode video from a compressed data stream
@@ -1008,7 +1008,7 @@ avhuff_error avhuff_decoder::decode_audio(int channels, int samples, const UINT8
* @return An avhuff_error.
*/
-avhuff_error avhuff_decoder::decode_video(int width, int height, const UINT8 *source, UINT32 complength, UINT8 *dest, UINT32 dstride, UINT32 dxor)
+avhuff_error avhuff_decoder::decode_video(int width, int height, const uint8_t *source, uint32_t complength, uint8_t *dest, uint32_t dstride, uint32_t dxor)
{
// if the high bit of the first byte is set, we decode losslessly
if (source[0] & 0x80)
@@ -1018,7 +1018,7 @@ avhuff_error avhuff_decoder::decode_video(int width, int height, const UINT8 *so
}
/**
- * @fn avhuff_error avhuff_decoder::decode_video_lossless(int width, int height, const UINT8 *source, UINT32 complength, UINT8 *dest, UINT32 dstride, UINT32 dxor)
+ * @fn avhuff_error avhuff_decoder::decode_video_lossless(int width, int height, const uint8_t *source, uint32_t complength, uint8_t *dest, uint32_t dstride, uint32_t dxor)
*
* @brief -------------------------------------------------
* decode_video_lossless - do a lossless video decoding using deltas and huffman
@@ -1036,7 +1036,7 @@ avhuff_error avhuff_decoder::decode_video(int width, int height, const UINT8 *so
* @return An avhuff_error.
*/
-avhuff_error avhuff_decoder::decode_video_lossless(int width, int height, const UINT8 *source, UINT32 complength, UINT8 *dest, UINT32 dstride, UINT32 dxor)
+avhuff_error avhuff_decoder::decode_video_lossless(int width, int height, const uint8_t *source, uint32_t complength, uint8_t *dest, uint32_t dstride, uint32_t dxor)
{
// skip the first byte
bitstream_in bitbuf(source, complength);
@@ -1060,10 +1060,10 @@ avhuff_error avhuff_decoder::decode_video_lossless(int width, int height, const
m_ycontext.reset();
m_cbcontext.reset();
m_crcontext.reset();
- for (UINT32 dy = 0; dy < height; dy++)
+ for (uint32_t dy = 0; dy < height; dy++)
{
- UINT8 *row = dest + dy * dstride;
- for (UINT32 dx = 0; dx < width / 2; dx++)
+ uint8_t *row = dest + dy * dstride;
+ for (uint32_t dx = 0; dx < width / 2; dx++)
{
row[0 ^ dxor] = m_ycontext.decode_one(bitbuf);
row[1 ^ dxor] = m_cbcontext.decode_one(bitbuf);
diff --git a/src/lib/util/avhuff.h b/src/lib/util/avhuff.h
index ca1bd4cec49..9d00ed423e6 100644
--- a/src/lib/util/avhuff.h
+++ b/src/lib/util/avhuff.h
@@ -66,12 +66,12 @@ public:
}
bitmap_yuy16 video; // pointer to video bitmap
- UINT32 maxsamples; // maximum number of samples per channel
- UINT32 * actsamples; // actual number of samples per channel
- INT16 * audio[16]; // pointer to individual audio channels
- UINT32 maxmetalength; // maximum length of metadata
- UINT32 * actmetalength; // actual length of metadata
- UINT8 * metadata; // pointer to metadata buffer
+ uint32_t maxsamples; // maximum number of samples per channel
+ uint32_t * actsamples; // actual number of samples per channel
+ int16_t * audio[16]; // pointer to individual audio channels
+ uint32_t maxmetalength; // maximum length of metadata
+ uint32_t * actmetalength; // actual length of metadata
+ uint8_t * metadata; // pointer to metadata buffer
};
@@ -85,12 +85,12 @@ public:
avhuff_encoder();
// encode/decode
- avhuff_error encode_data(const UINT8 *source, UINT8 *dest, UINT32 &complength);
+ avhuff_error encode_data(const uint8_t *source, uint8_t *dest, uint32_t &complength);
// static helpers
- static UINT32 raw_data_size(const UINT8 *data);
- static UINT32 raw_data_size(UINT32 width, UINT32 height, UINT8 channels, UINT32 numsamples, UINT32 metadatasize = 0) { return 12 + channels * numsamples * 2 + width * height * 2; }
- static avhuff_error assemble_data(std::vector<UINT8> &buffer, bitmap_yuy16 &bitmap, UINT8 channels, UINT32 numsamples, INT16 **samples, UINT8 *metadata = nullptr, UINT32 metadatasize = 0);
+ static uint32_t raw_data_size(const uint8_t *data);
+ static uint32_t raw_data_size(uint32_t width, uint32_t height, uint8_t channels, uint32_t numsamples, uint32_t metadatasize = 0) { return 12 + channels * numsamples * 2 + width * height * 2; }
+ static avhuff_error assemble_data(std::vector<uint8_t> &buffer, bitmap_yuy16 &bitmap, uint8_t channels, uint32_t numsamples, int16_t **samples, uint8_t *metadata = nullptr, uint32_t metadatasize = 0);
private:
// delta-RLE Huffman encoder
@@ -102,24 +102,24 @@ private:
: m_rlecount(0) { }
// histogramming
- UINT16 *rle_and_histo_bitmap(const UINT8 *source, UINT32 items_per_row, UINT32 item_advance, UINT32 row_count);
+ uint16_t *rle_and_histo_bitmap(const uint8_t *source, uint32_t items_per_row, uint32_t item_advance, uint32_t row_count);
// encoding
void flush_rle() { m_rlecount = 0; }
- void encode_one(bitstream_out &bitbuf, UINT16 *&rleptr);
+ void encode_one(bitstream_out &bitbuf, uint16_t *&rleptr);
huffman_error export_tree_rle(bitstream_out &bitbuf) { return m_encoder.export_tree_rle(bitbuf); }
private:
// internal state
int m_rlecount;
huffman_encoder<256 + 16> m_encoder;
- std::vector<UINT16> m_rlebuffer;
+ std::vector<uint16_t> m_rlebuffer;
};
// internal helpers
- avhuff_error encode_audio(const UINT8 *source, int channels, int samples, UINT8 *dest, UINT8 *sizes);
- avhuff_error encode_video(const UINT8 *source, int width, int height, UINT8 *dest, UINT32 &complength);
- avhuff_error encode_video_lossless(const UINT8 *source, int width, int height, UINT8 *dest, UINT32 &complength);
+ avhuff_error encode_audio(const uint8_t *source, int channels, int samples, uint8_t *dest, uint8_t *sizes);
+ avhuff_error encode_video(const uint8_t *source, int width, int height, uint8_t *dest, uint32_t &complength);
+ avhuff_error encode_video_lossless(const uint8_t *source, int width, int height, uint8_t *dest, uint32_t &complength);
// video encoding contexts
deltarle_encoder m_ycontext;
@@ -127,7 +127,7 @@ private:
deltarle_encoder m_crcontext;
// audio encoding contexts
- std::vector<UINT8> m_audiobuffer;
+ std::vector<uint8_t> m_audiobuffer;
#if AVHUFF_USE_FLAC
flac_encoder m_flac_encoder;
#else
@@ -150,7 +150,7 @@ public:
void configure(const avhuff_decompress_config &config);
// encode/decode
- avhuff_error decode_data(const UINT8 *source, UINT32 complength, UINT8 *dest);
+ avhuff_error decode_data(const uint8_t *source, uint32_t complength, uint8_t *dest);
private:
// delta-RLE Huffman decoder
@@ -166,21 +166,21 @@ private:
// decoding
void flush_rle() { m_rlecount = 0; }
- UINT32 decode_one(bitstream_in &bitbuf);
+ uint32_t decode_one(bitstream_in &bitbuf);
huffman_error import_tree_rle(bitstream_in &bitbuf) { return m_decoder.import_tree_rle(bitbuf); }
private:
// internal state
int m_rlecount;
- UINT8 m_prevdata;
+ uint8_t m_prevdata;
huffman_decoder<256 + 16> m_decoder;
};
// internal helpers
- avhuff_error decode_audio(int channels, int samples, const UINT8 *source, UINT8 **dest, UINT32 dxor, const UINT8 *sizes);
- avhuff_error decode_video(int width, int height, const UINT8 *source, UINT32 complength, UINT8 *dest, UINT32 dstride, UINT32 dxor);
- avhuff_error decode_video_lossless(int width, int height, const UINT8 *source, UINT32 complength, UINT8 *dest, UINT32 dstride, UINT32 dxor);
+ avhuff_error decode_audio(int channels, int samples, const uint8_t *source, uint8_t **dest, uint32_t dxor, const uint8_t *sizes);
+ avhuff_error decode_video(int width, int height, const uint8_t *source, uint32_t complength, uint8_t *dest, uint32_t dstride, uint32_t dxor);
+ avhuff_error decode_video_lossless(int width, int height, const uint8_t *source, uint32_t complength, uint8_t *dest, uint32_t dstride, uint32_t dxor);
// internal state
avhuff_decompress_config m_config;
diff --git a/src/lib/util/bitmap.cpp b/src/lib/util/bitmap.cpp
index 2436e474136..b70d7ce1c8b 100644
--- a/src/lib/util/bitmap.cpp
+++ b/src/lib/util/bitmap.cpp
@@ -21,9 +21,9 @@
//**************************************************************************
/** @brief alignment values; 128 bytes is the largest cache line on typical architectures today. */
-const UINT32 BITMAP_OVERALL_ALIGN = 128;
+const uint32_t BITMAP_OVERALL_ALIGN = 128;
/** @brief The bitmap rowbytes align. */
-const UINT32 BITMAP_ROWBYTES_ALIGN = 128;
+const uint32_t BITMAP_ROWBYTES_ALIGN = 128;
@@ -36,7 +36,7 @@ const UINT32 BITMAP_ROWBYTES_ALIGN = 128;
// rowpixels value
//-------------------------------------------------
-inline INT32 bitmap_t::compute_rowpixels(int width, int xslop)
+inline int32_t bitmap_t::compute_rowpixels(int width, int xslop)
{
int rowpixels_align = BITMAP_ROWBYTES_ALIGN / (m_bpp / 8);
return ((width + 2 * xslop + (rowpixels_align - 1)) / rowpixels_align) * rowpixels_align;
@@ -51,7 +51,7 @@ inline INT32 bitmap_t::compute_rowpixels(int width, int xslop)
inline void bitmap_t::compute_base(int xslop, int yslop)
{
m_base = m_alloc + (m_rowpixels * yslop + xslop) * (m_bpp / 8);
- UINT64 aligned_base = ((reinterpret_cast<UINT64>(m_base) + (BITMAP_OVERALL_ALIGN - 1)) / BITMAP_OVERALL_ALIGN) * BITMAP_OVERALL_ALIGN;
+ uint64_t aligned_base = ((reinterpret_cast<uint64_t>(m_base) + (BITMAP_OVERALL_ALIGN - 1)) / BITMAP_OVERALL_ALIGN) * BITMAP_OVERALL_ALIGN;
m_base = reinterpret_cast<void *>(aligned_base);
}
@@ -191,7 +191,7 @@ void bitmap_t::allocate(int width, int height, int xslop, int yslop)
// allocate memory for the bitmap itself
m_allocbytes = m_rowpixels * (m_height + 2 * yslop) * m_bpp / 8;
m_allocbytes += BITMAP_OVERALL_ALIGN - 1;
- m_alloc = new UINT8[m_allocbytes];
+ m_alloc = new uint8_t[m_allocbytes];
// clear to 0 by default
memset(m_alloc, 0, m_allocbytes);
@@ -225,7 +225,7 @@ void bitmap_t::resize(int width, int height, int xslop, int yslop)
// determine how much memory we need for the new bitmap
int new_rowpixels = compute_rowpixels(width, xslop);
- UINT32 new_allocbytes = new_rowpixels * (height + 2 * yslop) * m_bpp / 8;
+ uint32_t new_allocbytes = new_rowpixels * (height + 2 * yslop) * m_bpp / 8;
new_allocbytes += BITMAP_OVERALL_ALIGN - 1;
// if we need more memory, just realloc
@@ -354,7 +354,7 @@ void bitmap_t::set_palette(palette_t *palette)
}
/**
- * @fn void bitmap_t::fill(UINT32 color, const rectangle &cliprect)
+ * @fn void bitmap_t::fill(uint32_t color, const rectangle &cliprect)
*
* @brief -------------------------------------------------
* fill -- fill a bitmap with a solid color
@@ -364,7 +364,7 @@ void bitmap_t::set_palette(palette_t *palette)
* @param cliprect The cliprect.
*/
-void bitmap_t::fill(UINT32 color, const rectangle &cliprect)
+void bitmap_t::fill(uint32_t color, const rectangle &cliprect)
{
// if we have a cliprect, intersect with that
rectangle fill = cliprect;
@@ -377,29 +377,29 @@ void bitmap_t::fill(UINT32 color, const rectangle &cliprect)
{
case 8:
// 8bpp always uses memset
- for (INT32 y = fill.min_y; y <= fill.max_y; y++)
- memset(raw_pixptr(y, fill.min_x), (UINT8)color, fill.width());
+ for (int32_t y = fill.min_y; y <= fill.max_y; y++)
+ memset(raw_pixptr(y, fill.min_x), (uint8_t)color, fill.width());
break;
case 16:
// 16bpp can use memset if the bytes are equal
- if ((UINT8)(color >> 8) == (UINT8)color)
+ if ((uint8_t)(color >> 8) == (uint8_t)color)
{
- for (INT32 y = fill.min_y; y <= fill.max_y; y++)
- memset(raw_pixptr(y, fill.min_x), (UINT8)color, fill.width() * 2);
+ for (int32_t y = fill.min_y; y <= fill.max_y; y++)
+ memset(raw_pixptr(y, fill.min_x), (uint8_t)color, fill.width() * 2);
}
else
{
// Fill the first line the hard way
- UINT16 *destrow = &pixt<UINT16>(fill.min_y);
- for (INT32 x = fill.min_x; x <= fill.max_x; x++)
- destrow[x] = (UINT16)color;
+ uint16_t *destrow = &pixt<uint16_t>(fill.min_y);
+ for (int32_t x = fill.min_x; x <= fill.max_x; x++)
+ destrow[x] = (uint16_t)color;
// For the other lines, just copy the first one
- void *destrow0 = &pixt<UINT16>(fill.min_y, fill.min_x);
- for (INT32 y = fill.min_y + 1; y <= fill.max_y; y++)
+ void *destrow0 = &pixt<uint16_t>(fill.min_y, fill.min_x);
+ for (int32_t y = fill.min_y + 1; y <= fill.max_y; y++)
{
- destrow = &pixt<UINT16>(y, fill.min_x);
+ destrow = &pixt<uint16_t>(y, fill.min_x);
memcpy(destrow, destrow0, fill.width() * 2);
}
}
@@ -407,23 +407,23 @@ void bitmap_t::fill(UINT32 color, const rectangle &cliprect)
case 32:
// 32bpp can use memset if the bytes are equal
- if ((UINT8)(color >> 8) == (UINT8)color && (UINT16)(color >> 16) == (UINT16)color)
+ if ((uint8_t)(color >> 8) == (uint8_t)color && (uint16_t)(color >> 16) == (uint16_t)color)
{
- for (INT32 y = fill.min_y; y <= fill.max_y; y++)
- memset(&pixt<UINT32>(y, fill.min_x), (UINT8)color, fill.width() * 4);
+ for (int32_t y = fill.min_y; y <= fill.max_y; y++)
+ memset(&pixt<uint32_t>(y, fill.min_x), (uint8_t)color, fill.width() * 4);
}
else
{
// Fill the first line the hard way
- UINT32 *destrow = &pixt<UINT32>(fill.min_y);
- for (INT32 x = fill.min_x; x <= fill.max_x; x++)
- destrow[x] = (UINT32)color;
+ uint32_t *destrow = &pixt<uint32_t>(fill.min_y);
+ for (int32_t x = fill.min_x; x <= fill.max_x; x++)
+ destrow[x] = (uint32_t)color;
// For the other lines, just copy the first one
- UINT32 *destrow0 = &pixt<UINT32>(fill.min_y, fill.min_x);
- for (INT32 y = fill.min_y + 1; y <= fill.max_y; y++)
+ uint32_t *destrow0 = &pixt<uint32_t>(fill.min_y, fill.min_x);
+ for (int32_t y = fill.min_y + 1; y <= fill.max_y; y++)
{
- destrow = &pixt<UINT32>(y, fill.min_x);
+ destrow = &pixt<uint32_t>(y, fill.min_x);
memcpy(destrow, destrow0, fill.width() * 4);
}
}
@@ -431,23 +431,23 @@ void bitmap_t::fill(UINT32 color, const rectangle &cliprect)
case 64:
// 64bpp can use memset if the bytes are equal
- if ((UINT8)(color >> 8) == (UINT8)color && (UINT16)(color >> 16) == (UINT16)color)
+ if ((uint8_t)(color >> 8) == (uint8_t)color && (uint16_t)(color >> 16) == (uint16_t)color)
{
- for (INT32 y = fill.min_y; y <= fill.max_y; y++)
- memset(&pixt<UINT64>(y, fill.min_x), (UINT8)color, fill.width() * 8);
+ for (int32_t y = fill.min_y; y <= fill.max_y; y++)
+ memset(&pixt<uint64_t>(y, fill.min_x), (uint8_t)color, fill.width() * 8);
}
else
{
// Fill the first line the hard way
- UINT64 *destrow = &pixt<UINT64>(fill.min_y);
- for (INT32 x = fill.min_x; x <= fill.max_x; x++)
- destrow[x] = (UINT64)color;
+ uint64_t *destrow = &pixt<uint64_t>(fill.min_y);
+ for (int32_t x = fill.min_x; x <= fill.max_x; x++)
+ destrow[x] = (uint64_t)color;
// For the other lines, just copy the first one
- UINT64 *destrow0 = &pixt<UINT64>(fill.min_y, fill.min_x);
- for (INT32 y = fill.min_y + 1; y <= fill.max_y; y++)
+ uint64_t *destrow0 = &pixt<uint64_t>(fill.min_y, fill.min_x);
+ for (int32_t y = fill.min_y + 1; y <= fill.max_y; y++)
{
- destrow = &pixt<UINT64>(y, fill.min_x);
+ destrow = &pixt<uint64_t>(y, fill.min_x);
memcpy(destrow, destrow0, fill.width() * 8);
}
}
diff --git a/src/lib/util/bitmap.h b/src/lib/util/bitmap.h
index 23d05af90df..7d367bcb5cb 100644
--- a/src/lib/util/bitmap.h
+++ b/src/lib/util/bitmap.h
@@ -45,14 +45,14 @@ public:
// construction/destruction
rectangle()
: min_x(0), max_x(0), min_y(0), max_y(0) { }
- rectangle(INT32 minx, INT32 maxx, INT32 miny, INT32 maxy)
+ rectangle(int32_t minx, int32_t maxx, int32_t miny, int32_t maxy)
: min_x(minx), max_x(maxx), min_y(miny), max_y(maxy) { }
// getters
- INT32 left() const { return min_x; }
- INT32 right() const { return max_x; }
- INT32 top() const { return min_y; }
- INT32 bottom() const { return max_y; }
+ int32_t left() const { return min_x; }
+ int32_t right() const { return max_x; }
+ int32_t top() const { return min_y; }
+ int32_t bottom() const { return max_y; }
// compute intersection with another rect
rectangle &operator&=(const rectangle &src)
@@ -84,32 +84,32 @@ public:
// other helpers
bool empty() const { return (min_x > max_x || min_y > max_y); }
- bool contains(INT32 x, INT32 y) const { return (x >= min_x && x <= max_x && y >= min_y && y <= max_y); }
+ bool contains(int32_t x, int32_t y) const { return (x >= min_x && x <= max_x && y >= min_y && y <= max_y); }
bool contains(const rectangle &rect) const { return (min_x <= rect.min_x && max_x >= rect.max_x && min_y <= rect.min_y && max_y >= rect.max_y); }
- INT32 width() const { return max_x + 1 - min_x; }
- INT32 height() const { return max_y + 1 - min_y; }
- INT32 xcenter() const { return (min_x + max_x + 1) / 2; }
- INT32 ycenter() const { return (min_y + max_y + 1) / 2; }
+ int32_t width() const { return max_x + 1 - min_x; }
+ int32_t height() const { return max_y + 1 - min_y; }
+ int32_t xcenter() const { return (min_x + max_x + 1) / 2; }
+ int32_t ycenter() const { return (min_y + max_y + 1) / 2; }
// setters
- void set(INT32 minx, INT32 maxx, INT32 miny, INT32 maxy) { min_x = minx; max_x = maxx; min_y = miny; max_y = maxy; }
- void setx(INT32 minx, INT32 maxx) { min_x = minx; max_x = maxx; }
- void sety(INT32 miny, INT32 maxy) { min_y = miny; max_y = maxy; }
- void set_width(INT32 width) { max_x = min_x + width - 1; }
- void set_height(INT32 height) { max_y = min_y + height - 1; }
- void set_origin(INT32 x, INT32 y) { max_x += x - min_x; max_y += y - min_y; min_x = x; min_y = y; }
- void set_size(INT32 width, INT32 height) { set_width(width); set_height(height); }
+ void set(int32_t minx, int32_t maxx, int32_t miny, int32_t maxy) { min_x = minx; max_x = maxx; min_y = miny; max_y = maxy; }
+ void setx(int32_t minx, int32_t maxx) { min_x = minx; max_x = maxx; }
+ void sety(int32_t miny, int32_t maxy) { min_y = miny; max_y = maxy; }
+ void set_width(int32_t width) { max_x = min_x + width - 1; }
+ void set_height(int32_t height) { max_y = min_y + height - 1; }
+ void set_origin(int32_t x, int32_t y) { max_x += x - min_x; max_y += y - min_y; min_x = x; min_y = y; }
+ void set_size(int32_t width, int32_t height) { set_width(width); set_height(height); }
// offset helpers
- void offset(INT32 xdelta, INT32 ydelta) { min_x += xdelta; max_x += xdelta; min_y += ydelta; max_y += ydelta; }
- void offsetx(INT32 delta) { min_x += delta; max_x += delta; }
- void offsety(INT32 delta) { min_y += delta; max_y += delta; }
+ void offset(int32_t xdelta, int32_t ydelta) { min_x += xdelta; max_x += xdelta; min_y += ydelta; max_y += ydelta; }
+ void offsetx(int32_t delta) { min_x += delta; max_x += delta; }
+ void offsety(int32_t delta) { min_y += delta; max_y += delta; }
// internal state
- INT32 min_x; // minimum X, or left coordinate
- INT32 max_x; // maximum X, or right coordinate (inclusive)
- INT32 min_y; // minimum Y, or top coordinate
- INT32 max_y; // maximum Y, or bottom coordinate (inclusive)
+ int32_t min_x; // minimum X, or left coordinate
+ int32_t max_x; // maximum X, or right coordinate (inclusive)
+ int32_t min_y; // minimum Y, or top coordinate
+ int32_t max_y; // maximum Y, or bottom coordinate (inclusive)
};
@@ -135,11 +135,11 @@ public:
void reset();
// getters
- INT32 width() const { return m_width; }
- INT32 height() const { return m_height; }
- INT32 rowpixels() const { return m_rowpixels; }
- INT32 rowbytes() const { return m_rowpixels * m_bpp / 8; }
- UINT8 bpp() const { return m_bpp; }
+ int32_t width() const { return m_width; }
+ int32_t height() const { return m_height; }
+ int32_t rowpixels() const { return m_rowpixels; }
+ int32_t rowbytes() const { return m_rowpixels * m_bpp / 8; }
+ uint8_t bpp() const { return m_bpp; }
bitmap_format format() const { return m_format; }
bool valid() const { return (m_base != nullptr); }
palette_t *palette() const { return m_palette; }
@@ -151,9 +151,9 @@ public:
// operations
void set_palette(palette_t *palette);
- void fill(UINT32 color) { fill(color, m_cliprect); }
- void fill(UINT32 color, const rectangle &cliprect);
- void plot_box(int x, int y, int width, int height, UINT32 color)
+ void fill(uint32_t color) { fill(color, m_cliprect); }
+ void fill(uint32_t color, const rectangle &cliprect);
+ void plot_box(int x, int y, int width, int height, uint32_t color)
{
rectangle clip(x, x + width - 1, y, y + height - 1);
fill(color, clip);
@@ -161,8 +161,8 @@ public:
// pixel access
template<typename _PixelType>
- _PixelType &pixt(INT32 y, INT32 x = 0) const { return *(reinterpret_cast<_PixelType *>(m_base) + y * m_rowpixels + x); }
- void *raw_pixptr(INT32 y, INT32 x = 0) const { return reinterpret_cast<UINT8 *>(m_base) + (y * m_rowpixels + x) * m_bpp / 8; }
+ _PixelType &pixt(int32_t y, int32_t x = 0) const { return *(reinterpret_cast<_PixelType *>(m_base) + y * m_rowpixels + x); }
+ void *raw_pixptr(int32_t y, int32_t x = 0) const { return reinterpret_cast<uint8_t *>(m_base) + (y * m_rowpixels + x) * m_bpp / 8; }
protected:
// for use by subclasses only to ensure type correctness
@@ -171,18 +171,18 @@ protected:
private:
// internal helpers
- INT32 compute_rowpixels(int width, int xslop);
+ int32_t compute_rowpixels(int width, int xslop);
void compute_base(int xslop, int yslop);
// internal state
- UINT8 * m_alloc; // pointer to allocated pixel memory
- UINT32 m_allocbytes; // size of our allocation
+ uint8_t * m_alloc; // pointer to allocated pixel memory
+ uint32_t m_allocbytes; // size of our allocation
void * m_base; // pointer to pixel (0,0) (adjusted for padding)
- INT32 m_rowpixels; // pixels per row (including padding)
- INT32 m_width; // width of the bitmap
- INT32 m_height; // height of the bitmap
+ int32_t m_rowpixels; // pixels per row (including padding)
+ int32_t m_width; // width of the bitmap
+ int32_t m_height; // height of the bitmap
bitmap_format m_format; // format of the bitmap
- UINT8 m_bpp; // bits per pixel
+ uint8_t m_bpp; // bits per pixel
palette_t * m_palette; // optional palette
rectangle m_cliprect; // a clipping rectangle covering the full bitmap
};
@@ -200,17 +200,17 @@ private:
protected:
// construction/destruction -- subclasses only
bitmap8_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 8, width, height, xslop, yslop) { }
- bitmap8_t(bitmap_format format, UINT8 *base, int width, int height, int rowpixels) : bitmap_t(format, 8, base, width, height, rowpixels) { assert(valid_format(format)); }
+ bitmap8_t(bitmap_format format, uint8_t *base, int width, int height, int rowpixels) : bitmap_t(format, 8, base, width, height, rowpixels) { assert(valid_format(format)); }
bitmap8_t(bitmap_format format, bitmap8_t &source, const rectangle &subrect) : bitmap_t(format, 8, source, subrect) { }
public:
// getters
- UINT8 bpp() const { return 8; }
+ uint8_t bpp() const { return 8; }
// pixel accessors
- typedef UINT8 pixel_t;
- pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); }
- pixel_t &pix8(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); }
+ typedef uint8_t pixel_t;
+ pixel_t &pix(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); }
+ pixel_t &pix8(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); }
};
// 16bpp bitmaps
@@ -223,17 +223,17 @@ private:
protected:
// construction/destruction -- subclasses only
bitmap16_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 16, width, height, xslop, yslop) { assert(valid_format(format)); }
- bitmap16_t(bitmap_format format, UINT16 *base, int width, int height, int rowpixels) : bitmap_t(format, 16, base, width, height, rowpixels) { assert(valid_format(format)); }
+ bitmap16_t(bitmap_format format, uint16_t *base, int width, int height, int rowpixels) : bitmap_t(format, 16, base, width, height, rowpixels) { assert(valid_format(format)); }
bitmap16_t(bitmap_format format, bitmap16_t &source, const rectangle &subrect) : bitmap_t(format, 16, source, subrect) { }
public:
// getters
- UINT8 bpp() const { return 16; }
+ uint8_t bpp() const { return 16; }
// pixel accessors
- typedef UINT16 pixel_t;
- pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); }
- pixel_t &pix16(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); }
+ typedef uint16_t pixel_t;
+ pixel_t &pix(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); }
+ pixel_t &pix16(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); }
};
// 32bpp bitmaps
@@ -246,17 +246,17 @@ private:
protected:
// construction/destruction -- subclasses only
bitmap32_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 32, width, height, xslop, yslop) { assert(valid_format(format)); }
- bitmap32_t(bitmap_format format, UINT32 *base, int width, int height, int rowpixels) : bitmap_t(format, 32, base, width, height, rowpixels) { assert(valid_format(format)); }
+ bitmap32_t(bitmap_format format, uint32_t *base, int width, int height, int rowpixels) : bitmap_t(format, 32, base, width, height, rowpixels) { assert(valid_format(format)); }
bitmap32_t(bitmap_format format, bitmap32_t &source, const rectangle &subrect) : bitmap_t(format, 32, source, subrect) { }
public:
// getters
- UINT8 bpp() const { return 32; }
+ uint8_t bpp() const { return 32; }
// pixel accessors
- typedef UINT32 pixel_t;
- pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); }
- pixel_t &pix32(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); }
+ typedef uint32_t pixel_t;
+ pixel_t &pix(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); }
+ pixel_t &pix32(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); }
};
// 64bpp bitmaps
@@ -269,17 +269,17 @@ private:
protected:
// construction/destruction -- subclasses only
bitmap64_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 64, width, height, xslop, yslop) { assert(valid_format(format)); }
- bitmap64_t(bitmap_format format, UINT64 *base, int width, int height, int rowpixels) : bitmap_t(format, 64, base, width, height, rowpixels) { assert(valid_format(format)); }
+ bitmap64_t(bitmap_format format, uint64_t *base, int width, int height, int rowpixels) : bitmap_t(format, 64, base, width, height, rowpixels) { assert(valid_format(format)); }
bitmap64_t(bitmap_format format, bitmap64_t &source, const rectangle &subrect) : bitmap_t(format, 64, source, subrect) { }
public:
// getters
- UINT8 bpp() const { return 64; }
+ uint8_t bpp() const { return 64; }
// pixel accessors
- typedef UINT64 pixel_t;
- pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); }
- pixel_t &pix64(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); }
+ typedef uint64_t pixel_t;
+ pixel_t &pix(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); }
+ pixel_t &pix64(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); }
};
@@ -293,9 +293,9 @@ class bitmap_ind8 : public bitmap8_t
public:
// construction/destruction
bitmap_ind8(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap8_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_ind8(UINT8 *base, int width, int height, int rowpixels) : bitmap8_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_ind8(uint8_t *base, int width, int height, int rowpixels) : bitmap8_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_ind8(bitmap_ind8 &source, const rectangle &subrect) : bitmap8_t(k_bitmap_format, source, subrect) { }
- void wrap(UINT8 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
+ void wrap(uint8_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(const bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); }
// getters
@@ -310,9 +310,9 @@ class bitmap_ind16 : public bitmap16_t
public:
// construction/destruction
bitmap_ind16(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap16_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_ind16(UINT16 *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_ind16(uint16_t *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_ind16(bitmap_ind16 &source, const rectangle &subrect) : bitmap16_t(k_bitmap_format, source, subrect) { }
- void wrap(UINT16 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
+ void wrap(uint16_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(const bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); }
// getters
@@ -327,9 +327,9 @@ class bitmap_ind32 : public bitmap32_t
public:
// construction/destruction
bitmap_ind32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_ind32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_ind32(uint32_t *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_ind32(bitmap_ind32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { }
- void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
+ void wrap(uint32_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(const bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); }
// getters
@@ -344,9 +344,9 @@ class bitmap_ind64 : public bitmap64_t
public:
// construction/destruction
bitmap_ind64(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap64_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_ind64(UINT64 *base, int width, int height, int rowpixels) : bitmap64_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_ind64(uint64_t *base, int width, int height, int rowpixels) : bitmap64_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_ind64(bitmap_ind64 &source, const rectangle &subrect) : bitmap64_t(k_bitmap_format, source, subrect) { }
- void wrap(UINT64 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
+ void wrap(uint64_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(const bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); }
// getters
@@ -364,9 +364,9 @@ class bitmap_yuy16 : public bitmap16_t
public:
// construction/destruction
bitmap_yuy16(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap16_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_yuy16(UINT16 *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_yuy16(uint16_t *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_yuy16(bitmap_yuy16 &source, const rectangle &subrect) : bitmap16_t(k_bitmap_format, source, subrect) { }
- void wrap(UINT16 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
+ void wrap(uint16_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(const bitmap_yuy16 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); }
// getters
@@ -381,9 +381,9 @@ class bitmap_rgb32 : public bitmap32_t
public:
// construction/destruction
bitmap_rgb32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_rgb32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_rgb32(uint32_t *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_rgb32(bitmap_rgb32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { }
- void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
+ void wrap(uint32_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(const bitmap_rgb32 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); }
// getters
@@ -398,9 +398,9 @@ class bitmap_argb32 : public bitmap32_t
public:
// construction/destruction
bitmap_argb32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { }
- bitmap_argb32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
+ bitmap_argb32(uint32_t *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
bitmap_argb32(bitmap_argb32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { }
- void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
+ void wrap(uint32_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); }
void wrap(const bitmap_argb32 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); }
// getters
diff --git a/src/lib/util/bitstream.h b/src/lib/util/bitstream.h
index 2f36271d296..0056c4ce38e 100644
--- a/src/lib/util/bitstream.h
+++ b/src/lib/util/bitstream.h
@@ -25,25 +25,25 @@ class bitstream_in
{
public:
// construction/destruction
- bitstream_in(const void *src, UINT32 srclength);
+ bitstream_in(const void *src, uint32_t srclength);
// getters
bool overflow() const { return ((m_doffset - m_bits / 8) > m_dlength); }
- UINT32 read_offset() const;
+ uint32_t read_offset() const;
// operations
- UINT32 read(int numbits);
- UINT32 peek(int numbits);
+ uint32_t read(int numbits);
+ uint32_t peek(int numbits);
void remove(int numbits);
- UINT32 flush();
+ uint32_t flush();
private:
// internal state
- UINT32 m_buffer; // current bit accumulator
+ uint32_t m_buffer; // current bit accumulator
int m_bits; // number of bits in the accumulator
- const UINT8 * m_read; // read pointer
- UINT32 m_doffset; // byte offset within the data
- UINT32 m_dlength; // length of the data
+ const uint8_t * m_read; // read pointer
+ uint32_t m_doffset; // byte offset within the data
+ uint32_t m_dlength; // length of the data
};
@@ -52,22 +52,22 @@ class bitstream_out
{
public:
// construction/destruction
- bitstream_out(void *dest, UINT32 destlength);
+ bitstream_out(void *dest, uint32_t destlength);
// getters
bool overflow() const { return (m_doffset > m_dlength); }
// operations
- void write(UINT32 newbits, int numbits);
- UINT32 flush();
+ void write(uint32_t newbits, int numbits);
+ uint32_t flush();
private:
// internal state
- UINT32 m_buffer; // current bit accumulator
+ uint32_t m_buffer; // current bit accumulator
int m_bits; // number of bits in the accumulator
- UINT8 * m_write; // write pointer
- UINT32 m_doffset; // byte offset within the data
- UINT32 m_dlength; // length of the data
+ uint8_t * m_write; // write pointer
+ uint32_t m_doffset; // byte offset within the data
+ uint32_t m_dlength; // length of the data
};
@@ -80,10 +80,10 @@ private:
// bitstream_in - constructor
//-------------------------------------------------
-inline bitstream_in::bitstream_in(const void *src, UINT32 srclength)
+inline bitstream_in::bitstream_in(const void *src, uint32_t srclength)
: m_buffer(0),
m_bits(0),
- m_read(reinterpret_cast<const UINT8 *>(src)),
+ m_read(reinterpret_cast<const uint8_t *>(src)),
m_doffset(0),
m_dlength(srclength)
{
@@ -95,7 +95,7 @@ inline bitstream_in::bitstream_in(const void *src, UINT32 srclength)
// but don't advance the input pointer
//-------------------------------------------------
-inline UINT32 bitstream_in::peek(int numbits)
+inline uint32_t bitstream_in::peek(int numbits)
{
if (numbits == 0)
return 0;
@@ -133,9 +133,9 @@ inline void bitstream_in::remove(int numbits)
// read - fetch the requested number of bits
//-------------------------------------------------
-inline UINT32 bitstream_in::read(int numbits)
+inline uint32_t bitstream_in::read(int numbits)
{
- UINT32 result = peek(numbits);
+ uint32_t result = peek(numbits);
remove(numbits);
return result;
}
@@ -145,9 +145,9 @@ inline UINT32 bitstream_in::read(int numbits)
// read_offset - return the current read offset
//-------------------------------------------------
-inline UINT32 bitstream_in::read_offset() const
+inline uint32_t bitstream_in::read_offset() const
{
- UINT32 result = m_doffset;
+ uint32_t result = m_doffset;
int bits = m_bits;
while (bits >= 8)
{
@@ -162,7 +162,7 @@ inline UINT32 bitstream_in::read_offset() const
// flush - flush to the nearest byte
//-------------------------------------------------
-inline UINT32 bitstream_in::flush()
+inline uint32_t bitstream_in::flush()
{
while (m_bits >= 8)
{
@@ -178,10 +178,10 @@ inline UINT32 bitstream_in::flush()
// bitstream_out - constructor
//-------------------------------------------------
-inline bitstream_out::bitstream_out(void *dest, UINT32 destlength)
+inline bitstream_out::bitstream_out(void *dest, uint32_t destlength)
: m_buffer(0),
m_bits(0),
- m_write(reinterpret_cast<UINT8 *>(dest)),
+ m_write(reinterpret_cast<uint8_t *>(dest)),
m_doffset(0),
m_dlength(destlength)
{
@@ -194,7 +194,7 @@ inline bitstream_out::bitstream_out(void *dest, UINT32 destlength)
// data stream
//-------------------------------------------------
-inline void bitstream_out::write(UINT32 newbits, int numbits)
+inline void bitstream_out::write(uint32_t newbits, int numbits)
{
// flush the buffer if we're going to overflow it
if (m_bits + numbits > 32)
@@ -224,7 +224,7 @@ inline void bitstream_out::write(UINT32 newbits, int numbits)
// final output size in bytes
//-------------------------------------------------
-inline UINT32 bitstream_out::flush()
+inline uint32_t bitstream_out::flush()
{
while (m_bits > 0)
{
diff --git a/src/lib/util/cdrom.cpp b/src/lib/util/cdrom.cpp
index 7b5dae18a4e..3da270b55e3 100644
--- a/src/lib/util/cdrom.cpp
+++ b/src/lib/util/cdrom.cpp
@@ -130,7 +130,7 @@ struct cdrom_file
-------------------------------------------------*/
/**
- * @fn static inline UINT32 physical_to_chd_lba(cdrom_file *file, UINT32 physlba, UINT32 &tracknum)
+ * @fn static inline uint32_t physical_to_chd_lba(cdrom_file *file, uint32_t physlba, uint32_t &tracknum)
*
* @brief Physical to chd lba.
*
@@ -138,12 +138,12 @@ struct cdrom_file
* @param physlba The physlba.
* @param [in,out] tracknum The tracknum.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-static inline UINT32 physical_to_chd_lba(cdrom_file *file, UINT32 physlba, UINT32 &tracknum)
+static inline uint32_t physical_to_chd_lba(cdrom_file *file, uint32_t physlba, uint32_t &tracknum)
{
- UINT32 chdlba;
+ uint32_t chdlba;
int track;
/* loop until our current LBA is less than the start LBA of the next track */
@@ -164,7 +164,7 @@ static inline UINT32 physical_to_chd_lba(cdrom_file *file, UINT32 physlba, UINT3
-------------------------------------------------*/
/**
- * @fn static inline UINT32 logical_to_chd_lba(cdrom_file *file, UINT32 loglba, UINT32 &tracknum)
+ * @fn static inline uint32_t logical_to_chd_lba(cdrom_file *file, uint32_t loglba, uint32_t &tracknum)
*
* @brief Logical to chd lba.
*
@@ -172,12 +172,12 @@ static inline UINT32 physical_to_chd_lba(cdrom_file *file, UINT32 physlba, UINT3
* @param loglba The loglba.
* @param [in,out] tracknum The tracknum.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-static inline UINT32 logical_to_chd_lba(cdrom_file *file, UINT32 loglba, UINT32 &tracknum)
+static inline uint32_t logical_to_chd_lba(cdrom_file *file, uint32_t loglba, uint32_t &tracknum)
{
- UINT32 chdlba, physlba;
+ uint32_t chdlba, physlba;
int track;
/* loop until our current LBA is less than the start LBA of the next track */
@@ -221,7 +221,7 @@ cdrom_file *cdrom_open(const char *inputfile)
{
int i;
cdrom_file *file;
- UINT32 physofs, logofs;
+ uint32_t physofs, logofs;
/* allocate memory for the CD-ROM file */
file = new (std::nothrow) cdrom_file();
@@ -317,7 +317,7 @@ cdrom_file *cdrom_open(chd_file *chd)
{
int i;
cdrom_file *file;
- UINT32 physofs, chdofs, logofs;
+ uint32_t physofs, chdofs, logofs;
chd_error err;
/* punt if no CHD */
@@ -432,7 +432,7 @@ void cdrom_close(cdrom_file *file)
***************************************************************************/
/**
- * @fn chd_error read_partial_sector(cdrom_file *file, void *dest, UINT32 lbasector, UINT32 chdsector, UINT32 tracknum, UINT32 startoffs, UINT32 length)
+ * @fn chd_error read_partial_sector(cdrom_file *file, void *dest, uint32_t lbasector, uint32_t chdsector, uint32_t tracknum, uint32_t startoffs, uint32_t length)
*
* @brief Reads partial sector.
*
@@ -447,7 +447,7 @@ void cdrom_close(cdrom_file *file)
* @return The partial sector.
*/
-chd_error read_partial_sector(cdrom_file *file, void *dest, UINT32 lbasector, UINT32 chdsector, UINT32 tracknum, UINT32 startoffs, UINT32 length, bool phys=false)
+chd_error read_partial_sector(cdrom_file *file, void *dest, uint32_t lbasector, uint32_t chdsector, uint32_t tracknum, uint32_t startoffs, uint32_t length, bool phys=false)
{
chd_error result = CHDERR_NONE;
bool needswap = false;
@@ -466,7 +466,7 @@ chd_error read_partial_sector(cdrom_file *file, void *dest, UINT32 lbasector, UI
// if a CHD, just read
if (file->chd != nullptr)
{
- result = file->chd->read_bytes(UINT64(chdsector) * UINT64(CD_FRAME_SIZE) + startoffs, dest, length);
+ result = file->chd->read_bytes(uint64_t(chdsector) * uint64_t(CD_FRAME_SIZE) + startoffs, dest, length);
/* swap CDDA in the case of LE GDROMs */
if ((file->cdtoc.flags & CD_FLAG_GDROMLE) && (file->cdtoc.tracks[tracknum].trktype == CD_TRACK_AUDIO))
needswap = true;
@@ -476,7 +476,7 @@ chd_error read_partial_sector(cdrom_file *file, void *dest, UINT32 lbasector, UI
// else read from the appropriate file
util::core_file &srcfile = *file->fhandle[tracknum];
- UINT64 sourcefileoffset = file->track_info.track[tracknum].offset;
+ uint64_t sourcefileoffset = file->track_info.track[tracknum].offset;
int bytespersector = file->cdtoc.tracks[tracknum].datasize + file->cdtoc.tracks[tracknum].subsize;
sourcefileoffset += chdsector * bytespersector + startoffs;
@@ -491,7 +491,7 @@ chd_error read_partial_sector(cdrom_file *file, void *dest, UINT32 lbasector, UI
if (needswap)
{
- UINT8 *buffer = (UINT8 *)dest - startoffs;
+ uint8_t *buffer = (uint8_t *)dest - startoffs;
for (int swapindex = startoffs; swapindex < 2352; swapindex += 2 )
{
int swaptemp = buffer[ swapindex ];
@@ -509,7 +509,7 @@ chd_error read_partial_sector(cdrom_file *file, void *dest, UINT32 lbasector, UI
-------------------------------------------------*/
/**
- * @fn UINT32 cdrom_read_data(cdrom_file *file, UINT32 lbasector, void *buffer, UINT32 datatype, bool phys)
+ * @fn uint32_t cdrom_read_data(cdrom_file *file, uint32_t lbasector, void *buffer, uint32_t datatype, bool phys)
*
* @brief Cdrom read data.
*
@@ -519,17 +519,17 @@ chd_error read_partial_sector(cdrom_file *file, void *dest, UINT32 lbasector, UI
* @param datatype The datatype.
* @param phys true to physical.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-UINT32 cdrom_read_data(cdrom_file *file, UINT32 lbasector, void *buffer, UINT32 datatype, bool phys)
+uint32_t cdrom_read_data(cdrom_file *file, uint32_t lbasector, void *buffer, uint32_t datatype, bool phys)
{
if (file == nullptr)
return 0;
// compute CHD sector and tracknumber
- UINT32 tracknum = 0;
- UINT32 chdsector;
+ uint32_t tracknum = 0;
+ uint32_t chdsector;
if (phys)
{
@@ -541,7 +541,7 @@ UINT32 cdrom_read_data(cdrom_file *file, UINT32 lbasector, void *buffer, UINT32
}
/* copy out the requested sector */
- UINT32 tracktype = file->cdtoc.tracks[tracknum].trktype;
+ uint32_t tracktype = file->cdtoc.tracks[tracknum].trktype;
if ((datatype == tracktype) || (datatype == CD_TRACK_RAW_DONTCARE))
{
@@ -558,10 +558,10 @@ UINT32 cdrom_read_data(cdrom_file *file, UINT32 lbasector, void *buffer, UINT32
/* return 2352 byte mode 1 raw sector from 2048 bytes of mode 1 data */
if ((datatype == CD_TRACK_MODE1_RAW) && (tracktype == CD_TRACK_MODE1))
{
- UINT8 *bufptr = (UINT8 *)buffer;
- UINT32 msf = lba_to_msf(lbasector);
+ uint8_t *bufptr = (uint8_t *)buffer;
+ uint32_t msf = lba_to_msf(lbasector);
- static const UINT8 syncbytes[12] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00};
+ static const uint8_t syncbytes[12] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00};
memcpy(bufptr, syncbytes, 12);
bufptr[12] = msf>>16;
bufptr[13] = msf>>8;
@@ -595,7 +595,7 @@ UINT32 cdrom_read_data(cdrom_file *file, UINT32 lbasector, void *buffer, UINT32
-------------------------------------------------*/
/**
- * @fn UINT32 cdrom_read_subcode(cdrom_file *file, UINT32 lbasector, void *buffer, bool phys)
+ * @fn uint32_t cdrom_read_subcode(cdrom_file *file, uint32_t lbasector, void *buffer, bool phys)
*
* @brief Cdrom read subcode.
*
@@ -604,17 +604,17 @@ UINT32 cdrom_read_data(cdrom_file *file, UINT32 lbasector, void *buffer, UINT32
* @param [in,out] buffer If non-null, the buffer.
* @param phys true to physical.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-UINT32 cdrom_read_subcode(cdrom_file *file, UINT32 lbasector, void *buffer, bool phys)
+uint32_t cdrom_read_subcode(cdrom_file *file, uint32_t lbasector, void *buffer, bool phys)
{
if (file == nullptr)
return ~0;
// compute CHD sector and tracknumber
- UINT32 tracknum = 0;
- UINT32 chdsector;
+ uint32_t tracknum = 0;
+ uint32_t chdsector;
if (phys)
{
@@ -645,19 +645,19 @@ UINT32 cdrom_read_subcode(cdrom_file *file, UINT32 lbasector, void *buffer, bool
-------------------------------------------------*/
/**
- * @fn UINT32 cdrom_get_track(cdrom_file *file, UINT32 frame)
+ * @fn uint32_t cdrom_get_track(cdrom_file *file, uint32_t frame)
*
* @brief Cdrom get track.
*
* @param [in,out] file If non-null, the file.
* @param frame The frame.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-UINT32 cdrom_get_track(cdrom_file *file, UINT32 frame)
+uint32_t cdrom_get_track(cdrom_file *file, uint32_t frame)
{
- UINT32 track = 0;
+ uint32_t track = 0;
if (file == nullptr)
return ~0;
@@ -675,17 +675,17 @@ UINT32 cdrom_get_track(cdrom_file *file, UINT32 frame)
-------------------------------------------------*/
/**
- * @fn UINT32 cdrom_get_track_start(cdrom_file *file, UINT32 track)
+ * @fn uint32_t cdrom_get_track_start(cdrom_file *file, uint32_t track)
*
* @brief Cdrom get track start.
*
* @param [in,out] file If non-null, the file.
* @param track The track.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-UINT32 cdrom_get_track_start(cdrom_file *file, UINT32 track)
+uint32_t cdrom_get_track_start(cdrom_file *file, uint32_t track)
{
if (file == nullptr)
return ~0;
@@ -703,17 +703,17 @@ UINT32 cdrom_get_track_start(cdrom_file *file, UINT32 track)
-------------------------------------------------*/
/**
- * @fn UINT32 cdrom_get_track_start_phys(cdrom_file *file, UINT32 track)
+ * @fn uint32_t cdrom_get_track_start_phys(cdrom_file *file, uint32_t track)
*
* @brief Cdrom get track start physical.
*
* @param [in,out] file If non-null, the file.
* @param track The track.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-UINT32 cdrom_get_track_start_phys(cdrom_file *file, UINT32 track)
+uint32_t cdrom_get_track_start_phys(cdrom_file *file, uint32_t track)
{
if (file == nullptr)
return ~0;
@@ -843,7 +843,7 @@ const cdrom_toc *cdrom_get_toc(cdrom_file *file)
-------------------------------------------------*/
/**
- * @fn static void cdrom_get_info_from_type_string(const char *typestring, UINT32 *trktype, UINT32 *datasize)
+ * @fn static void cdrom_get_info_from_type_string(const char *typestring, uint32_t *trktype, uint32_t *datasize)
*
* @brief Cdrom get information from type string.
*
@@ -852,7 +852,7 @@ const cdrom_toc *cdrom_get_toc(cdrom_file *file)
* @param [in,out] datasize If non-null, the datasize.
*/
-static void cdrom_get_info_from_type_string(const char *typestring, UINT32 *trktype, UINT32 *datasize)
+static void cdrom_get_info_from_type_string(const char *typestring, uint32_t *trktype, uint32_t *datasize)
{
if (!strcmp(typestring, "MODE1"))
{
@@ -1035,7 +1035,7 @@ void cdrom_convert_subtype_string_to_pregap_info(const char *typestring, cdrom_t
-------------------------------------------------*/
/**
- * @fn const char *cdrom_get_type_string(UINT32 trktype)
+ * @fn const char *cdrom_get_type_string(uint32_t trktype)
*
* @brief Cdrom get type string.
*
@@ -1044,7 +1044,7 @@ void cdrom_convert_subtype_string_to_pregap_info(const char *typestring, cdrom_t
* @return null if it fails, else a char*.
*/
-const char *cdrom_get_type_string(UINT32 trktype)
+const char *cdrom_get_type_string(uint32_t trktype)
{
switch (trktype)
{
@@ -1067,7 +1067,7 @@ const char *cdrom_get_type_string(UINT32 trktype)
-------------------------------------------------*/
/**
- * @fn const char *cdrom_get_subtype_string(UINT32 subtype)
+ * @fn const char *cdrom_get_subtype_string(uint32_t subtype)
*
* @brief Cdrom get subtype string.
*
@@ -1076,7 +1076,7 @@ const char *cdrom_get_type_string(UINT32 trktype)
* @return null if it fails, else a char*.
*/
-const char *cdrom_get_subtype_string(UINT32 subtype)
+const char *cdrom_get_subtype_string(uint32_t subtype)
{
switch (subtype)
{
@@ -1225,13 +1225,13 @@ chd_error cdrom_parse_metadata(chd_file *chd, cdrom_toc *toc)
printf("toc->numtrks = %u?!\n", toc->numtrks);
/* look for old-style metadata */
- std::vector<UINT8> oldmetadata;
+ std::vector<uint8_t> oldmetadata;
err = chd->read_metadata(CDROM_OLD_METADATA_TAG, 0, oldmetadata);
if (err != CHDERR_NONE)
return err;
/* reconstruct the TOC from it */
- UINT32 *mrp = reinterpret_cast<UINT32 *>(&oldmetadata[0]);
+ uint32_t *mrp = reinterpret_cast<uint32_t *>(&oldmetadata[0]);
toc->numtrks = *mrp++;
for (i = 0; i < CD_MAX_TRACKS; i++)
@@ -1334,7 +1334,7 @@ chd_error cdrom_write_metadata(chd_file *chd, const cdrom_toc *toc)
* -------------------------------------------------.
*/
-static const UINT8 ecclow[256] =
+static const uint8_t ecclow[256] =
{
0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e,
@@ -1355,7 +1355,7 @@ static const UINT8 ecclow[256] =
};
/** @brief The ecchigh[ 256]. */
-static const UINT8 ecchigh[256] =
+static const uint8_t ecchigh[256] =
{
0x00, 0xf4, 0xf5, 0x01, 0xf7, 0x03, 0x02, 0xf6, 0xf3, 0x07, 0x06, 0xf2, 0x04, 0xf0, 0xf1, 0x05,
0xfb, 0x0f, 0x0e, 0xfa, 0x0c, 0xf8, 0xf9, 0x0d, 0x08, 0xfc, 0xfd, 0x09, 0xff, 0x0b, 0x0a, 0xfe,
@@ -1382,7 +1382,7 @@ static const UINT8 ecchigh[256] =
* -------------------------------------------------.
*/
-static const UINT16 poffsets[ECC_P_NUM_BYTES][ECC_P_COMP] =
+static const uint16_t poffsets[ECC_P_NUM_BYTES][ECC_P_COMP] =
{
{ 0x000,0x056,0x0ac,0x102,0x158,0x1ae,0x204,0x25a,0x2b0,0x306,0x35c,0x3b2,0x408,0x45e,0x4b4,0x50a,0x560,0x5b6,0x60c,0x662,0x6b8,0x70e,0x764,0x7ba },
{ 0x001,0x057,0x0ad,0x103,0x159,0x1af,0x205,0x25b,0x2b1,0x307,0x35d,0x3b3,0x409,0x45f,0x4b5,0x50b,0x561,0x5b7,0x60d,0x663,0x6b9,0x70f,0x765,0x7bb },
@@ -1479,7 +1479,7 @@ static const UINT16 poffsets[ECC_P_NUM_BYTES][ECC_P_COMP] =
* -------------------------------------------------.
*/
-static const UINT16 qoffsets[ECC_Q_NUM_BYTES][ECC_Q_COMP] =
+static const uint16_t qoffsets[ECC_Q_NUM_BYTES][ECC_Q_COMP] =
{
{ 0x000,0x058,0x0b0,0x108,0x160,0x1b8,0x210,0x268,0x2c0,0x318,0x370,0x3c8,0x420,0x478,0x4d0,0x528,0x580,0x5d8,0x630,0x688,0x6e0,0x738,0x790,0x7e8,0x840,0x898,0x034,0x08c,0x0e4,0x13c,0x194,0x1ec,0x244,0x29c,0x2f4,0x34c,0x3a4,0x3fc,0x454,0x4ac,0x504,0x55c,0x5b4 },
{ 0x001,0x059,0x0b1,0x109,0x161,0x1b9,0x211,0x269,0x2c1,0x319,0x371,0x3c9,0x421,0x479,0x4d1,0x529,0x581,0x5d9,0x631,0x689,0x6e1,0x739,0x791,0x7e9,0x841,0x899,0x035,0x08d,0x0e5,0x13d,0x195,0x1ed,0x245,0x29d,0x2f5,0x34d,0x3a5,0x3fd,0x455,0x4ad,0x505,0x55d,0x5b5 },
@@ -1542,14 +1542,14 @@ static const UINT16 qoffsets[ECC_Q_NUM_BYTES][ECC_Q_COMP] =
// particular to a mode
//-------------------------------------------------
-inline UINT8 ecc_source_byte(const UINT8 *sector, UINT32 offset)
+inline uint8_t ecc_source_byte(const uint8_t *sector, uint32_t offset)
{
// in mode 2 always treat these as 0 bytes
return (sector[MODE_OFFSET] == 2 && offset < 4) ? 0x00 : sector[SYNC_OFFSET + SYNC_NUM_BYTES + offset];
}
/**
- * @fn void ecc_compute_bytes(const UINT8 *sector, const UINT16 *row, int rowlen, UINT8 &val1, UINT8 &val2)
+ * @fn void ecc_compute_bytes(const uint8_t *sector, const uint16_t *row, int rowlen, uint8_t &val1, uint8_t &val2)
*
* @brief -------------------------------------------------
* ecc_compute_bytes - calculate an ECC value (P or Q)
@@ -1562,7 +1562,7 @@ inline UINT8 ecc_source_byte(const UINT8 *sector, UINT32 offset)
* @param [in,out] val2 The second value.
*/
-void ecc_compute_bytes(const UINT8 *sector, const UINT16 *row, int rowlen, UINT8 &val1, UINT8 &val2)
+void ecc_compute_bytes(const uint8_t *sector, const uint16_t *row, int rowlen, uint8_t &val1, uint8_t &val2)
{
val1 = val2 = 0;
for (int component = 0; component < rowlen; component++)
@@ -1576,7 +1576,7 @@ void ecc_compute_bytes(const UINT8 *sector, const UINT16 *row, int rowlen, UINT8
}
/**
- * @fn bool ecc_verify(const UINT8 *sector)
+ * @fn bool ecc_verify(const uint8_t *sector)
*
* @brief -------------------------------------------------
* ecc_verify - verify the P and Q ECC codes in a sector
@@ -1587,12 +1587,12 @@ void ecc_compute_bytes(const UINT8 *sector, const UINT16 *row, int rowlen, UINT8
* @return true if it succeeds, false if it fails.
*/
-bool ecc_verify(const UINT8 *sector)
+bool ecc_verify(const uint8_t *sector)
{
// first verify P bytes
for (int byte = 0; byte < ECC_P_NUM_BYTES; byte++)
{
- UINT8 val1, val2;
+ uint8_t val1, val2;
ecc_compute_bytes(sector, poffsets[byte], ECC_P_COMP, val1, val2);
if (sector[ECC_P_OFFSET + byte] != val1 || sector[ECC_P_OFFSET + ECC_P_NUM_BYTES + byte] != val2)
return false;
@@ -1601,7 +1601,7 @@ bool ecc_verify(const UINT8 *sector)
// then verify Q bytes
for (int byte = 0; byte < ECC_Q_NUM_BYTES; byte++)
{
- UINT8 val1, val2;
+ uint8_t val1, val2;
ecc_compute_bytes(sector, qoffsets[byte], ECC_Q_COMP, val1, val2);
if (sector[ECC_Q_OFFSET + byte] != val1 || sector[ECC_Q_OFFSET + ECC_Q_NUM_BYTES + byte] != val2)
return false;
@@ -1610,7 +1610,7 @@ bool ecc_verify(const UINT8 *sector)
}
/**
- * @fn void ecc_generate(UINT8 *sector)
+ * @fn void ecc_generate(uint8_t *sector)
*
* @brief -------------------------------------------------
* ecc_generate - generate the P and Q ECC codes for a sector, overwriting any
@@ -1620,7 +1620,7 @@ bool ecc_verify(const UINT8 *sector)
* @param [in,out] sector If non-null, the sector.
*/
-void ecc_generate(UINT8 *sector)
+void ecc_generate(uint8_t *sector)
{
// first verify P bytes
for (int byte = 0; byte < ECC_P_NUM_BYTES; byte++)
@@ -1632,7 +1632,7 @@ void ecc_generate(UINT8 *sector)
}
/**
- * @fn void ecc_clear(UINT8 *sector)
+ * @fn void ecc_clear(uint8_t *sector)
*
* @brief -------------------------------------------------
* ecc_clear - erase the ECC P and Q cods to 0 within a sector
@@ -1641,7 +1641,7 @@ void ecc_generate(UINT8 *sector)
* @param [in,out] sector If non-null, the sector.
*/
-void ecc_clear(UINT8 *sector)
+void ecc_clear(uint8_t *sector)
{
memset(&sector[ECC_P_OFFSET], 0, 2 * ECC_P_NUM_BYTES);
memset(&sector[ECC_Q_OFFSET], 0, 2 * ECC_Q_NUM_BYTES);
diff --git a/src/lib/util/cdrom.h b/src/lib/util/cdrom.h
index c495a405513..21665c1326f 100644
--- a/src/lib/util/cdrom.h
+++ b/src/lib/util/cdrom.h
@@ -23,7 +23,7 @@
***************************************************************************/
// tracks are padded to a multiple of this many frames
-const UINT32 CD_TRACK_PADDING = 4;
+const uint32_t CD_TRACK_PADDING = 4;
#define CD_MAX_TRACKS (99) /* AFAIK the theoretical limit */
#define CD_MAX_SECTOR_DATA (2352)
@@ -67,33 +67,33 @@ struct cdrom_file;
struct cdrom_track_info
{
/* fields used by CHDMAN and in MAME */
- UINT32 trktype; /* track type */
- UINT32 subtype; /* subcode data type */
- UINT32 datasize; /* size of data in each sector of this track */
- UINT32 subsize; /* size of subchannel data in each sector of this track */
- UINT32 frames; /* number of frames in this track */
- UINT32 extraframes; /* number of "spillage" frames in this track */
- UINT32 pregap; /* number of pregap frames */
- UINT32 postgap; /* number of postgap frames */
- UINT32 pgtype; /* type of sectors in pregap */
- UINT32 pgsub; /* type of subchannel data in pregap */
- UINT32 pgdatasize; /* size of data in each sector of the pregap */
- UINT32 pgsubsize; /* size of subchannel data in each sector of the pregap */
+ uint32_t trktype; /* track type */
+ uint32_t subtype; /* subcode data type */
+ uint32_t datasize; /* size of data in each sector of this track */
+ uint32_t subsize; /* size of subchannel data in each sector of this track */
+ uint32_t frames; /* number of frames in this track */
+ uint32_t extraframes; /* number of "spillage" frames in this track */
+ uint32_t pregap; /* number of pregap frames */
+ uint32_t postgap; /* number of postgap frames */
+ uint32_t pgtype; /* type of sectors in pregap */
+ uint32_t pgsub; /* type of subchannel data in pregap */
+ uint32_t pgdatasize; /* size of data in each sector of the pregap */
+ uint32_t pgsubsize; /* size of subchannel data in each sector of the pregap */
/* fields used in CHDMAN only */
- UINT32 padframes; /* number of frames of padding to add to the end of the track; needed for GDI */
+ uint32_t padframes; /* number of frames of padding to add to the end of the track; needed for GDI */
/* fields used in MAME/MESS only */
- UINT32 logframeofs; /* logical frame of actual track data - offset by pregap size if pregap not physically present */
- UINT32 physframeofs; /* physical frame of actual track data in CHD data */
- UINT32 chdframeofs; /* frame number this track starts at on the CHD */
+ uint32_t logframeofs; /* logical frame of actual track data - offset by pregap size if pregap not physically present */
+ uint32_t physframeofs; /* physical frame of actual track data in CHD data */
+ uint32_t chdframeofs; /* frame number this track starts at on the CHD */
};
struct cdrom_toc
{
- UINT32 numtrks; /* number of tracks */
- UINT32 flags; /* see FLAG_ above */
+ uint32_t numtrks; /* number of tracks */
+ uint32_t flags; /* see FLAG_ above */
cdrom_track_info tracks[CD_MAX_TRACKS];
};
@@ -110,13 +110,13 @@ void cdrom_close(cdrom_file *file);
cdrom_file *cdrom_open(const char *inputfile);
/* core read access */
-UINT32 cdrom_read_data(cdrom_file *file, UINT32 lbasector, void *buffer, UINT32 datatype, bool phys=false);
-UINT32 cdrom_read_subcode(cdrom_file *file, UINT32 lbasector, void *buffer, bool phys=false);
+uint32_t cdrom_read_data(cdrom_file *file, uint32_t lbasector, void *buffer, uint32_t datatype, bool phys=false);
+uint32_t cdrom_read_subcode(cdrom_file *file, uint32_t lbasector, void *buffer, bool phys=false);
/* handy utilities */
-UINT32 cdrom_get_track(cdrom_file *file, UINT32 frame);
-UINT32 cdrom_get_track_start(cdrom_file *file, UINT32 track);
-UINT32 cdrom_get_track_start_phys(cdrom_file *file, UINT32 track);
+uint32_t cdrom_get_track(cdrom_file *file, uint32_t frame);
+uint32_t cdrom_get_track_start(cdrom_file *file, uint32_t track);
+uint32_t cdrom_get_track_start_phys(cdrom_file *file, uint32_t track);
/* TOC utilities */
int cdrom_get_last_track(cdrom_file *file);
@@ -129,15 +129,15 @@ void cdrom_convert_type_string_to_track_info(const char *typestring, cdrom_track
void cdrom_convert_type_string_to_pregap_info(const char *typestring, cdrom_track_info *info);
void cdrom_convert_subtype_string_to_track_info(const char *typestring, cdrom_track_info *info);
void cdrom_convert_subtype_string_to_pregap_info(const char *typestring, cdrom_track_info *info);
-const char *cdrom_get_type_string(UINT32 trktype);
-const char *cdrom_get_subtype_string(UINT32 subtype);
+const char *cdrom_get_type_string(uint32_t trktype);
+const char *cdrom_get_subtype_string(uint32_t subtype);
chd_error cdrom_parse_metadata(chd_file *chd, cdrom_toc *toc);
chd_error cdrom_write_metadata(chd_file *chd, const cdrom_toc *toc);
// ECC utilities
-bool ecc_verify(const UINT8 *sector);
-void ecc_generate(UINT8 *sector);
-void ecc_clear(UINT8 *sector);
+bool ecc_verify(const uint8_t *sector);
+void ecc_generate(uint8_t *sector);
+void ecc_clear(uint8_t *sector);
@@ -145,14 +145,14 @@ void ecc_clear(UINT8 *sector);
INLINE FUNCTIONS
***************************************************************************/
-static inline UINT32 msf_to_lba(UINT32 msf)
+static inline uint32_t msf_to_lba(uint32_t msf)
{
return ( ((msf&0x00ff0000)>>16) * 60 * 75) + (((msf&0x0000ff00)>>8) * 75) + ((msf&0x000000ff)>>0);
}
-static inline UINT32 lba_to_msf(UINT32 lba)
+static inline uint32_t lba_to_msf(uint32_t lba)
{
- UINT8 m, s, f;
+ uint8_t m, s, f;
m = lba / (60 * 75);
lba -= m * (60 * 75);
@@ -167,9 +167,9 @@ static inline UINT32 lba_to_msf(UINT32 lba)
// segacd needs it like this.. investigate
// Angelo also says PCE tracks often start playing at the
// wrong address.. related?
-static inline UINT32 lba_to_msf_alt(int lba)
+static inline uint32_t lba_to_msf_alt(int lba)
{
- UINT32 ret = 0;
+ uint32_t ret = 0;
ret |= ((lba / (60 * 75))&0xff)<<16;
ret |= (((lba / 75) % 60)&0xff)<<8;
diff --git a/src/lib/util/chd.cpp b/src/lib/util/chd.cpp
index 8bce55cb947..19836a8ee2a 100644
--- a/src/lib/util/chd.cpp
+++ b/src/lib/util/chd.cpp
@@ -35,10 +35,10 @@ const char *CDROM_TRACK_METADATA2_FORMAT = "TRACK:%d TYPE:%s SUBTYPE:%s FRAMES:%
const char *GDROM_TRACK_METADATA_FORMAT = "TRACK:%d TYPE:%s SUBTYPE:%s FRAMES:%d PAD:%d PREGAP:%d PGTYPE:%s PGSUB:%s POSTGAP:%d";
const char *AV_METADATA_FORMAT = "FPS:%d.%06d WIDTH:%d HEIGHT:%d INTERLACED:%d CHANNELS:%d SAMPLERATE:%d";
-static const UINT32 METADATA_HEADER_SIZE = 16; // metadata header size
+static const uint32_t METADATA_HEADER_SIZE = 16; // metadata header size
-static const UINT8 V34_MAP_ENTRY_FLAG_TYPE_MASK = 0x0f; // what type of hunk
-static const UINT8 V34_MAP_ENTRY_FLAG_NO_CRC = 0x10; // no CRC is present
+static const uint8_t V34_MAP_ENTRY_FLAG_TYPE_MASK = 0x0f; // what type of hunk
+static const uint8_t V34_MAP_ENTRY_FLAG_NO_CRC = 0x10; // no CRC is present
@@ -101,12 +101,12 @@ enum
// description of where a metadata entry lives within the file
struct chd_file::metadata_entry
{
- UINT64 offset; // offset within the file of the header
- UINT64 next; // offset within the file of the next header
- UINT64 prev; // offset within the file of the previous header
- UINT32 length; // length of the metadata
- UINT32 metatag; // metadata tag
- UINT8 flags; // flag bits
+ uint64_t offset; // offset within the file of the header
+ uint64_t next; // offset within the file of the next header
+ uint64_t prev; // offset within the file of the previous header
+ uint32_t length; // length of the metadata
+ uint32_t metatag; // metadata tag
+ uint8_t flags; // flag bits
};
@@ -114,7 +114,7 @@ struct chd_file::metadata_entry
struct chd_file::metadata_hash
{
- UINT8 tag[4]; // tag of the metadata in big-endian
+ uint8_t tag[4]; // tag of the metadata in big-endian
util::sha1_t sha1; // hash data
};
@@ -129,9 +129,9 @@ struct chd_file::metadata_hash
// a byte buffer
//-------------------------------------------------
-inline UINT64 chd_file::be_read(const UINT8 *base, int numbytes)
+inline uint64_t chd_file::be_read(const uint8_t *base, int numbytes)
{
- UINT64 result = 0;
+ uint64_t result = 0;
while (numbytes--)
result = (result << 8) | *base++;
return result;
@@ -143,7 +143,7 @@ inline UINT64 chd_file::be_read(const UINT8 *base, int numbytes)
// buffer
//-------------------------------------------------
-inline void chd_file::be_write(UINT8 *base, UINT64 value, int numbytes)
+inline void chd_file::be_write(uint8_t *base, uint64_t value, int numbytes)
{
base += numbytes;
while (numbytes--)
@@ -159,7 +159,7 @@ inline void chd_file::be_write(UINT8 *base, UINT64 value, int numbytes)
// stream in bigendian order
//-------------------------------------------------
-inline util::sha1_t chd_file::be_read_sha1(const UINT8 *base)
+inline util::sha1_t chd_file::be_read_sha1(const uint8_t *base)
{
util::sha1_t result;
memcpy(&result.m_raw[0], base, sizeof(result.m_raw));
@@ -172,7 +172,7 @@ inline util::sha1_t chd_file::be_read_sha1(const UINT8 *base)
// stream in bigendian order
//-------------------------------------------------
-inline void chd_file::be_write_sha1(UINT8 *base, util::sha1_t value)
+inline void chd_file::be_write_sha1(uint8_t *base, util::sha1_t value)
{
memcpy(base, &value.m_raw[0], sizeof(value.m_raw));
}
@@ -183,7 +183,7 @@ inline void chd_file::be_write_sha1(UINT8 *base, util::sha1_t value)
// offset; on failure throw an error
//-------------------------------------------------
-inline void chd_file::file_read(UINT64 offset, void *dest, UINT32 length)
+inline void chd_file::file_read(uint64_t offset, void *dest, uint32_t length)
{
// no file = failure
if (m_file == nullptr)
@@ -191,7 +191,7 @@ inline void chd_file::file_read(UINT64 offset, void *dest, UINT32 length)
// seek and read
m_file->seek(offset, SEEK_SET);
- UINT32 count = m_file->read(dest, length);
+ uint32_t count = m_file->read(dest, length);
if (count != length)
throw CHDERR_READ_ERROR;
}
@@ -202,7 +202,7 @@ inline void chd_file::file_read(UINT64 offset, void *dest, UINT32 length)
// offset; on failure throw an error
//-------------------------------------------------
-inline void chd_file::file_write(UINT64 offset, const void *source, UINT32 length)
+inline void chd_file::file_write(uint64_t offset, const void *source, uint32_t length)
{
// no file = failure
if (m_file == nullptr)
@@ -210,7 +210,7 @@ inline void chd_file::file_write(UINT64 offset, const void *source, UINT32 lengt
// seek and write
m_file->seek(offset, SEEK_SET);
- UINT32 count = m_file->write(source, length);
+ uint32_t count = m_file->write(source, length);
if (count != length)
throw CHDERR_WRITE_ERROR;
}
@@ -222,7 +222,7 @@ inline void chd_file::file_write(UINT64 offset, const void *source, UINT32 lengt
// alignment; on failure throw an error
//-------------------------------------------------
-inline UINT64 chd_file::file_append(const void *source, UINT32 length, UINT32 alignment)
+inline uint64_t chd_file::file_append(const void *source, uint32_t length, uint32_t alignment)
{
// no file = failure
if (m_file == nullptr)
@@ -232,18 +232,18 @@ inline UINT64 chd_file::file_append(const void *source, UINT32 length, UINT32 al
m_file->seek(0, SEEK_END);
if (alignment != 0)
{
- UINT64 offset = m_file->tell();
- UINT32 delta = offset % alignment;
+ uint64_t offset = m_file->tell();
+ uint32_t delta = offset % alignment;
if (delta != 0)
{
// pad with 0's from a local buffer
- UINT8 buffer[1024];
+ uint8_t buffer[1024];
memset(buffer, 0, sizeof(buffer));
delta = alignment - delta;
while (delta != 0)
{
- UINT32 bytes_to_write = (std::min<std::size_t>)(sizeof(buffer), delta);
- UINT32 count = m_file->write(buffer, bytes_to_write);
+ uint32_t bytes_to_write = (std::min<std::size_t>)(sizeof(buffer), delta);
+ uint32_t count = m_file->write(buffer, bytes_to_write);
if (count != bytes_to_write)
throw CHDERR_WRITE_ERROR;
delta -= bytes_to_write;
@@ -252,8 +252,8 @@ inline UINT64 chd_file::file_append(const void *source, UINT32 length, UINT32 al
}
// write the real data
- UINT64 offset = m_file->tell();
- UINT32 count = m_file->write(source, length);
+ uint64_t offset = m_file->tell();
+ uint32_t count = m_file->write(source, length);
if (count != length)
throw CHDERR_READ_ERROR;
return offset;
@@ -265,9 +265,9 @@ inline UINT64 chd_file::file_append(const void *source, UINT32 length, UINT32 al
// necessary to represent all numbers 0..value
//-------------------------------------------------
-inline UINT8 chd_file::bits_for_value(UINT64 value)
+inline uint8_t chd_file::bits_for_value(uint64_t value)
{
- UINT8 result = 0;
+ uint8_t result = 0;
while (value != 0)
value >>= 1, result++;
return result;
@@ -325,7 +325,7 @@ util::sha1_t chd_file::sha1()
try
{
// read the big-endian version
- UINT8 rawbuf[sizeof(util::sha1_t)];
+ uint8_t rawbuf[sizeof(util::sha1_t)];
file_read(m_sha1_offset, rawbuf, sizeof(rawbuf));
return be_read_sha1(rawbuf);
}
@@ -358,7 +358,7 @@ util::sha1_t chd_file::raw_sha1()
throw CHDERR_UNSUPPORTED_VERSION;
// read the big-endian version
- UINT8 rawbuf[sizeof(util::sha1_t)];
+ uint8_t rawbuf[sizeof(util::sha1_t)];
file_read(m_rawsha1_offset, rawbuf, sizeof(rawbuf));
return be_read_sha1(rawbuf);
}
@@ -391,7 +391,7 @@ util::sha1_t chd_file::parent_sha1()
throw CHDERR_UNSUPPORTED_VERSION;
// read the big-endian version
- UINT8 rawbuf[sizeof(util::sha1_t)];
+ uint8_t rawbuf[sizeof(util::sha1_t)];
file_read(m_parentsha1_offset, rawbuf, sizeof(rawbuf));
return be_read_sha1(rawbuf);
}
@@ -403,7 +403,7 @@ util::sha1_t chd_file::parent_sha1()
}
/**
- * @fn chd_error chd_file::hunk_info(UINT32 hunknum, chd_codec_type &compressor, UINT32 &compbytes)
+ * @fn chd_error chd_file::hunk_info(uint32_t hunknum, chd_codec_type &compressor, uint32_t &compbytes)
*
* @brief -------------------------------------------------
* hunk_info - return information about this hunk
@@ -416,14 +416,14 @@ util::sha1_t chd_file::parent_sha1()
* @return A chd_error.
*/
-chd_error chd_file::hunk_info(UINT32 hunknum, chd_codec_type &compressor, UINT32 &compbytes)
+chd_error chd_file::hunk_info(uint32_t hunknum, chd_codec_type &compressor, uint32_t &compbytes)
{
// error if invalid
if (hunknum >= m_hunkcount)
return CHDERR_HUNK_OUT_OF_RANGE;
// get the map pointer
- UINT8 *rawmap;
+ uint8_t *rawmap;
switch (m_version)
{
// v3/v4 map entries
@@ -526,11 +526,11 @@ chd_error chd_file::hunk_info(UINT32 hunknum, chd_codec_type &compressor, UINT32
void chd_file::set_raw_sha1(util::sha1_t rawdata)
{
// create a big-endian version
- UINT8 rawbuf[sizeof(util::sha1_t)];
+ uint8_t rawbuf[sizeof(util::sha1_t)];
be_write_sha1(rawbuf, rawdata);
// write to the header
- UINT64 offset = (m_rawsha1_offset != 0) ? m_rawsha1_offset : m_sha1_offset;
+ uint64_t offset = (m_rawsha1_offset != 0) ? m_rawsha1_offset : m_sha1_offset;
assert(offset != 0);
file_write(offset, rawbuf, sizeof(rawbuf));
@@ -558,7 +558,7 @@ void chd_file::set_parent_sha1(util::sha1_t parent)
throw CHDERR_INVALID_FILE;
// create a big-endian version
- UINT8 rawbuf[sizeof(util::sha1_t)];
+ uint8_t rawbuf[sizeof(util::sha1_t)];
be_write_sha1(rawbuf, parent);
// write to the header
@@ -567,7 +567,7 @@ void chd_file::set_parent_sha1(util::sha1_t parent)
}
/**
- * @fn chd_error chd_file::create(util::core_file &file, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 unitbytes, chd_codec_type compression[4])
+ * @fn chd_error chd_file::create(util::core_file &file, uint64_t logicalbytes, uint32_t hunkbytes, uint32_t unitbytes, chd_codec_type compression[4])
*
* @brief -------------------------------------------------
* create - create a new file with no parent using an existing opened file handle
@@ -582,7 +582,7 @@ void chd_file::set_parent_sha1(util::sha1_t parent)
* @return A chd_error.
*/
-chd_error chd_file::create(util::core_file &file, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 unitbytes, chd_codec_type compression[4])
+chd_error chd_file::create(util::core_file &file, uint64_t logicalbytes, uint32_t hunkbytes, uint32_t unitbytes, chd_codec_type compression[4])
{
// make sure we don't already have a file open
if (m_file != nullptr)
@@ -602,7 +602,7 @@ chd_error chd_file::create(util::core_file &file, UINT64 logicalbytes, UINT32 hu
}
/**
- * @fn chd_error chd_file::create(util::core_file &file, UINT64 logicalbytes, UINT32 hunkbytes, chd_codec_type compression[4], chd_file &parent)
+ * @fn chd_error chd_file::create(util::core_file &file, uint64_t logicalbytes, uint32_t hunkbytes, chd_codec_type compression[4], chd_file &parent)
*
* @brief -------------------------------------------------
* create - create a new file with a parent using an existing opened file handle
@@ -617,7 +617,7 @@ chd_error chd_file::create(util::core_file &file, UINT64 logicalbytes, UINT32 hu
* @return A chd_error.
*/
-chd_error chd_file::create(util::core_file &file, UINT64 logicalbytes, UINT32 hunkbytes, chd_codec_type compression[4], chd_file &parent)
+chd_error chd_file::create(util::core_file &file, uint64_t logicalbytes, uint32_t hunkbytes, chd_codec_type compression[4], chd_file &parent)
{
// make sure we don't already have a file open
if (m_file != nullptr)
@@ -637,7 +637,7 @@ chd_error chd_file::create(util::core_file &file, UINT64 logicalbytes, UINT32 hu
}
/**
- * @fn chd_error chd_file::create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 unitbytes, chd_codec_type compression[4])
+ * @fn chd_error chd_file::create(const char *filename, uint64_t logicalbytes, uint32_t hunkbytes, uint32_t unitbytes, chd_codec_type compression[4])
*
* @brief -------------------------------------------------
* create - create a new file with no parent using a filename
@@ -652,7 +652,7 @@ chd_error chd_file::create(util::core_file &file, UINT64 logicalbytes, UINT32 hu
* @return A chd_error.
*/
-chd_error chd_file::create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 unitbytes, chd_codec_type compression[4])
+chd_error chd_file::create(const char *filename, uint64_t logicalbytes, uint32_t hunkbytes, uint32_t unitbytes, chd_codec_type compression[4])
{
// make sure we don't already have a file open
if (m_file != nullptr)
@@ -682,7 +682,7 @@ chd_error chd_file::create(const char *filename, UINT64 logicalbytes, UINT32 hun
}
/**
- * @fn chd_error chd_file::create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, chd_codec_type compression[4], chd_file &parent)
+ * @fn chd_error chd_file::create(const char *filename, uint64_t logicalbytes, uint32_t hunkbytes, chd_codec_type compression[4], chd_file &parent)
*
* @brief -------------------------------------------------
* create - create a new file with a parent using a filename
@@ -697,7 +697,7 @@ chd_error chd_file::create(const char *filename, UINT64 logicalbytes, UINT32 hun
* @return A chd_error.
*/
-chd_error chd_file::create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, chd_codec_type compression[4], chd_file &parent)
+chd_error chd_file::create(const char *filename, uint64_t logicalbytes, uint32_t hunkbytes, chd_codec_type compression[4], chd_file &parent)
{
// make sure we don't already have a file open
if (m_file != nullptr)
@@ -747,7 +747,7 @@ chd_error chd_file::open(const char *filename, bool writeable, chd_file *parent)
return CHDERR_ALREADY_OPEN;
// open the file
- const UINT32 openflags = writeable ? (OPEN_FLAG_READ | OPEN_FLAG_WRITE) : OPEN_FLAG_READ;
+ const uint32_t openflags = writeable ? (OPEN_FLAG_READ | OPEN_FLAG_WRITE) : OPEN_FLAG_READ;
util::core_file::ptr file;
const osd_file::error filerr = util::core_file::open(filename, openflags, file);
if (filerr != osd_file::error::NONE)
@@ -847,7 +847,7 @@ void chd_file::close()
}
/**
- * @fn chd_error chd_file::read_hunk(UINT32 hunknum, void *buffer)
+ * @fn chd_error chd_file::read_hunk(uint32_t hunknum, void *buffer)
*
* @brief -------------------------------------------------
* read - read a single hunk from the CHD file
@@ -869,7 +869,7 @@ void chd_file::close()
* @return The hunk.
*/
-chd_error chd_file::read_hunk(UINT32 hunknum, void *buffer)
+chd_error chd_file::read_hunk(uint32_t hunknum, void *buffer)
{
// wrap this for clean reporting
try
@@ -883,11 +883,11 @@ chd_error chd_file::read_hunk(UINT32 hunknum, void *buffer)
throw CHDERR_HUNK_OUT_OF_RANGE;
// get a pointer to the map entry
- UINT64 blockoffs;
- UINT32 blocklen;
- UINT32 blockcrc;
- UINT8 *rawmap;
- UINT8 *dest = reinterpret_cast<UINT8 *>(buffer);
+ uint64_t blockoffs;
+ uint32_t blocklen;
+ uint32_t blockcrc;
+ uint8_t *rawmap;
+ uint8_t *dest = reinterpret_cast<uint8_t *>(buffer);
switch (m_version)
{
// v3/v4 map entries
@@ -914,7 +914,7 @@ chd_error chd_file::read_hunk(UINT32 hunknum, void *buffer)
case V34_MAP_ENTRY_TYPE_MINI:
be_write(dest, blockoffs, 8);
- for (UINT32 bytes = 8; bytes < m_hunkbytes; bytes++)
+ for (uint32_t bytes = 8; bytes < m_hunkbytes; bytes++)
dest[bytes] = dest[bytes - 8];
if (!(rawmap[15] & V34_MAP_ENTRY_FLAG_NO_CRC) && util::crc32_creator::simple(dest, m_hunkbytes) != blockcrc)
throw CHDERR_DECOMPRESSION_ERROR;
@@ -937,7 +937,7 @@ chd_error chd_file::read_hunk(UINT32 hunknum, void *buffer)
// uncompressed case
if (!compressed())
{
- blockoffs = UINT64(be_read(rawmap, 4)) * UINT64(m_hunkbytes);
+ blockoffs = uint64_t(be_read(rawmap, 4)) * uint64_t(m_hunkbytes);
if (blockoffs != 0)
file_read(blockoffs, dest, m_hunkbytes);
else if (m_parent_missing)
@@ -979,7 +979,7 @@ chd_error chd_file::read_hunk(UINT32 hunknum, void *buffer)
case COMPRESSION_PARENT:
if (m_parent_missing)
throw CHDERR_REQUIRES_PARENT;
- return m_parent->read_bytes(UINT64(blockoffs) * UINT64(m_parent->unit_bytes()), dest, m_hunkbytes);
+ return m_parent->read_bytes(uint64_t(blockoffs) * uint64_t(m_parent->unit_bytes()), dest, m_hunkbytes);
}
break;
}
@@ -996,7 +996,7 @@ chd_error chd_file::read_hunk(UINT32 hunknum, void *buffer)
}
/**
- * @fn chd_error chd_file::write_hunk(UINT32 hunknum, const void *buffer)
+ * @fn chd_error chd_file::write_hunk(uint32_t hunknum, const void *buffer)
*
* @brief -------------------------------------------------
* write - write a single hunk to the CHD file
@@ -1014,7 +1014,7 @@ chd_error chd_file::read_hunk(UINT32 hunknum, void *buffer)
* @return A chd_error.
*/
-chd_error chd_file::write_hunk(UINT32 hunknum, const void *buffer)
+chd_error chd_file::write_hunk(uint32_t hunknum, const void *buffer)
{
// wrap this for clean reporting
try
@@ -1036,16 +1036,16 @@ chd_error chd_file::write_hunk(UINT32 hunknum, const void *buffer)
throw CHDERR_FILE_NOT_WRITEABLE;
// see if we have allocated the space on disk for this hunk
- UINT8 *rawmap = &m_rawmap[hunknum * 4];
- UINT32 rawentry = be_read(rawmap, 4);
+ uint8_t *rawmap = &m_rawmap[hunknum * 4];
+ uint32_t rawentry = be_read(rawmap, 4);
// if not, allocate one now
if (rawentry == 0)
{
// first make sure we need to allocate it
bool all_zeros = true;
- const UINT32 *scan = reinterpret_cast<const UINT32 *>(buffer);
- for (UINT32 index = 0; index < m_hunkbytes / 4; index++)
+ const uint32_t *scan = reinterpret_cast<const uint32_t *>(buffer);
+ for (uint32_t index = 0; index < m_hunkbytes / 4; index++)
if (scan[index] != 0)
{
all_zeros = false;
@@ -1070,7 +1070,7 @@ chd_error chd_file::write_hunk(UINT32 hunknum, const void *buffer)
// otherwise, just overwrite
else
- file_write(UINT64(rawentry) * UINT64(m_hunkbytes), buffer, m_hunkbytes);
+ file_write(uint64_t(rawentry) * uint64_t(m_hunkbytes), buffer, m_hunkbytes);
return CHDERR_NONE;
}
@@ -1082,7 +1082,7 @@ chd_error chd_file::write_hunk(UINT32 hunknum, const void *buffer)
}
/**
- * @fn chd_error chd_file::read_units(UINT64 unitnum, void *buffer, UINT32 count)
+ * @fn chd_error chd_file::read_units(uint64_t unitnum, void *buffer, uint32_t count)
*
* @brief -------------------------------------------------
* read_units - read the given number of units from the CHD
@@ -1095,13 +1095,13 @@ chd_error chd_file::write_hunk(UINT32 hunknum, const void *buffer)
* @return The units.
*/
-chd_error chd_file::read_units(UINT64 unitnum, void *buffer, UINT32 count)
+chd_error chd_file::read_units(uint64_t unitnum, void *buffer, uint32_t count)
{
- return read_bytes(unitnum * UINT64(m_unitbytes), buffer, count * m_unitbytes);
+ return read_bytes(unitnum * uint64_t(m_unitbytes), buffer, count * m_unitbytes);
}
/**
- * @fn chd_error chd_file::write_units(UINT64 unitnum, const void *buffer, UINT32 count)
+ * @fn chd_error chd_file::write_units(uint64_t unitnum, const void *buffer, uint32_t count)
*
* @brief -------------------------------------------------
* write_units - write the given number of units to the CHD
@@ -1114,13 +1114,13 @@ chd_error chd_file::read_units(UINT64 unitnum, void *buffer, UINT32 count)
* @return A chd_error.
*/
-chd_error chd_file::write_units(UINT64 unitnum, const void *buffer, UINT32 count)
+chd_error chd_file::write_units(uint64_t unitnum, const void *buffer, uint32_t count)
{
- return write_bytes(unitnum * UINT64(m_unitbytes), buffer, count * m_unitbytes);
+ return write_bytes(unitnum * uint64_t(m_unitbytes), buffer, count * m_unitbytes);
}
/**
- * @fn chd_error chd_file::read_bytes(UINT64 offset, void *buffer, UINT32 bytes)
+ * @fn chd_error chd_file::read_bytes(uint64_t offset, void *buffer, uint32_t bytes)
*
* @brief -------------------------------------------------
* read_bytes - read from the CHD at a byte level, using the cache to handle partial
@@ -1134,17 +1134,17 @@ chd_error chd_file::write_units(UINT64 unitnum, const void *buffer, UINT32 count
* @return The bytes.
*/
-chd_error chd_file::read_bytes(UINT64 offset, void *buffer, UINT32 bytes)
+chd_error chd_file::read_bytes(uint64_t offset, void *buffer, uint32_t bytes)
{
// iterate over hunks
- UINT32 first_hunk = offset / m_hunkbytes;
- UINT32 last_hunk = (offset + bytes - 1) / m_hunkbytes;
- UINT8 *dest = reinterpret_cast<UINT8 *>(buffer);
- for (UINT32 curhunk = first_hunk; curhunk <= last_hunk; curhunk++)
+ uint32_t first_hunk = offset / m_hunkbytes;
+ uint32_t last_hunk = (offset + bytes - 1) / m_hunkbytes;
+ uint8_t *dest = reinterpret_cast<uint8_t *>(buffer);
+ for (uint32_t curhunk = first_hunk; curhunk <= last_hunk; curhunk++)
{
// determine start/end boundaries
- UINT32 startoffs = (curhunk == first_hunk) ? (offset % m_hunkbytes) : 0;
- UINT32 endoffs = (curhunk == last_hunk) ? ((offset + bytes - 1) % m_hunkbytes) : (m_hunkbytes - 1);
+ uint32_t startoffs = (curhunk == first_hunk) ? (offset % m_hunkbytes) : 0;
+ uint32_t endoffs = (curhunk == last_hunk) ? ((offset + bytes - 1) % m_hunkbytes) : (m_hunkbytes - 1);
// if it's a full block, just read directly from disk unless it's the cached hunk
chd_error err = CHDERR_NONE;
@@ -1173,7 +1173,7 @@ chd_error chd_file::read_bytes(UINT64 offset, void *buffer, UINT32 bytes)
}
/**
- * @fn chd_error chd_file::write_bytes(UINT64 offset, const void *buffer, UINT32 bytes)
+ * @fn chd_error chd_file::write_bytes(uint64_t offset, const void *buffer, uint32_t bytes)
*
* @brief -------------------------------------------------
* write_bytes - write to the CHD at a byte level, using the cache to handle partial
@@ -1187,17 +1187,17 @@ chd_error chd_file::read_bytes(UINT64 offset, void *buffer, UINT32 bytes)
* @return A chd_error.
*/
-chd_error chd_file::write_bytes(UINT64 offset, const void *buffer, UINT32 bytes)
+chd_error chd_file::write_bytes(uint64_t offset, const void *buffer, uint32_t bytes)
{
// iterate over hunks
- UINT32 first_hunk = offset / m_hunkbytes;
- UINT32 last_hunk = (offset + bytes - 1) / m_hunkbytes;
- const UINT8 *source = reinterpret_cast<const UINT8 *>(buffer);
- for (UINT32 curhunk = first_hunk; curhunk <= last_hunk; curhunk++)
+ uint32_t first_hunk = offset / m_hunkbytes;
+ uint32_t last_hunk = (offset + bytes - 1) / m_hunkbytes;
+ const uint8_t *source = reinterpret_cast<const uint8_t *>(buffer);
+ for (uint32_t curhunk = first_hunk; curhunk <= last_hunk; curhunk++)
{
// determine start/end boundaries
- UINT32 startoffs = (curhunk == first_hunk) ? (offset % m_hunkbytes) : 0;
- UINT32 endoffs = (curhunk == last_hunk) ? ((offset + bytes - 1) % m_hunkbytes) : (m_hunkbytes - 1);
+ uint32_t startoffs = (curhunk == first_hunk) ? (offset % m_hunkbytes) : 0;
+ uint32_t endoffs = (curhunk == last_hunk) ? ((offset + bytes - 1) % m_hunkbytes) : (m_hunkbytes - 1);
// if it's a full block, just write directly to disk unless it's the cached hunk
chd_error err = CHDERR_NONE;
@@ -1227,7 +1227,7 @@ chd_error chd_file::write_bytes(UINT64 offset, const void *buffer, UINT32 bytes)
}
/**
- * @fn chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, std::string &output)
+ * @fn chd_error chd_file::read_metadata(chd_metadata_tag searchtag, uint32_t searchindex, std::string &output)
*
* @brief -------------------------------------------------
* read_metadata - read the indexed metadata of the given type
@@ -1243,7 +1243,7 @@ chd_error chd_file::write_bytes(UINT64 offset, const void *buffer, UINT32 bytes)
* @return The metadata.
*/
-chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, std::string &output)
+chd_error chd_file::read_metadata(chd_metadata_tag searchtag, uint32_t searchindex, std::string &output)
{
// wrap this for clean reporting
try
@@ -1271,7 +1271,7 @@ chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex
}
/**
- * @fn chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, std::vector<UINT8> &output)
+ * @fn chd_error chd_file::read_metadata(chd_metadata_tag searchtag, uint32_t searchindex, std::vector<uint8_t> &output)
*
* @brief Reads a metadata.
*
@@ -1285,7 +1285,7 @@ chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex
* @return The metadata.
*/
-chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, std::vector<UINT8> &output)
+chd_error chd_file::read_metadata(chd_metadata_tag searchtag, uint32_t searchindex, std::vector<uint8_t> &output)
{
// wrap this for clean reporting
try
@@ -1309,7 +1309,7 @@ chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex
}
/**
- * @fn chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, void *output, UINT32 outputlen, UINT32 &resultlen)
+ * @fn chd_error chd_file::read_metadata(chd_metadata_tag searchtag, uint32_t searchindex, void *output, uint32_t outputlen, uint32_t &resultlen)
*
* @brief Reads a metadata.
*
@@ -1325,7 +1325,7 @@ chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex
* @return The metadata.
*/
-chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, void *output, UINT32 outputlen, UINT32 &resultlen)
+chd_error chd_file::read_metadata(chd_metadata_tag searchtag, uint32_t searchindex, void *output, uint32_t outputlen, uint32_t &resultlen)
{
// wrap this for clean reporting
try
@@ -1349,7 +1349,7 @@ chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex
}
/**
- * @fn chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, std::vector<UINT8> &output, chd_metadata_tag &resulttag, UINT8 &resultflags)
+ * @fn chd_error chd_file::read_metadata(chd_metadata_tag searchtag, uint32_t searchindex, std::vector<uint8_t> &output, chd_metadata_tag &resulttag, uint8_t &resultflags)
*
* @brief Reads a metadata.
*
@@ -1365,7 +1365,7 @@ chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex
* @return The metadata.
*/
-chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, std::vector<UINT8> &output, chd_metadata_tag &resulttag, UINT8 &resultflags)
+chd_error chd_file::read_metadata(chd_metadata_tag searchtag, uint32_t searchindex, std::vector<uint8_t> &output, chd_metadata_tag &resulttag, uint8_t &resultflags)
{
// wrap this for clean reporting
try
@@ -1391,7 +1391,7 @@ chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex
}
/**
- * @fn chd_error chd_file::write_metadata(chd_metadata_tag metatag, UINT32 metaindex, const void *inputbuf, UINT32 inputlen, UINT8 flags)
+ * @fn chd_error chd_file::write_metadata(chd_metadata_tag metatag, uint32_t metaindex, const void *inputbuf, uint32_t inputlen, uint8_t flags)
*
* @brief -------------------------------------------------
* write_metadata - write the indexed metadata of the given type
@@ -1406,7 +1406,7 @@ chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex
* @return A chd_error.
*/
-chd_error chd_file::write_metadata(chd_metadata_tag metatag, UINT32 metaindex, const void *inputbuf, UINT32 inputlen, UINT8 flags)
+chd_error chd_file::write_metadata(chd_metadata_tag metatag, uint32_t metaindex, const void *inputbuf, uint32_t inputlen, uint8_t flags)
{
// wrap this for clean reporting
try
@@ -1428,7 +1428,7 @@ chd_error chd_file::write_metadata(chd_metadata_tag metatag, UINT32 metaindex, c
// if the lengths don't match, we need to update the length in our header
if (inputlen != metaentry.length)
{
- UINT8 length[3];
+ uint8_t length[3];
be_write(length, inputlen, 3);
file_write(metaentry.offset + 5, length, sizeof(length));
}
@@ -1446,14 +1446,14 @@ chd_error chd_file::write_metadata(chd_metadata_tag metatag, UINT32 metaindex, c
if (!finished)
{
// now build us a new entry
- UINT8 raw_meta_header[METADATA_HEADER_SIZE];
+ uint8_t raw_meta_header[METADATA_HEADER_SIZE];
be_write(&raw_meta_header[0], metatag, 4);
raw_meta_header[4] = flags;
be_write(&raw_meta_header[5], (inputlen & 0x00ffffff) | (flags << 24), 3);
be_write(&raw_meta_header[8], 0, 8);
// append the new header, then the data
- UINT64 offset = file_append(raw_meta_header, sizeof(raw_meta_header));
+ uint64_t offset = file_append(raw_meta_header, sizeof(raw_meta_header));
file_append(inputbuf, inputlen);
// set the previous entry to point to us
@@ -1473,7 +1473,7 @@ chd_error chd_file::write_metadata(chd_metadata_tag metatag, UINT32 metaindex, c
}
/**
- * @fn chd_error chd_file::delete_metadata(chd_metadata_tag metatag, UINT32 metaindex)
+ * @fn chd_error chd_file::delete_metadata(chd_metadata_tag metatag, uint32_t metaindex)
*
* @brief -------------------------------------------------
* delete_metadata - remove the given metadata from the list
@@ -1488,7 +1488,7 @@ chd_error chd_file::write_metadata(chd_metadata_tag metatag, UINT32 metaindex, c
* @return A chd_error.
*/
-chd_error chd_file::delete_metadata(chd_metadata_tag metatag, UINT32 metaindex)
+chd_error chd_file::delete_metadata(chd_metadata_tag metatag, uint32_t metaindex)
{
// wrap this for clean reporting
try
@@ -1530,7 +1530,7 @@ chd_error chd_file::clone_all_metadata(chd_file &source)
try
{
// iterate over metadata entries in the source
- std::vector<UINT8> filedata;
+ std::vector<uint8_t> filedata;
metadata_entry metaentry;
metaentry.metatag = 0;
metaentry.length = 0;
@@ -1543,7 +1543,7 @@ chd_error chd_file::clone_all_metadata(chd_file &source)
source.file_read(metaentry.offset + METADATA_HEADER_SIZE, &filedata[0], metaentry.length);
// write it to the destination
- chd_error err = write_metadata(metaentry.metatag, (UINT32)-1, &filedata[0], metaentry.length, metaentry.flags);
+ chd_error err = write_metadata(metaentry.metatag, (uint32_t)-1, &filedata[0], metaentry.length, metaentry.flags);
if (err != CHDERR_NONE)
throw err;
}
@@ -1577,7 +1577,7 @@ util::sha1_t chd_file::compute_overall_sha1(util::sha1_t rawsha1)
return rawsha1;
// iterate over metadata
- std::vector<UINT8> filedata;
+ std::vector<uint8_t> filedata;
std::vector<metadata_hash> hasharray;
metadata_entry metaentry;
for (bool has_data = metadata_find(CHDMETATAG_WILDCARD, 0, metaentry); has_data; has_data = metadata_find(CHDMETATAG_WILDCARD, 0, metaentry, true))
@@ -1704,17 +1704,17 @@ const char *chd_file::error_string(chd_error err)
//**************************************************************************
/**
- * @fn UINT32 chd_file::guess_unitbytes()
+ * @fn uint32_t chd_file::guess_unitbytes()
*
* @brief -------------------------------------------------
* guess_unitbytes - for older CHD formats, take a guess at the bytes/unit based on
* metadata
* -------------------------------------------------.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-UINT32 chd_file::guess_unitbytes()
+uint32_t chd_file::guess_unitbytes()
{
// look for hard disk metadata; if found, then the unit size == sector size
std::string metadata;
@@ -1735,7 +1735,7 @@ UINT32 chd_file::guess_unitbytes()
}
/**
- * @fn void chd_file::parse_v3_header(UINT8 *rawheader, sha1_t &parentsha1)
+ * @fn void chd_file::parse_v3_header(uint8_t *rawheader, sha1_t &parentsha1)
*
* @brief -------------------------------------------------
* parse_v3_header - parse the header from a v3 file and configure core parameters
@@ -1750,7 +1750,7 @@ UINT32 chd_file::guess_unitbytes()
* @param [in,out] parentsha1 The first parentsha.
*/
-void chd_file::parse_v3_header(UINT8 *rawheader, util::sha1_t &parentsha1)
+void chd_file::parse_v3_header(uint8_t *rawheader, util::sha1_t &parentsha1)
{
// verify header length
if (be_read(&rawheader[8], 4) != V3_HEADER_SIZE)
@@ -1764,7 +1764,7 @@ void chd_file::parse_v3_header(UINT8 *rawheader, util::sha1_t &parentsha1)
m_hunkcount = be_read(&rawheader[24], 4);
// extract parent SHA-1
- UINT32 flags = be_read(&rawheader[16], 4);
+ uint32_t flags = be_read(&rawheader[16], 4);
m_allow_writes = (flags & 2) == 0;
// determine compression
@@ -1798,7 +1798,7 @@ void chd_file::parse_v3_header(UINT8 *rawheader, util::sha1_t &parentsha1)
}
/**
- * @fn void chd_file::parse_v4_header(UINT8 *rawheader, sha1_t &parentsha1)
+ * @fn void chd_file::parse_v4_header(uint8_t *rawheader, sha1_t &parentsha1)
*
* @brief -------------------------------------------------
* parse_v4_header - parse the header from a v4 file and configure core parameters
@@ -1813,7 +1813,7 @@ void chd_file::parse_v3_header(UINT8 *rawheader, util::sha1_t &parentsha1)
* @param [in,out] parentsha1 The first parentsha.
*/
-void chd_file::parse_v4_header(UINT8 *rawheader, util::sha1_t &parentsha1)
+void chd_file::parse_v4_header(uint8_t *rawheader, util::sha1_t &parentsha1)
{
// verify header length
if (be_read(&rawheader[8], 4) != V4_HEADER_SIZE)
@@ -1827,7 +1827,7 @@ void chd_file::parse_v4_header(UINT8 *rawheader, util::sha1_t &parentsha1)
m_hunkcount = be_read(&rawheader[24], 4);
// extract parent SHA-1
- UINT32 flags = be_read(&rawheader[16], 4);
+ uint32_t flags = be_read(&rawheader[16], 4);
m_allow_writes = (flags & 2) == 0;
// determine compression
@@ -1861,7 +1861,7 @@ void chd_file::parse_v4_header(UINT8 *rawheader, util::sha1_t &parentsha1)
}
/**
- * @fn void chd_file::parse_v5_header(UINT8 *rawheader, sha1_t &parentsha1)
+ * @fn void chd_file::parse_v5_header(uint8_t *rawheader, sha1_t &parentsha1)
*
* @brief -------------------------------------------------
* parse_v5_header - read the header from a v5 file and configure core parameters
@@ -1873,7 +1873,7 @@ void chd_file::parse_v4_header(UINT8 *rawheader, util::sha1_t &parentsha1)
* @param [in,out] parentsha1 The first parentsha.
*/
-void chd_file::parse_v5_header(UINT8 *rawheader, util::sha1_t &parentsha1)
+void chd_file::parse_v5_header(uint8_t *rawheader, util::sha1_t &parentsha1)
{
// verify header length
if (be_read(&rawheader[8], 4) != V5_HEADER_SIZE)
@@ -1931,29 +1931,29 @@ chd_error chd_file::compress_v5_map()
util::crc16_t mapcrc = util::crc16_creator::simple(&m_rawmap[0], m_hunkcount * 12);
// create a buffer to hold the RLE data
- std::vector<UINT8> compression_rle(m_hunkcount);
- UINT8 *dest = &compression_rle[0];
+ std::vector<uint8_t> compression_rle(m_hunkcount);
+ uint8_t *dest = &compression_rle[0];
// use a huffman encoder for 16 different codes, maximum length is 8 bits
huffman_encoder<16, 8> encoder;
encoder.histo_reset();
// RLE-compress the compression type since we expect runs of the same
- UINT32 max_self = 0;
- UINT32 last_self = 0;
- UINT64 max_parent = 0;
- UINT64 last_parent = 0;
- UINT32 max_complen = 0;
- UINT8 lastcomp = 0;
+ uint32_t max_self = 0;
+ uint32_t last_self = 0;
+ uint64_t max_parent = 0;
+ uint64_t last_parent = 0;
+ uint32_t max_complen = 0;
+ uint8_t lastcomp = 0;
int count = 0;
for (int hunknum = 0; hunknum < m_hunkcount; hunknum++)
{
- UINT8 curcomp = m_rawmap[hunknum * 12 + 0];
+ uint8_t curcomp = m_rawmap[hunknum * 12 + 0];
// promote self block references to more compact forms
if (curcomp == COMPRESSION_SELF)
{
- UINT32 refhunk = be_read(&m_rawmap[hunknum * 12 + 4], 6);
+ uint32_t refhunk = be_read(&m_rawmap[hunknum * 12 + 4], 6);
if (refhunk == last_self)
curcomp = COMPRESSION_SELF_0;
else if (refhunk == last_self + 1)
@@ -1966,21 +1966,21 @@ chd_error chd_file::compress_v5_map()
// promote parent block references to more compact forms
else if (curcomp == COMPRESSION_PARENT)
{
- UINT32 refunit = be_read(&m_rawmap[hunknum * 12 + 4], 6);
- if (refunit == (UINT64(hunknum) * UINT64(m_hunkbytes)) / m_unitbytes)
+ uint32_t refunit = be_read(&m_rawmap[hunknum * 12 + 4], 6);
+ if (refunit == (uint64_t(hunknum) * uint64_t(m_hunkbytes)) / m_unitbytes)
curcomp = COMPRESSION_PARENT_SELF;
else if (refunit == last_parent)
curcomp = COMPRESSION_PARENT_0;
else if (refunit == last_parent + m_hunkbytes / m_unitbytes)
curcomp = COMPRESSION_PARENT_1;
else
- max_parent = std::max(max_parent, UINT64(refunit));
+ max_parent = std::max(max_parent, uint64_t(refunit));
last_parent = refunit;
}
// track maximum compressed length
else //if (curcomp >= COMPRESSION_TYPE_0 && curcomp <= COMPRESSION_TYPE_3)
- max_complen = std::max(max_complen, UINT32(be_read(&m_rawmap[hunknum * 12 + 1], 3)));
+ max_complen = std::max(max_complen, uint32_t(be_read(&m_rawmap[hunknum * 12 + 1], 3)));
// track repeats
if (curcomp == lastcomp)
@@ -2014,7 +2014,7 @@ chd_error chd_file::compress_v5_map()
}
// compute a tree and export it to the buffer
- std::vector<UINT8> compressed(m_hunkcount * 6);
+ std::vector<uint8_t> compressed(m_hunkcount * 6);
bitstream_out bitbuf(&compressed[16], compressed.size() - 16);
huffman_error err = encoder.compute_tree_from_histo();
if (err != HUFFERR_NONE)
@@ -2024,31 +2024,31 @@ chd_error chd_file::compress_v5_map()
throw CHDERR_COMPRESSION_ERROR;
// encode the data
- for (UINT8 *src = &compression_rle[0]; src < dest; src++)
+ for (uint8_t *src = &compression_rle[0]; src < dest; src++)
encoder.encode_one(bitbuf, *src);
// determine the number of bits we need to hold the a length
// and a hunk index
- UINT8 lengthbits = bits_for_value(max_complen);
- UINT8 selfbits = bits_for_value(max_self);
- UINT8 parentbits = bits_for_value(max_parent);
+ uint8_t lengthbits = bits_for_value(max_complen);
+ uint8_t selfbits = bits_for_value(max_self);
+ uint8_t parentbits = bits_for_value(max_parent);
// for each compression type, output the relevant data
lastcomp = 0;
count = 0;
- UINT8 *src = &compression_rle[0];
- UINT64 firstoffs = 0;
+ uint8_t *src = &compression_rle[0];
+ uint64_t firstoffs = 0;
for (int hunknum = 0; hunknum < m_hunkcount; hunknum++)
{
- UINT8 *rawmap = &m_rawmap[hunknum * 12];
- UINT32 length = be_read(&rawmap[1], 3);
- UINT64 offset = be_read(&rawmap[4], 6);
- UINT16 crc = be_read(&rawmap[10], 2);
+ uint8_t *rawmap = &m_rawmap[hunknum * 12];
+ uint32_t length = be_read(&rawmap[1], 3);
+ uint64_t offset = be_read(&rawmap[4], 6);
+ uint16_t crc = be_read(&rawmap[10], 2);
// if no count remaining, fetch the next entry
if (count == 0)
{
- UINT8 val = *src++;
+ uint8_t val = *src++;
if (val == COMPRESSION_RLE_SMALL)
count = 2 + *src++;
else if (val == COMPRESSION_RLE_LARGE)
@@ -2080,12 +2080,12 @@ chd_error chd_file::compress_v5_map()
break;
case COMPRESSION_SELF:
- assert(offset < (UINT64(1) << selfbits));
+ assert(offset < (uint64_t(1) << selfbits));
bitbuf.write(offset, selfbits);
break;
case COMPRESSION_PARENT:
- assert(offset < (UINT64(1) << parentbits));
+ assert(offset < (uint64_t(1) << parentbits));
bitbuf.write(offset, parentbits);
break;
@@ -2099,7 +2099,7 @@ chd_error chd_file::compress_v5_map()
}
// write the map header
- UINT32 complen = bitbuf.flush();
+ uint32_t complen = bitbuf.flush();
assert(!bitbuf.overflow());
be_write(&compressed[0], complen, 4);
be_write(&compressed[4], firstoffs, 6);
@@ -2113,7 +2113,7 @@ chd_error chd_file::compress_v5_map()
m_mapoffset = file_append(&compressed[0], complen + 16);
// then write the map offset
- UINT8 rawbuf[sizeof(UINT64)];
+ uint8_t rawbuf[sizeof(uint64_t)];
be_write(rawbuf, m_mapoffset, 8);
file_write(m_mapoffset_offset, rawbuf, sizeof(rawbuf));
return CHDERR_NONE;
@@ -2145,17 +2145,17 @@ void chd_file::decompress_v5_map()
}
// read the reader
- UINT8 rawbuf[16];
+ uint8_t rawbuf[16];
file_read(m_mapoffset, rawbuf, sizeof(rawbuf));
- UINT32 mapbytes = be_read(&rawbuf[0], 4);
- UINT64 firstoffs = be_read(&rawbuf[4], 6);
- UINT16 mapcrc = be_read(&rawbuf[10], 2);
- UINT8 lengthbits = rawbuf[12];
- UINT8 selfbits = rawbuf[13];
- UINT8 parentbits = rawbuf[14];
+ uint32_t mapbytes = be_read(&rawbuf[0], 4);
+ uint64_t firstoffs = be_read(&rawbuf[4], 6);
+ uint16_t mapcrc = be_read(&rawbuf[10], 2);
+ uint8_t lengthbits = rawbuf[12];
+ uint8_t selfbits = rawbuf[13];
+ uint8_t parentbits = rawbuf[14];
// now read the map
- std::vector<UINT8> compressed(mapbytes);
+ std::vector<uint8_t> compressed(mapbytes);
file_read(m_mapoffset + 16, &compressed[0], mapbytes);
bitstream_in bitbuf(&compressed[0], compressed.size());
@@ -2164,16 +2164,16 @@ void chd_file::decompress_v5_map()
huffman_error err = decoder.import_tree_rle(bitbuf);
if (err != HUFFERR_NONE)
throw CHDERR_DECOMPRESSION_ERROR;
- UINT8 lastcomp = 0;
+ uint8_t lastcomp = 0;
int repcount = 0;
for (int hunknum = 0; hunknum < m_hunkcount; hunknum++)
{
- UINT8 *rawmap = &m_rawmap[hunknum * 12];
+ uint8_t *rawmap = &m_rawmap[hunknum * 12];
if (repcount > 0)
rawmap[0] = lastcomp, repcount--;
else
{
- UINT8 val = decoder.decode_one(bitbuf);
+ uint8_t val = decoder.decode_one(bitbuf);
if (val == COMPRESSION_RLE_SMALL)
rawmap[0] = lastcomp, repcount = 2 + decoder.decode_one(bitbuf);
else if (val == COMPRESSION_RLE_LARGE)
@@ -2184,15 +2184,15 @@ void chd_file::decompress_v5_map()
}
// then iterate through the hunks and extract the needed data
- UINT64 curoffset = firstoffs;
- UINT32 last_self = 0;
- UINT64 last_parent = 0;
+ uint64_t curoffset = firstoffs;
+ uint32_t last_self = 0;
+ uint64_t last_parent = 0;
for (int hunknum = 0; hunknum < m_hunkcount; hunknum++)
{
- UINT8 *rawmap = &m_rawmap[hunknum * 12];
- UINT64 offset = curoffset;
- UINT32 length = 0;
- UINT16 crc = 0;
+ uint8_t *rawmap = &m_rawmap[hunknum * 12];
+ uint64_t offset = curoffset;
+ uint32_t length = 0;
+ uint16_t crc = 0;
switch (rawmap[0])
{
// base types
@@ -2228,7 +2228,7 @@ void chd_file::decompress_v5_map()
case COMPRESSION_PARENT_SELF:
rawmap[0] = COMPRESSION_PARENT;
- last_parent = offset = (UINT64(hunknum) * UINT64(m_hunkbytes)) / m_unitbytes;
+ last_parent = offset = (uint64_t(hunknum) * uint64_t(m_hunkbytes)) / m_unitbytes;
break;
case COMPRESSION_PARENT_1:
@@ -2297,7 +2297,7 @@ chd_error chd_file::create_common()
}
// create our V5 header
- UINT8 rawheader[V5_HEADER_SIZE];
+ uint8_t rawheader[V5_HEADER_SIZE];
memcpy(&rawheader[0], "MComprHD", 8);
be_write(&rawheader[8], V5_HEADER_SIZE, 4);
be_write(&rawheader[12], m_version, 4);
@@ -2328,12 +2328,12 @@ chd_error chd_file::create_common()
// write out the map (if not compressed)
if (!compressed())
{
- UINT32 mapsize = m_mapentrybytes * m_hunkcount;
- UINT8 buffer[4096] = { 0 };
- UINT64 offset = m_mapoffset;
+ uint32_t mapsize = m_mapentrybytes * m_hunkcount;
+ uint8_t buffer[4096] = { 0 };
+ uint64_t offset = m_mapoffset;
while (mapsize != 0)
{
- UINT32 bytes_to_write = (std::min<size_t>)(mapsize, sizeof(buffer));
+ uint32_t bytes_to_write = (std::min<size_t>)(mapsize, sizeof(buffer));
file_write(offset, buffer, bytes_to_write);
offset += bytes_to_write;
mapsize -= bytes_to_write;
@@ -2390,7 +2390,7 @@ chd_error chd_file::open_common(bool writeable)
m_allow_reads = true;
// read the raw header
- UINT8 rawheader[MAX_HEADER_SIZE];
+ uint8_t rawheader[MAX_HEADER_SIZE];
file_read(0, rawheader, sizeof(rawheader));
// verify the signature
@@ -2473,7 +2473,7 @@ void chd_file::create_open_common()
}
/**
- * @fn void chd_file::verify_proper_compression_append(UINT32 hunknum)
+ * @fn void chd_file::verify_proper_compression_append(uint32_t hunknum)
*
* @brief -------------------------------------------------
* verify_proper_compression_append - verify that the given hunk is a proper candidate
@@ -2491,7 +2491,7 @@ void chd_file::create_open_common()
* @param hunknum The hunknum.
*/
-void chd_file::verify_proper_compression_append(UINT32 hunknum)
+void chd_file::verify_proper_compression_append(uint32_t hunknum)
{
// punt if no file
if (m_file == nullptr)
@@ -2510,7 +2510,7 @@ void chd_file::verify_proper_compression_append(UINT32 hunknum)
throw CHDERR_FILE_NOT_WRITEABLE;
// only permitted to write new blocks
- UINT8 *rawmap = &m_rawmap[hunknum * 12];
+ uint8_t *rawmap = &m_rawmap[hunknum * 12];
if (rawmap[0] != 0xff)
throw CHDERR_COMPRESSION_ERROR;
@@ -2521,7 +2521,7 @@ void chd_file::verify_proper_compression_append(UINT32 hunknum)
}
/**
- * @fn void chd_file::hunk_write_compressed(UINT32 hunknum, INT8 compression, const UINT8 *compressed, UINT32 complength, crc16_t crc16)
+ * @fn void chd_file::hunk_write_compressed(uint32_t hunknum, int8_t compression, const uint8_t *compressed, uint32_t complength, crc16_t crc16)
*
* @brief -------------------------------------------------
* hunk_write_compressed - write a hunk to a compressed CHD, discovering the best
@@ -2535,16 +2535,16 @@ void chd_file::verify_proper_compression_append(UINT32 hunknum)
* @param crc16 The CRC 16.
*/
-void chd_file::hunk_write_compressed(UINT32 hunknum, INT8 compression, const UINT8 *compressed, UINT32 complength, util::crc16_t crc16)
+void chd_file::hunk_write_compressed(uint32_t hunknum, int8_t compression, const uint8_t *compressed, uint32_t complength, util::crc16_t crc16)
{
// verify that we are appending properly to a compressed file
verify_proper_compression_append(hunknum);
// write the final result
- UINT64 offset = file_append(compressed, complength);
+ uint64_t offset = file_append(compressed, complength);
// update the map entry
- UINT8 *rawmap = &m_rawmap[hunknum * 12];
+ uint8_t *rawmap = &m_rawmap[hunknum * 12];
rawmap[0] = (compression == -1) ? COMPRESSION_NONE : compression;
be_write(&rawmap[1], complength, 3);
be_write(&rawmap[4], offset, 6);
@@ -2552,7 +2552,7 @@ void chd_file::hunk_write_compressed(UINT32 hunknum, INT8 compression, const UIN
}
/**
- * @fn void chd_file::hunk_copy_from_self(UINT32 hunknum, UINT32 otherhunk)
+ * @fn void chd_file::hunk_copy_from_self(uint32_t hunknum, uint32_t otherhunk)
*
* @brief -------------------------------------------------
* hunk_copy_from_self - mark a hunk as being a copy of another hunk in the same CHD
@@ -2565,7 +2565,7 @@ void chd_file::hunk_write_compressed(UINT32 hunknum, INT8 compression, const UIN
* @param otherhunk The otherhunk.
*/
-void chd_file::hunk_copy_from_self(UINT32 hunknum, UINT32 otherhunk)
+void chd_file::hunk_copy_from_self(uint32_t hunknum, uint32_t otherhunk)
{
// verify that we are appending properly to a compressed file
verify_proper_compression_append(hunknum);
@@ -2575,7 +2575,7 @@ void chd_file::hunk_copy_from_self(UINT32 hunknum, UINT32 otherhunk)
throw CHDERR_INVALID_PARAMETER;
// update the map entry
- UINT8 *rawmap = &m_rawmap[hunknum * 12];
+ uint8_t *rawmap = &m_rawmap[hunknum * 12];
rawmap[0] = COMPRESSION_SELF;
be_write(&rawmap[1], 0, 3);
be_write(&rawmap[4], otherhunk, 6);
@@ -2583,7 +2583,7 @@ void chd_file::hunk_copy_from_self(UINT32 hunknum, UINT32 otherhunk)
}
/**
- * @fn void chd_file::hunk_copy_from_parent(UINT32 hunknum, UINT64 parentunit)
+ * @fn void chd_file::hunk_copy_from_parent(uint32_t hunknum, uint64_t parentunit)
*
* @brief -------------------------------------------------
* hunk_copy_from_parent - mark a hunk as being a copy of a hunk from a parent CHD
@@ -2593,13 +2593,13 @@ void chd_file::hunk_copy_from_self(UINT32 hunknum, UINT32 otherhunk)
* @param parentunit The parentunit.
*/
-void chd_file::hunk_copy_from_parent(UINT32 hunknum, UINT64 parentunit)
+void chd_file::hunk_copy_from_parent(uint32_t hunknum, uint64_t parentunit)
{
// verify that we are appending properly to a compressed file
verify_proper_compression_append(hunknum);
// update the map entry
- UINT8 *rawmap = &m_rawmap[hunknum * 12];
+ uint8_t *rawmap = &m_rawmap[hunknum * 12];
rawmap[0] = COMPRESSION_PARENT;
be_write(&rawmap[1], 0, 3);
be_write(&rawmap[4], parentunit, 6);
@@ -2607,7 +2607,7 @@ void chd_file::hunk_copy_from_parent(UINT32 hunknum, UINT64 parentunit)
}
/**
- * @fn bool chd_file::metadata_find(chd_metadata_tag metatag, INT32 metaindex, metadata_entry &metaentry, bool resume)
+ * @fn bool chd_file::metadata_find(chd_metadata_tag metatag, int32_t metaindex, metadata_entry &metaentry, bool resume)
*
* @brief -------------------------------------------------
* metadata_find - find a metadata entry
@@ -2621,7 +2621,7 @@ void chd_file::hunk_copy_from_parent(UINT32 hunknum, UINT64 parentunit)
* @return true if it succeeds, false if it fails.
*/
-bool chd_file::metadata_find(chd_metadata_tag metatag, INT32 metaindex, metadata_entry &metaentry, bool resume)
+bool chd_file::metadata_find(chd_metadata_tag metatag, int32_t metaindex, metadata_entry &metaentry, bool resume)
{
// start at the beginning unless we're resuming a previous search
if (!resume)
@@ -2639,7 +2639,7 @@ bool chd_file::metadata_find(chd_metadata_tag metatag, INT32 metaindex, metadata
while (metaentry.offset != 0)
{
// read the raw header
- UINT8 raw_meta_header[METADATA_HEADER_SIZE];
+ uint8_t raw_meta_header[METADATA_HEADER_SIZE];
file_read(metaentry.offset, raw_meta_header, sizeof(raw_meta_header));
// extract the data
@@ -2663,7 +2663,7 @@ bool chd_file::metadata_find(chd_metadata_tag metatag, INT32 metaindex, metadata
}
/**
- * @fn void chd_file::metadata_set_previous_next(UINT64 prevoffset, UINT64 nextoffset)
+ * @fn void chd_file::metadata_set_previous_next(uint64_t prevoffset, uint64_t nextoffset)
*
* @brief -------------------------------------------------
* metadata_set_previous_next - set the 'next' offset of a piece of metadata
@@ -2673,9 +2673,9 @@ bool chd_file::metadata_find(chd_metadata_tag metatag, INT32 metaindex, metadata
* @param nextoffset The nextoffset.
*/
-void chd_file::metadata_set_previous_next(UINT64 prevoffset, UINT64 nextoffset)
+void chd_file::metadata_set_previous_next(uint64_t prevoffset, uint64_t nextoffset)
{
- UINT64 offset = 0;
+ uint64_t offset = 0;
// if we were the first entry, make the next entry the first
if (prevoffset == 0)
@@ -2689,7 +2689,7 @@ void chd_file::metadata_set_previous_next(UINT64 prevoffset, UINT64 nextoffset)
offset = prevoffset + 8;
// create a big-endian version
- UINT8 rawbuf[sizeof(UINT64)];
+ uint8_t rawbuf[sizeof(uint64_t)];
be_write(rawbuf, nextoffset, 8);
// write to the header and update our local copy
@@ -2714,7 +2714,7 @@ void chd_file::metadata_update_hash()
util::sha1_t fullsha1 = compute_overall_sha1(raw_sha1());
// create a big-endian version
- UINT8 rawbuf[sizeof(util::sha1_t)];
+ uint8_t rawbuf[sizeof(util::sha1_t)];
be_write_sha1(&rawbuf[0], fullsha1);
// write to the header
@@ -2863,9 +2863,9 @@ chd_error chd_file_compressor::compress_continue(double &progress, double &ratio
while (m_read_queue_offset < m_logicalbytes && osd_work_queue_items(m_read_queue) < 2)
{
// see if we have enough free work items to read the next half of a buffer
- UINT32 startitem = m_read_queue_offset / hunk_bytes();
- UINT32 enditem = startitem + WORK_BUFFER_HUNKS / 2;
- UINT32 curitem;
+ uint32_t startitem = m_read_queue_offset / hunk_bytes();
+ uint32_t enditem = startitem + WORK_BUFFER_HUNKS / 2;
+ uint32_t curitem;
for (curitem = startitem; curitem < enditem; curitem++)
if (m_work_item[curitem % WORK_BUFFER_HUNKS].m_status != WS_READY)
break;
@@ -2899,11 +2899,11 @@ chd_error chd_file_compressor::compress_continue(double &progress, double &ratio
// for parent walking, just add to the hashmap
if (m_walking_parent)
{
- UINT32 uph = hunk_bytes() / unit_bytes();
- UINT32 units = uph;
+ uint32_t uph = hunk_bytes() / unit_bytes();
+ uint32_t units = uph;
if (item.m_hunknum == hunk_count() - 1 || !compressed())
units = 1;
- for (UINT32 unit = 0; unit < units; unit++)
+ for (uint32_t unit = 0; unit < units; unit++)
if (m_parent_map.find(item.m_hash[unit].m_crc16, item.m_hash[unit].m_sha1) == hashmap::NOT_FOUND)
m_parent_map.add(item.m_hunknum * uph + unit, item.m_hash[unit].m_crc16, item.m_hash[unit].m_sha1);
}
@@ -2917,7 +2917,7 @@ chd_error chd_file_compressor::compress_continue(double &progress, double &ratio
// writes of all-0 data don't actually take space, so see if we count this
chd_codec_type codec = CHD_CODEC_NONE;
- UINT32 complen;
+ uint32_t complen;
hunk_info(item.m_hunknum, codec, complen);
if (codec == CHD_CODEC_NONE)
m_total_out += m_hunkbytes;
@@ -2927,7 +2927,7 @@ chd_error chd_file_compressor::compress_continue(double &progress, double &ratio
else do
{
// first see if the hunk is in the parent or self maps
- UINT64 selfhunk = m_current_map.find(item.m_hash[0].m_crc16, item.m_hash[0].m_sha1);
+ uint64_t selfhunk = m_current_map.find(item.m_hash[0].m_crc16, item.m_hash[0].m_sha1);
if (selfhunk != hashmap::NOT_FOUND)
{
hunk_copy_from_self(item.m_hunknum, selfhunk);
@@ -2937,7 +2937,7 @@ chd_error chd_file_compressor::compress_continue(double &progress, double &ratio
// if not, see if it's in the parent map
if (m_parent != nullptr)
{
- UINT64 parentunit = m_parent_map.find(item.m_hash[0].m_crc16, item.m_hash[0].m_sha1);
+ uint64_t parentunit = m_parent_map.find(item.m_hash[0].m_crc16, item.m_hash[0].m_sha1);
if (parentunit != hashmap::NOT_FOUND)
{
hunk_copy_from_parent(item.m_hunknum, parentunit);
@@ -3028,10 +3028,10 @@ void *chd_file_compressor::async_walk_parent_static(void *param, int threadid)
void chd_file_compressor::async_walk_parent(work_item &item)
{
// compute CRC-16 and SHA-1 hashes for each unit, unless we're the last one or we're uncompressed
- UINT32 units = hunk_bytes() / unit_bytes();
+ uint32_t units = hunk_bytes() / unit_bytes();
if (item.m_hunknum == m_hunkcount - 1 || !compressed())
units = 1;
- for (UINT32 unit = 0; unit < units; unit++)
+ for (uint32_t unit = 0; unit < units; unit++)
{
item.m_hash[unit].m_crc16 = util::crc16_creator::simple(item.m_data + unit * unit_bytes(), hunk_bytes());
item.m_hash[unit].m_sha1 = util::sha1_creator::simple(item.m_data + unit * unit_bytes(), hunk_bytes());
@@ -3121,8 +3121,8 @@ void chd_file_compressor::async_read()
return;
// determine parameters for the read
- UINT32 work_buffer_bytes = WORK_BUFFER_HUNKS * hunk_bytes();
- UINT32 numbytes = work_buffer_bytes / 2;
+ uint32_t work_buffer_bytes = WORK_BUFFER_HUNKS * hunk_bytes();
+ uint32_t numbytes = work_buffer_bytes / 2;
if (m_read_done_offset + numbytes > logical_bytes())
numbytes = logical_bytes() - m_read_done_offset;
@@ -3130,15 +3130,15 @@ void chd_file_compressor::async_read()
try
{
// do the read
- UINT8 *dest = &m_work_buffer[0] + (m_read_done_offset % work_buffer_bytes);
+ uint8_t *dest = &m_work_buffer[0] + (m_read_done_offset % work_buffer_bytes);
assert(dest == &m_work_buffer[0] || dest == &m_work_buffer[work_buffer_bytes/2]);
- UINT64 end_offset = m_read_done_offset + numbytes;
+ uint64_t end_offset = m_read_done_offset + numbytes;
// if walking the parent, read in hunks from the parent CHD
if (m_walking_parent)
{
- UINT8 *curdest = dest;
- for (UINT64 curoffs = m_read_done_offset; curoffs < end_offset + 1; curoffs += hunk_bytes())
+ uint8_t *curdest = dest;
+ for (uint64_t curoffs = m_read_done_offset; curoffs < end_offset + 1; curoffs += hunk_bytes())
{
m_parent->read_hunk(curoffs / hunk_bytes(), curdest);
curdest += hunk_bytes();
@@ -3150,9 +3150,9 @@ void chd_file_compressor::async_read()
read_data(dest, m_read_done_offset, numbytes);
// spawn off work for each hunk
- for (UINT64 curoffs = m_read_done_offset; curoffs < end_offset; curoffs += hunk_bytes())
+ for (uint64_t curoffs = m_read_done_offset; curoffs < end_offset; curoffs += hunk_bytes())
{
- UINT32 hunknum = curoffs / hunk_bytes();
+ uint32_t hunknum = curoffs / hunk_bytes();
work_item &item = m_work_item[hunknum % WORK_BUFFER_HUNKS];
assert(item.m_status == WS_READING);
item.m_status = WS_QUEUED;
@@ -3242,7 +3242,7 @@ void chd_file_compressor::hashmap::reset()
}
/**
- * @fn UINT64 chd_file_compressor::hashmap::find(crc16_t crc16, sha1_t sha1)
+ * @fn uint64_t chd_file_compressor::hashmap::find(crc16_t crc16, sha1_t sha1)
*
* @brief -------------------------------------------------
* find - find an item in the CRC map
@@ -3251,10 +3251,10 @@ void chd_file_compressor::hashmap::reset()
* @param crc16 The CRC 16.
* @param sha1 The first sha.
*
- * @return An UINT64.
+ * @return An uint64_t.
*/
-UINT64 chd_file_compressor::hashmap::find(util::crc16_t crc16, util::sha1_t sha1)
+uint64_t chd_file_compressor::hashmap::find(util::crc16_t crc16, util::sha1_t sha1)
{
// look up the entry in the map
for (entry_t *entry = m_map[crc16]; entry != nullptr; entry = entry->m_next)
@@ -3264,7 +3264,7 @@ UINT64 chd_file_compressor::hashmap::find(util::crc16_t crc16, util::sha1_t sha1
}
/**
- * @fn void chd_file_compressor::hashmap::add(UINT64 itemnum, crc16_t crc16, sha1_t sha1)
+ * @fn void chd_file_compressor::hashmap::add(uint64_t itemnum, crc16_t crc16, sha1_t sha1)
*
* @brief -------------------------------------------------
* add - add an item to the CRC map
@@ -3275,7 +3275,7 @@ UINT64 chd_file_compressor::hashmap::find(util::crc16_t crc16, util::sha1_t sha1
* @param sha1 The first sha.
*/
-void chd_file_compressor::hashmap::add(UINT64 itemnum, util::crc16_t crc16, util::sha1_t sha1)
+void chd_file_compressor::hashmap::add(uint64_t itemnum, util::crc16_t crc16, util::sha1_t sha1)
{
// add to the appropriate map
if (m_block_list->m_nextalloc == ARRAY_LENGTH(m_block_list->m_array))
diff --git a/src/lib/util/chd.h b/src/lib/util/chd.h
index 51c6fed0b54..a85ae1b9c10 100644
--- a/src/lib/util/chd.h
+++ b/src/lib/util/chd.h
@@ -33,17 +33,17 @@
V1 header:
[ 0] char tag[8]; // 'MComprHD'
- [ 8] UINT32 length; // length of header (including tag and length fields)
- [ 12] UINT32 version; // drive format version
- [ 16] UINT32 flags; // flags (see below)
- [ 20] UINT32 compression; // compression type
- [ 24] UINT32 hunksize; // 512-byte sectors per hunk
- [ 28] UINT32 totalhunks; // total # of hunks represented
- [ 32] UINT32 cylinders; // number of cylinders on hard disk
- [ 36] UINT32 heads; // number of heads on hard disk
- [ 40] UINT32 sectors; // number of sectors on hard disk
- [ 44] UINT8 md5[16]; // MD5 checksum of raw data
- [ 60] UINT8 parentmd5[16]; // MD5 checksum of parent file
+ [ 8] uint32_t length; // length of header (including tag and length fields)
+ [ 12] uint32_t version; // drive format version
+ [ 16] uint32_t flags; // flags (see below)
+ [ 20] uint32_t compression; // compression type
+ [ 24] uint32_t hunksize; // 512-byte sectors per hunk
+ [ 28] uint32_t totalhunks; // total # of hunks represented
+ [ 32] uint32_t cylinders; // number of cylinders on hard disk
+ [ 36] uint32_t heads; // number of heads on hard disk
+ [ 40] uint32_t sectors; // number of sectors on hard disk
+ [ 44] uint8_t md5[16]; // MD5 checksum of raw data
+ [ 60] uint8_t parentmd5[16]; // MD5 checksum of parent file
[ 76] (V1 header length)
Flags:
@@ -56,26 +56,26 @@
V1 map format:
- [ 0] UINT64 offset : 44; // starting offset within the file
- [ 0] UINT64 length : 20; // length of data; if == hunksize, data is uncompressed
+ [ 0] uint64_t offset : 44; // starting offset within the file
+ [ 0] uint64_t length : 20; // length of data; if == hunksize, data is uncompressed
=========================================================================
V2 header:
[ 0] char tag[8]; // 'MComprHD'
- [ 8] UINT32 length; // length of header (including tag and length fields)
- [ 12] UINT32 version; // drive format version
- [ 16] UINT32 flags; // flags (see below)
- [ 20] UINT32 compression; // compression type
- [ 24] UINT32 hunksize; // seclen-byte sectors per hunk
- [ 28] UINT32 totalhunks; // total # of hunks represented
- [ 32] UINT32 cylinders; // number of cylinders on hard disk
- [ 36] UINT32 heads; // number of heads on hard disk
- [ 40] UINT32 sectors; // number of sectors on hard disk
- [ 44] UINT8 md5[16]; // MD5 checksum of raw data
- [ 60] UINT8 parentmd5[16]; // MD5 checksum of parent file
- [ 76] UINT32 seclen; // number of bytes per sector
+ [ 8] uint32_t length; // length of header (including tag and length fields)
+ [ 12] uint32_t version; // drive format version
+ [ 16] uint32_t flags; // flags (see below)
+ [ 20] uint32_t compression; // compression type
+ [ 24] uint32_t hunksize; // seclen-byte sectors per hunk
+ [ 28] uint32_t totalhunks; // total # of hunks represented
+ [ 32] uint32_t cylinders; // number of cylinders on hard disk
+ [ 36] uint32_t heads; // number of heads on hard disk
+ [ 40] uint32_t sectors; // number of sectors on hard disk
+ [ 44] uint8_t md5[16]; // MD5 checksum of raw data
+ [ 60] uint8_t parentmd5[16]; // MD5 checksum of parent file
+ [ 76] uint32_t seclen; // number of bytes per sector
[ 80] (V2 header length)
Flags and map format are same as V1
@@ -85,18 +85,18 @@
V3 header:
[ 0] char tag[8]; // 'MComprHD'
- [ 8] UINT32 length; // length of header (including tag and length fields)
- [ 12] UINT32 version; // drive format version
- [ 16] UINT32 flags; // flags (see below)
- [ 20] UINT32 compression; // compression type
- [ 24] UINT32 totalhunks; // total # of hunks represented
- [ 28] UINT64 logicalbytes; // logical size of the data (in bytes)
- [ 36] UINT64 metaoffset; // offset to the first blob of metadata
- [ 44] UINT8 md5[16]; // MD5 checksum of raw data
- [ 60] UINT8 parentmd5[16]; // MD5 checksum of parent file
- [ 76] UINT32 hunkbytes; // number of bytes per hunk
- [ 80] UINT8 sha1[20]; // SHA1 checksum of raw data
- [100] UINT8 parentsha1[20];// SHA1 checksum of parent file
+ [ 8] uint32_t length; // length of header (including tag and length fields)
+ [ 12] uint32_t version; // drive format version
+ [ 16] uint32_t flags; // flags (see below)
+ [ 20] uint32_t compression; // compression type
+ [ 24] uint32_t totalhunks; // total # of hunks represented
+ [ 28] uint64_t logicalbytes; // logical size of the data (in bytes)
+ [ 36] uint64_t metaoffset; // offset to the first blob of metadata
+ [ 44] uint8_t md5[16]; // MD5 checksum of raw data
+ [ 60] uint8_t parentmd5[16]; // MD5 checksum of parent file
+ [ 76] uint32_t hunkbytes; // number of bytes per hunk
+ [ 80] uint8_t sha1[20]; // SHA1 checksum of raw data
+ [100] uint8_t parentsha1[20];// SHA1 checksum of parent file
[120] (V3 header length)
Flags are the same as V1
@@ -108,28 +108,28 @@
V3 map format:
- [ 0] UINT64 offset; // starting offset within the file
- [ 8] UINT32 crc32; // 32-bit CRC of the uncompressed data
- [ 12] UINT16 length_lo; // lower 16 bits of length
- [ 14] UINT8 length_hi; // upper 8 bits of length
- [ 15] UINT8 flags; // flags, indicating compression info
+ [ 0] uint64_t offset; // starting offset within the file
+ [ 8] uint32_t crc32; // 32-bit CRC of the uncompressed data
+ [ 12] uint16_t length_lo; // lower 16 bits of length
+ [ 14] uint8_t length_hi; // upper 8 bits of length
+ [ 15] uint8_t flags; // flags, indicating compression info
=========================================================================
V4 header:
[ 0] char tag[8]; // 'MComprHD'
- [ 8] UINT32 length; // length of header (including tag and length fields)
- [ 12] UINT32 version; // drive format version
- [ 16] UINT32 flags; // flags (see below)
- [ 20] UINT32 compression; // compression type
- [ 24] UINT32 totalhunks; // total # of hunks represented
- [ 28] UINT64 logicalbytes; // logical size of the data (in bytes)
- [ 36] UINT64 metaoffset; // offset to the first blob of metadata
- [ 44] UINT32 hunkbytes; // number of bytes per hunk
- [ 48] UINT8 sha1[20]; // combined raw+meta SHA1
- [ 68] UINT8 parentsha1[20];// combined raw+meta SHA1 of parent
- [ 88] UINT8 rawsha1[20]; // raw data SHA1
+ [ 8] uint32_t length; // length of header (including tag and length fields)
+ [ 12] uint32_t version; // drive format version
+ [ 16] uint32_t flags; // flags (see below)
+ [ 20] uint32_t compression; // compression type
+ [ 24] uint32_t totalhunks; // total # of hunks represented
+ [ 28] uint64_t logicalbytes; // logical size of the data (in bytes)
+ [ 36] uint64_t metaoffset; // offset to the first blob of metadata
+ [ 44] uint32_t hunkbytes; // number of bytes per hunk
+ [ 48] uint8_t sha1[20]; // combined raw+meta SHA1
+ [ 68] uint8_t parentsha1[20];// combined raw+meta SHA1 of parent
+ [ 88] uint8_t rawsha1[20]; // raw data SHA1
[108] (V4 header length)
Flags are the same as V1
@@ -147,17 +147,17 @@
V5 header:
[ 0] char tag[8]; // 'MComprHD'
- [ 8] UINT32 length; // length of header (including tag and length fields)
- [ 12] UINT32 version; // drive format version
- [ 16] UINT32 compressors[4];// which custom compressors are used?
- [ 32] UINT64 logicalbytes; // logical size of the data (in bytes)
- [ 40] UINT64 mapoffset; // offset to the map
- [ 48] UINT64 metaoffset; // offset to the first blob of metadata
- [ 56] UINT32 hunkbytes; // number of bytes per hunk (512k maximum)
- [ 60] UINT32 unitbytes; // number of bytes per unit within each hunk
- [ 64] UINT8 rawsha1[20]; // raw data SHA1
- [ 84] UINT8 sha1[20]; // combined raw+meta SHA1
- [104] UINT8 parentsha1[20];// combined raw+meta SHA1 of parent
+ [ 8] uint32_t length; // length of header (including tag and length fields)
+ [ 12] uint32_t version; // drive format version
+ [ 16] uint32_t compressors[4];// which custom compressors are used?
+ [ 32] uint64_t logicalbytes; // logical size of the data (in bytes)
+ [ 40] uint64_t mapoffset; // offset to the map
+ [ 48] uint64_t metaoffset; // offset to the first blob of metadata
+ [ 56] uint32_t hunkbytes; // number of bytes per hunk (512k maximum)
+ [ 60] uint32_t unitbytes; // number of bytes per unit within each hunk
+ [ 64] uint8_t rawsha1[20]; // raw data SHA1
+ [ 84] uint8_t sha1[20]; // combined raw+meta SHA1
+ [104] uint8_t parentsha1[20];// combined raw+meta SHA1 of parent
[124] (V5 header length)
If parentsha1 != 0, we have a parent (no need for flags)
@@ -165,25 +165,25 @@
V5 uncompressed map format:
- [ 0] UINT32 offset; // starting offset / hunk size
+ [ 0] uint32_t offset; // starting offset / hunk size
V5 compressed map format header:
- [ 0] UINT32 length; // length of compressed map
+ [ 0] uint32_t length; // length of compressed map
[ 4] UINT48 datastart; // offset of first block
- [ 10] UINT16 crc; // crc-16 of the map
- [ 12] UINT8 lengthbits; // bits used to encode complength
- [ 13] UINT8 hunkbits; // bits used to encode self-refs
- [ 14] UINT8 parentunitbits; // bits used to encode parent unit refs
- [ 15] UINT8 reserved; // future use
+ [ 10] uint16_t crc; // crc-16 of the map
+ [ 12] uint8_t lengthbits; // bits used to encode complength
+ [ 13] uint8_t hunkbits; // bits used to encode self-refs
+ [ 14] uint8_t parentunitbits; // bits used to encode parent unit refs
+ [ 15] uint8_t reserved; // future use
[ 16] (compressed header length)
Each compressed map entry, once expanded, looks like:
- [ 0] UINT8 compression; // compression type
+ [ 0] uint8_t compression; // compression type
[ 1] UINT24 complength; // compressed length
[ 4] UINT48 offset; // offset
- [ 10] UINT16 crc; // crc-16 of the data
+ [ 10] uint16_t crc; // crc-16 of the data
***************************************************************************/
@@ -198,14 +198,14 @@ const chd_codec_type CHD_CODEC_PARENT = 2; // copy of a parent's hunk
const chd_codec_type CHD_CODEC_MINI = 3; // legacy "mini" 8-byte repeat
// core types
-typedef UINT32 chd_metadata_tag;
+typedef uint32_t chd_metadata_tag;
// metadata parameters
const chd_metadata_tag CHDMETATAG_WILDCARD = 0;
-const UINT32 CHDMETAINDEX_APPEND = ~0;
+const uint32_t CHDMETAINDEX_APPEND = ~0;
// metadata flags
-const UINT8 CHD_MDFLAGS_CHECKSUM = 0x01; // indicates data is checksummed
+const uint8_t CHD_MDFLAGS_CHECKSUM = 0x01; // indicates data is checksummed
// standard hard disk metadata
const chd_metadata_tag HARD_DISK_METADATA_TAG = CHD_MAKE_TAG('G','D','D','D');
@@ -292,11 +292,11 @@ class chd_file
friend class chd_verifier;
// constants
- static const UINT32 HEADER_VERSION = 5;
- static const UINT32 V3_HEADER_SIZE = 120;
- static const UINT32 V4_HEADER_SIZE = 108;
- static const UINT32 V5_HEADER_SIZE = 124;
- static const UINT32 MAX_HEADER_SIZE = V5_HEADER_SIZE;
+ static const uint32_t HEADER_VERSION = 5;
+ static const uint32_t V3_HEADER_SIZE = 120;
+ static const uint32_t V4_HEADER_SIZE = 108;
+ static const uint32_t V5_HEADER_SIZE = 124;
+ static const uint32_t MAX_HEADER_SIZE = V5_HEADER_SIZE;
public:
// construction/destruction
@@ -308,29 +308,29 @@ public:
// getters
bool opened() const { return (m_file != nullptr); }
- UINT32 version() const { return m_version; }
- UINT64 logical_bytes() const { return m_logicalbytes; }
- UINT32 hunk_bytes() const { return m_hunkbytes; }
- UINT32 hunk_count() const { return m_hunkcount; }
- UINT32 unit_bytes() const { return m_unitbytes; }
- UINT64 unit_count() const { return m_unitcount; }
+ uint32_t version() const { return m_version; }
+ uint64_t logical_bytes() const { return m_logicalbytes; }
+ uint32_t hunk_bytes() const { return m_hunkbytes; }
+ uint32_t hunk_count() const { return m_hunkcount; }
+ uint32_t unit_bytes() const { return m_unitbytes; }
+ uint64_t unit_count() const { return m_unitcount; }
bool compressed() const { return (m_compression[0] != CHD_CODEC_NONE); }
chd_codec_type compression(int index) const { return m_compression[index]; }
chd_file *parent() const { return m_parent; }
util::sha1_t sha1();
util::sha1_t raw_sha1();
util::sha1_t parent_sha1();
- chd_error hunk_info(UINT32 hunknum, chd_codec_type &compressor, UINT32 &compbytes);
+ chd_error hunk_info(uint32_t hunknum, chd_codec_type &compressor, uint32_t &compbytes);
// setters
void set_raw_sha1(util::sha1_t rawdata);
void set_parent_sha1(util::sha1_t parent);
// file create
- chd_error create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 unitbytes, chd_codec_type compression[4]);
- chd_error create(util::core_file &file, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 unitbytes, chd_codec_type compression[4]);
- chd_error create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, chd_codec_type compression[4], chd_file &parent);
- chd_error create(util::core_file &file, UINT64 logicalbytes, UINT32 hunkbytes, chd_codec_type compression[4], chd_file &parent);
+ chd_error create(const char *filename, uint64_t logicalbytes, uint32_t hunkbytes, uint32_t unitbytes, chd_codec_type compression[4]);
+ chd_error create(util::core_file &file, uint64_t logicalbytes, uint32_t hunkbytes, uint32_t unitbytes, chd_codec_type compression[4]);
+ chd_error create(const char *filename, uint64_t logicalbytes, uint32_t hunkbytes, chd_codec_type compression[4], chd_file &parent);
+ chd_error create(util::core_file &file, uint64_t logicalbytes, uint32_t hunkbytes, chd_codec_type compression[4], chd_file &parent);
// file open
chd_error open(const char *filename, bool writeable = false, chd_file *parent = nullptr);
@@ -340,22 +340,22 @@ public:
void close();
// read/write
- chd_error read_hunk(UINT32 hunknum, void *buffer);
- chd_error write_hunk(UINT32 hunknum, const void *buffer);
- chd_error read_units(UINT64 unitnum, void *buffer, UINT32 count = 1);
- chd_error write_units(UINT64 unitnum, const void *buffer, UINT32 count = 1);
- chd_error read_bytes(UINT64 offset, void *buffer, UINT32 bytes);
- chd_error write_bytes(UINT64 offset, const void *buffer, UINT32 bytes);
+ chd_error read_hunk(uint32_t hunknum, void *buffer);
+ chd_error write_hunk(uint32_t hunknum, const void *buffer);
+ chd_error read_units(uint64_t unitnum, void *buffer, uint32_t count = 1);
+ chd_error write_units(uint64_t unitnum, const void *buffer, uint32_t count = 1);
+ chd_error read_bytes(uint64_t offset, void *buffer, uint32_t bytes);
+ chd_error write_bytes(uint64_t offset, const void *buffer, uint32_t bytes);
// metadata management
- chd_error read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, std::string &output);
- chd_error read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, std::vector<UINT8> &output);
- chd_error read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, void *output, UINT32 outputlen, UINT32 &resultlen);
- chd_error read_metadata(chd_metadata_tag searchtag, UINT32 searchindex, std::vector<UINT8> &output, chd_metadata_tag &resulttag, UINT8 &resultflags);
- chd_error write_metadata(chd_metadata_tag metatag, UINT32 metaindex, const void *inputbuf, UINT32 inputlen, UINT8 flags = CHD_MDFLAGS_CHECKSUM);
- chd_error write_metadata(chd_metadata_tag metatag, UINT32 metaindex, const std::string &input, UINT8 flags = CHD_MDFLAGS_CHECKSUM) { return write_metadata(metatag, metaindex, input.c_str(), input.length() + 1, flags); }
- chd_error write_metadata(chd_metadata_tag metatag, UINT32 metaindex, const std::vector<UINT8> &input, UINT8 flags = CHD_MDFLAGS_CHECKSUM) { return write_metadata(metatag, metaindex, &input[0], input.size(), flags); }
- chd_error delete_metadata(chd_metadata_tag metatag, UINT32 metaindex);
+ chd_error read_metadata(chd_metadata_tag searchtag, uint32_t searchindex, std::string &output);
+ chd_error read_metadata(chd_metadata_tag searchtag, uint32_t searchindex, std::vector<uint8_t> &output);
+ chd_error read_metadata(chd_metadata_tag searchtag, uint32_t searchindex, void *output, uint32_t outputlen, uint32_t &resultlen);
+ chd_error read_metadata(chd_metadata_tag searchtag, uint32_t searchindex, std::vector<uint8_t> &output, chd_metadata_tag &resulttag, uint8_t &resultflags);
+ chd_error write_metadata(chd_metadata_tag metatag, uint32_t metaindex, const void *inputbuf, uint32_t inputlen, uint8_t flags = CHD_MDFLAGS_CHECKSUM);
+ chd_error write_metadata(chd_metadata_tag metatag, uint32_t metaindex, const std::string &input, uint8_t flags = CHD_MDFLAGS_CHECKSUM) { return write_metadata(metatag, metaindex, input.c_str(), input.length() + 1, flags); }
+ chd_error write_metadata(chd_metadata_tag metatag, uint32_t metaindex, const std::vector<uint8_t> &input, uint8_t flags = CHD_MDFLAGS_CHECKSUM) { return write_metadata(metatag, metaindex, &input[0], input.size(), flags); }
+ chd_error delete_metadata(chd_metadata_tag metatag, uint32_t metaindex);
chd_error clone_all_metadata(chd_file &source);
// hashing helper
@@ -372,31 +372,31 @@ private:
struct metadata_hash;
// inline helpers
- UINT64 be_read(const UINT8 *base, int numbytes);
- void be_write(UINT8 *base, UINT64 value, int numbytes);
- util::sha1_t be_read_sha1(const UINT8 *base);
- void be_write_sha1(UINT8 *base, util::sha1_t value);
- void file_read(UINT64 offset, void *dest, UINT32 length);
- void file_write(UINT64 offset, const void *source, UINT32 length);
- UINT64 file_append(const void *source, UINT32 length, UINT32 alignment = 0);
- UINT8 bits_for_value(UINT64 value);
+ uint64_t be_read(const uint8_t *base, int numbytes);
+ void be_write(uint8_t *base, uint64_t value, int numbytes);
+ util::sha1_t be_read_sha1(const uint8_t *base);
+ void be_write_sha1(uint8_t *base, util::sha1_t value);
+ void file_read(uint64_t offset, void *dest, uint32_t length);
+ void file_write(uint64_t offset, const void *source, uint32_t length);
+ uint64_t file_append(const void *source, uint32_t length, uint32_t alignment = 0);
+ uint8_t bits_for_value(uint64_t value);
// internal helpers
- UINT32 guess_unitbytes();
- void parse_v3_header(UINT8 *rawheader, util::sha1_t &parentsha1);
- void parse_v4_header(UINT8 *rawheader, util::sha1_t &parentsha1);
- void parse_v5_header(UINT8 *rawheader, util::sha1_t &parentsha1);
+ uint32_t guess_unitbytes();
+ void parse_v3_header(uint8_t *rawheader, util::sha1_t &parentsha1);
+ void parse_v4_header(uint8_t *rawheader, util::sha1_t &parentsha1);
+ void parse_v5_header(uint8_t *rawheader, util::sha1_t &parentsha1);
chd_error compress_v5_map();
void decompress_v5_map();
chd_error create_common();
chd_error open_common(bool writeable);
void create_open_common();
- void verify_proper_compression_append(UINT32 hunknum);
- void hunk_write_compressed(UINT32 hunknum, INT8 compression, const UINT8 *compressed, UINT32 complength, util::crc16_t crc16);
- void hunk_copy_from_self(UINT32 hunknum, UINT32 otherhunk);
- void hunk_copy_from_parent(UINT32 hunknum, UINT64 parentunit);
- bool metadata_find(chd_metadata_tag metatag, INT32 metaindex, metadata_entry &metaentry, bool resume = false);
- void metadata_set_previous_next(UINT64 prevoffset, UINT64 nextoffset);
+ void verify_proper_compression_append(uint32_t hunknum);
+ void hunk_write_compressed(uint32_t hunknum, int8_t compression, const uint8_t *compressed, uint32_t complength, util::crc16_t crc16);
+ void hunk_copy_from_self(uint32_t hunknum, uint32_t otherhunk);
+ void hunk_copy_from_parent(uint32_t hunknum, uint64_t parentunit);
+ bool metadata_find(chd_metadata_tag metatag, int32_t metaindex, metadata_entry &metaentry, bool resume = false);
+ void metadata_set_previous_next(uint64_t prevoffset, uint64_t nextoffset);
void metadata_update_hash();
static int CLIB_DECL metadata_hash_compare(const void *elem1, const void *elem2);
@@ -407,36 +407,36 @@ private:
bool m_allow_writes; // permit writes to this CHD?
// core parameters from the header
- UINT32 m_version; // version of the header
- UINT64 m_logicalbytes; // logical size of the raw CHD data in bytes
- UINT64 m_mapoffset; // offset of map
- UINT64 m_metaoffset; // offset to first metadata bit
- UINT32 m_hunkbytes; // size of each raw hunk in bytes
- UINT32 m_hunkcount; // number of hunks represented
- UINT32 m_unitbytes; // size of each unit in bytes
- UINT64 m_unitcount; // number of units represented
+ uint32_t m_version; // version of the header
+ uint64_t m_logicalbytes; // logical size of the raw CHD data in bytes
+ uint64_t m_mapoffset; // offset of map
+ uint64_t m_metaoffset; // offset to first metadata bit
+ uint32_t m_hunkbytes; // size of each raw hunk in bytes
+ uint32_t m_hunkcount; // number of hunks represented
+ uint32_t m_unitbytes; // size of each unit in bytes
+ uint64_t m_unitcount; // number of units represented
chd_codec_type m_compression[4]; // array of compression types used
chd_file * m_parent; // pointer to parent file, or nullptr if none
bool m_parent_missing; // are we missing our parent?
// key offsets within the header
- UINT64 m_mapoffset_offset; // offset of map offset field
- UINT64 m_metaoffset_offset;// offset of metaoffset field
- UINT64 m_sha1_offset; // offset of SHA1 field
- UINT64 m_rawsha1_offset; // offset of raw SHA1 field
- UINT64 m_parentsha1_offset;// offset of paren SHA1 field
+ uint64_t m_mapoffset_offset; // offset of map offset field
+ uint64_t m_metaoffset_offset;// offset of metaoffset field
+ uint64_t m_sha1_offset; // offset of SHA1 field
+ uint64_t m_rawsha1_offset; // offset of raw SHA1 field
+ uint64_t m_parentsha1_offset;// offset of paren SHA1 field
// map information
- UINT32 m_mapentrybytes; // length of each entry in a map
- std::vector<UINT8> m_rawmap; // raw map data
+ uint32_t m_mapentrybytes; // length of each entry in a map
+ std::vector<uint8_t> m_rawmap; // raw map data
// compression management
chd_decompressor * m_decompressor[4]; // array of decompression codecs
- std::vector<UINT8> m_compressed; // temporary buffer for compressed data
+ std::vector<uint8_t> m_compressed; // temporary buffer for compressed data
// caching
- std::vector<UINT8> m_cache; // single-hunk cache for partial reads/writes
- UINT32 m_cachehunk; // which hunk is in the cache?
+ std::vector<uint8_t> m_cache; // single-hunk cache for partial reads/writes
+ uint32_t m_cachehunk; // which hunk is in the cache?
};
@@ -456,7 +456,7 @@ public:
protected:
// required override: read more data
- virtual UINT32 read_data(void *dest, UINT64 offset, UINT32 length) = 0;
+ virtual uint32_t read_data(void *dest, uint64_t offset, uint32_t length) = 0;
private:
// hash map for looking up values
@@ -469,17 +469,17 @@ private:
// operations
void reset();
- UINT64 find(util::crc16_t crc16, util::sha1_t sha1);
- void add(UINT64 itemnum, util::crc16_t crc16, util::sha1_t sha1);
+ uint64_t find(util::crc16_t crc16, util::sha1_t sha1);
+ void add(uint64_t itemnum, util::crc16_t crc16, util::sha1_t sha1);
// constants
- static const UINT64 NOT_FOUND = ~UINT64(0);
+ static const uint64_t NOT_FOUND = ~uint64_t(0);
private:
// internal entry
struct entry_t
{
entry_t * m_next; // next entry in list
- UINT64 m_itemnum; // item number
+ uint64_t m_itemnum; // item number
util::sha1_t m_sha1; // SHA-1 of the block
};
@@ -490,7 +490,7 @@ private:
: m_next(prev), m_nextalloc(0) { }
entry_block * m_next; // next block in list
- UINT32 m_nextalloc; // next to be allocated
+ uint32_t m_nextalloc; // next to be allocated
entry_t m_array[16384]; // array of entries
};
@@ -534,12 +534,12 @@ private:
chd_file_compressor *m_compressor; // pointer back to the compressor
// TODO: had to change this to be able to use atomic_* functions on this
//volatile work_status m_status; // current status of this item
- std::atomic<INT32> m_status; // current status of this item
- UINT32 m_hunknum; // number of the hunk we're working on
- UINT8 * m_data; // pointer to the data we are working on
- UINT8 * m_compressed; // pointer to the compressed data
- UINT32 m_complen; // compressed data length
- INT8 m_compression; // type of compression used
+ std::atomic<int32_t> m_status; // current status of this item
+ uint32_t m_hunknum; // number of the hunk we're working on
+ uint8_t * m_data; // pointer to the data we are working on
+ uint8_t * m_compressed; // pointer to the compressed data
+ uint32_t m_complen; // compressed data length
+ int8_t m_compression; // type of compression used
chd_compressor_group *m_codecs; // codec instance
std::vector<hash_pair> m_hash; // array of hashes
};
@@ -554,8 +554,8 @@ private:
// current compression status
bool m_walking_parent; // are we building the parent map?
- UINT64 m_total_in; // total bytes in
- UINT64 m_total_out; // total bytes out
+ uint64_t m_total_in; // total bytes in
+ uint64_t m_total_out; // total bytes out
util::sha1_creator m_compsha1; // running SHA-1 on raw data
// hash lookup maps
@@ -564,20 +564,20 @@ private:
// read I/O thread
osd_work_queue * m_read_queue; // work queue for reading
- UINT64 m_read_queue_offset;// next offset to enqueue
- UINT64 m_read_done_offset; // next offset that will complete
+ uint64_t m_read_queue_offset;// next offset to enqueue
+ uint64_t m_read_done_offset; // next offset that will complete
bool m_read_error; // error during reading?
// work item thread
static const int WORK_BUFFER_HUNKS = 256;
osd_work_queue * m_work_queue; // queue for doing work on other threads
- std::vector<UINT8> m_work_buffer; // buffer containing hunk data to work on
- std::vector<UINT8> m_compressed_buffer;// buffer containing compressed data
+ std::vector<uint8_t> m_work_buffer; // buffer containing hunk data to work on
+ std::vector<uint8_t> m_compressed_buffer;// buffer containing compressed data
work_item m_work_item[WORK_BUFFER_HUNKS]; // status of each hunk
chd_compressor_group * m_codecs[WORK_MAX_THREADS]; // codecs to use
// output state
- UINT32 m_write_hunk; // next hunk to write
+ uint32_t m_write_hunk; // next hunk to write
};
diff --git a/src/lib/util/chdcd.cpp b/src/lib/util/chdcd.cpp
index 76da08b6b9e..f6176cd4cd9 100644
--- a/src/lib/util/chdcd.cpp
+++ b/src/lib/util/chdcd.cpp
@@ -76,7 +76,7 @@ static std::string get_file_path(std::string &path)
-------------------------------------------------*/
/**
- * @fn static UINT64 get_file_size(const char *filename)
+ * @fn static uint64_t get_file_size(const char *filename)
*
* @brief Gets file size.
*
@@ -85,7 +85,7 @@ static std::string get_file_path(std::string &path)
* @return The file size.
*/
-static UINT64 get_file_size(const char *filename)
+static uint64_t get_file_size(const char *filename)
{
osd_file::ptr file;
std::uint64_t filesize = 0;
@@ -120,7 +120,7 @@ static int tokenize( const char *linebuffer, int i, int linebuffersize, char *to
int singlequote = 0;
int doublequote = 0;
- while ((i < linebuffersize) && isspace((UINT8)linebuffer[i]))
+ while ((i < linebuffersize) && isspace((uint8_t)linebuffer[i]))
{
i++;
}
@@ -135,7 +135,7 @@ static int tokenize( const char *linebuffer, int i, int linebuffersize, char *to
{
singlequote = !singlequote;
}
- else if (!singlequote && !doublequote && isspace((UINT8)linebuffer[i]))
+ else if (!singlequote && !doublequote && isspace((uint8_t)linebuffer[i]))
{
break;
}
@@ -196,24 +196,24 @@ static int msf_to_frames( char *token )
-------------------------------------------------*/
/**
- * @fn static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs)
+ * @fn static uint32_t parse_wav_sample(const char *filename, uint32_t *dataoffs)
*
* @brief Parse WAV sample.
*
* @param filename Filename of the file.
* @param [in,out] dataoffs If non-null, the dataoffs.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs)
+static uint32_t parse_wav_sample(const char *filename, uint32_t *dataoffs)
{
unsigned long offset = 0;
- UINT32 length, rate, filesize;
- UINT16 bits, temp16;
+ uint32_t length, rate, filesize;
+ uint16_t bits, temp16;
char buf[32];
osd_file::ptr file;
- UINT64 fsize = 0;
+ uint64_t fsize = 0;
std::uint32_t actual;
osd_file::error filerr = osd_file::open(filename, OPEN_FLAG_READ, file, fsize);
@@ -361,7 +361,7 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs)
}
/**
- * @fn UINT16 read_uint16(FILE *infile)
+ * @fn uint16_t read_uint16(FILE *infile)
*
* @brief Reads uint 16.
*
@@ -370,9 +370,9 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs)
* @return The uint 16.
*/
-UINT16 read_uint16(FILE *infile)
+uint16_t read_uint16(FILE *infile)
{
- UINT16 res = 0;
+ uint16_t res = 0;
unsigned char buffer[2];
fread(buffer, 2, 1, infile);
@@ -383,7 +383,7 @@ UINT16 read_uint16(FILE *infile)
}
/**
- * @fn UINT32 read_uint32(FILE *infile)
+ * @fn uint32_t read_uint32(FILE *infile)
*
* @brief Reads uint 32.
*
@@ -392,9 +392,9 @@ UINT16 read_uint16(FILE *infile)
* @return The uint 32.
*/
-UINT32 read_uint32(FILE *infile)
+uint32_t read_uint32(FILE *infile)
{
- UINT32 res = 0;
+ uint32_t res = 0;
unsigned char buffer[4];
fread(buffer, 4, 1, infile);
@@ -405,7 +405,7 @@ UINT32 read_uint32(FILE *infile)
}
/**
- * @fn UINT64 read_uint64(FILE *infile)
+ * @fn uint64_t read_uint64(FILE *infile)
*
* @brief Reads uint 64.
*
@@ -414,10 +414,10 @@ UINT32 read_uint32(FILE *infile)
* @return The uint 64.
*/
-UINT64 read_uint64(FILE *infile)
+uint64_t read_uint64(FILE *infile)
{
- UINT64 res0 = U64(0), res1 = U64(0);
- UINT64 res;
+ uint64_t res0 = U64(0), res1 = U64(0);
+ uint64_t res;
unsigned char buffer[8];
fread(buffer, 8, 1, infile);
@@ -450,7 +450,7 @@ chd_error chdcd_parse_nero(const char *tocfname, cdrom_toc &outtoc, chdcd_track_
{
FILE *infile;
unsigned char buffer[12];
- UINT32 chain_offs, chunk_size;
+ uint32_t chain_offs, chunk_size;
int done = 0;
std::string path = std::string(tocfname);
@@ -491,8 +491,8 @@ chd_error chdcd_parse_nero(const char *tocfname, cdrom_toc &outtoc, chdcd_track_
while (!done)
{
- UINT32 offset;
- UINT8 start, end;
+ uint32_t offset;
+ uint8_t start, end;
int track;
fseek(infile, chain_offs, SEEK_SET);
@@ -518,8 +518,8 @@ chd_error chdcd_parse_nero(const char *tocfname, cdrom_toc &outtoc, chdcd_track_
offset = 0;
for (track = start; track <= end; track++)
{
- UINT32 size, mode;
- UINT64 index0, index1, track_end;
+ uint32_t size, mode;
+ uint64_t index0, index1, track_end;
fseek(infile, 12, SEEK_CUR); // skip ISRC code
size = read_uint16(infile);
@@ -529,9 +529,9 @@ chd_error chdcd_parse_nero(const char *tocfname, cdrom_toc &outtoc, chdcd_track_
index1 = read_uint64(infile);
track_end = read_uint64(infile);
-// printf("Track %d: sector size %d mode %x index0 %llx index1 %llx track_end %llx (pregap %d sectors, length %d sectors)\n", track, size, mode, index0, index1, track_end, (UINT32)(index1-index0)/size, (UINT32)(track_end-index1)/size);
+// printf("Track %d: sector size %d mode %x index0 %llx index1 %llx track_end %llx (pregap %d sectors, length %d sectors)\n", track, size, mode, index0, index1, track_end, (uint32_t)(index1-index0)/size, (uint32_t)(track_end-index1)/size);
outinfo.track[track-1].fname.assign(tocfname);
- outinfo.track[track-1].offset = offset + (UINT32)(index1-index0);
+ outinfo.track[track-1].offset = offset + (uint32_t)(index1-index0);
outinfo.track[track-1].idx0offs = 0;
outinfo.track[track-1].idx1offs = 0;
@@ -588,8 +588,8 @@ chd_error chdcd_parse_nero(const char *tocfname, cdrom_toc &outtoc, chdcd_track_
outtoc.tracks[track-1].subtype = CD_SUB_NONE;
outtoc.tracks[track-1].subsize = 0;
- outtoc.tracks[track-1].pregap = (UINT32)(index1-index0)/size;
- outtoc.tracks[track-1].frames = (UINT32)(track_end-index1)/size;
+ outtoc.tracks[track-1].pregap = (uint32_t)(index1-index0)/size;
+ outtoc.tracks[track-1].frames = (uint32_t)(track_end-index1)/size;
outtoc.tracks[track-1].postgap = 0;
outtoc.tracks[track-1].pgtype = 0;
outtoc.tracks[track-1].pgsub = CD_SUB_NONE;
@@ -597,7 +597,7 @@ chd_error chdcd_parse_nero(const char *tocfname, cdrom_toc &outtoc, chdcd_track_
outtoc.tracks[track-1].pgsubsize = 0;
outtoc.tracks[track-1].padframes = 0;
- offset += (UINT32)track_end-index1;
+ offset += (uint32_t)track_end-index1;
}
}
@@ -649,7 +649,7 @@ chd_error chdcd_parse_iso(const char *tocfname, cdrom_toc &outtoc, chdcd_track_i
memset(&outtoc, 0, sizeof(outtoc));
outinfo.reset();
- UINT64 size = get_file_size(tocfname);
+ uint64_t size = get_file_size(tocfname);
fclose(infile);
@@ -846,7 +846,7 @@ chd_error chdcd_parse_cue(const char *tocfname, cdrom_toc &outtoc, chdcd_track_i
int i, trknum;
static char token[512];
std::string lastfname;
- UINT32 wavlen, wavoffs;
+ uint32_t wavlen, wavoffs;
std::string path = std::string(tocfname);
infile = fopen(tocfname, "rt");
@@ -1039,7 +1039,7 @@ chd_error chdcd_parse_cue(const char *tocfname, cdrom_toc &outtoc, chdcd_track_i
/* now go over the files again and set the lengths */
for (trknum = 0; trknum < outtoc.numtrks; trknum++)
{
- UINT64 tlen = 0;
+ uint64_t tlen = 0;
// this is true for cue/bin and cue/iso, and we need it for cue/wav since .WAV is little-endian
if (outtoc.tracks[trknum].trktype == CD_TRACK_AUDIO)
@@ -1226,7 +1226,7 @@ chd_error chdcd_parse_toc(const char *tocfname, cdrom_toc &outtoc, chdcd_track_i
/* it's a decimal offset, use it */
f = strtoul(&token[1], nullptr, 10);
}
- else if (isdigit((UINT8)token[0]))
+ else if (isdigit((uint8_t)token[0]))
{
/* convert the time to an offset */
f = msf_to_frames( token );
@@ -1242,14 +1242,14 @@ chd_error chdcd_parse_toc(const char *tocfname, cdrom_toc &outtoc, chdcd_track_i
TOKENIZE
- if (isdigit((UINT8)token[0]))
+ if (isdigit((uint8_t)token[0]))
{
// this could be the length or an offset from the previous field.
f = msf_to_frames( token );
TOKENIZE
- if (isdigit((UINT8)token[0]))
+ if (isdigit((uint8_t)token[0]))
{
// it was an offset.
f *= (outtoc.tracks[trknum].datasize + outtoc.tracks[trknum].subsize);
diff --git a/src/lib/util/chdcd.h b/src/lib/util/chdcd.h
index 6adcf29ce7b..3f31bad7e00 100644
--- a/src/lib/util/chdcd.h
+++ b/src/lib/util/chdcd.h
@@ -19,10 +19,10 @@ struct chdcd_track_input_entry
void reset() { fname.clear(); offset = idx0offs = idx1offs = 0; swap = false; }
std::string fname; // filename for each track
- UINT32 offset; // offset in the data file for each track
+ uint32_t offset; // offset in the data file for each track
bool swap; // data needs to be byte swapped
- UINT32 idx0offs;
- UINT32 idx1offs;
+ uint32_t idx0offs;
+ uint32_t idx1offs;
};
struct chdcd_track_input_info
diff --git a/src/lib/util/chdcodec.cpp b/src/lib/util/chdcodec.cpp
index e2758f08a9e..71763163a87 100644
--- a/src/lib/util/chdcodec.cpp
+++ b/src/lib/util/chdcodec.cpp
@@ -25,7 +25,7 @@
// GLOBAL VARIABLES
//**************************************************************************
-static const UINT8 s_cd_sync_header[12] = { 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00 };
+static const uint8_t s_cd_sync_header[12] = { 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00 };
@@ -52,7 +52,7 @@ private:
static void fast_free(voidpf opaque, voidpf address);
static const int MAX_ZLIB_ALLOCS = 64;
- UINT32 * m_allocptr[MAX_ZLIB_ALLOCS];
+ uint32_t * m_allocptr[MAX_ZLIB_ALLOCS];
};
@@ -63,11 +63,11 @@ class chd_zlib_compressor : public chd_compressor
{
public:
// construction/destruction
- chd_zlib_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy);
+ chd_zlib_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy);
~chd_zlib_compressor();
// core functionality
- virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override;
+ virtual uint32_t compress(const uint8_t *src, uint32_t srclen, uint8_t *dest) override;
private:
// internal state
@@ -83,11 +83,11 @@ class chd_zlib_decompressor : public chd_decompressor
{
public:
// construction/destruction
- chd_zlib_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy);
+ chd_zlib_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy);
~chd_zlib_decompressor();
// core functionality
- virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override;
+ virtual void decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen) override;
private:
// internal state
@@ -112,7 +112,7 @@ private:
static void fast_free(void *p, void *address);
static const int MAX_LZMA_ALLOCS = 64;
- UINT32 * m_allocptr[MAX_LZMA_ALLOCS];
+ uint32_t * m_allocptr[MAX_LZMA_ALLOCS];
};
@@ -123,14 +123,14 @@ class chd_lzma_compressor : public chd_compressor
{
public:
// construction/destruction
- chd_lzma_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy);
+ chd_lzma_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy);
~chd_lzma_compressor();
// core functionality
- virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override;
+ virtual uint32_t compress(const uint8_t *src, uint32_t srclen, uint8_t *dest) override;
// helpers
- static void configure_properties(CLzmaEncProps &props, UINT32 hunkbytes);
+ static void configure_properties(CLzmaEncProps &props, uint32_t hunkbytes);
private:
// internal state
@@ -146,11 +146,11 @@ class chd_lzma_decompressor : public chd_decompressor
{
public:
// construction/destruction
- chd_lzma_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy);
+ chd_lzma_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy);
~chd_lzma_decompressor();
// core functionality
- virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override;
+ virtual void decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen) override;
private:
// internal state
@@ -166,10 +166,10 @@ class chd_huffman_compressor : public chd_compressor
{
public:
// construction/destruction
- chd_huffman_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy);
+ chd_huffman_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy);
// core functionality
- virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override;
+ virtual uint32_t compress(const uint8_t *src, uint32_t srclen, uint8_t *dest) override;
private:
// internal state
@@ -184,10 +184,10 @@ class chd_huffman_decompressor : public chd_decompressor
{
public:
// construction/destruction
- chd_huffman_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy);
+ chd_huffman_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy);
// core functionality
- virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override;
+ virtual void decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen) override;
private:
// internal state
@@ -202,13 +202,13 @@ class chd_flac_compressor : public chd_compressor
{
public:
// construction/destruction
- chd_flac_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy);
+ chd_flac_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy);
// core functionality
- virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override;
+ virtual uint32_t compress(const uint8_t *src, uint32_t srclen, uint8_t *dest) override;
// static helpers
- static UINT32 blocksize(UINT32 bytes);
+ static uint32_t blocksize(uint32_t bytes);
private:
// internal state
@@ -224,10 +224,10 @@ class chd_flac_decompressor : public chd_decompressor
{
public:
// construction/destruction
- chd_flac_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy);
+ chd_flac_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy);
// core functionality
- virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override;
+ virtual void decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen) override;
private:
// internal state
@@ -243,14 +243,14 @@ class chd_cd_flac_compressor : public chd_compressor
{
public:
// construction/destruction
- chd_cd_flac_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy);
+ chd_cd_flac_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy);
~chd_cd_flac_compressor();
// core functionality
- virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override;
+ virtual uint32_t compress(const uint8_t *src, uint32_t srclen, uint8_t *dest) override;
// static helpers
- static UINT32 blocksize(UINT32 bytes);
+ static uint32_t blocksize(uint32_t bytes);
private:
// internal state
@@ -258,7 +258,7 @@ private:
flac_encoder m_encoder;
z_stream m_deflater;
chd_zlib_allocator m_allocator;
- std::vector<UINT8> m_buffer;
+ std::vector<uint8_t> m_buffer;
};
@@ -269,11 +269,11 @@ class chd_cd_flac_decompressor : public chd_decompressor
{
public:
// construction/destruction
- chd_cd_flac_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy);
+ chd_cd_flac_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy);
~chd_cd_flac_decompressor();
// core functionality
- virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override;
+ virtual void decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen) override;
private:
// internal state
@@ -281,7 +281,7 @@ private:
flac_decoder m_decoder;
z_stream m_inflater;
chd_zlib_allocator m_allocator;
- std::vector<UINT8> m_buffer;
+ std::vector<uint8_t> m_buffer;
};
@@ -292,7 +292,7 @@ class chd_cd_compressor : public chd_compressor
{
public:
// construction/destruction
- chd_cd_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+ chd_cd_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_compressor(chd, hunkbytes, lossy),
m_base_compressor(chd, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA, lossy),
m_subcode_compressor(chd, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SUBCODE_DATA, lossy),
@@ -304,25 +304,25 @@ public:
}
// core functionality
- virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override
+ virtual uint32_t compress(const uint8_t *src, uint32_t srclen, uint8_t *dest) override
{
// determine header bytes
- UINT32 frames = srclen / CD_FRAME_SIZE;
- UINT32 complen_bytes = (srclen < 65536) ? 2 : 3;
- UINT32 ecc_bytes = (frames + 7) / 8;
- UINT32 header_bytes = ecc_bytes + complen_bytes;
+ uint32_t frames = srclen / CD_FRAME_SIZE;
+ uint32_t complen_bytes = (srclen < 65536) ? 2 : 3;
+ uint32_t ecc_bytes = (frames + 7) / 8;
+ uint32_t header_bytes = ecc_bytes + complen_bytes;
// clear out destination header
memset(dest, 0, header_bytes);
// copy audio data followed by subcode data
- for (UINT32 framenum = 0; framenum < frames; framenum++)
+ for (uint32_t framenum = 0; framenum < frames; framenum++)
{
memcpy(&m_buffer[framenum * CD_MAX_SECTOR_DATA], &src[framenum * CD_FRAME_SIZE], CD_MAX_SECTOR_DATA);
memcpy(&m_buffer[frames * CD_MAX_SECTOR_DATA + framenum * CD_MAX_SUBCODE_DATA], &src[framenum * CD_FRAME_SIZE + CD_MAX_SECTOR_DATA], CD_MAX_SUBCODE_DATA);
// clear out ECC data if we can
- UINT8 *sector = &m_buffer[framenum * CD_MAX_SECTOR_DATA];
+ uint8_t *sector = &m_buffer[framenum * CD_MAX_SECTOR_DATA];
if (memcmp(sector, s_cd_sync_header, sizeof(s_cd_sync_header)) == 0 && ecc_verify(sector))
{
dest[framenum / 8] |= 1 << (framenum % 8);
@@ -332,7 +332,7 @@ public:
}
// encode the base portion
- UINT32 complen = m_base_compressor.compress(&m_buffer[0], frames * CD_MAX_SECTOR_DATA, &dest[header_bytes]);
+ uint32_t complen = m_base_compressor.compress(&m_buffer[0], frames * CD_MAX_SECTOR_DATA, &dest[header_bytes]);
if (complen >= srclen)
throw CHDERR_COMPRESSION_ERROR;
@@ -350,7 +350,7 @@ private:
// internal state
_BaseCompressor m_base_compressor;
_SubcodeCompressor m_subcode_compressor;
- std::vector<UINT8> m_buffer;
+ std::vector<uint8_t> m_buffer;
};
@@ -361,7 +361,7 @@ class chd_cd_decompressor : public chd_decompressor
{
public:
// construction/destruction
- chd_cd_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+ chd_cd_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_decompressor(chd, hunkbytes, lossy),
m_base_decompressor(chd, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA, lossy),
m_subcode_decompressor(chd, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SUBCODE_DATA, lossy),
@@ -373,16 +373,16 @@ public:
}
// core functionality
- virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override
+ virtual void decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen) override
{
// determine header bytes
- UINT32 frames = destlen / CD_FRAME_SIZE;
- UINT32 complen_bytes = (destlen < 65536) ? 2 : 3;
- UINT32 ecc_bytes = (frames + 7) / 8;
- UINT32 header_bytes = ecc_bytes + complen_bytes;
+ uint32_t frames = destlen / CD_FRAME_SIZE;
+ uint32_t complen_bytes = (destlen < 65536) ? 2 : 3;
+ uint32_t ecc_bytes = (frames + 7) / 8;
+ uint32_t header_bytes = ecc_bytes + complen_bytes;
// extract compressed length of base
- UINT32 complen_base = (src[ecc_bytes + 0] << 8) | src[ecc_bytes + 1];
+ uint32_t complen_base = (src[ecc_bytes + 0] << 8) | src[ecc_bytes + 1];
if (complen_bytes > 2)
complen_base = (complen_base << 8) | src[ecc_bytes + 2];
@@ -391,13 +391,13 @@ public:
m_subcode_decompressor.decompress(&src[header_bytes + complen_base], complen - complen_base - header_bytes, &m_buffer[frames * CD_MAX_SECTOR_DATA], frames * CD_MAX_SUBCODE_DATA);
// reassemble the data
- for (UINT32 framenum = 0; framenum < frames; framenum++)
+ for (uint32_t framenum = 0; framenum < frames; framenum++)
{
memcpy(&dest[framenum * CD_FRAME_SIZE], &m_buffer[framenum * CD_MAX_SECTOR_DATA], CD_MAX_SECTOR_DATA);
memcpy(&dest[framenum * CD_FRAME_SIZE + CD_MAX_SECTOR_DATA], &m_buffer[frames * CD_MAX_SECTOR_DATA + framenum * CD_MAX_SUBCODE_DATA], CD_MAX_SUBCODE_DATA);
// reconstitute the ECC data and sync header
- UINT8 *sector = &dest[framenum * CD_FRAME_SIZE];
+ uint8_t *sector = &dest[framenum * CD_FRAME_SIZE];
if ((src[framenum / 8] & (1 << (framenum % 8))) != 0)
{
memcpy(sector, s_cd_sync_header, sizeof(s_cd_sync_header));
@@ -410,7 +410,7 @@ private:
// internal state
_BaseDecompressor m_base_decompressor;
_SubcodeDecompressor m_subcode_decompressor;
- std::vector<UINT8> m_buffer;
+ std::vector<uint8_t> m_buffer;
};
@@ -421,10 +421,10 @@ class chd_avhuff_compressor : public chd_compressor
{
public:
// construction/destruction
- chd_avhuff_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy);
+ chd_avhuff_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy);
// core functionality
- virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) override;
+ virtual uint32_t compress(const uint8_t *src, uint32_t srclen, uint8_t *dest) override;
private:
// internal helpers
@@ -443,10 +443,10 @@ class chd_avhuff_decompressor : public chd_decompressor
{
public:
// construction/destruction
- chd_avhuff_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy);
+ chd_avhuff_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy);
// core functionality
- virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) override;
+ virtual void decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen) override;
virtual void configure(int param, void *config) override;
private:
@@ -488,7 +488,7 @@ const chd_codec_list::codec_entry chd_codec_list::s_codec_list[] =
// chd_codec - constructor
//-------------------------------------------------
-chd_codec::chd_codec(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_codec::chd_codec(chd_file &chd, uint32_t hunkbytes, bool lossy)
: m_chd(chd),
m_hunkbytes(hunkbytes),
m_lossy(lossy)
@@ -525,7 +525,7 @@ void chd_codec::configure(int param, void *config)
// chd_compressor - constructor
//-------------------------------------------------
-chd_compressor::chd_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_compressor::chd_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_codec(chd, hunkbytes, lossy)
{
}
@@ -540,7 +540,7 @@ chd_compressor::chd_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
// chd_decompressor - constructor
//-------------------------------------------------
-chd_decompressor::chd_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_decompressor::chd_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_codec(chd, hunkbytes, lossy)
{
}
@@ -614,7 +614,7 @@ const chd_codec_list::codec_entry *chd_codec_list::find_in_list(chd_codec_type t
// chd_compressor_group - constructor
//-------------------------------------------------
-chd_compressor_group::chd_compressor_group(chd_file &chd, UINT32 compressor_list[4])
+chd_compressor_group::chd_compressor_group(chd_file &chd, uint32_t compressor_list[4])
: m_hunkbytes(chd.hunk_bytes()),
m_compress_test(m_hunkbytes)
#if CHDCODEC_VERIFY_COMPRESSION
@@ -658,11 +658,11 @@ chd_compressor_group::~chd_compressor_group()
// compression for this hunk
//-------------------------------------------------
-INT8 chd_compressor_group::find_best_compressor(const UINT8 *src, UINT8 *compressed, UINT32 &complen)
+int8_t chd_compressor_group::find_best_compressor(const uint8_t *src, uint8_t *compressed, uint32_t &complen)
{
// determine best compression technique
complen = m_hunkbytes;
- INT8 compression = -1;
+ int8_t compression = -1;
for (int codecnum = 0; codecnum < ARRAY_LENGTH(m_compressor); codecnum++)
if (m_compressor[codecnum] != nullptr)
{
@@ -670,7 +670,7 @@ INT8 chd_compressor_group::find_best_compressor(const UINT8 *src, UINT8 *compres
try
{
// if this is the best one, copy the data into the permanent buffer
- UINT32 compbytes = m_compressor[codecnum]->compress(src, m_hunkbytes, &m_compress_test[0]);
+ uint32_t compbytes = m_compressor[codecnum]->compress(src, m_hunkbytes, &m_compress_test[0]);
#if CHDCODEC_VERIFY_COMPRESSION
try
{
@@ -768,7 +768,7 @@ voidpf chd_zlib_allocator::fast_alloc(voidpf opaque, uInt items, uInt size)
// reuse a hunk if we can
for (int scan = 0; scan < MAX_ZLIB_ALLOCS; scan++)
{
- UINT32 *ptr = codec->m_allocptr[scan];
+ uint32_t *ptr = codec->m_allocptr[scan];
if (ptr != nullptr && size == *ptr)
{
// set the low bit of the size so we don't match next time
@@ -778,7 +778,7 @@ voidpf chd_zlib_allocator::fast_alloc(voidpf opaque, uInt items, uInt size)
}
// alloc a new one and put it into the list
- UINT32 *ptr = reinterpret_cast<UINT32 *>(new UINT8[size + sizeof(UINT32)]);
+ uint32_t *ptr = reinterpret_cast<uint32_t *>(new uint8_t[size + sizeof(uint32_t)]);
for (int scan = 0; scan < MAX_ZLIB_ALLOCS; scan++)
if (codec->m_allocptr[scan] == nullptr)
{
@@ -802,7 +802,7 @@ void chd_zlib_allocator::fast_free(voidpf opaque, voidpf address)
chd_zlib_allocator *codec = reinterpret_cast<chd_zlib_allocator *>(opaque);
// find the hunk
- UINT32 *ptr = reinterpret_cast<UINT32 *>(address) - 1;
+ uint32_t *ptr = reinterpret_cast<uint32_t *>(address) - 1;
for (int scan = 0; scan < MAX_ZLIB_ALLOCS; scan++)
if (ptr == codec->m_allocptr[scan])
{
@@ -822,7 +822,7 @@ void chd_zlib_allocator::fast_free(voidpf opaque, voidpf address)
// chd_zlib_compressor - constructor
//-------------------------------------------------
-chd_zlib_compressor::chd_zlib_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_zlib_compressor::chd_zlib_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_compressor(chd, hunkbytes, lossy)
{
// initialize the deflater
@@ -853,7 +853,7 @@ chd_zlib_compressor::~chd_zlib_compressor()
// compress - compress data using the ZLIB codec
//-------------------------------------------------
-UINT32 chd_zlib_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *dest)
+uint32_t chd_zlib_compressor::compress(const uint8_t *src, uint32_t srclen, uint8_t *dest)
{
// reset the decompressor
m_deflater.next_in = const_cast<Bytef *>(src);
@@ -887,7 +887,7 @@ UINT32 chd_zlib_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *des
// chd_zlib_decompressor - constructor
//-------------------------------------------------
-chd_zlib_decompressor::chd_zlib_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_zlib_decompressor::chd_zlib_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_decompressor(chd, hunkbytes, lossy)
{
// init the inflater
@@ -919,7 +919,7 @@ chd_zlib_decompressor::~chd_zlib_decompressor()
// codec
//-------------------------------------------------
-void chd_zlib_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen)
+void chd_zlib_decompressor::decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
{
// reset the decompressor
m_inflater.next_in = const_cast<Bytef *>(src);
@@ -988,7 +988,7 @@ void *chd_lzma_allocator::fast_alloc(void *p, size_t size)
// reuse a hunk if we can
for (int scan = 0; scan < MAX_LZMA_ALLOCS; scan++)
{
- UINT32 *ptr = codec->m_allocptr[scan];
+ uint32_t *ptr = codec->m_allocptr[scan];
if (ptr != nullptr && size == *ptr)
{
// set the low bit of the size so we don't match next time
@@ -998,7 +998,7 @@ void *chd_lzma_allocator::fast_alloc(void *p, size_t size)
}
// alloc a new one and put it into the list
- UINT32 *ptr = reinterpret_cast<UINT32 *>(new UINT8[size + sizeof(UINT32)]);
+ uint32_t *ptr = reinterpret_cast<uint32_t *>(new uint8_t[size + sizeof(uint32_t)]);
for (int scan = 0; scan < MAX_LZMA_ALLOCS; scan++)
if (codec->m_allocptr[scan] == nullptr)
{
@@ -1025,7 +1025,7 @@ void chd_lzma_allocator::fast_free(void *p, void *address)
chd_lzma_allocator *codec = reinterpret_cast<chd_lzma_allocator *>(p);
// find the hunk
- UINT32 *ptr = reinterpret_cast<UINT32 *>(address) - 1;
+ uint32_t *ptr = reinterpret_cast<uint32_t *>(address) - 1;
for (int scan = 0; scan < MAX_LZMA_ALLOCS; scan++)
if (ptr == codec->m_allocptr[scan])
{
@@ -1045,7 +1045,7 @@ void chd_lzma_allocator::fast_free(void *p, void *address)
// chd_lzma_compressor - constructor
//-------------------------------------------------
-chd_lzma_compressor::chd_lzma_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_lzma_compressor::chd_lzma_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_compressor(chd, hunkbytes, lossy)
{
// initialize the properties
@@ -1066,7 +1066,7 @@ chd_lzma_compressor::~chd_lzma_compressor()
// compress - compress data using the LZMA codec
//-------------------------------------------------
-UINT32 chd_lzma_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *dest)
+uint32_t chd_lzma_compressor::compress(const uint8_t *src, uint32_t srclen, uint8_t *dest)
{
// allocate the encoder
CLzmaEncHandle encoder = LzmaEnc_Create(&m_allocator);
@@ -1104,7 +1104,7 @@ UINT32 chd_lzma_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *des
// codec
//-------------------------------------------------
-void chd_lzma_compressor::configure_properties(CLzmaEncProps &props, UINT32 hunkbytes)
+void chd_lzma_compressor::configure_properties(CLzmaEncProps &props, uint32_t hunkbytes)
{
LzmaEncProps_Init(&props);
props.level = 9;
@@ -1122,7 +1122,7 @@ void chd_lzma_compressor::configure_properties(CLzmaEncProps &props, UINT32 hunk
// chd_lzma_decompressor - constructor
//-------------------------------------------------
-chd_lzma_decompressor::chd_lzma_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_lzma_decompressor::chd_lzma_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_decompressor(chd, hunkbytes, lossy)
{
// construct the decoder
@@ -1177,7 +1177,7 @@ chd_lzma_decompressor::~chd_lzma_decompressor()
// codec
//-------------------------------------------------
-void chd_lzma_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen)
+void chd_lzma_decompressor::decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
{
// initialize
LzmaDec_Init(&m_decoder);
@@ -1201,7 +1201,7 @@ void chd_lzma_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 *
// chd_huffman_compressor - constructor
//-------------------------------------------------
-chd_huffman_compressor::chd_huffman_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_huffman_compressor::chd_huffman_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_compressor(chd, hunkbytes, lossy)
{
}
@@ -1212,9 +1212,9 @@ chd_huffman_compressor::chd_huffman_compressor(chd_file &chd, UINT32 hunkbytes,
// codec
//-------------------------------------------------
-UINT32 chd_huffman_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *dest)
+uint32_t chd_huffman_compressor::compress(const uint8_t *src, uint32_t srclen, uint8_t *dest)
{
- UINT32 complen;
+ uint32_t complen;
if (m_encoder.encode(src, srclen, dest, srclen, complen) != HUFFERR_NONE)
throw CHDERR_COMPRESSION_ERROR;
return complen;
@@ -1230,7 +1230,7 @@ UINT32 chd_huffman_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *
// chd_huffman_decompressor - constructor
//-------------------------------------------------
-chd_huffman_decompressor::chd_huffman_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_huffman_decompressor::chd_huffman_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_decompressor(chd, hunkbytes, lossy)
{
}
@@ -1241,7 +1241,7 @@ chd_huffman_decompressor::chd_huffman_decompressor(chd_file &chd, UINT32 hunkbyt
// codec
//-------------------------------------------------
-void chd_huffman_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen)
+void chd_huffman_decompressor::decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
{
if (m_decoder.decode(src, complen, dest, destlen) != HUFFERR_NONE)
throw CHDERR_COMPRESSION_ERROR;
@@ -1257,12 +1257,12 @@ void chd_huffman_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT
// chd_flac_compressor - constructor
//-------------------------------------------------
-chd_flac_compressor::chd_flac_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_flac_compressor::chd_flac_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_compressor(chd, hunkbytes, lossy)
{
// determine whether we want native or swapped samples
- UINT16 native_endian = 0;
- *reinterpret_cast<UINT8 *>(&native_endian) = 1;
+ uint16_t native_endian = 0;
+ *reinterpret_cast<uint8_t *>(&native_endian) = 1;
m_big_endian = (native_endian == 0x100);
// configure the encoder
@@ -1277,22 +1277,22 @@ chd_flac_compressor::chd_flac_compressor(chd_file &chd, UINT32 hunkbytes, bool l
// compress - compress data using the FLAC codec
//-------------------------------------------------
-UINT32 chd_flac_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *dest)
+uint32_t chd_flac_compressor::compress(const uint8_t *src, uint32_t srclen, uint8_t *dest)
{
// reset and encode big-endian
m_encoder.reset(dest + 1, hunkbytes() - 1);
- if (!m_encoder.encode_interleaved(reinterpret_cast<const INT16 *>(src), srclen / 4, !m_big_endian))
+ if (!m_encoder.encode_interleaved(reinterpret_cast<const int16_t *>(src), srclen / 4, !m_big_endian))
throw CHDERR_COMPRESSION_ERROR;
- UINT32 complen_be = m_encoder.finish();
+ uint32_t complen_be = m_encoder.finish();
// reset and encode little-endian
m_encoder.reset(dest + 1, hunkbytes() - 1);
- if (!m_encoder.encode_interleaved(reinterpret_cast<const INT16 *>(src), srclen / 4, m_big_endian))
+ if (!m_encoder.encode_interleaved(reinterpret_cast<const int16_t *>(src), srclen / 4, m_big_endian))
throw CHDERR_COMPRESSION_ERROR;
- UINT32 complen_le = m_encoder.finish();
+ uint32_t complen_le = m_encoder.finish();
// pick the best one and add a byte
- UINT32 complen = std::min(complen_le, complen_be);
+ uint32_t complen = std::min(complen_le, complen_be);
if (complen + 1 >= hunkbytes())
throw CHDERR_COMPRESSION_ERROR;
@@ -1302,7 +1302,7 @@ UINT32 chd_flac_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *des
{
dest[0] = 'B';
m_encoder.reset(dest + 1, hunkbytes() - 1);
- if (!m_encoder.encode_interleaved(reinterpret_cast<const INT16 *>(src), srclen / 4, !m_big_endian))
+ if (!m_encoder.encode_interleaved(reinterpret_cast<const int16_t *>(src), srclen / 4, !m_big_endian))
throw CHDERR_COMPRESSION_ERROR;
m_encoder.finish();
}
@@ -1314,11 +1314,11 @@ UINT32 chd_flac_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *des
// blocksize - return the optimal block size
//-------------------------------------------------
-UINT32 chd_flac_compressor::blocksize(UINT32 bytes)
+uint32_t chd_flac_compressor::blocksize(uint32_t bytes)
{
// determine FLAC block size, which must be 16-65535
// clamp to 2k since that's supposed to be the sweet spot
- UINT32 hunkbytes = bytes / 4;
+ uint32_t hunkbytes = bytes / 4;
while (hunkbytes > 2048)
hunkbytes /= 2;
return hunkbytes;
@@ -1334,12 +1334,12 @@ UINT32 chd_flac_compressor::blocksize(UINT32 bytes)
// chd_flac_decompressor - constructor
//-------------------------------------------------
-chd_flac_decompressor::chd_flac_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_flac_decompressor::chd_flac_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_decompressor(chd, hunkbytes, lossy)
{
// determine whether we want native or swapped samples
- UINT16 native_endian = 0;
- *reinterpret_cast<UINT8 *>(&native_endian) = 1;
+ uint16_t native_endian = 0;
+ *reinterpret_cast<uint8_t *>(&native_endian) = 1;
m_big_endian = (native_endian == 0x100);
}
@@ -1349,7 +1349,7 @@ chd_flac_decompressor::chd_flac_decompressor(chd_file &chd, UINT32 hunkbytes, bo
// codec
//-------------------------------------------------
-void chd_flac_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen)
+void chd_flac_decompressor::decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
{
// determine the endianness
bool swap_endian;
@@ -1363,7 +1363,7 @@ void chd_flac_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 *
// reset and decode
if (!m_decoder.reset(44100, 2, chd_flac_compressor::blocksize(destlen), src + 1, complen - 1))
throw CHDERR_DECOMPRESSION_ERROR;
- if (!m_decoder.decode_interleaved(reinterpret_cast<INT16 *>(dest), destlen / 4, swap_endian))
+ if (!m_decoder.decode_interleaved(reinterpret_cast<int16_t *>(dest), destlen / 4, swap_endian))
throw CHDERR_DECOMPRESSION_ERROR;
// finish up
@@ -1380,7 +1380,7 @@ void chd_flac_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 *
// chd_cd_flac_compressor - constructor
//-------------------------------------------------
-chd_cd_flac_compressor::chd_cd_flac_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_cd_flac_compressor::chd_cd_flac_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_compressor(chd, hunkbytes, lossy),
m_buffer(hunkbytes)
{
@@ -1389,8 +1389,8 @@ chd_cd_flac_compressor::chd_cd_flac_compressor(chd_file &chd, UINT32 hunkbytes,
throw CHDERR_CODEC_ERROR;
// determine whether we want native or swapped samples
- UINT16 native_endian = 0;
- *reinterpret_cast<UINT8 *>(&native_endian) = 1;
+ uint16_t native_endian = 0;
+ *reinterpret_cast<uint8_t *>(&native_endian) = 1;
m_swap_endian = (native_endian == 1);
// configure the encoder
@@ -1428,11 +1428,11 @@ chd_cd_flac_compressor::~chd_cd_flac_compressor()
// and use zlib on the subcode data
//-------------------------------------------------
-UINT32 chd_cd_flac_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *dest)
+uint32_t chd_cd_flac_compressor::compress(const uint8_t *src, uint32_t srclen, uint8_t *dest)
{
// copy audio data followed by subcode data
- UINT32 frames = hunkbytes() / CD_FRAME_SIZE;
- for (UINT32 framenum = 0; framenum < frames; framenum++)
+ uint32_t frames = hunkbytes() / CD_FRAME_SIZE;
+ for (uint32_t framenum = 0; framenum < frames; framenum++)
{
memcpy(&m_buffer[framenum * CD_MAX_SECTOR_DATA], &src[framenum * CD_FRAME_SIZE], CD_MAX_SECTOR_DATA);
memcpy(&m_buffer[frames * CD_MAX_SECTOR_DATA + framenum * CD_MAX_SUBCODE_DATA], &src[framenum * CD_FRAME_SIZE + CD_MAX_SECTOR_DATA], CD_MAX_SUBCODE_DATA);
@@ -1440,12 +1440,12 @@ UINT32 chd_cd_flac_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *
// reset and encode the audio portion
m_encoder.reset(dest, hunkbytes());
- UINT8 *buffer = &m_buffer[0];
- if (!m_encoder.encode_interleaved(reinterpret_cast<INT16 *>(buffer), frames * CD_MAX_SECTOR_DATA/4, m_swap_endian))
+ uint8_t *buffer = &m_buffer[0];
+ if (!m_encoder.encode_interleaved(reinterpret_cast<int16_t *>(buffer), frames * CD_MAX_SECTOR_DATA/4, m_swap_endian))
throw CHDERR_COMPRESSION_ERROR;
// finish up
- UINT32 complen = m_encoder.finish();
+ uint32_t complen = m_encoder.finish();
// deflate the subcode data
m_deflater.next_in = const_cast<Bytef *>(&m_buffer[frames * CD_MAX_SECTOR_DATA]);
@@ -1469,7 +1469,7 @@ UINT32 chd_cd_flac_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *
}
/**
- * @fn UINT32 chd_cd_flac_compressor::blocksize(UINT32 bytes)
+ * @fn uint32_t chd_cd_flac_compressor::blocksize(uint32_t bytes)
*
* @brief -------------------------------------------------
* blocksize - return the optimal block size
@@ -1477,13 +1477,13 @@ UINT32 chd_cd_flac_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *
*
* @param bytes The bytes.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-UINT32 chd_cd_flac_compressor::blocksize(UINT32 bytes)
+uint32_t chd_cd_flac_compressor::blocksize(uint32_t bytes)
{
// for CDs it seems that CD_MAX_SECTOR_DATA is the right target
- UINT32 blocksize = bytes / 4;
+ uint32_t blocksize = bytes / 4;
while (blocksize > CD_MAX_SECTOR_DATA)
blocksize /= 2;
return blocksize;
@@ -1496,7 +1496,7 @@ UINT32 chd_cd_flac_compressor::blocksize(UINT32 bytes)
//**************************************************************************
/**
- * @fn chd_cd_flac_decompressor::chd_cd_flac_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+ * @fn chd_cd_flac_decompressor::chd_cd_flac_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
*
* @brief -------------------------------------------------
* chd_cd_flac_decompressor - constructor
@@ -1509,7 +1509,7 @@ UINT32 chd_cd_flac_compressor::blocksize(UINT32 bytes)
* @param lossy true to lossy.
*/
-chd_cd_flac_decompressor::chd_cd_flac_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_cd_flac_decompressor::chd_cd_flac_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_decompressor(chd, hunkbytes, lossy),
m_buffer(hunkbytes)
{
@@ -1518,8 +1518,8 @@ chd_cd_flac_decompressor::chd_cd_flac_decompressor(chd_file &chd, UINT32 hunkbyt
throw CHDERR_CODEC_ERROR;
// determine whether we want native or swapped samples
- UINT16 native_endian = 0;
- *reinterpret_cast<UINT8 *>(&native_endian) = 1;
+ uint16_t native_endian = 0;
+ *reinterpret_cast<uint8_t *>(&native_endian) = 1;
m_swap_endian = (native_endian == 1);
// init the inflater
@@ -1549,7 +1549,7 @@ chd_cd_flac_decompressor::~chd_cd_flac_decompressor()
}
/**
- * @fn void chd_cd_flac_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen)
+ * @fn void chd_cd_flac_decompressor::decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
*
* @brief -------------------------------------------------
* decompress - decompress data using the FLAC codec
@@ -1564,18 +1564,18 @@ chd_cd_flac_decompressor::~chd_cd_flac_decompressor()
* @param destlen The destlen.
*/
-void chd_cd_flac_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen)
+void chd_cd_flac_decompressor::decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
{
// reset and decode
- UINT32 frames = destlen / CD_FRAME_SIZE;
+ uint32_t frames = destlen / CD_FRAME_SIZE;
if (!m_decoder.reset(44100, 2, chd_cd_flac_compressor::blocksize(frames * CD_MAX_SECTOR_DATA), src, complen))
throw CHDERR_DECOMPRESSION_ERROR;
- UINT8 *buffer = &m_buffer[0];
- if (!m_decoder.decode_interleaved(reinterpret_cast<INT16 *>(buffer), frames * CD_MAX_SECTOR_DATA/4, m_swap_endian))
+ uint8_t *buffer = &m_buffer[0];
+ if (!m_decoder.decode_interleaved(reinterpret_cast<int16_t *>(buffer), frames * CD_MAX_SECTOR_DATA/4, m_swap_endian))
throw CHDERR_DECOMPRESSION_ERROR;
// inflate the subcode data
- UINT32 offset = m_decoder.finish();
+ uint32_t offset = m_decoder.finish();
m_inflater.next_in = const_cast<Bytef *>(src + offset);
m_inflater.avail_in = complen - offset;
m_inflater.total_in = 0;
@@ -1594,7 +1594,7 @@ void chd_cd_flac_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT
throw CHDERR_DECOMPRESSION_ERROR;
// reassemble the data
- for (UINT32 framenum = 0; framenum < frames; framenum++)
+ for (uint32_t framenum = 0; framenum < frames; framenum++)
{
memcpy(&dest[framenum * CD_FRAME_SIZE], &m_buffer[framenum * CD_MAX_SECTOR_DATA], CD_MAX_SECTOR_DATA);
memcpy(&dest[framenum * CD_FRAME_SIZE + CD_MAX_SECTOR_DATA], &m_buffer[frames * CD_MAX_SECTOR_DATA + framenum * CD_MAX_SUBCODE_DATA], CD_MAX_SUBCODE_DATA);
@@ -1608,7 +1608,7 @@ void chd_cd_flac_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT
//**************************************************************************
/**
- * @fn chd_avhuff_compressor::chd_avhuff_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+ * @fn chd_avhuff_compressor::chd_avhuff_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
*
* @brief -------------------------------------------------
* chd_avhuff_compressor - constructor
@@ -1619,7 +1619,7 @@ void chd_cd_flac_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT
* @param lossy true to lossy.
*/
-chd_avhuff_compressor::chd_avhuff_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_avhuff_compressor::chd_avhuff_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_compressor(chd, hunkbytes, lossy),
m_postinit(false)
{
@@ -1635,7 +1635,7 @@ chd_avhuff_compressor::chd_avhuff_compressor(chd_file &chd, UINT32 hunkbytes, bo
}
/**
- * @fn UINT32 chd_avhuff_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *dest)
+ * @fn uint32_t chd_avhuff_compressor::compress(const uint8_t *src, uint32_t srclen, uint8_t *dest)
*
* @brief -------------------------------------------------
* compress - compress data using the A/V codec
@@ -1650,10 +1650,10 @@ chd_avhuff_compressor::chd_avhuff_compressor(chd_file &chd, UINT32 hunkbytes, bo
* @param srclen The srclen.
* @param [in,out] dest If non-null, destination for the.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-UINT32 chd_avhuff_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *dest)
+uint32_t chd_avhuff_compressor::compress(const uint8_t *src, uint32_t srclen, uint8_t *dest)
{
// if we haven't yet set up the avhuff code, do it now
if (!m_postinit)
@@ -1669,7 +1669,7 @@ UINT32 chd_avhuff_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *d
}
// encode the audio and video
- UINT32 complen;
+ uint32_t complen;
avhuff_error averr = m_encoder.encode_data(src, dest, complen);
if (averr != AVHERR_NONE || complen > srclen)
throw CHDERR_COMPRESSION_ERROR;
@@ -1703,9 +1703,9 @@ void chd_avhuff_compressor::postinit()
throw CHDERR_INVALID_METADATA;
// compute the bytes per frame
- UINT32 fps_times_1million = fps * 1000000 + fpsfrac;
- UINT32 max_samples_per_frame = (UINT64(rate) * 1000000 + fps_times_1million - 1) / fps_times_1million;
- UINT32 bytes_per_frame = 12 + channels * max_samples_per_frame * 2 + width * height * 2;
+ uint32_t fps_times_1million = fps * 1000000 + fpsfrac;
+ uint32_t max_samples_per_frame = (uint64_t(rate) * 1000000 + fps_times_1million - 1) / fps_times_1million;
+ uint32_t bytes_per_frame = 12 + channels * max_samples_per_frame * 2 + width * height * 2;
if (bytes_per_frame > hunkbytes())
throw CHDERR_INVALID_METADATA;
@@ -1720,7 +1720,7 @@ void chd_avhuff_compressor::postinit()
//**************************************************************************
/**
- * @fn chd_avhuff_decompressor::chd_avhuff_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+ * @fn chd_avhuff_decompressor::chd_avhuff_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
*
* @brief -------------------------------------------------
* chd_avhuff_decompressor - constructor
@@ -1731,13 +1731,13 @@ void chd_avhuff_compressor::postinit()
* @param lossy true to lossy.
*/
-chd_avhuff_decompressor::chd_avhuff_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy)
+chd_avhuff_decompressor::chd_avhuff_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy)
: chd_decompressor(chd, hunkbytes, lossy)
{
}
/**
- * @fn void chd_avhuff_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen)
+ * @fn void chd_avhuff_decompressor::decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
*
* @brief -------------------------------------------------
* decompress - decompress data using the A/V codec
@@ -1752,7 +1752,7 @@ chd_avhuff_decompressor::chd_avhuff_decompressor(chd_file &chd, UINT32 hunkbytes
* @param destlen The destlen.
*/
-void chd_avhuff_decompressor::decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen)
+void chd_avhuff_decompressor::decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
{
// decode the audio and video
avhuff_error averr = m_decoder.decode_data(src, complen, dest);
diff --git a/src/lib/util/chdcodec.h b/src/lib/util/chdcodec.h
index 0b56cbdeb9c..899b5363592 100644
--- a/src/lib/util/chdcodec.h
+++ b/src/lib/util/chdcodec.h
@@ -36,7 +36,7 @@
class chd_file;
// base types
-typedef UINT32 chd_codec_type;
+typedef uint32_t chd_codec_type;
// ======================> chd_codec
@@ -46,7 +46,7 @@ class chd_codec
{
protected:
// can't create these directly
- chd_codec(chd_file &file, UINT32 hunkbytes, bool lossy);
+ chd_codec(chd_file &file, uint32_t hunkbytes, bool lossy);
public:
// allow public deletion
@@ -54,7 +54,7 @@ public:
// accessors
chd_file &chd() const { return m_chd; }
- UINT32 hunkbytes() const { return m_hunkbytes; }
+ uint32_t hunkbytes() const { return m_hunkbytes; }
bool lossy() const { return m_lossy; }
// implementation
@@ -63,7 +63,7 @@ public:
private:
// internal state
chd_file & m_chd;
- UINT32 m_hunkbytes;
+ uint32_t m_hunkbytes;
bool m_lossy;
};
@@ -75,11 +75,11 @@ class chd_compressor : public chd_codec
{
protected:
// can't create these directly
- chd_compressor(chd_file &file, UINT32 hunkbytes, bool lossy);
+ chd_compressor(chd_file &file, uint32_t hunkbytes, bool lossy);
public:
// implementation
- virtual UINT32 compress(const UINT8 *src, UINT32 srclen, UINT8 *dest) = 0;
+ virtual uint32_t compress(const uint8_t *src, uint32_t srclen, uint8_t *dest) = 0;
};
@@ -90,11 +90,11 @@ class chd_decompressor : public chd_codec
{
protected:
// can't create these directly
- chd_decompressor(chd_file &file, UINT32 hunkbytes, bool lossy);
+ chd_decompressor(chd_file &file, uint32_t hunkbytes, bool lossy);
public:
// implementation
- virtual void decompress(const UINT8 *src, UINT32 complen, UINT8 *dest, UINT32 destlen) = 0;
+ virtual void decompress(const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen) = 0;
};
@@ -119,18 +119,18 @@ private:
chd_codec_type m_type;
bool m_lossy;
const char * m_name;
- chd_compressor * (*m_construct_compressor)(chd_file &, UINT32, bool);
- chd_decompressor * (*m_construct_decompressor)(chd_file &, UINT32, bool);
+ chd_compressor * (*m_construct_compressor)(chd_file &, uint32_t, bool);
+ chd_decompressor * (*m_construct_decompressor)(chd_file &, uint32_t, bool);
};
// internal helper functions
static const codec_entry *find_in_list(chd_codec_type type);
template<class _CompressorClass>
- static chd_compressor *construct_compressor(chd_file &chd, UINT32 hunkbytes, bool lossy) { return new _CompressorClass(chd, hunkbytes, lossy); }
+ static chd_compressor *construct_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy) { return new _CompressorClass(chd, hunkbytes, lossy); }
template<class _DecompressorClass>
- static chd_decompressor *construct_decompressor(chd_file &chd, UINT32 hunkbytes, bool lossy) { return new _DecompressorClass(chd, hunkbytes, lossy); }
+ static chd_decompressor *construct_decompressor(chd_file &chd, uint32_t hunkbytes, bool lossy) { return new _DecompressorClass(chd, hunkbytes, lossy); }
// the static list
static const codec_entry s_codec_list[];
@@ -148,16 +148,16 @@ public:
~chd_compressor_group();
// find the best compressor
- INT8 find_best_compressor(const UINT8 *src, UINT8 *compressed, UINT32 &complen);
+ int8_t find_best_compressor(const uint8_t *src, uint8_t *compressed, uint32_t &complen);
private:
// internal state
- UINT32 m_hunkbytes; // number of bytes in a hunk
+ uint32_t m_hunkbytes; // number of bytes in a hunk
chd_compressor * m_compressor[4]; // array of active codecs
- std::vector<UINT8> m_compress_test; // test buffer for compression
+ std::vector<uint8_t> m_compress_test; // test buffer for compression
#if CHDCODEC_VERIFY_COMPRESSION
chd_decompressor * m_decompressor[4]; // array of active codecs
- std::vector<UINT8> m_decompressed; // verification buffer
+ std::vector<uint8_t> m_decompressed; // verification buffer
#endif
};
diff --git a/src/lib/util/corefile.cpp b/src/lib/util/corefile.cpp
index 699ef91027b..76b788174ab 100644
--- a/src/lib/util/corefile.cpp
+++ b/src/lib/util/corefile.cpp
@@ -1221,7 +1221,7 @@ osd_file::error core_file::load(std::string const &filename, void **data, std::u
return osd_file::error::NONE;
}
-osd_file::error core_file::load(std::string const &filename, std::vector<UINT8> &data)
+osd_file::error core_file::load(std::string const &filename, std::vector<uint8_t> &data)
{
ptr file;
@@ -1320,7 +1320,7 @@ bool core_filename_ends_with(const std::string &filename, const std::string &ext
// work backwards checking for a match
while (matches && extlen > 0 && namelen > 0)
{
- if (tolower((UINT8)filename[--namelen]) != tolower((UINT8)extension[--extlen]))
+ if (tolower((uint8_t)filename[--namelen]) != tolower((uint8_t)extension[--extlen]))
matches = false;
}
diff --git a/src/lib/util/corefile.h b/src/lib/util/corefile.h
index 70b966c394c..2c4a5da8217 100644
--- a/src/lib/util/corefile.h
+++ b/src/lib/util/corefile.h
@@ -101,7 +101,7 @@ public:
// open a file with the specified filename, read it into memory, and return a pointer
static osd_file::error load(std::string const &filename, void **data, std::uint32_t &length);
- static osd_file::error load(std::string const &filename, std::vector<UINT8> &data);
+ static osd_file::error load(std::string const &filename, std::vector<uint8_t> &data);
// ----- file write -----
diff --git a/src/lib/util/corestr.cpp b/src/lib/util/corestr.cpp
index 7daad5cc0cb..ed9c8e77b0a 100644
--- a/src/lib/util/corestr.cpp
+++ b/src/lib/util/corestr.cpp
@@ -22,8 +22,8 @@ int core_stricmp(const char *s1, const char *s2)
{
for (;;)
{
- int c1 = tolower((UINT8)*s1++);
- int c2 = tolower((UINT8)*s2++);
+ int c1 = tolower((uint8_t)*s1++);
+ int c2 = tolower((uint8_t)*s2++);
if (c1 == 0 || c1 != c2)
return c1 - c2;
}
@@ -39,8 +39,8 @@ int core_strnicmp(const char *s1, const char *s2, size_t n)
size_t i;
for (i = 0; i < n; i++)
{
- int c1 = tolower((UINT8)*s1++);
- int c2 = tolower((UINT8)*s2++);
+ int c1 = tolower((uint8_t)*s1++);
+ int c2 = tolower((uint8_t)*s2++);
if (c1 == 0 || c1 != c2)
return c1 - c2;
}
@@ -166,7 +166,7 @@ std::string strtrimspace(std::string& str)
int start = 0;
for (auto & elem : str)
{
- if (!isspace(UINT8(elem))) break;
+ if (!isspace(uint8_t(elem))) break;
start++;
}
int end = str.length();
@@ -174,7 +174,7 @@ std::string strtrimspace(std::string& str)
{
for (size_t i = str.length() - 1; i > 0; i--)
{
- if (!isspace(UINT8(str[i]))) break;
+ if (!isspace(uint8_t(str[i]))) break;
end--;
}
}
diff --git a/src/lib/util/coreutil.cpp b/src/lib/util/coreutil.cpp
index 90bcab9ab1a..8ff9585d476 100644
--- a/src/lib/util/coreutil.cpp
+++ b/src/lib/util/coreutil.cpp
@@ -27,9 +27,9 @@ int bcd_adjust(int value)
}
-UINT32 dec_2_bcd(UINT32 a)
+uint32_t dec_2_bcd(uint32_t a)
{
- UINT32 result = 0;
+ uint32_t result = 0;
int shift = 0;
while (a != 0)
@@ -42,10 +42,10 @@ UINT32 dec_2_bcd(UINT32 a)
}
-UINT32 bcd_2_dec(UINT32 a)
+uint32_t bcd_2_dec(uint32_t a)
{
- UINT32 result = 0;
- UINT32 scale = 1;
+ uint32_t result = 0;
+ uint32_t scale = 1;
while (a != 0)
{
@@ -106,19 +106,19 @@ int gregorian_days_in_month(int month, int year)
void rand_memory(void *memory, size_t length)
{
- static UINT32 seed = 0;
- UINT8 *bytes = (UINT8 *) memory;
+ static uint32_t seed = 0;
+ uint8_t *bytes = (uint8_t *) memory;
size_t i;
for (i = 0; i < length; i++)
{
seed = seed * 214013 + 2531011;
- bytes[i] = (UINT8) (seed >> 16);
+ bytes[i] = (uint8_t) (seed >> 16);
}
}
-UINT32 core_crc32(UINT32 crc, const UINT8 *buf, UINT32 len)
+uint32_t core_crc32(uint32_t crc, const uint8_t *buf, uint32_t len)
{
return crc32(crc, buf, len);
}
diff --git a/src/lib/util/coreutil.h b/src/lib/util/coreutil.h
index 839e72686ea..167f696970e 100644
--- a/src/lib/util/coreutil.h
+++ b/src/lib/util/coreutil.h
@@ -21,8 +21,8 @@
***************************************************************************/
int bcd_adjust(int value);
-UINT32 dec_2_bcd(UINT32 a);
-UINT32 bcd_2_dec(UINT32 a);
+uint32_t dec_2_bcd(uint32_t a);
+uint32_t bcd_2_dec(uint32_t a);
/***************************************************************************
@@ -39,6 +39,6 @@ int gregorian_days_in_month(int month, int year);
void rand_memory(void *memory, size_t length);
-UINT32 core_crc32(UINT32 crc, const UINT8 *buf, UINT32 len);
+uint32_t core_crc32(uint32_t crc, const uint8_t *buf, uint32_t len);
#endif /* __COREUTIL_H__ */
diff --git a/src/lib/util/flac.cpp b/src/lib/util/flac.cpp
index 46d349c3452..cd84dfbca13 100644
--- a/src/lib/util/flac.cpp
+++ b/src/lib/util/flac.cpp
@@ -28,7 +28,7 @@ flac_encoder::flac_encoder()
}
-flac_encoder::flac_encoder(void *buffer, UINT32 buflength)
+flac_encoder::flac_encoder(void *buffer, uint32_t buflength)
{
init_common();
reset(buffer, buflength);
@@ -86,7 +86,7 @@ bool flac_encoder::reset()
// reset - reset state with new memory parameters
//-------------------------------------------------
-bool flac_encoder::reset(void *buffer, UINT32 buflength)
+bool flac_encoder::reset(void *buffer, uint32_t buflength)
{
// configure the output
m_compressed_start = reinterpret_cast<FLAC__byte *>(buffer);
@@ -115,24 +115,24 @@ bool flac_encoder::reset(util::core_file &file)
// interleaved samples
//-------------------------------------------------
-bool flac_encoder::encode_interleaved(const INT16 *samples, UINT32 samples_per_channel, bool swap_endian)
+bool flac_encoder::encode_interleaved(const int16_t *samples, uint32_t samples_per_channel, bool swap_endian)
{
int shift = swap_endian ? 8 : 0;
// loop over source samples
int num_channels = FLAC__stream_encoder_get_channels(m_encoder);
- UINT32 srcindex = 0;
+ uint32_t srcindex = 0;
while (samples_per_channel != 0)
{
// process in batches of 2k samples
FLAC__int32 converted_buffer[2048];
FLAC__int32 *dest = converted_buffer;
- UINT32 cur_samples = (std::min<size_t>)(ARRAY_LENGTH(converted_buffer) / num_channels, samples_per_channel);
+ uint32_t cur_samples = (std::min<size_t>)(ARRAY_LENGTH(converted_buffer) / num_channels, samples_per_channel);
// convert a buffers' worth
- for (UINT32 sampnum = 0; sampnum < cur_samples; sampnum++)
+ for (uint32_t sampnum = 0; sampnum < cur_samples; sampnum++)
for (int channel = 0; channel < num_channels; channel++, srcindex++)
- *dest++ = INT16((UINT16(samples[srcindex]) << shift) | (UINT16(samples[srcindex]) >> shift));
+ *dest++ = int16_t((uint16_t(samples[srcindex]) << shift) | (uint16_t(samples[srcindex]) >> shift));
// process this batch
if (!FLAC__stream_encoder_process_interleaved(m_encoder, converted_buffer, cur_samples))
@@ -148,24 +148,24 @@ bool flac_encoder::encode_interleaved(const INT16 *samples, UINT32 samples_per_c
// sample streams
//-------------------------------------------------
-bool flac_encoder::encode(INT16 *const *samples, UINT32 samples_per_channel, bool swap_endian)
+bool flac_encoder::encode(int16_t *const *samples, uint32_t samples_per_channel, bool swap_endian)
{
int shift = swap_endian ? 8 : 0;
// loop over source samples
int num_channels = FLAC__stream_encoder_get_channels(m_encoder);
- UINT32 srcindex = 0;
+ uint32_t srcindex = 0;
while (samples_per_channel != 0)
{
// process in batches of 2k samples
FLAC__int32 converted_buffer[2048];
FLAC__int32 *dest = converted_buffer;
- UINT32 cur_samples = (std::min<size_t>)(ARRAY_LENGTH(converted_buffer) / num_channels, samples_per_channel);
+ uint32_t cur_samples = (std::min<size_t>)(ARRAY_LENGTH(converted_buffer) / num_channels, samples_per_channel);
// convert a buffers' worth
- for (UINT32 sampnum = 0; sampnum < cur_samples; sampnum++, srcindex++)
+ for (uint32_t sampnum = 0; sampnum < cur_samples; sampnum++, srcindex++)
for (int channel = 0; channel < num_channels; channel++)
- *dest++ = INT16((UINT16(samples[channel][srcindex]) << shift) | (UINT16(samples[channel][srcindex]) >> shift));
+ *dest++ = int16_t((uint16_t(samples[channel][srcindex]) << shift) | (uint16_t(samples[channel][srcindex]) >> shift));
// process this batch
if (!FLAC__stream_encoder_process_interleaved(m_encoder, converted_buffer, cur_samples))
@@ -181,7 +181,7 @@ bool flac_encoder::encode(INT16 *const *samples, UINT32 samples_per_channel, boo
// stream
//-------------------------------------------------
-UINT32 flac_encoder::finish()
+uint32_t flac_encoder::finish()
{
// process the data and return the amount written
FLAC__stream_encoder_finish(m_encoder);
@@ -297,7 +297,7 @@ flac_decoder::flac_decoder()
// flac_decoder - constructor
//-------------------------------------------------
-flac_decoder::flac_decoder(const void *buffer, UINT32 length, const void *buffer2, UINT32 length2)
+flac_decoder::flac_decoder(const void *buffer, uint32_t length, const void *buffer2, uint32_t length2)
: m_decoder(FLAC__stream_decoder_new()),
m_file(nullptr),
m_compressed_offset(0),
@@ -363,7 +363,7 @@ bool flac_decoder::reset()
// reset - reset state with new memory parameters
//-------------------------------------------------
-bool flac_decoder::reset(const void *buffer, UINT32 length, const void *buffer2, UINT32 length2)
+bool flac_decoder::reset(const void *buffer, uint32_t length, const void *buffer2, uint32_t length2)
{
m_file = nullptr;
m_compressed_start = reinterpret_cast<const FLAC__byte *>(buffer);
@@ -379,10 +379,10 @@ bool flac_decoder::reset(const void *buffer, UINT32 length, const void *buffer2,
// and a custom-generated header
//-------------------------------------------------
-bool flac_decoder::reset(UINT32 sample_rate, UINT8 num_channels, UINT32 block_size, const void *buffer, UINT32 length)
+bool flac_decoder::reset(uint32_t sample_rate, uint8_t num_channels, uint32_t block_size, const void *buffer, uint32_t length)
{
// modify the template header with our parameters
- static const UINT8 s_header_template[0x2a] =
+ static const uint8_t s_header_template[0x2a] =
{
0x66, 0x4C, 0x61, 0x43, // +00: 'fLaC' stream header
0x80, // +04: metadata block type 0 (STREAMINFO),
@@ -436,7 +436,7 @@ bool flac_decoder::reset(util::core_file &file)
// sound stream
//-------------------------------------------------
-bool flac_decoder::decode_interleaved(INT16 *samples, UINT32 num_samples, bool swap_endian)
+bool flac_decoder::decode_interleaved(int16_t *samples, uint32_t num_samples, bool swap_endian)
{
// configure the uncompressed buffer
memset(m_uncompressed_start, 0, sizeof(m_uncompressed_start));
@@ -458,7 +458,7 @@ bool flac_decoder::decode_interleaved(INT16 *samples, UINT32 num_samples, bool s
// data streams
//-------------------------------------------------
-bool flac_decoder::decode(INT16 **samples, UINT32 num_samples, bool swap_endian)
+bool flac_decoder::decode(int16_t **samples, uint32_t num_samples, bool swap_endian)
{
// make sure we don't have too many channels
int chans = channels();
@@ -485,7 +485,7 @@ bool flac_decoder::decode(INT16 **samples, UINT32 num_samples, bool swap_endian)
// finish - finish up the decode
//-------------------------------------------------
-UINT32 flac_decoder::finish()
+uint32_t flac_decoder::finish()
{
// get the final decoding position and move forward
FLAC__uint64 position = 0;
@@ -513,7 +513,7 @@ FLAC__StreamDecoderReadStatus flac_decoder::read_callback_static(const FLAC__Str
FLAC__StreamDecoderReadStatus flac_decoder::read_callback(FLAC__byte buffer[], size_t *bytes)
{
- UINT32 expected = *bytes;
+ uint32_t expected = *bytes;
// if a file, just read
if (m_file != nullptr)
@@ -523,10 +523,10 @@ FLAC__StreamDecoderReadStatus flac_decoder::read_callback(FLAC__byte buffer[], s
else
{
// copy from primary buffer first
- UINT32 outputpos = 0;
+ uint32_t outputpos = 0;
if (outputpos < *bytes && m_compressed_offset < m_compressed_length)
{
- UINT32 bytes_to_copy = (std::min<size_t>)(*bytes - outputpos, m_compressed_length - m_compressed_offset);
+ uint32_t bytes_to_copy = (std::min<size_t>)(*bytes - outputpos, m_compressed_length - m_compressed_offset);
memcpy(&buffer[outputpos], m_compressed_start + m_compressed_offset, bytes_to_copy);
outputpos += bytes_to_copy;
m_compressed_offset += bytes_to_copy;
@@ -535,7 +535,7 @@ FLAC__StreamDecoderReadStatus flac_decoder::read_callback(FLAC__byte buffer[], s
// once we're out of that, copy from the secondary buffer
if (outputpos < *bytes && m_compressed_offset < m_compressed_length + m_compressed2_length)
{
- UINT32 bytes_to_copy = (std::min<size_t>)(*bytes - outputpos, m_compressed2_length - (m_compressed_offset - m_compressed_length));
+ uint32_t bytes_to_copy = (std::min<size_t>)(*bytes - outputpos, m_compressed2_length - (m_compressed_offset - m_compressed_length));
memcpy(&buffer[outputpos], m_compressed2_start + m_compressed_offset - m_compressed_length, bytes_to_copy);
outputpos += bytes_to_copy;
m_compressed_offset += bytes_to_copy;
@@ -597,10 +597,10 @@ FLAC__StreamDecoderWriteStatus flac_decoder::write_callback(const ::FLAC__Frame
int blocksize = frame->header.blocksize;
if (m_uncompressed_start[1] == nullptr)
{
- INT16 *dest = m_uncompressed_start[0] + m_uncompressed_offset * frame->header.channels;
+ int16_t *dest = m_uncompressed_start[0] + m_uncompressed_offset * frame->header.channels;
for (int sampnum = 0; sampnum < blocksize && m_uncompressed_offset < m_uncompressed_length; sampnum++, m_uncompressed_offset++)
for (int chan = 0; chan < frame->header.channels; chan++)
- *dest++ = INT16((UINT16(buffer[chan][sampnum]) << shift) | (UINT16(buffer[chan][sampnum]) >> shift));
+ *dest++ = int16_t((uint16_t(buffer[chan][sampnum]) << shift) | (uint16_t(buffer[chan][sampnum]) >> shift));
}
// non-interleaved case
@@ -609,7 +609,7 @@ FLAC__StreamDecoderWriteStatus flac_decoder::write_callback(const ::FLAC__Frame
for (int sampnum = 0; sampnum < blocksize && m_uncompressed_offset < m_uncompressed_length; sampnum++, m_uncompressed_offset++)
for (int chan = 0; chan < frame->header.channels; chan++)
if (m_uncompressed_start[chan] != nullptr)
- m_uncompressed_start[chan][m_uncompressed_offset] = INT16((UINT16(buffer[chan][sampnum]) << shift) | (UINT16(buffer[chan][sampnum]) >> shift));
+ m_uncompressed_start[chan][m_uncompressed_offset] = int16_t((uint16_t(buffer[chan][sampnum]) << shift) | (uint16_t(buffer[chan][sampnum]) >> shift));
}
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
diff --git a/src/lib/util/flac.h b/src/lib/util/flac.h
index 2bb41964a43..f5951945b07 100644
--- a/src/lib/util/flac.h
+++ b/src/lib/util/flac.h
@@ -30,14 +30,14 @@ class flac_encoder
public:
// construction/destruction
flac_encoder();
- flac_encoder(void *buffer, UINT32 buflength);
+ flac_encoder(void *buffer, uint32_t buflength);
flac_encoder(util::core_file &file);
~flac_encoder();
// configuration
- void set_sample_rate(UINT32 sample_rate) { m_sample_rate = sample_rate; }
- void set_num_channels(UINT8 num_channels) { m_channels = num_channels; }
- void set_block_size(UINT32 block_size) { m_block_size = block_size; }
+ void set_sample_rate(uint32_t sample_rate) { m_sample_rate = sample_rate; }
+ void set_num_channels(uint8_t num_channels) { m_channels = num_channels; }
+ void set_block_size(uint32_t block_size) { m_block_size = block_size; }
void set_strip_metadata(bool strip) { m_strip_metadata = strip; }
// getters (valid after reset)
@@ -46,15 +46,15 @@ public:
// reset
bool reset();
- bool reset(void *buffer, UINT32 buflength);
+ bool reset(void *buffer, uint32_t buflength);
bool reset(util::core_file &file);
// encode a buffer
- bool encode_interleaved(const INT16 *samples, UINT32 samples_per_channel, bool swap_endian = false);
- bool encode(INT16 *const *samples, UINT32 samples_per_channel, bool swap_endian = false);
+ bool encode_interleaved(const int16_t *samples, uint32_t samples_per_channel, bool swap_endian = false);
+ bool encode(int16_t *const *samples, uint32_t samples_per_channel, bool swap_endian = false);
// finish up
- UINT32 finish();
+ uint32_t finish();
private:
// internal helpers
@@ -65,18 +65,18 @@ private:
// internal state
FLAC__StreamEncoder * m_encoder; // actual encoder
util::core_file * m_file; // output file
- UINT32 m_compressed_offset; // current offset with the compressed stream
+ uint32_t m_compressed_offset; // current offset with the compressed stream
FLAC__byte * m_compressed_start; // start of compressed data
- UINT32 m_compressed_length; // length of the compressed stream
+ uint32_t m_compressed_length; // length of the compressed stream
// parameters
- UINT32 m_sample_rate; // sample rate
- UINT8 m_channels; // number of channels
- UINT32 m_block_size; // block size
+ uint32_t m_sample_rate; // sample rate
+ uint8_t m_channels; // number of channels
+ uint32_t m_block_size; // block size
// header stripping
bool m_strip_metadata; // strip the metadata?
- UINT32 m_ignore_bytes; // how many bytes to ignore when writing
+ uint32_t m_ignore_bytes; // how many bytes to ignore when writing
bool m_found_audio; // have we hit the audio yet?
};
@@ -88,30 +88,30 @@ class flac_decoder
public:
// construction/destruction
flac_decoder();
- flac_decoder(const void *buffer, UINT32 length, const void *buffer2 = nullptr, UINT32 length2 = 0);
+ flac_decoder(const void *buffer, uint32_t length, const void *buffer2 = nullptr, uint32_t length2 = 0);
flac_decoder(util::core_file &file);
~flac_decoder();
// getters (valid after reset)
- UINT32 sample_rate() const { return m_sample_rate; }
- UINT8 channels() const { return m_channels; }
- UINT8 bits_per_sample() const { return m_bits_per_sample; }
- UINT32 total_samples() const { return FLAC__stream_decoder_get_total_samples(m_decoder); }
+ uint32_t sample_rate() const { return m_sample_rate; }
+ uint8_t channels() const { return m_channels; }
+ uint8_t bits_per_sample() const { return m_bits_per_sample; }
+ uint32_t total_samples() const { return FLAC__stream_decoder_get_total_samples(m_decoder); }
FLAC__StreamDecoderState state() const { return FLAC__stream_decoder_get_state(m_decoder); }
const char *state_string() const { return FLAC__stream_decoder_get_resolved_state_string(m_decoder); }
// reset
bool reset();
- bool reset(const void *buffer, UINT32 length, const void *buffer2 = nullptr, UINT32 length2 = 0);
- bool reset(UINT32 sample_rate, UINT8 num_channels, UINT32 block_size, const void *buffer, UINT32 length);
+ bool reset(const void *buffer, uint32_t length, const void *buffer2 = nullptr, uint32_t length2 = 0);
+ bool reset(uint32_t sample_rate, uint8_t num_channels, uint32_t block_size, const void *buffer, uint32_t length);
bool reset(util::core_file &file);
// decode to a buffer; num_samples must be a multiple of the block size
- bool decode_interleaved(INT16 *samples, UINT32 num_samples, bool swap_endian = false);
- bool decode(INT16 **samples, UINT32 num_samples, bool swap_endian = false);
+ bool decode_interleaved(int16_t *samples, uint32_t num_samples, bool swap_endian = false);
+ bool decode(int16_t **samples, uint32_t num_samples, bool swap_endian = false);
// finish up
- UINT32 finish();
+ uint32_t finish();
private:
// internal helpers
@@ -126,19 +126,19 @@ private:
// output state
FLAC__StreamDecoder * m_decoder; // actual encoder
util::core_file * m_file; // output file
- UINT32 m_sample_rate; // decoded sample rate
- UINT8 m_channels; // decoded number of channels
- UINT8 m_bits_per_sample; // decoded bits per sample
- UINT32 m_compressed_offset; // current offset in compressed data
+ uint32_t m_sample_rate; // decoded sample rate
+ uint8_t m_channels; // decoded number of channels
+ uint8_t m_bits_per_sample; // decoded bits per sample
+ uint32_t m_compressed_offset; // current offset in compressed data
const FLAC__byte * m_compressed_start; // start of compressed data
- UINT32 m_compressed_length; // length of compressed data
+ uint32_t m_compressed_length; // length of compressed data
const FLAC__byte * m_compressed2_start; // start of compressed data
- UINT32 m_compressed2_length; // length of compressed data
- INT16 * m_uncompressed_start[8];// pointer to start of uncompressed data (up to 8 streams)
- UINT32 m_uncompressed_offset; // current position in uncompressed data
- UINT32 m_uncompressed_length; // length of uncompressed data
+ uint32_t m_compressed2_length; // length of compressed data
+ int16_t * m_uncompressed_start[8];// pointer to start of uncompressed data (up to 8 streams)
+ uint32_t m_uncompressed_offset; // current position in uncompressed data
+ uint32_t m_uncompressed_length; // length of uncompressed data
bool m_uncompressed_swap; // swap uncompressed sample data
- UINT8 m_custom_header[0x2a]; // custom header
+ uint8_t m_custom_header[0x2a]; // custom header
};
diff --git a/src/lib/util/harddisk.cpp b/src/lib/util/harddisk.cpp
index 6bb121f36b2..31c6a36ed28 100644
--- a/src/lib/util/harddisk.cpp
+++ b/src/lib/util/harddisk.cpp
@@ -119,7 +119,7 @@ hard_disk_info *hard_disk_get_info(hard_disk_file *file)
-------------------------------------------------*/
/**
- * @fn UINT32 hard_disk_read(hard_disk_file *file, UINT32 lbasector, void *buffer)
+ * @fn uint32_t hard_disk_read(hard_disk_file *file, uint32_t lbasector, void *buffer)
*
* @brief Hard disk read.
*
@@ -127,10 +127,10 @@ hard_disk_info *hard_disk_get_info(hard_disk_file *file)
* @param lbasector The lbasector.
* @param [in,out] buffer If non-null, the buffer.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-UINT32 hard_disk_read(hard_disk_file *file, UINT32 lbasector, void *buffer)
+uint32_t hard_disk_read(hard_disk_file *file, uint32_t lbasector, void *buffer)
{
chd_error err = file->chd->read_units(lbasector, buffer);
return (err == CHDERR_NONE);
@@ -143,7 +143,7 @@ UINT32 hard_disk_read(hard_disk_file *file, UINT32 lbasector, void *buffer)
-------------------------------------------------*/
/**
- * @fn UINT32 hard_disk_write(hard_disk_file *file, UINT32 lbasector, const void *buffer)
+ * @fn uint32_t hard_disk_write(hard_disk_file *file, uint32_t lbasector, const void *buffer)
*
* @brief Hard disk write.
*
@@ -151,10 +151,10 @@ UINT32 hard_disk_read(hard_disk_file *file, UINT32 lbasector, void *buffer)
* @param lbasector The lbasector.
* @param buffer The buffer.
*
- * @return An UINT32.
+ * @return An uint32_t.
*/
-UINT32 hard_disk_write(hard_disk_file *file, UINT32 lbasector, const void *buffer)
+uint32_t hard_disk_write(hard_disk_file *file, uint32_t lbasector, const void *buffer)
{
chd_error err = file->chd->write_units(lbasector, buffer);
return (err == CHDERR_NONE);
diff --git a/src/lib/util/harddisk.h b/src/lib/util/harddisk.h
index 5b32c905d94..727f9a3fd07 100644
--- a/src/lib/util/harddisk.h
+++ b/src/lib/util/harddisk.h
@@ -25,10 +25,10 @@ struct hard_disk_file;
struct hard_disk_info
{
- UINT32 cylinders;
- UINT32 heads;
- UINT32 sectors;
- UINT32 sectorbytes;
+ uint32_t cylinders;
+ uint32_t heads;
+ uint32_t sectors;
+ uint32_t sectorbytes;
};
@@ -43,7 +43,7 @@ void hard_disk_close(hard_disk_file *file);
chd_file *hard_disk_get_chd(hard_disk_file *file);
hard_disk_info *hard_disk_get_info(hard_disk_file *file);
-UINT32 hard_disk_read(hard_disk_file *file, UINT32 lbasector, void *buffer);
-UINT32 hard_disk_write(hard_disk_file *file, UINT32 lbasector, const void *buffer);
+uint32_t hard_disk_read(hard_disk_file *file, uint32_t lbasector, void *buffer);
+uint32_t hard_disk_write(hard_disk_file *file, uint32_t lbasector, const void *buffer);
#endif /* __HARDDISK_H__ */
diff --git a/src/lib/util/hash.cpp b/src/lib/util/hash.cpp
index 9ba632240dc..4593ad181a4 100644
--- a/src/lib/util/hash.cpp
+++ b/src/lib/util/hash.cpp
@@ -362,7 +362,7 @@ void hash_collection::begin(const char *types)
// buffer - add the given buffer to the hash
//-------------------------------------------------
-void hash_collection::buffer(const UINT8 *data, UINT32 length)
+void hash_collection::buffer(const uint8_t *data, uint32_t length)
{
assert(m_creator != nullptr);
diff --git a/src/lib/util/hash.h b/src/lib/util/hash.h
index ec628a949f2..23c8702958e 100644
--- a/src/lib/util/hash.h
+++ b/src/lib/util/hash.h
@@ -75,8 +75,8 @@ public:
bool remove(char type);
// CRC-specific helpers
- bool crc(UINT32 &result) const { result = m_crc32; return m_has_crc32; }
- void add_crc(UINT32 crc) { m_crc32 = crc; m_has_crc32 = true; }
+ bool crc(uint32_t &result) const { result = m_crc32; return m_has_crc32; }
+ void add_crc(uint32_t crc) { m_crc32 = crc; m_has_crc32 = true; }
// SHA1-specific helpers
bool sha1(sha1_t &result) const { result = m_sha1; return m_has_sha1; }
@@ -90,9 +90,9 @@ public:
// creation
void begin(const char *types = nullptr);
- void buffer(const UINT8 *data, UINT32 length);
+ void buffer(const uint8_t *data, uint32_t length);
void end();
- void compute(const UINT8 *data, UINT32 length, const char *types = nullptr) { begin(types); buffer(data, length); end(); }
+ void compute(const uint8_t *data, uint32_t length, const char *types = nullptr) { begin(types); buffer(data, length); end(); }
private:
// internal helpers
diff --git a/src/lib/util/hashing.cpp b/src/lib/util/hashing.cpp
index dd6b9847f15..448cdc5d6ec 100644
--- a/src/lib/util/hashing.cpp
+++ b/src/lib/util/hashing.cpp
@@ -184,7 +184,7 @@ std::string crc32_t::as_string() const
// the currently-accumulated value
//-------------------------------------------------
-void crc32_creator::append(const void *data, UINT32 length)
+void crc32_creator::append(const void *data, uint32_t length)
{
m_accum.m_raw = crc32(m_accum, reinterpret_cast<const Bytef *>(data), length);
}
@@ -236,7 +236,7 @@ std::string crc16_t::as_string() const
}
/**
- * @fn void crc16_creator::append(const void *data, UINT32 length)
+ * @fn void crc16_creator::append(const void *data, uint32_t length)
*
* @brief -------------------------------------------------
* append - hash a block of data, appending to the currently-accumulated value
@@ -246,9 +246,9 @@ std::string crc16_t::as_string() const
* @param length The length.
*/
-void crc16_creator::append(const void *data, UINT32 length)
+void crc16_creator::append(const void *data, uint32_t length)
{
- static const UINT16 s_table[256] =
+ static const uint16_t s_table[256] =
{
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
@@ -284,10 +284,10 @@ void crc16_creator::append(const void *data, UINT32 length)
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
};
- const UINT8 *src = reinterpret_cast<const UINT8 *>(data);
+ const uint8_t *src = reinterpret_cast<const uint8_t *>(data);
// fetch the current value into a local and rip through the source data
- UINT16 crc = m_accum.m_raw;
+ uint16_t crc = m_accum.m_raw;
while (length-- != 0)
crc = (crc << 8) ^ s_table[(crc >> 8) ^ *src++];
m_accum.m_raw = crc;
diff --git a/src/lib/util/hashing.h b/src/lib/util/hashing.h
index 8b58d3afc8b..906bad047b4 100644
--- a/src/lib/util/hashing.h
+++ b/src/lib/util/hashing.h
@@ -33,10 +33,10 @@ struct sha1_t
{
bool operator==(const sha1_t &rhs) const { return memcmp(m_raw, rhs.m_raw, sizeof(m_raw)) == 0; }
bool operator!=(const sha1_t &rhs) const { return memcmp(m_raw, rhs.m_raw, sizeof(m_raw)) != 0; }
- operator UINT8 *() { return m_raw; }
+ operator uint8_t *() { return m_raw; }
bool from_string(const char *string, int length = -1);
std::string as_string() const;
- UINT8 m_raw[20];
+ uint8_t m_raw[20];
static const sha1_t null;
};
@@ -51,7 +51,7 @@ public:
void reset() { sha1_init(&m_context); }
// append data
- void append(const void *data, UINT32 length) { sha1_update(&m_context, length, reinterpret_cast<const UINT8 *>(data)); }
+ void append(const void *data, uint32_t length) { sha1_update(&m_context, length, reinterpret_cast<const uint8_t *>(data)); }
// finalize and compute the final digest
sha1_t finish()
@@ -63,7 +63,7 @@ public:
}
// static wrapper to just get the digest from a block
- static sha1_t simple(const void *data, UINT32 length)
+ static sha1_t simple(const void *data, uint32_t length)
{
sha1_creator creator;
creator.append(data, length);
@@ -84,10 +84,10 @@ struct md5_t
{
bool operator==(const md5_t &rhs) const { return memcmp(m_raw, rhs.m_raw, sizeof(m_raw)) == 0; }
bool operator!=(const md5_t &rhs) const { return memcmp(m_raw, rhs.m_raw, sizeof(m_raw)) != 0; }
- operator UINT8 *() { return m_raw; }
+ operator uint8_t *() { return m_raw; }
bool from_string(const char *string, int length = -1);
std::string as_string() const;
- UINT8 m_raw[16];
+ uint8_t m_raw[16];
static const md5_t null;
};
@@ -102,7 +102,7 @@ public:
void reset() { MD5Init(&m_context); }
// append data
- void append(const void *data, UINT32 length) { MD5Update(&m_context, reinterpret_cast<const unsigned char *>(data), length); }
+ void append(const void *data, uint32_t length) { MD5Update(&m_context, reinterpret_cast<const unsigned char *>(data), length); }
// finalize and compute the final digest
md5_t finish()
@@ -113,7 +113,7 @@ public:
}
// static wrapper to just get the digest from a block
- static md5_t simple(const void *data, UINT32 length)
+ static md5_t simple(const void *data, uint32_t length)
{
md5_creator creator;
creator.append(data, length);
@@ -134,11 +134,11 @@ struct crc32_t
{
bool operator==(const crc32_t &rhs) const { return m_raw == rhs.m_raw; }
bool operator!=(const crc32_t &rhs) const { return m_raw != rhs.m_raw; }
- crc32_t &operator=(const UINT32 crc) { m_raw = crc; return *this; }
- operator UINT32() const { return m_raw; }
+ crc32_t &operator=(const uint32_t crc) { m_raw = crc; return *this; }
+ operator uint32_t() const { return m_raw; }
bool from_string(const char *string, int length = -1);
std::string as_string() const;
- UINT32 m_raw;
+ uint32_t m_raw;
static const crc32_t null;
};
@@ -153,13 +153,13 @@ public:
void reset() { m_accum.m_raw = 0; }
// append data
- void append(const void *data, UINT32 length);
+ void append(const void *data, uint32_t length);
// finalize and compute the final digest
crc32_t finish() { return m_accum; }
// static wrapper to just get the digest from a block
- static crc32_t simple(const void *data, UINT32 length)
+ static crc32_t simple(const void *data, uint32_t length)
{
crc32_creator creator;
creator.append(data, length);
@@ -180,11 +180,11 @@ struct crc16_t
{
bool operator==(const crc16_t &rhs) const { return m_raw == rhs.m_raw; }
bool operator!=(const crc16_t &rhs) const { return m_raw != rhs.m_raw; }
- crc16_t &operator=(const UINT16 crc) { m_raw = crc; return *this; }
- operator UINT16() const { return m_raw; }
+ crc16_t &operator=(const uint16_t crc) { m_raw = crc; return *this; }
+ operator uint16_t() const { return m_raw; }
bool from_string(const char *string, int length = -1);
std::string as_string() const;
- UINT16 m_raw;
+ uint16_t m_raw;
static const crc16_t null;
};
@@ -199,13 +199,13 @@ public:
void reset() { m_accum.m_raw = 0xffff; }
// append data
- void append(const void *data, UINT32 length);
+ void append(const void *data, uint32_t length);
// finalize and compute the final digest
crc16_t finish() { return m_accum; }
// static wrapper to just get the digest from a block
- static crc16_t simple(const void *data, UINT32 length)
+ static crc16_t simple(const void *data, uint32_t length)
{
crc16_creator creator;
creator.append(data, length);
diff --git a/src/lib/util/huffman.cpp b/src/lib/util/huffman.cpp
index c38d78853fb..d3a73315ea9 100644
--- a/src/lib/util/huffman.cpp
+++ b/src/lib/util/huffman.cpp
@@ -121,7 +121,7 @@
// decoding context
//-------------------------------------------------
-huffman_context_base::huffman_context_base(int numcodes, int maxbits, lookup_value *lookup, UINT32 *histo, node_t *nodes)
+huffman_context_base::huffman_context_base(int numcodes, int maxbits, lookup_value *lookup, uint32_t *histo, node_t *nodes)
: m_numcodes(numcodes),
m_maxbits(maxbits),
m_prevdata(0),
@@ -268,8 +268,8 @@ huffman_error huffman_context_base::import_tree_huffman(bitstream_in &bitbuf)
smallhuff.build_lookup_table();
// determine the maximum length of an RLE count
- UINT32 temp = m_numcodes - 9;
- UINT8 rlefullbits = 0;
+ uint32_t temp = m_numcodes - 9;
+ uint8_t rlefullbits = 0;
while (temp != 0)
temp >>= 1, rlefullbits++;
@@ -316,10 +316,10 @@ huffman_error huffman_context_base::import_tree_huffman(bitstream_in &bitbuf)
huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
{
// first RLE compress the lengths of all the nodes
- std::vector<UINT8> rle_data(m_numcodes);
- UINT8 *dest = &rle_data[0];
- std::vector<UINT16> rle_lengths(m_numcodes/3);
- UINT16 *lengths = &rle_lengths[0];
+ std::vector<uint8_t> rle_data(m_numcodes);
+ uint8_t *dest = &rle_data[0];
+ std::vector<uint16_t> rle_lengths(m_numcodes/3);
+ uint16_t *lengths = &rle_lengths[0];
int last = ~0;
int repcount = 0;
@@ -387,17 +387,17 @@ huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
bitbuf.write(7, 3);
// determine the maximum length of an RLE count
- UINT32 temp = m_numcodes - 9;
- UINT8 rlefullbits = 0;
+ uint32_t temp = m_numcodes - 9;
+ uint8_t rlefullbits = 0;
while (temp != 0)
temp >>= 1, rlefullbits++;
// now encode the RLE data
lengths = &rle_lengths[0];
- for (UINT8 *src = &rle_data[0]; src < dest; src++)
+ for (uint8_t *src = &rle_data[0]; src < dest; src++)
{
// encode the data
- UINT8 data = *src;
+ uint8_t data = *src;
smallhuff.encode_one(bitbuf, data);
// if this is an RLE token, encode the length following
@@ -424,17 +424,17 @@ huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
huffman_error huffman_context_base::compute_tree_from_histo()
{
// compute the number of data items in the histogram
- UINT32 sdatacount = 0;
+ uint32_t sdatacount = 0;
for (int i = 0; i < m_numcodes; i++)
sdatacount += m_datahisto[i];
// binary search to achieve the optimum encoding
- UINT32 lowerweight = 0;
- UINT32 upperweight = sdatacount * 2;
+ uint32_t lowerweight = 0;
+ uint32_t upperweight = sdatacount * 2;
while (1)
{
// build a tree using the current weight
- UINT32 curweight = (upperweight + lowerweight) / 2;
+ uint32_t curweight = (upperweight + lowerweight) / 2;
int curmaxbits = build_tree(sdatacount, curweight);
// apply binary search here
@@ -520,7 +520,7 @@ int CLIB_DECL huffman_context_base::tree_node_compare(const void *item1, const v
// data distribution
//-------------------------------------------------
-int huffman_context_base::build_tree(UINT32 totaldata, UINT32 totalweight)
+int huffman_context_base::build_tree(uint32_t totaldata, uint32_t totalweight)
{
// make a list of all non-zero nodes
std::vector<node_t *> list(m_numcodes * 2);
@@ -534,7 +534,7 @@ int huffman_context_base::build_tree(UINT32 totaldata, UINT32 totalweight)
m_huffnode[curcode].m_bits = curcode;
// scale the weight by the current effective length, ensuring we don't go to 0
- m_huffnode[curcode].m_weight = UINT64(m_datahisto[curcode]) * UINT64(totalweight) / UINT64(totaldata);
+ m_huffnode[curcode].m_weight = uint64_t(m_datahisto[curcode]) * uint64_t(totalweight) / uint64_t(totaldata);
if (m_huffnode[curcode].m_weight == 0)
m_huffnode[curcode].m_weight = 1;
}
@@ -613,7 +613,7 @@ int huffman_context_base::build_tree(UINT32 totaldata, UINT32 totalweight)
huffman_error huffman_context_base::assign_canonical_codes()
{
// build up a histogram of bit lengths
- UINT32 bithisto[33] = { 0 };
+ uint32_t bithisto[33] = { 0 };
for (int curcode = 0; curcode < m_numcodes; curcode++)
{
node_t &node = m_huffnode[curcode];
@@ -624,10 +624,10 @@ huffman_error huffman_context_base::assign_canonical_codes()
}
// for each code length, determine the starting code number
- UINT32 curstart = 0;
+ uint32_t curstart = 0;
for (int codelen = 32; codelen > 0; codelen--)
{
- UINT32 nextstart = (curstart + bithisto[codelen]) >> 1;
+ uint32_t nextstart = (curstart + bithisto[codelen]) >> 1;
if (codelen != 1 && nextstart * 2 != (curstart + bithisto[codelen]))
return HUFFERR_INTERNAL_INCONSISTENCY;
bithisto[codelen] = curstart;
@@ -691,11 +691,11 @@ huffman_8bit_encoder::huffman_8bit_encoder()
// encode - encode a full buffer
//-------------------------------------------------
-huffman_error huffman_8bit_encoder::encode(const UINT8 *source, UINT32 slength, UINT8 *dest, UINT32 dlength, UINT32 &complength)
+huffman_error huffman_8bit_encoder::encode(const uint8_t *source, uint32_t slength, uint8_t *dest, uint32_t dlength, uint32_t &complength)
{
// first compute the histogram
histo_reset();
- for (UINT32 cur = 0; cur < slength; cur++)
+ for (uint32_t cur = 0; cur < slength; cur++)
histo_one(source[cur]);
// then compute the tree
@@ -710,7 +710,7 @@ huffman_error huffman_8bit_encoder::encode(const UINT8 *source, UINT32 slength,
return err;
// then encode the data
- for (UINT32 cur = 0; cur < slength; cur++)
+ for (uint32_t cur = 0; cur < slength; cur++)
encode_one(bitbuf, source[cur]);
complength = bitbuf.flush();
return bitbuf.overflow() ? HUFFERR_OUTPUT_BUFFER_TOO_SMALL : HUFFERR_NONE;
@@ -731,7 +731,7 @@ huffman_8bit_decoder::huffman_8bit_decoder()
}
/**
- * @fn huffman_error huffman_8bit_decoder::decode(const UINT8 *source, UINT32 slength, UINT8 *dest, UINT32 dlength)
+ * @fn huffman_error huffman_8bit_decoder::decode(const uint8_t *source, uint32_t slength, uint8_t *dest, uint32_t dlength)
*
* @brief -------------------------------------------------
* decode - decode a full buffer
@@ -745,7 +745,7 @@ huffman_8bit_decoder::huffman_8bit_decoder()
* @return A huffman_error.
*/
-huffman_error huffman_8bit_decoder::decode(const UINT8 *source, UINT32 slength, UINT8 *dest, UINT32 dlength)
+huffman_error huffman_8bit_decoder::decode(const uint8_t *source, uint32_t slength, uint8_t *dest, uint32_t dlength)
{
// first import the tree
bitstream_in bitbuf(source, slength);
@@ -754,7 +754,7 @@ huffman_error huffman_8bit_decoder::decode(const UINT8 *source, UINT32 slength,
return err;
// then decode the data
- for (UINT32 cur = 0; cur < dlength; cur++)
+ for (uint32_t cur = 0; cur < dlength; cur++)
dest[cur] = decode_one(bitbuf);
bitbuf.flush();
return bitbuf.overflow() ? HUFFERR_INPUT_BUFFER_TOO_SMALL : HUFFERR_NONE;
diff --git a/src/lib/util/huffman.h b/src/lib/util/huffman.h
index a2bed42bbf9..2814eb127dd 100644
--- a/src/lib/util/huffman.h
+++ b/src/lib/util/huffman.h
@@ -44,20 +44,20 @@ enum huffman_error
class huffman_context_base
{
protected:
- typedef UINT16 lookup_value;
+ typedef uint16_t lookup_value;
// a node in the huffman tree
struct node_t
{
node_t * m_parent; // pointer to parent node
- UINT32 m_count; // number of hits on this node
- UINT32 m_weight; // assigned weight of this node
- UINT32 m_bits; // bits used to encode the node
- UINT8 m_numbits; // number of bits needed for this node
+ uint32_t m_count; // number of hits on this node
+ uint32_t m_weight; // assigned weight of this node
+ uint32_t m_bits; // bits used to encode the node
+ uint8_t m_numbits; // number of bits needed for this node
};
// construction/destruction
- huffman_context_base(int numcodes, int maxbits, lookup_value *lookup, UINT32 *histo, node_t *nodes);
+ huffman_context_base(int numcodes, int maxbits, lookup_value *lookup, uint32_t *histo, node_t *nodes);
// tree creation
huffman_error compute_tree_from_histo();
@@ -73,18 +73,18 @@ protected:
// internal helpers
void write_rle_tree_bits(bitstream_out &bitbuf, int value, int repcount, int numbits);
static int CLIB_DECL tree_node_compare(const void *item1, const void *item2);
- int build_tree(UINT32 totaldata, UINT32 totalweight);
+ int build_tree(uint32_t totaldata, uint32_t totalweight);
huffman_error assign_canonical_codes();
void build_lookup_table();
protected:
// internal state
- UINT32 m_numcodes; // number of total codes being processed
- UINT8 m_maxbits; // maximum bits per code
- UINT8 m_prevdata; // value of the previous data (for delta-RLE encoding)
+ uint32_t m_numcodes; // number of total codes being processed
+ uint8_t m_maxbits; // maximum bits per code
+ uint8_t m_prevdata; // value of the previous data (for delta-RLE encoding)
int m_rleremaining; // number of RLE bytes remaining (for delta-RLE encoding)
lookup_value * m_lookup; // pointer to the lookup table
- UINT32 * m_datahisto; // histogram of data values
+ uint32_t * m_datahisto; // histogram of data values
node_t * m_huffnode; // array of nodes
};
@@ -102,8 +102,8 @@ public:
// single item operations
void histo_reset() { memset(m_datahisto_array, 0, sizeof(m_datahisto_array)); }
- void histo_one(UINT32 data);
- void encode_one(bitstream_out &bitbuf, UINT32 data);
+ void histo_one(uint32_t data);
+ void encode_one(bitstream_out &bitbuf, uint32_t data);
// expose tree computation and export
using huffman_context_base::compute_tree_from_histo;
@@ -112,7 +112,7 @@ public:
private:
// array versions of the info we need
- UINT32 m_datahisto_array[_NumCodes];
+ uint32_t m_datahisto_array[_NumCodes];
node_t m_huffnode_array[_NumCodes * 2];
};
@@ -129,7 +129,7 @@ public:
: huffman_context_base(_NumCodes, _MaxBits, m_lookup_array, nullptr, m_huffnode_array) { }
// single item operations
- UINT32 decode_one(bitstream_in &bitbuf);
+ uint32_t decode_one(bitstream_in &bitbuf);
// expose tree import
using huffman_context_base::import_tree_rle;
@@ -152,7 +152,7 @@ public:
huffman_8bit_encoder();
// operations
- huffman_error encode(const UINT8 *source, UINT32 slength, UINT8 *dest, UINT32 destlength, UINT32 &complength);
+ huffman_error encode(const uint8_t *source, uint32_t slength, uint8_t *dest, uint32_t destlength, uint32_t &complength);
};
@@ -166,7 +166,7 @@ public:
huffman_8bit_decoder();
// operations
- huffman_error decode(const UINT8 *source, UINT32 slength, UINT8 *dest, UINT32 destlength);
+ huffman_error decode(const uint8_t *source, uint32_t slength, uint8_t *dest, uint32_t destlength);
};
@@ -180,7 +180,7 @@ public:
//-------------------------------------------------
template<int _NumCodes, int _MaxBits>
-inline void huffman_encoder<_NumCodes, _MaxBits>::histo_one(UINT32 data)
+inline void huffman_encoder<_NumCodes, _MaxBits>::histo_one(uint32_t data)
{
m_datahisto[data]++;
}
@@ -192,7 +192,7 @@ inline void huffman_encoder<_NumCodes, _MaxBits>::histo_one(UINT32 data)
//-------------------------------------------------
template<int _NumCodes, int _MaxBits>
-inline void huffman_encoder<_NumCodes, _MaxBits>::encode_one(bitstream_out &bitbuf, UINT32 data)
+inline void huffman_encoder<_NumCodes, _MaxBits>::encode_one(bitstream_out &bitbuf, uint32_t data)
{
// write the data
node_t &node = m_huffnode[data];
@@ -206,10 +206,10 @@ inline void huffman_encoder<_NumCodes, _MaxBits>::encode_one(bitstream_out &bitb
//-------------------------------------------------
template<int _NumCodes, int _MaxBits>
-inline UINT32 huffman_decoder<_NumCodes, _MaxBits>::decode_one(bitstream_in &bitbuf)
+inline uint32_t huffman_decoder<_NumCodes, _MaxBits>::decode_one(bitstream_in &bitbuf)
{
// peek ahead to get maxbits worth of data
- UINT32 bits = bitbuf.peek(m_maxbits);
+ uint32_t bits = bitbuf.peek(m_maxbits);
// look it up, then remove the actual number of bits for this code
lookup_value lookup = m_lookup[bits];
diff --git a/src/lib/util/jedparse.cpp b/src/lib/util/jedparse.cpp
index 9bed1164303..c2c9a139a6a 100644
--- a/src/lib/util/jedparse.cpp
+++ b/src/lib/util/jedparse.cpp
@@ -38,8 +38,8 @@
struct jed_parse_info
{
- UINT16 checksum; /* checksum value */
- UINT32 explicit_numfuses; /* explicitly specified number of fuses */
+ uint16_t checksum; /* checksum value */
+ uint32_t explicit_numfuses; /* explicitly specified number of fuses */
};
@@ -86,10 +86,10 @@ static int isdelim(char c)
character stream
-------------------------------------------------*/
-static UINT32 suck_number(const UINT8 **psrc)
+static uint32_t suck_number(const uint8_t **psrc)
{
- const UINT8 *src = *psrc;
- UINT32 value = 0;
+ const uint8_t *src = *psrc;
+ uint32_t value = 0;
/* skip delimiters */
while (isdelim(*src))
@@ -117,7 +117,7 @@ static UINT32 suck_number(const UINT8 **psrc)
process_field - process a single JEDEC field
-------------------------------------------------*/
-static void process_field(jed_data *data, const UINT8 *cursrc, const UINT8 *srcend, jed_parse_info *pinfo)
+static void process_field(jed_data *data, const uint8_t *cursrc, const uint8_t *srcend, jed_parse_info *pinfo)
{
/* switch off of the field type */
switch (*cursrc)
@@ -147,7 +147,7 @@ static void process_field(jed_data *data, const UINT8 *cursrc, const UINT8 *srce
/* fuse states */
case 'L':
{
- UINT32 curfuse;
+ uint32_t curfuse;
/* read the fuse number */
cursrc++;
@@ -189,11 +189,11 @@ static void process_field(jed_data *data, const UINT8 *cursrc, const UINT8 *srce
int jed_parse(const void *data, size_t length, jed_data *result)
{
- const UINT8 *cursrc = (const UINT8 *)data;
- const UINT8 *srcend = cursrc + length;
- const UINT8 *scan;
+ const uint8_t *cursrc = (const uint8_t *)data;
+ const uint8_t *srcend = cursrc + length;
+ const uint8_t *scan;
jed_parse_info pinfo;
- UINT16 checksum;
+ uint16_t checksum;
int i;
/* initialize the output and the intermediate info struct */
@@ -218,7 +218,7 @@ int jed_parse(const void *data, size_t length, jed_data *result)
checksum += *scan;
if (scan + 4 < srcend && ishex(scan[1]) && ishex(scan[2]) && ishex(scan[3]) && ishex(scan[4]))
{
- UINT16 dessum = (hexval(scan[1]) << 12) | (hexval(scan[2]) << 8) | (hexval(scan[3]) << 4) | hexval(scan[4] << 0);
+ uint16_t dessum = (hexval(scan[1]) << 12) | (hexval(scan[2]) << 8) | (hexval(scan[3]) << 4) | hexval(scan[4] << 0);
if (dessum != 0 && dessum != checksum)
return JEDERR_BAD_XMIT_SUM;
}
@@ -283,13 +283,13 @@ int jed_parse(const void *data, size_t length, jed_data *result)
size_t jed_output(const jed_data *data, void *result, size_t length)
{
- UINT8 *curdst = (UINT8 *)result;
- UINT8 *dstend = curdst + length;
+ uint8_t *curdst = (uint8_t *)result;
+ uint8_t *dstend = curdst + length;
int i, zeros, ones;
char tempbuf[256];
- UINT16 checksum;
- UINT8 defbyte;
- UINT8 *temp;
+ uint16_t checksum;
+ uint8_t defbyte;
+ uint8_t *temp;
/* always start the DST with a standard header and an STX */
tempbuf[0] = 0x02;
@@ -355,7 +355,7 @@ size_t jed_output(const jed_data *data, void *result, size_t length)
/* now compute the transmission checksum */
checksum = 0;
- for (temp = (UINT8 *)result; temp < curdst && temp < dstend; temp++)
+ for (temp = (uint8_t *)result; temp < curdst && temp < dstend; temp++)
checksum += *temp & 0x7f;
checksum += 0x03;
@@ -367,7 +367,7 @@ size_t jed_output(const jed_data *data, void *result, size_t length)
curdst += strlen(tempbuf);
/* return the final size */
- return curdst - (UINT8 *)result;
+ return curdst - (uint8_t *)result;
}
@@ -379,7 +379,7 @@ size_t jed_output(const jed_data *data, void *result, size_t length)
int jedbin_parse(const void *data, size_t length, jed_data *result)
{
- const UINT8 *cursrc = (const UINT8 *)data;
+ const uint8_t *cursrc = (const uint8_t *)data;
/* initialize the output */
memset(result, 0, sizeof(*result));
@@ -424,7 +424,7 @@ int jedbin_parse(const void *data, size_t length, jed_data *result)
size_t jedbin_output(const jed_data *data, void *result, size_t length)
{
- UINT8 *curdst = (UINT8 *)result;
+ uint8_t *curdst = (uint8_t *)result;
/* ensure we have enough room */
if (length >= 4 + (data->numfuses + 7) / 8)
diff --git a/src/lib/util/jedparse.h b/src/lib/util/jedparse.h
index 0f23462b995..e2eca46b236 100644
--- a/src/lib/util/jedparse.h
+++ b/src/lib/util/jedparse.h
@@ -35,8 +35,8 @@
struct jed_data
{
- UINT32 numfuses; /* number of defined fuses */
- UINT8 fusemap[JED_MAX_FUSES / 8];/* array of bit-packed data */
+ uint32_t numfuses; /* number of defined fuses */
+ uint8_t fusemap[JED_MAX_FUSES / 8];/* array of bit-packed data */
};
@@ -63,7 +63,7 @@ size_t jedbin_output(const jed_data *data, void *result, size_t length);
INLINE FUNCTIONS
***************************************************************************/
-static inline int jed_get_fuse(const jed_data *data, UINT32 fusenum)
+static inline int jed_get_fuse(const jed_data *data, uint32_t fusenum)
{
if (fusenum < JED_MAX_FUSES)
return (data->fusemap[fusenum / 8] >> (fusenum % 8)) & 1;
@@ -72,7 +72,7 @@ static inline int jed_get_fuse(const jed_data *data, UINT32 fusenum)
}
-static inline void jed_set_fuse(jed_data *data, UINT32 fusenum, UINT8 value)
+static inline void jed_set_fuse(jed_data *data, uint32_t fusenum, uint8_t value)
{
if (fusenum < JED_MAX_FUSES)
{
diff --git a/src/lib/util/options.cpp b/src/lib/util/options.cpp
index f799ad06c97..7e40ab736de 100644
--- a/src/lib/util/options.cpp
+++ b/src/lib/util/options.cpp
@@ -53,7 +53,7 @@ const char *const core_options::s_option_unadorned[MAX_UNADORNED_OPTIONS] =
// entry - constructor
//-------------------------------------------------
-core_options::entry::entry(const char *name, const char *description, UINT32 flags, const char *defvalue)
+core_options::entry::entry(const char *name, const char *description, uint32_t flags, const char *defvalue)
: m_next(nullptr),
m_flags(flags),
m_seqid(0),
@@ -139,7 +139,7 @@ void core_options::entry::set_description(const char *description)
}
-void core_options::entry::set_flag(UINT32 mask, UINT32 flag)
+void core_options::entry::set_flag(uint32_t mask, uint32_t flag)
{
m_flags = ( m_flags & mask ) | flag;
}
@@ -254,7 +254,7 @@ bool core_options::operator!=(const core_options &rhs)
// options set
//-------------------------------------------------
-void core_options::add_entry(const char *name, const char *description, UINT32 flags, const char *defvalue, bool override_existing)
+void core_options::add_entry(const char *name, const char *description, uint32_t flags, const char *defvalue, bool override_existing)
{
// allocate a new entry
auto newentry = global_alloc(entry(name, description, flags, defvalue));
@@ -410,7 +410,7 @@ bool core_options::parse_ini_file(util::core_file &inifile, int priority, int ig
// find the extent of the name
char *optionname;
for (optionname = buffer; *optionname != 0; optionname++)
- if (!isspace((UINT8)*optionname))
+ if (!isspace((uint8_t)*optionname))
break;
// skip comments
@@ -420,7 +420,7 @@ bool core_options::parse_ini_file(util::core_file &inifile, int priority, int ig
// scan forward to find the first space
char *temp;
for (temp = optionname; *temp != 0; temp++)
- if (isspace((UINT8)*temp))
+ if (isspace((uint8_t)*temp))
break;
// if we hit the end early, print a warning and continue
@@ -601,7 +601,7 @@ int core_options::priority(const char *name) const
// seqid - return the seqid for a given option
//-------------------------------------------------
-UINT32 core_options::seqid(const char *name) const
+uint32_t core_options::seqid(const char *name) const
{
auto curentry = m_entrymap.find(name);
return (curentry != m_entrymap.end()) ? curentry->second->seqid() : 0;
@@ -655,7 +655,7 @@ bool core_options::set_value(const char *name, float value, int priority, std::s
}
-void core_options::set_flag(const char *name, UINT32 mask, UINT32 flag)
+void core_options::set_flag(const char *name, uint32_t mask, uint32_t flag)
{
// find the entry first
auto curentry = m_entrymap.find(name);
diff --git a/src/lib/util/options.h b/src/lib/util/options.h
index d25a29ef1db..c99b99d3f5b 100644
--- a/src/lib/util/options.h
+++ b/src/lib/util/options.h
@@ -21,7 +21,7 @@
//**************************************************************************
// option types
-const UINT32 OPTION_TYPE_MASK = 0x0007; // up to 8 different types
+const uint32_t OPTION_TYPE_MASK = 0x0007; // up to 8 different types
enum
{
OPTION_INVALID, // invalid
@@ -40,7 +40,7 @@ const int OPTION_PRIORITY_NORMAL = 100; // normal priority
const int OPTION_PRIORITY_HIGH = 150; // high priority
const int OPTION_PRIORITY_MAXIMUM = 255; // maximum priority
-const UINT32 OPTION_FLAG_INTERNAL = 0x40000000;
+const uint32_t OPTION_FLAG_INTERNAL = 0x40000000;
//**************************************************************************
@@ -52,7 +52,7 @@ struct options_entry
{
const char * name; // name on the command line
const char * defvalue; // default value of this argument
- UINT32 flags; // flags to describe the option
+ uint32_t flags; // flags to describe the option
const char * description; // description for -showusage
};
@@ -70,7 +70,7 @@ public:
friend class simple_list<entry>;
// construction/destruction
- entry(const char *name, const char *description, UINT32 flags = 0, const char *defvalue = nullptr);
+ entry(const char *name, const char *description, uint32_t flags = 0, const char *defvalue = nullptr);
public:
// getters
@@ -81,9 +81,9 @@ public:
const char *default_value() const { return m_defdata.c_str(); }
const char *minimum() const { return m_minimum.c_str(); }
const char *maximum() const { return m_maximum.c_str(); }
- UINT32 seqid() const { return m_seqid; }
+ uint32_t seqid() const { return m_seqid; }
int type() const { return (m_flags & OPTION_TYPE_MASK); }
- UINT32 flags() const { return m_flags; }
+ uint32_t flags() const { return m_flags; }
bool is_header() const { return type() == OPTION_HEADER; }
bool is_command() const { return type() == OPTION_COMMAND; }
bool is_internal() const { return (m_flags & OPTION_FLAG_INTERNAL)!=0; }
@@ -95,15 +95,15 @@ public:
void set_value(const char *newvalue, int priority);
void set_default_value(const char *defvalue);
void set_description(const char *description);
- void set_flag(UINT32 mask, UINT32 flag);
+ void set_flag(uint32_t mask, uint32_t flag);
void mark_changed() { m_changed = true; }
void revert(int priority_hi, int priority_lo);
private:
// internal state
entry * m_next; // link to the next data
- UINT32 m_flags; // flags from the entry
- UINT32 m_seqid; // sequence ID; bumped on each change
+ uint32_t m_flags; // flags from the entry
+ uint32_t m_seqid; // sequence ID; bumped on each change
bool m_error_reported; // have we reported an error on this option yet?
int m_priority; // priority of the data set
const char * m_description; // description for this item
@@ -139,7 +139,7 @@ public:
auto_iterator end() const { return m_entrylist.end(); }
// configuration
- void add_entry(const char *name, const char *description, UINT32 flags = 0, const char *defvalue = nullptr, bool override_existing = false);
+ void add_entry(const char *name, const char *description, uint32_t flags = 0, const char *defvalue = nullptr, bool override_existing = false);
void add_entry(const options_entry &data, bool override_existing = false) { add_entry(data.name, data.description, data.flags, data.defvalue, override_existing); }
void add_entries(const options_entry *entrylist, bool override_existing = false);
void set_default_value(const char *name, const char *defvalue);
@@ -164,7 +164,7 @@ public:
bool bool_value(const char *name) const { return (atoi(value(name)) != 0); }
int int_value(const char *name) const { return atoi(value(name)); }
float float_value(const char *name) const { return atof(value(name)); }
- UINT32 seqid(const char *name) const;
+ uint32_t seqid(const char *name) const;
bool exists(const char *name) const;
bool is_changed(const char *name) const;
@@ -172,7 +172,7 @@ public:
bool set_value(const char *name, const char *value, int priority, std::string &error_string);
bool set_value(const char *name, int value, int priority, std::string &error_string);
bool set_value(const char *name, float value, int priority, std::string &error_string);
- void set_flag(const char *name, UINT32 mask, UINT32 flags);
+ void set_flag(const char *name, uint32_t mask, uint32_t flags);
void mark_changed(const char *name);
// misc
diff --git a/src/lib/util/palette.cpp b/src/lib/util/palette.cpp
index 196031d3694..c6a9e07d9d6 100644
--- a/src/lib/util/palette.cpp
+++ b/src/lib/util/palette.cpp
@@ -38,7 +38,7 @@ const rgb_t rgb_t::amber(247, 170, 0);
// entry for brightness
//-------------------------------------------------
-inline rgb_t palette_t::adjust_palette_entry(rgb_t entry, float brightness, float contrast, const UINT8 *gamma_map)
+inline rgb_t palette_t::adjust_palette_entry(rgb_t entry, float brightness, float contrast, const uint8_t *gamma_map)
{
int r = rgb_t::clamp(float(gamma_map[entry.r()]) * contrast + brightness);
int g = rgb_t::clamp(float(gamma_map[entry.g()]) * contrast + brightness);
@@ -69,7 +69,7 @@ palette_client::dirty_state::dirty_state()
// min/max values
//-------------------------------------------------
-const UINT32 *palette_client::dirty_state::dirty_list(UINT32 &mindirty, UINT32 &maxdirty)
+const uint32_t *palette_client::dirty_state::dirty_list(uint32_t &mindirty, uint32_t &maxdirty)
{
// fill in the mindirty/maxdirty
mindirty = m_mindirty;
@@ -85,10 +85,10 @@ const UINT32 *palette_client::dirty_state::dirty_list(UINT32 &mindirty, UINT32 &
// dirty
//-------------------------------------------------
-void palette_client::dirty_state::resize(UINT32 colors)
+void palette_client::dirty_state::resize(uint32_t colors)
{
// resize to the correct number of dwords and mark all entries dirty
- UINT32 dirty_dwords = (colors + 31) / 32;
+ uint32_t dirty_dwords = (colors + 31) / 32;
m_dirty.resize(dirty_dwords);
memset(&m_dirty[0], 0xff, dirty_dwords*4);
@@ -105,7 +105,7 @@ void palette_client::dirty_state::resize(UINT32 colors)
// mark_dirty - mark a single entry dirty
//-------------------------------------------------
-void palette_client::dirty_state::mark_dirty(UINT32 index)
+void palette_client::dirty_state::mark_dirty(uint32_t index)
{
m_dirty[index / 32] |= 1 << (index % 32);
m_mindirty = std::min(m_mindirty, index);
@@ -121,7 +121,7 @@ void palette_client::dirty_state::mark_dirty(UINT32 index)
void palette_client::dirty_state::reset()
{
// erase relevant entries in the new live one
- memset(&m_dirty[m_mindirty / 32], 0, ((m_maxdirty / 32) + 1 - (m_mindirty / 32)) * sizeof(UINT32));
+ memset(&m_dirty[m_mindirty / 32], 0, ((m_maxdirty / 32) + 1 - (m_mindirty / 32)) * sizeof(uint32_t));
m_mindirty = m_dirty.size() * 32 - 1;
m_maxdirty = 0;
}
@@ -146,7 +146,7 @@ palette_client::palette_client(palette_t &palette)
palette.ref();
// resize the dirty lists
- UINT32 total_colors = palette.num_colors() * palette.num_groups();
+ uint32_t total_colors = palette.num_colors() * palette.num_groups();
m_dirty[0].resize(total_colors);
m_dirty[1].resize(total_colors);
@@ -180,10 +180,10 @@ palette_client::~palette_client()
// list for a client
//-------------------------------------------------
-const UINT32 *palette_client::dirty_list(UINT32 &mindirty, UINT32 &maxdirty)
+const uint32_t *palette_client::dirty_list(uint32_t &mindirty, uint32_t &maxdirty)
{
// if nothing to report, report nothing and don't swap
- const UINT32 *result = m_live->dirty_list(mindirty, maxdirty);
+ const uint32_t *result = m_live->dirty_list(mindirty, maxdirty);
if (result == nullptr)
return nullptr;
@@ -207,7 +207,7 @@ const UINT32 *palette_client::dirty_list(UINT32 &mindirty, UINT32 &maxdirty)
// alloc - static allocator
//-------------------------------------------------
-palette_t *palette_t::alloc(UINT32 numcolors, UINT32 numgroups)
+palette_t *palette_t::alloc(uint32_t numcolors, uint32_t numgroups)
{
return new palette_t(numcolors, numgroups);
}
@@ -217,7 +217,7 @@ palette_t *palette_t::alloc(UINT32 numcolors, UINT32 numgroups)
// palette_t - constructor
//-------------------------------------------------
-palette_t::palette_t(UINT32 numcolors, UINT32 numgroups)
+palette_t::palette_t(uint32_t numcolors, uint32_t numgroups)
: m_refcount(1),
m_numcolors(numcolors),
m_numgroups(numgroups),
@@ -233,25 +233,25 @@ palette_t::palette_t(UINT32 numcolors, UINT32 numgroups)
m_client_list(nullptr)
{
// initialize gamma map
- for (UINT32 index = 0; index < 256; index++)
+ for (uint32_t index = 0; index < 256; index++)
m_gamma_map[index] = index;
// initialize the per-entry data
- for (UINT32 index = 0; index < numcolors; index++)
+ for (uint32_t index = 0; index < numcolors; index++)
{
m_entry_color[index] = rgb_t::black;
m_entry_contrast[index] = 1.0f;
}
// initialize the per-group data
- for (UINT32 index = 0; index < numgroups; index++)
+ for (uint32_t index = 0; index < numgroups; index++)
{
m_group_bright[index] = 0.0f;
m_group_contrast[index] = 1.0f;
}
// initialize the expanded data
- for (UINT32 index = 0; index < numcolors * numgroups; index++)
+ for (uint32_t index = 0; index < numcolors * numgroups; index++)
{
m_adjusted_color[index] = rgb_t::black;
m_adjusted_rgb15[index] = rgb_t::black.as_rgb15();
@@ -359,7 +359,7 @@ void palette_t::set_gamma(float gamma)
// given palette index
//-------------------------------------------------
-void palette_t::entry_set_color(UINT32 index, rgb_t rgb)
+void palette_t::entry_set_color(uint32_t index, rgb_t rgb)
{
// if out of range, or unchanged, ignore
if (index >= m_numcolors || m_entry_color[index] == rgb)
@@ -379,7 +379,7 @@ void palette_t::entry_set_color(UINT32 index, rgb_t rgb)
// given palette index
//-------------------------------------------------
-void palette_t::entry_set_red_level(UINT32 index, UINT8 level)
+void palette_t::entry_set_red_level(uint32_t index, uint8_t level)
{
// if out of range, or unchanged, ignore
if (index >= m_numcolors || m_entry_color[index].r() == level)
@@ -399,7 +399,7 @@ void palette_t::entry_set_red_level(UINT32 index, UINT8 level)
// given palette index
//-------------------------------------------------
-void palette_t::entry_set_green_level(UINT32 index, UINT8 level)
+void palette_t::entry_set_green_level(uint32_t index, uint8_t level)
{
// if out of range, or unchanged, ignore
if (index >= m_numcolors || m_entry_color[index].g() == level)
@@ -419,7 +419,7 @@ void palette_t::entry_set_green_level(UINT32 index, UINT8 level)
// given palette index
//-------------------------------------------------
-void palette_t::entry_set_blue_level(UINT32 index, UINT8 level)
+void palette_t::entry_set_blue_level(uint32_t index, uint8_t level)
{
// if out of range, or unchanged, ignore
if (index >= m_numcolors || m_entry_color[index].b() == level)
@@ -439,7 +439,7 @@ void palette_t::entry_set_blue_level(UINT32 index, UINT8 level)
// adjustment for a single palette index
//-------------------------------------------------
-void palette_t::entry_set_contrast(UINT32 index, float contrast)
+void palette_t::entry_set_contrast(uint32_t index, float contrast)
{
// if out of range, or unchanged, ignore
if (index >= m_numcolors || m_entry_contrast[index] == contrast)
@@ -459,7 +459,7 @@ void palette_t::entry_set_contrast(UINT32 index, float contrast)
// brightness for a palette group
//-------------------------------------------------
-void palette_t::group_set_brightness(UINT32 group, float brightness)
+void palette_t::group_set_brightness(uint32_t group, float brightness)
{
// convert incoming value to normalized result
brightness = (brightness - 1.0f) * 256.0f;
@@ -482,7 +482,7 @@ void palette_t::group_set_brightness(UINT32 group, float brightness)
// contrast for a palette group
//-------------------------------------------------
-void palette_t::group_set_contrast(UINT32 group, float contrast)
+void palette_t::group_set_contrast(uint32_t group, float contrast)
{
// if out of range, or unchanged, ignore
if (group >= m_numgroups || m_group_contrast[group] == contrast)
@@ -502,43 +502,43 @@ void palette_t::group_set_contrast(UINT32 group, float contrast)
// entries
//-------------------------------------------------
-void palette_t::normalize_range(UINT32 start, UINT32 end, int lum_min, int lum_max)
+void palette_t::normalize_range(uint32_t start, uint32_t end, int lum_min, int lum_max)
{
// clamp within range
start = std::max(start, 0U);
end = std::min(end, m_numcolors - 1);
// find the minimum and maximum brightness of all the colors in the range
- INT32 ymin = 1000 * 255, ymax = 0;
- for (UINT32 index = start; index <= end; index++)
+ int32_t ymin = 1000 * 255, ymax = 0;
+ for (uint32_t index = start; index <= end; index++)
{
rgb_t rgb = m_entry_color[index];
- UINT32 y = 299 * rgb.r() + 587 * rgb.g() + 114 * rgb.b();
- ymin = (std::min<UINT32>)(ymin, y);
- ymax = (std::max<UINT32>)(ymax, y);
+ uint32_t y = 299 * rgb.r() + 587 * rgb.g() + 114 * rgb.b();
+ ymin = (std::min<uint32_t>)(ymin, y);
+ ymax = (std::max<uint32_t>)(ymax, y);
}
// determine target minimum/maximum
- INT32 tmin = (lum_min < 0) ? ((ymin + 500) / 1000) : lum_min;
- INT32 tmax = (lum_max < 0) ? ((ymax + 500) / 1000) : lum_max;
+ int32_t tmin = (lum_min < 0) ? ((ymin + 500) / 1000) : lum_min;
+ int32_t tmax = (lum_max < 0) ? ((ymax + 500) / 1000) : lum_max;
// now normalize the palette
- for (UINT32 index = start; index <= end; index++)
+ for (uint32_t index = start; index <= end; index++)
{
rgb_t rgb = m_entry_color[index];
- INT32 y = 299 * rgb.r() + 587 * rgb.g() + 114 * rgb.b();
- INT32 u = ((INT32)rgb.b()-y /1000)*492 / 1000;
- INT32 v = ((INT32)rgb.r()-y / 1000)*877 / 1000;
- INT32 target = tmin + ((y - ymin) * (tmax - tmin + 1)) / (ymax - ymin);
- UINT8 r = rgb_t::clamp(target + 1140 * v / 1000);
- UINT8 g = rgb_t::clamp(target - 395 * u / 1000 - 581 * v / 1000);
- UINT8 b = rgb_t::clamp(target + 2032 * u / 1000);
+ int32_t y = 299 * rgb.r() + 587 * rgb.g() + 114 * rgb.b();
+ int32_t u = ((int32_t)rgb.b()-y /1000)*492 / 1000;
+ int32_t v = ((int32_t)rgb.r()-y / 1000)*877 / 1000;
+ int32_t target = tmin + ((y - ymin) * (tmax - tmin + 1)) / (ymax - ymin);
+ uint8_t r = rgb_t::clamp(target + 1140 * v / 1000);
+ uint8_t g = rgb_t::clamp(target - 395 * u / 1000 - 581 * v / 1000);
+ uint8_t b = rgb_t::clamp(target + 2032 * u / 1000);
entry_set_color(index, rgb_t(r, g, b));
}
}
/**
- * @fn void palette_t::update_adjusted_color(UINT32 group, UINT32 index)
+ * @fn void palette_t::update_adjusted_color(uint32_t group, uint32_t index)
*
* @brief -------------------------------------------------
* update_adjusted_color - update a color index by group and index pair
@@ -548,7 +548,7 @@ void palette_t::normalize_range(UINT32 start, UINT32 end, int lum_min, int lum_m
* @param index Zero-based index of the.
*/
-void palette_t::update_adjusted_color(UINT32 group, UINT32 index)
+void palette_t::update_adjusted_color(uint32_t group, uint32_t index)
{
// compute the adjusted value
rgb_t adjusted = adjust_palette_entry(m_entry_color[index],
@@ -557,7 +557,7 @@ void palette_t::update_adjusted_color(UINT32 group, UINT32 index)
m_gamma_map);
// if not different, ignore
- UINT32 finalindex = group * m_numcolors + index;
+ uint32_t finalindex = group * m_numcolors + index;
if (m_adjusted_color[finalindex] == adjusted)
return;
diff --git a/src/lib/util/palette.h b/src/lib/util/palette.h
index a7054a93501..bfc591d7b2a 100644
--- a/src/lib/util/palette.h
+++ b/src/lib/util/palette.h
@@ -25,7 +25,7 @@
class palette_t;
// an rgb15_t is a single combined 15-bit R,G,B value
-typedef UINT16 rgb15_t;
+typedef uint16_t rgb15_t;
// ======================> rgb_t
@@ -36,33 +36,33 @@ class rgb_t
public:
// construction/destruction
rgb_t(): m_data(0) { }
- rgb_t(UINT32 data) { m_data = data; }
- rgb_t(UINT8 r, UINT8 g, UINT8 b) { m_data = (255 << 24) | (r << 16) | (g << 8) | b; }
- rgb_t(UINT8 a, UINT8 r, UINT8 g, UINT8 b) { m_data = (a << 24) | (r << 16) | (g << 8) | b; }
+ rgb_t(uint32_t data) { m_data = data; }
+ rgb_t(uint8_t r, uint8_t g, uint8_t b) { m_data = (255 << 24) | (r << 16) | (g << 8) | b; }
+ rgb_t(uint8_t a, uint8_t r, uint8_t g, uint8_t b) { m_data = (a << 24) | (r << 16) | (g << 8) | b; }
// getters
- UINT8 a() const { return m_data >> 24; }
- UINT8 r() const { return m_data >> 16; }
- UINT8 g() const { return m_data >> 8; }
- UINT8 b() const { return m_data >> 0; }
+ uint8_t a() const { return m_data >> 24; }
+ uint8_t r() const { return m_data >> 16; }
+ uint8_t g() const { return m_data >> 8; }
+ uint8_t b() const { return m_data >> 0; }
rgb15_t as_rgb15() const { return ((r() >> 3) << 10) | ((g() >> 3) << 5) | ((b() >> 3) << 0); }
- UINT8 brightness() const { return (r() * 222 + g() * 707 + b() * 71) / 1000; }
- UINT32 const *ptr() const { return &m_data; }
+ uint8_t brightness() const { return (r() * 222 + g() * 707 + b() * 71) / 1000; }
+ uint32_t const *ptr() const { return &m_data; }
// setters
- rgb_t &set_a(UINT8 a) { m_data &= ~0xff000000; m_data |= a << 24; return *this; }
- rgb_t &set_r(UINT8 r) { m_data &= ~0x00ff0000; m_data |= r << 16; return *this; }
- rgb_t &set_g(UINT8 g) { m_data &= ~0x0000ff00; m_data |= g << 8; return *this; }
- rgb_t &set_b(UINT8 b) { m_data &= ~0x000000ff; m_data |= b << 0; return *this; }
+ rgb_t &set_a(uint8_t a) { m_data &= ~0xff000000; m_data |= a << 24; return *this; }
+ rgb_t &set_r(uint8_t r) { m_data &= ~0x00ff0000; m_data |= r << 16; return *this; }
+ rgb_t &set_g(uint8_t g) { m_data &= ~0x0000ff00; m_data |= g << 8; return *this; }
+ rgb_t &set_b(uint8_t b) { m_data &= ~0x000000ff; m_data |= b << 0; return *this; }
// implicit conversion operators
- operator UINT32() const { return m_data; }
+ operator uint32_t() const { return m_data; }
// operations
- rgb_t &scale8(UINT8 scale) { m_data = rgb_t(clamphi((a() * scale) >> 8), clamphi((r() * scale) >> 8), clamphi((g() * scale) >> 8), clamphi((b() * scale) >> 8)); return *this; }
+ rgb_t &scale8(uint8_t scale) { m_data = rgb_t(clamphi((a() * scale) >> 8), clamphi((r() * scale) >> 8), clamphi((g() * scale) >> 8), clamphi((b() * scale) >> 8)); return *this; }
// assignment operators
- rgb_t &operator=(UINT32 rhs) { m_data = rhs; return *this; }
+ rgb_t &operator=(uint32_t rhs) { m_data = rhs; return *this; }
rgb_t &operator+=(const rgb_t &rhs) { m_data = rgb_t(clamphi(a() + rhs.a()), clamphi(r() + rhs.r()), clamphi(g() + rhs.g()), clamphi(b() + rhs.b())); return *this; }
rgb_t &operator-=(const rgb_t &rhs) { m_data = rgb_t(clamplo(a() - rhs.a()), clamplo(r() - rhs.r()), clamplo(g() - rhs.g()), clamplo(b() - rhs.b())); return *this; }
@@ -71,9 +71,9 @@ public:
rgb_t operator-(const rgb_t &rhs) const { rgb_t result = *this; result -= rhs; return result; }
// static helpers
- static UINT8 clamp(INT32 value) { return (value < 0) ? 0 : (value > 255) ? 255 : value; }
- static UINT8 clamphi(INT32 value) { return (value > 255) ? 255 : value; }
- static UINT8 clamplo(INT32 value) { return (value < 0) ? 0 : value; }
+ static uint8_t clamp(int32_t value) { return (value < 0) ? 0 : (value > 255) ? 255 : value; }
+ static uint8_t clamphi(int32_t value) { return (value > 255) ? 255 : value; }
+ static uint8_t clamplo(int32_t value) { return (value < 0) ? 0 : value; }
// constants
static const rgb_t black;
@@ -83,7 +83,7 @@ public:
static const rgb_t transparent;
private:
- UINT32 m_data;
+ uint32_t m_data;
};
@@ -100,10 +100,10 @@ public:
// getters
palette_client *next() const { return m_next; }
palette_t &palette() const { return m_palette; }
- const UINT32 *dirty_list(UINT32 &mindirty, UINT32 &maxdirty);
+ const uint32_t *dirty_list(uint32_t &mindirty, uint32_t &maxdirty);
// dirty marking
- void mark_dirty(UINT32 index) { m_live->mark_dirty(index); }
+ void mark_dirty(uint32_t index) { m_live->mark_dirty(index); }
private:
// internal object to track dirty states
@@ -114,16 +114,16 @@ private:
dirty_state();
// operations
- const UINT32 *dirty_list(UINT32 &mindirty, UINT32 &maxdirty);
- void resize(UINT32 colors);
- void mark_dirty(UINT32 index);
+ const uint32_t *dirty_list(uint32_t &mindirty, uint32_t &maxdirty);
+ void resize(uint32_t colors);
+ void mark_dirty(uint32_t index);
void reset();
private:
// internal state
- std::vector<UINT32> m_dirty; // bitmap of dirty entries
- UINT32 m_mindirty; // minimum dirty entry
- UINT32 m_maxdirty; // minimum dirty entry
+ std::vector<uint32_t> m_dirty; // bitmap of dirty entries
+ uint32_t m_mindirty; // minimum dirty entry
+ uint32_t m_maxdirty; // minimum dirty entry
};
// internal state
@@ -144,7 +144,7 @@ class palette_t
public:
// static constructor: used to ensure same new/delete is used
- static palette_t *alloc(UINT32 numcolors, UINT32 numgroups = 1);
+ static palette_t *alloc(uint32_t numcolors, uint32_t numgroups = 1);
// reference counting
void ref() { m_refcount++; }
@@ -154,8 +154,8 @@ public:
int num_colors() const { return m_numcolors; }
int num_groups() const { return m_numgroups; }
int max_index() const { return m_numcolors * m_numgroups + 2; }
- UINT32 black_entry() const { return m_numcolors * m_numgroups + 0; }
- UINT32 white_entry() const { return m_numcolors * m_numgroups + 1; }
+ uint32_t black_entry() const { return m_numcolors * m_numgroups + 0; }
+ uint32_t white_entry() const { return m_numcolors * m_numgroups + 1; }
// overall adjustments
void set_brightness(float brightness);
@@ -163,16 +163,16 @@ public:
void set_gamma(float gamma);
// entry getters
- rgb_t entry_color(UINT32 index) const { return (index < m_numcolors) ? m_entry_color[index] : rgb_t::black; }
- rgb_t entry_adjusted_color(UINT32 index) const { return (index < m_numcolors * m_numgroups) ? m_adjusted_color[index] : rgb_t::black; }
- float entry_contrast(UINT32 index) const { return (index < m_numcolors) ? m_entry_contrast[index] : 1.0f; }
+ rgb_t entry_color(uint32_t index) const { return (index < m_numcolors) ? m_entry_color[index] : rgb_t::black; }
+ rgb_t entry_adjusted_color(uint32_t index) const { return (index < m_numcolors * m_numgroups) ? m_adjusted_color[index] : rgb_t::black; }
+ float entry_contrast(uint32_t index) const { return (index < m_numcolors) ? m_entry_contrast[index] : 1.0f; }
// entry setters
- void entry_set_color(UINT32 index, rgb_t rgb);
- void entry_set_red_level(UINT32 index, UINT8 level);
- void entry_set_green_level(UINT32 index, UINT8 level);
- void entry_set_blue_level(UINT32 index, UINT8 level);
- void entry_set_contrast(UINT32 index, float contrast);
+ void entry_set_color(uint32_t index, rgb_t rgb);
+ void entry_set_red_level(uint32_t index, uint8_t level);
+ void entry_set_green_level(uint32_t index, uint8_t level);
+ void entry_set_blue_level(uint32_t index, uint8_t level);
+ void entry_set_contrast(uint32_t index, float contrast);
// entry list getters
const rgb_t *entry_list_raw() const { return &m_entry_color[0]; }
@@ -180,30 +180,30 @@ public:
const rgb_t *entry_list_adjusted_rgb15() const { return &m_adjusted_rgb15[0]; }
// group adjustments
- void group_set_brightness(UINT32 group, float brightness);
- void group_set_contrast(UINT32 group, float contrast);
+ void group_set_brightness(uint32_t group, float brightness);
+ void group_set_contrast(uint32_t group, float contrast);
// utilities
- void normalize_range(UINT32 start, UINT32 end, int lum_min = 0, int lum_max = 255);
+ void normalize_range(uint32_t start, uint32_t end, int lum_min = 0, int lum_max = 255);
private:
// construction/destruction
- palette_t(UINT32 numcolors, UINT32 numgroups = 1);
+ palette_t(uint32_t numcolors, uint32_t numgroups = 1);
~palette_t();
// internal helpers
- rgb_t adjust_palette_entry(rgb_t entry, float brightness, float contrast, const UINT8 *gamma_map);
- void update_adjusted_color(UINT32 group, UINT32 index);
+ rgb_t adjust_palette_entry(rgb_t entry, float brightness, float contrast, const uint8_t *gamma_map);
+ void update_adjusted_color(uint32_t group, uint32_t index);
// internal state
- UINT32 m_refcount; // reference count on the palette
- UINT32 m_numcolors; // number of colors in the palette
- UINT32 m_numgroups; // number of groups in the palette
+ uint32_t m_refcount; // reference count on the palette
+ uint32_t m_numcolors; // number of colors in the palette
+ uint32_t m_numgroups; // number of groups in the palette
float m_brightness; // overall brightness value
float m_contrast; // overall contrast value
float m_gamma; // overall gamma value
- UINT8 m_gamma_map[256]; // gamma map
+ uint8_t m_gamma_map[256]; // gamma map
std::vector<rgb_t> m_entry_color; // array of raw colors
std::vector<float> m_entry_contrast; // contrast value for each entry
@@ -227,7 +227,7 @@ private:
//-------------------------------------------------
template<int _NumBits>
-inline UINT8 palexpand(UINT8 bits)
+inline uint8_t palexpand(uint8_t bits)
{
if (_NumBits == 1) { return (bits & 1) ? 0xff : 0x00; }
if (_NumBits == 2) { bits &= 3; return (bits << 6) | (bits << 4) | (bits << 2) | bits; }
@@ -244,13 +244,13 @@ inline UINT8 palexpand(UINT8 bits)
// palxbit - convert an x-bit value to 8 bits
//-------------------------------------------------
-inline UINT8 pal1bit(UINT8 bits) { return palexpand<1>(bits); }
-inline UINT8 pal2bit(UINT8 bits) { return palexpand<2>(bits); }
-inline UINT8 pal3bit(UINT8 bits) { return palexpand<3>(bits); }
-inline UINT8 pal4bit(UINT8 bits) { return palexpand<4>(bits); }
-inline UINT8 pal5bit(UINT8 bits) { return palexpand<5>(bits); }
-inline UINT8 pal6bit(UINT8 bits) { return palexpand<6>(bits); }
-inline UINT8 pal7bit(UINT8 bits) { return palexpand<7>(bits); }
+inline uint8_t pal1bit(uint8_t bits) { return palexpand<1>(bits); }
+inline uint8_t pal2bit(uint8_t bits) { return palexpand<2>(bits); }
+inline uint8_t pal3bit(uint8_t bits) { return palexpand<3>(bits); }
+inline uint8_t pal4bit(uint8_t bits) { return palexpand<4>(bits); }
+inline uint8_t pal5bit(uint8_t bits) { return palexpand<5>(bits); }
+inline uint8_t pal6bit(uint8_t bits) { return palexpand<6>(bits); }
+inline uint8_t pal7bit(uint8_t bits) { return palexpand<7>(bits); }
//-------------------------------------------------
@@ -259,7 +259,7 @@ inline UINT8 pal7bit(UINT8 bits) { return palexpand<7>(bits); }
//-------------------------------------------------
template<int _RBits, int _GBits, int _BBits>
-inline rgb_t rgbexpand(UINT32 data, UINT8 rshift, UINT8 gshift, UINT8 bshift)
+inline rgb_t rgbexpand(uint32_t data, uint8_t rshift, uint8_t gshift, uint8_t bshift)
{
return rgb_t(palexpand<_RBits>(data >> rshift), palexpand<_GBits>(data >> gshift), palexpand<_BBits>(data >> bshift));
}
@@ -267,14 +267,14 @@ inline rgb_t rgbexpand(UINT32 data, UINT8 rshift, UINT8 gshift, UINT8 bshift)
//-------------------------------------------------
// palxxx - create an x-x-x color by extracting
-// bits from a UINT32
+// bits from a uint32_t
//-------------------------------------------------
-inline rgb_t pal332(UINT32 data, UINT8 rshift, UINT8 gshift, UINT8 bshift) { return rgbexpand<3,3,2>(data, rshift, gshift, bshift); }
-inline rgb_t pal444(UINT32 data, UINT8 rshift, UINT8 gshift, UINT8 bshift) { return rgbexpand<4,4,4>(data, rshift, gshift, bshift); }
-inline rgb_t pal555(UINT32 data, UINT8 rshift, UINT8 gshift, UINT8 bshift) { return rgbexpand<5,5,5>(data, rshift, gshift, bshift); }
-inline rgb_t pal565(UINT32 data, UINT8 rshift, UINT8 gshift, UINT8 bshift) { return rgbexpand<5,6,5>(data, rshift, gshift, bshift); }
-inline rgb_t pal888(UINT32 data, UINT8 rshift, UINT8 gshift, UINT8 bshift) { return rgbexpand<8,8,8>(data, rshift, gshift, bshift); }
+inline rgb_t pal332(uint32_t data, uint8_t rshift, uint8_t gshift, uint8_t bshift) { return rgbexpand<3,3,2>(data, rshift, gshift, bshift); }
+inline rgb_t pal444(uint32_t data, uint8_t rshift, uint8_t gshift, uint8_t bshift) { return rgbexpand<4,4,4>(data, rshift, gshift, bshift); }
+inline rgb_t pal555(uint32_t data, uint8_t rshift, uint8_t gshift, uint8_t bshift) { return rgbexpand<5,5,5>(data, rshift, gshift, bshift); }
+inline rgb_t pal565(uint32_t data, uint8_t rshift, uint8_t gshift, uint8_t bshift) { return rgbexpand<5,6,5>(data, rshift, gshift, bshift); }
+inline rgb_t pal888(uint32_t data, uint8_t rshift, uint8_t gshift, uint8_t bshift) { return rgbexpand<8,8,8>(data, rshift, gshift, bshift); }
#endif // __PALETTE_H__
diff --git a/src/lib/util/plaparse.cpp b/src/lib/util/plaparse.cpp
index 74bc8edcc69..d1e7c679f97 100644
--- a/src/lib/util/plaparse.cpp
+++ b/src/lib/util/plaparse.cpp
@@ -33,11 +33,11 @@
struct parse_info
{
- UINT32 inputs; /* number of input columns */
- UINT32 outputs; /* number of output columns */
- UINT32 terms; /* number of terms */
- UINT32 xorval[JED_MAX_FUSES/64]; /* output polarity */
- UINT32 xorptr;
+ uint32_t inputs; /* number of input columns */
+ uint32_t outputs; /* number of output columns */
+ uint32_t terms; /* number of terms */
+ uint32_t xorval[JED_MAX_FUSES/64]; /* output polarity */
+ uint32_t xorptr;
};
@@ -61,9 +61,9 @@ static bool iscrlf(char c)
character stream
-------------------------------------------------*/
-static UINT32 suck_number(const UINT8 **src, const UINT8 *srcend)
+static uint32_t suck_number(const uint8_t **src, const uint8_t *srcend)
{
- UINT32 value = 0;
+ uint32_t value = 0;
// find first digit
while (*src < srcend && !iscrlf(**src) && !isdigit(**src))
@@ -89,10 +89,10 @@ static UINT32 suck_number(const UINT8 **src, const UINT8 *srcend)
process_terms - process input/output matrix
-------------------------------------------------*/
-static bool process_terms(jed_data *data, const UINT8 **src, const UINT8 *srcend, parse_info *pinfo)
+static bool process_terms(jed_data *data, const uint8_t **src, const uint8_t *srcend, parse_info *pinfo)
{
- UINT32 curinput = 0;
- UINT32 curoutput = 0;
+ uint32_t curinput = 0;
+ uint32_t curoutput = 0;
bool outputs = false;
// symbols for 0, 1, dont_care, no_meaning
@@ -195,7 +195,7 @@ static bool process_terms(jed_data *data, const UINT8 **src, const UINT8 *srcend
process_field - process a single field
-------------------------------------------------*/
-static bool process_field(jed_data *data, const UINT8 **src, const UINT8 *srcend, parse_info *pinfo)
+static bool process_field(jed_data *data, const uint8_t **src, const uint8_t *srcend, parse_info *pinfo)
{
// valid keywords
static const char *const keywords[] = { "i", "o", "p", "phase", "e", "\0" };
@@ -213,7 +213,7 @@ static bool process_field(jed_data *data, const UINT8 **src, const UINT8 *srcend
// find keyword
char dest[0x10];
memset(dest, 0, ARRAY_LENGTH(dest));
- const UINT8 *seek = *src;
+ const uint8_t *seek = *src;
int destptr = 0;
while (seek < srcend && isalpha(*seek) && destptr < ARRAY_LENGTH(dest) - 1)
@@ -223,7 +223,7 @@ static bool process_field(jed_data *data, const UINT8 **src, const UINT8 *srcend
destptr++;
}
- UINT8 find = 0;
+ uint8_t find = 0;
while (strlen(keywords[find]) && strcmp(dest, keywords[find]))
find++;
@@ -308,8 +308,8 @@ static bool process_field(jed_data *data, const UINT8 **src, const UINT8 *srcend
int pla_parse(const void *data, size_t length, jed_data *result)
{
- const UINT8 *src = (const UINT8 *)data;
- const UINT8 *srcend = src + length;
+ const uint8_t *src = (const uint8_t *)data;
+ const uint8_t *srcend = src + length;
parse_info pinfo;
memset(&pinfo, 0, sizeof(pinfo));
diff --git a/src/lib/util/png.cpp b/src/lib/util/png.cpp
index 11c0bb4db7b..d1189d5ffc2 100644
--- a/src/lib/util/png.cpp
+++ b/src/lib/util/png.cpp
@@ -26,7 +26,7 @@ struct image_data_chunk
{
image_data_chunk * next;
int length;
- UINT8 * data;
+ uint8_t * data;
};
@@ -35,8 +35,8 @@ struct png_private
png_info * pnginfo;
image_data_chunk * idata;
image_data_chunk ** idata_next;
- UINT8 bpp;
- UINT32 rowbytes;
+ uint8_t bpp;
+ uint32_t rowbytes;
};
@@ -53,41 +53,41 @@ static const int samples[] = { 1, 0, 3, 1, 2, 0, 4 };
INLINE FUNCTIONS
***************************************************************************/
-static inline UINT8 fetch_8bit(UINT8 *v)
+static inline uint8_t fetch_8bit(uint8_t *v)
{
return *v;
}
#ifdef UNUSED_FUNCTION
-static inline UINT16 fetch_16bit(UINT8 *v)
+static inline uint16_t fetch_16bit(uint8_t *v)
{
- return big_endianize_int16(*(UINT16 *)v);
+ return big_endianize_int16(*(uint16_t *)v);
}
#endif
-static inline UINT32 fetch_32bit(UINT8 *v)
+static inline uint32_t fetch_32bit(uint8_t *v)
{
- return big_endianize_int32(*(UINT32 *)v);
+ return big_endianize_int32(*(uint32_t *)v);
}
-static inline void put_8bit(UINT8 *v, UINT8 data)
+static inline void put_8bit(uint8_t *v, uint8_t data)
{
*v = data;
}
#ifdef UNUSED_FUNCTION
-static inline void put_16bit(UINT8 *v, UINT16 data)
+static inline void put_16bit(uint8_t *v, uint16_t data)
{
- *(UINT16 *)v = big_endianize_int16(data);
+ *(uint16_t *)v = big_endianize_int16(data);
}
#endif
-static inline void put_32bit(UINT8 *v, UINT32 data)
+static inline void put_32bit(uint8_t *v, uint32_t data)
{
- *(UINT32 *)v = big_endianize_int32(data);
+ *(uint32_t *)v = big_endianize_int32(data);
}
@@ -150,7 +150,7 @@ void png_free(png_info *pnginfo)
static png_error verify_header(util::core_file &fp)
{
- UINT8 signature[8];
+ uint8_t signature[8];
/* read 8 bytes */
if (fp.read(signature, 8) != 8)
@@ -168,10 +168,10 @@ static png_error verify_header(util::core_file &fp)
read_chunk - read the next PNG chunk
-------------------------------------------------*/
-static png_error read_chunk(util::core_file &fp, UINT8 **data, UINT32 *type, UINT32 *length)
+static png_error read_chunk(util::core_file &fp, uint8_t **data, uint32_t *type, uint32_t *length)
{
- UINT32 crc, chunk_crc;
- UINT8 tempbuff[4];
+ uint32_t crc, chunk_crc;
+ uint8_t tempbuff[4];
/* fetch the length of this chunk */
if (fp.read(tempbuff, 4) != 4)
@@ -195,7 +195,7 @@ static png_error read_chunk(util::core_file &fp, UINT8 **data, UINT32 *type, UIN
if (*length != 0)
{
/* allocate memory for this chunk */
- *data = (UINT8 *)malloc(*length);
+ *data = (uint8_t *)malloc(*length);
if (*data == nullptr)
return PNGERR_OUT_OF_MEMORY;
@@ -235,7 +235,7 @@ static png_error read_chunk(util::core_file &fp, UINT8 **data, UINT32 *type, UIN
process_chunk - process a PNG chunk
-------------------------------------------------*/
-static png_error process_chunk(png_private *png, UINT8 *data, UINT32 type, UINT32 length, int *keepmem)
+static png_error process_chunk(png_private *png, uint8_t *data, uint32_t type, uint32_t length, int *keepmem)
{
/* default to not keeping memory */
*keepmem = FALSE;
@@ -336,7 +336,7 @@ static png_error process_chunk(png_private *png, UINT8 *data, UINT32 type, UINT3
unfilter_row - unfilter a single row of pixels
-------------------------------------------------*/
-static png_error unfilter_row(int type, UINT8 *src, UINT8 *dst, UINT8 *dstprev, int bpp, int rowbytes)
+static png_error unfilter_row(int type, uint8_t *src, uint8_t *dst, uint8_t *dstprev, int bpp, int rowbytes)
{
int x;
@@ -387,13 +387,13 @@ static png_error unfilter_row(int type, UINT8 *src, UINT8 *dst, UINT8 *dstprev,
case PNG_PF_Paeth:
for (x = 0; x < rowbytes; x++)
{
- INT32 pa = (x < bpp) ? 0 : dst[-bpp];
- INT32 pc = (x < bpp || dstprev == nullptr) ? 0 : dstprev[-bpp];
- INT32 pb = (dstprev == nullptr) ? 0 : *dstprev++;
- INT32 prediction = pa + pb - pc;
- INT32 da = abs(prediction - pa);
- INT32 db = abs(prediction - pb);
- INT32 dc = abs(prediction - pc);
+ int32_t pa = (x < bpp) ? 0 : dst[-bpp];
+ int32_t pc = (x < bpp || dstprev == nullptr) ? 0 : dstprev[-bpp];
+ int32_t pb = (dstprev == nullptr) ? 0 : *dstprev++;
+ int32_t prediction = pa + pb - pc;
+ int32_t da = abs(prediction - pa);
+ int32_t db = abs(prediction - pb);
+ int32_t dc = abs(prediction - pc);
if (da <= db && da <= dc)
*dst++ = *src++ + pa;
else if (db <= dc)
@@ -421,7 +421,7 @@ static png_error process_image(png_private *png)
int rowbytes, bpp, imagesize;
png_error error = PNGERR_NONE;
image_data_chunk *idat;
- UINT8 *src, *dst;
+ uint8_t *src, *dst;
z_stream stream;
int zerr, y;
@@ -431,7 +431,7 @@ static png_error process_image(png_private *png)
imagesize = png->pnginfo->height * (rowbytes + 1);
/* allocate memory for the filtered image */
- png->pnginfo->image = (UINT8 *)malloc(imagesize);
+ png->pnginfo->image = (uint8_t *)malloc(imagesize);
if (png->pnginfo->image == nullptr)
return PNGERR_OUT_OF_MEMORY;
@@ -504,7 +504,7 @@ handle_error:
png_error png_read_file(util::core_file &fp, png_info *pnginfo)
{
- UINT8 *chunk_data = nullptr;
+ uint8_t *chunk_data = nullptr;
png_private png;
png_error error;
@@ -522,7 +522,7 @@ png_error png_read_file(util::core_file &fp, png_info *pnginfo)
/* loop until we hit an IEND chunk */
for ( ; ; )
{
- UINT32 chunk_type, chunk_length;
+ uint32_t chunk_type, chunk_length;
int keepmem;
/* read a chunk */
@@ -583,7 +583,7 @@ png_error png_read_bitmap(util::core_file &fp, bitmap_argb32 &bitmap)
{
png_error result;
png_info png;
- UINT8 *src;
+ uint8_t *src;
int x, y;
/* read the PNG data */
@@ -614,7 +614,7 @@ png_error png_read_bitmap(util::core_file &fp, bitmap_argb32 &bitmap)
for (x = 0; x < png.width; x++, src++)
{
/* determine alpha and expand to 32bpp */
- UINT8 alpha = (*src < png.num_trans) ? png.trans[*src] : 0xff;
+ uint8_t alpha = (*src < png.num_trans) ? png.trans[*src] : 0xff;
bitmap.pix32(y, x) = (alpha << 24) | (png.palette[*src * 3] << 16) | (png.palette[*src * 3 + 1] << 8) | png.palette[*src * 3 + 2];
}
}
@@ -657,14 +657,14 @@ png_error png_read_bitmap(util::core_file &fp, bitmap_argb32 &bitmap)
png_error png_expand_buffer_8bit(png_info *pnginfo)
{
int i,j, k;
- UINT8 *inp, *outp, *outbuf;
+ uint8_t *inp, *outp, *outbuf;
/* nothing to do if we're at 8 or greater already */
if (pnginfo->bit_depth >= 8)
return PNGERR_NONE;
/* allocate a new buffer at 8-bit */
- outbuf = (UINT8 *)malloc(pnginfo->width * pnginfo->height);
+ outbuf = (uint8_t *)malloc(pnginfo->width * pnginfo->height);
if (outbuf == nullptr)
return PNGERR_OUT_OF_MEMORY;
@@ -747,10 +747,10 @@ png_error png_add_text(png_info *pnginfo, const char *keyword, const char *text)
the given file
-------------------------------------------------*/
-static png_error write_chunk(util::core_file &fp, const UINT8 *data, UINT32 type, UINT32 length)
+static png_error write_chunk(util::core_file &fp, const uint8_t *data, uint32_t type, uint32_t length)
{
- UINT8 tempbuff[8];
- UINT32 crc;
+ uint8_t tempbuff[8];
+ uint32_t crc;
/* stuff the length/type into the buffer */
put_32bit(tempbuff + 0, length);
@@ -783,13 +783,13 @@ static png_error write_chunk(util::core_file &fp, const UINT8 *data, UINT32 type
chunk to the given file by deflating it
-------------------------------------------------*/
-static png_error write_deflated_chunk(util::core_file &fp, UINT8 *data, UINT32 type, UINT32 length)
+static png_error write_deflated_chunk(util::core_file &fp, uint8_t *data, uint32_t type, uint32_t length)
{
- UINT64 lengthpos = fp.tell();
- UINT8 tempbuff[8192];
- UINT32 zlength = 0;
+ uint64_t lengthpos = fp.tell();
+ uint8_t tempbuff[8192];
+ uint32_t zlength = 0;
z_stream stream;
- UINT32 crc;
+ uint32_t crc;
int zerr;
/* stuff the length/type into the buffer */
@@ -883,7 +883,7 @@ static png_error convert_bitmap_to_image_palette(png_info *pnginfo, const bitmap
rowbytes = pnginfo->width;
/* allocate memory for the palette */
- pnginfo->palette = (UINT8 *)malloc(3 * 256);
+ pnginfo->palette = (uint8_t *)malloc(3 * 256);
if (pnginfo->palette == nullptr)
return PNGERR_OUT_OF_MEMORY;
@@ -898,7 +898,7 @@ static png_error convert_bitmap_to_image_palette(png_info *pnginfo, const bitmap
}
/* allocate memory for the image */
- pnginfo->image = (UINT8 *)malloc(pnginfo->height * (rowbytes + 1));
+ pnginfo->image = (uint8_t *)malloc(pnginfo->height * (rowbytes + 1));
if (pnginfo->image == nullptr)
{
free(pnginfo->palette);
@@ -908,8 +908,8 @@ static png_error convert_bitmap_to_image_palette(png_info *pnginfo, const bitmap
/* copy in the pixels, specifying a nullptr filter */
for (y = 0; y < pnginfo->height; y++)
{
- UINT16 *src = reinterpret_cast<UINT16 *>(bitmap.raw_pixptr(y));
- UINT8 *dst = pnginfo->image + y * (rowbytes + 1);
+ uint16_t *src = reinterpret_cast<uint16_t *>(bitmap.raw_pixptr(y));
+ uint8_t *dst = pnginfo->image + y * (rowbytes + 1);
/* store the filter byte, then copy the data */
*dst++ = 0;
@@ -940,14 +940,14 @@ static png_error convert_bitmap_to_image_rgb(png_info *pnginfo, const bitmap_t &
rowbytes = pnginfo->width * (alpha ? 4 : 3);
/* allocate memory for the image */
- pnginfo->image = (UINT8 *)malloc(pnginfo->height * (rowbytes + 1));
+ pnginfo->image = (uint8_t *)malloc(pnginfo->height * (rowbytes + 1));
if (pnginfo->image == nullptr)
return PNGERR_OUT_OF_MEMORY;
/* copy in the pixels, specifying a nullptr filter */
for (y = 0; y < pnginfo->height; y++)
{
- UINT8 *dst = pnginfo->image + y * (rowbytes + 1);
+ uint8_t *dst = pnginfo->image + y * (rowbytes + 1);
/* store the filter byte, then copy the data */
*dst++ = 0;
@@ -955,7 +955,7 @@ static png_error convert_bitmap_to_image_rgb(png_info *pnginfo, const bitmap_t &
/* 16bpp palettized format */
if (bitmap.format() == BITMAP_FORMAT_IND16)
{
- UINT16 *src16 = reinterpret_cast<UINT16 *>(bitmap.raw_pixptr(y));
+ uint16_t *src16 = reinterpret_cast<uint16_t *>(bitmap.raw_pixptr(y));
for (x = 0; x < pnginfo->width; x++)
{
rgb_t color = palette[*src16++];
@@ -968,7 +968,7 @@ static png_error convert_bitmap_to_image_rgb(png_info *pnginfo, const bitmap_t &
/* 32-bit RGB direct */
else if (bitmap.format() == BITMAP_FORMAT_RGB32)
{
- UINT32 *src32 = reinterpret_cast<UINT32 *>(bitmap.raw_pixptr(y));
+ uint32_t *src32 = reinterpret_cast<uint32_t *>(bitmap.raw_pixptr(y));
for (x = 0; x < pnginfo->width; x++)
{
rgb_t raw = *src32++;
@@ -981,7 +981,7 @@ static png_error convert_bitmap_to_image_rgb(png_info *pnginfo, const bitmap_t &
/* 32-bit ARGB direct */
else if (bitmap.format() == BITMAP_FORMAT_ARGB32)
{
- UINT32 *src32 = reinterpret_cast<UINT32 *>(bitmap.raw_pixptr(y));
+ uint32_t *src32 = reinterpret_cast<uint32_t *>(bitmap.raw_pixptr(y));
for (x = 0; x < pnginfo->width; x++)
{
rgb_t raw = *src32++;
@@ -1008,7 +1008,7 @@ static png_error convert_bitmap_to_image_rgb(png_info *pnginfo, const bitmap_t &
static png_error write_png_stream(util::core_file &fp, png_info *pnginfo, const bitmap_t &bitmap, int palette_length, const rgb_t *palette)
{
- UINT8 tempbuff[16];
+ uint8_t tempbuff[16];
png_text *text;
png_error error;
@@ -1048,7 +1048,7 @@ static png_error write_png_stream(util::core_file &fp, png_info *pnginfo, const
/* write TEXT chunks */
for (text = pnginfo->textlist; text != nullptr; text = text->next)
{
- error = write_chunk(fp, (UINT8 *)text->keyword, PNG_CN_tEXt, (UINT32)strlen(text->keyword) + 1 + (UINT32)strlen(text->text));
+ error = write_chunk(fp, (uint8_t *)text->keyword, PNG_CN_tEXt, (uint32_t)strlen(text->keyword) + 1 + (uint32_t)strlen(text->text));
if (error != PNGERR_NONE)
goto handle_error;
}
@@ -1110,7 +1110,7 @@ png_error png_write_bitmap(util::core_file &fp, png_info *info, bitmap_t &bitmap
png_error mng_capture_start(util::core_file &fp, bitmap_t &bitmap, double rate)
{
- UINT8 mhdr[28];
+ uint8_t mhdr[28];
png_error error;
if (fp.write(MNG_Signature, 8) != 8)
diff --git a/src/lib/util/png.h b/src/lib/util/png.h
index 00522f12f5c..ed74fc6fc8f 100644
--- a/src/lib/util/png.h
+++ b/src/lib/util/png.h
@@ -89,24 +89,24 @@ struct png_text
struct png_info
{
- UINT8 * image;
- UINT32 width, height;
- UINT32 xres, yres;
+ uint8_t * image;
+ uint32_t width, height;
+ uint32_t xres, yres;
rectangle screen;
double xscale, yscale;
double source_gamma;
- UINT32 resolution_unit;
- UINT8 bit_depth;
- UINT8 color_type;
- UINT8 compression_method;
- UINT8 filter_method;
- UINT8 interlace_method;
-
- UINT8 * palette;
- UINT32 num_palette;
-
- UINT8 * trans;
- UINT32 num_trans;
+ uint32_t resolution_unit;
+ uint8_t bit_depth;
+ uint8_t color_type;
+ uint8_t compression_method;
+ uint8_t filter_method;
+ uint8_t interlace_method;
+
+ uint8_t * palette;
+ uint32_t num_palette;
+
+ uint8_t * trans;
+ uint32_t num_trans;
png_text * textlist;
};
diff --git a/src/lib/util/pool.cpp b/src/lib/util/pool.cpp
index f1f42bb58bf..1acb8d0d6e6 100644
--- a/src/lib/util/pool.cpp
+++ b/src/lib/util/pool.cpp
@@ -32,7 +32,7 @@
struct objtype_entry
{
objtype_entry * next;
- UINT32 type;
+ uint32_t type;
const char * friendly;
void (*destructor)(void *, size_t);
};
diff --git a/src/lib/util/pool.h b/src/lib/util/pool.h
index 341d57a6626..a43dacd87b2 100644
--- a/src/lib/util/pool.h
+++ b/src/lib/util/pool.h
@@ -37,7 +37,7 @@
***************************************************************************/
/* pool types are UINT32s */
-typedef UINT32 object_type;
+typedef uint32_t object_type;
/* opaque type representing a pool of objects */
struct object_pool;
diff --git a/src/lib/util/sha1.cpp b/src/lib/util/sha1.cpp
index 700c691622e..f1f00a60310 100644
--- a/src/lib/util/sha1.cpp
+++ b/src/lib/util/sha1.cpp
@@ -31,15 +31,15 @@
#include <stdlib.h>
#include <string.h>
-static unsigned int READ_UINT32(const UINT8* data)
+static unsigned int READ_UINT32(const uint8_t* data)
{
- return ((UINT32)data[0] << 24) |
- ((UINT32)data[1] << 16) |
- ((UINT32)data[2] << 8) |
- ((UINT32)data[3]);
+ return ((uint32_t)data[0] << 24) |
+ ((uint32_t)data[1] << 16) |
+ ((uint32_t)data[2] << 8) |
+ ((uint32_t)data[3]);
}
-static void WRITE_UINT32(unsigned char* data, UINT32 val)
+static void WRITE_UINT32(unsigned char* data, uint32_t val)
{
data[0] = (val >> 24) & 0xFF;
data[1] = (val >> 16) & 0xFF;
@@ -154,7 +154,7 @@ sha1_init(struct sha1_ctx *ctx)
Note that this function destroys the data area */
/**
- * @fn static void sha1_transform(UINT32 *state, UINT32 *data)
+ * @fn static void sha1_transform(uint32_t *state, uint32_t *data)
*
* @brief Sha 1 transform.
*
@@ -163,9 +163,9 @@ sha1_init(struct sha1_ctx *ctx)
*/
static void
-sha1_transform(UINT32 *state, UINT32 *data)
+sha1_transform(uint32_t *state, uint32_t *data)
{
- UINT32 A, B, C, D, E; /* Local vars */
+ uint32_t A, B, C, D, E; /* Local vars */
/* Set up first buffer and local data buffer */
A = state[0];
@@ -268,7 +268,7 @@ sha1_transform(UINT32 *state, UINT32 *data)
}
/**
- * @fn static void sha1_block(struct sha1_ctx *ctx, const UINT8 *block)
+ * @fn static void sha1_block(struct sha1_ctx *ctx, const uint8_t *block)
*
* @brief Sha 1 block.
*
@@ -277,9 +277,9 @@ sha1_transform(UINT32 *state, UINT32 *data)
*/
static void
-sha1_block(struct sha1_ctx *ctx, const UINT8 *block)
+sha1_block(struct sha1_ctx *ctx, const uint8_t *block)
{
- UINT32 data[SHA1_DATA_LENGTH];
+ uint32_t data[SHA1_DATA_LENGTH];
int i;
/* Update block count */
@@ -294,7 +294,7 @@ sha1_block(struct sha1_ctx *ctx, const UINT8 *block)
}
/**
- * @fn void sha1_update(struct sha1_ctx *ctx, unsigned length, const UINT8 *buffer)
+ * @fn void sha1_update(struct sha1_ctx *ctx, unsigned length, const uint8_t *buffer)
*
* @brief Sha 1 update.
*
@@ -305,7 +305,7 @@ sha1_block(struct sha1_ctx *ctx, const UINT8 *block)
void
sha1_update(struct sha1_ctx *ctx,
- unsigned length, const UINT8 *buffer)
+ unsigned length, const uint8_t *buffer)
{
if (ctx->index)
{ /* Try to fill partial block */
@@ -350,7 +350,7 @@ sha1_update(struct sha1_ctx *ctx,
void
sha1_final(struct sha1_ctx *ctx)
{
- UINT32 data[SHA1_DATA_LENGTH];
+ uint32_t data[SHA1_DATA_LENGTH];
int i;
int words;
@@ -391,7 +391,7 @@ sha1_final(struct sha1_ctx *ctx)
}
/**
- * @fn void sha1_digest(const struct sha1_ctx *ctx, unsigned length, UINT8 *digest)
+ * @fn void sha1_digest(const struct sha1_ctx *ctx, unsigned length, uint8_t *digest)
*
* @brief Sha 1 digest.
*
@@ -403,7 +403,7 @@ sha1_final(struct sha1_ctx *ctx)
void
sha1_digest(const struct sha1_ctx *ctx,
unsigned length,
- UINT8 *digest)
+ uint8_t *digest)
{
unsigned i;
unsigned words;
@@ -419,7 +419,7 @@ sha1_digest(const struct sha1_ctx *ctx,
if (leftover)
{
- UINT32 word;
+ uint32_t word;
unsigned j = leftover;
assert(i < _SHA1_DIGEST_LENGTH);
diff --git a/src/lib/util/sha1.h b/src/lib/util/sha1.h
index ba5866c5819..177caf9f6dc 100644
--- a/src/lib/util/sha1.h
+++ b/src/lib/util/sha1.h
@@ -38,9 +38,9 @@
struct sha1_ctx
{
- UINT32 digest[_SHA1_DIGEST_LENGTH]; /* Message digest */
- UINT32 count_low, count_high; /* 64-bit block count */
- UINT8 block[SHA1_DATA_SIZE]; /* SHA1 data buffer */
+ uint32_t digest[_SHA1_DIGEST_LENGTH]; /* Message digest */
+ uint32_t count_low, count_high; /* 64-bit block count */
+ uint8_t block[SHA1_DATA_SIZE]; /* SHA1 data buffer */
unsigned int index; /* index into buffer */
};
@@ -50,7 +50,7 @@ sha1_init(struct sha1_ctx *ctx);
void
sha1_update(struct sha1_ctx *ctx,
unsigned length,
- const UINT8 *data);
+ const uint8_t *data);
void
sha1_final(struct sha1_ctx *ctx);
@@ -58,6 +58,6 @@ sha1_final(struct sha1_ctx *ctx);
void
sha1_digest(const struct sha1_ctx *ctx,
unsigned length,
- UINT8 *digest);
+ uint8_t *digest);
#endif /* NETTLE_SHA1_H_INCLUDED */
diff --git a/src/lib/util/vbiparse.cpp b/src/lib/util/vbiparse.cpp
index 854b5fbd384..42249ab6794 100644
--- a/src/lib/util/vbiparse.cpp
+++ b/src/lib/util/vbiparse.cpp
@@ -40,10 +40,10 @@
code from a line of video data
-------------------------------------------------*/
-int vbi_parse_manchester_code(const UINT16 *source, int sourcewidth, int sourceshift, int expectedbits, UINT32 *result)
+int vbi_parse_manchester_code(const uint16_t *source, int sourcewidth, int sourceshift, int expectedbits, uint32_t *result)
{
- UINT8 srcabs[MAX_SOURCE_WIDTH];
- UINT8 min, max, mid, srcabsval;
+ uint8_t srcabs[MAX_SOURCE_WIDTH];
+ uint8_t min, max, mid, srcabsval;
double clock, bestclock;
int x, firstedge;
int besterr;
@@ -57,7 +57,7 @@ int vbi_parse_manchester_code(const UINT16 *source, int sourcewidth, int sources
max = 0x00;
for (x = 0; x < sourcewidth; x++)
{
- UINT8 rawsrc = source[x] >> sourceshift;
+ uint8_t rawsrc = source[x] >> sourceshift;
min = std::min(min, rawsrc);
max = std::max(max, rawsrc);
}
@@ -75,7 +75,7 @@ int vbi_parse_manchester_code(const UINT16 *source, int sourcewidth, int sources
srcabsval = (source[0] > mid);
for (x = 0; x < sourcewidth; x++)
{
- UINT8 rawsrc = source[x] >> sourceshift;
+ uint8_t rawsrc = source[x] >> sourceshift;
if (rawsrc >= max)
srcabsval = 1;
else if (rawsrc <= min)
@@ -147,13 +147,13 @@ int vbi_parse_manchester_code(const UINT16 *source, int sourcewidth, int sources
/* compute left and right average values */
leftavg = 0;
for (tx = leftstart; tx <= leftend; tx++)
- leftavg += (UINT8)(source[tx] >> sourceshift) - mid;
+ leftavg += (uint8_t)(source[tx] >> sourceshift) - mid;
leftabs = (leftavg >= 0);
leftavg = (leftavg < 0) ? -leftavg : leftavg;
rightavg = 0;
for (tx = rightstart; tx <= rightend; tx++)
- rightavg += (UINT8)(source[tx] >> sourceshift) - mid;
+ rightavg += (uint8_t)(source[tx] >> sourceshift) - mid;
rightabs = (rightavg >= 0);
rightavg = (rightavg < 0) ? -rightavg : rightavg;
@@ -174,7 +174,7 @@ int vbi_parse_manchester_code(const UINT16 *source, int sourcewidth, int sources
flag" from a line of video data
-------------------------------------------------*/
-int vbi_parse_white_flag(const UINT16 *source, int sourcewidth, int sourceshift)
+int vbi_parse_white_flag(const uint16_t *source, int sourcewidth, int sourceshift)
{
int histo[256] = { 0 };
int minval = 0xff;
@@ -187,7 +187,7 @@ int vbi_parse_white_flag(const UINT16 *source, int sourcewidth, int sourceshift)
/* compute a histogram of values */
for (x = 0; x < sourcewidth; x++)
{
- UINT8 yval = source[x] >> sourceshift;
+ uint8_t yval = source[x] >> sourceshift;
histo[yval]++;
}
@@ -261,7 +261,7 @@ int vbi_parse_white_flag(const UINT16 *source, int sourcewidth, int sourceshift)
thresh = minval + 3 * (maxval - minval) / 4;
for (x = 0; x < sourcewidth; x++)
{
- UINT8 yval = source[x] >> sourceshift;
+ uint8_t yval = source[x] >> sourceshift;
above += (yval >= thresh);
}
/* if at least 80% of the pixels are above the threshold, we'll call it white */
@@ -277,7 +277,7 @@ int vbi_parse_white_flag(const UINT16 *source, int sourcewidth, int sourceshift)
-------------------------------------------------*/
/**
- * @fn void vbi_parse_all(const UINT16 *source, int sourcerowpixels, int sourcewidth, int sourceshift, vbi_metadata *vbi)
+ * @fn void vbi_parse_all(const uint16_t *source, int sourcerowpixels, int sourcewidth, int sourceshift, vbi_metadata *vbi)
*
* @brief Vbi parse all.
*
@@ -288,10 +288,10 @@ int vbi_parse_white_flag(const UINT16 *source, int sourcewidth, int sourceshift)
* @param [in,out] vbi If non-null, the vbi.
*/
-void vbi_parse_all(const UINT16 *source, int sourcerowpixels, int sourcewidth, int sourceshift, vbi_metadata *vbi)
+void vbi_parse_all(const uint16_t *source, int sourcerowpixels, int sourcewidth, int sourceshift, vbi_metadata *vbi)
{
- UINT32 bits[2][24];
- UINT8 bitnum;
+ uint32_t bits[2][24];
+ uint8_t bitnum;
/* first reset it all */
memset(vbi, 0, sizeof(*vbi));
@@ -351,7 +351,7 @@ void vbi_parse_all(const UINT16 *source, int sourcerowpixels, int sourcewidth, i
-------------------------------------------------*/
/**
- * @fn void vbi_metadata_pack(UINT8 *dest, UINT32 framenum, const vbi_metadata *vbi)
+ * @fn void vbi_metadata_pack(uint8_t *dest, uint32_t framenum, const vbi_metadata *vbi)
*
* @brief Vbi metadata pack.
*
@@ -360,7 +360,7 @@ void vbi_parse_all(const UINT16 *source, int sourcerowpixels, int sourcewidth, i
* @param vbi The vbi.
*/
-void vbi_metadata_pack(UINT8 *dest, UINT32 framenum, const vbi_metadata *vbi)
+void vbi_metadata_pack(uint8_t *dest, uint32_t framenum, const vbi_metadata *vbi)
{
dest[0] = framenum >> 16;
dest[1] = framenum >> 8;
@@ -387,7 +387,7 @@ void vbi_metadata_pack(UINT8 *dest, UINT32 framenum, const vbi_metadata *vbi)
-------------------------------------------------*/
/**
- * @fn void vbi_metadata_unpack(vbi_metadata *vbi, UINT32 *framenum, const UINT8 *source)
+ * @fn void vbi_metadata_unpack(vbi_metadata *vbi, uint32_t *framenum, const uint8_t *source)
*
* @brief Vbi metadata unpack.
*
@@ -396,7 +396,7 @@ void vbi_metadata_pack(UINT8 *dest, UINT32 framenum, const vbi_metadata *vbi)
* @param source Source for the.
*/
-void vbi_metadata_unpack(vbi_metadata *vbi, UINT32 *framenum, const UINT8 *source)
+void vbi_metadata_unpack(vbi_metadata *vbi, uint32_t *framenum, const uint8_t *source)
{
if (framenum != nullptr)
*framenum = (source[0] << 16) | (source[1] << 8) | source[2];
diff --git a/src/lib/util/vbiparse.h b/src/lib/util/vbiparse.h
index 687f984622c..ed67a3fee9f 100644
--- a/src/lib/util/vbiparse.h
+++ b/src/lib/util/vbiparse.h
@@ -61,11 +61,11 @@
struct vbi_metadata
{
- UINT8 white; /* white flag: on or off */
- UINT32 line16; /* line 16 code */
- UINT32 line17; /* line 17 code */
- UINT32 line18; /* line 18 code */
- UINT32 line1718; /* most plausible value from lines 17/18 */
+ uint8_t white; /* white flag: on or off */
+ uint32_t line16; /* line 16 code */
+ uint32_t line17; /* line 17 code */
+ uint32_t line18; /* line 18 code */
+ uint32_t line1718; /* most plausible value from lines 17/18 */
};
@@ -75,19 +75,19 @@ struct vbi_metadata
***************************************************************************/
/* parse a Manchester code from a line of video data */
-int vbi_parse_manchester_code(const UINT16 *source, int sourcewidth, int sourceshift, int expectedbits, UINT32 *result);
+int vbi_parse_manchester_code(const uint16_t *source, int sourcewidth, int sourceshift, int expectedbits, uint32_t *result);
/* compute the "white flag" from a line of video data */
-int vbi_parse_white_flag(const UINT16 *source, int sourcewidth, int sourceshift);
+int vbi_parse_white_flag(const uint16_t *source, int sourcewidth, int sourceshift);
/* parse everything from a video frame */
-void vbi_parse_all(const UINT16 *source, int sourcerowpixels, int sourcewidth, int sourceshift, vbi_metadata *vbi);
+void vbi_parse_all(const uint16_t *source, int sourcerowpixels, int sourcewidth, int sourceshift, vbi_metadata *vbi);
/* pack the VBI data down into a smaller form for storage */
-void vbi_metadata_pack(UINT8 *dest, UINT32 framenum, const vbi_metadata *vbi);
+void vbi_metadata_pack(uint8_t *dest, uint32_t framenum, const vbi_metadata *vbi);
/* unpack the VBI data from a smaller form into the full structure */
-void vbi_metadata_unpack(vbi_metadata *vbi, UINT32 *framenum, const UINT8 *source);
+void vbi_metadata_unpack(vbi_metadata *vbi, uint32_t *framenum, const uint8_t *source);
#endif /* __VBIPARSE_H__ */
diff --git a/src/lib/util/wavwrite.cpp b/src/lib/util/wavwrite.cpp
index d052287216d..0667e9dcaff 100644
--- a/src/lib/util/wavwrite.cpp
+++ b/src/lib/util/wavwrite.cpp
@@ -8,16 +8,16 @@
struct wav_file
{
FILE *file;
- UINT32 total_offs;
- UINT32 data_offs;
+ uint32_t total_offs;
+ uint32_t data_offs;
};
wav_file *wav_open(const char *filename, int sample_rate, int channels)
{
wav_file *wav;
- UINT32 bps, temp32;
- UINT16 align, temp16;
+ uint32_t bps, temp32;
+ uint16_t align, temp16;
/* allocate memory for the wav struct */
wav = global_alloc_nothrow(wav_file);
@@ -90,8 +90,8 @@ wav_file *wav_open(const char *filename, int sample_rate, int channels)
void wav_close(wav_file *wav)
{
- UINT32 total;
- UINT32 temp32;
+ uint32_t total;
+ uint32_t temp32;
if (!wav) return;
@@ -114,7 +114,7 @@ void wav_close(wav_file *wav)
}
-void wav_add_data_16(wav_file *wav, INT16 *data, int samples)
+void wav_add_data_16(wav_file *wav, int16_t *data, int samples)
{
if (!wav) return;
@@ -124,9 +124,9 @@ void wav_add_data_16(wav_file *wav, INT16 *data, int samples)
}
-void wav_add_data_32(wav_file *wav, INT32 *data, int samples, int shift)
+void wav_add_data_32(wav_file *wav, int32_t *data, int samples, int shift)
{
- std::vector<INT16> temp;
+ std::vector<int16_t> temp;
int i;
if (!wav || !samples) return;
@@ -147,9 +147,9 @@ void wav_add_data_32(wav_file *wav, INT32 *data, int samples, int shift)
}
-void wav_add_data_16lr(wav_file *wav, INT16 *left, INT16 *right, int samples)
+void wav_add_data_16lr(wav_file *wav, int16_t *left, int16_t *right, int samples)
{
- std::vector<INT16> temp;
+ std::vector<int16_t> temp;
int i;
if (!wav || !samples) return;
@@ -167,9 +167,9 @@ void wav_add_data_16lr(wav_file *wav, INT16 *left, INT16 *right, int samples)
}
-void wav_add_data_32lr(wav_file *wav, INT32 *left, INT32 *right, int samples, int shift)
+void wav_add_data_32lr(wav_file *wav, int32_t *left, int32_t *right, int samples, int shift)
{
- std::vector<INT16> temp;
+ std::vector<int16_t> temp;
int i;
if (!wav || !samples) return;
diff --git a/src/lib/util/wavwrite.h b/src/lib/util/wavwrite.h
index 376856fb16f..da94a9d3782 100644
--- a/src/lib/util/wavwrite.h
+++ b/src/lib/util/wavwrite.h
@@ -10,9 +10,9 @@ struct wav_file;
wav_file *wav_open(const char *filename, int sample_rate, int channels);
void wav_close(wav_file*wavptr);
-void wav_add_data_16(wav_file *wavptr, INT16 *data, int samples);
-void wav_add_data_32(wav_file *wavptr, INT32 *data, int samples, int shift);
-void wav_add_data_16lr(wav_file *wavptr, INT16 *left, INT16 *right, int samples);
-void wav_add_data_32lr(wav_file *wavptr, INT32 *left, INT32 *right, int samples, int shift);
+void wav_add_data_16(wav_file *wavptr, int16_t *data, int samples);
+void wav_add_data_32(wav_file *wavptr, int32_t *data, int samples, int shift);
+void wav_add_data_16lr(wav_file *wavptr, int16_t *left, int16_t *right, int samples);
+void wav_add_data_32lr(wav_file *wavptr, int32_t *left, int32_t *right, int samples, int shift);
#endif /* __WAVWRITE_H__ */
diff --git a/src/lib/util/xmlfile.cpp b/src/lib/util/xmlfile.cpp
index b1ed844dc71..98689283c4e 100644
--- a/src/lib/util/xmlfile.cpp
+++ b/src/lib/util/xmlfile.cpp
@@ -32,7 +32,7 @@ struct xml_parse_info
XML_Parser parser;
xml_data_node * rootnode;
xml_data_node * curnode;
- UINT32 flags;
+ uint32_t flags;
};
@@ -103,7 +103,7 @@ static const char *copystring_lower(const char *input)
if (newstr != nullptr)
{
for (i = 0; input[i] != 0; i++)
- newstr[i] = tolower((UINT8)input[i]);
+ newstr[i] = tolower((uint8_t)input[i]);
newstr[i] = 0;
}
@@ -635,7 +635,7 @@ const char *xml_normalize_string(const char *string)
static void *expat_malloc(size_t size)
{
- UINT32 *result = (UINT32 *)malloc(size + 4 * sizeof(UINT32));
+ uint32_t *result = (uint32_t *)malloc(size + 4 * sizeof(uint32_t));
*result = size;
return &result[4];
}
@@ -651,7 +651,7 @@ static void *expat_malloc(size_t size)
static void expat_free(void *ptr)
{
if (ptr != nullptr)
- free(&((UINT32 *)ptr)[-4]);
+ free(&((uint32_t *)ptr)[-4]);
}
/**
@@ -672,7 +672,7 @@ static void *expat_realloc(void *ptr, size_t size)
return nullptr;
if (ptr != nullptr)
{
- UINT32 oldsize = ((UINT32 *)ptr)[-4];
+ uint32_t oldsize = ((uint32_t *)ptr)[-4];
memcpy(newptr, ptr, oldsize);
expat_free(ptr);
}
@@ -856,11 +856,11 @@ static void expat_element_end(void *data, const XML_Char *name)
char *end = start + strlen(start);
/* first strip leading spaces */
- while (*start && isspace((UINT8)*start))
+ while (*start && isspace((uint8_t)*start))
start++;
/* then strip trailing spaces */
- while (end > start && isspace((UINT8)end[-1]))
+ while (end > start && isspace((uint8_t)end[-1]))
end--;
/* if nothing left, just free it */
diff --git a/src/lib/util/xmlfile.h b/src/lib/util/xmlfile.h
index e116366643f..eac3cdff4c2 100644
--- a/src/lib/util/xmlfile.h
+++ b/src/lib/util/xmlfile.h
@@ -81,7 +81,7 @@ struct xml_parse_options
{
xml_parse_error * error;
void (*init_parser)(struct XML_ParserStruct *parser);
- UINT32 flags;
+ uint32_t flags;
};
diff --git a/src/lib/util/zippath.cpp b/src/lib/util/zippath.cpp
index 1eb2eba9274..2ee9082a817 100644
--- a/src/lib/util/zippath.cpp
+++ b/src/lib/util/zippath.cpp
@@ -363,7 +363,7 @@ done:
// -------------------------------------------------
/**
- * @fn osd_file::error zippath_fopen(const std::string &filename, UINT32 openflags, util::core_file::ptr &file, std::string &revised_path)
+ * @fn osd_file::error zippath_fopen(const std::string &filename, uint32_t openflags, util::core_file::ptr &file, std::string &revised_path)
*
* @brief Zippath fopen.
*
@@ -375,7 +375,7 @@ done:
* @return A osd_file::error.
*/
-osd_file::error zippath_fopen(const std::string &filename, UINT32 openflags, util::core_file::ptr &file, std::string &revised_path)
+osd_file::error zippath_fopen(const std::string &filename, uint32_t openflags, util::core_file::ptr &file, std::string &revised_path)
{
osd_file::error filerr = osd_file::error::NOT_FOUND;
archive_file::error ziperr;
diff --git a/src/lib/util/zippath.h b/src/lib/util/zippath.h
index 9c5b361b076..89656e6cf10 100644
--- a/src/lib/util/zippath.h
+++ b/src/lib/util/zippath.h
@@ -49,7 +49,7 @@ std::string zippath_combine(const std::string &path1, const std::string &path2);
// ----- file operations -----
// opens a zip path file
-osd_file::error zippath_fopen(const std::string &filename, UINT32 openflags, util::core_file::ptr &file, std::string &revised_path);
+osd_file::error zippath_fopen(const std::string &filename, uint32_t openflags, util::core_file::ptr &file, std::string &revised_path);
// ----- directory operations ----- */