Skip to content

Commit f75297c

Browse files
tests: cleanup and add comment about mpg123 deterministic decoding test (fixes #3107)
1 parent 8063553 commit f75297c

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

Tests/MP3DecoderTests.cpp

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class MP3DecoderTests: public ::testing::Test {
2828
}
2929
};
3030

31-
3231
static void runMp3TwoPieceTestWithBackend(int backend) {
3332
deadbeef->conf_set_int ("mp3.backend", backend);
3433

@@ -45,55 +44,59 @@ static void runMp3TwoPieceTestWithBackend(int backend) {
4544
DB_fileinfo_t *fi = dec->open (0);
4645
dec->init (fi, it);
4746

48-
int64_t size = 176400;
49-
char *buffer = (char *)malloc (size*2);
50-
51-
// request twice as much to make sure we don't overshoot
52-
int res = dec->read (fi, buffer, (int)size*2);
53-
54-
EXPECT_EQ(res, size);
47+
const int64_t size = 44100*2*sizeof(uint16_t);
48+
unsigned char *buffer1 = (unsigned char *)calloc (1, size);
49+
unsigned char *buffer2 = (unsigned char *)calloc (1, size);
5550

56-
char *buffer2 = (char *)malloc (size*2); // buffer is over-allocated to check for trailing data
51+
// Read whole 1 second
52+
int res1 = dec->read (fi, (char *)buffer1, (int)size);
53+
EXPECT_EQ(res1, size);
5754

5855
// read first part
5956
dec->seek_sample (fi, 0);
6057

61-
res = dec->read (fi, buffer2, (int)size/2);
62-
EXPECT_EQ(res, size/2);
58+
int res2 = dec->read (fi, (char *)buffer2, (int)size/2);
59+
EXPECT_EQ(res2, size/2);
6360

6461
dec->seek_sample (fi, 44100/2);
65-
res = dec->read (fi, buffer2+size/2, (int)size);
66-
EXPECT_EQ(res, size/2);
62+
int res3 = dec->read (fi, (char *)(buffer2 + size/2), (int)size/2);
63+
EXPECT_EQ(res3, size/2);
6764

6865
#if 0
69-
FILE *fp1 = fopen ("buffer1.raw", "w+b");
70-
FILE *fp2 = fopen ("buffer2.raw", "w+b");
71-
fwrite (buffer, size, 1, fp1);
66+
FILE *fp1 = fopen ("/Users/waker/buffer1.raw", "w+b");
67+
FILE *fp2 = fopen ("/Users/waker/buffer2.raw", "w+b");
68+
fwrite (buffer1, size, 1, fp1);
7269
fwrite (buffer2, size, 1, fp2);
7370
fclose (fp1);
7471
fclose (fp2);
7572
#endif
7673

77-
int cmp1 = memcmp (buffer, buffer2, size/2);
78-
EXPECT_TRUE(cmp1==0);
74+
int cmp_half1 = memcmp (buffer1, buffer2, size/2);
75+
EXPECT_EQ(cmp_half1, 0);
7976

80-
int cmp2 = memcmp (buffer+size/2, buffer2+size/2, size/2);
81-
EXPECT_TRUE(cmp2==0);
77+
int cmp2_half2 = memcmp (buffer1+size/2, buffer2+size/2, size/2);
78+
EXPECT_EQ(cmp2_half2, 0);
8279

83-
int cmp = memcmp (buffer, buffer2, size);
80+
int cmp_whole = memcmp (buffer1, buffer2, size);
81+
EXPECT_EQ(cmp_whole, 0);
8482

85-
free (buffer);
83+
free (buffer1);
8684
free (buffer2);
8785

8886
dec->free (fi);
8987

9088
deadbeef->plt_unref ((ddb_playlist_t *)plt);
9189

92-
EXPECT_TRUE(cmp==0);
9390
}
9491

9592
#if !__aarch64__
96-
// FIXME: Looks like MPG123 generates bad data in that test. Needs proper debugging on arm64 host.
93+
// #3107: This test is failing on arm64.
94+
// Proper investigation has been conducted,
95+
// mpg123 doesn't produce the same data on ARM64 when reading in 2 pieces vs 1 piece,
96+
// neither with OPT_NEON64, nor OPT_GENERIC modes.
97+
// Also the whole signal output differs between OPT_NEON64 and OPT_AVX modes.
98+
// Even comparing weakly as a signal with large tolerance doesn't give meaningful result,
99+
// so the test has to be disabled.
97100
TEST_F(MP3DecoderTests, test_DecodeMP3As2PiecesMPG123_SameAs1Piece) {
98101
runMp3TwoPieceTestWithBackend(0); // mpg123
99102
}

0 commit comments

Comments
 (0)