From: <man...@us...> - 2015-03-04 14:43:04
|
Revision: 4824 http://sourceforge.net/p/modplug/code/4824 Author: manxorist Date: 2015-03-04 14:42:51 +0000 (Wed, 04 Mar 2015) Log Message: ----------- [Fix] Stream Export: Cleanup a couple of 64bit warnings. Modified Paths: -------------- trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp Modified: trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2015-03-04 13:50:05 UTC (rev 4823) +++ trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2015-03-04 14:42:51 UTC (rev 4824) @@ -239,7 +239,12 @@ } break; } - FLAC__stream_encoder_process_interleaved(encoder, &sampleBuf[0], frameCount); + while(frameCount > 0) + { + unsigned int frameCountChunk = mpt::saturate_cast<unsigned int>(frameCount); + FLAC__stream_encoder_process_interleaved(encoder, &sampleBuf[0], frameCountChunk); + frameCount -= frameCountChunk; + } } virtual void Finalize() { Modified: trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2015-03-04 13:50:05 UTC (rev 4823) +++ trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2015-03-04 14:42:51 UTC (rev 4824) @@ -872,7 +872,7 @@ } DWORD size = 0; buf.resize(blade_outputbytes); - blade.beEncodeChunk(bestream, samples.size(), &samples[0], (PBYTE)&buf[0], &size); + blade.beEncodeChunk(bestream, static_cast<DWORD>(samples.size()), &samples[0], (PBYTE)&buf[0], &size); ASSERT(size <= buf.size()); buf.resize(size); WriteBuffer(); @@ -891,7 +891,7 @@ blade_sampleBuf.clear(); DWORD size = 0; buf.resize(blade_outputbytes); - blade.beEncodeChunk(bestream, samples.size(), &samples[0], (PBYTE)&buf[0], &size); + blade.beEncodeChunk(bestream, static_cast<DWORD>(samples.size()), &samples[0], (PBYTE)&buf[0], &size); ASSERT(size <= buf.size()); buf.resize(size); WriteBuffer(); @@ -1366,9 +1366,9 @@ acm_sampleBuf.pop_front(); } std::memcpy(&acmSrcBuf[0], &samples[0], acmSrcBuf.size()); - acmHeader.cbSrcLength = acmSrcBuf.size(); + acmHeader.cbSrcLength = static_cast<DWORD>(acmSrcBuf.size()); acmHeader.cbSrcLengthUsed = 0; - acmHeader.cbDstLength = acmDstBuf.size(); + acmHeader.cbDstLength = static_cast<DWORD>(acmDstBuf.size()); acmHeader.cbDstLengthUsed = 0; acmStreamConvert(acmStream, &acmHeader, ACM_STREAMCONVERTF_BLOCKALIGN); if(acmHeader.cbDstLengthUsed) @@ -1405,9 +1405,9 @@ } std::memcpy(&acmSrcBuf[0], &samples[0], samples.size() * sizeof(int16)); } - acmHeader.cbSrcLength = samples.size() * sizeof(int16); + acmHeader.cbSrcLength = static_cast<DWORD>(samples.size() * sizeof(int16)); acmHeader.cbSrcLengthUsed = 0; - acmHeader.cbDstLength = acmDstBuf.size(); + acmHeader.cbDstLength = static_cast<DWORD>(acmDstBuf.size()); acmHeader.cbDstLengthUsed = 0; acmStreamConvert(acmStream, &acmHeader, ACM_STREAMCONVERTF_END); if(acmHeader.cbDstLengthUsed) Modified: trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp 2015-03-04 13:50:05 UTC (rev 4823) +++ trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp 2015-03-04 14:42:51 UTC (rev 4824) @@ -233,7 +233,7 @@ const char *version_string = opus.opus_get_version_string ? opus.opus_get_version_string() : nullptr; if(version_string) { - PushUint32LE(opus_comments_buf, std::strlen(version_string)); + PushUint32LE(opus_comments_buf, mpt::saturate_cast<uint32>(std::strlen(version_string))); for(/*nothing*/; *version_string; ++version_string) { opus_comments_buf.push_back(*version_string); @@ -242,17 +242,17 @@ { PushUint32LE(opus_comments_buf, 0); } - PushUint32LE(opus_comments_buf, opus_comments.size()); + PushUint32LE(opus_comments_buf, mpt::saturate_cast<uint32>(opus_comments.size())); for(std::vector<std::string>::const_iterator it = opus_comments.begin(); it != opus_comments.end(); ++it) { - PushUint32LE(opus_comments_buf, it->length()); + PushUint32LE(opus_comments_buf, mpt::saturate_cast<uint32>(it->length())); for(std::size_t i = 0; i < it->length(); ++i) { opus_comments_buf.push_back((*it)[i]); } } op.packet = &opus_comments_buf[0]; - op.bytes = opus_comments_buf.size(); + op.bytes = mpt::saturate_cast<long>(opus_comments_buf.size()); op.b_o_s = 0; op.e_o_s = 0; op.granulepos = 0; @@ -284,7 +284,7 @@ WriteInterleaved(opus_extrasamples, &extraBuf[0]); int cur_frame_size = 960 * opus_samplerate / 48000; - int last_frame_size = (opus_sampleBuf.size() / opus_channels) * opus_samplerate / 48000; + int last_frame_size = (static_cast<int>(opus_sampleBuf.size()) / opus_channels) * opus_samplerate / 48000; opus_frameBuf.resize(opus_channels * cur_frame_size); for(size_t sample = 0; sample < opus_frameBuf.size(); ++sample) @@ -299,7 +299,7 @@ opus_sampleBuf.clear(); opus_frameData.resize(65536); - opus_frameData.resize(opus.opus_multistream_encode_float(st, &opus_frameBuf[0], cur_frame_size, &opus_frameData[0], opus_frameData.size())); + opus_frameData.resize(opus.opus_multistream_encode_float(st, &opus_frameBuf[0], cur_frame_size, &opus_frameData[0], static_cast<opus_int32>(opus_frameData.size()))); enc_granulepos += last_frame_size * 48000 / opus_samplerate; op.b_o_s = 0; @@ -307,7 +307,7 @@ op.granulepos = enc_granulepos; op.packetno = packetno; op.packet = &opus_frameData[0]; - op.bytes = opus_frameData.size(); + op.bytes = static_cast<long>(opus_frameData.size()); opus.ogg_stream_packetin(&os, &op); packetno++; @@ -535,7 +535,7 @@ } opus_frameData.resize(65536); - opus_frameData.resize(opus.opus_multistream_encode_float(st, &opus_frameBuf[0], cur_frame_size, &opus_frameData[0], opus_frameData.size())); + opus_frameData.resize(opus.opus_multistream_encode_float(st, &opus_frameBuf[0], cur_frame_size, &opus_frameData[0], static_cast<opus_int32>(opus_frameData.size()))); enc_granulepos += cur_frame_size * 48000 / opus_samplerate; op.b_o_s = 0; @@ -543,7 +543,7 @@ op.granulepos = enc_granulepos; op.packetno = packetno; op.packet = &opus_frameData[0]; - op.bytes = opus_frameData.size(); + op.bytes = static_cast<long>(opus_frameData.size()); opus.ogg_stream_packetin(&os, &op); packetno++; Modified: trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2015-03-04 13:50:05 UTC (rev 4823) +++ trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2015-03-04 14:42:51 UTC (rev 4824) @@ -361,29 +361,35 @@ StartStream(); } ASSERT(inited && started); - float **buffer = vorbis.vorbis_analysis_buffer(&vd, count); - for(size_t frame = 0; frame < count; ++frame) + size_t countTotal = count; + while(countTotal > 0) { - for(int channel = 0; channel < vorbis_channels; ++channel) + int countChunk = mpt::saturate_cast<int>(countTotal); + countTotal -= countChunk; + float **buffer = vorbis.vorbis_analysis_buffer(&vd, countChunk); + for(int frame = 0; frame < countChunk; ++frame) { - buffer[channel][frame] = interleaved[frame*vorbis_channels+channel]; + for(int channel = 0; channel < vorbis_channels; ++channel) + { + buffer[channel][frame] = interleaved[frame*vorbis_channels+channel]; + } } - } - vorbis.vorbis_analysis_wrote(&vd, count); - while(vorbis.vorbis_analysis_blockout(&vd, &vb) == 1) - { - vorbis.vorbis_analysis(&vb, NULL); - vorbis.vorbis_bitrate_addblock(&vb); - while(vorbis.vorbis_bitrate_flushpacket(&vd, &op)) + vorbis.vorbis_analysis_wrote(&vd, countChunk); + while(vorbis.vorbis_analysis_blockout(&vd, &vb) == 1) { - vorbis.ogg_stream_packetin(&os, &op); - while(true) + vorbis.vorbis_analysis(&vb, NULL); + vorbis.vorbis_bitrate_addblock(&vb); + while(vorbis.vorbis_bitrate_flushpacket(&vd, &op)) { - int gotPage = vorbis.ogg_stream_pageout(&os, &og); - if(!gotPage) break; - WritePage(); + vorbis.ogg_stream_packetin(&os, &op); + while(true) + { + int gotPage = vorbis.ogg_stream_pageout(&os, &og); + if(!gotPage) break; + WritePage(); + } } - } + } } } virtual void Finalize() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |