comparison music2/koedec_ogg.cc @ 65:4416cfac86ae

Convert EUC-JP files to UTF8
author Thibaut Girka <thib@sitedethib.com>
date Fri, 26 Nov 2010 10:53:15 +0100
parents 15a18fbe6f21
children
comparison
equal deleted inserted replaced
64:045ca45f9610 65:4416cfac86ae
70 FILE* stream; 70 FILE* stream;
71 int length; 71 int length;
72 int offset; 72 int offset;
73 }; 73 };
74 74
75 /* ogg stream 読み込み用の dummy callback */ 75 /* ogg stream 茯粋昭睡 dummy callback */
76 static size_t ogg_readfunc(void* ptr, size_t size, size_t nmemb, void* datasource) { 76 static size_t ogg_readfunc(void* ptr, size_t size, size_t nmemb, void* datasource) {
77 OggInfo* info = (OggInfo*)datasource; 77 OggInfo* info = (OggInfo*)datasource;
78 int pt = ftell(info->stream) - info->offset; 78 int pt = ftell(info->stream) - info->offset;
79 if (pt+size*nmemb > info->length) { 79 if (pt+size*nmemb > info->length) {
80 nmemb = (info->length-pt) / size; 80 nmemb = (info->length-pt) / size;
108 return fseek(f, off, whence); 108 return fseek(f, off, whence);
109 } 109 }
110 110
111 extern char* decode_koe_ogg(AvgKoeInfo info, int* dest_len) { 111 extern char* decode_koe_ogg(AvgKoeInfo info, int* dest_len) {
112 if (info.stream == NULL) return NULL; 112 if (info.stream == NULL) return NULL;
113 // Voice ファイルを直接指定すると全ストリームを再生してしまうので 113 // Voice <ゃ贋・絎鴻若障
114 // 必要な部分だけ切り出して callback 経由で帰す 114 // 綽荀冴 callback 腟宴у鍵
115 fseek(info.stream, info.offset, SEEK_SET); 115 fseek(info.stream, info.offset, SEEK_SET);
116 116
117 ov_callbacks callback; 117 ov_callbacks callback;
118 callback.read_func = &ogg_readfunc; 118 callback.read_func = &ogg_readfunc;
119 callback.seek_func = &ogg_seekfunc; 119 callback.seek_func = &ogg_seekfunc;
149 cur += r; 149 cur += r;
150 if (cur_size-INITSIZE/4 < cur) Resize(); 150 if (cur_size-INITSIZE/4 < cur) Resize();
151 } while(1); 151 } while(1);
152 ov_clear(&vf); 152 ov_clear(&vf);
153 153
154 *dest_len = cur; // うまくコンバートできてるのかなあ…… 154 *dest_len = cur; // 障潟潟若с
155 const char* header = MakeWavHeader(info.rate, channels, 2, cur); 155 const char* header = MakeWavHeader(info.rate, channels, 2, cur);
156 memcpy(out, header, 0x2c); 156 memcpy(out, header, 0x2c);
157 157
158 char* ret = out; 158 char* ret = out;
159 out = NULL; 159 out = NULL;