[xiph-commits] r12435 - in trunk/xiph-qt: . build-macosx/XiphQT.xcodeproj common tests/common

arek at svn.xiph.org arek at svn.xiph.org
Mon Feb 5 17:49:36 PST 2007


Author: arek
Date: 2007-02-05 17:49:26 -0800 (Mon, 05 Feb 2007)
New Revision: 12435

Added:
   trunk/xiph-qt/tests/common/XCACodecTests.cpp
   trunk/xiph-qt/tests/common/XCACodecTests.h
Modified:
   trunk/xiph-qt/AUTHORS
   trunk/xiph-qt/build-macosx/XiphQT.xcodeproj/project.pbxproj
   trunk/xiph-qt/common/XCACodec.cpp
Log:
Checking for zero-sized input on decoding.

Modified: trunk/xiph-qt/AUTHORS
===================================================================
--- trunk/xiph-qt/AUTHORS	2007-02-06 01:19:26 UTC (rev 12434)
+++ trunk/xiph-qt/AUTHORS	2007-02-06 01:49:26 UTC (rev 12435)
@@ -1 +1,5 @@
 Arek Korbik  <arkadini at gmail.com>
+  - development
+
+Jan Gerber
+  - testing, bug fixes

Modified: trunk/xiph-qt/build-macosx/XiphQT.xcodeproj/project.pbxproj
===================================================================
--- trunk/xiph-qt/build-macosx/XiphQT.xcodeproj/project.pbxproj	2007-02-06 01:19:26 UTC (rev 12434)
+++ trunk/xiph-qt/build-macosx/XiphQT.xcodeproj/project.pbxproj	2007-02-06 01:49:26 UTC (rev 12435)
@@ -54,6 +54,7 @@
 		7326B54A0B5AC44B004CE9D3 /* CAFLACDecoderPublic.r in Rez */ = {isa = PBXBuildFile; fileRef = 73744C6C0B1A2B78002B059E /* CAFLACDecoderPublic.r */; };
 		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 */; };
 		737448B60B19EC05002B059E /* common.c in Sources */ = {isa = PBXBuildFile; fileRef = 7374489F0B19EC05002B059E /* common.c */; };
 		737448B70B19EC05002B059E /* OggImport.c in Sources */ = {isa = PBXBuildFile; fileRef = 737448A20B19EC05002B059E /* OggImport.c */; };
 		737448B80B19EC05002B059E /* rb.c in Sources */ = {isa = PBXBuildFile; fileRef = 737448A50B19EC05002B059E /* rb.c */; };
