6 * Usage : decode [-3|4|5] [-a|u|l] < infile > outfile
13 * Unpack input codes and pass them back as bytes.
14 * Returns 1 if there is residual input, returns -1 if eof, else returns 0.
21 static unsigned int in_buffer = 0;
22 static int in_bits = 0;
23 unsigned char in_byte;
26 if (fread(&in_byte, sizeof (char), 1, stdin) != 1) {
30 in_buffer |= (in_byte << in_bits);
33 *code = in_buffer & ((1 << bits) - 1);
47 struct g72x_state state;
53 g72x_init_state(&state);
54 out_coding = AUDIO_ENCODING_ULAW;
55 out_size = sizeof (char);
56 dec_routine = g721_decoder;
59 /* Process encoding argument, if any */
60 while ((argc > 1) && (argv[1][0] == '-')) {
63 dec_routine = g723_24_decoder;
67 dec_routine = g721_decoder;
71 dec_routine = g723_40_decoder;
75 out_coding = AUDIO_ENCODING_ULAW;
76 out_size = sizeof (char);
79 out_coding = AUDIO_ENCODING_ALAW;
80 out_size = sizeof (char);
83 out_coding = AUDIO_ENCODING_LINEAR;
84 out_size = sizeof (short);
87 fprintf(stderr, "CCITT ADPCM Decoder -- usage:\n");
88 fprintf(stderr, "\tdecode [-3|4|5] [-a|u|l] < infile > outfile\n");
89 fprintf(stderr, "where:\n");
90 fprintf(stderr, "\t-3\tProcess G.723 24kbps (3-bit) input data\n");
91 fprintf(stderr, "\t-4\tProcess G.721 32kbps (4-bit) input data [default]\n");
92 fprintf(stderr, "\t-5\tProcess G.723 40kbps (5-bit) input data\n");
93 fprintf(stderr, "\t-a\tGenerate 8-bit A-law data\n");
94 fprintf(stderr, "\t-u\tGenerate 8-bit u-law data [default]\n");
95 fprintf(stderr, "\t-l\tGenerate 16-bit linear PCM data\n");
102 /* Read and unpack input codes and process them */
103 while (unpack_input(&code, dec_bits) >= 0) {
104 sample = (*dec_routine)(code, out_coding, &state);
106 fwrite(&sample, out_size, 1, stdout);
108 code = (unsigned char)sample;
109 fwrite(&code, out_size, 1, stdout);