[xiph-commits] r16919 - in trunk/oggdsf/src/lib/codecs/theora: filters/dsfTheoraDecoder filters/dsfTheoraEncoder libs/libOOTheora

cristianadam at svn.xiph.org cristianadam at svn.xiph.org
Thu Feb 18 11:53:13 PST 2010


Author: cristianadam
Date: 2010-02-18 11:53:13 -0800 (Thu, 18 Feb 2010)
New Revision: 16919

Removed:
   trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/theora_cdecl.h
Modified:
   trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp
   trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.h
   trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.cpp
   trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.h
   trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraEncoder.h
Log:
Offset test works now. Some code cleanup.

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp	2010-02-18 19:23:21 UTC (rev 16918)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp	2010-02-18 19:53:13 UTC (rev 16919)
@@ -279,8 +279,8 @@
 	inFormatBuffer->bmiHeader.biClrUsed = 0;        //Use max colour depth
 
 	inFormatBuffer->bmiHeader.biCompression = m_outputVideoParams[inPosition].fourCC;
-	inFormatBuffer->bmiHeader.biWidth = ((locFilter->m_theoraFormatInfo->pictureWidth + 15) >> 4) << 4;
-	inFormatBuffer->bmiHeader.biHeight = ((locFilter->m_theoraFormatInfo->pictureHeight + 15) >> 4) << 4; 
+    inFormatBuffer->bmiHeader.biWidth = locFilter->m_theoraFormatInfo->pictureWidth;
+    inFormatBuffer->bmiHeader.biHeight = locFilter->m_theoraFormatInfo->pictureHeight;
 	inFormatBuffer->bmiHeader.biPlanes = 1;    //Must be 1
 	inFormatBuffer->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);   
 	inFormatBuffer->bmiHeader.biSizeImage = GetBitmapSize(&inFormatBuffer->bmiHeader);
@@ -315,8 +315,8 @@
 	inFormatBuffer->bmiHeader.biClrUsed = 0;        //Use max colour depth
 
 	inFormatBuffer->bmiHeader.biCompression = m_outputVideoParams[inPosition].fourCC;
-	inFormatBuffer->bmiHeader.biHeight = ((locFilter->m_theoraFormatInfo->pictureHeight + 15) >> 4) << 4;
-    inFormatBuffer->bmiHeader.biWidth = ((locFilter->m_theoraFormatInfo->pictureWidth + 15) >> 4) << 4;
+    inFormatBuffer->bmiHeader.biWidth = locFilter->m_theoraFormatInfo->pictureWidth;
+    inFormatBuffer->bmiHeader.biHeight = locFilter->m_theoraFormatInfo->pictureHeight;
 	inFormatBuffer->bmiHeader.biPlanes = 1;    //Must be 1
 	inFormatBuffer->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 	inFormatBuffer->bmiHeader.biSizeImage = GetBitmapSize(&inFormatBuffer->bmiHeader);
@@ -432,7 +432,11 @@
 			m_bmiFrameSize = (m_bmiHeight * m_bmiWidth * locVideoHeader->bmiHeader.biBitCount) / 8;
 		}
 
-		LOG(logDEBUG) << "Check transform OK";
+        LOG(logDEBUG) << "Check transform:";
+        LOG(logDEBUG) << "\tbmiWidth: " << m_bmiWidth;
+        LOG(logDEBUG) << "\tbmiHeight: " << m_bmiHeight;
+        LOG(logDEBUG) << "\tbmiFrameSize: " << m_bmiFrameSize;
+
 		return S_OK;
 	} 
     else 
@@ -452,11 +456,8 @@
 
 	//MTS::: Maybe this needs to be reconsidered for other output types... ie rgb32 will be much bigger
 
-	const unsigned long MIN_BUFFER_SIZE = 16*16;			//What should this be ????
-	const unsigned long DEFAULT_BUFFER_SIZE = 1024*1024 * 2;
 	const unsigned long MIN_NUM_BUFFERS = 1;
 	const unsigned long DEFAULT_NUM_BUFFERS = 1;
-
 	
 	//Validate and change what we have been requested to do.
 	//Allignment of data
@@ -470,19 +471,18 @@
 	}
 
 	//Size of each buffer
