[xiph-commits] r12814 - in trunk/xiph-qt: CAVorbis/src build-macosx build-macosx/XiphQT.xcodeproj tests tests/CAVorbis

arek at svn.xiph.org arek at svn.xiph.org
Tue Mar 27 15:09:39 PDT 2007


Author: arek
Date: 2007-03-27 15:09:32 -0700 (Tue, 27 Mar 2007)
New Revision: 12814

Added:
   trunk/xiph-qt/tests/CAVorbis/
   trunk/xiph-qt/tests/CAVorbis/OggVorbisTests.cpp
   trunk/xiph-qt/tests/CAVorbis/OggVorbisTests.h
Modified:
   trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.cpp
   trunk/xiph-qt/CAVorbis/src/vorbis_versions.h
   trunk/xiph-qt/build-macosx/Info (decoders).plist
   trunk/xiph-qt/build-macosx/Info.plist
   trunk/xiph-qt/build-macosx/XiphQT.xcodeproj/project.pbxproj
Log:
Added checking for the end of the buffered ogg-page; updated versions.

Modified: trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.cpp
===================================================================
--- trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.cpp	2007-03-27 20:20:13 UTC (rev 12813)
+++ trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.cpp	2007-03-27 22:09:32 UTC (rev 12814)
@@ -139,10 +139,13 @@
                 UInt32 vorbis_return = CAVorbisDecoder::ProduceOutputPackets(the_data, vorbis_returned_data, vorbis_packets, NULL);
                 if (vorbis_return == kAudioCodecProduceOutputPacketSuccess ||
                     vorbis_return == kAudioCodecProduceOutputPacketSuccessHasMore ||
-                    vorbis_return == kAudioCodecProduceOutputPacketNeedsMoreInputData) {
+                    vorbis_return == kAudioCodecProduceOutputPacketNeedsMoreInputData)
+                {
                     vorbis_total_returned_data += vorbis_returned_data;
 
-                    if (vorbis_return == kAudioCodecProduceOutputPacketSuccess || vorbis_return == kAudioCodecProduceOutputPacketNeedsMoreInputData)
+                    if (vorbis_return == kAudioCodecProduceOutputPacketSuccess ||
+                        vorbis_return == kAudioCodecProduceOutputPacketNeedsMoreInputData ||
+                        vorbis_packets == mSOBufferPackets)
                     {
                         /* ok, all data decoded */
                         mSOBufferUsed = vorbis_total_returned_data;

Modified: trunk/xiph-qt/CAVorbis/src/vorbis_versions.h
===================================================================
--- trunk/xiph-qt/CAVorbis/src/vorbis_versions.h	2007-03-27 20:20:13 UTC (rev 12813)
+++ trunk/xiph-qt/CAVorbis/src/vorbis_versions.h	2007-03-27 22:09:32 UTC (rev 12814)
@@ -33,10 +33,10 @@
 
 
 #ifdef DEBUG
-#define kCAVorbis_adec_Version		(0x00FF0108)
+#define kCAVorbis_adec_Version		(0x00FF0109)
 #define kCAVorbis_aenc_Version		(0x00FF0101)
 #else
-#define kCAVorbis_adec_Version		(0x00000108)
+#define kCAVorbis_adec_Version		(0x00000109)
 #define kCAVorbis_aenc_Version		(0x00000101)
 #endif /* DEBUG */
 

Modified: trunk/xiph-qt/build-macosx/Info (decoders).plist
===================================================================
--- trunk/xiph-qt/build-macosx/Info (decoders).plist	2007-03-27 20:20:13 UTC (rev 12813)
+++ trunk/xiph-qt/build-macosx/Info (decoders).plist	2007-03-27 22:09:32 UTC (rev 12814)
@@ -7,7 +7,7 @@
 	<key>CFBundleExecutable</key>
 	<string>XiphQT (decoders)</string>
 	<key>CFBundleGetInfoString</key>
-	<string>Xiph QuickTime Components 0.1.7 (decoders only), Copyright © 2005-2007 Arek Korbik</string>
+	<string>Xiph QuickTime Components 0.1.8svn (decoders only), Copyright © 2005-2007 Arek Korbik</string>
 	<key>CFBundleIconFile</key>
 	<string></string>
 	<key>CFBundleIdentifier</key>
@@ -17,14 +17,14 @@
 	<key>CFBundlePackageType</key>
 	<string>BNDL</string>
 	<key>CFBundleShortVersionString</key>
-	<string>0.1.7</string>
+	<string>0.1.8svn</string>
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>0.1.7</string>
+	<string>0.1.8svn</string>
 	<key>CSResourcesFileMapped</key>
 	<true/>
 	<key>NSHumanReadableCopyright</key>
-	<string>Xiph QuickTime Components 0.1.7 (decoders only), Copyright © 2005-2007 Arek Korbik</string>
+	<string>Xiph QuickTime Components 0.1.8svn (decoders only), Copyright © 2005-2007 Arek Korbik</string>
 </dict>
 </plist>

Modified: trunk/xiph-qt/build-macosx/Info.plist
===================================================================
--- trunk/xiph-qt/build-macosx/Info.plist	2007-03-27 20:20:13 UTC (rev 12813)
+++ trunk/xiph-qt/build-macosx/Info.plist	2007-03-27 22:09:32 UTC (rev 12814)
@@ -7,7 +7,7 @@
 	<key>CFBundleExecutable</key>
 	<string>XiphQT</string>
 	<key>CFBundleGetInfoString</key>
-	<string>Xiph QuickTime Components 0.1.7, Copyright © 2005-2007 Arek Korbik</string>
+	<string>Xiph QuickTime Components 0.1.8svn, Copyright © 2005-2007 Arek Korbik</string>
 	<key>CFBundleIconFile</key>
 	<string></string>
 	<key>CFBundleIdentifier</key>
@@ -19,11 +19,11 @@
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>0.1.7</string>
+	<string>0.1.8svn</string>
 	<key>CFBundleShortVersionString</key>
-	<string>0.1.7</string>
+	<string>0.1.8svn</string>
 	<key>NSHumanReadableCopyright</key>
-	<string>Xiph QuickTime Components 0.1.7, Copyright © 2005-2007 Arek Korbik</string>
+	<string>Xiph QuickTime Components 0.1.8svn, Copyright © 2005-2007 Arek Korbik</string>
 	<key>CSResourcesFileMapped</key>
 	<true/>
 </dict>

Modified: trunk/xiph-qt/build-macosx/XiphQT.xcodeproj/project.pbxproj
===================================================================
--- trunk/xiph-qt/build-macosx/XiphQT.xcodeproj/project.pbxproj	2007-03-27 20:20:13 UTC (rev 12813)
+++ trunk/xiph-qt/build-macosx/XiphQT.xcodeproj/project.pbxproj	2007-03-27 22:09:32 UTC (rev 12814)
@@ -53,6 +53,10 @@
 		7326B54D0B5AC44B004CE9D3 /* MetaDataConfig.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 737449730B19F922002B059E /* MetaDataConfig.plist */; };
 		73271C840B610B2400175874 /* RingBufferTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 73271C830B610B2400175874 /* RingBufferTests.cpp */; };
 		734716840B77F72E001F439D /* XCACodecTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 734716820B77F72E001F439D /* XCACodecTests.cpp */; };
