mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	test: add more lossless tests
Also test that S16->F32->S32 and U16->F32->U32 are lossless.
This commit is contained in:
		
							parent
							
								
									edf2062830
								
							
						
					
					
						commit
						463e723a1e
					
				
					 1 changed files with 13 additions and 5 deletions
				
			
		| 
						 | 
					@ -546,13 +546,17 @@ static void test_lossless_u8(void)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
static void test_lossless_s16(void)
 | 
					static void test_lossless_s16(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int16_t i;
 | 
						int32_t i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fprintf(stderr, "test %s:\n", __func__);
 | 
						fprintf(stderr, "test %s:\n", __func__);
 | 
				
			||||||
	for (i = S16_MIN; i < S16_MAX; i+=3) {
 | 
						for (i = S16_MIN; i <= S16_MAX; i+=3) {
 | 
				
			||||||
		float v = S16_TO_F32(i);
 | 
							float v = S16_TO_F32((int16_t)i);
 | 
				
			||||||
		int16_t t = F32_TO_S16(v);
 | 
							int16_t t = F32_TO_S16(v);
 | 
				
			||||||
		spa_assert_se(i == t);
 | 
							spa_assert_se(i == t);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							int32_t t2 = F32_TO_S32(v);
 | 
				
			||||||
 | 
							spa_assert_se(i<<16 == t2);
 | 
				
			||||||
 | 
							spa_assert_se(i == t2>>16);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -561,10 +565,14 @@ static void test_lossless_u16(void)
 | 
				
			||||||
	uint32_t i;
 | 
						uint32_t i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fprintf(stderr, "test %s:\n", __func__);
 | 
						fprintf(stderr, "test %s:\n", __func__);
 | 
				
			||||||
	for (i = U16_MIN; i < U16_MAX; i+=3) {
 | 
						for (i = U16_MIN; i <= U16_MAX; i+=3) {
 | 
				
			||||||
		float v = U16_TO_F32(i);
 | 
							float v = U16_TO_F32((uint16_t)i);
 | 
				
			||||||
		uint16_t t = F32_TO_U16(v);
 | 
							uint16_t t = F32_TO_U16(v);
 | 
				
			||||||
		spa_assert_se(i == t);
 | 
							spa_assert_se(i == t);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							uint32_t t2 = F32_TO_U32(v);
 | 
				
			||||||
 | 
							spa_assert_se(i<<16 == t2);
 | 
				
			||||||
 | 
							spa_assert_se(i == t2>>16);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue