Debian Codegraph @

Xpjproject/pjmedia/src/test/vectors/swapendian.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #include <stdio.h>
20
21 int main(int argc, char *argv[])
22 {
23 FILE *in, *out;
24 char frm[2];
25 unsigned count;
26
27 if (argc != 3) {
28 puts("Usage: swapendian input.pcm OUTPUT.PCM");
29 return 1;
30 }
31
32 in = fopen(argv[1], "rb");
33 if (!in) {
34 puts("Open error");
35 return 1;
36 }
37
38 out = fopen(argv[2], "wb");
39 if (!out) {
40 puts("Open error");
41 fclose(in);
42 return 1;
43 }
44
45 count = 0;
46 for (;;) {
47 char tmp;
48
49 if (fread(frm, 2, 1, in) != 1)
50 break;
51
52 tmp = frm[0];
53 frm[0] = frm[1];
54 frm[1] = tmp;
55
56 if (fwrite(frm, 2, 1, out) != 1) {
57 puts("Write error");
58 break;
59 }
60
61 ++count;
62 }
63
64 printf("%d samples converted\n", count);
65
66 fclose(in);
67 fclose(out);
68
69 return 0;
70 }
71
72