[xiph-commits] r11324 - in trunk/xiph-qt: OggImport/OggImport.xcodeproj OggImport/src common

arek at svn.xiph.org arek at svn.xiph.org
Sun Apr 30 15:24:40 PDT 2006


Author: arek
Date: 2006-04-30 15:24:28 -0700 (Sun, 30 Apr 2006)
New Revision: 11324

Added:
   trunk/xiph-qt/OggImport/src/utils.c
   trunk/xiph-qt/OggImport/src/utils.h
Modified:
   trunk/xiph-qt/OggImport/OggImport.xcodeproj/project.pbxproj
   trunk/xiph-qt/OggImport/src/importer_types.h
   trunk/xiph-qt/OggImport/src/stream_flac.c
   trunk/xiph-qt/OggImport/src/stream_speex.c
   trunk/xiph-qt/OggImport/src/stream_theora.c
   trunk/xiph-qt/common/data_types.h
   trunk/xiph-qt/common/fccs.h
Log:
Disabled changing of movie timescale and added vorbis comments handling in speex streams; some code organization and cleanup.

Modified: trunk/xiph-qt/OggImport/OggImport.xcodeproj/project.pbxproj
===================================================================
--- trunk/xiph-qt/OggImport/OggImport.xcodeproj/project.pbxproj	2006-04-30 22:09:34 UTC (rev 11323)
+++ trunk/xiph-qt/OggImport/OggImport.xcodeproj/project.pbxproj	2006-04-30 22:24:28 UTC (rev 11324)
@@ -19,6 +19,7 @@
 		73182D9F090AB83F00C25A13 /* Vorbis.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 73182D9E090AB83F00C25A13 /* Vorbis.framework */; };
 		73182E37090AD49700C25A13 /* stream_vorbis.c in Sources */ = {isa = PBXBuildFile; fileRef = 73182E35090AD49700C25A13 /* stream_vorbis.c */; };
 		7321B3690A022B20004A699F /* TheoraExp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7321B3680A022B20004A699F /* TheoraExp.framework */; };
+		7321B3990A03BC0A004A699F /* utils.c in Sources */ = {isa = PBXBuildFile; fileRef = 7321B3970A03BC0A004A699F /* utils.c */; };
 		73A515E509844E1D0018101A /* stream_flac.c in Sources */ = {isa = PBXBuildFile; fileRef = 73A515E209844E1D0018101A /* stream_flac.c */; };
 		73BED3E709D77E8500ACC195 /* stream_theora.c in Sources */ = {isa = PBXBuildFile; fileRef = 73BED3E409D77E8500ACC195 /* stream_theora.c */; };
 		73E8B16D090BE13600686EE5 /* stream_speex.c in Sources */ = {isa = PBXBuildFile; fileRef = 73E8B16A090BE13600686EE5 /* stream_speex.c */; };
@@ -89,6 +90,8 @@
 		73182E35090AD49700C25A13 /* stream_vorbis.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = stream_vorbis.c; path = src/stream_vorbis.c; sourceTree = "<group>"; };
 		73182E4C090AE29000C25A13 /* stream_types_vorbis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = stream_types_vorbis.h; path = src/stream_types_vorbis.h; sourceTree = "<group>"; };
 		7321B3680A022B20004A699F /* TheoraExp.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TheoraExp.framework; path = /Library/Frameworks/TheoraExp.framework; sourceTree = "<absolute>"; };
+		7321B3970A03BC0A004A699F /* utils.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = utils.c; path = src/utils.c; sourceTree = "<group>"; };
+		7321B3980A03BC0A004A699F /* utils.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = utils.h; path = src/utils.h; sourceTree = "<group>"; };
 		737C5A6D0912A05200700B79 /* fccs.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = fccs.h; path = ../common/fccs.h; sourceTree = SOURCE_ROOT; };
 		738602C50915732900CB8105 /* icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = icon.icns; path = ../resources/icon.icns; sourceTree = SOURCE_ROOT; };
 		738602C60915732900CB8105 /* icon.r */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.rez; name = icon.r; path = ../resources/icon.r; sourceTree = SOURCE_ROOT; };