+		736266AB0BB9502C006BE1C2 /* OggVorbisTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 736266A90BB9502C006BE1C2 /* OggVorbisTests.cpp */; };
+		736266AC0BB950A0006BE1C2 /* CAOggVorbisDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 73744A250B1A031D002B059E /* CAOggVorbisDecoder.cpp */; };
+		736266AD0BB950AD006BE1C2 /* CAVorbisDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 73744A270B1A031D002B059E /* CAVorbisDecoder.cpp */; };
+		736266B80BB95199006BE1C2 /* libvorbis.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 730B1CB90B19C37600E06B34 /* libvorbis.a */; };
 		7373EDD00B7BDCAA00591836 /* samplerefs.c in Sources */ = {isa = PBXBuildFile; fileRef = 7373EDCE0B7BDCAA00591836 /* samplerefs.c */; };
 		7373EDD20B7BDCAA00591836 /* samplerefs.c in Sources */ = {isa = PBXBuildFile; fileRef = 7373EDCE0B7BDCAA00591836 /* samplerefs.c */; };
 		737448B60B19EC05002B059E /* common.c in Sources */ = {isa = PBXBuildFile; fileRef = 7374489F0B19EC05002B059E /* common.c */; };
@@ -253,6 +257,34 @@
 			remoteGlobalIDString = 7388363F0B191426005C7A69;
 			remoteInfo = "libtheoradec (static)";
 		};
