paul griffiths
2008-Mar-31 11:08 UTC
[Vorbis] Problem creating ogg comment header for theatrical/stage/disco lighting stream
Hi, I am creating a new ogg stream for theatrical/stage/disco lighting and am having trouble encoding my comment header with the following code in _tp_writelsbint function, it does not write the second byte to the ogg buffer. I am using windows and have created a new win32 library project with visual studio and added my code, what do i have to do to get the function working? Is there a project preset I have to change? or something else? I can manualy add to ogg buffer like oggpackB_write(opb, 55, 8) ok, so it's not the buffer that's the problem but the part where it's bit-shifting the second line in the function. I have taken the code from Theora library as it's closer to using libogg2 than vorbis library. Vorbis is working ok in my application but have yet to include theora. Is it my library or my application using my library that is the problem? Thanks for your time. Paul. www.avacodec.com - Audio Video Atmosphere http://www.ableton.com/forum/viewtopic.php?t=71817&postdays=0&postorder=asc&start=75 static void _tp_writelsbint(oggpack_buffer *opb, long value) { oggpackB_write(opb, value&0xFF, 8); // writes to ogg buffer ok oggpackB_write(opb, value>>8&0xFF, 8); // does not write to ogg buffer oggpackB_write(opb, value>>16&0xFF, 8); oggpackB_write(opb, value>>24&0xFF, 8); } /* build the comment header packet from the passed metadata */ int libava_encode_comment(libava_state *t, libava_comment *tc, ogg_packet *op) { const char *vendor = libava_version_string(); const int vendor_length = strlen(vendor); CP_INSTANCE *cpi=(CP_INSTANCE *)(t->internal_encode); #ifndef LIBOGG2 oggpackB_reset(cpi->oggbuffer); #else oggpackB_writeinit(cpi->oggbuffer, cpi->oggbufferstate); #endif oggpackB_write(cpi->oggbuffer, 0x81, 8); _tp_writebuffer(cpi->oggbuffer, "libava", 6); _tp_writelsbint(cpi->oggbuffer, vendor_length); _tp_writebuffer(cpi->oggbuffer, vendor, vendor_length); _tp_writelsbint(cpi->oggbuffer, tc->comments); if(tc->comments){ int i; for(i=0;i<tc->comments;i++){ if(tc->user_comments[i]){ _tp_writelsbint(cpi->oggbuffer,tc->comment_lengths[i]); _tp_writebuffer(cpi->oggbuffer,tc->user_comments[i],tc->comment_lengths[i]); }else{ oggpackB_write(cpi->oggbuffer,0,32); } } } #ifndef LIBOGG2 op->packet=oggpackB_get_buffer(cpi->oggbuffer); #else op->packet=oggpackB_writebuffer(cpi->oggbuffer); #endif op->bytes=oggpackB_bytes(cpi->oggbuffer); op->b_o_s=0; op->e_o_s=0; op->packetno=0; op->granulepos=0; return (0); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/vorbis/attachments/20080331/480d42c9/attachment.htm
xiphmont at xiph.org
2008-Mar-31 17:08 UTC
[Vorbis] Problem creating ogg comment header for theatrical/stage/disco lighting stream
On Mon, Mar 31, 2008 at 7:08 AM, paul griffiths <avalightingstudio at googlemail.com> wrote:> > > I have taken the code from Theora library as > it's closer to using libogg2 than vorbis library. Vorbis is working ok in my > application but have yet to include theora. Is it my library or my > application using my library that is the problem?Libogg2 was an experiment that hasn't been released because of a number of API changes that need to be made. There's nothing wrong with the code in it, but you shouldn't use it because I can pretty much guarantee it the API will change in the future. When libogg2 finally does see the official light of day, it will support the complete libogg1 namespace and behavior. So, code to libogg1. As for 'it doesn't write the second byte', how are you checking? Libogg2 uses fragmented linked buffers internally they can be tricky to inspect. Also, you can write all 32 bits at a time, you don't need to break it up into byte writes; if you really want to write in little endian order, use the non-'B' versions of the calls. Monty