12 int main(int argc, char *argv[])
17 int chunk, total_out, status, c;
18 int input_avail, output_avail;
24 strm.bit_per_sample = 8;
27 strm.flags = AE_DATA_MSB | AE_DATA_PREPROCESS;
30 while ((c = getopt (argc, argv, "cb:B:R:")) != -1)
34 chunk = 2 * atoi(optarg);
37 strm.bit_per_sample = atoi(optarg);
40 strm.rsi = atoi(optarg);
47 fprintf (stderr, "Option -%c requires an argument.\n", optopt);
48 else if (isprint (optopt))
49 fprintf (stderr, "Unknown option `-%c'.\n", optopt);
52 "Unknown option character `\\x%x'.\n",
65 fprintf(stderr, "Usage: %s [ -c ] [ -b chunksize ] name\n", argv[0]);
69 out = (uint8_t *)malloc(chunk);
70 in = (uint8_t *)malloc(chunk);
73 if (in == NULL || out == NULL)
76 if (ae_encode_init(&strm) != AE_OK)
81 strm.avail_out = chunk;
87 if ((infp = fopen(infn, "r")) == NULL)
96 outfn = malloc(strlen(infn) + 4);
100 sprintf(outfn, "%s.aee", infn);
102 if ((outfp = fopen(outfn, "w")) == NULL)
106 while(input_avail || output_avail)
108 if (strm.avail_in == 0 && input_avail)
110 strm.avail_in = fread(in, 1, chunk, infp);
111 if (strm.avail_in != chunk)
113 strm.next_in = (uint8_t *)in;
116 if ((status = ae_encode(&strm, AE_NO_FLUSH)) != AE_OK)
118 fprintf(stderr, "error is %i\n", status);
122 if (strm.total_out - total_out > 0)
124 fwrite(out, strm.total_out - total_out, 1, outfp);
125 total_out = strm.total_out;
128 strm.avail_out = chunk;
137 if ((status = ae_encode(&strm, AE_FLUSH)) != AE_OK)
139 fprintf(stderr, "error is %i\n", status);
143 if (strm.total_out - total_out > 0)
145 fwrite(out, strm.total_out - total_out, 1, outfp);
148 ae_encode_end(&strm);