TheoraEncoder Class Reference

Implementation of Adaptor that takes UncompressedVideoFrame as input and returns an CompressedVideoFrame as output. <short description="">. More...

#include <TheoraEncoder.hpp>

Inheritance diagram for TheoraEncoder:

VideoAdaptor Adaptor List of all members.

Public Member Functions

 TheoraEncoder (VideoESInfo *ves)
list< Frame * > adapt (Frame *frm)
 YUVFrame in - TheoraFrame out.
TheoraEncoderclone ()
 Create a shallow copy of the Adaptor.
void initialize ()
 Initialize internal data structures.
u32 getTranscodingCosts () const
 returns adaptation costs (CPU only) per second! For visual streams they are expressed in pixels/seconds.

Detailed Description

Implementation of Adaptor that takes UncompressedVideoFrame as input and returns an CompressedVideoFrame as output. <short description="">.

Author:
Thomas Kuglitsch
Version:
Id
TheoraEncoder.hpp,v 1.3 2006/10/25 07:29:10 tkuglits Exp

Definition at line 67 of file TheoraEncoder.hpp.


Member Function Documentation

list< Frame * > TheoraEncoder::adapt Frame frm  )  [virtual]
 

YUVFrame in - TheoraFrame out.

Input YUVFrame object will be deleted in this method! Adaptor implementation for YUVFrame objects.

Parameters:
*frm Pointer to YUVFrame object.
Returns:
List containing TheoraFrame objects.

Reimplemented from Adaptor.

Definition at line 83 of file TheoraEncoder.cpp.

References CompressedVideoFrame::detectFrameType(), Frame::getAU(), Frame::getMediaTimeScale(), Frame::setAU(), and Frame::setMediaTimeScale().

00083 { 00084 list <Frame *>frmList; 00085 ogg_packet *op; 00086 yuv_buffer *yuv; 00087 theora_info *ti; 00088 CompressedVideoFrame *theoraFrame; 00089 AU *pAU; 00090 00091 AU *au = frm->getAU(); 00092 op = new ogg_packet; 00093 yuv = new yuv_buffer; 00094 ti = OGGMuxDemuxIO::getTheoraInfo(); 00095 00096 dprintf_full("TheoraEncoder::adapt(%p)\n",frm); 00097 { 00098 yuv->y_width = ti->width; 00099 yuv->y_height = ti->height; 00100 yuv->y_stride = ti->width; 00101 00102 yuv->uv_width = ti->width / 2; 00103 yuv->uv_height = ti->height / 2; 00104 yuv->uv_stride = ti->width / 2; 00105 00106 yuv->y = au->payload; 00107 yuv->u = au->payload + ti->width * ti->height; 00108 yuv->v = au->payload + ti->width * ti->height * 5/4; 00109 } 00110 00111 double start_dtime, now_dtime; 00112 struct timeval now_tv; 00113 gettimeofday(&now_tv,NULL); 00114 start_dtime = now_tv.tv_sec + now_tv.tv_usec/1000000.0; 00115 00116 theora_encode_YUVin( OGGMuxDemuxIO::getTheoraState(), yuv); 00117 theora_encode_packetout(OGGMuxDemuxIO::getTheoraState(), 0, op); 00118 00119 int op_size = sizeof(ogg_packet); 00120 u8* op_copy = new u8[op_size + op->bytes]; 00121 00122 { 00123 ogg_packet *tmp = (ogg_packet*)op_copy; 00124 00125 // op_copy = (u8*)&op; 00126 // tmp->packet = op->packet; 00127 00128 memcpy(op_copy, op, op_size); 00129 tmp->packet = op_copy + op_size; 00130 memcpy(tmp->packet, op->packet, op->bytes); 00131 } 00132 00133 gettimeofday(&now_tv,NULL); 00134 now_dtime = now_tv.tv_sec + now_tv.tv_usec/1000000.0; 00135 00136 pAU = new AU(); 00137 pAU->payload = op_copy; 00138 pAU->size = op->bytes; 00139 00140 theoraFrame = new CompressedVideoFrame(Frame::UNKNOWN_VOP, ti->width, ti->height); 00141 theoraFrame->detectFrameType(); 00142 theoraFrame->setAU(pAU); 00143 theoraFrame->setMediaTimeScale(frm->getMediaTimeScale()); 00144 frmList.push_back(theoraFrame); 00145 00146 dprintf_full("TheoraEncoder::adapt(%p) %li bytes ... %u bytes in %2.0f sec\n",frm,op->bytes,au->size, (now_dtime-start_dtime)*1000.0); 00147 00148 return frmList; 00149 }

TheoraEncoder* TheoraEncoder::clone  )  [inline, virtual]
 

Create a shallow copy of the Adaptor.

Creates an Adaptor with the same setup (without copying the current status).

Returns:
An Adaptor object.

Implements Adaptor.

Definition at line 82 of file TheoraEncoder.hpp.

00082 { return NULL; };

u32 TheoraEncoder::getTranscodingCosts  )  const [inline, virtual]
 

returns adaptation costs (CPU only) per second! For visual streams they are expressed in pixels/seconds.

Call this only on INITIALIZED adaptors!!!! Otherwise costs will be way too high.

Implements Adaptor.

Definition at line 84 of file TheoraEncoder.hpp.

00084 { 00085 return 0; 00086 };

void TheoraEncoder::initialize  )  [virtual]
 

Initialize internal data structures.

Implements Adaptor.

Definition at line 151 of file TheoraEncoder.cpp.

00151 { 00152 00153 /* 00154 theora_encode_init(td, ti); 00155 theora_info_clear(ti); 00156 00157 // first, encode theora header 00158 //theora_encode_header(td, &op); 00159 00160 //VideoFrame *vf = new CompressedVideoFrame(FrameType t, int width, int height); 00161 VideoFrame *vf; 00162 vf = new CompressedVideoFrame(Frame::NN_VOP, frame_x, frame_y); 00163 // OGGMuxDemuxIO::writeFrame(Frame *frm, ESInfo *out_es = NULL); 00164 // OGGMuxDemuxIO::writeFrame(vf); 00165 initialized = true; 00166 */ 00167 }


The documentation for this class was generated from the following files: