return 0;
}
-int main (void)
+int check_byte_orderings(struct test_state *state)
{
int status;
- struct aec_stream strm;
- struct test_state state;
-
- state.buf_len = state.ibuf_len = BUF_SIZE;
- state.cbuf_len = 2 * BUF_SIZE;
-
- state.ubuf = (unsigned char *)malloc(state.buf_len);
- state.cbuf = (unsigned char *)malloc(state.cbuf_len);
- state.obuf = (unsigned char *)malloc(state.buf_len);
-
- if (!state.ubuf || !state.cbuf || !state.obuf) {
- printf("Not enough memory.\n");
- return 99;
- }
-
- strm.flags = AEC_DATA_PREPROCESS;
- state.strm = &strm;
- state.codec = encode_decode_small;
printf("----------------------------\n");
printf("Checking LSB first, unsigned\n");
printf("----------------------------\n");
- status = check_bps(&state);
+ status = check_bps(state);
if (status)
- goto DESTRUCT;
+ return status;
printf("--------------------------\n");
printf("Checking LSB first, signed\n");
printf("--------------------------\n");
- strm.flags |= AEC_DATA_SIGNED;
+ state->strm->flags |= AEC_DATA_SIGNED;
- status = check_bps(&state);
+ status = check_bps(state);
if (status)
- goto DESTRUCT;
+ return status;
- strm.flags &= ~AEC_DATA_SIGNED;
- strm.flags |= AEC_DATA_MSB;
+ state->strm->flags &= ~AEC_DATA_SIGNED;
+ state->strm->flags |= AEC_DATA_MSB;
printf("----------------------------\n");
printf("Checking MSB first, unsigned\n");
printf("----------------------------\n");
- status = check_bps(&state);
+ status = check_bps(state);
if (status)
- goto DESTRUCT;
+ return status;
printf("--------------------------\n");
printf("Checking MSB first, signed\n");
printf("--------------------------\n");
- strm.flags |= AEC_DATA_SIGNED;
+ state->strm->flags |= AEC_DATA_SIGNED;
+
+ status = check_bps(state);
+ if (status)
+ return status;
+}
+
+int main (void)
+{
+ int status;
+ struct aec_stream strm;
+ struct test_state state;
+
+ state.buf_len = state.ibuf_len = BUF_SIZE;
+ state.cbuf_len = 2 * BUF_SIZE;
+
+ state.ubuf = (unsigned char *)malloc(state.buf_len);
+ state.cbuf = (unsigned char *)malloc(state.cbuf_len);
+ state.obuf = (unsigned char *)malloc(state.buf_len);
- status = check_bps(&state);
+ if (!state.ubuf || !state.cbuf || !state.obuf) {
+ printf("Not enough memory.\n");
+ return 99;
+ }
+
+ strm.flags = AEC_DATA_PREPROCESS;
+ state.strm = &strm;
+
+ printf("***************************\n");
+ printf("Checking with small buffers\n");
+ printf("***************************\n");
+ state.codec = encode_decode_small;
+ status = check_byte_orderings(&state);
if (status)
goto DESTRUCT;
+ printf("***************************\n");
+ printf("Checking with large buffers\n");
+ printf("***************************\n");
+ state.codec = encode_decode_large;
+ status = check_byte_orderings(&state);
+
DESTRUCT:
free(state.ubuf);
free(state.cbuf);