I'm trying to encode a picture from my webcam using the theora codec. The final "product" must encode a frame, send it over the network and decode it on "the other side". For now, it must only work locally so we don't care about the transmission. This is what I've understood till now: I have a char * buffer from the camera RG24,I convert it to YCbCr 4:4:4, I encode it, resulting an ogg_packet. Then I provide this ogg_packet to the decoder, get the YCbCr buffer , convert it back to RGB24 then display it. Now the questions: I have a Codec class with a function encoderInitialize(), where I initialize the encoder, filling a th_info structure with the image's properties, fps, aspect ratio, colorspace, quality and pixel_fmt. Then I allocate a th_enc_ctx handle and repeatedly call th_encode_flushheader(). Do I have to save this header packets? Do i have to provide this header packets to the decoder when I initialize it? Because the documentation says /Parse the header packets by repeatedly calling th_decode_headerin(). Thank you,/ -- Mircea Gliga -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/theora/attachments/20091125/5c95eb4f/attachment.htm
2009/11/25 Mircea Gliga <mgliga at integrasoft.ro>:> [...] Then I allocate a th_enc_ctx handle and repeatedly call > th_encode_flushheader(). > Do I have to save this header packets? Do i have to provide this header > packets to the decoder when I > initialize it? Because the documentation says Parse the header packets by > repeatedly calling > th_decode_headerin().Yes, you have to pass the headers into the decoder to configure it to correctly parse the data packets. -r
I've created a test class with an encoder and decoder. I'm creating the theora headers and immediately add them to the decoder. For the first 2 packets th_decode_headerin returns positive nr, at the 3rd packet returns TH_EBADHEADER. Am I aloud to do that? I'm not using ogg_stream_packetin. I just want to encode a picture, resulting an ogg_packet, then decode it on the client side... ogg_packet op; th_enc_ctx *td; th_comment tc,tc1; th_info theoraInfo,theoraInfo1; th_setup_info *ts1; for(;;) { int ret = th_encode_flushheader(td,&tc,&op); int ret2 = th_decode_headerin(&theoraInfo1,&tc1,&ts1,&op); if(0==ret) break; } What am i doing wrong here ? Mircea Gliga Mircea Gliga wrote:> > > Mircea Gliga > > > > Ralph Giles wrote: >> 2009/11/25 Mircea Gliga <mgliga at integrasoft.ro>: >> >> >>> [...] Then I allocate a th_enc_ctx handle and repeatedly call >>> th_encode_flushheader(). >>> Do I have to save this header packets? Do i have to provide this header >>> packets to the decoder when I >>> initialize it? Because the documentation says Parse the header packets by >>> repeatedly calling >>> th_decode_headerin(). >>> >> >> Yes, you have to pass the headers into the decoder to configure it to >> correctly parse the data packets. >> >> -r >> >>-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/theora/attachments/20091126/feb9629f/attachment.htm