I recently used libtheora 1.1.1, and tried to assemble a test function for both encode and decode. I got an error when using theora_decode_header(), just as the problem described in the article titled with "problem in using libtheora in vc++"(You can google this article).
After research, I found a solution for the problem. The problem is actually because the places for theora_decode_header() is not correct. The theora_decode_header() should be right after related theora_encode_xxx()(including theora_encode_header(), theora_encode_comment(), theora_encode_tables()). So if use the correct order for theora_decode_header(), it will execute successfully.
The order should be like this:
...
ogg_packet headerPacket, commentPacket, tablePacket;
theora_encode_header( &theoraState, &headerPacket );
theora_decode_header( &theoraInfo, &theoraComment, &headerPacket );
// COPY_WRITE_OR_TRANSMIT_PACKET( headerPacket );
theora_comment_init( &encoderComment );
theora_decode_header( &theoraInfo, &theoraComment, &commentPacket );
theora_encode_comment( &encoderComment, &commentPacket );
theora_comment_clear( &encoderComment );
// COPY_WRITE_OR_TRANSMIT_PACKET( commentPacket )
theora_encode_tables( &theoraState, &tablePacket );
theora_decode_header( &theoraInfo, &theoraComment, &tablePacket );
// COPY_WRITE_OR_TRANSMIT_PACKET( tablePacket )
theora_decode_init( &theoraStateDec, &theoraInfo );
...
阅读(672) | 评论(0) | 转发(0) |