[Scummvm-cvs-logs] scummvm master -> 963075386118ac0da1404192d4c8ee4a51813cd7

clone2727 clone2727 at gmail.com
Wed Mar 19 00:17:05 CET 2014


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9630753861 COMMON: Move some QuickTime Track variables into SampleDesc where they belong


Commit: 963075386118ac0da1404192d4c8ee4a51813cd7
    https://github.com/scummvm/scummvm/commit/963075386118ac0da1404192d4c8ee4a51813cd7
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2014-03-18T19:12:20-04:00

Commit Message:
COMMON: Move some QuickTime Track variables into SampleDesc where they belong

Changed paths:
    audio/decoders/quicktime.cpp
    common/quicktime.cpp
    common/quicktime.h



diff --git a/audio/decoders/quicktime.cpp b/audio/decoders/quicktime.cpp
index 787b547..547abd2 100644
--- a/audio/decoders/quicktime.cpp
+++ b/audio/decoders/quicktime.cpp
@@ -585,7 +585,7 @@ bool QuickTimeAudioDecoder::AudioSampleDesc::isAudioCodecSupported() const {
 
 	if (_codecTag == MKTAG('m', 'p', '4', 'a')) {
 		Common::String audioType;
-		switch (_parentTrack->objectTypeMP4) {
+		switch (_objectTypeMP4) {
 		case 0x40: // AAC
 #ifdef USE_FAAD
 			return true;
@@ -643,13 +643,13 @@ void QuickTimeAudioDecoder::AudioSampleDesc::initCodec() {
 	switch (_codecTag) {
 	case MKTAG('Q', 'D', 'M', '2'):
 #ifdef AUDIO_QDM2_H
-		_codec = makeQDM2Decoder(_parentTrack->extraData);
+		_codec = makeQDM2Decoder(_extraData);
 #endif
 		break;
 	case MKTAG('m', 'p', '4', 'a'):
 #ifdef USE_FAAD
-		if (_parentTrack->objectTypeMP4 == 0x40)
-			_codec = makeAACDecoder(_parentTrack->extraData);
+		if (_objectTypeMP4 == 0x40)
+			_codec = makeAACDecoder(_extraData);
 #endif
 		break;
 	default:
diff --git a/common/quicktime.cpp b/common/quicktime.cpp
index 6ab5a42..76880e1 100644
--- a/common/quicktime.cpp
+++ b/common/quicktime.cpp
@@ -529,7 +529,7 @@ int QuickTimeParser::readSTSD(Atom atom) {
 	_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags
 
 	uint32 entryCount = _fd->readUint32BE();
-	track->sampleDescs.resize(entryCount);
+	track->sampleDescs.reserve(entryCount);
 
 	for (uint32 i = 0; i < entryCount; i++) { // Parsing Sample description table
 		Atom a = { 0, 0, 0 };
@@ -541,7 +541,7 @@ int QuickTimeParser::readSTSD(Atom atom) {
 		_fd->readUint16BE(); // reserved
 		_fd->readUint16BE(); // index
 
-		track->sampleDescs[i] = readSampleDesc(track, format, size - 16);
+		track->sampleDescs.push_back(readSampleDesc(track, format, size - 16));
 
 		debug(0, "size=%d 4CC= %s codec_type=%d", size, tag2str(format), track->codecType);
 
@@ -692,8 +692,14 @@ int QuickTimeParser::readWAVE(Atom atom) {
 	if (atom.size > (1 << 30))
 		return -1;
 
-	if (track->sampleDescs[0]->getCodecTag() == MKTAG('Q', 'D', 'M', '2')) // Read extra data for QDM2
-		track->extraData = _fd->readStream(atom.size);
+	// We should only get here within an stsd atom
+	if (track->sampleDescs.empty())
+		return -1;
+
+	SampleDesc *sampleDesc = track->sampleDescs.back();
+
+	if (sampleDesc->getCodecTag() == MKTAG('Q', 'D', 'M', '2')) // Read extra data for QDM2
+		sampleDesc->_extraData = _fd->readStream(atom.size);
 	else if (atom.size > 8)
 		return readDefault(atom);
 	else
@@ -735,6 +741,12 @@ int QuickTimeParser::readESDS(Atom atom) {
 
 	Track *track = _tracks.back();
 
+	// We should only get here within an stsd atom
+	if (track->sampleDescs.empty())
+		return -1;
+
+	SampleDesc *sampleDesc = track->sampleDescs.back();
+
 	_fd->readUint32BE(); // version + flags
 
 	byte tag;
@@ -750,7 +762,7 @@ int QuickTimeParser::readESDS(Atom atom) {
 	if (tag != kMP4DecConfigDescTag)
 		return 0;
 
-	track->objectTypeMP4 = _fd->readByte();
+	sampleDesc->_objectTypeMP4 = _fd->readByte();
 	_fd->readByte();                      // stream type
 	_fd->readUint16BE(); _fd->readByte(); // buffer size
 	_fd->readUint32BE();                  // max bitrate
@@ -761,9 +773,9 @@ int QuickTimeParser::readESDS(Atom atom) {
 	if (tag != kMP4DecSpecificDescTag)
 		return 0;
 
-	track->extraData = _fd->readStream(length);
+	sampleDesc->_extraData = _fd->readStream(length);
 
-	debug(0, "MPEG-4 object type = %02x", track->objectTypeMP4);
+	debug(0, "MPEG-4 object type = %02x", sampleDesc->_objectTypeMP4);
 	return 0;
 }
 
@@ -773,8 +785,14 @@ int QuickTimeParser::readSMI(Atom atom) {
 
 	Track *track = _tracks.back();
 
+	// We should only get here within an stsd atom
+	if (track->sampleDescs.empty())
+		return -1;
+
+	SampleDesc *sampleDesc = track->sampleDescs.back();
+
 	// This atom just contains SVQ3 extra data
-	track->extraData = _fd->readStream(atom.size);
+	sampleDesc->_extraData = _fd->readStream(atom.size);
 
 	return 0;
 }
@@ -794,6 +812,12 @@ void QuickTimeParser::close() {
 QuickTimeParser::SampleDesc::SampleDesc(Track *parentTrack, uint32 codecTag) {
 	_parentTrack = parentTrack;
 	_codecTag = codecTag;
+	_extraData = 0;
+	_objectTypeMP4 = 0;
+}
+
+QuickTimeParser::SampleDesc::~SampleDesc() {
+	delete _extraData;
 }
 
 QuickTimeParser::Track::Track() {
@@ -814,11 +838,9 @@ QuickTimeParser::Track::Track() {
 	codecType = CODEC_TYPE_MOV_OTHER;
 	editCount = 0;
 	editList = 0;
-	extraData = 0;
 	frameCount = 0;
 	duration = 0;
 	startTime = 0;
-	objectTypeMP4 = 0;
 	mediaDuration = 0;
 }
 
@@ -829,7 +851,6 @@ QuickTimeParser::Track::~Track() {
 	delete[] sampleSizes;
 	delete[] keyframes;
 	delete[] editList;
-	delete extraData;
 
 	for (uint32 i = 0; i < sampleDescs.size(); i++)
 		delete sampleDescs[i];
diff --git a/common/quicktime.h b/common/quicktime.h
index caa9257..f5fd578 100644
--- a/common/quicktime.h
+++ b/common/quicktime.h
@@ -108,10 +108,13 @@ protected:
 	class SampleDesc {
 	public:
 		SampleDesc(Track *parentTrack, uint32 codecTag);
-		virtual ~SampleDesc() {}
+		virtual ~SampleDesc();
 
 		uint32 getCodecTag() const { return _codecTag; }
 
+		SeekableReadStream *_extraData;
+		byte _objectTypeMP4;
+
 	protected:
 		Track *_parentTrack;
 		uint32 _codecTag;
@@ -150,16 +153,12 @@ protected:
 		uint32 editCount;
 		EditListEntry *editList;
 
-		SeekableReadStream *extraData;
-
 		uint32 frameCount;
 		uint32 duration;
 		uint32 mediaDuration;
 		uint32 startTime;
 		Rational scaleFactorX;
 		Rational scaleFactorY;
-
-		byte objectTypeMP4;
 	};
 
 	virtual SampleDesc *readSampleDesc(Track *track, uint32 format, uint32 descSize) = 0;






More information about the Scummvm-git-logs mailing list