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