-	if (inPropertyRequest->cbBuffer < MIN_BUFFER_SIZE) 
+	if (m_pOutput->CurrentMediaType().formattype == FORMAT_VideoInfo2)
 	{
-		if (m_pOutput->CurrentMediaType().formattype == FORMAT_VideoInfo2)
-		{
-			VIDEOINFOHEADER2* pvih = (VIDEOINFOHEADER2*)m_pOutput->CurrentMediaType().Format();
-			locReqAlloc.cbBuffer = pvih->bmiHeader.biSizeImage;
-		}
-		else if (m_pOutput->CurrentMediaType().formattype == FORMAT_VideoInfo)
-		{
-			VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)m_pOutput->CurrentMediaType().Format();
-			locReqAlloc.cbBuffer = pvih->bmiHeader.biSizeImage;
-		}
-	} 
+		VIDEOINFOHEADER2* pvih = (VIDEOINFOHEADER2*)m_pOutput->CurrentMediaType().Format();
+		locReqAlloc.cbBuffer = m_theoraFormatInfo->outerFrameHeight * m_theoraFormatInfo->outerFrameWidth *
+            pvih->bmiHeader.biBitCount / 8;
+	}
+	else if (m_pOutput->CurrentMediaType().formattype == FORMAT_VideoInfo)
+	{
+		VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)m_pOutput->CurrentMediaType().Format();
+        locReqAlloc.cbBuffer = m_theoraFormatInfo->outerFrameHeight * m_theoraFormatInfo->outerFrameWidth *
+            pvih->bmiHeader.biBitCount / 8;
+	}
 	else 
 	{
 		locReqAlloc.cbBuffer = inPropertyRequest->cbBuffer;
@@ -772,18 +772,20 @@
 
 HRESULT TheoraDecodeFilter::DecodeToRGB565(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd)
 {
-	BYTE* locBuffer = NULL;
+    LOG(logDEBUG) << __FUNCTIONW__;
+
+    BYTE* locBuffer = NULL;
 	outSample->GetPointer(&locBuffer);
 
-	unsigned char * ptry = inYUVBuffer->y;
-	unsigned char * ptru = inYUVBuffer->u;
-	unsigned char * ptrv = inYUVBuffer->v;
+    unsigned char * ptry = inYUVBuffer->y + m_xOffset * inYUVBuffer->y_stride;
+    unsigned char * ptru = inYUVBuffer->u + (m_xOffset / 2) * inYUVBuffer->uv_stride;
+    unsigned char * ptrv = inYUVBuffer->v + (m_xOffset / 2) * inYUVBuffer->uv_stride;
 	unsigned char * ptro = locBuffer;
 
-	for (int i = m_yOffset; i < inYUVBuffer->y_height; ++i) 
+	for (unsigned long i = m_yOffset; i < m_pictureHeight + m_yOffset; ++i) 
 	{
 		unsigned char* ptro2 = ptro;
-		for (int j = m_xOffset; j < inYUVBuffer->y_width; j += 2) 
+		for (unsigned long j = m_xOffset; j < m_pictureWidth + m_xOffset; j += 2) 
 		{
 			short pr, pg, pb, y;
 			short r, g, b;
@@ -832,18 +834,20 @@
 
 HRESULT TheoraDecodeFilter::DecodeToRGB32(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd)
 {
+    LOG(logDEBUG) << __FUNCTIONW__;
+
 	unsigned char* locBuffer = NULL;
 	outSample->GetPointer(&locBuffer);
 
-	unsigned char * ptry = inYUVBuffer->y;
-	unsigned char * ptru = inYUVBuffer->u;
-	unsigned char * ptrv = inYUVBuffer->v;
+    unsigned char * ptry = inYUVBuffer->y + m_xOffset * inYUVBuffer->y_stride;
+    unsigned char * ptru = inYUVBuffer->u + (m_xOffset / 2) * inYUVBuffer->uv_stride;
+    unsigned char * ptrv = inYUVBuffer->v + (m_xOffset / 2) * inYUVBuffer->uv_stride;
 	unsigned char * ptro = locBuffer;
 
-	for (int i = m_yOffset; i < inYUVBuffer->y_height; i++) 
+	for (unsigned long i = m_yOffset; i < m_pictureHeight + m_yOffset; i++) 
 	{
 		unsigned char* ptro2 = ptro;
-		for (int j = m_xOffset; j < inYUVBuffer->y_width; j += 2) 
+		for (unsigned long j = m_xOffset; j < m_pictureWidth + m_xOffset; j += 2) 
 		{
 			short pr, pg, pb, y;
 			short r, g, b;
@@ -888,18 +892,20 @@
 
 HRESULT TheoraDecodeFilter::DecodeToYUY2(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd) 
 {
+    LOG(logDEBUG) << __FUNCTIONW__;
+
     unsigned char* locBuffer = NULL;
     outSample->GetPointer(&locBuffer);
 
-    unsigned char * ptry = inYUVBuffer->y;
-    unsigned char * ptru = inYUVBuffer->u;
-    unsigned char * ptrv = inYUVBuffer->v;
+    unsigned char * ptry = inYUVBuffer->y + m_xOffset * inYUVBuffer->y_stride;
+    unsigned char * ptru = inYUVBuffer->u + (m_xOffset / 2) * inYUVBuffer->uv_stride;
+    unsigned char * ptrv = inYUVBuffer->v + (m_xOffset / 2) * inYUVBuffer->uv_stride;
     unsigned char * ptro = locBuffer;
 
-    for (int i = m_yOffset; i < inYUVBuffer->y_height; ++i) 
+    for (unsigned long i = m_yOffset; i < m_pictureHeight + m_yOffset; ++i) 
     {
         unsigned char* ptro2 = ptro;
-        for (int j = m_xOffset; j < inYUVBuffer->y_width; j += 2) 
+        for (unsigned long j = m_xOffset; j < m_pictureWidth + m_xOffset; j += 2) 
         {
             *ptro2++ = ptry[j];
             *ptro2++ = ptru[j / 2];
@@ -923,12 +929,14 @@
 
 HRESULT TheoraDecodeFilter::DecodeToYV12(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd) 
 {
+    LOG(logDEBUG) << __FUNCTIONW__;
+
 	BYTE* locBuffer = NULL;
 	outSample->GetPointer(&locBuffer);
 
-    unsigned char * ptry = inYUVBuffer->y;
-    unsigned char * ptru = inYUVBuffer->u;
-    unsigned char * ptrv = inYUVBuffer->v;
+    unsigned char * ptry = inYUVBuffer->y + m_xOffset * inYUVBuffer->y_stride;
+    unsigned char * ptru = inYUVBuffer->u + (m_xOffset / 2) * inYUVBuffer->uv_stride;
+    unsigned char * ptrv = inYUVBuffer->v + (m_xOffset / 2) * inYUVBuffer->uv_stride;
     unsigned char * ptro = locBuffer;
 
 	for (unsigned long line = 0; line < m_pictureHeight; ++line) 
@@ -974,27 +982,23 @@
 
 	if (sampleMediaSubType == MEDIASUBTYPE_YV12) 
 	{
-		LOG(logDEBUG) << "Decoding to YV12";
 		return DecodeToYV12(inYUVBuffer, outSample, inIsKeyFrame, inStart, inEnd);
 	} 
 	else if (sampleMediaSubType == MEDIASUBTYPE_YUY2) 
 	{
-		LOG(logDEBUG) << "Decoding to YUY2";
 		return DecodeToYUY2(inYUVBuffer, outSample, inIsKeyFrame, inStart, inEnd);
 	} 
 	else if (sampleMediaSubType == MEDIASUBTYPE_RGB565) 
 	{
-		LOG(logDEBUG) << "Decoding to RGB565";
 		return DecodeToRGB565(inYUVBuffer, outSample, inIsKeyFrame, inStart, inEnd);
 	} 
 	else if (sampleMediaSubType == MEDIASUBTYPE_RGB32) 
 	{
-		LOG(logDEBUG) << "Decoding to RGB32";
 		return DecodeToRGB32(inYUVBuffer, outSample, inIsKeyFrame, inStart, inEnd);
 	} 
 	else 
 	{
-		LOG(logDEBUG) << "Decoding to unknown type - failure";
+		LOG(logERROR) << "Decoding to unknown type - failure";
 		return E_FAIL;
 	}
 }
@@ -1105,6 +1109,23 @@
 	m_theoraFormatInfo->targetQuality = (locIdentHeader[40]) >> 2;
 
 	m_theoraFormatInfo->maxKeyframeInterval= (((locIdentHeader[40]) % 4) << 3) + (locIdentHeader[41] >> 5);
+
+    LOG(logINFO) << "Theora Format: ";
+    LOG(logINFO) << "\ttheoraVersion: " << m_theoraFormatInfo->theoraVersion;
+    LOG(logINFO) << "\touterFrameWidth: " << m_theoraFormatInfo->outerFrameWidth;
+    LOG(logINFO) << "\touterFrameHeight: " << m_theoraFormatInfo->outerFrameHeight;
+    LOG(logINFO) << "\tpictureWidth: " << m_theoraFormatInfo->pictureWidth;
+    LOG(logINFO) << "\tpictureHeight: " << m_theoraFormatInfo->pictureHeight;
+    LOG(logINFO) << "\txOffset: " << m_theoraFormatInfo->xOffset;
+    LOG(logINFO) << "\tyOffset: " << m_theoraFormatInfo->yOffset;
+    LOG(logINFO) << "\tframeRateNumerator: " << m_theoraFormatInfo->frameRateNumerator;
+    LOG(logINFO) << "\tframeRateDenominator: " << m_theoraFormatInfo->frameRateDenominator;
+    LOG(logINFO) << "\taspectNumerator: " << m_theoraFormatInfo->aspectNumerator;
+    LOG(logINFO) << "\taspectDenominator: " << m_theoraFormatInfo->aspectDenominator;
+    LOG(logINFO) << "\tcolourSpace: " << m_theoraFormatInfo->colourSpace;
+    LOG(logINFO) << "\ttargetBitrate: " << m_theoraFormatInfo->targetBitrate;
+    LOG(logINFO) << "\ttargetQuality: " << m_theoraFormatInfo->targetQuality;
+    LOG(logINFO) << "\tmaxKeyframeInterval: " << m_theoraFormatInfo->maxKeyframeInterval;
 }
 
 CBasePin* TheoraDecodeFilter::GetPin(int inPinNo)

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.h	2010-02-18 19:23:21 UTC (rev 16918)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraEncoder/TheoraEncodeInputPin.h	2010-02-18 19:53:13 UTC (rev 16919)
@@ -33,11 +33,7 @@
 #include "theoraencoderdllstuff.h"
 #include "TheoraEncoder.h"
 
-extern "C" {
-#include "theora_cdecl.h"
-}
 
-
 //Mmmmm macrolicious !
 //#define INT_FLOOR(num,scale) (num - (num % scale))
 #define CLIP3(x,y,z) ((z < x) ? x : ((z > y) ? y : z))

Modified: trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.cpp	2010-02-18 19:23:21 UTC (rev 16918)
+++ trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.cpp	2010-02-18 19:53:13 UTC (rev 16919)
@@ -32,76 +32,57 @@
 #include "stdafx.h"
 #include "theoradecoder.h"
 
-TheoraDecoder::TheoraDecoder(void)
+TheoraDecoder::TheoraDecoder()
 	: mFirstPacket(true)
 	, mFirstHeader(true)
 	, mPacketCount(0)
-#ifdef USE_THEORA_EXP
-	, mTheoraSetup(NULL)
-	, mTheoraState(NULL)
-#endif
+	, mTheoraSetup(0)
+	, mTheoraState(0)
 {
-#ifndef USE_THEORA_EXP
-	memset(&mTheoraState, 0, sizeof(mTheoraState));
-#endif
 }
 
-TheoraDecoder::~TheoraDecoder(void)
+TheoraDecoder::~TheoraDecoder()
 {
-#ifdef USE_THEORA_EXP
 	th_comment_clear(&mTheoraComment);
 	th_info_clear(&mTheoraInfo);
 
 	th_decode_free(mTheoraState);
 	th_setup_free(mTheoraSetup);
-#else
-	theora_comment_clear(&mTheoraComment); 
-	theora_info_clear(&mTheoraInfo); 
-
-	theora_clear(&mTheoraState); 
-#endif
-
 }
 
 bool TheoraDecoder::initCodec() 
 {
-#ifdef USE_THEORA_EXP
 	th_comment_init(&mTheoraComment);
 	th_info_init(&mTheoraInfo);
-
-#else
-	theora_comment_init(&mTheoraComment);
-	theora_info_init(&mTheoraInfo);
-#endif
 	
 	return true;
  }
 
+yuv_buffer* TheoraDecoder::decodeTheora(StampedOggPacket* inPacket) 
+{		
+    //Accepts packet and deletes it.
 
-
-yuv_buffer* TheoraDecoder::decodeTheora(StampedOggPacket* inPacket) {		//Accepts packet and deletes it.
-
-	if (mPacketCount < 3) {
+	if (mPacketCount < 3) 
+    {
 		decodeHeader(inPacket);		//Accepts header and deletes it.
 
-		if (mPacketCount == 3) {
-#ifdef USE_THEORA_EXP
+		if (mPacketCount == 3) 
+        {
 			mTheoraState = th_decode_alloc(&mTheoraInfo, mTheoraSetup);
-#else
-			theora_decode_init(&mTheoraState, &mTheoraInfo);
-#endif
 			//TODO::: Post processing http://people.xiph.org/~tterribe/doc/libtheora-exp/theoradec_8h.html#a1
-
 		}
-
 		
 		return NULL;
-	} else {
-		//if (mFirstPacket) {
+	} 
+    else 
+    {
+		//if (mFirstPacket) 
+        //{
 		//	theora_decode_init(&mTheoraState, &mTheoraInfo);
 		//	mFirstPacket = false;
 		//}
-		if ((inPacket->packetSize() > 0) && ((inPacket->packetData()[0] & 128) != 0)) {
+		if (inPacket->packetSize() > 0 && (inPacket->packetData()[0] & 128) != 0) 
+        {
 			//Ignore header packets
 			delete inPacket;
 			return NULL;
@@ -109,16 +90,11 @@
 
 		ogg_packet* locOldPack = simulateOldOggPacket(inPacket);		//Accepts the packet and deletes it.
 
-#ifdef USE_THEORA_EXP
-
 		th_decode_packetin(mTheoraState, locOldPack, NULL);
-#else
-		theora_decode_packetin(&mTheoraState, locOldPack);
-#endif
-		delete locOldPack->packet;
+
+        delete locOldPack->packet;
 		delete locOldPack;
 		
-#ifdef USE_THEORA_EXP
 		th_decode_ycbcr_out(mTheoraState, mYCbCrBuffer);
 
 		//TODO:::
@@ -145,26 +121,27 @@
 		mYUVBuffer.uv_stride = mYCbCrBuffer[1].stride;
 		mYUVBuffer.u = mYCbCrBuffer[1].data;
 		mYUVBuffer.v = mYCbCrBuffer[2].data;
-
-#else
-		//Ignore return value... always returns 0 (or crashes :)
-		theora_decode_YUVout(&mTheoraState, &mYUVBuffer);
-#endif
 		
 		return &mYUVBuffer;
 	}
-
 }
 
-ogg_packet* TheoraDecoder::simulateOldOggPacket(StampedOggPacket* inPacket) {		//inPacket is accepted and deleted.
+ogg_packet* TheoraDecoder::simulateOldOggPacket(StampedOggPacket* inPacket) 
+{		
+    //inPacket is accepted and deleted.
 	const unsigned char NOT_USED = 0;
 	ogg_packet* locOldPacket = new ogg_packet;		//Returns this... the caller is responsible for it.
-	if (mFirstHeader) {
+	
+    if (mFirstHeader) 
+    {
 		locOldPacket->b_o_s = 1;
 		mFirstHeader = false;
-	} else {
+	} 
+    else 
+    {
 		locOldPacket->b_o_s = NOT_USED;
 	}
+
 	locOldPacket->e_o_s = NOT_USED;
 	locOldPacket->bytes = inPacket->packetSize();
 	locOldPacket->granulepos = inPacket->endTime();
@@ -181,26 +158,26 @@
 bool TheoraDecoder::isKeyFrame(StampedOggPacket* inPacket)
 {
 	const unsigned char KEY_FRAME_FLAG = 0x40;
-	if ((inPacket->packetSize() > 0) && (inPacket->packetData() != NULL)) {
+	if (inPacket->packetSize() > 0 && inPacket->packetData() != NULL) 
+    {
 		return ((inPacket->packetData()[0] & KEY_FRAME_FLAG) == KEY_FRAME_FLAG) ? false : true;
-	} else {
-		return false;
-	}
+	} 
+
+    return false;
 }
+
 bool TheoraDecoder::decodeHeader(StampedOggPacket* inHeaderPacket) 
-{		//inHeaderPacket is accepted and deleted.
+{		
+    //inHeaderPacket is accepted and deleted.
 	//TODO::: Error handling
 
 	ogg_packet* locOldPack = simulateOldOggPacket(inHeaderPacket);		//Accepts packet and deletes it.
 
-#ifdef USE_THEORA_EXP
-	th_decode_headerin(&mTheoraInfo, &mTheoraComment, &mTheoraSetup, locOldPack);
-#else
-	theora_decode_header(&mTheoraInfo, &mTheoraComment, locOldPack);
-#endif
+    th_decode_headerin(&mTheoraInfo, &mTheoraComment, &mTheoraSetup, locOldPack);
 
 	delete locOldPack->packet;
 	delete locOldPack;
-	mPacketCount++;
+
+    mPacketCount++;
 	return true;
-}
\ No newline at end of file
+}

Modified: trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.h	2010-02-18 19:23:21 UTC (rev 16918)
+++ trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.h	2010-02-18 19:53:13 UTC (rev 16919)
@@ -33,26 +33,19 @@
 #include "libootheora.h"
 #include <libOOOgg/dllstuff.h>
 #include <libOOOgg/StampedOggPacket.h>
-extern "C" {
-#define USE_THEORA_EXP
 
-#ifdef USE_THEORA_EXP
-#include "theora/codec.h"
-#include "theora/theoradec.h"
+#include <theora/theora.h>
+#include <theora/codec.h>
+#include <theora/theoradec.h>
 
 //Need this for yuv_buffer for now.
-#include "theora_cdecl.h"
+//#include "theora_cdecl.h"
 
-
-#else
-#include "theora_cdecl.h"
-#endif
-}
 class LIBOOTHEORA_API TheoraDecoder
 {
 public:
-	TheoraDecoder(void);
-	~TheoraDecoder(void);
+	TheoraDecoder();
+	~TheoraDecoder();
 
 	/// Initialise the internal theora decoder.
 	bool initCodec();
@@ -62,11 +55,9 @@
 
 	/// Returns true if the packet is a keyframe.
 	bool isKeyFrame(StampedOggPacket* inPacket);
-#ifdef USE_THEORA_EXP
-	th_info mTheoraInfo;
-#else
-	theora_info mTheoraInfo;
-#endif
+
+    th_info mTheoraInfo;
+
 protected:
 
 	/// Moves the pointers around to make it look like a xiph ogg packet.
@@ -76,15 +67,11 @@
 	bool decodeHeader(StampedOggPacket* inHeaderPacket);
 
 	//theora_info mTheoraInfo;
-#ifdef USE_THEORA_EXP
-	th_ycbcr_buffer mYCbCrBuffer;
+
+    th_ycbcr_buffer mYCbCrBuffer;
 	th_comment mTheoraComment;
 	th_setup_info* mTheoraSetup;
 	th_dec_ctx* mTheoraState;
-#else
-	theora_comment mTheoraComment;
-	theora_state mTheoraState;
-#endif
 	yuv_buffer mYUVBuffer;
 
 	StampedOggPacket* mPartialPacket; //TEMP !!

Modified: trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraEncoder.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraEncoder.h	2010-02-18 19:23:21 UTC (rev 16918)
+++ trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraEncoder.h	2010-02-18 19:53:13 UTC (rev 16919)
@@ -33,9 +33,8 @@
 #include "libootheora.h"
 #include <libOOOgg/dllstuff.h>
 #include <libOOOgg/StampedOggPacket.h>
-extern "C" {
-#include "theora_cdecl.h"
-}
+#include <theora/theora.h>
+
 class LIBOOTHEORA_API TheoraEncoder
 {
 public:

Deleted: trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/theora_cdecl.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/theora_cdecl.h	2010-02-18 19:23:21 UTC (rev 16918)
+++ trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/theora_cdecl.h	2010-02-18 19:53:13 UTC (rev 16919)
@@ -1,332 +0,0 @@
-/********************************************************************
- *                                                                  *
- * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
- *                                                                  *
- * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003                *
- * by the Xiph.Org Foundation http://www.xiph.org/                  *
- *                                                                  *
- ********************************************************************
-
-  function:
-  last mod: $Id: theora.h,v 1.18 2004/03/09 06:18:44 msmith Exp $
-
- ********************************************************************/
-
-#ifndef _O_THEORA_H_
-#define _O_THEORA_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-#ifndef LIBOGG2
-#include <ogg/ogg.h>
-#else
-#include <ogg2/ogg.h>
-/* This is temporary until libogg2 is more complete */
-ogg_buffer_state *ogg_buffer_create(void);
-#endif
-
-/** \mainpage
- * 
- * \section intro Introduction
- *
- * This is the documentation for the libtheora C API.
- * libtheora is the reference implementation for
- * <a href="http://www.theora.org/">Theora</a>, a free video codec.
- * Theora is derived from On2's VP3 codec with improved integration for
- * Ogg multimedia formats by <a href="http://www.xiph.org/">Xiph.Org</a>.
- * 
- * \section overview Overview
- *
- * This library will both decode and encode theora packets to/from raw YUV 
- * frames.  In either case, the packets will most likely either come from or
- * need to be embedded in an ogg stream.  Use 
- * <a href="http://xiph.org/ogg/">libogg</a> or 
- * <a href="http://www.annodex.net/software/liboggz/index.html">liboggz</a>
- * to extract/package these packets.
- *
- * \section decoding Decoding Process
- *
- * Decoding can be seperated into the following steps:
- * -# initialise theora_info and theora_comment structures using 
- *    theora_info_init() and theora_comment_init():
- \verbatim
- theora_info     info;
- theora_comment  comment;
-   
- theora_info_init(&info);
- theora_comment_init(&comment);
- \endverbatim
- * -# retrieve header packets from ogg stream (there should be 3) and decode 
- *    into theora_info and theora_comment structures using 
- *    theora_decode_header().  See \ref identification for more information on 
- *    identifying which packets are theora packets.
- \verbatim
- int i;
- for (i = 0; i < 3; i++)
- {
-   (get a theora packet "op" from the ogg stream)
-   theora_decode_header(&info, &comment, op);
- }
- \endverbatim
- * -# initialise the decoder based on the information retrieved into the
- *    theora_info struct by theora_decode_header().  You will need a 
- *    theora_state struct.
- \verbatim
- theora_state state;
- 
- theora_decode_init(&state, &info);
- \endverbatim
- * -# pass in packets and retrieve decoded frames!  See the yuv_buffer 
- *    documentation for information on how to retrieve raw YUV data.
- \verbatim
- yuf_buffer buffer;
- while (last packet was not e_o_s) {
-   (get a theora packet "op" from the ogg stream)
-   theora_decode_packetin(&state, op);
-   theora_decode_YUVout(&state, &buffer);
- }
- \endverbatim
- *  
- *
- * \subsection identification Identifying Theora Packets
- *
- * all streams inside an ogg file have a unique serial_no attached to the 
- * stream.  Typically, you will want to 
- *  - retrieve the serial_no for each b_o_s (beginning of stream) page 
- *    encountered within the pgg file; 
- *  - test the first (only) packet on that page to determine if it is a theora 
- *    packet;
- *  - once you have found a theora b_o_s page then use the retrieved serial_no 
- *    to identify future packets belonging to the same theora stream.
- * 
- * Note that you \e cannot use theora_packet_isheader() to determine if a 
- * packet is a theora packet or not, as this function does not perform any
- * checking beyond whether a header bit is present.  Instead, use the
- * theora_decode_header() function and check the return value; or examine the
- * header bytes at the beginning of the ogg page.
- *
- * \subsection example Example Decoder 
- *
- * see <a href="http://svn.xiph.org/trunk/theora/examples/dump_video.c">
- * examples/dump_video.c</a> for a simple decoder implementation.
- *
- * \section encoding Encoding Process
- *
- * see <a href="http://svn.xiph.org/trunk/theora/examples/encoder_example.c">
- * examples/encoder_example.c</a> for a simple encoder implementation.
- */
-
-/** \file
- * The libtheora C API.
- */
-
-/**
- * A YUV buffer for passing uncompressed frames to and from the codec.
- * This holds a Y'CbCr frame in planar format. The CbCr planes can be
- * subsampled and have their own separate dimensions and row stride
- * offsets. Note that the strides may be negative in some 
- * configurations. For theora the width and height of the largest plane
- * must be a multiple of 16. The actual meaningful picture size and 
- * offset are stored in the theora_info structure; frames returned by
- * the decoder may need to be cropped for display.
- *
- * All samples are 8 bits. Within each plane samples are ordered by
- * row from the top of the frame to the bottom. Within each row samples
- * are ordered from left to right.
- *
- * During decode, the yuv_buffer struct is allocated by the user, but all
- * fields (including luma and chroma pointers) are filled by the library.  
- * These pointers address library-internal memory and their contents should 
- * not be modified.
- *
- * Conversely, during encode the user allocates the struct and fills out all
- * fields.  The user also manages the data addressed by the luma and chroma
- * pointers.  See the encoder_example.c and dump_video.c example files in
- * theora/examples/ for more information.
- */
-typedef struct {
-    int   y_width;      /**< Width of the Y' luminance plane */
-    int   y_height;     /**< Height of the luminance plane */
-    int   y_stride;     /**< Offset in bytes between successive rows */
-
-    int   uv_width;     /**< Height of the Cb and Cr chroma planes */
-    int   uv_height;    /**< Width of the chroma planes */
-    int   uv_stride;    /**< Offset between successive chroma rows */
-    unsigned char *y;   /**< Pointer to start of luminance data */
-    unsigned char *u;   /**< Pointer to start of Cb data */
-    unsigned char *v;   /**< Pointer to start of Cr data */
-
-} yuv_buffer;
-
-/**
- * A Colorspace.
- */
-typedef enum {
-  OC_CS_UNSPECIFIED,    /**< The colorspace is unknown or unspecified */
-  OC_CS_ITU_REC_470M,   /**< This is the best option for 'NTSC' content */
-  OC_CS_ITU_REC_470BG,  /**< This is the best option for 'PAL' content */
-  OC_CS_NSPACES         /**< This marks the end of the defined colorspaces */
-} theora_colorspace;
-
-/**
- * A Chroma subsampling
- *
- * These enumerate the available chroma subsampling options supported
- * by the theora format. See Section 4.4 of the specification for
- * exact definitions.
- */
-typedef enum {
-  OC_PF_420,    /**< Chroma subsampling by 2 in each direction (4:2:0) */
-  OC_PF_RSVD,   /**< Reserved value */
-  OC_PF_422,    /**< Horizonatal chroma subsampling by 2 (4:2:2) */
-  OC_PF_444,    /**< No chroma subsampling at all (4:4:4) */
-} theora_pixelformat;
-
-/**
- * Theora bitstream info.
- * Contains the basic playback parameters for a stream,
- * corresponds to the initial 'info' header packet.
- * 
- * Encoded theora frames must be a multiple of 16 is size;
- * this is what the width and height members represent. To
- * handle other sizes, a crop rectangle is specified in 
- * frame_height and frame_width, offset_x and offset_y. The
- * offset and size should still be a multiple of 2 to avoid
- * chroma sampling shifts. Offset values in this structure
- * are measured from the  upper left of the image.
- *
- * Frame rate, in frames per second, is stored as a rational
- * fraction. So is the aspect ratio. Note that this refers
- * to the aspect ratio of the frame pixels, not of the
- * overall frame itself.
- * 
- * see the example code for use of the other parameters and
- * good default settings for the encoder parameters.
- */
-typedef struct {
-  ogg_uint32_t  width;		/**< encoded frame width  */
-  ogg_uint32_t  height;		/**< encoded frame height */
-  ogg_uint32_t  frame_width;	/**< display frame width  */
-  ogg_uint32_t  frame_height;	/**< display frame height */
-  ogg_uint32_t  offset_x;	/**< horizontal offset of the displayed frame */
-  ogg_uint32_t  offset_y;	/**< vertical offset of the displayed frame */
-  ogg_uint32_t  fps_numerator;	    /**< frame rate numerator **/
-  ogg_uint32_t  fps_denominator;    /**< frame rate denominator **/
-  ogg_uint32_t  aspect_numerator;   /**< pixel aspect ratio numerator */
-  ogg_uint32_t  aspect_denominator; /**< pixel aspect ratio denominator */
-  theora_colorspace colorspace;	    /**< colorspace */
-  int           target_bitrate;	    /**< nominal bitrate in bits per second */
-  int           quality;  /**< Nominal quality setting, 0-63 */
-  int           quick_p;  /**< Quick encode/decode */
-
-  /* decode only */
-  unsigned char version_major;
-  unsigned char version_minor;
-  unsigned char version_subminor;
-
-  void *codec_setup;
-
-  /* encode only */
-  int           dropframes_p;
-  int           keyframe_auto_p;
-  ogg_uint32_t  keyframe_frequency;
-  ogg_uint32_t  keyframe_frequency_force;  /* also used for decode init to
-                                              get granpos shift correct */
-  ogg_uint32_t  keyframe_data_target_bitrate;
-  ogg_int32_t   keyframe_auto_threshold;
-  ogg_uint32_t  keyframe_mindistance;
-  ogg_int32_t   noise_sensitivity;
-  ogg_int32_t   sharpness;
-
-  theora_pixelformat pixelformat;	/**< chroma subsampling mode to expect */
-
-} theora_info;
-
-/** Codec internal state and context.
- */
-typedef struct{
-  theora_info *i;
-  ogg_int64_t granulepos;
-
-  void *internal_encode;
-  void *internal_decode;
-
-} theora_state;
-
-/** 
- * Comment header metadata.
- *
- * This structure holds the in-stream metadata corresponding to
- * the 'comment' header packet.
- *
- * Meta data is stored as a series of (tag, value) pairs, in
- * length-encoded string vectors. The first occurence of the 
- * '=' character delimits the tag and value. A particular tag
- * may occur more than once. The character set encoding for
- * the strings is always utf-8, but the tag names are limited
- * to case-insensitive ascii. See the spec for details.
- *
- * In filling in this structure, theora_decode_header() will
- * null-terminate the user_comment strings for safety. However,
- * the bitstream format itself treats them as 8-bit clean,
- * and so the length array should be treated as authoritative
- * for their length.
- */
-typedef struct theora_comment{
-  char **user_comments;         /**< An array of comment string vectors */
-  int   *comment_lengths;       /**< An array of corresponding string vector lengths in bytes */
-  int    comments;              /**< The total number of comment string vectors */
-  char  *vendor;                /**< The vendor string identifying the encoder, null terminated */
-
-} theora_comment;
-
-#define OC_FAULT       -1       /**< General failure */
-#define OC_EINVAL      -10      /**< Library encountered invalid internal data */
-#define OC_DISABLED    -11      /**< Requested action is disabled */
-#define OC_BADHEADER   -20      /**< Header packet was corrupt/invalid */
-#define OC_NOTFORMAT   -21      /**< Packet is not a theora packet */
-#define OC_VERSION     -22      /**< Bitstream version is not handled */
-#define OC_IMPL        -23      /**< Feature or action not implemented */
-#define OC_BADPACKET   -24      /**< Packet is corrupt */
-#define OC_NEWPACKET   -25      /**< Packet is an (ignorable) unhandled extension */
-#define OC_DUPFRAME    1        /**< Packet is a dropped frame */
-
-
-extern const char* __cdecl theora_version_string(void);
-extern ogg_uint32_t __cdecl theora_version_number(void);
-extern int __cdecl theora_encode_init(theora_state *th, theora_info *c);
-extern int __cdecl theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);
-extern int __cdecl theora_encode_packetout( theora_state *t, int last_p,
-                                    ogg_packet *op);
-extern int __cdecl theora_encode_header(theora_state *t, ogg_packet *op);
-extern int __cdecl theora_encode_comment(theora_comment *tc, ogg_packet *op);
-extern int __cdecl theora_encode_tables(theora_state *t, ogg_packet *op);
-extern int __cdecl theora_decode_header(theora_info *ci, theora_comment *cc,
-                                ogg_packet *op);
-extern int __cdecl theora_decode_init(theora_state *th, theora_info *c);
-extern int __cdecl theora_decode_packetin(theora_state *th,ogg_packet *op);
-extern int __cdecl theora_decode_YUVout(theora_state *th,yuv_buffer *yuv);
-extern double __cdecl theora_granule_time(theora_state *th,ogg_int64_t granulepos);
-extern void __cdecl theora_info_init(theora_info *c);
-extern void __cdecl theora_info_clear(theora_info *c);
-extern void __cdecl theora_clear(theora_state *t);
-
-extern void __cdecl theora_comment_init(theora_comment *tc);
-extern void __cdecl theora_comment_add(theora_comment *tc, char *comment);
-extern void __cdecl theora_comment_add_tag(theora_comment *tc,
-                                       char *tag, char *value);
-extern char *__cdecl theora_comment_query(theora_comment *tc, char *tag, int count);
-extern int   __cdecl theora_comment_query_count(theora_comment *tc, char *tag);
-extern void  __cdecl theora_comment_clear(theora_comment *tc);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _O_THEORA_H_ */



More information about the commits mailing list