<div>Dear Sir/Madam,</div>
<div> </div>
<div> 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> </div>
<div>1) theora_info_clear( &encoderInfo ); after theora_encode_init( &theoraState, &encoderInfo );</div>
<div>2) theora_decode_init( &theoraStateDec, &theoraInfo ); </div>
<div> </div>
<div> For problem 2, i find that all the calls to theora_decode_header are failed and it returns either -21 or -20.</div>
<div> </div>
<div> 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> </div>
<div>Thanks a lot</div>
<div>Pong<br> </div>
<div> </div>
<div>
<p>theora_info_init( &encoderInfo );<br> encoderInfo.frame_width = nFrameW; //INPUT_FRAME_WIDTH; // Must be multiple of 16<br> encoderInfo.frame_height = nFrameH; //INPUT_FRAME_HEIGHT; // Must be multiple of 16
<br> encoderInfo.width = encoderInfo.frame_width;<br> encoderInfo.height = encoderInfo.frame_height;<br> encoderInfo.offset_x = 0;<br> encoderInfo.offset_y = 0;<br> encoderInfo.fps_numerator
= 15;//INPUT_FRAMES_PER_SECOND;<br> encoderInfo.fps_denominator = 1;<br> encoderInfo.aspect_numerator = encoderInfo.width; // Aspect = width/height<br> encoderInfo.aspect_denominator = encoderInfo.height
; //<br> encoderInfo.colorspace = OC_CS_UNSPECIFIED;<br>// encoderInfo.target_bitrate = 90000; //45000; // Anywhere between 45kbps and 2000kbps<br>// encoderInfo.target_bitrate = 45000; //45000; // Anywhere between 45kbps and 2000kbps
<br> encoderInfo.target_bitrate = 45000; //45000; // Anywhere between 45kbps and 2000kbps<br> encoderInfo.quality = 10; <br> encoderInfo.dropframes_p = 0;<br> encoderInfo.quick_p = 1;
<br> encoderInfo.keyframe_auto_p = 1;<br> encoderInfo.keyframe_frequency = 64;<br> encoderInfo.keyframe_frequency_force = 64;<br> encoderInfo.keyframe_data_target_bitrate = encoderInfo.target_bitrate * 3 / 2;
<br> encoderInfo.keyframe_auto_threshold = 80;<br> encoderInfo.keyframe_mindistance = 8;<br> encoderInfo.noise_sensitivity = 1;<br> theora_encode_init( &theoraState, &encoderInfo );<br> theora_info_clear( &encoderInfo ); // i get a error here
<br> //<br> ogg_packet headerPacket, commentPacket, tablePacket;<br> theora_encode_header( &theoraState, &headerPacket );<br> // COPY_WRITE_OR_TRANSMIT_PACKET( headerPacket );<br> theora_comment_init( &encoderComment );
<br> theora_encode_comment( &encoderComment, &commentPacket );<br> // COPY_WRITE_OR_TRANSMIT_PACKET( commentPacket )<br> theora_comment_clear( &encoderComment );<br> theora_encode_tables( &theoraState, &tablePacket );
<br> // COPY_WRITE_OR_TRANSMIT_PACKET( tablePacket )<br> yuv.y_width = encoderInfo.width;<br> yuv.y_height = encoderInfo.height;<br> yuv.y_stride = encoderInfo.width;<br> yuv.y = pYBuff; // yBuffer;<br> yuv.uv_width
= nFrameW / 2; // INPUT_FRAME_WIDTH / 2;<br> yuv.uv_height = nFrameH / 2; // INPUT_FRAME_HEIGHT / 2;<br> yuv.uv_stride = yuv.uv_width;<br> yuv.u = pUBuff; // uBuffer; <br> yuv.v = pVBuff; // vBuffer;
</p>
<p> // DECODER INIT<br> theora_info_init( &theoraInfo );<br> theora_comment_init( &theoraComment ); </p>
<p> theora_decode_header( &theoraInfo, &theoraComment, &headerPacket );<br> theora_decode_header( &theoraInfo, &theoraComment, &commentPacket );<br> theora_decode_header( &theoraInfo, &theoraComment, &tablePacket );
</p>
<p> theora_decode_init( &theoraStateDec, &theoraInfo ); // i get an error here as the calls to theora_decode_header are all failed</p></div>