+		736266B00BB95163006BE1C2 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 738A452D0B18659A00B43A0C /* Ogg.xcodeproj */;
+			proxyType = 1;
+			remoteGlobalIDString = 734FB2E40B18B33E00D561D7 /* libogg (static) */;
+			remoteInfo = "libogg (static)";
+		};
+		736266B20BB95163006BE1C2 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 738837B00B19386C005C7A69 /* Vorbis.xcodeproj */;
+			proxyType = 1;
+			remoteGlobalIDString = 738835E30B18F870005C7A69 /* libvorbis (static) */;
+			remoteInfo = "libvorbis (static)";
+		};
+		736266B40BB95163006BE1C2 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 73744C260B1A25A2002B059E /* FLAC.xcodeproj */;
+			proxyType = 1;
+			remoteGlobalIDString = 73744B1A0B1A1C43002B059E /* libflac (static) */;
+			remoteInfo = "libflac (static)";
+		};
+		736266B60BB95163006BE1C2 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 73744C260B1A25A2002B059E /* FLAC.xcodeproj */;
+			proxyType = 1;
+			remoteGlobalIDString = 73744B510B1A21DA002B059E /* libflac++ (static) */;
+			remoteInfo = "libflac++ (static)";
+		};
 		737449200B19F043002B059E /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
 			containerPortal = 738A452D0B18659A00B43A0C /* Ogg.xcodeproj */;
@@ -372,6 +404,8 @@
 		73271C830B610B2400175874 /* RingBufferTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RingBufferTests.cpp; path = ../tests/common/RingBufferTests.cpp; sourceTree = SOURCE_ROOT; };
 		734716820B77F72E001F439D /* XCACodecTests.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = XCACodecTests.cpp; path = ../tests/common/XCACodecTests.cpp; sourceTree = SOURCE_ROOT; };
 		734716830B77F72E001F439D /* XCACodecTests.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = XCACodecTests.h; path = ../tests/common/XCACodecTests.h; sourceTree = SOURCE_ROOT; };
+		736266A90BB9502C006BE1C2 /* OggVorbisTests.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = OggVorbisTests.cpp; path = ../tests/CAVorbis/OggVorbisTests.cpp; sourceTree = SOURCE_ROOT; };
+		736266AA0BB9502C006BE1C2 /* OggVorbisTests.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = OggVorbisTests.h; path = ../tests/CAVorbis/OggVorbisTests.h; sourceTree = SOURCE_ROOT; };
 		7373EDCE0B7BDCAA00591836 /* samplerefs.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = samplerefs.c; path = ../OggImport/src/samplerefs.c; sourceTree = SOURCE_ROOT; };
 		7373EDCF0B7BDCAA00591836 /* samplerefs.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = samplerefs.h; path = ../OggImport/src/samplerefs.h; sourceTree = SOURCE_ROOT; };
 		7374489F0B19EC05002B059E /* common.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = common.c; path = ../OggImport/src/common.c; sourceTree = SOURCE_ROOT; };
@@ -513,6 +547,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				736266B80BB95199006BE1C2 /* libvorbis.a in Frameworks */,
 				73C752FA0B5FD91100615F6C /* libflac++.a in Frameworks */,
 				73C752FB0B5FD91200615F6C /* libflac.a in Frameworks */,
 				73C752FD0B5FD92200615F6C /* libogg.a in Frameworks */,
@@ -665,6 +700,15 @@
 			name = common;
 			sourceTree = "<group>";
 		};
