diff --git a/.github/workflows/security-regressions.yml b/.github/workflows/security-regressions.yml new file mode 100644 index 00000000000..e2fddfce727 --- /dev/null +++ b/.github/workflows/security-regressions.yml @@ -0,0 +1,67 @@ +name: Security regression tests +on: + pull_request: + branches: [master] + paths: + - 'Tests/CodeScanning/**' + - 'third-party/**' + - 'Telegram/WatchApp/Packages/**' + - 'submodules/CompanionRenderer/**' + - 'submodules/ffmpeg/**' + - 'submodules/TelegramUI/Components/RichTextEditor/Host/Engine/Scripts/ime_keyboard_contract.py' + - 'submodules/TelegramUI/Components/RichTextEditor/Host/Engine/Scripts/tests/test_ime_keyboard_contract.py' + - '.github/workflows/security-regressions.yml' + push: + branches: [master] + paths: + - 'Tests/CodeScanning/**' + - 'third-party/**' + - 'Telegram/WatchApp/Packages/**' + - 'submodules/CompanionRenderer/**' + - 'submodules/ffmpeg/**' + - 'submodules/TelegramUI/Components/RichTextEditor/Host/Engine/Scripts/ime_keyboard_contract.py' + - 'submodules/TelegramUI/Components/RichTextEditor/Host/Engine/Scripts/tests/test_ime_keyboard_contract.py' + - '.github/workflows/security-regressions.yml' +permissions: + contents: read +jobs: + parser: + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Escaped and adversarial keyboard defaults + working-directory: submodules/TelegramUI/Components/RichTextEditor/Host/Engine/Scripts/tests + run: >- + python3 -m unittest + test_ime_keyboard_contract.IMEKeyboardContractTests.test_defaults_inventory_parser_rejects_malformed_output + test_ime_keyboard_contract.IMEKeyboardContractTests.test_defaults_inventory_parser_handles_escapes_and_rejects_long_invalid_strings + codecs: + runs-on: macos-26 + timeout-minutes: 30 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Native codec test dependencies + run: | + if ! pkg-config --exists libavcodec libavformat libavutil libswscale; then + brew install pkg-config ffmpeg + fi + - name: OpenH264 and Subcodec round-trip regression suites + run: python3 Tests/CodeScanning/native_regressions.py + watch-codecs: + runs-on: macos-26 + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + package: [OpusKit, WebPKit, RLottieKit] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Package codec regression tests + run: swift test --package-path Telegram/WatchApp/Packages/${{ matrix.package }} diff --git a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/celt/celt_encoder.c b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/celt/celt_encoder.c index 7f32a801c60..67371f7ec73 100644 --- a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/celt/celt_encoder.c +++ b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/celt/celt_encoder.c @@ -138,7 +138,7 @@ OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_get_size(const CELTMode *mode, int int size = sizeof(struct CELTEncoder) + (channels*mode->overlap-1)*sizeof(celt_sig) /* celt_sig in_mem[channels*mode->overlap]; */ + channels*COMBFILTER_MAXPERIOD*sizeof(celt_sig) /* celt_sig prefilter_mem[channels*COMBFILTER_MAXPERIOD]; */ - + 4*channels*mode->nbEBands*sizeof(opus_val16); /* opus_val16 oldBandE[channels*mode->nbEBands]; */ + + (unsigned long)(4)*channels*mode->nbEBands*sizeof(opus_val16); /* opus_val16 oldBandE[channels*mode->nbEBands]; */ /* opus_val16 oldLogE[channels*mode->nbEBands]; */ /* opus_val16 oldLogE2[channels*mode->nbEBands]; */ /* opus_val16 energyError[channels*mode->nbEBands]; */ diff --git a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/celt/opus_custom_demo.c b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/celt/opus_custom_demo.c index ae41c0de5a2..9f5abe77cbe 100644 --- a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/celt/opus_custom_demo.c +++ b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/celt/opus_custom_demo.c @@ -125,8 +125,8 @@ int main(int argc, char *argv[]) opus_custom_encoder_ctl(enc,OPUS_SET_COMPLEXITY(complexity)); } - in = (opus_int16*)malloc(frame_size*channels*sizeof(opus_int16)); - out = (opus_int16*)malloc(frame_size*channels*sizeof(opus_int16)); + in = (opus_int16*)malloc((unsigned long)(frame_size)*channels*sizeof(opus_int16)); + out = (opus_int16*)malloc((unsigned long)(frame_size)*channels*sizeof(opus_int16)); while (!feof(fin)) { diff --git a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/celt/tests/test_unit_mathops.c b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/celt/tests/test_unit_mathops.c index 0615448db2e..6f1ca6657f6 100644 --- a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/celt/tests/test_unit_mathops.c +++ b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/celt/tests/test_unit_mathops.c @@ -58,7 +58,7 @@ void testdiv(void) #ifdef FIXED_POINT prod = (1./32768./65526.)*val*i; #else - prod = val*i; + prod = (double)(val)*i; #endif if (fabs(prod-1) > .00025) { diff --git a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/silk/CNG.c b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/silk/CNG.c index 2a910099ed3..d4371b47c4f 100644 --- a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/silk/CNG.c +++ b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/silk/CNG.c @@ -112,7 +112,7 @@ void silk_CNG( } } /* Update CNG excitation buffer with excitation from this subframe */ - silk_memmove( &psCNG->CNG_exc_buf_Q14[ psDec->subfr_length ], psCNG->CNG_exc_buf_Q14, ( psDec->nb_subfr - 1 ) * psDec->subfr_length * sizeof( opus_int32 ) ); + silk_memmove( &psCNG->CNG_exc_buf_Q14[ psDec->subfr_length ], psCNG->CNG_exc_buf_Q14, (unsigned long)(( psDec->nb_subfr - 1 )) * psDec->subfr_length * sizeof( opus_int32 ) ); silk_memcpy( psCNG->CNG_exc_buf_Q14, &psDec->exc_Q14[ subfr * psDec->subfr_length ], psDec->subfr_length * sizeof( opus_int32 ) ); /* Smooth gains */ diff --git a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/silk/float/burg_modified_FLP.c b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/silk/float/burg_modified_FLP.c index f5bef5ddbed..a800bf6ee7f 100644 --- a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/silk/float/burg_modified_FLP.c +++ b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/silk/float/burg_modified_FLP.c @@ -80,8 +80,8 @@ silk_float silk_burg_modified_FLP( /* O returns residual energy tmp1 = x_ptr[ n ]; tmp2 = x_ptr[ subfr_length - n - 1 ]; for( k = 0; k < n; k++ ) { - C_first_row[ k ] -= x_ptr[ n ] * x_ptr[ n - k - 1 ]; - C_last_row[ k ] -= x_ptr[ subfr_length - n - 1 ] * x_ptr[ subfr_length - n + k ]; + C_first_row[ k ] -= (double)(x_ptr[ n ]) * x_ptr[ n - k - 1 ]; + C_last_row[ k ] -= (double)(x_ptr[ subfr_length - n - 1 ]) * x_ptr[ subfr_length - n + k ]; Atmp = Af[ k ]; tmp1 += x_ptr[ n - k - 1 ] * Atmp; tmp2 += x_ptr[ subfr_length - n + k ] * Atmp; diff --git a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/silk/float/residual_energy_FLP.c b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/silk/float/residual_energy_FLP.c index 1bd07b33a4d..d61f599a950 100644 --- a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/silk/float/residual_energy_FLP.c +++ b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/silk/float/residual_energy_FLP.c @@ -106,12 +106,12 @@ void silk_residual_energy_FLP( /* Filter input to create the LPC residual for each frame half, and measure subframe energies */ silk_LPC_analysis_filter_FLP( LPC_res, a[ 0 ], x + 0 * shift, 2 * shift, LPC_order ); - nrgs[ 0 ] = ( silk_float )( gains[ 0 ] * gains[ 0 ] * silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) ); - nrgs[ 1 ] = ( silk_float )( gains[ 1 ] * gains[ 1 ] * silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) ); + nrgs[ 0 ] = ( silk_float )( (double)(gains[ 0 ]) * gains[ 0 ] * silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) ); + nrgs[ 1 ] = ( silk_float )( (double)(gains[ 1 ]) * gains[ 1 ] * silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) ); if( nb_subfr == MAX_NB_SUBFR ) { silk_LPC_analysis_filter_FLP( LPC_res, a[ 1 ], x + 2 * shift, 2 * shift, LPC_order ); - nrgs[ 2 ] = ( silk_float )( gains[ 2 ] * gains[ 2 ] * silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) ); - nrgs[ 3 ] = ( silk_float )( gains[ 3 ] * gains[ 3 ] * silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) ); + nrgs[ 2 ] = ( silk_float )( (double)(gains[ 2 ]) * gains[ 2 ] * silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) ); + nrgs[ 3 ] = ( silk_float )( (double)(gains[ 3 ]) * gains[ 3 ] * silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) ); } } diff --git a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/mapping_matrix.c b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/mapping_matrix.c index 3f78ab5990c..b8a1bfa91bd 100644 --- a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/mapping_matrix.c +++ b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/mapping_matrix.c @@ -47,7 +47,7 @@ opus_int32 mapping_matrix_get_size(int rows, int cols) */ if (rows > 255 || cols > 255) return 0; - size = rows * (opus_int32)cols * sizeof(opus_int16); + size = (unsigned long)(rows) * (opus_int32)cols * sizeof(opus_int16); if (size > 65004) return 0; diff --git a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/opus_compare.c b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/opus_compare.c index 1956e08fa5c..6edc8e5a18c 100644 --- a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/opus_compare.c +++ b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/opus_compare.c @@ -95,7 +95,7 @@ static void band_energy(float *_out,float *_ps,const int *_bands,int _nbands, size_t xi; int xj; int ps_sz; - window=(float *)opus_malloc((3+_nchannels)*_window_sz*sizeof(*window)); + window=(float *)opus_malloc((unsigned long)((3+_nchannels))*_window_sz*sizeof(*window)); c=window+_window_sz; s=c+_window_sz; x=s+_window_sz; diff --git a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/opus_projection_decoder.c b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/opus_projection_decoder.c index c2e07d5bcf7..b8f34c56ff7 100644 --- a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/opus_projection_decoder.c +++ b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/opus_projection_decoder.c @@ -135,7 +135,7 @@ int opus_projection_decoder_init(OpusProjectionDecoder *st, opus_int32 Fs, /* Verify supplied matrix size. */ nb_input_streams = streams + coupled_streams; - expected_matrix_size = nb_input_streams * channels * sizeof(opus_int16); + expected_matrix_size = (unsigned long)(nb_input_streams) * channels * sizeof(opus_int16); if (expected_matrix_size != demixing_matrix_size) { RESTORE_STACK; diff --git a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/opus_projection_encoder.c b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/opus_projection_encoder.c index 92813ad01f1..26d4d11b826 100644 --- a/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/opus_projection_encoder.c +++ b/Telegram/WatchApp/Packages/OpusKit/Sources/COpus/libopus/src/opus_projection_encoder.c @@ -440,7 +440,7 @@ int opus_projection_encoder_ctl(OpusProjectionEncoder *st, int request, ...) goto bad_arg; } *value = - ms_encoder->layout.nb_channels * (ms_encoder->layout.nb_streams + (unsigned long)(ms_encoder->layout.nb_channels) * (ms_encoder->layout.nb_streams + ms_encoder->layout.nb_coupled_streams) * sizeof(opus_int16); } break; @@ -476,7 +476,7 @@ int opus_projection_encoder_ctl(OpusProjectionEncoder *st, int request, ...) goto bad_arg; } internal_short = mapping_matrix_get_data(demixing_matrix); - internal_size = nb_input_streams * nb_output_streams * sizeof(opus_int16); + internal_size = (unsigned long)(nb_input_streams) * nb_output_streams * sizeof(opus_int16); if (external_size != internal_size) { goto bad_arg; diff --git a/Telegram/WatchApp/Packages/RLottieKit/Sources/RLottieCore/rlottie/src/vector/stb/stb_image.h b/Telegram/WatchApp/Packages/RLottieKit/Sources/RLottieCore/rlottie/src/vector/stb/stb_image.h index ae0c1e52970..137d6a001d7 100644 --- a/Telegram/WatchApp/Packages/RLottieKit/Sources/RLottieCore/rlottie/src/vector/stb/stb_image.h +++ b/Telegram/WatchApp/Packages/RLottieKit/Sources/RLottieCore/rlottie/src/vector/stb/stb_image.h @@ -1583,7 +1583,7 @@ static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int r if (req_comp == img_n) return data; STBI_ASSERT(req_comp >= 1 && req_comp <= 4); - good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2); + good = (stbi__uint16 *) stbi__malloc((size_t)(req_comp) * x * y * 2); if (good == NULL) { STBI_FREE(data); return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); diff --git a/Telegram/WatchApp/Packages/RLottieKit/Sources/RLottieCore/rlottie/src/vector/vbitmap.cpp b/Telegram/WatchApp/Packages/RLottieKit/Sources/RLottieCore/rlottie/src/vector/vbitmap.cpp index 22cb24346a3..409e6d85eaf 100644 --- a/Telegram/WatchApp/Packages/RLottieKit/Sources/RLottieCore/rlottie/src/vector/vbitmap.cpp +++ b/Telegram/WatchApp/Packages/RLottieKit/Sources/RLottieCore/rlottie/src/vector/vbitmap.cpp @@ -38,7 +38,7 @@ void VBitmap::Impl::reset(size_t width, size_t height, VBitmap::Format format) mDepth = depth(format); mStride = ((mWidth * mDepth + 31) >> 5) << 2; // bytes per scanline (must be multiple of 4) - mOwnData = std::make_unique(mStride * mHeight); + mOwnData = std::make_unique((size_t)(mStride) * mHeight); } void VBitmap::Impl::reset(uchar *data, size_t width, size_t height, size_t bytesPerLine, diff --git a/Telegram/WatchApp/Packages/RLottieKit/Sources/RLottieCore/rlottie/src/wasm/rlottiewasm.cpp b/Telegram/WatchApp/Packages/RLottieKit/Sources/RLottieCore/rlottie/src/wasm/rlottiewasm.cpp index 4c759cc7688..3c606d01024 100644 --- a/Telegram/WatchApp/Packages/RLottieKit/Sources/RLottieCore/rlottie/src/wasm/rlottiewasm.cpp +++ b/Telegram/WatchApp/Packages/RLottieKit/Sources/RLottieCore/rlottie/src/wasm/rlottiewasm.cpp @@ -51,7 +51,7 @@ class __attribute__((visibility("default"))) RlottieWasm { mWidth = width; mHeight = height; - mBuffer = std::make_unique(mWidth * mHeight * 4); + mBuffer = std::make_unique((size_t)(mWidth) * mHeight * 4); } explicit RlottieWasm(const char *data) diff --git a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dec/alpha_dec.c b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dec/alpha_dec.c index b6c874fb84d..600954dbd4e 100644 --- a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dec/alpha_dec.c +++ b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dec/alpha_dec.c @@ -97,7 +97,7 @@ WEBP_NODISCARD static int ALPHInit(ALPHDecoder* const dec, const uint8_t* data, // No need to copy the scaling parameters. if (dec->method_ == ALPHA_NO_COMPRESSION) { - const size_t alpha_decoded_size = dec->width_ * dec->height_; + const size_t alpha_decoded_size = (size_t)(dec->width_) * dec->height_; ok = (alpha_data_size >= alpha_decoded_size); } else { assert(dec->method_ == ALPHA_LOSSLESS_COMPRESSION); diff --git a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dec/frame_dec.c b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dec/frame_dec.c index 91ca1f8609a..daa0a008082 100644 --- a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dec/frame_dec.c +++ b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dec/frame_dec.c @@ -688,11 +688,11 @@ static int AllocateMemory(VP8Decoder* const dec) { const size_t mb_info_size = (mb_w + 1) * sizeof(VP8MB); const size_t f_info_size = (dec->filter_type_ > 0) ? - mb_w * (dec->mt_method_ > 0 ? 2 : 1) * sizeof(VP8FInfo) + (unsigned long)(mb_w) * (dec->mt_method_ > 0 ? 2 : 1) * sizeof(VP8FInfo) : 0; const size_t yuv_size = YUV_SIZE * sizeof(*dec->yuv_b_); const size_t mb_data_size = - (dec->mt_method_ == 2 ? 2 : 1) * mb_w * sizeof(*dec->mb_data_); + (unsigned long)((dec->mt_method_ == 2 ? 2 : 1)) * mb_w * sizeof(*dec->mb_data_); const size_t cache_height = (16 * num_caches + kFilterExtraRows[dec->filter_type_]) * 3 / 2; const size_t cache_size = top_size * cache_height; diff --git a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dsp/filters.c b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dsp/filters.c index c9232ff16a6..aa220e46f2c 100644 --- a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dsp/filters.c +++ b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dsp/filters.c @@ -49,7 +49,7 @@ static WEBP_INLINE void DoHorizontalFilter_C(const uint8_t* in, int row, int num_rows, int inverse, uint8_t* out) { const uint8_t* preds; - const size_t start_offset = row * stride; + const size_t start_offset = (size_t)(row) * stride; const int last_row = row + num_rows; DCHECK(in, out); in += start_offset; @@ -86,7 +86,7 @@ static WEBP_INLINE void DoVerticalFilter_C(const uint8_t* in, int row, int num_rows, int inverse, uint8_t* out) { const uint8_t* preds; - const size_t start_offset = row * stride; + const size_t start_offset = (size_t)(row) * stride; const int last_row = row + num_rows; DCHECK(in, out); in += start_offset; @@ -131,7 +131,7 @@ static WEBP_INLINE void DoGradientFilter_C(const uint8_t* in, int row, int num_rows, int inverse, uint8_t* out) { const uint8_t* preds; - const size_t start_offset = row * stride; + const size_t start_offset = (size_t)(row) * stride; const int last_row = row + num_rows; DCHECK(in, out); in += start_offset; diff --git a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dsp/filters_sse2.c b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dsp/filters_sse2.c index bb4b5d58748..ebaa809146e 100644 --- a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dsp/filters_sse2.c +++ b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/dsp/filters_sse2.c @@ -78,7 +78,7 @@ static WEBP_INLINE void DoHorizontalFilter_SSE2(const uint8_t* in, int stride, int row, int num_rows, uint8_t* out) { - const size_t start_offset = row * stride; + const size_t start_offset = (size_t)(row) * stride; const int last_row = row + num_rows; DCHECK(in, out); in += start_offset; @@ -111,7 +111,7 @@ static WEBP_INLINE void DoVerticalFilter_SSE2(const uint8_t* in, int width, int height, int stride, int row, int num_rows, uint8_t* out) { - const size_t start_offset = row * stride; + const size_t start_offset = (size_t)(row) * stride; const int last_row = row + num_rows; DCHECK(in, out); in += start_offset; @@ -174,7 +174,7 @@ static WEBP_INLINE void DoGradientFilter_SSE2(const uint8_t* in, int width, int height, int stride, int row, int num_rows, uint8_t* out) { - const size_t start_offset = row * stride; + const size_t start_offset = (size_t)(row) * stride; const int last_row = row + num_rows; DCHECK(in, out); in += start_offset; diff --git a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/utils/palette.c b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/utils/palette.c index 515da210195..6cbd41d8563 100644 --- a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/utils/palette.c +++ b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/utils/palette.c @@ -307,7 +307,7 @@ static int PaletteSortModifiedZeng(const WebPPicture* const pic, if (num_colors <= 1) return 1; // Build the co-occurrence matrix. cooccurrence = - (uint32_t*)WebPSafeCalloc(num_colors * num_colors, sizeof(*cooccurrence)); + (uint32_t*)WebPSafeCalloc((uint64_t)(num_colors) * num_colors, sizeof(*cooccurrence)); if (cooccurrence == NULL) { return 0; } diff --git a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/utils/quant_levels_dec_utils.c b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/utils/quant_levels_dec_utils.c index 97e78937043..a34a6c23850 100644 --- a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/utils/quant_levels_dec_utils.c +++ b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/utils/quant_levels_dec_utils.c @@ -217,7 +217,7 @@ static int InitParams(uint8_t* const data, int width, int height, int stride, int radius, SmoothParams* const p) { const int R = 2 * radius + 1; // total size of the kernel - const size_t size_scratch_m = (R + 1) * width * sizeof(*p->start_); + const size_t size_scratch_m = (unsigned long)((R + 1)) * width * sizeof(*p->start_); const size_t size_m = width * sizeof(*p->average_); const size_t size_lut = (1 + 2 * LUT_SIZE) * sizeof(*p->correction_); const size_t total_size = size_scratch_m + size_m + size_lut; diff --git a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/utils/quant_levels_utils.c b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/utils/quant_levels_utils.c index d65ad3c29db..a7f0582e540 100644 --- a/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/utils/quant_levels_utils.c +++ b/Telegram/WatchApp/Packages/WebPKit/Sources/WebPCore/libwebp/src/utils/quant_levels_utils.c @@ -30,7 +30,7 @@ int QuantizeLevels(uint8_t* const data, int width, int height, int q_level[NUM_SYMBOLS] = { 0 }; double inv_q_level[NUM_SYMBOLS] = { 0 }; int min_s = 255, max_s = 0; - const size_t data_size = height * width; + const size_t data_size = (size_t)(height) * width; int i, num_levels_in, iter; double last_err = 1.e38, err = 0.; const double err_threshold = ERROR_THRESHOLD * data_size; diff --git a/Tests/CodeScanning/native_regressions.py b/Tests/CodeScanning/native_regressions.py new file mode 100644 index 00000000000..38800447cfd --- /dev/null +++ b/Tests/CodeScanning/native_regressions.py @@ -0,0 +1,34 @@ +"""Run the existing codec round-trip suites on an Apple Silicon host.""" +import pathlib +import re +import subprocess +import tempfile + + +ROOT = pathlib.Path(__file__).resolve().parents[2] +SOURCE = ROOT / 'third-party' / 'subcodec' + + +def run(*command): + subprocess.run(command, check=True, cwd=ROOT) + + +def main(): + cmake = (SOURCE / 'CMakeLists.txt').read_text() + targets = [] + for name in ('CORE_TESTS', 'E2E_TESTS'): + match = re.search(r'set\(' + name + r'\s+([^)]*)\)', cmake) + if match is None: + raise RuntimeError('Missing codec test target list: ' + name) + targets.extend(match.group(1).split()) + if not targets or len(targets) != len(set(targets)): + raise RuntimeError('The codec test target list must be nonempty and unique') + with tempfile.TemporaryDirectory(prefix='telegram-codec-regressions-') as directory: + run('cmake', '-S', str(SOURCE), '-B', directory, '-DCMAKE_BUILD_TYPE=Release') + run('cmake', '--build', directory, '--parallel', '3', '--target', *targets) + # Several existing tests use fixed /tmp fixture names; keep execution serial. + run('ctest', '--test-dir', directory, '--output-on-failure', '--parallel', '1') + + +if __name__ == '__main__': + main() diff --git a/docs/code-scanning-remediation.md b/docs/code-scanning-remediation.md new file mode 100644 index 00000000000..d656ff14e23 --- /dev/null +++ b/docs/code-scanning-remediation.md @@ -0,0 +1,33 @@ +# Code scanning remediation — October 2026 + +## Source changes + +Integer products are evaluated in the destination width before allocation-size, stride, offset and accumulator conversions. Floating-point products accumulated in double are evaluated in double except the intentionally float-rounded FFmpeg dither paths. Macro allocation helpers promote their operands before multiplying. + +The keyboard-defaults parser uses disjoint escaped/unescaped character alternatives, avoiding exponential backtracking on malformed backslash-heavy strings. A bounded subprocess regression verifies rejection of a 100,000-backslash unterminated string. + +## Verification + +Local checks completed: FFmpeg and JPEG XL core library builds; libwebp build and three lossless encode/decode pixel comparisons; Clang compilation checks for all changed Watch Opus/WebP codec source units and the OpenSubdiv/CompanionRenderer units. + +Apple Silicon Subcodec and Watch Swift-package regression suites run in `.github/workflows/security-regressions.yml`. Full iOS integration is verified by the existing application build before release. The WebAssembly example is not an iOS build target and cannot be executed by the native host checks. + +## Reviewed findings + +These findings are documented individually in the GitHub Code scanning dashboard; scanning rules remain enabled. + +### Alerts 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288 + +Reviewed the H.264 bit-depth templates: block is declared int16_t* for the shared interface, while high-bit-depth instantiations store dctcoef as 32-bit coefficients. Multiplying the coefficient offset by sizeof(pixel) (1 for 8-bit, 2 for high-bit-depth) intentionally converts to int16_t storage units. The loop indices are bounded. Removing this scaling would address the wrong coefficient block and corrupt decoding; this is not double-scaling a pointer of the actual stored coefficient type. + +### Alerts 224 + +Reviewed every ParseOffset caller in time_zone_posix.cc: hours are constrained to 0..24 or -167..167, minutes/seconds to 0..59, and sign is +/-1. All intermediate products and the final offset fit signed 32-bit int (absolute value <=604799). The later int_fast32_t conversion cannot expose an overflowing multiplication on any supported ABI. + +### Alerts 1236, 1237 + +Reviewed the floating-point dither template: the products are float operations intentionally accumulated in double, using normalized audio samples, fixed scale and bounded filter/noise-shaping state. They are not integer buffer-size calculations. Promoting these operands changes the specified float rounding of the audio dither path; no pointer, allocation length or security boundary is derived from the product. + +### Alerts 4 + +Reviewed DecryptMatch.py: this is a read-only decoder for existing Fastlane Match encrypted certificate archives. EVP_BytesToKey reproduces the legacy OpenSSL V1 MD5/SHA256 derivation required by that file format; it is not a password verifier or a password-hash database and does not create new encrypted archives. Changing the digest would make existing archives undecryptable. The versioned newer archive decoder uses its own prescribed KDF. diff --git a/submodules/CompanionRenderer/Core/Subdivision.cpp b/submodules/CompanionRenderer/Core/Subdivision.cpp index 592bba84ebb..9c3c887db26 100644 --- a/submodules/CompanionRenderer/Core/Subdivision.cpp +++ b/submodules/CompanionRenderer/Core/Subdivision.cpp @@ -178,7 +178,7 @@ void applySubdivision(Primitive& p,const SubdivisionCage& cage) { auto surface=prepareSubdivision(p,cage);const auto& s=*surface; p.base.clear();p.indices.clear();p.weights.clear();p.joints.clear();p.influences=0; p.morphPositions.assign(s.morphCount,{});p.morphNormals.assign(s.morphCount,{}); - size_t count=0;for(auto& q:s.patches)count+=(q.segments+1)*(q.segments+1); + size_t count=0;for(auto& q:s.patches)count+=(unsigned long)((q.segments+1))*(q.segments+1); check(count<=200000,"Subdivision mesh exceeds vertex budget");p.base.reserve(count); for(auto& q:s.patches) { uint32_t start=uint32_t(p.base.size()),n=q.segments; diff --git a/submodules/CompanionRenderer/ThirdParty/opensubdiv/far/patchTable.cpp b/submodules/CompanionRenderer/ThirdParty/opensubdiv/far/patchTable.cpp index 2e74f39258c..544e8dd273b 100644 --- a/submodules/CompanionRenderer/ThirdParty/opensubdiv/far/patchTable.cpp +++ b/submodules/CompanionRenderer/ThirdParty/opensubdiv/far/patchTable.cpp @@ -136,7 +136,7 @@ void PatchTable::allocateVaryingVertices( PatchDescriptor desc, int numPatches) { _varyingDesc = desc; - _varyingVerts.resize(numPatches*desc.GetNumControlVertices()); + _varyingVerts.resize((size_t)(numPatches)*desc.GetNumControlVertices()); } inline PatchTable::FVarPatchChannel & @@ -164,7 +164,7 @@ PatchTable::allocateFVarPatchChannelValues( c.stride = std::max(regDesc.GetNumControlVertices(), irregDesc.GetNumControlVertices()); - c.patchValues.resize(numPatches * c.stride); + c.patchValues.resize((size_t)(numPatches) * c.stride); c.patchParam.resize(numPatches); } void @@ -495,7 +495,7 @@ PatchTable::getPatchFVarValues(int patch, int channel) const { int ncvsThisPatch = c.patchParam[patch].IsRegular() ? c.regDesc.GetNumControlVertices() : c.irregDesc.GetNumControlVertices(); - return ConstIndexArray(&c.patchValues[patch * c.stride], ncvsThisPatch); + return ConstIndexArray(&c.patchValues[(size_t)(patch) * c.stride], ncvsThisPatch); } ConstIndexArray PatchTable::GetPatchFVarValues(PatchHandle const & handle, int channel) const { diff --git a/submodules/CompanionRenderer/ThirdParty/opensubdiv/far/patchTableFactory.cpp b/submodules/CompanionRenderer/ThirdParty/opensubdiv/far/patchTableFactory.cpp index 7f8477d86cf..873e38c85a2 100644 --- a/submodules/CompanionRenderer/ThirdParty/opensubdiv/far/patchTableFactory.cpp +++ b/submodules/CompanionRenderer/ThirdParty/opensubdiv/far/patchTableFactory.cpp @@ -1923,7 +1923,7 @@ PatchTableBuilder::LegacyGregoryHelper::FinalizeVertexValence( Level const & lastLevel = _refiner.getLevel(_refiner.GetMaxLevel()); - int * vTableEntry = &vTable[lastLevelOffset * vWidth]; + int * vTableEntry = &vTable[(size_t)(lastLevelOffset) * vWidth]; for (int vIndex = 0; vIndex < lastLevel.getNumVertices(); ++vIndex) { // Gather the one-ring around the vertex and set its resulting size diff --git a/submodules/CompanionRenderer/ThirdParty/opensubdiv/vtr/level.cpp b/submodules/CompanionRenderer/ThirdParty/opensubdiv/vtr/level.cpp index 787dcf1e0f9..fd023b48b23 100644 --- a/submodules/CompanionRenderer/ThirdParty/opensubdiv/vtr/level.cpp +++ b/submodules/CompanionRenderer/ThirdParty/opensubdiv/vtr/level.cpp @@ -1480,7 +1480,7 @@ namespace { _countsAndOffsets[2*i] = 0; _countsAndOffsets[2*i+1] = i * _memberCountPerComp; } - _regIndices.resize(_compCount * _memberCountPerComp); + _regIndices.resize((size_t)(_compCount) * _memberCountPerComp); } inline IndexArray @@ -1523,7 +1523,7 @@ namespace { _countsAndOffsets.push_back(_compCount * _memberCountPerComp); ++ _compCount; - _regIndices.resize(_compCount * _memberCountPerComp); + _regIndices.resize((size_t)(_compCount) * _memberCountPerComp); } int DynamicRelation::compressMemberIndices() { @@ -1572,7 +1572,7 @@ namespace { Index *srcMembers = 0; if (count <= _memberCountPerComp) { - srcMembers = &_regIndices[i * _memberCountPerComp]; + srcMembers = &_regIndices[(size_t)(i) * _memberCountPerComp]; } else { srcMembers = &_irregIndices[i][0]; memberMax = std::max(memberMax, count); diff --git a/submodules/TelegramUI/Components/RichTextEditor/Host/Engine/Scripts/ime_keyboard_contract.py b/submodules/TelegramUI/Components/RichTextEditor/Host/Engine/Scripts/ime_keyboard_contract.py index 16bee4e7e01..69254406629 100755 --- a/submodules/TelegramUI/Components/RichTextEditor/Host/Engine/Scripts/ime_keyboard_contract.py +++ b/submodules/TelegramUI/Components/RichTextEditor/Host/Engine/Scripts/ime_keyboard_contract.py @@ -231,7 +231,7 @@ def parse_defaults_array(output): if len(lines) < 2 or lines[0].strip() != "(" or lines[-1].strip() != ")": raise ContractError("defaults output is not an array") result = [] - item_pattern = re.compile(r'^\s*"((?:\\.|[^"])*)",?\s*$') + item_pattern = re.compile(r'^\s*"((?:\\.|[^"\\])*)",?\s*$') for line in lines[1:-1]: match = item_pattern.match(line) if match is None: diff --git a/submodules/TelegramUI/Components/RichTextEditor/Host/Engine/Scripts/tests/test_ime_keyboard_contract.py b/submodules/TelegramUI/Components/RichTextEditor/Host/Engine/Scripts/tests/test_ime_keyboard_contract.py index 2e32b5aa674..99267d7301f 100644 --- a/submodules/TelegramUI/Components/RichTextEditor/Host/Engine/Scripts/tests/test_ime_keyboard_contract.py +++ b/submodules/TelegramUI/Components/RichTextEditor/Host/Engine/Scripts/tests/test_ime_keyboard_contract.py @@ -1,6 +1,8 @@ import importlib.util import json import pathlib +import subprocess +import sys import tempfile import unittest @@ -233,6 +235,32 @@ def test_defaults_inventory_parser_rejects_malformed_output(self): with self.assertRaises(MODULE.ContractError): MODULE.parse_defaults_array(malformed) + def test_defaults_inventory_parser_handles_escapes_and_rejects_long_invalid_strings(self): + identifier = 'en_US@sw="QWERTY";hw=Custom\\Keyboard' + self.assertEqual( + MODULE.parse_defaults_array('(\n ' + json.dumps(identifier) + ',\n)'), + [identifier], + ) + # Overlapping backslash alternatives used to make a missing closing + # quote take exponential time. Keep the potentially hanging input in a + # child process so a regression fails within a bounded time. + code = ''' +import runpy, sys +module = runpy.run_path(sys.argv[1]) +payload = '(\\n "' + '\\\\' * 100000 + '\\n)' +try: + module['parse_defaults_array'](payload) +except module['ContractError']: + pass +else: + raise AssertionError('malformed string was accepted') +''' + completed = subprocess.run( + [sys.executable, '-c', code, str(ROOT / 'Scripts' / 'ime_keyboard_contract.py')], + capture_output=True, text=True, timeout=10, + ) + self.assertEqual(completed.returncode, 0, completed.stderr) + def test_execution_is_injected_and_preserves_command_log(self): contract = MODULE.load_contract(CONTRACT_PATH) expected = [ diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/doc/examples/demux_decode.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/doc/examples/demux_decode.c index 64f5547bc43..a1489a09b5f 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/doc/examples/demux_decode.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/doc/examples/demux_decode.c @@ -89,7 +89,7 @@ static int output_video_frame(AVFrame *frame) static int output_audio_frame(AVFrame *frame) { - size_t unpadded_linesize = frame->nb_samples * av_get_bytes_per_sample(frame->format); + size_t unpadded_linesize = (size_t)(frame->nb_samples) * av_get_bytes_per_sample(frame->format); printf("audio_frame n:%d nb_samples:%d pts:%s\n", audio_frame_count++, frame->nb_samples, av_ts2timestr(frame->pts, &audio_dec_ctx->time_base)); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/4xm.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/4xm.c index c6b2ce12304..28d4dc3950b 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/4xm.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/4xm.c @@ -1014,8 +1014,8 @@ static av_cold int decode_init(AVCodecContext *avctx) if (ret < 0) return ret; - f->frame_buffer = av_mallocz(avctx->width * avctx->height * 2); - f->last_frame_buffer = av_mallocz(avctx->width * avctx->height * 2); + f->frame_buffer = av_mallocz((size_t)(avctx->width) * avctx->height * 2); + f->last_frame_buffer = av_mallocz((size_t)(avctx->width) * avctx->height * 2); if (!f->frame_buffer || !f->last_frame_buffer) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/aacpsy.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/aacpsy.c index 299a0a9f0a0..7d256868068 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/aacpsy.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/aacpsy.c @@ -352,8 +352,8 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) { float bark_width = coeffs[g+1].barks - coeffs->barks; coeff->spread_low[0] = ff_exp10(-bark_width * PSY_3GPP_THR_SPREAD_LOW); coeff->spread_hi [0] = ff_exp10(-bark_width * PSY_3GPP_THR_SPREAD_HI); - coeff->spread_low[1] = ff_exp10(-bark_width * en_spread_low); - coeff->spread_hi [1] = ff_exp10(-bark_width * en_spread_hi); + coeff->spread_low[1] = ff_exp10((double)(-bark_width) * en_spread_low); + coeff->spread_hi [1] = ff_exp10((double)(-bark_width) * en_spread_hi); pe_min = bark_pe * bark_width; minsnr = exp2(pe_min / band_sizes[g]) - 1.5f; coeff->min_snr = av_clipf(1.0f / minsnr, PSY_SNR_25DB, PSY_SNR_1DB); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ac3enc_float.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ac3enc_float.c index 0ae7ddd7eb1..5ddecbd9f9f 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ac3enc_float.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ac3enc_float.c @@ -43,7 +43,7 @@ static void scale_coefficients(AC3EncodeContext *s) int cpl = s->cpl_on; s->ac3dsp.float_to_fixed24(s->fixed_coef_buffer + (chan_size * !cpl), s->mdct_coef_buffer + (chan_size * !cpl), - chan_size * (s->channels + cpl)); + (size_t)(chan_size) * (s->channels + cpl)); } diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/alsdec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/alsdec.c index 5378d01d43d..d44b780265b 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/alsdec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/alsdec.c @@ -1926,7 +1926,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, } ctx->crc = av_crc(ctx->crc_table, ctx->crc, crc_source, - ctx->cur_frame_length * channels * + (size_t)(ctx->cur_frame_length) * channels * av_get_bytes_per_sample(avctx->sample_fmt)); } @@ -2063,9 +2063,9 @@ static av_cold int decode_init(AVCodecContext *avctx) ctx->quant_cof = av_malloc_array(num_buffers, sizeof(*ctx->quant_cof)); ctx->lpc_cof = av_malloc_array(num_buffers, sizeof(*ctx->lpc_cof)); - ctx->quant_cof_buffer = av_malloc_array(num_buffers * sconf->max_order, + ctx->quant_cof_buffer = av_malloc_array((size_t)(num_buffers) * sconf->max_order, sizeof(*ctx->quant_cof_buffer)); - ctx->lpc_cof_buffer = av_malloc_array(num_buffers * sconf->max_order, + ctx->lpc_cof_buffer = av_malloc_array((size_t)(num_buffers) * sconf->max_order, sizeof(*ctx->lpc_cof_buffer)); ctx->lpc_cof_reversed_buffer = av_malloc_array(sconf->max_order, sizeof(*ctx->lpc_cof_buffer)); @@ -2106,7 +2106,7 @@ static av_cold int decode_init(AVCodecContext *avctx) // allocate and assign channel data buffer for mcc mode if (sconf->mc_coding) { - ctx->chan_data_buffer = av_calloc(num_buffers * num_buffers, + ctx->chan_data_buffer = av_calloc((size_t)(num_buffers) * num_buffers, sizeof(*ctx->chan_data_buffer)); ctx->chan_data = av_calloc(num_buffers, sizeof(*ctx->chan_data)); ctx->reverted_channels = av_malloc_array(num_buffers, @@ -2160,7 +2160,7 @@ static av_cold int decode_init(AVCodecContext *avctx) // allocate previous raw sample buffer ctx->prev_raw_samples = av_malloc_array(sconf->max_order, sizeof(*ctx->prev_raw_samples)); - ctx->raw_buffer = av_calloc(channels * channel_size, sizeof(*ctx->raw_buffer)); + ctx->raw_buffer = av_calloc((size_t)(channels) * channel_size, sizeof(*ctx->raw_buffer)); ctx->raw_samples = av_malloc_array(channels, sizeof(*ctx->raw_samples)); if (!ctx->prev_raw_samples || !ctx->raw_buffer|| !ctx->raw_samples) { av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); @@ -2175,7 +2175,7 @@ static av_cold int decode_init(AVCodecContext *avctx) // allocate crc buffer if (HAVE_BIGENDIAN != sconf->msb_first && sconf->crc_enabled && (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_CAREFUL))) { - ctx->crc_buffer = av_malloc_array(ctx->cur_frame_length * + ctx->crc_buffer = av_malloc_array((size_t)(ctx->cur_frame_length) * channels * av_get_bytes_per_sample(avctx->sample_fmt), sizeof(*ctx->crc_buffer)); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/aom_film_grain_template.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/aom_film_grain_template.c index 5f9f29f1fab..11e4f903a78 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/aom_film_grain_template.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/aom_film_grain_template.c @@ -501,7 +501,7 @@ FUNC(apply_grain_row)(AVFrame *out, const AVFrame *in, if (data->num_y_points) { const int bh = FFMIN(out->height - row * FG_BLOCK_SIZE, FG_BLOCK_SIZE); - const ptrdiff_t off = row * FG_BLOCK_SIZE * out->linesize[0]; + const ptrdiff_t off = (ptrdiff_t)(row) * FG_BLOCK_SIZE * out->linesize[0]; FUNC(fgy_32x32xn_c)((pixel *) ((char *) out->data[0] + off), luma_src, out->linesize[0], params, out->width, scaling[0], grain_lut[0], bh, row HBD_CALL); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/atrac3plusdsp.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/atrac3plusdsp.c index 6942cba5060..70a3e77b00f 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/atrac3plusdsp.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/atrac3plusdsp.c @@ -128,7 +128,7 @@ static void waves_synth(Atrac3pWaveSynthParams *synth_param, for (wn = 0; wn < waves_info->num_wavs; wn++, wave_param++) { /* amplitude dequantization */ - amp = amp_sf_tab[wave_param->amp_sf] * + amp = (double)(amp_sf_tab[wave_param->amp_sf]) * (!synth_param->amplitude_mode ? (wave_param->amp_index + 1) / 15.13f : 1.0f); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/atrac9dec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/atrac9dec.c index 3c18ae8b424..ef8f3752278 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/atrac9dec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/atrac9dec.c @@ -777,7 +777,7 @@ static int atrac9_decode_block(ATRAC9Context *s, GetBitContext *gb, ATRAC9ChannelData *c = &b->channel[i]; const int dst_idx = s->block_config->plane_map[block_idx][i]; const int wsize = 1 << s->frame_log2; - const ptrdiff_t offset = wsize*frame_idx*sizeof(float); + const ptrdiff_t offset = (unsigned long)(wsize)*frame_idx*sizeof(float); float *dst = (float *)(frame->extended_data[dst_idx] + offset); s->tx_fn(s->tx, s->temp, c->coeffs, sizeof(float)); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/audiotoolboxdec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/audiotoolboxdec.c index 08203c53106..afade412d9f 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/audiotoolboxdec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/audiotoolboxdec.c @@ -401,7 +401,7 @@ static av_cold int ffat_create_decoder(AVCodecContext *avctx, ffat_update_ctx(avctx); - if(!(at->decoded_data = av_malloc(av_get_bytes_per_sample(avctx->sample_fmt) + if(!(at->decoded_data = av_malloc((size_t)(av_get_bytes_per_sample(avctx->sample_fmt)) * avctx->frame_size * avctx->ch_layout.nb_channels))) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/bfi.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/bfi.c index 1d2d3a72045..9be217dc178 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/bfi.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/bfi.c @@ -41,7 +41,7 @@ static av_cold int bfi_decode_init(AVCodecContext *avctx) { BFIContext *bfi = avctx->priv_data; avctx->pix_fmt = AV_PIX_FMT_PAL8; - bfi->dst = av_mallocz(avctx->width * avctx->height); + bfi->dst = av_mallocz((size_t)(avctx->width) * avctx->height); if (!bfi->dst) return AVERROR(ENOMEM); return 0; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/bink.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/bink.c index e5300be000e..5bbeae0983c 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/bink.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/bink.c @@ -590,7 +590,7 @@ static int binkb_read_bundle(BinkContext *c, GetBitContext *gb, int bundle_num) int i, len; CHECK_READ_VAL(gb, b, len); - if (b->data_end - b->cur_dec < len * (1 + (bits > 8))) + if (b->data_end - b->cur_dec < (long)(len) * (1 + (bits > 8))) return AVERROR_INVALIDDATA; if (bits <= 8) { if (!issigned) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/bonk.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/bonk.c index 67eb8d6a14b..c6bdbf112cc 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/bonk.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/bonk.c @@ -116,8 +116,8 @@ static av_cold int bonk_init(AVCodecContext *avctx) if (!s->input_samples) return AVERROR(ENOMEM); - s->samples[0] = av_calloc(s->samples_per_packet * s->down_sampling, sizeof(*s->samples[0])); - s->samples[1] = av_calloc(s->samples_per_packet * s->down_sampling, sizeof(*s->samples[0])); + s->samples[0] = av_calloc((size_t)(s->samples_per_packet) * s->down_sampling, sizeof(*s->samples[0])); + s->samples[1] = av_calloc((size_t)(s->samples_per_packet) * s->down_sampling, sizeof(*s->samples[0])); if (!s->samples[0] || !s->samples[1]) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cavs.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cavs.c index 4db68924521..b38951fcc22 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cavs.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cavs.c @@ -537,8 +537,8 @@ static inline void scale_mv(AVSContext *h, int *d_x, int *d_y, cavs_vector *src, int distp) { int64_t den = h->scale_den[FFMAX(src->ref, 0)]; - *d_x = (src->x * distp * den + 256 + FF_SIGNBIT(src->x)) >> 9; - *d_y = (src->y * distp * den + 256 + FF_SIGNBIT(src->y)) >> 9; + *d_x = ((long)(src->x) * distp * den + 256 + FF_SIGNBIT(src->x)) >> 9; + *d_y = ((long)(src->y) * distp * den + 256 + FF_SIGNBIT(src->y)) >> 9; } static inline void mv_pred_median(AVSContext *h, @@ -767,9 +767,9 @@ int ff_cavs_init_top_lines(AVSContext *h) h->top_border_v = av_calloc(h->mb_width, 10); /* alloc space for co-located MVs and types */ - h->col_mv = av_calloc(h->mb_width * h->mb_height, + h->col_mv = av_calloc((size_t)(h->mb_width) * h->mb_height, 4 * sizeof(*h->col_mv)); - h->col_type_base = av_mallocz(h->mb_width * h->mb_height); + h->col_type_base = av_mallocz((size_t)(h->mb_width) * h->mb_height); h->block = av_mallocz(64 * sizeof(int16_t)); if (!h->top_qp || !h->top_mv[0] || !h->top_mv[1] || !h->top_pred_Y || diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cdxl.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cdxl.c index c30e85b2ed7..8949b1a6930 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cdxl.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cdxl.c @@ -287,7 +287,7 @@ static int cdxl_decode_frame(AVCodecContext *avctx, AVFrame *p, else aligned_width = FFALIGN(c->avctx->width, 16); c->padded_bits = aligned_width - c->avctx->width; - if (c->video_size < aligned_width * avctx->height * (int64_t)c->bpp / 8) + if (c->video_size < (long)(aligned_width) * avctx->height * (int64_t)c->bpp / 8) return AVERROR_INVALIDDATA; if (!encoding && c->palette_size && c->bpp <= 8 && c->format != CHUNKY) { avctx->pix_fmt = AV_PIX_FMT_PAL8; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cfhd.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cfhd.c index 4d430e32efd..e016864a0a2 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cfhd.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cfhd.c @@ -740,7 +740,7 @@ static int cfhd_decode(AVCodecContext *avctx, AVFrame *pic, } if (lowpass_height > lowpass_a_height || lowpass_width > lowpass_a_width || - lowpass_width * lowpass_height * sizeof(int16_t) > bytestream2_get_bytes_left(&gb)) { + (unsigned long)(lowpass_width) * lowpass_height * sizeof(int16_t) > bytestream2_get_bytes_left(&gb)) { av_log(avctx, AV_LOG_ERROR, "Too many lowpass coefficients\n"); ret = AVERROR(EINVAL); goto end; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cfhdenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cfhdenc.c index db435f321c1..e8fa23af417 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cfhdenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cfhdenc.c @@ -283,9 +283,9 @@ static av_cold int cfhd_encode_init(AVCodecContext *avctx) h2 = h4 * 2; s->plane[i].dwt_buf = - av_calloc(h8 * 8 * w8 * 8, sizeof(*s->plane[i].dwt_buf)); + av_calloc((size_t)(h8) * 8 * w8 * 8, sizeof(*s->plane[i].dwt_buf)); s->plane[i].dwt_tmp = - av_calloc(h8 * 8 * w8 * 8, sizeof(*s->plane[i].dwt_tmp)); + av_calloc((size_t)(h8) * 8 * w8 * 8, sizeof(*s->plane[i].dwt_tmp)); if (!s->plane[i].dwt_buf || !s->plane[i].dwt_tmp) return AVERROR(ENOMEM); @@ -370,7 +370,7 @@ static av_cold int cfhd_encode_init(AVCodecContext *avctx) if (s->planes != 4) return 0; - s->alpha = av_calloc(avctx->width * avctx->height, sizeof(*s->alpha)); + s->alpha = av_calloc((size_t)(avctx->width) * avctx->height, sizeof(*s->alpha)); if (!s->alpha) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cljrenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cljrenc.c index 3b71a85aa94..3b6aca7c138 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cljrenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/cljrenc.c @@ -56,7 +56,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, return AVERROR_EXPERIMENTAL; } - ret = ff_get_encode_buffer(avctx, pkt, 4 * avctx->height * ((avctx->width + 3) / 4), 0); + ret = ff_get_encode_buffer(avctx, pkt, (int64_t)(4) * avctx->height * ((avctx->width + 3) / 4), 0); if (ret < 0) return ret; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/d3d12va_encode.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/d3d12va_encode.c index 2cca179b839..cf009c2a27d 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/d3d12va_encode.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/d3d12va_encode.c @@ -204,7 +204,7 @@ static int d3d12va_encode_setup_roi(AVCodecContext *avctx, if (is_av1) { pic->qp_map = av_calloc(block_width * block_height, sizeof(int16_t)); } else { - pic->qp_map = av_calloc(block_width * block_height, sizeof(int8_t)); + pic->qp_map = av_calloc((size_t)(block_width) * block_height, sizeof(int8_t)); } if (!pic->qp_map) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dca_core.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dca_core.c index cb1f7b7bbfa..b1fb6caa1c1 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dca_core.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dca_core.c @@ -1976,7 +1976,7 @@ int ff_dca_core_filter_fixed(DCACoreDecoder *s, int x96_synth) // Reallocate PCM output buffer av_fast_malloc(&s->output_buffer, &s->output_size, - nsamples * av_popcount(s->ch_mask) * sizeof(int32_t)); + (unsigned long)(nsamples) * av_popcount(s->ch_mask) * sizeof(int32_t)); if (!s->output_buffer) return AVERROR(ENOMEM); @@ -2184,7 +2184,7 @@ static int filter_frame_float(DCACoreDecoder *s, AVFrame *frame) nchannels = av_popcount(s->ch_mask) - avctx->ch_layout.nb_channels; if (nchannels > 0) { av_fast_malloc(&s->output_buffer, &s->output_size, - nsamples * nchannels * sizeof(float)); + (unsigned long)(nsamples) * nchannels * sizeof(float)); if (!s->output_buffer) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dca_xll.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dca_xll.c index 6eedad7eb87..440f8682587 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dca_xll.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dca_xll.c @@ -747,7 +747,7 @@ static int chs_assemble_freq_bands(DCAXllDecoder *s, DCAXllChSet *c) // Reallocate frequency band assembly buffer av_fast_malloc(&c->sample_buffer[2], &c->sample_size[2], - 2 * nsamples * c->nchannels * sizeof(int32_t)); + (unsigned long)(2) * nsamples * c->nchannels * sizeof(int32_t)); if (!c->sample_buffer[2]) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dfa.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dfa.c index 1efaefcb699..d974f015a8a 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dfa.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dfa.c @@ -47,7 +47,7 @@ static av_cold int dfa_decode_init(AVCodecContext *avctx) av_assert0(av_image_check_size(avctx->width, avctx->height, 0, avctx) >= 0); - s->frame_buf = av_mallocz(avctx->width * avctx->height); + s->frame_buf = av_mallocz((size_t)(avctx->width) * avctx->height); if (!s->frame_buf) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/diracdec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/diracdec.c index a4a719aa8e2..d51ee737953 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/diracdec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/diracdec.c @@ -306,7 +306,7 @@ static int alloc_sequence_buffers(DiracContext *s) w = FFALIGN(CALC_PADDING(w, MAX_DWT_LEVELS), 8); /* FIXME: Should this be 16 for SSE??? */ h = top_padding + CALC_PADDING(h, MAX_DWT_LEVELS) + max_yblen/2; - s->plane[i].idwt.buf_base = av_calloc(w + max_xblen, h * (2 << s->pshift)); + s->plane[i].idwt.buf_base = av_calloc(w + max_xblen, (size_t)(h) * (2 << s->pshift)); s->plane[i].idwt.tmp = av_malloc_array((w+16), 2 << s->pshift); s->plane[i].idwt.buf = s->plane[i].idwt.buf_base + (top_padding*w)*(2 << s->pshift); if (!s->plane[i].idwt.buf_base || !s->plane[i].idwt.tmp) @@ -941,7 +941,7 @@ static int decode_lowdelay(DiracContext *s) int slice_num = 0; if (s->slice_params_num_buf != (s->num_x * s->num_y)) { - s->slice_params_buf = av_realloc_f(s->slice_params_buf, s->num_x * s->num_y, sizeof(DiracSlice)); + s->slice_params_buf = av_realloc_f(s->slice_params_buf, (size_t)(s->num_x) * s->num_y, sizeof(DiracSlice)); if (!s->slice_params_buf) { av_log(s->avctx, AV_LOG_ERROR, "slice params buffer allocation failure\n"); s->slice_params_num_buf = 0; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dnxhddata.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dnxhddata.c index ce06d77f18e..5ed7b0e712b 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dnxhddata.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dnxhddata.c @@ -1101,7 +1101,7 @@ int ff_dnxhd_get_hr_frame_size(int cid, int w, int h) if (!entry) return -1; - result = ((h + 15) / 16) * ((w + 15) / 16) * (int64_t)entry->packet_scale.num / entry->packet_scale.den; + result = (long)(((h + 15) / 16)) * ((w + 15) / 16) * (int64_t)entry->packet_scale.num / entry->packet_scale.den; result = (result + 2048) / 4096 * 4096; return FFMAX(result, 8192); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dnxhdenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dnxhdenc.c index 844731f6c40..a57ec863e91 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dnxhdenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dnxhdenc.c @@ -335,7 +335,7 @@ static av_cold int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias) static av_cold int dnxhd_init_rc(DNXHDEncContext *ctx) { - if (!FF_ALLOCZ_TYPED_ARRAY(ctx->mb_rc, (ctx->m.c.avctx->qmax + 1) * ctx->m.c.mb_num)) + if (!FF_ALLOCZ_TYPED_ARRAY(ctx->mb_rc, (size_t)((ctx->m.c.avctx->qmax + 1)) * ctx->m.c.mb_num)) return AVERROR(ENOMEM); if (ctx->m.c.avctx->mb_decision != FF_MB_DECISION_RD) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dovi_rpuenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dovi_rpuenc.c index 0c22bf34ede..cdccf83a198 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dovi_rpuenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dovi_rpuenc.c @@ -182,7 +182,7 @@ static av_cold int dovi_configure_ext(DOVIContext *s, enum AVCodecID codec_id, } } - pps = width * height; + pps = (uint64_t)(width) * height; if (framerate.num) { pps = pps * framerate.num / framerate.den; } else { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dpx.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dpx.c index 52a03501ec8..2ce26279d2d 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dpx.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dpx.c @@ -626,10 +626,10 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, // to detect it // Also handle special case with unpadded content dpx->need_align = FFALIGN(dpx->stride, 4); - if (dpx->need_align*avctx->height + (int64_t)offset > avpkt->size && + if ((long)(dpx->need_align)*avctx->height + (int64_t)offset > avpkt->size && (!dpx->unpadded_10bit || (avctx->width * avctx->height * dpx->components + 2) / 3 * 4 + (int64_t)offset > avpkt->size)) { // Alignment seems unappliable, try without - if (dpx->stride*avctx->height + (int64_t)offset > avpkt->size || dpx->unpadded_10bit) { + if ((long)(dpx->stride)*avctx->height + (int64_t)offset > avpkt->size || dpx->unpadded_10bit) { av_log(avctx, AV_LOG_ERROR, "Overread buffer. Invalid header?\n"); return AVERROR_INVALIDDATA; } else { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dvdsubdec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dvdsubdec.c index 9f9845bf8e7..df9e90b7f73 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dvdsubdec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dvdsubdec.c @@ -378,7 +378,7 @@ static int decode_dvd_subtitles(void *logctx, DVDSubContext *ctx, if (!sub_header->rects[0]) goto fail; sub_header->num_rects = 1; - bitmap = sub_header->rects[0]->data[0] = av_malloc(w * h); + bitmap = sub_header->rects[0]->data[0] = av_malloc((size_t)(w) * h); if (!bitmap) goto fail; if (decode_rle(bitmap, w * 2, w, (h + 1) / 2, ctx->used_color, @@ -481,7 +481,7 @@ static int find_smallest_bounding_rectangle(DVDSubContext *ctx, AVSubtitle *s) x2--; w = x2 - x1 + 1; h = y2 - y1 + 1; - bitmap = av_malloc(w * h); + bitmap = av_malloc((size_t)(w) * h); if (!bitmap) return 1; for(y = 0; y < h; y++) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dvenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dvenc.c index f25c3ddfeeb..f598b711771 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dvenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dvenc.c @@ -548,7 +548,7 @@ static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, const uint8_t *d if (data) { if (DV_PROFILE_IS_HD(s->sys)) { - s->get_pixels(blk, data, linesize * (1 << bi->dct_mode)); + s->get_pixels(blk, data, (ptrdiff_t)(linesize) * (1 << bi->dct_mode)); s->fdct[0](blk); } else { bi->dct_mode = dv_guess_dct_mode(s, data, linesize); @@ -911,7 +911,7 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg) if ((s->sys->pix_fmt == AV_PIX_FMT_YUV420P) || (s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) || (s->sys->height >= 720 && mb_y != 134)) { - y_stride = s->frame->linesize[0] * (1 << (3*!enc_blk->dct_mode)); + y_stride = (ptrdiff_t)(s->frame->linesize[0]) * (1 << (3*!enc_blk->dct_mode)); } else { y_stride = 16; } diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dxtory.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dxtory.c index a9b5d835dbb..b442a095016 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dxtory.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dxtory.c @@ -44,9 +44,9 @@ static int64_t get_raw_size(enum AVPixelFormat fmt, int width, int height) case AV_PIX_FMT_YUV444P: return width * height * 3LL; case AV_PIX_FMT_YUV420P: - return (int64_t)(width * height) + 2 * AV_CEIL_RSHIFT(width, 1) * AV_CEIL_RSHIFT(height, 1); + return (int64_t)(width * height) + (long)(2) * AV_CEIL_RSHIFT(width, 1) * AV_CEIL_RSHIFT(height, 1); case AV_PIX_FMT_YUV410P: - return (int64_t)(width * height) + 2 * AV_CEIL_RSHIFT(width, 2) * AV_CEIL_RSHIFT(height, 2); + return (int64_t)(width * height) + (long)(2) * AV_CEIL_RSHIFT(width, 2) * AV_CEIL_RSHIFT(height, 2); } return 0; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dxv.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dxv.c index 626dd75a338..c4ab6c292e1 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dxv.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dxv.c @@ -978,8 +978,8 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame, return AVERROR_INVALIDDATA; } - ctx->tex_size = avctx->coded_width / (texdsp_ctx.raw_ratio / (avctx->pix_fmt == AV_PIX_FMT_RGBA ? 4 : 1)) * - avctx->coded_height / TEXTURE_BLOCK_H * + ctx->tex_size = (size_t)(avctx->coded_width / (texdsp_ctx.raw_ratio / (avctx->pix_fmt == AV_PIX_FMT_RGBA ? 4 : 1)) * + avctx->coded_height / TEXTURE_BLOCK_H) * texdsp_ctx.tex_ratio; unsigned old_size = ctx->tex_data_size; void *ptr = av_fast_realloc(ctx->tex_data, &ctx->tex_data_size, ctx->tex_size + AV_INPUT_BUFFER_PADDING_SIZE); @@ -993,8 +993,8 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame, if (avctx->pix_fmt != AV_PIX_FMT_RGBA) { int i; - ctx->ctex_size = avctx->coded_width / 2 / ctexdsp_ctx.raw_ratio * - avctx->coded_height / 2 / TEXTURE_BLOCK_H * + ctx->ctex_size = (int64_t)(avctx->coded_width / 2 / ctexdsp_ctx.raw_ratio * + avctx->coded_height / 2 / TEXTURE_BLOCK_H) * ctexdsp_ctx.tex_ratio; ctx->op_size[0] = avctx->coded_width * avctx->coded_height / 16; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dxvenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dxvenc.c index 0a2dd8077b7..36c973d4171 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dxvenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/dxvenc.c @@ -269,8 +269,8 @@ static av_cold int dxv_init(AVCodecContext *avctx) return AVERROR_INVALIDDATA; } ctx->enc.raw_ratio = 16; - ctx->tex_size = DXV_ALIGN(avctx->width) / TEXTURE_BLOCK_W * - DXV_ALIGN(avctx->height) / TEXTURE_BLOCK_H * + ctx->tex_size = (int64_t)(DXV_ALIGN(avctx->width) / TEXTURE_BLOCK_W * + DXV_ALIGN(avctx->height) / TEXTURE_BLOCK_H) * ctx->enc.tex_ratio; ctx->enc.slice_count = av_clip(avctx->thread_count, 1, DXV_ALIGN(avctx->height) / TEXTURE_BLOCK_H); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/eacmv.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/eacmv.c index 15d3550cb8f..617171b2460 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/eacmv.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/eacmv.c @@ -195,7 +195,7 @@ static int cmv_decode_frame(AVCodecContext *avctx, AVFrame *frame, return ret; buf += EA_PREAMBLE_SIZE; - if (!(buf[0]&1) && buf_end - buf < s->width * s->height * (int64_t)(100 - s->avctx->discard_damaged_percentage) / 100) + if (!(buf[0]&1) && buf_end - buf < (long)(s->width) * s->height * (int64_t)(100 - s->avctx->discard_damaged_percentage) / 100) return AVERROR_INVALIDDATA; if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/eatgv.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/eatgv.c index 35bd88b7403..bc50ca1eebe 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/eatgv.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/eatgv.c @@ -314,7 +314,7 @@ static int tgv_decode_frame(AVCodecContext *avctx, AVFrame *frame, frame->pict_type = AV_PICTURE_TYPE_I; if (!s->frame_buffer && - !(s->frame_buffer = av_mallocz(s->width * s->height))) + !(s->frame_buffer = av_mallocz((size_t)(s->width) * s->height))) return AVERROR(ENOMEM); if (unpack(buf, buf_end, s->frame_buffer, s->avctx->width, s->avctx->height) < 0) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/elbg.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/elbg.c index 84043af4fd3..7205ed80403 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/elbg.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/elbg.c @@ -411,7 +411,7 @@ static void do_elbg(ELBGContext *restrict elbg, int *points, int numpoints, memset(size_part, 0, elbg->num_cb * sizeof(*size_part)); - memset(elbg->codebook, 0, elbg->num_cb * elbg->dim * sizeof(*elbg->codebook)); + memset(elbg->codebook, 0, (unsigned long)(elbg->num_cb) * elbg->dim * sizeof(*elbg->codebook)); for (i=0; i < numpoints; i++) { size_part[elbg->nearest_cb[i]]++; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1dec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1dec.c index 28e6ec3c4d8..8c795f1d2ae 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1dec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1dec.c @@ -327,7 +327,7 @@ static int decode_remap(FFV1Context *f, FFV1SliceContext *sc) unsigned run0 = lu ? 0 : run; unsigned run1 = lu ? run : 1; - i += run0 * current_mul; + i += (long)(run0) * current_mul; while (run1--) { if (current_mul > 1) { @@ -695,7 +695,7 @@ static int decode_header(AVCodecContext *avctx, RangeCoder *c, for (i = 0; w > (1<height + i + 6) / 8 * s) + if (buf_size < (unsigned long)((avctx->height + i + 6) / 8) * s) return AVERROR_INVALIDDATA; } diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1enc.c index b6d25013f03..63ed20999a3 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1enc.c @@ -283,7 +283,7 @@ static int encode_plane(FFV1Context *f, FFV1SliceContext *sc, sample[2] = sc->sample_buffer; // dummy to avoid UB pointer arithmetic - memset(sc->sample_buffer, 0, ring_size * (w + 6) * sizeof(*sc->sample_buffer)); + memset(sc->sample_buffer, 0, (unsigned long)(ring_size) * (w + 6) * sizeof(*sc->sample_buffer)); for (y = 0; y < h; y++) { for (i = 0; i < ring_size; i++) @@ -577,7 +577,7 @@ int ff_ffv1_encode_determine_slices(AVCodecContext *avctx) int maxh = (avctx->height + s->num_v_slices - 1) / s->num_v_slices; if (s->num_h_slices > max_h_slices || s->num_v_slices > max_v_slices) continue; - if (maxw * maxh * (int64_t)(s->bits_per_raw_sample+1) * plane_count > 8<<24) + if ((long)(maxw) * maxh * (int64_t)(s->bits_per_raw_sample+1) * plane_count > 8<<24) continue; if (s->version < 4) if ( ff_need_new_slices(avctx->width , s->num_h_slices, s->chroma_h_shift) @@ -1032,7 +1032,7 @@ static av_cold int encode_init_internal(AVCodecContext *avctx) sc->unit[p] = av_malloc_array(sc->slice_width, sc->slice_height * sizeof(**sc->unit)); if (!sc->unit[p]) return AVERROR(ENOMEM); - sc->bitmap[p] = av_malloc_array(sc->slice_width * sc->slice_height, sizeof(*sc->bitmap[p])); + sc->bitmap[p] = av_malloc_array((size_t)(sc->slice_width) * sc->slice_height, sizeof(*sc->bitmap[p])); if (!sc->bitmap[p]) return AVERROR(ENOMEM); } else { @@ -1318,7 +1318,7 @@ static int encode_float32_remap_segment(FFV1SliceContext *sc, } else { val = last_val + ((1LL<<32) - last_val + current_mul - 1) / current_mul * current_mul; av_assert2(val >= (1LL<<32)); - val += lu * current_mul; //ensure a run1 ends + val += (long)(lu) * current_mul; //ensure a run1 ends } } else val = sc->unit[p][i].val; @@ -1517,7 +1517,7 @@ static int encode_float32_rgb_frame(FFV1Context *f, FFV1SliceContext *sc, for (int p = 0; p < MAX_PLANES; ++p) sample[p][2] = sc->sample_buffer32; // dummy to avoid UB pointer arithmetic - memset(RENAME(sc->sample_buffer), 0, ring_size * MAX_PLANES * + memset(RENAME(sc->sample_buffer), 0, (unsigned long)(ring_size) * MAX_PLANES * (w + 6) * sizeof(*RENAME(sc->sample_buffer))); for (y = 0; y < h; y++) { @@ -1689,16 +1689,16 @@ size_t ff_ffv1_encode_buffer_size(AVCodecContext *avctx) int w = avctx->width + f->num_h_slices; int h = avctx->height + f->num_v_slices; - size_t maxsize = w*h * (1 + f->transparency); + size_t maxsize = (size_t)(w)*h * (1 + f->transparency); if (f->chroma_planes) - maxsize += AV_CEIL_RSHIFT(w, f->chroma_h_shift) * AV_CEIL_RSHIFT(h, f->chroma_v_shift) * 2; + maxsize += (unsigned long)(AV_CEIL_RSHIFT(w, f->chroma_h_shift)) * AV_CEIL_RSHIFT(h, f->chroma_v_shift) * 2; maxsize += f->slice_count * 800; //for slice header if (f->version > 3) { maxsize *= f->bits_per_raw_sample + 1; if (f->remap_mode) - maxsize += f->slice_count * 70000 * (1 + 2*f->chroma_planes + f->transparency); + maxsize += (unsigned long)(f->slice_count) * 70000 * (1 + 2*f->chroma_planes + f->transparency); } else { - maxsize += f->slice_count * 2 * (avctx->width + avctx->height); //for bug with slices that code some pixels more than once + maxsize += (unsigned long)(f->slice_count) * 2 * (avctx->width + avctx->height); //for bug with slices that code some pixels more than once maxsize *= 8*(2*f->bits_per_raw_sample + 5); } maxsize >>= 3; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1enc_template.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1enc_template.c index 63eb99b9293..f1c4ee89e63 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1enc_template.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1enc_template.c @@ -192,7 +192,7 @@ static int RENAME(encode_rgb_frame)(FFV1Context *f, FFV1SliceContext *sc, for (int p = 0; p < MAX_PLANES; ++p) sample[p][2] = RENAME(sc->sample_buffer); - memset(RENAME(sc->sample_buffer), 0, ring_size * MAX_PLANES * + memset(RENAME(sc->sample_buffer), 0, (unsigned long)(ring_size) * MAX_PLANES * (w + 6) * sizeof(*RENAME(sc->sample_buffer))); for (y = 0; y < h; y++) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1enc_vulkan.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1enc_vulkan.c index 0e891f08884..9698e0fa3e3 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1enc_vulkan.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ffv1enc_vulkan.c @@ -223,7 +223,7 @@ static int vulkan_encode_ffv1_submit_frame(AVCodecContext *avctx, RET(ff_vk_get_pooled_buffer(&fv->s, &fv->slice_data_pool, &slice_data_ref, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, - NULL, slice_state_size*f->slice_count, + NULL, (size_t)(slice_state_size)*f->slice_count, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)); /* Only save it if we're going to use it again */ @@ -604,7 +604,7 @@ static int get_packet(AVCodecContext *avctx, FFVkExecContext *exec, ff_vk_exec_wait(&fv->s, exec); /* Invalidate slice/output data if needed */ - uint32_t rb_off = fd->idx*f->max_slice_count*sizeof(uint32_t); + uint32_t rb_off = (unsigned long)(fd->idx)*f->max_slice_count*sizeof(uint32_t); if (!(fv->results_buf.flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) { VkMappedMemoryRange invalidate_data = { .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, @@ -1236,7 +1236,7 @@ static av_cold int vulkan_encode_ffv1_init(AVCodecContext *avctx) /* Buffers */ RET(ff_vk_create_buf(&fv->s, &fv->results_buf, - fv->async_depth*f->max_slice_count*sizeof(uint32_t), + (unsigned long)(fv->async_depth)*f->max_slice_count*sizeof(uint32_t), NULL, NULL, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/fitsenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/fitsenc.c index 2a315140682..0da998e486e 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/fitsenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/fitsenc.c @@ -77,7 +77,7 @@ static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt, return AVERROR(EINVAL); } - data_size = (bitpix >> 3) * avctx->height * avctx->width * naxis3; + data_size = (uint64_t)((bitpix >> 3)) * avctx->height * avctx->width * naxis3; padded_data_size = ((data_size + 2879) / 2880 ) * 2880; if ((ret = ff_get_encode_buffer(avctx, pkt, padded_data_size, 0)) < 0) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flacenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flacenc.c index ead2c55f104..5d583ee21c6 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flacenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flacenc.c @@ -572,10 +572,10 @@ static uint64_t subframe_count_exact(FlacEncodeContext *s, FlacSubframe *sub, if (sub->type == FLAC_SUBFRAME_CONSTANT) { count += sub->obits; } else if (sub->type == FLAC_SUBFRAME_VERBATIM) { - count += s->frame.blocksize * sub->obits; + count += (unsigned long)(s->frame.blocksize) * sub->obits; } else { /* warm-up samples */ - count += pred_order * sub->obits; + count += (unsigned long)(pred_order) * sub->obits; /* LPC coefficients */ if (sub->type == FLAC_SUBFRAME_LPC) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flashsv.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flashsv.c index ba5c995006b..3d347453c3d 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flashsv.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flashsv.c @@ -354,11 +354,11 @@ static int flashsv_decode_frame(AVCodecContext *avctx, AVFrame *rframe, return err; s->keyframedata = avpkt->data; if (s->blocks) - memset(s->blocks, 0, (v_blocks + !!v_part) * (h_blocks + !!h_part) * + memset(s->blocks, 0, (unsigned long)((v_blocks + !!v_part)) * (h_blocks + !!h_part) * sizeof(s->blocks[0])); } if(s->ver == 2 && !s->blocks) - s->blocks = av_mallocz((v_blocks + !!v_part) * (h_blocks + !!h_part) * + s->blocks = av_mallocz((unsigned long)((v_blocks + !!v_part)) * (h_blocks + !!h_part) * sizeof(s->blocks[0])); ff_dlog(avctx, "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n", @@ -480,7 +480,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, AVFrame *rframe, } if (s->is_keyframe && s->ver == 2) { if (!s->keyframe) { - s->keyframe = av_malloc(s->frame->linesize[0] * avctx->height); + s->keyframe = av_malloc((size_t)(s->frame->linesize[0]) * avctx->height); if (!s->keyframe) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate image data\n"); return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flashsv2enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flashsv2enc.c index 17e0bc1b3c6..1fa7ab605b5 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flashsv2enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flashsv2enc.c @@ -146,7 +146,7 @@ static void init_blocks(FlashSV2Context * s, Block * blocks, { int row, col; Block *b; - memset(blocks, 0, s->cols * s->rows * sizeof(*blocks)); + memset(blocks, 0, (unsigned long)(s->cols) * s->rows * sizeof(*blocks)); for (col = 0; col < s->cols; col++) { for (row = 0; row < s->rows; row++) { b = blocks + (col + row * s->cols); @@ -185,19 +185,19 @@ static int update_block_dimensions(FlashSV2Context *s, int block_width, int bloc s->block_height = block_height; s->rows = (s->image_height + s->block_height - 1) / s->block_height; s->cols = (s->image_width + s->block_width - 1) / s->block_width; - if (s->rows * s->cols > s->blocks_size / sizeof(Block)) { + if ((unsigned long)(s->rows) * s->cols > s->blocks_size / sizeof(Block)) { s->frame_blocks = av_realloc_array(s->frame_blocks, s->rows, s->cols * sizeof(Block)); s->key_blocks = av_realloc_array(s->key_blocks, s->cols, s->rows * sizeof(Block)); if (!s->frame_blocks || !s->key_blocks) { av_log(s->avctx, AV_LOG_ERROR, "Memory allocation failed.\n"); return AVERROR(ENOMEM); } - s->blocks_size = s->rows * s->cols * sizeof(Block); + s->blocks_size = (unsigned long)(s->rows) * s->cols * sizeof(Block); } init_blocks(s, s->frame_blocks, s->encbuffer, s->databuffer); init_blocks(s, s->key_blocks, s->keybuffer, 0); - av_fast_malloc(&s->blockbuffer, &s->blockbuffer_size, block_width * block_height * 6); + av_fast_malloc(&s->blockbuffer, &s->blockbuffer_size, (size_t)(block_width) * block_height * 6); if (!s->blockbuffer) { av_log(s->avctx, AV_LOG_ERROR, "Could not allocate block buffer.\n"); return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flashsvenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flashsvenc.c index bd4c8651e20..97bacd96a31 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flashsvenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flashsvenc.c @@ -177,7 +177,7 @@ static int encode_bitstream(FlashSVContext *s, const AVFrame *p, uint8_t *buf, if (res || *I_frame) { unsigned long zsize = 3 * block_width * block_height + 12; ret = compress2(ptr + 2, &zsize, s->tmpblock, - 3 * cur_blk_width * cur_blk_height, + (uLong)(3) * cur_blk_width * cur_blk_height, s->compression_level); if (ret != Z_OK) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flicvideo.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flicvideo.c index f17e61a9f2b..4d90ceaaa61 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flicvideo.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/flicvideo.c @@ -198,7 +198,7 @@ static int flic_decode_frame_1BPP(AVCodecContext *avctx, direction = s->frame->linesize[0] > 0; pixels = s->frame->data[0]; - pixel_limit = s->avctx->height * s->frame->linesize[0]; + pixel_limit = (ptrdiff_t)(s->avctx->height) * s->frame->linesize[0]; if (buf_size < 16 || buf_size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) return AVERROR_INVALIDDATA; frame_size = bytestream2_get_le32(&g2); @@ -282,7 +282,7 @@ static int flic_decode_frame_1BPP(AVCodecContext *avctx, if (starting_line >= s->avctx->height) return AVERROR_INVALIDDATA; y_ptr = 0; - y_ptr += starting_line * s->frame->linesize[0]; + y_ptr += (long)(starting_line) * s->frame->linesize[0]; compressed_lines = bytestream2_get_le16(&g2); while (compressed_lines > 0) { @@ -398,7 +398,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx, direction = s->frame->linesize[0] > 0; pixels = s->frame->data[0]; - pixel_limit = s->avctx->height * s->frame->linesize[0]; + pixel_limit = (ptrdiff_t)(s->avctx->height) * s->frame->linesize[0]; if (buf_size < 16 || buf_size > INT_MAX - (3 * 256 + AV_INPUT_BUFFER_PADDING_SIZE)) return AVERROR_INVALIDDATA; frame_size = bytestream2_get_le32(&g2); @@ -488,7 +488,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx, line_packets = -line_packets; if (line_packets > s->avctx->height) return AVERROR_INVALIDDATA; - y_ptr += line_packets * s->frame->linesize[0]; + y_ptr += (long)(line_packets) * s->frame->linesize[0]; } else if ((line_packets & 0xC000) == 0x4000) { av_log(avctx, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", line_packets); } else if ((line_packets & 0xC000) == 0x8000) { @@ -539,7 +539,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx, if (starting_line >= s->avctx->height) return AVERROR_INVALIDDATA; y_ptr = 0; - y_ptr += starting_line * s->frame->linesize[0]; + y_ptr += (long)(starting_line) * s->frame->linesize[0]; compressed_lines = bytestream2_get_le16(&g2); while (compressed_lines > 0) { @@ -731,7 +731,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx, direction = s->frame->linesize[0] > 0; pixels = s->frame->data[0]; - pixel_limit = s->avctx->height * s->frame->linesize[0]; + pixel_limit = (ptrdiff_t)(s->avctx->height) * s->frame->linesize[0]; frame_size = bytestream2_get_le32(&g2); bytestream2_skip(&g2, 2); /* skip the magic number */ @@ -784,7 +784,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx, line_packets = -line_packets; if (line_packets > s->avctx->height) return AVERROR_INVALIDDATA; - y_ptr += line_packets * s->frame->linesize[0]; + y_ptr += (long)(line_packets) * s->frame->linesize[0]; } else { compressed_lines--; pixel_ptr = y_ptr; @@ -1031,7 +1031,7 @@ static int flic_decode_frame_24BPP(AVCodecContext *avctx, direction = s->frame->linesize[0] > 0; pixels = s->frame->data[0]; - pixel_limit = s->avctx->height * s->frame->linesize[0]; + pixel_limit = (ptrdiff_t)(s->avctx->height) * s->frame->linesize[0]; frame_size = bytestream2_get_le32(&g2); bytestream2_skip(&g2, 2); /* skip the magic number */ @@ -1084,7 +1084,7 @@ static int flic_decode_frame_24BPP(AVCodecContext *avctx, line_packets = -line_packets; if (line_packets > s->avctx->height) return AVERROR_INVALIDDATA; - y_ptr += line_packets * s->frame->linesize[0]; + y_ptr += (long)(line_packets) * s->frame->linesize[0]; } else { compressed_lines--; pixel_ptr = y_ptr; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/fmvc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/fmvc.c index b51b18a9eec..bd2e3a86c82 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/fmvc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/fmvc.c @@ -613,8 +613,8 @@ static av_cold int decode_init(AVCodecContext *avctx) } s->bpp = avctx->bits_per_coded_sample >> 3; - s->buffer_size = avctx->width * avctx->height * 4; - s->pbuffer_size = avctx->width * avctx->height * 4; + s->buffer_size = (size_t)(avctx->width) * avctx->height * 4; + s->pbuffer_size = (size_t)(avctx->width) * avctx->height * 4; s->buffer = av_mallocz(s->buffer_size); s->pbuffer = av_mallocz(s->pbuffer_size); if (!s->buffer || !s->pbuffer) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/g2meet.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/g2meet.c index f3347e951eb..f7ea0cff651 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/g2meet.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/g2meet.c @@ -970,7 +970,7 @@ static int epic_jb_decode_tile(G2MContext *c, int tile_x, int tile_y, tr = (tr_r << R_shift) | (tr_g << G_shift) | (tr_b << B_shift); memset(c->kempf_flags, 0, - (aheight >> 3) * bstride * sizeof(*c->kempf_flags)); + (unsigned long)((aheight >> 3)) * bstride * sizeof(*c->kempf_flags)); for (j = 0; j < tile_height; j += 8) { for (i = 0; i < tile_width; i += 8) { c->kempf_flags[(i >> 3) + (j >> 3) * bstride] = 0; @@ -1055,7 +1055,7 @@ static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y, int hdr, zsize, npal, tidx = -1, ret; const uint8_t *src_end = src + src_size; uint8_t pal[768], transp[3]; - uLongf dlen = (c->tile_width + 1) * c->tile_height; + uLongf dlen = (uLongf)((c->tile_width + 1)) * c->tile_height; int sub_type; int nblocks, cblocks, bstride; int bits, bitbuf, coded; @@ -1164,7 +1164,7 @@ static int g2m_init_buffers(G2MContext *c) c->framebuf_stride = FFALIGN(c->width + 15, 16) * 3; aligned_height = c->height + 15; - av_fast_mallocz(&c->framebuf, &c->framebuf_allocated, c->framebuf_stride * aligned_height); + av_fast_mallocz(&c->framebuf, &c->framebuf_allocated, (size_t)(c->framebuf_stride) * aligned_height); if (!c->framebuf) return AVERROR(ENOMEM); @@ -1181,11 +1181,11 @@ static int g2m_init_buffers(G2MContext *c) av_freep(&c->kempf_flags); av_freep(&c->epic_buf_base); c->epic_buf = NULL; - c->synth_tile = av_mallocz(c->tile_stride * aligned_height); - c->jpeg_tile = av_mallocz(c->tile_stride * aligned_height); + c->synth_tile = av_mallocz((size_t)(c->tile_stride) * aligned_height); + c->jpeg_tile = av_mallocz((size_t)(c->tile_stride) * aligned_height); c->kempf_buf = av_mallocz((c->tile_width + 1) * aligned_height + AV_INPUT_BUFFER_PADDING_SIZE); - c->kempf_flags = av_mallocz(c->tile_width * aligned_height); + c->kempf_flags = av_mallocz((size_t)(c->tile_width) * aligned_height); if (!c->synth_tile || !c->jpeg_tile || !c->kempf_buf || !c->kempf_flags) return AVERROR(ENOMEM); @@ -1243,7 +1243,7 @@ static int g2m_load_cursor(AVCodecContext *avctx, G2MContext *c, return AVERROR_PATCHWELCOME; } - if ((err = av_reallocp(&c->cursor, cursor_stride * cursor_h)) < 0) { + if ((err = av_reallocp(&c->cursor, (size_t)(cursor_stride) * cursor_h)) < 0) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate cursor buffer\n"); return err; } diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/g723_1dec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/g723_1dec.c index 67a5df55ff0..b7f72969437 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/g723_1dec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/g723_1dec.c @@ -868,13 +868,13 @@ static void generate_noise(G723_1_ChannelContext *p) if (shift < 0) { for (j = 0; j < SUBFRAME_LEN * 2; j++) { t = vector_ptr[j] * (1 << -shift); - sum += t * t; + sum += (long)(t) * t; tmp[j] = t; } } else { for (j = 0; j < SUBFRAME_LEN * 2; j++) { t = vector_ptr[j] >> shift; - sum += t * t; + sum += (long)(t) * t; tmp[j] = t; } } diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/g723_1enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/g723_1enc.c index 4fd4567a876..d7e67741dcc 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/g723_1enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/g723_1enc.c @@ -613,7 +613,7 @@ static void harmonic_filter(HFParam *hf, const int16_t *src, int16_t *dest) int i; for (i = 0; i < SUBFRAME_LEN; i++) { - int64_t temp = hf->gain * src[i - hf->index] * 2; + int64_t temp = (int64_t)(hf->gain) * src[i - hf->index] * 2; dest[i] = av_clipl_int32(src[i] * (1 << 16) - temp + (1 << 15)) >> 16; } } @@ -622,7 +622,7 @@ static void harmonic_noise_sub(HFParam *hf, const int16_t *src, int16_t *dest) { int i; for (i = 0; i < SUBFRAME_LEN; i++) { - int64_t temp = hf->gain * src[i - hf->index] * 2; + int64_t temp = (int64_t)(hf->gain) * src[i - hf->index] * 2; dest[i] = av_clipl_int32((dest[i] - src[i]) * (1 << 16) + temp + (1 << 15)) >> 16; } @@ -769,7 +769,7 @@ static void acb_search(G723_1_ChannelContext *p, int16_t *residual, for (j = 0, k = 0; j < tbl_size; j++, k += 20) { temp = 0; for (l = 0; l < 20; l++) - temp += ccr_buf[20 * i + l] * cb_tbl[k + l]; + temp += (long)(ccr_buf[20 * i + l]) * cb_tbl[k + l]; temp = av_clipl_int32(temp); if (temp > max) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/gif.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/gif.c index 132ce07e6cd..0cbc0a960b0 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/gif.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/gif.c @@ -402,7 +402,7 @@ static int gif_image_write_image(AVCodecContext *avctx, if (shrunk_palette_count) { if (!s->shrunk_buf) { - s->shrunk_buf = av_malloc(avctx->height * linesize); + s->shrunk_buf = av_malloc((size_t)(avctx->height) * linesize); if (!s->shrunk_buf) { av_log(avctx, AV_LOG_ERROR, "Could not allocated remapped frame buffer.\n"); return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/gifdec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/gifdec.c index ae45eb0f6d4..2c780b8def0 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/gifdec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/gifdec.c @@ -234,7 +234,7 @@ static int gif_read_image(GifState *s, AVFrame *frame) else s->stored_bg_color = s->bg_color; } else if (s->gce_disposal == GCE_DISPOSAL_RESTORE) { - av_fast_malloc(&s->stored_img, &s->stored_img_size, FFABS(frame->linesize[0]) * frame->height); + av_fast_malloc(&s->stored_img, &s->stored_img_size, (size_t)(FFABS(frame->linesize[0])) * frame->height); if (!s->stored_img) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/h264_mb.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/h264_mb.c index 67fa980de33..624c8b635c1 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/h264_mb.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/h264_mb.c @@ -217,7 +217,7 @@ static av_always_inline void mc_dir_part(const H264Context *h, H264SliceContext const int mx = sl->mv_cache[list][scan8[n]][0] + src_x_offset * 8; int my = sl->mv_cache[list][scan8[n]][1] + src_y_offset * 8; const int luma_xy = (mx & 3) + ((my & 3) << 2); - ptrdiff_t offset = (mx >> 2) * (1 << pixel_shift) + (my >> 2) * sl->mb_linesize; + ptrdiff_t offset = (long)((mx >> 2)) * (1 << pixel_shift) + (my >> 2) * sl->mb_linesize; uint8_t *src_y = pic->data[0] + offset; uint8_t *src_cb, *src_cr; int extra_width = 0; @@ -492,7 +492,7 @@ static av_always_inline void prefetch_motion(const H264Context *h, H264SliceCont const int mx = (sl->mv_cache[list][scan8[0]][0] >> 2) + 16 * sl->mb_x + 8; const int my = (sl->mv_cache[list][scan8[0]][1] >> 2) + 16 * sl->mb_y; uint8_t **src = sl->ref_list[list][refn].data; - int off = mx * (1<< pixel_shift) + + int off = (long)(mx) * (1<< pixel_shift) + (my + (sl->mb_x & 3) * 4) * sl->mb_linesize + (64 << pixel_shift); h->vdsp.prefetch(src[0] + off, sl->linesize, 4); @@ -500,7 +500,7 @@ static av_always_inline void prefetch_motion(const H264Context *h, H264SliceCont h->vdsp.prefetch(src[1] + off, sl->linesize, 4); h->vdsp.prefetch(src[2] + off, sl->linesize, 4); } else { - off= ((mx>>1)+64) * (1<>1) + (sl->mb_x&7))*sl->uvlinesize; + off= (long)(((mx>>1)+64)) * (1<>1) + (sl->mb_x&7))*sl->uvlinesize; h->vdsp.prefetch(src[1] + off, src[2] - src[1], 2); } } diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hapdec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hapdec.c index 70bf592f2aa..45d32346e59 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hapdec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hapdec.c @@ -284,7 +284,7 @@ static int hap_decode(AVCodecContext *avctx, AVFrame *frame, if (ret < 0) return ret; - if (ctx->tex_size != (avctx->coded_width / TEXTURE_BLOCK_W) + if (ctx->tex_size != (unsigned long)((avctx->coded_width / TEXTURE_BLOCK_W)) *(avctx->coded_height / TEXTURE_BLOCK_H) *ctx->dec[t].tex_ratio) { av_log(avctx, AV_LOG_ERROR, "uncompressed size mismatches\n"); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hapenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hapenc.c index 6882b1e563c..0f812de2451 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hapenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hapenc.c @@ -280,8 +280,8 @@ static av_cold int hap_init(AVCodecContext *avctx) /* Texture compression ratio is constant, so can we computer * beforehand the final size of the uncompressed buffer. */ - ctx->tex_size = avctx->width / TEXTURE_BLOCK_W * - avctx->height / TEXTURE_BLOCK_H * ctx->enc.tex_ratio; + ctx->tex_size = (size_t)(avctx->width / TEXTURE_BLOCK_W * + avctx->height / TEXTURE_BLOCK_H) * ctx->enc.tex_ratio; switch (ctx->opt_compressor) { case HAP_COMP_NONE: diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hevc/cabac.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hevc/cabac.c index 55d5741f875..3c23d73e9ec 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hevc/cabac.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hevc/cabac.c @@ -1022,7 +1022,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, const HEVCPPS *pps, int pred_mode_intra = (c_idx == 0) ? lc->tu.intra_pred_mode : lc->tu.intra_pred_mode_c; - memset(coeffs, 0, trafo_size * trafo_size * sizeof(int16_t)); + memset(coeffs, 0, (unsigned long)(trafo_size) * trafo_size * sizeof(int16_t)); // Derive QP for dequant if (!lc->cu.cu_transquant_bypass_flag) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hevc/ps.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hevc/ps.c index a21563c2e22..9b9ef7f00ab 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hevc/ps.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hevc/ps.c @@ -2102,7 +2102,7 @@ static inline int setup_pps(AVCodecContext *avctx, GetBitContext *gb, pps->ctb_addr_rs_to_ts = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_rs_to_ts)); pps->ctb_addr_ts_to_rs = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_ts_to_rs)); pps->tile_id = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->tile_id)); - pps->min_tb_addr_zs_tab = av_malloc_array((sps->tb_mask+2) * (sps->tb_mask+2), sizeof(*pps->min_tb_addr_zs_tab)); + pps->min_tb_addr_zs_tab = av_malloc_array((size_t)((sps->tb_mask+2)) * (sps->tb_mask+2), sizeof(*pps->min_tb_addr_zs_tab)); if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs || !pps->tile_id || !pps->min_tb_addr_zs_tab) { return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hnm4video.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hnm4video.c index 51e75789d2a..01445b28021 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hnm4video.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hnm4video.c @@ -471,9 +471,9 @@ static av_cold int hnm_decode_init(AVCodecContext *avctx) avctx->pix_fmt = AV_PIX_FMT_PAL8; hnm->width = avctx->width; hnm->height = avctx->height; - hnm->buffer1 = av_mallocz(avctx->width * avctx->height); - hnm->buffer2 = av_mallocz(avctx->width * avctx->height); - hnm->processed = av_mallocz(avctx->width * avctx->height); + hnm->buffer1 = av_mallocz((size_t)(avctx->width) * avctx->height); + hnm->buffer2 = av_mallocz((size_t)(avctx->width) * avctx->height); + hnm->processed = av_mallocz((size_t)(avctx->width) * avctx->height); if (!hnm->buffer1 || !hnm->buffer2 || !hnm->processed) { av_log(avctx, AV_LOG_ERROR, "av_mallocz() failed\n"); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hqx.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hqx.c index 9ec66725809..c85267e9811 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hqx.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/hqx.c @@ -131,9 +131,9 @@ static inline void put_blocks(HQXContext *ctx, int plane, uint8_t *p = ctx->pic->data[plane] + x * 2; ctx->hqxdsp.idct_put((uint16_t *)(p + y * lsize), - lsize * fields, block0, quant); + (ptrdiff_t)(lsize) * fields, block0, quant); ctx->hqxdsp.idct_put((uint16_t *)(p + (y + (ilace ? 1 : 8)) * lsize), - lsize * fields, block1, quant); + (ptrdiff_t)(lsize) * fields, block1, quant); } static inline void hqx_get_ac(GetBitContext *gb, const HQXAC *ac, diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/iff.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/iff.c index 66839c3c393..f6c6d4985da 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/iff.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/iff.c @@ -284,7 +284,7 @@ static int extract_header(AVCodecContext *const avctx, return AVERROR(ENOMEM); ham_count = 8 * (1 << s->ham); - s->ham_palbuf = av_malloc(extra_space * (ham_count << !!(s->masking == MASK_HAS_MASK)) * sizeof (uint32_t) + AV_INPUT_BUFFER_PADDING_SIZE); + s->ham_palbuf = av_malloc((unsigned long)(extra_space) * (ham_count << !!(s->masking == MASK_HAS_MASK)) * sizeof (uint32_t) + AV_INPUT_BUFFER_PADDING_SIZE); if (!s->ham_palbuf) return AVERROR(ENOMEM); @@ -381,8 +381,8 @@ static av_cold int decode_init(AVCodecContext *avctx) s->video_size = FFALIGN(avctx->width, 2) * avctx->height * s->bpp; if (!s->video_size) return AVERROR_INVALIDDATA; - s->video[0] = av_calloc(FFALIGN(avctx->width, 2) * avctx->height, s->bpp); - s->video[1] = av_calloc(FFALIGN(avctx->width, 2) * avctx->height, s->bpp); + s->video[0] = av_calloc((size_t)(FFALIGN(avctx->width, 2)) * avctx->height, s->bpp); + s->video[1] = av_calloc((size_t)(FFALIGN(avctx->width, 2)) * avctx->height, s->bpp); s->pal = av_calloc(256, sizeof(*s->pal)); if (!s->video[0] || !s->video[1] || !s->pal) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ivi.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ivi.c index a38f382d5f2..819eabf47ce 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ivi.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ivi.c @@ -331,7 +331,7 @@ av_cold int ff_ivi_init_planes(AVCodecContext *avctx, IVIPlaneDesc *planes, cons align_fac = p ? 8 : 16; width_aligned = FFALIGN(b_width , align_fac); height_aligned = FFALIGN(b_height, align_fac); - buf_size = width_aligned * height_aligned * sizeof(int16_t); + buf_size = (unsigned long)(width_aligned) * height_aligned * sizeof(int16_t); for (b = 0; b < planes[p].num_bands; b++) { band = &planes[p].bands[b]; /* select appropriate plane/band */ diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/j2kenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/j2kenc.c index cba4d18adf5..6fc9fe0952d 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/j2kenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/j2kenc.c @@ -641,7 +641,7 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20 int pass_t = 2, passno, x, y, max=0, nmsedec, bpno; int64_t wmsedec = 0; - memset(t1->flags, 0, t1->stride * (height + 2) * sizeof(*t1->flags)); + memset(t1->flags, 0, (unsigned long)(t1->stride) * (height + 2) * sizeof(*t1->flags)); for (y = 0; y < height; y++){ for (x = 0; x < width; x++){ diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/jpeg2000dec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/jpeg2000dec.c index 8b6b7cc1eec..de9398acbc5 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/jpeg2000dec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/jpeg2000dec.c @@ -318,7 +318,7 @@ static int get_siz(Jpeg2000DecoderContext *s) return AVERROR(EINVAL); } - s->tile = av_calloc(s->numXtiles * s->numYtiles, sizeof(*s->tile)); + s->tile = av_calloc((size_t)(s->numXtiles) * s->numYtiles, sizeof(*s->tile)); if (!s->tile) { s->numXtiles = s->numYtiles = 0; return AVERROR(ENOMEM); @@ -2030,13 +2030,13 @@ static int decode_cblk(const Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *cod av_assert0(width <= 1024U && height <= 1024U); av_assert0(width*height <= 4096); - memset(t1->data, 0, t1->stride * height * sizeof(*t1->data)); + memset(t1->data, 0, (unsigned long)(t1->stride) * height * sizeof(*t1->data)); /* If code-block contains no compressed data: nothing to do. */ if (!cblk->length) return 0; - memset(t1->flags, 0, t1->stride * (height + 2) * sizeof(*t1->flags)); + memset(t1->flags, 0, (unsigned long)(t1->stride) * (height + 2) * sizeof(*t1->flags)); cblk->data[cblk->length] = 0xff; cblk->data[cblk->length+1] = 0xff; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/jpeglsenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/jpeglsenc.c index 64440de2421..569d467836f 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/jpeglsenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/jpeglsenc.c @@ -435,9 +435,9 @@ static av_cold int encode_jpegls_init(AVCodecContext *avctx) ctx->comps = 3; size = FF_INPUT_BUFFER_MIN_SIZE; /* INT_MAX due to PutBit-API. */ - if (avctx->width * (unsigned)avctx->height > (INT_MAX - size) / 4 / ctx->comps) + if ((unsigned long)(avctx->width) * (unsigned)avctx->height > (INT_MAX - size) / 4 / ctx->comps) return AVERROR(ERANGE); - size += 4 * ctx->comps * avctx->width * avctx->height; + size += (unsigned long)(4) * ctx->comps * avctx->width * avctx->height; ctx->size = size; ctx->buf = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE); if (!ctx->buf) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/kgv1dec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/kgv1dec.c index bdc5a16259a..2b2c94bd3d9 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/kgv1dec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/kgv1dec.c @@ -74,8 +74,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, } if (!c->frame_buffer) { - c->frame_buffer = av_mallocz(avctx->width * avctx->height * 2); - c->last_frame_buffer = av_mallocz(avctx->width * avctx->height * 2); + c->frame_buffer = av_mallocz((size_t)(avctx->width) * avctx->height * 2); + c->last_frame_buffer = av_mallocz((size_t)(avctx->width) * avctx->height * 2); if (!c->frame_buffer || !c->last_frame_buffer) { decode_flush(avctx); return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/lcldec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/lcldec.c index e9d4283eefe..2bd69f1dbc6 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/lcldec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/lcldec.c @@ -304,7 +304,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, case IMGTYPE_YUV111: case IMGTYPE_RGB24: for (row = 0; row < height; row++) { - pixel_ptr = row * width * 3; + pixel_ptr = (ptrdiff_t)(row) * width * 3; yq = encoded[pixel_ptr++]; unsigned uqvq = AV_RL16(encoded+pixel_ptr); pixel_ptr += 2; @@ -350,7 +350,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, break; case IMGTYPE_YUV211: for (row = 0; row < height; row++) { - pixel_ptr = row * width * 2; + pixel_ptr = (ptrdiff_t)(row) * width * 2; yq = uq = vq =0; for (col = 0; col < width/2; col++) { encoded[pixel_ptr] = yq -= encoded[pixel_ptr]; @@ -363,7 +363,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, break; case IMGTYPE_YUV420: for (row = 0; row < height/2; row++) { - pixel_ptr = row * width * 3; + pixel_ptr = (ptrdiff_t)(row) * width * 3; yq = y1q = uq = vq =0; for (col = 0; col < width/2; col++) { encoded[pixel_ptr] = yq -= encoded[pixel_ptr]; @@ -424,7 +424,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, case IMGTYPE_RGB24: linesize = len < FFALIGN(3 * width, 4) * height ? 3 * width : FFALIGN(3 * width, 4); for (row = height - 1; row >= 0; row--) { - pixel_ptr = row * frame->linesize[0]; + pixel_ptr = (ptrdiff_t)(row) * frame->linesize[0]; memcpy(outptr + pixel_ptr, encoded, 3 * width); encoded += linesize; } diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/lclenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/lclenc.c index f328e12627d..bd27a4b1ec5 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/lclenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/lclenc.c @@ -71,7 +71,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, z_stream *const zstream = &c->zstream.zstream; int i, ret; int zret; // Zlib return code - int max_size = deflateBound(zstream, avctx->width * avctx->height * 3); + int max_size = deflateBound(zstream, (uLong)(avctx->width) * avctx->height * 3); if ((ret = ff_alloc_packet(avctx, pkt, max_size)) < 0) return ret; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libaribcaption.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libaribcaption.c index 66d18b9d388..b511eecbf91 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libaribcaption.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libaribcaption.c @@ -403,7 +403,7 @@ static int aribcaption_trans_bitmap_subtitle(ARIBCaptionContext *ctx) rect->w = image->width * ctx->bitmap_plane_width / ctx->frame_width; rect->h = image->height * ctx->bitmap_plane_height / ctx->frame_height; - rect->data[0] = av_mallocz(rect->w * rect->h); + rect->data[0] = av_mallocz((size_t)(rect->w) * rect->h); if (!rect->data[0]) { ret = AVERROR(ENOMEM); goto fail; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libcelt_dec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libcelt_dec.c index fcd4fc77364..055daa194eb 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libcelt_dec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libcelt_dec.c @@ -120,7 +120,7 @@ static int libcelt_dec_decode(AVCodecContext *c, AVFrame *frame, if (celt->discard) { frame->nb_samples -= celt->discard; memmove(pcm, pcm + celt->discard * c->ch_layout.nb_channels, - frame->nb_samples * c->ch_layout.nb_channels * sizeof(int16_t)); + (unsigned long)(frame->nb_samples) * c->ch_layout.nb_channels * sizeof(int16_t)); celt->discard = 0; } *got_frame_ptr = 1; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libmpeghdec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libmpeghdec.c index ecc3a2dc09f..49678ea9c48 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libmpeghdec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libmpeghdec.c @@ -196,7 +196,7 @@ static int mpegh3dadec_decode_frame(AVCodecContext *avctx, AVFrame *frame, return ret; memcpy(frame->extended_data[0], s->decoder_buffer, - avctx->ch_layout.nb_channels * frame->nb_samples * + (unsigned long)(avctx->ch_layout.nb_channels) * frame->nb_samples * sizeof(*s->decoder_buffer) /* only AV_SAMPLE_FMT_S32 is supported */); *got_frame_ptr = 1; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libopusenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libopusenc.c index 927776bbca0..03d92d780e7 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libopusenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libopusenc.c @@ -411,7 +411,7 @@ static av_cold int libopus_encode_init(AVCodecContext *avctx) } avctx->extradata_size = header_size; - opus->samples = av_calloc(frame_size, channels * + opus->samples = av_calloc(frame_size, (size_t)(channels) * av_get_bytes_per_sample(avctx->sample_fmt)); if (!opus->samples) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate samples buffer.\n"); @@ -445,8 +445,8 @@ static void libopus_copy_samples_with_channel_map( int sample, channel; for (sample = 0; sample < nb_samples; ++sample) { for (channel = 0; channel < nb_channels; ++channel) { - const size_t src_pos = bytes_per_sample * (nb_channels * sample + channel); - const size_t dst_pos = bytes_per_sample * (nb_channels * sample + channel_map[channel]); + const size_t src_pos = (size_t)(bytes_per_sample) * (nb_channels * sample + channel); + const size_t dst_pos = (size_t)(bytes_per_sample) * (nb_channels * sample + channel_map[channel]); memcpy(&dst[dst_pos], &src[src_pos], bytes_per_sample); } diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libx264.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libx264.c index b688d4f3218..0e3cc4846b7 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libx264.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libx264.c @@ -360,7 +360,7 @@ static int setup_mb_info(AVCodecContext *ctx, x264_picture_t *pic, mbinfo_rects = (const AVVideoRect *)av_video_hint_rects(info); nb_rects = info->nb_rects; - mbinfo = av_calloc(mb_width * mb_height, sizeof(*mbinfo)); + mbinfo = av_calloc((size_t)(mb_width) * mb_height, sizeof(*mbinfo)); if (!mbinfo) return AVERROR(ENOMEM); @@ -425,7 +425,7 @@ static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic, } nb_rois = size / roi_size; - qoffsets = av_calloc(mbx * mby, sizeof(*qoffsets)); + qoffsets = av_calloc((size_t)(mbx) * mby, sizeof(*qoffsets)); if (!qoffsets) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libx265.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libx265.c index 7d488c0f4be..3869ca1357b 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libx265.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/libx265.c @@ -662,7 +662,7 @@ static av_cold int libx265_encode_set_roi(libx265Context *ctx, const AVFrame *fr } nb_rois = sd->size / roi_size; - qoffsets = av_calloc(mbx * mby, sizeof(*qoffsets)); + qoffsets = av_calloc((size_t)(mbx) * mby, sizeof(*qoffsets)); if (!qoffsets) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ljpegenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ljpegenc.c index ab37ab0d5cc..a086e6c4ec3 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ljpegenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ljpegenc.c @@ -219,11 +219,11 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if( avctx->pix_fmt == AV_PIX_FMT_BGR0 || avctx->pix_fmt == AV_PIX_FMT_BGR24) - max_pkt_size += width * height * 3 * 4; + max_pkt_size += (unsigned long)(width) * height * 3 * 4; else if(avctx->pix_fmt == AV_PIX_FMT_BGRA) - max_pkt_size += width * height * 4 * 4; + max_pkt_size += (unsigned long)(width) * height * 4 * 4; else { - max_pkt_size += mb_width * mb_height * 3 * 4 + max_pkt_size += (unsigned long)(mb_width) * mb_height * 3 * 4 * s->hsample[0] * s->vsample[0]; } diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/magicyuv.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/magicyuv.c index 04fb6cc147e..c07f3f1832c 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/magicyuv.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/magicyuv.c @@ -152,7 +152,7 @@ static int magy_decode_slice10(AVCodecContext *avctx, void *tdata, int height = AV_CEIL_RSHIFT(FFMIN(s->slice_height, avctx->coded_height - j * s->slice_height), s->vshift[i]); int width = AV_CEIL_RSHIFT(avctx->coded_width, s->hshift[i]); int sheight = AV_CEIL_RSHIFT(s->slice_height, s->vshift[i]); - ptrdiff_t fake_stride = (p->linesize[i] / 2) * (1 + interlaced); + ptrdiff_t fake_stride = (ptrdiff_t)((p->linesize[i] / 2)) * (1 + interlaced); ptrdiff_t stride = p->linesize[i] / 2; const VLC_MULTI_ELEM *const multi = s->multi[i].table; const VLCElem *const vlc = s->vlc[i].table; @@ -167,7 +167,7 @@ static int magy_decode_slice10(AVCodecContext *avctx, void *tdata, flags = get_bits(&gb, 8); pred = get_bits(&gb, 8); - dst = (uint16_t *)p->data[i] + j * sheight * stride; + dst = (uint16_t *)p->data[i] + (long)(j) * sheight * stride; if (flags & 1) { if (get_bits_left(&gb) < bps * width * height) return AVERROR_INVALIDDATA; @@ -184,7 +184,7 @@ static int magy_decode_slice10(AVCodecContext *avctx, void *tdata, switch (pred) { case LEFT: - dst = (uint16_t *)p->data[i] + j * sheight * stride; + dst = (uint16_t *)p->data[i] + (long)(j) * sheight * stride; s->llviddsp.add_left_pred_int16(dst, dst, max, width, 0); dst += stride; if (interlaced) { @@ -197,7 +197,7 @@ static int magy_decode_slice10(AVCodecContext *avctx, void *tdata, } break; case GRADIENT: - dst = (uint16_t *)p->data[i] + j * sheight * stride; + dst = (uint16_t *)p->data[i] + (long)(j) * sheight * stride; s->llviddsp.add_left_pred_int16(dst, dst, max, width, 0); dst += stride; if (interlaced) { @@ -218,7 +218,7 @@ static int magy_decode_slice10(AVCodecContext *avctx, void *tdata, } break; case MEDIAN: - dst = (uint16_t *)p->data[i] + j * sheight * stride; + dst = (uint16_t *)p->data[i] + (long)(j) * sheight * stride; s->llviddsp.add_left_pred_int16(dst, dst, max, width, 0); dst += stride; if (interlaced) { @@ -274,7 +274,7 @@ static int magy_decode_slice(AVCodecContext *avctx, void *tdata, int height = AV_CEIL_RSHIFT(FFMIN(s->slice_height, avctx->coded_height - j * s->slice_height), s->vshift[i]); int width = AV_CEIL_RSHIFT(avctx->coded_width, s->hshift[i]); int sheight = AV_CEIL_RSHIFT(s->slice_height, s->vshift[i]); - ptrdiff_t fake_stride = p->linesize[i] * (1 + interlaced); + ptrdiff_t fake_stride = (ptrdiff_t)(p->linesize[i]) * (1 + interlaced); ptrdiff_t stride = p->linesize[i]; const uint8_t *slice = s->buf + s->slices[i][j].start; const VLC_MULTI_ELEM *const multi = s->multi[i].table; @@ -285,7 +285,7 @@ static int magy_decode_slice(AVCodecContext *avctx, void *tdata, flags = bytestream_get_byte(&slice); pred = bytestream_get_byte(&slice); - dst = p->data[i] + j * sheight * stride; + dst = p->data[i] + (long)(j) * sheight * stride; if (flags & 1) { if (s->slices[i][j].size - 2 < width * height) return AVERROR_INVALIDDATA; @@ -305,7 +305,7 @@ static int magy_decode_slice(AVCodecContext *avctx, void *tdata, switch (pred) { case LEFT: - dst = p->data[i] + j * sheight * stride; + dst = p->data[i] + (long)(j) * sheight * stride; s->llviddsp.add_left_pred(dst, dst, width, 0); dst += stride; if (interlaced) { @@ -318,7 +318,7 @@ static int magy_decode_slice(AVCodecContext *avctx, void *tdata, } break; case GRADIENT: - dst = p->data[i] + j * sheight * stride; + dst = p->data[i] + (long)(j) * sheight * stride; s->llviddsp.add_left_pred(dst, dst, width, 0); dst += stride; if (interlaced) { @@ -342,7 +342,7 @@ static int magy_decode_slice(AVCodecContext *avctx, void *tdata, } break; case MEDIAN: - dst = p->data[i] + j * sheight * stride; + dst = p->data[i] + (long)(j) * sheight * stride; s->llviddsp.add_left_pred(dst, dst, width, 0); dst += stride; if (interlaced) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/magicyuvenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/magicyuvenc.c index 80a54638bc7..1a6de1c332f 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/magicyuvenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/magicyuvenc.c @@ -209,14 +209,14 @@ static av_cold int magy_encode_init(AVCodecContext *avctx) s->slice_height = FFALIGN((avctx->height + s->nb_slices - 1) / s->nb_slices, 1 << s->vshift[1]); s->nb_slices = (avctx->height + s->slice_height - 1) / s->slice_height; s->nb_slices = FFMIN(256U / s->planes, s->nb_slices); - s->slices = av_calloc(s->nb_slices * s->planes, sizeof(*s->slices)); + s->slices = av_calloc((size_t)(s->nb_slices) * s->planes, sizeof(*s->slices)); if (!s->slices) return AVERROR(ENOMEM); if (s->correlate) { size_t max_align = av_cpu_max_align(); size_t aligned_width = FFALIGN(avctx->width, max_align); - s->decorrelate_buf[0] = av_calloc(2U * (s->nb_slices * s->slice_height), + s->decorrelate_buf[0] = av_calloc((size_t)(2U) * ((size_t)(s->nb_slices) * s->slice_height), aligned_width); if (!s->decorrelate_buf[0]) return AVERROR(ENOMEM); @@ -562,9 +562,9 @@ static int magy_encode_frame(AVCodecContext *avctx, AVPacket *pkt, for (size_t k = 0; k < FF_ARRAY_ELEMS(sl->counts); ++k) size += sl->counts[k] * s->he[j][k].len; size = AV_CEIL_RSHIFT(size, 3); - sl->encode_raw = size >= sl->width * sl->height; + sl->encode_raw = size >= (long)(sl->width) * sl->height; if (sl->encode_raw) - size = sl->width * sl->height; + size = (int64_t)(sl->width) * sl->height; sl->size = FFALIGN(size + 2, 4); sl->pos = pkt_size; pkt_size += sl->size; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mfenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mfenc.c index 541f7fb9612..7ced113df00 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mfenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mfenc.c @@ -313,7 +313,7 @@ static int mf_a_avframe_to_sample(AVCodecContext *avctx, const AVFrame *frame, I size_t bps; IMFSample *sample; - bps = av_get_bytes_per_sample(avctx->sample_fmt) * avctx->ch_layout.nb_channels; + bps = (size_t)(av_get_bytes_per_sample(avctx->sample_fmt)) * avctx->ch_layout.nb_channels; len = frame->nb_samples * bps; sample = ff_create_memory_sample(&c->functions, frame->data[0], len, diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpeg12dec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpeg12dec.c index 4c83bcfa90e..9f540f2698b 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpeg12dec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpeg12dec.c @@ -951,8 +951,8 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) // MPEG-2 fps av_reduce(&s->avctx->framerate.num, &s->avctx->framerate.den, - ff_mpeg12_frame_rate_tab[s1->frame_rate_index].num * s1->frame_rate_ext.num, - ff_mpeg12_frame_rate_tab[s1->frame_rate_index].den * s1->frame_rate_ext.den, + (int64_t)(ff_mpeg12_frame_rate_tab[s1->frame_rate_index].num) * s1->frame_rate_ext.num, + (int64_t)(ff_mpeg12_frame_rate_tab[s1->frame_rate_index].den) * s1->frame_rate_ext.den, 1 << 30); switch (s->chroma_format) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpeg4videodec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpeg4videodec.c index 3d20f7c3891..e7c793f8ddd 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpeg4videodec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpeg4videodec.c @@ -567,12 +567,12 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g sprite_offset[1][0] = (((int64_t)-r * sprite_ref[0][0] + virtual_ref[0][0]) * ((int64_t)-2 * vop_ref[0][0] + 1) + ((int64_t) r * sprite_ref[0][1] - virtual_ref[0][1]) * - ((int64_t)-2 * vop_ref[0][1] + 1) + 2 * w2 * r * + ((int64_t)-2 * vop_ref[0][1] + 1) + (long)(2) * w2 * r * (int64_t) sprite_ref[0][0] - 16 * w2 + (1 << (alpha + rho + 1))); sprite_offset[1][1] = (((int64_t)-r * sprite_ref[0][1] + virtual_ref[0][1]) * ((int64_t)-2 * vop_ref[0][0] + 1) + ((int64_t)-r * sprite_ref[0][0] + virtual_ref[0][0]) * - ((int64_t)-2 * vop_ref[0][1] + 1) + 2 * w2 * r * + ((int64_t)-2 * vop_ref[0][1] + 1) + (long)(2) * w2 * r * (int64_t) sprite_ref[0][1] - 16 * w2 + (1 << (alpha + rho + 1))); sprite_delta[0][0] = (-r * sprite_ref[0][0] + virtual_ref[0][0]); sprite_delta[0][1] = (+r * sprite_ref[0][1] - virtual_ref[0][1]); @@ -596,11 +596,11 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g ((int64_t)1 << (alpha + beta + rho - min_ab - 1)); sprite_offset[1][0] = ((int64_t)-r * sprite_ref[0][0] + virtual_ref[0][0]) * h3 * (-2 * vop_ref[0][0] + 1) + ((int64_t)-r * sprite_ref[0][0] + virtual_ref[1][0]) * w3 * (-2 * vop_ref[0][1] + 1) + - (int64_t)2 * w2 * h3 * r * sprite_ref[0][0] - 16 * w2 * h3 + + (int64_t)2 * w2 * h3 * r * sprite_ref[0][0] - (long)(16) * w2 * h3 + ((int64_t)1 << (alpha + beta + rho - min_ab + 1)); sprite_offset[1][1] = ((int64_t)-r * sprite_ref[0][1] + virtual_ref[0][1]) * h3 * (-2 * vop_ref[0][0] + 1) + ((int64_t)-r * sprite_ref[0][1] + virtual_ref[1][1]) * w3 * (-2 * vop_ref[0][1] + 1) + - (int64_t)2 * w2 * h3 * r * sprite_ref[0][1] - 16 * w2 * h3 + + (int64_t)2 * w2 * h3 * r * sprite_ref[0][1] - (long)(16) * w2 * h3 + ((int64_t)1 << (alpha + beta + rho - min_ab + 1)); sprite_delta[0][0] = (-r * (int64_t)sprite_ref[0][0] + virtual_ref[0][0]) * h3; sprite_delta[0][1] = (-r * (int64_t)sprite_ref[0][0] + virtual_ref[1][0]) * w3; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpeg_er.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpeg_er.c index 5bb5ed84413..2b71262c351 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpeg_er.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpeg_er.c @@ -81,10 +81,10 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, s->mb_y * 16 * s->linesize + s->mb_x * 16; s->dest[1] = s->cur_pic.data[1] + - s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize + + (long)(s->mb_y) * (16 >> s->chroma_y_shift) * s->uvlinesize + s->mb_x * (16 >> s->chroma_x_shift); s->dest[2] = s->cur_pic.data[2] + - s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize + + (long)(s->mb_y) * (16 >> s->chroma_y_shift) * s->uvlinesize + s->mb_x * (16 >> s->chroma_x_shift); if (ref) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpegutils.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpegutils.c index 73b6650b70d..b31c4b06bd9 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpegutils.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpegutils.c @@ -170,7 +170,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, /* size is width * height * 2 * 4 where 2 is for directions and 4 is * for the maximum number of MB (4 MB in case of IS_8x8) */ - AVMotionVector *mvs = av_malloc_array(mb_width * mb_height, 2 * 4 * sizeof(AVMotionVector)); + AVMotionVector *mvs = av_malloc_array((size_t)(mb_width) * mb_height, 2 * 4 * sizeof(AVMotionVector)); if (!mvs) return; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpegvideo.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpegvideo.c index 09e5a962395..0a5c3d57794 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpegvideo.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpegvideo.c @@ -299,7 +299,7 @@ av_cold int ff_mpv_init_context_frame(MpegEncContext *s) // When encoding, each slice (and therefore each thread) // gets its own ac_val and dc_val buffers in order to avoid // races. - size_t allslice_yc_size = yc_size * (s->encoding ? nb_slices : 1); + size_t allslice_yc_size = (size_t)(yc_size) * (s->encoding ? nb_slices : 1); if (s->out_format == FMT_H263) { /* ac values */ if (!FF_ALLOCZ_TYPED_ARRAY(s->ac_val_base, allslice_yc_size)) @@ -315,7 +315,7 @@ av_cold int ff_mpv_init_context_frame(MpegEncContext *s) // y_size and therefore yc_size is always odd; allocate one element // more for each encoder slice in order to be able to align each slice's // dc_val to four in order to use aligned stores when cleaning dc_val. - allslice_yc_size += s->encoding * nb_slices; + allslice_yc_size += (unsigned long)(s->encoding) * nb_slices; if (!FF_ALLOC_TYPED_ARRAY(s->dc_val_base, allslice_yc_size)) return AVERROR(ENOMEM); s->dc_val = s->dc_val_base + s->b8_stride + 1; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpegvideo_enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpegvideo_enc.c index 83bc4cee096..633ee2d8b3a 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpegvideo_enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/mpegvideo_enc.c @@ -1937,7 +1937,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, if (s->mb_info) { s->mb_info_ptr = av_packet_new_side_data(pkt, AV_PKT_DATA_H263_MB_INFO, - s->c.mb_width*s->c.mb_height*12); + (size_t)(s->c.mb_width)*s->c.mb_height*12); if (!s->mb_info_ptr) return AVERROR(ENOMEM); s->prev_mb_info = s->last_mb_info = s->mb_info_size = 0; @@ -2304,9 +2304,9 @@ static av_always_inline void encode_mb_internal(MPVEncContext *const s, ptr_y = s->new_pic->data[0] + (mb_y * 16 * wrap_y) + mb_x * 16; ptr_cb = s->new_pic->data[1] + - (mb_y * mb_block_height * wrap_c) + mb_x * mb_block_width; + ((long)(mb_y) * mb_block_height * wrap_c) + mb_x * mb_block_width; ptr_cr = s->new_pic->data[2] + - (mb_y * mb_block_height * wrap_c) + mb_x * mb_block_width; + ((long)(mb_y) * mb_block_height * wrap_c) + mb_x * mb_block_width; if ((mb_x * 16 + 16 > s->c.width || mb_y * 16 + 16 > s->c.height) && s->c.codec_id != AV_CODEC_ID_AMV) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/msvideo1enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/msvideo1enc.c index b1cae720814..36b5353ec8d 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/msvideo1enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/msvideo1enc.c @@ -84,7 +84,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, dst= buf= pkt->data; if(!c->prev) - c->prev = av_malloc(avctx->width * 3 * (avctx->height + 3)); + c->prev = av_malloc((size_t)(avctx->width) * 3 * (avctx->height + 3)); if (!c->prev) return AVERROR(ENOMEM); prevptr = c->prev + avctx->width * 3 * (FFALIGN(avctx->height, 4) - 1); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/opus/enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/opus/enc.c index 587e4ed69d0..720321435c7 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/opus/enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/opus/enc.c @@ -601,7 +601,7 @@ static int opus_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, /* Remove samples from queue and skip if needed */ ff_af_queue_remove(&s->afq, s->packet.frames*frame_size, &avpkt->pts, &avpkt->duration); - discard_padding = s->packet.frames*frame_size - ff_samples_from_time_base(avctx, avpkt->duration); + discard_padding = (long)(s->packet.frames)*frame_size - ff_samples_from_time_base(avctx, avpkt->duration); if (discard_padding > 0) { uint8_t *side = av_packet_new_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, 10); if (!side) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/opus/pvq.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/opus/pvq.c index 3dea7c19f20..19284759fe5 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/opus/pvq.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/opus/pvq.c @@ -304,7 +304,7 @@ static inline uint64_t celt_cwrsi(uint32_t N, uint32_t K, uint32_t i, int *y) i -= p; val = (k0 - K + s) ^ s; - norm += val * val; + norm += (unsigned long)(val) * val; *y++ = val; } else { /*Lots of dimensions case:*/ /*Are there any pulses in this dimension at all?*/ @@ -326,7 +326,7 @@ static inline uint64_t celt_cwrsi(uint32_t N, uint32_t K, uint32_t i, int *y) i -= p; val = (k0 - K + s) ^ s; - norm += val * val; + norm += (unsigned long)(val) * val; *y++ = val; } } @@ -344,13 +344,13 @@ static inline uint64_t celt_cwrsi(uint32_t N, uint32_t K, uint32_t i, int *y) i -= 2 * K - 1; val = (k0 - K + s) ^ s; - norm += val * val; + norm += (unsigned long)(val) * val; *y++ = val; /* N==1 */ s = -i; val = (K + s) ^ s; - norm += val * val; + norm += (unsigned long)(val) * val; *y = val; return norm; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/osq.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/osq.c index 512581e0a43..a67034690dc 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/osq.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/osq.c @@ -121,7 +121,7 @@ static av_cold int osq_init(AVCodecContext *avctx) avctx->bits_per_raw_sample = avctx->extradata[2]; s->nb_samples = AV_RL64(avctx->extradata + 16); s->frame_samples = AV_RL16(avctx->extradata + 8); - s->max_framesize = (s->frame_samples * 16 + 1024) * avctx->ch_layout.nb_channels; + s->max_framesize = (size_t)((s->frame_samples * 16 + 1024)) * avctx->ch_layout.nb_channels; s->bitstream = av_calloc(s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE, sizeof(*s->bitstream)); if (!s->bitstream) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pcm-bluray.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pcm-bluray.c index 194224c67eb..d86c19b5f90 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pcm-bluray.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pcm-bluray.c @@ -111,7 +111,7 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx, return AVERROR_INVALIDDATA; } - avctx->bit_rate = FFALIGN(avctx->ch_layout.nb_channels, 2) * avctx->sample_rate * + avctx->bit_rate = (int64_t)(FFALIGN(avctx->ch_layout.nb_channels, 2)) * avctx->sample_rate * avctx->bits_per_coded_sample; if (avctx->debug & FF_DEBUG_PICT_INFO) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pcm-dvd.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pcm-dvd.c index b3f0624b5b2..c96f530e52e 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pcm-dvd.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pcm-dvd.c @@ -96,7 +96,7 @@ static int pcm_dvd_parse_header(AVCodecContext *avctx, const uint8_t *header) av_channel_layout_uninit(&avctx->ch_layout); av_channel_layout_default(&avctx->ch_layout, channels); /* calculate the bitrate */ - avctx->bit_rate = channels * + avctx->bit_rate = (int64_t)(channels) * avctx->sample_rate * avctx->bits_per_coded_sample; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pcm.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pcm.c index 157adc92d77..aec7bdca21b 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pcm.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pcm.c @@ -121,7 +121,7 @@ av_unused static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, n = frame->nb_samples * avctx->ch_layout.nb_channels; samples = (const short *)frame->data[0]; - if ((ret = ff_get_encode_buffer(avctx, avpkt, n * sample_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, (int64_t)(n) * sample_size, 0)) < 0) return ret; dst = avpkt->data; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pixlet.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pixlet.c index e9c561d70d9..2d4b0fcc95e 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pixlet.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pixlet.c @@ -142,7 +142,7 @@ static int read_low_coeffs(AVCodecContext *avctx, int16_t *dst, int size, escape = ((1 << nbits) - 1) * cnt1; } else { skip_bits(bc, nbits); - escape = value + ((1 << nbits) - 1) * cnt1 - 1; + escape = value + (long)(((1 << nbits) - 1)) * cnt1 - 1; } } else { escape = get_bits(bc, 16); @@ -170,7 +170,7 @@ static int read_low_coeffs(AVCodecContext *avctx, int16_t *dst, int size, value = show_bits(bc, nbits); if (value > 1) { skip_bits(bc, nbits); - rlen = value + escape * cnt1 - 1; + rlen = value + (long)(escape) * cnt1 - 1; } else { skip_bits(bc, nbits - 1); rlen = escape * cnt1; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pnmdec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pnmdec.c index b99b26a3908..c2d510dc8da 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pnmdec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/pnmdec.c @@ -134,7 +134,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p, do_read: ptr = p->data[0]; linesize = p->linesize[0]; - if (n * avctx->height > s->bytestream_end - s->bytestream) + if ((long)(n) * avctx->height > s->bytestream_end - s->bytestream) return AVERROR_INVALIDDATA; if(s->type < 4 || (is_mono && s->type==7)){ for (i=0; iheight; i++) { @@ -307,7 +307,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p, } } } else { - if (avctx->width * avctx->height * 6 > s->bytestream_end - s->bytestream) + if ((long)(avctx->width) * avctx->height * 6 > s->bytestream_end - s->bytestream) return AVERROR_INVALIDDATA; scale = 1.f / s->scale; if (s->endian) { @@ -358,7 +358,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p, break; case AV_PIX_FMT_GRAYF32: if (!s->half) { - if (avctx->width * avctx->height * 4 > s->bytestream_end - s->bytestream) + if ((long)(avctx->width) * avctx->height * 4 > s->bytestream_end - s->bytestream) return AVERROR_INVALIDDATA; scale = 1.f / s->scale; if (s->endian) { @@ -381,7 +381,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p, } } } else { - if (avctx->width * avctx->height * 2 > s->bytestream_end - s->bytestream) + if ((long)(avctx->width) * avctx->height * 2 > s->bytestream_end - s->bytestream) return AVERROR_INVALIDDATA; scale = 1.f / s->scale; if (s->endian) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/proresenc_kostya.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/proresenc_kostya.c index ccb41c0d233..edf8481dd1d 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/proresenc_kostya.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/proresenc_kostya.c @@ -65,7 +65,7 @@ static void get_slice_data(ProresContext *ctx, const uint16_t *src, for (i = 0; i < mbs_per_slice; i++, src += mb_width) { if (x >= w) { - memset(blocks, 0, 64 * (mbs_per_slice - i) * blocks_per_mb + memset(blocks, 0, (unsigned long)(64) * (mbs_per_slice - i) * blocks_per_mb * sizeof(*blocks)); return; } @@ -363,7 +363,7 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, pwidth = avctx->width >> 1; } - linesize = pic->linesize[i] * ctx->pictures_per_frame; + linesize = (ptrdiff_t)(pic->linesize[i]) * ctx->pictures_per_frame; src = (const uint16_t*)(pic->data[i] + yp * linesize + line_add * pic->linesize[i]) + xp; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/psd.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/psd.c index 426ac40b01c..72d0dad4eec 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/psd.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/psd.c @@ -325,7 +325,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, return ret; s->pixel_size = s->channel_depth >> 3;/* in byte */ - s->line_size = s->width * s->pixel_size; + s->line_size = (uint64_t)(s->width) * s->pixel_size; switch (s->color_mode) { case PSD_BITMAP: diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/qoidec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/qoidec.c index bb48fa23cf0..4fa06a85c74 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/qoidec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/qoidec.c @@ -67,7 +67,7 @@ static int qoi_decode_frame(AVCodecContext *avctx, AVFrame *p, return ret; dst = p->data[0]; - len = width * height * channels; + len = (uint64_t)(width) * height * channels; for (int n = 0, off_x = 0; n < len; n += channels, off_x++) { if (off_x >= width) { off_x = 0; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/qsvenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/qsvenc.c index fc1b8795d89..72aee16e634 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/qsvenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/qsvenc.c @@ -2058,7 +2058,7 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame, /* and to make allocation continuous for data[0]/data[1] */ if ((frame->height & (q->height_align - 1) || frame->linesize[0] & (q->width_align - 1)) || ((frame->format == AV_PIX_FMT_NV12 || frame->format == AV_PIX_FMT_P010 || frame->format == AV_PIX_FMT_P012) && - (frame->data[1] - frame->data[0] != frame->linesize[0] * FFALIGN(qf->frame->height, q->height_align)))) { + (frame->data[1] - frame->data[0] != (long)(frame->linesize[0]) * FFALIGN(qf->frame->height, q->height_align)))) { int tmp_w, tmp_h; qf->frame->height = tmp_h = FFALIGN(frame->height, q->height_align); qf->frame->width = tmp_w = FFALIGN(frame->width, q->width_align); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/r210enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/r210enc.c index b1ade5cde64..8e219d63c34 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/r210enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/r210enc.c @@ -50,7 +50,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const uint8_t *srcr_line, *srcg_line, *srcb_line; uint8_t *dst; - ret = ff_get_encode_buffer(avctx, pkt, 4 * aligned_width * avctx->height, 0); + ret = ff_get_encode_buffer(avctx, pkt, (int64_t)(4) * aligned_width * avctx->height, 0); if (ret < 0) return ret; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rasc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rasc.c index 5f956a9b2c7..a4c4d6aec1a 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rasc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rasc.c @@ -296,7 +296,7 @@ static int decode_move(AVCodecContext *avctx, b2 -= s->frame2->linesize[0]; } } else if (type == 0) { - av_fast_padded_malloc(&s->mv_scratch, &s->mv_scratch_size, w * h * s->bpp); + av_fast_padded_malloc(&s->mv_scratch, &s->mv_scratch_size, (size_t)(w) * h * s->bpp); uint8_t *buffer = s->mv_scratch; if (!buffer) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ratecontrol.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ratecontrol.c index d48ede909cb..2d9591cff29 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ratecontrol.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/ratecontrol.c @@ -270,8 +270,8 @@ static double get_qscale(MPVMainEncContext *const m, RateControlEntry *rce, double const_values[] = { M_PI, M_E, - rce->i_tex_bits * rce->qscale, - rce->p_tex_bits * rce->qscale, + (double)(rce->i_tex_bits) * rce->qscale, + (double)(rce->p_tex_bits) * rce->qscale, (rce->i_tex_bits + rce->p_tex_bits) * (double)rce->qscale, rce->mv_bits / mb_num, rce->pict_type == AV_PICTURE_TYPE_B ? (rce->f_code + rce->b_code) * 0.5 : rce->f_code, diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/roqaudioenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/roqaudioenc.c index 8a626c0d29f..becdaf35846 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/roqaudioenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/roqaudioenc.c @@ -136,7 +136,7 @@ static int roq_dpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, if (in && context->input_frames < 8) { memcpy(&context->frame_buffer[context->buffered_samples * channels], - in, avctx->frame_size * channels * sizeof(*in)); + in, (unsigned long)(avctx->frame_size) * channels * sizeof(*in)); context->buffered_samples += avctx->frame_size; if (context->input_frames == 0) context->first_pts = frame->pts; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/roqvideoenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/roqvideoenc.c index 03a1651c7f5..7d9a730ab8c 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/roqvideoenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/roqvideoenc.c @@ -1015,7 +1015,7 @@ static av_cold int roq_encode_init(AVCodecContext *avctx) /* 4x4 codebook needs 6 * 4 * 4 / 4 * width * height / 16 * sizeof(int); * and so does the points buffer. */ enc->closest_cb = - av_malloc_array(roq->width * roq->height, 3 * sizeof(int)); + av_malloc_array((size_t)(roq->width) * roq->height, 3 * sizeof(int)); if (!enc->this_motion4 || !enc->last_motion4 || !enc->this_motion8 || !enc->last_motion8 || !enc->closest_cb) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rscc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rscc.c index 3715e1c6d42..f24729b138c 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rscc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rscc.c @@ -127,7 +127,7 @@ static av_cold int rscc_init(AVCodecContext *avctx) } /* Store the value to check for keyframes */ - ctx->inflated_size = avctx->width * avctx->height * ctx->component_size; + ctx->inflated_size = (uLongf)(avctx->width) * avctx->height * ctx->component_size; /* Allocate maximum size possible, a full frame */ ctx->inflated_buf = av_malloc(ctx->inflated_size); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rv34.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rv34.c index 6942cc2e20b..ea518d61b8c 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rv34.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rv34.c @@ -1389,15 +1389,15 @@ static int rv34_decoder_alloc(RV34DecContext *r) { r->intra_types_stride = r->s.mb_width * 4 + 4; - r->cbp_chroma = av_mallocz(r->s.mb_stride * r->s.mb_height * + r->cbp_chroma = av_mallocz((unsigned long)(r->s.mb_stride) * r->s.mb_height * sizeof(*r->cbp_chroma)); - r->cbp_luma = av_mallocz(r->s.mb_stride * r->s.mb_height * + r->cbp_luma = av_mallocz((unsigned long)(r->s.mb_stride) * r->s.mb_height * sizeof(*r->cbp_luma)); - r->deblock_coefs = av_mallocz(r->s.mb_stride * r->s.mb_height * + r->deblock_coefs = av_mallocz((unsigned long)(r->s.mb_stride) * r->s.mb_height * sizeof(*r->deblock_coefs)); r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist)); - r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * + r->mb_type = av_mallocz((unsigned long)(r->s.mb_stride) * r->s.mb_height * sizeof(*r->mb_type)); if (!(r->cbp_chroma && r->cbp_luma && r->deblock_coefs && diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rv60dec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rv60dec.c index 2a7c5c11470..30043f0ae0d 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rv60dec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/rv60dec.c @@ -304,14 +304,14 @@ static int update_dimensions_clear_info(RV60Context *s, int width, int height) if ((ret = av_reallocp_array(&s->slice, s->cu_height, sizeof(s->slice[0]))) < 0) return ret; - if ((ret = av_reallocp_array(&s->pu_info, s->pu_stride * (s->cu_height << 3), sizeof(s->pu_info[0]))) < 0) + if ((ret = av_reallocp_array(&s->pu_info, (size_t)(s->pu_stride) * (s->cu_height << 3), sizeof(s->pu_info[0]))) < 0) return ret; - if ((ret = av_reallocp_array(&s->blk_info, s->blk_stride * (s->cu_height << 4), sizeof(s->blk_info[0]))) < 0) + if ((ret = av_reallocp_array(&s->blk_info, (size_t)(s->blk_stride) * (s->cu_height << 4), sizeof(s->blk_info[0]))) < 0) return ret; - memset(s->pu_info, 0, s->pu_stride * (s->cu_height << 3) * sizeof(s->pu_info[0])); - memset(s->blk_info, 0, s->blk_stride * (s->cu_height << 4) * sizeof(s->blk_info[0])); + memset(s->pu_info, 0, (unsigned long)(s->pu_stride) * (s->cu_height << 3) * sizeof(s->pu_info[0])); + memset(s->blk_info, 0, (unsigned long)(s->blk_stride) * (s->cu_height << 4) * sizeof(s->blk_info[0])); for (int j = 0; j < s->cu_height << 4; j++) for (int i = 0; i < s->cu_width << 4; i++) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/s302menc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/s302menc.c index ba84ab73b69..bdc31f5ff1c 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/s302menc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/s302menc.c @@ -62,7 +62,7 @@ static av_cold int s302m_encode_init(AVCodecContext *avctx) } avctx->frame_size = 0; - avctx->bit_rate = 48000 * avctx->ch_layout.nb_channels * + avctx->bit_rate = (int64_t)(48000) * avctx->ch_layout.nb_channels * (avctx->bits_per_raw_sample + 4); s->framing_index = 0; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sanm.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sanm.c index c566e3e5c3e..ecb4135365b 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sanm.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sanm.c @@ -439,12 +439,12 @@ static void init_sizes(SANMVideoContext *ctx, int width, int height) { ctx->width = width; ctx->height = height; - ctx->npixels = width * height; + ctx->npixels = (long)(width) * height; ctx->aligned_width = FFALIGN(width, 8); ctx->aligned_height = FFALIGN(height, 8); - ctx->buf_size = ctx->aligned_width * ctx->aligned_height * sizeof(ctx->frm0[0]); + ctx->buf_size = (unsigned long)(ctx->aligned_width) * ctx->aligned_height * sizeof(ctx->frm0[0]); ctx->pitch = width; } diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/screenpresso.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/screenpresso.c index b27154991c9..bf108b00b25 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/screenpresso.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/screenpresso.c @@ -80,7 +80,7 @@ static av_cold int screenpresso_init(AVCodecContext *avctx) return AVERROR(ENOMEM); /* Allocate maximum size possible, a full RGBA frame */ - ctx->inflated_size = avctx->width * avctx->height * 4; + ctx->inflated_size = (uLongf)(avctx->width) * avctx->height * 4; ctx->inflated_buf = av_malloc(ctx->inflated_size); if (!ctx->inflated_buf) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sga.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sga.c index b6902452d38..ac29c9f8210 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sga.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sga.c @@ -334,12 +334,12 @@ static int sga_decode_frame(AVCodecContext *avctx, AVFrame *frame, return ret; av_fast_padded_malloc(&s->tileindex_data, &s->tileindex_size, - avctx->width * avctx->height); + (size_t)(avctx->width) * avctx->height); if (!s->tileindex_data) return AVERROR(ENOMEM); av_fast_padded_malloc(&s->palmapindex_data, &s->palmapindex_size, - s->tiles_w * s->tiles_h); + (size_t)(s->tiles_w) * s->tiles_h); if (!s->palmapindex_data) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sgienc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sgienc.c index 93ec9ff6cf7..49b798cf3f7 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sgienc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sgienc.c @@ -156,7 +156,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, else // assume sgi_rle_encode() produces at most 2x size of input length += tablesize * 2 + depth * height * (2 * width + 1); - if ((ret = ff_alloc_packet(avctx, pkt, bytes_per_channel * length)) < 0) + if ((ret = ff_alloc_packet(avctx, pkt, (int64_t)(bytes_per_channel) * length)) < 0) return ret; bytestream2_init_writer(&pbc, pkt->data, pkt->size); @@ -197,7 +197,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, bytestream2_skip_p(&pbc, tablesize); /* Make an intermediate consecutive buffer. */ - if (!(encode_buf = av_malloc(width * bytes_per_channel))) + if (!(encode_buf = av_malloc((size_t)(width) * bytes_per_channel))) return AVERROR(ENOMEM); for (z = 0; z < depth; z++) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/snow.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/snow.c index b2850356efc..ae91acf782e 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/snow.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/snow.c @@ -169,7 +169,7 @@ int ff_snow_alloc_blocks(SnowContext *s){ s->b_height= h; av_free(s->block); - s->block = av_calloc(w * h, sizeof(*s->block) << (s->block_max_depth*2)); + s->block = av_calloc((size_t)(w) * h, sizeof(*s->block) << (s->block_max_depth*2)); if (!s->block) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/snowdec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/snowdec.c index aaf01295a5d..43b55842378 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/snowdec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/snowdec.c @@ -661,7 +661,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, if (s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS) { size_t size; - res = av_size_mult(s->b_width * s->b_height, sizeof(AVMotionVector) << (s->block_max_depth*2), &size); + res = av_size_mult((size_t)(s->b_width) * s->b_height, sizeof(AVMotionVector) << (s->block_max_depth*2), &size); if (res) return res; av_fast_malloc(&s->avmv, &s->avmv_size, size); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/snowenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/snowenc.c index e92f0825791..84fc8d4dfe1 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/snowenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/snowenc.c @@ -692,7 +692,7 @@ static int get_dc(SnowEncContext *enc, int mb_x, int mb_y, int plane_index) b->type|= BLOCK_INTRA; b->color[plane_index]= 0; - memset(dst, 0, obmc_stride*obmc_stride*sizeof(IDWTELEM)); + memset(dst, 0, (unsigned long)(obmc_stride)*obmc_stride*sizeof(IDWTELEM)); for(i=0; i<4; i++){ int mb_x2= mb_x + (i &1) - 1; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sunrast.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sunrast.c index cc27838f5bc..f55552c97e7 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sunrast.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/sunrast.c @@ -150,7 +150,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, AVFrame *p, ptr = ptr2 = av_malloc_array((w + 15), h); if (!ptr) return AVERROR(ENOMEM); - stride = (w + 15 >> 3) * depth; + stride = (ptrdiff_t)((w + 15 >> 3)) * depth; } else { ptr = p->data[0]; stride = p->linesize[0]; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/svq1enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/svq1enc.c index 4855bed188c..06a8902573f 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/svq1enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/svq1enc.c @@ -516,7 +516,7 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx) if (avctx->frame_num) av_log(avctx, AV_LOG_DEBUG, "RD: %f\n", - s->rd_total / (double)(avctx->width * avctx->height * + s->rd_total / (double)((long)(avctx->width) * avctx->height * avctx->frame_num)); av_freep(&s->m.me.scratchpad); @@ -607,9 +607,9 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx) s->m.me.temp = s->m.me.scratchpad = av_mallocz((avctx->width + 64) * 2 * 16 * 2 * sizeof(uint8_t)); - s->mb_type = av_mallocz((s->y_block_width + 1) * + s->mb_type = av_mallocz((unsigned long)((s->y_block_width + 1)) * s->y_block_height * sizeof(int16_t)); - s->dummy = av_mallocz((s->y_block_width + 1) * + s->dummy = av_mallocz((unsigned long)((s->y_block_width + 1)) * s->y_block_height * sizeof(int32_t)); s->m.new_pic = av_frame_alloc(); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/svq3.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/svq3.c index 296e81f3225..54247302dcb 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/svq3.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/svq3.c @@ -1336,7 +1336,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) if (!s->intra4x4_pred_mode) return AVERROR(ENOMEM); - s->mb2br_xy = av_mallocz(s->mb_stride * (s->mb_height + 1) * + s->mb2br_xy = av_mallocz((unsigned long)(s->mb_stride) * (s->mb_height + 1) * sizeof(*s->mb2br_xy)); if (!s->mb2br_xy) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/targa.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/targa.c index 7e016ea4afc..18225ec263b 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/targa.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/targa.c @@ -179,7 +179,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, } if (!(compr & TGA_RLE)) { - img_size = w * ((bpp + 1) >> 3); + img_size = (size_t)(w) * ((bpp + 1) >> 3); if (bytestream2_get_bytes_left(&s->gb) < img_size * h) { av_log(avctx, AV_LOG_ERROR, "Not enough data available for image\n"); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/tdsc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/tdsc.c index 8baf8e9d93e..b9c2302c990 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/tdsc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/tdsc.c @@ -107,7 +107,7 @@ static av_cold int tdsc_init(AVCodecContext *avctx) } /* This value should be large enough for a RAW-only frame plus headers */ - ctx->deflatelen = avctx->width * avctx->height * (3 + 1); + ctx->deflatelen = (uLongf)(avctx->width) * avctx->height * (3 + 1); ret = av_reallocp(&ctx->deflatebuffer, ctx->deflatelen); if (ret < 0) return ret; @@ -222,7 +222,7 @@ static int tdsc_load_cursor(AVCodecContext *avctx) ctx->cursor_hot_y = FFMIN(ctx->cursor_hot_y, ctx->cursor_h - 1); } - ret = av_reallocp(&ctx->cursor, ctx->cursor_stride * ctx->cursor_h); + ret = av_reallocp(&ctx->cursor, (size_t)(ctx->cursor_stride) * ctx->cursor_h); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate cursor buffer.\n"); return ret; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/texturedsp.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/texturedsp.c index 721bfc17f5a..07d7bf91d74 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/texturedsp.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/texturedsp.c @@ -434,7 +434,7 @@ static inline void rgtc_block_internal(uint8_t *dst, ptrdiff_t stride, int c = color_tab[i]; if (mono){ - dst [x * pix_size + y * stride + offset] = (uint8_t)c; + dst [(long)(x) * pix_size + y * stride + offset] = (uint8_t)c; } else{ uint32_t pixel = RGBA(c, c, c, 255U); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/tiff.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/tiff.c index bb8120bc1b8..f83b6fe65e0 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/tiff.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/tiff.c @@ -2089,7 +2089,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, for (i = 0; i < 3; i++) { cam2xyz[c][i] = 0.; for (j = 0; j < 3; j++) - cam2xyz[c][i] += s->camera_calibration[c][j] * s->color_matrix[j][i] * s->as_shot_white[i]; + cam2xyz[c][i] += (double)(s->camera_calibration[c][j]) * s->color_matrix[j][i] * s->as_shot_white[i]; } } @@ -2201,7 +2201,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, s->avctx->pix_fmt == AV_PIX_FMT_RGBA) { stride = stride * 5 / 4; five_planes = - dst = av_malloc(stride * s->height); + dst = av_malloc((size_t)(stride) * s->height); if (!dst) return AVERROR(ENOMEM); } diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/truemotion2.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/truemotion2.c index 7ae9a67ec41..16fa7f169a1 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/truemotion2.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/truemotion2.c @@ -971,7 +971,7 @@ static av_cold int decode_init(AVCodecContext *avctx) w += 8; h += 8; - l->Y_base = av_calloc(w * h, 2 * sizeof(*l->Y_base)); + l->Y_base = av_calloc((size_t)(w) * h, 2 * sizeof(*l->Y_base)); if (!l->Y_base) return AVERROR(ENOMEM); l->y_stride = w; @@ -979,7 +979,7 @@ static av_cold int decode_init(AVCodecContext *avctx) l->Y2 = l->Y1 + w * h; w = (w + 1) >> 1; h = (h + 1) >> 1; - l->UV_base = av_calloc(w * h, 4 * sizeof(*l->UV_base)); + l->UV_base = av_calloc((size_t)(w) * h, 4 * sizeof(*l->UV_base)); if (!l->UV_base) return AVERROR(ENOMEM); l->uv_stride = w; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/tscc2.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/tscc2.c index cfe5a6e7524..3da1bb5f005 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/tscc2.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/tscc2.c @@ -342,7 +342,7 @@ static av_cold int tscc2_decode_init(AVCodecContext *avctx) c->mb_width = FFALIGN(avctx->width, 16) >> 4; c->mb_height = FFALIGN(avctx->height, 8) >> 3; - c->slice_quants = av_malloc(c->mb_width * c->mb_height); + c->slice_quants = av_malloc((size_t)(c->mb_width) * c->mb_height); if (!c->slice_quants) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate slice information\n"); return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/twinvq.h b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/twinvq.h index 84f4e514384..9489499eb72 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/twinvq.h +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/twinvq.h @@ -200,7 +200,7 @@ static inline void twinvq_memset_float(float *buf, float val, int size) static inline float twinvq_mulawinv(float y, float clip, float mu) { y = av_clipf(y / clip, -1, 1); - return clip * FFSIGN(y) * (exp(log(1 + mu) * fabs(y)) - 1) / mu; + return (double)(clip) * FFSIGN(y) * (exp(log(1 + mu) * fabs(y)) - 1) / mu; } int ff_twinvq_decode_frame(AVCodecContext *avctx, AVFrame *frame, diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/utils.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/utils.c index 615d60cd58a..57b905e497f 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/utils.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/utils.c @@ -735,7 +735,7 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, case AV_CODEC_ID_ADPCM_IMA_XBOX: if (bps != 4) return 0; - tmp = blocks * ((ba - 4 * ch) / (bps * ch) * 8); + tmp = (int64_t)(blocks) * ((int64_t)((ba - 4 * ch) / (bps * ch)) * 8); break; case AV_CODEC_ID_ADPCM_IMA_WAV: if (bps < 2 || bps > 5) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v210enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v210enc.c index 2194e2128c1..47e60f0595f 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v210enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v210enc.c @@ -75,7 +75,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, int ret; uint8_t *dst; - ret = ff_get_encode_buffer(avctx, pkt, avctx->height * stride, 0); + ret = ff_get_encode_buffer(avctx, pkt, (int64_t)(avctx->height) * stride, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); return ret; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v308enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v308enc.c index 884932da44e..67f82e6fc8f 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v308enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v308enc.c @@ -48,7 +48,7 @@ static int v308_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const uint8_t *y, *u, *v; int i, j, ret; - ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 3, 0); + ret = ff_get_encode_buffer(avctx, pkt, (int64_t)(avctx->width) * avctx->height * 3, 0); if (ret < 0) return ret; dst = pkt->data; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v408enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v408enc.c index 4b6717a1fb2..accb11859ae 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v408enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v408enc.c @@ -42,7 +42,7 @@ static int v408_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const uint8_t *y, *u, *v, *a; int i, j, ret; - ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 4, 0); + ret = ff_get_encode_buffer(avctx, pkt, (int64_t)(avctx->width) * avctx->height * 4, 0); if (ret < 0) return ret; dst = pkt->data; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v410enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v410enc.c index 1350acebba7..0a3c2103852 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v410enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/v410enc.c @@ -50,7 +50,7 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint32_t val; int i, j, ret; - ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 4, 0); + ret = ff_get_encode_buffer(avctx, pkt, (int64_t)(avctx->width) * avctx->height * 4, 0); if (ret < 0) return ret; dst = pkt->data; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vb.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vb.c index 42d6f26f6c6..3ad8cac83ae 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vb.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vb.c @@ -256,8 +256,8 @@ static av_cold int decode_init(AVCodecContext *avctx) c->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_PAL8; - c->frame = av_mallocz(avctx->width * avctx->height); - c->prev_frame = av_mallocz(avctx->width * avctx->height); + c->frame = av_mallocz((size_t)(avctx->width) * avctx->height); + c->prev_frame = av_mallocz((size_t)(avctx->width) * avctx->height); if (!c->frame || !c->prev_frame) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc1.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc1.c index e365aaec84d..893c9564dbb 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc1.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc1.c @@ -445,8 +445,8 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb) } else av_reduce(&v->s.avctx->sample_aspect_ratio.num, &v->s.avctx->sample_aspect_ratio.den, - v->s.avctx->height * w, - v->s.avctx->width * h, + (int64_t)(v->s.avctx->height) * w, + (int64_t)(v->s.avctx->width) * h, 1 << 30); } ff_set_sar(v->s.avctx, v->s.avctx->sample_aspect_ratio); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc1dec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc1dec.c index 12b1e094157..eac9228dea5 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc1dec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc1dec.c @@ -363,12 +363,12 @@ static av_cold int vc1_decode_init_alloc_tables(VC1Context *v) int mb_height = FFALIGN(s->mb_height, 2); /* Allocate mb bitplanes */ - v->mv_type_mb_plane = av_malloc (s->mb_stride * mb_height); - v->direct_mb_plane = av_malloc (s->mb_stride * mb_height); - v->forward_mb_plane = av_malloc (s->mb_stride * mb_height); - v->fieldtx_plane = av_mallocz(s->mb_stride * mb_height); - v->acpred_plane = av_malloc (s->mb_stride * mb_height); - v->over_flags_plane = av_malloc (s->mb_stride * mb_height); + v->mv_type_mb_plane = av_malloc ((size_t)(s->mb_stride) * mb_height); + v->direct_mb_plane = av_malloc ((size_t)(s->mb_stride) * mb_height); + v->forward_mb_plane = av_malloc ((size_t)(s->mb_stride) * mb_height); + v->fieldtx_plane = av_mallocz((size_t)(s->mb_stride) * mb_height); + v->acpred_plane = av_malloc ((size_t)(s->mb_stride) * mb_height); + v->over_flags_plane = av_malloc ((size_t)(s->mb_stride) * mb_height); if (!v->mv_type_mb_plane || !v->direct_mb_plane || !v->forward_mb_plane || !v->fieldtx_plane || !v->acpred_plane || !v->over_flags_plane) return AVERROR(ENOMEM); @@ -399,7 +399,7 @@ static av_cold int vc1_decode_init_alloc_tables(VC1Context *v) v->mb_type = v->mb_type_base + s->b8_stride + 1; /* allocate memory to store block level MV info */ - v->blk_mv_type_base = av_mallocz( s->b8_stride * (mb_height * 2 + 1)); + v->blk_mv_type_base = av_mallocz( (size_t)(s->b8_stride) * (mb_height * 2 + 1)); if (!v->blk_mv_type_base) return AVERROR(ENOMEM); v->blk_mv_type = v->blk_mv_type_base + s->b8_stride + 1; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc2enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc2enc.c index 2c155c01a16..6a7efb48004 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc2enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc2enc.c @@ -977,7 +977,7 @@ static av_cold int vc2_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, /* Rate control */ s->frame_max_bytes = (av_rescale(r_bitrate, s->avctx->time_base.num, s->avctx->time_base.den) >> 3) - header_size; - s->slice_max_bytes = slice_ceil = av_rescale(s->frame_max_bytes, 1, s->num_x*s->num_y); + s->slice_max_bytes = slice_ceil = av_rescale(s->frame_max_bytes, 1, (int64_t)(s->num_x)*s->num_y); /* Find an appropriate size scaler */ while (sig_size > 255) { @@ -1155,7 +1155,7 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx) b->width = w; b->height = h; b->stride = p->coef_stride; - shift = (o > 1)*b->height*b->stride + (o & 1)*b->width; + shift = (long)((o > 1))*b->height*b->stride + (long)((o & 1))*b->width; b->buf = p->coef_buf + shift; } } @@ -1172,7 +1172,7 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx) s->num_x = s->plane[0].dwt_width/s->slice_width; s->num_y = s->plane[0].dwt_height/s->slice_height; - s->slice_args = av_calloc(s->num_x*s->num_y, sizeof(SliceArgs)); + s->slice_args = av_calloc((size_t)(s->num_x)*s->num_y, sizeof(SliceArgs)); if (!s->slice_args) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc2enc_dwt.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc2enc_dwt.c index 5fb2642c92f..595ff3d9ed1 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc2enc_dwt.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vc2enc_dwt.c @@ -263,7 +263,7 @@ av_cold int ff_vc2enc_init_transforms(VC2TransformContext *s, int p_stride, s->vc2_subband_dwt[VC2_TRANSFORM_HAAR_S] = vc2_subband_dwt_haar_shift; /* Pad by the slice size, only matters for non-Haar wavelets */ - s->buffer = av_calloc((p_stride + slice_w)*(p_height + slice_h), sizeof(dwtcoef)); + s->buffer = av_calloc((size_t)((p_stride + slice_w))*(p_height + slice_h), sizeof(dwtcoef)); if (!s->buffer) return 1; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/videotoolboxenc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/videotoolboxenc.c index cb3571c7234..29200f8dd08 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/videotoolboxenc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/videotoolboxenc.c @@ -2259,7 +2259,7 @@ static int vtenc_cm_to_avpacket( out_buf_size = header_size + in_buf_size + sei_nalu_size + - nalu_count * ((int)sizeof(start_code) - (int)length_code_size); + (unsigned long)(nalu_count) * ((int)sizeof(start_code) - (int)length_code_size); status = ff_get_encode_buffer(avctx, pkt, out_buf_size, 0); if (status < 0) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vp56.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vp56.c index 0d13d7a276c..6b445659d60 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vp56.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vp56.c @@ -573,7 +573,7 @@ static int vp56_size_changed(VP56Context *s) s->have_undamaged_frame = 0; for (i=0; i<4; i++) - s->stride[i] = s->flip * s->frames[VP56_FRAME_CURRENT]->linesize[i]; + s->stride[i] = (ptrdiff_t)(s->flip) * s->frames[VP56_FRAME_CURRENT]->linesize[i]; s->mb_width = (avctx->coded_width +15) / 16; s->mb_height = (avctx->coded_height+15) / 16; @@ -586,7 +586,7 @@ static int vp56_size_changed(VP56Context *s) av_reallocp_array(&s->above_blocks, 4*s->mb_width+6, sizeof(*s->above_blocks)); - av_reallocp_array(&s->macroblocks, s->mb_width*s->mb_height, + av_reallocp_array(&s->macroblocks, (size_t)(s->mb_width)*s->mb_height, sizeof(*s->macroblocks)); av_free(s->edge_emu_buffer_alloc); s->edge_emu_buffer_alloc = av_malloc(16*stride*2); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vp8.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vp8.c index 9010e19e6b7..d430af53ffc 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vp8.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vp8.c @@ -107,7 +107,7 @@ static int vp8_alloc_frame(VP8Context *s, VP8Frame *f, int ref) ref ? AV_GET_BUFFER_FLAG_REF : 0); if (ret < 0) return ret; - f->seg_map = av_refstruct_allocz(s->mb_width * s->mb_height); + f->seg_map = av_refstruct_allocz((size_t)(s->mb_width) * s->mb_height); if (!f->seg_map) { ret = AVERROR(ENOMEM); goto fail; @@ -227,7 +227,7 @@ int update_dimensions(VP8Context *s, int width, int height, int is_vp7) sizeof(*s->macroblocks)); s->intra4x4_pred_mode_top = av_mallocz(s->mb_width * 4); } else // Sliced threading - s->macroblocks_base = av_mallocz((s->mb_width + 2) * (s->mb_height + 2) * + s->macroblocks_base = av_mallocz((unsigned long)((s->mb_width + 2)) * (s->mb_height + 2) * sizeof(*s->macroblocks)); s->top_nnz = av_mallocz(s->mb_width * sizeof(*s->top_nnz)); s->top_border = av_mallocz((s->mb_width + 1) * sizeof(*s->top_border)); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vp9.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vp9.c index c175169ce49..da48bcd5026 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vp9.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vp9.c @@ -279,7 +279,7 @@ static int update_size(AVCodecContext *avctx, int w, int h) s->rows = (h + 7) >> 3; lflvl_len = avctx->active_thread_type == FF_THREAD_SLICE ? s->sb_rows : 1; -#define assign(var, type, n) var = (type) p; p += s->sb_cols * (n) * sizeof(*var) +#define assign(var, type, n) var = (type) p; p += (size_t)s->sb_cols * (n) * sizeof(*var) av_freep(&s->intra_pred_data[0]); // FIXME we slightly over-allocate here for subsampled chroma, but a little // bit of padding shouldn't affect performance... @@ -337,7 +337,7 @@ static int update_block_buffers(AVCodecContext *avctx) if (s->s.frames[CUR_FRAME].uses_2pass) { int sbs = s->sb_cols * s->sb_rows; - td->b_base = av_malloc_array(s->cols * s->rows, sizeof(VP9Block)); + td->b_base = av_malloc_array((size_t)(s->cols) * s->rows, sizeof(VP9Block)); td->block_base = av_mallocz(((64 * 64 + 2 * chroma_blocks) * bytesperpixel * sizeof(int16_t) + 16 * 16 + 2 * chroma_eobs) * sbs); if (!td->b_base || !td->block_base) @@ -349,7 +349,7 @@ static int update_block_buffers(AVCodecContext *avctx) td->uveob_base[1] = td->uveob_base[0] + chroma_eobs * sbs; if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) { - td->block_structure = av_malloc_array(s->cols * s->rows, sizeof(*td->block_structure)); + td->block_structure = av_malloc_array((size_t)(s->cols) * s->rows, sizeof(*td->block_structure)); if (!td->block_structure) return AVERROR(ENOMEM); } @@ -370,7 +370,7 @@ static int update_block_buffers(AVCodecContext *avctx) s->td[i].uveob_base[1] = s->td[i].uveob_base[0] + chroma_eobs; if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) { - s->td[i].block_structure = av_malloc_array(s->cols * s->rows, sizeof(*td->block_structure)); + s->td[i].block_structure = av_malloc_array((size_t)(s->cols) * s->rows, sizeof(*td->block_structure)); if (!s->td[i].block_structure) return AVERROR(ENOMEM); } diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vulkan_ffv1.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vulkan_ffv1.c index 1ea927ccd34..4f08e327c8f 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vulkan_ffv1.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vulkan_ffv1.c @@ -134,7 +134,7 @@ static int vk_ffv1_start_frame(AVCodecContext *avctx, err = ff_vk_get_pooled_buffer(&ctx->s, &fv->slice_state_pool, &fp->slice_state, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, - NULL, f->slice_count*fp->slice_state_size, + NULL, (size_t)(f->slice_count)*fp->slice_state_size, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); if (err < 0) return err; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vulkan_prores.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vulkan_prores.c index 69a9a080b9a..a4af76a6292 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vulkan_prores.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vulkan_prores.c @@ -86,7 +86,7 @@ static int vk_prores_start_frame(AVCodecContext *avctx, pp->slice_offsets_sz = (pr->slice_count + 1) * sizeof(uint32_t); pp->qmat_sz = sizeof(pr->qmat_luma) + sizeof(pr->qmat_chroma); - pp->mb_params_sz = pr->mb_width * pr->mb_height * sizeof(uint8_t); + pp->mb_params_sz = (unsigned long)(pr->mb_width) * pr->mb_height * sizeof(uint8_t); pp->slice_offsets_off = 0; pp->qmat_off = FFALIGN(pp->slice_offsets_off + pp->slice_offsets_sz, diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/cabac.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/cabac.c index c2dbd467090..7be0fd4a92e 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/cabac.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/cabac.c @@ -2480,11 +2480,11 @@ static int hls_residual_coding(VVCLocalContext *lc, TransformBlock *tb) if ((rc.last_sub_block > 0 || rc.last_scan_pos > 0 ) && !c_idx) lc->parse.mts_dc_only = 0; - memset(tb->coeffs, 0, tb->tb_width * tb->tb_height * sizeof(*tb->coeffs)); - memset(rc.abs_level, 0, tb->tb_width * tb->tb_height * sizeof(rc.abs_level[0])); + memset(tb->coeffs, 0, (unsigned long)(tb->tb_width) * tb->tb_height * sizeof(*tb->coeffs)); + memset(rc.abs_level, 0, (unsigned long)(tb->tb_width) * tb->tb_height * sizeof(rc.abs_level[0])); memset(rc.sb_coded_flag, 0, rc.nb_sbs); - memset(rc.abs_level_pass1, 0, tb->tb_width * tb->tb_height * sizeof(rc.abs_level_pass1[0])); - memset(rc.sig_coeff_flag, 0, tb->tb_width * tb->tb_height * sizeof(rc.sig_coeff_flag[0])); + memset(rc.abs_level_pass1, 0, (unsigned long)(tb->tb_width) * tb->tb_height * sizeof(rc.abs_level_pass1[0])); + memset(rc.sig_coeff_flag, 0, (unsigned long)(tb->tb_width) * tb->tb_height * sizeof(rc.sig_coeff_flag[0])); for (int i = rc.last_sub_block; i >= 0; i--) { int ret = residual_coding_subblock(lc, &rc, i); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/ctu.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/ctu.c index e50ac592bdc..8180f2ab853 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/ctu.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/ctu.c @@ -394,7 +394,7 @@ static int hls_transform_unit(VVCLocalContext *lc, int x0, int y0,int tu_width, return ret; set_tb_tab(fc->tab.tu_coded_flag[tb->c_idx], tu->coded_flag[tb->c_idx], fc, tb); } else if (cu->act_enabled_flag) { - memset(tb->coeffs, 0, tb->tb_width * tb->tb_height * sizeof(*tb->coeffs)); + memset(tb->coeffs, 0, (unsigned long)(tb->tb_width) * tb->tb_height * sizeof(*tb->coeffs)); } if (tb->c_idx != CR) set_tb_size(fc, tb); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/filter_template.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/filter_template.c index 6dd73100897..c6d5f2c089c 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/filter_template.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/filter_template.c @@ -684,7 +684,7 @@ static void FUNC(vvc_loop_filter_chroma)(uint8_t *_pix, const ptrdiff_t _xstrid const int tc = _tc[i] << (BIT_DEPTH - 10); #endif if (tc) { - pixel *pix = (pixel *)_pix + i * size * ystride; + pixel *pix = (pixel *)_pix + (long)(i) * size * ystride; const uint8_t no_p = _no_p[i]; const uint8_t no_q = _no_q[i]; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/inter.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/inter.c index 7d6e79e49bc..e4c5c779990 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/inter.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/vvc/inter.c @@ -96,7 +96,7 @@ static void emulated_half(const VVCLocalContext *lc, uint8_t *dst, const ptrdiff const VVCFrameContext *fc = lc->fc; int pic_width, pic_height; - src += y_off * src_stride + x_off * (1 << ps); + src += y_off * src_stride + (long)(x_off) * (1 << ps); clip_to_subpic(&x_off, &y_off, &pic_width, &pic_height, subpic, half_sb, dmvr_clip); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/xsubdec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/xsubdec.c index 6be4c18b0b5..b72d78e9821 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/xsubdec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/xsubdec.c @@ -117,7 +117,7 @@ static int decode_frame(AVCodecContext *avctx, AVSubtitle *sub, rect->w = w; rect->h = h; rect->type = SUBTITLE_BITMAP; rect->linesize[0] = w; - rect->data[0] = av_malloc(w * h); + rect->data[0] = av_malloc((size_t)(w) * h); rect->nb_colors = 4; rect->data[1] = av_mallocz(AVPALETTE_SIZE); if (!rect->data[0] || !rect->data[1]) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/yuv4enc.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/yuv4enc.c index 093038142f3..96c12a28964 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/yuv4enc.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/yuv4enc.c @@ -31,7 +31,7 @@ static int yuv4_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const uint8_t *y, *u, *v; int ret; - ret = ff_get_encode_buffer(avctx, pkt, 6 * ((avctx->width + 1) / 2) + ret = ff_get_encode_buffer(avctx, pkt, (int64_t)(6) * ((avctx->width + 1) / 2) * ((avctx->height + 1) / 2), 0); if (ret < 0) return ret; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/zmbv.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/zmbv.c index fe12f3f84aa..0d277fa0713 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/zmbv.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavcodec/zmbv.c @@ -138,7 +138,7 @@ static int zmbv_decode_xor_8(ZmbvContext *c) } if (d) { /* apply XOR'ed difference */ - if (c->decomp_len - (src - c->decomp_buf) < bw2 * bh2) + if (c->decomp_len - (src - c->decomp_buf) < (long)(bw2) * bh2) return AVERROR_INVALIDDATA; out = output + x; for (j = 0; j < bh2; j++) { @@ -214,7 +214,7 @@ static int zmbv_decode_xor_16(ZmbvContext *c) } if (d) { /* apply XOR'ed difference */ - if (c->decomp_len - (src - c->decomp_buf) < bw2 * bh2 * 2) + if (c->decomp_len - (src - c->decomp_buf) < (long)(bw2) * bh2 * 2) return AVERROR_INVALIDDATA; out = output + x; for (j = 0; j < bh2; j++){ @@ -380,7 +380,7 @@ static int zmbv_decode_xor_32(ZmbvContext *c) } if (d) { /* apply XOR'ed difference */ - if (c->decomp_len - (src - c->decomp_buf) < bw2 * bh2 * 4) + if (c->decomp_len - (src - c->decomp_buf) < (long)(bw2) * bh2 * 4) return AVERROR_INVALIDDATA; out = output + x; for (j = 0; j < bh2; j++){ @@ -509,8 +509,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, } if (c->alloc_bpp < c->bpp) { - c->cur = av_realloc_f(c->cur, avctx->width * avctx->height, (c->bpp / 8)); - c->prev = av_realloc_f(c->prev, avctx->width * avctx->height, (c->bpp / 8)); + c->cur = av_realloc_f(c->cur, (size_t)(avctx->width) * avctx->height, (c->bpp / 8)); + c->prev = av_realloc_f(c->prev, (size_t)(avctx->width) * avctx->height, (c->bpp / 8)); c->alloc_bpp = c->bpp; } c->bx = (c->width + c->bw - 1) / c->bw; diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavformat/demux.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavformat/demux.c index 555399720cb..b5ef0f8f2a6 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavformat/demux.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavformat/demux.c @@ -1333,7 +1333,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, static int64_t ts_to_samples(AVStream *st, int64_t ts) { - return av_rescale(ts, st->time_base.num * st->codecpar->sample_rate, st->time_base.den); + return av_rescale(ts, (int64_t)(st->time_base.num) * st->codecpar->sample_rate, st->time_base.den); } static int codec_close(FFStream *sti) diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavformat/lafdec.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavformat/lafdec.c index e641d4b6ee4..12ab02a2475 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavformat/lafdec.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavformat/lafdec.c @@ -146,7 +146,7 @@ static int laf_read_header(AVFormatContext *ctx) (int64_t)bpp * st_count * (int64_t)sample_rate == 0 ) return AVERROR_INVALIDDATA; - s->data = av_calloc(st_count * sample_rate, bpp); + s->data = av_calloc((size_t)(st_count) * sample_rate, bpp); if (!s->data) return AVERROR(ENOMEM); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavutil/pca.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavutil/pca.c index 7c3eb42b146..0e1c0ce2b4a 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavutil/pca.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavutil/pca.c @@ -48,7 +48,7 @@ PCA *ff_pca_init(int n){ pca->n= n; pca->z = av_malloc_array(n, sizeof(*pca->z)); pca->count=0; - pca->covariance= av_calloc(n*n, sizeof(double)); + pca->covariance= av_calloc((size_t)(n)*n, sizeof(double)); pca->mean= av_calloc(n, sizeof(double)); if (!pca->z || !pca->covariance || !pca->mean) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavutil/vulkan.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavutil/vulkan.c index ff24b956cd2..09c87b3b787 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavutil/vulkan.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libavutil/vulkan.c @@ -458,7 +458,7 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, AVVulkanDeviceQueueFamily *qf, pool->query_results = 0; } - pool->qd_size = (pool->query_results + pool->query_statuses)*(query_64bit ? 8 : 4); + pool->qd_size = (size_t)((pool->query_results + pool->query_statuses))*(query_64bit ? 8 : 4); /* Allocate space for the query data */ pool->query_data = av_calloc(nb_contexts, pool->qd_size); diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libswresample/rematrix.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libswresample/rematrix.c index a4911a29221..4cf48724c1c 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libswresample/rematrix.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libswresample/rematrix.c @@ -468,7 +468,7 @@ av_cold int swri_rematrix_init(SwrContext *s){ } if (s->midbuf.fmt == AV_SAMPLE_FMT_S16P){ int maxsum = 0; - s->native_matrix = av_calloc(nb_in * nb_out, sizeof(int)); + s->native_matrix = av_calloc((size_t)(nb_in) * nb_out, sizeof(int)); if (!s->native_matrix) return AVERROR(ENOMEM); for (i = 0; i < nb_out; i++) { @@ -494,7 +494,7 @@ av_cold int swri_rematrix_init(SwrContext *s){ s->mix_any_f = get_mix_any_func_clip_s16(s); } }else if(s->midbuf.fmt == AV_SAMPLE_FMT_FLTP){ - s->native_matrix = av_calloc(nb_in * nb_out, sizeof(float)); + s->native_matrix = av_calloc((size_t)(nb_in) * nb_out, sizeof(float)); if (!s->native_matrix) return AVERROR(ENOMEM); for (i = 0; i < nb_out; i++) @@ -505,7 +505,7 @@ av_cold int swri_rematrix_init(SwrContext *s){ s->mix_2_1_f = sum2_float; s->mix_any_f = get_mix_any_func_float(s); }else if(s->midbuf.fmt == AV_SAMPLE_FMT_DBLP){ - s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double)); + s->native_matrix = av_calloc((size_t)(nb_in) * nb_out, sizeof(double)); if (!s->native_matrix) return AVERROR(ENOMEM); for (i = 0; i < nb_out; i++) @@ -516,7 +516,7 @@ av_cold int swri_rematrix_init(SwrContext *s){ s->mix_2_1_f = sum2_double; s->mix_any_f = get_mix_any_func_double(s); }else if(s->midbuf.fmt == AV_SAMPLE_FMT_S32P){ - s->native_matrix = av_calloc(nb_in * nb_out, sizeof(int)); + s->native_matrix = av_calloc((size_t)(nb_in) * nb_out, sizeof(int)); if (!s->native_matrix) return AVERROR(ENOMEM); for (i = 0; i < nb_out; i++) { diff --git a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libswresample/resample.c b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libswresample/resample.c index 16d48e93daf..4b82f3b3760 100644 --- a/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libswresample/resample.c +++ b/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-8.1.2/libswresample/resample.c @@ -242,7 +242,7 @@ static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_r c->factor = factor; c->filter_length = filter_length; c->filter_alloc = FFALIGN(c->filter_length, 8); - c->filter_bank = av_calloc(c->filter_alloc, (phase_count+1)*c->felem_size); + c->filter_bank = av_calloc(c->filter_alloc, (size_t)((phase_count+1))*c->felem_size); c->filter_type = filter_type; c->kaiser_beta = kaiser_beta; c->phase_count_compensation = phase_count_compensation; @@ -289,7 +289,7 @@ static int rebuild_filter_bank_with_compensation(ResampleContext *c) av_assert0(!c->frac && !c->dst_incr_mod); - new_filter_bank = av_calloc(c->filter_alloc, (phase_count + 1) * c->felem_size); + new_filter_bank = av_calloc(c->filter_alloc, (size_t)((phase_count + 1)) * c->felem_size); if (!new_filter_bank) return AVERROR(ENOMEM); diff --git a/third-party/libjxl/libjxl/lib/extras/metrics.cc b/third-party/libjxl/libjxl/lib/extras/metrics.cc index 8d91da6b8f1..0ed98865253 100644 --- a/third-party/libjxl/libjxl/lib/extras/metrics.cc +++ b/third-party/libjxl/libjxl/lib/extras/metrics.cc @@ -167,7 +167,7 @@ void ComputeSumOfSquares(const ImageBundle& ib1, const ImageBundle& ib2, } } for (size_t j = 0; j < 3; j++) { - sum_of_squares[j] += yuvdiff[j] * yuvdiff[j]; + sum_of_squares[j] += (double)(yuvdiff[j]) * yuvdiff[j]; } } } diff --git a/third-party/libjxl/libjxl/lib/jpegli/color_quantize.cc b/third-party/libjxl/libjxl/lib/jpegli/color_quantize.cc index 1079c45c9fa..f0a92a20380 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/color_quantize.cc +++ b/third-party/libjxl/libjxl/lib/jpegli/color_quantize.cc @@ -256,7 +256,7 @@ void ChooseColorMap2Pass(j_decompress_ptr cinfo) { JPEGLI_ERROR("Two-pass quantizer must use RGB output color space."); } jpeg_decomp_master* m = cinfo->master; - const size_t num_pixels = cinfo->output_width * cinfo->output_height; + const size_t num_pixels = (size_t)(cinfo->output_width) * cinfo->output_height; const int max_color_count = std::max(num_pixels, 1u << 18); const int max_palette_size = cinfo->desired_number_of_colors; std::unique_ptr red(new uint8_t[max_color_count]); diff --git a/third-party/libjxl/libjxl/lib/jpegli/decode.cc b/third-party/libjxl/libjxl/lib/jpegli/decode.cc index 758babeb5ec..b3590cc1f9d 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/decode.cc +++ b/third-party/libjxl/libjxl/lib/jpegli/decode.cc @@ -109,7 +109,7 @@ void InitProgressMonitor(j_decompress_ptr cinfo, bool coef_only) { int nc = cinfo->num_components; int estimated_num_scans = cinfo->progressive_mode ? 2 + 3 * nc : (m->is_multiscan_ ? nc : 1); - cinfo->progress->pass_limit = cinfo->total_iMCU_rows * estimated_num_scans; + cinfo->progress->pass_limit = (long)(cinfo->total_iMCU_rows) * estimated_num_scans; cinfo->progress->pass_counter = 0; if (coef_only) { cinfo->progress->total_passes = 1; @@ -139,7 +139,7 @@ void ProgressMonitorInputPass(j_decompress_ptr cinfo) { cinfo->input_iMCU_row); if (cinfo->progress->pass_counter > cinfo->progress->pass_limit) { cinfo->progress->pass_limit = - cinfo->input_scan_number * cinfo->total_iMCU_rows; + (long)(cinfo->input_scan_number) * cinfo->total_iMCU_rows; } (*cinfo->progress->progress_monitor)(reinterpret_cast(cinfo)); } @@ -261,7 +261,7 @@ void PrepareForScan(j_decompress_ptr cinfo) { size_t mcu_size = 0; for (int i = 0; i < cinfo->comps_in_scan; ++i) { jpeg_component_info* comp = cinfo->cur_comp_info[i]; - mcu_size += comp->h_samp_factor * comp->v_samp_factor; + mcu_size += (unsigned long)(comp->h_samp_factor) * comp->v_samp_factor; } if (mcu_size > D_MAX_BLOCKS_IN_MCU) { JPEGLI_ERROR("MCU size too big"); @@ -401,7 +401,7 @@ bool IsInputReady(j_decompress_ptr cinfo) { bool ReadOutputPass(j_decompress_ptr cinfo) { jpeg_decomp_master* m = cinfo->master; if (!m->pixels_) { - size_t stride = cinfo->out_color_components * cinfo->output_width; + size_t stride = (size_t)(cinfo->out_color_components) * cinfo->output_width; size_t num_samples = cinfo->output_height * stride; m->pixels_ = Allocate(cinfo, num_samples, JPOOL_IMAGE); m->scanlines_ = @@ -486,7 +486,7 @@ void AllocateCoefficientBuffer(j_decompress_ptr cinfo) { void AllocateOutputBuffers(j_decompress_ptr cinfo) { jpeg_decomp_master* m = cinfo->master; - size_t iMCU_width = cinfo->max_h_samp_factor * m->min_scaled_dct_size; + size_t iMCU_width = (size_t)(cinfo->max_h_samp_factor) * m->min_scaled_dct_size; size_t output_stride = m->iMCU_cols_ * iMCU_width; m->need_context_rows_ = false; for (int c = 0; c < cinfo->num_components; ++c) { @@ -496,7 +496,7 @@ void AllocateOutputBuffers(j_decompress_ptr cinfo) { } for (int c = 0; c < cinfo->num_components; ++c) { const auto& comp = cinfo->comp_info[c]; - size_t cheight = comp.v_samp_factor * m->scaled_dct_size[c]; + size_t cheight = (size_t)(comp.v_samp_factor) * m->scaled_dct_size[c]; int downsampled_width = output_stride / m->h_factor[c]; m->raw_height_[c] = cinfo->total_iMCU_rows * cheight; if (m->need_context_rows_) { @@ -898,7 +898,7 @@ void jpegli_crop_scanline(j_decompress_ptr cinfo, JDIMENSION* xoffset, } // TODO(szabadka) Skip the IDCT for skipped over blocks. size_t xend = *xoffset + *width; - size_t iMCU_width = m->min_scaled_dct_size * cinfo->max_h_samp_factor; + size_t iMCU_width = (size_t)(m->min_scaled_dct_size) * cinfo->max_h_samp_factor; *xoffset = (*xoffset / iMCU_width) * iMCU_width; *width = xend - *xoffset; cinfo->master->xoffset_ = *xoffset; diff --git a/third-party/libjxl/libjxl/lib/jpegli/decode_api_test.cc b/third-party/libjxl/libjxl/lib/jpegli/decode_api_test.cc index 39dd693ce0e..d5ebd10b969 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/decode_api_test.cc +++ b/third-party/libjxl/libjxl/lib/jpegli/decode_api_test.cc @@ -182,7 +182,7 @@ void ReadOutputImage(const DecompressParams& dparams, j_decompress_ptr cinfo, } else { size_t lines_left = yoffset + ysize_cropped - cinfo->output_scanline; max_lines = std::min(max_output_lines, lines_left); - size_t stride = cinfo->output_width * cinfo->out_color_components * + size_t stride = (unsigned long)(cinfo->output_width) * cinfo->out_color_components * bytes_per_sample; std::vector scanlines(max_lines); for (size_t i = 0; i < max_lines; ++i) { diff --git a/third-party/libjxl/libjxl/lib/jpegli/encode.cc b/third-party/libjxl/libjxl/lib/jpegli/encode.cc index 8a106e239a5..8c4ef5b1e72 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/encode.cc +++ b/third-party/libjxl/libjxl/lib/jpegli/encode.cc @@ -215,7 +215,7 @@ void ValidateScanScript(j_compress_ptr cinfo) { for (int j = 0; j < si.comps_in_scan; ++j) { int ci = si.component_index[j]; jpeg_component_info* comp = &cinfo->comp_info[ci]; - mcu_size += comp->h_samp_factor * comp->v_samp_factor; + mcu_size += (unsigned long)(comp->h_samp_factor) * comp->v_samp_factor; } if (mcu_size > C_MAX_BLOCKS_IN_MCU) { JPEGLI_ERROR("MCU size too big"); @@ -295,7 +295,7 @@ void ProcessCompressionParams(j_compress_ptr cinfo) { size_t total_iMCU_cols = DivCeil(cinfo->image_width, iMCU_width); cinfo->total_iMCU_rows = DivCeil(cinfo->image_height, iMCU_height); m->xsize_blocks = total_iMCU_cols * cinfo->max_h_samp_factor; - m->ysize_blocks = cinfo->total_iMCU_rows * cinfo->max_v_samp_factor; + m->ysize_blocks = (size_t)(cinfo->total_iMCU_rows) * cinfo->max_v_samp_factor; size_t blocks_per_iMCU = 0; for (int c = 0; c < cinfo->num_components; ++c) { @@ -310,7 +310,7 @@ void ProcessCompressionParams(j_compress_ptr cinfo) { comp->downsampled_height = DivCeil(cinfo->image_height, m->v_factor[c]); comp->width_in_blocks = DivCeil(comp->downsampled_width, DCTSIZE); comp->height_in_blocks = DivCeil(comp->downsampled_height, DCTSIZE); - blocks_per_iMCU += comp->h_samp_factor * comp->v_samp_factor; + blocks_per_iMCU += (unsigned long)(comp->h_samp_factor) * comp->v_samp_factor; } m->blocks_per_iMCU_row = total_iMCU_cols * blocks_per_iMCU; // Disable adaptive quantization for subsampled luma channel. @@ -356,7 +356,7 @@ void ProcessCompressionParams(j_compress_ptr cinfo) { for (int j = 0; j < scan_info->comps_in_scan; ++j) { int comp_idx = scan_info->component_index[j]; jpeg_component_info* comp = &cinfo->comp_info[comp_idx]; - sti->blocks_in_MCU += comp->h_samp_factor * comp->v_samp_factor; + sti->blocks_in_MCU += (unsigned long)(comp->h_samp_factor) * comp->v_samp_factor; } } size_t num_MCUs = sti->MCU_rows_in_scan * sti->MCUs_per_row; diff --git a/third-party/libjxl/libjxl/lib/jpegli/encode_finish.cc b/third-party/libjxl/libjxl/lib/jpegli/encode_finish.cc index 955676bdee8..fb305675095 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/encode_finish.cc +++ b/third-party/libjxl/libjxl/lib/jpegli/encode_finish.cc @@ -100,7 +100,7 @@ float ComputePSNR(j_compress_ptr cinfo, int sampling) { ComputeInverseWeights(qmc, iqmc); for (JDIMENSION by = 0; by < comp->height_in_blocks; by += sampling) { JBLOCKARRAY ba = GetBlockRow(cinfo, c, by); - const float* qf = m->quant_field.Row(by * v_factor); + const float* qf = m->quant_field.Row((ssize_t)(by) * v_factor); for (JDIMENSION bx = 0; bx < comp->width_in_blocks; bx += sampling) { error += BlockError(&ba[0][bx][0], qmc, iqmc, qf[bx * h_factor], zero_bias_offset, zero_bias_mul); @@ -123,7 +123,7 @@ void ReQuantizeCoeffs(j_compress_ptr cinfo) { const float* zero_bias_mul = m->zero_bias_mul[c]; for (JDIMENSION by = 0; by < comp->height_in_blocks; ++by) { JBLOCKARRAY ba = GetBlockRow(cinfo, c, by); - const float* qf = m->quant_field.Row(by * v_factor); + const float* qf = m->quant_field.Row((ssize_t)(by) * v_factor); for (JDIMENSION bx = 0; bx < comp->width_in_blocks; ++bx) { ReQuantizeBlock(&ba[0][bx][0], qmc, qf[bx * h_factor], zero_bias_offset, zero_bias_mul); diff --git a/third-party/libjxl/libjxl/lib/jpegli/encode_streaming.cc b/third-party/libjxl/libjxl/lib/jpegli/encode_streaming.cc index 89dbd813f85..244a279fccd 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/encode_streaming.cc +++ b/third-party/libjxl/libjxl/lib/jpegli/encode_streaming.cc @@ -145,7 +145,7 @@ void ProcessiMCURow(j_compress_ptr cinfo) { const float* imcu_start[kMaxComponents]; for (int c = 0; c < cinfo->num_components; ++c) { jpeg_component_info* comp = &cinfo->comp_info[c]; - imcu_start[c] = m->raw_data[c]->Row(mcu_y * comp->v_samp_factor * DCTSIZE); + imcu_start[c] = m->raw_data[c]->Row((ssize_t)(mcu_y) * comp->v_samp_factor * DCTSIZE); } const float* qf = nullptr; if (adaptive_quant) { diff --git a/third-party/libjxl/libjxl/lib/jpegli/entropy_coding.cc b/third-party/libjxl/libjxl/lib/jpegli/entropy_coding.cc index 149768fd307..ca97a651490 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/entropy_coding.cc +++ b/third-party/libjxl/libjxl/lib/jpegli/entropy_coding.cc @@ -42,7 +42,7 @@ size_t MaxNumTokensPerMCURow(j_compress_ptr cinfo) { size_t blocks_per_mcu = 0; for (int c = 0; c < cinfo->num_components; ++c) { jpeg_component_info* comp = &cinfo->comp_info[c]; - blocks_per_mcu += comp->h_samp_factor * comp->v_samp_factor; + blocks_per_mcu += (unsigned long)(comp->h_samp_factor) * comp->v_samp_factor; } return kDCTBlockSize * blocks_per_mcu * MCUs_per_row; } @@ -91,7 +91,7 @@ void TokenizeACProgressiveScan(j_compress_ptr cinfo, int scan_index, const int Se = scan_info->Se; const size_t restart_interval = sti->restart_interval; int restarts_to_go = restart_interval; - size_t num_blocks = comp->height_in_blocks * comp->width_in_blocks; + size_t num_blocks = (size_t)(comp->height_in_blocks) * comp->width_in_blocks; size_t num_restarts = restart_interval > 0 ? DivCeil(num_blocks, restart_interval) : 1; size_t restart_idx = 0; @@ -214,7 +214,7 @@ void TokenizeACRefinementScan(j_compress_ptr cinfo, int scan_index, RefToken token; int eob_run = 0; int eob_refbits = 0; - size_t num_blocks = comp->height_in_blocks * comp->width_in_blocks; + size_t num_blocks = (size_t)(comp->height_in_blocks) * comp->width_in_blocks; size_t num_restarts = restart_interval > 0 ? DivCeil(num_blocks, restart_interval) : 1; sti->tokens = m->next_refinement_token; @@ -474,7 +474,7 @@ void TokenizeJpeg(j_compress_ptr cinfo) { if (si->Ss > 0 && si->Ah > 0) { int comp_idx = si->component_index[0]; const jpeg_component_info* comp = &cinfo->comp_info[comp_idx]; - size_t num_blocks = comp->width_in_blocks * comp->height_in_blocks; + size_t num_blocks = (size_t)(comp->width_in_blocks) * comp->height_in_blocks; max_refinement_tokens += (1 + (si->Se - si->Ss) / 16) * num_blocks; } } @@ -563,7 +563,7 @@ float HistogramCost(const Histogram& histo) { for (size_t i = 0; i < kJpegHuffmanAlphabetSize; ++i) { if (depths[i] > 0) { header_bits += 8; - data_bits += counts[i] * depths[i]; + data_bits += (unsigned long)(counts[i]) * depths[i]; } } return header_bits + data_bits; diff --git a/third-party/libjxl/libjxl/lib/jpegli/input_suspension_test.cc b/third-party/libjxl/libjxl/lib/jpegli/input_suspension_test.cc index 565559bccec..3465aead51f 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/input_suspension_test.cc +++ b/third-party/libjxl/libjxl/lib/jpegli/input_suspension_test.cc @@ -168,7 +168,7 @@ void ReadOutputImage(const DecompressParams& dparams, j_decompress_ptr cinfo, if (max_output_lines == 0) max_output_lines = cinfo->output_height; size_t lines_left = cinfo->output_height - cinfo->output_scanline; max_lines = std::min(max_output_lines, lines_left); - size_t stride = cinfo->output_width * cinfo->num_components; + size_t stride = (size_t)(cinfo->output_width) * cinfo->num_components; std::vector scanlines(max_lines); for (size_t i = 0; i < max_lines; ++i) { size_t yidx = cinfo->output_scanline + i; diff --git a/third-party/libjxl/libjxl/lib/jpegli/output_suspension_test.cc b/third-party/libjxl/libjxl/lib/jpegli/output_suspension_test.cc index 73db791727b..b48631df3ae 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/output_suspension_test.cc +++ b/third-party/libjxl/libjxl/lib/jpegli/output_suspension_test.cc @@ -79,7 +79,7 @@ TEST_P(OutputSuspensionTestParam, PixelData) { cinfo.optimize_coding = FALSE; jpegli_start_compress(&cinfo, TRUE); - size_t stride = cinfo.image_width * cinfo.input_components; + size_t stride = (size_t)(cinfo.image_width) * cinfo.input_components; std::vector row_bytes(config.lines_batch_size * stride); while (cinfo.next_scanline < cinfo.image_height) { size_t lines_left = cinfo.image_height - cinfo.next_scanline; diff --git a/third-party/libjxl/libjxl/lib/jpegli/render.cc b/third-party/libjxl/libjxl/lib/jpegli/render.cc index 24e7e99618a..20ba7e47787 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/render.cc +++ b/third-party/libjxl/libjxl/lib/jpegli/render.cc @@ -647,7 +647,7 @@ void ProcessRawOutput(j_decompress_ptr cinfo, JSAMPIMAGE data) { size_t comp_width = compinfo.width_in_blocks * DCTSIZE; size_t comp_height = compinfo.height_in_blocks * DCTSIZE; size_t comp_nrows = compinfo.v_samp_factor * DCTSIZE; - size_t y0 = cinfo->output_iMCU_row * compinfo.v_samp_factor * DCTSIZE; + size_t y0 = (size_t)(cinfo->output_iMCU_row) * compinfo.v_samp_factor * DCTSIZE; size_t y1 = std::min(y0 + comp_nrows, comp_height); for (size_t y = y0; y < y1; ++y) { float* rows[1] = {m->raw_output_[c].Row(y)}; @@ -670,8 +670,8 @@ void ProcessOutput(j_decompress_ptr cinfo, size_t* num_output_rows, const int hfactor = cinfo->max_h_samp_factor; const size_t context = m->need_context_rows_ ? 1 : 0; const size_t imcu_row = cinfo->output_iMCU_row; - const size_t imcu_height = vfactor * m->min_scaled_dct_size; - const size_t imcu_width = hfactor * m->min_scaled_dct_size; + const size_t imcu_height = (size_t)(vfactor) * m->min_scaled_dct_size; + const size_t imcu_width = (size_t)(hfactor) * m->min_scaled_dct_size; const size_t output_width = m->iMCU_cols_ * imcu_width; if (imcu_row == cinfo->total_iMCU_rows || (imcu_row > context && diff --git a/third-party/libjxl/libjxl/lib/jpegli/source_manager_test.cc b/third-party/libjxl/libjxl/lib/jpegli/source_manager_test.cc index e15d18ec80b..9485aca49f7 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/source_manager_test.cc +++ b/third-party/libjxl/libjxl/lib/jpegli/source_manager_test.cc @@ -23,7 +23,7 @@ void ReadOutputImage(j_decompress_ptr cinfo, TestImage* output) { output->xsize = cinfo->output_width; output->components = cinfo->num_components; output->AllocatePixels(); - size_t stride = cinfo->output_width * cinfo->num_components; + size_t stride = (size_t)(cinfo->output_width) * cinfo->num_components; while (cinfo->output_scanline < cinfo->output_height) { JSAMPROW scanline = &output->pixels[cinfo->output_scanline * stride]; jpegli_read_scanlines(cinfo, &scanline, 1); diff --git a/third-party/libjxl/libjxl/lib/jpegli/streaming_test.cc b/third-party/libjxl/libjxl/lib/jpegli/streaming_test.cc index 9dcc0ff4ef7..a2baed4ea89 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/streaming_test.cc +++ b/third-party/libjxl/libjxl/lib/jpegli/streaming_test.cc @@ -114,7 +114,7 @@ TEST_P(StreamingTestParam, TestStreaming) { cinfo.optimize_coding = FALSE; jpegli_start_compress(&cinfo, TRUE); - size_t stride = cinfo.image_width * cinfo.input_components; + size_t stride = (size_t)(cinfo.image_width) * cinfo.input_components; size_t iMCU_height = 8 * cinfo.max_v_samp_factor; std::vector row_bytes(iMCU_height * stride); size_t yin = 0; diff --git a/third-party/libjxl/libjxl/lib/jpegli/test_utils-inl.h b/third-party/libjxl/libjxl/lib/jpegli/test_utils-inl.h index a4549171878..096465aa835 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/test_utils-inl.h +++ b/third-party/libjxl/libjxl/lib/jpegli/test_utils-inl.h @@ -416,7 +416,7 @@ void CopyCoefficients(j_decompress_ptr cinfo, jvirt_barray_ptr* coef_arrays, j_common_ptr comptr = reinterpret_cast(cinfo); for (int c = 0; c < cinfo->num_components; ++c) { jpeg_component_info* comp = &cinfo->comp_info[c]; - std::vector coeffs(comp->width_in_blocks * comp->height_in_blocks * + std::vector coeffs((size_t)(comp->width_in_blocks) * comp->height_in_blocks * DCTSIZE2); for (size_t by = 0; by < comp->height_in_blocks; ++by) { JBLOCKARRAY ba = (*cinfo->mem->access_virt_barray)(comptr, coef_arrays[c], diff --git a/third-party/libjxl/libjxl/lib/jpegli/test_utils.cc b/third-party/libjxl/libjxl/lib/jpegli/test_utils.cc index e4a4dc7a6ab..f0238799abf 100644 --- a/third-party/libjxl/libjxl/lib/jpegli/test_utils.cc +++ b/third-party/libjxl/libjxl/lib/jpegli/test_utils.cc @@ -464,7 +464,7 @@ void GenerateCoeffs(const CompressParams& jparams, TestImage* img) { for (size_t c = 0; c < img->components; ++c) { int xsize_blocks = jparams.comp_width(*img, c) / DCTSIZE; int ysize_blocks = jparams.comp_height(*img, c) / DCTSIZE; - std::vector plane(ysize_blocks * xsize_blocks * DCTSIZE2); + std::vector plane((size_t)(ysize_blocks) * xsize_blocks * DCTSIZE2); for (int by = 0; by < ysize_blocks; ++by) { for (int bx = 0; bx < xsize_blocks; ++bx) { JCOEF* block = &plane[(by * xsize_blocks + bx) * DCTSIZE2]; @@ -644,7 +644,7 @@ void EncodeWithJpegli(const TestImage& input, const CompressParams& jparams, } } } else { - size_t stride = cinfo->image_width * cinfo->input_components * + size_t stride = (size_t)(cinfo->image_width) * cinfo->input_components * jpegli_bytes_per_sample(input.data_type); std::vector row_bytes(stride); for (size_t y = 0; y < cinfo->image_height; ++y) { diff --git a/third-party/libjxl/libjxl/lib/jxl/jpeg/dec_jpeg_data_writer.cc b/third-party/libjxl/libjxl/lib/jxl/jpeg/dec_jpeg_data_writer.cc index 1714c2b4fd7..f3950cc9f28 100644 --- a/third-party/libjxl/libjxl/lib/jxl/jpeg/dec_jpeg_data_writer.cc +++ b/third-party/libjxl/libjxl/lib/jxl/jpeg/dec_jpeg_data_writer.cc @@ -808,7 +808,7 @@ SerializationStatus JXL_NOINLINE DoEncodeScan(const JPEGData& jpg, int n_blocks_y = is_interleaved ? c.v_samp_factor : 1; int n_blocks_x = is_interleaved ? c.h_samp_factor : 1; // compressed size per block cannot be more than 512 bytes per component - Reserve(bw, 512 * n_blocks_y * n_blocks_x); + Reserve(bw, (size_t)(512) * n_blocks_y * n_blocks_x); for (int iy = 0; iy < n_blocks_y; ++iy) { for (int ix = 0; ix < n_blocks_x; ++ix) { int block_y = ss.mcu_y * n_blocks_y + iy; diff --git a/third-party/libjxl/libjxl/lib/jxl/matrix_ops.h b/third-party/libjxl/libjxl/lib/jxl/matrix_ops.h index 1a969bd4f0a..c8348c657ce 100644 --- a/third-party/libjxl/libjxl/lib/jxl/matrix_ops.h +++ b/third-party/libjxl/libjxl/lib/jxl/matrix_ops.h @@ -26,7 +26,7 @@ void Mul3x3Matrix(const T* a, const T* b, T* c) { for (size_t y = 0; y < 3; y++) { double e = 0; for (size_t z = 0; z < 3; z++) { - e += a[y * 3 + z] * temp[z]; + e += (double)(a[y * 3 + z]) * temp[z]; } c[y * 3 + x] = e; } @@ -39,7 +39,7 @@ void Mul3x3Vector(const T* a, const T* b, T* c) { for (size_t y = 0; y < 3; y++) { double e = 0; for (size_t x = 0; x < 3; x++) { - e += a[y * 3 + x] * b[x]; + e += (double)(a[y * 3 + x]) * b[x]; } c[y] = e; } diff --git a/third-party/libjxl/libjxl/lib/jxl/modular/transform/enc_palette.cc b/third-party/libjxl/libjxl/lib/jxl/modular/transform/enc_palette.cc index e400e15e984..2d1bdb8ae42 100644 --- a/third-party/libjxl/libjxl/lib/jxl/modular/transform/enc_palette.cc +++ b/third-party/libjxl/libjxl/lib/jxl/modular/transform/enc_palette.cc @@ -133,7 +133,7 @@ struct PaletteIterationData { delta_frequency.first[2]}; float delta_distance = sqrt(palette_internal::ColorDistance({0, 0, 0}, current_delta)) + 1; - delta_frequency.second *= delta_distance * delta_distance_multiplier; + delta_frequency.second *= (double)(delta_distance) * delta_distance_multiplier; } // Sort by weighted frequency. diff --git a/third-party/libjxl/libjxl/lib/jxl/render_pipeline/low_memory_render_pipeline.cc b/third-party/libjxl/libjxl/lib/jxl/render_pipeline/low_memory_render_pipeline.cc index 7116326e4a2..6e67b2c913e 100644 --- a/third-party/libjxl/libjxl/lib/jxl/render_pipeline/low_memory_render_pipeline.cc +++ b/third-party/libjxl/libjxl/lib/jxl/render_pipeline/low_memory_render_pipeline.cc @@ -659,7 +659,7 @@ void LowMemoryRenderPipeline::RenderRect(size_t thread_id, // If necessary, get the output buffers. if (mode == RenderPipelineChannelMode::kInOut) { for (size_t iy = 0; iy < (1u << shifty); iy++) { - output_rows[c][iy] = rows.GetBuffer(i, y * (1 << shifty) + iy, c); + output_rows[c][iy] = rows.GetBuffer(i, (unsigned long)(y) * (1 << shifty) + iy, c); } } } diff --git a/third-party/libjxl/libjxl/lib/jxl/splines.cc b/third-party/libjxl/libjxl/lib/jxl/splines.cc index 15fd6ce5b54..4927d71421f 100644 --- a/third-party/libjxl/libjxl/lib/jxl/splines.cc +++ b/third-party/libjxl/libjxl/lib/jxl/splines.cc @@ -126,7 +126,7 @@ void ComputeSegments(const Spline::Point& center, const float intensity, // Distance beyond which max_color*intensity*exp(-d^2 / (2 * sigma^2)) drops // below 10^-kDistanceExp. const float maximum_distance = - std::sqrt(-2 * sigma * sigma * + std::sqrt((double)(-2) * sigma * sigma * (std::log(0.1) * kDistanceExp - std::log(max_color))); SplineSegment segment; segment.center_y = center.y; diff --git a/third-party/libjxl/libjxl/third_party/highway/hwy/aligned_allocator_test.cc b/third-party/libjxl/libjxl/third_party/highway/hwy/aligned_allocator_test.cc index 5d678a0de6c..42df789455c 100644 --- a/third-party/libjxl/libjxl/third_party/highway/hwy/aligned_allocator_test.cc +++ b/third-party/libjxl/libjxl/third_party/highway/hwy/aligned_allocator_test.cc @@ -218,7 +218,7 @@ TEST(AlignedAllocatorTest, AllocMultipleInt) { for (size_t i = 0; i < kSize; i++) { // Performs a computation using ptr[] to prevent it being optimized away. ptr[i] = static_cast(i); - if (i) ret += ptr[i] * ptr[i - 1]; + if (i) ret += (unsigned long)(ptr[i]) * ptr[i - 1]; } EXPECT_NE(0U, ret); } diff --git a/third-party/libjxl/libjxl/third_party/skcms/skcms.cc b/third-party/libjxl/libjxl/third_party/skcms/skcms.cc index 4db244df86a..49db666b717 100644 --- a/third-party/libjxl/libjxl/third_party/skcms/skcms.cc +++ b/third-party/libjxl/libjxl/third_party/skcms/skcms.cc @@ -668,7 +668,7 @@ static bool init_tables(const uint8_t* table_base, uint64_t max_tables_len, uint uint32_t byte_len_all_input_tables = out->input_channels * byte_len_per_input_table; uint32_t byte_len_all_output_tables = out->output_channels * byte_len_per_output_table; - uint64_t grid_size = out->output_channels * byte_width; + uint64_t grid_size = (uint64_t)out->output_channels * byte_width; for (uint32_t axis = 0; axis < out->input_channels; ++axis) { grid_size *= out->grid_points[axis]; } diff --git a/third-party/libyuv/third_party/libyuv/unit_test/scale_argb_test.cc b/third-party/libyuv/third_party/libyuv/unit_test/scale_argb_test.cc index f54a68f11fb..d5a1b74e9aa 100644 --- a/third-party/libyuv/third_party/libyuv/unit_test/scale_argb_test.cc +++ b/third-party/libyuv/third_party/libyuv/unit_test/scale_argb_test.cc @@ -165,7 +165,7 @@ static int ARGBClipTestFilter(int src_width, const int b = 128; int64_t src_argb_plane_size = - (Abs(src_width) + b * 2) * (Abs(src_height) + b * 2) * 4; + (int64_t)((Abs(src_width) + b * 2)) * (Abs(src_height) + b * 2) * 4; int src_stride_argb = (b * 2 + Abs(src_width)) * 4; align_buffer_page_end(src_argb, src_argb_plane_size); @@ -175,7 +175,7 @@ static int ARGBClipTestFilter(int src_width, } memset(src_argb, 1, src_argb_plane_size); - int64_t dst_argb_plane_size = (dst_width + b * 2) * (dst_height + b * 2) * 4; + int64_t dst_argb_plane_size = (int64_t)((dst_width + b * 2)) * (dst_height + b * 2) * 4; int dst_stride_argb = (b * 2 + dst_width) * 4; int i, j; @@ -434,9 +434,9 @@ static int YUVToARGBTestFilter(int src_width, int dst_height, FilterMode f, int benchmark_iterations) { - int64_t src_y_plane_size = Abs(src_width) * Abs(src_height); + int64_t src_y_plane_size = (int64_t)(Abs(src_width)) * Abs(src_height); int64_t src_uv_plane_size = - ((Abs(src_width) + 1) / 2) * ((Abs(src_height) + 1) / 2); + (int64_t)(((Abs(src_width) + 1) / 2)) * ((Abs(src_height) + 1) / 2); int src_stride_y = Abs(src_width); int src_stride_uv = (Abs(src_width) + 1) / 2; diff --git a/third-party/libyuv/third_party/libyuv/unit_test/scale_plane_test.cc b/third-party/libyuv/third_party/libyuv/unit_test/scale_plane_test.cc index 9ce47a02c3f..731ccd85635 100644 --- a/third-party/libyuv/third_party/libyuv/unit_test/scale_plane_test.cc +++ b/third-party/libyuv/third_party/libyuv/unit_test/scale_plane_test.cc @@ -184,7 +184,7 @@ static int TestPlaneFilter_16(int src_width, } int i; - int64_t src_y_plane_size = (Abs(src_width)) * (Abs(src_height)); + int64_t src_y_plane_size = (int64_t)((Abs(src_width))) * (Abs(src_height)); int src_stride_y = Abs(src_width); int dst_y_plane_size = dst_width * dst_height; int dst_stride_y = dst_width; diff --git a/third-party/libyuv/third_party/libyuv/unit_test/scale_test.cc b/third-party/libyuv/third_party/libyuv/unit_test/scale_test.cc index 6e3b9271c3b..0f9aa508c78 100644 --- a/third-party/libyuv/third_party/libyuv/unit_test/scale_test.cc +++ b/third-party/libyuv/third_party/libyuv/unit_test/scale_test.cc @@ -52,8 +52,8 @@ static int I420TestFilter(int src_width, int src_width_uv = (Abs(src_width) + 1) >> 1; int src_height_uv = (Abs(src_height) + 1) >> 1; - int64_t src_y_plane_size = (Abs(src_width)) * (Abs(src_height)); - int64_t src_uv_plane_size = (src_width_uv) * (src_height_uv); + int64_t src_y_plane_size = (int64_t)((Abs(src_width))) * (Abs(src_height)); + int64_t src_uv_plane_size = (int64_t)((src_width_uv)) * (src_height_uv); int src_stride_y = Abs(src_width); int src_stride_uv = src_width_uv; @@ -72,8 +72,8 @@ static int I420TestFilter(int src_width, int dst_width_uv = (dst_width + 1) >> 1; int dst_height_uv = (dst_height + 1) >> 1; - int64_t dst_y_plane_size = (dst_width) * (dst_height); - int64_t dst_uv_plane_size = (dst_width_uv) * (dst_height_uv); + int64_t dst_y_plane_size = (int64_t)((dst_width)) * (dst_height); + int64_t dst_uv_plane_size = (int64_t)((dst_width_uv)) * (dst_height_uv); int dst_stride_y = dst_width; int dst_stride_uv = dst_width_uv; @@ -171,8 +171,8 @@ static int I420TestFilter_12(int src_width, int src_width_uv = (Abs(src_width) + 1) >> 1; int src_height_uv = (Abs(src_height) + 1) >> 1; - int64_t src_y_plane_size = (Abs(src_width)) * (Abs(src_height)); - int64_t src_uv_plane_size = (src_width_uv) * (src_height_uv); + int64_t src_y_plane_size = (int64_t)((Abs(src_width))) * (Abs(src_height)); + int64_t src_uv_plane_size = (int64_t)((src_width_uv)) * (src_height_uv); int src_stride_y = Abs(src_width); int src_stride_uv = src_width_uv; @@ -288,8 +288,8 @@ static int I420TestFilter_16(int src_width, int src_width_uv = (Abs(src_width) + 1) >> 1; int src_height_uv = (Abs(src_height) + 1) >> 1; - int64_t src_y_plane_size = (Abs(src_width)) * (Abs(src_height)); - int64_t src_uv_plane_size = (src_width_uv) * (src_height_uv); + int64_t src_y_plane_size = (int64_t)((Abs(src_width))) * (Abs(src_height)); + int64_t src_uv_plane_size = (int64_t)((src_width_uv)) * (src_height_uv); int src_stride_y = Abs(src_width); int src_stride_uv = src_width_uv; @@ -404,8 +404,8 @@ static int I444TestFilter(int src_width, int src_width_uv = Abs(src_width); int src_height_uv = Abs(src_height); - int64_t src_y_plane_size = (Abs(src_width)) * (Abs(src_height)); - int64_t src_uv_plane_size = (src_width_uv) * (src_height_uv); + int64_t src_y_plane_size = (int64_t)((Abs(src_width))) * (Abs(src_height)); + int64_t src_uv_plane_size = (int64_t)((src_width_uv)) * (src_height_uv); int src_stride_y = Abs(src_width); int src_stride_uv = src_width_uv; @@ -424,8 +424,8 @@ static int I444TestFilter(int src_width, int dst_width_uv = dst_width; int dst_height_uv = dst_height; - int64_t dst_y_plane_size = (dst_width) * (dst_height); - int64_t dst_uv_plane_size = (dst_width_uv) * (dst_height_uv); + int64_t dst_y_plane_size = (int64_t)((dst_width)) * (dst_height); + int64_t dst_uv_plane_size = (int64_t)((dst_width_uv)) * (dst_height_uv); int dst_stride_y = dst_width; int dst_stride_uv = dst_width_uv; @@ -523,8 +523,8 @@ static int I444TestFilter_12(int src_width, int src_width_uv = Abs(src_width); int src_height_uv = Abs(src_height); - int64_t src_y_plane_size = (Abs(src_width)) * (Abs(src_height)); - int64_t src_uv_plane_size = (src_width_uv) * (src_height_uv); + int64_t src_y_plane_size = (int64_t)((Abs(src_width))) * (Abs(src_height)); + int64_t src_uv_plane_size = (int64_t)((src_width_uv)) * (src_height_uv); int src_stride_y = Abs(src_width); int src_stride_uv = src_width_uv; @@ -640,8 +640,8 @@ static int I444TestFilter_16(int src_width, int src_width_uv = Abs(src_width); int src_height_uv = Abs(src_height); - int64_t src_y_plane_size = (Abs(src_width)) * (Abs(src_height)); - int64_t src_uv_plane_size = (src_width_uv) * (src_height_uv); + int64_t src_y_plane_size = (int64_t)((Abs(src_width))) * (Abs(src_height)); + int64_t src_uv_plane_size = (int64_t)((src_width_uv)) * (src_height_uv); int src_stride_y = Abs(src_width); int src_stride_uv = src_width_uv; @@ -756,8 +756,8 @@ static int NV12TestFilter(int src_width, int src_width_uv = (Abs(src_width) + 1) >> 1; int src_height_uv = (Abs(src_height) + 1) >> 1; - int64_t src_y_plane_size = (Abs(src_width)) * (Abs(src_height)); - int64_t src_uv_plane_size = (src_width_uv) * (src_height_uv)*2; + int64_t src_y_plane_size = (int64_t)((Abs(src_width))) * (Abs(src_height)); + int64_t src_uv_plane_size = (int64_t)((src_width_uv)) * (src_height_uv)*2; int src_stride_y = Abs(src_width); int src_stride_uv = src_width_uv * 2; @@ -774,8 +774,8 @@ static int NV12TestFilter(int src_width, int dst_width_uv = (dst_width + 1) >> 1; int dst_height_uv = (dst_height + 1) >> 1; - int64_t dst_y_plane_size = (dst_width) * (dst_height); - int64_t dst_uv_plane_size = (dst_width_uv) * (dst_height_uv)*2; + int64_t dst_y_plane_size = (int64_t)((dst_width)) * (dst_height); + int64_t dst_uv_plane_size = (int64_t)((dst_width_uv)) * (dst_height_uv)*2; int dst_stride_y = dst_width; int dst_stride_uv = dst_width_uv * 2; diff --git a/third-party/mozjpeg/mozjpeg/jdmainct.c b/third-party/mozjpeg/mozjpeg/jdmainct.c index d332e6b2fa1..1de29596794 100644 --- a/third-party/mozjpeg/mozjpeg/jdmainct.c +++ b/third-party/mozjpeg/mozjpeg/jdmainct.c @@ -157,7 +157,7 @@ alloc_funny_pointers(j_decompress_ptr cinfo) */ xbuf = (JSAMPARRAY) (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, - 2 * (rgroup * (M + 4)) * sizeof(JSAMPROW)); + (unsigned long)(2) * ((unsigned long)(rgroup) * (M + 4)) * sizeof(JSAMPROW)); xbuf += rgroup; /* want one row group at negative offsets */ main_ptr->xbuffer[0][ci] = xbuf; xbuf += rgroup * (M + 4); diff --git a/third-party/mozjpeg/mozjpeg/tjunittest.c b/third-party/mozjpeg/mozjpeg/tjunittest.c index 165dff13c26..4628ae71ee4 100644 --- a/third-party/mozjpeg/mozjpeg/tjunittest.c +++ b/third-party/mozjpeg/mozjpeg/tjunittest.c @@ -437,7 +437,7 @@ static void _decompTest(tjhandle handle, unsigned char *jpegBuf, if (_hdrw != w || _hdrh != h || _hdrsubsamp != subsamp) THROW("Incorrect JPEG header"); - dstSize = scaledWidth * scaledHeight * tjPixelSize[pf]; + dstSize = (unsigned long)(scaledWidth) * scaledHeight * tjPixelSize[pf]; if ((dstBuf = (unsigned char *)malloc(dstSize)) == NULL) THROW("Memory allocation failure"); memset(dstBuf, 0, dstSize); diff --git a/third-party/mozjpeg/mozjpeg/yuvjpeg.c b/third-party/mozjpeg/mozjpeg/yuvjpeg.c index 92d0d8d80eb..019bde0d305 100644 --- a/third-party/mozjpeg/mozjpeg/yuvjpeg.c +++ b/third-party/mozjpeg/mozjpeg/yuvjpeg.c @@ -159,7 +159,7 @@ int main(int argc, char *argv[]) { /* Check that the file size matches 4:2:0 yuv. */ if (yuv_size != - (size_t)luma_width*luma_height + 2*chroma_width*chroma_height) { + (size_t)luma_width*luma_height + (unsigned long)(2)*chroma_width*chroma_height) { fclose(yuv_fd); fprintf(stderr, "Unexpected input format!\n"); return 1; diff --git a/third-party/openh264/third_party/openh264/src/codec/decoder/core/src/decoder_core.cpp b/third-party/openh264/third_party/openh264/src/codec/decoder/core/src/decoder_core.cpp index 11b4f761013..a7f0bbde0f7 100644 --- a/third-party/openh264/third_party/openh264/src/codec/decoder/core/src/decoder_core.cpp +++ b/third-party/openh264/third_party/openh264/src/codec/decoder/core/src/decoder_core.cpp @@ -1510,81 +1510,81 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid pCtx->pDqLayersList[i] = pDq; //to keep consistence with in UninitialDqLayersContext() memset (pDq, 0, sizeof (SDqLayer)); - pCtx->sMb.pMbType[i] = (uint32_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint32_t), + pCtx->sMb.pMbType[i] = (uint32_t*)pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof (uint32_t), "pCtx->sMb.pMbType[]"); - pCtx->sMb.pMv[i][LIST_0] = (int16_t (*)[16][2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + pCtx->sMb.pMv[i][LIST_0] = (int16_t (*)[16][2])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]"); - pCtx->sMb.pMv[i][LIST_1] = (int16_t (*)[16][2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + pCtx->sMb.pMv[i][LIST_1] = (int16_t (*)[16][2])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]"); - pCtx->sMb.pRefIndex[i][LIST_0] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz (pCtx->sMb.iMbWidth * + pCtx->sMb.pRefIndex[i][LIST_0] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]"); - pCtx->sMb.pRefIndex[i][LIST_1] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz (pCtx->sMb.iMbWidth * + pCtx->sMb.pRefIndex[i][LIST_1] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]"); - pCtx->sMb.pDirect[i] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * + pCtx->sMb.pDirect[i] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pDirect[]"); - pCtx->sMb.pLumaQp[i] = (int8_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), + pCtx->sMb.pLumaQp[i] = (int8_t*)pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof (int8_t), "pCtx->sMb.pLumaQp[]"); - pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i] = (bool*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * + pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i] = (bool*)pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( bool), "pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[]"); - pCtx->sMb.pTransformSize8x8Flag[i] = (bool*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + pCtx->sMb.pTransformSize8x8Flag[i] = (bool*)pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( bool), "pCtx->sMb.pTransformSize8x8Flag[]"); - pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int8_t) * 2, "pCtx->sMb.pChromaQp[]"); - pCtx->sMb.pMvd[i][LIST_0] = (int16_t (*)[16][2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + pCtx->sMb.pMvd[i][LIST_0] = (int16_t (*)[16][2])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMvd[][]"); - pCtx->sMb.pMvd[i][LIST_1] = (int16_t (*)[16][2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + pCtx->sMb.pMvd[i][LIST_1] = (int16_t (*)[16][2])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMvd[][]"); - pCtx->sMb.pCbfDc[i] = (uint16_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint16_t), + pCtx->sMb.pCbfDc[i] = (uint16_t*)pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof (uint16_t), "pCtx->sMb.pCbfDc[]"); - pCtx->sMb.pNzc[i] = (int8_t (*)[24])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + pCtx->sMb.pNzc[i] = (int8_t (*)[24])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int8_t) * 24, "pCtx->sMb.pNzc[]"); - pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int8_t) * 24, "pCtx->sMb.pNzcRs[]"); - pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])pMa->WelsMallocz (pCtx->sMb.iMbWidth * + pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof (int16_t) * MB_COEFF_LIST_SIZE, "pCtx->sMb.pScaledTCoeff[]"); - pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int8_t) * 8, "pCtx->sMb.pIntraPredMode[]"); - pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz (pCtx->sMb.iMbWidth * + pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]"); - pCtx->sMb.pIntraNxNAvailFlag[i] = (uint8_t (*))pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + pCtx->sMb.pIntraNxNAvailFlag[i] = (uint8_t (*))pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int8_t), "pCtx->sMb.pIntraNxNAvailFlag"); - pCtx->sMb.pChromaPredMode[i] = (int8_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), + pCtx->sMb.pChromaPredMode[i] = (int8_t*)pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof (int8_t), "pCtx->sMb.pChromaPredMode[]"); - pCtx->sMb.pCbp[i] = (int8_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), + pCtx->sMb.pCbp[i] = (int8_t*)pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof (int8_t), "pCtx->sMb.pCbp[]"); - pCtx->sMb.pSubMbType[i] = (uint32_t (*)[MB_PARTITION_SIZE])pMa->WelsMallocz (pCtx->sMb.iMbWidth * + pCtx->sMb.pSubMbType[i] = (uint32_t (*)[MB_PARTITION_SIZE])pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( uint32_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]"); - pCtx->sMb.pSliceIdc[i] = (int32_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t), + pCtx->sMb.pSliceIdc[i] = (int32_t*) pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof (int32_t), "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010 - pCtx->sMb.pResidualPredFlag[i] = (int8_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + pCtx->sMb.pResidualPredFlag[i] = (int8_t*) pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int8_t), "pCtx->sMb.pResidualPredFlag[]"); - pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * + pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( int8_t), "pCtx->sMb.pInterPredictionDoneFlag[]"); - pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( bool), "pCtx->sMb.pMbCorrectlyDecodedFlag[]"); - pCtx->sMb.pMbRefConcealedFlag[i] = (bool*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( + pCtx->sMb.pMbRefConcealedFlag[i] = (bool*) pMa->WelsMallocz ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof ( bool), "pCtx->pMbRefConcealedFlag[]"); @@ -1620,7 +1620,7 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid ) ) - memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t))); + memset (pCtx->sMb.pSliceIdc[i], 0xff, ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof (int32_t))); ++ i; } while (i < LAYER_NUM_EXCHANGEABLE); @@ -2591,9 +2591,9 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf if (pCtx->iTotalNumMbRec == 0) { //Picture start to decode for (int32_t i = 0; i < LAYER_NUM_EXCHANGEABLE; ++ i) - memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t))); - memset (pCtx->pCurDqLayer->pMbCorrectlyDecodedFlag, 0, pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight * sizeof (bool)); - memset (pCtx->pCurDqLayer->pMbRefConcealedFlag, 0, pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight * sizeof (bool)); + memset (pCtx->sMb.pSliceIdc[i], 0xff, ((unsigned long)(pCtx->sMb.iMbWidth) * pCtx->sMb.iMbHeight * sizeof (int32_t))); + memset (pCtx->pCurDqLayer->pMbCorrectlyDecodedFlag, 0, (unsigned long)(pCtx->pSps->iMbWidth) * pCtx->pSps->iMbHeight * sizeof (bool)); + memset (pCtx->pCurDqLayer->pMbRefConcealedFlag, 0, (unsigned long)(pCtx->pSps->iMbWidth) * pCtx->pSps->iMbHeight * sizeof (bool)); memset (pCtx->pDec->pRefPic[LIST_0], 0, sizeof (PPicture) * MAX_DPB_COUNT); memset (pCtx->pDec->pRefPic[LIST_1], 0, sizeof (PPicture) * MAX_DPB_COUNT); pCtx->pDec->iMbNum = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight; diff --git a/third-party/openh264/third_party/openh264/src/codec/encoder/core/src/encoder_ext.cpp b/third-party/openh264/third_party/openh264/src/codec/encoder/core/src/encoder_ext.cpp index 08f2776a79c..d0d10599b35 100644 --- a/third-party/openh264/third_party/openh264/src/codec/encoder/core/src/encoder_ext.cpp +++ b/third-party/openh264/third_party/openh264/src/codec/encoder/core/src/encoder_ext.cpp @@ -1479,7 +1479,7 @@ int32_t RequestMemoryVaaScreen (SVAAFrameInfo* pVaa, CMemoryAlign* pMa, const const int32_t iCountMax8x8BNum) { SVAAFrameInfoExt* pVaaExt = static_cast (pVaa); - pVaaExt->pVaaBlockStaticIdc[0] = (static_cast (pMa->WelsMallocz (iNumRef * iCountMax8x8BNum * sizeof ( + pVaaExt->pVaaBlockStaticIdc[0] = (static_cast (pMa->WelsMallocz ((unsigned long)(iNumRef) * iCountMax8x8BNum * sizeof ( uint8_t), "pVaa->pVaaBlockStaticIdc[0]"))); if (NULL == pVaaExt->pVaaBlockStaticIdc[0]) { return 1; diff --git a/third-party/openh264/third_party/openh264/src/codec/encoder/core/src/ratectl.cpp b/third-party/openh264/third_party/openh264/src/codec/encoder/core/src/ratectl.cpp index 40af74d94e1..9b1e8e4e1f0 100644 --- a/third-party/openh264/third_party/openh264/src/codec/encoder/core/src/ratectl.cpp +++ b/third-party/openh264/third_party/openh264/src/codec/encoder/core/src/ratectl.cpp @@ -220,7 +220,7 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) { const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId; const int32_t input_iBitsPerFrame = WELS_DIV_ROUND (pDLayerParam->iSpatialBitrate, pDLayerParamInternal->fOutputFrameRate); - const int64_t kiGopBits = input_iBitsPerFrame * kiGopSize; + const int64_t kiGopBits = (int64_t)(input_iBitsPerFrame) * kiGopSize; int32_t i; pWelsSvcRc->iBitRate = pDLayerParam->iSpatialBitrate; diff --git a/third-party/openh264/third_party/openh264/src/codec/processing/src/backgrounddetection/BackgroundDetection.cpp b/third-party/openh264/third_party/openh264/src/codec/processing/src/backgrounddetection/BackgroundDetection.cpp index 1e66a62918c..03a29f25f98 100644 --- a/third-party/openh264/third_party/openh264/src/codec/processing/src/backgrounddetection/BackgroundDetection.cpp +++ b/third-party/openh264/third_party/openh264/src/codec/processing/src/backgrounddetection/BackgroundDetection.cpp @@ -109,7 +109,7 @@ EResult CBackgroundDetection::Set (int32_t iType, void* pParam) { inline SBackgroundOU* CBackgroundDetection::AllocateOUArrayMemory (int32_t iWidth, int32_t iHeight) { int32_t iMaxOUWidth = (BGD_OU_SIZE - 1 + iWidth) >> LOG2_BGD_OU_SIZE; int32_t iMaxOUHeight = (BGD_OU_SIZE - 1 + iHeight) >> LOG2_BGD_OU_SIZE; - return (SBackgroundOU*)WelsMalloc (iMaxOUWidth * iMaxOUHeight * sizeof (SBackgroundOU)); + return (SBackgroundOU*)WelsMalloc ((unsigned long)(iMaxOUWidth) * iMaxOUHeight * sizeof (SBackgroundOU)); } void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_t iMbIndex, int32_t iMbWidth, diff --git a/third-party/subcodec/src/sprite_encode.cpp b/third-party/subcodec/src/sprite_encode.cpp index 9abe2b823f0..6db76e5b10f 100644 --- a/third-party/subcodec/src/sprite_encode.cpp +++ b/third-party/subcodec/src/sprite_encode.cpp @@ -257,8 +257,8 @@ std::expected SpriteEncoder::encode( int cwm = impl_->canvas_width_mbs; // Split into color (left half) and alpha (right half) - std::vector color(hwm * hhm); - std::vector alpha_mbs(hwm * hhm); + std::vector color((size_t)hwm * hhm); + std::vector alpha_mbs((size_t)hwm * hhm); for (int mb_y = 0; mb_y < hhm; mb_y++) { for (int mb_x = 0; mb_x < hwm; mb_x++) { diff --git a/third-party/subcodec/test/test_ipcm.cpp b/third-party/subcodec/test/test_ipcm.cpp index 43faed11c61..2c1d1dd2bd9 100644 --- a/third-party/subcodec/test/test_ipcm.cpp +++ b/third-party/subcodec/test/test_ipcm.cpp @@ -48,7 +48,7 @@ static int decode_stream(const uint8_t* data, size_t size, out[decoded].width = w; out[decoded].height = h; - out[decoded].y.resize(w * h); + out[decoded].y.resize((size_t)(w) * h); out[decoded].cb.resize(w / 2 * h / 2); out[decoded].cr.resize(w / 2 * h / 2); diff --git a/third-party/subcodec/test/test_mux.cpp b/third-party/subcodec/test/test_mux.cpp index 69a5b5c4019..3337080ce76 100644 --- a/third-party/subcodec/test/test_mux.cpp +++ b/third-party/subcodec/test/test_mux.cpp @@ -219,7 +219,7 @@ static int decode_stream(const uint8_t* data, size_t size, out_frames[decoded].width = w; out_frames[decoded].height = h; - out_frames[decoded].y.resize(w * h); + out_frames[decoded].y.resize((size_t)(w) * h); out_frames[decoded].cb.resize(w / 2 * h / 2); out_frames[decoded].cr.resize(w / 2 * h / 2); @@ -273,7 +273,7 @@ static int decode_sprite_ref(sprite_result_t* sprite, decoded_frame_t* out_frame out_frames[i].width = half_w; out_frames[i].height = h; - out_frames[i].y.resize(half_w * h); + out_frames[i].y.resize((size_t)(half_w) * h); out_frames[i].cb.resize(half_w / 2 * h / 2); out_frames[i].cr.resize(half_w / 2 * h / 2); diff --git a/third-party/subcodec/test/test_mux_alpha.cpp b/third-party/subcodec/test/test_mux_alpha.cpp index 7269779ef09..df35284713e 100644 --- a/third-party/subcodec/test/test_mux_alpha.cpp +++ b/third-party/subcodec/test/test_mux_alpha.cpp @@ -244,7 +244,7 @@ static int decode_stream(const uint8_t* data, size_t size, out_frames[decoded].width = w; out_frames[decoded].height = h; - out_frames[decoded].y.resize(w * h); + out_frames[decoded].y.resize((size_t)(w) * h); out_frames[decoded].cb.resize(w / 2 * h / 2); out_frames[decoded].cr.resize(w / 2 * h / 2); diff --git a/third-party/subcodec/test/test_mux_surface.cpp b/third-party/subcodec/test/test_mux_surface.cpp index fa2fada48a5..42fe26c6d1f 100644 --- a/third-party/subcodec/test/test_mux_surface.cpp +++ b/third-party/subcodec/test/test_mux_surface.cpp @@ -215,7 +215,7 @@ static int decode_stream(const uint8_t* data, size_t size, out_frames[decoded].width = w; out_frames[decoded].height = h; - out_frames[decoded].y.resize(w * h); + out_frames[decoded].y.resize((size_t)(w) * h); out_frames[decoded].cb.resize(w / 2 * h / 2); out_frames[decoded].cr.resize(w / 2 * h / 2); @@ -269,7 +269,7 @@ static int decode_sprite_ref(sprite_result_t* sprite, decoded_frame_t* out_frame out_frames[i].width = half_w; out_frames[i].height = h; - out_frames[i].y.resize(half_w * h); + out_frames[i].y.resize((size_t)(half_w) * h); out_frames[i].cb.resize(half_w / 2 * h / 2); out_frames[i].cr.resize(half_w / 2 * h / 2); diff --git a/third-party/subcodec/test/test_resize.cpp b/third-party/subcodec/test/test_resize.cpp index c57cd8feadd..2f52c50b937 100644 --- a/third-party/subcodec/test/test_resize.cpp +++ b/third-party/subcodec/test/test_resize.cpp @@ -158,7 +158,7 @@ static int decode_stream(const uint8_t* data, size_t size, out_frames[decoded].width = w; out_frames[decoded].height = h; - out_frames[decoded].y.resize(w * h); + out_frames[decoded].y.resize((size_t)(w) * h); out_frames[decoded].cb.resize(w / 2 * h / 2); out_frames[decoded].cr.resize(w / 2 * h / 2); diff --git a/third-party/subcodec/test/test_sprite_encode_alpha.cpp b/third-party/subcodec/test/test_sprite_encode_alpha.cpp index fb94edc09e6..210710ec5b5 100644 --- a/third-party/subcodec/test/test_sprite_encode_alpha.cpp +++ b/third-party/subcodec/test/test_sprite_encode_alpha.cpp @@ -15,8 +15,8 @@ static int test_alpha_encode() { int half_chroma = padded / 2; std::vector y(padded * padded); - std::vector cb(half_chroma * half_chroma, 128); - std::vector cr(half_chroma * half_chroma, 128); + std::vector cb((size_t)(half_chroma) * half_chroma, 128); + std::vector cr((size_t)(half_chroma) * half_chroma, 128); for (int r = 0; r < padded; r++) for (int c = 0; c < padded; c++) y[r * padded + c] = static_cast((r + c) % 256); diff --git a/third-party/subcodec/test/test_sprite_extractor.cpp b/third-party/subcodec/test/test_sprite_extractor.cpp index b0229acdf8a..9e063678006 100644 --- a/third-party/subcodec/test/test_sprite_extractor.cpp +++ b/third-party/subcodec/test/test_sprite_extractor.cpp @@ -61,8 +61,8 @@ static int test_alpha_extraction() { printf("test_alpha_extraction...\n"); int ss = 64, stride = ss, chroma_ss = ss / 2; - std::vector y(ss * ss), cb(chroma_ss * chroma_ss, 128), - cr(chroma_ss * chroma_ss, 128), alpha(ss * ss, 255); + std::vector y(ss * ss), cb((size_t)(chroma_ss) * chroma_ss, 128), + cr((size_t)(chroma_ss) * chroma_ss, 128), alpha(ss * ss, 255); auto ext = SpriteExtractor::create({.sprite_size = ss, .qp = 26}, "/tmp/test_alpha_extract.mbs"); diff --git a/third-party/subcodec/tools/bench_profile.cpp b/third-party/subcodec/tools/bench_profile.cpp index 416d4434c42..6836edd864e 100644 --- a/third-party/subcodec/tools/bench_profile.cpp +++ b/third-party/subcodec/tools/bench_profile.cpp @@ -172,7 +172,7 @@ static std::string extract_mbs(const std::string& input_path, int sprite_size, i AVPacket* pkt = av_packet_alloc(); AVFrame* raw = av_frame_alloc(); - std::vector alpha(sprite_size * sprite_size, 255); + std::vector alpha((size_t)(sprite_size) * sprite_size, 255); int frame_count = 0; auto try_receive = [&]() { @@ -306,8 +306,8 @@ int main(int argc, char* argv[]) { int h_px = mux.height_mbs() * 16; int cw = w_px / 2, ch = h_px / 2; std::vector dec_y(w_px * h_px, 0); - std::vector dec_cb(cw * ch, 128); - std::vector dec_cr(cw * ch, 128); + std::vector dec_cb((size_t)(cw) * ch, 128); + std::vector dec_cr((size_t)(cw) * ch, 128); /* Timed resize */ os_signpost_id_t rid = os_signpost_id_generate(log); diff --git a/third-party/subcodec/tools/sprite_extract.cpp b/third-party/subcodec/tools/sprite_extract.cpp index 6c98fac8869..bebdd56ac9c 100644 --- a/third-party/subcodec/tools/sprite_extract.cpp +++ b/third-party/subcodec/tools/sprite_extract.cpp @@ -260,7 +260,7 @@ int main(int argc, char* argv[]) { int luma_w = yuv_frame->width; int luma_h = yuv_frame->height; if ((int)opaque_alpha.size() < luma_w * luma_h) - opaque_alpha.assign(luma_w * luma_h, 255); + opaque_alpha.assign((size_t)(luma_w) * luma_h, 255); auto result = ext.add_frame( yuv_frame->data[0], yuv_frame->linesize[0], yuv_frame->data[1], yuv_frame->linesize[1], diff --git a/third-party/webp/libwebp/examples/anim_diff.c b/third-party/webp/libwebp/examples/anim_diff.c index 7ffabc8fd4a..1b18220b156 100644 --- a/third-party/webp/libwebp/examples/anim_diff.c +++ b/third-party/webp/libwebp/examples/anim_diff.c @@ -35,7 +35,7 @@ static int AdditionWillOverflow(int a, int b) { static int FramesAreEqual(const uint8_t* const rgba1, const uint8_t* const rgba2, int width, int height) { const int stride = width * 4; // Always true for 'DecodedFrame.rgba'. - return !memcmp(rgba1, rgba2, stride * height); + return !memcmp(rgba1, rgba2, (size_t)(stride) * height); } static WEBP_INLINE int PixelsAreSimilar(uint32_t src, uint32_t dst, diff --git a/third-party/webp/libwebp/examples/anim_dump.c b/third-party/webp/libwebp/examples/anim_dump.c index e4473386aad..86eef759cc1 100644 --- a/third-party/webp/libwebp/examples/anim_dump.c +++ b/third-party/webp/libwebp/examples/anim_dump.c @@ -105,7 +105,7 @@ int main(int argc, const char* argv[]) { buffer.height = image.canvas_height; buffer.u.RGBA.rgba = image.frames[i].rgba; buffer.u.RGBA.stride = buffer.width * sizeof(uint32_t); - buffer.u.RGBA.size = buffer.u.RGBA.stride * buffer.height; + buffer.u.RGBA.size = (size_t)(buffer.u.RGBA.stride) * buffer.height; WSNPRINTF(out_file, sizeof(out_file), "%s/%s%.4d.%s", dump_folder, prefix, i, suffix); if (!WebPSaveImage(&buffer, format, (const char*)out_file)) { diff --git a/third-party/webp/libwebp/examples/cwebp.c b/third-party/webp/libwebp/examples/cwebp.c index cab70054e5e..cdf7250bd9f 100644 --- a/third-party/webp/libwebp/examples/cwebp.c +++ b/third-party/webp/libwebp/examples/cwebp.c @@ -132,7 +132,7 @@ static void AllocExtraInfo(WebPPicture* const pic) { const int mb_w = (pic->width + 15) / 16; const int mb_h = (pic->height + 15) / 16; pic->extra_info = - (uint8_t*)WebPMalloc(mb_w * mb_h * sizeof(*pic->extra_info)); + (uint8_t*)WebPMalloc((unsigned long)(mb_w) * mb_h * sizeof(*pic->extra_info)); } static void PrintByteCount(const int bytes[4], int total_size, diff --git a/third-party/webp/libwebp/examples/dwebp.c b/third-party/webp/libwebp/examples/dwebp.c index 652de6a6ee7..96bef3b388e 100644 --- a/third-party/webp/libwebp/examples/dwebp.c +++ b/third-party/webp/libwebp/examples/dwebp.c @@ -133,10 +133,10 @@ static uint8_t* AllocateExternalBuffer(WebPDecoderConfig* config, format == RGB_565) ? 2 : 4; uint32_t stride = bpp * w + 7; // <- just for exercising - external_buffer = (uint8_t*)WebPMalloc(stride * h); + external_buffer = (uint8_t*)WebPMalloc((size_t)(stride) * h); if (external_buffer == NULL) return NULL; output_buffer->u.RGBA.stride = stride; - output_buffer->u.RGBA.size = stride * h; + output_buffer->u.RGBA.size = (size_t)(stride) * h; output_buffer->u.RGBA.rgba = external_buffer; } else { // YUV and YUVA const int has_alpha = WebPIsAlphaMode(output_buffer->colorspace); @@ -151,12 +151,12 @@ static uint8_t* AllocateExternalBuffer(WebPDecoderConfig* config, tmp = external_buffer; output_buffer->u.YUVA.y = tmp; output_buffer->u.YUVA.y_stride = stride; - output_buffer->u.YUVA.y_size = stride * h; + output_buffer->u.YUVA.y_size = (size_t)(stride) * h; tmp += output_buffer->u.YUVA.y_size; if (has_alpha) { output_buffer->u.YUVA.a = tmp; output_buffer->u.YUVA.a_stride = stride; - output_buffer->u.YUVA.a_size = stride * h; + output_buffer->u.YUVA.a_size = (size_t)(stride) * h; tmp += output_buffer->u.YUVA.a_size; } else { output_buffer->u.YUVA.a = NULL; diff --git a/third-party/webp/libwebp/extras/get_disto.c b/third-party/webp/libwebp/extras/get_disto.c index 3aa345bbbc6..73cba29ea4c 100644 --- a/third-party/webp/libwebp/extras/get_disto.c +++ b/third-party/webp/libwebp/extras/get_disto.c @@ -165,7 +165,7 @@ static int SSIMScaleChannel(uint8_t* src1, int stride1, int x_stride, int w, int h, int do_scaling) { int x, y; int max = 0; - uint8_t* const plane1 = (uint8_t*)malloc(2 * w * h * sizeof(*plane1)); + uint8_t* const plane1 = (uint8_t*)malloc((unsigned long)(2) * w * h * sizeof(*plane1)); uint8_t* const plane2 = plane1 + w * h; if (plane1 == NULL) return -1; diff --git a/third-party/webp/libwebp/imageio/pnmdec.c b/third-party/webp/libwebp/imageio/pnmdec.c index 0d592c32970..139cdbc1419 100644 --- a/third-party/webp/libwebp/imageio/pnmdec.c +++ b/third-party/webp/libwebp/imageio/pnmdec.c @@ -235,12 +235,12 @@ int ReadPNM(const uint8_t* const data, size_t data_size, tmp_rgb = rgb; for (j = 0; j < info.height; ++j) { const uint8_t* in = data + offset; - offset += info.bytes_per_px * info.width; + offset += (unsigned long)(info.bytes_per_px) * info.width; assert(offset <= data_size); if (info.max_value == 255 && info.depth >= 3) { // RGB or RGBA if (info.depth == 3 || keep_alpha) { - memcpy(tmp_rgb, in, info.depth * info.width * sizeof(*in)); + memcpy(tmp_rgb, in, (unsigned long)(info.depth) * info.width * sizeof(*in)); } else { assert(info.depth == 4 && !keep_alpha); for (i = 0; i < info.width; ++i) { diff --git a/third-party/webp/libwebp/imageio/webpdec.c b/third-party/webp/libwebp/imageio/webpdec.c index aed60e14b5d..5cf2c5015dd 100644 --- a/third-party/webp/libwebp/imageio/webpdec.c +++ b/third-party/webp/libwebp/imageio/webpdec.c @@ -193,7 +193,7 @@ int ReadWebP(const uint8_t* const data, size_t data_size, #endif output_buffer->u.RGBA.rgba = (uint8_t*)pic->argb; output_buffer->u.RGBA.stride = pic->argb_stride * sizeof(uint32_t); - output_buffer->u.RGBA.size = output_buffer->u.RGBA.stride * pic->height; + output_buffer->u.RGBA.size = (size_t)(output_buffer->u.RGBA.stride) * pic->height; } else { output_buffer->colorspace = has_alpha ? MODE_YUVA : MODE_YUV; output_buffer->u.YUVA.y = pic->y; @@ -204,10 +204,10 @@ int ReadWebP(const uint8_t* const data, size_t data_size, output_buffer->u.YUVA.u_stride = pic->uv_stride; output_buffer->u.YUVA.v_stride = pic->uv_stride; output_buffer->u.YUVA.a_stride = has_alpha ? pic->a_stride : 0; - output_buffer->u.YUVA.y_size = pic->height * pic->y_stride; - output_buffer->u.YUVA.u_size = (pic->height + 1) / 2 * pic->uv_stride; - output_buffer->u.YUVA.v_size = (pic->height + 1) / 2 * pic->uv_stride; - output_buffer->u.YUVA.a_size = pic->height * pic->a_stride; + output_buffer->u.YUVA.y_size = (size_t)(pic->height) * pic->y_stride; + output_buffer->u.YUVA.u_size = (size_t)((pic->height + 1) / 2) * pic->uv_stride; + output_buffer->u.YUVA.v_size = (size_t)((pic->height + 1) / 2) * pic->uv_stride; + output_buffer->u.YUVA.a_size = (size_t)(pic->height) * pic->a_stride; } output_buffer->is_external_memory = 1; diff --git a/third-party/webp/libwebp/sharpyuv/sharpyuv.c b/third-party/webp/libwebp/sharpyuv/sharpyuv.c index b94885a6c32..e3bb62fa3cf 100644 --- a/third-party/webp/libwebp/sharpyuv/sharpyuv.c +++ b/third-party/webp/libwebp/sharpyuv/sharpyuv.c @@ -292,7 +292,7 @@ static void* SafeMalloc(uint64_t nmemb, size_t size) { return malloc((size_t)total_size); } -#define SAFE_ALLOC(W, H, T) ((T*)SafeMalloc((W) * (H), sizeof(T))) +#define SAFE_ALLOC(W, H, T) ((T*)SafeMalloc((uint64_t)(W) * (H), sizeof(T))) static int DoSharpArgbToYuv(const uint8_t* r_ptr, const uint8_t* g_ptr, const uint8_t* b_ptr, int rgb_step, int rgb_stride, @@ -312,13 +312,13 @@ static int DoSharpArgbToYuv(const uint8_t* r_ptr, const uint8_t* g_ptr, // TODO(skal): allocate one big memory chunk. But for now, it's easier // for valgrind debugging to have several chunks. - fixed_y_t* const tmp_buffer = SAFE_ALLOC(w * 3, 2, fixed_y_t); // scratch + fixed_y_t* const tmp_buffer = SAFE_ALLOC((uint64_t)w * 3, 2, fixed_y_t); // scratch fixed_y_t* const best_y_base = SAFE_ALLOC(w, h, fixed_y_t); fixed_y_t* const target_y_base = SAFE_ALLOC(w, h, fixed_y_t); fixed_y_t* const best_rgb_y = SAFE_ALLOC(w, 2, fixed_y_t); - fixed_t* const best_uv_base = SAFE_ALLOC(uv_w * 3, uv_h, fixed_t); - fixed_t* const target_uv_base = SAFE_ALLOC(uv_w * 3, uv_h, fixed_t); - fixed_t* const best_rgb_uv = SAFE_ALLOC(uv_w * 3, 1, fixed_t); + fixed_t* const best_uv_base = SAFE_ALLOC((uint64_t)uv_w * 3, uv_h, fixed_t); + fixed_t* const target_uv_base = SAFE_ALLOC((uint64_t)uv_w * 3, uv_h, fixed_t); + fixed_t* const best_rgb_uv = SAFE_ALLOC((uint64_t)uv_w * 3, 1, fixed_t); fixed_y_t* best_y = best_y_base; fixed_y_t* target_y = target_y_base; fixed_t* best_uv = best_uv_base; diff --git a/third-party/webp/libwebp/src/dec/alpha_dec.c b/third-party/webp/libwebp/src/dec/alpha_dec.c index 663255c42fd..5501567a279 100644 --- a/third-party/webp/libwebp/src/dec/alpha_dec.c +++ b/third-party/webp/libwebp/src/dec/alpha_dec.c @@ -93,7 +93,7 @@ static int ALPHInit(ALPHDecoder* const dec, const uint8_t* data, // No need to copy the scaling parameters. if (dec->method_ == ALPHA_NO_COMPRESSION) { - const size_t alpha_decoded_size = dec->width_ * dec->height_; + const size_t alpha_decoded_size = (size_t)(dec->width_) * dec->height_; ok = (alpha_data_size >= alpha_decoded_size); } else { assert(dec->method_ == ALPHA_LOSSLESS_COMPRESSION); diff --git a/third-party/webp/libwebp/src/dec/frame_dec.c b/third-party/webp/libwebp/src/dec/frame_dec.c index 91ca1f8609a..daa0a008082 100644 --- a/third-party/webp/libwebp/src/dec/frame_dec.c +++ b/third-party/webp/libwebp/src/dec/frame_dec.c @@ -688,11 +688,11 @@ static int AllocateMemory(VP8Decoder* const dec) { const size_t mb_info_size = (mb_w + 1) * sizeof(VP8MB); const size_t f_info_size = (dec->filter_type_ > 0) ? - mb_w * (dec->mt_method_ > 0 ? 2 : 1) * sizeof(VP8FInfo) + (unsigned long)(mb_w) * (dec->mt_method_ > 0 ? 2 : 1) * sizeof(VP8FInfo) : 0; const size_t yuv_size = YUV_SIZE * sizeof(*dec->yuv_b_); const size_t mb_data_size = - (dec->mt_method_ == 2 ? 2 : 1) * mb_w * sizeof(*dec->mb_data_); + (unsigned long)((dec->mt_method_ == 2 ? 2 : 1)) * mb_w * sizeof(*dec->mb_data_); const size_t cache_height = (16 * num_caches + kFilterExtraRows[dec->filter_type_]) * 3 / 2; const size_t cache_size = top_size * cache_height; diff --git a/third-party/webp/libwebp/src/dsp/filters.c b/third-party/webp/libwebp/src/dsp/filters.c index c1350d5c9d2..385be630743 100644 --- a/third-party/webp/libwebp/src/dsp/filters.c +++ b/third-party/webp/libwebp/src/dsp/filters.c @@ -47,7 +47,7 @@ static WEBP_INLINE void DoHorizontalFilter_C(const uint8_t* in, int row, int num_rows, int inverse, uint8_t* out) { const uint8_t* preds; - const size_t start_offset = row * stride; + const size_t start_offset = (size_t)(row) * stride; const int last_row = row + num_rows; SANITY_CHECK(in, out); in += start_offset; @@ -84,7 +84,7 @@ static WEBP_INLINE void DoVerticalFilter_C(const uint8_t* in, int row, int num_rows, int inverse, uint8_t* out) { const uint8_t* preds; - const size_t start_offset = row * stride; + const size_t start_offset = (size_t)(row) * stride; const int last_row = row + num_rows; SANITY_CHECK(in, out); in += start_offset; @@ -129,7 +129,7 @@ static WEBP_INLINE void DoGradientFilter_C(const uint8_t* in, int row, int num_rows, int inverse, uint8_t* out) { const uint8_t* preds; - const size_t start_offset = row * stride; + const size_t start_offset = (size_t)(row) * stride; const int last_row = row + num_rows; SANITY_CHECK(in, out); in += start_offset; diff --git a/third-party/webp/libwebp/src/dsp/filters_sse2.c b/third-party/webp/libwebp/src/dsp/filters_sse2.c index 5c33ec15e21..c2030233d62 100644 --- a/third-party/webp/libwebp/src/dsp/filters_sse2.c +++ b/third-party/webp/libwebp/src/dsp/filters_sse2.c @@ -76,7 +76,7 @@ static WEBP_INLINE void DoHorizontalFilter_SSE2(const uint8_t* in, int stride, int row, int num_rows, uint8_t* out) { - const size_t start_offset = row * stride; + const size_t start_offset = (size_t)(row) * stride; const int last_row = row + num_rows; SANITY_CHECK(in, out); in += start_offset; @@ -109,7 +109,7 @@ static WEBP_INLINE void DoVerticalFilter_SSE2(const uint8_t* in, int width, int height, int stride, int row, int num_rows, uint8_t* out) { - const size_t start_offset = row * stride; + const size_t start_offset = (size_t)(row) * stride; const int last_row = row + num_rows; SANITY_CHECK(in, out); in += start_offset; @@ -172,7 +172,7 @@ static WEBP_INLINE void DoGradientFilter_SSE2(const uint8_t* in, int width, int height, int stride, int row, int num_rows, uint8_t* out) { - const size_t start_offset = row * stride; + const size_t start_offset = (size_t)(row) * stride; const int last_row = row + num_rows; SANITY_CHECK(in, out); in += start_offset; diff --git a/third-party/webp/libwebp/src/enc/alpha_enc.c b/third-party/webp/libwebp/src/enc/alpha_enc.c index 4a599f88a98..bc07f368313 100644 --- a/third-party/webp/libwebp/src/enc/alpha_enc.c +++ b/third-party/webp/libwebp/src/enc/alpha_enc.c @@ -116,7 +116,7 @@ static int EncodeAlphaInternal(const uint8_t* const data, int width, int height, const uint8_t* alpha_src; WebPFilterFunc filter_func; uint8_t header; - const size_t data_size = width * height; + const size_t data_size = (size_t)(width) * height; const uint8_t* output = NULL; size_t output_size = 0; VP8LBitWriter tmp_bw; @@ -305,7 +305,7 @@ static int EncodeAlpha(VP8Encoder* const enc, const int height = pic->height; uint8_t* quant_alpha = NULL; - const size_t data_size = width * height; + const size_t data_size = (size_t)(width) * height; uint64_t sse = 0; int ok = 1; const int reduce_levels = (quality < 100); diff --git a/third-party/webp/libwebp/src/enc/analysis_enc.c b/third-party/webp/libwebp/src/enc/analysis_enc.c index 962eaa998f8..55282bfb12d 100644 --- a/third-party/webp/libwebp/src/enc/analysis_enc.c +++ b/third-party/webp/libwebp/src/enc/analysis_enc.c @@ -30,7 +30,7 @@ static void SmoothSegmentMap(VP8Encoder* const enc) { const int w = enc->mb_w_; const int h = enc->mb_h_; const int majority_cnt_3_x_3_grid = 5; - uint8_t* const tmp = (uint8_t*)WebPSafeMalloc(w * h, sizeof(*tmp)); + uint8_t* const tmp = (uint8_t*)WebPSafeMalloc((uint64_t)(w) * h, sizeof(*tmp)); assert((uint64_t)(w * h) == (uint64_t)w * h); // no overflow, as per spec if (tmp == NULL) return; diff --git a/third-party/webp/libwebp/src/enc/backward_references_enc.c b/third-party/webp/libwebp/src/enc/backward_references_enc.c index dc98bf17194..f7da1376e1c 100644 --- a/third-party/webp/libwebp/src/enc/backward_references_enc.c +++ b/third-party/webp/libwebp/src/enc/backward_references_enc.c @@ -597,7 +597,7 @@ static int BackwardReferencesLz77Box(int xsize, int ysize, int window_offsets_size = 0; int window_offsets_new_size = 0; uint16_t* const counts_ini = - (uint16_t*)WebPSafeMalloc(xsize * ysize, sizeof(*counts_ini)); + (uint16_t*)WebPSafeMalloc((uint64_t)(xsize) * ysize, sizeof(*counts_ini)); int best_offset_prev = -1, best_length_prev = -1; if (counts_ini == NULL) return 0; diff --git a/third-party/webp/libwebp/src/enc/quant_enc.c b/third-party/webp/libwebp/src/enc/quant_enc.c index 6d8202d2771..38d8a28e1d4 100644 --- a/third-party/webp/libwebp/src/enc/quant_enc.c +++ b/third-party/webp/libwebp/src/enc/quant_enc.c @@ -282,7 +282,7 @@ static void SetupMatrices(VP8Encoder* enc) { m->min_disto_ = 20 * m->y1_.q_[0]; // quantization-aware min disto m->max_edge_ = 0; - m->i4_penalty_ = 1000 * q_i4 * q_i4; + m->i4_penalty_ = (score_t)(1000) * q_i4 * q_i4; } } diff --git a/third-party/webp/libwebp/src/enc/vp8l_enc.c b/third-party/webp/libwebp/src/enc/vp8l_enc.c index c43d990d17e..b7293227887 100644 --- a/third-party/webp/libwebp/src/enc/vp8l_enc.c +++ b/third-party/webp/libwebp/src/enc/vp8l_enc.c @@ -1884,7 +1884,7 @@ int VP8LEncodeImage(const WebPConfig* const config, if (picture->extra_info != NULL) { const int mb_w = (width + 15) >> 4; const int mb_h = (height + 15) >> 4; - memset(picture->extra_info, 0, mb_w * mb_h * sizeof(*picture->extra_info)); + memset(picture->extra_info, 0, (unsigned long)(mb_w) * mb_h * sizeof(*picture->extra_info)); } Error: diff --git a/third-party/webp/libwebp/src/enc/webp_enc.c b/third-party/webp/libwebp/src/enc/webp_enc.c index 583fe6a8bbd..53072bb6911 100644 --- a/third-party/webp/libwebp/src/enc/webp_enc.c +++ b/third-party/webp/libwebp/src/enc/webp_enc.c @@ -150,10 +150,10 @@ static VP8Encoder* InitVP8Encoder(const WebPConfig* const config, const int mb_h = (picture->height + 15) >> 4; const int preds_w = 4 * mb_w + 1; const int preds_h = 4 * mb_h + 1; - const size_t preds_size = preds_w * preds_h * sizeof(*enc->preds_); + const size_t preds_size = (unsigned long)(preds_w) * preds_h * sizeof(*enc->preds_); const int top_stride = mb_w * 16; const size_t nz_size = (mb_w + 1) * sizeof(*enc->nz_) + WEBP_ALIGN_CST; - const size_t info_size = mb_w * mb_h * sizeof(*enc->mb_info_); + const size_t info_size = (unsigned long)(mb_w) * mb_h * sizeof(*enc->mb_info_); const size_t samples_size = 2 * top_stride * sizeof(*enc->y_top_) // top-luma/u/v + WEBP_ALIGN_CST; // align all diff --git a/third-party/webp/libwebp/src/mux/anim_encode.c b/third-party/webp/libwebp/src/mux/anim_encode.c index d1c61a2f1ee..bace39c3f85 100644 --- a/third-party/webp/libwebp/src/mux/anim_encode.c +++ b/third-party/webp/libwebp/src/mux/anim_encode.c @@ -1438,7 +1438,7 @@ static int DecodeFrameOntoCanvas(const WebPMuxFrameInfo* const frame, config.output.colorspace = MODE_BGRA; config.output.u.RGBA.rgba = (uint8_t*)sub_image.argb; config.output.u.RGBA.stride = sub_image.argb_stride * 4; - config.output.u.RGBA.size = config.output.u.RGBA.stride * sub_image.height; + config.output.u.RGBA.size = (size_t)(config.output.u.RGBA.stride) * sub_image.height; if (WebPDecode(image->bytes, image->size, &config) != VP8_STATUS_OK) { return 0; diff --git a/third-party/webp/libwebp/src/utils/palette.c b/third-party/webp/libwebp/src/utils/palette.c index 515da210195..6cbd41d8563 100644 --- a/third-party/webp/libwebp/src/utils/palette.c +++ b/third-party/webp/libwebp/src/utils/palette.c @@ -307,7 +307,7 @@ static int PaletteSortModifiedZeng(const WebPPicture* const pic, if (num_colors <= 1) return 1; // Build the co-occurrence matrix. cooccurrence = - (uint32_t*)WebPSafeCalloc(num_colors * num_colors, sizeof(*cooccurrence)); + (uint32_t*)WebPSafeCalloc((uint64_t)(num_colors) * num_colors, sizeof(*cooccurrence)); if (cooccurrence == NULL) { return 0; } diff --git a/third-party/webp/libwebp/src/utils/quant_levels_dec_utils.c b/third-party/webp/libwebp/src/utils/quant_levels_dec_utils.c index 97e78937043..a34a6c23850 100644 --- a/third-party/webp/libwebp/src/utils/quant_levels_dec_utils.c +++ b/third-party/webp/libwebp/src/utils/quant_levels_dec_utils.c @@ -217,7 +217,7 @@ static int InitParams(uint8_t* const data, int width, int height, int stride, int radius, SmoothParams* const p) { const int R = 2 * radius + 1; // total size of the kernel - const size_t size_scratch_m = (R + 1) * width * sizeof(*p->start_); + const size_t size_scratch_m = (unsigned long)((R + 1)) * width * sizeof(*p->start_); const size_t size_m = width * sizeof(*p->average_); const size_t size_lut = (1 + 2 * LUT_SIZE) * sizeof(*p->correction_); const size_t total_size = size_scratch_m + size_m + size_lut; diff --git a/third-party/webp/libwebp/src/utils/quant_levels_utils.c b/third-party/webp/libwebp/src/utils/quant_levels_utils.c index d65ad3c29db..a7f0582e540 100644 --- a/third-party/webp/libwebp/src/utils/quant_levels_utils.c +++ b/third-party/webp/libwebp/src/utils/quant_levels_utils.c @@ -30,7 +30,7 @@ int QuantizeLevels(uint8_t* const data, int width, int height, int q_level[NUM_SYMBOLS] = { 0 }; double inv_q_level[NUM_SYMBOLS] = { 0 }; int min_s = 255, max_s = 0; - const size_t data_size = height * width; + const size_t data_size = (size_t)(height) * width; int i, num_levels_in, iter; double last_err = 1.e38, err = 0.; const double err_threshold = ERROR_THRESHOLD * data_size; diff --git a/third-party/webp/libwebp/swig/libwebp_java_wrap.c b/third-party/webp/libwebp/swig/libwebp_java_wrap.c index c8d4b133129..58bf97bb64c 100644 --- a/third-party/webp/libwebp/swig/libwebp_java_wrap.c +++ b/third-party/webp/libwebp/swig/libwebp_java_wrap.c @@ -913,7 +913,7 @@ static size_t ReturnedBufferSize( for (p = size_map; p->function; ++p) { if (!strcmp(function, p->function)) { - size = *width * *height * p->size_multiplier; + size = (size_t)(*width) * *height * p->size_multiplier; break; } } diff --git a/third-party/webp/libwebp/swig/libwebp_python_wrap.c b/third-party/webp/libwebp/swig/libwebp_python_wrap.c index 3aa27285e83..197ce634d69 100644 --- a/third-party/webp/libwebp/swig/libwebp_python_wrap.c +++ b/third-party/webp/libwebp/swig/libwebp_python_wrap.c @@ -3427,7 +3427,7 @@ static size_t ReturnedBufferSize( for (p = size_map; p->function; ++p) { if (!strcmp(function, p->function)) { - size = *width * *height * p->size_multiplier; + size = (size_t)(*width) * *height * p->size_multiplier; break; } } diff --git a/third-party/webp/libwebp/tests/fuzzer/simple_api_fuzzer.c b/third-party/webp/libwebp/tests/fuzzer/simple_api_fuzzer.c index 7d2b7f81a95..32d0e67248a 100644 --- a/third-party/webp/libwebp/tests/fuzzer/simple_api_fuzzer.c +++ b/third-party/webp/libwebp/tests/fuzzer/simple_api_fuzzer.c @@ -45,7 +45,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) { buf = WebPDecodeYUV(data, size, &w, &h, &u, &v, &stride, &uv_stride); } else if (value < 0xe8) { const int stride = (value < 0xbe ? 4 : 3) * w; - size_t buf_size = stride * h; + size_t buf_size = (size_t)(stride) * h; if (value % 0x10 == 0) buf_size--; uint8_t* const ext_buf = (uint8_t*)malloc(buf_size); if (value < 0x94) { @@ -63,7 +63,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) { } free(ext_buf); } else { - size_t luma_size = w * h; + size_t luma_size = (size_t)(w) * h; const int uv_stride = (w + 1) / 2; size_t u_size = uv_stride * (h + 1) / 2; size_t v_size = uv_stride * (h + 1) / 2; diff --git a/third-party/webrtc/absl/absl/debugging/symbolize_elf.inc b/third-party/webrtc/absl/absl/debugging/symbolize_elf.inc index ae75cd4153d..e1209876166 100644 --- a/third-party/webrtc/absl/absl/debugging/symbolize_elf.inc +++ b/third-party/webrtc/absl/absl/debugging/symbolize_elf.inc @@ -595,7 +595,7 @@ bool ForEachSection(int fd, ElfW(Shdr) shstrtab; off_t shstrtab_offset = static_cast(elf_header.e_shoff) + - elf_header.e_shentsize * elf_header.e_shstrndx; + (long)(elf_header.e_shentsize) * elf_header.e_shstrndx; if (!file.ReadFromOffsetExact(&shstrtab, sizeof(shstrtab), shstrtab_offset)) { return false; } @@ -603,7 +603,7 @@ bool ForEachSection(int fd, for (int i = 0; i < elf_header.e_shnum; ++i) { ElfW(Shdr) out; off_t section_header_offset = - static_cast(elf_header.e_shoff) + elf_header.e_shentsize * i; + static_cast(elf_header.e_shoff) + (long)(elf_header.e_shentsize) * i; if (!file.ReadFromOffsetExact(&out, sizeof(out), section_header_offset)) { return false; } @@ -654,14 +654,14 @@ bool GetSectionHeaderByName(int fd, const char *name, size_t name_len, ElfW(Shdr) shstrtab; off_t shstrtab_offset = static_cast(elf_header.e_shoff) + - elf_header.e_shentsize * elf_header.e_shstrndx; + (long)(elf_header.e_shentsize) * elf_header.e_shstrndx; if (!file.ReadFromOffsetExact(&shstrtab, sizeof(shstrtab), shstrtab_offset)) { return false; } for (int i = 0; i < elf_header.e_shnum; ++i) { off_t section_header_offset = - static_cast(elf_header.e_shoff) + elf_header.e_shentsize * i; + static_cast(elf_header.e_shoff) + (long)(elf_header.e_shentsize) * i; if (!file.ReadFromOffsetExact(out, sizeof(*out), section_header_offset)) { return false; }