aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kvilib/CMakeLists.txt3
-rw-r--r--src/kvilib/ext/KviOggTheoraDecoder.cpp339
-rw-r--r--src/kvilib/ext/KviOggTheoraDecoder.h128
-rw-r--r--src/kvilib/ext/KviOggTheoraEncoder.cpp (renamed from src/kvilib/ext/KviTheoraDecoder.cpp)333
-rw-r--r--src/kvilib/ext/KviOggTheoraEncoder.h140
-rw-r--r--src/kvilib/ext/KviOggTheoraGeometry.h53
-rw-r--r--src/kvilib/ext/KviTheoraDecoder.h253
-rw-r--r--src/modules/dcc/codec.cpp6
-rw-r--r--src/modules/dcc/codec.h10
9 files changed, 689 insertions, 576 deletions
diff --git a/src/kvilib/CMakeLists.txt b/src/kvilib/CMakeLists.txt
index b63d7c3c6..98271a4ab 100644
--- a/src/kvilib/CMakeLists.txt
+++ b/src/kvilib/CMakeLists.txt
@@ -146,7 +146,8 @@ ENDIF()
IF(NOT DEFINED COMPILE_DISABLE_OGG_THEORA)
LIST(APPEND kvilib_SRCS
- ext/KviTheoraDecoder.cpp
+ ext/KviOggTheoraDecoder.cpp
+ ext/KviOggTheoraEncoder.cpp
)
ENDIF()
diff --git a/src/kvilib/ext/KviOggTheoraDecoder.cpp b/src/kvilib/ext/KviOggTheoraDecoder.cpp
new file mode 100644
index 000000000..8262c7abb
--- /dev/null
+++ b/src/kvilib/ext/KviOggTheoraDecoder.cpp
@@ -0,0 +1,339 @@
+//=============================================================================
+//
+// File : KviTheoraDecoder.cpp
+// Creation date : Sat Nov 21 2009 22:53:21 CEST by Fabio Bas
+//
+// This file is part of the KVIrc irc client distribution
+// Copyright (C) 2009 Fabio Bas (ctrlaltca at libero dot it)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// Based on the example encoder/player from Xiph.Org Foundation:
+//=============================================================================
+//
+// function: example encoder application; makes an Ogg Theora/Vorbis
+// file from YUV4MPEG2 and WAV input
+// last mod: $Id: encoder_example.c 16517 2009-08-25 19:48:57Z giles $
+//
+//=============================================================================
+//
+// function: example SDL player application; plays Ogg Theora files (with
+// optional Vorbis audio second stream)
+// last mod: $Id: player_example.c 16628 2009-10-10 05:50:52Z gmaxwell $
+//
+//=============================================================================
+
+#ifndef COMPILE_DISABLE_OGG_THEORA
+
+#include <string.h>
+#include <sys/time.h>
+
+#include "KviMemory.h"
+#include "KviOggTheoraDecoder.h"
+#include "KviOggIrcText.h"
+#include "KviDataBuffer.h"
+
+using namespace KviOggIrcText;
+
+
+
+
+
+
+//------------------------------------------------------------------------------
+#define OC_CLAMP255(_x) ((unsigned char)((((_x)<0)-1)&((_x)|-((_x)>255))))
+
+KviTheoraDecoder::KviTheoraDecoder(KviDataBuffer * videoSignal,KviDataBuffer * textSignal)
+{
+ m_pVideoSignal=videoSignal;
+ m_pTextSignal=textSignal;
+ theora_p=0;
+ stateflag=0;
+ ts=NULL;
+ thda=false;
+ thtic=false;
+
+ irct_p=0;
+
+ /* single frame video buffering */
+ videobuf_ready=0;
+ videobuf_granulepos=-1;
+ videobuf_time=0;
+
+ /* start up Ogg stream synchronization layer */
+ ogg_sync_init(&oy);
+
+ /* init supporting Theora structures needed in header parsing */
+ th_comment_init(&tc);
+ th_info_init(&ti);
+
+ for(int i=0;i<256;i++)
+ {
+ lu_Y[i] = 2441889*(i- 16) + 1048576;
+ lu_R[i] = 3347111*(i-128);
+ lu_GV[i] = -1704917*(i-128);
+ lu_GU[i] = -821585*(i-128);
+ lu_B[i] = 4230442*(i-128);
+ }
+}
+
+KviTheoraDecoder::~KviTheoraDecoder()
+{
+ if(theora_p){
+ ogg_stream_clear(&to);
+ th_decode_free(td);
+ th_comment_clear(&tc);
+ th_info_clear(&ti);
+ }
+
+ if(irct_p)
+ {
+ ogg_stream_clear(&zo);
+ irct_encode_clear();
+ }
+
+ ogg_sync_clear(&oy);
+}
+
+void KviTheoraDecoder::addData(KviDataBuffer * stream)
+{
+// qDebug("adddata signal %p stream size %d",m_pVideoSignal, stream->size() );
+ if(stream->size()==0)return;
+ /* Ogg file open; parse the headers */
+
+ if(!stateflag)
+ {
+
+ char *buffer=ogg_sync_buffer(&oy,stream->size());
+ memcpy(buffer,stream->data(),stream->size());
+ ogg_sync_wrote(&oy,stream->size());
+ stream->clear();
+
+ while(ogg_sync_pageout(&oy,&og)>0)
+ {
+ ogg_stream_state test;
+
+ /* is this a mandated initial header? If not, stop parsing */
+ if(!ogg_page_bos(&og))
+ {
+ /* don't leak the page; get it into the appropriate stream */
+// qDebug("queue_page && return");
+ queue_page(&og);
+ stateflag=1;
+ return;
+ }
+
+ ogg_stream_init(&test,ogg_page_serialno(&og));
+ ogg_stream_pagein(&test,&og);
+ ogg_stream_packetout(&test,&op);
+
+
+ /* identify the codec: try theora */
+ if(!theora_p && th_decode_headerin(&ti,&tc,&ts,&op)>=0){
+ qDebug("is theora, ts=%p &ts=%p",ts, &ts);
+ /* it is theora */
+ memcpy(&to,&test,sizeof(test));
+ theora_p=1;
+ }else if(!irct_p && irct_decode_headerin(&op)>=0){
+ qDebug("is irct");
+ /* it is irct */
+ memcpy(&zo,&test,sizeof(test));
+ irct_p=1;
+ }else{
+// qDebug("is other");
+ /* whatever it is, we don't care about it */
+ ogg_stream_clear(&test);
+ }
+ }
+ /* fall through to non-bos page parsing */
+ }
+
+// qDebug("checkpoint 2, theora_p=%d ",theora_p);
+ /* we're expecting more header packets. */
+ if((theora_p && theora_p<3))
+ {
+ int ret;
+
+ /* look for further theora headers */
+ while(theora_p && (theora_p<3) && (ret=ogg_stream_packetout(&to,&op)))
+ {
+ if(ret<0){
+ qDebug("Error parsing Theora stream headers; corrupt stream?");
+ return;
+ }
+ if(!th_decode_headerin(&ti,&tc,&ts,&op)){
+ qDebug("Error parsing Theora stream headers; corrupt stream?");
+ return;
+ }
+ theora_p++;
+ }
+
+ /* The header pages/packets will arrive before anything else we
+ care about, or the stream is not obeying spec */
+ if(ogg_sync_pageout(&oy,&og)>0)
+ {
+ qDebug("queue_page");
+ queue_page(&og); /* demux into the appropriate stream */
+ } else {
+ qDebug("TheoraDecoder: need more data!");
+ //need more data
+ return;
+ }
+ }
+
+// qDebug("checkpoint 3");
+ /* and now we have it all. initialize decoders */
+ if(theora_p && !thda)
+ {
+ thda=true;
+ td=th_decode_alloc(&ti,ts);
+ qDebug("Ogg logical stream %lx is Theora %dx%d %.02f fps",
+ to.serialno,ti.pic_width,ti.pic_height,
+ (double)ti.fps_numerator/ti.fps_denominator);
+
+ geometry.pic_w = ti.pic_width;
+ geometry.pic_h = ti.pic_height;
+ geometry.frame_w = ti.frame_width;
+ geometry.frame_h = ti.frame_height;
+ geometry.pic_x = ti.pic_x;
+ geometry.pic_y = ti.pic_y;
+
+ px_fmt=ti.pixel_fmt;
+ switch(ti.pixel_fmt)
+ {
+ case TH_PF_444: qDebug(" 4:4:4 video"); break;
+ default:
+ qDebug(" video (UNSUPPORTED Chroma sampling!)");
+ return;
+ break;
+ }
+ th_decode_ctl(td,TH_DECCTL_GET_PPLEVEL_MAX,&pp_level_max,sizeof(pp_level_max));
+ pp_level=pp_level_max;
+ th_decode_ctl(td,TH_DECCTL_SET_PPLEVEL,&pp_level,sizeof(pp_level));
+ pp_inc=0;
+
+ int w = ((ti.pic_x + ti.pic_width + 1) &~ 1) - (ti.pic_x &~ 1);
+ int h = ((ti.pic_y + ti.pic_height + 1) &~ 1) - (ti.pic_y &~ 1);
+ RGBbuffer = (unsigned char *) calloc(sizeof(char), w * h * 4);
+ } else if(!thtic)
+ {
+ thtic=true;
+ /* tear down the partial theora setup */
+ th_info_clear(&ti);
+ th_comment_clear(&tc);
+
+ th_setup_free(ts);
+ }
+// stateflag=0; /* playback has not begun */
+
+ if(irct_p)
+ {
+ if(ogg_stream_packetout(&zo,&op)>0)
+ {
+ char * textPkt=0;
+ int textSize=0;
+ if(irct_decode_packetin(&textPkt, &textSize, &op)==0)
+ {
+ m_pTextSignal->append((unsigned char *)textPkt, textSize);
+ }
+ }
+ }
+
+ if(theora_p && !videobuf_ready)
+ {
+ if(stream->size()>0)
+ {
+ char *buffer=ogg_sync_buffer(&oy,stream->size());
+ memcpy(buffer,stream->data(),stream->size());
+ ogg_sync_wrote(&oy,stream->size());
+ stream->clear();
+
+ while(ogg_sync_pageout(&oy,&og)>0)
+ queue_page(&og);
+ }
+// qDebug("loop4 theora_p=%d videobuf_ready=%d",theora_p, videobuf_ready);
+ // theora is one in, one out...
+
+ if(ogg_stream_packetout(&to,&op)>0)
+ {
+ if(th_decode_packetin(td,&op,&videobuf_granulepos)==0)
+ videobuf_ready=1;
+ } else {
+// qDebug("ogg_stream_packetout <=0");
+ //need more data :)
+ return;
+ }
+ }
+
+ if(!videobuf_ready)return;
+
+
+ if(stateflag && videobuf_ready)
+ {
+ video_write();
+ videobuf_ready=0;
+ }
+
+ // if our buffers either don't exist or are ready to go,we can begin playback
+ if(!theora_p || videobuf_ready)stateflag=1;
+}
+
+/* helper: push a page into the appropriate steam */
+/* this can be done blindly; a stream won't accept a page
+ that doesn't belong to it */
+int KviTheoraDecoder::queue_page(ogg_page *page)
+{
+ if(theora_p)ogg_stream_pagein(&to,page);
+ if(irct_p)ogg_stream_pagein(&zo,page);
+ return 0;
+}
+
+void KviTheoraDecoder::video_write(void)
+{
+ th_ycbcr_buffer yuv;
+ int y_offset;
+ th_decode_ycbcr_out(td,yuv);
+
+ y_offset=(geometry.pic_x&~1)+yuv[0].stride*(geometry.pic_y&~1);
+
+ for(int i=0;i<geometry.pic_h;i++)
+ {
+ unsigned char *in_y = (unsigned char *)yuv[0].data+y_offset+yuv[0].stride*i;
+ unsigned char *in_u = (unsigned char *)yuv[1].data+y_offset+yuv[1].stride*i;
+ unsigned char *in_v = (unsigned char *)yuv[2].data+y_offset+yuv[2].stride*i;
+ unsigned char *out = RGBbuffer+(geometry.pic_w * i * ARGB32_BPP);
+ for (int j=0;j<geometry.pic_w;j++)
+ {
+ int r, g, b;
+ int y = lu_Y[in_y[j]];
+ b=(y + lu_B[in_u[j]])>>21;
+ out[j*4] = OC_CLAMP255(b);
+ g=(y + lu_GV[in_v[j]] + lu_GU[in_u[j]])>>21;
+ out[j*4+1] = OC_CLAMP255(g);
+ r=(y + lu_R[in_v[j]])>>21;
+ out[j*4+2] = OC_CLAMP255(r);
+ out[j*4+3] = 255; //alpha
+ }
+
+ }
+
+ int size = sizeof(char) * geometry.pic_w * geometry.pic_h * ARGB32_BPP;
+
+// qDebug("VIDEO WRITE size=%d",size);
+ m_pVideoSignal->clear();
+ m_pVideoSignal->append(RGBbuffer, size);
+}
+
+#endif // COMPILE_DISABLE_OGG_THEORA \ No newline at end of file
diff --git a/src/kvilib/ext/KviOggTheoraDecoder.h b/src/kvilib/ext/KviOggTheoraDecoder.h
new file mode 100644
index 000000000..1e5016c72
--- /dev/null
+++ b/src/kvilib/ext/KviOggTheoraDecoder.h
@@ -0,0 +1,128 @@
+#ifndef _KVI_OGGTHEORADECODER_H_
+#define _KVI_OGGTHEORADECODER_H_
+//=============================================================================
+//
+// File : KviOggTheoraDecoder.h
+// Creation date : Sat Nov 21 2009 22:53:21 CEST by Fabio Bas
+//
+// This file is part of the KVIrc irc client distribution
+// Copyright (C) 2009 Fabio Bas (ctrlaltca at libero dot it)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+/**
+* \file KviOggTheoraDecoder.h
+* \author Fabio Bas
+* \brief Contains the KviOggTheoraDecoder class
+*/
+
+#ifndef COMPILE_DISABLE_OGG_THEORA
+
+#include "kvi_settings.h"
+#include "KviOggTheoraGeometry.h"
+
+#include "theora/theoradec.h"
+
+/**
+* \def ARGB32_BPP Bytes per pixel in an ARGB32 image
+*/
+#define ARGB32_BPP 4
+
+class KviDataBuffer;
+
+
+/**
+* \class KviTheoraDecoder
+* \brief An ogg/theora+irct decoder class; accepts a proper ogg stream, outputs argb32 images and binary text
+*/
+class KVILIB_API KviTheoraDecoder
+{
+public:
+ /**
+ * \brief Constructs the KviTheoraDecoder object
+ * \param videoSignal the output video stream object
+ * \param textSignal the output text stream object
+ * \return KviTheoraDecoder
+ */
+ KviTheoraDecoder(KviDataBuffer * videoSignal,KviDataBuffer * textSignal);
+
+ /**
+ * \brief Destroys the KviTheoraEncoder object
+ */
+ virtual ~KviTheoraDecoder();
+
+ /**
+ * \brief Feeds the decoded with some received data to decode
+ * \param stream the databuffer containing the received data
+ * \return void
+ */
+ void addData(KviDataBuffer * stream);
+private:
+ KviDataBuffer * m_pVideoSignal; /**< Output video stream pointer */
+ KviDataBuffer * m_pTextSignal; /**< Output text stream pointer */
+ KviOggTheoraGeometry geometry; /**< Stream geometry definition */
+ unsigned char * RGBbuffer; /**< RGB decoded surface pointer */
+
+ // Ogg and codec state for demux/decode
+ ogg_sync_state oy;
+ ogg_packet op; /**< One raw packet of encoded data */
+ ogg_page og; /**< One Ogg bitstream page. Vorbis packets are inside */
+ ogg_stream_state to; /**< Take physical pages, weld into a logical stream of theora packets */
+ ogg_stream_state zo; /**< Take physical pages, weld into a logical stream of irct packets */
+
+ th_info ti; /**< Theora stream info struct */
+ th_comment tc; /**< Theora stream comments struct */
+ th_dec_ctx * td; /**< Theora stream decoding struct */
+ th_setup_info * ts; /**< Theora stream setup info struct */
+ th_pixel_fmt px_fmt; /**< Theora stream pixel format definition */
+
+ int theora_p; /**< True if the ogg stream contains a theora stream */
+ int irct_p; /**< True if the ogg stream contains an irct stream */
+ int stateflag; /**< Internal flag used in stream processing */
+
+ int lu_Y[256]; /**< Surface used in yuv->rgb processing (Y) */
+ int lu_R[256]; /**< Surface used in yuv->rgb processing (R) */
+ int lu_GU[256]; /**< Surface used in yuv->rgb processing (GU) */
+ int lu_GV[256]; /**< Surface used in yuv->rgb processing (GV) */
+ int lu_B[256]; /**< Surface used in yuv->rgb processing (B) */
+
+ // Single frame video buffering
+ int videobuf_ready; /**< Single frame video buffering : ready state */
+ ogg_int64_t videobuf_granulepos; /**< Single frame video buffering : granule position */
+ double videobuf_time; /**< Single frame video buffering : duration */
+
+ int pp_level_max; /**< Theora postprocessing: max level */
+ int pp_level; /**< Theora postprocessing: current level */
+ int pp_inc; /**< Theora postprocessing: increment */
+
+ bool thda; /**< Theora decode alloc state */
+ bool thtic; /**< Theora setup clear state */
+private:
+ /**
+ * \brief Internal function that queues an ogg page to the codec decoders
+ * \return int
+ */
+ int queue_page(ogg_page *page);
+ /**
+ * \brief Internal function that takes a theora yuv buffer, transforms it and appends to the video stream
+ * \return int
+ */
+ void video_write(void);
+};
+
+#endif // COMPILE_DISABLE_OGG_THEORA
+#endif // KVI_OGGTHEORADECODER_H_
diff --git a/src/kvilib/ext/KviTheoraDecoder.cpp b/src/kvilib/ext/KviOggTheoraEncoder.cpp
index 999dc892a..e508de56c 100644
--- a/src/kvilib/ext/KviTheoraDecoder.cpp
+++ b/src/kvilib/ext/KviOggTheoraEncoder.cpp
@@ -1,10 +1,10 @@
//=============================================================================
//
-// File : KviTheoraDecoder.cpp
-// Creation date : Sat Nov 21 2009 22:53:21 CEST by Fabio Bas
+// File : KviOggTheoraEncoder.cpp
+// Creation date : Wed Dec 29 2010 15:51:21 CEST by Elvio Basello
//
// This file is part of the KVIrc irc client distribution
-// Copyright (C) 2009 Fabio Bas (ctrlaltca at libero dot it)
+// Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com)
//
// This program is FREE software. You can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -20,34 +20,19 @@
// along with this program. If not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
-// Based on the example encoder/player from Xiph.Org Foundation:
-//=============================================================================
-//
-// function: example encoder application; makes an Ogg Theora/Vorbis
-// file from YUV4MPEG2 and WAV input
-// last mod: $Id: encoder_example.c 16517 2009-08-25 19:48:57Z giles $
-//
-//=============================================================================
-//
-// function: example SDL player application; plays Ogg Theora files (with
-// optional Vorbis audio second stream)
-// last mod: $Id: player_example.c 16628 2009-10-10 05:50:52Z gmaxwell $
-//
//=============================================================================
#ifndef COMPILE_DISABLE_OGG_THEORA
-#include <string.h>
+#include "KviMemory.h"
+#include "KviOggTheoraEncoder.h"
+#include "KviOggIrcText.h"
+#include "KviDataBuffer.h"
+
#include <stdlib.h>
#include <time.h>
-#include <sys/time.h>
#include <math.h>
-#include "KviTheoraDecoder.h"
-#include "KviOggIrcText.h"
-
-#include "KviDataBuffer.h"
-
using namespace KviOggIrcText;
static void rgb32toyuv444(QRgb * rgbPt, unsigned char *yuvPt, int w, int h)
@@ -64,7 +49,8 @@ static void rgb32toyuv444(QRgb * rgbPt, unsigned char *yuvPt, int w, int h)
return;
}
-KviTheoraEncoder::KviTheoraEncoder(KviDataBuffer * stream, int iWidth, int iHeight, int iFpsN, int iFpsD, int iParN, int iParD)
+
+KviOggTheoraEncoder::KviOggTheoraEncoder(KviDataBuffer * stream, int iWidth, int iHeight, int iFpsN, int iFpsD, int iParN, int iParD)
{
//used to check functions results
int ret;
@@ -211,7 +197,7 @@ KviTheoraEncoder::KviTheoraEncoder(KviDataBuffer * stream, int iWidth, int iHeig
}
}
-KviTheoraEncoder::~KviTheoraEncoder()
+KviOggTheoraEncoder::~KviOggTheoraEncoder()
{
// Call th_encode_free() to release all encoder memory.
th_encode_free(td);
@@ -224,7 +210,7 @@ KviTheoraEncoder::~KviTheoraEncoder()
irct_encode_clear();
}
-void KviTheoraEncoder::addVideoFrame(QRgb * rgb32, int)
+void KviOggTheoraEncoder::addVideoFrame(QRgb * rgb32, int)
{
/*
* For each uncompressed frame:
@@ -254,7 +240,7 @@ void KviTheoraEncoder::addVideoFrame(QRgb * rgb32, int)
videoflag=0;
}
-void KviTheoraEncoder::addTextFrame(unsigned char* textPkt, int textSize)
+void KviOggTheoraEncoder::addTextFrame(unsigned char* textPkt, int textSize)
{
ogg_page textpage;
ogg_packet op;
@@ -274,7 +260,7 @@ void KviTheoraEncoder::addTextFrame(unsigned char* textPkt, int textSize)
textflag=0;
}
-int KviTheoraEncoder::fetch_and_process_video_packet(quint8 * videoYuv,th_enc_ctx *td,ogg_packet *op)
+int KviOggTheoraEncoder::fetch_and_process_video_packet(quint8 * videoYuv,th_enc_ctx *td,ogg_packet *op)
{
th_ycbcr_buffer ycbcr;
@@ -340,7 +326,7 @@ int KviTheoraEncoder::fetch_and_process_video_packet(quint8 * videoYuv,th_enc_ct
return th_encode_packetout(td,frame_state<1,op);
}
-int KviTheoraEncoder::fetch_and_process_video(quint8 * videoYuv,ogg_page *videopage,
+int KviOggTheoraEncoder::fetch_and_process_video(quint8 * videoYuv,ogg_page *videopage,
ogg_stream_state *to,th_enc_ctx *td,int videoflag)
{
ogg_packet op;
@@ -358,296 +344,11 @@ ogg_stream_state *to,th_enc_ctx *td,int videoflag)
return videoflag;
}
-int KviTheoraEncoder::ilog(unsigned _v)
+int KviOggTheoraEncoder::ilog(unsigned _v)
{
int ret;
for(ret=0;_v;ret++)_v>>=1;
return ret;
}
-
-//------------------------------------------------------------------------------
-#define OC_CLAMP255(_x) ((unsigned char)((((_x)<0)-1)&((_x)|-((_x)>255))))
-
-KviTheoraDecoder::KviTheoraDecoder(KviDataBuffer * videoSignal,KviDataBuffer * textSignal)
-{
- m_pVideoSignal=videoSignal;
- m_pTextSignal=textSignal;
- theora_p=0;
- stateflag=0;
- ts=NULL;
- thda=false;
- thtic=false;
-
- irct_p=0;
-
- /* single frame video buffering */
- videobuf_ready=0;
- videobuf_granulepos=-1;
- videobuf_time=0;
-
- /* start up Ogg stream synchronization layer */
- ogg_sync_init(&oy);
-
- /* init supporting Theora structures needed in header parsing */
- th_comment_init(&tc);
- th_info_init(&ti);
-
- for(int i=0;i<256;i++)
- {
- lu_Y[i] = 2441889*(i- 16) + 1048576;
- lu_R[i] = 3347111*(i-128);
- lu_GV[i] = -1704917*(i-128);
- lu_GU[i] = -821585*(i-128);
- lu_B[i] = 4230442*(i-128);
- }
-}
-
-KviTheoraDecoder::~KviTheoraDecoder()
-{
- if(theora_p){
- ogg_stream_clear(&to);
- th_decode_free(td);
- th_comment_clear(&tc);
- th_info_clear(&ti);
- }
-
- if(irct_p)
- {
- ogg_stream_clear(&zo);
- irct_encode_clear();
- }
-
- ogg_sync_clear(&oy);
-}
-
-void KviTheoraDecoder::addData(KviDataBuffer * stream)
-{
-// qDebug("adddata signal %p stream size %d",m_pVideoSignal, stream->size() );
- if(stream->size()==0)return;
- /* Ogg file open; parse the headers */
-
- if(!stateflag)
- {
-
- char *buffer=ogg_sync_buffer(&oy,stream->size());
- memcpy(buffer,stream->data(),stream->size());
- ogg_sync_wrote(&oy,stream->size());
- stream->clear();
-
- while(ogg_sync_pageout(&oy,&og)>0)
- {
- ogg_stream_state test;
-
- /* is this a mandated initial header? If not, stop parsing */
- if(!ogg_page_bos(&og))
- {
- /* don't leak the page; get it into the appropriate stream */
-// qDebug("queue_page && return");
- queue_page(&og);
- stateflag=1;
- return;
- }
-
- ogg_stream_init(&test,ogg_page_serialno(&og));
- ogg_stream_pagein(&test,&og);
- ogg_stream_packetout(&test,&op);
-
-
- /* identify the codec: try theora */
- if(!theora_p && th_decode_headerin(&ti,&tc,&ts,&op)>=0){
- qDebug("is theora, ts=%p &ts=%p",ts, &ts);
- /* it is theora */
- memcpy(&to,&test,sizeof(test));
- theora_p=1;
- }else if(!irct_p && irct_decode_headerin(&op)>=0){
- qDebug("is irct");
- /* it is irct */
- memcpy(&zo,&test,sizeof(test));
- irct_p=1;
- }else{
-// qDebug("is other");
- /* whatever it is, we don't care about it */
- ogg_stream_clear(&test);
- }
- }
- /* fall through to non-bos page parsing */
- }
-
-// qDebug("checkpoint 2, theora_p=%d ",theora_p);
- /* we're expecting more header packets. */
- if((theora_p && theora_p<3))
- {
- int ret;
-
- /* look for further theora headers */
- while(theora_p && (theora_p<3) && (ret=ogg_stream_packetout(&to,&op)))
- {
- if(ret<0){
- qDebug("Error parsing Theora stream headers; corrupt stream?");
- return;
- }
- if(!th_decode_headerin(&ti,&tc,&ts,&op)){
- qDebug("Error parsing Theora stream headers; corrupt stream?");
- return;
- }
- theora_p++;
- }
-
- /* The header pages/packets will arrive before anything else we
- care about, or the stream is not obeying spec */
- if(ogg_sync_pageout(&oy,&og)>0)
- {
- qDebug("queue_page");
- queue_page(&og); /* demux into the appropriate stream */
- } else {
- qDebug("TheoraDecoder: need more data!");
- //need more data
- return;
- }
- }
-
-// qDebug("checkpoint 3");
- /* and now we have it all. initialize decoders */
- if(theora_p && !thda)
- {
- thda=true;
- td=th_decode_alloc(&ti,ts);
- qDebug("Ogg logical stream %lx is Theora %dx%d %.02f fps",
- to.serialno,ti.pic_width,ti.pic_height,
- (double)ti.fps_numerator/ti.fps_denominator);
-
- geometry.pic_w = ti.pic_width;
- geometry.pic_h = ti.pic_height;
- geometry.frame_w = ti.frame_width;
- geometry.frame_h = ti.frame_height;
- geometry.pic_x = ti.pic_x;
- geometry.pic_y = ti.pic_y;
-
- px_fmt=ti.pixel_fmt;
- switch(ti.pixel_fmt)
- {
- case TH_PF_444: qDebug(" 4:4:4 video"); break;
- default:
- qDebug(" video (UNSUPPORTED Chroma sampling!)");
- return;
- break;
- }
- th_decode_ctl(td,TH_DECCTL_GET_PPLEVEL_MAX,&pp_level_max,sizeof(pp_level_max));
- pp_level=pp_level_max;
- th_decode_ctl(td,TH_DECCTL_SET_PPLEVEL,&pp_level,sizeof(pp_level));
- pp_inc=0;
-
- int w = ((ti.pic_x + ti.pic_width + 1) &~ 1) - (ti.pic_x &~ 1);
- int h = ((ti.pic_y + ti.pic_height + 1) &~ 1) - (ti.pic_y &~ 1);
- RGBbuffer = (unsigned char *) calloc(sizeof(char), w * h * 4);
- } else if(!thtic)
- {
- thtic=true;
- /* tear down the partial theora setup */
- th_info_clear(&ti);
- th_comment_clear(&tc);
-
- th_setup_free(ts);
- }
-// stateflag=0; /* playback has not begun */
-
- if(irct_p)
- {
- if(ogg_stream_packetout(&zo,&op)>0)
- {
- char * textPkt=0;
- int textSize=0;
- if(irct_decode_packetin(&textPkt, &textSize, &op)==0)
- {
- m_pTextSignal->append((unsigned char *)textPkt, textSize);
- }
- }
- }
-
- if(theora_p && !videobuf_ready)
- {
- if(stream->size()>0)
- {
- char *buffer=ogg_sync_buffer(&oy,stream->size());
- memcpy(buffer,stream->data(),stream->size());
- ogg_sync_wrote(&oy,stream->size());
- stream->clear();
-
- while(ogg_sync_pageout(&oy,&og)>0)
- queue_page(&og);
- }
-// qDebug("loop4 theora_p=%d videobuf_ready=%d",theora_p, videobuf_ready);
- // theora is one in, one out...
-
- if(ogg_stream_packetout(&to,&op)>0)
- {
- if(th_decode_packetin(td,&op,&videobuf_granulepos)==0)
- videobuf_ready=1;
- } else {
-// qDebug("ogg_stream_packetout <=0");
- //need more data :)
- return;
- }
- }
-
- if(!videobuf_ready)return;
-
-
- if(stateflag && videobuf_ready)
- {
- video_write();
- videobuf_ready=0;
- }
-
- // if our buffers either don't exist or are ready to go,we can begin playback
- if(!theora_p || videobuf_ready)stateflag=1;
-}
-
-/* helper: push a page into the appropriate steam */
-/* this can be done blindly; a stream won't accept a page
- that doesn't belong to it */
-int KviTheoraDecoder::queue_page(ogg_page *page)
-{
- if(theora_p)ogg_stream_pagein(&to,page);
- if(irct_p)ogg_stream_pagein(&zo,page);
- return 0;
-}
-
-void KviTheoraDecoder::video_write(void)
-{
- th_ycbcr_buffer yuv;
- int y_offset;
- th_decode_ycbcr_out(td,yuv);
-
- y_offset=(geometry.pic_x&~1)+yuv[0].stride*(geometry.pic_y&~1);
-
- for(int i=0;i<geometry.pic_h;i++)
- {
- unsigned char *in_y = (unsigned char *)yuv[0].data+y_offset+yuv[0].stride*i;
- unsigned char *in_u = (unsigned char *)yuv[1].data+y_offset+yuv[1].stride*i;
- unsigned char *in_v = (unsigned char *)yuv[2].data+y_offset+yuv[2].stride*i;
- unsigned char *out = RGBbuffer+(geometry.pic_w * i * ARGB32_BPP);
- for (int j=0;j<geometry.pic_w;j++)
- {
- int r, g, b;
- int y = lu_Y[in_y[j]];
- b=(y + lu_B[in_u[j]])>>21;
- out[j*4] = OC_CLAMP255(b);
- g=(y + lu_GV[in_v[j]] + lu_GU[in_u[j]])>>21;
- out[j*4+1] = OC_CLAMP255(g);
- r=(y + lu_R[in_v[j]])>>21;
- out[j*4+2] = OC_CLAMP255(r);
- out[j*4+3] = 255; //alpha
- }
-
- }
-
- int size = sizeof(char) * geometry.pic_w * geometry.pic_h * ARGB32_BPP;
-
-// qDebug("VIDEO WRITE size=%d",size);
- m_pVideoSignal->clear();
- m_pVideoSignal->append(RGBbuffer, size);
-}
-
-#endif // COMPILE_DISABLE_OGG_THEORA \ No newline at end of file
+#endif // COMPILE_DISABLE_OGG_THEORA
diff --git a/src/kvilib/ext/KviOggTheoraEncoder.h b/src/kvilib/ext/KviOggTheoraEncoder.h
new file mode 100644
index 000000000..f28ea8bff
--- /dev/null
+++ b/src/kvilib/ext/KviOggTheoraEncoder.h
@@ -0,0 +1,140 @@
+#ifndef _KVIOGGTHEORAENCODER_H_
+#define _KVIOGGTHEORAENCODER_H_
+
+//=============================================================================
+//
+// File : KviOggTheoraEncoder.h
+// Creation date : Wed Dec 29 2010 15:51:21 CEST by Elvio Basello
+//
+// This file is part of the KVIrc irc client distribution
+// Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+/**
+* \file KviOggTheoraEncoder.h
+* \author Elvio Basello
+* \brief Contains the KviOggTheoraEncoder class
+*
+* This file was originally part of KviOggTheoraDecoder.h
+*/
+
+#ifndef COMPILE_DISABLE_OGG_THEORA
+
+#include "kvi_settings.h"
+#include "KviOggTheoraGeometry.h"
+
+#include "theora/theoraenc.h"
+
+#include <QColor>
+
+class KviDataBuffer;
+
+/**
+* \def YUV444_BPP Bytes per pixel in a YUV444 image
+*/
+#define YUV444_BPP 3
+
+
+/**
+* \class KviOggTheoraEncoder
+* \brief An ogg/theora+irct encoder class; accepts argb32 images and binary text, outputs an ogg stream
+*/
+class KVILIB_API KviOggTheoraEncoder
+{
+public:
+ /**
+ * \brief Constructs the KviOggTheoraEncoder object
+ * \param stream the output stream object
+ * \param iWidth width of the stream
+ * \param iHeight height of the stream
+ * \param iFpsN frames per second: numerator
+ * \param iFpsD frames per second: denominator
+ * \param iParN aspect ratio: numerator
+ * \param iParD aspect ratio: denominator
+ * \return KviOggTheoraEncoder
+ */
+ KviOggTheoraEncoder(KviDataBuffer * stream, int iWidth=320, int iHeight=240, int iFpsN=5, int iFpsD=1, int iParN=4, int iParD=3);
+
+ /**
+ * \brief Destroys the KviOggTheoraEncoder object
+ */
+ virtual ~KviOggTheoraEncoder();
+private:
+ KviOggTheoraGeometry geometry; /**< Stream geometry definition */
+ KviDataBuffer * m_pStream; /**< Stream pointer */
+ quint8 * videoYuv; /**< Yuv encoded surface pointer */
+
+ ogg_int64_t text_sofar; /**< Number of transmitted text frames */
+
+ int frame_state; /**< Internal flag used in video frame processing */
+ unsigned char * yuvframe[3]; /**< Internal struct used in video frame processing */
+
+ size_t y4m_dst_buf_sz; /**< The size of each converted frame buffer */
+ size_t y4m_dst_buf_read_sz; /**< The amount to read directly into the converted frame buffer */
+ size_t y4m_aux_buf_sz; /**< The size of the auxilliary buffer */
+ size_t y4m_aux_buf_read_sz; /**< The amount to read into the auxilliary buffer */
+
+ ogg_stream_state zo; /**< Take physical pages, weld into a logical stream of irct packets */
+ ogg_stream_state to; /**< Take physical pages, weld into a logical stream of theora packets */
+ ogg_page og; /**< One Ogg bitstream page. Vorbis packets are inside */
+ ogg_packet op; /**< One raw packet of encoded data */
+
+ th_enc_ctx * td; /**< Theora stream encoding struct */
+ th_info ti; /**< Theora stream info struct */
+ th_comment tc; /**< Theora stream comments struct */
+
+ int textflag; /**< Internal flag used in text frame processing */
+ int videoflag; /**< Internal flag used in video frame processing */
+public:
+ /**
+ * \brief Appends a video frame to the stream
+ * \param rgb32 video frame as a matrix of rgb32 pixels
+ * \param videoSize size of the video frame
+ * \return void
+ */
+ void addVideoFrame(QRgb * rgb32, int videoSize);
+
+ /**
+ * \brief Appends a text frame to the stream
+ * \param textPkt buffer containing the text
+ * \param textSize size of the text buffer
+ * \return void
+ */
+ void addTextFrame(unsigned char* textPkt, int textSize);
+private:
+ /**
+ * \brief Internal function that processes a video frame to create an ogg page
+ * \return int
+ */
+ int fetch_and_process_video(quint8 * videoYuv,ogg_page *videopage,ogg_stream_state *to,th_enc_ctx *td,int videoflag);
+
+ /**
+ * \brief Internal function that processes a video frame to create an ogg packet
+ * \return int
+ */
+ int fetch_and_process_video_packet(quint8 * videoYuv,th_enc_ctx *td,ogg_packet *op);
+
+ /**
+ * \brief Internal function used to calculate our granule shift
+ * \return int
+ */
+ static int ilog(unsigned _v);
+};
+
+#endif // COMPILE_DISABLE_OGG_THEORA
+#endif // _KVIOGGTHEORAENCODER_H_
diff --git a/src/kvilib/ext/KviOggTheoraGeometry.h b/src/kvilib/ext/KviOggTheoraGeometry.h
new file mode 100644
index 000000000..410a8d23c
--- /dev/null
+++ b/src/kvilib/ext/KviOggTheoraGeometry.h
@@ -0,0 +1,53 @@
+#ifndef _KVIOGGTHEORAGEOMETRY_H_
+#define _KVIOGGTHEORAGEOMETRY_H_
+
+//=============================================================================
+//
+// File : KviOggTheoraGeometry.h
+// Creation date : Wed Dec 29 2010 15:51:21 CEST by Elvio Basello
+//
+// This file is part of the KVIrc irc client distribution
+// Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+/**
+* \file KviOggTheoraGeometry.h
+* \author Elvio Basello
+* \brief This file was originally part of KviTheoraDecoder.h
+*/
+
+#ifndef COMPILE_DISABLE_OGG_THEORA
+
+/**
+* \typedef KviOggTheoraGeometry
+* \brief Contains all the needed geometry information of a theora video stream
+*/
+typedef struct _KviOggTheoraGeometry
+{
+ int pic_w; /**< width of original picture geometry, chosen by the user */
+ int pic_h; /**< height of original picture geometry, chosen by the user */
+
+ int frame_w; /**< width of the picture frame (calculated geometry) */
+ int frame_h; /**< height of the picture frame (calculated geometry) */
+
+ int pic_x; /**< x offset of the picture inside the frame (calculated geometry) */
+ int pic_y; /**< y offset of the picture inside the frame (calculated geometry) */
+} KviOggTheoraGeometry;
+
+#endif // COMPILE_DISABLE_OGG_THEORA
+#endif // _KVIOGGTHEORAGEOMETRY_H_
diff --git a/src/kvilib/ext/KviTheoraDecoder.h b/src/kvilib/ext/KviTheoraDecoder.h
deleted file mode 100644
index 32c5d3e53..000000000
--- a/src/kvilib/ext/KviTheoraDecoder.h
+++ /dev/null
@@ -1,253 +0,0 @@
-#ifndef KVI_OGGTHEORA_H_
-#define KVI_OGGTHEORA_H_
-//=============================================================================
-//
-// File : KviTheoraDecoder.h
-// Creation date : Sat Nov 21 2009 22:53:21 CEST by Fabio Bas
-//
-// This file is part of the KVIrc irc client distribution
-// Copyright (C) 2009 Fabio Bas (ctrlaltca at libero dot it)
-//
-// This program is FREE software. You can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your opinion) any later version.
-//
-// This program is distributed in the HOPE that it will be USEFUL,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-// See the GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, write to the Free Software Foundation,
-// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-//=============================================================================
-
-/**
-* \file KviTheoraDecoder.h
-* \author Fabio Bas
-* \brief Contains the KviTheoraEncoder and KviTheoraDecoder classes;
-*/
-
-#ifndef COMPILE_DISABLE_OGG_THEORA
-
-#include "kvi_settings.h"
-#include "KviMemory.h"
-
-#include "theora/theoradec.h"
-#include "theora/theoraenc.h"
-
-#include <QColor>
-
-/**
-* \def OC_MINI simple minimum function
-*/
-#define OC_MINI(_a,_b) ((_a)>(_b)?(_b):(_a))
-/**
-* \def OC_MINI simple maximum function
-*/
-#define OC_MAXI(_a,_b) ((_a)<(_b)?(_b):(_a))
-/**
-* \def OC_MINI simple clamp function
-*/
-#define OC_CLAMPI(_a,_b,_c) (OC_MAXI(_a,OC_MINI(_b,_c)))
-
-/**
-* \def YUV444_BPP bytes per pixel in a YUV444 image
-*/
-#define YUV444_BPP 3
-/**
-* \def ARGB32_BPP bytes per pixel in an ARGB32 image
-*/
-#define ARGB32_BPP 4
-
-class KviDataBuffer;
-
-/**
-* \struct KviTheoraGeometry
-* \brief Contains all the needed geometry information of a theora video stream
-*/
-
-typedef struct _KviTheoraGeometry
-{
- int pic_w; /**< width of original picture geometry, chosen by the user */
- int pic_h; /**< height of original picture geometry, chosen by the user */
-
- int frame_w; /**< width of the picture frame (calculated geometry) */
- int frame_h; /**< height of the picture frame (calculated geometry) */
-
- int pic_x; /**< x offset of the picture inside the frame (calculated geometry) */
- int pic_y; /**< y offset of the picture inside the frame (calculated geometry) */
-} KviTheoraGeometry;
-
-
-
-/**
-* \class KviTheoraEncoder
-* \brief An ogg/theora+irct encoder class; accepts argb32 images and binary text, outputs an ogg stream
-*/
-class KVILIB_API KviTheoraEncoder
-{
-public:
- /**
- * \brief Constructs the KviTheoraEncoder object
- * \param stream the output stream object
- * \param iWidth width of the stream
- * \param iHeight height of the stream
- * \param iFpsN frames per second: numerator
- * \param iFpsD frames per second: denominator
- * \param iParN aspect ratio: numerator
- * \param iParD aspect ratio: denominator
- * \return KviTheoraEncoder
- */
- KviTheoraEncoder(KviDataBuffer * stream, int iWidth=320, int iHeight=240, int iFpsN=5, int iFpsD=1, int iParN=4, int iParD=3);
-
- /**
- * \brief Destroys the KviTheoraEncoder object
- */
- virtual ~KviTheoraEncoder();
-private:
- KviTheoraGeometry geometry; /**< Stream geometry definition */
- KviDataBuffer * m_pStream; /**< Stream pointer */
- quint8 * videoYuv; /**< Yuv encoded surface pointer */
-
- ogg_int64_t text_sofar; /**< Number of transmitted text frames */
-
- int frame_state; /**< Internal flag used in video frame processing */
- unsigned char * yuvframe[3]; /**< Internal struct used in video frame processing */
-
- size_t y4m_dst_buf_sz; /**< The size of each converted frame buffer */
- size_t y4m_dst_buf_read_sz;/**< The amount to read directly into the converted frame buffer */
- size_t y4m_aux_buf_sz; /**< The size of the auxilliary buffer */
- size_t y4m_aux_buf_read_sz;/**< The amount to read into the auxilliary buffer */
-
- ogg_stream_state zo; /**< Take physical pages, weld into a logical stream of irct packets */
- ogg_stream_state to; /**< Take physical pages, weld into a logical stream of theora packets */
- ogg_page og; /**< One Ogg bitstream page. Vorbis packets are inside */
- ogg_packet op; /**< One raw packet of encoded data */
-
- th_enc_ctx * td; /**< Theora stream encoding struct */
- th_info ti; /**< Theora stream info struct */
- th_comment tc; /**< Theora stream comments struct */
-
- int textflag; /**< Internal flag used in text frame processing */
- int videoflag; /**< Internal flag used in video frame processing */
-public:
- /**
- * \brief Appends a video frame to the stream
- * \param rgb32 video frame as a matrix of rgb32 pixels
- * \param videoSize size of the video frame
- * \return void
- */
- void addVideoFrame(QRgb * rgb32, int videoSize);
-
- /**
- * \brief Appends a text frame to the stream
- * \param textPkt buffer containing the text
- * \param textSize size of the text buffer
- * \return void
- */
- void addTextFrame(unsigned char* textPkt, int textSize);
-private:
- /**
- * \brief Internal function that processes a video frame to create an ogg page
- * \return int
- */
- int fetch_and_process_video(quint8 * videoYuv,ogg_page *videopage,ogg_stream_state *to,th_enc_ctx *td,int videoflag);
-
- /**
- * \brief Internal function that processes a video frame to create an ogg packet
- * \return int
- */
- int fetch_and_process_video_packet(quint8 * videoYuv,th_enc_ctx *td,ogg_packet *op);
-
- /**
- * \brief Internal function used to calculate our granule shift
- * \return int
- */
- static int ilog(unsigned _v);
-};
-
-/**
-* \class KviTheoraDecoder
-* \brief An ogg/theora+irct decoder class; accepts a proper ogg stream, outputs argb32 images and binary text
-*/
-
-class KVILIB_API KviTheoraDecoder
-{
-public:
- /**
- * \brief Constructs the KviTheoraDecoder object
- * \param videoSignal the output video stream object
- * \param textSignal the output text stream object
- * \return KviTheoraDecoder
- */
- KviTheoraDecoder(KviDataBuffer * videoSignal,KviDataBuffer * textSignal);
-
- /**
- * \brief Destroys the KviTheoraEncoder object
- */
- virtual ~KviTheoraDecoder();
-
- /**
- * \brief Feeds the decoded with some received data to decode
- * \param stream the databuffer containing the received data
- * \return void
- */
- void addData(KviDataBuffer * stream);
-private:
- KviDataBuffer * m_pVideoSignal; /**< Output video stream pointer */
- KviDataBuffer * m_pTextSignal; /**< Output text stream pointer */
- KviTheoraGeometry geometry; /**< Stream geometry definition */
- unsigned char * RGBbuffer; /**< RGB decoded surface pointer */
-
- // Ogg and codec state for demux/decode
- ogg_sync_state oy;
- ogg_packet op; /**< One raw packet of encoded data */
- ogg_page og; /**< One Ogg bitstream page. Vorbis packets are inside */
- ogg_stream_state to; /**< Take physical pages, weld into a logical stream of theora packets */
- ogg_stream_state zo; /**< Take physical pages, weld into a logical stream of irct packets */
-
- th_info ti; /**< Theora stream info struct */
- th_comment tc; /**< Theora stream comments struct */
- th_dec_ctx * td; /**< Theora stream decoding struct */
- th_setup_info * ts; /**< Theora stream setup info struct */
- th_pixel_fmt px_fmt; /**< Theora stream pixel format definition */
-
- int theora_p; /**< True if the ogg stream contains a theora stream */
- int irct_p; /**< True if the ogg stream contains an irct stream */
- int stateflag; /**< Internal flag used in stream processing */
-
- int lu_Y[256]; /**< Surface used in yuv->rgb processing (Y) */
- int lu_R[256]; /**< Surface used in yuv->rgb processing (R) */
- int lu_GU[256]; /**< Surface used in yuv->rgb processing (GU) */
- int lu_GV[256]; /**< Surface used in yuv->rgb processing (GV) */
- int lu_B[256]; /**< Surface used in yuv->rgb processing (B) */
-
- //
- int videobuf_ready; /**< Single frame video buffering : ready state */
- ogg_int64_t videobuf_granulepos; /**< Single frame video buffering : granule position */
- double videobuf_time; /**< Single frame video buffering : duration */
-
- int pp_level_max; /**< Theora postprocessing: max level */
- int pp_level; /**< Theora postprocessing: current level */
- int pp_inc; /**< Theora postprocessing: increment */
-
- bool thda; /**< Theora decode alloc state */
- bool thtic; /**< Theora setup clear state */
-private:
- /**
- * \brief Internal function that queues an ogg page to the codec decoders
- * \return int
- */
- int queue_page(ogg_page *page);
- /**
- * \brief Internal function that takes a theora yuv buffer, transforms it and appends to the video stream
- * \return int
- */
- void video_write(void);
-};
-
-#endif // COMPILE_DISABLE_OGG_THEORA
-#endif /* KVI_OGGTHEORA_H_ */
diff --git a/src/modules/dcc/codec.cpp b/src/modules/dcc/codec.cpp
index c20d2f7d1..39ab5d98b 100644
--- a/src/modules/dcc/codec.cpp
+++ b/src/modules/dcc/codec.cpp
@@ -288,7 +288,7 @@ void KviDccVideoTheoraCodec::encodeVideo(KviDataBuffer * videoSignal,KviDataBuff
if(videoSignal->size() < 1) return;
if(!m_pEncoder)
- m_pEncoder = new KviTheoraEncoder(stream);
+ m_pEncoder = new KviOggTheoraEncoder(stream);
m_pEncoder->addVideoFrame((QRgb *) videoSignal->data(),videoSignal->size());
videoSignal->clear();
@@ -299,7 +299,7 @@ void KviDccVideoTheoraCodec::encodeText(KviDataBuffer * textSignal, KviDataBuffe
if(textSignal->size() < 1) return;
if(!m_pEncoder)
- m_pEncoder = new KviTheoraEncoder(stream);
+ m_pEncoder = new KviOggTheoraEncoder(stream);
m_pEncoder->addTextFrame(textSignal->data(),textSignal->size());
textSignal->clear();
@@ -310,7 +310,7 @@ void KviDccVideoTheoraCodec::decode(KviDataBuffer * stream,KviDataBuffer * video
if(stream->size() < 1)return;
if(!m_pDecoder)
- m_pDecoder = new KviTheoraDecoder(videoSignal, textSignal);
+ m_pDecoder = new KviOggTheoraDecoder(videoSignal, textSignal);
m_pDecoder->addData(stream);
}
diff --git a/src/modules/dcc/codec.h b/src/modules/dcc/codec.h
index fe4955161..16897304c 100644
--- a/src/modules/dcc/codec.h
+++ b/src/modules/dcc/codec.h
@@ -25,9 +25,13 @@
//=============================================================================
#include "KviCString.h"
-#include "KviTheoraDecoder.h"
#include "KviDataBuffer.h"
+#ifndef COMPILE_DISABLE_OGG_THEORA
+ #include "KviOggTheoraDecoder.h"
+ #include "KviOggTheoraEncoder.h"
+#endif
+
class KviDccVoiceCodec
{
public:
@@ -97,8 +101,8 @@ public:
virtual int encodedFrameSize();
virtual int decodedFrameSize();
private:
- KviTheoraEncoder *m_pEncoder;
- KviTheoraDecoder *m_pDecoder;
+ KviOggTheoraEncoder * m_pEncoder;
+ KviOggTheoraDecoder * m_pDecoder;
};
#endif // COMPILE_DISABLE_OGG_THEORA
#endif //_CODEC_H_