@@ -165,6 +168,8 @@
 		08FB77ADFE841716C02AAC07 /* Source */ = {
 			isa = PBXGroup;
 			children = (
+				7321B3970A03BC0A004A699F /* utils.c */,
+				7321B3980A03BC0A004A699F /* utils.h */,
 				73BED3E309D77E6300ACC195 /* theora */,
 				73A515E109844DF70018101A /* flac */,
 				73E8B169090BE11D00686EE5 /* speex */,
@@ -343,6 +348,7 @@
 				73E8B16D090BE13600686EE5 /* stream_speex.c in Sources */,
 				73A515E509844E1D0018101A /* stream_flac.c in Sources */,
 				73BED3E709D77E8500ACC195 /* stream_theora.c in Sources */,
+				7321B3990A03BC0A004A699F /* utils.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/xiph-qt/OggImport/src/importer_types.h
===================================================================
--- trunk/xiph-qt/OggImport/src/importer_types.h	2006-04-30 22:09:34 UTC (rev 11323)
+++ trunk/xiph-qt/OggImport/src/importer_types.h	2006-04-30 22:24:28 UTC (rev 11324)
@@ -104,6 +104,8 @@
 
     TimeValue           incompleteCompensation;
 
+    TimeValue           lastMediaInserted;
+    TimeValue           mediaLength;
     TimeValue           insertTime;
     TimeValue           streamOffset;
     // SInt32              sampleOffset;

Modified: trunk/xiph-qt/OggImport/src/stream_flac.c
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_flac.c	2006-04-30 22:09:34 UTC (rev 11323)
+++ trunk/xiph-qt/OggImport/src/stream_flac.c	2006-04-30 22:24:28 UTC (rev 11324)
@@ -39,42 +39,9 @@
 
 #include "fccs.h"
 #include "data_types.h"
+#include "utils.h"
 
 
-static int unpack_vorbis_coments(vorbis_comment *vc, const void *data, UInt32 data_size)
-{
-    int i;
-    char *dptr = (char *) data;
-    char *dend = dptr + data_size;
-    int len = EndianU32_LtoN(*(UInt32 *)dptr);
-    int commnum = 0;
-    char save;
-
-    dptr += 4 + len;
-    if (len >= 0 && dptr < dend) {
-        commnum = EndianU32_LtoN(*(UInt32 *)dptr);
-        if (commnum >= 0) {
-            dptr += 4;
-
-            for (i = 0; i < commnum && dptr <= dend; i++) {
-                len = EndianU32_LtoN(*(UInt32 *)dptr);
-                dptr += 4;
-                if (dptr + len > dend)
-                    break;
-
-                save = *(dptr + len);
-                *(dptr + len) = '\0';
-                vorbis_comment_add(vc, dptr);
-                dptr += len;
-                *dptr = save;
-            }
-        }
-    }
-
-    //vorbis_comment_clear(vc);
-    return 0;
-}
-
 int recognize_header__flac(ogg_page *op)
 {
     char fh[] = {0x7f, 'F', 'L', 'A', 'C', '\0'};
@@ -233,7 +200,7 @@
                 if (((* (char *) op.packet) & 0x7f) == 4) {
                     dbg_printf("!  > - flac_stream_page - mb: %ld, skipped: %ld, h: %02x\n", si->si_flac.metablocks, si->si_flac.skipped,
                                (*(char *) op.packet) & 0x7f);
-                    unpack_vorbis_coments(&si->si_flac.vc, ((char *) op.packet) + 4, op.bytes - 4);
+                    unpack_vorbis_comments(&si->si_flac.vc, ((char *) op.packet) + 4, op.bytes - 4);
                     /*err =*/ DecodeCommentsQT(globals, si, &si->si_flac.vc);
                     //NotifyMovieChanged(globals);
                 }
@@ -289,7 +256,7 @@
                 if (((* (unsigned char *) op.packet) & 0x7f) == 4) {
                     dbg_printf("!  > - flac_stream_page - mb: %ld, skipped: %ld, h: %02x\n", si->si_flac.metablocks, si->si_flac.skipped,
                                (*(char *) op.packet) & 0x7f);
-                    unpack_vorbis_coments(&si->si_flac.vc, ((char *) op.packet) + 4, op.bytes - 4);
+                    unpack_vorbis_comments(&si->si_flac.vc, ((char *) op.packet) + 4, op.bytes - 4);
                     /*err =*/ DecodeCommentsQT(globals, si, &si->si_flac.vc);
                     //NotifyMovieChanged(globals);
                 }

Modified: trunk/xiph-qt/OggImport/src/stream_speex.c
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_speex.c	2006-04-30 22:09:34 UTC (rev 11323)
+++ trunk/xiph-qt/OggImport/src/stream_speex.c	2006-04-30 22:24:28 UTC (rev 11324)
@@ -39,8 +39,8 @@
 
 #include "fccs.h"
 #include "data_types.h"
+#include "utils.h"
 
-
 int recognize_header__speex(ogg_page *op)
 {
     if (!strncmp("Speex   ", (char *)op->body, 8))
@@ -117,7 +117,6 @@
                                       EndianS32_NtoB(ogg_page_serialno(op)) };
     unsigned long atomhead[2] = { EndianU32_NtoB(opckt->bytes + sizeof(atomhead)), EndianU32_NtoB(kCookieTypeSpeexHeader) };
     SpeexHeader *inheader = (SpeexHeader *) opckt->packet;
-    //vorbis_synthesis_headerin(&si->si_vorbis.vi, &si->si_vorbis.vc, opckt); //check errors?
 
     si->si_speex.header.bitrate =                 EndianS32_LtoN(inheader->bitrate);
     si->si_speex.header.extra_headers =           EndianS32_LtoN(inheader->extra_headers);
@@ -179,14 +178,14 @@
 
                 PtrAndHand(atomhead, si->soundDescExtension, sizeof(atomhead));
                 PtrAndHand(op.packet, si->soundDescExtension, op.bytes);
-                //vorbis_synthesis_headerin(&si->si_vorbis.vi, &si->si_vorbis.vc, &op);
 
                 ret = CreateTrackAndMedia(globals, si, opg);
                 if (ret != noErr) {
                     dbg_printf("??? -- CreateTrackAndMedia failed?: %ld\n", (long)ret);
                 }
 
-                // /*err =*/ DecodeCommentsQT(globals, si, &si->si_vorbis.vc);
+                unpack_vorbis_comments(&si->si_speex.vc, op.packet, op.bytes);
+                /*err =*/ DecodeCommentsQT(globals, si, &si->si_speex.vc);
                 //NotifyMovieChanged(globals);
 
                 si->si_speex.state = kSStateReadingAdditionalHeaders;
@@ -292,11 +291,13 @@
                                 SetTrackEnabled(si->theTrack, true);
                             }
                         }
