This avoids use of uninitialized data (valgrind errors) in EncodeDecodeTestAPI.ScreenContent_LosslessLink0_EnableLongTermReference. Normally the buffer is initialized separately for each encoded frame if using EncodeDecodeTestAPIBase::EncodeOneFrame, but for tests that use encoder_->EncodeFrame directly, make sure the data always is initialized.
Showing the changes to test/api/encode_options_test.cpp (1 of 1 file). Show all
Unified · Split
| @@ -36,6 +36,7 @@ bool EncodeDecodeTestAPIBase::InitialEncDec (int iWidth, int iHeight) { · 35 unmodified lines | |||
| 36 | 36 | ||
| 37 | //set a fixed random value | 37 | //set a fixed random value |
| 38 | iRandValue = rand() % 256; | 38 | iRandValue = rand() % 256; |
| 39 | memset (buf_.data(), iRandValue, frameSize); | ||
| 39 | return true; | 40 | return true; |
| 40 | } | 41 | } |
| 41 | 42 | ||
| @@ -2158,11 +2159,6 @@ TEST_F (EncodeDecodeTestAPI, UnsupportedVideoSizeInput) { · 2116 unmodified lines | |||
| 2158 | 2159 | ||
| 2159 | ASSERT_TRUE (InitialEncDec (iSrcWidth, iSrcHeight)); | 2160 | ASSERT_TRUE (InitialEncDec (iSrcWidth, iSrcHeight)); |
| 2160 | 2161 | ||
| 2161 | int frameSize = EncPic.iPicWidth * EncPic.iPicHeight * 3 / 2; | ||
| 2162 | int lumaSize = EncPic.iPicWidth * EncPic.iPicHeight; | ||
| 2163 | memset (buf_.data(), iRandValue, lumaSize); | ||
| 2164 | memset (buf_.data() + lumaSize, rand() % 256, (frameSize - lumaSize)); | ||
| 2165 | |||
| 2166 | iRet = encoder_->EncodeFrame (&EncPic, &info); | 2162 | iRet = encoder_->EncodeFrame (&EncPic, &info); |
| 2167 | 2163 | ||
| 2168 | ASSERT_TRUE (iRet == cmResultSuccess) << "rv = " << iRet; | 2164 | ASSERT_TRUE (iRet == cmResultSuccess) << "rv = " << iRet; |