+		736266A80BB9500B006BE1C2 /* CAVorbis */ = {
+			isa = PBXGroup;
+			children = (
+				736266A90BB9502C006BE1C2 /* OggVorbisTests.cpp */,
+				736266AA0BB9502C006BE1C2 /* OggVorbisTests.h */,
+			);
+			name = CAVorbis;
+			sourceTree = "<group>";
+		};
 		737448880B19EAE7002B059E /* OggImport */ = {
 			isa = PBXGroup;
 			children = (
@@ -973,6 +1017,7 @@
 		73C752A30B5FB78300615F6C /* Tests */ = {
 			isa = PBXGroup;
 			children = (
+				736266A80BB9500B006BE1C2 /* CAVorbis */,
 				73C752A40B5FB79A00615F6C /* CAFLAC */,
 				73271C7F0B610A9600175874 /* common */,
 			);
@@ -1029,6 +1074,10 @@
 			buildRules = (
 			);
 			dependencies = (
+				736266B10BB95163006BE1C2 /* PBXTargetDependency */,
+				736266B30BB95163006BE1C2 /* PBXTargetDependency */,
+				736266B50BB95163006BE1C2 /* PBXTargetDependency */,
+				736266B70BB95163006BE1C2 /* PBXTargetDependency */,
 			);
 			name = tests;
 			productName = tests;
@@ -1348,6 +1397,9 @@
 				73C752F30B5FD8D300615F6C /* GetCodecBundle.cpp in Sources */,
 				73271C840B610B2400175874 /* RingBufferTests.cpp in Sources */,
 				734716840B77F72E001F439D /* XCACodecTests.cpp in Sources */,
+				736266AB0BB9502C006BE1C2 /* OggVorbisTests.cpp in Sources */,
+				736266AC0BB950A0006BE1C2 /* CAOggVorbisDecoder.cpp in Sources */,
+				736266AD0BB950AD006BE1C2 /* CAVorbisDecoder.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1425,6 +1477,26 @@
 			name = "libtheoradec (static)";
 			targetProxy = 7326B50F0B5AC44B004CE9D3 /* PBXContainerItemProxy */;
 		};
+		736266B10BB95163006BE1C2 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			name = "libogg (static)";
+			targetProxy = 736266B00BB95163006BE1C2 /* PBXContainerItemProxy */;
+		};
+		736266B30BB95163006BE1C2 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			name = "libvorbis (static)";
+			targetProxy = 736266B20BB95163006BE1C2 /* PBXContainerItemProxy */;
+		};
+		736266B50BB95163006BE1C2 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			name = "libflac (static)";
+			targetProxy = 736266B40BB95163006BE1C2 /* PBXContainerItemProxy */;
+		};
+		736266B70BB95163006BE1C2 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			name = "libflac++ (static)";
+			targetProxy = 736266B60BB95163006BE1C2 /* PBXContainerItemProxy */;
+		};
 		737449210B19F043002B059E /* PBXTargetDependency */ = {
 			isa = PBXTargetDependency;
 			name = "libogg (static)";
@@ -1657,10 +1729,7 @@
 				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h";
-				GCC_PREPROCESSOR_DEFINITIONS = (
-					"$(inherited)",
-					NDEBUG,
-				);
+				GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
 					"../external-libs/ogg/include",
@@ -1670,6 +1739,7 @@
 					"../external-libs/theora/include",
 					"../external-libs/flac/include",
 					../CAFLAC/src,
+					../CAVorbis/src,
 					../utils,
 				);
 				INFOPLIST_FILE = "tests-Info.plist";
@@ -1696,10 +1766,7 @@
 				GCC_MODEL_TUNING = G4;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h";
-				GCC_PREPROCESSOR_DEFINITIONS = (
-					"$(inherited)",
-					NDEBUG,
-				);
+				GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
 					"../external-libs/ogg/include",
@@ -1709,6 +1776,7 @@
 					"../external-libs/theora/include",
 					"../external-libs/flac/include",
 					../CAFLAC/src,
+					../CAVorbis/src,
 					../utils,
 				);
 				INFOPLIST_FILE = "tests-Info.plist";

