Julius 4.2
libsent/src/util/endian.c
説明を見る。
00001 
00018 /*
00019  * Copyright (c) 1991-2011 Kawahara Lab., Kyoto University
00020  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00021  * Copyright (c) 2005-2011 Julius project team, Nagoya Institute of Technology
00022  * All rights reserved
00023  */
00024 
00025 #include <sent/stddefs.h>
00026 
00034 void
00035 swap_bytes(char *buf, size_t unitbyte, size_t unitnum)
00036 {
00037   char *p, c;
00038   int i, j;
00039 
00040   p = buf;
00041   while (unitnum > 0) {
00042     i=0; j=unitbyte-1;
00043     while(i<j) {
00044       c = p[i]; p[i] = p[j]; p[j] = c;
00045       i++;j--;
00046     }
00047     p += unitbyte;
00048     unitnum--;
00049   }
00050 }
00051 
00058 void
00059 swap_sample_bytes(SP16 *buf, int len)
00060 {
00061   char *p;
00062   char t;
00063   int i;
00064   
00065   p = (char *)buf;
00066 
00067   for (i=0;i<len;i++) {
00068     t = *p;
00069     *p = *(p + 1);
00070     *(p + 1) = t;
00071     p += 2;
00072   }
00073 }