<DIV>Thanks! </DIV>
<DIV> </DIV>
<DIV>But assumes that a vorbis packet covers two input buffer, will errors happen? Or packet miss?</DIV>
<DIV>></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Hi,</DIV>
<DIV>You need ov_open_callbacks().<BR>My hack around this is to create the functions given below.</DIV>
<DIV>ov_callbacks cb = { vread, vseek, vclose, vtell };<BR>ov_open_callbacks((void *) 0x12345678, &vf, NULL, 0, cb);</DIV>
<DIV>This implementation is merely a hack. I hope it helps you though :)<BR>-Nikhil</DIV>
<DIV>static unsigned char src[] = {<BR> /* data here */<BR>};</DIV>
<DIV>static unsigned char *current = src;<BR>static unsigned char *src_end = src + sizeof(src);</DIV>
<DIV>static size_t vread(void *ptr, size_t size, size_t n, void *datasource)<BR>{<BR> /* hack: this function is always called with size = 1 */<BR> if (n > src_end - current)<BR> n = src_end - current;<BR> memcpy(ptr, current, n);<BR> current += n;<BR> //fprintf(stderr, "vread: size: %d, nmemb: %d -> ret: %d\n", size, nmemb<BR> return n;<BR>}</DIV>
<DIV>static int vseek(void *datasource, ogg_int64_t offset, int whence)<BR>{<BR> //fprintf(stderr, "vseek: %d whence: %d\n", offset, whence);<BR> switch (whence) {<BR> case SEEK_END:<BR> current = src_end - 1 - offset;<BR> break;<BR> case SEEK_CUR:<BR> current += offset;<BR> break;<BR> case SEEK_SET:<BR> current = src +
offset;<BR> break;<BR> default:<BR> return -1;<BR> }<BR> return 0;<BR>}</DIV>
<DIV>static int vclose(void *datasource)<BR>{<BR> //fprintf(stderr, "vclose\n");<BR> return 0;<BR>}</DIV>
<DIV>static long vtell(void *datasource)<BR>{<BR> //fprintf(stderr, "vtell\n");<BR> return (current - src);<BR>}</DIV>
<DIV><BR>On Mon, Oct 25, 2004 at 03:42:09PM +0800, Gavin Chen wrote:<BR>> Hi all,<BR>> <BR>> I am ready to port the Tremor low-mem branch to my portable device.<BR>> <BR>> But for some restriction, I have to use an input buffer as a input parameter to the OGG deccoder.<BR>> <BR>> For example,<BR>> <BR>> char pBuf[1024];<BR>> short pPCM[x];<BR>> FILE *pFile = fopen(xxxx);<BR>> pBuf <---- fread(pFile), read 1k file content in binary mode;<BR>> pPCM <----- OGG_Decoder(pBuf), Decode the ogg buffer to PCM data;<BR>> output PCM;<BR>> <BR>> But, current Tremor uses ov_open and ov_read to implement the decode process. <BR>> Can anyone give me some advices? Or anyone realized this?Thanks! <BR>> <BR>> <BR>> <BR>> <BR>> ---------------------------------<BR>> Do You Yahoo!?<BR>> 150????MP3????????????????????????<BR>> ??????????????????????????????????????<BR>>
1G????1000?????????????????????<BR>> _______________________________________________<BR>> Tremor mailing list<BR>> <A href="mailto:Tremor@xiph.org">Tremor@xiph.org</A><BR>> <A href="http://lists.xiph.org/mailman/listinfo/tremor">http://lists.xiph.org/mailman/listinfo/tremor</A></DIV>
<DIV>-- <BR>My skin is soapy, and my hair is wet,<BR>and Tegrin spelled backward is Nirget :D<BR>_______________________________________________<BR>Tremor mailing list<BR><A href="mailto:Tremor@xiph.org">Tremor@xiph.org</A><BR><A href="http://lists.xiph.org/mailman/listinfo/tremor">http://lists.xiph.org/mailman/listinfo/tremor</A><BR></DIV><p><br><hr size=1><b>Do You Yahoo!?</b><br>
<a href="http://music.yisou.com" target=blank>150万曲MP3疯狂搜,带您闯入音乐殿堂</a><br><a href="http://image.yisou.com" target=blank>美女明星应有尽有,搜遍美图、艳图和酷图</a><br>
<a href="http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/" target=blank>1G就是1000兆,雅虎电邮自助扩容!</a>