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