+                        /*
                         if (GetMovieTimeScale(globals->theMovie) < GetMediaTimeScale(si->theMedia)) {
                             dbg_printf("   # - changing movie time scale: %ld --> %ld\n",
                                        GetMovieTimeScale(globals->theMovie), GetMediaTimeScale(si->theMedia));
                             SetMovieTimeScale(globals->theMovie, GetMediaTimeScale(si->theMedia));
                         }
+                        */
                     }
                     si->insertTime = -1;
                     timeLoaded = GetTrackOffset(si->theTrack) + GetTrackDuration(si->theTrack);

Modified: trunk/xiph-qt/OggImport/src/stream_theora.c
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_theora.c	2006-04-30 22:09:34 UTC (rev 11323)
+++ trunk/xiph-qt/OggImport/src/stream_theora.c	2006-04-30 22:24:28 UTC (rev 11324)
@@ -292,7 +292,7 @@
                     ret = PtrAndHand(endAtom, si->soundDescExtension, sizeof(endAtom));
                     if (ret == noErr) {
                         ret = AddImageDescriptionExtension((ImageDescriptionHandle) si->sampleDesc,
-                                                           si->soundDescExtension, 'XYZ?' /* siDecompressionParams */);
+                                                           si->soundDescExtension, kSampleDescriptionExtensionTheora);
                         //dbg_printf("??? -- Adding extension: %ld\n", ret);
                     } else {
                         //dbg_printf("??? -- Hmm, something went wrong: %ld\n", ret);
@@ -317,21 +317,6 @@
                     si->lastGranulePos = 0;
             }
             si->si_theora.state = kTStateReadingPackets;
-#if 0
-            {
-                Handle h = NewHandleClear(sizeof(si->si_theora));
-                ret = BeginMediaEdits(si->theMedia);
-                dbg_printf("! -T-XXX:: ret = %ld\n", ret);
-                ret = AddMediaSample(si->theMedia, h, 0, sizeof(si->si_theora), 249, si->sampleDesc, 1, 0, NULL);
-                dbg_printf("! -T-XXX:: ret = %ld\n", ret);
-                ret = EndMediaEdits(si->theMedia);
-                dbg_printf("! -T-XXX:: ret = %ld\n", ret);
-                ret = InsertMediaIntoTrack(si->theTrack, si->insertTime /*inserted*/, /* si->lastGranulePos */ 0,
-                                           249, fixed1);
-                dbg_printf("! -T-XXX:: ret = %ld\n", ret);
-                si->insertTime = -1;
-            }
-#endif /* 0 */
             break;
 
         case kTStateReadingPackets:

