diff options
author | Chris Robinson <[email protected]> | 2023-12-23 03:07:57 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-12-23 03:07:57 -0800 |
commit | 4720b2c64d91facea24e8411c104770bd3763afa (patch) | |
tree | 7ab1cc05e307be0b18ef6cc3cc8a84ece8dae624 /examples | |
parent | d7304c49a1d2cea2dae0ae38fdd9706dbcdb561f (diff) |
Fix implicit widening after multiplication
Diffstat (limited to 'examples')
-rw-r--r-- | examples/alffplay.cpp | 16 | ||||
-rw-r--r-- | examples/alstream.c | 12 |
2 files changed, 14 insertions, 14 deletions
diff --git a/examples/alffplay.cpp b/examples/alffplay.cpp index 7a4b7aac..890ecedb 100644 --- a/examples/alffplay.cpp +++ b/examples/alffplay.cpp @@ -285,7 +285,7 @@ struct AudioState { AVStream *mStream{nullptr}; AVCodecCtxPtr mCodecCtx; - DataQueue<2*1024*1024> mQueue; + DataQueue<size_t{2}*1024*1024> mQueue; /* Used for clock difference average computation */ seconds_d64 mClockDiffAvg{0}; @@ -372,7 +372,7 @@ struct VideoState { AVStream *mStream{nullptr}; AVCodecCtxPtr mCodecCtx; - DataQueue<14*1024*1024> mQueue; + DataQueue<size_t{14}*1024*1024> mQueue; /* The pts of the currently displayed frame, and the time (av_gettime) it * was last updated - used to have running video pts @@ -738,8 +738,8 @@ bool AudioState::readAudio(uint8_t *samples, unsigned int length, int &sample_sk { const auto len = static_cast<unsigned int>(mSamplesLen - mSamplesPos); if(rem > len) rem = len; - std::copy_n(mSamples + static_cast<unsigned int>(mSamplesPos)*mFrameSize, - rem*mFrameSize, samples); + std::copy_n(mSamples + static_cast<unsigned int>(mSamplesPos)*size_t{mFrameSize}, + rem*size_t{mFrameSize}, samples); } else { @@ -751,7 +751,7 @@ bool AudioState::readAudio(uint8_t *samples, unsigned int length, int &sample_sk mSamplesPos += static_cast<int>(rem); mCurrentPts += nanoseconds{seconds{rem}} / mCodecCtx->sample_rate; - samples += rem*mFrameSize; + samples += rem*size_t{mFrameSize}; audio_size += rem; while(mSamplesPos >= mSamplesLen) @@ -1165,7 +1165,7 @@ int AudioState::handler() * ordering and normalization, so a custom matrix is needed to * scale and reorder the source from AmbiX. */ - std::vector<double> mtx(64*64, 0.0); + std::vector<double> mtx(size_t{64}*64, 0.0); mtx[0 + 0*64] = std::sqrt(0.5); mtx[3 + 1*64] = 1.0; mtx[1 + 2*64] = 1.0; @@ -1546,8 +1546,8 @@ void VideoState::updateVideo(SDL_Window *screen, SDL_Renderer *renderer, bool re /* point pict at the queue */ std::array<uint8_t*,3> pict_data; pict_data[0] = static_cast<uint8_t*>(pixels); - pict_data[1] = pict_data[0] + w*h; - pict_data[2] = pict_data[1] + w*h/4; + pict_data[1] = pict_data[0] + ptrdiff_t{w}*h; + pict_data[2] = pict_data[1] + ptrdiff_t{w}*h/4; std::array pict_linesize{pitch, pitch/2, pitch/2}; diff --git a/examples/alstream.c b/examples/alstream.c index 5cbbc2a7..c781f3d7 100644 --- a/examples/alstream.c +++ b/examples/alstream.c @@ -338,21 +338,21 @@ static int StartPlayer(StreamPlayer *player) if(player->sample_type == Int16) { slen = sf_readf_short(player->sndfile, player->membuf, - player->block_count * player->sampleblockalign); + (sf_count_t)player->block_count * player->sampleblockalign); if(slen < 1) break; slen *= player->byteblockalign; } else if(player->sample_type == Float) { slen = sf_readf_float(player->sndfile, player->membuf, - player->block_count * player->sampleblockalign); + (sf_count_t)player->block_count * player->sampleblockalign); if(slen < 1) break; slen *= player->byteblockalign; } else { slen = sf_read_raw(player->sndfile, player->membuf, - player->block_count * player->byteblockalign); + (sf_count_t)player->block_count * player->byteblockalign); if(slen > 0) slen -= slen%player->byteblockalign; if(slen < 1) break; } @@ -409,19 +409,19 @@ static int UpdatePlayer(StreamPlayer *player) if(player->sample_type == Int16) { slen = sf_readf_short(player->sndfile, player->membuf, - player->block_count * player->sampleblockalign); + (sf_count_t)player->block_count * player->sampleblockalign); if(slen > 0) slen *= player->byteblockalign; } else if(player->sample_type == Float) { slen = sf_readf_float(player->sndfile, player->membuf, - player->block_count * player->sampleblockalign); + (sf_count_t)player->block_count * player->sampleblockalign); if(slen > 0) slen *= player->byteblockalign; } else { slen = sf_read_raw(player->sndfile, player->membuf, - player->block_count * player->byteblockalign); + (sf_count_t)player->block_count * player->byteblockalign); if(slen > 0) slen -= slen%player->byteblockalign; } |