<div>Dear Sir/Madam,</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I am trying to use Theora in VC++ as i think Theora is a very good codec. However, when i implement the encoding and decoding parts, i get an unexpected error when i call:</div>
<div>&nbsp;</div>
<div>1) theora_info_clear( &amp;encoderInfo ); after theora_encode_init( &amp;theoraState, &amp;encoderInfo );</div>
<div>2)&nbsp;theora_decode_init( &amp;theoraStateDec, &amp;theoraInfo ); </div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For problem 2, i find that all the calls to theora_decode_header are failed and it returns either -21 or -20.</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The following is the code that i am trying. Would you please have a look and see what is going wrong with me?</div>
<div>&nbsp;</div>
<div>Thanks a lot</div>
<div>Pong<br>&nbsp;</div>
<div>&nbsp;</div>
<div>
<p>theora_info_init( &amp;encoderInfo );<br>&nbsp;&nbsp;encoderInfo.frame_width&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= nFrameW; //INPUT_FRAME_WIDTH;&nbsp; // Must be multiple of 16<br>&nbsp;&nbsp;encoderInfo.frame_height&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= nFrameH; //INPUT_FRAME_HEIGHT; // Must be multiple of 16
<br>&nbsp;&nbsp;encoderInfo.width&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= encoderInfo.frame_width;<br>&nbsp;&nbsp;encoderInfo.height&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= encoderInfo.frame_height;<br>&nbsp;&nbsp;encoderInfo.offset_x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= 0;<br>&nbsp;&nbsp;encoderInfo.offset_y&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= 0;<br>&nbsp;&nbsp;encoderInfo.fps_numerator
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= 15;//INPUT_FRAMES_PER_SECOND;<br>&nbsp;&nbsp;encoderInfo.fps_denominator&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= 1;<br>&nbsp;&nbsp;encoderInfo.aspect_numerator&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= encoderInfo.width;&nbsp; // Aspect =&nbsp; width/height<br>&nbsp;&nbsp;encoderInfo.aspect_denominator&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= encoderInfo.height
; //<br>&nbsp;&nbsp;encoderInfo.colorspace&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= OC_CS_UNSPECIFIED;<br>//&nbsp;&nbsp;encoderInfo.target_bitrate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= 90000; //45000; // Anywhere between 45kbps and 2000kbps<br>//&nbsp;&nbsp;encoderInfo.target_bitrate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= 45000; //45000; // Anywhere between 45kbps and 2000kbps
<br>&nbsp;&nbsp;encoderInfo.target_bitrate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= 45000; //45000; // Anywhere between 45kbps and 2000kbps<br>&nbsp;&nbsp;encoderInfo.quality&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;= 10; <br>&nbsp;&nbsp;encoderInfo.dropframes_p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= 0;<br>&nbsp;&nbsp;encoderInfo.quick_p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= 1;
<br>&nbsp;&nbsp;encoderInfo.keyframe_auto_p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= 1;<br>&nbsp;&nbsp;encoderInfo.keyframe_frequency&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= 64;<br>&nbsp;&nbsp;encoderInfo.keyframe_frequency_force&nbsp;&nbsp;&nbsp;= 64;<br>&nbsp;&nbsp;encoderInfo.keyframe_data_target_bitrate&nbsp;= encoderInfo.target_bitrate * 3 / 2;
<br>&nbsp;&nbsp;encoderInfo.keyframe_auto_threshold&nbsp;&nbsp;&nbsp;&nbsp;= 80;<br>&nbsp;&nbsp;encoderInfo.keyframe_mindistance&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= 8;<br>&nbsp;&nbsp;encoderInfo.noise_sensitivity&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= 1;<br>&nbsp;&nbsp;theora_encode_init( &amp;theoraState, &amp;encoderInfo );<br>&nbsp;&nbsp;theora_info_clear( &amp;encoderInfo ); // i get a error here
<br>&nbsp;&nbsp;//<br>&nbsp;&nbsp;ogg_packet headerPacket, commentPacket, tablePacket;<br>&nbsp;&nbsp;theora_encode_header( &amp;theoraState, &amp;headerPacket );<br>&nbsp;//&nbsp;COPY_WRITE_OR_TRANSMIT_PACKET( headerPacket );<br>&nbsp;&nbsp;theora_comment_init( &amp;encoderComment );
<br>&nbsp;&nbsp;theora_encode_comment( &amp;encoderComment, &amp;commentPacket );<br>&nbsp;//&nbsp;COPY_WRITE_OR_TRANSMIT_PACKET( commentPacket )<br>&nbsp;&nbsp;theora_comment_clear( &amp;encoderComment );<br>&nbsp;&nbsp;theora_encode_tables( &amp;theoraState, &amp;tablePacket );
<br>&nbsp;//&nbsp;COPY_WRITE_OR_TRANSMIT_PACKET( tablePacket )<br>&nbsp;&nbsp;yuv.y_width&nbsp;&nbsp; = encoderInfo.width;<br>&nbsp;&nbsp;yuv.y_height&nbsp; = encoderInfo.height;<br>&nbsp;&nbsp;yuv.y_stride&nbsp; = encoderInfo.width;<br>&nbsp;&nbsp;yuv.y&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = pYBuff; // yBuffer;<br>&nbsp;&nbsp;yuv.uv_width
&nbsp; = nFrameW / 2; // INPUT_FRAME_WIDTH / 2;<br>&nbsp;&nbsp;yuv.uv_height = nFrameH / 2; // INPUT_FRAME_HEIGHT / 2;<br>&nbsp;&nbsp;yuv.uv_stride = yuv.uv_width;<br>&nbsp;&nbsp;yuv.u&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = pUBuff; // uBuffer; <br>&nbsp;&nbsp;yuv.v&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = pVBuff; // vBuffer; 
</p>
<p>&nbsp;&nbsp;// DECODER INIT<br>&nbsp;&nbsp;theora_info_init( &amp;theoraInfo );<br>&nbsp;&nbsp;theora_comment_init( &amp;theoraComment );&nbsp;</p>
<p>&nbsp;&nbsp;theora_decode_header( &amp;theoraInfo, &amp;theoraComment, &amp;headerPacket );<br>&nbsp;&nbsp;theora_decode_header( &amp;theoraInfo, &amp;theoraComment, &amp;commentPacket );<br>&nbsp;&nbsp;theora_decode_header( &amp;theoraInfo, &amp;theoraComment, &amp;tablePacket );
</p>
<p>&nbsp;&nbsp;theora_decode_init( &amp;theoraStateDec, &amp;theoraInfo ); // i get an error here as the calls to theora_decode_header are all failed</p></div>