diff --git a/src/common/common.cpp b/src/common/common.cpp index 011cd2b6f..256a38848 100644 --- a/src/common/common.cpp +++ b/src/common/common.cpp @@ -223,26 +223,26 @@ byte_cursor_c::get_uint32_be() { } unsigned short -byte_cursor_c::get_uint16() { +byte_cursor_c::get_uint16_le() { unsigned short v; if ((pos + 2) > size) throw exception(); - v = ::get_uint16(&data[pos]); + v = ::get_uint16_le(&data[pos]); pos += 2; return v; } unsigned int -byte_cursor_c::get_uint32() { +byte_cursor_c::get_uint32_le() { unsigned int v; if ((pos + 4) > size) throw exception(); - v = ::get_uint32(&data[pos]); + v = ::get_uint32_le(&data[pos]); pos += 4; return v; @@ -308,7 +308,7 @@ _trace(const char *func, */ uint16_t -get_uint16(const void *buf) { +get_uint16_le(const void *buf) { uint16_t ret; unsigned char *tmp; @@ -321,7 +321,7 @@ get_uint16(const void *buf) { } uint32_t -get_uint24(const void *buf) { +get_uint24_le(const void *buf) { uint32_t ret; unsigned char *tmp; @@ -335,7 +335,7 @@ get_uint24(const void *buf) { } uint32_t -get_uint32(const void *buf) { +get_uint32_le(const void *buf) { uint32_t ret; unsigned char *tmp; @@ -350,7 +350,7 @@ get_uint32(const void *buf) { } uint64_t -get_uint64(const void *buf) { +get_uint64_le(const void *buf) { uint64_t ret; unsigned char *tmp; @@ -430,7 +430,7 @@ get_uint64_be(const void *buf) { } void -put_uint16(void *buf, +put_uint16_le(void *buf, uint16_t value) { unsigned char *tmp; @@ -441,7 +441,7 @@ put_uint16(void *buf, } void -put_uint32(void *buf, +put_uint32_le(void *buf, uint32_t value) { unsigned char *tmp; @@ -454,7 +454,7 @@ put_uint32(void *buf, } void -put_uint64(void *buf, +put_uint64_le(void *buf, uint64_t value) { unsigned char *tmp; diff --git a/src/common/common.h b/src/common/common.h index b7f7f1bfa..1152c4683 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -135,17 +135,17 @@ void MTX_DLL_API _trace(const char *func, const char *file, int line); void MTX_DLL_API mxhexdump(int level, const unsigned char *buffer, int lenth); #define get_fourcc(b) get_uint32_be(b) -uint16_t MTX_DLL_API get_uint16(const void *buf); -uint32_t MTX_DLL_API get_uint24(const void *buf); -uint32_t MTX_DLL_API get_uint32(const void *buf); -uint64_t MTX_DLL_API get_uint64(const void *buf); +uint16_t MTX_DLL_API get_uint16_le(const void *buf); +uint32_t MTX_DLL_API get_uint24_le(const void *buf); +uint32_t MTX_DLL_API get_uint32_le(const void *buf); +uint64_t MTX_DLL_API get_uint64_le(const void *buf); uint16_t MTX_DLL_API get_uint16_be(const void *buf); uint32_t MTX_DLL_API get_uint24_be(const void *buf); uint32_t MTX_DLL_API get_uint32_be(const void *buf); uint64_t MTX_DLL_API get_uint64_be(const void *buf); -void MTX_DLL_API put_uint16(void *buf, uint16_t value); -void MTX_DLL_API put_uint32(void *buf, uint32_t value); -void MTX_DLL_API put_uint64(void *buf, uint64_t value); +void MTX_DLL_API put_uint16_le(void *buf, uint16_t value); +void MTX_DLL_API put_uint32_le(void *buf, uint32_t value); +void MTX_DLL_API put_uint64_le(void *buf, uint64_t value); void MTX_DLL_API put_uint16_be(void *buf, uint16_t value); void MTX_DLL_API put_uint32_be(void *buf, uint32_t value); void MTX_DLL_API put_uint64_be(void *buf, uint64_t value); @@ -451,8 +451,8 @@ public: byte_cursor_c(const unsigned char *ndata, int nsize); virtual unsigned char get_uint8(); - virtual unsigned short get_uint16(); - virtual unsigned int get_uint32(); + virtual unsigned short get_uint16_le(); + virtual unsigned int get_uint32_le(); virtual unsigned short get_uint16_be(); virtual unsigned int get_uint32_be(); virtual void get_bytes(unsigned char *dst, int n); diff --git a/src/common/mm_io.cpp b/src/common/mm_io.cpp index f62a503ec..cab87eaef 100644 --- a/src/common/mm_io.cpp +++ b/src/common/mm_io.cpp @@ -376,43 +376,43 @@ mm_io_c::read_uint8() { } uint16_t -mm_io_c::read_uint16() { +mm_io_c::read_uint16_le() { unsigned char buffer[2]; if (read(buffer, 2) != 2) throw exception(); - return get_uint16(buffer); + return get_uint16_le(buffer); } uint32_t -mm_io_c::read_uint24() { +mm_io_c::read_uint24_le() { unsigned char buffer[3]; if (read(buffer, 3) != 3) throw exception(); - return get_uint24(buffer); + return get_uint24_le(buffer); } uint32_t -mm_io_c::read_uint32() { +mm_io_c::read_uint32_le() { unsigned char buffer[4]; if (read(buffer, 4) != 4) throw exception(); - return get_uint32(buffer); + return get_uint32_le(buffer); } uint64_t -mm_io_c::read_uint64() { +mm_io_c::read_uint64_le() { unsigned char buffer[8]; if (read(buffer, 8) != 8) throw exception(); - return get_uint64(buffer); + return get_uint64_le(buffer); } uint16_t @@ -461,26 +461,26 @@ mm_io_c::write_uint8(unsigned char value) { } int -mm_io_c::write_uint16(uint16_t value) { +mm_io_c::write_uint16_le(uint16_t value) { uint16_t buffer; - put_uint16(&buffer, value); + put_uint16_le(&buffer, value); return write(&buffer, sizeof(uint16_t)); } int -mm_io_c::write_uint32(uint32_t value) { +mm_io_c::write_uint32_le(uint32_t value) { uint32_t buffer; - put_uint32(&buffer, value); + put_uint32_le(&buffer, value); return write(&buffer, sizeof(uint32_t)); } int -mm_io_c::write_uint64(uint64_t value) { +mm_io_c::write_uint64_le(uint64_t value) { uint64_t buffer; - put_uint64(&buffer, value); + put_uint64_le(&buffer, value); return write(&buffer, sizeof(uint64_t)); } diff --git a/src/common/mm_io.h b/src/common/mm_io.h index bb07f2782..9c05c6996 100644 --- a/src/common/mm_io.h +++ b/src/common/mm_io.h @@ -44,18 +44,18 @@ public: virtual uint32 read(void *buffer, size_t size) = 0; virtual uint32_t read(string &buffer, size_t size); virtual unsigned char read_uint8(); - virtual uint16_t read_uint16(); - virtual uint32_t read_uint24(); - virtual uint32_t read_uint32(); - virtual uint64_t read_uint64(); + virtual uint16_t read_uint16_le(); + virtual uint32_t read_uint24_le(); + virtual uint32_t read_uint32_le(); + virtual uint64_t read_uint64_le(); virtual uint16_t read_uint16_be(); virtual uint32_t read_uint24_be(); virtual uint32_t read_uint32_be(); virtual uint64_t read_uint64_be(); virtual int write_uint8(unsigned char value); - virtual int write_uint16(uint16_t value); - virtual int write_uint32(uint32_t value); - virtual int write_uint64(uint64_t value); + virtual int write_uint16_le(uint16_t value); + virtual int write_uint32_le(uint32_t value); + virtual int write_uint64_le(uint64_t value); virtual int write_uint16_be(uint16_t value); virtual int write_uint32_be(uint32_t value); virtual int write_uint64_be(uint64_t value); diff --git a/src/extract/tracks.cpp b/src/extract/tracks.cpp index 1b84e80ae..e229bb6cc 100644 --- a/src/extract/tracks.cpp +++ b/src/extract/tracks.cpp @@ -527,15 +527,15 @@ create_output_files() { memcpy(&wh->riff.id, "RIFF", 4); memcpy(&wh->riff.wave_id, "WAVE", 4); memcpy(&wh->format.id, "fmt ", 4); - put_uint32(&wh->format.len, 16); - put_uint16(&wh->common.wFormatTag, 1); - put_uint16(&wh->common.wChannels, tracks[i].a_channels); - put_uint32(&wh->common.dwSamplesPerSec, (int)tracks[i].a_sfreq); - put_uint32(&wh->common.dwAvgBytesPerSec, + put_uint32_le(&wh->format.len, 16); + put_uint16_le(&wh->common.wFormatTag, 1); + put_uint16_le(&wh->common.wChannels, tracks[i].a_channels); + put_uint32_le(&wh->common.dwSamplesPerSec, (int)tracks[i].a_sfreq); + put_uint32_le(&wh->common.dwAvgBytesPerSec, tracks[i].a_channels * (int)tracks[i].a_sfreq * tracks[i].a_bps / 8); - put_uint16(&wh->common.wBlockAlign, 4); - put_uint16(&wh->common.wBitsPerSample, tracks[i].a_bps); + put_uint16_le(&wh->common.wBlockAlign, 4); + put_uint16_le(&wh->common.wBitsPerSample, tracks[i].a_bps); memcpy(&wh->data.id, "data", 4); tracks[i].out->write(wh, sizeof(wave_header)); @@ -1020,8 +1020,8 @@ close_files() { case FILE_TYPE_WAV: // Fix the header with the real number of bytes written. tracks[i].out->setFilePointer(0); - put_uint32(&tracks[i].wh.riff.len, tracks[i].bytes_written + 36); - put_uint32(&tracks[i].wh.data.len, tracks[i].bytes_written); + put_uint32_le(&tracks[i].wh.riff.len, tracks[i].bytes_written + 36); + put_uint32_le(&tracks[i].wh.data.len, tracks[i].bytes_written); tracks[i].out->write(&tracks[i].wh, sizeof(wave_header)); delete tracks[i].out; @@ -1065,12 +1065,12 @@ close_files() { memcpy(tta_header.signature, "TTA1", 4); if (tracks[i].a_bps != 3) - put_uint16(&tta_header.audio_format, 1); + put_uint16_le(&tta_header.audio_format, 1); else - put_uint16(&tta_header.audio_format, 3); - put_uint16(&tta_header.channels, tracks[i].a_channels); - put_uint16(&tta_header.bits_per_sample, tracks[i].a_bps); - put_uint32(&tta_header.sample_rate, (int)tracks[i].a_sfreq); + put_uint16_le(&tta_header.audio_format, 3); + put_uint16_le(&tta_header.channels, tracks[i].a_channels); + put_uint16_le(&tta_header.bits_per_sample, tracks[i].a_bps); + put_uint32_le(&tta_header.sample_rate, (int)tracks[i].a_sfreq); mxverb(2, "bw: %lld num: %d\n", tracks[i].bytes_written, tracks[i].frame_sizes.size()); if (tracks[i].last_duration <= 0) @@ -1078,24 +1078,24 @@ close_files() { tracks[i].a_sfreq) * 1000000000ll; mxverb(2, "ladu: %lld\n", tracks[i].last_duration); - put_uint32(&tta_header.data_length, + put_uint32_le(&tta_header.data_length, (uint32_t)(tracks[i].a_sfreq * (TTA_FRAME_TIME * (tracks[i].frame_sizes.size() - 1) + (double)tracks[i].last_duration / 1000000000.0l))); - put_uint32(&tta_header.crc, + put_uint32_le(&tta_header.crc, calc_crc32((unsigned char *)&tta_header, sizeof(tta_file_header_t) - 4)); tracks[i].out->write(&tta_header, sizeof(tta_file_header_t)); buffer = (unsigned char *)safemalloc(tracks[i].frame_sizes.size() * 4); for (k = 0; k < tracks[i].frame_sizes.size(); k++) - put_uint32(buffer + 4 * k, tracks[i].frame_sizes[k]); + put_uint32_le(buffer + 4 * k, tracks[i].frame_sizes[k]); tracks[i].out->write(buffer, tracks[i].frame_sizes.size() * 4); crc = calc_crc32(buffer, tracks[i].frame_sizes.size() * 4); mxverb(2, "crc: 0x%08x\n", crc); - tracks[i].out->write_uint32(crc); + tracks[i].out->write_uint32_le(crc); safefree(buffer); mxinfo(_("\nThe temporary TTA file for track ID %lld is being " @@ -1502,12 +1502,12 @@ extract_tracks(const char *file_name) { unsigned char *fcc = (unsigned char *)&bih->bi_compression; mxprints(pbuffer, " (FourCC: %c%c%c%c, 0x%08x)", fcc[0], fcc[1], fcc[2], fcc[3], - get_uint32(&bih->bi_compression)); + get_uint32_le(&bih->bi_compression)); } else if (ms_compat && (kax_track_type == 'a') && (c_priv.GetSize() >= sizeof(alWAVEFORMATEX))) { alWAVEFORMATEX *wfe = (alWAVEFORMATEX *)&binary(c_priv); mxprints(pbuffer, " (format tag: 0x%04x)", - get_uint16(&wfe->w_format_tag)); + get_uint16_le(&wfe->w_format_tag)); } else pbuffer[0] = 0; show_element(l3, 3, _("CodecPrivate, length %llu%s"), diff --git a/src/info/mkvinfo.cpp b/src/info/mkvinfo.cpp index c4ca4bbe0..aec206a68 100644 --- a/src/info/mkvinfo.cpp +++ b/src/info/mkvinfo.cpp @@ -995,13 +995,13 @@ def_handle(tracks) { fourcc_buffer = mxsprintf(" (FourCC: %c%c%c%c, 0x%08x)", fcc[0], fcc[1], fcc[2], fcc[3], - get_uint32(&bih->bi_compression)); + get_uint32_le(&bih->bi_compression)); } else if (ms_compat && (kax_track_type == 'a') && (c_priv.GetSize() >= sizeof(alWAVEFORMATEX))) { alWAVEFORMATEX *wfe = (alWAVEFORMATEX *)&binary(c_priv); fourcc_buffer = mxsprintf(" (format tag: 0x%04x)", - get_uint16(&wfe->w_format_tag)); + get_uint16_le(&wfe->w_format_tag)); } if (calc_checksums && !show_summary) fourcc_buffer += diff --git a/src/input/r_avi.cpp b/src/input/r_avi.cpp index f8295f758..f4bcf2b13 100644 --- a/src/input/r_avi.cpp +++ b/src/input/r_avi.cpp @@ -174,7 +174,7 @@ avi_reader_c::create_packetizer(int64_t tid) { ti->private_data = (unsigned char *)avi->bitmap_info_header; if (ti->private_data != NULL) - ti->private_size = get_uint32(&avi->bitmap_info_header->bi_size); + ti->private_size = get_uint32_le(&avi->bitmap_info_header->bi_size); ti->id = 0; // ID for the video track. vptzr = add_packetizer(new video_packetizer_c(this, NULL, AVI_frame_rate(avi), @@ -244,13 +244,14 @@ avi_reader_c::add_audio_demuxer(int aid) { demuxer.samples_per_second = AVI_audio_rate(avi); demuxer.channels = AVI_audio_channels(avi); demuxer.bits_per_sample = AVI_audio_bits(avi); - ti->avi_block_align = get_uint16(&wfe->n_block_align); - ti->avi_avg_bytes_per_sec = get_uint32(&wfe->n_avg_bytes_per_sec); - ti->avi_samples_per_chunk = get_uint32(&avi->stream_headers[aid].dw_scale); + ti->avi_block_align = get_uint16_le(&wfe->n_block_align); + ti->avi_avg_bytes_per_sec = get_uint32_le(&wfe->n_avg_bytes_per_sec); + ti->avi_samples_per_chunk = + get_uint32_le(&avi->stream_headers[aid].dw_scale); - if (get_uint16(&wfe->cb_size) > 0) { + if (get_uint16_le(&wfe->cb_size) > 0) { ti->private_data = (unsigned char *)(wfe + 1); - ti->private_size = get_uint16(&wfe->cb_size); + ti->private_size = get_uint16_le(&wfe->cb_size); } else { ti->private_data = NULL; ti->private_size = 0; diff --git a/src/input/r_matroska.cpp b/src/input/r_matroska.cpp index b6b01e8aa..8720e49fd 100644 --- a/src/input/r_matroska.cpp +++ b/src/input/r_matroska.cpp @@ -335,7 +335,7 @@ kax_reader_c::verify_tracks() { bih = (alBITMAPINFOHEADER *)t->private_data; - u = get_uint32(&bih->bi_width); + u = get_uint32_le(&bih->bi_width); if (t->v_width != u) { if (verbose) mxwarn(PFX "(MS compatibility " @@ -346,7 +346,7 @@ kax_reader_c::verify_tracks() { t->v_width = u; } - u = get_uint32(&bih->bi_height); + u = get_uint32_le(&bih->bi_height); if (t->v_height != u) { if (verbose) mxwarn(PFX "(MS compatibility " @@ -393,8 +393,8 @@ kax_reader_c::verify_tracks() { t->ms_compat = 1; wfe = (alWAVEFORMATEX *)t->private_data; - t->a_formattag = get_uint16(&wfe->w_format_tag); - u = get_uint32(&wfe->n_samples_per_sec); + t->a_formattag = get_uint16_le(&wfe->w_format_tag); + u = get_uint32_le(&wfe->n_samples_per_sec); if (((uint32_t)t->a_sfreq) != u) { if (verbose) mxwarn(PFX "(MS compatibility mode for " @@ -405,7 +405,7 @@ kax_reader_c::verify_tracks() { t->a_sfreq = (float)u; } - u = get_uint16(&wfe->n_channels); + u = get_uint16_le(&wfe->n_channels); if (t->a_channels != u) { if (verbose) mxwarn(PFX "(MS compatibility mode for " @@ -416,7 +416,7 @@ kax_reader_c::verify_tracks() { t->a_channels = u; } - u = get_uint16(&wfe->w_bits_per_sample); + u = get_uint16_le(&wfe->w_bits_per_sample); if (t->a_bps != u) { if (verbose && (t->a_formattag == 0x0001)) mxwarn(PFX "(MS compatibility mode for " diff --git a/src/input/r_ogm.cpp b/src/input/r_ogm.cpp index 1440d9d93..dae4610db 100644 --- a/src/input/r_ogm.cpp +++ b/src/input/r_ogm.cpp @@ -77,13 +77,13 @@ extract_vorbis_comments(unsigned char *buffer, comments = NULL; try { in.skip(7); // 0x03 "vorbis" - n = in.read_uint32(); // vendor_length + n = in.read_uint32_le(); // vendor_length in.skip(n); // vendor_string - n = in.read_uint32(); // user_comment_list_length + n = in.read_uint32_le(); // user_comment_list_length comments = (char **)safemalloc((n + 1) * sizeof(char *)); memset(comments, 0, (n + 1) * sizeof(char *)); for (i = 0; i < n; i++) { - len = in.read_uint32(); + len = in.read_uint32_le(); comments[i] = (char *)safemalloc(len + 1); if (in.read(comments[i], len) != len) throw false; @@ -414,21 +414,21 @@ ogm_reader_c::create_packetizer(int64_t tid) { case OGM_STREAM_TYPE_VIDEO: // AVI compatibility mode. Fill in the values we've got and guess // the others. - put_uint32(&bih.bi_size, sizeof(alBITMAPINFOHEADER)); - put_uint32(&bih.bi_width, get_uint32(&sth->sh.video.width)); - put_uint32(&bih.bi_height, get_uint32(&sth->sh.video.height)); - put_uint16(&bih.bi_planes, 1); - put_uint16(&bih.bi_bit_count, 24); + put_uint32_le(&bih.bi_size, sizeof(alBITMAPINFOHEADER)); + put_uint32_le(&bih.bi_width, get_uint32_le(&sth->sh.video.width)); + put_uint32_le(&bih.bi_height, get_uint32_le(&sth->sh.video.height)); + put_uint16_le(&bih.bi_planes, 1); + put_uint16_le(&bih.bi_bit_count, 24); memcpy(&bih.bi_compression, sth->subtype, 4); - put_uint32(&bih.bi_size_image, get_uint32(&bih.bi_width) * - get_uint32(&bih.bi_height) * 3); + put_uint32_le(&bih.bi_size_image, get_uint32_le(&bih.bi_width) * + get_uint32_le(&bih.bi_height) * 3); ti->private_data = (unsigned char *)&bih; ti->private_size = sizeof(alBITMAPINFOHEADER); ptzr = new video_packetizer_c(this, NULL, (double)10000000.0 / - get_uint64(&sth->time_unit), - get_uint32(&sth->sh.video.width), - get_uint32(&sth->sh.video.height), + get_uint64_le(&sth->time_unit), + get_uint32_le(&sth->sh.video.width), + get_uint32_le(&sth->sh.video.height), false, ti); mxinfo(FMT_TID "Using the video output module.\n", ti->fname.c_str(), @@ -438,25 +438,28 @@ ogm_reader_c::create_packetizer(int64_t tid) { break; case OGM_STREAM_TYPE_PCM: - ptzr = new pcm_packetizer_c(this, get_uint64(&sth->samples_per_unit), - get_uint16(&sth->sh.audio.channels), - get_uint16(&sth->bits_per_sample), ti); + ptzr = new pcm_packetizer_c(this, + get_uint64_le(&sth->samples_per_unit), + get_uint16_le(&sth->sh.audio.channels), + get_uint16_le(&sth->bits_per_sample), ti); mxinfo(FMT_TID "Using the PCM output module.\n", ti->fname.c_str(), (int64_t)tid); break; case OGM_STREAM_TYPE_MP3: - ptzr = new mp3_packetizer_c(this, get_uint64(&sth->samples_per_unit), - get_uint16(&sth->sh.audio.channels), + ptzr = new mp3_packetizer_c(this, + get_uint64_le(&sth->samples_per_unit), + get_uint16_le(&sth->sh.audio.channels), true, ti); mxinfo(FMT_TID "Using the MP3 output module.\n", ti->fname.c_str(), (int64_t)tid); break; case OGM_STREAM_TYPE_AC3: - ptzr = new ac3_packetizer_c(this, get_uint64(&sth->samples_per_unit), - get_uint16(&sth->sh.audio.channels), 0, + ptzr = new ac3_packetizer_c(this, + get_uint64_le(&sth->samples_per_unit), + get_uint16_le(&sth->sh.audio.channels), 0, ti); mxinfo(FMT_TID "Using the AC3 output module.\n", ti->fname.c_str(), (int64_t)tid); @@ -477,8 +480,8 @@ ogm_reader_c::create_packetizer(int64_t tid) { } if (!aac_info_extracted) { sbr = false; - channels = get_uint16(&sth->sh.audio.channels); - sample_rate = get_uint64(&sth->samples_per_unit); + channels = get_uint16_le(&sth->sh.audio.channels); + sample_rate = get_uint64_le(&sth->samples_per_unit); profile = AAC_PROFILE_LC; } mxverb(2, "ogm_reader: %lld/%s: profile %d, channels %d, sample_rate " @@ -681,7 +684,7 @@ ogm_reader_c::handle_new_stream(ogg_page *og) { dmx->stype = OGM_STREAM_TYPE_VIDEO; dmx->native_mode = false; if (video_fps < 0) - video_fps = 10000000.0 / (float)get_uint64(&sth->time_unit); + video_fps = 10000000.0 / (float)get_uint64_le(&sth->time_unit); dmx->in_use = true; return; diff --git a/src/input/r_qtmp4.cpp b/src/input/r_qtmp4.cpp index b633c5abd..a299223a5 100644 --- a/src/input/r_qtmp4.cpp +++ b/src/input/r_qtmp4.cpp @@ -1105,7 +1105,8 @@ qtmp4_reader_c::parse_esds_atom(mm_mem_io_c &memio, throw exception(); mxverb(2, PFX "%*sesds: decoder specific descriptor, len: %u\n", lsp, "", len); - mxverb(3, PFX "%*sesds: dumping decoder specific descriptor\n", lsp + 2, ""); + mxverb(3, PFX "%*sesds: dumping decoder specific descriptor\n", lsp + 2, + ""); mxhexdump(3, e->decoder_config, e->decoder_config_len); tag = memio.read_uint8(); @@ -1152,14 +1153,14 @@ qtmp4_reader_c::create_packetizer(int64_t tid) { bih = (alBITMAPINFOHEADER *) safemalloc(sizeof(alBITMAPINFOHEADER)); memset(bih, 0, sizeof(alBITMAPINFOHEADER)); - put_uint32(&bih->bi_size, sizeof(alBITMAPINFOHEADER)); - put_uint32(&bih->bi_width, dmx->v_width); - put_uint32(&bih->bi_height, dmx->v_height); - put_uint16(&bih->bi_planes, 1); - put_uint16(&bih->bi_bit_count, dmx->v_bitdepth); + put_uint32_le(&bih->bi_size, sizeof(alBITMAPINFOHEADER)); + put_uint32_le(&bih->bi_width, dmx->v_width); + put_uint32_le(&bih->bi_height, dmx->v_height); + put_uint16_le(&bih->bi_planes, 1); + put_uint16_le(&bih->bi_bit_count, dmx->v_bitdepth); memcpy(&bih->bi_compression, "DIVX", 4); - put_uint32(&bih->bi_size_image, get_uint32(&bih->bi_width) * - get_uint32(&bih->bi_height) * 3); + put_uint32_le(&bih->bi_size_image, get_uint32_le(&bih->bi_width) * + get_uint32_le(&bih->bi_height) * 3); ti->private_size = sizeof(alBITMAPINFOHEADER); ti->private_data = (unsigned char *)bih; dmx->ptzr = diff --git a/src/input/r_tta.cpp b/src/input/r_tta.cpp index 6befd352b..d82b2e9df 100644 --- a/src/input/r_tta.cpp +++ b/src/input/r_tta.cpp @@ -76,14 +76,16 @@ tta_reader_c::tta_reader_c(track_info_c *nti) size -= id3_tag_present_at_end(*mm_io); do { - seek_point = mm_io->read_uint32(); + seek_point = mm_io->read_uint32_le(); seek_sum += seek_point + 4; seek_points.push_back(seek_point); } while (seek_sum < size); mxverb(2, "tta: ch %u bps %u sr %u dl %u seek_sum %lld size %lld num %u\n", - get_uint16(&header.channels), get_uint16(&header.bits_per_sample), - get_uint32(&header.sample_rate), get_uint32(&header.data_length), + get_uint16_le(&header.channels), + get_uint16_le(&header.bits_per_sample), + get_uint32_le(&header.sample_rate), + get_uint32_le(&header.data_length), seek_sum, size, seek_points.size()); if (seek_sum != size) @@ -113,9 +115,9 @@ tta_reader_c::create_packetizer(int64_t) { if (NPTZR() != 0) return; - ttapacketizer = new tta_packetizer_c(this, get_uint16(&header.channels), - get_uint16(&header.bits_per_sample), - get_uint32(&header.sample_rate), ti); + ttapacketizer = new tta_packetizer_c(this, get_uint16_le(&header.channels), + get_uint16_le(&header.bits_per_sample), + get_uint32_le(&header.sample_rate), ti); add_packetizer(ttapacketizer); mxinfo(FMT_TID "Using the TTA output module.\n", ti->fname.c_str(), (int64_t)0); @@ -142,13 +144,13 @@ tta_reader_c::read(generic_packetizer_c *, if (pos >= seek_points.size()) { double samples_left; - samples_left = (double)get_uint32(&header.data_length) - + samples_left = (double)get_uint32_le(&header.data_length) - (seek_points.size() - 1) * TTA_FRAME_TIME * - get_uint32(&header.sample_rate); + get_uint32_le(&header.sample_rate); mxverb(2, "tta: samples_left %f\n", samples_left); PTZR0->process(mem, -1, irnd(samples_left * 1000000000.0l / - get_uint32(&header.sample_rate))); + get_uint32_le(&header.sample_rate))); } else PTZR0->process(mem); bytes_processed += nread; diff --git a/src/input/r_wav.cpp b/src/input/r_wav.cpp index 12598cbec..d2839c627 100644 --- a/src/input/r_wav.cpp +++ b/src/input/r_wav.cpp @@ -83,9 +83,9 @@ wav_reader_c::wav_reader_c(track_info_c *nti) throw error_c("wav_reader: Source is not a valid WAVE file."); if (mm_io->read(&wheader, sizeof(wheader)) != sizeof(wheader)) throw error_c("wav_reader: could not read WAVE header."); - bps = get_uint16(&wheader.common.wChannels) * - get_uint16(&wheader.common.wBitsPerSample) * - get_uint32(&wheader.common.dwSamplesPerSec) / 8; + bps = get_uint16_le(&wheader.common.wChannels) * + get_uint16_le(&wheader.common.wBitsPerSample) * + get_uint32_le(&wheader.common.dwSamplesPerSec) / 8; chunk = (unsigned char *)safemalloc(bps + 1); bytes_processed = 0; ti->id = 0; // ID for this track. @@ -94,10 +94,10 @@ wav_reader_c::wav_reader_c(track_info_c *nti) while (1) { if (!strncmp((char *)wheader.data.id, "data", 4)) break; - if ((mm_io->getFilePointer() + get_uint32(&wheader.data.len) + + if ((mm_io->getFilePointer() + get_uint32_le(&wheader.data.len) + sizeof(struct chunk_struct)) > size) throw error_c("wav_reader: No 'data' chunk found."); - mm_io->setFilePointer(get_uint32(&wheader.data.len), seek_current); + mm_io->setFilePointer(get_uint32_le(&wheader.data.len), seek_current); if (mm_io->read(&wheader.data, sizeof(struct chunk_struct)) != sizeof(struct chunk_struct)) throw error_c("wav_reader: No 'data' chunk found."); @@ -156,9 +156,10 @@ wav_reader_c::create_packetizer(int64_t) { if (!is_dts) { generic_packetizer_c *ptzr; ptzr = - new pcm_packetizer_c(this, get_uint32(&wheader.common.dwSamplesPerSec), - get_uint16(&wheader.common.wChannels), - get_uint16(&wheader.common.wBitsPerSample), ti); + new pcm_packetizer_c(this, + get_uint32_le(&wheader.common.dwSamplesPerSec), + get_uint16_le(&wheader.common.wChannels), + get_uint16_le(&wheader.common.wBitsPerSample), ti); add_packetizer(ptzr); mxinfo(FMT_TID "Using the PCM output module.\n", ti->fname.c_str(), (int64_t)0); @@ -245,7 +246,7 @@ wav_reader_c::read(generic_packetizer_c *, int wav_reader_c::get_progress() { - return 100 * bytes_processed / (get_uint32(&wheader.riff.len) - + return 100 * bytes_processed / (get_uint32_le(&wheader.riff.len) - sizeof(wheader) + 8); } diff --git a/src/input/r_wavpack.cpp b/src/input/r_wavpack.cpp index faf92c654..b31a3b9a5 100644 --- a/src/input/r_wavpack.cpp +++ b/src/input/r_wavpack.cpp @@ -40,7 +40,7 @@ wavpack_reader_c::probe_file(mm_io_c *mm_io, return 0; } if (!strncmp(header.ck_id, "wvpk", 4)) { - header.version = get_uint16(&header.version); + header.version = get_uint16_le(&header.version); if ((header.version >> 8) == 4) return 1; } @@ -120,14 +120,14 @@ wavpack_reader_c::read(generic_packetizer_c *ptzr, WV_KEEP_HEADER_POSITION); // keep the header minus the ID & size (all found in Matroska) - put_uint16(chunk, dummy_header.version); + put_uint16_le(chunk, dummy_header.version); chunk[2] = dummy_header.track_no; chunk[3] = dummy_header.index_no; - put_uint32(&chunk[4], dummy_header.total_samples); - put_uint32(&chunk[8], dummy_header.block_index); - put_uint32(&chunk[12], dummy_header.block_samples); - put_uint32(&chunk[16], dummy_header.flags); - put_uint32(&chunk[20], dummy_header.crc); + put_uint32_le(&chunk[4], dummy_header.total_samples); + put_uint32_le(&chunk[8], dummy_header.block_index); + put_uint32_le(&chunk[12], dummy_header.block_samples); + put_uint32_le(&chunk[16], dummy_header.flags); + put_uint32_le(&chunk[20], dummy_header.crc); if (mm_io->read(&chunk[sizeof(wavpack_header_t) - WV_KEEP_HEADER_POSITION], data_size) < 0) diff --git a/src/merge/cluster_helper.cpp b/src/merge/cluster_helper.cpp index c2b8814b2..d02f28247 100644 --- a/src/merge/cluster_helper.cpp +++ b/src/merge/cluster_helper.cpp @@ -511,7 +511,8 @@ cluster_helper_c::render_cluster(ch_contents_t *clstr) { else if (write_cues && !added_to_cues) { // Update the cues (index table) either if cue entries for // I frames were requested and this is an I frame... - if (((source->get_cue_creation() == CUE_STRATEGY_IFRAMES) && (pack->bref == -1)) + if (((source->get_cue_creation() == CUE_STRATEGY_IFRAMES) && + (pack->bref == -1)) || // ... or if the user requested entries for all frames ... (source->get_cue_creation() == CUE_STRATEGY_ALL) || diff --git a/src/merge/mkvmerge.cpp b/src/merge/mkvmerge.cpp index 73e3cdf28..5b3b5c9f0 100644 --- a/src/merge/mkvmerge.cpp +++ b/src/merge/mkvmerge.cpp @@ -76,7 +76,7 @@ file_type_t file_types[] = {"mp2 ", FILE_TYPE_MP3, "MPEG-1 layer II audio (CBR and VBR/ABR)"}, {"mp3 ", FILE_TYPE_MP3, "MPEG-1 layer III audio (CBR and VBR/ABR)"}, {"mkv ", FILE_TYPE_MATROSKA, "general Matroska files"}, - {"ogg ", FILE_TYPE_OGM, "general OGG media stream, audio/video embedded in OGG"}, + {"ogg ", FILE_TYPE_OGM, "audio/video embedded in OGG"}, {"mov ", FILE_TYPE_QTMP4, "Quicktime/MP4 audio and video"}, {"rm ", FILE_TYPE_REAL, "RealMedia audio and video"}, {"srt ", FILE_TYPE_SRT, "SRT text subtitles"}, diff --git a/src/output/p_wavpack.cpp b/src/output/p_wavpack.cpp index 4e4ed7e87..bf26b4b0f 100644 --- a/src/output/p_wavpack.cpp +++ b/src/output/p_wavpack.cpp @@ -59,8 +59,8 @@ wavpack_packetizer_c::process(memory_c &mem, int64_t, int64_t) { debug_enter("wavpack_packetizer_c::process"); - int64_t samples = get_uint32(&mem.data[12]); - int64_t sample_index = get_uint32(&mem.data[8]); + int64_t samples = get_uint32_le(&mem.data[12]); + int64_t sample_index = get_uint32_le(&mem.data[8]); if (duration == -1) { add_packet(mem, irnd(sample_index * 1000000000 / sample_rate),