tests/checkasm/svq1enc: Use proper range for input

ssd_int8_vs_int16 is only called from encode_block()
in svq1enc.c; it calls it in stages: At stage 0,
the int16_t array contains the difference of two
uint16_t. At each of the following stages, the
int16_t array is filled by subtracting an int8_t from
the current stage's int16_t array. The maximum stage
is five, so the int16_t are in the range
(-255 - 5 * 127)..(255 + 5 * 128).

This commit modifies the checkasm test to only use
values from this range, fixing (undefined) integer overflow
in the test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2024-05-06 17:25:44 +02:00
parent ebe78e3ef0
commit 6fa967810d
1 changed files with 3 additions and 2 deletions

View File

@ -18,7 +18,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#include "libavcodec/svq1encdsp.h"
@ -26,11 +25,13 @@
#include "checkasm.h"
#define BUF_SIZE 1024
#define MIN_VAL (-255 - 5 * 127)
#define MAX_VAL ( 255 + 5 * 128)
#define randomize(buf, len) \
do { \
for (int i = 0; i < len; i++) \
buf[i] = ((rnd() % 65281) - 32641); \
buf[i] = ((rnd() % (MAX_VAL - MIN_VAL + 1)) + MIN_VAL); \
} while (0)
static void test_ssd_int8_vs_int16(SVQ1EncDSPContext *s) {