static void etsi_compliance_tests(void) { perform_linear_test(TRUE, 1, "Seq01"); perform_linear_test(TRUE, 1, "Seq02"); perform_linear_test(TRUE, 1, "Seq03"); perform_linear_test(TRUE, 1, "Seq04"); perform_linear_test(FALSE, 1, "Seq05"); perform_law_test(TRUE, 'a', "Seq01"); perform_law_test(TRUE, 'a', "Seq02"); perform_law_test(TRUE, 'a', "Seq03"); perform_law_test(TRUE, 'a', "Seq04"); perform_law_test(FALSE, 'a', "Seq05"); perform_law_test(TRUE, 'u', "Seq01"); perform_law_test(TRUE, 'u', "Seq02"); perform_law_test(TRUE, 'u', "Seq03"); perform_law_test(TRUE, 'u', "Seq04"); perform_law_test(FALSE, 'u', "Seq05"); /* This is not actually an ETSI test */ perform_pack_unpack_test(); printf("Tests passed.\n"); }
int main(int argc, char *argv[]) { AFfilehandle inhandle; AFfilehandle outhandle; int frames; int outframes; int bytes; int16_t pre_amp[HIST_LEN]; int16_t post_amp[HIST_LEN]; uint8_t gsm0610_data[HIST_LEN]; gsm0610_state_t *gsm0610_enc_state; gsm0610_state_t *gsm0610_dec_state; int opt; int etsitests; int packing; etsitests = TRUE; packing = GSM0610_PACKING_NONE; while ((opt = getopt(argc, argv, "lp:")) != -1) { switch (opt) { case 'l': etsitests = FALSE; break; case 'p': packing = atoi(optarg); break; default: //usage(); exit(2); } } if (etsitests) { perform_linear_test(TRUE, 1, "Seq01"); perform_linear_test(TRUE, 1, "Seq02"); perform_linear_test(TRUE, 1, "Seq03"); perform_linear_test(TRUE, 1, "Seq04"); perform_linear_test(FALSE, 1, "Seq05"); perform_law_test(TRUE, 'a', "Seq01"); perform_law_test(TRUE, 'a', "Seq02"); perform_law_test(TRUE, 'a', "Seq03"); perform_law_test(TRUE, 'a', "Seq04"); perform_law_test(FALSE, 'a', "Seq05"); perform_law_test(TRUE, 'u', "Seq01"); perform_law_test(TRUE, 'u', "Seq02"); perform_law_test(TRUE, 'u', "Seq03"); perform_law_test(TRUE, 'u', "Seq04"); perform_law_test(FALSE, 'u', "Seq05"); /* This is not actually an ETSI test */ perform_pack_unpack_test(); printf("Tests passed.\n"); } else { if ((inhandle = afOpenFile_telephony_read(IN_FILE_NAME, 1)) == AF_NULL_FILEHANDLE) { fprintf(stderr, " Cannot open wave file '%s'\n", IN_FILE_NAME); exit(2); } if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE) { fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME); exit(2); } if ((gsm0610_enc_state = gsm0610_init(NULL, packing)) == NULL) { fprintf(stderr, " Cannot create encoder\n"); exit(2); } if ((gsm0610_dec_state = gsm0610_init(NULL, packing)) == NULL) { fprintf(stderr, " Cannot create decoder\n"); exit(2); } while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, pre_amp, 2*BLOCK_LEN))) { bytes = gsm0610_encode(gsm0610_enc_state, gsm0610_data, pre_amp, frames); gsm0610_decode(gsm0610_dec_state, post_amp, gsm0610_data, bytes); outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, post_amp, frames); } if (afCloseFile(inhandle) != 0) { fprintf(stderr, " Cannot close wave file '%s'\n", IN_FILE_NAME); exit(2); } if (afCloseFile(outhandle) != 0) { fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME); exit(2); } gsm0610_release(gsm0610_enc_state); gsm0610_release(gsm0610_dec_state); } return 0; }