Copied: trunk/xiph-qt/tests/CAVorbis/OggVorbisTests.cpp (from rev 12796, trunk/xiph-qt/tests/CAFLAC/OggFLACTests.cpp)
===================================================================
--- trunk/xiph-qt/tests/CAFLAC/OggFLACTests.cpp	2007-03-22 12:01:49 UTC (rev 12796)
+++ trunk/xiph-qt/tests/CAVorbis/OggVorbisTests.cpp	2007-03-27 22:09:32 UTC (rev 12814)
@@ -0,0 +1,422 @@
+/*
+ *  OggVorbisTests.cpp
+ *
+ *    CAOggVorbisDecoder class test cases.
+ *
+ *
+ *  Copyright (c) 2007  Arek Korbik
+ *
+ *  This file is part of XiphQT, the Xiph QuickTime Components.
+ *
+ *  XiphQT is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  XiphQT 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
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with XiphQT; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ *
+ *  Last modified: $Id$
+ *
+ */
+
+
+#include "OggVorbisTests.h"
+#include <iostream>
+#include <fstream>
+
+
+OggVorbisTests::OggVorbisTests(TestInvocation *invocation)
+    : TestCase(invocation)
+{
+}
+
+
+OggVorbisTests::~OggVorbisTests()
+{
+}
+
+void OggVorbisTests::setUp()
+{
+    mOggDecoder = new CAOggVorbisDecoder();
+}
+
+void OggVorbisTests::tearDown()
+{
+    delete mOggDecoder;
+    mOggDecoder = NULL;
+}
+
+void OggVorbisTests::noop()
+{
+}
+
+void OggVorbisTests::append_uninitialized()
+{
+    UInt32 bytes = 0;
+    UInt32 packets = 0;
+
+    Boolean appended = false;
+
+    try {
+        mOggDecoder->AppendInputData(NULL, bytes, packets, NULL);
+        appended = true;
+    } catch (...) {
+    };
+
+    CPTAssert(appended == false);
+}
+
+void OggVorbisTests::init_cookie()
+{
+    std::ifstream f_in;
+    char cookie[8192];
+
+    f_in.open("../tests/data/vorbis.ogg.cookie", std::ios::in);
+
+    CPTAssert(f_in.good());
+
+    f_in.read(cookie, 8192);
+    f_in.close();
+
+    AudioStreamBasicDescription in_dsc = {44100.0, 'XoVs', 0, 0, 0, 0, 2, 0, 0};
+    AudioStreamBasicDescription out_dsc = {44100.0, kAudioFormatLinearPCM,
+                                           kAudioFormatFlagsNativeFloatPacked,
+                                           8, 1, 8, 2, 32, 0};
+
+    mOggDecoder->Initialize(&in_dsc, &out_dsc, NULL, 0);
+
+    CPTAssert(!mOggDecoder->IsInitialized());
+
+    mOggDecoder->Uninitialize();
+
+    CPTAssert(!mOggDecoder->IsInitialized());
+
+    mOggDecoder->Initialize(NULL, NULL, cookie, 4216);
+
+    CPTAssert(mOggDecoder->IsInitialized());
+}
+
+void OggVorbisTests::append_single()
+{
+    std::ifstream f_in;
+    char buffer[16384];
+
+    f_in.open("../tests/data/vorbis.ogg.cookie", std::ios::in);
+
+    CPTAssert(f_in.good());
+
+    f_in.read(buffer, 16384);
+    f_in.close();
+
+    AudioStreamBasicDescription in_dsc = {44100.0, 'XoVs', 0, 0, 0, 0, 2, 0, 0};
+    AudioStreamBasicDescription out_dsc = {44100.0, kAudioFormatLinearPCM,
+                                           kAudioFormatFlagsNativeFloatPacked,
+                                           8, 1, 8, 2, 32, 0};
+
+    mOggDecoder->Initialize(&in_dsc, &out_dsc, buffer, 4216);
+    CPTAssert(mOggDecoder->IsInitialized());
+
+    f_in.open("../tests/data/vorbis.ogg.data", std::ios::in);
+
+    CPTAssert(f_in.good());
+
+    f_in.read(buffer, 16384);
+    f_in.close();
+
+    UInt32 bytes = 4152;
+    UInt32 packets = 1;
+
+    Boolean appended = false;
+
+    AudioStreamPacketDescription pd = {0, 6720, 4152};
+
+    try {
+        mOggDecoder->AppendInputData(buffer, bytes, packets, &pd);
+        appended = true;
+    } catch (...) {
+    };
+
+    CPTAssert(appended == true);
+
+    packets = 6720;
+    bytes = 8 * packets;
+    char audio[bytes];
+    UInt32 ac_ret = kAudioCodecProduceOutputPacketFailure;
+
+    try {
+        ac_ret = mOggDecoder->ProduceOutputPackets(audio, bytes, packets, NULL);
+    } catch (...) {
+        bytes = 0;
+        packets = 0;
+    };
+
+    CPTAssert(ac_ret == kAudioCodecProduceOutputPacketSuccess &&
+              bytes == 53760 && packets == 6720);
+}
+
+void OggVorbisTests::append_multiple()
+{
+    std::ifstream f_in;
+    char buffer[16384];
+
+    f_in.open("../tests/data/vorbis.ogg.cookie", std::ios::in);
+
+    CPTAssert(f_in.good());
+
+    f_in.read(buffer, 16384);
+    f_in.close();
+
+    AudioStreamBasicDescription in_dsc = {44100.0, 'XoVs', 0, 0, 0, 0, 2, 0, 0};
+    AudioStreamBasicDescription out_dsc = {44100.0, kAudioFormatLinearPCM,
+                                           kAudioFormatFlagsNativeFloatPacked,
+                                           8, 1, 8, 2, 32, 0};
+
+    mOggDecoder->Initialize(&in_dsc, &out_dsc, buffer, 4216);
+    CPTAssert(mOggDecoder->IsInitialized());
+
+    f_in.open("../tests/data/vorbis.ogg.data", std::ios::in);
+
+    CPTAssert(f_in.good());
+
+    f_in.read(buffer, 16384);
+    f_in.close();
+
+    UInt32 bytes = 8370;
+    UInt32 packets = 2;
+
+    Boolean appended = false;
+
+    AudioStreamPacketDescription pd[2] = {{0, 6720, 4152}, {4152, 7168, 4218}};
+
+    try {
+        mOggDecoder->AppendInputData(buffer, bytes, packets, pd);
+        appended = true;
+    } catch (...) {
+    };
+
+    CPTAssert(appended == true);
+
+    packets = 6720;
+    bytes = 8 * packets;
+    char audio[bytes];
+    UInt32 ac_ret = kAudioCodecProduceOutputPacketFailure;
+
+    try {
+        ac_ret = mOggDecoder->ProduceOutputPackets(audio, bytes, packets, NULL);
+    } catch (...) {
+        bytes = 0;
+        packets = 0;
+    };
+
+    CPTAssert(ac_ret == kAudioCodecProduceOutputPacketSuccess &&
+              bytes == 53760 && packets == 6720);
+}
+
+/*
+ * The first ogg page contains more/less audio data than indicated by the grpos.
+ * (Vorbis I specification, Section A.2)
+ */
+void OggVorbisTests::audio_offset()
+{
+    std::ifstream f_in;
+    char cookie[8192];
+    char buffer[16384];
+    UInt32 cookie_size = 4216;
+
+    f_in.open("../tests/data/vorbis.ogg.cookie", std::ios::in);
+
+    CPTAssert(f_in.good());
+
+    f_in.read(cookie, 8192);
+    f_in.close();
+
+    AudioStreamBasicDescription in_dsc = {44100.0, 'XoVs', 0, 0, 0, 0, 2, 0, 0};
+    AudioStreamBasicDescription out_dsc = {44100.0, kAudioFormatLinearPCM,
+                                           kAudioFormatFlagsNativeFloatPacked,
+                                           8, 1, 8, 2, 32, 0};
+
+    mOggDecoder->Initialize(&in_dsc, &out_dsc, cookie, cookie_size);
+    CPTAssert(mOggDecoder->IsInitialized());
+
+    f_in.open("../tests/data/vorbis.ogg.data", std::ios::in);
+
+    CPTAssert(f_in.good());
+
+    f_in.read(buffer, 16384);
+    f_in.close();
+
+    UInt32 bytes = 4152;
+    UInt32 packets = 1;
+    UInt32 orig_duration = 6720;
+
+    Boolean appended = false;
+
+    AudioStreamPacketDescription pd = {0, orig_duration, 4152};
+
+    try {
+        mOggDecoder->AppendInputData(buffer, bytes, packets, &pd);
+        appended = true;
+    } catch (...) {
+    };
+
+    CPTAssert(appended == true);
+
+    packets = orig_duration;
+    bytes = 8 * packets;
+    char audio_1[bytes];
+    UInt32 ac_ret = kAudioCodecProduceOutputPacketFailure;
+
+    try {
+        ac_ret = mOggDecoder->ProduceOutputPackets(audio_1, bytes, packets, NULL);
+    } catch (...) {
+        bytes = 0;
+        packets = 0;
+    };
+
+    CPTAssert(ac_ret == kAudioCodecProduceOutputPacketSuccess &&
+              bytes == (orig_duration * 8) && packets == orig_duration);
+
+    /* decode again, increased duration (decoder should prepend zeros) */
+    mOggDecoder->Reset();
+    mOggDecoder->Uninitialize();
+    CPTAssert(!mOggDecoder->IsInitialized());
+
+    mOggDecoder->Initialize(&in_dsc, &out_dsc, cookie, cookie_size);
+    CPTAssert(mOggDecoder->IsInitialized());
+
+    bytes = 4152;
+    packets = 1;
+    appended = false;
+    UInt32 inc_duration = 6721;
+
+    pd.mStartOffset = 0;
+    pd.mVariableFramesInPacket = inc_duration;
+    pd.mDataByteSize = 4152;
+
+    try {
+        mOggDecoder->AppendInputData(buffer, bytes, packets, &pd);
+        appended = true;
+    } catch (...) {
+    };
+
+    CPTAssert(appended == true);
+
+    packets = inc_duration;
+    bytes = 8 * packets;
+    char audio_2[bytes];
+    char audio_z[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+    ac_ret = kAudioCodecProduceOutputPacketFailure;
+
+    try {
+        ac_ret = mOggDecoder->ProduceOutputPackets(audio_2, bytes, packets, NULL);
+    } catch (...) {
+        bytes = 0;
+        packets = 0;
+    };
+
+    CPTAssert(ac_ret == kAudioCodecProduceOutputPacketSuccess &&
+              bytes == (inc_duration * 8) && packets == inc_duration);
+    CPTAssert(memcmp(audio_2, audio_z, 8) == 0);
+    CPTAssert(memcmp(audio_2 + ((inc_duration - orig_duration) * 8),
+                     audio_1, (orig_duration * 8)) == 0);
+
+    /* decode again, decreased duration (decoder should truncate head) */
+    mOggDecoder->Reset();
+    mOggDecoder->Uninitialize();
+    CPTAssert(!mOggDecoder->IsInitialized());
+
+    mOggDecoder->Initialize(&in_dsc, &out_dsc, cookie, cookie_size);
+    CPTAssert(mOggDecoder->IsInitialized());
+
+    bytes = 4152;
+    packets = 1;
+    appended = false;
+    UInt32 dec_duration_1 = 6716;
+
+    pd.mStartOffset = 0;
+    pd.mVariableFramesInPacket = dec_duration_1;
+    pd.mDataByteSize = 4152;
+
+    try {
+        mOggDecoder->AppendInputData(buffer, bytes, packets, &pd);
+        appended = true;
+    } catch (...) {
+    };
+
+    CPTAssert(appended == true);
+
+    packets = dec_duration_1;
+    bytes = 8 * packets;
+    ac_ret = kAudioCodecProduceOutputPacketFailure;
+
+    try {
+        ac_ret = mOggDecoder->ProduceOutputPackets(audio_2, bytes, packets, NULL);
+    } catch (...) {
+        bytes = 0;
+        packets = 0;
+    };
+
+    CPTAssert(ac_ret == kAudioCodecProduceOutputPacketSuccess &&
+              bytes == (dec_duration_1 * 8) && packets == dec_duration_1);
+    CPTAssert(memcmp(audio_2, audio_1 + ((orig_duration - dec_duration_1) * 8),
+                     (dec_duration_1 * 8)) == 0);
+
+    /* decode again, duration decreased a lot */
+    mOggDecoder->Reset();
+    mOggDecoder->Uninitialize();
+    CPTAssert(!mOggDecoder->IsInitialized());
+
+    mOggDecoder->Initialize(&in_dsc, &out_dsc, cookie, cookie_size);
+    CPTAssert(mOggDecoder->IsInitialized());
+
+    bytes = 4152;
+    packets = 1;
+    appended = false;
+    UInt32 dec_duration_2 = 2560;
+
+    pd.mStartOffset = 0;
+    pd.mVariableFramesInPacket = dec_duration_2;
+    pd.mDataByteSize = 4152;
+
+    try {
+        mOggDecoder->AppendInputData(buffer, bytes, packets, &pd);
+        appended = true;
+    } catch (...) {
+    };
+
+    CPTAssert(appended == true);
+
+    packets = dec_duration_2;
+    bytes = 8 * packets;
+    ac_ret = kAudioCodecProduceOutputPacketFailure;
+
+    try {
+        ac_ret = mOggDecoder->ProduceOutputPackets(audio_2, bytes, packets, NULL);
+    } catch (...) {
+        bytes = 0;
+        packets = 0;
+    };
+
+    CPTAssert(ac_ret == kAudioCodecProduceOutputPacketSuccess &&
+              bytes == (dec_duration_2 * 8) && packets == dec_duration_2);
+    CPTAssert(memcmp(audio_2, audio_1 + ((orig_duration - dec_duration_2) * 8),
+                     (dec_duration_2 * 8)) == 0);
+}
+
+
+OggVorbisTests t_OV_noop(TEST_INVOCATION(OggVorbisTests, noop));
+OggVorbisTests t_OV_append_uninitialized(TEST_INVOCATION(OggVorbisTests,
+                                                         append_uninitialized));
+OggVorbisTests t_OV_init_cookie(TEST_INVOCATION(OggVorbisTests, init_cookie));
+OggVorbisTests t_OV_append_single(TEST_INVOCATION(OggVorbisTests, append_single));
+OggVorbisTests t_OV_append_multiple(TEST_INVOCATION(OggVorbisTests,
+                                                    append_multiple));
+OggVorbisTests t_OV_audio_offset(TEST_INVOCATION(OggVorbisTests, audio_offset));

Copied: trunk/xiph-qt/tests/CAVorbis/OggVorbisTests.h (from rev 12796, trunk/xiph-qt/tests/CAFLAC/OggFLACTests.h)
===================================================================
--- trunk/xiph-qt/tests/CAFLAC/OggFLACTests.h	2007-03-22 12:01:49 UTC (rev 12796)
+++ trunk/xiph-qt/tests/CAVorbis/OggVorbisTests.h	2007-03-27 22:09:32 UTC (rev 12814)
@@ -0,0 +1,50 @@
+/*
+ *  OggVorbisTests.h
+ *
+ *    CAOggVorbisDecoder class test cases header file.
+ *
+ *
+ *  Copyright (c) 2007  Arek Korbik
+ *
+ *  This file is part of XiphQT, the Xiph QuickTime Components.
+ *
+ *  XiphQT is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  XiphQT 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
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with XiphQT; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ *
+ *  Last modified: $Id$
+ *
+ */
+
+
+#include <CPlusTest/CPlusTest.h>
+#include "CAOggVorbisDecoder.h"
+
+class OggVorbisTests : public TestCase {
+public:
+    OggVorbisTests(TestInvocation* invocation);
+    virtual ~OggVorbisTests();
+
+    void setUp();
+    void tearDown();
+
+    CAOggVorbisDecoder *mOggDecoder;
+
+    void noop();
+    void append_uninitialized();
+    void init_cookie();
+    void append_single();
+    void append_multiple();
+    void audio_offset();
+};



More information about the commits mailing list