@@ -369,6 +370,8 @@
 		7326B5520B5AC44B004CE9D3 /* Info (decoders).plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "Info (decoders).plist"; sourceTree = "<group>"; };
 		73271C820B610B2400175874 /* RingBufferTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RingBufferTests.h; path = ../tests/common/RingBufferTests.h; sourceTree = SOURCE_ROOT; };
 		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; };
 		7374489F0B19EC05002B059E /* common.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = common.c; path = ../OggImport/src/common.c; sourceTree = SOURCE_ROOT; };
 		737448A00B19EC05002B059E /* common.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = common.h; path = ../OggImport/src/common.h; sourceTree = SOURCE_ROOT; };
 		737448A10B19EC05002B059E /* importer_types.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = importer_types.h; path = ../OggImport/src/importer_types.h; sourceTree = SOURCE_ROOT; };
@@ -654,6 +657,8 @@
 		73271C7F0B610A9600175874 /* common */ = {
 			isa = PBXGroup;
 			children = (
+				734716820B77F72E001F439D /* XCACodecTests.cpp */,
+				734716830B77F72E001F439D /* XCACodecTests.h */,
 				73271C820B610B2400175874 /* RingBufferTests.h */,
 				73271C830B610B2400175874 /* RingBufferTests.cpp */,
 			);
@@ -1339,6 +1344,7 @@
 				73C752F10B5FD8BB00615F6C /* ringbuffer.cpp in Sources */,
 				73C752F30B5FD8D300615F6C /* GetCodecBundle.cpp in Sources */,
 				73271C840B610B2400175874 /* RingBufferTests.cpp in Sources */,
+				734716840B77F72E001F439D /* XCACodecTests.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/xiph-qt/common/XCACodec.cpp
===================================================================
--- trunk/xiph-qt/common/XCACodec.cpp	2007-02-06 01:19:26 UTC (rev 12434)
+++ trunk/xiph-qt/common/XCACodec.cpp	2007-02-06 01:49:26 UTC (rev 12435)
@@ -69,7 +69,10 @@
                 packet++;
                 packets_added++;
             }
-        } else {
+        } else if (mInputFormat.mBytesPerFrame != 0) { /* inPacketDescription == NULL here, but it's and error condition
+                                                          if we're doing decoding (mInputFormat.mBytesPerFrame == 0), so
+                                                          skip this branch -- thanks to Jan Gerber for spotting it. */
+
             if (ioInputDataByteSize < bytesToCopy)
                 bytesToCopy = ioInputDataByteSize;
 

Added: trunk/xiph-qt/tests/common/XCACodecTests.cpp
===================================================================
--- trunk/xiph-qt/tests/common/XCACodecTests.cpp	2007-02-06 01:19:26 UTC (rev 12434)
+++ trunk/xiph-qt/tests/common/XCACodecTests.cpp	2007-02-06 01:49:26 UTC (rev 12435)
@@ -0,0 +1,114 @@
+/*
+ *  XCACodecTests.cpp
+ *
+ *    XCACodec 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 "XCACodecTests.h"
+
+
+XCACodecTests::XCACodecTests(TestInvocation *invocation)
+    : TestCase(invocation)
+{
+}
+
+
+XCACodecTests::~XCACodecTests()
+{
+}
+
+void XCACodecTests::setUp()
+{
+    //mCodec = new XCACodec();
+    mCodec = new test_XCACodec();
+}
+
+void XCACodecTests::tearDown()
+{
+    delete mCodec;
+    mCodec = NULL;
+}
+
+void XCACodecTests::noop()
+{
+}
+
+void XCACodecTests::append_uninitialized()
+{
+    UInt32 bytes = 0;
+    UInt32 packets = 0;
+
+    Boolean appended = false;
+
+    try {
+        mCodec->AppendInputData(NULL, bytes, packets, NULL);
+        appended = true;
+    } catch (...) {
+    };
+
+    CPTAssert(appended == false);
+}
+
+void XCACodecTests::append_zero()
+{
+    UInt32 bytes = 0;
+    UInt32 packets = 0;
+
+    Boolean appended = false;
+    Boolean other_error = false;
+    ComponentResult ac_error = kAudioCodecNoError;
+
+    mCodec->Initialize(NULL, NULL, NULL, 0);
+    CPTAssert(mCodec->IsInitialized());
+
+    try {
+        mCodec->AppendInputData(NULL, bytes, packets, NULL);
+        appended = true;
+    } catch (ComponentResult acError) {
+        ac_error = acError;
+    } catch (...) {
+        other_error = true;
+    };
+
+    CPTAssert(appended == false);
+    CPTAssert(bytes == 0);
+    CPTAssert(packets == 0);
+    CPTAssert(other_error == false);
+
+    /* There is no apparent appropriate error code for 0-sized input
+       on decoding, NotEnoughBufferSpace seems to do the trick on both
+       PPC/Intel. */
+    CPTAssert(ac_error == kAudioCodecNotEnoughBufferSpaceError);
+
+    mCodec->Uninitialize();
+    CPTAssert(mCodec->IsInitialized() == false);
+}
+
+XCACodecTests t_xcac_noop(TEST_INVOCATION(XCACodecTests, noop));
+XCACodecTests t_xcac_append_uninitialized(TEST_INVOCATION(XCACodecTests,
+                                                          append_uninitialized));
+XCACodecTests t_xcac_append_zero(TEST_INVOCATION(XCACodecTests, append_zero));


Property changes on: trunk/xiph-qt/tests/common/XCACodecTests.cpp
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/xiph-qt/tests/common/XCACodecTests.h
===================================================================
--- trunk/xiph-qt/tests/common/XCACodecTests.h	2007-02-06 01:19:26 UTC (rev 12434)
+++ trunk/xiph-qt/tests/common/XCACodecTests.h	2007-02-06 01:49:26 UTC (rev 12435)
@@ -0,0 +1,61 @@
+/*
+ *  XCACodecTests.h
+ *
+ *    XCACodec 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 "XCACodec.h"
+
+class test_XCACodec : public XCACodec {
+ protected:
+    virtual void InPacket(const void* inInputData,
+                          const AudioStreamPacketDescription* inPacketDescription) {};
+
+    virtual UInt32 FramesReady() const { return 0; };
+    virtual Boolean GenerateFrames() { return false; };
+    virtual void OutputFrames(void* outOutputData, UInt32 inNumberFrames,
+                              UInt32 inFramesOffset,
+                              AudioStreamPacketDescription* outPacketDescription) const {};
+    virtual void Zap(UInt32 inFrames) {};
+
+};
+
+class XCACodecTests : public TestCase {
+public:
+    XCACodecTests(TestInvocation* invocation);
+    virtual ~XCACodecTests();
+
+    void setUp();
+    void tearDown();
+
+    XCACodec *mCodec;
+
+    void noop();
+    void append_uninitialized();
+    void append_zero();
+};


Property changes on: trunk/xiph-qt/tests/common/XCACodecTests.h
___________________________________________________________________
Name: svn:keywords
   + Id



More information about the commits mailing list