[xiph-commits] r8054 - in trunk/oggdsf/src/lib/codecs/theora:
filters/dsfTheoraDecoder libs/libOOTheora
illiminable at motherfish-iii.xiph.org
illiminable at motherfish-iii.xiph.org
Tue Oct 19 00:15:34 PDT 2004
Author: illiminable
Date: 2004-10-19 00:15:34 -0700 (Tue, 19 Oct 2004)
New Revision: 8054
Modified:
trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp
trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.cpp
Log:
* Fixed some leaks in theora decoder.
Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp 2004-10-19 06:22:26 UTC (rev 8053)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp 2004-10-19 07:15:34 UTC (rev 8054)
@@ -77,6 +77,9 @@
TheoraDecodeFilter::~TheoraDecodeFilter() {
delete mTheoraDecoder;
mTheoraDecoder = NULL;
+
+ delete mTheoraFormatInfo;
+ mTheoraFormatInfo = NULL;
//debugLog.close();
}
@@ -362,7 +365,8 @@
} else {
//debugLog<<"Attempting dynamic change..."<<endl;
}
-
+
+ //This packet is given to the decoder.
StampedOggPacket* locPacket = new StampedOggPacket(locNewBuff, inInputSample->GetActualDataLength(), false, false, locStart, locEnd, StampedOggPacket::OGG_END_ONLY);
yuv_buffer* locYUV = mTheoraDecoder->decodeTheora(locPacket);
if (locYUV != NULL) {
@@ -674,7 +678,7 @@
void TheoraDecodeFilter::setTheoraFormat(sTheoraFormatBlock* inFormatBlock)
{
delete mTheoraFormatInfo;
- mTheoraFormatInfo = new sTheoraFormatBlock;
+ mTheoraFormatInfo = new sTheoraFormatBlock; //Deelted in destructor.
*mTheoraFormatInfo = *inFormatBlock;
}
@@ -686,13 +690,13 @@
if (m_pInput == NULL) {
- m_pInput = new TheoraDecodeInputPin(this, &locHR);
+ m_pInput = new TheoraDecodeInputPin(this, &locHR); //Deleted in base destructor
if (m_pInput == NULL) {
return NULL;
}
- m_pOutput = new TheoraDecodeOutputPin(this, &locHR);
+ m_pOutput = new TheoraDecodeOutputPin(this, &locHR); //Deleted in base destructor
if (m_pOutput == NULL) {
Modified: trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.cpp 2004-10-19 06:22:26 UTC (rev 8053)
+++ trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.cpp 2004-10-19 07:15:34 UTC (rev 8054)
@@ -52,10 +52,10 @@
//This is temporary... get it out of here after testing
-yuv_buffer* TheoraDecoder::decodeTheora(StampedOggPacket* inPacket) {
+yuv_buffer* TheoraDecoder::decodeTheora(StampedOggPacket* inPacket) { //Accepts packet and deletes it.
if (mPacketCount < 3) {
- decodeHeader(inPacket);
+ decodeHeader(inPacket); //Accepts header and deletes it.
return NULL;
} else {
@@ -63,8 +63,9 @@
theora_decode_init(&mTheoraState, &mTheoraInfo);
mFirstPacket = false;
}
-
- theora_decode_packetin(&mTheoraState, simulateOldOggPacket(inPacket));
+ ogg_packet* locOldPack = simulateOldOggPacket(inPacket); //Accepts the packet and deletes it.
+ theora_decode_packetin(&mTheoraState, locOldPack);
+ delete locOldPack;
int locRetVal = theora_decode_YUVout(&mTheoraState, &mYUVBuffer);
//Error check
@@ -73,9 +74,9 @@
}
-ogg_packet* TheoraDecoder::simulateOldOggPacket(StampedOggPacket* inPacket) {
+ogg_packet* TheoraDecoder::simulateOldOggPacket(StampedOggPacket* inPacket) { //inPacket is accepted and deleted.
const unsigned char NOT_USED = 0;
- ogg_packet* locOldPacket = new ogg_packet;
+ ogg_packet* locOldPacket = new ogg_packet; //Returns this... the caller is responsible for it.
if (mFirstHeader) {
locOldPacket->b_o_s = 1;
mFirstHeader = false;
@@ -87,10 +88,19 @@
locOldPacket->granulepos = inPacket->endTime();
locOldPacket->packet = inPacket->packetData();
locOldPacket->packetno = NOT_USED;
- return locOldPacket;
+
+ //Set this to NULL do it doesn't get deleted by the destructor we are about invoke.
+ inPacket->setPacketData(NULL);
+ delete inPacket;
+
+ return locOldPacket; //Gives a poitner to the caller.
}
-bool TheoraDecoder::decodeHeader(StampedOggPacket* inHeaderPacket) {
- theora_decode_header(&mTheoraInfo, &mTheoraComment, simulateOldOggPacket(inHeaderPacket));
+bool TheoraDecoder::decodeHeader(StampedOggPacket* inHeaderPacket) { //inHeaderPacket is accepted and deleted.
+
+ ogg_packet* locOldPack = simulateOldOggPacket(inHeaderPacket); //Accepts packet and deletes it.
+ theora_decode_header(&mTheoraInfo, &mTheoraComment, locOldPack);
+
+ delete locOldPack;
mPacketCount++;
return true;
}
\ No newline at end of file
More information about the commits
mailing list