Added: trunk/xiph-qt/OggImport/src/utils.c
===================================================================
--- trunk/xiph-qt/OggImport/src/utils.c	2006-04-30 22:09:34 UTC (rev 11323)
+++ trunk/xiph-qt/OggImport/src/utils.c	2006-04-30 22:24:28 UTC (rev 11324)
@@ -0,0 +1,65 @@
+/*
+ *  utils.c
+ *
+ *    Small support functions for ogg processing.
+ *
+ *
+ *  Copyright (c) 2006  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 "debug.h"
+#include "utils.h"
+
+int unpack_vorbis_comments(vorbis_comment *vc, const void *data, UInt32 data_size)
+{
+    int i;
+    char *dptr = (char *) data;
+    char *dend = dptr + data_size;
+    int len = EndianU32_LtoN(*(UInt32 *)dptr);
+    int commnum = 0;
+    char save;
+
+    dptr += 4 + len;
+    if (len >= 0 && dptr < dend) {
+        commnum = EndianU32_LtoN(*(UInt32 *)dptr);
+        if (commnum >= 0) {
+            dptr += 4;
+
+            for (i = 0; i < commnum && dptr <= dend; i++) {
+                len = EndianU32_LtoN(*(UInt32 *)dptr);
+                dptr += 4;
+                if (dptr + len > dend)
+                    break;
+
+                save = *(dptr + len);
+                *(dptr + len) = '\0';
+                vorbis_comment_add(vc, dptr);
+                dptr += len;
+                *dptr = save;
+            }
+        }
+    }
+
+    return 0;
+}


Property changes on: trunk/xiph-qt/OggImport/src/utils.c
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/xiph-qt/OggImport/src/utils.h
===================================================================
--- trunk/xiph-qt/OggImport/src/utils.h	2006-04-30 22:09:34 UTC (rev 11323)
+++ trunk/xiph-qt/OggImport/src/utils.h	2006-04-30 22:24:28 UTC (rev 11324)
@@ -0,0 +1,39 @@
+/*
+ *  utils.h
+ *
+ *    Support functions header file.
+ *
+ *
+ *  Copyright (c) 2006  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$
+ *
+ */
+
+
+#if !defined(__ogg_utils_h__)
+#define __ogg_utils_h__
+
+#include <Vorbis/codec.h>
+
+extern int unpack_vorbis_comments(vorbis_comment *vc, const void *data, UInt32 data_size);
+
+
+#endif /* __ogg_utils_h__ */


Property changes on: trunk/xiph-qt/OggImport/src/utils.h
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: trunk/xiph-qt/common/data_types.h
===================================================================
--- trunk/xiph-qt/common/data_types.h	2006-04-30 22:09:34 UTC (rev 11323)
+++ trunk/xiph-qt/common/data_types.h	2006-04-30 22:24:28 UTC (rev 11324)
@@ -63,6 +63,12 @@
     kCookieTypeFLACMetadata = 'fCtM'
 };
 
+
+enum {
+    kSampleDescriptionExtensionTheora = 'XdxT',
+};
+
+
 struct OggSerialNoAtom {
     long size;			// = sizeof(OggSerialNoAtom)
     long type;			// = kOggCookieSerialNoType

Modified: trunk/xiph-qt/common/fccs.h
===================================================================
--- trunk/xiph-qt/common/fccs.h	2006-04-30 22:09:34 UTC (rev 11323)
+++ trunk/xiph-qt/common/fccs.h	2006-04-30 22:24:28 UTC (rev 11324)
@@ -36,6 +36,8 @@
 
 
 enum {
+    kXiphComponentsManufacturer             = 'Xiph',
+
     kAudioFormatXiphVorbis                  = 'XiVs',
     kAudioFormatXiphOggFramedVorbis         = 'XoVs',
 
@@ -44,6 +46,8 @@
 
     kAudioFormatXiphFLAC                    = 'XiFL',
     kAudioFormatXiphOggFramedFLAC           = 'XoFL',
+
+    kVideoFormatXiphTheora                  = 'XiTh'
 };
 
 



More information about the commits mailing list