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, "scb:B:R:J:")) != -1)
37 strm.bit_per_sample = atoi(optarg);
40 strm.block_size = atoi(optarg);
43 strm.rsi = atoi(optarg);
49 strm.flags |= AE_DATA_SIGNED;
53 fprintf (stderr, "Option -%c requires an argument.\n", optopt);
54 else if (isprint (optopt))
55 fprintf (stderr, "Unknown option `-%c'.\n", optopt);
58 "Unknown option character `\\x%x'.\n",
71 fprintf(stderr, "Usage: %s [ -c ] [ -b chunksize ] name\n", argv[0]);
75 out = (uint8_t *)malloc(chunk);
76 in = (uint8_t *)malloc(chunk);
79 if (in == NULL || out == NULL)
82 if (ae_encode_init(&strm) != AE_OK)
87 strm.avail_out = chunk;
93 if ((infp = fopen(infn, "r")) == NULL)
102 outfn = malloc(strlen(infn) + 4);
106 sprintf(outfn, "%s.aee", infn);
108 if ((outfp = fopen(outfn, "w")) == NULL)
112 while(input_avail || output_avail)
114 if (strm.avail_in == 0 && input_avail)
116 strm.avail_in = fread(in, 1, chunk, infp);
117 if (strm.avail_in != chunk)
119 strm.next_in = (uint8_t *)in;
122 if ((status = ae_encode(&strm, AE_NO_FLUSH)) != AE_OK)
124 fprintf(stderr, "error is %i\n", status);
128 if (strm.total_out - total_out > 0)
130 fwrite(out, strm.total_out - total_out, 1, outfp);
131 total_out = strm.total_out;
134 strm.avail_out = chunk;
143 if ((status = ae_encode(&strm, AE_FLUSH)) != AE_OK)
145 fprintf(stderr, "error is %i\n", status);
149 if (strm.total_out - total_out > 0)
151 fwrite(out, strm.total_out - total_out, 1, outfp);
154 ae_encode_end(&strm);