[Tremor] Tremor API

Nikhil Patil nikhil at ee.iitb.ac.in
Mon Oct 25 01:09:55 PDT 2004


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


More information about the Tremor mailing list