This commit is contained in:
twinaphex 2021-11-06 18:46:41 +01:00
parent b6f66b9ee8
commit 1b28eeb5c8
3 changed files with 1 additions and 1206 deletions

View File

@ -169,7 +169,7 @@ SOURCES_C += $(LIBVORBIS_DIR)/lib/analysis.c \
$(LIBVORBIS_DIR)/lib/window.c
SOURCES_C += $(LIBOGG_DIR)/src/bitwise.c \
$(LIBOGG_DIR)/src/framing.c
$(LIBOGG_DIR)/src/framing.c
endif
# The custom memory allocation system should be used consistently across the core

File diff suppressed because it is too large Load Diff

View File

@ -447,140 +447,3 @@ long vorbis_book_codelen(codebook *book,int entry){
return book->c->lengthlist[entry];
return -1;
}
#ifdef _V_SELFTEST
/* Unit tests of the dequantizer; this stuff will be OK
cross-platform, I simply want to be sure that special mapping cases
actually work properly; a bug could go unnoticed for a while */
#include <stdio.h>
/* cases:
no mapping
full, explicit mapping
algorithmic mapping
nonsequential
sequential
*/
static long full_quantlist1[]={0,1,2,3, 4,5,6,7, 8,3,6,1};
static long partial_quantlist1[]={0,7,2};
/* no mapping */
static_codebook test1={
4,16,
NULL,
0,
0,0,0,0,
NULL,
0
};
static float *test1_result=NULL;
/* linear, full mapping, nonsequential */
static_codebook test2={
4,3,
NULL,
2,
-533200896,1611661312,4,0,
full_quantlist1,
0
};
static float test2_result[]={-3,-2,-1,0, 1,2,3,4, 5,0,3,-2};
/* linear, full mapping, sequential */
static_codebook test3={
4,3,
NULL,
2,
-533200896,1611661312,4,1,
full_quantlist1,
0
};
static float test3_result[]={-3,-5,-6,-6, 1,3,6,10, 5,5,8,6};
/* linear, algorithmic mapping, nonsequential */
static_codebook test4={
3,27,
NULL,
1,
-533200896,1611661312,4,0,
partial_quantlist1,
0
};
static float test4_result[]={-3,-3,-3, 4,-3,-3, -1,-3,-3,
-3, 4,-3, 4, 4,-3, -1, 4,-3,
-3,-1,-3, 4,-1,-3, -1,-1,-3,
-3,-3, 4, 4,-3, 4, -1,-3, 4,
-3, 4, 4, 4, 4, 4, -1, 4, 4,
-3,-1, 4, 4,-1, 4, -1,-1, 4,
-3,-3,-1, 4,-3,-1, -1,-3,-1,
-3, 4,-1, 4, 4,-1, -1, 4,-1,
-3,-1,-1, 4,-1,-1, -1,-1,-1};
/* linear, algorithmic mapping, sequential */
static_codebook test5={
3,27,
NULL,
1,
-533200896,1611661312,4,1,
partial_quantlist1,
0
};
static float test5_result[]={-3,-6,-9, 4, 1,-2, -1,-4,-7,
-3, 1,-2, 4, 8, 5, -1, 3, 0,
-3,-4,-7, 4, 3, 0, -1,-2,-5,
-3,-6,-2, 4, 1, 5, -1,-4, 0,
-3, 1, 5, 4, 8,12, -1, 3, 7,
-3,-4, 0, 4, 3, 7, -1,-2, 2,
-3,-6,-7, 4, 1, 0, -1,-4,-5,
-3, 1, 0, 4, 8, 7, -1, 3, 2,
-3,-4,-5, 4, 3, 2, -1,-2,-3};
void run_test(static_codebook *b,float *comp){
float *out=_book_unquantize(b,b->entries,NULL);
int i;
if(comp){
if(!out){
fprintf(stderr,"_book_unquantize incorrectly returned NULL\n");
exit(1);
}
for(i=0;i<b->entries*b->dim;i++)
if(fabs(out[i]-comp[i])>.0001){
fprintf(stderr,"disagreement in unquantized and reference data:\n"
"position %d, %g != %g\n",i,out[i],comp[i]);
exit(1);
}
}else{
if(out){
fprintf(stderr,"_book_unquantize returned a value array: \n"
" correct result should have been NULL\n");
exit(1);
}
}
}
int main(){
/* run the nine dequant tests, and compare to the hand-rolled results */
fprintf(stderr,"Dequant test 1... ");
run_test(&test1,test1_result);
fprintf(stderr,"OK\nDequant test 2... ");
run_test(&test2,test2_result);
fprintf(stderr,"OK\nDequant test 3... ");
run_test(&test3,test3_result);
fprintf(stderr,"OK\nDequant test 4... ");
run_test(&test4,test4_result);
fprintf(stderr,"OK\nDequant test 5... ");
run_test(&test5,test5_result);
fprintf(stderr,"OK\n\n");
return(0);
}
#endif