diff --git a/content/media/ogg/Makefile.in b/content/media/ogg/Makefile.in index d8eff6105e4..1528f257ed4 100644 --- a/content/media/ogg/Makefile.in +++ b/content/media/ogg/Makefile.in @@ -47,13 +47,11 @@ LIBXUL_LIBRARY = 1 EXPORTS += \ - nsChannelReader.h \ nsOggDecoder.h \ nsOggCodecState.h \ $(NULL) CPPSRCS = \ - nsChannelReader.cpp \ nsOggDecoder.cpp \ nsOggCodecState.cpp \ nsOggReader.cpp \ diff --git a/content/media/ogg/nsChannelReader.cpp b/content/media/ogg/nsChannelReader.cpp deleted file mode 100644 index 2e935628613..00000000000 --- a/content/media/ogg/nsChannelReader.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla code. - * - * The Initial Developer of the Original Code is the Mozilla Corporation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Double - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#include "nsAString.h" -#include "nsThreadUtils.h" -#include "nsNetUtil.h" -#include "prlog.h" -#include "nsOggDecoder.h" -#include "nsChannelReader.h" -#include "nsIScriptSecurityManager.h" - -OggPlayErrorCode nsChannelReader::initialise(int aBlock) -{ - return E_OGGPLAY_OK; -} - -OggPlayErrorCode nsChannelReader::destroy() -{ - // We don't have to do anything here, the decoder will clean stuff up - return E_OGGPLAY_OK; -} - -void nsChannelReader::SetLastFrameTime(PRInt64 aTime) -{ - mLastFrameTime = aTime; -} - -size_t nsChannelReader::io_read(char* aBuffer, size_t aCount) -{ - PRUint32 bytes = 0; - nsresult rv = mStream->Read(aBuffer, aCount, &bytes); - if (!NS_SUCCEEDED(rv)) { - return static_cast(OGGZ_ERR_SYSTEM); - } - nsOggDecoder* decoder = - static_cast(mStream->Decoder()); - decoder->NotifyBytesConsumed(bytes); - return bytes; -} - -int nsChannelReader::io_seek(long aOffset, int aWhence) -{ - nsresult rv = mStream->Seek(aWhence, aOffset); - if (NS_SUCCEEDED(rv)) - return aOffset; - - return OGGZ_STOP_ERR; -} - -long nsChannelReader::io_tell() -{ - return mStream->Tell(); -} - -ogg_int64_t nsChannelReader::duration() -{ - return mLastFrameTime; -} - -static OggPlayErrorCode oggplay_channel_reader_initialise(OggPlayReader* aReader, int aBlock) -{ - nsChannelReader * me = static_cast(aReader); - - if (me == NULL) { - return E_OGGPLAY_BAD_READER; - } - return me->initialise(aBlock); -} - -static OggPlayErrorCode oggplay_channel_reader_destroy(OggPlayReader* aReader) -{ - nsChannelReader* me = static_cast(aReader); - return me->destroy(); -} - -static size_t oggplay_channel_reader_io_read(void* aReader, void* aBuffer, size_t aCount) -{ - nsChannelReader* me = static_cast(aReader); - return me->io_read(static_cast(aBuffer), aCount); -} - -static int oggplay_channel_reader_io_seek(void* aReader, long aOffset, int aWhence) -{ - nsChannelReader* me = static_cast(aReader); - return me->io_seek(aOffset, aWhence); -} - -static long oggplay_channel_reader_io_tell(void* aReader) -{ - nsChannelReader* me = static_cast(aReader); - return me->io_tell(); -} - -static ogg_int64_t oggplay_channel_reader_duration(struct _OggPlayReader *aReader) -{ - nsChannelReader* me = static_cast(aReader); - return me->duration(); -} - -void nsChannelReader::Init(nsMediaStream* aStream) -{ - mStream = aStream; -} - -nsChannelReader::~nsChannelReader() -{ - MOZ_COUNT_DTOR(nsChannelReader); -} - -nsChannelReader::nsChannelReader() : - mLastFrameTime(-1) -{ - MOZ_COUNT_CTOR(nsChannelReader); - OggPlayReader* reader = this; - reader->initialise = &oggplay_channel_reader_initialise; - reader->destroy = &oggplay_channel_reader_destroy; - reader->seek = 0; - reader->io_read = &oggplay_channel_reader_io_read; - reader->io_seek = &oggplay_channel_reader_io_seek; - reader->io_tell = &oggplay_channel_reader_io_tell; - reader->duration = &oggplay_channel_reader_duration; -} diff --git a/content/media/ogg/nsChannelReader.h b/content/media/ogg/nsChannelReader.h deleted file mode 100644 index 316fd2a469e..00000000000 --- a/content/media/ogg/nsChannelReader.h +++ /dev/null @@ -1,87 +0,0 @@ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla code. - * - * The Initial Developer of the Original Code is the Mozilla Corporation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Double - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#if !defined(nsChannelReader_h_) -#define nsChannelReader_h_ - -#include "nsAutoPtr.h" -#include "nsMediaStream.h" - -#include "oggplay/oggplay.h" - -class nsIURI; -class nsIChannel; -class nsIStreamListener; -class nsMediaDecoder; - -class nsChannelReader : public OggPlayReader -{ -public: - nsChannelReader(); - ~nsChannelReader(); - - /** - * Initialize the reader with the media stream. - * This takes ownership of aStream. - */ - void Init(nsMediaStream* aStream); - - nsMediaStream* Stream() { return mStream; } - - // Set the time of the last frame. This is returned in duration() to - // liboggplay. Call with decoder lock obtained so that liboggplay cannot - // call duration() on the decoder thread while it is changing. - void SetLastFrameTime(PRInt64 aTime); - - nsIPrincipal* GetCurrentPrincipal(); - - // Implementation of OggPlay Reader API. - OggPlayErrorCode initialise(int aBlock); - OggPlayErrorCode destroy(); - size_t io_read(char* aBuffer, size_t aCount); - int io_seek(long aOffset, int aWhence); - long io_tell(); - ogg_int64_t duration(); - -public: - nsAutoPtr mStream; - - // Timestamp of the end of the last frame in the media resource. - // -1 if not known. - PRInt64 mLastFrameTime; -}; - -#endif diff --git a/content/media/ogg/nsOggPlayStateMachine.cpp b/content/media/ogg/nsOggPlayStateMachine.cpp index 41015cabd48..5ad39db6a74 100644 --- a/content/media/ogg/nsOggPlayStateMachine.cpp +++ b/content/media/ogg/nsOggPlayStateMachine.cpp @@ -43,7 +43,6 @@ #include "nsBuiltinDecoder.h" #include "nsOggReader.h" #include "nsOggPlayStateMachine.h" -#include "oggplay/oggplay.h" #include "mozilla/mozalloc.h" #include "VideoUtils.h" diff --git a/gfx/layers/ImageLayers.h b/gfx/layers/ImageLayers.h index 1b1f9653704..e305fa3d180 100644 --- a/gfx/layers/ImageLayers.h +++ b/gfx/layers/ImageLayers.h @@ -246,10 +246,8 @@ public: /** * This makes a copy of the data buffers. * XXX Eventually we will change this to not make a copy of the data, - * but we can't do that until we have tighter control of nsOggDecoder's - * buffer management (i.e. not going through liboggplay). Right now - * it doesn't matter because the BasicLayer implementation does YCbCr - * conversion here anyway. + * Right now it doesn't matter because the BasicLayer implementation + * does YCbCr conversion here anyway. */ virtual void SetData(const Data& aData) = 0; diff --git a/layout/build/Makefile.in b/layout/build/Makefile.in index a28433fdacc..07cfbab1c86 100644 --- a/layout/build/Makefile.in +++ b/layout/build/Makefile.in @@ -118,10 +118,7 @@ endif ifdef MOZ_OGG SHARED_LIBRARY_LIBS += \ - $(DEPTH)/media/libfishsound/src/libfishsound/$(LIB_PREFIX)fishsound.$(LIB_SUFFIX) \ $(DEPTH)/media/libogg/src/$(LIB_PREFIX)ogg.$(LIB_SUFFIX) \ - $(DEPTH)/media/liboggplay/src/liboggplay/$(LIB_PREFIX)oggplay.$(LIB_SUFFIX) \ - $(DEPTH)/media/liboggz/src/liboggz/$(LIB_PREFIX)oggz.$(LIB_SUFFIX) \ $(DEPTH)/media/libtheora/lib/$(LIB_PREFIX)theora.$(LIB_SUFFIX) \ $(DEPTH)/media/libvorbis/lib/$(LIB_PREFIX)vorbis.$(LIB_SUFFIX) \ $(DEPTH)/content/media/ogg/$(LIB_PREFIX)gkconogg_s.$(LIB_SUFFIX) \ diff --git a/media/libfishsound/AUTHORS b/media/libfishsound/AUTHORS deleted file mode 100644 index 20ec4dfdce4..00000000000 --- a/media/libfishsound/AUTHORS +++ /dev/null @@ -1,25 +0,0 @@ -Conrad Parker - - Design, implementation. - - Vorbis, Speex support - -Tobias Gehrig - - FLAC support - -Michel Salim - - libFLAC 1.1.3 support - -Silvia Pfeiffer - - MS Windows porting, general packaging. - -Zentaro Kavanagh - - Windows porting and packaging. - - -based on code from: - -libvorbis, by Monty , Xiph.org Foundation. - -libspeex, by Jean-Marc Valin , -Xiph.Org Foundation - -libFLAC, by Josh Coalson, Xiph.Org Foundation. diff --git a/media/libfishsound/COPYING b/media/libfishsound/COPYING deleted file mode 100644 index 0be71ec661c..00000000000 --- a/media/libfishsound/COPYING +++ /dev/null @@ -1,29 +0,0 @@ - Copyright (C) 2003 CSIRO Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the CSIRO nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/media/libfishsound/ChangeLog b/media/libfishsound/ChangeLog deleted file mode 100644 index f01edb3e174..00000000000 --- a/media/libfishsound/ChangeLog +++ /dev/null @@ -1,83 +0,0 @@ -2007-01-12 Thomas Vander Stichele - - * Makefile.am: - dist m4 macro - * include/fishsound/Makefile.am: - fix include directory when overriding includedir - -2005-06-13 Thomas Vander Stichele - - * autogen.sh: - * m4/as-ac-expand.m4: - add m4 dir and use it - add an expand macro - * configure.ac: - uniformize configure's output across the annodex stack - -Thu Jan 13 17:58:45 EST 2005 Conrad Parker - - * added liboil support from David Schleef - -Thu Jun 24 18:48:46 EST 2004 Conrad Parker - - * Version 0.6.3 - - Bug fixes: - * non-interleaved Speex encoding re-written and tested - * memory leak in comments API closed - - Tests and examples: - * new examples fishsound-encdec and fishsound-decenc to trial - encode<->decode pipelines - * improved testing of Speex non-interleaved encoding - -Fri May 21 14:32:41 EST 2004 Conrad Parker - - * Version 0.6.2 - - Improved handling of first and last blocks of data (bos and eos - packets in Ogg): - * new fish_sound_prepare_truncation() API call - * improved encdec-audio test to keep track of frames in and out, - and warn if unequal. (Currently not set to FAIL on this condition - as it appears to be common for Speex) - - Updates to Win32 nmake build files - -Wed May 5 21:44:26 EST 2004 Conrad Parker - - * Version 0.6.1 - - Added support for comment packets, tests, and various bugfixes. - * Added fish_sound_comment_() API, - * Fixed segv bug in decoding stereo Speex to non-interleaved - * Added test for encode/decode pipeline with a variety of - combinations of format, interleave, samplerate, channels and - buffer size. - * Added tests for comments data structure and encode/decode pipeline - - * Added fish_sound_{get,set}_frameno() API calls - -Wed Mar 24 17:53:55 EST 2004 Conrad Parker - - * Version 0.6.0 - * moved encode and decode to examples, added documentation for each - * added fish_sound_{get,set}_interleave() api calls - * various bugfixes from zen and silvia - * updated win32 dev files from silvia - -Sun Mar 07 17:30:00 EST 2004 Silvia Pfeiffer - * Version 0.5.41 - * fixed up windows port and release preparation with - REAME files etc. - - -Some time in the year 2003... - - * A new fish was born... - - * ... by Conrad Parker - - * ... and it had a long unlogged journey... - - * before arriving at 0.5.40 . :) diff --git a/media/libfishsound/Makefile.in b/media/libfishsound/Makefile.in deleted file mode 100644 index b3f479e345f..00000000000 --- a/media/libfishsound/Makefile.in +++ /dev/null @@ -1,51 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = fishsound - -DIRS = \ - include \ - src \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/media/libfishsound/README b/media/libfishsound/README deleted file mode 100644 index 17330c40589..00000000000 --- a/media/libfishsound/README +++ /dev/null @@ -1,46 +0,0 @@ -FishSound, the sound of fish! ------------------------------ - - Full documentation is available in doc/fishsound/html/index.html, - or online at http://www.annodex.net/software/libfishsound/html/ - - Updates are available online at the FishSound homepage: - http://www.annodex.net/software/libfishsound/ - -libfishsound provides a simple programming interface for decoding and -encoding audio data using Xiph.Org codecs (FLAC, Speex and Vorbis). - -libfishsound by itself is designed to handle raw codec streams from a -lower level layer such as UDP datagrams. When these codecs are used in -files, they are commonly encapsulated in Ogg to produce Ogg FLAC, Speex -and Ogg Vorbis files. - -libfishsound is a wrapper around the existing codec libraries and provides -a consistent, higher-level programming interface. It has been designed for -use in a wide variety of applications; it has no direct dependencies on -Ogg encapsulation, though it is most commonly used in conjunction with -liboggz to decode or encode FLAC, Speex or Vorbis audio tracks in Ogg files, -including Ogg Theora and Annodex. - -This source tarball -------------------- - -FishSound has been developed and tested on GNU/Linux, Darwin/MacOSX and -Win32. It probably also works on other Unix-like systems via GNU autoconf. -For Win32: nmake Makefiles, Visual Studio .NET 2003 solution files and -Visual C++ 6.0 workspace files are all provided in the source distribution. - -Details for building with GNU autotools are in the file INSTALL. Read the -file README.win32 for installing under MS Windows. - - src/libfishsound/ the library source code. - src/examples/ example tools for programming with libfishsound. - - include/ the libfishound include files that will be installed - into the system include directory. - - doc/ documentation for libfishsound. The subdirectory - doc/libfishsound is autocreated by doxygen from - comments contained in - - win32/ files necessary to compile under MS Windows. diff --git a/media/libfishsound/README_MOZILLA b/media/libfishsound/README_MOZILLA deleted file mode 100644 index 5eba70365f2..00000000000 --- a/media/libfishsound/README_MOZILLA +++ /dev/null @@ -1,18 +0,0 @@ -The source from this directory was copied from the libfishsound git -distribution using the update.sh script. The only changes made -were those applied by update.sh and the addition/upate of Makefile.in -files for the Mozilla build system. - -Some files are renamed during the copy to prevent clashes with object -file names with other Mozilla libraries. - -The git commit id used was 20b5cdf6fe38f61a9847e46e82da60d7ac4b7877 -from git://git.xiph.org/libfishsound.git - -endian.patch is applied to fix Bug 452698. - -bug487519.patch: Fixes for bug487519 -trac497.patch: Annodex trac ticket 497 fix and mozilla bug 462141. -fishsound_reset.patch: Fixes bug 516323. -bug520500.patch: Don't reject files with vorbis comments with name or - values of length 0. diff --git a/media/libfishsound/bug487519.patch b/media/libfishsound/bug487519.patch deleted file mode 100644 index 9ed03df4199..00000000000 --- a/media/libfishsound/bug487519.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/media/libfishsound/src/libfishsound/fishsound_vorbis.c b/media/libfishsound/src/libfishsound/fishsound_vorbis.c -index 68bdb3a..236dda4 100644 ---- a/media/libfishsound/src/libfishsound/fishsound_vorbis.c -+++ b/media/libfishsound/src/libfishsound/fishsound_vorbis.c -@@ -154,9 +154,13 @@ fs_vorbis_decode (FishSound * fsound, unsigned char * buf, long bytes) - } else { - FishSoundDecoded_FloatIlv df; - FishSoundDecoded_Float dfi; -- -- if (vorbis_synthesis (&fsv->vb, &op) == 0) -+ int r; -+ if ((r = vorbis_synthesis (&fsv->vb, &op)) == 0) - vorbis_synthesis_blockin (&fsv->vd, &fsv->vb); -+ -+ if (r == OV_EBADPACKET) { -+ return FISH_SOUND_ERR_GENERIC; -+ } - - while ((samples = vorbis_synthesis_pcmout (&fsv->vd, &fsv->pcm)) > 0) { - vorbis_synthesis_read (&fsv->vd, samples); diff --git a/media/libfishsound/bug520500.patch b/media/libfishsound/bug520500.patch deleted file mode 100644 index 9d2450b70e3..00000000000 --- a/media/libfishsound/bug520500.patch +++ /dev/null @@ -1,54 +0,0 @@ -diff --git a/media/libfishsound/src/libfishsound/fishsound_comments.c b/media/libfishsound/src/libfishsound/fishsound_comments.c ---- a/media/libfishsound/src/libfishsound/fishsound_comments.c -+++ b/media/libfishsound/src/libfishsound/fishsound_comments.c -@@ -480,44 +480,47 @@ fish_sound_comments_decode (FishSound * - len=readint(c, 0); - debug_printf (1, "[%d] len %d\n", i, len); - - c+=4; - if (len > (unsigned long) (end-c)) return -1; - - name = c; - value = fs_index_len (c, '=', len); -+ n = 0; - if (value) { - *value = '\0'; - value++; -- - n = c+len - value; -+ -+ } -+ if (n) { - if ((nvalue = fs_strdup_len (value, n)) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - - debug_printf (1, "%s -> %s (length %d)", name, nvalue, n); - - if ((comment = fs_comment_new (name, nvalue)) == NULL) { - fs_free (nvalue); - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - - if (_fs_comment_add (fsound, comment) == NULL) { - fs_free (nvalue); - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - - fs_free (nvalue); -- } else { -+ } else if (len > 0) { - debug_printf (1, "[%d] %s (no value)", i, name, len); - - if ((nvalue = fs_strdup_len (name, len)) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - -- if ((comment = fs_comment_new (nvalue, NULL)) == NULL) { -+ if ((comment = fs_comment_new (nvalue, "")) == NULL) { - fs_free (nvalue); - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - - if (_fs_comment_add (fsound, comment) == NULL) { - fs_free (nvalue); - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } diff --git a/media/libfishsound/endian.patch b/media/libfishsound/endian.patch deleted file mode 100644 index 55b07d048e2..00000000000 --- a/media/libfishsound/endian.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/media/libfishsound/include/fishsound/config.h b/media/libfishsound/include/fishsound/config.h -index 573822f..b7cae62 100644 ---- a/media/libfishsound/include/fishsound/config.h -+++ b/media/libfishsound/include/fishsound/config.h -@@ -104,3 +104,8 @@ - #undef HAVE_VORBISENC - #define HAVE_VORBISENC 0 - #undef DEBUG -+ -+#include "prcpucfg.h" -+#ifdef IS_BIG_ENDIAN -+#define WORDS_BIGENDIAN -+#endif -diff --git a/media/libfishsound/src/libfishsound/config.h b/media/libfishsound/src/libfishsound/config.h -index 573822f..b7cae62 100644 ---- a/media/libfishsound/src/libfishsound/config.h -+++ b/media/libfishsound/src/libfishsound/config.h -@@ -104,3 +104,8 @@ - #undef HAVE_VORBISENC - #define HAVE_VORBISENC 0 - #undef DEBUG -+ -+#include "prcpucfg.h" -+#ifdef IS_BIG_ENDIAN -+#define WORDS_BIGENDIAN -+#endif diff --git a/media/libfishsound/fishsound_reset.patch b/media/libfishsound/fishsound_reset.patch deleted file mode 100644 index e29ed10e225..00000000000 --- a/media/libfishsound/fishsound_reset.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/media/libfishsound/src/libfishsound/fishsound_vorbis.c b/media/libfishsound/src/libfishsound/fishsound_vorbis.c ---- a/media/libfishsound/src/libfishsound/fishsound_vorbis.c -+++ b/media/libfishsound/src/libfishsound/fishsound_vorbis.c -@@ -412,7 +412,7 @@ - FishSoundVorbisInfo * fsv = (FishSoundVorbisInfo *)fsound->codec_data; - - vorbis_block_init (&fsv->vd, &fsv->vb); -- -+ fsv->packetno = 0; - return 0; - } - diff --git a/media/libfishsound/include/Makefile.in b/media/libfishsound/include/Makefile.in deleted file mode 100644 index 59cfebd3d99..00000000000 --- a/media/libfishsound/include/Makefile.in +++ /dev/null @@ -1,47 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = fishsound -DIRS = fishsound - -include $(topsrcdir)/config/rules.mk diff --git a/media/libfishsound/include/fishsound/Makefile.in b/media/libfishsound/include/fishsound/Makefile.in deleted file mode 100644 index 45361b4f4e3..00000000000 --- a/media/libfishsound/include/fishsound/Makefile.in +++ /dev/null @@ -1,55 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -EXPORTS_NAMESPACES = fishsound - -EXPORTS_fishsound = \ - comments.h \ - constants.h \ - decode.h \ - deprecated.h \ - encode.h \ - fishsound.h \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/media/libfishsound/include/fishsound/comments.h b/media/libfishsound/include/fishsound/comments.h deleted file mode 100644 index c52ecf48eec..00000000000 --- a/media/libfishsound/include/fishsound/comments.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __FISH_SOUND_COMMENT_H__ -#define __FISH_SOUND_COMMENT_H__ - -/** \file - * Encoding and decoding of comments. - * - * Vorbis and Speex bitstreams - * use a comment format called "Vorbiscomment", defined - * here. - * Many standard comment names (such as TITLE, COPYRIGHT and GENRE) are - * defined in that document. - * - * The following general features of Vorbiscomment are relevant to this API: - * - Each stream has one comment packet, which occurs before any encoded - * audio data in the stream. - * - When encoding, FishSound will generate the comment block and pass it - * to the encoded() callback in sequence, just like any other packet. - * Hence, all comments must be set before any call to fish_sound_encode_*(). - * - When decoding, FishSound will decode the comment block before calling - * the first decoded() callback. Hence, retrieving comment data is possible - * from as soon as the decoded() callback is first called. - * - * Each comment block contains one Vendor string, which can be retrieved - * with fish_sound_comment_get_vendor(). When encoding, this string is - * effectively fixed by the codec libraries; it cannot be set by the - * application. - * - * The rest of a comment block consists of \a name = \a value pairs, with - * the following restrictions: - * - Both the \a name and \a value must be non-empty - * - The \a name is case-insensitive and must consist of ASCII within the - * range 0x20 to 0x7D inclusive, 0x3D ('=') excluded. - * - The \a name is not unique; multiple entries may exist with equivalent - * \a name within a Vorbiscomment block. - * - The \a value may be any UTF-8 string. - * - * \section comments_get Retrieving comments - * - * FishSound contains API methods to iterate through all comments associated - * with a FishSound* handle (fish_sound_comment_first() and - * fish_sound_comment_next(), and to iterate through comments matching a - * particular name (fish_sound_comment_first_byname() and - * fish_sound_comment_next_byname()). Given that multiple comments may exist - * with the same \a name, you should not use - * fish_sound_comment_first_byname() as a simple "get" function. - * - * \section comments_set Encoding comments - * - * For encoding, FishSound contains API methods for adding comments - * (fish_sound_comment_add() and fish_sound_comment_add_byname() - * and for removing comments - * (fish_sound_comment_remove() and fish_sound_comment_remove_byname()). - */ - -#include - -/** - * A comment. - */ -typedef struct { - /** The name of the comment, eg. "AUTHOR" */ - char * name; - - /** The value of the comment, as UTF-8 */ - char * value; -} FishSoundComment; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Retrieve the vendor string. - * \param fsound A FishSound* handle - * \returns A read-only copy of the vendor string - * \retval NULL No vendor string is associated with \a fsound, - * or \a fsound is NULL. - */ -const char * -fish_sound_comment_get_vendor (FishSound * fsound); - - -/** - * Retrieve the first comment. - * \param fsound A FishSound* handle - * \returns A read-only copy of the first comment, or NULL if no comments - * exist for this FishSound* object. - */ -const FishSoundComment * -fish_sound_comment_first (FishSound * fsound); - -/** - * Retrieve the next comment. - * \param fsound A FishSound* handle - * \param comment The previous comment. - * \returns A read-only copy of the comment immediately following the given - * comment. - */ -const FishSoundComment * -fish_sound_comment_next (FishSound * fsound, const FishSoundComment * comment); - -/** - * Retrieve the first comment with a given name. - * \param fsound A FishSound* handle - * \param name the name of the comment to retrieve. - * \returns A read-only copy of the first comment matching the given \a name. - * \retval NULL no match was found. - * \note If \a name is NULL, the behaviour is the same as for - * fish_sound_comment_first() - */ -const FishSoundComment * -fish_sound_comment_first_byname (FishSound * fsound, char * name); - -/** - * Retrieve the next comment following and with the same name as a given - * comment. - * \param fsound A FishSound* handle - * \param comment A comment - * \returns A read-only copy of the next comment with the same name as - * \a comment. - * \retval NULL no further comments with the same name exist for - * this FishSound* object. - */ -const FishSoundComment * -fish_sound_comment_next_byname (FishSound * fsound, - const FishSoundComment * comment); - -/** - * Add a comment - * \param fsound A FishSound* handle (created with mode FISH_SOUND_ENCODE) - * \param comment The comment to add - * \retval 0 Success - * \retval FISH_SOUND_ERR_BAD \a fsound is not a valid FishSound* handle - * \retval FISH_SOUND_ERR_INVALID Operation not suitable for this FishSound - */ -int -fish_sound_comment_add (FishSound * fsound, FishSoundComment * comment); - -/** - * Add a comment by name and value. - * \param fsound A FishSound* handle (created with mode FISH_SOUND_ENCODE) - * \param name The name of the comment to add - * \param value The contents of the comment to add - * \retval 0 Success - * \retval FISH_SOUND_ERR_BAD \a fsound is not a valid FishSound* handle - * \retval FISH_SOUND_ERR_INVALID Operation not suitable for this FishSound - */ -int -fish_sound_comment_add_byname (FishSound * fsound, const char * name, - const char * value); - -/** - * Remove a comment - * \param fsound A FishSound* handle (created with FISH_SOUND_ENCODE) - * \param comment The comment to remove. - * \retval 1 Success: comment removed - * \retval 0 No-op: comment not found, nothing to remove - * \retval FISH_SOUND_ERR_BAD \a fsound is not a valid FishSound* handle - * \retval FISH_SOUND_ERR_INVALID Operation not suitable for this FishSound - */ -int -fish_sound_comment_remove (FishSound * fsound, FishSoundComment * comment); - -/** - * Remove all comments with a given name. - * \param fsound A FishSound* handle (created with FISH_SOUND_ENCODE) - * \param name The name of the comments to remove - * \retval ">= 0" The number of comments removed - * \retval FISH_SOUND_ERR_BAD \a fsound is not a valid FishSound* handle - * \retval FISH_SOUND_ERR_INVALID Operation not suitable for this FishSound - */ -int -fish_sound_comment_remove_byname (FishSound * fsound, char * name); - -#ifdef __cplusplus -} -#endif - -#endif /* __FISH_SOUND_COMMENTS_H__ */ diff --git a/media/libfishsound/include/fishsound/config.h b/media/libfishsound/include/fishsound/config.h deleted file mode 100644 index 561526a2614..00000000000 --- a/media/libfishsound/include/fishsound/config.h +++ /dev/null @@ -1,138 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define if building universal (internal helper macro) */ -/* #undef AC_APPLE_UNIVERSAL_BUILD */ - -/* Do not build decoding support */ -#define FS_DECODE 1 - -/* Do not build encoding support */ -#define FS_ENCODE 0 - -/* Define to build experimental code */ -/* #undef FS_EXPERIMENTAL */ - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have libFLAC */ -#define HAVE_FLAC 0 - -/* Define to 1 if you have libFLAC 1.1.2 */ -/* #undef HAVE_FLAC_1_1_2 */ - -/* Define to 1 if you have libFLAC 1.1.3 */ -/* #undef HAVE_FLAC_1_1_3 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define if have libsndfile */ -/* #undef HAVE_LIBSNDFILE1 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define if have liboggz */ -/* #undef HAVE_OGGZ */ - -/* Define to 1 if you have libspeex */ -#define HAVE_SPEEX 0 - -/* Define to 1 if you have libspeex 1.1.x */ -/* #undef HAVE_SPEEX_1_1 */ - -/* Define to 1 if speex_lib_get_mode() exists in libspeex */ -/* #undef HAVE_SPEEX_LIB_GET_MODE */ - -/* Define to 1 if you have the header file. */ -/* #define HAVE_STDINT_H 1 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if the system has the type `uintptr_t'. */ -/* #define HAVE_UINTPTR_T 1 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have libvorbis */ -#define HAVE_VORBIS 1 - -/* Define to 1 if you have libvorbisenc */ -#define HAVE_VORBISENC 0 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "libfishsound" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "0.9.2" - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -/* # undef WORDS_BIGENDIAN */ -# endif -#endif - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ -#undef FS_ENCODE -#define FS_ENCODE 0 -#undef HAVE_FLAC -#define HAVE_FLAC 0 -#undef HAVE_OGGZ -#define HAVE_OGGZ 1 -#undef HAVE_SPEEX -#define HAVE_SPEEX 0 -#undef HAVE_VORBIS -#define HAVE_VORBIS 1 -#undef HAVE_VORBISENC -#define HAVE_VORBISENC 0 -#undef DEBUG - -#include "prcpucfg.h" -#ifdef IS_BIG_ENDIAN -#define WORDS_BIGENDIAN -#endif diff --git a/media/libfishsound/include/fishsound/constants.h b/media/libfishsound/include/fishsound/constants.h deleted file mode 100644 index ca8f8041977..00000000000 --- a/media/libfishsound/include/fishsound/constants.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __FISH_SOUND_CONSTANTS_H__ -#define __FISH_SOUND_CONSTANTS_H__ - -/** \file - * Constants used by libfishsound - */ - -/** Mode of operation (encode or decode) */ -typedef enum _FishSoundMode { - /** Decode */ - FISH_SOUND_DECODE = 0x10, - - /** Encode */ - FISH_SOUND_ENCODE = 0x20 -} FishSoundMode; - -/** Identifiers for supported codecs */ -typedef enum _FishSoundCodecID { - /** Unknown */ - FISH_SOUND_UNKNOWN = 0x00, - - /** Vorbis */ - FISH_SOUND_VORBIS = 0x01, - - /** Speex */ - FISH_SOUND_SPEEX = 0x02, - - /** Flac */ - FISH_SOUND_FLAC = 0x03 -} FishSoundCodecID; - -/** Decode callback return values */ -typedef enum _FishSoundStopCtl { - /** Continue calling decode callbacks */ - FISH_SOUND_CONTINUE = 0, - - /** Stop calling callbacks, but retain buffered data */ - FISH_SOUND_STOP_OK = 1, - - /** Stop calling callbacks, and purge buffered data */ - FISH_SOUND_STOP_ERR = -1 -} FishSoundStopCtl; - -/** Command codes */ -typedef enum _FishSoundCommand { - /** No operation */ - FISH_SOUND_COMMAND_NOP = 0x0000, - - /** Retrieve the FishSoundInfo */ - FISH_SOUND_GET_INFO = 0x1000, - - /** Query if multichannel audio should be interpreted as interleaved */ - FISH_SOUND_GET_INTERLEAVE = 0x2000, - - /** Set to 1 to interleave, 0 to non-interleave */ - FISH_SOUND_SET_INTERLEAVE = 0x2001, - - FISH_SOUND_SET_ENCODE_VBR = 0x4000, - - FISH_SOUND_COMMAND_MAX -} FishSoundCommand; - -/** Error values */ -typedef enum _FishSoundError { - /** No error */ - FISH_SOUND_OK = 0, - - /** generic error */ - FISH_SOUND_ERR_GENERIC = -1, - - /** Not a valid FishSound* handle */ - FISH_SOUND_ERR_BAD = -2, - - /** The requested operation is not suitable for this FishSound* handle */ - FISH_SOUND_ERR_INVALID = -3, - - /** Out of memory */ - FISH_SOUND_ERR_OUT_OF_MEMORY = -4, - - /** Functionality disabled at build time */ - FISH_SOUND_ERR_DISABLED = -10, - - /** Too few bytes passed to fish_sound_identify() */ - FISH_SOUND_ERR_SHORT_IDENTIFY = -20, - - /** Comment violates VorbisComment restrictions */ - FISH_SOUND_ERR_COMMENT_INVALID = -21 -} FishSoundError; - -#endif /* __FISH_SOUND_CONSTANTS_H__ */ diff --git a/media/libfishsound/include/fishsound/decode.h b/media/libfishsound/include/fishsound/decode.h deleted file mode 100644 index 44c8139fdb5..00000000000 --- a/media/libfishsound/include/fishsound/decode.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __FISH_SOUND_DECODE_H__ -#define __FISH_SOUND_DECODE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** \file - * Decode functions and callback prototypes - */ - -/** - * Signature of a callback for libfishsound to call when it has decoded - * PCM audio data, and you want this provided as non-interleaved floats. - * \param fsound The FishSound* handle - * \param pcm The decoded audio - * \param frames The count of frames decoded - * \param user_data Arbitrary user data - * \retval FISH_SOUND_CONTINUE Continue decoding - * \retval FISH_SOUND_STOP_OK Stop decoding immediately and - * return control to the fish_sound_decode() caller - * \retval FISH_SOUND_STOP_ERR Stop decoding immediately, purge buffered - * data, and return control to the fish_sound_decode() caller - */ -typedef int (*FishSoundDecoded_Float) (FishSound * fsound, float * pcm[], - long frames, void * user_data); - -/** - * Signature of a callback for libfishsound to call when it has decoded - * PCM audio data, and you want this provided as interleaved floats. - * \param fsound The FishSound* handle - * \param pcm The decoded audio - * \param frames The count of frames decoded - * \param user_data Arbitrary user data - * \retval FISH_SOUND_CONTINUE Continue decoding - * \retval FISH_SOUND_STOP_OK Stop decoding immediately and - * return control to the fish_sound_decode() caller - * \retval FISH_SOUND_STOP_ERR Stop decoding immediately, purge buffered - * data, and return control to the fish_sound_decode() caller - */ -typedef int (*FishSoundDecoded_FloatIlv) (FishSound * fsound, float ** pcm, - long frames, void * user_data); - -/** - * Set the callback for libfishsound to call when it has a block of decoded - * PCM audio ready, and you want this provided as non-interleaved floats. - * \param fsound A FishSound* handle (created with mode FISH_SOUND_DECODE) - * \param decoded The callback to call - * \param user_data Arbitrary user data to pass to the callback - * \retval 0 Success - * \retval FISH_SOUND_ERR_BAD Not a valid FishSound* handle - * \retval FISH_SOUND_ERR_OUT_OF_MEMORY Out of memory - */ -int fish_sound_set_decoded_float (FishSound * fsound, - FishSoundDecoded_Float decoded, - void * user_data); - -/** - * Set the callback for libfishsound to call when it has a block of decoded - * PCM audio ready, and you want this provided as interleaved floats. - * \param fsound A FishSound* handle (created with mode FISH_SOUND_DECODE) - * \param decoded The callback to call - * \param user_data Arbitrary user data to pass to the callback - * \retval 0 Success - * \retval FISH_SOUND_ERR_BAD Not a valid FishSound* handle - * \retval FISH_SOUND_ERR_OUT_OF_MEMORY Out of memory - */ -int fish_sound_set_decoded_float_ilv (FishSound * fsound, - FishSoundDecoded_FloatIlv decoded, - void * user_data); - -/** - * Decode a block of compressed data. - * No internal buffering is done, so a complete compressed audio packet - * must be passed each time. - * \param fsound A FishSound* handle (created with mode FISH_SOUND_DECODE) - * \param buf A buffer containing a compressed audio packet - * \param bytes A count of bytes to decode (i.e. the length of buf) - * \returns The number of bytes consumed - * \retval FISH_SOUND_ERR_STOP_OK Decoding was stopped by a FishSoundDecode* - * callback returning FISH_SOUND_STOP_OK before any input bytes were consumed. - * This will occur when PCM is decoded from previously buffered input, and - * stopping is immediately requested. - * \retval FISH_SOUND_ERR_STOP_ERR Decoding was stopped by a FishSoundDecode* - * callback returning FISH_SOUND_STOP_ERR before any input bytes were consumed. - * This will occur when PCM is decoded from previously buffered input, and - * stopping is immediately requested. - * \retval FISH_SOUND_ERR_BAD Not a valid FishSound* handle - * \retval FISH_SOUND_ERR_OUT_OF_MEMORY Out of memory - */ -long fish_sound_decode (FishSound * fsound, unsigned char * buf, long bytes); - -#ifdef __cplusplus -} -#endif - -#endif /* __FISH_SOUND_DECODE_H__ */ diff --git a/media/libfishsound/include/fishsound/deprecated.h b/media/libfishsound/include/fishsound/deprecated.h deleted file mode 100644 index e67d278c284..00000000000 --- a/media/libfishsound/include/fishsound/deprecated.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __FISH_SOUND_DEPRECATED_H__ -#define __FISH_SOUND_DEPRECATED_H__ - -/** \file - * Deprecated interfaces - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * DEPRECATED TYPE. - * Signature of a callback for libfishsound to call when it has decoded - * PCM audio data, and you want this provided as floats using the current - * interleave method as set by fish_sound_set_interleave(). - */ -typedef FishSoundDecoded_Float FishSoundDecoded; - -/** - * DEPRECATED FUNCTION. - * Set the callback for libfishsound to call when it has a block of decoded - * PCM audio ready, and you want this provided as floats using the current - * interleave method as set by fish_sound_set_interleave(). - * This function, and fish_sound_set_interleave(), have been superceded by - * the typesafe fish_sound_set_decoded_TYPE() callbacks, such as - * fish_sound_set_decoded_float() or fish_sound_set_decoded_float_ilv(). - * - * \param fsound A FishSound* handle (created with mode FISH_SOUND_DECODE) - * \param decoded The callback to call - * \param user_data Arbitrary user data to pass to the callback - * \returns 0 on success, -1 on failure - */ -int fish_sound_set_decoded_callback (FishSound * fsound, - FishSoundDecoded decoded, - void * user_data); - -/** - * DEPRECATED FUNCTION. - * Set the PCM format used by a FishSound object. The default value is - * non-interleaved. - * Prior to libfishsound 0.7.0, you would (optionally) specify whether you - * wanted to receive interleaved or per-channel PCM data using - * fish_sound_set_interleave(), the default being per-channel - * (non-interleaved) PCM. - * Whether or not your decoded callback expects interleaved or - * non-interleaved data is now implied by the particular - * fish_sound_set_decoded_TYPE() method you use to set it, such as - * fish_sound_set_decoded_float() or fish_sound_set_decoded_float_ilv(). - * - * \param fsound A FishSound* handle - * \param interleave Whether to use interleaved PCM or not. Valid values are - * 0 for non-interleaved, and 1 for interleaved. - * \retval 0 Success - * \retval -1 Invalid \a fsound - */ -int fish_sound_set_interleave (FishSound * fsound, int interleave); - -/** - * DEPRECATED FUNCTION. - * Encode a block of audio - * \param fsound A FishSound* handle (created with mode FISH_SOUND_ENCODE) - * \param pcm The audio data to encode - * \param frames A count of frames to encode - * \returns The number of frames encoded - * \note For multichannel audio, the audio data is interpreted according - * to the current PCM style - */ -long fish_sound_encode (FishSound * fsound, float ** pcm, long frames); - -#ifdef __cplusplus -} -#endif - -#endif /* __FISH_SOUND_DEPRECATED_H__ */ diff --git a/media/libfishsound/include/fishsound/encode.h b/media/libfishsound/include/fishsound/encode.h deleted file mode 100644 index 5a467a10336..00000000000 --- a/media/libfishsound/include/fishsound/encode.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __FISH_SOUND_ENCODE_H__ -#define __FISH_SOUND_ENCODE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** \file - * Encode functions and callback prototypes - */ - -/** - * Signature of a callback for libfishsound to call when it has encoded - * data. - * \param fsound The FishSound* handle - * \param buf The encoded data - * \param bytes The count of bytes encoded - * \param user_data Arbitrary user data - * \retval 0 to continue - * \retval non-zero to stop encoding immediately and - * return control to the fish_sound_encode() caller - */ -typedef int (*FishSoundEncoded) (FishSound * fsound, unsigned char * buf, - long bytes, void * user_data); - -/** - * Set the callback for libfishsound to call when it has a block of - * encoded data ready - * \param fsound A FishSound* handle (created with mode FISH_SOUND_ENCODE) - * \param encoded The callback to call - * \param user_data Arbitrary user data to pass to the callback - * \returns 0 on success, -1 on failure - */ -int fish_sound_set_encoded_callback (FishSound * fsound, - FishSoundEncoded encoded, - void * user_data); - -/** - * Encode a block of PCM audio given as non-interleaved floats. - * \param fsound A FishSound* handle (created with mode FISH_SOUND_ENCODE) - * \param pcm The audio data to encode - * \param frames A count of frames to encode - * \returns The number of frames encoded - * \note For multichannel audio, the audio data is interpreted according - * to the current PCM style - */ -long fish_sound_encode_float (FishSound * fsound, float * pcm[], long frames); - -/** - * Encode a block of audio given as interleaved floats. - * \param fsound A FishSound* handle (created with mode FISH_SOUND_ENCODE) - * \param pcm The audio data to encode - * \param frames A count of frames to encode - * \returns The number of frames encoded - * \note For multichannel audio, the audio data is interpreted according - * to the current PCM style - */ -long fish_sound_encode_float_ilv (FishSound * fsound, float ** pcm, - long frames); - -#ifdef __cplusplus -} -#endif - -#endif /* __FISH_SOUND_ENCODE_H__ */ diff --git a/media/libfishsound/include/fishsound/fishsound.h b/media/libfishsound/include/fishsound/fishsound.h deleted file mode 100644 index 84f6e1d01af..00000000000 --- a/media/libfishsound/include/fishsound/fishsound.h +++ /dev/null @@ -1,589 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __FISH_SOUND_H__ -#define __FISH_SOUND_H__ - -#include - -/** \mainpage - * - * \section intro FishSound, the sound of fish! - * - * This is the documentation for the FishSound C API. FishSound provides - * a simple programming interface for decoding and encoding audio data - * using Xiph.Org codecs (FLAC, Speex and Vorbis). - * - * libfishsound by itself is designed to handle raw codec streams from - * a lower level layer such as UDP datagrams. - * When these codecs are used in files, they are commonly encapsulated in - * Ogg to produce - * Ogg FLAC, Speex and Ogg Vorbis files. - * Example C programs using - * liboggz to - * read and write these files are provided in the libfishsound sources. - * - * For more information on the design and history of libfishsound, see the - * \link about About \endlink section of this documentation, and the - * libfishsound - * homepage. - * - * \subsection contents Contents - * - * - \link fishsound.h fishsound.h \endlink: - * Documentation of the FishSound API. - * - * - \link comments.h Handling comments \endlink: - * How to add and retrieve \a name = \a value metadata in Vorbis and Speex - * streams. - * - * - \link decode Decoding audio data \endlink: - * How to decode audio data with FishSound, including source for a fully - * working Ogg FLAC, Speex and Ogg Vorbis decoder. - * - * - \link encode Encoding audio data \endlink: - * How to encode audio data with FishSound, including source for a fully - * working Ogg FLAC, Speex and Ogg Vorbis encoder. - * - * - \link configuration Configuration \endlink: - * Customizing libfishsound to only decode or encode, - * or to disable support for a particular codec. - * - * - \link building Building \endlink: - * Information related to building software that uses libfishsound. - * - * - \link about About \endlink: - * Design, motivation, history and acknowledgements. - * - * \section Licensing - * - * libfishsound is provided under the following BSD-style open source license: - * - * \include COPYING - * - */ - -/** \defgroup about About - * - * \section design Design - * libfishsound provides a simple programming interface for decoding and - * encoding audio data using codecs from - * Xiph.Org. - * - * libfishsound by itself is designed to handle raw codec streams from - * a lower level layer such as UDP datagrams. - * When these codecs are used in files, they are commonly encapsulated in - * Ogg to produce - * Ogg FLAC, Speex and Ogg Vorbis files. - * Example C programs using - * liboggz to - * read and write these files are provided in the libfishsound sources. - * - * libfishsound is implemented as a wrapper around the existing codec - * libraries and provides a consistent, higher-level programming - * interface. The motivation for this is twofold: to simplify the task - * of developing application software that supports these codecs, - * and to ensure that valid codec streams are generated. - * - * \section history History - * libfishsound was designed and developed by Conrad Parker on the - * weekend of October 18-19 2003. Previously the author had implemented - * Vorbis and Speex support in the following software: - * - Sweep, a - * digital audio editor with decoding and GUI control of all encoding - * options of Vorbis and Speex - * - Speex support in the xine - * multimedia player - * - Vorbis and Speex importers for - * libannodex, - the basic library for reading and writing - * Annodex.net media files. - * - * The implementation of libfishsound draws heavily on these sources, and - * in turn the original example sources of libvorbis and libvorbisenc by - * Monty, and libspeex by Jean-Marc Valin. - * - * The naming of libfishsound reflects both the Xiph.Org logo and - * the author's reputation as a dirty, smelly old fish. - * - * \section limitations Limitations - * - * libfishsound has been designed to accomodate the various decoding and - * encoding styles required by a wide variety of software. However, as it - * is an abstraction of the underlying libvorbis, libvorbisenc and libspeex - * libraries, it may not be possible to implement some low-level techniques - * that these libraries enable, such as parallelization of Vorbis sub-block - * decoding. Nevertheless it is expected that libfishsound is a useful - * API for most software requiring Vorbis or Speex support, including most - * applications the author has encountered. - * - * \section acknowledgements Acknowledgements - * Much of the API design follows the style of - * libsndfile. - * The author would like to thank Erik de Castro Lopo for feedback on the - * design of libfishsound. - */ - -/** \defgroup configuration Configuration - * - * \section platforms Platform-specific configuration - * - * FishSound can be configured on most platforms using the GNU autoconf - * ./configure system described below. - * - * For Win32, see the \link win32 README.win32 \endlink section. You will - * need to edit win32/config.h by hand to achieve the customizations - * described below. - * - * \section ./configure ./configure - * - * It is possible to customize the functionality of libfishsound - * by using various ./configure flags when - * building it from source; for example you can build a smaller - * version of libfishsound to only decode or encode, or and you can - * choose to disable support for a particular codec. - * By default, both decoding and encoding support is built for all - * codecs found on the system. - * - * For general information about using ./configure, see the file - * \link install INSTALL \endlink - * - * \subsection no_encode Removing encoding support - * - * Configuring with \a --disable-encode will remove all support for encoding: - * - All internal encoding related functions will not be built - * - Any attempt to call fish_sound_new() with \a mode == FISH_SOUND_ENCODE - * will fail, returning NULL - * - Any attempt to call fish_sound_encode_*() will return - * FISH_SOUND_ERR_DISABLED - * - The resulting library will not be linked against libvorbisenc - * - * \subsection no_decode Removing decoding support - * - * Configuring with \a --disable-decode will remove all support for decoding: - * - All internal decoding related functions will not be built - * - Any attempt to call fish_sound_new() with \a mode == FISH_SOUND_DECODE - * will fail, returning NULL - * - Any attempt to call fish_sound_decode() will return - * FISH_SOUND_ERR_DISABLED - * - * \subsection no_flac Removing FLAC support - * - * Configuring with \a --disable-flac will remove all support for FLAC: - * - All internal FLAC related functions will not be built - * - Any attempt to call fish_sound_new() with \a mode == FISH_SOUND_ENCODE - * and \a fsinfo->format == FISH_SOUND_FLAC will fail, returning NULL - * - The resulting library will not be linked against libFLAC - * - * \subsection no_speex Removing Speex support - * - * Configuring with \a --disable-speex will remove all support for Speex: - * - All internal Speex related functions will not be built - * - Any attempt to call fish_sound_new() with \a mode == FISH_SOUND_ENCODE - * and \a fsinfo->format == FISH_SOUND_SPEEX will fail, returning NULL - * - The resulting library will not be linked against libspeex - * - * \subsection no_vorbis Removing Vorbis support - * - * Configuring with \a --disable-vorbis will remove all support for Vorbis: - * - All internal Vorbis related functions will not be built - * - Any attempt to call fish_sound_new() with \a mode == FISH_SOUND_ENCODE - * and \a fsinfo->format == FISH_SOUND_VORBIS will fail, returning NULL - * - The resulting library will not be linked against libvorbis or libvorbisenc - * - * \subsection summary Configuration summary - * - * Upon successful configuration, you should see something like this: -
-------------------------------------------------------------------------
-  libfishsound 0.9.0:  Automatic configuration OK.
-
-  General configuration:
-
-    Experimental code: ........... no
-    Decoding support: ............ yes
-    Encoding support: ............ yes
-
-  Library configuration (./src/libfishsound):
-
-    FLAC support: ................ yes
-    Speex support: ............... yes (1.1.x)
-    Vorbis support: .............. yes
-
-  Example programs (./src/examples):
-
-    fishsound-identify fishsound-decode fishsound-encode
-
-  Installation paths:
-
-    libfishsound: ................ /usr/local/lib
-    C header files: .............. /usr/local/include/fishsound
-    Documentation: ............... /usr/local/share/doc/libfishsound
-
-  Building:
-
-    Type 'make' to compile libfishsound.
-
-    Type 'make install' to install libfishsound.
-
-    Type 'make check' to run test suite (Valgrind testing not enabled)
-
-  Example programs will be built but not installed.
-------------------------------------------------------------------------
-
- */ - -/** \defgroup install Installation - * \section install INSTALL - * - * \include INSTALL - */ - -/** \defgroup win32 Building on Win32 - * \section win32 README.Win32 - * - * \include README.win32 - */ - -/** \defgroup building Building against libfishsound - * - * - * \section autoconf Using GNU autoconf - * - * If you are using GNU autoconf, you do not need to call pkg-config - * directly. Use the following macro to determine if libfishsound is - * available: - * -
- PKG_CHECK_MODULES(FISHSOUND, fishsound >= 0.6.0,
-                   HAVE_FISHSOUND="yes", HAVE_FISHSOUND="no")
- if test "x$HAVE_FISHSOUND" = "xyes" ; then
-   AC_SUBST(FISHSOUND_CFLAGS)
-   AC_SUBST(FISHSOUND_LIBS)
- fi
- 
- * (Note that if your application requires FLAC support, you should check - * for a version of fishsound >= 0.9.0). - * - * If libfishsound is found, HAVE_FISHSOUND will be set to "yes", and - * the autoconf variables FISHSOUND_CFLAGS and FISHSOUND_LIBS will - * be set appropriately. - * - * \section pkg-config Determining compiler options with pkg-config - * - * If you are not using GNU autoconf in your project, you can use the - * pkg-config tool directly to determine the correct compiler options. - * -
- FISHSOUND_CFLAGS=`pkg-config --cflags fishsound`
-
- FISHSOUND_LIBS=`pkg-config --libs fishsound`
- 
- * - */ - -/** \file - * The libfishsound C API. - * - * \section general General usage - * - * All access is managed via a FishSound* handle. This is instantiated - * using fish_sound_new() and should be deleted with fish_sound_delete() - * when no longer required. If there is a discontinuity in the input - * data (eg. after seeking in an input file), call fish_sound_reset() to - * reset the internal codec state. - * - * \section decoding Decoding - * - * libfishsound provides callback based decoding: you feed it encoded audio - * data, and it will call your callback with decoded PCM. A more detailed - * explanation and a full example of decoding Ogg FLAC, Speex and Ogg Vorbis - * files is provided in the \link decode Decoding audio data \endlink section. - * - * \section encoding Encoding - * - * libfishsound provides callback based encoding: you feed it PCM audio, - * and it will call your callback with encoded audio data. A more detailed - * explanation and a full example of encoding Ogg FLAC, Speex and Ogg Vorbis - * files is provided in the \link encode Encoding audio data \endlink section. - */ - -/** \defgroup decode Decoding audio data - * - * To decode audio data using libfishsound: - * - * - create a FishSound* object with mode FISH_SOUND_DECODE. fish_sound_new() - * will return a new FishSound* object, initialised for decoding, and the - * FishSoundInfo structure will be cleared. - * - provide a FishSoundDecoded_* callback for libfishsound to call when it has - * decoded audio. - * - (optionally) specify whether you want to receive interleaved or - * per-channel PCM data, using a fish_sound_set_interleave(). - * The default is for per-channel (non-interleaved) PCM. - * - feed encoded audio data to libfishsound via fish_sound_decode(). - * libfishsound will decode the audio for you, calling the FishSoundDecoded_* - * callback you provided earlier each time it has a block of audio ready. - * - when finished, call fish_sound_delete(). - * - * This procedure is illustrated in src/examples/fishsound-decode.c. - * Note that this example additionally: - * - uses liboggz to - * demultiplex audio data from an Ogg encapsulated FLAC, Speex or Vorbis - * stream. The step of feeding encoded data to libfishsound is done within - * the OggzReadPacket callback. - * - uses libsndfile to - * write the decoded audio to a WAV file. - * - * Hence this example code demonstrates all that is needed to decode - * Ogg FLAC, Speex or Ogg Vorbis files: - * - * \include fishsound-decode.c - */ - -/** \defgroup encode Encoding audio data - * - * To encode audio data using libfishsound: - * - * - create a FishSound* object with mode FISH_SOUND_ENCODE, and with a - * FishSoundInfo structure filled in with the required encoding parameters. - * fish_sound_new() will return a new FishSound* object initialised for - * encoding. - * - provide a FishSoundEncoded callback for libfishsound to call when it - * has a block of encoded audio - * - feed raw PCM audio data to libfishsound via fish_sound_encode_*(). - * libfishsound will encode the audio for you, calling the FishSoundEncoded - * callback you provided earlier each time it has a block of encoded audio - * ready. - * - when finished, call fish_sound_delete(). - * - * This procedure is illustrated in src/examples/fishsound-encode.c. - * Note that this example additionally: - * - uses libsndfile to - * read input from a PCM audio file (WAV, AIFF, etc.) - * - uses liboggz to - * encapsulate the encoded FLAC, Speex or Vorbis data in an Ogg stream. - * - * Hence this example code demonstrates all that is needed to encode - * Ogg FLAC, Speex and Ogg Vorbis files: - * - * \include fishsound-encode.c - */ - -/** - * Info about a particular encoder/decoder instance - */ -typedef struct { - /** Sample rate of audio data in Hz */ - int samplerate; - - /** Count of channels */ - int channels; - - /** FISH_SOUND_VORBIS, FISH_SOUND_SPEEX, FISH_SOUND_FLAC etc. */ - int format; -} FishSoundInfo; - -/** - * Info about a particular sound format - */ -typedef struct { - /** FISH_SOUND_VORBIS, FISH_SOUND_SPEEX, FISH_SOUND_FLAC etc. */ - int format; - - /** Printable name */ - const char * name; - - /** Commonly used file extension */ - const char * extension; -} FishSoundFormat; - -/** - * An opaque handle to a FishSound. This is returned by fishsound_new() - * and is passed to all other fish_sound_*() functions. - */ -typedef void * FishSound; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Identify a codec based on the first few bytes of data. - * \param buf A pointer to the first few bytes of the data - * \param bytes The count of bytes available at buf - * \retval FISH_SOUND_xxxxxx FISH_SOUND_VORBIS, FISH_SOUND_SPEEX or - * FISH_SOUND_FLAC if \a buf was identified as the initial bytes of a - * supported codec - * \retval FISH_SOUND_UNKNOWN if the codec could not be identified - * \retval FISH_SOUND_ERR_SHORT_IDENTIFY if \a bytes is less than 8 - * \note If \a bytes is exactly 8, then only a weak check is performed, - * which is fast but may return a false positive. - * \note If \a bytes is greater than 8, then a stronger check is performed - * in which an attempt is made to decode \a buf as the initial header of - * each supported codec. This is unlikely to return a false positive but - * is only useful if \a buf is the entire payload of a packet derived from - * a lower layer such as Ogg framing or UDP datagrams. - */ -int -fish_sound_identify (unsigned char * buf, long bytes); - -/** - * Instantiate a new FishSound* handle - * \param mode FISH_SOUND_DECODE or FISH_SOUND_ENCODE - * \param fsinfo Encoder configuration, may be NULL for FISH_SOUND_DECODE - * \returns A new FishSound* handle, or NULL on error - */ -FishSound * fish_sound_new (int mode, FishSoundInfo * fsinfo); - -/** - * Flush any internally buffered data, forcing encode - * \param fsound A FishSound* handle - * \returns 0 on success, -1 on failure - */ -long fish_sound_flush (FishSound * fsound); - -/** - * Reset the codec state of a FishSound object. - * - * When decoding from a seekable file, fish_sound_reset() should be called - * after any seek operations. See also fish_sound_set_frameno(). - * - * \param fsound A FishSound* handle - * \returns 0 on success, -1 on failure - */ -int fish_sound_reset (FishSound * fsound); - -/** - * Delete a FishSound object - * \param fsound A FishSound* handle - * \returns 0 on success, -1 on failure - */ -int fish_sound_delete (FishSound * fsound); - -/** - * Command interface - * \param fsound A FishSound* handle - * \param command The command action - * \param data Command data - * \param datasize Size of the data in bytes - * \returns 0 on success, -1 on failure - */ -int fish_sound_command (FishSound * fsound, int command, void * data, - int datasize); - -/** - * Query whether a FishSound object is using interleaved PCM - * \param fsound A FishSound* handle - * \retval 0 \a fsound uses non-interleaved PCM - * \retval 1 \a fsound uses interleaved PCM - * \retval -1 Invalid \a fsound, or out of memory. - */ -int fish_sound_get_interleave (FishSound * fsound); - -/** - * Query the current frame number of a FishSound object. - * - * For decoding, this is the greatest frame index that has been decoded and - * made available to a FishSoundDecoded callback. This function is safe to - * call from within a FishSoundDecoded callback, and corresponds to the frame - * number of the last frame in the current decoded block. - * - * For encoding, this is the greatest frame index that has been encoded. This - * function is safe to call from within a FishSoundEncoded callback, and - * corresponds to the frame number of the last frame encoded in the current - * block. - * - * \param fsound A FishSound* handle - * \returns The current frame number - * \retval -1 Invalid \a fsound - */ -long fish_sound_get_frameno (FishSound * fsound); - -/** - * Set the current frame number of a FishSound object. - * - * When decoding from a seekable file, fish_sound_set_frameno() should be - * called after any seek operations, otherwise the value returned by - * fish_sound_get_frameno() will simply continue to increment. See also - * fish_sound_reset(). - * - * \param fsound A FishSound* handle - * \param frameno The current frame number. - * \retval 0 Success - * \retval -1 Invalid \a fsound - */ -int fish_sound_set_frameno (FishSound * fsound, long frameno); - -/** - * Prepare truncation details for the next block of data. - * The semantics of these parameters derives directly from Ogg encapsulation - * of Vorbis, described - * here. - * - * When decoding from Ogg, you should call this function with the \a granulepos - * and \a eos of the \a ogg_packet structure. This call should be made before - * passing the packet's data to fish_sound_decode(). Failure to do so may - * result in minor decode errors on the first and/or last packet of the stream. - * - * When encoding into Ogg, you should call this function with the \a granulepos - * and \a eos that will be used for the \a ogg_packet structure. This call - * should be made before passing the block of audio data to - * fish_sound_encode_*(). Failure to do so may result in minor encoding errors - * on the first and/or last packet of the stream. - * - * \param fsound A FishSound* handle - * \param next_granulepos The "granulepos" for the next block to decode. - * If unknown, set \a next_granulepos to -1. Otherwise, - * \a next_granulepos specifies the frameno of the final frame in the - * block. This is authoritative, hence can be used to indicate - * various forms of truncation at the beginning or end of a stream. - * Mid-stream, a later-than-expected "granulepos" indicates that some - * data was missing. - * \param next_eos A boolean indicating whether the next data block will be - * the last in the stream. - * \retval 0 Success - * \retval -1 Invalid \a fsound - */ -int fish_sound_prepare_truncation (FishSound * fsound, long next_granulepos, - int next_eos); - -#ifdef __cplusplus -} -#endif - -#include -#include -#include - -#include - -#endif /* __FISH_SOUND_H__ */ diff --git a/media/libfishsound/src/Makefile.in b/media/libfishsound/src/Makefile.in deleted file mode 100644 index 22e5b97144a..00000000000 --- a/media/libfishsound/src/Makefile.in +++ /dev/null @@ -1,47 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = fishsound -DIRS = libfishsound - -include $(topsrcdir)/config/rules.mk diff --git a/media/libfishsound/src/libfishsound/Makefile.in b/media/libfishsound/src/libfishsound/Makefile.in deleted file mode 100644 index 7d2fea60785..00000000000 --- a/media/libfishsound/src/libfishsound/Makefile.in +++ /dev/null @@ -1,58 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = fishsound -LIBRARY_NAME = fishsound -FORCE_STATIC_LIB= 1 - -CSRCS = \ - fishsound_comments.c \ - fishsound_decode.c \ - fishsound.c \ - fs_vector.c \ - fishsound_speex.c \ - fishsound_vorbis.c \ - fishsound_flac.c \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/media/libfishsound/src/libfishsound/config.h b/media/libfishsound/src/libfishsound/config.h deleted file mode 100644 index 561526a2614..00000000000 --- a/media/libfishsound/src/libfishsound/config.h +++ /dev/null @@ -1,138 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define if building universal (internal helper macro) */ -/* #undef AC_APPLE_UNIVERSAL_BUILD */ - -/* Do not build decoding support */ -#define FS_DECODE 1 - -/* Do not build encoding support */ -#define FS_ENCODE 0 - -/* Define to build experimental code */ -/* #undef FS_EXPERIMENTAL */ - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have libFLAC */ -#define HAVE_FLAC 0 - -/* Define to 1 if you have libFLAC 1.1.2 */ -/* #undef HAVE_FLAC_1_1_2 */ - -/* Define to 1 if you have libFLAC 1.1.3 */ -/* #undef HAVE_FLAC_1_1_3 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define if have libsndfile */ -/* #undef HAVE_LIBSNDFILE1 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define if have liboggz */ -/* #undef HAVE_OGGZ */ - -/* Define to 1 if you have libspeex */ -#define HAVE_SPEEX 0 - -/* Define to 1 if you have libspeex 1.1.x */ -/* #undef HAVE_SPEEX_1_1 */ - -/* Define to 1 if speex_lib_get_mode() exists in libspeex */ -/* #undef HAVE_SPEEX_LIB_GET_MODE */ - -/* Define to 1 if you have the header file. */ -/* #define HAVE_STDINT_H 1 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if the system has the type `uintptr_t'. */ -/* #define HAVE_UINTPTR_T 1 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have libvorbis */ -#define HAVE_VORBIS 1 - -/* Define to 1 if you have libvorbisenc */ -#define HAVE_VORBISENC 0 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "libfishsound" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "0.9.2" - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -/* # undef WORDS_BIGENDIAN */ -# endif -#endif - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ -#undef FS_ENCODE -#define FS_ENCODE 0 -#undef HAVE_FLAC -#define HAVE_FLAC 0 -#undef HAVE_OGGZ -#define HAVE_OGGZ 1 -#undef HAVE_SPEEX -#define HAVE_SPEEX 0 -#undef HAVE_VORBIS -#define HAVE_VORBIS 1 -#undef HAVE_VORBISENC -#define HAVE_VORBISENC 0 -#undef DEBUG - -#include "prcpucfg.h" -#ifdef IS_BIG_ENDIAN -#define WORDS_BIGENDIAN -#endif diff --git a/media/libfishsound/src/libfishsound/convert.h b/media/libfishsound/src/libfishsound/convert.h deleted file mode 100644 index 5a490d9690e..00000000000 --- a/media/libfishsound/src/libfishsound/convert.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __FISH_SOUND_CONVERT_H__ -#define __FISH_SOUND_CONVERT_H__ - -/* inline functions */ - -static inline void -_fs_deinterleave (float ** src, float * dest[], - long frames, int channels, float mult_factor) -{ - int i, j; - float * d, * s = (float *)src; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - d = dest[j]; - d[i] = s[i*channels + j] * mult_factor; - } - } -} - -static inline void -_fs_interleave (float * src[], float ** dest, - long frames, int channels, float mult_factor) -{ - int i, j; - float * s, * d = (float *)dest; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - s = src[j]; - d[i*channels + j] = s[i] * mult_factor; - } - } -} - -#endif /* __FISH_SOUND_CONVERT_H__ */ diff --git a/media/libfishsound/src/libfishsound/convert_c.h b/media/libfishsound/src/libfishsound/convert_c.h deleted file mode 100644 index 7bb900fcfee..00000000000 --- a/media/libfishsound/src/libfishsound/convert_c.h +++ /dev/null @@ -1,415 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __FISH_SOUND_CONVERT_C_H__ -#define __FISH_SOUND_CONVERT_C_H__ - -#include -#include - -/* inline functions */ - -static inline void -_fs_deinterleave_s_s (short ** src, short * dest[], - long frames, int channels) -{ - int i, j; - short * d, * s = (short *)src; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - d = dest[j]; - d[i] = s[i*channels + j]; - } - } -} - -static inline void -_fs_deinterleave_s_i (short ** src, int * dest[], long frames, int channels) -{ - int i, j; - short * s = (short *)src; - int * d; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - d = dest[j]; - d[i] = (int) s[i*channels + j]; - } - } -} - -static inline void -_fs_deinterleave_s_f (short ** src, float * dest[], long frames, int channels, - float mult) -{ - int i, j; - short * s = (short *)src; - float * d; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - d = dest[j]; - d[i] = ((float) s[i*channels + j]) * mult; - } - } -} - -static inline void -_fs_deinterleave_s_d (short ** src, double * dest[], long frames, int channels, - double mult) -{ - int i, j; - short * s = (short *)src; - double * d; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - d = dest[j]; - d[i] = ((double) s[i*channels + j]) * mult; - } - } -} - -static inline void -_fs_deinterleave_f_s (float ** src, short * dest[], - long frames, int channels, float mult) -{ - int i, j; - float * s = (float *)src; - short * d; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - d = dest[j]; - d[i] = (short) (s[i*channels + j] * mult); - } - } -} - -static inline void -_fs_deinterleave_f_i (float ** src, int * dest[], - long frames, int channels, float mult) -{ - int i, j; - float * s = (float *)src; - int * d; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - d = dest[j]; - d[i] = (int) (s[i*channels + j] * mult); - } - } -} - -static inline void -_fs_deinterleave_f_f (float ** src, float * dest[], - long frames, int channels, float mult) -{ - int i, j; - float * s = (float *)src, * d; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - d = dest[j]; - d[i] = s[i*channels + j] * mult; - } - } -} - -static inline void -_fs_deinterleave_f_d (float ** src, double * dest[], - long frames, int channels, double mult) -{ - int i, j; - float * s = (float *)src; - double * d; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - d = dest[j]; - d[i] = (double) s[i*channels + j] * mult; - } - } -} - -static inline void -_fs_interleave_f_s (float * src[], short ** dest, - long frames, int channels, float mult) -{ - int i, j; - float * s; - short * d = (short *)dest; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - s = src[j]; - d[i*channels + j] = (short) (s[i] * mult); - } - } -} - -static inline void -_fs_interleave_s_s (short * src[], short ** dest, - long frames, int channels) -{ - int i, j; - short * s, * d = (short *)dest; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - s = src[j]; - d[i*channels + j] = s[i]; - } - } -} - -static inline void -_fs_interleave_s_f (short * src[], float ** dest, - long frames, int channels, float mult) -{ - int i, j; - short * s; - float * d = (float *)dest; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - s = src[j]; - d[i*channels + j] = (float) (s[i] * mult); - } - } -} - -static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) { - int ret=x; - ret-= ((x<=32767)-1)&(x-32767); - ret-= ((x>=-32768)-1)&(x+32768); - return(ret); -} - -static inline void -_fs_interleave_i_s (ogg_int32_t * src[], short ** dest, - long frames, int channels, int shift) -{ - int i, j; - ogg_int32_t * s; - short * d = (short *)dest; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - s = src[j]; - d[i*channels + j] = (short) CLIP_TO_15(s[i]>>9); - } - } -} - -static inline void -_fs_interleave_i_f (int * src[], float ** dest, - long frames, int channels, float mult) -{ - int i, j; - int * s; - float * d = (float *)dest; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - s = src[j]; - d[i*channels + j] = (float) (s[i] * mult); - } - } -} - -static inline void -_fs_interleave_f_f (float * src[], float ** dest, - long frames, int channels, float mult) -{ - int i, j; - float * s, * d = (float *)dest; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - s = src[j]; - d[i*channels + j] = s[i] * mult; - } - } -} - -static inline void -_fs_interleave_d_s (double * src[], short ** dest, - long frames, int channels, double mult) -{ - int i, j; - double * s; - short * d = (short *)dest; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - s = src[j]; - d[i*channels + j] = (short) (s[i] * mult); - } - } -} - -static inline void -_fs_interleave_d_f (double * src[], float ** dest, - long frames, int channels, float mult) -{ - int i, j; - double * s; - float * d = (float *)dest; - - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - s = src[j]; - d[i*channels + j] = (float) s[i] * mult; - } - } -} - -static inline void -_fs_convert_s_s (short * src, short * dest, long samples) -{ - memcpy (dest, src, samples * sizeof (short)); -} - -static inline void -_fs_convert_s_i (short * src, int * dest, long samples) -{ - int i; - - for (i = 0; i < samples; i++) { - dest[i] = (int) src[i]; - } -} - -static inline void -_fs_convert_s_f (short * src, float * dest, long samples, float mult) -{ - int i; - - for (i = 0; i < samples; i++) { - dest[i] = (float) src[i] * mult; - } -} - -static inline void -_fs_convert_s_d (short * src, double * dest, long samples, double mult) -{ - int i; - - for (i = 0; i < samples; i++) { - dest[i] = ((double)src[i]) * mult; - } -} - -static inline void -_fs_convert_i_s (int * src, short * dest, long samples) -{ - int i; - - for (i = 0; i < samples; i++) { - dest[i] = (short) src[i]; - } -} - -static inline void -_fs_convert_i_f (int * src, float * dest, long samples, float mult) -{ - int i; - - for (i = 0; i < samples; i++) { - dest[i] = (float) src[i] * mult; - } -} - -static inline void -_fs_convert_f_s (float * src, short * dest, long samples, float mult) -{ - int i; - - for (i = 0; i < samples; i++) { - dest[i] = (short) (src[i] * mult); - } -} - -static inline void -_fs_convert_f_i (float * src, int * dest, long samples, float mult) -{ - int i; - - for (i = 0; i < samples; i++) { - dest[i] = (int) (src[i] * mult); - } -} - -static inline void -_fs_convert_f_f (float * src, float * dest, long samples, float mult) -{ - int i; - - for (i = 0; i < samples; i++) { - dest[i] = src[i] * mult; - } -} - -static inline void -_fs_convert_f_d (float * src, double * dest, long samples, double mult) -{ - int i; - - for (i = 0; i < samples; i++) { - dest[i] = (double)src[i] * mult; - } -} - -static inline void -_fs_convert_d_s (double * src, short * dest, long samples, double mult) -{ - int i; - - for (i = 0; i < samples; i++) { - dest[i] = (short) (src[i] * mult); - } -} - -static inline void -_fs_convert_d_f (double * src, float * dest, long samples, float mult) -{ - int i; - - for (i = 0; i < samples; i++) { - dest[i] = (float)src[i] * mult; - } -} - -#endif /* __FISH_SOUND_CONVERT_C_H__ */ diff --git a/media/libfishsound/src/libfishsound/convert_oil.h b/media/libfishsound/src/libfishsound/convert_oil.h deleted file mode 100644 index cacff7feb17..00000000000 --- a/media/libfishsound/src/libfishsound/convert_oil.h +++ /dev/null @@ -1,393 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * David Schleef, ds@schleef.org - * January, 2005 - */ - -#ifndef __FISH_SOUND_CONVERT_OIL_H__ -#define __FISH_SOUND_CONVERT_OIL_H__ - -#include -#include -#include - -/* inline functions */ - -static inline void -_fs_deinterleave_s_s (short ** src, short * dest[], - long frames, int channels) -{ - int j; - short * s = (short *)src; - -#define oil_restride_s16(a,b,c,d,e) oil_conv_u16_s16((uint16_t *)a,b,c,d,e) - for (j = 0; j < channels; j++) { - oil_restride_s16 (dest[j], sizeof(short), s + j, - channels * sizeof(short), frames); - } -} - -static inline void -_fs_deinterleave_s_i (short ** src, int * dest[], long frames, int channels) -{ - int j; - short * s = (short *)src; - - for (j = 0; j < channels; j++) { - oil_conv_s32_s16 (dest[j], sizeof(int), s + j, - channels * sizeof(short), frames); - } -} - -static inline void -_fs_deinterleave_s_f (short ** src, float * dest[], long frames, int channels, - float mult) -{ - int j; - short * s = (short *)src; - - for (j = 0; j < channels; j++) { - oil_conv_f32_s16 (dest[j], sizeof(float), s + j, - channels * sizeof(short), frames); - oil_scalarmult_f32 (dest[j], sizeof (float), dest[j], sizeof(float), - &mult, frames); - } -} - -static inline void -_fs_deinterleave_s_d (short ** src, double * dest[], long frames, int channels, - double mult) -{ - int j; - short * s = (short *)src; - - for (j = 0; j < channels; j++) { - oil_conv_f64_s16 (dest[j], sizeof(double), s + j, - channels * sizeof(short), frames); - oil_scalarmult_f64 (dest[j], sizeof (double), dest[j], sizeof (double), - &mult, frames); - } -} - -static inline void -_fs_deinterleave_f_s (float ** src, short * dest[], - long frames, int channels, float mult) -{ - int i, j; - float * s = (float *)src; - short * d; - - /* FIXME: this needs a temporary buffer for liboil */ - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - d = dest[j]; - d[i] = (short) (s[i*channels + j] * mult); - } - } -} - -static inline void -_fs_deinterleave_f_i (float ** src, int * dest[], - long frames, int channels, float mult) -{ - int i, j; - float * s = (float *)src; - int * d; - - /* FIXME: this needs a temporary buffer for liboil */ - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - d = dest[j]; - d[i] = (int) (s[i*channels + j] * mult); - } - } -} - -static inline void -_fs_deinterleave_f_f (float ** src, float * dest[], - long frames, int channels, float mult) -{ - int j; - float * s = (float *)src; - - for (j = 0; j < channels; j++) { - oil_scalarmult_f32 (dest[j], sizeof(float), s + j, - channels * sizeof(float), &mult, frames); - } -} - -static inline void -_fs_deinterleave_f_d (float ** src, double * dest[], - long frames, int channels, double mult) -{ - int j; - float * s = (float *)src; - - for (j = 0; j < channels; j++) { - oil_conv_f64_f32 (dest[j], sizeof(double), s + j, - channels * sizeof(float), frames); - oil_scalarmult_f64 (dest[j], sizeof(double), dest[j], - sizeof(double), &mult, frames); - } -} - -static inline void -_fs_interleave_f_s (float * src[], short ** dest, - long frames, int channels, float mult) -{ - int i, j; - float * s; - short * d = (short *)dest; - - /* FIXME: this needs a temporary buffer for liboil */ - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - s = src[j]; - d[i*channels + j] = (short) (s[i] * mult); - } - } -} - -static inline void -_fs_interleave_s_s (short * src[], short ** dest, - long frames, int channels) -{ - int j; - short * d = (short *)dest; - - for (j = 0; j < channels; j++) { - oil_restride_s16 (d + j, sizeof (short) * channels, src[j], - sizeof (short), frames); - } -} - -static inline void -_fs_interleave_s_f (short * src[], float ** dest, - long frames, int channels, float mult) -{ - int j; - float * d = (float *)dest; - - for (j = 0; j < channels; j++) { - oil_conv_f32_s16 (d + j, sizeof (float) * channels, src[j], - sizeof (short), frames); - } - oil_scalarmult_f32 (d, sizeof(float), d, sizeof(float), &mult, - channels * frames); -} - -static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) { - int ret=x; - ret-= ((x<=32767)-1)&(x-32767); - ret-= ((x>=-32768)-1)&(x+32768); - return(ret); -} - -static inline void -_fs_interleave_i_s (ogg_int32_t * src[], short ** dest, - long frames, int channels, int shift) -{ - int i, j; - ogg_int32_t * s; - short * d = (short *)dest; - - /* FIXME: shouldn't this use shift? */ - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - s = src[j]; - d[i*channels + j] = (short) CLIP_TO_15(s[i]>>9); - } - } -} - -static inline void -_fs_interleave_i_f (int * src[], float ** dest, - long frames, int channels, float mult) -{ - int j; - float * d = (float *)dest; - - for (j = 0; j < channels; j++) { - oil_conv_f32_s32 (d + j, sizeof (float) * channels, src[j], - sizeof (int), frames); - } - oil_scalarmult_f32 (d, sizeof(float), d, sizeof(float), &mult, - channels * frames); -} - -static inline void -_fs_interleave_f_f (float * src[], float ** dest, - long frames, int channels, float mult) -{ - int j; - float * d = (float *)dest; - - for (j = 0; j < channels; j++) { - oil_scalarmult_f32 (d + j, sizeof (float) * channels, src[j], - sizeof (float), &mult, frames); - } -} - -static inline void -_fs_interleave_d_s (double * src[], short ** dest, - long frames, int channels, double mult) -{ - int i, j; - double * s; - short * d = (short *)dest; - - /* FIXME: needs temporary buffer */ - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - s = src[j]; - d[i*channels + j] = (short) (s[i] * mult); - } - } -} - -static inline void -_fs_interleave_d_f (double * src[], float ** dest, - long frames, int channels, float mult) -{ - int j; - float * d = (float *)dest; - - for (j = 0; j < channels; j++) { - oil_conv_f32_f64 (d + j, sizeof (float) * channels, src[j], - sizeof (double), frames); - } - oil_scalarmult_f32 (d, sizeof(float), d, sizeof(float), &mult, - channels * frames); -} - -static inline void -_fs_convert_s_s (short * src, short * dest, long samples) -{ - memcpy (dest, src, samples * sizeof (short)); -} - -static inline void -_fs_convert_s_i (short * src, int * dest, long samples) -{ - oil_conv_s32_s16 (dest, sizeof(int), src, sizeof(short), samples); -} - -static inline void -_fs_convert_s_f (short * src, float * dest, long samples, float mult) -{ - oil_conv_f32_s16 (dest, sizeof(float), src, sizeof(short), samples); - oil_scalarmult_f32 (dest, sizeof(float), dest, sizeof(float), &mult, samples); -} - -static inline void -_fs_convert_s_d (short * src, double * dest, long samples, double mult) -{ - oil_conv_f64_s16 (dest, sizeof(double), src, sizeof(short), samples); - oil_scalarmult_f64 (dest, sizeof(double), dest, sizeof(double), &mult, - samples); -} - -static inline void -_fs_convert_i_s (int * src, short * dest, long samples) -{ - /* FIXME: should this clip? */ - oil_conv_s16_s32 (dest, sizeof(dest), src, sizeof(int), samples); - /* oil_clipconv_s16_s32 (dest, sizeof(dest), src, sizeof(int), samples); */ -} - -static inline void -_fs_convert_i_f (int * src, float * dest, long samples, float mult) -{ - oil_conv_f32_s32 (dest, sizeof(float), src, sizeof(int), samples); - oil_scalarmult_f32 (dest, sizeof(float), dest, sizeof(float), &mult, samples); -} - -static inline void -_fs_convert_f_s (float * src, short * dest, long samples, float mult) -{ - int i; - - /* FIXME: needs temp buffer */ - for (i = 0; i < samples; i++) { - dest[i] = (short) (src[i] * mult); - } -} - -static inline void -_fs_convert_f_i (float * src, int * dest, long samples, float mult) -{ - int i; - - /* FIXME: needs temp buffer */ - for (i = 0; i < samples; i++) { - dest[i] = (int) (src[i] * mult); - } -} - -static inline void -_fs_convert_f_f (float * src, float * dest, long samples, float mult) -{ - oil_scalarmult_f32 (dest, sizeof(float), src, sizeof(float), &mult, samples); -} - -static inline void -_fs_convert_f_d (float * src, double * dest, long samples, double mult) -{ - oil_conv_f64_f32 (dest, sizeof(double), src, sizeof(float), samples); - oil_scalarmult_f64 (dest, sizeof(double), dest, sizeof(double), &mult, samples); -} - -static inline void -_fs_convert_d_s (double * src, short * dest, long samples, double mult) -{ - int i; - - /* FIXME: needs temp buffer */ - for (i = 0; i < samples; i++) { - dest[i] = (short) (src[i] * mult); - } -} - -static inline void -_fs_convert_d_f (double * src, float * dest, long samples, float mult) -{ - int i; - - /* FIXME: needs temp buffer */ - for (i = 0; i < samples; i++) { - dest[i] = (float)src[i] * mult; - } -} - -#endif /* __FISH_SOUND_CONVERT_OIL_H__ */ diff --git a/media/libfishsound/src/libfishsound/debug.h b/media/libfishsound/src/libfishsound/debug.h deleted file mode 100644 index ac367c48e0d..00000000000 --- a/media/libfishsound/src/libfishsound/debug.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * A generic debugging printer. - * - * Conrad Parker , May 2009 - * - * Usage: - * - * #define DEBUG_LEVEL 3 - * #include "debug.h" - * - * ... - * debug_printf (2, "Something went wrong"); - * ... - * - * The macro print_debug(level, fmt) prints a formatted debugging message - * of level 'level' to stderr. You should set the maximum tolerable debug - * level before including debug.h. If it is 0, or if neither DEBUG_LEVEL - * nor DEBUG are defined, then the debug_printf() macro is ignored, and - * none of this file is included. - */ -#ifndef __DEBUG_H__ -#define __DEBUG_H__ - -/* MSVC can't handle C99 */ -#if (defined (_MSCVER) || defined (_MSC_VER)) -#define debug_printf // -#else - -#ifdef DEBUG -#ifndef DEBUG_LEVEL -#define DEBUG_LEVEL 1 -#endif -#endif - -#if (DEBUG_LEVEL > 0) - -#define DEBUG_MAXLINE 4096 - -#include -#include -#include -#include - -/* - * debug_print_err (func, line, fmt) - * - * Print a formatted error message to stderr. - */ -static void -debug_print_err (const char * func, int line, const char * fmt, ...) -{ - va_list ap; - int errno_save; - char buf[DEBUG_MAXLINE]; - int n=0; - - errno_save = errno; - - va_start (ap, fmt); - - if (func) { - snprintf (buf+n, DEBUG_MAXLINE-n, "%s():%d: ", func, line); - n = strlen (buf); - } - - vsnprintf (buf+n, DEBUG_MAXLINE-n, fmt, ap); - n = strlen (buf); - - fflush (stdout); /* in case stdout and stderr are the same */ - fputs (buf, stderr); - fputc ('\n', stderr); - fflush (NULL); - - va_end (ap); -} - -/* - * debug_printf (level, fmt) - * - * Print a formatted debugging message of level 'level' to stderr - */ -#define debug_printf(x,y...) {if (x <= DEBUG_LEVEL) debug_print_err (__func__, __LINE__, y);} - -#undef MAXLINE - -#else -#define debug_printf(x,y...) -#endif - -#endif /* non-C99 */ - -#endif /* __DEBUG_H__ */ diff --git a/media/libfishsound/src/libfishsound/fishsound.c b/media/libfishsound/src/libfishsound/fishsound.c deleted file mode 100644 index b096008bb02..00000000000 --- a/media/libfishsound/src/libfishsound/fishsound.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#include -#include - -#include "private.h" - -int -fish_sound_identify (unsigned char * buf, long bytes) -{ - if (bytes < 8) return FISH_SOUND_ERR_SHORT_IDENTIFY; - - if (HAVE_VORBIS && - fish_sound_vorbis_identify (buf, bytes) != FISH_SOUND_UNKNOWN) - return FISH_SOUND_VORBIS; - - if (HAVE_SPEEX && - fish_sound_speex_identify (buf, bytes) != FISH_SOUND_UNKNOWN) - return FISH_SOUND_SPEEX; - - if (fish_sound_flac_identify (buf, bytes) != FISH_SOUND_UNKNOWN) - return FISH_SOUND_FLAC; - - return FISH_SOUND_UNKNOWN; -} - -int -fish_sound_set_format (FishSound * fsound, int format) -{ - if (format == FISH_SOUND_VORBIS) { - fsound->codec = fish_sound_vorbis_codec (); - } else if (format == FISH_SOUND_SPEEX) { - fsound->codec = fish_sound_speex_codec (); - } else if (format == FISH_SOUND_FLAC) { - fsound->codec = fish_sound_flac_codec (); - } else { - return -1; - } - - if (fsound->codec && fsound->codec->init) - if (fsound->codec->init (fsound) == NULL) return -1; - - fsound->info.format = format; - - return format; -} - -FishSound * -fish_sound_new (int mode, FishSoundInfo * fsinfo) -{ - FishSound * fsound; - - if (!FS_DECODE && mode == FISH_SOUND_DECODE) return NULL; - - if (!FS_ENCODE && mode == FISH_SOUND_ENCODE) return NULL; - - if (mode == FISH_SOUND_ENCODE) { - if (fsinfo == NULL) { - return NULL; - } else { - if (!(HAVE_VORBIS && HAVE_VORBISENC)) { - if (fsinfo->format == FISH_SOUND_VORBIS) return NULL; - } - if (!HAVE_SPEEX) { - if (fsinfo->format == FISH_SOUND_SPEEX) return NULL; - } - if (!HAVE_FLAC) { - if (fsinfo->format == FISH_SOUND_FLAC) return NULL; - } - } - } else if (mode != FISH_SOUND_DECODE) { - return NULL; - } - - fsound = fs_malloc (sizeof (FishSound)); - if (fsound == NULL) return NULL; - - fsound->mode = mode; - fsound->interleave = 0; - fsound->frameno = 0; - fsound->next_granulepos = -1; - fsound->next_eos = 0; - fsound->codec = NULL; - fsound->codec_data = NULL; - fsound->callback.encoded = NULL; - fsound->user_data = NULL; - - fish_sound_comments_init (fsound); - - if (mode == FISH_SOUND_DECODE) { - fsound->info.samplerate = 0; - fsound->info.channels = 0; - fsound->info.format = FISH_SOUND_UNKNOWN; - } else if (mode == FISH_SOUND_ENCODE) { - fsound->info.samplerate = fsinfo->samplerate; - fsound->info.channels = fsinfo->channels; - fsound->info.format = fsinfo->format; - - if (fish_sound_set_format (fsound, fsinfo->format) == -1) { - fs_free (fsound); - return NULL; - } - } - - return fsound; -} - -long -fish_sound_flush (FishSound * fsound) -{ - if (fsound == NULL) return -1; - - if (fsound->codec && fsound->codec->flush) - return fsound->codec->flush (fsound); - - return 0; -} - -int -fish_sound_reset (FishSound * fsound) -{ - if (fsound == NULL) return -1; - - if (fsound->codec && fsound->codec->reset) - return fsound->codec->reset (fsound); - - return 0; -} - -FishSound * -fish_sound_delete (FishSound * fsound) -{ - if (fsound == NULL) return NULL; - - if (fsound->codec && fsound->codec->del) - fsound->codec->del (fsound); - - fs_free (fsound->codec); - - fish_sound_comments_free (fsound); - - fs_free (fsound); - - return NULL; -} - -int -fish_sound_command (FishSound * fsound, int command, void * data, int datasize) -{ - FishSoundInfo * fsinfo = (FishSoundInfo *)data; - int * pi = (int *)data; - - if (fsound == NULL) return -1; - - switch (command) { - case FISH_SOUND_GET_INFO: - memcpy (fsinfo, &fsound->info, sizeof (FishSoundInfo)); - break; - case FISH_SOUND_GET_INTERLEAVE: - *pi = fsound->interleave; - break; - case FISH_SOUND_SET_INTERLEAVE: - fsound->interleave = (*pi ? 1 : 0); - break; - default: - if (fsound->codec && fsound->codec->command) - return fsound->codec->command (fsound, command, data, datasize); - break; - } - - return 0; -} - -int -fish_sound_get_interleave (FishSound * fsound) -{ - if (fsound == NULL) return -1; - - return fsound->interleave; -} - -#ifndef FS_DISABLE_DEPRECATED -int -fish_sound_set_interleave (FishSound * fsound, int interleave) -{ - if (fsound == NULL) return -1; - - fsound->interleave = (interleave ? 1 : 0); - - return 0; -} -#endif - -long -fish_sound_get_frameno (FishSound * fsound) -{ - if (fsound == NULL) return -1L; - - return fsound->frameno; -} - -int -fish_sound_set_frameno (FishSound * fsound, long frameno) -{ - if (fsound == NULL) return -1; - - fsound->frameno = frameno; - - return 0; -} - -int -fish_sound_prepare_truncation (FishSound * fsound, long next_granulepos, - int next_eos) -{ - if (fsound == NULL) return -1; - - fsound->next_granulepos = next_granulepos; - fsound->next_eos = next_eos; - - return 0; -} diff --git a/media/libfishsound/src/libfishsound/fishsound_comments.c b/media/libfishsound/src/libfishsound/fishsound_comments.c deleted file mode 100644 index 52d28f48ed8..00000000000 --- a/media/libfishsound/src/libfishsound/fishsound_comments.c +++ /dev/null @@ -1,654 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#include -#include -#include -#include /* ULONG_MAX */ -#ifndef WIN32 -#include -#endif - -#include "private.h" - -/*#define DEBUG*/ -#include "debug.h" - -/* Ensure comment vector length can be expressed in 32 bits - * including space for the trailing NUL */ -#define MAX_COMMENT_LENGTH 0xFFFFFFFE -#define fs_comment_clamp(c) MIN((c),MAX_COMMENT_LENGTH) - -static size_t -fs_comment_len (const char * s) -{ - size_t len; - - if (s == NULL) return 0; - - len = strlen (s); - return fs_comment_clamp(len); -} - -static char * -fs_strdup (const char * s) -{ - char * ret; - if (s == NULL) return NULL; - ret = fs_malloc (fs_comment_len(s) + 1); - if (ret == NULL) return NULL; - return strcpy (ret, s); -} - -static char * -fs_strdup_len (const char * s, size_t len) -{ - char * ret; - if (s == NULL) return NULL; - if (len == 0) return NULL; - len = fs_comment_clamp(len); - ret = fs_malloc (len + 1); - if (ret == NULL) return NULL; - if (strncpy (ret, s, len) == NULL) { - fs_free (ret); - return NULL; - } - - ret[len] = '\0'; - return ret; -} - -static char * -fs_index_len (const char * s, char c, int len) -{ - int i; - - for (i = 0; *s && i < len; i++, s++) { - if (*s == c) return (char *)s; - } - - if (i < len) return (char *)s; - - return NULL; -} - -/* - Comments will be stored in the Vorbis style. - It is describled in the "Structure" section of - http://www.xiph.org/ogg/vorbis/doc/v-comment.html - -The comment header is decoded as follows: - 1) [vendor_length] = read an unsigned integer of 32 bits - 2) [vendor_string] = read a UTF-8 vector as [vendor_length] octets - 3) [user_comment_list_length] = read an unsigned integer of 32 bits - 4) iterate [user_comment_list_length] times { - 5) [length] = read an unsigned integer of 32 bits - 6) this iteration's user comment = read a UTF-8 vector as [length] octets - } - 7) [framing_bit] = read a single bit as boolean - 8) if ( [framing_bit] unset or end of packet ) then ERROR - 9) done. - - If you have troubles, please write to ymnk@jcraft.com. - */ - -#define readint(buf, base) (((buf[base+3]<<24)&0xff000000)| \ - ((buf[base+2]<<16)&0xff0000)| \ - ((buf[base+1]<<8)&0xff00)| \ - (buf[base]&0xff)) -#define writeint(buf, base, val) do{ buf[base+3]=((val)>>24)&0xff; \ - buf[base+2]=((val)>>16)&0xff; \ - buf[base+1]=((val)>>8)&0xff; \ - buf[base]=(val)&0xff; \ - }while(0) - -static int -fs_comment_validate_byname (const char * name, const char * value) -{ - const char * c; - - if (!name || !value) return 0; - - for (c = name; *c; c++) { - if (*c < 0x20 || *c > 0x7D || *c == 0x3D) { - debug_printf (1, "XXX char %c in %s invalid", *c, name); - return 0; - } - } - - /* XXX: we really should validate value as UTF-8 here, but ... */ - - return 1; -} - -static FishSoundComment * -fs_comment_new (const char * name, const char * value) -{ - FishSoundComment * comment; - - if (!fs_comment_validate_byname (name, value)) return NULL; - /* Ensures that name != NULL, value != NULL, and validates strings */ - - comment = fs_malloc (sizeof (FishSoundComment)); - if (comment == NULL) return NULL; - - comment->name = fs_strdup (name); - if (comment->name == NULL) { - fs_free (comment); - return NULL; - } - - comment->value = fs_strdup (value); - if (comment->value == NULL) { - fs_free (comment->name); - fs_free (comment); - return NULL; - } - - return comment; -} - -static void -fs_comment_free (FishSoundComment * comment) -{ - if (!comment) return; - if (comment->name) fs_free (comment->name); - if (comment->value) fs_free (comment->value); - fs_free (comment); -} - -static int -fs_comment_cmp (const FishSoundComment * comment1, const FishSoundComment * comment2) -{ - if (comment1 == comment2) return 1; - if (!comment1 || !comment2) return 0; - - if (strcasecmp (comment1->name, comment2->name)) return 0; - if (strcmp (comment1->value, comment2->value)) return 0; - - return 1; -} - -int -fish_sound_comment_set_vendor (FishSound * fsound, const char * vendor_string) -{ - if (fsound == NULL) return FISH_SOUND_ERR_BAD; - - if (fsound->vendor) fs_free (fsound->vendor); - - if ((fsound->vendor = fs_strdup (vendor_string)) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - - return 0; -} - -/* Public API */ - -const char * -fish_sound_comment_get_vendor (FishSound * fsound) -{ - if (fsound == NULL) return NULL; - - return fsound->vendor; -} - -const FishSoundComment * -fish_sound_comment_first (FishSound * fsound) -{ - if (fsound == NULL) return NULL; - - return fs_vector_nth (fsound->comments, 0); -} - -const FishSoundComment * -fish_sound_comment_first_byname (FishSound * fsound, char * name) -{ - FishSoundComment * comment; - int i; - - if (fsound == NULL) return NULL; - - if (name == NULL) return fs_vector_nth (fsound->comments, 0); - - if (!fs_comment_validate_byname (name, "")) - return NULL; - - for (i = 0; i < fs_vector_size (fsound->comments); i++) { - comment = (FishSoundComment *) fs_vector_nth (fsound->comments, i); - if (comment->name && !strcasecmp (name, comment->name)) - return comment; - } - - return NULL; -} - -const FishSoundComment * -fish_sound_comment_next (FishSound * fsound, const FishSoundComment * comment) -{ - int i; - - if (fsound == NULL || comment == NULL) return NULL; - - i = fs_vector_find_index (fsound->comments, comment); - - return fs_vector_nth (fsound->comments, i+1); -} - -const FishSoundComment * -fish_sound_comment_next_byname (FishSound * fsound, - const FishSoundComment * comment) -{ - FishSoundComment * v_comment; - int i; - - if (fsound == NULL || comment == NULL) return NULL; - - i = fs_vector_find_index (fsound->comments, comment); - - for (i++; i < fs_vector_size (fsound->comments); i++) { - v_comment = (FishSoundComment *) fs_vector_nth (fsound->comments, i); - if (v_comment->name && !strcasecmp (comment->name, v_comment->name)) - return v_comment; - } - - return NULL; -} - -#define _fs_comment_add(f,c) fs_vector_insert ((f)->comments, (c)) - -int -fish_sound_comment_add (FishSound * fsound, FishSoundComment * comment) -{ -#if FS_ENCODE - FishSoundComment * new_comment; -#endif - - if (fsound == NULL) return FISH_SOUND_ERR_BAD; - - if (fsound->mode != FISH_SOUND_ENCODE) - return FISH_SOUND_ERR_INVALID; - -#if FS_ENCODE - if (!fs_comment_validate_byname (comment->name, comment->value)) - return FISH_SOUND_ERR_COMMENT_INVALID; - - if ((new_comment = fs_comment_new (comment->name, comment->value)) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - - if (_fs_comment_add (fsound, new_comment) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - - return FISH_SOUND_OK; -#else - return FISH_SOUND_ERR_DISABLED; -#endif -} - -int -fish_sound_comment_add_byname (FishSound * fsound, const char * name, - const char * value) -{ -#if FS_ENCODE - FishSoundComment * comment; -#endif - - if (fsound == NULL) return FISH_SOUND_ERR_BAD; - - if (fsound->mode != FISH_SOUND_ENCODE) - return FISH_SOUND_ERR_INVALID; - -#if FS_ENCODE - if (!fs_comment_validate_byname (name, value)) - return FISH_SOUND_ERR_COMMENT_INVALID; - - if ((comment = fs_comment_new (name, value)) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - - if (_fs_comment_add (fsound, comment) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - - return FISH_SOUND_OK; - - return 0; - -#else - return FISH_SOUND_ERR_DISABLED; -#endif -} - -int -fish_sound_comment_remove (FishSound * fsound, FishSoundComment * comment) -{ -#if FS_ENCODE - FishSoundComment * v_comment; -#endif - - if (fsound == NULL) return FISH_SOUND_ERR_BAD; - - if (fsound->mode != FISH_SOUND_ENCODE) - return FISH_SOUND_ERR_INVALID; - -#if FS_ENCODE - - v_comment = fs_vector_find (fsound->comments, comment); - - if (v_comment == NULL) return 0; - - fs_vector_remove (fsound->comments, v_comment); - fs_comment_free (v_comment); - - return 1; - -#else - return FISH_SOUND_ERR_DISABLED; -#endif -} - -int -fish_sound_comment_remove_byname (FishSound * fsound, char * name) -{ -#if FS_ENCODE - FishSoundComment * comment; - int i; -#endif - int ret = 0; - - if (fsound == NULL) return FISH_SOUND_ERR_BAD; - - if (fsound->mode != FISH_SOUND_ENCODE) - return FISH_SOUND_ERR_INVALID; - -#if FS_ENCODE - for (i = 0; i < fs_vector_size (fsound->comments); i++) { - comment = (FishSoundComment *) fs_vector_nth (fsound->comments, i); - if (!strcasecmp (name, comment->name)) { - fish_sound_comment_remove (fsound, comment); - i--; - ret++; - } - } - - return ret; - -#else - return FISH_SOUND_ERR_DISABLED; -#endif -} - -/* Internal API */ -int -fish_sound_comments_init (FishSound * fsound) -{ - fsound->vendor = NULL; - fsound->comments = fs_vector_new ((FishSoundCmpFunc) fs_comment_cmp); - - return 0; -} - -int -fish_sound_comments_free (FishSound * fsound) -{ - fs_vector_foreach (fsound->comments, (FishSoundFunc)fs_comment_free); - fs_vector_delete (fsound->comments); - fsound->comments = NULL; - - if (fsound->vendor) fs_free (fsound->vendor); - fsound->vendor = NULL; - - return 0; -} - -int -fish_sound_comments_decode (FishSound * fsound, unsigned char * comments, - long length) -{ - char *c= (char *)comments; - int i, nb_fields, n; - size_t len; - char *end; - char * name, * value, * nvalue = NULL; - FishSoundComment * comment; - - if (length<8) - return -1; - - end = c+length; - len=readint(c, 0); - - c+=4; - if (len > (unsigned long) length - 4) return -1; - - /* Vendor */ - if (len > 0) { - if ((nvalue = fs_strdup_len (c, len)) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - if (fish_sound_comment_set_vendor (fsound, nvalue) == FISH_SOUND_ERR_OUT_OF_MEMORY) { - fs_free (nvalue); - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - - fs_free (nvalue); - } -#ifdef DEBUG - fwrite(c, 1, len, stderr); fputc ('\n', stderr); -#endif - c+=len; - - if (c+4>end) return -1; - - /* This value gets checked effectively by the 'for' condition - and the checks within the loop for c running off the end. */ - nb_fields=readint(c, 0); - debug_printf (1, "%d comments", nb_fields); - - c+=4; - for (i=0;iend) return -1; - - len=readint(c, 0); - debug_printf (1, "[%d] len %d\n", i, len); - - c+=4; - if (len > (unsigned long) (end-c)) return -1; - - name = c; - value = fs_index_len (c, '=', len); - n = 0; - if (value) { - *value = '\0'; - value++; - n = c+len - value; - - } - if (n) { - if ((nvalue = fs_strdup_len (value, n)) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - - debug_printf (1, "%s -> %s (length %d)", name, nvalue, n); - - if ((comment = fs_comment_new (name, nvalue)) == NULL) { - fs_free (nvalue); - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - - if (_fs_comment_add (fsound, comment) == NULL) { - fs_free (nvalue); - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - - fs_free (nvalue); - } else if (len > 0) { - debug_printf (1, "[%d] %s (no value)", i, name, len); - - if ((nvalue = fs_strdup_len (name, len)) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - - if ((comment = fs_comment_new (nvalue, "")) == NULL) { - fs_free (nvalue); - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - - if (_fs_comment_add (fsound, comment) == NULL) { - fs_free (nvalue); - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - - fs_free (nvalue); - } - - c+=len; - } - - debug_printf (1, "OUT"); - - return FISH_SOUND_OK; -} - -/* - * Pre-condition: at least one of accum, delta are non-zero, - * ie. don't call accum_length (0, 0); - * \retval 0 Failure: integer overflow - */ -static unsigned long -accum_length (unsigned long * accum, unsigned long delta) -{ - /* Pre-condition: don't call accum_length (0, 0) */ - if (*accum == 0 && delta == 0) - return 0; - - /* Check for integer overflow */ - if (delta > ULONG_MAX - (*accum)) - return 0; - - *accum += delta; - - return *accum; -} - -long -fish_sound_comments_encode (FishSound * fsound, unsigned char * buf, - long length) -{ - char * c = (char *)buf; - const FishSoundComment * comment; - int nb_fields = 0, vendor_length = 0; - unsigned long actual_length = 0, remaining = length, field_length; - - /* Vendor string */ - if (fsound->vendor) - vendor_length = fs_comment_len (fsound->vendor); - if (accum_length (&actual_length, 4 + vendor_length) == 0) - return 0; - - /* user comment list length */ - if (accum_length (&actual_length, 4) == 0) - return 0; - - for (comment = fish_sound_comment_first (fsound); comment; - comment = fish_sound_comment_next (fsound, comment)) { - /* [size]"name" */ - if (accum_length (&actual_length, 4 + fs_comment_len (comment->name)) == 0) - return 0; - if (comment->value) { - /* "=value" */ - if (accum_length (&actual_length, 1 + fs_comment_len (comment->value)) == 0) - return 0; - } - - debug_printf (1, "%s = %s", comment->name, comment->value); - - nb_fields++; - } - - /* framing bit */ - if (accum_length (&actual_length, 1) == 0) - return 0; - - /* NB. actual_length is not modified from here onwards */ - - if (buf == NULL) return actual_length; - - remaining -= 4; - if (remaining <= 0) return actual_length; - writeint (c, 0, vendor_length); - c += 4; - - if (fsound->vendor) { - field_length = fs_comment_len (fsound->vendor); - memcpy (c, fsound->vendor, MIN (field_length, remaining)); - c += field_length; remaining -= field_length; - if (remaining <= 0) return actual_length; - } - - remaining -= 4; - if (remaining <= 0) return actual_length; - writeint (c, 0, nb_fields); - c += 4; - - for (comment = fish_sound_comment_first (fsound); comment; - comment = fish_sound_comment_next (fsound, comment)) { - - field_length = fs_comment_len (comment->name); /* [size]"name" */ - if (comment->value) - field_length += 1 + fs_comment_len (comment->value); /* "=value" */ - - remaining -= 4; - if (remaining <= 0) return actual_length; - writeint (c, 0, field_length); - c += 4; - - field_length = fs_comment_len (comment->name); - memcpy (c, comment->name, MIN (field_length, remaining)); - c += field_length; remaining -= field_length; - if (remaining <= 0) return actual_length; - - if (comment->value) { - remaining --; - if (remaining <= 0) return actual_length; - *c = '='; - c++; - - field_length = fs_comment_len (comment->value); - memcpy (c, comment->value, MIN (field_length, remaining)); - c += field_length; remaining -= field_length; - if (remaining <= 0) return actual_length; - } - } - - if (remaining <= 0) return actual_length; - *c = 0x01; - - return actual_length; -} diff --git a/media/libfishsound/src/libfishsound/fishsound_decode.c b/media/libfishsound/src/libfishsound/fishsound_decode.c deleted file mode 100644 index ae966243027..00000000000 --- a/media/libfishsound/src/libfishsound/fishsound_decode.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#include -#include - -#include "private.h" - -static int -fs_decode_update (FishSound * fsound, int interleave) -{ - int ret = 0; - - if (fsound->codec && fsound->codec->update) - ret = fsound->codec->update (fsound, interleave); - - if (ret >= 0) { - fsound->interleave = interleave; - } - - return ret; -} - -int fish_sound_set_decoded_float (FishSound * fsound, - FishSoundDecoded_Float decoded, - void * user_data) -{ - int ret = 0; - - if (fsound == NULL) return FISH_SOUND_ERR_BAD; - -#if FS_DECODE - ret = fs_decode_update (fsound, 0); - - if (ret >= 0) { - fsound->callback.decoded_float = decoded; - fsound->user_data = user_data; - } -#else - return FISH_SOUND_ERR_DISABLED; -#endif - - return ret; -} - -int fish_sound_set_decoded_float_ilv (FishSound * fsound, - FishSoundDecoded_FloatIlv decoded, - void * user_data) -{ - int ret = 0; - - if (fsound == NULL) return FISH_SOUND_ERR_BAD; - -#if FS_DECODE - ret = fs_decode_update (fsound, 1); - - if (ret >= 0) { - fsound->callback.decoded_float_ilv = decoded; - fsound->user_data = user_data; - } -#else - return FISH_SOUND_ERR_DISABLED; -#endif - - return ret; -} - -long -fish_sound_decode (FishSound * fsound, unsigned char * buf, long bytes) -{ - int format; - - if (fsound == NULL) return FISH_SOUND_ERR_BAD; - -#if FS_DECODE - if (fsound->info.format == FISH_SOUND_UNKNOWN) { - format = fish_sound_identify (buf, bytes); - if (format == FISH_SOUND_UNKNOWN) return -1; - - fish_sound_set_format (fsound, format); - } - - /*printf ("format: %s\n", fsound->codec->format->name);*/ - - if (fsound->codec && fsound->codec->decode) - return fsound->codec->decode (fsound, buf, bytes); -#else - return FISH_SOUND_ERR_DISABLED; -#endif - - return 0; -} - - -/* DEPRECATED */ -int fish_sound_set_decoded_callback (FishSound * fsound, - FishSoundDecoded_Float decoded, - void * user_data) -{ - if (fsound == NULL) return -1; - - return fsound->interleave ? - fish_sound_set_decoded_float_ilv (fsound, decoded, user_data) : - fish_sound_set_decoded_float (fsound, decoded, user_data); -} diff --git a/media/libfishsound/src/libfishsound/fishsound_encode.c b/media/libfishsound/src/libfishsound/fishsound_encode.c deleted file mode 100644 index f1f4f98fa71..00000000000 --- a/media/libfishsound/src/libfishsound/fishsound_encode.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#include -#include - -#include "private.h" - -int -fish_sound_set_encoded_callback (FishSound * fsound, - FishSoundEncoded encoded, - void * user_data) -{ - if (fsound == NULL) return -1; - -#if FS_ENCODE - fsound->callback.encoded = (void *)encoded; - fsound->user_data = user_data; -#else - return FISH_SOUND_ERR_DISABLED; -#endif - - return 0; -} - -long fish_sound_encode_float (FishSound * fsound, float * pcm[], long frames) -{ - if (fsound == NULL) return -1; - -#if FS_ENCODE - if (fsound->codec && fsound->codec->encode_f) - return fsound->codec->encode_f (fsound, pcm, frames); -#else - return FISH_SOUND_ERR_DISABLED; -#endif - - return 0; -} - -long fish_sound_encode_float_ilv (FishSound * fsound, float ** pcm, - long frames) -{ - if (fsound == NULL) return -1; - -#if FS_ENCODE - if (fsound->codec && fsound->codec->encode_f_ilv) - return fsound->codec->encode_f_ilv (fsound, pcm, frames); -#else - return FISH_SOUND_ERR_DISABLED; -#endif - - return 0; -} - -#ifndef FS_DISABLE_DEPRECATED -long -fish_sound_encode (FishSound * fsound, float ** pcm, long frames) -{ - if (fsound == NULL) return -1; - -#if FS_ENCODE - if (fsound->interleave) { - if (fsound->codec && fsound->codec->encode_f_ilv) - return fsound->codec->encode_f_ilv (fsound, pcm, frames); - } else { - if (fsound->codec && fsound->codec->encode_f) - return fsound->codec->encode_f (fsound, pcm, frames); - } -#else - return FISH_SOUND_ERR_DISABLED; -#endif - - return 0; -} -#endif /* DEPRECATED */ diff --git a/media/libfishsound/src/libfishsound/fishsound_flac.c b/media/libfishsound/src/libfishsound/fishsound_flac.c deleted file mode 100644 index 90621aec867..00000000000 --- a/media/libfishsound/src/libfishsound/fishsound_flac.c +++ /dev/null @@ -1,851 +0,0 @@ -/* - Copyright (C) 2007 Annodex Association - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Annodex Association nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ASSOCIATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* Original patches by Tobias Gehrig, 2005 - * http://www.annodex.net/software/libfishsound/libfishsound-flac/ - * - * The Ogg FLAC mapping is documented in: - * http://flac.sourceforge.net/ogg_mapping.html - */ - -#include "config.h" - -#include -#include -#include - -#include "private.h" -#include "convert.h" - -#define DEBUG_VERBOSE 2 -/* #define DEBUG */ -/* #define DEBUG_LEVEL DEBUG_VERBOSE */ -#include "debug.h" - -#if HAVE_FLAC - -#include "FLAC/all.h" - -#define BITS_PER_SAMPLE 24 - -typedef struct _FishSoundFlacInfo { - FLAC__StreamDecoder *fsd; - FLAC__StreamEncoder *fse; - unsigned char * buffer; - char header; - long bufferlength; - unsigned long packetno; - struct { - unsigned char major, minor; - } version; - unsigned short header_packets; - void * ipcm; -#if FS_DECODE - float * pcm_out[8]; /* non-interleaved pcm, output (decode only); - * FLAC does max 8 channels */ -#endif -#if FS_ENCODE - FLAC__StreamMetadata * enc_vc_metadata; /* FLAC metadata structure for - * vorbiscomments (encode only) */ -#endif -} FishSoundFlacInfo; - -int -fish_sound_flac_identify (unsigned char * buf, long bytes) -{ - if (bytes < 8) return FISH_SOUND_UNKNOWN; - if (buf[0] != 0x7f) return FISH_SOUND_UNKNOWN; - if (!strncmp ((char *)buf+1, "FLAC", 4)) { - debug_printf(1, "flac found"); - /* if only a short buffer was passed, do a weak identify */ - if (bytes == 8) return FISH_SOUND_FLAC; - - /* otherwise, look for the fLaC header preceding STREAMINFO */ - if (!strncmp ((char *)buf+9, "fLaC", 4)) { - return FISH_SOUND_FLAC; - } - } - - return FISH_SOUND_UNKNOWN; -} - -static int -fs_flac_command (FishSound * fsound, int command, void * data, int datasize) -{ - return 0; -} - -#if FS_DECODE -static FLAC__StreamDecoderReadStatus -fs_flac_read_callback(const FLAC__StreamDecoder *decoder, - FLAC__byte buffer[], unsigned *bytes, - void *client_data) -{ - FishSound* fsound = (FishSound*)client_data; - FishSoundFlacInfo* fi = (FishSoundFlacInfo *)fsound->codec_data; - debug_printf(DEBUG_VERBOSE, "fs_flac_read_callback: IN"); - if (fi->bufferlength > *bytes) { - debug_printf(1, "too much data"); - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - } else if (fi->bufferlength < 1) { - debug_printf(1, "no data, %ld",fi->bufferlength); - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - } - - memcpy(buffer, fi->buffer, fi->bufferlength); - *bytes = fi->bufferlength; - fi->bufferlength = 0; - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; -} - -static FLAC__StreamDecoderWriteStatus -fs_flac_write_callback(const FLAC__StreamDecoder *decoder, - const FLAC__Frame *frame, - const FLAC__int32 * const buffer[], - void *client_data) -{ - FishSound* fsound = (FishSound*)client_data; - FishSoundFlacInfo* fi = (FishSoundFlacInfo *)fsound->codec_data; - int i, j, channels, blocksize, offset; - float * ipcm; - - channels = frame->header.channels; - blocksize = frame->header.blocksize; - - debug_printf(DEBUG_VERBOSE, "IN, blocksize %d", blocksize); - - fsound->frameno += blocksize; - - if (fsound->callback.decoded_float) { - float norm = 1.0 / ((1 << (frame->header.bits_per_sample - 1))); - - if (fsound->interleave) { - FishSoundDecoded_FloatIlv dfi; - float* retpcm; - - if ((ipcm = realloc(fi->ipcm, sizeof(float) * channels * blocksize)) == NULL) - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - - fi->ipcm = ipcm; - retpcm = (float*) fi->ipcm; - for (i = 0; i < blocksize; i++) { - offset = i * channels; - for (j = 0; j < channels; j++) - retpcm[offset + j] = buffer[j][i] * norm; - } - dfi = (FishSoundDecoded_FloatIlv)fsound->callback.decoded_float_ilv; - dfi (fsound, (float **)retpcm, blocksize, fsound->user_data); - } else { - FishSoundDecoded_Float df; - FLAC__int32 * s = (FLAC__int32 *)buffer; /* de-interleave source */ - float *d; /* de-interleave dest */ - - for (j = 0; j < channels; j++) { - if ((ipcm = realloc(fi->pcm_out[j], sizeof(float) * blocksize)) == NULL) - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - fi->pcm_out[j] = ipcm; - } - for (i = 0; i < blocksize; i++) - for (j = 0; j < channels; j++) { - d = fi->pcm_out[j]; - d[i] = s[i*channels + j] * norm; - } - df = (FishSoundDecoded_Float)fsound->callback.decoded_float; - df (fsound, fi->pcm_out, blocksize, fsound->user_data); - } - } - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -static void -fs_flac_meta_callback(const FLAC__StreamDecoder *decoder, - const FLAC__StreamMetadata *metadata, - void *client_data) -{ - FishSound* fsound = (FishSound*)client_data; - /* FishSoundFlacInfo* fi = (FishSoundFlacInfo *)fsound->codec_data; */ - debug_printf(1, "IN"); - - switch (metadata->type) { - case FLAC__METADATA_TYPE_STREAMINFO: - debug_printf(1, "channels %d, samplerate %d", - metadata->data.stream_info.channels, - metadata->data.stream_info.sample_rate); - fsound->info.channels = metadata->data.stream_info.channels; - fsound->info.samplerate = metadata->data.stream_info.sample_rate; - break; - default: - debug_printf(1, "not yet implemented type"); - break; - } -} - -static void -fs_flac_error_callback(const FLAC__StreamDecoder *decoder, - FLAC__StreamDecoderErrorStatus status, - void *client_data) -{ - debug_printf(1, "IN"); - fprintf(stderr, "FLAC ERROR: %s\n", FLAC__StreamDecoderErrorStatusString[status]); -} -#endif -#if FS_DECODE -static void* -fs_flac_decode_header (FishSound * fsound, unsigned char *buf, long bytes) -{ - FishSoundFlacInfo *fi = fsound->codec_data; - - if (bytes < 9) return NULL; - if (buf[0] != 0x7f) return NULL; - if (strncmp((char *)buf+1, "FLAC", 4) != 0) return NULL; - fi->version.major = buf[5]; - fi->version.minor = buf[6]; - debug_printf(1, "Flac Ogg Mapping Version: %d.%d", - fi->version.major, fi->version.minor); - fi->header_packets = buf[7] << 8 | buf[8]; - debug_printf(1, "Number of Header packets: %d", fi->header_packets); - - if ((fi->fsd = FLAC__stream_decoder_new()) == NULL) { - debug_printf (1, "unable to create new stream_decoder"); - return NULL; - } - -#if defined (HAVE_FLAC_1_1_2) - FLAC__stream_decoder_set_read_callback(fi->fsd, fs_flac_read_callback); - FLAC__stream_decoder_set_write_callback(fi->fsd, fs_flac_write_callback); - FLAC__stream_decoder_set_metadata_callback(fi->fsd, fs_flac_meta_callback); - FLAC__stream_decoder_set_error_callback(fi->fsd, fs_flac_error_callback); - FLAC__stream_decoder_set_client_data(fi->fsd, fsound); - - if (FLAC__stream_decoder_init(fi->fsd) != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA) - return NULL; -#elif defined (HAVE_FLAC_1_1_3) - if (FLAC__stream_decoder_init_stream - (fi->fsd, - fs_flac_read_callback, - NULL, /* seek callback */ - NULL, /* tell callback */ - NULL, /* length callback */ - NULL, /* EOF callback */ - fs_flac_write_callback, - fs_flac_meta_callback, - fs_flac_error_callback, - fsound - ) != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA) - return NULL; -#endif - - return fi->fsd; -} - -static long -fs_flac_decode (FishSound * fsound, unsigned char * buf, long bytes) -{ - FishSoundFlacInfo *fi = fsound->codec_data; - - debug_printf(DEBUG_VERBOSE, "IN, fi->packetno = %ld", fi->packetno); - - if (fi->packetno == 0) { - if (fs_flac_decode_header (fsound, buf, bytes) == NULL) { - debug_printf(1, "Error reading header"); - return -1; - } - if ((fi->buffer = fs_malloc(sizeof(unsigned char)*bytes)) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - - memcpy(fi->buffer, buf+9, bytes-9); - fi->bufferlength = bytes-9; - } - else if (fi->packetno <= fi->header_packets){ - unsigned char* tmp; - debug_printf(1, "handling header (fi->header_packets = %d)", - fi->header_packets); - -#if 0 - if (fi->packetno == 1) fish_sound_comments_decode (fsound, buf, bytes); -#endif - - if ((buf[0] & 0x7) == 4) { - int len = (buf[1]<<16) + (buf[2]<<8) + buf[3]; - debug_printf (1, "got vorbiscomments len %d", len); - - if (fish_sound_comments_decode (fsound, buf+4, len) == FISH_SOUND_ERR_OUT_OF_MEMORY) { - fi->packetno++; - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - } - - if ((tmp = fs_malloc(sizeof(unsigned char)*(fi->bufferlength+bytes))) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - - memcpy(tmp, fi->buffer, fi->bufferlength); - memcpy(tmp+fi->bufferlength, buf, bytes); - fi->bufferlength += bytes; - fs_free(fi->buffer); - fi->buffer = tmp; - if (fi->packetno == fi->header_packets) { - if (FLAC__stream_decoder_process_until_end_of_metadata(fi->fsd) == false) { - goto dec_err; - } - fs_free(fi->buffer); - } - } else { - fi->buffer = buf; - fi->bufferlength = bytes; - if (FLAC__stream_decoder_process_single(fi->fsd) == false) { - goto dec_err; - } - } - fi->packetno++; - - return 0; - -dec_err: - switch (FLAC__stream_decoder_get_state(fi->fsd)) { - case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR: - return FISH_SOUND_ERR_OUT_OF_MEMORY; - default: - return FISH_SOUND_ERR_GENERIC; - } -} -#else /* !FS_DECODE */ - -#define fs_flac_decode NULL - -#endif - - -#if FS_ENCODE -static FLAC__StreamEncoderWriteStatus -fs_flac_enc_write_callback(const FLAC__StreamEncoder *encoder, - const FLAC__byte buffer[], unsigned bytes, - unsigned samples, unsigned current_frame, - void *client_data) -{ - FishSound* fsound = (FishSound*)client_data; - FishSoundFlacInfo *fi = fsound->codec_data; - - debug_printf(1, "IN"); - debug_printf(1, "bytes: %d, samples: %d", bytes, samples); - - if (fsound->callback.encoded) { - FishSoundEncoded encoded = (FishSoundEncoded) fsound->callback.encoded; - if (fi->packetno == 0 && fi->header <= 1) { - if (fi->header == 0) { - /* libFLAC has called us with data containing the normal fLaC header - * and a STREAMINFO block. Prepend the FLAC Ogg mapping header, - * as described in http://flac.sourceforge.net/ogg_mapping.html. - */ - debug_printf(1, "generating FLAC header packet: %c%c%c%c", - buffer[0], buffer[1], buffer[2], buffer[3]); - - if ((fi->buffer = (unsigned char*)fs_malloc(sizeof(unsigned char)*(bytes+9))) == NULL) - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - - fi->buffer[0] = 0x7f; - fi->buffer[1] = 0x46; /* 'F' */ - fi->buffer[2] = 0x4c; /* 'L' */ - fi->buffer[3] = 0x41; /* 'A' */ - fi->buffer[4] = 0x43; /* 'C' */ - fi->buffer[5] = 1; /* Version major generated by this file */ - fi->buffer[6] = 0; /* Version minor generated by this file */ - fi->buffer[7] = 0; /* MSB(be): Nr. other non-audio header packets */ - fi->buffer[8] = 1; /* LSB(be): Nr. other non-audio header packets */ - memcpy (fi->buffer+9, buffer, bytes); /* fLaC header ++ STREAMINFO */ - fi->bufferlength = bytes+9; - - fi->header++; - } else { - /* Make a temporary copy of the metadata header to pass to the user - * callback. - */ - unsigned char* tmp; - - if ((tmp = (unsigned char*)fs_malloc(sizeof(unsigned char)*(bytes+fi->bufferlength))) == NULL) - return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR; - - memcpy (tmp, fi->buffer, fi->bufferlength); - memcpy (tmp+fi->bufferlength, buffer, bytes); - fs_free(fi->buffer); - fi->buffer = tmp; - fi->bufferlength += bytes; - fi->header++; - encoded (fsound, (unsigned char *)fi->buffer, (long)fi->bufferlength, - fsound->user_data); - } - } else { - fsound->frameno += samples; - encoded (fsound, (unsigned char *)buffer, (long)bytes, - fsound->user_data); - } - } - - return FLAC__STREAM_ENCODER_WRITE_STATUS_OK; -} - -static void -fs_flac_enc_meta_callback(const FLAC__StreamEncoder *encoder, - const FLAC__StreamMetadata *metadata, - void *client_data) -{ - /* FishSound* fsound = (FishSound*)client_data; */ - /* FishSoundFlacInfo* fi = (FishSoundFlacInfo *)fsound->codec_data; */ - debug_printf(1, "IN"); - - switch (metadata->type) { - case FLAC__METADATA_TYPE_STREAMINFO: - debug_printf(1, "channels %d, samplerate %d", - metadata->data.stream_info.channels, - metadata->data.stream_info.sample_rate); - /* - fsound->info.channels = metadata->data.stream_info.channels; - fsound->info.samplerate = metadata->data.stream_info.sample_rate; - */ - break; - default: - debug_printf(1, "metadata type not yet implemented"); - break; - } - - return; -} - -/* Create a local alias for an unwieldy type name */ -typedef FLAC__StreamMetadata_VorbisComment_Entry FLAC__VCEntry; - -static void -fs_flac_metadata_free (FLAC__StreamMetadata * metadata) -{ - unsigned int i, length; - FLAC__VCEntry * comments; - - if (metadata == NULL) return; - - length = metadata->data.vorbis_comment.num_comments; - comments = metadata->data.vorbis_comment.comments; - - for (i = 0; i < length; i++) { - fs_free (comments[i].entry); - } - - fs_free (comments); - fs_free (metadata); - - return; -} - -static FLAC__byte * -fs_flac_encode_vcentry (const FishSoundComment * comment) -{ - FLAC__byte * entry; - FLAC__uint32 length; - size_t name_len=0, value_len=0; - - name_len = strlen(comment->name); - length = name_len + 1; - - if (comment->value) { - value_len = strlen (comment->value); - length += value_len + 1; - } - - if ((entry = fs_malloc (length)) == NULL) - return NULL; - - /* We assume that comment->name, value are NUL terminated, as they were - * produced by our own comments.c */ - strcpy ((char *)entry, comment->name); - - if (comment->value) { - entry[name_len] = '='; - strcpy ((char *)&entry[name_len+1], comment->value); - } - - entry[length-1] = '\0'; - - return entry; -} - -static FLAC__StreamMetadata * -fs_flac_encode_vorbiscomments (FishSound * fsound) -{ - FishSoundFlacInfo * fi = fsound->codec_data; - FLAC__StreamMetadata * metadata = NULL; - const FishSoundComment * comment; - unsigned int i=0, length=0, total_length; - FLAC__VCEntry * comments; - - /* libFLAC seems to require us to know the total length of the generated - * vorbiscomment packet, even though it will silently generate the - * vendor string. Hence, this value was determined by inspection for - * the version "reference libFLAC 1.1.2" - */ - total_length = 40; - - /* Count the number of comments */ - for (comment = fish_sound_comment_first (fsound); comment; - comment = fish_sound_comment_next (fsound, comment)) { - length++; - } - - if (length == 0) return NULL; - - if ((comments = (FLAC__VCEntry *)fs_malloc (sizeof(FLAC__VCEntry) * length)) == NULL) - goto encode_vc_oom; - - for (comment = fish_sound_comment_first (fsound); comment; - comment = fish_sound_comment_next (fsound, comment)) { - if ((comments[i].entry = fs_flac_encode_vcentry (comment)) == NULL) { - } - comments[i].length = strlen((char *)comments[i].entry); - - /* In the generated vorbiscomment data, each entry is preceded by a - * 32bit length specifier. */ - total_length += 4 + comments[i].length; - i++; - } - - if ((metadata = (FLAC__StreamMetadata *) fs_malloc (sizeof (*metadata))) == NULL) - goto encode_vc_oom; - - metadata->type = FLAC__METADATA_TYPE_VORBIS_COMMENT; - metadata->is_last = true; - metadata->length = total_length; - /* Don't bother setting the vendor_string, as libFLAC ignores it */ - metadata->data.vorbis_comment.num_comments = length; - metadata->data.vorbis_comment.comments = comments; - - /* Remember the allocated metadata */ - fi->enc_vc_metadata = metadata; - - return metadata; - -encode_vc_oom: - if (metadata != NULL) - fs_free (metadata); - - /* Unwind allocated comment entries */ - for (i--; i >= 0; i--) { - if (comments[i].entry != NULL) - fs_free (comments[i].entry); - } - - if (comments != NULL) - fs_free (comments); - - return NULL; -} - -static FishSound * -fs_flac_enc_headers (FishSound * fsound) -{ - FishSoundFlacInfo * fi = fsound->codec_data; - FLAC__StreamMetadata * metadata; - - fi->fse = FLAC__stream_encoder_new(); - FLAC__stream_encoder_set_channels(fi->fse, fsound->info.channels); - FLAC__stream_encoder_set_sample_rate(fi->fse, fsound->info.samplerate); - FLAC__stream_encoder_set_bits_per_sample(fi->fse, BITS_PER_SAMPLE); - -#if defined (HAVE_FLAC_1_1_2) - FLAC__stream_encoder_set_write_callback(fi->fse, fs_flac_enc_write_callback); - FLAC__stream_encoder_set_metadata_callback(fi->fse, fs_flac_enc_meta_callback); - FLAC__stream_encoder_set_client_data(fi->fse, fsound); -#endif - - metadata = fs_flac_encode_vorbiscomments (fsound); - if (metadata != NULL) - FLAC__stream_encoder_set_metadata (fi->fse, &metadata, 1); - - /* FLAC__stream_encoder_set_total_samples_estimate(fi->fse, ...);*/ - -#if defined (HAVE_FLAC_1_1_2) - if (FLAC__stream_encoder_init(fi->fse) != FLAC__STREAM_ENCODER_OK) - return NULL; -#elif defined (HAVE_FLAC_1_1_3) - if (FLAC__stream_encoder_init_stream - (fi->fse, - fs_flac_enc_write_callback, - NULL, /* seek callback */ - NULL, /* tell callback */ - fs_flac_enc_meta_callback, - fsound - ) != FLAC__STREAM_ENCODER_OK) - return NULL; - -#endif - - return fsound; -} - -static long -fs_flac_encode_fatal (FishSoundFlacInfo *fi, long err) -{ - FLAC__stream_encoder_delete (fi->fse); - fi->fse = NULL; - return err; -} - -static long -fs_flac_encode_f (FishSound * fsound, float * pcm[], long frames) -{ - FishSoundFlacInfo *fi = fsound->codec_data; - FLAC__int32 *buffer, *ipcm; - float * p, norm = (1 << (BITS_PER_SAMPLE - 1)); - long i; - int j, channels = fsound->info.channels; - - debug_printf("IN, frames = %ld", frames); - - if ((ipcm = realloc(fi->ipcm, sizeof(FLAC__int32) * channels * frames)) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - - fi->ipcm = ipcm; - buffer = (FLAC__int32*) fi->ipcm; - for (i = 0; i < frames; i++) { - for (j = 0; j < channels; j++) { - p = pcm[j]; - buffer[i*channels + j] = (FLAC__int32) (p[i] * norm); - } - } - - if (fi->packetno == 0) - fs_flac_enc_headers (fsound); - - /* We could have used FLAC__stream_encoder_process() and a more direct - * conversion loop above, rather than converting and interleaving. */ - if (FLAC__stream_encoder_process_interleaved(fi->fse, buffer, frames) == false) { - switch (FLAC__stream_encoder_get_state (fi->fse)) { - case FLAC__STREAM_ENCODER_OK: - case FLAC__STREAM_ENCODER_UNINITIALIZED: - break; - case FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR: - return fs_flac_encode_fatal (fi, FISH_SOUND_ERR_OUT_OF_MEMORY); - default: - return fs_flac_encode_fatal (fi, FISH_SOUND_ERR_GENERIC); - } - } - - fi->packetno++; - - return frames; -} - -static long -fs_flac_encode_f_ilv (FishSound * fsound, float ** pcm, long frames) -{ - FishSoundFlacInfo *fi = fsound->codec_data; - FLAC__int32 *buffer, *ipcm; - float * p = (float*)pcm, norm = (1 << (BITS_PER_SAMPLE - 1)); - long i, length = frames * fsound->info.channels; - - debug_printf(1, "IN, frames = %ld", frames); - - if ((ipcm = realloc(fi->ipcm, sizeof(FLAC__int32)*fsound->info.channels*frames)) == NULL) - return FISH_SOUND_ERR_OUT_OF_MEMORY; - - fi->ipcm = ipcm; - buffer = (FLAC__int32*) fi->ipcm; - for (i=0; ipacketno == 0) - fs_flac_enc_headers (fsound); - - if (FLAC__stream_encoder_process_interleaved(fi->fse, buffer, frames) == false) { - switch (FLAC__stream_encoder_get_state (fi->fse)) { - case FLAC__STREAM_ENCODER_OK: - case FLAC__STREAM_ENCODER_UNINITIALIZED: - break; - case FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR: - return fs_flac_encode_fatal (fi, FISH_SOUND_ERR_OUT_OF_MEMORY); - default: - return fs_flac_encode_fatal (fi, FISH_SOUND_ERR_GENERIC); - } - } - - fi->packetno++; - - return frames; -} -#else /* ! FS_ENCODE */ - -#define fs_flac_encode_f NULL -#define fs_flac_encode_f_ilv NULL - -#endif /* ! FS_ENCODE */ - - -static FishSound * -fs_flac_delete (FishSound * fsound) -{ - FishSoundFlacInfo * fi = (FishSoundFlacInfo *)fsound->codec_data; - int i; - - debug_printf("IN"); - - if (fsound->mode == FISH_SOUND_DECODE) { - if (fi->fsd) { - FLAC__stream_decoder_finish(fi->fsd); - FLAC__stream_decoder_delete(fi->fsd); - } - } else if (fsound->mode == FISH_SOUND_ENCODE) { - if (fi->fse) { - FLAC__stream_encoder_finish(fi->fse); - FLAC__stream_encoder_delete(fi->fse); - } - if (fi->buffer) { - fs_free(fi->buffer); - fi->buffer = NULL; - } - } - - if (fi->ipcm) fs_free(fi->ipcm); - for (i = 0; i < 8; i++) { - if (fi->pcm_out[i]) fs_free (fi->pcm_out[i]); - } - -#if FS_ENCODE - if (fi->enc_vc_metadata) { - fs_flac_metadata_free (fi->enc_vc_metadata); - } -#endif - - fs_free (fi); - fsound->codec_data = NULL; - - return fsound; -} - -static int -fs_flac_update (FishSound * fsound, int interleave) -{ - return 0; -} - -static int -fs_flac_reset (FishSound * fsound) -{ - /*FishSoundFlacInfo * fi = (FishSoundFlacInfo *)fsound->codec_data;*/ -#if 0 - if (fsound->mode == FISH_SOUND_DECODE) { - FLAC__stream_decoder_reset(fi->fsd); - } else if (fsound->mode == FISH_SOUND_ENCODE) { - } -#endif - return 0; -} - -static long -fs_flac_flush (FishSound * fsound) -{ - FishSoundFlacInfo * fi = (FishSoundFlacInfo *)fsound->codec_data; - - debug_printf("IN (%s)", fsound->mode == FISH_SOUND_DECODE ? "decode" : "encode"); - - if (fsound->mode == FISH_SOUND_DECODE) { - FLAC__stream_decoder_finish(fi->fsd); - } else if (fsound->mode == FISH_SOUND_ENCODE) { - FLAC__stream_encoder_finish(fi->fse); - } - - return 0; -} - -static FishSound * -fs_flac_init (FishSound * fsound) -{ - FishSoundFlacInfo *fi; - int i; - - fi = fs_malloc (sizeof (FishSoundFlacInfo)); - if (fi == NULL) return NULL; - fi->fsd = NULL; - fi->fse = NULL; - fi->buffer = NULL; - fi->packetno = 0; - fi->header = 0; - fi->header_packets = 0; - - fi->ipcm = NULL; - for (i = 0; i < 8; i++) { - fi->pcm_out[i] = NULL; - } - -#if FS_ENCODE - fi->enc_vc_metadata = NULL; -#endif - - fsound->codec_data = fi; - - return fsound; -} - -FishSoundCodec * -fish_sound_flac_codec (void) -{ - FishSoundCodec * codec; - - codec = (FishSoundCodec *) fs_malloc (sizeof (FishSoundCodec)); - if (codec == NULL) return NULL; - - codec->format.format = FISH_SOUND_FLAC; - codec->format.name = "Flac (Xiph.Org)"; - codec->format.extension = "ogg"; - - codec->init = fs_flac_init; - codec->del = fs_flac_delete; - codec->reset = fs_flac_reset; - codec->update = fs_flac_update; - codec->command = fs_flac_command; - codec->decode = fs_flac_decode; - codec->encode_f = fs_flac_encode_f; - codec->encode_f_ilv = fs_flac_encode_f_ilv; - codec->flush = fs_flac_flush; - - return codec; -} - -#else /* !HAVE_FLAC */ - -int -fish_sound_flac_identify (unsigned char * buf, long bytes) -{ - return FISH_SOUND_UNKNOWN; -} - -FishSoundCodec * -fish_sound_flac_codec (void) -{ - return NULL; -} - -#endif diff --git a/media/libfishsound/src/libfishsound/fishsound_speex.c b/media/libfishsound/src/libfishsound/fishsound_speex.c deleted file mode 100644 index c4c024b3346..00000000000 --- a/media/libfishsound/src/libfishsound/fishsound_speex.c +++ /dev/null @@ -1,802 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#include -#include -#include - -#if HAVE_STDINT_H -#include -#endif - -#include - -#include "private.h" -#include "convert.h" - -/*#define DEBUG*/ -#include "debug.h" - -#if HAVE_SPEEX - -#if HAVE_SPEEX_1_1 -#include -#include -#include -#include - -#else /* Speex 1.0 */ - -#include -#include -#include -#include -#endif - -/* Format for the vendor string: "Encoded with Speex VERSION", where VERSION - * is the libspeex version as read from a newly-generated Speex header. - */ -#define VENDOR_FORMAT "Encoded with Speex %s" - -#define DEFAULT_ENH_ENABLED 1 - -#define MAX_FRAME_BYTES 2000 - -typedef struct _FishSoundSpeexEnc { - int frame_offset; /* number of speex frames done in this packet */ - int pcm_offset; - char cbits[MAX_FRAME_BYTES]; - int id; -} FishSoundSpeexEnc; - -typedef struct _FishSoundSpeexInfo { - int packetno; - void * st; - SpeexBits bits; - int frame_size; - int nframes; - int extra_headers; - SpeexStereoState stereo; - int pcm_len; /* nr frames in pcm */ - float * ipcm; /* interleaved pcm */ - float * pcm[2]; /* Speex does max 2 channels */ - FishSoundSpeexEnc * enc; -} FishSoundSpeexInfo; - -int -fish_sound_speex_identify (unsigned char * buf, long bytes) -{ - SpeexHeader * header; - - if (bytes < 8) return FISH_SOUND_UNKNOWN; - - if (!strncmp ((char *)buf, "Speex ", 8)) { - /* if only a short buffer was passed, do a weak identify */ - if (bytes == 8) return FISH_SOUND_SPEEX; - - /* otherwise, assume the buffer is an entire initial header and - * feed it to speex_packet_to_header() */ - if ((header = speex_packet_to_header ((char *)buf, (int)bytes)) != NULL) { - fs_free(header); - return FISH_SOUND_SPEEX; - } - } - - return FISH_SOUND_UNKNOWN; -} - -static int -fs_speex_command (FishSound * fsound, int command, void * data, int datasize) -{ - return 0; -} - -#if FS_DECODE -static void * -process_header(unsigned char * buf, long bytes, int enh_enabled, - int * frame_size, int * rate, - int * nframes, int forceMode, int * channels, - SpeexStereoState * stereo, int * extra_headers) -{ - void *st; - SpeexMode *mode; - SpeexHeader *header; - int modeID; - SpeexCallback callback; - - header = speex_packet_to_header((char*)buf, (int)bytes); - if (!header) { - /* cannot read header */ - return NULL; - } - - if (header->mode >= SPEEX_NB_MODES || header->mode < 0) { - /* Mode number does not (any longer) exist in this version */ - return NULL; - } - - modeID = header->mode; - if (forceMode!=-1) - modeID = forceMode; - -#if HAVE_SPEEX_LIB_GET_MODE - mode = (SpeexMode *) speex_lib_get_mode (modeID); -#else - /* speex_mode_list[] is declared const in speex 1.1.x, hence the cast */ - mode = (SpeexMode *)speex_mode_list[modeID]; -#endif - - if (header->speex_version_id > 1) { - /* Unknown bitstream version */ - return NULL; - } - - if (mode->bitstream_version < header->mode_bitstream_version) { - /* The file was encoded with a newer version of Speex, - * need to upgrade in order to play it */ - return NULL; - } - - if (mode->bitstream_version > header->mode_bitstream_version) { - /* The file was encoded with an older version of Speex. - * You would need to downgrade the version in order to play it */ - return NULL; - } - - st = speex_decoder_init(mode); - if (!st) { - /* Decoder initialization failed */ - return NULL; - } - - speex_decoder_ctl(st, SPEEX_SET_ENH, &enh_enabled); - speex_decoder_ctl(st, SPEEX_GET_FRAME_SIZE, frame_size); - - if (!(*channels==1)) - { - callback.callback_id = SPEEX_INBAND_STEREO; - callback.func = speex_std_stereo_request_handler; - callback.data = stereo; - speex_decoder_ctl(st, SPEEX_SET_HANDLER, &callback); - } - if (!*rate) - *rate = header->rate; - /* Adjust rate if --force-* options are used */ - if (forceMode!=-1) - { - if (header->mode < forceMode) - *rate <<= (forceMode - header->mode); - if (header->mode > forceMode) - *rate >>= (header->mode - forceMode); - } - - speex_decoder_ctl(st, SPEEX_SET_SAMPLING_RATE, rate); - - *nframes = header->frames_per_packet; - - if (*channels == -1) - *channels = header->nb_channels; - - debug_printf (1, "Decoding %d Hz audio using %s mode", - *rate, mode->modeName); - -#ifdef DEBUG - if (*channels==1) - fprintf (stderr, " (mono"); - else - fprintf (stderr, " (stereo"); - - if (header->vbr) - fprintf (stderr, " (VBR)\n"); - else - fprintf(stderr, "\n"); -#endif - - *extra_headers = header->extra_headers; - - fs_free(header); - - return st; -} - -static int -fs_speex_free_buffers (FishSound * fsound) -{ - FishSoundSpeexInfo * fss = (FishSoundSpeexInfo *)fsound->codec_data; - - if (fsound->mode == FISH_SOUND_DECODE) { - if (fss->ipcm && fss->ipcm != fss->pcm[0]) fs_free (fss->ipcm); - if (fss->pcm[0]) fs_free (fss->pcm[0]); - if (fss->pcm[1]) fs_free (fss->pcm[1]); - } else { - if (fss->ipcm) fs_free (fss->ipcm); - } - - return 0; -} - -static inline int -fs_speex_float_dispatch (FishSound * fsound) -{ - FishSoundSpeexInfo * fss = (FishSoundSpeexInfo *)fsound->codec_data; - FishSoundDecoded_FloatIlv df; - FishSoundDecoded_Float dfi; - int retval; - - if (fsound->interleave) { - dfi = (FishSoundDecoded_FloatIlv)fsound->callback.decoded_float_ilv; - retval = dfi (fsound, (float **)fss->ipcm, fss->frame_size, - fsound->user_data); - } else { - df = (FishSoundDecoded_Float)fsound->callback.decoded_float; - retval = df (fsound, fss->pcm, fss->frame_size, fsound->user_data); - } - - return retval; -} - -static long -fs_speex_decode (FishSound * fsound, unsigned char * buf, long bytes) -{ - FishSoundSpeexInfo * fss = (FishSoundSpeexInfo *)fsound->codec_data; - int enh_enabled = DEFAULT_ENH_ENABLED; - int rate = 0; - int channels = -1; - int forceMode = -1; - int i, j; - - if (fss->packetno == 0) { - fss->st = process_header (buf, bytes, enh_enabled, - &fss->frame_size, &rate, - &fss->nframes, forceMode, &channels, - &fss->stereo, - &fss->extra_headers); - - if (fss->st == NULL) { - /* TODO: Return more specific error identifiers for invalid header fields */ - return FISH_SOUND_ERR_GENERIC; - } - - debug_printf (1, "speex: got %d channels, %d Hz", channels, rate); - - fsound->info.samplerate = rate; - fsound->info.channels = channels; - - /* Sanity check the channels value, as we will use it to determine buffer - sizes below. - */ - if (channels < 1 || channels > 2) - return FISH_SOUND_ERR_GENERIC; - -#if HAVE_UINTPTR_T - /* Sanity check: frame_size is not so large that the buffer size calculations - * would wrap. In reality, frame_size is set by libspeex according to the - * mode index specified in the file header, and is usually equal to 320. - */ - if (fss->frame_size > UINTPTR_MAX / (sizeof(float) * channels)) - return FISH_SOUND_ERR_GENERIC; -#endif - - fss->ipcm = fs_malloc (sizeof (float) * fss->frame_size * channels); - if (fss->ipcm == NULL) { - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - - if (channels == 1) { - fss->pcm[0] = fss->ipcm; - } else if (channels == 2) { - fss->pcm[0] = fs_malloc (sizeof (float) * fss->frame_size); - if (fss->pcm[0] == NULL) { - fs_free (fss->ipcm); - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - fss->pcm[1] = fs_malloc (sizeof (float) * fss->frame_size); - if (fss->pcm[1] == NULL) { - fs_free (fss->pcm[0]); - fs_free (fss->ipcm); - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - } - - if (fss->nframes == 0) fss->nframes = 1; - - } else if (fss->packetno == 1) { - /* Comments */ - if (fish_sound_comments_decode (fsound, buf, bytes) == FISH_SOUND_ERR_OUT_OF_MEMORY) { - fss->packetno++; - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - } else if (fss->packetno <= 1+fss->extra_headers) { - /* Unknown extra headers */ - } else { - speex_bits_read_from (&fss->bits, (char *)buf, (int)bytes); - - for (i = 0; i < fss->nframes; i++) { - /* Decode frame */ - speex_decode (fss->st, &fss->bits, fss->ipcm); - - if (fsound->info.channels == 2) { - speex_decode_stereo (fss->ipcm, fss->frame_size, &fss->stereo); - if (fsound->interleave) { - for (j = 0; j < fss->frame_size * fsound->info.channels; j++) { - fss->ipcm[j] /= 32767.0; - } - } else { - _fs_deinterleave ((float **)fss->ipcm, fss->pcm, - fss->frame_size, 2, (float)(1/32767.0)); - } - } else { - for (j = 0; j < fss->frame_size; j++) { - fss->ipcm[j] /= 32767.0; - } - } - - fsound->frameno += fss->frame_size; - - fs_speex_float_dispatch (fsound); - } - } - - fss->packetno++; - - return 0; -} -#else /* !FS_DECODE */ - -#define fs_speex_decode NULL - -#endif - - -#if FS_ENCODE -static FishSound * -fs_speex_enc_headers (FishSound * fsound) -{ - FishSoundSpeexInfo * fss = (FishSoundSpeexInfo *)fsound->codec_data; - int modeID; - SpeexMode * mode = NULL; - SpeexHeader header; - unsigned char * header_buf = NULL, * comments_buf = NULL; - int header_bytes, comments_bytes; - size_t buflen; - - modeID = 1; - -#if HAVE_SPEEX_LIB_GET_MODE - mode = (SpeexMode *) speex_lib_get_mode (modeID); -#else - /* speex_mode_list[] is declared const in speex 1.1.x, hence the cast */ - mode = (SpeexMode *)speex_mode_list[modeID]; -#endif - - speex_init_header (&header, fsound->info.samplerate, 1, mode); - header.frames_per_packet = fss->nframes; /* XXX: frames per packet */ - header.vbr = 1; /* XXX: VBR */ - header.nb_channels = fsound->info.channels; - - fss->st = speex_encoder_init (mode); - - if (fsound->callback.encoded) { - char vendor_string[128]; - - /* Allocate and create header */ - header_buf = (unsigned char *) speex_header_to_packet (&header, &header_bytes); - if (header_buf == NULL) { - return NULL; - } - - /* Allocate and create comments */ - snprintf (vendor_string, 128, VENDOR_FORMAT, header.speex_version); - if (fish_sound_comment_set_vendor (fsound, vendor_string) == FISH_SOUND_ERR_OUT_OF_MEMORY) { - fs_free (header_buf); - return NULL; - } - comments_bytes = fish_sound_comments_encode (fsound, NULL, 0); - comments_buf = fs_malloc (comments_bytes); - if (comments_buf == NULL) { - fs_free (header_buf); - return NULL; - } - } - - speex_encoder_ctl (fss->st, SPEEX_SET_SAMPLING_RATE, - &fsound->info.samplerate); - - speex_encoder_ctl (fss->st, SPEEX_GET_FRAME_SIZE, &fss->frame_size); - - debug_printf (1, "got frame size %d", fss->frame_size); - - /* XXX: set VBR etc. */ - - buflen = fss->frame_size * fsound->info.channels * sizeof (float); - fss->ipcm = fs_malloc (buflen); - if (fss->ipcm == NULL) { - if (comments_buf) fs_free (comments_buf); - if (header_buf) fs_free (header_buf); - return NULL; - } - memset (fss->ipcm, 0, buflen); - - /* Allocations succeeded, actually call encoded callback for headers */ - if (fsound->callback.encoded) { - FishSoundEncoded encoded = (FishSoundEncoded)fsound->callback.encoded; - - /* header */ - encoded (fsound, header_buf, (long)header_bytes, fsound->user_data); - fss->packetno++; - fs_free (header_buf); - - /* comments */ - comments_bytes = fish_sound_comments_encode (fsound, comments_buf, comments_bytes); - encoded (fsound, comments_buf, (long)comments_bytes, fsound->user_data); - fss->packetno++; - fs_free (comments_buf); - } - - return fsound; -} - -static long -fs_speex_encode_write (FishSound * fsound) -{ - FishSoundSpeexInfo * fss = (FishSoundSpeexInfo *)fsound->codec_data; - FishSoundSpeexEnc * fse = (FishSoundSpeexEnc *)fss->enc; - int bytes; - - speex_bits_insert_terminator (&fss->bits); - bytes = speex_bits_write (&fss->bits, fse->cbits, MAX_FRAME_BYTES); - speex_bits_reset (&fss->bits); - - if (fsound->callback.encoded) { - FishSoundEncoded encoded = (FishSoundEncoded)fsound->callback.encoded; - - encoded (fsound, (unsigned char *)fse->cbits, (long)bytes, - fsound->user_data); - } - - return bytes; -} - -static long -fs_speex_encode_block (FishSound * fsound) -{ - FishSoundSpeexInfo * fss = (FishSoundSpeexInfo *)fsound->codec_data; - FishSoundSpeexEnc * fse = (FishSoundSpeexEnc *)fss->enc; - long nencoded = fse->pcm_offset; - - if (fsound->info.channels == 2) - speex_encode_stereo (fss->ipcm, fse->pcm_offset, &fss->bits); - - speex_encode (fss->st, fss->ipcm, &fss->bits); - - fsound->frameno += fse->pcm_offset; - fse->frame_offset++; - - if (fse->frame_offset == fss->nframes) { - fs_speex_encode_write (fsound); - fse->frame_offset = 0; - } - - fse->pcm_offset = 0; - - return nencoded; -} - -static long -fs_speex_encode_f_ilv (FishSound * fsound, float ** pcm, long frames) -{ - FishSoundSpeexInfo * fss = (FishSoundSpeexInfo *)fsound->codec_data; - FishSoundSpeexEnc * fse = (FishSoundSpeexEnc *)fss->enc; - long remaining = frames, len, nencoded = 0; - int j, start, end; - int channels = fsound->info.channels; - float * p = (float *)pcm; - - if (fss->packetno == 0) - fs_speex_enc_headers (fsound); - - while (remaining > 0) { - len = MIN (remaining, fss->frame_size - fse->pcm_offset); - - start = fse->pcm_offset * channels; - end = (len + fse->pcm_offset) * channels; - for (j = start; j < end; j++) { - fss->ipcm[j] = *p++ * (float)32767.0; - } - - fse->pcm_offset += len; - - if (fse->pcm_offset == fss->frame_size) { - nencoded += fs_speex_encode_block (fsound); - } - - remaining -= len; - } - - return frames - remaining; -} - -static long -fs_speex_encode_f (FishSound * fsound, float * pcm[], long frames) -{ - FishSoundSpeexInfo * fss = (FishSoundSpeexInfo *)fsound->codec_data; - FishSoundSpeexEnc * fse = (FishSoundSpeexEnc *)fss->enc; - long remaining = frames, len, n = 0, nencoded = 0; - int j, start; - - if (fss->packetno == 0) - fs_speex_enc_headers (fsound); - - while (remaining > 0) { - len = MIN (remaining, fss->frame_size - fse->pcm_offset); - - start = fse->pcm_offset; - fss->pcm[0] = &pcm[0][n]; - - if (fsound->info.channels == 2) { - fss->pcm[1] = &pcm[1][n]; - _fs_interleave (fss->pcm, (float **)&fss->ipcm[start*2], - len, 2, 32767.0); - } else { - for (j = 0; j < len; j++) { - fss->ipcm[start + j] = fss->pcm[0][j] * (float)32767.0; - } - } - - fse->pcm_offset += len; - - if (fse->pcm_offset == fss->frame_size) { - nencoded += fs_speex_encode_block (fsound); - } - - remaining -= len; - n += len; - } - - return frames - remaining; -} - -static long -fs_speex_flush (FishSound * fsound) -{ - FishSoundSpeexInfo * fss = (FishSoundSpeexInfo *)fsound->codec_data; - FishSoundSpeexEnc * fse = (FishSoundSpeexEnc *)fss->enc; - long nencoded = 0; - - if (fsound->mode != FISH_SOUND_ENCODE) - return 0; - - if (fse->pcm_offset > 0) { - nencoded += fs_speex_encode_block (fsound); - } - - /* If, at this point, fse->frame_offset == 0, then either: - - all remaining encoded data has just been flushed out via - fs_speex_encode_block(), OR - - there was no data remaining to flush at the beginning of this - function (fse->pcm_offset == 0 && fse->frame_offset == 0) - */ - if (fse->frame_offset == 0) return 0; - - while (fse->frame_offset < fss->nframes) { - speex_bits_pack (&fss->bits, 15, 5); - fse->frame_offset++; - } - - nencoded += fs_speex_encode_write (fsound); - fse->frame_offset = 0; - - return nencoded; -} - -#else /* !FS_ENCODE */ - -#define fs_speex_encode_f NULL -#define fs_speex_encode_f_ilv NULL -#define fs_speex_flush NULL - -#endif - -static int -fs_speex_reset (FishSound * fsound) -{ - /*FishSoundSpeexInfo * fss = (FishSoundSpeexInfo *)fsound->codec_data;*/ - - return 0; -} - -static int -fs_speex_update (FishSound * fsound, int interleave) -{ - FishSoundSpeexInfo * fss = (FishSoundSpeexInfo *)fsound->codec_data; - size_t pcm_size = sizeof (float); - float *ipcm_new, *pcm0, *pcm1; - - ipcm_new = (float *)fs_realloc (fss->ipcm, - pcm_size * fss->frame_size * fsound->info.channels); - if (ipcm_new == NULL) return FISH_SOUND_ERR_OUT_OF_MEMORY; - - fss->ipcm = ipcm_new; - - if (interleave) { - /* if transitioning from non-interleave to interleave, - free non-ilv buffers */ - if (!fsound->interleave && fsound->info.channels == 2) { - if (fss->pcm[0]) fs_free (fss->pcm[0]); - if (fss->pcm[1]) fs_free (fss->pcm[1]); - fss->pcm[0] = NULL; - fss->pcm[1] = NULL; - } - } else { - if (fsound->info.channels == 1) { - fss->pcm[0] = (float *) fss->ipcm; - } else if (fsound->info.channels == 2) { -#if HAVE_UINTPTR_T - /* Sanity check: frame_size is not so large that the buffer size calculations - * would wrap. In reality, frame_size is set by libspeex according to the - * mode index specified in the file header, and is usually equal to 320. - */ - if (fss->frame_size > UINTPTR_MAX / pcm_size) - return FISH_SOUND_ERR_GENERIC; -#endif - - pcm0 = fs_realloc (fss->pcm[0], pcm_size * fss->frame_size); - if (pcm0 == NULL) { - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - - pcm1 = fs_realloc (fss->pcm[1], pcm_size * fss->frame_size); - if (pcm1 == NULL) { - fs_free (pcm0); - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - - fss->pcm[0] = pcm0; - fss->pcm[1] = pcm1; - } - } - - return 0; -} - -static FishSound * -fs_speex_enc_init (FishSound * fsound) -{ - FishSoundSpeexInfo * fss = (FishSoundSpeexInfo *)fsound->codec_data; - FishSoundSpeexEnc * fse; - - fse = fs_malloc (sizeof (FishSoundSpeexEnc)); - if (fse == NULL) return NULL; - - fse->frame_offset = 0; - fse->pcm_offset = 0; - fse->id = 0; - - fss->enc = fse; - - return fsound; -} - -static FishSound * -fs_speex_init (FishSound * fsound) -{ - FishSoundSpeexInfo * fss; - SpeexStereoState stereo_init = SPEEX_STEREO_STATE_INIT; - - fss = fs_malloc (sizeof (FishSoundSpeexInfo)); - if (fss == NULL) return NULL; - - fss->packetno = 0; - fss->st = NULL; - fss->frame_size = 0; - fss->nframes = 1; - fss->pcm_len = 0; - fss->ipcm = NULL; - fss->pcm[0] = NULL; - fss->pcm[1] = NULL; - - memcpy (&fss->stereo, &stereo_init, sizeof (SpeexStereoState)); - - speex_bits_init (&fss->bits); - - fsound->codec_data = fss; - - if (fsound->mode == FISH_SOUND_ENCODE) - fs_speex_enc_init (fsound); - - return fsound; -} - -static FishSound * -fs_speex_delete (FishSound * fsound) -{ - FishSoundSpeexInfo * fss = (FishSoundSpeexInfo *)fsound->codec_data; - - fs_speex_free_buffers (fsound); - - if (fsound->mode == FISH_SOUND_DECODE) { - if (fss->st) speex_decoder_destroy (fss->st); - } else if (fsound->mode == FISH_SOUND_ENCODE) { - if (fss->st) speex_encoder_destroy (fss->st); - if (fss->enc) fs_free (fss->enc); - } - speex_bits_destroy (&fss->bits); - - fs_free (fss); - fsound->codec_data = NULL; - - return fsound; -} - -FishSoundCodec * -fish_sound_speex_codec (void) -{ - FishSoundCodec * codec; - - codec = (FishSoundCodec *) fs_malloc (sizeof (FishSoundCodec)); - if (codec == NULL) return NULL; - - codec->format.format = FISH_SOUND_SPEEX; - codec->format.name = "Speex (Xiph.Org)"; - codec->format.extension = "spx"; - - codec->init = fs_speex_init; - codec->del = fs_speex_delete; - codec->reset = fs_speex_reset; - codec->update = fs_speex_update; - codec->command = fs_speex_command; - codec->decode = fs_speex_decode; - codec->encode_f = fs_speex_encode_f; - codec->encode_f_ilv = fs_speex_encode_f_ilv; - codec->flush = fs_speex_flush; - - return codec; -} - -#else /* !HAVE_SPEEX */ - -int -fish_sound_speex_identify (unsigned char * buf, long bytes) -{ - return FISH_SOUND_UNKNOWN; -} - -FishSoundCodec * -fish_sound_speex_codec (void) -{ - return NULL; -} - -#endif - diff --git a/media/libfishsound/src/libfishsound/fishsound_vorbis.c b/media/libfishsound/src/libfishsound/fishsound_vorbis.c deleted file mode 100644 index a5b607bd14a..00000000000 --- a/media/libfishsound/src/libfishsound/fishsound_vorbis.c +++ /dev/null @@ -1,511 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#include -#include -#include - -#include - -#include "private.h" -#include "convert.h" - -/*#define DEBUG*/ -#include "debug.h" - -#if HAVE_VORBIS - -#include -#if HAVE_VORBISENC -#include -#endif - -typedef struct _FishSoundVorbisInfo { - int packetno; - int finished; - vorbis_info vi; - vorbis_comment vc; - vorbis_dsp_state vd; /** central working state for the PCM->packet encoder */ - vorbis_block vb; /** local working space for PCM->packet encode */ - float ** pcm; /** ongoing pcm working space for decoder (stateful) */ - float * ipcm; /** interleaved pcm for interfacing with user */ - long max_pcm; -} FishSoundVorbisInfo; - -int -fish_sound_vorbis_identify (unsigned char * buf, long bytes) -{ - struct vorbis_info vi; - struct vorbis_comment vc; - ogg_packet op; - int ret, id = FISH_SOUND_UNKNOWN; - - if (!strncmp ((char *)&buf[1], "vorbis", 6)) { - /* if only a short buffer was passed, do a weak identify */ - if (bytes == 8) return FISH_SOUND_VORBIS; - - /* otherwise, assume the buffer is an entire initial header and - * feed it to vorbis_synthesis_headerin() */ - - vorbis_info_init (&vi); - vorbis_comment_init (&vc); - - op.packet = buf; - op.bytes = bytes; - op.b_o_s = 1; - op.e_o_s = 0; - op.granulepos = 0; - op.packetno = 0; - - if ((ret = vorbis_synthesis_headerin (&vi, &vc, &op)) == 0) { - if (vi.rate != 0) id = FISH_SOUND_VORBIS; - } else { - debug_printf (1, "vorbis_synthesis_headerin returned %d", ret); - } - - vorbis_info_clear (&vi); - } - - return id; -} - -static int -fs_vorbis_command (FishSound * fsound, int command, void * data, - int datasize) -{ - return 0; -} - -#if FS_DECODE -static long -fs_vorbis_decode (FishSound * fsound, unsigned char * buf, long bytes) -{ - FishSoundVorbisInfo * fsv = (FishSoundVorbisInfo *)fsound->codec_data; - ogg_packet op; - long samples; - float * pcm_new; - int ret; - - /* Make an ogg_packet structure to pass the data to libvorbis */ - op.packet = buf; - op.bytes = bytes; - op.b_o_s = (fsv->packetno == 0) ? 1 : 0; - op.e_o_s = fsound->next_eos; - op.granulepos = fsound->next_granulepos; - op.packetno = fsv->packetno; - - if (fsv->packetno < 3) { - - if ((ret = vorbis_synthesis_headerin (&fsv->vi, &fsv->vc, &op)) == 0) { - if (fsv->vi.rate != 0) { - debug_printf (1, "Got vorbis info: version %d\tchannels %d\trate %ld", - fsv->vi.version, fsv->vi.channels, fsv->vi.rate); - fsound->info.samplerate = fsv->vi.rate; - fsound->info.channels = fsv->vi.channels; - } - } - - /* Decode comments from packet 1. Vorbis has 7 bytes of marker at the - * start of vorbiscomment packet. */ - if (fsv->packetno == 1 && bytes > 7 && buf[0] == 0x03 && - !strncmp ((char *)&buf[1], "vorbis", 6)) { - if (fish_sound_comments_decode (fsound, buf+7, bytes-7) == FISH_SOUND_ERR_OUT_OF_MEMORY) { - fsv->packetno++; - return FISH_SOUND_ERR_OUT_OF_MEMORY; - } - } else if (fsv->packetno == 2) { - vorbis_synthesis_init (&fsv->vd, &fsv->vi); - vorbis_block_init (&fsv->vd, &fsv->vb); - } - } else { - FishSoundDecoded_FloatIlv df; - FishSoundDecoded_Float dfi; - int r; - if ((r = vorbis_synthesis (&fsv->vb, &op)) == 0) - vorbis_synthesis_blockin (&fsv->vd, &fsv->vb); - - if (r == OV_EBADPACKET) { - return FISH_SOUND_ERR_GENERIC; - } - - while ((samples = vorbis_synthesis_pcmout (&fsv->vd, &fsv->pcm)) > 0) { - vorbis_synthesis_read (&fsv->vd, samples); - - if (fsound->frameno != -1) - fsound->frameno += samples; - - if (fsound->interleave) { - if (samples > fsv->max_pcm) { - pcm_new = realloc (fsv->ipcm, sizeof(float) * samples * - fsound->info.channels); - if (pcm_new == NULL) { - /* Allocation failure; just truncate here, fail gracefully elsewhere */ - samples = fsv->max_pcm; - } else { - fsv->ipcm = pcm_new; - fsv->max_pcm = samples; - } - } - _fs_interleave (fsv->pcm, (float **)fsv->ipcm, samples, - fsound->info.channels, 1.0); - - dfi = (FishSoundDecoded_FloatIlv)fsound->callback.decoded_float_ilv; - dfi (fsound, (float **)fsv->ipcm, samples, fsound->user_data); - } else { - df = (FishSoundDecoded_Float)fsound->callback.decoded_float; - df (fsound, fsv->pcm, samples, fsound->user_data); - } - } - } - - if (fsound->next_granulepos != -1) { - fsound->frameno = fsound->next_granulepos; - fsound->next_granulepos = -1; - } - - fsv->packetno++; - - return 0; -} -#else /* !FS_DECODE */ - -#define fs_vorbis_decode NULL - -#endif - -#if FS_ENCODE && HAVE_VORBISENC - -static FishSound * -fs_vorbis_enc_headers (FishSound * fsound) -{ - FishSoundVorbisInfo * fsv = (FishSoundVorbisInfo *)fsound->codec_data; - const FishSoundComment * comment; - ogg_packet header; - ogg_packet header_comm; - ogg_packet header_code; - - /* Vorbis streams begin with three headers: - * 1. The initial header (with most of the codec setup parameters), - * which is mandated by the Ogg bitstream spec, - * 2. The second header which holds any comment fields, - * 3. The third header which contains the bitstream codebook. - * We merely need to make the headers, then pass them to libvorbis one at - * a time; libvorbis handles the additional Ogg bitstream constraints. - */ - - /* Update the comments */ - for (comment = fish_sound_comment_first (fsound); comment; - comment = fish_sound_comment_next (fsound, comment)) { - debug_printf (1, "%s = %s", comment->name, comment->value); - vorbis_comment_add_tag (&fsv->vc, comment->name, comment->value); - } - - /* Generate the headers */ - vorbis_analysis_headerout(&fsv->vd, &fsv->vc, - &header, &header_comm, &header_code); - - /* Pass the generated headers to the user */ - if (fsound->callback.encoded) { - FishSoundEncoded encoded = (FishSoundEncoded)fsound->callback.encoded; - - encoded (fsound, header.packet, header.bytes, fsound->user_data); - encoded (fsound, header_comm.packet, header_comm.bytes, - fsound->user_data); - encoded (fsound, header_code.packet, header_code.bytes, - fsound->user_data); - fsv->packetno = 3; - } - - return fsound; -} - -static long -fs_vorbis_encode_write (FishSound * fsound, long len) -{ - FishSoundVorbisInfo * fsv = (FishSoundVorbisInfo *)fsound->codec_data; - ogg_packet op; - - vorbis_analysis_wrote (&fsv->vd, len); - - while (vorbis_analysis_blockout (&fsv->vd, &fsv->vb) == 1) { - vorbis_analysis (&fsv->vb, NULL); - vorbis_bitrate_addblock (&fsv->vb); - - while (vorbis_bitrate_flushpacket (&fsv->vd, &op)) { - if (fsound->callback.encoded) { - FishSoundEncoded encoded = (FishSoundEncoded)fsound->callback.encoded; - - if (op.granulepos != -1) - fsound->frameno = op.granulepos; - - encoded (fsound, op.packet, op.bytes, fsound->user_data); - - fsv->packetno++; - } - } - } - - return len; -} - -static int -fs_vorbis_finish (FishSound * fsound) -{ - FishSoundVorbisInfo * fsv = (FishSoundVorbisInfo *)fsound->codec_data; - - if (!fsv->finished) { - if (fsound->mode == FISH_SOUND_ENCODE) { - fs_vorbis_encode_write (fsound, 0); - } - fsv->finished = 1; - } - - return 0; -} - -static long -fs_vorbis_encode_f_ilv (FishSound * fsound, float ** pcm, long frames) -{ - FishSoundVorbisInfo * fsv = (FishSoundVorbisInfo *)fsound->codec_data; - float ** vpcm; - long len, remaining = frames; - float * d = (float *)pcm; - - if (fsv->packetno == 0) { - fs_vorbis_enc_headers (fsound); - } - - if (frames == 0) { - fs_vorbis_finish (fsound); - return 0; - } - - while (remaining > 0) { - len = MIN (1024, remaining); - - /* expose the buffer to submit data */ - vpcm = vorbis_analysis_buffer (&fsv->vd, 1024); - - _fs_deinterleave ((float **)d, vpcm, len, fsound->info.channels, 1.0); - - d += (len * fsound->info.channels); - - fs_vorbis_encode_write (fsound, len); - - remaining -= len; - } - - /** - * End of input. Tell libvorbis we're at the end of stream so that it can - * handle the last frame and mark the end of stream in the output properly. - */ - if (fsound->next_eos) - fs_vorbis_finish (fsound); - - return 0; -} - -static long -fs_vorbis_encode_f (FishSound * fsound, float * pcm[], long frames) -{ - FishSoundVorbisInfo * fsv = (FishSoundVorbisInfo *)fsound->codec_data; - float ** vpcm; - long len, remaining = frames; - int i; - - if (fsv->packetno == 0) { - fs_vorbis_enc_headers (fsound); - } - - if (frames == 0) { - fs_vorbis_finish (fsound); - return 0; - } - - while (remaining > 0) { - len = MIN (1024, remaining); - - debug_printf (1, "processing %ld frames", len); - - /* expose the buffer to submit data */ - vpcm = vorbis_analysis_buffer (&fsv->vd, 1024); - - for (i = 0; i < fsound->info.channels; i++) { - memcpy (vpcm[i], pcm[i], sizeof (float) * len); - } - - fs_vorbis_encode_write (fsound, len); - - remaining -= len; - } - - /** - * End of input. Tell libvorbis we're at the end of stream so that it can - * handle the last frame and mark the end of stream in the output properly. - */ - if (fsound->next_eos) - fs_vorbis_finish (fsound); - - return 0; -} - -static FishSound * -fs_vorbis_enc_init (FishSound * fsound) -{ - FishSoundVorbisInfo * fsv = (FishSoundVorbisInfo *)fsound->codec_data; - - debug_printf (1, "Vorbis enc init: %d channels, %d Hz", fsound->info.channels, - fsound->info.samplerate); - - vorbis_encode_init_vbr (&fsv->vi, fsound->info.channels, - fsound->info.samplerate, (float)0.3 /* quality */); - - /* set up the analysis state and auxiliary encoding storage */ - vorbis_analysis_init (&fsv->vd, &fsv->vi); - vorbis_block_init (&fsv->vd, &fsv->vb); - - return fsound; -} - -#else /* ! FS_ENCODE && HAVE_VORBISENC */ - -#define fs_vorbis_encode_f NULL -#define fs_vorbis_encode_f_ilv NULL -#define fs_vorbis_finish NULL - -#endif /* ! FS_ENCODE && HAVE_VORBISENC */ - -static int -fs_vorbis_reset (FishSound * fsound) -{ - FishSoundVorbisInfo * fsv = (FishSoundVorbisInfo *)fsound->codec_data; - - vorbis_block_init (&fsv->vd, &fsv->vb); - fsv->packetno = 0; - return 0; -} - -static FishSound * -fs_vorbis_init (FishSound * fsound) -{ - FishSoundVorbisInfo * fsv; - - fsv = fs_malloc (sizeof (FishSoundVorbisInfo)); - if (fsv == NULL) return NULL; - - fsv->packetno = 0; - fsv->finished = 0; - vorbis_info_init (&fsv->vi); - vorbis_comment_init (&fsv->vc); - memset(&fsv->vd, 0, sizeof(fsv->vd)); - vorbis_block_init (&fsv->vd, &fsv->vb); - fsv->pcm = NULL; - fsv->ipcm = NULL; - fsv->max_pcm = 0; - - fsound->codec_data = fsv; - -#if FS_ENCODE && HAVE_VORBISENC - - if (fsound->mode == FISH_SOUND_ENCODE) { - fs_vorbis_enc_init (fsound); - } - -#endif /* FS_ENCODE && HAVE_VORBISENC */ - - return fsound; -} - -static FishSound * -fs_vorbis_delete (FishSound * fsound) -{ - FishSoundVorbisInfo * fsv = (FishSoundVorbisInfo *)fsound->codec_data; - -#if FS_ENCODE && HAVE_VORBISENC - fs_vorbis_finish (fsound); -#endif /* FS_ENCODE && HAVE_VORBISENC */ - - if (fsv->ipcm) fs_free (fsv->ipcm); - - vorbis_block_clear (&fsv->vb); - vorbis_dsp_clear (&fsv->vd); - vorbis_comment_clear (&fsv->vc); - vorbis_info_clear (&fsv->vi); - - fs_free (fsv); - fsound->codec_data = NULL; - - return fsound; -} - -FishSoundCodec * -fish_sound_vorbis_codec (void) -{ - FishSoundCodec * codec; - - codec = (FishSoundCodec *) fs_malloc (sizeof (FishSoundCodec)); - if (codec == NULL) return NULL; - - codec->format.format = FISH_SOUND_VORBIS; - codec->format.name = "Vorbis (Xiph.Org)"; - codec->format.extension = "ogg"; - - codec->init = fs_vorbis_init; - codec->del = fs_vorbis_delete; - codec->reset = fs_vorbis_reset; - codec->update = NULL; /* XXX */ - codec->command = fs_vorbis_command; - codec->decode = fs_vorbis_decode; - codec->encode_f = fs_vorbis_encode_f; - codec->encode_f_ilv = fs_vorbis_encode_f_ilv; - codec->flush = NULL; - - return codec; -} - -#else /* !HAVE_VORBIS */ - -int -fish_sound_vorbis_identify (unsigned char * buf, long bytes) -{ - return FISH_SOUND_UNKNOWN; -} - -FishSoundCodec * -fish_sound_vorbis_codec (void) -{ - return NULL; -} - -#endif diff --git a/media/libfishsound/src/libfishsound/fs_compat.h b/media/libfishsound/src/libfishsound/fs_compat.h deleted file mode 100644 index 1f9ebe32dfd..00000000000 --- a/media/libfishsound/src/libfishsound/fs_compat.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -/* WINDOWS */ -#ifdef _WIN32 -#define inline __inline -#define alloca _alloca -#define strncasecmp _strnicmp -#define snprintf _snprintf -#ifndef __SYMBIAN32__ -#define strcasecmp _stricmp -#endif /* ! __SYMBIAN32__ */ -#endif - -/* malloc/realloc/free macros */ -#ifndef fs_malloc -#define fs_malloc malloc -#endif - -#ifndef fs_realloc -#define fs_realloc realloc -#endif - -#ifndef fs_free -#define fs_free free -#endif diff --git a/media/libfishsound/src/libfishsound/fs_vector.c b/media/libfishsound/src/libfishsound/fs_vector.c deleted file mode 100644 index dbee9c61c1a..00000000000 --- a/media/libfishsound/src/libfishsound/fs_vector.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include - -#include "fs_compat.h" - -typedef int (*FishSoundFunc) (void * data); -typedef int (*FishSoundCmpFunc) (const void * data1, const void * data2); - -typedef struct _FishSoundVector FishSoundVector; - -struct _FishSoundVector { - int max_elements; - int nr_elements; - FishSoundCmpFunc cmp; - void ** data; -}; - -/* - * A vector of void *. New elements will be appended at the tail. - */ - -FishSoundVector * -fs_vector_new (FishSoundCmpFunc cmp) -{ - FishSoundVector * vector; - - vector = fs_malloc (sizeof (FishSoundVector)); - if (vector == NULL) return NULL; - - vector->max_elements = 0; - vector->nr_elements = 0; - vector->cmp = cmp; - vector->data = NULL; - - return vector; -} - -static void -fs_vector_clear (FishSoundVector * vector) -{ - fs_free (vector->data); - vector->data = NULL; - vector->nr_elements = 0; - vector->max_elements = 0; -} - -void -fs_vector_delete (FishSoundVector * vector) -{ - fs_vector_clear (vector); - fs_free (vector); -} - -int -fs_vector_size (FishSoundVector * vector) -{ - if (vector == NULL) return 0; - - return vector->nr_elements; -} - -void * -fs_vector_nth (FishSoundVector * vector, int n) -{ - if (vector == NULL) return NULL; - - if (n >= vector->nr_elements) return NULL; - - return vector->data[n]; -} - -int -fs_vector_find_index (FishSoundVector * vector, const void * data) -{ - void * v_data; - int i; - - for (i = 0; i < vector->nr_elements; i++) { - v_data = vector->data[i]; - if (vector->cmp (v_data, data)) - return i; - } - - return -1; -} - -void * -fs_vector_find (FishSoundVector * vector, const void * data) -{ - void * v_data; - int i; - - for (i = 0; i < vector->nr_elements; i++) { - v_data = vector->data[i]; - if (vector->cmp (v_data, data)) - return v_data; - } - - return NULL; -} - -int -fs_vector_foreach (FishSoundVector * vector, FishSoundFunc func) -{ - int i; - - for (i = 0; i < vector->nr_elements; i++) { - func (vector->data[i]); - } - - return 0; -} - -static FishSoundVector * -fs_vector_grow (FishSoundVector * vector) -{ - void * new_elements; - int new_max_elements; - - vector->nr_elements++; - - if (vector->nr_elements > vector->max_elements) { - if (vector->max_elements == 0) { - new_max_elements = 1; - } else { - new_max_elements = vector->max_elements * 2; - } - - new_elements = - fs_realloc (vector->data, (size_t)new_max_elements * sizeof (void *)); - - if (new_elements == NULL) { - vector->nr_elements--; - return NULL; - } - - vector->max_elements = new_max_elements; - vector->data = new_elements; - } - - return vector; -} - -void * -fs_vector_insert (FishSoundVector * vector, void * data) -{ - if (vector == NULL) return NULL; - - if (fs_vector_grow (vector) == NULL) - return NULL; - - vector->data[vector->nr_elements-1] = data; - - return data; - -} - -static void * -fs_vector_remove_nth (FishSoundVector * vector, int n) -{ - int i; - void * new_elements; - int new_max_elements; - - vector->nr_elements--; - - if (vector->nr_elements == 0) { - fs_vector_clear (vector); - } else { - for (i = n; i < vector->nr_elements; i++) { - vector->data[i] = vector->data[i+1]; - } - - if (vector->nr_elements < vector->max_elements/2) { - new_max_elements = vector->max_elements/2; - - new_elements = - fs_realloc (vector->data, - (size_t)new_max_elements * sizeof (void *)); - - if (new_elements == NULL) - return NULL; - - vector->max_elements = new_max_elements; - vector->data = new_elements; - } - } - - return vector; -} - -FishSoundVector * -fs_vector_remove (FishSoundVector * vector, void * data) -{ - int i; - - for (i = 0; i < vector->nr_elements; i++) { - if (vector->data[i] == data) { - return fs_vector_remove_nth (vector, i); - } - } - - return vector; -} diff --git a/media/libfishsound/src/libfishsound/fs_vector.h b/media/libfishsound/src/libfishsound/fs_vector.h deleted file mode 100644 index 4e34bdab6e5..00000000000 --- a/media/libfishsound/src/libfishsound/fs_vector.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __FS_VECTOR_H__ -#define __FS_VECTOR_H__ - -typedef void FishSoundVector; - -typedef int (*FishSoundFunc) (void * data); -typedef int (*FishSoundCmpFunc) (void * data1, void * data2); - -FishSoundVector * -fs_vector_new (FishSoundCmpFunc cmp); - -void -fs_vector_delete (FishSoundVector * vector); - -void * -fs_vector_nth (FishSoundVector * vector, int n); - -int -fs_vector_find_index (FishSoundVector * vector, const void * data); - -void * -fs_vector_find (FishSoundVector * vector, const void * data); - -int -fs_vector_foreach (FishSoundVector * vector, FishSoundFunc func); - -int -fs_vector_size (FishSoundVector * vector); - -/** - * Add an element to a vector. - * \param vector An FishSoundVector - * \param data The new element to add - * \retval data If the element was successfully added - * \retval NULL If adding the element failed due to a realloc() error - */ -void * -fs_vector_insert (FishSoundVector * vector, void * data); - -/** - * Remove a (void *) element of a vector - * \retval \a vector on success - * \retval NULL on failure (realloc error) - */ -FishSoundVector * -fs_vector_remove (FishSoundVector * vector, void * data); - -#endif /* __FS_VECTOR_H__ */ diff --git a/media/libfishsound/src/libfishsound/private.h b/media/libfishsound/src/libfishsound/private.h deleted file mode 100644 index 646d6624d0a..00000000000 --- a/media/libfishsound/src/libfishsound/private.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __FISH_SOUND_PRIVATE_H__ -#define __FISH_SOUND_PRIVATE_H__ - -#include - -#include "fs_compat.h" -#include "fs_vector.h" - -#include - -#undef MIN -#define MIN(a,b) (((a)<(b))?(a):(b)) - -typedef struct _FishSound FishSound; -typedef struct _FishSoundInfo FishSoundInfo; -typedef struct _FishSoundCodec FishSoundCodec; -typedef struct _FishSoundFormat FishSoundFormat; -typedef struct _FishSoundComment FishSoundComment; - -typedef int (*FSCodecIdentify) (unsigned char * buf, long bytes); -typedef FishSound * (*FSCodecInit) (FishSound * fsound); -typedef FishSound * (*FSCodecDelete) (FishSound * fsound); -typedef int (*FSCodecReset) (FishSound * fsound); -typedef int (*FSCodecUpdate) (FishSound * fsound, int interleave); -typedef int (*FSCodecCommand) (FishSound * fsound, int command, - void * data, int datasize); -typedef long (*FSCodecDecode) (FishSound * fsound, unsigned char * buf, - long bytes); -typedef long (*FSCodecEncode_Float) (FishSound * fsound, float * pcm[], - long frames); -typedef long (*FSCodecEncode_FloatIlv) (FishSound * fsound, - float ** pcm, long frames); -typedef long (*FSCodecFlush) (FishSound * fsound); - -#include -#include - -struct _FishSoundFormat { - int format; - const char * name; - const char * extension; -}; - -struct _FishSoundCodec { - struct _FishSoundFormat format; - FSCodecInit init; - FSCodecDelete del; - FSCodecReset reset; - FSCodecUpdate update; - FSCodecCommand command; - FSCodecDecode decode; - FSCodecEncode_FloatIlv encode_f_ilv; - FSCodecEncode_Float encode_f; - FSCodecFlush flush; -}; - -struct _FishSoundInfo { - int samplerate; - int channels; - int format; -}; - -struct _FishSoundComment { - char * name; - char * value; -}; - -union FishSoundCallback { - FishSoundDecoded_Float decoded_float; - FishSoundDecoded_FloatIlv decoded_float_ilv; - FishSoundEncoded encoded; -}; - -struct _FishSound { - /** FISH_SOUND_DECODE or FISH_SOUND_ENCODE */ - FishSoundMode mode; - - /** General info related to sound */ - FishSoundInfo info; - - /** Interleave boolean */ - int interleave; - - /** - * Current frameno. - */ - long frameno; - - /** - * Truncation frameno for the next block of data sent to decode. - * In Ogg encapsulation, this is represented by the Ogg packet's - * "granulepos" field. - */ - long next_granulepos; - - /** - * Flag if the next block of data sent to decode will be the last one - * for this stream (eos = End Of Stream). - * In Ogg encapsulation, this is represented by the Ogg packet's - * "eos" field. - */ - int next_eos; - - /** The codec class structure */ - FishSoundCodec * codec; - - /** codec specific data */ - void * codec_data; - - /* encode or decode callback */ - union FishSoundCallback callback; - - /** user data for encode/decode callback */ - void * user_data; - - /** The comments */ - char * vendor; - FishSoundVector * comments; -}; - -int fish_sound_identify (unsigned char * buf, long bytes); -int fish_sound_set_format (FishSound * fsound, int format); - -/* Format specific interfaces */ -int fish_sound_vorbis_identify (unsigned char * buf, long bytes); -FishSoundCodec * fish_sound_vorbis_codec (void); - -int fish_sound_speex_identify (unsigned char * buf, long bytes); -FishSoundCodec * fish_sound_speex_codec (void); - -int fish_sound_flac_identify (unsigned char * buf, long bytes); -FishSoundCodec * fish_sound_flac_codec (void); - -/* comments */ -int fish_sound_comments_init (FishSound * fsound); -int fish_sound_comments_free (FishSound * fsound); -int fish_sound_comments_decode (FishSound * fsound, unsigned char * buf, - long bytes); -long fish_sound_comments_encode (FishSound * fsound, unsigned char * buf, - long length); - -/** - * Set the vendor string. - * \param fsound A FishSound* handle (created with FISH_SOUND_ENCODE) - * \param vendor The vendor string. - * \retval 0 Success - * \retval FISH_SOUND_ERR_BAD \a fsound is not a valid FishSound* handle - * \retval FISH_SOUND_ERR_INVALID Operation not suitable for this FishSound - */ -int -fish_sound_comment_set_vendor (FishSound * fsound, const char * vendor); - -const FishSoundComment * fish_sound_comment_first (FishSound * fsound); -const FishSoundComment * -fish_sound_comment_next (FishSound * fsound, const FishSoundComment * comment); - -#endif /* __FISH_SOUND_PRIVATE_H__ */ diff --git a/media/libfishsound/trac497.patch b/media/libfishsound/trac497.patch deleted file mode 100644 index 0d840215799..00000000000 --- a/media/libfishsound/trac497.patch +++ /dev/null @@ -1,47 +0,0 @@ -diff --git a/media/libfishsound/src/libfishsound/fishsound_comments.c b/media/libfishsound/src/libfishsound/fishsound_comments.c -index b71164f..414e210 100644 ---- a/media/libfishsound/src/libfishsound/fishsound_comments.c -+++ b/media/libfishsound/src/libfishsound/fishsound_comments.c -@@ -290,7 +290,9 @@ fish_sound_comment_next_byname (FishSound * fsound, - int - fish_sound_comment_add (FishSound * fsound, FishSoundComment * comment) - { -+#if FS_ENCODE - FishSoundComment * new_comment; -+#endif - - if (fsound == NULL) return FISH_SOUND_ERR_BAD; - -@@ -317,7 +319,9 @@ int - fish_sound_comment_add_byname (FishSound * fsound, const char * name, - const char * value) - { -+#if FS_ENCODE - FishSoundComment * comment; -+#endif - - if (fsound == NULL) return FISH_SOUND_ERR_BAD; - -@@ -346,7 +350,9 @@ fish_sound_comment_add_byname (FishSound * fsound, const char * name, - int - fish_sound_comment_remove (FishSound * fsound, FishSoundComment * comment) - { -+#if FS_ENCODE - FishSoundComment * v_comment; -+#endif - - if (fsound == NULL) return FISH_SOUND_ERR_BAD; - -@@ -372,8 +378,11 @@ fish_sound_comment_remove (FishSound * fsound, FishSoundComment * comment) - int - fish_sound_comment_remove_byname (FishSound * fsound, char * name) - { -+#if FS_ENCODE - FishSoundComment * comment; -- int i, ret = 0; -+ int i; -+#endif -+ int ret = 0; - - if (fsound == NULL) return FISH_SOUND_ERR_BAD; - diff --git a/media/libfishsound/update.sh b/media/libfishsound/update.sh deleted file mode 100644 index ff02493a714..00000000000 --- a/media/libfishsound/update.sh +++ /dev/null @@ -1,46 +0,0 @@ -# Usage: cp $1/update.sh -# -# Copies the needed files from a directory containing the original -# libfishsound source that we need for the Mozilla HTML5 media support. -cp $1/config.h ./include/fishsound/config.h -echo "#undef FS_ENCODE" >>./include/fishsound/config.h -echo "#define FS_ENCODE 0" >>./include/fishsound/config.h -echo "#undef HAVE_FLAC" >>./include/fishsound/config.h -echo "#define HAVE_FLAC 0" >>./include/fishsound/config.h -echo "#undef HAVE_OGGZ" >>./include/fishsound/config.h -echo "#define HAVE_OGGZ 1" >>./include/fishsound/config.h -echo "#undef HAVE_SPEEX" >>./include/fishsound/config.h -echo "#define HAVE_SPEEX 0" >>./include/fishsound/config.h -echo "#undef HAVE_VORBIS" >>./include/fishsound/config.h -echo "#define HAVE_VORBIS 1" >>./include/fishsound/config.h -echo "#undef HAVE_VORBISENC" >>./include/fishsound/config.h -echo "#define HAVE_VORBISENC 0" >>./include/fishsound/config.h -echo "#undef DEBUG" >>./include/fishsound/config.h -cp $1/include/fishsound/encode.h ./include/fishsound/encode.h -cp $1/include/fishsound/comments.h ./include/fishsound/comments.h -cp $1/include/fishsound/deprecated.h ./include/fishsound/deprecated.h -cp $1/include/fishsound/fishsound.h ./include/fishsound/fishsound.h -cp $1/include/fishsound/constants.h ./include/fishsound/constants.h -cp $1/include/fishsound/decode.h ./include/fishsound/decode.h -cp $1/COPYING ./COPYING -cp $1/README ./README -cp ./include/fishsound/config.h ./src/libfishsound/config.h -cp $1/src/libfishsound/decode.c ./src/libfishsound/fishsound_decode.c -cp $1/src/libfishsound/fishsound.c ./src/libfishsound/fishsound.c -sed s/\#include\ \/\#if\ HAVE_VORBISENC\\n\#include\ \\\n\#endif/g $1/src/libfishsound/vorbis.c >./src/libfishsound/fishsound_vorbis.c -cp $1/src/libfishsound/flac.c ./src/libfishsound/fishsound_flac.c -cp $1/src/libfishsound/comments.c ./src/libfishsound/fishsound_comments.c -cp $1/src/libfishsound/private.h ./src/libfishsound/private.h -cp $1/src/libfishsound/fs_compat.h ./src/libfishsound/fs_compat.h -cp $1/src/libfishsound/speex.c ./src/libfishsound/fishsound_speex.c -cp $1/src/libfishsound/encode.c ./src/libfishsound/fishsound_encode.c -cp $1/src/libfishsound/fs_vector.h ./src/libfishsound/fs_vector.h -cp $1/src/libfishsound/fs_vector.c ./src/libfishsound/fs_vector.c -cp $1/src/libfishsound/convert.h ./src/libfishsound/convert.h -cp $1/src/libfishsound/debug.h ./src/libfishsound/debug.h -cp $1/AUTHORS ./AUTHORS -patch -p3 -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = oggplay - -DIRS = \ - include \ - src \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/media/liboggplay/README b/media/liboggplay/README deleted file mode 100644 index 5ba3d83e1f1..00000000000 --- a/media/liboggplay/README +++ /dev/null @@ -1,68 +0,0 @@ -OggPlay: a library for playing Ogg multimedia - -Overview --------- - -The current version of the plugin is still under development therefore -the setup requires manual installation of the plugin. For more information, -see also: - - http://wiki.xiph.org/index.php/OggPlay - -Dependencies ------------- - -For the core library (liboggplay), you need - - * libogg, libvorbis, libtheora, optionally libspeex -- from http://www.xiph.org/ - - svn co http://svn.xiph.org/trunk/ogg/ ogg - svn co http://svn.xiph.org/trunk/vorbis/ vorbis - svn co http://svn.xiph.org/trunk/theora/ theora - - * liboggz and libfishsound -- from svn.annodex.net: - - git clone git://git.xiph.org/liboggz.git - git clone git://git.xiph.org/libfishsound.git - -Optionally, for Kate stream support, you need - - * libkate -- from http://libkate.googlecode.com/ - -To render Kate streams as video overlays, you need - - * libtiger -- from http://libtiger.googlecode.com/ - -Note that libtiger needs Pango and Cairo: - - * Pango -- http://www.pango.org/ - * Cairo -- http://cairographics.com/ - -See the README files associated with these libraries for installation -instructions. - -To build src/examples/glut-player, you need: - * The core liboggplay dependencies (listed above) - * GLUT -- see http://www.opengl.org/resources/libraries/ - -To build src/examples/dump-all-streams, you need: - * The core liboggplay dependencies (listed above) - * libsndfile -- from http://www.mega-nerd.com/libsndfile/ - -To build src/tools/oggplay-dump-first-frame, you need: - * The core liboggplay dependencies (listed above) - * Imlib2 -- from your distribution or from - http://sourceforge.net/project/showfiles.php?group_id=2&package_id=11130 - -On Debian, the required packages for all these additional libraries are: - g++ libogg-dev libvorbis-dev libspeex-dev libtheora-dev libsndfile1-dev - libimlib2-dev libglut-dev - -Compile and Install liboggplay ------------------------------- - -./autogen.sh -./configure -make && make install - - diff --git a/media/liboggplay/README_MOZILLA b/media/liboggplay/README_MOZILLA deleted file mode 100644 index 23ddb0d3ee7..00000000000 --- a/media/liboggplay/README_MOZILLA +++ /dev/null @@ -1,48 +0,0 @@ -The source from this directory was copied from the liboggplay svn -source using the update.sh script. The only changes made were those -applied by update.sh and the addition/upate of Makefile.in files for -the Mozilla build system. - -git://git.xiph.org/liboggplay.git - -The git commit ID used was 404316e5957370b3c854a86910c237c90746c325. - -The following local patches have been applied: - -endian: pick up NSPR's little/big endian defines in oggplay's config.h. - -bug481921: fix a crash in oggplay_callback_info_prepare(). - -aspect-ratio: Adds oggplay_get_video_aspect_ratio, used for bug 480058. - -bug493678.patch: fix for infinite loop in oggplay_step_decode. See bug 493678. - -seek_to_key_frame.patch: Adds oggplay_seek_to_keyframe(), as per bug 463358. - -oggplay_os2.patch: Bug 448918 - add OS/2 support (this patch should be - removed when OS/2 support is added upstream) - -bug496529.patch: Fix bug 496529. - -bug500311.patch: Fix crash during decoder initialization. - -faster_seek.patch: Fix for bug 501031, make seeking faster over HTTP. - -fix-17ef4ca82df28.patch: Fix oggplay_callback_predetected() to return - value interpreted as success upon success. - Fixes liboggplay changeset 17ef4ca82df28. - -handle-read-errors.patch: Make oggplay_initialise() handle closing of stream - while reading. Prevents infinite loop. Further fix - to 17ef4ca82df28. - -bug515217.patch: Fix crash where presentation thread releases a buffer just - before decode thread tries to set that buffer as the last at EOF. -bug504843.patch: Abort when decoding video excessively large video frames. - -fishsound_reset.patch: Fixes bug 516323. - -bug520493.patch: Ensure liboggplay returns data when all tracks - are deactivated when a callback reaches EOF. - -bug523816.patch: Correct CMML data buffer size calculation. diff --git a/media/liboggplay/aspect_ratio.patch b/media/liboggplay/aspect_ratio.patch deleted file mode 100644 index e2076d3ae1a..00000000000 --- a/media/liboggplay/aspect_ratio.patch +++ /dev/null @@ -1,72 +0,0 @@ -diff --git a/media/liboggplay/include/oggplay/oggplay.h b/media/liboggplay/include/oggplay/oggplay.h ---- a/media/liboggplay/include/oggplay/oggplay.h -+++ b/media/liboggplay/include/oggplay/oggplay.h -@@ -226,16 +226,19 @@ oggplay_get_audio_samplerate(OggPlay *me - * @retval E_OGGPLAY_BAD_TRACK the given track number does not exists - * @retval E_OGGPLAY_WRONG_TRACK_TYPE the given track is not an audio track - * @retval E_OGGPLAY_UNINITIALISED the OggPlay handle is uninitalised. - */ - OggPlayErrorCode - oggplay_get_video_fps(OggPlay *me, int track, int* fps_denom, int* fps_num); - - OggPlayErrorCode -+oggplay_get_video_aspect_ratio(OggPlay *me, int track, int* aspect_denom, int* aspect_num); -+ -+OggPlayErrorCode - oggplay_convert_video_to_rgb(OggPlay *me, int track, int convert, int swap_rgb); - - OggPlayErrorCode - oggplay_get_kate_category(OggPlay *me, int track, const char** category); - - OggPlayErrorCode - oggplay_get_kate_language(OggPlay *me, int track, const char** language); - -diff --git a/media/liboggplay/src/liboggplay/oggplay.c b/media/liboggplay/src/liboggplay/oggplay.c ---- a/media/liboggplay/src/liboggplay/oggplay.c -+++ b/media/liboggplay/src/liboggplay/oggplay.c -@@ -297,16 +297,45 @@ oggplay_get_video_fps(OggPlay *me, int t - - (*fps_denom) = decode->video_info.fps_denominator; - (*fps_num) = decode->video_info.fps_numerator; - - return E_OGGPLAY_OK; - } - - OggPlayErrorCode -+oggplay_get_video_aspect_ratio(OggPlay *me, int track, int* aspect_denom, int* aspect_num) { -+ OggPlayTheoraDecode *decode; -+ -+ if (me == NULL) { -+ return E_OGGPLAY_BAD_OGGPLAY; -+ } -+ -+ if (track < 0 || track >= me->num_tracks) { -+ return E_OGGPLAY_BAD_TRACK; -+ } -+ -+ if (me->decode_data[track]->decoded_type != OGGPLAY_YUV_VIDEO) { -+ return E_OGGPLAY_WRONG_TRACK_TYPE; -+ } -+ -+ decode = (OggPlayTheoraDecode *)(me->decode_data[track]); -+ -+ if ((decode->video_info.aspect_denominator == 0) -+ || (decode->video_info.aspect_numerator == 0)) { -+ return E_OGGPLAY_UNINITIALISED; -+ } -+ -+ (*aspect_denom) = decode->video_info.aspect_denominator; -+ (*aspect_num) = decode->video_info.aspect_numerator; -+ -+ return E_OGGPLAY_OK; -+} -+ -+OggPlayErrorCode - oggplay_convert_video_to_rgb(OggPlay *me, int track, int convert, int swap_rgb) { - OggPlayTheoraDecode *decode; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { diff --git a/media/liboggplay/bug481921.patch b/media/liboggplay/bug481921.patch deleted file mode 100644 index e2e6971c4d5..00000000000 --- a/media/liboggplay/bug481921.patch +++ /dev/null @@ -1,32 +0,0 @@ -diff --git a/media/liboggplay/src/liboggplay/oggplay_callback_info.c b/media/liboggplay/src/liboggplay/oggplay_callback_info.c ---- a/media/liboggplay/src/liboggplay/oggplay_callback_info.c -+++ b/media/liboggplay/src/liboggplay/oggplay_callback_info.c -@@ -133,21 +133,23 @@ oggplay_callback_info_prepare(OggPlay *m - - track_info->available_records = count; - track_info->required_records = 0; - - track_info->data_type = track->decoded_type; - - count = 0; - for (p = q; p != NULL; p = p->next) { -- track_info->records[count++] = p; -- if (p->presentation_time <= me->target + track->offset) { -- track_info->required_records++; -- p->has_been_presented = 1; -- //lpt = p->presentation_time; -+ if (!p->has_been_presented) { -+ track_info->records[count++] = p; -+ if (p->presentation_time <= me->target + track->offset) { -+ track_info->required_records++; -+ p->has_been_presented = 1; -+ //lpt = p->presentation_time; -+ } - } - } - - if (track_info->required_records > 0) { - /* - * if the StreamState is FIRST_DATA then update it to INITIALISED, - * as we've marked the first data instance - */ diff --git a/media/liboggplay/bug487519.patch b/media/liboggplay/bug487519.patch deleted file mode 100644 index 6205d29bf77..00000000000 --- a/media/liboggplay/bug487519.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff --git a/media/liboggplay/src/liboggplay/oggplay_callback.c b/media/liboggplay/src/liboggplay/oggplay_callback.c ---- a/media/liboggplay/src/liboggplay/oggplay_callback.c -+++ b/media/liboggplay/src/liboggplay/oggplay_callback.c -@@ -543,16 +543,26 @@ oggplay_callback_audio (OGGZ * oggz, ogg - } - - default: - /* there was no problem with decoding */ - if (!common->num_header_packets) common->initialised |= 1; - break; - } - -+ if (bytes_read < 0) { -+ printf("\nERROR HADNLING MISMATCH BETWEEN liboggplay AND mozilla\n\n"); -+ // Unrecoverable error, disable track -+ op->e_o_s = 1; -+ common->active = 0; -+ common->player->active_tracks--; -+ return OGGZ_ERR_HOLE_IN_DATA; -+ } -+ -+ - if (decoder->sound_info.channels == 0) { - fish_sound_command(decoder->sound_handle, FISH_SOUND_GET_INFO, - &(decoder->sound_info), sizeof(FishSoundInfo)); - } - - if (op->e_o_s) { - common->active = 0; - common->player->active_tracks--; diff --git a/media/liboggplay/bug493678.patch b/media/liboggplay/bug493678.patch deleted file mode 100644 index 1721d2bdad6..00000000000 --- a/media/liboggplay/bug493678.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/media/liboggplay/src/liboggplay/oggplay_callback.c b/media/liboggplay/src/liboggplay/oggplay_callback.c -index 7683b80..ad127a0 100644 ---- a/media/liboggplay/src/liboggplay/oggplay_callback.c -+++ b/media/liboggplay/src/liboggplay/oggplay_callback.c -@@ -536,7 +536,7 @@ oggplay_initialise_decoder(OggPlay *me, int content_type, int serialno) { - decoder->content_type = content_type; - decoder->content_type_name = - oggz_stream_get_content_type (me->oggz, serialno); -- decoder->active = 1; -+ decoder->active = 0; - decoder->final_granulepos = -1; - decoder->player = me; - decoder->decoded_type = OGGPLAY_TYPE_UNKNOWN; diff --git a/media/liboggplay/bug496529.patch b/media/liboggplay/bug496529.patch deleted file mode 100644 index 61ed4bd7572..00000000000 --- a/media/liboggplay/bug496529.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/media/liboggplay/src/liboggplay/oggplay_yuv2rgb.c b/media/liboggplay/src/liboggplay/oggplay_yuv2rgb.c ---- a/media/liboggplay/src/liboggplay/oggplay_yuv2rgb.c -+++ b/media/liboggplay/src/liboggplay/oggplay_yuv2rgb.c -@@ -174,17 +174,17 @@ YUV_CONVERT(yuv444_to_argb_vanilla, CONV - * macros as there's no way e.g. we could compile a x86 asm code - * on a ppc machine and vica-versa - */ - #if defined(i386) || defined(__x86__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_AMD64) - #if !defined(_M_AMD64) - #define ENABLE_MMX - #endif - #include "x86/oggplay_yuv2rgb_x86.c" --#if defined(ATTRIBUTE_ALIGNED_MAX) && ATTRIBUTE_ALIGNED_MAX >= 16 -+#if defined(_MSC_VER) || defined(ATTRIBUTE_ALIGNED_MAX) && ATTRIBUTE_ALIGNED_MAX >= 16 - #define ENABLE_SSE2 - #endif - #elif defined(__ppc__) || defined(__ppc64__) - #define ENABLE_ALTIVEC - //altivec intristics only working with -maltivec gcc flag, - //but we want runtime altivec detection, hence this has to be - //fixed! - //#include "oggplay_yuv2rgb_altivec.c" diff --git a/media/liboggplay/bug500311.patch b/media/liboggplay/bug500311.patch deleted file mode 100644 index d2f30ad0d07..00000000000 --- a/media/liboggplay/bug500311.patch +++ /dev/null @@ -1,79 +0,0 @@ -diff --git a/media/liboggplay/src/liboggplay/oggplay.c b/media/liboggplay/src/liboggplay/oggplay.c ---- a/media/liboggplay/src/liboggplay/oggplay.c -+++ b/media/liboggplay/src/liboggplay/oggplay.c -@@ -149,16 +149,17 @@ oggplay_initialise(OggPlay *me, int bloc - } - - /* - * set all the tracks to inactive - */ - for (i = 0; i < me->num_tracks; i++) { - me->decode_data[i]->active = 0; - } -+ me->active_tracks = 0; - - /* - * if the buffer was set up before initialisation, prepare it now - */ - if (me->buffer != NULL) { - oggplay_buffer_prepare(me); - } - -diff --git a/media/liboggplay/src/liboggplay/oggplay_callback.c b/media/liboggplay/src/liboggplay/oggplay_callback.c ---- a/media/liboggplay/src/liboggplay/oggplay_callback.c -+++ b/media/liboggplay/src/liboggplay/oggplay_callback.c -@@ -60,16 +60,17 @@ oggplay_init_theora(void *user_data) { - theora_info_init(&(decoder->video_info)); - theora_comment_init(&(decoder->video_comment)); - decoder->granulepos_seen = 0; - decoder->frame_delta = 0; - decoder->y_width = 0; - decoder->convert_to_rgb = 0; - decoder->swap_rgb = 0; - decoder->decoder.decoded_type = OGGPLAY_YUV_VIDEO; -+ decoder->decoder.player->active_tracks++; - } - - void - oggplay_shutdown_theora(void *user_data) { - OggPlayDecode * common; - OggPlayTheoraDecode * decoder = (OggPlayTheoraDecode *)user_data; - - if (decoder == NULL) { -@@ -499,16 +500,17 @@ oggplay_init_audio (void * user_data) { - } - - decoder->sound_info.channels = 0; - fish_sound_set_decoded_float_ilv(decoder->sound_handle, - oggplay_fish_sound_callback_floats, - (void *)decoder); - - decoder->decoder.decoded_type = OGGPLAY_FLOATS_AUDIO; -+ decoder->decoder.player->active_tracks++; - } - - void - oggplay_shutdown_audio(void *user_data) { - - OggPlayAudioDecode * decoder = (OggPlayAudioDecode *)user_data; - - if (decoder == NULL) { -@@ -814,17 +816,17 @@ oggplay_initialise_decoder(OggPlay *me, - - if (decoder == NULL) - return NULL; - - decoder->serialno = serialno; - decoder->content_type = content_type; - decoder->content_type_name = - oggz_stream_get_content_type (me->oggz, serialno); -- decoder->active = 0; -+ decoder->active = 1; - decoder->final_granulepos = -1; - decoder->player = me; - decoder->decoded_type = OGGPLAY_TYPE_UNKNOWN; - decoder->num_header_packets = - oggz_stream_get_numheaders (me->oggz, serialno); - - /* - * set the StreamInfo to unitialised until we get some real data in diff --git a/media/liboggplay/bug504843.patch b/media/liboggplay/bug504843.patch deleted file mode 100644 index 62f1db4ad90..00000000000 --- a/media/liboggplay/bug504843.patch +++ /dev/null @@ -1,185 +0,0 @@ -diff --git a/media/liboggplay/include/oggplay/oggplay.h b/media/liboggplay/include/oggplay/oggplay.h ---- a/media/liboggplay/include/oggplay/oggplay.h -+++ b/media/liboggplay/include/oggplay/oggplay.h -@@ -116,17 +116,17 @@ oggplay_new_with_reader(OggPlayReader *r - * - * @param me OggPlay handle - * @param block passed as the second argument to the OggPlayReader's initialise - * function. E.g. in case of OggPlayTCPReader block == 0 sets the socket to non-blocking - * mode. - * @retval E_OGGPLAY_OK on success - * @retval E_OGGPLAY_OGGZ_UNHAPPY something went wrong while calling oggz_io_set_* functions. - * @retval E_OGGPLAY_BAD_INPUT got EOF or OGGZ_ERR_HOLE_IN_DATA occured. -- * @retval E_OGGPLAY_OUT_OF_MEMORY ran out of memory -+ * @retval E_OGGPLAY_OUT_OF_MEMORY ran out of memory or video frame too large. - * @retval E_OGGPLAY_BAD_OGGPLAY invalid OggPlay handle. - */ - OggPlayErrorCode - oggplay_initialise(OggPlay *me, int block); - - /** - * Sets a user defined OggPlayDataCallback function for the OggPlay handle. - * -@@ -344,13 +344,31 @@ oggplay_get_available(OggPlay *player); - * @retval E_OGGPLAY_BAD_OGGPLAY invalid OggPlay handle - */ - ogg_int64_t - oggplay_get_duration(OggPlay * player); - - int - oggplay_media_finished_retrieving(OggPlay * player); - -+/** -+ * Sets the maximum video frame size, in pixels, which OggPlay will attempt to -+ * decode. Call this after oggplay_new_with_reader() but before -+ * oggplay_initialise() to prevent crashes with excessivly large video frame -+ * sizes. oggplay_initialise() will return E_OGGPLAY_OUT_OF_MEMORY if the -+ * decoded video's frame requires more than max_frame_pixels. Unless -+ * oggplay_set_max_video_size() is called, default maximum number of pixels -+ * per frame is INT_MAX. -+ * -+ * @param player OggPlay handle. -+ * @param max_frame_pixels max number of pixels per frame. -+ * @retval E_OGGPLAY_OK on success. -+ * @retval E_OGGPLAY_BAD_OGGPLAY invalid OggPlay handle. -+ */ -+int -+oggplay_set_max_video_frame_pixels(OggPlay *player, -+ int max_frame_pixels); -+ - #ifdef __cplusplus - } - #endif - - #endif /* __OGGPLAY_H__ */ -diff --git a/media/liboggplay/src/liboggplay/oggplay.c b/media/liboggplay/src/liboggplay/oggplay.c ---- a/media/liboggplay/src/liboggplay/oggplay.c -+++ b/media/liboggplay/src/liboggplay/oggplay.c -@@ -68,16 +68,17 @@ oggplay_new_with_reader(OggPlayReader *r - me->target = 0L; - me->active_tracks = 0; - me->buffer = NULL; - me->shutdown = 0; - me->trash = NULL; - me->oggz = NULL; - me->pt_update_valid = 1; - me->duration = -1; -+ me->max_video_frame_pixels = OGGPLAY_TYPE_MAX_SIGNED(int); - - return me; - - } - - OggPlayErrorCode - oggplay_initialise(OggPlay *me, int block) { - -@@ -958,8 +959,16 @@ oggplay_media_finished_retrieving(OggPla - if (me->reader == NULL) { - return E_OGGPLAY_BAD_READER; - } - - return me->reader->finished_retrieving(me->reader); - - } - -+int -+oggplay_set_max_video_frame_pixels(OggPlay *player, -+ int max_frame_pixels) { -+ if (!player) -+ return E_OGGPLAY_BAD_OGGPLAY; -+ player->max_video_frame_pixels = max_frame_pixels; -+ return E_OGGPLAY_OK; -+} -diff --git a/media/liboggplay/src/liboggplay/oggplay_callback.c b/media/liboggplay/src/liboggplay/oggplay_callback.c ---- a/media/liboggplay/src/liboggplay/oggplay_callback.c -+++ b/media/liboggplay/src/liboggplay/oggplay_callback.c -@@ -83,16 +83,42 @@ oggplay_shutdown_theora(void *user_data) - - if (common->initialised == 1 && decoder->decoder.num_header_packets == 0) { - theora_clear(&(decoder->video_handle)); - } - theora_info_clear(&(decoder->video_info)); - theora_comment_clear(&(decoder->video_comment)); - } - -+/** -+ * Returns 1 if the video as described by |info| requires more than -+ * max_video_pixels pixels per frame, otherwise returns 0. -+ */ -+static int -+frame_is_too_large(theora_info *info, long max_video_pixels) { -+ int overflow = 0; -+ long frame_pixels = 0; -+ long display_pixels = 0; -+ if (!info) { -+ return 1; -+ } -+ overflow |= oggplay_mul_signed_overflow(info->frame_width, -+ info->frame_height, -+ &frame_pixels); -+ overflow |= oggplay_mul_signed_overflow(info->width, -+ info->height, -+ &display_pixels); -+ if (overflow || -+ frame_pixels > max_video_pixels || -+ display_pixels > max_video_pixels) { -+ return 1; -+ } -+ return 0; -+} -+ - int - oggplay_callback_theora (OGGZ * oggz, ogg_packet * op, long serialno, - void * user_data) { - - OggPlayTheoraDecode * decoder = (OggPlayTheoraDecode *)user_data; - OggPlayDecode * common = NULL; - ogg_int64_t granulepos = oggz_tell_granulepos(oggz); - yuv_buffer buffer; -@@ -184,17 +210,24 @@ oggplay_callback_theora (OGGZ * oggz, og - ((decoder->video_info.height - decoder->video_info.offset_y)video_info.frame_height) - || - ((decoder->video_info.width - decoder->video_info.offset_x)video_info.frame_width) - ) - { - common->initialised |= -1; - return OGGZ_CONTINUE; - } -- -+ -+ /* Ensure the video frames don't require more pixels than our -+ * allowed maximum. */ -+ if (frame_is_too_large(&decoder->video_info, -+ common->player->max_video_frame_pixels)) { -+ return OGGZ_ERR_OUT_OF_MEMORY; -+ } -+ - if (theora_decode_init(&(decoder->video_handle), &(decoder->video_info))) { - common->initialised |= -1; - return OGGZ_CONTINUE; - } - - common->initialised |= 1; - } - return OGGZ_CONTINUE; -diff --git a/media/liboggplay/src/liboggplay/oggplay_private.h b/media/liboggplay/src/liboggplay/oggplay_private.h ---- a/media/liboggplay/src/liboggplay/oggplay_private.h -+++ b/media/liboggplay/src/liboggplay/oggplay_private.h -@@ -256,16 +256,17 @@ struct _OggPlay { - ogg_int64_t target; /**< */ - int active_tracks; /**< number of active tracks */ - volatile OggPlayBuffer * buffer; /**< @see OggPlayBuffer */ - ogg_int64_t presentation_time; /**< */ - OggPlaySeekTrash * trash; /**< @see OggPlaySeekTrash */ - int shutdown; /**< "= 1" indicates shutdown event */ - int pt_update_valid; /**< */ - ogg_int64_t duration; /**< The value of the duration the last time it was retrieved.*/ -+ int max_video_frame_pixels; /**< Maximum number of pixels we'll allow in a video frame.*/ - }; - - void - oggplay_set_data_callback_force(OggPlay *me, OggPlayDataCallback callback, - void *user); - - void - oggplay_take_out_trash(OggPlay *me, OggPlaySeekTrash *trash); diff --git a/media/liboggplay/bug515217.patch b/media/liboggplay/bug515217.patch deleted file mode 100644 index 74accd7b0d7..00000000000 --- a/media/liboggplay/bug515217.patch +++ /dev/null @@ -1,98 +0,0 @@ -diff --git a/media/liboggplay/src/liboggplay/oggplay.c b/media/liboggplay/src/liboggplay/oggplay.c ---- a/media/liboggplay/src/liboggplay/oggplay.c -+++ b/media/liboggplay/src/liboggplay/oggplay.c -@@ -746,29 +746,27 @@ read_more_data: - * set all of the tracks to inactive - */ - for (i = 0; i < me->num_tracks; i++) { - me->decode_data[i]->active = 0; - } - me->active_tracks = 0; - - if (info != NULL) { -+ /* ensure all tracks have their final data packet set to end_of_stream */ -+ OggPlayCallbackInfo *p = info[0]; -+ for (i = 0; i < me->num_tracks; i++) { -+ p->stream_info = OGGPLAY_STREAM_LAST_DATA; -+ p++; -+ } -+ - me->callback (me, num_records, info, me->callback_user_ptr); - oggplay_callback_info_destroy(me, info); - } - -- /* -- * ensure all tracks have their final data packet set to end_of_stream -- * But skip doing this if we're shutting down --- me->buffer may not -- * be in a safe state. -- */ -- if (me->buffer != NULL && !me->shutdown) { -- oggplay_buffer_set_last_data(me, me->buffer); -- } -- - /* we reached the end of the stream */ - return E_OGGPLAY_OK; - - case OGGZ_ERR_HOLE_IN_DATA: - /* there was a whole in the data */ - return E_OGGPLAY_BAD_INPUT; - - case OGGZ_ERR_STOP_ERR: -diff --git a/media/liboggplay/src/liboggplay/oggplay_buffer.c b/media/liboggplay/src/liboggplay/oggplay_buffer.c ---- a/media/liboggplay/src/liboggplay/oggplay_buffer.c -+++ b/media/liboggplay/src/liboggplay/oggplay_buffer.c -@@ -138,38 +138,16 @@ oggplay_buffer_is_full(volatile OggPlayB - buffer->buffer_list[WRAP_INC(buffer->last_filled, buffer->buffer_size)] - != - NULL - ) - ); - - } - --void --oggplay_buffer_set_last_data(OggPlay *me, volatile OggPlayBuffer *buffer) --{ -- -- int i; -- OggPlayCallbackInfo *p; -- -- /* -- * we're at last data before we've even started! -- */ -- if (buffer->last_filled == -1) { -- return; -- } -- -- p = (OggPlayCallbackInfo *)buffer->buffer_list[buffer->last_filled]; -- -- for (i = 0; i < me->num_tracks; i++) { -- p->stream_info = OGGPLAY_STREAM_LAST_DATA; -- p++; -- } --} -- - int - oggplay_buffer_callback(OggPlay *me, int tracks, - OggPlayCallbackInfo **track_info, void *user) { - - int i; - int j; - int k; - OggPlayDataHeader ** headers; -diff --git a/media/liboggplay/src/liboggplay/oggplay_buffer.h b/media/liboggplay/src/liboggplay/oggplay_buffer.h ---- a/media/liboggplay/src/liboggplay/oggplay_buffer.h -+++ b/media/liboggplay/src/liboggplay/oggplay_buffer.h -@@ -53,12 +53,9 @@ int - oggplay_buffer_is_full(volatile OggPlayBuffer *buffer); - - void - oggplay_buffer_shutdown(OggPlay *me, volatile OggPlayBuffer *buffer); - - void - oggplay_buffer_prepare(OggPlay *me); - --void --oggplay_buffer_set_last_data(OggPlay *me, volatile OggPlayBuffer *buffer); -- - #endif diff --git a/media/liboggplay/bug520493.patch b/media/liboggplay/bug520493.patch deleted file mode 100644 index 5ed0f98475e..00000000000 --- a/media/liboggplay/bug520493.patch +++ /dev/null @@ -1,66 +0,0 @@ -diff --git a/media/liboggplay/src/liboggplay/oggplay.c b/media/liboggplay/src/liboggplay/oggplay.c ---- a/media/liboggplay/src/liboggplay/oggplay.c -+++ b/media/liboggplay/src/liboggplay/oggplay.c -@@ -638,16 +638,17 @@ OggPlayErrorCode - oggplay_step_decoding(OggPlay *me) { - - OggPlayCallbackInfo ** info; - int num_records; - int r; - int i; - int need_data = 0; - int chunk_count = 0; -+ int read_data = 0; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - /* - * check whether the OggPlayDataCallback is set for the given - * OggPlay handle. If not return with error as there's no callback -@@ -686,17 +687,21 @@ read_more_data: - if (me->active_tracks == 0) { - int remaining = 0; - for (i = 0; i < me->num_tracks; i++) { - if (me->decode_data[i]->current_loc + - me->decode_data[i]->granuleperiod >= me->target + me->decode_data[i]->offset) { - remaining++; - } - } -- if (remaining == 0) { -+ if (remaining == 0 && !read_data) { -+ /* -+ * There's no more data to read, and we've not read any that needs -+ * to be sent to the buffer list via a callback, so exit. -+ */ - return E_OGGPLAY_OK; - } - } - - /* - * if any of the tracks have not yet met the target (modified by that - * track's offset), then retrieve more data - */ -@@ -783,16 +788,21 @@ read_more_data: - * e.g. some buffer overflow. - */ - - case OGGZ_ERR_OUT_OF_MEMORY: - /* ran out of memory during decoding! */ - return E_OGGPLAY_OUT_OF_MEMORY; - - default: -+ /* -+ * We read some data. Set a flag so that we're guaranteed to try to -+ * send it to the buffer list via a callback. -+ */ -+ read_data = 1; - break; - } - } - /* - * prepare a callback - */ - num_records = oggplay_callback_info_prepare (me, &info); - if (info != NULL) { diff --git a/media/liboggplay/bug523816.patch b/media/liboggplay/bug523816.patch deleted file mode 100644 index d48da380457..00000000000 --- a/media/liboggplay/bug523816.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff --git a/media/liboggplay/src/liboggplay/oggplay_data.c b/media/liboggplay/src/liboggplay/oggplay_data.c ---- a/media/liboggplay/src/liboggplay/oggplay_data.c -+++ b/media/liboggplay/src/liboggplay/oggplay_data.c -@@ -353,22 +353,19 @@ oggplay_data_handle_audio_data (OggPlayD - OggPlayErrorCode - oggplay_data_handle_cmml_data(OggPlayDecode *decode, - unsigned char *data, - long size) { - - OggPlayTextRecord * record = NULL; - size_t record_size = sizeof(OggPlayTextRecord); - -- /* check that the size we want to allocate doesn't overflow */ -- if ((size < 0) || (size+1 < 0)) { -- return E_OGGPLAY_TYPE_OVERFLOW; -- } -- size += 1; -- -+ /* Include extra byte for null terminating record data buffer */ -+ record_size += 1; -+ - if - ( - oggplay_check_add_overflow (record_size, size, &record_size) - == - E_OGGPLAY_TYPE_OVERFLOW - ) - { - return E_OGGPLAY_TYPE_OVERFLOW; diff --git a/media/liboggplay/endian.patch b/media/liboggplay/endian.patch deleted file mode 100644 index ed516b30dba..00000000000 --- a/media/liboggplay/endian.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff --git a/media/liboggplay/src/liboggplay/config.h b/media/liboggplay/src/liboggplay/config.h ---- a/media/liboggplay/src/liboggplay/config.h -+++ b/media/liboggplay/src/liboggplay/config.h -@@ -102,8 +102,14 @@ - # ifndef WORDS_BIGENDIAN - /* # undef WORDS_BIGENDIAN */ - # endif - #endif - - /* Define to empty if `const' does not conform to ANSI C. */ - /* #undef const */ - #undef HAVE_GLUT -+ -+#include "prcpucfg.h" -+#ifdef IS_BIG_ENDIAN -+#define WORDS_BIGENDIAN 1 -+#endif -+ diff --git a/media/liboggplay/faster_seek.patch b/media/liboggplay/faster_seek.patch deleted file mode 100644 index 6f36a9709ea..00000000000 --- a/media/liboggplay/faster_seek.patch +++ /dev/null @@ -1,78 +0,0 @@ -diff --git a/media/liboggplay/include/oggplay/oggplay_seek.h b/media/liboggplay/include/oggplay/oggplay_seek.h ---- a/media/liboggplay/include/oggplay/oggplay_seek.h -+++ b/media/liboggplay/include/oggplay/oggplay_seek.h -@@ -53,15 +53,13 @@ - OggPlayErrorCode - oggplay_seek(OggPlay *me, ogg_int64_t milliseconds); - - /** - * Seeks to key frame before |milliseconds|. - */ - OggPlayErrorCode - oggplay_seek_to_keyframe(OggPlay *me, -- int* tracks, -- int num_tracks, - ogg_int64_t milliseconds, - ogg_int64_t offset_begin, - ogg_int64_t offset_end); - - #endif -diff --git a/media/liboggplay/src/liboggplay/oggplay_seek.c b/media/liboggplay/src/liboggplay/oggplay_seek.c ---- a/media/liboggplay/src/liboggplay/oggplay_seek.c -+++ b/media/liboggplay/src/liboggplay/oggplay_seek.c -@@ -186,54 +186,39 @@ oggplay_take_out_trash(OggPlay *me, OggP - - if (p != NULL) { - oggplay_free(p); - } - } - - OggPlayErrorCode - oggplay_seek_to_keyframe(OggPlay *me, -- int* tracks, -- int num_tracks, - ogg_int64_t milliseconds, - ogg_int64_t offset_begin, - ogg_int64_t offset_end) - { -- long *serial_nos; -- int i; - ogg_int64_t eof, time; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - -- if (num_tracks > me->num_tracks || milliseconds < 0) -+ if (milliseconds < 0) - return E_OGGPLAY_CANT_SEEK; - - eof = oggplay_get_duration(me); - if (eof > -1 && milliseconds > eof) { - return E_OGGPLAY_CANT_SEEK; - } - -- // Get the serialnos for the tracks we're seeking. -- serial_nos = (long*)oggplay_malloc(sizeof(long)*num_tracks); -- if (!serial_nos) { -- return E_OGGPLAY_CANT_SEEK; -- } -- for (i=0; idecode_data[tracks[i]]->serialno; -- } - - time = oggz_keyframe_seek_set(me->oggz, -- serial_nos, -- num_tracks, - milliseconds, - offset_begin, - offset_end); -- oggplay_free(serial_nos); - - if (time == -1) { - return E_OGGPLAY_CANT_SEEK; - } - - oggplay_seek_cleanup(me, time); - - return E_OGGPLAY_OK; diff --git a/media/liboggplay/fishsound_reset.patch b/media/liboggplay/fishsound_reset.patch deleted file mode 100644 index 59b833d7349..00000000000 --- a/media/liboggplay/fishsound_reset.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/media/liboggplay/src/liboggplay/oggplay_seek.c b/media/liboggplay/src/liboggplay/oggplay_seek.c ---- a/media/liboggplay/src/liboggplay/oggplay_seek.c -+++ b/media/liboggplay/src/liboggplay/oggplay_seek.c -@@ -166,6 +166,20 @@ oggplay_seek_cleanup(OggPlay* me, ogg_in - - *p = trash; - -+ if (milliseconds == 0) { -+ for (i = 0; i < me->num_tracks; i++) { -+ OggPlayDecode *track = me->decode_data[i]; -+ FishSound *sound_handle; -+ OggPlayAudioDecode *audio_decode; -+ if (track->content_type != OGGZ_CONTENT_VORBIS) { -+ continue; -+ } -+ audio_decode = (OggPlayAudioDecode*)track; -+ sound_handle = audio_decode->sound_handle; -+ fish_sound_reset(sound_handle); -+ } -+ } -+ - return E_OGGPLAY_OK; - } - diff --git a/media/liboggplay/fix-17ef4ca82df28.patch b/media/liboggplay/fix-17ef4ca82df28.patch deleted file mode 100644 index d4c5a87bdca..00000000000 --- a/media/liboggplay/fix-17ef4ca82df28.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/media/liboggplay/src/liboggplay/oggplay_callback.c b/media/liboggplay/src/liboggplay/oggplay_callback.c ---- a/media/liboggplay/src/liboggplay/oggplay_callback.c -+++ b/media/liboggplay/src/liboggplay/oggplay_callback.c -@@ -977,10 +982,10 @@ oggplay_callback_predetected (OGGZ *oggz - } - } - - /* disable the callback for unforeseen streams */ - oggz_set_read_callback (me->oggz, -1, NULL, NULL); - } - - /* read the header part of the ogg content in a packet-by-packet manner */ -- return ((ret < 0) ? ret : OGGZ_STOP_OK); -+ return ((ret < 0) ? ret : OGGZ_CONTINUE); - } diff --git a/media/liboggplay/handle-read-errors.patch b/media/liboggplay/handle-read-errors.patch deleted file mode 100644 index 18403683ec4..00000000000 --- a/media/liboggplay/handle-read-errors.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/media/liboggplay/src/liboggplay/oggplay.c b/media/liboggplay/src/liboggplay/oggplay.c ---- a/media/liboggplay/src/liboggplay/oggplay.c -+++ b/media/liboggplay/src/liboggplay/oggplay.c -@@ -136,16 +136,22 @@ oggplay_initialise(OggPlay *me, int bloc - - case OGGZ_ERR_OUT_OF_MEMORY: - /* ran out of memory during decoding! */ - return E_OGGPLAY_OUT_OF_MEMORY; - - case OGGZ_ERR_STOP_ERR: - /* */ - return E_OGGPLAY_BAD_OGGPLAY; -+ -+ default: -+ /* If the read otherwise failed, bail out. */ -+ if (i < 0) -+ return E_OGGPLAY_BAD_INPUT; -+ break; - } - - if (me->all_tracks_initialised) { - break; - } - } - - /* diff --git a/media/liboggplay/include/Makefile.in b/media/liboggplay/include/Makefile.in deleted file mode 100644 index e11914f4cff..00000000000 --- a/media/liboggplay/include/Makefile.in +++ /dev/null @@ -1,47 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = oggplay -DIRS = oggplay - -include $(topsrcdir)/config/rules.mk diff --git a/media/liboggplay/include/oggplay/Makefile.in b/media/liboggplay/include/oggplay/Makefile.in deleted file mode 100644 index c26c7502d60..00000000000 --- a/media/liboggplay/include/oggplay/Makefile.in +++ /dev/null @@ -1,57 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -EXPORTS_NAMESPACES = oggplay - -EXPORTS_oggplay = \ - config_win32.h \ - oggplay.h \ - oggplay_callback_info.h \ - oggplay_enums.h \ - oggplay_reader.h \ - oggplay_tools.h \ - oggplay_seek.h \ - oggplay_query.h \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/media/liboggplay/include/oggplay/config_win32.h b/media/liboggplay/include/oggplay/config_win32.h deleted file mode 100644 index fdc60abca99..00000000000 --- a/media/liboggplay/include/oggplay/config_win32.h +++ /dev/null @@ -1,78 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_DLFCN_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_INTTYPES_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_MEMORY_H */ - -/* Define if have liboggz */ -#define HAVE_OGGZ 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_STDINT_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_STRINGS_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_STAT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_TYPES_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_UNISTD_H */ - -/* Name of package */ -#define PACKAGE "liboggplay" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "0.2.0" - -/* Request Winsock 2.2 */ -#define HAVE_WINSOCK2 1 - -/* Make sure inline is treated properly */ -#define inline __inline - -/* snprintf portability */ -#define snprintf _snprintf - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -/* #undef WORDS_BIGENDIAN */ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Maximum supported data alignment */ -#define ATTRIBUTE_ALIGNED_MAX 16 diff --git a/media/liboggplay/include/oggplay/oggplay.h b/media/liboggplay/include/oggplay/oggplay.h deleted file mode 100644 index 7044f541fba..00000000000 --- a/media/liboggplay/include/oggplay/oggplay.h +++ /dev/null @@ -1,374 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** @file - * - * The liboggplay C API. - * - * @authors - * Shane Stephens - * Michael Martin - * Viktor Gal - */ - -#ifndef __OGGPLAY_H__ -#define __OGGPLAY_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** - * This is returned by oggplay_open_with_reader() or oggplay_new_with_reader(). - */ -typedef struct _OggPlay OggPlay; - -/** - * A structure for storing the decoded frames for the various streams in the - * Ogg container. - */ -typedef struct _OggPlayCallbackInfo OggPlayCallbackInfo; - -/** - * This is the signature of a callback which you must provide for OggPlay - * to call whenever there's any unpresented decoded frame available. - * - * @see oggplay_step_decoding - * @param player The OggPlay handle - * @param num_records size of the OggPlayCallbackInfo array - * @param records array of OggPlayCallbackInfo - * @param user A generic pointer for the data the user provided earlier. - * @returns 0 to continue, non-zero to instruct OggPlay to stop. - * - */ -typedef int (OggPlayDataCallback) (OggPlay *player, int num_records, - OggPlayCallbackInfo **records, void *user); - -#include -#include -#include -#include - -/** - * Create an OggPlay handle associated with the given reader. - * - * This functions creates a new OggPlay handle associated with - * the OggPlayReader and it calls oggplay_initialise to - * read the header packets of the Ogg container. - * - * @param reader an OggPlayReader handle associated with the Ogg content - * @return A new OggPlay handle - * @retval NULL in case of error. - */ -OggPlay * -oggplay_open_with_reader(OggPlayReader *reader); - -/** - * Create a new OggPlay handle associated with the given reader. - * - * @param reader OggPlayReader handle associated with the Ogg content - * @return A new OggPlay handle - * @retval NULL in case of error. - */ -OggPlay * -oggplay_new_with_reader(OggPlayReader *reader); - - -/** - * Initialise the OggPlay handle. - * - * This function creates an Oggz handle and sets it's OggzIO* - * functions to the OggPlayReader's io_* functions. Moreover - * it reads the Ogg container's content until it hasn't got - * all the streams' headers. - * - * @param me OggPlay handle - * @param block passed as the second argument to the OggPlayReader's initialise - * function. E.g. in case of OggPlayTCPReader block == 0 sets the socket to non-blocking - * mode. - * @retval E_OGGPLAY_OK on success - * @retval E_OGGPLAY_OGGZ_UNHAPPY something went wrong while calling oggz_io_set_* functions. - * @retval E_OGGPLAY_BAD_INPUT got EOF or OGGZ_ERR_HOLE_IN_DATA occured. - * @retval E_OGGPLAY_OUT_OF_MEMORY ran out of memory or video frame too large. - * @retval E_OGGPLAY_BAD_OGGPLAY invalid OggPlay handle. - */ -OggPlayErrorCode -oggplay_initialise(OggPlay *me, int block); - -/** - * Sets a user defined OggPlayDataCallback function for the OggPlay handle. - * - * @param me OggPlay handle. - * @param callback A custom callback function. - * @param user Arbitrary data one wishes to pass to the callback function. - * @retval E_OGGPLAY_OK on success - * @retval E_OGGPLAY_BUFFER_MODE We are running in buffer mode, i.e. oggplay_use_buffer - * has been called earlier. - * @retval E_OGGPLAY_BAD_OGGPLAY Invalid OggPlay handle. - */ -OggPlayErrorCode -oggplay_set_data_callback(OggPlay *me, OggPlayDataCallback callback, - void *user); - - -OggPlayErrorCode -oggplay_set_callback_num_frames(OggPlay *me, int stream, int frames); - -OggPlayErrorCode -oggplay_set_callback_period(OggPlay *me, int stream, int milliseconds); - -OggPlayErrorCode -oggplay_set_offset(OggPlay *me, int track, ogg_int64_t offset); - -/** - * Get the given video track's Y-plane's width and height. - * - * @param me OggPlay handle - * @param track the track number of the video track - * @param y_width the width of the Y-plane - * @param y_height the height of the Y-plane - * @retval E_OGGPLAY_OK on success. - * @retval E_OGGPLAY_BAD_OGGPLAY invalid OggPlay handle - * @retval E_OGGPLAY_BAD_TRACK the given track number does not exists - * @retval E_OGGPLAY_WRONG_TRACK_TYPE the given track is not an audio track - * @retval E_OGGPLAY_UNINITIALISED the OggPlay handle is uninitalised. - */ -OggPlayErrorCode -oggplay_get_video_y_size(OggPlay *me, int track, int *y_width, int *y_height); - -/** - * Get the given video track's UV-plane's width and height. - * - * @param me OggPlay handle - * @param track the track number of the video track - * @param uv_width the width of the UV-plane - * @param uv_height the height of the UV-plane - * @retval E_OGGPLAY_OK on success. - * @retval E_OGGPLAY_BAD_OGGPLAY invalid OggPlay handle - * @retval E_OGGPLAY_BAD_TRACK the given track number does not exists - * @retval E_OGGPLAY_WRONG_TRACK_TYPE the given track is not an audio track - * @retval E_OGGPLAY_UNINITIALISED the OggPlay handle is uninitalised. - */ -OggPlayErrorCode -oggplay_get_video_uv_size(OggPlay *me, int track, int *uv_width, int *uv_height); - -/** - * Get the number of channels of the audio track. - * - * @param me OggPlay handle - * @param track the track number of the audio track - * @param channels the number of channels of the given audio track. - * @retval E_OGGPLAY_OK on success. - * @retval E_OGGPLAY_BAD_OGGPLAY invalid OggPlay handle - * @retval E_OGGPLAY_BAD_TRACK the given track number does not exists - * @retval E_OGGPLAY_WRONG_TRACK_TYPE the given track is not an audio track - * @retval E_OGGPLAY_UNINITIALISED the OggPlay handle is uninitalised. - */ -OggPlayErrorCode -oggplay_get_audio_channels(OggPlay *me, int track, int *channels); - -/** - * Get the sample rate of the of the audio track - * - * @param me OggPlay handle - * @param track the track number of the audio track - * @param samplerate the sample rate of the audio track. - * @retval E_OGGPLAY_OK on success. - * @retval E_OGGPLAY_BAD_OGGPLAY invalid OggPlay handle - * @retval E_OGGPLAY_BAD_TRACK the given track number does not exists - * @retval E_OGGPLAY_WRONG_TRACK_TYPE the given track is not an audio track - * @retval E_OGGPLAY_UNINITIALISED the OggPlay handle is uninitalised. - */ -OggPlayErrorCode -oggplay_get_audio_samplerate(OggPlay *me, int track, int *samplerate); - -/** - * Get the frame-per-second value the of a given video track. - * - * @param me OggPlay handle - * @param track the track number of the audio track - * @param fps_denom the denumerator of the FPS - * @param fps_num the numerator of the FPS - * @retval E_OGGPLAY_OK on success. - * @retval E_OGGPLAY_BAD_OGGPLAY invalid OggPlay handle - * @retval E_OGGPLAY_BAD_TRACK the given track number does not exists - * @retval E_OGGPLAY_WRONG_TRACK_TYPE the given track is not an audio track - * @retval E_OGGPLAY_UNINITIALISED the OggPlay handle is uninitalised. - */ -OggPlayErrorCode -oggplay_get_video_fps(OggPlay *me, int track, int* fps_denom, int* fps_num); - -OggPlayErrorCode -oggplay_get_video_aspect_ratio(OggPlay *me, int track, int* aspect_denom, int* aspect_num); - -OggPlayErrorCode -oggplay_convert_video_to_rgb(OggPlay *me, int track, int convert, int swap_rgb); - -OggPlayErrorCode -oggplay_get_kate_category(OggPlay *me, int track, const char** category); - -OggPlayErrorCode -oggplay_get_kate_language(OggPlay *me, int track, const char** language); - -OggPlayErrorCode -oggplay_set_kate_tiger_rendering(OggPlay *me, int track, int use_tiger, int swap_rgb, int default_width, int default_height); - -OggPlayErrorCode -oggplay_overlay_kate_track_on_video(OggPlay *me, int kate_track, int video_track); - -OggPlayErrorCode -oggplay_start_decoding(OggPlay *me); - -/** - * Decode the streams in the Ogg container until we find data that hasn't - * been presented, yet. - * - * Whenever there is data that hasn't been presented the OggPlayDataCallback - * function will be called. - * - * @param me OggPlay handle - * @retval E_OGGPLAY_OK reached the end of the stream or shutdown detected - * @retval E_OGGPLAY_CONTINUE successfully decoded the frames. - * @retval E_OGGPLAY_BAD_INPUT OGGZ_ERR_HOLE_IN_DATA occured while decoding - * @retval E_OGGPLAY_UNINITIALISED the OggPlayDataCallback of the OggPlay handle is not set. - * @retval E_OGGPLAY_USER_INTERRUPT user interrupted the decoding - * @retval E_OGGPLAY_OUT_OF_MEMORY ran out of memory while decoding - */ -OggPlayErrorCode -oggplay_step_decoding(OggPlay *me); - -/** - * Use the built-in OggPlayBuffer for buffering the decoded frames - * - * The built-in OggPlayBuffer implements a simple lock-free FIFO for - * storing the decoded frames. - * - * It tries to set the OggPlay handle's OggPlayDataCallback function to it's - * own implementation (oggplay_buffer_callback). Thus it will fail if - * a user already set OggPlayDataCallback of the OggPlay handle - * with oggplay_set_data_callback. - * - * One can retrive the next record in the queue by - * calling oggplay_buffer_retrieve_next. - * - * @param player the OggPlay handle - * @param size The size of the buffer, i.e. the number of records it can store - * @retval E_OGGPLAY_OK on succsess - * @retval E_OGGPLAY_BAD_OGGPLAY The supplied OggPlay handle is not valid - * @retval E_OGGPLAY_CALLBACK_MODE The given OggPlay handle's OggPlayDataCallback - * function is already set, i.e. running in callback-mode. - * @retval E_OGGPLAY_OUT_OF_MEMORY Ran out of memory while trying to allocate memory for the buffer. - */ -OggPlayErrorCode -oggplay_use_buffer(OggPlay *player, int size); - -/** - * Retrive the next element in the buffer. - * - * @param player OggPlay handle - * @return array of OggPlayCallbackInfo - one per track. - * @retval NULL if there was no available. - */ -OggPlayCallbackInfo ** -oggplay_buffer_retrieve_next(OggPlay *player); - -/** - * Release the given buffer item. - * - * After retrieving and processing one buffer item, in order - * to remove the given item from the queue and release the - * memory allocated by the buffer item one needs to call this - * function. - * - * @param player OggPlay handle - * @param track_info OggPlayCallbackInfo array to release. - * @retval E_OGGPLAY_OK on success. - * @retval E_OGGPLAY_BAD_OGGPLAY invalid OggPlay handle. - */ -OggPlayErrorCode -oggplay_buffer_release(OggPlay *player, OggPlayCallbackInfo **track_info); - -void -oggplay_prepare_for_close(OggPlay *me); - -/** - * Destroys the OggPlay handle along with the associated OggPlayReader - * and clears out the buffer and shuts down the callback function. - * - * @param player an OggPlay handle - * @retval E_OGGPLAY_OK on success - */ -OggPlayErrorCode -oggplay_close(OggPlay *player); - -int -oggplay_get_available(OggPlay *player); - -/** - * Get the duration of the Ogg content. - * - * @param player OggPlay handle. - * @return The duration of the content in milliseconds. - * @retval E_OGGPLAY_BAD_OGGPLAY invalid OggPlay handle - */ -ogg_int64_t -oggplay_get_duration(OggPlay * player); - -int -oggplay_media_finished_retrieving(OggPlay * player); - -/** - * Sets the maximum video frame size, in pixels, which OggPlay will attempt to - * decode. Call this after oggplay_new_with_reader() but before - * oggplay_initialise() to prevent crashes with excessivly large video frame - * sizes. oggplay_initialise() will return E_OGGPLAY_OUT_OF_MEMORY if the - * decoded video's frame requires more than max_frame_pixels. Unless - * oggplay_set_max_video_size() is called, default maximum number of pixels - * per frame is INT_MAX. - * - * @param player OggPlay handle. - * @param max_frame_pixels max number of pixels per frame. - * @retval E_OGGPLAY_OK on success. - * @retval E_OGGPLAY_BAD_OGGPLAY invalid OggPlay handle. - */ -int -oggplay_set_max_video_frame_pixels(OggPlay *player, - int max_frame_pixels); - -#ifdef __cplusplus -} -#endif - -#endif /* __OGGPLAY_H__ */ diff --git a/media/liboggplay/include/oggplay/oggplay_callback_info.h b/media/liboggplay/include/oggplay/oggplay_callback_info.h deleted file mode 100644 index 84b119e3334..00000000000 --- a/media/liboggplay/include/oggplay/oggplay_callback_info.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** @file - * oggplay_callback_info.h - * - * @authors - * Shane Stephens - * Michael Martin - * Viktor Gal - */ - -#ifndef __OGGPLAY_CALLBACK_INFO__ -#define __OGGPLAY_CALLBACK_INFO__ - -/** structure for storing a YUV video frame */ -typedef struct { - unsigned char * y; /**< Y-plane */ - unsigned char * u; /**< U-plane*/ - unsigned char * v; /**< V-plane */ -} OggPlayVideoData; - -/** structure for storing a video frame in RGB fromat */ -typedef struct { - unsigned char * rgba; /**< may be NULL if no alpha */ - unsigned char * rgb; /**< may be NULL if alpha */ - size_t width; /**< width in pixels */ - size_t height; /**< height in pixels */ - size_t stride; /**< stride */ -} OggPlayOverlayData; - -/** Type for representing audio data */ -typedef void * OggPlayAudioData; - -/** Type for representing text data */ -typedef char OggPlayTextData; - -struct _OggPlayDataHeader; -/** Header for the various data formats */ -typedef struct _OggPlayDataHeader OggPlayDataHeader; - -/** - * Get the data type of the given OggPlayCallbackInfo. - * - * @param info - * @returns The data type of the given OggPlayCallbackInfo - * @see OggPlayDataType - */ -OggPlayDataType -oggplay_callback_info_get_type(OggPlayCallbackInfo *info); - -int -oggplay_callback_info_get_available(OggPlayCallbackInfo *info); - - -int -oggplay_callback_info_get_required(OggPlayCallbackInfo *info); - -/** - * Get the array of records stored in the OggPlayCallbackInfo - * - * @param info - * @returns array of records - * @retval NULL if the supplied OggPlayCallbackInfo is a NULL pointer - */ -OggPlayDataHeader ** -oggplay_callback_info_get_headers(OggPlayCallbackInfo *info); - -/** - * Get the size of the given record. - * - * @param header - * @returns The number of samples in the record. - */ -ogg_int64_t -oggplay_callback_info_get_record_size(OggPlayDataHeader *header); - -/** - * Extract the video frame from the supplied record. - * - * @param header - * @returns the video frame - * @retval NULL if the supplied OggPlayCallbackInfo is a NULL pointer - */ -OggPlayVideoData * -oggplay_callback_info_get_video_data(OggPlayDataHeader *header); - -/** - * Extract the overlay data from the supplied record. - * - * @param header - * @returns OggPlayOverlayData - * @retval NULL if the supplied OggPlayCallbackInfo is a NULL pointer - */ -OggPlayOverlayData * -oggplay_callback_info_get_overlay_data(OggPlayDataHeader *header); - -/** - * Extract the audio data from the supplied record. - * - * @param header - * @returns OggPlayAudioData. - * @retval NULL if the supplied OggPlayCallbackInfo is a NULL pointer - */ -OggPlayAudioData * -oggplay_callback_info_get_audio_data(OggPlayDataHeader *header); - -/** - * Extract the text data from the supplied record. - * - * @param header - * @returns OggPlayTextData - * @retval NULL if the supplied OggPlayCallbackInfo is a NULL pointer - */ -OggPlayTextData * -oggplay_callback_info_get_text_data(OggPlayDataHeader *header); - -/** - * Get the state of the stream. - * - * @param info - * @returns State of the given stream. - * @see OggPlayStreamInfo - */ -OggPlayStreamInfo -oggplay_callback_info_get_stream_info(OggPlayCallbackInfo *info); - - -void -oggplay_callback_info_lock_item(OggPlayDataHeader *header); - -void -oggplay_callback_info_unlock_item(OggPlayDataHeader *header); - -/** - * Get the presentation time of the given record. - * - * @param header - * @returns presentation time of the given frame in milliseconds. - */ -long -oggplay_callback_info_get_presentation_time(OggPlayDataHeader *header); - -#endif diff --git a/media/liboggplay/include/oggplay/oggplay_enums.h b/media/liboggplay/include/oggplay/oggplay_enums.h deleted file mode 100644 index eb97ab44f05..00000000000 --- a/media/liboggplay/include/oggplay/oggplay_enums.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** @file - * General constants used by liboggplay - * - * @authors - * Shane Stephens - * Michael Martin - * Viktor Gal - */ - -#ifndef __OGGPLAY_ENUMS_H__ -#define __OGGPLAY_ENUMS_H__ - -/** - * Definitions of error return values. - */ -typedef enum OggPlayErrorCode { - E_OGGPLAY_CONTINUE = 1, - E_OGGPLAY_OK = 0, /**< No error */ - E_OGGPLAY_BAD_OGGPLAY = -1, /**< supplied oggplay is not a valid OggPlay */ - E_OGGPLAY_BAD_READER = -2, /**< OggPlayReader is invalid */ - E_OGGPLAY_BAD_INPUT = -3, /**< Error in the input */ - E_OGGPLAY_NO_SUCH_CHUNK = -4, - E_OGGPLAY_BAD_TRACK = -5, /**< The requested track number does not exists */ - E_OGGPLAY_TRACK_IS_SKELETON = -6, /**< Trying to activate a Skeleton track */ - E_OGGPLAY_OGGZ_UNHAPPY = -7, /**< OGGZ error occured */ - E_OGGPLAY_END_OF_FILE = -8, /**< End of file */ - E_OGGPLAY_TRACK_IS_OVER = -9, /**< A given track has ended */ - E_OGGPLAY_BAD_CALLBACK_INFO = -10, /**< Invalid OggPlayCallbackInfo */ - E_OGGPLAY_WRONG_TRACK_TYPE = -11, /**< */ - E_OGGPLAY_UNINITIALISED = -12, /**< The OggPlay handle is not initialised */ - E_OGGPLAY_CALLBACK_MODE = -13, /**< OggPlay is used in callback mode */ - E_OGGPLAY_BUFFER_MODE = -14, /**< OggPlay is used in buffer mode */ - E_OGGPLAY_USER_INTERRUPT = -15, /**< User interrupt received */ - E_OGGPLAY_SOCKET_ERROR = -16, /**< Error while creating socket */ - E_OGGPLAY_TIMEOUT = -17, /**< TCP connection timeouted */ - E_OGGPLAY_CANT_SEEK = -18, /**< Could not performed the requested seek */ - E_OGGPLAY_NO_KATE_SUPPORT = -19, /**< LibKate is not supported */ - E_OGGPLAY_NO_TIGER_SUPPORT = -20, /**< LibTiger is not supported */ - E_OGGPLAY_OUT_OF_MEMORY = -21, /**< Out of memory */ - E_OGGPLAY_TYPE_OVERFLOW = -22, /**< Integer overflow detected */ - E_OGGPLAY_TRACK_IS_UNKNOWN = -23, /**< The selected track's content type is UNKNOWN */ - E_OGGPLAY_TRACK_UNINITIALISED = -24, /**< Track is not initialised, i.e. bad headers or haven't seen them */ - E_OGGPLAY_NOTCHICKENPAYBACK = -777 -} OggPlayErrorCode; - -/** - * Definitions of the various record types - */ -typedef enum OggPlayDataType { - OGGPLAY_INACTIVE = -1, /**< record is inactive */ - OGGPLAY_YUV_VIDEO = 0, /**< record is a YUV format video */ - OGGPLAY_RGBA_VIDEO = 1, /**< record is a video in RGB format */ - OGGPLAY_SHORTS_AUDIO = 1000, /**< audio record in short format */ - OGGPLAY_FLOATS_AUDIO = 1001, /**< audio record in float format */ - OGGPLAY_CMML = 2000, /**< CMML record */ - OGGPLAY_KATE = 3000, /**< KATE record */ - OGGPLAY_TYPE_UNKNOWN = 9000 /**< content type of the record is unknown */ -} OggPlayDataType; - -/** - * Definitions of the various states of a stream. - */ -typedef enum OggPlayStreamInfo { - OGGPLAY_STREAM_UNINITIALISED = 0, /**< Stream is not initialised */ - OGGPLAY_STREAM_FIRST_DATA = 1, /**< Stream received it's first data frame */ - OGGPLAY_STREAM_INITIALISED = 2, /**< Stream is initialised */ - OGGPLAY_STREAM_LAST_DATA = 3, /**< Stream received it's last data frame */ - OGGPLAY_STREAM_JUST_SEEKED = 4 /**< We've just seeked in the stream */ -} OggPlayStreamInfo; - -#endif diff --git a/media/liboggplay/include/oggplay/oggplay_query.h b/media/liboggplay/include/oggplay/oggplay_query.h deleted file mode 100644 index ce15b914cfd..00000000000 --- a/media/liboggplay/include/oggplay/oggplay_query.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** @file - * oggplay_query.h - * - * @authors - * Shane Stephens - * Viktor Gal - */ - -#ifndef __OGGPLAY_QUERY_H__ -#define __OGGPLAY_QUERY_H__ - -#include - -/** - * Get the number of tracks in the Ogg container. - * - * @param me OggPlay handle - * @retval "> 0" number of tracks - * @retval E_OGGPLAY_BAD_OGGPLAY the supplied OggPlay - * @retval E_OGGPLAY_BAD_READER - * @retval E_OGGPLAY_UNINITIALISED the is not initialised. - */ -int -oggplay_get_num_tracks (OggPlay * me); - -/** - * Retrieve the type of a track. - * - * @param me OggPlay handle - * @param track_num the desired track's number - * @retval "> 0" the track's type (see OggzStreamContent) - * @retval "< 0" error occured - */ -OggzStreamContent -oggplay_get_track_type (OggPlay * me, int track_num); - -/** - * Get a track's type name. - * - * @param me OggPlay handle - * @param track_num the desired track's number - * @retval typa name of the track - * @retval NULL in case of error. - */ -const char * -oggplay_get_track_typename (OggPlay * me, int track_num); - -/** - * Set a track active. - * - * @param me OggPlay handle - * @param track_num the desired track's number for activation - * @retval E_OGGPLAY_OK on success - * @retval E_OGGPLAY_BAD_OGGPLAY the supplied OggPlay is invalid - * @retval E_OGGPLAY_BAD_READER the OggPlayReader associated with the Ogg - * container is invalid - * @retval E_OGGPLAY_UNINITIALISED the tracks are not initialised - * @retval E_OGGPLAY_BAD_TRACK invalid track number - * @retval E_OGGPLAY_TRACK_IS_SKELETON the chosen track is a Skeleton track - * @retval E_OGGPLAY_TRACK_IS_UNKNOWN the chosen track's content type is unknown - * @retval E_OGGPLAY_TRACK_UNINITIALISED the chosen track was not initialised - * @retval E_OGGPLAY_TRACK_IS_OVER the track is over. - */ -OggPlayErrorCode -oggplay_set_track_active(OggPlay *me, int track_num); - -/** - * Inactivate a given track. - * - * @param me OggPlay handle - * @param track_num the desired track's number for inactivation - * @retval E_OGGPLAY_OK on success - * @retval E_OGGPLAY_BAD_OGGPLAY the supplied OggPlay is invalid - * @retval E_OGGPLAY_BAD_READER the OggPlayReader associated with the Ogg - * container is invalid - * @retval E_OGGPLAY_UNINITIALISED the tracks are not initialised - * @retval E_OGGPLAY_BAD_TRACK invalid track number - * @retval E_OGGPLAY_TRACK_IS_SKELETON the chosen track is a Skeleton track - * @retval E_OGGPLAY_TRACK_IS_UNKNOWN the chosen track's content type is unknown - */ -OggPlayErrorCode -oggplay_set_track_inactive(OggPlay *me, int track_num); - -#endif diff --git a/media/liboggplay/include/oggplay/oggplay_reader.h b/media/liboggplay/include/oggplay/oggplay_reader.h deleted file mode 100644 index fdf45357dc9..00000000000 --- a/media/liboggplay/include/oggplay/oggplay_reader.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** @file - * oggplay_reader.h - * - * @authors - * Shane Stephens - * Michael Martin - */ - -#ifndef __OGGPLAY_READER_H__ -#define __OGGPLAY_READER_H__ - -#include -#include -#include - -struct _OggPlayReader; - -/** */ -typedef struct _OggPlayReader { - OggPlayErrorCode (*initialise) (struct _OggPlayReader * me, int block); - OggPlayErrorCode (*destroy) (struct _OggPlayReader * me); - OggPlayErrorCode (*seek) (struct _OggPlayReader *me, OGGZ *oggz, - ogg_int64_t milliseconds); - int (*available) (struct _OggPlayReader *me, - ogg_int64_t current_bytes, - ogg_int64_t current_time); - ogg_int64_t (*duration) (struct _OggPlayReader *me); - int (*finished_retrieving)(struct _OggPlayReader *me); - - /* low-level io functions for oggz */ - size_t (*io_read)(void *user_handle, void *buf, size_t n); - int (*io_seek)(void *user_handle, long offset, int whence); - long (*io_tell)(void *user_handle); -} OggPlayReader; - -/** - * Create and initialise an OggPlayReader for a given Ogg file. - * - * @param filename The file to open - * @return A new OggPlayReader handle - * @retval NULL if error occured. - */ -OggPlayReader * -oggplay_file_reader_new(const char *filename); - -/** - * Create and initialise an OggPlayReader for an Ogg content at a given URI. - * - * @param uri The URI to the Ogg file. - * @param proxy Proxy - * @param proxy_port Proxy port. - * @return A new OggPlayReader handle - * @retval NULL on error. - */ -OggPlayReader * -oggplay_tcp_reader_new(const char *uri, const char *proxy, int proxy_port); - -#endif diff --git a/media/liboggplay/include/oggplay/oggplay_seek.h b/media/liboggplay/include/oggplay/oggplay_seek.h deleted file mode 100644 index 36d5fd6734a..00000000000 --- a/media/liboggplay/include/oggplay/oggplay_seek.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** @file - * oggplay_seek.h - * - * @authors - * Shane Stephens - */ - -#ifndef __OGGPLAY_SEEK_H__ -#define __OGGPLAY_SEEK_H__ - -/** - * Seeks to a requested position. - * - * @param me OggPlay handle associated with the stream - * @param milliseconds - * @retval E_OGGPLAY_OK on success - * @retval E_OGGPLAY_BAD_OGGPLAY the supplied OggPlay handle was invalid - * @retval E_OGGPLAY_CANT_SEEK error occured while trying to seek - * @retval E_OGGPLAY_OUT_OF_MEMORY ran out of memory while trying to allocate the new buffer and trash. - */ -OggPlayErrorCode -oggplay_seek(OggPlay *me, ogg_int64_t milliseconds); - -/** - * Seeks to key frame before |milliseconds|. - */ -OggPlayErrorCode -oggplay_seek_to_keyframe(OggPlay *me, - ogg_int64_t milliseconds, - ogg_int64_t offset_begin, - ogg_int64_t offset_end); - -#endif diff --git a/media/liboggplay/include/oggplay/oggplay_tools.h b/media/liboggplay/include/oggplay/oggplay_tools.h deleted file mode 100644 index 4ee4fa75687..00000000000 --- a/media/liboggplay/include/oggplay/oggplay_tools.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** @file - * oggplay_tools.h - * - * @authors - * Shane Stephens - * Michael Martin - */ - -#ifndef __OGGPLAY_TOOLS_H__ -#define __OGGPLAY_TOOLS_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef WIN32 -#include -#else -#include -#include -#endif - -/** structure holds pointers to y, u, v channels */ -typedef struct _OggPlayYUVChannels { - unsigned char * ptry; /**< Y channel */ - unsigned char * ptru; /**< U channel */ - unsigned char * ptrv; /**< V channel*/ - int y_width; /**< the width of the Y plane */ - int y_height; /**< the height of the Y plane */ - int uv_width; /**< the width of the U/V plane */ - int uv_height; /**< the height of the U/V plane*/ -} OggPlayYUVChannels; - -/** structure holds pointers to RGB packets */ -typedef struct _OggPlayRGBChannels { - unsigned char * ptro; /**< the RGB stream in the requested packaging format */ - int rgb_width; /**< width of the RGB frame */ - int rgb_height; /**< height of the RGB frame */ -} OggPlayRGBChannels; - - -void -oggplay_yuv2rgba(const OggPlayYUVChannels *yuv, OggPlayRGBChannels * rgb); - -void -oggplay_yuv2bgra(const OggPlayYUVChannels* yuv, OggPlayRGBChannels * rgb); - -void -oggplay_yuv2argb(const OggPlayYUVChannels *yuv, OggPlayRGBChannels * rgb); - -ogg_int64_t -oggplay_sys_time_in_ms(void); - -void -oggplay_millisleep(long ms); - -#ifdef __cplusplus -} -#endif - -#endif /*__OGGPLAY_TOOLS_H__*/ - diff --git a/media/liboggplay/liboggplay-199a8cea6c4fd6d.patch b/media/liboggplay/liboggplay-199a8cea6c4fd6d.patch deleted file mode 100644 index 57067f9dd85..00000000000 --- a/media/liboggplay/liboggplay-199a8cea6c4fd6d.patch +++ /dev/null @@ -1,50 +0,0 @@ -commit 199a8cea6c4fd6d765254e7a384ac9df21ee2656 -Author: Viktor Gal -Date: Fri May 8 15:44:51 2009 +1000 - - In the commit of 34c82de a bug was introduced in 'oggplay_data_handle_audio_data' function: - the number of samples in the record was not the correct value! The value of it - was incorrectly the size of the samples in the record. - -diff --git a/src/liboggplay/oggplay_data.c b/src/liboggplay/oggplay_data.c -index 4df5275..9376938 100644 ---- a/src/liboggplay/oggplay_data.c -+++ b/src/liboggplay/oggplay_data.c -@@ -301,6 +301,7 @@ oggplay_data_handle_audio_data (OggPlayDecode *decode, void *data, - - int num_channels, ret; - size_t record_size = sizeof(OggPlayAudioRecord); -+ long samples_size; - OggPlayAudioRecord * record = NULL; - - num_channels = ((OggPlayAudioDecode *)decode)->sound_info.channels; -@@ -310,17 +311,17 @@ oggplay_data_handle_audio_data (OggPlayDecode *decode, void *data, - return E_OGGPLAY_TYPE_OVERFLOW; - } - -- ret = oggplay_mul_signed_overflow (samples, num_channels, &samples); -+ ret = oggplay_mul_signed_overflow (samples, num_channels, &samples_size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - -- ret = oggplay_mul_signed_overflow (samples, samplesize, &samples); -+ ret = oggplay_mul_signed_overflow (samples_size, samplesize, &samples_size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - -- ret = oggplay_check_add_overflow (record_size, samples, &record_size); -+ ret = oggplay_check_add_overflow (record_size, samples_size, &record_size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } -@@ -339,7 +340,7 @@ oggplay_data_handle_audio_data (OggPlayDecode *decode, void *data, - record->data = (void *)(record + 1); - - /* copy the received data - the header has been initialised! */ -- memcpy (record->data, data, samples); -+ memcpy (record->data, data, samples_size); - /* - printf("[%f%f%f]\n", ((float *)record->data)[0], ((float *)record->data)[1], - ((float *)record->data)[2]); diff --git a/media/liboggplay/oggplay_os2.patch b/media/liboggplay/oggplay_os2.patch deleted file mode 100644 index 32b636b8bb4..00000000000 --- a/media/liboggplay/oggplay_os2.patch +++ /dev/null @@ -1,304 +0,0 @@ -diff --git a/media/liboggplay/src/liboggplay/oggplay_private.h b/media/liboggplay/src/liboggplay/oggplay_private.h ---- a/media/liboggplay/src/liboggplay/oggplay_private.h -+++ b/media/liboggplay/src/liboggplay/oggplay_private.h -@@ -62,16 +62,22 @@ - - #ifdef WIN32 - - #ifdef HAVE_WINSOCK2 - #include - #else - #include - #endif -+#endif -+ -+#ifdef OS2 -+#define INCL_DOSSEMAPHORES -+#define INCL_DOSPROCESS -+#include - #endif - - // for Win32 has to be included last - #include "std_semaphore.h" - - /** - * - * has_been_presented: 0 until the data has been added as a "required" element, -diff --git a/media/liboggplay/src/liboggplay/oggplay_tools.c b/media/liboggplay/src/liboggplay/oggplay_tools.c ---- a/media/liboggplay/src/liboggplay/oggplay_tools.c -+++ b/media/liboggplay/src/liboggplay/oggplay_tools.c -@@ -53,15 +53,17 @@ oggplay_sys_time_in_ms(void) { - return (ogg_int64_t)tv.tv_sec * 1000 + (ogg_int64_t)tv.tv_usec / 1000; - #endif - } - - void - oggplay_millisleep(long ms) { - #ifdef WIN32 - Sleep(ms); -+#elif defined(OS2) -+ DosSleep(ms); - #else - struct timespec ts = {0, (ogg_int64_t)ms * 1000000LL}; - nanosleep(&ts, NULL); - #endif - } - - -diff --git a/media/liboggplay/src/liboggplay/os2_semaphore.c b/media/liboggplay/src/liboggplay/os2_semaphore.c -new file mode 100644 ---- /dev/null -+++ b/media/liboggplay/src/liboggplay/os2_semaphore.c -@@ -0,0 +1,163 @@ -+/* ***** BEGIN LICENSE BLOCK ***** -+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1 -+ * -+ * The contents of this file are subject to the Mozilla Public License Version -+ * 1.1 (the "License"); you may not use this file except in compliance with -+ * the License. You may obtain a copy of the License at -+ * http://www.mozilla.org/MPL/ -+ * -+ * Software distributed under the License is distributed on an "AS IS" basis, -+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -+ * for the specific language governing rights and limitations under the -+ * License. -+ * -+ * The Original Code is the Mozilla browser. -+ * -+ * The Initial Developer of the Original Code is -+ * Richard Walsh -+ * Portions created by the Initial Developer are Copyright (c) 2008 -+ * the Initial Developer. All Rights Reserved. -+ * -+ * Contributor(s): -+ * -+ * Alternatively, the contents of this file may be used under the terms of -+ * either the GNU General Public License Version 2 or later (the "GPL"), or -+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -+ * in which case the provisions of the GPL or the LGPL are applicable instead -+ * of those above. If you wish to allow use of your version of this file only -+ * under the terms of either the GPL or the LGPL, and not to allow others to -+ * use your version of this file under the terms of the MPL, indicate your -+ * decision by deleting the provisions above and replace them with the notice -+ * and other provisions required by the GPL or the LGPL. If you do not delete -+ * the provisions above, a recipient may use your version of this file under -+ * the terms of any one of the MPL, the GPL or the LGPL. -+ * -+ * ***** END LICENSE BLOCK ***** * -+ */ -+/*****************************************************************************/ -+/* -+ * This is a conservative implementation of a posix counting semaphore. -+ * It relies on the state of the underlying OS/2 event semaphore to -+ * control whether sem_wait() blocks or returns immediately, and only -+ * uses its count to change the sem's state from posted to reset. -+ * (A more "activist" approach would use the count to decide whether -+ * to return immediately or to call DosWaitEventSem().) -+ * -+ */ -+/*****************************************************************************/ -+ -+#include -+#define INCL_DOS -+#include -+#include "os2_semaphore.h" -+ -+#ifndef ERROR_SEM_BUSY -+#define ERROR_SEM_BUSY 301 -+#endif -+ -+#define SEM_WAIT 20000 -+ -+/*****************************************************************************/ -+ -+int sem_init(sem_t *sem, int pshared, unsigned value) -+{ -+ OS2SEM * psem; -+ -+ if (!sem) -+ return -1; -+ *sem = 0; -+ -+ psem = (OS2SEM*)malloc(sizeof(OS2SEM)); -+ if (!psem) -+ return -1; -+ -+ if (DosCreateMutexSem(0, &psem->hmtx, 0, 0)) { -+ free(psem); -+ return -1; -+ } -+ -+ if (DosCreateEventSem(0, &psem->hev, 0, (value ? 1 : 0))) { -+ DosCloseMutexSem(psem->hmtx); -+ free(psem); -+ return -1; -+ } -+ -+ psem->cnt = value; -+ *sem = psem; -+ return 0; -+} -+ -+/*****************************************************************************/ -+ -+int sem_wait(sem_t *sem) -+{ -+ OS2SEM * psem; -+ ULONG cnt; -+ -+ if (!sem || !*sem) -+ return -1; -+ psem = *sem; -+ -+ if (DosWaitEventSem(psem->hev, -1)) -+ return -1; -+ -+ if (DosRequestMutexSem(psem->hmtx, SEM_WAIT)) -+ return -1; -+ -+ if (psem->cnt) -+ psem->cnt--; -+ if (!psem->cnt) -+ DosResetEventSem(psem->hev, &cnt); -+ DosReleaseMutexSem(psem->hmtx); -+ -+ return 0; -+} -+ -+/*****************************************************************************/ -+ -+int sem_post(sem_t *sem) -+{ -+ OS2SEM * psem; -+ -+ if (!sem || !*sem) -+ return -1; -+ psem = *sem; -+ -+ if (!DosRequestMutexSem(psem->hmtx, SEM_WAIT)) { -+ psem->cnt++; -+ DosPostEventSem(psem->hev); -+ DosReleaseMutexSem(psem->hmtx); -+ return 0; -+ } -+ -+ return -1; -+} -+ -+/*****************************************************************************/ -+ -+int sem_destroy(sem_t *sem) -+{ -+ OS2SEM * psem; -+ -+ if (!sem || !*sem) -+ return -1; -+ psem = *sem; -+ -+ if (DosCloseMutexSem(psem->hmtx) == ERROR_SEM_BUSY) { -+ DosRequestMutexSem(psem->hmtx, SEM_WAIT); -+ DosReleaseMutexSem(psem->hmtx); -+ DosCloseMutexSem(psem->hmtx); -+ } -+ -+ if (DosCloseEventSem(psem->hev) == ERROR_SEM_BUSY) { -+ DosPostEventSem(psem->hev); -+ DosSleep(1); -+ DosCloseEventSem(psem->hev); -+ } -+ -+ free(psem); -+ return 0; -+} -+ -+/*****************************************************************************/ -+ -diff --git a/media/liboggplay/src/liboggplay/os2_semaphore.h b/media/liboggplay/src/liboggplay/os2_semaphore.h -new file mode 100644 ---- /dev/null -+++ b/media/liboggplay/src/liboggplay/os2_semaphore.h -@@ -0,0 +1,57 @@ -+/* ***** BEGIN LICENSE BLOCK ***** -+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1 -+ * -+ * The contents of this file are subject to the Mozilla Public License Version -+ * 1.1 (the "License"); you may not use this file except in compliance with -+ * the License. You may obtain a copy of the License at -+ * http://www.mozilla.org/MPL/ -+ * -+ * Software distributed under the License is distributed on an "AS IS" basis, -+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -+ * for the specific language governing rights and limitations under the -+ * License. -+ * -+ * The Original Code is the Mozilla browser. -+ * -+ * The Initial Developer of the Original Code is -+ * Richard Walsh -+ * Portions created by the Initial Developer are Copyright (c) 2008 -+ * the Initial Developer. All Rights Reserved. -+ * -+ * Contributor(s): -+ * -+ * Alternatively, the contents of this file may be used under the terms of -+ * either the GNU General Public License Version 2 or later (the "GPL"), or -+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -+ * in which case the provisions of the GPL or the LGPL are applicable instead -+ * of those above. If you wish to allow use of your version of this file only -+ * under the terms of either the GPL or the LGPL, and not to allow others to -+ * use your version of this file under the terms of the MPL, indicate your -+ * decision by deleting the provisions above and replace them with the notice -+ * and other provisions required by the GPL or the LGPL. If you do not delete -+ * the provisions above, a recipient may use your version of this file under -+ * the terms of any one of the MPL, the GPL or the LGPL. -+ * -+ * ***** END LICENSE BLOCK ***** * -+ */ -+/*****************************************************************************/ -+ -+#ifndef _os2_semaphore_ -+#define _os2_semaphore_ -+ -+typedef struct _OS2SEM { -+ HMTX hmtx; -+ HEV hev; -+ ULONG cnt; -+} OS2SEM; -+ -+typedef OS2SEM * sem_t; -+ -+int sem_init(sem_t *sem, int pshared, unsigned value); -+int sem_wait(sem_t *sem); -+int sem_post(sem_t *sem); -+int sem_destroy(sem_t *sem); -+ -+#endif -+/*****************************************************************************/ -+ -diff --git a/media/liboggplay/src/liboggplay/std_semaphore.h b/media/liboggplay/src/liboggplay/std_semaphore.h ---- a/media/liboggplay/src/liboggplay/std_semaphore.h -+++ b/media/liboggplay/src/liboggplay/std_semaphore.h -@@ -83,16 +83,23 @@ typedef sem_t semaphore; - typedef sem_t semaphore; - #elif defined(WIN32) - #include - #define SEM_CREATE(p,s) (!(p = CreateSemaphore(NULL, (long)(s), (long)(s), NULL))) - #define SEM_SIGNAL(p) (!ReleaseSemaphore(p, 1, NULL)) - #define SEM_WAIT(p) WaitForSingleObject(p, INFINITE) - #define SEM_CLOSE(p) (!CloseHandle(p)) - typedef HANDLE semaphore; -+#elif defined(OS2) -+#include "os2_semaphore.h" -+#define SEM_CREATE(p,s) sem_init(&(p), 1, s) -+#define SEM_SIGNAL(p) sem_post(&(p)) -+#define SEM_WAIT(p) sem_wait(&(p)) -+#define SEM_CLOSE(p) sem_destroy(&(p)) -+typedef sem_t semaphore; - #elif defined(__APPLE__) - #include - #define SEM_CREATE(p,s) MPCreateSemaphore(s, s, &(p)) - #define SEM_SIGNAL(p) MPSignalSemaphore(p) - #define SEM_WAIT(p) MPWaitOnSemaphore(p, kDurationForever) - #define SEM_CLOSE(p) MPDeleteSemaphore(p) - typedef MPSemaphoreID semaphore; - #endif diff --git a/media/liboggplay/seek_to_key_frame.patch b/media/liboggplay/seek_to_key_frame.patch deleted file mode 100644 index 980e02d5499..00000000000 --- a/media/liboggplay/seek_to_key_frame.patch +++ /dev/null @@ -1,87 +0,0 @@ -diff --git a/media/liboggplay/include/oggplay/oggplay_seek.h b/media/liboggplay/include/oggplay/oggplay_seek.h ---- a/media/liboggplay/include/oggplay/oggplay_seek.h -+++ b/media/liboggplay/include/oggplay/oggplay_seek.h -@@ -48,9 +48,20 @@ - * @retval E_OGGPLAY_OK on success - * @retval E_OGGPLAY_BAD_OGGPLAY the supplied OggPlay handle was invalid - * @retval E_OGGPLAY_CANT_SEEK error occured while trying to seek - * @retval E_OGGPLAY_OUT_OF_MEMORY ran out of memory while trying to allocate the new buffer and trash. - */ - OggPlayErrorCode - oggplay_seek(OggPlay *me, ogg_int64_t milliseconds); - -+/** -+ * Seeks to key frame before |milliseconds|. -+ */ -+OggPlayErrorCode -+oggplay_seek_to_keyframe(OggPlay *me, -+ int* tracks, -+ int num_tracks, -+ ogg_int64_t milliseconds, -+ ogg_int64_t offset_begin, -+ ogg_int64_t offset_end); -+ - #endif -diff --git a/media/liboggplay/src/liboggplay/oggplay_seek.c b/media/liboggplay/src/liboggplay/oggplay_seek.c ---- a/media/liboggplay/src/liboggplay/oggplay_seek.c -+++ b/media/liboggplay/src/liboggplay/oggplay_seek.c -@@ -183,8 +183,59 @@ oggplay_take_out_trash(OggPlay *me, OggP - } - p = trash; - } - - if (p != NULL) { - oggplay_free(p); - } - } -+ -+OggPlayErrorCode -+oggplay_seek_to_keyframe(OggPlay *me, -+ int* tracks, -+ int num_tracks, -+ ogg_int64_t milliseconds, -+ ogg_int64_t offset_begin, -+ ogg_int64_t offset_end) -+{ -+ long *serial_nos; -+ int i; -+ ogg_int64_t eof, time; -+ -+ if (me == NULL) { -+ return E_OGGPLAY_BAD_OGGPLAY; -+ } -+ -+ if (num_tracks > me->num_tracks || milliseconds < 0) -+ return E_OGGPLAY_CANT_SEEK; -+ -+ eof = oggplay_get_duration(me); -+ if (eof > -1 && milliseconds > eof) { -+ return E_OGGPLAY_CANT_SEEK; -+ } -+ -+ // Get the serialnos for the tracks we're seeking. -+ serial_nos = (long*)oggplay_malloc(sizeof(long)*num_tracks); -+ if (!serial_nos) { -+ return E_OGGPLAY_CANT_SEEK; -+ } -+ for (i=0; idecode_data[tracks[i]]->serialno; -+ } -+ -+ time = oggz_keyframe_seek_set(me->oggz, -+ serial_nos, -+ num_tracks, -+ milliseconds, -+ offset_begin, -+ offset_end); -+ oggplay_free(serial_nos); -+ -+ if (time == -1) { -+ return E_OGGPLAY_CANT_SEEK; -+ } -+ -+ oggplay_seek_cleanup(me, time); -+ -+ return E_OGGPLAY_OK; -+ -+} diff --git a/media/liboggplay/src/Makefile.in b/media/liboggplay/src/Makefile.in deleted file mode 100644 index 756590266e6..00000000000 --- a/media/liboggplay/src/Makefile.in +++ /dev/null @@ -1,47 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = oggplay -DIRS = liboggplay - -include $(topsrcdir)/config/rules.mk diff --git a/media/liboggplay/src/liboggplay/Makefile.in b/media/liboggplay/src/liboggplay/Makefile.in deleted file mode 100644 index b5317688481..00000000000 --- a/media/liboggplay/src/liboggplay/Makefile.in +++ /dev/null @@ -1,81 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -DEFINES += -DHAVE_CONFIG_H - -MODULE = oggplay -LIBRARY_NAME = oggplay -FORCE_STATIC_LIB= 1 - -EXPORTS = \ - oggplay_buffer.h \ - oggplay_callback.h \ - oggplay_data.h \ - std_semaphore.h \ - $(NULL) - -CSRCS = \ - oggplay.c \ - oggplay_callback.c \ - oggplay_query.c \ - oggplay_data.c \ - oggplay_callback_info.c \ - oggplay_buffer.c \ - oggplay_seek.c \ - oggplay_yuv2rgb.c \ - oggplay_tools.c \ - $(NULL) - -ifeq ($(OS_ARCH),OS2) -EXPORTS += \ - os2_semaphore.h \ - $(NULL) - -CSRCS += \ - os2_semaphore.c \ - $(NULL) -endif - -include $(topsrcdir)/config/rules.mk - -LOCAL_INCLUDES += -I$(srcdir)/../../include/oggplay diff --git a/media/liboggplay/src/liboggplay/config.h b/media/liboggplay/src/liboggplay/config.h deleted file mode 100644 index 66a0522e714..00000000000 --- a/media/liboggplay/src/liboggplay/config.h +++ /dev/null @@ -1,115 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define if building universal (internal helper macro) */ -/* #undef AC_APPLE_UNIVERSAL_BUILD */ - -/* Maximum supported data alignment */ - - -/* Define to 1 if you have the `assert' function. */ -/* #undef HAVE_ASSERT */ - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define if have libfishsound */ -#define HAVE_FISHSOUND /**/ - -/* Define if we have GLUT. */ -/* #undef HAVE_GLUT */ - -/* Define if have Imlib2 */ -/* #undef HAVE_IMLIB2 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define if have libkate */ -/* #undef HAVE_KATE */ - -/* Define if have libsndfile */ -/* #undef HAVE_LIBSNDFILE1 */ - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define if have liboggz */ -#define HAVE_OGGZ /**/ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define if have libtiger */ -/* #undef HAVE_TIGER */ - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -/* #undef NO_MINUS_C_MINUS_O */ - -/* Name of package */ -#define PACKAGE "liboggplay" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "0.2.0" - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -/* # undef WORDS_BIGENDIAN */ -# endif -#endif - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ -#undef HAVE_GLUT - -#include "prcpucfg.h" -#ifdef IS_BIG_ENDIAN -#define WORDS_BIGENDIAN 1 -#endif - diff --git a/media/liboggplay/src/liboggplay/cpu.c b/media/liboggplay/src/liboggplay/cpu.c deleted file mode 100644 index 19a2f1601b4..00000000000 --- a/media/liboggplay/src/liboggplay/cpu.c +++ /dev/null @@ -1,284 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2008 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - - CPU capability detection for x86 processors. - Originally written by Rudolf Marek. - - function: - last mod: $Id$ - - ********************************************************************/ - -#include "cpu.h" - -/* for detecting AltiVec support */ -# if (defined(__ppc__) || defined(__ppc64__)) -# if defined(__APPLE__) || defined(__MACOSX__) -#include -# else -#include -#include -# endif -# endif - -# if (defined(__ppc__) || defined(__ppc64__)) && !(defined(__APPLE__) || defined(__MACOSX__)) -static jmp_buf jmpbuf; - -static void illegal_instruction(int sig) -{ - longjmp(jmpbuf, 1); -} -# endif - -#if defined(i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_AMD64) -# if !defined(_MSC_VER) -# if defined(__amd64__)||defined(__x86_64__) -/*On x86-64, gcc seems to be able to figure out how to save %rbx for us when - compiling with -fPIC.*/ -# define cpuid(_op,_eax,_ebx,_ecx,_edx) \ - __asm__ __volatile__( \ - "cpuid\n\t" \ - :[eax]"=a"(_eax),[ebx]"=b"(_ebx),[ecx]"=c"(_ecx),[edx]"=d"(_edx) \ - :"a"(_op) \ - :"cc" \ - ) -# else -/*On x86-32, not so much.*/ -# define cpuid(_op,_eax,_ebx,_ecx,_edx) \ - __asm__ __volatile__( \ - "xchgl %%ebx,%[ebx]\n\t" \ - "cpuid\n\t" \ - "xchgl %%ebx,%[ebx]\n\t" \ - :[eax]"=a"(_eax),[ebx]"=r"(_ebx),[ecx]"=c"(_ecx),[edx]"=d"(_edx) \ - :"a"(_op) \ - :"cc" \ - ) -# endif -# else -# if defined(_M_IX86) -/*Why does MSVC need this complicated rigamarole? - At this point I honestly do not care.*/ - -/*Visual C cpuid helper function. - For VS2005 we could as well use the _cpuid builtin, but that wouldn't work - for VS2003 users, so we do it in inline assembler.*/ -static void oc_cpuid_helper(ogg_uint32_t _cpu_info[4],ogg_uint32_t _op){ - _asm { - mov eax,[_op] - mov esi,_cpu_info - cpuid - mov [esi+0],eax - mov [esi+4],ebx - mov [esi+8],ecx - mov [esi+12],edx - } -} - -# define cpuid(_op,_eax,_ebx,_ecx,_edx) \ - do{ \ - ogg_uint32_t cpu_info[4]; \ - oc_cpuid_helper(cpu_info,_op); \ - (_eax)=cpu_info[0]; \ - (_ebx)=cpu_info[1]; \ - (_ecx)=cpu_info[2]; \ - (_edx)=cpu_info[3]; \ - }while(0) - -static void oc_detect_cpuid_helper(ogg_uint32_t *_eax,ogg_uint32_t *_ebx){ - _asm{ - pushfd - pushfd - pop eax - mov ebx,eax - xor eax,200000h - push eax - popfd - pushfd - pop eax - popfd - mov ecx,_eax - mov [ecx],eax - mov ecx,_ebx - mov [ecx],ebx - } -} -# elif defined(_M_AMD64) -# include -# define cpuid(_op,_eax,_ebx,_ecx,_edx) \ - do{ \ - int cpu_info[4]; \ - __cpuid(cpu_info,_op); \ - (_eax)=cpu_info[0]; \ - (_ebx)=cpu_info[1]; \ - (_ecx)=cpu_info[2]; \ - (_edx)=cpu_info[3]; \ - }while(0) -# endif -# endif -#endif /* x86-only cpuid */ - -static ogg_uint32_t oc_parse_intel_flags(ogg_uint32_t _edx,ogg_uint32_t _ecx){ - ogg_uint32_t flags; - /*If there isn't even MMX, give up.*/ - if(!(_edx&0x00800000))return 0; - flags=OC_CPU_X86_MMX; - if(_edx&0x02000000)flags|=OC_CPU_X86_MMXEXT|OC_CPU_X86_SSE; - if(_edx&0x04000000)flags|=OC_CPU_X86_SSE2; - if(_ecx&0x00000001)flags|=OC_CPU_X86_PNI; - if(_ecx&0x00000100)flags|=OC_CPU_X86_SSSE3; - if(_ecx&0x00080000)flags|=OC_CPU_X86_SSE4_1; - if(_ecx&0x00100000)flags|=OC_CPU_X86_SSE4_2; - return flags; -} - -static ogg_uint32_t oc_parse_amd_flags(ogg_uint32_t _edx,ogg_uint32_t _ecx){ - ogg_uint32_t flags; - /*If there isn't even MMX, give up.*/ - if(!(_edx&0x00800000))return 0; - flags=OC_CPU_X86_MMX; - if(_edx&0x00400000)flags|=OC_CPU_X86_MMXEXT; - if(_edx&0x80000000)flags|=OC_CPU_X86_3DNOW; - if(_edx&0x40000000)flags|=OC_CPU_X86_3DNOWEXT; - if(_ecx&0x00000040)flags|=OC_CPU_X86_SSE4A; - if(_ecx&0x00000800)flags|=OC_CPU_X86_SSE5; - return flags; -} - -static ogg_uint32_t oc_cpu_flags_get(void){ - ogg_uint32_t flags = 0; -# if defined(__ppc__) || defined(__ppc64__) -/* detect AltiVec extension if compiling it for ppc */ -# if defined(__APPLE__) || defined(__MACOSX__) || defined(__DARWIN__) - int selectors[2] = { CTL_HW, HW_VECTORUNIT }; - int i_has_altivec = 0; - size_t i_length = sizeof( i_has_altivec ); - int i_error = sysctl( selectors, 2, &i_has_altivec, &i_length, NULL, 0); - - if( i_error == 0 && i_has_altivec != 0 ) - flags |= OC_CPU_PPC_ALTIVEC; -# else - void (*handler) (int sig); - handler = signal(SIGILL, illegal_instruction); - if (setjmp(jmpbuf) == 0) - { - __asm__ __volatile__ ( - "mtspr 256, %0\n\t" - "vand %%v0, %%v0, %%v0" - : : "r"(-1) ); - - flags |= OC_CPU_PPC_ALTIVEC; - } - signal(SIGILL, handler); -# endif -/* detect x86 CPU extensions */ -# elif defined(i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_AMD64) - ogg_uint32_t eax; - ogg_uint32_t ebx; - ogg_uint32_t ecx; - ogg_uint32_t edx; -# if !defined(__amd64__)&&!defined(__x86_64__)&&!defined(_M_AMD64) - /*Not all x86-32 chips support cpuid, so we have to check.*/ -# if !defined(_MSC_VER) - __asm__ __volatile__( - "pushfl\n\t" - "pushfl\n\t" - "popl %[a]\n\t" - "movl %[a],%[b]\n\t" - "xorl $0x200000,%[a]\n\t" - "pushl %[a]\n\t" - "popfl\n\t" - "pushfl\n\t" - "popl %[a]\n\t" - "popfl\n\t" - :[a]"=r"(eax),[b]"=r"(ebx) - : - :"cc" - ); -# else - oc_detect_cpuid_helper(&eax,&ebx); -# endif - /*No cpuid.*/ - if(eax==ebx)return 0; -# endif - cpuid(0,eax,ebx,ecx,edx); - /* l e t n I e n i u n e G*/ - if((ecx==0x6C65746E&&edx==0x49656E69&&ebx==0x756E6547)|| - /* 6 8 x M T e n i u n e G*/ - (ecx==0x3638784D&&edx==0x54656E69&&ebx==0x756E6547)) { - /*Intel, Transmeta (tested with Crusoe TM5800):*/ - cpuid(1,eax,ebx,ecx,edx); - flags=oc_parse_intel_flags(edx,ecx); - } - /* D M A c i t n e h t u A*/ - else if((ecx==0x444D4163&&edx==0x69746E65&&ebx==0x68747541)|| - /* C S N y b e d o e G*/ - (ecx==0x43534E20&&edx==0x79622065&&ebx==0x646F6547)){ - /*AMD, Geode:*/ - cpuid(0x80000000,eax,ebx,ecx,edx); - if(eax<0x80000001)flags=0; - else{ - cpuid(0x80000001,eax,ebx,ecx,edx); - flags=oc_parse_amd_flags(edx,ecx); - } - /*Also check for SSE.*/ - cpuid(1,eax,ebx,ecx,edx); - flags|=oc_parse_intel_flags(edx,ecx); - } - /*Technically some VIA chips can be configured in the BIOS to return any - string here the user wants. - There is a special detection method that can be used to identify such - processors, but in my opinion, if the user really wants to change it, they - deserve what they get.*/ - /* s l u a H r u a t n e C*/ - else if(ecx==0x736C7561&&edx==0x48727561&&ebx==0x746E6543){ - /*VIA:*/ - /*I only have documentation for the C7 (Esther) and Isaiah (forthcoming) - chips (thanks to the engineers from Centaur Technology who provided it). - These chips support Intel-like cpuid info. - The C3-2 (Nehemiah) cores appear to, as well.*/ - cpuid(1,eax,ebx,ecx,edx); - flags=oc_parse_intel_flags(edx,ecx); - cpuid(0x80000000,eax,ebx,ecx,edx); - if(eax>=0x80000001){ - /*The (non-Nehemiah) C3 processors support AMD-like cpuid info. - We need to check this even if the Intel test succeeds to pick up 3DNow! - support on these processors. - Unlike actual AMD processors, we cannot _rely_ on this info, since - some cores (e.g., the 693 stepping of the Nehemiah) claim to support - this function, yet return edx=0, despite the Intel test indicating - MMX support. - Therefore the features detected here are strictly added to those - detected by the Intel test.*/ - /*TODO: How about earlier chips?*/ - cpuid(0x80000001,eax,ebx,ecx,edx); - /*Note: As of the C7, this function returns Intel-style extended feature - flags, not AMD-style. - Currently, this only defines bits 11, 20, and 29 (0x20100800), which - do not conflict with any of the AMD flags we inspect. - For the remaining bits, Intel tells us, "Do not count on their value", - but VIA assures us that they will all be zero (at least on the C7 and - Isaiah chips). - In the (unlikely) event a future processor uses bits 18, 19, 30, or 31 - (0xC0C00000) for something else, we will have to add code to detect - the model to decide when it is appropriate to inspect them.*/ - flags|=oc_parse_amd_flags(edx,ecx); - } - } - else{ - /*Implement me.*/ - flags=0; - } -# else - /* not x86 or ppc */ -# endif - return flags; -} diff --git a/media/liboggplay/src/liboggplay/cpu.h b/media/liboggplay/src/liboggplay/cpu.h deleted file mode 100644 index b057bd36f36..00000000000 --- a/media/liboggplay/src/liboggplay/cpu.h +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007 * - * by the Xiph.Org Foundation and contributors http://www.xiph.org/ * - * * - ******************************************************************** - function: - last mod: $Id$ - - ********************************************************************/ - -#ifndef __CPU_H__ -#define __CPU_H__ - -#define OC_CPU_X86_MMX (1<<0) -#define OC_CPU_X86_3DNOW (1<<1) -#define OC_CPU_X86_3DNOWEXT (1<<2) -#define OC_CPU_X86_MMXEXT (1<<3) -#define OC_CPU_X86_SSE (1<<4) -#define OC_CPU_X86_SSE2 (1<<5) -#define OC_CPU_X86_PNI (1<<6) -#define OC_CPU_X86_SSSE3 (1<<7) -#define OC_CPU_X86_SSE4_1 (1<<8) -#define OC_CPU_X86_SSE4_2 (1<<9) -#define OC_CPU_X86_SSE4A (1<<10) -#define OC_CPU_X86_SSE5 (1<<11) -#define OC_CPU_PPC_ALTIVEC (1<<12) - -#endif diff --git a/media/liboggplay/src/liboggplay/oggplay.c b/media/liboggplay/src/liboggplay/oggplay.c deleted file mode 100644 index 54899ea4178..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay.c +++ /dev/null @@ -1,982 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay.c - * - * Shane Stephens - * Michael Martin - */ - -#include "oggplay_private.h" -#include "oggplay_buffer.h" - -#include -#include - -#define OGGZ_READ_CHUNK_SIZE 8192 - -OggPlay * -oggplay_new_with_reader(OggPlayReader *reader) { - - OggPlay * me = NULL; - - /* check whether the reader is valid. */ - if (reader == NULL) - return NULL; - - me = (OggPlay *)oggplay_malloc (sizeof(OggPlay)); - if (me == NULL) - return NULL; - - me->reader = reader; - me->decode_data = NULL; - me->callback_info = NULL; - me->num_tracks = 0; - me->all_tracks_initialised = 0; - me->callback_period = 0; - me->callback = NULL; - me->target = 0L; - me->active_tracks = 0; - me->buffer = NULL; - me->shutdown = 0; - me->trash = NULL; - me->oggz = NULL; - me->pt_update_valid = 1; - me->duration = -1; - me->max_video_frame_pixels = OGGPLAY_TYPE_MAX_SIGNED(int); - - return me; - -} - -OggPlayErrorCode -oggplay_initialise(OggPlay *me, int block) { - - OggPlayErrorCode return_val; - int i; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - return_val = me->reader->initialise(me->reader, block); - - if (return_val != E_OGGPLAY_OK) { - return return_val; - } - - /* - * this is the cut-off time value below which packets will be ignored. Initialise it to 0 here. - * We'll reinitialise it when/if we encounter a skeleton header - */ - me->presentation_time = 0; - - /* - * start to retrieve data, until we get all of the track info. We need - * to do this now so that the user can query us for this info before entering - * the main loop - */ - me->oggz = oggz_new(OGGZ_READ | OGGZ_AUTO); - if (me->oggz == NULL) - return E_OGGPLAY_OGGZ_UNHAPPY; - - if (oggz_io_set_read(me->oggz, me->reader->io_read, me->reader) != 0) - return E_OGGPLAY_OGGZ_UNHAPPY; - - if (oggz_io_set_seek(me->oggz, me->reader->io_seek, me->reader) != 0) - return E_OGGPLAY_OGGZ_UNHAPPY; - - if (oggz_io_set_tell(me->oggz, me->reader->io_tell, me->reader) != 0) - return E_OGGPLAY_OGGZ_UNHAPPY; - - if (oggz_set_read_callback(me->oggz, -1, oggplay_callback_predetected, me)) - return E_OGGPLAY_OGGZ_UNHAPPY; - - while (1) { - i = oggz_read (me->oggz, OGGZ_READ_CHUNK_SIZE); - - switch (i) { - case 0: - /* - * EOF reached while processing headers, - * possible erroneous file, mark it as such. - */ - case OGGZ_ERR_HOLE_IN_DATA: - /* there was a whole in the data */ - return E_OGGPLAY_BAD_INPUT; - - case OGGZ_ERR_OUT_OF_MEMORY: - /* ran out of memory during decoding! */ - return E_OGGPLAY_OUT_OF_MEMORY; - - case OGGZ_ERR_STOP_ERR: - /* */ - return E_OGGPLAY_BAD_OGGPLAY; - - default: - /* If the read otherwise failed, bail out. */ - if (i < 0) - return E_OGGPLAY_BAD_INPUT; - break; - } - - if (me->all_tracks_initialised) { - break; - } - } - - /* - * set all the tracks to inactive - */ - for (i = 0; i < me->num_tracks; i++) { - me->decode_data[i]->active = 0; - } - me->active_tracks = 0; - - /* - * if the buffer was set up before initialisation, prepare it now - */ - if (me->buffer != NULL) { - oggplay_buffer_prepare(me); - } - - return E_OGGPLAY_OK; - -} - -OggPlay * -oggplay_open_with_reader(OggPlayReader *reader) { - - OggPlay *me = NULL; - int r = E_OGGPLAY_TIMEOUT; - - if ((me = oggplay_new_with_reader(reader)) == NULL) - return NULL; - - while (r == E_OGGPLAY_TIMEOUT) { - r = oggplay_initialise(me, 0); - } - - if (r != E_OGGPLAY_OK) { - - /* in case of error close the OggPlay handle */ - oggplay_close(me); - - return NULL; - } - - return me; -} - -/* - * API function to prevent bad input, and to prevent data callbacks being registered - * in buffer mode - */ -OggPlayErrorCode -oggplay_set_data_callback(OggPlay *me, OggPlayDataCallback callback, - void *user) { - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (me->buffer != NULL) { - return E_OGGPLAY_BUFFER_MODE; - } - - oggplay_set_data_callback_force(me, callback, user); - return E_OGGPLAY_OK; - -} - -/* - * internal function that doesn't perform error checking. Used so the buffer - * can register a callback! - */ -void -oggplay_set_data_callback_force(OggPlay *me, OggPlayDataCallback callback, - void *user) { - - me->callback = callback; - me->callback_user_ptr = user; - -} - - -OggPlayErrorCode -oggplay_set_callback_num_frames(OggPlay *me, int track, int frames) { - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - me->callback_period = me->decode_data[track]->granuleperiod * frames; - me->target = me->presentation_time + me->callback_period - 1; - - return E_OGGPLAY_OK; -} - -OggPlayErrorCode -oggplay_set_callback_period(OggPlay *me, int track, int milliseconds) { - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - me->callback_period = OGGPLAY_TIME_INT_TO_FP(((ogg_int64_t)milliseconds))/1000; - me->target = me->presentation_time + me->callback_period - 1; - - return E_OGGPLAY_OK; -} - -OggPlayErrorCode -oggplay_set_offset(OggPlay *me, int track, ogg_int64_t offset) { - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - me->decode_data[track]->offset = OGGPLAY_TIME_INT_TO_FP(offset) / 1000; - - return E_OGGPLAY_OK; - -} - -OggPlayErrorCode -oggplay_get_video_fps(OggPlay *me, int track, int* fps_denom, int* fps_num) { - OggPlayTheoraDecode *decode; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - if (me->decode_data[track]->decoded_type != OGGPLAY_YUV_VIDEO) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - decode = (OggPlayTheoraDecode *)(me->decode_data[track]); - - if ((decode->video_info.fps_denominator == 0) - || (decode->video_info.fps_numerator == 0)) { - return E_OGGPLAY_UNINITIALISED; - } - - (*fps_denom) = decode->video_info.fps_denominator; - (*fps_num) = decode->video_info.fps_numerator; - - return E_OGGPLAY_OK; -} - -OggPlayErrorCode -oggplay_get_video_aspect_ratio(OggPlay *me, int track, int* aspect_denom, int* aspect_num) { - OggPlayTheoraDecode *decode; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - if (me->decode_data[track]->decoded_type != OGGPLAY_YUV_VIDEO) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - decode = (OggPlayTheoraDecode *)(me->decode_data[track]); - - if ((decode->video_info.aspect_denominator == 0) - || (decode->video_info.aspect_numerator == 0)) { - return E_OGGPLAY_UNINITIALISED; - } - - (*aspect_denom) = decode->video_info.aspect_denominator; - (*aspect_num) = decode->video_info.aspect_numerator; - - return E_OGGPLAY_OK; -} - -OggPlayErrorCode -oggplay_convert_video_to_rgb(OggPlay *me, int track, int convert, int swap_rgb) { - OggPlayTheoraDecode *decode; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - if (me->decode_data[track]->content_type != OGGZ_CONTENT_THEORA) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - decode = (OggPlayTheoraDecode *)(me->decode_data[track]); - - if (decode->convert_to_rgb != convert || decode->swap_rgb != swap_rgb) { - decode->convert_to_rgb = convert; - decode->swap_rgb = swap_rgb; - me->decode_data[track]->decoded_type = convert ? OGGPLAY_RGBA_VIDEO : OGGPLAY_YUV_VIDEO; - - /* flush any records created with previous type */ - oggplay_data_free_list(me->decode_data[track]->data_list); - me->decode_data[track]->data_list = NULL; - } - - return E_OGGPLAY_OK; -} - -OggPlayErrorCode -oggplay_get_video_y_size(OggPlay *me, int track, int *y_width, int *y_height) { - - OggPlayTheoraDecode *decode; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - if (me->decode_data[track]->decoded_type != OGGPLAY_YUV_VIDEO) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - decode = (OggPlayTheoraDecode *)(me->decode_data[track]); - - if (decode->y_width == 0) { - return E_OGGPLAY_UNINITIALISED; - } - - (*y_width) = decode->y_width; - (*y_height) = decode->y_height; - - return E_OGGPLAY_OK; - -} - -OggPlayErrorCode -oggplay_get_video_uv_size(OggPlay *me, int track, int *uv_width, int *uv_height) -{ - - OggPlayTheoraDecode *decode; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - if (me->decode_data[track]->decoded_type != OGGPLAY_YUV_VIDEO) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - decode = (OggPlayTheoraDecode *)(me->decode_data[track]); - - if (decode->y_width == 0) { - return E_OGGPLAY_UNINITIALISED; - } - - (*uv_width) = decode->uv_width; - (*uv_height) = decode->uv_height; - - return E_OGGPLAY_OK; - -} - -OggPlayErrorCode -oggplay_get_audio_channels(OggPlay *me, int track, int* channels) { - - OggPlayAudioDecode *decode; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - if (me->decode_data[track]->decoded_type != OGGPLAY_FLOATS_AUDIO) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - decode = (OggPlayAudioDecode *)(me->decode_data[track]); - - if (decode->sound_info.channels == 0) { - return E_OGGPLAY_UNINITIALISED; - } - (*channels) = decode->sound_info.channels; - return E_OGGPLAY_OK; - -} - -OggPlayErrorCode -oggplay_get_audio_samplerate(OggPlay *me, int track, int* rate) { - - OggPlayAudioDecode * decode; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - if (me->decode_data[track]->decoded_type != OGGPLAY_FLOATS_AUDIO) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - decode = (OggPlayAudioDecode *)(me->decode_data[track]); - - if (decode->sound_info.channels == 0) { - return E_OGGPLAY_UNINITIALISED; - } - (*rate) = decode->sound_info.samplerate; - return E_OGGPLAY_OK; - -} - -OggPlayErrorCode -oggplay_get_kate_category(OggPlay *me, int track, const char** category) { - - OggPlayKateDecode * decode; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - if (me->decode_data[track]->content_type != OGGZ_CONTENT_KATE) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - decode = (OggPlayKateDecode *)(me->decode_data[track]); - -#ifdef HAVE_KATE - if (decode->decoder.initialised) { - (*category) = decode->k_state.ki->category; - return E_OGGPLAY_OK; - } - else return E_OGGPLAY_UNINITIALISED; -#else - return E_OGGPLAY_NO_KATE_SUPPORT; -#endif -} - -OggPlayErrorCode -oggplay_get_kate_language(OggPlay *me, int track, const char** language) { - - OggPlayKateDecode * decode; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - if (me->decode_data[track]->content_type != OGGZ_CONTENT_KATE) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - decode = (OggPlayKateDecode *)(me->decode_data[track]); - -#ifdef HAVE_KATE - if (decode->decoder.initialised) { - (*language) = decode->k_state.ki->language; - return E_OGGPLAY_OK; - } - else return E_OGGPLAY_UNINITIALISED; -#else - return E_OGGPLAY_NO_KATE_SUPPORT; -#endif -} - -OggPlayErrorCode -oggplay_set_kate_tiger_rendering(OggPlay *me, int track, int use_tiger, int swap_rgb, int default_width, int default_height) { - - OggPlayKateDecode * decode; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track < 0 || track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - if (me->decode_data[track]->content_type != OGGZ_CONTENT_KATE) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - decode = (OggPlayKateDecode *)(me->decode_data[track]); - -#ifdef HAVE_KATE -#ifdef HAVE_TIGER - if (decode->decoder.initialised && decode->tr) { - decode->use_tiger = use_tiger; - decode->swap_rgb = swap_rgb; - decode->default_width = default_width; - decode->default_height = default_height; - decode->decoder.decoded_type = use_tiger ? OGGPLAY_RGBA_VIDEO : OGGPLAY_KATE; - return E_OGGPLAY_OK; - } - else return E_OGGPLAY_UNINITIALISED; -#else - return E_OGGPLAY_NO_TIGER_SUPPORT; -#endif -#else - return E_OGGPLAY_NO_KATE_SUPPORT; -#endif -} - -OggPlayErrorCode -oggplay_overlay_kate_track_on_video(OggPlay *me, int kate_track, int video_track) { - - OggPlayKateDecode * decode; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (kate_track < 0 || kate_track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - if (video_track < 0 || video_track >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - if (me->decode_data[kate_track]->content_type != OGGZ_CONTENT_KATE) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - if (me->decode_data[kate_track]->decoded_type != OGGPLAY_RGBA_VIDEO) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - if (me->decode_data[video_track]->content_type != OGGZ_CONTENT_THEORA) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - if (me->decode_data[video_track]->decoded_type != OGGPLAY_RGBA_VIDEO) { - return E_OGGPLAY_WRONG_TRACK_TYPE; - } - - decode = (OggPlayKateDecode *)(me->decode_data[kate_track]); - -#ifdef HAVE_KATE -#ifdef HAVE_TIGER - decode->overlay_dest = video_track; - return E_OGGPLAY_OK; -#else - return E_OGGPLAY_NO_TIGER_SUPPORT; -#endif -#else - return E_OGGPLAY_NO_KATE_SUPPORT; -#endif -} - -#define MAX_CHUNK_COUNT 10 - -OggPlayErrorCode -oggplay_step_decoding(OggPlay *me) { - - OggPlayCallbackInfo ** info; - int num_records; - int r; - int i; - int need_data = 0; - int chunk_count = 0; - int read_data = 0; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - /* - * check whether the OggPlayDataCallback is set for the given - * OggPlay handle. If not return with error as there's no callback - * function processing the decoded data. - */ - if (me->callback == NULL) { - return E_OGGPLAY_UNINITIALISED; - } - - /* - * clean up any trash pointers. As soon as the current buffer has a - * frame taken out, we know the old buffer will no longer be used. - */ - - if - ( - me->trash != NULL - && - (me->buffer == NULL || me->buffer->last_emptied > -1) - ) - { - oggplay_take_out_trash(me, me->trash); - me->trash = NULL; - } - -read_more_data: - - while (1) { - /* - * if there are no active tracks, we might need to return some data - * left over at the end of a once-active track that has had all of its - * data processed. Look through the tracks to find these overhangs - */ - int r; - - if (me->active_tracks == 0) { - int remaining = 0; - for (i = 0; i < me->num_tracks; i++) { - if (me->decode_data[i]->current_loc + - me->decode_data[i]->granuleperiod >= me->target + me->decode_data[i]->offset) { - remaining++; - } - } - if (remaining == 0 && !read_data) { - /* - * There's no more data to read, and we've not read any that needs - * to be sent to the buffer list via a callback, so exit. - */ - return E_OGGPLAY_OK; - } - } - - /* - * if any of the tracks have not yet met the target (modified by that - * track's offset), then retrieve more data - */ - need_data = 0; - for (i = 0; i < me->num_tracks; i++) { - if (me->decode_data[i]->active == 0) - continue; - if (me->decode_data[i]->content_type == OGGZ_CONTENT_CMML) - continue; - if (me->decode_data[i]->content_type == OGGZ_CONTENT_KATE) - continue; - if - ( - me->decode_data[i]->current_loc - < - me->target + me->decode_data[i]->offset - ) - { - need_data = 1; - break; - } - } - - if (!need_data) { - break; - } - - /* - * get a chunk of data. If we're at the end of the file, then we must - * have some final frames to render (?). E_OGGPLAY_END_OF_FILE is - * only returned if there is *no* more data. - */ - - if (chunk_count > MAX_CHUNK_COUNT) { - return E_OGGPLAY_TIMEOUT; - } - - chunk_count += 1; - - r = oggz_read(me->oggz, OGGZ_READ_CHUNK_SIZE); - - switch (r) { - case 0: - /* end-of-file */ - - num_records = oggplay_callback_info_prepare(me, &info); - /* - * set all of the tracks to inactive - */ - for (i = 0; i < me->num_tracks; i++) { - me->decode_data[i]->active = 0; - } - me->active_tracks = 0; - - if (info != NULL) { - /* ensure all tracks have their final data packet set to end_of_stream */ - OggPlayCallbackInfo *p = info[0]; - for (i = 0; i < me->num_tracks; i++) { - p->stream_info = OGGPLAY_STREAM_LAST_DATA; - p++; - } - - me->callback (me, num_records, info, me->callback_user_ptr); - oggplay_callback_info_destroy(me, info); - } - - /* we reached the end of the stream */ - return E_OGGPLAY_OK; - - case OGGZ_ERR_HOLE_IN_DATA: - /* there was a whole in the data */ - return E_OGGPLAY_BAD_INPUT; - - case OGGZ_ERR_STOP_ERR: - /* - * one of the callback functions requested us to stop. - * as this currently happens only when one of the - * OggzReadPacket callback functions does not receive - * the user provided data, i.e. the OggPlayDecode struct - * for the track mark it as a memory problem, since this - * could happen only if something is wrong with the memory, - * e.g. some buffer overflow. - */ - - case OGGZ_ERR_OUT_OF_MEMORY: - /* ran out of memory during decoding! */ - return E_OGGPLAY_OUT_OF_MEMORY; - - default: - /* - * We read some data. Set a flag so that we're guaranteed to try to - * send it to the buffer list via a callback. - */ - read_data = 1; - break; - } - } - /* - * prepare a callback - */ - num_records = oggplay_callback_info_prepare (me, &info); - if (info != NULL) { - r = me->callback (me, num_records, info, me->callback_user_ptr); - oggplay_callback_info_destroy (me, info); - } else { - r = 0; - } - - /* - * clean the data lists - */ - for (i = 0; i < me->num_tracks; i++) { - oggplay_data_clean_list (me->decode_data[i]); - } - - /* - * there was an error during info prepare! - * abort decoding! - */ - if (num_records < 0) { - return num_records; - } - - /* if we received an shutdown event, dont try to read more data...*/ - if (me->shutdown) { - return E_OGGPLAY_OK; - } - - /* we require more data for decoding */ - if (info == NULL) { - goto read_more_data; - } - - me->target += me->callback_period; - if (r == -1) { - return E_OGGPLAY_USER_INTERRUPT; - } - - return E_OGGPLAY_CONTINUE; - -} - -OggPlayErrorCode -oggplay_start_decoding(OggPlay *me) { - - int r; - - while (1) { - r = oggplay_step_decoding(me); - if (r == E_OGGPLAY_CONTINUE || r == E_OGGPLAY_TIMEOUT) { - continue; - } - return (OggPlayErrorCode)r; - } -} - -OggPlayErrorCode -oggplay_close(OggPlay *me) { - - int i; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (me->reader != NULL) { - me->reader->destroy(me->reader); - } - - /* */ - if (me->decode_data != NULL) { - for (i = 0; i < me->num_tracks; i++) { - oggplay_callback_shutdown(me->decode_data[i]); - } - } - - if (me->oggz) - oggz_close(me->oggz); - - if (me->buffer != NULL) { - oggplay_buffer_shutdown(me, me->buffer); - } - - if (me->callback_info != NULL) { - oggplay_free(me->callback_info); - } - - oggplay_free(me->decode_data); - oggplay_free(me); - - return E_OGGPLAY_OK; -} - -/* - * this function is required to release the frame_sem in the buffer, if - * the buffer is being used. - */ -void -oggplay_prepare_for_close(OggPlay *me) { - - me->shutdown = 1; - if (me->buffer != NULL) { - SEM_SIGNAL(((OggPlayBuffer *)(me->buffer))->frame_sem); - } -} - -int -oggplay_get_available(OggPlay *me) { - - ogg_int64_t current_time, current_byte; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - current_time = oggz_tell_units(me->oggz); - current_byte = (ogg_int64_t)oggz_tell(me->oggz); - - return me->reader->available(me->reader, current_byte, current_time); - -} - -ogg_int64_t -oggplay_get_duration(OggPlay *me) { - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - /* If the reader has a duration function we always call that - * function to find the duration. We never cache the result - * of that function. - * - * If there is no reader duration function we use our cached - * duration value, or do a liboggz seek to find it and cache - * that. - */ - if (me->reader->duration) { - ogg_int64_t d = me->reader->duration(me->reader); - if (d >= 0) { - me->duration = d; - } - } - - if (me->duration < 0) { - ogg_int64_t pos; - pos = oggz_tell_units(me->oggz); - me->duration = oggz_seek_units(me->oggz, 0, SEEK_END); - oggz_seek_units(me->oggz, pos, SEEK_SET); - oggplay_seek_cleanup(me, pos); - } - - return me->duration; -} - -int -oggplay_media_finished_retrieving(OggPlay *me) { - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (me->reader == NULL) { - return E_OGGPLAY_BAD_READER; - } - - return me->reader->finished_retrieving(me->reader); - -} - -int -oggplay_set_max_video_frame_pixels(OggPlay *player, - int max_frame_pixels) { - if (!player) - return E_OGGPLAY_BAD_OGGPLAY; - player->max_video_frame_pixels = max_frame_pixels; - return E_OGGPLAY_OK; -} diff --git a/media/liboggplay/src/liboggplay/oggplay_buffer.c b/media/liboggplay/src/liboggplay/oggplay_buffer.c deleted file mode 100644 index b51d8be4ddf..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_buffer.c +++ /dev/null @@ -1,372 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_buffer.c - * - * Shane Stephens - */ - -#include "oggplay_private.h" - -#include -#include - -#define OGGPLAY_DEFAULT_BUFFER_SIZE 20 -#define WRAP_INC(c, s) ((c + 1) % s) - - - -/* - * Call this function to initialise the oggplay lock-free buffer. Do not use - * the buffer and the callback together! - */ -OggPlayBuffer * -oggplay_buffer_new_buffer(int size) { - - OggPlayBuffer *buffer = NULL; - if (size < 0) { - size = OGGPLAY_DEFAULT_BUFFER_SIZE; - } - - buffer = (OggPlayBuffer*)oggplay_calloc(1, sizeof (OggPlayBuffer)); - - if (buffer == NULL) - return NULL; - - buffer->buffer_list = oggplay_calloc(size, sizeof (void *)); - if (buffer->buffer_list == NULL) - goto error; - - buffer->buffer_mirror = oggplay_calloc(size, sizeof (void *)); - if (buffer->buffer_mirror == NULL) - goto error; - - buffer->buffer_size = size; - buffer->last_filled = -1; - buffer->last_emptied = -1; - - if (SEM_CREATE(buffer->frame_sem, size) != 0) - goto error; - - return buffer; - -error: - if (buffer->buffer_list != NULL) - oggplay_free (buffer->buffer_list); - - if (buffer->buffer_mirror != NULL) - oggplay_free (buffer->buffer_mirror); - - oggplay_free (buffer); - - return NULL; -} - -void -oggplay_buffer_shutdown(OggPlay *me, volatile OggPlayBuffer *vbuffer) { - - int i; - int j; - - OggPlayBuffer *buffer = (OggPlayBuffer *)vbuffer; - - if (buffer == NULL) { - return; - } - - if (buffer->buffer_mirror != NULL) { - for (i = 0; i < buffer->buffer_size; i++) { - - if (buffer->buffer_mirror[i] != NULL) { - OggPlayCallbackInfo *ti = (OggPlayCallbackInfo *)buffer->buffer_mirror[i]; - for (j = 0; j < me->num_tracks; j++) { - if ( (ti+j) != NULL) { - oggplay_free((ti + j)->records); - } - } - oggplay_free(ti); - } - - } - oggplay_free(buffer->buffer_mirror); - } - - if (buffer->buffer_list != NULL) - oggplay_free(buffer->buffer_list); - - SEM_CLOSE(buffer->frame_sem); - oggplay_free(buffer); - buffer = NULL; -} - -int -oggplay_buffer_is_full(volatile OggPlayBuffer *buffer) { - - return - ( - (buffer == NULL) || ( - buffer->buffer_list[WRAP_INC(buffer->last_filled, buffer->buffer_size)] - != - NULL - ) - ); - -} - -int -oggplay_buffer_callback(OggPlay *me, int tracks, - OggPlayCallbackInfo **track_info, void *user) { - - int i; - int j; - int k; - OggPlayDataHeader ** headers; - OggPlayBuffer * buffer; - OggPlayCallbackInfo * ptr = track_info[0]; - int required; - - if (me == NULL) - return -1; - - buffer = (OggPlayBuffer *)me->buffer; - - if (buffer == NULL) { - return -1; - } - - SEM_WAIT(buffer->frame_sem); - - if (me->shutdown) { - return -1; - } - - /* - * lock the item going into the buffer so that it doesn't get cleaned up - */ - for (i = 0; i < tracks; i++) { - headers = oggplay_callback_info_get_headers(track_info[i]); - required = oggplay_callback_info_get_required(track_info[i]); - for (j = 0; j < required; j++) { - oggplay_callback_info_lock_item(headers[j]); - } - } - - /* - * check for and clean up empties - */ - for (k = 0; k < buffer->buffer_size; k++) { - if - ( - (buffer->buffer_list[k] == NULL) - && - (buffer->buffer_mirror[k] != NULL) - ) - { - OggPlayCallbackInfo *ti = (OggPlayCallbackInfo *)buffer->buffer_mirror[k]; - for (i = 0; i < tracks; i++) { - headers = oggplay_callback_info_get_headers(ti + i); - required = oggplay_callback_info_get_required(ti + i); - for (j = 0; j < required; j++) { - oggplay_callback_info_unlock_item(headers[j]); - } - /* free these here, because we couldn't free them in - * oggplay_callback_info_destroy for buffer mode - */ - if ((ti + i) != NULL) { - oggplay_free((ti + i)->records); - } - } - oggplay_free(ti); - buffer->buffer_mirror[k] = NULL; - } - } - - /* - * replace the decode_data buffer for the next callback - */ - me->callback_info = - (OggPlayCallbackInfo *)oggplay_calloc(me->num_tracks, sizeof (OggPlayCallbackInfo)); - if (me->callback_info == NULL) - return -1; - - /* - * fill both mirror and list, mirror first to avoid getting inconsistencies - */ - - buffer->last_filled = WRAP_INC(buffer->last_filled, buffer->buffer_size); - - /* - * set the buffer pointer in the first record - */ - ptr->buffer = buffer; - - buffer->buffer_mirror[buffer->last_filled] = ptr; - buffer->buffer_list[buffer->last_filled] = ptr; - - - if (oggplay_buffer_is_full(buffer)) { - /* - * user interrupt when we fill the buffer rather than when we have a - * decoded frame and the buffer is already full - */ - return -1; - } - - return 0; -} - -OggPlayCallbackInfo ** -oggplay_buffer_retrieve_next(OggPlay *me) { - - OggPlayBuffer * buffer = NULL; - int next_loc; - OggPlayCallbackInfo * next_item; - OggPlayCallbackInfo ** return_val; - int i; - - if (me == NULL) { - return NULL; - } - - buffer = (OggPlayBuffer *)me->buffer; - - if (buffer == NULL) { - return NULL; - } - - next_loc = WRAP_INC(buffer->last_emptied, buffer->buffer_size); - - if (buffer->buffer_list[next_loc] == NULL) { - return NULL; - } - - next_item = (OggPlayCallbackInfo*)buffer->buffer_list[next_loc]; - buffer->last_emptied = next_loc; - - return_val = oggplay_calloc(me->num_tracks, sizeof (OggPlayCallbackInfo *)); - if (return_val == NULL) { - return NULL; - } - - for (i = 0; i < me->num_tracks; i++) { - return_val[i] = next_item + i; - } - - return return_val; - -} - -OggPlayErrorCode -oggplay_buffer_release(OggPlay *me, OggPlayCallbackInfo **track_info) { - - OggPlayBuffer *buffer = NULL; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (track_info == NULL) { - return E_OGGPLAY_OK; - } - - buffer = (OggPlayBuffer *)track_info[0]->buffer; - - if (buffer == NULL) { - return E_OGGPLAY_CALLBACK_MODE; - } - - if (buffer->buffer_list[buffer->last_emptied] == NULL) { - return E_OGGPLAY_UNINITIALISED; - } - - if (track_info != NULL) { - oggplay_free(track_info); - } - - buffer->buffer_list[buffer->last_emptied] = NULL; - - SEM_SIGNAL(buffer->frame_sem); - - return E_OGGPLAY_OK; - -} - -OggPlayErrorCode -oggplay_use_buffer(OggPlay *me, int size) { - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (me->callback != NULL) { - return E_OGGPLAY_CALLBACK_MODE; - } - - if (me->buffer != NULL) { - /* - * we should check sizes, and maybe clear and reallocate the buffer? - */ - return E_OGGPLAY_OK; - } - - if( (me->buffer = oggplay_buffer_new_buffer(size)) == NULL) - return E_OGGPLAY_OUT_OF_MEMORY; - - /* - * if oggplay is already initialised, then prepare the buffer now - */ - if (me->all_tracks_initialised) { - oggplay_buffer_prepare(me); - } - - return E_OGGPLAY_OK; -} - -void -oggplay_buffer_prepare(OggPlay *me) { - - int i; - - if (me == NULL) - return; - - oggplay_set_data_callback_force(me, &oggplay_buffer_callback, NULL); - - for (i = 0; i < me->num_tracks; i++) { - if (oggplay_get_track_type(me, i) == OGGZ_CONTENT_THEORA) { - oggplay_set_callback_num_frames(me, i, 1); - break; - } - } - -} diff --git a/media/liboggplay/src/liboggplay/oggplay_buffer.h b/media/liboggplay/src/liboggplay/oggplay_buffer.h deleted file mode 100644 index 76ffb5a3dfe..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_buffer.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_buffer.h - * - * Shane Stephens - */ - -#ifndef __OGGPLAY_BUFFER_H__ -#define __OGGPLAY_BUFFER_H__ - -/** - * Creates a new buffer with the given size. - * - * @param size The number of frames the buffer can store. - * @return A new OggPlayBuffer. - * @retval NULL in case of error. - */ -OggPlayBuffer * -oggplay_buffer_new_buffer(int size); - -int -oggplay_buffer_is_full(volatile OggPlayBuffer *buffer); - -void -oggplay_buffer_shutdown(OggPlay *me, volatile OggPlayBuffer *buffer); - -void -oggplay_buffer_prepare(OggPlay *me); - -#endif diff --git a/media/liboggplay/src/liboggplay/oggplay_callback.c b/media/liboggplay/src/liboggplay/oggplay_callback.c deleted file mode 100644 index cf95a863829..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_callback.c +++ /dev/null @@ -1,1044 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_callback.c - * - * Shane Stephens - */ -#include "oggplay_private.h" - -#define TIME_THEORA_DECODE 0 - -#include -#if TIME_THEORA_DECODE -#include -#endif -#include -#include - -#define THEORA_VERSION(maj,min,rev) ((maj<<16)+(min<<8)+rev) - -void -oggplay_init_theora(void *user_data) { - - OggPlayTheoraDecode * decoder = (OggPlayTheoraDecode *)user_data; - - if (decoder == NULL) { - return; - } - - theora_info_init(&(decoder->video_info)); - theora_comment_init(&(decoder->video_comment)); - decoder->granulepos_seen = 0; - decoder->frame_delta = 0; - decoder->y_width = 0; - decoder->convert_to_rgb = 0; - decoder->swap_rgb = 0; - decoder->decoder.decoded_type = OGGPLAY_YUV_VIDEO; - decoder->decoder.player->active_tracks++; -} - -void -oggplay_shutdown_theora(void *user_data) { - OggPlayDecode * common; - OggPlayTheoraDecode * decoder = (OggPlayTheoraDecode *)user_data; - - if (decoder == NULL) { - return; - } - - if ((common = &(decoder->decoder)) == NULL) { - return; - } - - if (common->initialised == 1 && decoder->decoder.num_header_packets == 0) { - theora_clear(&(decoder->video_handle)); - } - theora_info_clear(&(decoder->video_info)); - theora_comment_clear(&(decoder->video_comment)); -} - -/** - * Returns 1 if the video as described by |info| requires more than - * max_video_pixels pixels per frame, otherwise returns 0. - */ -static int -frame_is_too_large(theora_info *info, long max_video_pixels) { - int overflow = 0; - long frame_pixels = 0; - long display_pixels = 0; - if (!info) { - return 1; - } - overflow |= oggplay_mul_signed_overflow(info->frame_width, - info->frame_height, - &frame_pixels); - overflow |= oggplay_mul_signed_overflow(info->width, - info->height, - &display_pixels); - if (overflow || - frame_pixels > max_video_pixels || - display_pixels > max_video_pixels) { - return 1; - } - return 0; -} - -int -oggplay_callback_theora (OGGZ * oggz, ogg_packet * op, long serialno, - void * user_data) { - - OggPlayTheoraDecode * decoder = (OggPlayTheoraDecode *)user_data; - OggPlayDecode * common = NULL; - ogg_int64_t granulepos = oggz_tell_granulepos(oggz); - yuv_buffer buffer; - int granuleshift; - long frame; - OggPlayErrorCode ret; - - /* check whether user_data is valid */ - if (decoder == NULL) { - return OGGZ_STOP_ERR; - } - - if ((common = &(decoder->decoder)) == NULL) { - return OGGZ_STOP_ERR; - } - -#if TIME_THEORA_DECODE - struct timeval tv; - struct timeval tv2; - int musec; -#endif - - if (!common->active) { - /* - * don't decode other packets - */ - return OGGZ_CONTINUE; - } - - if ((granulepos > 0) && (common->last_granulepos > granulepos)) { - /* - * the granule position is not monotonically increasing, - * something wrong with the page! - * skipping this page..... - */ - return OGGZ_CONTINUE; - } - - /* - * always decode headers - */ - if (theora_packet_isheader(op) && - common->num_header_packets > 0 && - common->initialised != -1) - { - if (theora_decode_header(&(decoder->video_info), &(decoder->video_comment), op) < 0) { - common->initialised |= -1; - return OGGZ_CONTINUE; - } - - /* - * initialise width/stride/height data (this is common to all frames). - * Use the buffer stride for the width to avoid passing negative stride - * issues on to the user. - */ - - if (--(common->num_header_packets) == 0) { - decoder->y_width = decoder->y_stride = decoder->video_info.frame_width; - decoder->y_height = decoder->video_info.frame_height; - - if (decoder->video_info.pixelformat == OC_PF_444) { - decoder->uv_width = decoder->uv_stride = decoder->video_info.frame_width; - decoder->uv_height = decoder->video_info.frame_height; - } else if (decoder->video_info.pixelformat == OC_PF_422) { - decoder->uv_width = decoder->uv_stride = decoder->video_info.frame_width / 2; - decoder->uv_height = decoder->video_info.frame_height; - } else if (decoder->video_info.pixelformat == OC_PF_420) { - decoder->uv_width = decoder->uv_stride = decoder->video_info.frame_width / 2; - decoder->uv_height = decoder->video_info.frame_height / 2; - } else { - common->initialised |= -1; - return OGGZ_CONTINUE; - } - - if (decoder->y_width == 0 || - decoder->y_height == 0 || - decoder->uv_width == 0 || - decoder->uv_height == 0) { - /* it's a theora track with one of it's plane's dimension 0 - * decoding this track is not possible. - */ - common->initialised |= -1; - return OGGZ_CONTINUE; - } - - /* Ensure the offsets do not push the viewable area outside of the decoded frame. */ - if - ( - ((decoder->video_info.height - decoder->video_info.offset_y)video_info.frame_height) - || - ((decoder->video_info.width - decoder->video_info.offset_x)video_info.frame_width) - ) - { - common->initialised |= -1; - return OGGZ_CONTINUE; - } - - /* Ensure the video frames don't require more pixels than our - * allowed maximum. */ - if (frame_is_too_large(&decoder->video_info, - common->player->max_video_frame_pixels)) { - return OGGZ_ERR_OUT_OF_MEMORY; - } - - if (theora_decode_init(&(decoder->video_handle), &(decoder->video_info))) { - common->initialised |= -1; - return OGGZ_CONTINUE; - } - - common->initialised |= 1; - } - return OGGZ_CONTINUE; - } else if (common->num_header_packets != 0) { - /* - * Invalid Ogg file. Missing headers - * - */ - return -1; - } - - /* - * if we get to here then we've passed all the header packets - */ - if (common->current_loc == -1) - common->current_loc = 0; - - /* - * Decode the frame - */ - -#if TIME_THEORA_DECODE - gettimeofday(&tv, NULL); -#endif - - if (theora_decode_packetin(&(decoder->video_handle), op) < 0) { - return OGGZ_CONTINUE; - } - - if (theora_decode_YUVout(&(decoder->video_handle), &buffer) < 0) { - return OGGZ_CONTINUE; - } - -#if TIME_THEORA_DECODE - gettimeofday(&tv2, NULL); - musec = tv2.tv_usec - tv.tv_usec; - if (tv2.tv_sec > tv.tv_sec) - musec += (tv2.tv_sec - tv.tv_sec) * 1000000; - printf("decode took %dus\n", musec); -#endif - - if (granulepos != -1) { - int version = - THEORA_VERSION(decoder->video_info.version_major, - decoder->video_info.version_minor, - decoder->video_info.version_subminor); - - /* - * save last granule position in order to be able to validate - * that it's monotonically increasing - */ - common->last_granulepos = granulepos; - - /* calculate the frame number */ - granuleshift = oggz_get_granuleshift(oggz, serialno); - frame = (granulepos >> granuleshift); - /* From theora bitstream version 3.2.1 onwards, frame granule numbers are - * relative to the end of the frame, i.e. frame granule numbers start at 1. - * We calcualte the presentation time as frame_number * granule_period, - * but that's only correct if frame numbers start at 0 (else it's the end - * time), so subtract 1 from the frame number if this is a theora stream - * of version 3.2.1 or greater to ensure correct presentation time - * calculation. - */ - if (version >= THEORA_VERSION(3,2,1)) { - frame--; - } - frame += (granulepos & ((1 << granuleshift) - 1)); - - /* calculate the current location in the stream */ - common->current_loc = frame * common->granuleperiod; - } else { - common->current_loc = -1; - } - - if - ( - (common->current_loc == -1) - || - (common->current_loc >= common->player->presentation_time) - ) - { - /* - * store the frame, - * use the buffer stride for the width to avoid passing negative stride - * issues on to the user. - */ - ret = oggplay_data_handle_theora_frame(decoder, &buffer); - if (ret != E_OGGPLAY_CONTINUE) { - return OGGZ_ERR_OUT_OF_MEMORY; - } - } - - if (op->e_o_s) { - common->active = 0; - common->player->active_tracks--; - } - - return OGGZ_CONTINUE; - -} - -void -oggplay_init_cmml (void * user_data) { - - OggPlayCmmlDecode * decoder = (OggPlayCmmlDecode *)user_data; - - if (decoder == NULL) { - return; - } - - decoder->decoder.decoded_type = OGGPLAY_CMML; - decoder->granuleshift = 32; /* default */ -} - -int -oggplay_callback_cmml (OGGZ * oggz, ogg_packet * op, long serialno, - void * user_data) { - - OggPlayCmmlDecode * decoder = (OggPlayCmmlDecode *)user_data; - OggPlayDecode * common = NULL; - ogg_int64_t granulepos = oggz_tell_granulepos (oggz); - OggPlayErrorCode ret; - - if (decoder == NULL) { - return OGGZ_STOP_ERR; - } - - if ((common = &(decoder->decoder)) == NULL) { - return OGGZ_STOP_ERR; - } - - if (common->num_header_packets) { - /* - * Process the headers of the CMML stream. - */ - - if (common->num_header_packets == 3) { - /* The CMML ident header packet */ - if (memcmp(op->packet, "CMML\0\0\0\0", 8) == 0) { - decoder->granuleshift = op->packet[28]; - } else { - /* Missing ident header ... */ - common->initialised |= -1; - } - } else if (common->num_header_packets == 2) { - /* CMML secondary header, with xml preamble and cmml tag */ - } else if (common->num_header_packets == 1) { - /* CMML secondary header, head tag */ - } - - if (!(--common->num_header_packets)) - common->initialised |= 1; - - } else { - /* - * Process the CMML stream content. - */ - - if (decoder->granuleshift > 0) { - granulepos >>= decoder->granuleshift; - } - - common->current_loc = granulepos * common->granuleperiod; - - ret = oggplay_data_handle_cmml_data (common, op->packet, op->bytes); - if (ret != E_OGGPLAY_CONTINUE) { - return OGGZ_ERR_OUT_OF_MEMORY; - } - } - - return OGGZ_CONTINUE; - -} - -void -oggplay_init_skel (void * user_data) { - - OggPlaySkeletonDecode * decoder = (OggPlaySkeletonDecode *)user_data; - - decoder->presentation_time = 0; - decoder->base_time = 0; -} - -static inline unsigned long extract_int32(unsigned char *data) { - return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); -} - -static inline ogg_int64_t extract_int64(unsigned char *data) { - return ((ogg_int64_t)(extract_int32(data))) | - (((ogg_int64_t)(extract_int32(data + 4))) << 32); -} - -int -oggplay_callback_skel (OGGZ * oggz, ogg_packet * op, long serialno, - void * user_data) { - - OggPlaySkeletonDecode * decoder = (OggPlaySkeletonDecode *)user_data; - - /* check whether user_input is valid */ - if (decoder == NULL) { - return OGGZ_STOP_ERR; - } - - if (strncmp((char *)op->packet, "fishead", 7) == 0) { - ogg_int64_t pt_num, pt_den, bt_num, bt_den; - - pt_num = extract_int64(op->packet + 12); - pt_den = extract_int64(op->packet + 20); - bt_num = extract_int64(op->packet + 28); - bt_den = extract_int64(op->packet + 36); - - if (pt_den != 0) { - decoder->presentation_time = OGGPLAY_TIME_INT_TO_FP(pt_num) / pt_den; - } else { - decoder->presentation_time = 0; - } - if (bt_den != 0) { - decoder->base_time = OGGPLAY_TIME_INT_TO_FP(bt_num) / bt_den; - } else { - decoder->base_time = 0; - } - - /* initialise the presentation times in the player to the values recorded in the skeleton */ - decoder->decoder.player->presentation_time = decoder->presentation_time; - - decoder->decoder.initialised = 1; - decoder->decoder.num_header_packets--; - } else { - int i; - long preroll = extract_int32(op->packet + 44); - long serialno = extract_int32(op->packet + 12); - OggPlay * player = decoder->decoder.player; - //ogg_int64_t start_granule = extract_int64(op->packet + 36); - - for (i = 1; i < player->num_tracks; i++) { - if (player->decode_data[i]->serialno == serialno) { - player->decode_data[i]->preroll = preroll; - break; - } - } - } - - return OGGZ_CONTINUE; - -} - -int -oggplay_fish_sound_callback_floats(FishSound * fsound, float ** pcm, - long frames, void *user_data) { - - OggPlayAudioDecode * decoder = (OggPlayAudioDecode *)user_data; - OggPlayDecode * common = NULL; - - if (decoder == NULL) { - return FISH_SOUND_STOP_ERR; - } - - if ((common = &(decoder->decoder)) == NULL) { - return FISH_SOUND_STOP_ERR; - } - - /* - * calculate the current location here so that it's only updated when - * audio data is actually available for processing - */ - if (common->last_granulepos > 0) { - common->current_loc = common->last_granulepos * common->granuleperiod; - } else { - common->current_loc = -1; - } - - if - ( - (common->current_loc == -1) - || - (common->current_loc >= common->player->presentation_time) - ) - { - /* - * store the frame - */ - oggplay_data_handle_audio_data(common, (short *)pcm, - frames, sizeof(float)); - - return FISH_SOUND_STOP_ERR; - } - - return FISH_SOUND_CONTINUE; -} - -void -oggplay_init_audio (void * user_data) { - - OggPlayAudioDecode * decoder = (OggPlayAudioDecode *)user_data; - - if (decoder == NULL) { - return; - } - - decoder->sound_handle = fish_sound_new(FISH_SOUND_DECODE, - &(decoder->sound_info)); - - if (decoder->sound_handle == NULL) { - return; - } - - decoder->sound_info.channels = 0; - fish_sound_set_decoded_float_ilv(decoder->sound_handle, - oggplay_fish_sound_callback_floats, - (void *)decoder); - - decoder->decoder.decoded_type = OGGPLAY_FLOATS_AUDIO; - decoder->decoder.player->active_tracks++; -} - -void -oggplay_shutdown_audio(void *user_data) { - - OggPlayAudioDecode * decoder = (OggPlayAudioDecode *)user_data; - - if (decoder == NULL) { - return; - } - - fish_sound_delete(decoder->sound_handle); - -} - -int -oggplay_callback_audio (OGGZ * oggz, ogg_packet * op, long serialno, - void * user_data) { - - OggPlayAudioDecode * decoder = (OggPlayAudioDecode *)user_data; - OggPlayDecode * common = NULL; - ogg_int64_t granulepos = oggz_tell_granulepos(oggz); - long bytes_read; - - /* check user input (user_data) */ - if (decoder == NULL) { - return OGGZ_STOP_ERR; - } - - if ((common = &(decoder->decoder)) == NULL) { - return OGGZ_STOP_ERR; - } - - if (granulepos > 0 && (!common->active)) { - return OGGZ_CONTINUE; - } - - if ((granulepos > 0) && (common->last_granulepos > granulepos)) { - return OGGZ_CONTINUE; - } - - /* Blindly register that we've processed a header packet. */ - if (common->num_header_packets) --common->num_header_packets; - - common->last_granulepos = granulepos; - - fish_sound_prepare_truncation (decoder->sound_handle, op->granulepos, - op->e_o_s); - - bytes_read = fish_sound_decode (decoder->sound_handle, op->packet, op->bytes); - switch (bytes_read) { - case FISH_SOUND_ERR_OUT_OF_MEMORY: - /* we ran out of memory... stop decoding. */ - return OGGZ_ERR_OUT_OF_MEMORY; - - case FISH_SOUND_ERR_GENERIC: - { - /* - * error occured while decoding the audio track - * disable the track, but if there are other tracks to decode - * contine decoding... - */ - - common->active = 0; - - if (common->player->active_tracks) common->player->active_tracks--; - if (common->num_header_packets >= 0) common->initialised |= -1; - - return OGGZ_CONTINUE; - } - - default: - /* there was no problem with decoding */ - if (!common->num_header_packets) common->initialised |= 1; - break; - } - - if (bytes_read < 0) { - printf("\nERROR HADNLING MISMATCH BETWEEN liboggplay AND mozilla\n\n"); - // Unrecoverable error, disable track - op->e_o_s = 1; - common->active = 0; - common->player->active_tracks--; - return OGGZ_ERR_HOLE_IN_DATA; - } - - - if (decoder->sound_info.channels == 0) { - fish_sound_command(decoder->sound_handle, FISH_SOUND_GET_INFO, - &(decoder->sound_info), sizeof(FishSoundInfo)); - } - - if (op->e_o_s) { - common->active = 0; - common->player->active_tracks--; - } - - return OGGZ_CONTINUE; -} - -void -oggplay_init_kate(void *user_data) { - -#ifdef HAVE_KATE - int ret; - OggPlayKateDecode * decoder = (OggPlayKateDecode *)user_data; - - if (decoder == NULL) { - return; - } - - decoder->decoder.decoded_type = OGGPLAY_KATE; - kate_info_init (&(decoder->k_info)); - kate_comment_init (&(decoder->k_comment)); - -#ifdef HAVE_TIGER - decoder->use_tiger = 1; - decoder->overlay_dest = -1; - decoder->swap_rgb = 0; - decoder->default_width = -1; - decoder->default_height = -1; - - ret = tiger_renderer_create(&(decoder->tr)); - if (ret < 0) { - /* what to do ? */ - decoder->tr = NULL; - } - if (decoder->use_tiger) { - decoder->decoder.decoded_type = OGGPLAY_RGBA_VIDEO; - } -#endif - -#endif -} - -void -oggplay_shutdown_kate(void *user_data) { - -#ifdef HAVE_KATE - OggPlayKateDecode * decoder = (OggPlayKateDecode *)user_data; - - if (decoder == NULL) { - return; - } -#ifdef HAVE_TIGER - if (decoder->tr) { - tiger_renderer_destroy(decoder->tr); - } -#endif - - if (decoder->decoder.initialised == 1) { - kate_clear (&(decoder->k_state)); - } - - kate_info_clear (&(decoder->k_info)); - kate_comment_clear (&(decoder->k_comment)); - -#endif -} - -int -oggplay_callback_kate (OGGZ * oggz, ogg_packet * op, long serialno, - void * user_data) { - -#ifdef HAVE_KATE - OggPlayKateDecode * decoder = (OggPlayKateDecode *)user_data; - OggPlayDecode * common = NULL; - ogg_int64_t granulepos = oggz_tell_granulepos(oggz); - int granuleshift; - ogg_int64_t base, offset; - kate_packet kp; - const kate_event *ev = NULL; - int ret; - - /* - * Basic error checking. - */ - if (decoder == NULL) { - return OGGZ_STOP_ERR; - } - - if ((common = &(decoder->decoder)) == NULL) { - return OGGZ_STOP_ERR; - } - - /* - * Stop processing the Ogg packet if the stream is not active. - */ - if (!common->active) { - return OGGZ_CONTINUE; - } - - /* create a kate_packet from the received ogg_packet */ - kate_packet_wrap (&kp, op->bytes, op->packet); - - /* - * Decode the headers of the kate stream. - */ - if (common->num_header_packets) { - ret = kate_decode_headerin (&(decoder->k_info), &(decoder->k_comment), &kp); - - if (ret == KATE_E_OUT_OF_MEMORY) { - return OGGZ_ERR_OUT_OF_MEMORY; - } - - common->initialised |= (ret < 0 ? -1 : ret); - common->num_header_packets--; - - /* if we _successfully_ processed all the headers initialise the decoder */ - if (!common->num_header_packets && (common->initialised == 1)) { - ret = kate_decode_init (&(decoder->k_state), &(decoder->k_info)); - - if (ret == KATE_E_OUT_OF_MEMORY) { - return OGGZ_ERR_OUT_OF_MEMORY; - } else if (ret < 0) { - common->initialised |= -1; - } - } - - return OGGZ_CONTINUE; - } - - /* - * Decode the payload of the stream. - */ - - ret = kate_decode_packetin (&(decoder->k_state), &kp); - if (ret == KATE_E_OUT_OF_MEMORY) { - return OGGZ_ERR_OUT_OF_MEMORY; - } else if (ret < 0){ - return OGGZ_CONTINUE; - } - - ret = kate_decode_eventout (&(decoder->k_state), &ev); - if (ret < 0) { - return OGGZ_CONTINUE; - } - - if (granulepos != -1) { - granuleshift = oggz_get_granuleshift(oggz, serialno); - base = (granulepos >> granuleshift); - offset = granulepos - (base << granuleshift); - common->current_loc = (base+offset) * common->granuleperiod; - } else { - common->current_loc = -1; - } - - if - ( - (common->current_loc == -1) - || - (common->current_loc >= common->player->presentation_time) - ) - { - /* - * process the data from the packet - * */ - if (ev) { - if (oggplay_data_handle_kate_data(decoder, ev) != E_OGGPLAY_CONTINUE) { - return OGGZ_ERR_OUT_OF_MEMORY; - } - } - } - - if (op->e_o_s) { - common->active = 0; - } - -#endif - - return OGGZ_CONTINUE; - -} - -OggPlayCallbackFunctions callbacks[] = { - {oggplay_init_theora, oggplay_callback_theora, oggplay_shutdown_theora, - sizeof(OggPlayTheoraDecode)}, /* THEORA */ - {oggplay_init_audio, oggplay_callback_audio, oggplay_shutdown_audio, - sizeof(OggPlayAudioDecode)}, /* VORBIS */ - {oggplay_init_audio, oggplay_callback_audio, oggplay_shutdown_audio, - sizeof(OggPlayAudioDecode)}, /* SPEEX */ - {NULL, NULL, NULL, sizeof(OggPlayDecode)}, /* PCM */ - {oggplay_init_cmml, oggplay_callback_cmml, NULL, sizeof(OggPlayCmmlDecode)}, /* CMML */ - {NULL, NULL, NULL, sizeof(OggPlayDecode)}, /* ANX2 */ - {oggplay_init_skel, oggplay_callback_skel, NULL, - sizeof(OggPlaySkeletonDecode)}, /* SKELETON */ - {NULL, NULL, NULL, sizeof(OggPlayDecode)}, /* FLAC0 */ - {NULL, NULL, NULL, sizeof(OggPlayDecode)}, /* FLAC */ - {NULL, NULL, NULL, sizeof(OggPlayDecode)}, /* ANXDATA */ - {NULL, NULL, NULL, sizeof(OggPlayDecode)}, /* CELT */ - {oggplay_init_kate, oggplay_callback_kate, oggplay_shutdown_kate, - sizeof(OggPlayKateDecode)}, /* KATE */ - {NULL, NULL, NULL, sizeof(OggPlayDecode)}, /* DIRAC */ - {NULL, NULL, NULL, sizeof(OggPlayDecode)} /* UNKNOWN */ -}; - -OggPlayDecode * -oggplay_initialise_decoder(OggPlay *me, int content_type, long serialno) { - - ogg_int64_t num; - ogg_int64_t denom; - OggPlayDecode *decoder = NULL; - - if (me == NULL) - return NULL; - - decoder = oggplay_malloc (callbacks[content_type].size); - - if (decoder == NULL) - return NULL; - - decoder->serialno = serialno; - decoder->content_type = content_type; - decoder->content_type_name = - oggz_stream_get_content_type (me->oggz, serialno); - decoder->active = 1; - decoder->final_granulepos = -1; - decoder->player = me; - decoder->decoded_type = OGGPLAY_TYPE_UNKNOWN; - decoder->num_header_packets = - oggz_stream_get_numheaders (me->oggz, serialno); - - /* - * set the StreamInfo to unitialised until we get some real data in - */ - decoder->stream_info = OGGPLAY_STREAM_UNINITIALISED; - - /* - * set to -1 until headers decoded - */ - decoder->current_loc = -1; - decoder->last_granulepos = 0; - - /* - * the offset is how far advanced or delayed this track is to the "standard" - * time position. An offset of 1000, for example, indicates that data for - * this track arrives 1 second in advance of data for other tracks - */ - decoder->offset = 0; - - oggz_get_granulerate(me->oggz, serialno, &num, &denom); - - /* - * convert num and denom to a 32.32 fixed point value - */ - if (num != 0) { - decoder->granuleperiod = OGGPLAY_TIME_INT_TO_FP(denom) / num; - } else { - decoder->granuleperiod = 0; - } - - if (callbacks[content_type].init != NULL) { - callbacks[content_type].init(decoder); - decoder->initialised = 0; - } else { - decoder->initialised = -1; - } - - oggplay_data_initialise_list(decoder); - - return decoder; -} - - -/* - * this function needs to be called on each track to clear up allocated memory - */ -void -oggplay_callback_shutdown(OggPlayDecode *decoder) { - - if (decoder == NULL) { - return; - } - - if (callbacks[decoder->content_type].shutdown != NULL) { - callbacks[decoder->content_type].shutdown(decoder); - } - - oggplay_data_shutdown_list(decoder); - - oggplay_free(decoder); -} - - -/* - * this is the callback that is used before all track types have been - * determined - i.e. at the beginning of an ogg bitstream or at the start - * of a new chain - */ -int -oggplay_callback_predetected (OGGZ *oggz, ogg_packet *op, long serialno, - void *user_data) { - - OggPlay * me = (OggPlay *)user_data; - int i; - int content_type = 0; - int ret = OGGZ_CONTINUE; - short new_stream = 1; - short read_more = 0; - ogg_int64_t granulepos = oggz_tell_granulepos(oggz); - - if (me == NULL) { - return OGGZ_STOP_ERR; - } - - content_type = oggz_stream_get_content (me->oggz, serialno); - - for (i = 0; i < me->num_tracks; i++) { - if (serialno == me->decode_data[i]->serialno) { - /* - * call appropriate callback - */ - if (callbacks[content_type].callback != NULL) { - ret = callbacks[content_type].callback(oggz, op, serialno, - me->decode_data[i]); - } - - new_stream = 0; - } - - /* a track that hasn't got all it's headers, but others are already having - * valueable data. A badly multiplexed Ogg file, as the specification - * requires that all headers has to be before any data comes. - * Instead of marking the whole file as a bad one, try to decode - * the streams, which headers are successfully decoded. - * and disable the tracks that haven't got enough header info. - */ - if (granulepos && me->decode_data[i]->num_header_packets) { - me->decode_data[i]->initialised = -1; - } - - /* - * check whether there is a stream that has not - * decoded all it's headers - */ - read_more |= (me->decode_data[i]->num_header_packets && (me->decode_data[i]->initialised != -1)); - } - - if (new_stream) { - /* check for possible overflow ... */ - if - ( - (++me->num_tracks <= 0) - || - (OGGPLAY_TYPE_MAX(size_t)/(me->num_tracks) < sizeof(OggPlayCallbackInfo)) - || - (OGGPLAY_TYPE_MAX(size_t)/me->num_tracks < sizeof(long)) - ) - { - return OGGZ_STOP_ERR; - } - - me->callback_info = oggplay_realloc (me->callback_info, - sizeof (OggPlayCallbackInfo) * me->num_tracks); - if (me->callback_info == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - - me->decode_data = oggplay_realloc (me->decode_data, - sizeof (long) * me->num_tracks); - if (me->decode_data == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - - me->decode_data[me->num_tracks - 1] = - oggplay_initialise_decoder(me, content_type, serialno); - if (me->decode_data[me->num_tracks - 1] == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - - /* - * call appropriate callback - */ - if (callbacks[content_type].callback != NULL) { - ret = callbacks[content_type].callback(oggz, op, serialno, - me->decode_data[me->num_tracks - 1]); - } - } else if (!read_more) { - /* - * all tracks' headers has been processed - * initialisation phase done, process the payloads. - */ - me->all_tracks_initialised = 1; - - /* set up all the callbacks for the detected streams */ - for (i = 0; i < me->num_tracks; i++) { - serialno = me->decode_data[i]->serialno; - content_type = oggz_stream_get_content (me->oggz, serialno); - if (oggz_set_read_callback (me->oggz, serialno, - callbacks[content_type].callback, - me->decode_data[i]) != 0) - { - return OGGZ_STOP_ERR; - } - } - - /* disable the callback for unforeseen streams */ - oggz_set_read_callback (me->oggz, -1, NULL, NULL); - } - - /* read the header part of the ogg content in a packet-by-packet manner */ - return ((ret < 0) ? ret : OGGZ_CONTINUE); -} diff --git a/media/liboggplay/src/liboggplay/oggplay_callback.h b/media/liboggplay/src/liboggplay/oggplay_callback.h deleted file mode 100644 index 986b844a847..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_callback.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_callback.h - * - * Shane Stephens - */ -#ifndef __OGGPLAY_CALLBACK_H__ -#define __OGGPLAY_CALLBACK_H__ - -int -oggplay_callback_predetected (OGGZ *oggz, ogg_packet *op, long serialno, - void *user_data); - -void -oggplay_process_leftover_packet(OggPlay *me); - -/** - * Create and initialise an OggPlayDecode handle. - * - * - * - * @param me OggPlay - * @param content_type - * @param serialno - * @return A new OggPlayDecode handle - * @retval NULL in case of error. - */ -OggPlayDecode * -oggplay_initialise_decoder(OggPlay *me, int content_type, long serialno); - -int -oggplay_callback_info_prepare(OggPlay *me, OggPlayCallbackInfo ***info); - -void -oggplay_callback_info_destroy(OggPlay *me, OggPlayCallbackInfo **info); - -void -oggplay_callback_shutdown(OggPlayDecode *decoder); -#endif diff --git a/media/liboggplay/src/liboggplay/oggplay_callback_info.c b/media/liboggplay/src/liboggplay/oggplay_callback_info.c deleted file mode 100644 index 34c01a89c24..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_callback_info.c +++ /dev/null @@ -1,506 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_callback_info.c - * - * Shane Stephens - */ -#include "oggplay_private.h" -#include - -extern void _print_list(char *name, OggPlayDataHeader *p); - -static void -clear_callback_info (OggPlay *me, OggPlayCallbackInfo ***info) { - int i; - - for (i = 0; i < me->num_tracks; ++i) { - if (((*info)[i] != NULL) && ((*info)[i]->records != NULL)) { - oggplay_free ((*info)[i]->records); - } - } - oggplay_free (*info); - *info = NULL; -} - -int -oggplay_callback_info_prepare(OggPlay *me, OggPlayCallbackInfo ***info) { - - int i; - int tcount = 0; - - int added_required_record = me->num_tracks; - ogg_int64_t diff; - ogg_int64_t latest_first_record = 0x0LL; - //ogg_int64_t lpt = 0; - - /* - * allocate the structure for return to the user - */ - (*info) = oggplay_calloc (me->num_tracks, sizeof (OggPlayCallbackInfo *)); - if ((*info) == NULL) - return E_OGGPLAY_OUT_OF_MEMORY; - - /* - * fill in each active track. Leave gaps for inactive tracks. - */ - for (i = 0; i < me->num_tracks; i++) { - OggPlayDecode * track = me->decode_data[i]; - OggPlayCallbackInfo * track_info = me->callback_info + i; - size_t count = 0; - OggPlayDataHeader * p; - OggPlayDataHeader * q = NULL; - - (*info)[i] = track_info; - -#ifdef HAVE_TIGER - /* not so nice to have this here, but the tiger_renderer needs updating regularly - * as some items may be animated, so would yield data without the stream actually - * receiving any packets. - * In addition, Kate streams can now be overlayed on top of a video, so this needs - * calling to render the overlay. - * FIXME: is this the best place to put this ? Might do too much work if the info - * is going to be destroyed ? - */ - if (track->content_type == OGGZ_CONTENT_KATE) { - OggPlayKateDecode *decode = (OggPlayKateDecode *)track; - OggPlayCallbackInfo * video_info = NULL; - if (decode->overlay_dest >= 0) - video_info = me->callback_info + decode->overlay_dest; - oggplay_data_update_tiger(decode, track->active, me->target, video_info); - } -#endif - - /* - * this track is inactive and has no data - create an empty record - * for it - */ - if (track->active == 0 && track->data_list == NULL) { - track_info->data_type = OGGPLAY_INACTIVE; - track_info->available_records = track_info->required_records = 0; - track_info->records = NULL; - track_info->stream_info = OGGPLAY_STREAM_UNINITIALISED; - added_required_record --; - continue; - } - - /* - * find the first not presented packet of data, count the total number that - * have not been presented - */ - for (p = track->data_list; p != NULL; p = p->next) { - if (!p->has_been_presented) { - if (q == NULL) { - q = p; - } - - /* check for overflow */ - if - ( - oggplay_check_add_overflow (count, 1, &count) - == - E_OGGPLAY_TYPE_OVERFLOW - ) - { - clear_callback_info (me, info); - return E_OGGPLAY_TYPE_OVERFLOW; - } - } - } - - /* - * tcount is set if any of the tracks have unpresented data - */ - if (count > 0) { - tcount = 1; - - /* - * set this track's StreamState. If the track isn't active and there's - * only one timestamp's worth of data in the data list, then this is - * the last data! - */ - if - ( - track->active == 0 - && - ( - track->end_of_data_list->presentation_time - <= - me->target + track->offset - ) - ) - { - track_info->stream_info = OGGPLAY_STREAM_LAST_DATA; - } else { - track_info->stream_info = track->stream_info; - } - - } else { - track_info->stream_info = OGGPLAY_STREAM_UNINITIALISED; - } - - if ((count+1) < count) { - clear_callback_info (me, info); - return E_OGGPLAY_TYPE_OVERFLOW; - } - /* null-terminate the record list for the python interface */ - track_info->records = - oggplay_calloc ((count+1), sizeof (OggPlayDataHeader *)); - if (track_info->records == NULL) { - clear_callback_info (me, info); - return E_OGGPLAY_OUT_OF_MEMORY; - } - - track_info->records[count] = NULL; - - track_info->available_records = count; - track_info->required_records = 0; - - track_info->data_type = track->decoded_type; - - count = 0; - for (p = q; p != NULL; p = p->next) { - if (!p->has_been_presented) { - track_info->records[count++] = p; - if (p->presentation_time <= me->target + track->offset) { - track_info->required_records++; - p->has_been_presented = 1; - //lpt = p->presentation_time; - } - } - } - - if (track_info->required_records > 0) { - /* - * if the StreamState is FIRST_DATA then update it to INITIALISED, - * as we've marked the first data instance - */ - if - ( - track->stream_info == OGGPLAY_STREAM_FIRST_DATA - || - track->stream_info == OGGPLAY_STREAM_JUST_SEEKED - ) - { - track->stream_info = OGGPLAY_STREAM_INITIALISED; - } - - } - - /* - printf("%d: %d/%d\t", i, - track_info->required_records, count); - - if (q != NULL) { - printf("fst: %lld lst: %lld sz: %lld pt: %lld\n", - q->presentation_time >> 32, lpt >> 32, - (lpt - q->presentation_time) >> 32, - me->presentation_time >> 32); - } - */ - - /* - * this statement detects if this track needs records but has none. - * We need to be careful - there are 2 cases where this could happen. The - * first is where the presentation time is less than it should be, and - * there is no data available between now and the target. In this case - * we want to set added_required_record to 0 and trigger the presentation - * time update code below. - * <-------data----------... - * ^ ^ ^ - * pt target current_loc - * - * The second case occurs when the packet from the last timestamp contained - * so much data that there *is* none in this timestamp. In this case we - * don't want to set added_required_record to 0. - * - * <----------data---------------|--------... - * <-timeslice1-><-timeslice2-><-timeslice3-> - * ^ ^ ^ - * pt target current_loc - * - * How do we discriminate between these two cases? We assume the pt update - * needs to be explicitly required (e.g. by seeking or start of movie), and - * create a new member in the player struct called pt_update_valid - */ - // TODO: I don't think that pt_update_valid is necessary any more, as this will only - // trigger now if there's no data in *ANY* of the tracks. Hence the audio timeslice case - // doesn't apply. - if - ( - track->decoded_type == OGGPLAY_CMML - || - track->decoded_type == OGGPLAY_KATE // TODO: check this is the right thing to do - || - ( - track_info->required_records == 0 - && - track->active == 1 - && - me->pt_update_valid - ) - ) { - added_required_record --; - } - - } /* end of for loop, that fills each track */ - - me->pt_update_valid = 0; - - //printf("\n"); - - /* - * there are no required records! This means that we need to advance the - * target to the period before the first actual record - the bitstream has - * lied about the presence of data here. - * - * This happens for example with some Annodex streams (a bug in libannodex - * causes incorrect timestamping) - * - * What we actually need is the first timestamp *just before* a timestamp - * with valid data on all active tracks that are not CMML tracks. - */ - latest_first_record = 0x0LL; - if (tcount > 0 && added_required_record == 0) { - for (i = 0; i < me->num_tracks; i++) { - OggPlayCallbackInfo * track_info = me->callback_info + i; - if (track_info->data_type == OGGPLAY_CMML || track_info->data_type == OGGPLAY_KATE) { - continue; - } - if (track_info->available_records > 0) { - if (track_info->records[0]->presentation_time > latest_first_record) { - latest_first_record = track_info->records[0]->presentation_time; - } - } - } - /* - * update target to the time-period before the first record. This is - * independent of the offset (after all, we want to maintain synchronisation - * between the streams). - */ - diff = latest_first_record - me->target; - diff = (diff / me->callback_period) * me->callback_period; - me->target += diff + me->callback_period; - - - /* - * update the presentation_time to the latest_first_record. This ensures - * that we don't play material for timestamps that only exist in one track. - */ - me->presentation_time = me->target - me->callback_period; - - /* - * indicate that we need to go through another round of fragment collection - * and callback creation - */ - for (i = 0; i < me->num_tracks; i++) { - if ((*info)[i]->records != NULL) - oggplay_free((*info)[i]->records); - } - oggplay_free(*info); - (*info) = NULL; - - } - - if (tcount == 0) { - for (i = 0; i < me->num_tracks; i++) { - if ((*info)[i]->records != NULL) - oggplay_free((*info)[i]->records); - } - oggplay_free(*info); - (*info) = NULL; - } - - return me->num_tracks; - -} - - -void -oggplay_callback_info_destroy(OggPlay *me, OggPlayCallbackInfo **info) { - - int i; - OggPlayCallbackInfo * p; - - for (i = 0; i < me->num_tracks; i++) { - p = info[i]; - if (me->buffer == NULL && p->records != NULL) - oggplay_free(p->records); - } - - oggplay_free(info); - -} - -OggPlayDataType -oggplay_callback_info_get_type(OggPlayCallbackInfo *info) { - - if (info == NULL) { - return (OggPlayDataType)E_OGGPLAY_BAD_CALLBACK_INFO; - } - - return info->data_type; - -} - -int -oggplay_callback_info_get_available(OggPlayCallbackInfo *info) { - - if (info == NULL) { - return E_OGGPLAY_BAD_CALLBACK_INFO; - } - - return info->available_records; - -} - -int -oggplay_callback_info_get_required(OggPlayCallbackInfo *info) { - - if (info == NULL) { - return E_OGGPLAY_BAD_CALLBACK_INFO; - } - - return info->required_records; - -} - -OggPlayStreamInfo -oggplay_callback_info_get_stream_info(OggPlayCallbackInfo *info) { - - if (info == NULL) { - return E_OGGPLAY_BAD_CALLBACK_INFO; - } - - return info->stream_info; -} - -OggPlayDataHeader ** -oggplay_callback_info_get_headers(OggPlayCallbackInfo *info) { - - if (info == NULL) { - return NULL; - } - - return info->records; - -} - -/** - * Returns number of samples in the record - * Note: the resulting data include samples for all audio channels */ -ogg_int64_t -oggplay_callback_info_get_record_size(OggPlayDataHeader *header) { - - if (header == NULL) { - return 0; - } - - return header->samples_in_record; - -} - -void -oggplay_callback_info_lock_item(OggPlayDataHeader *header) { - - if (header == NULL) { - return; - } - - header->lock += 1; - -} - -void -oggplay_callback_info_unlock_item(OggPlayDataHeader *header) { - - if (header == NULL) { - return; - } - - header->lock -= 1; -} - -long -oggplay_callback_info_get_presentation_time(OggPlayDataHeader *header) { - - if (header == NULL) { - return -1; - } - - return OGGPLAY_TIME_FP_TO_INT(header->presentation_time); -} - -OggPlayVideoData * -oggplay_callback_info_get_video_data(OggPlayDataHeader *header) { - - if (header == NULL) { - return NULL; - } - - return &((OggPlayVideoRecord *)header)->data; - -} - -OggPlayOverlayData * -oggplay_callback_info_get_overlay_data(OggPlayDataHeader *header) { - - if (header == NULL) { - return NULL; - } - - return &((OggPlayOverlayRecord *)header)->data; - -} - -OggPlayAudioData * -oggplay_callback_info_get_audio_data(OggPlayDataHeader *header) { - - if (header == NULL) { - return NULL; - } - - return (OggPlayAudioData *)((OggPlayAudioRecord *)header)->data; -} - -OggPlayTextData * -oggplay_callback_info_get_text_data(OggPlayDataHeader *header) { - - if (header == NULL) { - return NULL; - } - - return ((OggPlayTextRecord *)header)->data; - -} - diff --git a/media/liboggplay/src/liboggplay/oggplay_data.c b/media/liboggplay/src/liboggplay/oggplay_data.c deleted file mode 100644 index 2e9c8788e78..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_data.c +++ /dev/null @@ -1,736 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_data.c - * - * Shane Stephens - */ - -#include "oggplay_private.h" -#include "oggplay/oggplay_callback_info.h" - -#include -#include - -#if HAVE_INTTYPES_H -#include -#else -#if LONG_MAX==2147483647L -#define PRId64 "lld" -#else -#define PRId64 "ld" -#endif -#endif - -/* - * the normal lifecycle for a frame is: - * - * (1) frame gets decoded and added to list with a locking value of 1 - * (2) frame gets delivered to user - * (3) frame becomes out-of-date (its presentation time expires) and its - * lock is decremented - * (4) frame is removed from list and freed - * - * This can be modified by: - * (a) early consumption by user (user calls oggplay_mark_record_consumed) - * (b) frame locking by user (user calls oggplay_mark_record_locked) and - * subsequent unlocking (user calls oggplay_mark_record_consumed) - */ - -void -oggplay_data_initialise_list (OggPlayDecode *decode) { - - if (decode == NULL) { - return; - } - - decode->data_list = decode->end_of_data_list = NULL; - decode->untimed_data_list = NULL; - -} - -/* - * helper function to append data packets to end of data_list - */ -void -oggplay_data_add_to_list_end(OggPlayDecode *decode, OggPlayDataHeader *data) { - - if (decode == NULL) { - return; - } - - data->next = NULL; - - if (decode->data_list == NULL) { - decode->data_list = data; - decode->end_of_data_list = data; - } else { - decode->end_of_data_list->next = data; - decode->end_of_data_list = data; - } - -} - -/* - * helper function to append data packets to front of data_list - */ -void -oggplay_data_add_to_list_front(OggPlayDecode *decode, OggPlayDataHeader *data) { - if (decode == NULL) { - return; - } - - if (decode->data_list == NULL) { - decode->data_list = decode->end_of_data_list = data; - data->next = NULL; - } else { - data->next = decode->data_list; - decode->data_list = data; - } -} - -void -_print_list(char *name, OggPlayDataHeader *p) { - printf("%s: ", name); - for (; p != NULL; p = p->next) { - printf("%"PRId64"[%d]", OGGPLAY_TIME_FP_TO_INT (p->presentation_time), p->lock); - if (p->next != NULL) printf("->"); - } - printf("\n"); -} - - -void -oggplay_data_add_to_list (OggPlayDecode *decode, OggPlayDataHeader *data) { - - /* - * if this is a packet with an unknown display time, prepend it to - * the untimed_data_list for later timestamping. - */ - - ogg_int64_t samples_in_next_in_list; - - if ((decode == NULL) || (data == NULL)) { - return; - } - - //_print_list("before", decode->data_list); - //_print_list("untimed before", decode->untimed_data_list); - - if (data->presentation_time == -1) { - data->next = decode->untimed_data_list; - decode->untimed_data_list = data; - } else { - /* - * process the untimestamped data into the timestamped data list. - * - * First store any old data. - */ - ogg_int64_t presentation_time = data->presentation_time; - samples_in_next_in_list = data->samples_in_record; - - - while (decode->untimed_data_list != NULL) { - OggPlayDataHeader *untimed = decode->untimed_data_list; - - presentation_time -= - samples_in_next_in_list * decode->granuleperiod; - untimed->presentation_time = presentation_time; - decode->untimed_data_list = untimed->next; - samples_in_next_in_list = untimed->samples_in_record; - - if (untimed->presentation_time >= decode->player->presentation_time) { - oggplay_data_add_to_list_front(decode, untimed); - } else { - oggplay_free(untimed); - } - - } - - oggplay_data_add_to_list_end(decode, data); - - /* - * if the StreamInfo is still at uninitialised, then this is the first - * meaningful data packet! StreamInfo will be updated to - * OGGPLAY_STREAM_INITIALISED in oggplay_callback_info.c as part of the - * callback process. - */ - if (decode->stream_info == OGGPLAY_STREAM_UNINITIALISED) { - decode->stream_info = OGGPLAY_STREAM_FIRST_DATA; - } - - } - - //_print_list("after", decode->data_list); - //_print_list("untimed after", decode->untimed_data_list); - -} - -void -oggplay_data_free_list(OggPlayDataHeader *list) { - OggPlayDataHeader *p; - - while (list != NULL) { - p = list; - list = list->next; - oggplay_free(p); - } -} - -void -oggplay_data_shutdown_list (OggPlayDecode *decode) { - - if (decode == NULL) { - return; - } - - oggplay_data_free_list(decode->data_list); - oggplay_data_free_list(decode->untimed_data_list); - -} - -/* - * this function removes any displayed, unlocked frames from the list. - * - * this function also removes any undisplayed frames that are before the - * global presentation time. - */ -void -oggplay_data_clean_list (OggPlayDecode *decode) { - - ogg_int64_t target; - OggPlayDataHeader * header = NULL; - OggPlayDataHeader * p = NULL; - - if (decode == NULL) { - return; - } - header = decode->data_list; - target = decode->player->target; - - while (header != NULL) { - if - ( - header->lock == 0 - && - ( - ( - (header->presentation_time < (target + decode->offset)) - && - header->has_been_presented - ) - || - ( - (header->presentation_time < decode->player->presentation_time) - ) - ) - - ) - { - if (p == NULL) { - decode->data_list = decode->data_list->next; - if (decode->data_list == NULL) - decode->end_of_data_list = NULL; - oggplay_free (header); - header = decode->data_list; - } else { - if (header->next == NULL) - decode->end_of_data_list = p; - p->next = header->next; - oggplay_free (header); - header = p->next; - } - } else { - p = header; - header = header->next; - } - } -} - -void -oggplay_data_initialise_header (const OggPlayDecode *decode, - OggPlayDataHeader *header) { - - if ((decode == NULL) || (header == NULL)) { - return; - } - - /* - * the frame is not cleaned until its presentation time has passed. We'll - * check presentation times in oggplay_data_clean_list. - */ - header->lock = 0; - header->next = NULL; - header->presentation_time = decode->current_loc; - header->has_been_presented = 0; -} - -OggPlayErrorCode -oggplay_data_handle_audio_data (OggPlayDecode *decode, void *data, - long samples, size_t samplesize) { - - int num_channels, ret; - size_t record_size = sizeof(OggPlayAudioRecord); - long samples_size; - OggPlayAudioRecord * record = NULL; - - num_channels = ((OggPlayAudioDecode *)decode)->sound_info.channels; - - /* check for possible integer overflows....*/ - if ((samples < 0) || (num_channels < 0)) { - return E_OGGPLAY_TYPE_OVERFLOW; - } - - ret = oggplay_mul_signed_overflow (samples, num_channels, &samples_size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - - ret = oggplay_mul_signed_overflow (samples_size, samplesize, &samples_size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - - ret = oggplay_check_add_overflow (record_size, samples_size, &record_size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - - /* try to allocate the memory for the record */ - record = (OggPlayAudioRecord*)oggplay_calloc(record_size, 1); - if (record == NULL) { - return E_OGGPLAY_OUT_OF_MEMORY; - } - - /* initialise the header of OggPlayAudioRecord struct */ - oggplay_data_initialise_header(decode, &(record->header)); - - record->header.samples_in_record = samples; - - record->data = (void *)(record + 1); - - /* copy the received data - the header has been initialised! */ - memcpy (record->data, data, samples_size); - /* - printf("[%f%f%f]\n", ((float *)record->data)[0], ((float *)record->data)[1], - ((float *)record->data)[2]); - */ - oggplay_data_add_to_list(decode, &(record->header)); - - return E_OGGPLAY_CONTINUE; -} - -OggPlayErrorCode -oggplay_data_handle_cmml_data(OggPlayDecode *decode, - unsigned char *data, - long size) { - - OggPlayTextRecord * record = NULL; - size_t record_size = sizeof(OggPlayTextRecord); - - /* Include extra byte for null terminating record data buffer */ - record_size += 1; - - if - ( - oggplay_check_add_overflow (record_size, size, &record_size) - == - E_OGGPLAY_TYPE_OVERFLOW - ) - { - return E_OGGPLAY_TYPE_OVERFLOW; - } - - /* allocate the memory for the record */ - record = (OggPlayTextRecord*)oggplay_calloc (record_size, 1); - if (record == NULL) { - return E_OGGPLAY_OUT_OF_MEMORY; - } - - /* initialise the record's header */ - oggplay_data_initialise_header(decode, &(record->header)); - - record->header.samples_in_record = 1; - record->data = (char *)(record + 1); - - /* copy the data */ - memcpy(record->data, data, size); - record->data[size] = '\0'; - - oggplay_data_add_to_list(decode, &(record->header)); - - return E_OGGPLAY_CONTINUE; -} - -static int -get_uv_offset(OggPlayTheoraDecode *decode, yuv_buffer *buffer) -{ - int xo=0, yo = 0; - if (decode->y_width != 0 && - decode->uv_width != 0 && - decode->y_width/decode->uv_width != 0) { - xo = (decode->video_info.offset_x/(decode->y_width/decode->uv_width)); - } - if (decode->y_height != 0 && - decode->uv_height != 0 && - decode->y_height/decode->uv_height != 0) { - yo = (buffer->uv_stride)*(decode->video_info.offset_y/(decode->y_height/decode->uv_height)); - } - return xo + yo; -} - -int -oggplay_data_handle_theora_frame (OggPlayTheoraDecode *decode, - const yuv_buffer *buffer) { - - size_t size = sizeof (OggPlayVideoRecord); - int i, ret; - long y_size, uv_size, y_offset, uv_offset; - unsigned char * p; - unsigned char * q; - unsigned char * p2; - unsigned char * q2; - OggPlayVideoRecord * record; - OggPlayVideoData * data; - - /* check for possible integer overflows */ - ret = - oggplay_mul_signed_overflow (buffer->y_height, buffer->y_stride, &y_size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - - ret = - oggplay_mul_signed_overflow (buffer->uv_height, buffer->uv_stride, &uv_size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - - ret = oggplay_mul_signed_overflow (uv_size, 2, &uv_size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - - if (buffer->y_stride < 0) { - y_size *= -1; - uv_size *= -1; - } - - ret = oggplay_check_add_overflow (size, y_size, &size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - - ret = oggplay_check_add_overflow (size, uv_size, &size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - - /* - * we need to set the output strides to the input widths because we are - * trying not to pass negative output stride issues on to the poor user. - */ - record = (OggPlayVideoRecord*)oggplay_malloc (size); - - if (record == NULL) { - return E_OGGPLAY_OUT_OF_MEMORY; - } - - record->header.samples_in_record = 1; - data = &(record->data); - - data->y = (unsigned char *)(record + 1); - data->u = data->y + (decode->y_stride * decode->y_height); - data->v = data->u + (decode->uv_stride * decode->uv_height); - - /* - * *grumble* theora plays silly buggers with pointers so we need to do - * a row-by-row copy (stride may be negative) - */ - y_offset = (decode->video_info.offset_x&~1) - + buffer->y_stride*(decode->video_info.offset_y&~1); - p = data->y; - q = buffer->y + y_offset; - for (i = 0; i < decode->y_height; i++) { - memcpy(p, q, decode->y_width); - p += decode->y_width; - q += buffer->y_stride; - } - - uv_offset = get_uv_offset(decode, buffer); - p = data->u; - q = buffer->u + uv_offset; - p2 = data->v; - q2 = buffer->v + uv_offset; - for (i = 0; i < decode->uv_height; i++) { - memcpy(p, q, decode->uv_width); - memcpy(p2, q2, decode->uv_width); - p += decode->uv_width; - p2 += decode->uv_width; - q += buffer->uv_stride; - q2 += buffer->uv_stride; - } - - /* if we're to send RGB video, convert here */ - if (decode->convert_to_rgb) { - OggPlayYUVChannels yuv; - OggPlayRGBChannels rgb; - OggPlayOverlayRecord * orecord; - OggPlayOverlayData * odata; - long overlay_size; - - yuv.ptry = data->y; - yuv.ptru = data->u; - yuv.ptrv = data->v; - yuv.y_width = decode->y_width; - yuv.y_height = decode->y_height; - yuv.uv_width = decode->uv_width; - yuv.uv_height = decode->uv_height; - - size = sizeof(OggPlayOverlayRecord); - /* check for possible integer oveflows */ - ret = oggplay_mul_signed_overflow(decode->y_width, decode->y_height, - &overlay_size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - - ret = oggplay_mul_signed_overflow(overlay_size, 4, &overlay_size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - - ret = oggplay_check_add_overflow (size, overlay_size, &size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - - /* allocate memory for the overlay record */ - orecord = (OggPlayOverlayRecord*) oggplay_malloc (size); - if (orecord != NULL) { - oggplay_data_initialise_header((OggPlayDecode *)decode, &(orecord->header)); - orecord->header.samples_in_record = 1; - odata = &(orecord->data); - - rgb.ptro = (unsigned char*)(orecord+1); - rgb.rgb_width = yuv.y_width; - rgb.rgb_height = yuv.y_height; - - if (!decode->swap_rgb) { - oggplay_yuv2bgra(&yuv, &rgb); - } else { - oggplay_yuv2rgba(&yuv, &rgb); - } - - odata->rgb = rgb.ptro; - odata->rgba = NULL; - odata->width = rgb.rgb_width; - odata->height = rgb.rgb_height; - odata->stride = rgb.rgb_width*4; - - oggplay_free(record); - - oggplay_data_add_to_list((OggPlayDecode *)decode, &(orecord->header)); - } else { - /* memory allocation failed! */ - oggplay_free (record); - - return E_OGGPLAY_OUT_OF_MEMORY; - } - } - else { - oggplay_data_initialise_header((OggPlayDecode *)decode, &(record->header)); - oggplay_data_add_to_list((OggPlayDecode *)decode, &(record->header)); - } - - return E_OGGPLAY_CONTINUE; -} - -#ifdef HAVE_KATE -OggPlayErrorCode -oggplay_data_handle_kate_data(OggPlayKateDecode *decode, const kate_event *ev) { - - OggPlayTextRecord * record = NULL; - size_t rec_size = sizeof(OggPlayTextRecord); - - if (decode == NULL) { - return -1; - } -#ifdef HAVE_TIGER - tiger_renderer_add_event(decode->tr, ev->ki, ev); - - if (decode->use_tiger) { - /* if rendering with Tiger, we don't add an event, a synthetic one will be - generated each "tick" with an updated tracker state */ - } - else -#endif - { - /* check for integer overflow */ - if - ( - oggplay_check_add_overflow (rec_size, ev->len0, &rec_size) - == - E_OGGPLAY_TYPE_OVERFLOW - ) - { - return E_OGGPLAY_TYPE_OVERFLOW; - } - - record = (OggPlayTextRecord*)oggplay_calloc (rec_size, 1); - if (!record) { - return E_OGGPLAY_OUT_OF_MEMORY; - } - - oggplay_data_initialise_header(&decode->decoder, &(record->header)); - - //record->header.presentation_time = (ogg_int64_t)(ev->start_time*1000); - record->header.samples_in_record = (ev->end_time-ev->start_time)*1000; - record->data = (char *)(record + 1); - - memcpy(record->data, ev->text, ev->len0); - - oggplay_data_add_to_list(&decode->decoder, &(record->header)); - } - - return E_OGGPLAY_CONTINUE; -} -#endif - -#ifdef HAVE_TIGER -OggPlayErrorCode -oggplay_data_update_tiger(OggPlayKateDecode *decode, int active, ogg_int64_t presentation_time, OggPlayCallbackInfo *info) { - - OggPlayOverlayRecord * record = NULL; - OggPlayOverlayData * data = NULL; - size_t size = sizeof (OggPlayOverlayRecord); - int track = active && decode->use_tiger; - int ret; - kate_float t = OGGPLAY_TIME_FP_TO_INT(presentation_time) / 1000.0f; - - if (!decode->decoder.initialised) return -1; - - if (track) { - if (info) { - if (info->required_records>0) { - OggPlayDataHeader *header = info->records[0]; - data = (OggPlayOverlayData*)(header+1); - if (decode->tr && data->rgb) { -#if WORDS_BIGENDIAN || IS_BIG_ENDIAN - tiger_renderer_set_buffer(decode->tr, data->rgb, data->width, data->height, data->stride, 0); -#else - tiger_renderer_set_buffer(decode->tr, data->rgb, data->width, data->height, data->stride, 1); -#endif - } - else { - /* we're supposed to overlay on a frame, but the available frame has no RGB buffer */ - /* fprintf(stderr,"no RGB buffer found for video frame\n"); */ - return -1; - } - } - else { - /* we're supposed to overlay on a frame, but there is no frame available */ - /* fprintf(stderr,"no video frame to overlay on\n"); */ - return -1; - } - } - else { - // TODO: some way of knowing the size of the video we'll be drawing onto, if any - int width = decode->k_state.ki->original_canvas_width; - int height = decode->k_state.ki->original_canvas_height; - long overlay_size; - if (width <= 0 || height <= 0) { - /* some default resolution if we're not overlaying onto a video and the canvas size is unknown */ - if (decode->default_width > 0 && decode->default_height > 0) { - width = decode->default_width; - height = decode->default_height; - } - else { - width = 640; - height = 480; - } - } - /* check for integer overflow */ - ret = oggplay_mul_signed_overflow (width, height, &overlay_size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return ret; - } - - ret = oggplay_mul_signed_overflow (overlay_size, 4, &overlay_size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return E_OGGPLAY_TYPE_OVERFLOW; - } - - ret = oggplay_check_add_overflow (size, overlay_size, &size); - if (ret == E_OGGPLAY_TYPE_OVERFLOW) { - return E_OGGPLAY_TYPE_OVERFLOW; - } - - record = (OggPlayOverlayRecord*)oggplay_calloc (1, size); - if (!record) - return E_OGGPLAY_OUT_OF_MEMORY; - - record->header.samples_in_record = 1; - data= &(record->data); - oggplay_data_initialise_header((OggPlayDecode *)decode, &(record->header)); - - data->rgba = (unsigned char*)(record+1); - data->rgb = NULL; - data->width = width; - data->height = height; - data->stride = width*4; - - if (decode->tr && data->rgba) { - tiger_renderer_set_buffer(decode->tr, data->rgba, data->width, data->height, data->stride, decode->swap_rgb); - } - - oggplay_data_add_to_list(&decode->decoder, &(record->header)); - record->header.presentation_time=presentation_time; - } - } - - if (decode->tr) { - tiger_renderer_update(decode->tr, t, track); - } - - if (track) { - /* buffer was either calloced, so already cleared, or already filled with video, so no clearing */ - if (decode->tr) { - tiger_renderer_render(decode->tr); - } - } - - return E_OGGPLAY_CONTINUE; -} -#endif - diff --git a/media/liboggplay/src/liboggplay/oggplay_data.h b/media/liboggplay/src/liboggplay/oggplay_data.h deleted file mode 100644 index bcd37c91ed5..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_data.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_data.h - * - * Shane Stephens - */ -#ifndef __OGGPLAY_DATA_H__ -#define __OGGPLAY_DATA_H__ - -void -oggplay_data_initialise_list (OggPlayDecode *decode); - -OggPlayErrorCode -oggplay_data_handle_theora_frame (OggPlayTheoraDecode *decode, - const yuv_buffer *buffer); - -OggPlayErrorCode -oggplay_data_handle_audio_data (OggPlayDecode *decode, - void *data, long samples, size_t samplesize); - -OggPlayErrorCode -oggplay_data_handle_cmml_data(OggPlayDecode *decode, - unsigned char *data, long size); - -#ifdef HAVE_KATE -OggPlayErrorCode -oggplay_data_handle_kate_data(OggPlayKateDecode *decode, - const kate_event *ev); -#endif - -#ifdef HAVE_TIGER -OggPlayErrorCode -oggplay_data_update_tiger(OggPlayKateDecode *decode, - int active, ogg_int64_t presentation_time, - OggPlayCallbackInfo *info); -#endif - -void -oggplay_data_clean_list (OggPlayDecode *decode); - -void -oggplay_data_free_list(OggPlayDataHeader *list); - -void -oggplay_data_shutdown_list (OggPlayDecode *decode); -#endif diff --git a/media/liboggplay/src/liboggplay/oggplay_file_reader.c b/media/liboggplay/src/liboggplay/oggplay_file_reader.c deleted file mode 100644 index f15e2f691df..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_file_reader.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_file_reader.c - * - * Shane Stephens - * Michael Martin - */ - -#include "oggplay_private.h" -#include "oggplay_file_reader.h" - -#include -#include - -OggPlayErrorCode -oggplay_file_reader_initialise(OggPlayReader * opr, int block) { - - OggPlayFileReader * me = (OggPlayFileReader *)opr; - (void)block; /* unused for file readers */ - - if (me == NULL) { - return E_OGGPLAY_BAD_READER; - } - - me->file = fopen(me->file_name, "rb"); - - if (me->file == NULL) { - return E_OGGPLAY_BAD_INPUT; - } - - fseek(me->file, 0L, SEEK_END); - me->size = ftell(me->file); - fseek(me->file, 0L, SEEK_SET); - - me->current_position = 0; - - return E_OGGPLAY_OK; -} - -OggPlayErrorCode -oggplay_file_reader_destroy(OggPlayReader * opr) { - - OggPlayFileReader * me; - - if (opr == NULL) { - return E_OGGPLAY_BAD_READER; - } - - me = (OggPlayFileReader *)opr; - - if (me->file != NULL) { - fclose(me->file); - } - - oggplay_free(me); - - return E_OGGPLAY_OK; -} - -int -oggplay_file_reader_available(OggPlayReader * opr, ogg_int64_t current_bytes, - ogg_int64_t current_time) { - - OggPlayFileReader *me = (OggPlayFileReader *)opr; - - if (me == NULL) { - return -1; - } - - return me->size; - -} - -int -oggplay_file_reader_finished_retrieving(OggPlayReader *opr) { - - return 1; - -} - - -static size_t -oggplay_file_reader_io_read(void * user_handle, void * buf, size_t n) { - - OggPlayFileReader *me = (OggPlayFileReader *)user_handle; - int r; - - if (me == NULL) { - return -1; - } - - r = fread(buf, 1, n, me->file); - if (r > 0) { - me->current_position += r; - } - - return r; -} - -static int -oggplay_file_reader_io_seek(void * user_handle, long offset, int whence) { - - OggPlayFileReader * me = (OggPlayFileReader *)user_handle; - int r; - - if (me == NULL) { - return -1; - } - - r = fseek(me->file, offset, whence); - me->current_position = ftell(me->file); - return r; - -} - -static long -oggplay_file_reader_io_tell(void * user_handle) { - - OggPlayFileReader * me = (OggPlayFileReader *)user_handle; - - if (me == NULL) { - return -1; - } - - return ftell(me->file); - -} - -OggPlayReader * -oggplay_file_reader_new(const char *file_name) { - - OggPlayFileReader * me = oggplay_malloc (sizeof (OggPlayFileReader)); - - if (me == NULL) - return NULL; - - me->current_position = 0; - me->file_name = file_name; - me->file = NULL; - - me->functions.initialise = &oggplay_file_reader_initialise; - me->functions.destroy = &oggplay_file_reader_destroy; - me->functions.available = &oggplay_file_reader_available; - me->functions.finished_retrieving = &oggplay_file_reader_finished_retrieving; - me->functions.seek = NULL; - me->functions.duration = NULL; - me->functions.io_read = &oggplay_file_reader_io_read; - me->functions.io_seek = &oggplay_file_reader_io_seek; - me->functions.io_tell = &oggplay_file_reader_io_tell; - me->functions.duration = NULL; - - return (OggPlayReader *)me; - -} diff --git a/media/liboggplay/src/liboggplay/oggplay_file_reader.h b/media/liboggplay/src/liboggplay/oggplay_file_reader.h deleted file mode 100644 index ec077669ef5..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_file_reader.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_file_reader.h - * - * Shane Stephens - * Michael Martin - */ - -#ifndef __OGGPLAY_FILE_READER_H__ -#define __OGGPLAY_FILE_READER_H__ - -#include - -#define FILE_READER_CHUNK_SIZE 8192 -#define FILE_READER_INITIAL_NUM_BUFFERS 8 - -typedef struct { - OggPlayReader functions; - const char * file_name; - FILE * file; - long current_position; - long size; -} OggPlayFileReader; - -#endif diff --git a/media/liboggplay/src/liboggplay/oggplay_private.h b/media/liboggplay/src/liboggplay/oggplay_private.h deleted file mode 100644 index fb0d0653fad..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_private.h +++ /dev/null @@ -1,458 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_private.h - * - * Shane Stephens - * Michael Martin - */ -#ifndef __OGGPLAY_PRIVATE_H__ -#define __OGGPLAY_PRIVATE_H__ - -#ifdef HAVE_CONFIG_H -#ifdef WIN32 -#include "config_win32.h" -#else -#include -#endif -#endif - -#include - -#include -#include -#include - -#ifdef HAVE_KATE -#include -#endif -#ifdef HAVE_TIGER -#include -#endif - -#ifdef WIN32 - -#ifdef HAVE_WINSOCK2 -#include -#else -#include -#endif -#endif - -#ifdef OS2 -#define INCL_DOSSEMAPHORES -#define INCL_DOSPROCESS -#include -#endif - -// for Win32 has to be included last -#include "std_semaphore.h" - -/** - * - * has_been_presented: 0 until the data has been added as a "required" element, - * then 1. - */ -struct _OggPlayDataHeader { - int lock; - struct _OggPlayDataHeader * next; - ogg_int64_t presentation_time; - ogg_int64_t samples_in_record; - int has_been_presented; -}; - -typedef struct { - OggPlayDataHeader header; - OggPlayVideoData data; -} OggPlayVideoRecord; - -typedef struct { - OggPlayDataHeader header; - OggPlayOverlayData data; -} OggPlayOverlayRecord; - -typedef struct { - OggPlayDataHeader header; - void * data; -} OggPlayAudioRecord; - -typedef struct { - OggPlayDataHeader header; - char * data; -} OggPlayTextRecord; - -struct _OggPlay; - -typedef struct { - void ** buffer_list; - void ** buffer_mirror; - int buffer_size; - int last_filled; - int last_emptied; - semaphore frame_sem; -} OggPlayBuffer; - -struct _OggPlayCallbackInfo { - OggPlayDataType data_type; - int available_records; - int required_records; - OggPlayStreamInfo stream_info; - OggPlayDataHeader ** records; - OggPlayBuffer * buffer; -}; - -/** - * OggPlayDecode - * - * A structure that contains information about a single track within the Ogg - * file. - * - * data_list, end_of_data_list: Contain decoded data packets for this track. - * These packets are time-ordered, and have a - * known presentation time - * - * untimed_data_list: Contains decoded data packets for this track. - * These packets are reverse time-ordered, and - * have not got a known presentation time. This - * list gets constructed when a new Ogg file is - * first being read, and gets torn down as soon as - * the first packet with a granulepos is processed - * - * granuleperiod The period between adjacent samples in this - * track - */ -typedef struct { - long serialno; /**< identifies the logical bit stream */ - int content_type; - const char * content_type_name; - OggPlayDataType decoded_type; /**< type of the track @see OggPlayDataType */ - ogg_int64_t granuleperiod; - ogg_int64_t last_granulepos; /**< last seen granule position */ - ogg_int64_t offset; /**< */ - ogg_int64_t current_loc; /**< current location in the stream (in ) */ - int active; /**< indicates whether the track is active or not */ - ogg_int64_t final_granulepos; /**< */ - struct _OggPlay * player; /**< reference to the OggPlay handle */ - OggPlayDataHeader * data_list; - OggPlayDataHeader * end_of_data_list; - OggPlayDataHeader * untimed_data_list; - OggPlayStreamInfo stream_info; /**< @see OggPlayStreamInfo */ - int preroll; /**< num. of past content packets to take into account when decoding the current Ogg page */ - short initialised; /**< */ - int num_header_packets; /**< number of header packets left to process for the stream.*/ -} OggPlayDecode; - -typedef struct { - OggPlayDecode decoder; - theora_state video_handle; - theora_info video_info; - theora_comment video_comment; - int granulepos_seen; - int frame_delta; - int y_width; - int y_height; - int y_stride; - int uv_width; - int uv_height; - int uv_stride; - int cached_keyframe; - int convert_to_rgb; - int swap_rgb; -} OggPlayTheoraDecode; - -typedef struct { - OggPlayDecode decoder; - FishSound * sound_handle; - FishSoundInfo sound_info; -} OggPlayAudioDecode; - -typedef struct { - OggPlayDecode decoder; - int granuleshift; -} OggPlayCmmlDecode; - -/** - * OggPlaySkeletonDecode - */ -typedef struct { - OggPlayDecode decoder; - ogg_int64_t presentation_time; - ogg_int64_t base_time; -} OggPlaySkeletonDecode; - -typedef struct { - OggPlayDecode decoder; -#ifdef HAVE_KATE - int granuleshift; - kate_state k_state; - kate_info k_info; - kate_comment k_comment; - int init; -#ifdef HAVE_TIGER - int use_tiger; - int overlay_dest; - tiger_renderer *tr; - int default_width; - int default_height; - int swap_rgb; -#endif -#endif -} OggPlayKateDecode; - -struct OggPlaySeekTrash; - -/** - * - */ -typedef struct OggPlaySeekTrash { - OggPlayDataHeader * old_data; - OggPlayBuffer * old_buffer; - struct OggPlaySeekTrash * next; -} OggPlaySeekTrash; - -/** - * - */ -struct _OggPlay { - OggPlayReader * reader; /**< @see OggPlayReader */ - OGGZ * oggz; /**< @see OGGZ */ - OggPlayDecode ** decode_data; /**< */ - OggPlayCallbackInfo * callback_info; /**< */ - int num_tracks; /**< number of tracks in the Ogg container */ - int all_tracks_initialised; /**< "= 1" indicates that all tracks are initialised */ - ogg_int64_t callback_period; /**< */ - OggPlayDataCallback * callback; /**< */ - void * callback_user_ptr; /**< */ - ogg_int64_t target; /**< */ - int active_tracks; /**< number of active tracks */ - volatile OggPlayBuffer * buffer; /**< @see OggPlayBuffer */ - ogg_int64_t presentation_time; /**< */ - OggPlaySeekTrash * trash; /**< @see OggPlaySeekTrash */ - int shutdown; /**< "= 1" indicates shutdown event */ - int pt_update_valid; /**< */ - ogg_int64_t duration; /**< The value of the duration the last time it was retrieved.*/ - int max_video_frame_pixels; /**< Maximum number of pixels we'll allow in a video frame.*/ -}; - -void -oggplay_set_data_callback_force(OggPlay *me, OggPlayDataCallback callback, - void *user); - -void -oggplay_take_out_trash(OggPlay *me, OggPlaySeekTrash *trash); - -OggPlayErrorCode -oggplay_seek_cleanup(OggPlay *me, ogg_int64_t milliseconds); - -typedef struct { - void (*init) (void *user_data); - int (*callback) (OGGZ * oggz, ogg_packet * op, long serialno, - void * user_data); - void (*shutdown) (void *user_data); - int size; -} OggPlayCallbackFunctions; - -/** - * Conversion function for fixed point 32.32 representation of time. - * - * OGGPLAY_TIME_INT_TO_FP(x) - * converts 'x' to a 32.32 fixed point integer - * - * OGGPLAY_TIME_FP_TO_INT - * converts 'x' - a 32.32 fixed point integer - back to normal integer representation - * + changes the order of magnitude by 1000 - * e.g. if the fixed point number - 32.32 format - represents seconds - * then the macro will convert it to milliseconds. - */ -#define OGGPLAY_TIME_INT_TO_FP(x) ((x) << 32) -#define OGGPLAY_TIME_FP_TO_INT(x) (((((x) >> 16) * 1000) >> 16) & 0xFFFFFFFF) - -/* Allocate and free dynamic memory used by ogg. - * By default they are the ones from stdlib */ -#define oggplay_malloc _ogg_malloc -#define oggplay_calloc _ogg_calloc -#define oggplay_realloc _ogg_realloc -#define oggplay_free _ogg_free - -/** - * macros for obtaining a type's max and min values - * http://www.fefe.de/intof.html - */ -#define OGGPLAY_TYPE_HALF_MAX_SIGNED(type) ((type)1 << (sizeof(type)*8-2)) -#define OGGPLAY_TYPE_MAX_SIGNED(type) (OGGPLAY_TYPE_HALF_MAX_SIGNED(type) - 1 + OGGPLAY_TYPE_HALF_MAX_SIGNED(type)) -#define OGGPLAY_TYPE_MIN_SIGNED(type) (-1 - OGGPLAY_TYPE_MAX_SIGNED(type)) -#define OGGPLAY_TYPE_MIN(type) ((type)-1 < 1?OGGPLAY_TYPE_MIN_SIGNED(type):(type)0) -#define OGGPLAY_TYPE_MAX(type) ((type)~OGGPLAY_TYPE_MIN(type)) - -static inline int -oggplay_check_add_overflow (size_t a, long b, size_t* r) { - /* we cannot assume that sizeof(size_t) >= sizeof(long) !!! */ - if (sizeof(size_t) < sizeof(long)) { - /* check whether the number fits into a size_t */ - if - ( - (b < 0) ? - ((OGGPLAY_TYPE_MAX(size_t)+b >= 0) ? 0 : 1) : - ((OGGPLAY_TYPE_MAX(size_t)-b >= 0) ? 0 : 1) - ) - { - return E_OGGPLAY_TYPE_OVERFLOW; - } - } - /* check whether the sum of the 'a' and 'b' fits into a size_t */ - if - ( - (b < 0) ? - ((OGGPLAY_TYPE_MIN(size_t)-b <= a) ? 0 : 1) : - ((OGGPLAY_TYPE_MAX(size_t)-b >= a) ? 0 : 1) - ) - { - return E_OGGPLAY_TYPE_OVERFLOW; - } - - /* if 'r' is supplied give back the sum of 'a' and 'b' */ - if (r != NULL) - *r = a+b; - - return 0; -} - -static inline int -oggplay_mul_signed_overflow_generic(long a, long b, long *re) { - long _a, _b, ah, bh, x, y, r = 0; - int sign = 1; - - _a = a; - _b = b; - ah = _a >> (sizeof(long)*4); - bh = _b >> (sizeof(long)*4); - - if (a < 0) { - _a = -_a; - if (_a < 0) { - if (_b == 0 || _b == 1) { - r = _a*_b; - goto ok; - } else { - goto overflow; - } - } - sign = -sign; - ah = _a >> (sizeof(long)*4); - } - - if (_b < 0) { - _b = -_b; - if (_b < 0) { - if (_a == 0 || (_a == 1 && sign == 1)) { - r = _a*_b; - goto ok; - } else { - goto overflow; - } - } - sign = -sign; - bh = _b >> (sizeof(long)*4); - } - - if (ah != 0 && bh != 0) { - goto overflow; - } - - if (ah == 0 && bh == 0) { - r = _a*_b; - if (r < 0) - goto overflow; - - goto ok; - } - - if (_a < _b) { - x = _a; - _a = _b; - _b = x; - ah = bh; - } - - y = ah*_b; - if (y >= (1L << (sizeof(long)*4 - 1))) - goto overflow; - _a &= (1L << sizeof(long)*4) - 1; - x = _a*_b; - if (x < 0) - goto overflow; - x += (y << sizeof(long)*4); - if (x < 0) - goto overflow; - -ok: - if (re != NULL) { - *re = sign*r; - } - - return 0; - -overflow: - return E_OGGPLAY_TYPE_OVERFLOW; -} - -static inline int -oggplay_mul_signed_overflow(long a, long b, long *r) { - if (sizeof(long) > 4) { - return oggplay_mul_signed_overflow_generic (a, b, r); - } else { - ogg_int64_t c = (ogg_int64_t) a*b; - - /* check whether the result fits in a long bit */ - if - ( - (c < 1) ? - ((OGGPLAY_TYPE_MIN (long) > c) ? 1 : 0) : - ((OGGPLAY_TYPE_MAX (long) < c) ? 1 : 0) - ) - { - return E_OGGPLAY_TYPE_OVERFLOW; - } - - if (r != NULL) { - *r = (long)c; - } - return 0; - } -} - -#include "oggplay_callback.h" -#include "oggplay_data.h" -#include "oggplay_buffer.h" - -#endif diff --git a/media/liboggplay/src/liboggplay/oggplay_query.c b/media/liboggplay/src/liboggplay/oggplay_query.c deleted file mode 100644 index 405052c85d2..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_query.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_query.c - * - * Shane Stephens - */ - -#include "oggplay_private.h" - -int -oggplay_get_num_tracks (OggPlay * me) { - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (me->reader == NULL) { - return E_OGGPLAY_BAD_READER; - } - - if (me->all_tracks_initialised == 0) { - return E_OGGPLAY_UNINITIALISED; - } - - return me->num_tracks; - -} - -OggzStreamContent -oggplay_get_track_type (OggPlay * me, int track_num) { - - if (me == NULL) { - return (OggzStreamContent)E_OGGPLAY_BAD_OGGPLAY; - } - - if (me->reader == NULL) { - return (OggzStreamContent)E_OGGPLAY_BAD_READER; - } - - if (me->all_tracks_initialised == 0) { - return E_OGGPLAY_UNINITIALISED; - } - - if (track_num < 0 || track_num >= me->num_tracks) { - return (OggzStreamContent)E_OGGPLAY_BAD_TRACK; - } - - return (OggzStreamContent)me->decode_data[track_num]->content_type; -} - -const char * -oggplay_get_track_typename (OggPlay * me, int track_num) { - - if (me == NULL) { - return NULL; - } - - if (me->reader == NULL) { - return NULL; - } - - if (me->all_tracks_initialised == 0) { - return NULL; - } - - if (track_num < 0 || track_num >= me->num_tracks) { - return NULL; - } - - return me->decode_data[track_num]->content_type_name; -} - -OggPlayErrorCode -oggplay_set_track_active(OggPlay *me, int track_num) { - - ogg_int64_t p; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (me->reader == NULL) { - return E_OGGPLAY_BAD_READER; - } - - if (me->all_tracks_initialised == 0) { - return E_OGGPLAY_UNINITIALISED; - } - - if (track_num < 0 || track_num >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - /* - * Skeleton tracks should not be set active - data in them should be queried - * using alternative mechanisms (there is no concept of time-synced data - * in a skeleton track) - */ - if (me->decode_data[track_num]->content_type == OGGZ_CONTENT_SKELETON) { - return E_OGGPLAY_TRACK_IS_SKELETON; - } - - if (me->decode_data[track_num]->content_type == OGGZ_CONTENT_UNKNOWN) { - return E_OGGPLAY_TRACK_IS_UNKNOWN; - } - - /* there was an error while decoding the headers of this track! */ - if (me->decode_data[track_num]->initialised != 1) { - return E_OGGPLAY_TRACK_UNINITIALISED; - } - - if ((p = me->decode_data[track_num]->final_granulepos) != -1) { - if (p * me->decode_data[track_num]->granuleperiod > me->target) { - return E_OGGPLAY_TRACK_IS_OVER; - } - } - - if (me->decode_data[track_num]->active == 0) { - me->decode_data[track_num]->active = 1; - - /* - * CMML tracks aren't counted when deciding whether we've read enough data - * from the stream. This is because CMML data is not continuous, and - * determining that we've read enough data from each other stream is enough - * to determing that we've read any CMML data that is available. - * This also applies to Kate streams. - */ - if (me->decode_data[track_num]->content_type != OGGZ_CONTENT_CMML && me->decode_data[track_num]->content_type != OGGZ_CONTENT_KATE) { - me->active_tracks ++; - } - } - - return E_OGGPLAY_OK; - -} - -OggPlayErrorCode -oggplay_set_track_inactive(OggPlay *me, int track_num) { - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (me->reader == NULL) { - return E_OGGPLAY_BAD_READER; - } - - if (me->all_tracks_initialised == 0) { - return E_OGGPLAY_UNINITIALISED; - } - - if (track_num < 0 || track_num >= me->num_tracks) { - return E_OGGPLAY_BAD_TRACK; - } - - if (me->decode_data[track_num]->content_type == OGGZ_CONTENT_SKELETON) { - return E_OGGPLAY_TRACK_IS_SKELETON; - } - - if (me->decode_data[track_num]->content_type == OGGZ_CONTENT_UNKNOWN) { - return E_OGGPLAY_TRACK_IS_UNKNOWN; - } - - if (me->decode_data[track_num]->active == 1) { - me->decode_data[track_num]->active = 0; - - /* - * see above comment in oggplay_set_track_active - */ - if (me->decode_data[track_num]->content_type != OGGZ_CONTENT_CMML && me->decode_data[track_num]->content_type != OGGZ_CONTENT_KATE) { - me->active_tracks --; - } - } - - return E_OGGPLAY_OK; -} diff --git a/media/liboggplay/src/liboggplay/oggplay_seek.c b/media/liboggplay/src/liboggplay/oggplay_seek.c deleted file mode 100644 index 8a40991bc9e..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_seek.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_enums.h - * - * Shane Stephens - */ - -#include "oggplay_private.h" - -OggPlayErrorCode -oggplay_seek(OggPlay *me, ogg_int64_t milliseconds) { - - ogg_int64_t eof; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (milliseconds < 0) { - return E_OGGPLAY_CANT_SEEK; - } - - eof = oggplay_get_duration(me); - if (eof > -1 && milliseconds > eof) { - return E_OGGPLAY_CANT_SEEK; - } - - if (me->reader->seek != NULL) { - if - ( - me->reader->seek(me->reader, me->oggz, milliseconds) - == - E_OGGPLAY_CANT_SEEK - ) - { - return E_OGGPLAY_CANT_SEEK; - } - } else { - if (oggz_seek_units(me->oggz, milliseconds, SEEK_SET) == -1) { - return E_OGGPLAY_CANT_SEEK; - } - } - - return oggplay_seek_cleanup(me, milliseconds); -} - -OggPlayErrorCode -oggplay_seek_cleanup(OggPlay* me, ogg_int64_t milliseconds) -{ - - OggPlaySeekTrash * trash; - OggPlaySeekTrash ** p; - OggPlayDataHeader ** end_of_list_p; - int i; - - if (me == NULL) - return E_OGGPLAY_BAD_OGGPLAY; - - /* - * first, create a trash object to store the context that we want to - * delete but can't until the presentation thread is no longer using it - - * this will occur as soon as the thread calls oggplay_buffer_release_next - */ - - trash = oggplay_calloc(1, sizeof(OggPlaySeekTrash)); - - if (trash == NULL) - return E_OGGPLAY_OUT_OF_MEMORY; - - /* - * store the old buffer in it next. - */ - if (me->buffer != NULL) { - - trash->old_buffer = (OggPlayBuffer *)me->buffer; - - /* - * replace the buffer with a new one. From here on, the presentation thread - * will start using this buffer instead. - */ - me->buffer = oggplay_buffer_new_buffer(me->buffer->buffer_size); - - if (me->buffer == NULL) - { - return E_OGGPLAY_OUT_OF_MEMORY; - } - } - /* - * strip all of the data packets out of the streams and put them into the - * trash. We can free the untimed packets immediately - they are USELESS - * SCUM OF THE EARTH (and also unreferenced by the buffer). - */ - end_of_list_p = &trash->old_data; - for (i = 0; i < me->num_tracks; i++) { - OggPlayDecode *track = me->decode_data[i]; - if (track->data_list != NULL) { - *(end_of_list_p) = track->data_list; - end_of_list_p = &(track->end_of_data_list->next); - oggplay_data_free_list(track->untimed_data_list); - } - track->data_list = track->end_of_data_list = NULL; - track->untimed_data_list = NULL; - track->current_loc = -1; - track->last_granulepos = -1; - track->stream_info = OGGPLAY_STREAM_JUST_SEEKED; - } - - /* - * we need to notify the tiger renderer that we seeked, so that - * now obsolete events are discarded - */ -#ifdef HAVE_TIGER - for (i = 0; i < me->num_tracks; i++) { - OggPlayDecode *track = me->decode_data[i]; - if (track && track->content_type == OGGZ_CONTENT_KATE) { - OggPlayKateDecode *decode = (OggPlayKateDecode *)(me->decode_data[i]); - if (decode->use_tiger) tiger_renderer_seek(decode->tr, milliseconds/1000.0); - } - } -#endif - - /* - * set the presentation time - */ - me->presentation_time = milliseconds; - me->target = me->callback_period - 1; - me->pt_update_valid = 1; - - trash->next = NULL; - - p = &(me->trash); - while (*p != NULL) { - p = &((*p)->next); - } - - *p = trash; - - if (milliseconds == 0) { - for (i = 0; i < me->num_tracks; i++) { - OggPlayDecode *track = me->decode_data[i]; - FishSound *sound_handle; - OggPlayAudioDecode *audio_decode; - if (track->content_type != OGGZ_CONTENT_VORBIS) { - continue; - } - audio_decode = (OggPlayAudioDecode*)track; - sound_handle = audio_decode->sound_handle; - fish_sound_reset(sound_handle); - } - } - - return E_OGGPLAY_OK; -} - -void -oggplay_take_out_trash(OggPlay *me, OggPlaySeekTrash *trash) { - - OggPlaySeekTrash *p = NULL; - - for (; trash != NULL; trash = trash->next) { - - oggplay_buffer_shutdown(me, trash->old_buffer); - oggplay_data_free_list(trash->old_data); - if (p != NULL) { - oggplay_free(p); - } - p = trash; - } - - if (p != NULL) { - oggplay_free(p); - } -} - -OggPlayErrorCode -oggplay_seek_to_keyframe(OggPlay *me, - ogg_int64_t milliseconds, - ogg_int64_t offset_begin, - ogg_int64_t offset_end) -{ - ogg_int64_t eof, time; - - if (me == NULL) { - return E_OGGPLAY_BAD_OGGPLAY; - } - - if (milliseconds < 0) - return E_OGGPLAY_CANT_SEEK; - - eof = oggplay_get_duration(me); - if (eof > -1 && milliseconds > eof) { - return E_OGGPLAY_CANT_SEEK; - } - - - time = oggz_keyframe_seek_set(me->oggz, - milliseconds, - offset_begin, - offset_end); - - if (time == -1) { - return E_OGGPLAY_CANT_SEEK; - } - - oggplay_seek_cleanup(me, time); - - return E_OGGPLAY_OK; - -} diff --git a/media/liboggplay/src/liboggplay/oggplay_tcp_reader.c b/media/liboggplay/src/liboggplay/oggplay_tcp_reader.c deleted file mode 100644 index 84d76227052..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_tcp_reader.c +++ /dev/null @@ -1,773 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_tcp_reader.c - * - * Shane Stephens - * Michael Martin - */ - -#include "oggplay_private.h" -#include "oggplay_tcp_reader.h" - -#include -#include - -#ifdef WIN32 -#include -#include - -#else -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#if HAVE_ASSERT -#include -#else -#define assert(x) -#endif - -#define PRINT_BUFFER(s,m) \ - printf("%s: in_mem: %d size: %d pos: %d stored: %d\n", \ - s, m->amount_in_memory, m->buffer_size, \ - m->current_position, m->stored_offset); - -#ifndef WIN32 -typedef int SOCKET; -#define INVALID_SOCKET -1 -#endif - -#define START_TIMEOUT(ref) \ - (ref) = oggplay_sys_time_in_ms() - -#ifdef WIN32 -#define CHECK_ERROR(error) \ - (WSAGetLastError() == WSA##error) -#else -#define CHECK_ERROR(error) \ - (errno == error) -#endif - -#define RETURN_ON_TIMEOUT_OR_CONTINUE(ref) \ - if (oggplay_sys_time_in_ms() - (ref) > 500) { \ - return E_OGGPLAY_TIMEOUT; \ - } else { \ - oggplay_millisleep(10); \ - continue; \ - } - -#ifdef WIN32 -int -oggplay_set_socket_blocking_state(SOCKET socket, int is_blocking) { - u_long io_mode = !is_blocking; - if (ioctlsocket(socket, FIONBIO, &io_mode) == SOCKET_ERROR) { - return 0; - } - return 1; -} -#else -int -oggplay_set_socket_blocking_state(SOCKET socket, int is_blocking) { - if (fcntl(socket, F_SETFL, is_blocking ? 0 : O_NONBLOCK) == -1) { - return 0; - } - return 1; -} -#endif - -SOCKET -oggplay_create_socket() { - SOCKET sock; - -#ifdef WIN32 - WORD wVersionRequested; - WSADATA wsaData; -#ifdef HAVE_WINSOCK2 - wVersionRequested = MAKEWORD(2,2); -#else - wVersionRequested = MAKEWORD(1,1); -#endif - if (WSAStartup(wVersionRequested, &wsaData) == -1) { - printf("Socket open error\n"); - return INVALID_SOCKET; - } - if (wsaData.wVersion != wVersionRequested) { - printf("Incorrect winsock version [%d]\n", wVersionRequested); - WSACleanup(); - return INVALID_SOCKET; - } -#endif - - sock = socket(PF_INET, SOCK_STREAM, 0); - if (sock == INVALID_SOCKET) { - printf("Could not create socket\n"); -#ifdef WIN32 - WSACleanup(); -#endif - return INVALID_SOCKET; - } - - return sock; -} - -/** - * This function guarantees it will return malloced versions of host and - * path - * - * @param location Location of the Ogg content - * @param proxy The proxy if there's any. - * @param proxy_port The port of the proxy if there's any. - * @param host The host to connect to; using proxy if set. - * @param port The port to connect to; - * @param path The path where the content resides on the server. - * @retval -1 in case of error, 0 otherwise. - */ -int -oggplay_hostname_and_path(const char *location, const char *proxy, int proxy_port, - char **host, int *port, char **path) { - - - char * colon; - char * slash; - char * end_of_host; - - /* if we have a proxy installed this is all dead simple */ - if (proxy != NULL) { - if ((*host = strdup(proxy)) == NULL) - goto error; - - *port = proxy_port; - - if ((*path = strdup(location)) == NULL) - goto error; - - return 0; - } - - /* find start_pos */ - if (strncmp(location, "http://", 7) == 0) { - location += 7; - } - - colon = strchr(location, ':'); - slash = strchr(location, '/'); - - /* - * if both are null, then just set the simple defaults and return - */ - if (colon == NULL && slash == NULL) { - if ((*host = strdup(location)) == NULL) - goto error; - - *port = 80; - - if ((*path = strdup("/")) == NULL) - goto error; - - return 0; - } - - /* - * if there's a slash and it's before colon, there's no port. Hence, after - * this code, the only time that there's a port is when colon is non-NULL - */ - if (slash != NULL && colon > slash) { - colon = NULL; - } - - /* - * we might as well extract the port now. We can also work out where - * the end of the hostname is, as it's either the colon (if there's a port) - * or the slash (if there's no port) - */ - if (colon != NULL) { - *port = (int)strtol(colon+1, NULL, 10); - end_of_host = colon; - } else { - *port = 80; - end_of_host = slash; - } - - if ((*host = strdup(location)) == NULL) - goto error; - - (*host)[end_of_host - location] = '\0'; - - if (slash == NULL) { - if ((*path = strdup("/")) == NULL) - goto error; - - return 0; - } - - if ((*path = strdup(slash)) == NULL) - goto error; - - return 0; - -error: - /* there has been an error while copying strings... */ - if (*host != NULL) - oggplay_free(*host); - - return -1; -} - -OggPlayErrorCode -oggplay_connect_to_host(SOCKET socket, struct sockaddr *addr) { - - ogg_int64_t time_ref; - - START_TIMEOUT(time_ref); - - while (connect(socket, addr, sizeof(struct sockaddr_in)) < 0) { - if ( - CHECK_ERROR(EINPROGRESS) || CHECK_ERROR(EALREADY) -#ifdef WIN32 - /* see http://msdn2.microsoft.com/en-us/library/ms737625.aspx */ - || CHECK_ERROR(EWOULDBLOCK) || CHECK_ERROR(EINVAL) -#endif - ) { - RETURN_ON_TIMEOUT_OR_CONTINUE(time_ref); - } - else if CHECK_ERROR(EISCONN) - { - break; - } - printf("Could not connect to host; error code is %d\n", errno); - return CHECK_ERROR(ETIMEDOUT) ? E_OGGPLAY_TIMEOUT : - E_OGGPLAY_SOCKET_ERROR; - } - - return E_OGGPLAY_OK; - -} - - -OggPlayErrorCode -oggplay_tcp_reader_initialise(OggPlayReader * opr, int block) { - - OggPlayTCPReader * me = (OggPlayTCPReader *)opr; - struct hostent * he; - struct sockaddr_in addr; - char * host; - char * path; - int port; - int nbytes; - int remaining; - char http_request_header[1024]; - ogg_int64_t time_ref; - int r; - - char * pos; - size_t len; - - if (me == NULL) { - return E_OGGPLAY_BAD_READER; - } - if (me->state == OTRS_INIT_COMPLETE) { - return E_OGGPLAY_OK; - } - - /* - * Create the socket. - */ - if (me->state == OTRS_UNINITIALISED) { - assert(me->socket == INVALID_SOCKET); - - me->socket = oggplay_create_socket(); - if (me->socket == INVALID_SOCKET) { - return E_OGGPLAY_SOCKET_ERROR; - } - - me->state = OTRS_SOCKET_CREATED; - } - - /* - * If required, set the socket to non-blocking mode so we can - * timeout and return control to the caller. - */ - if (!block) { - if (!oggplay_set_socket_blocking_state(me->socket, 0)) { - return E_OGGPLAY_SOCKET_ERROR; - } - } - - /* - * Extract the host name and the path from the location. - */ - if (oggplay_hostname_and_path(me->location, me->proxy, me->proxy_port, - &host, &port, &path) != 0) - return E_OGGPLAY_OUT_OF_MEMORY; - - - /* - * Prepare the HTTP request header now, so we can free all our - * allocated memory before returning on any errors. - */ - snprintf(http_request_header, 1024, - "GET %s HTTP/1.0\n" - "Host: %s\n" - "User-Agent: AnnodexFirefoxPlugin/0.1\n" - "Accept: */*\n" - "Connection: Keep-Alive\n\n", path, host); - - he = gethostbyname(host); - - oggplay_free(host); - oggplay_free(path); - - if (he == NULL) { - printf("Host not found\n"); - return E_OGGPLAY_BAD_INPUT; - } - /* - * currently we only support IPv4 - * TODO: switch to getaddrinfo and support IPv6! - */ - if (sizeof(addr.sin_addr.s_addr) != he->h_length) { - printf("No IPv6 support, yet!\n"); - return E_OGGPLAY_BAD_INPUT; - } - - memcpy(&addr.sin_addr.s_addr, he->h_addr, he->h_length); - addr.sin_family = AF_INET; - addr.sin_port = htons(port); - - /* - * Connect to the host. - */ - if (me->state == OTRS_SOCKET_CREATED) { - r = oggplay_connect_to_host(me->socket, (struct sockaddr *)&addr); - if (r != E_OGGPLAY_OK) { - return r; - } - - me->state = OTRS_CONNECTED; - } - - /* - * Send the HTTP request header. - * - * If this times out after sending some, but not all, of the request header, - * we'll end up sending the entire header string again. This is probably not - * the best idea, so we may want to rework it at some time... - */ - if (me->state == OTRS_CONNECTED) { - oggplay_set_socket_blocking_state(me->socket, 1); - pos = http_request_header; - len = strlen(http_request_header); -#ifdef WIN32 - nbytes = send(me->socket, pos, len, 0); -#else - nbytes = write(me->socket, pos, len); -#endif - assert(nbytes == len); - if (nbytes < 0) { - return E_OGGPLAY_SOCKET_ERROR; - } - me->state = OTRS_SENT_HEADER; - } - - /* - * Strip out the HTTP response by finding the first Ogg packet. - */ - if (me->state == OTRS_SENT_HEADER) { - int offset; - int found_http_response = 0; - - if (me->buffer == NULL) { - me->buffer = (unsigned char*)oggplay_malloc(TCP_READER_MAX_IN_MEMORY); - if (me->buffer == NULL) - return E_OGGPLAY_OUT_OF_MEMORY; - - me->buffer_size = TCP_READER_MAX_IN_MEMORY; - me->amount_in_memory = 0; - } - - while (1) { - char *dpos; - - remaining = TCP_READER_MAX_IN_MEMORY - me->amount_in_memory - 1; -#ifdef WIN32 - nbytes = recv(me->socket, (char*)(me->buffer + me->amount_in_memory), - remaining, 0); -#else - nbytes = read(me->socket, (char*)(me->buffer + me->amount_in_memory), - remaining); -#endif - if (nbytes < 0) { - return E_OGGPLAY_SOCKET_ERROR; - } else if (nbytes == 0) { - /* - * End-of-file is an error here, because we should at least be able - * to read a complete HTTP response header. - */ - return E_OGGPLAY_END_OF_FILE; - } - - me->amount_in_memory += nbytes; - me->buffer[me->amount_in_memory] = '\0'; - - if (me->amount_in_memory < 15) { - continue; - } - - if - ( - (!found_http_response) - && - strncmp((char *)me->buffer, "HTTP/1.1 200 ", 13) != 0 - && - strncmp((char *)me->buffer, "HTTP/1.0 200 ", 13) != 0 - ) - { - return E_OGGPLAY_BAD_INPUT; - } else { - found_http_response = 1; - } - - dpos = strstr((char *)me->buffer, "X-Content-Duration:"); - if (dpos != NULL) { - me->duration = (int)(strtod(dpos + 20, NULL) * 1000); - } - - pos = strstr((char *)(me->buffer), "OggS"); - if (pos != NULL) { - break; - } - } - - offset = pos - (char *)(me->buffer); - memmove(me->buffer, pos, me->amount_in_memory - offset); - me->amount_in_memory -= offset; - me->backing_store = tmpfile(); - fwrite(me->buffer, 1, me->amount_in_memory, me->backing_store); - me->current_position = 0; - me->stored_offset = me->amount_in_memory; - me->amount_in_memory = 0; - me->state = OTRS_HTTP_RESPONDED; - } - - - - /* - * Read in enough data to fill the buffer. - */ - if (!block) { - oggplay_set_socket_blocking_state(me->socket, 0); - } - - if (me->state == OTRS_HTTP_RESPONDED) { - remaining = TCP_READER_MAX_IN_MEMORY - me->amount_in_memory; - START_TIMEOUT(time_ref); - while (remaining > 0) { -#ifdef WIN32 - nbytes = recv(me->socket, (char*)(me->buffer + me->amount_in_memory), - remaining, 0); -#else - nbytes = read(me->socket, me->buffer + me->amount_in_memory, remaining); -#endif - if (nbytes < 0) { -#ifdef WIN32 - if CHECK_ERROR(EWOULDBLOCK) { -#else - if CHECK_ERROR(EAGAIN) { -#endif - RETURN_ON_TIMEOUT_OR_CONTINUE(time_ref); - } - return E_OGGPLAY_SOCKET_ERROR; - } else if (nbytes == 0) { - /* - * End-of-file is *not* an error here, it's just a really small file. - */ - break; - } - me->amount_in_memory += nbytes; - remaining -= nbytes; - } - fwrite(me->buffer, 1, me->amount_in_memory, me->backing_store); - me->stored_offset += me->amount_in_memory; - me->amount_in_memory = 0; - me->state = OTRS_INIT_COMPLETE; - } - - /* - * Set the socket back to blocking mode. - */ - if (!oggplay_set_socket_blocking_state(me->socket, 1)) { - return E_OGGPLAY_SOCKET_ERROR; - } - - return E_OGGPLAY_OK; -} - - -OggPlayErrorCode -oggplay_tcp_reader_destroy(OggPlayReader * opr) { - - OggPlayTCPReader * me = (OggPlayTCPReader *)opr; - - if (me == NULL) { - return E_OGGPLAY_BAD_READER; - } - - if (me->socket != INVALID_SOCKET) { -#ifdef WIN32 -#ifdef HAVE_WINSOCK2 - shutdown(me->socket, SD_BOTH); -#endif - closesocket(me->socket); - WSACleanup(); -#else - close(me->socket); -#endif - } - - if (me->buffer != NULL) oggplay_free(me->buffer); - if (me->location != NULL) oggplay_free(me->location); - if (me->backing_store != NULL) { - fclose(me->backing_store); - } - oggplay_free(me); - return E_OGGPLAY_OK; -} - -OggPlayErrorCode -grab_some_data(OggPlayTCPReader *me, int block) { - - int remaining; - int r; - - if (me == NULL) { - return E_OGGPLAY_BAD_READER; - } - - if (me->socket == INVALID_SOCKET) return E_OGGPLAY_OK; - - /* - * see if we can grab some more data - * if we're not blocking, make sure there's some available data - */ - if (!block) { - struct timeval tv; - fd_set reads; - fd_set empty; - - tv.tv_sec = 0; - tv.tv_usec = 0; - FD_ZERO(&reads); - FD_ZERO(&empty); - FD_SET(me->socket, &reads); - if (select(me->socket + 1, &reads, &empty, &empty, &tv) == 0) { - return E_OGGPLAY_OK; - } - } - - remaining = me->buffer_size; -#ifdef WIN32 - r = recv(me->socket, (char*)(me->buffer + me->amount_in_memory), - remaining, 0); -#else - r = read(me->socket, me->buffer + me->amount_in_memory, remaining); -#endif - - if (!block && r <= 0) { -#ifdef WIN32 -#ifdef HAVE_WINSOCK2 - shutdown(me->socket, SD_BOTH); -#endif - closesocket(me->socket); - WSACleanup(); -#else - close(me->socket); -#endif - me->socket = INVALID_SOCKET; - } - - fwrite(me->buffer, 1, r, me->backing_store); - me->stored_offset += r; - - return E_OGGPLAY_OK; -} - -#define MIN(a,b) ((a)<(b)?(a):(b)) - -int -oggplay_tcp_reader_available(OggPlayReader * opr, ogg_int64_t current_bytes, - ogg_int64_t current_time) { - - OggPlayTCPReader * me; - ogg_int64_t tpb = (current_time << 16) / current_bytes; - - me = (OggPlayTCPReader *)opr; - - if (me == NULL) { - return E_OGGPLAY_BAD_READER; - } - - if (me->socket == INVALID_SOCKET) { - return me->duration; - } - - grab_some_data(me, 0); - if (me->duration > -1 && ((tpb * me->stored_offset) >> 16) > me->duration) - { - return me->duration; - } - return (int)((tpb * me->stored_offset) >> 16); - -} - -ogg_int64_t -oggplay_tcp_reader_duration(OggPlayReader * opr) { - OggPlayTCPReader *me = (OggPlayTCPReader *)opr; - - if (me == NULL) { - return E_OGGPLAY_BAD_READER; - } - - return me->duration; -} - -static size_t -oggplay_tcp_reader_io_read(void * user_handle, void * buf, size_t n) { - - OggPlayTCPReader * me = (OggPlayTCPReader *)user_handle; - int len; - - if (me == NULL) { - return E_OGGPLAY_BAD_READER; - } - - grab_some_data(me, 0); - - fseek(me->backing_store, me->current_position, SEEK_SET); - len = fread(buf, 1, n, me->backing_store); - if (len == 0) { - fseek(me->backing_store, 0, SEEK_END); - grab_some_data(me, 1); - fseek(me->backing_store, me->current_position, SEEK_SET); - len = fread(buf, 1, n, me->backing_store); - } - me->current_position += len; - fseek(me->backing_store, 0, SEEK_END); - return len; -} - -int -oggplay_tcp_reader_finished_retrieving(OggPlayReader *opr) { - OggPlayTCPReader *me = (OggPlayTCPReader *)opr; - return (me->socket == INVALID_SOCKET); -} - - -static int -oggplay_tcp_reader_io_seek(void * user_handle, long offset, int whence) { - - OggPlayTCPReader * me = (OggPlayTCPReader *)user_handle; - int r; - - if (me == NULL) { - return E_OGGPLAY_BAD_READER; - } - - fseek(me->backing_store, me->current_position, SEEK_SET); - r = fseek(me->backing_store, offset, whence); - me->current_position = ftell(me->backing_store); - fseek(me->backing_store, 0, SEEK_END); - - return r; -} - -static long -oggplay_tcp_reader_io_tell(void * user_handle) { - - OggPlayTCPReader * me = (OggPlayTCPReader *)user_handle; - - if (me == NULL) { - return E_OGGPLAY_BAD_READER; - } - - return me->current_position; - -} - -OggPlayReader * -oggplay_tcp_reader_new(const char *location, const char *proxy, int proxy_port) { - - OggPlayTCPReader * me = (OggPlayTCPReader *)oggplay_malloc (sizeof (OggPlayTCPReader)); - - if (me == NULL) - return NULL; - - me->state = OTRS_UNINITIALISED; - me->socket = INVALID_SOCKET; - me->buffer = NULL; - me->buffer_size = 0; - me->current_position = 0; - /* if there's not enough memory to copy the URI cancel the initialisation */ - if ( (me->location = strdup(location)) == NULL) - { - oggplay_tcp_reader_destroy ((OggPlayReader*)me); - return NULL; - } - me->amount_in_memory = 0; - me->backing_store = NULL; - me->stored_offset = 0; - - me->proxy = proxy; - me->proxy_port = proxy_port; - - me->functions.initialise = &oggplay_tcp_reader_initialise; - me->functions.destroy = &oggplay_tcp_reader_destroy; - me->functions.seek = NULL; - me->functions.available = &oggplay_tcp_reader_available; - me->functions.duration = &oggplay_tcp_reader_duration; - me->functions.finished_retrieving = &oggplay_tcp_reader_finished_retrieving; - me->functions.io_read = &oggplay_tcp_reader_io_read; - me->functions.io_seek = &oggplay_tcp_reader_io_seek; - me->functions.io_tell = &oggplay_tcp_reader_io_tell; - - return (OggPlayReader *)me; -} - - diff --git a/media/liboggplay/src/liboggplay/oggplay_tcp_reader.h b/media/liboggplay/src/liboggplay/oggplay_tcp_reader.h deleted file mode 100644 index 8290ee4d66b..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_tcp_reader.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_tcp_reader.h - * - * Shane Stephens - * Michael Martin - */ - -#ifndef __OGGPLAY_FILE_READER_H__ -#define __OGGPLAY_FILE_READER_H__ - -#include - -/* we'll fill to the MAX_IN_MEMORY line, then write out to the - * WRITE_THRESHOLD line - */ -#define TCP_READER_MAX_IN_MEMORY 128*1024 -#define TCP_READER_WRITE_THRESHOLD 64*1024 - -typedef enum { - TCP_READER_FROM_MEMORY, - TCP_READER_FROM_FILE -} dataLocation; - -typedef enum { - OTRS_UNINITIALISED, - OTRS_SOCKET_CREATED, - OTRS_CONNECTED, - OTRS_SENT_HEADER, - OTRS_HTTP_RESPONDED, - OTRS_INIT_COMPLETE -} OPTCPReaderState; - -typedef struct { - OggPlayReader functions; - OPTCPReaderState state; -#ifdef _WIN32 - SOCKET socket; -#else - int socket; -#endif - unsigned char * buffer; - int buffer_size; - int current_position; - char * location; - const char * proxy; - int proxy_port; - int amount_in_memory; - FILE * backing_store; - int stored_offset; - dataLocation mode; - int duration; -} OggPlayTCPReader; - -#endif diff --git a/media/liboggplay/src/liboggplay/oggplay_tools.c b/media/liboggplay/src/liboggplay/oggplay_tools.c deleted file mode 100644 index 3a93669416c..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_tools.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggplay_tools.c - * - * Shane Stephens - * Michael Martin - */ - - -#include "oggplay_private.h" -#include - -ogg_int64_t -oggplay_sys_time_in_ms(void) { -#ifdef WIN32 - FILETIME ft; - GetSystemTimeAsFileTime(&ft); - return ((ogg_int64_t)ft.dwHighDateTime << 32 | ft.dwLowDateTime) / 10000; -#else - struct timeval tv; - gettimeofday(&tv, NULL); - return (ogg_int64_t)tv.tv_sec * 1000 + (ogg_int64_t)tv.tv_usec / 1000; -#endif -} - -void -oggplay_millisleep(long ms) { -#ifdef WIN32 - Sleep(ms); -#elif defined(OS2) - DosSleep(ms); -#else - struct timespec ts = {0, (ogg_int64_t)ms * 1000000LL}; - nanosleep(&ts, NULL); -#endif -} - - diff --git a/media/liboggplay/src/liboggplay/oggplay_yuv2rgb.c b/media/liboggplay/src/liboggplay/oggplay_yuv2rgb.c deleted file mode 100644 index 6a2272247d7..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_yuv2rgb.c +++ /dev/null @@ -1,360 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * yuv2rgb.c - * - * YUV->RGB function, using platform-specific optimisations where possible. - * - * Shane Stephens - * Michael Martin - * Marcin Lubonski - * Viktor Gal - * Makoto Kato - */ - -#include "oggplay_private.h" -#include "oggplay_yuv2rgb_template.h" - -#ifdef __SUNPRO_C -#define DISABLE_CPU_FEATURES -/* gcc inline asm and intristics have problems with Sun Studio. - * We need to fix it. - */ -#else -/* cpu extension detection */ -#include "cpu.c" -#endif - -/** - * yuv_convert_fptr type is a function pointer type for - * the various yuv-rgb converters - */ -typedef void (*yuv_convert_fptr) (const OggPlayYUVChannels *yuv, - OggPlayRGBChannels *rgb); - -/* it is useless to determine each YUV conversion run - * the cpu type/featurs, thus we save the conversion function - * pointers - */ -static struct OggPlayYUVConverters { - yuv_convert_fptr yuv420rgba; /**< YUV420 to RGBA */ - yuv_convert_fptr yuv420bgra; /**< YUV420 to BGRA */ - yuv_convert_fptr yuv420argb; /**< YUV420 to ARGB */ - yuv_convert_fptr yuv422rgba; /**< YUV422 to RGBA */ - yuv_convert_fptr yuv422bgra; /**< YUV422 to BGRA */ - yuv_convert_fptr yuv422argb; /**< YUV422 to ARGB */ - yuv_convert_fptr yuv444rgba; /**< YUV444 to RGBA */ - yuv_convert_fptr yuv444bgra; /**< YUV444 to BGRA */ - yuv_convert_fptr yuv444argb; /**< YUV444 to ARGB */ -} yuv_conv = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; - -/** - * vanilla implementation of YUV-to-RGB conversion. - * - * - using table-lookups instead of multiplication - * - avoid CLAMPing by incorporating - * - */ - -#define prec 15 -static const int CoY = (int)(1.164 * (1 << prec) + 0.5); -static const int CoRV = (int)(1.596 * (1 << prec) + 0.5); -static const int CoGU = (int)(0.391 * (1 << prec) + 0.5); -static const int CoGV = (int)(0.813 * (1 << prec) + 0.5); -static const int CoBU = (int)(2.018 * (1 << prec) + 0.5); - -static int CoefsGU[256] = {0}; -static int CoefsGV[256]; -static int CoefsBU[256]; -static int CoefsRV[256]; -static int CoefsY[256]; - -#define CLAMP(v) ((v) > 255 ? 255 : (v) < 0 ? 0 : (v)) - -#define VANILLA_YUV2RGB_PIXEL(y, ruv, guv, buv) \ -r = (CoefsY[y] + ruv) >> prec; \ -g = (CoefsY[y] + guv) >> prec; \ -b = (CoefsY[y] + buv) >> prec; \ - -#define VANILLA_RGBA_OUT(out, r, g, b) \ -out[0] = CLAMP(r); \ -out[1] = CLAMP(g); \ -out[2] = CLAMP(b); \ -out[3] = 255; - -#define VANILLA_BGRA_OUT(out, r, g, b) \ -out[0] = CLAMP(b); \ -out[1] = CLAMP(g); \ -out[2] = CLAMP(r); \ -out[3] = 255; - -#define VANILLA_ARGB_OUT(out, r, g, b) \ -out[0] = 255; \ -out[1] = CLAMP(r); \ -out[2] = CLAMP(g); \ -out[3] = CLAMP(b); - -#define VANILLA_ABGR_OUT(out, r, g, b) \ -out[0] = 255; \ -out[1] = CLAMP(b); \ -out[2] = CLAMP(g); \ -out[3] = CLAMP(r); - -#define LOOKUP_COEFFS int ruv = CoefsRV[*pv]; \ - int guv = CoefsGU[*pu] + CoefsGV[*pv]; \ - int buv = CoefsBU[*pu]; \ - int r, g, b; - -/* yuv420p, yuv422p -> */ -#define CONVERT(OUTPUT_FUNC) LOOKUP_COEFFS \ - VANILLA_YUV2RGB_PIXEL(py[0], ruv, guv, buv) \ - OUTPUT_FUNC(dst, r, g, b) \ - VANILLA_YUV2RGB_PIXEL(py[1], ruv, guv, buv) \ - OUTPUT_FUNC((dst+4), r, g, b) - -#define CLEANUP - -YUV_CONVERT(yuv420_to_rgba_vanilla, CONVERT(VANILLA_RGBA_OUT), VANILLA_RGBA_OUT, 2, 8, 2, 1, 2) -YUV_CONVERT(yuv420_to_bgra_vanilla, CONVERT(VANILLA_BGRA_OUT), VANILLA_BGRA_OUT, 2, 8, 2, 1, 2) -YUV_CONVERT(yuv420_to_abgr_vanilla, CONVERT(VANILLA_ABGR_OUT), VANILLA_ABGR_OUT, 2, 8, 2, 1, 2) -YUV_CONVERT(yuv420_to_argb_vanilla, CONVERT(VANILLA_ARGB_OUT), VANILLA_ARGB_OUT, 2, 8, 2, 1, 2) - -YUV_CONVERT(yuv422_to_rgba_vanilla, CONVERT(VANILLA_RGBA_OUT), VANILLA_RGBA_OUT, 2, 8, 2, 1, 1) -YUV_CONVERT(yuv422_to_bgra_vanilla, CONVERT(VANILLA_BGRA_OUT), VANILLA_BGRA_OUT, 2, 8, 2, 1, 1) -YUV_CONVERT(yuv422_to_abgr_vanilla, CONVERT(VANILLA_ABGR_OUT), VANILLA_ABGR_OUT, 2, 8, 2, 1, 1) -YUV_CONVERT(yuv422_to_argb_vanilla, CONVERT(VANILLA_ARGB_OUT), VANILLA_ARGB_OUT, 2, 8, 2, 1, 1) - -#undef CONVERT - -/* yuv444p -> */ -#define CONVERT(OUTPUT_FUNC) LOOKUP_COEFFS \ - VANILLA_YUV2RGB_PIXEL(py[0], ruv, guv, buv) \ - OUTPUT_FUNC(dst, r, g, b) - -YUV_CONVERT(yuv444_to_rgba_vanilla, CONVERT(VANILLA_RGBA_OUT), VANILLA_RGBA_OUT, 1, 4, 1, 1, 1) -YUV_CONVERT(yuv444_to_bgra_vanilla, CONVERT(VANILLA_BGRA_OUT), VANILLA_BGRA_OUT, 1, 4, 1, 1, 1) -YUV_CONVERT(yuv444_to_abgr_vanilla, CONVERT(VANILLA_ABGR_OUT), VANILLA_ABGR_OUT, 1, 4, 1, 1, 1) -YUV_CONVERT(yuv444_to_argb_vanilla, CONVERT(VANILLA_ARGB_OUT), VANILLA_ARGB_OUT, 1, 4, 1, 1, 1) - -#undef CONVERT -#undef CLEANUP - -#ifndef DISABLE_CPU_FEATURES -/* although we use cpu runtime detection, we still need these - * macros as there's no way e.g. we could compile a x86 asm code - * on a ppc machine and vica-versa - */ -#if defined(i386) || defined(__x86__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_AMD64) -#if !defined(_M_AMD64) -#define ENABLE_MMX -#endif -#include "x86/oggplay_yuv2rgb_x86.c" -#if defined(_MSC_VER) || defined(ATTRIBUTE_ALIGNED_MAX) && ATTRIBUTE_ALIGNED_MAX >= 16 -#define ENABLE_SSE2 -#endif -#elif defined(__ppc__) || defined(__ppc64__) -#define ENABLE_ALTIVEC -//altivec intristics only working with -maltivec gcc flag, -//but we want runtime altivec detection, hence this has to be -//fixed! -//#include "oggplay_yuv2rgb_altivec.c" -#endif -#endif - - -/** - * Initialize the lookup-table for vanilla yuv to rgb conversion. - */ -static void -init_vanilla_coeffs (void) -{ - int i; - - for(i = 0; i < 256; ++i) - { - CoefsGU[i] = -CoGU * (i - 128); - CoefsGV[i] = -CoGV * (i - 128); - CoefsBU[i] = CoBU * (i - 128); - CoefsRV[i] = CoRV * (i - 128); - CoefsY[i] = CoY * (i - 16) + (prec/2); - } -} - -/** - * Initialize the function pointers in yuv_conv. - * - * Initialize the function pointers in yuv_conv, based on the - * the available CPU extensions. - */ -static void -init_yuv_converters(void) -{ - ogg_uint32_t features = 0; - - if ( yuv_conv.yuv420rgba == NULL ) - { - init_vanilla_coeffs (); -#ifndef DISABLE_CPU_FEATURES - features = oc_cpu_flags_get(); -#endif -#ifdef ENABLE_SSE2 - if (features & OC_CPU_X86_SSE2) - { - yuv_conv.yuv420rgba = yuv420_to_rgba_sse2; - yuv_conv.yuv420bgra = yuv420_to_bgra_sse2; - yuv_conv.yuv420argb = yuv420_to_argb_sse2; - yuv_conv.yuv422rgba = yuv422_to_rgba_sse2; - yuv_conv.yuv422bgra = yuv422_to_bgra_sse2; - yuv_conv.yuv422argb = yuv422_to_argb_sse2; - yuv_conv.yuv444rgba = yuv444_to_rgba_sse2; - yuv_conv.yuv444bgra = yuv444_to_bgra_sse2; - yuv_conv.yuv444argb = yuv444_to_argb_sse2; - return; - } -#endif /* SSE2 */ -#ifdef ENABLE_MMX -#ifdef ENABLE_SSE2 - else -#endif - if (features & OC_CPU_X86_MMXEXT) - { - yuv_conv.yuv420rgba = yuv420_to_rgba_sse; - yuv_conv.yuv420bgra = yuv420_to_bgra_sse; - yuv_conv.yuv420argb = yuv420_to_argb_sse; - yuv_conv.yuv422rgba = yuv422_to_rgba_sse; - yuv_conv.yuv422bgra = yuv422_to_bgra_sse; - yuv_conv.yuv422argb = yuv422_to_argb_sse; - yuv_conv.yuv444rgba = yuv444_to_rgba_sse; - yuv_conv.yuv444bgra = yuv444_to_bgra_sse; - yuv_conv.yuv444argb = yuv444_to_argb_sse; - return; - } - else if (features & OC_CPU_X86_MMX) - { - yuv_conv.yuv420rgba = yuv420_to_rgba_mmx; - yuv_conv.yuv420bgra = yuv420_to_bgra_mmx; - yuv_conv.yuv420argb = yuv420_to_argb_mmx; - yuv_conv.yuv422rgba = yuv422_to_rgba_mmx; - yuv_conv.yuv422bgra = yuv422_to_bgra_mmx; - yuv_conv.yuv422argb = yuv422_to_argb_mmx; - yuv_conv.yuv444rgba = yuv444_to_rgba_mmx; - yuv_conv.yuv444bgra = yuv444_to_bgra_mmx; - yuv_conv.yuv444argb = yuv444_to_argb_mmx; - return; - } -#elif defined(ENABLE_ALTIVEC) - if (features & OC_CPU_PPC_ALTIVEC) - { - yuv_conv.yuv420rgba = yuv420_to_abgr_vanilla; - yuv_conv.yuv420bgra = yuv420_to_argb_vanilla; - yuv_conv.yuv420argb = yuv420_to_bgra_vanilla; - yuv_conv.yuv422rgba = yuv422_to_abgr_vanilla; - yuv_conv.yuv422bgra = yuv422_to_argb_vanilla; - yuv_conv.yuv422argb = yuv422_to_bgra_vanilla; - yuv_conv.yuv444rgba = yuv444_to_abgr_vanilla; - yuv_conv.yuv444bgra = yuv444_to_argb_vanilla; - yuv_conv.yuv444argb = yuv444_to_bgra_vanilla; - return; - } -#endif - - /* - * no CPU extension was found... using vanilla converter, with respect - * to the endianness of the host - */ -#if WORDS_BIGENDIAN || IS_BIG_ENDIAN - yuv_conv.yuv420rgba = yuv420_to_abgr_vanilla; - yuv_conv.yuv420bgra = yuv420_to_argb_vanilla; - yuv_conv.yuv420argb = yuv420_to_bgra_vanilla; - yuv_conv.yuv422rgba = yuv422_to_abgr_vanilla; - yuv_conv.yuv422bgra = yuv422_to_argb_vanilla; - yuv_conv.yuv422argb = yuv422_to_bgra_vanilla; - yuv_conv.yuv444rgba = yuv444_to_abgr_vanilla; - yuv_conv.yuv444bgra = yuv444_to_argb_vanilla; - yuv_conv.yuv444argb = yuv444_to_bgra_vanilla; -#else - yuv_conv.yuv420rgba = yuv420_to_rgba_vanilla; - yuv_conv.yuv420bgra = yuv420_to_bgra_vanilla; - yuv_conv.yuv420argb = yuv420_to_argb_vanilla; - yuv_conv.yuv422rgba = yuv422_to_rgba_vanilla; - yuv_conv.yuv422bgra = yuv422_to_bgra_vanilla; - yuv_conv.yuv422argb = yuv422_to_argb_vanilla; - yuv_conv.yuv444rgba = yuv444_to_rgba_vanilla; - yuv_conv.yuv444bgra = yuv444_to_bgra_vanilla; - yuv_conv.yuv444argb = yuv444_to_argb_vanilla; -#endif - } -} - - -void -oggplay_yuv2rgba(const OggPlayYUVChannels* yuv, OggPlayRGBChannels* rgb) -{ - if (yuv_conv.yuv420rgba == NULL) - init_yuv_converters(); - - if (yuv->y_height!=yuv->uv_height) - yuv_conv.yuv420rgba(yuv, rgb); - else if (yuv->y_width!=yuv->uv_width) - yuv_conv.yuv422rgba(yuv,rgb); - else - yuv_conv.yuv444rgba(yuv,rgb); -} - -void -oggplay_yuv2bgra(const OggPlayYUVChannels* yuv, OggPlayRGBChannels * rgb) -{ - if (yuv_conv.yuv420bgra == NULL) - init_yuv_converters(); - - if (yuv->y_height!=yuv->uv_height) - yuv_conv.yuv420bgra(yuv, rgb); - else if (yuv->y_width!=yuv->uv_width) - yuv_conv.yuv422bgra(yuv,rgb); - else - yuv_conv.yuv444bgra(yuv,rgb);} - -void -oggplay_yuv2argb(const OggPlayYUVChannels* yuv, OggPlayRGBChannels * rgb) -{ - if (yuv_conv.yuv420argb == NULL) - init_yuv_converters(); - - if (yuv->y_height!=yuv->uv_height) - yuv_conv.yuv420argb(yuv, rgb); - else if (yuv->y_width!=yuv->uv_width) - yuv_conv.yuv422argb(yuv,rgb); - else - yuv_conv.yuv444argb(yuv,rgb); -} - diff --git a/media/liboggplay/src/liboggplay/oggplay_yuv2rgb_template.h b/media/liboggplay/src/liboggplay/oggplay_yuv2rgb_template.h deleted file mode 100644 index c32e7035d80..00000000000 --- a/media/liboggplay/src/liboggplay/oggplay_yuv2rgb_template.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef __OGGPLAY_YUV2RGB_TEMPLATE_H__ -#define __OGGPLAY_YUV2RGB_TEMPLATE_H__ - -#if defined(WIN32) -#define restrict -#else -#ifndef restrict -#define restrict __restrict__ -#endif -#endif - -/** - * Template for YUV to RGB conversion - * - * @param FUNC function name - * @param CONVERT a macro that defines the actual conversion function - * @param VANILLA_OUT - * @param NUM_PIXELS number of pixels processed in one iteration - * @param OUT_SHIFT number of pixels to shift after one iteration in rgb data stream - * @param Y_SHIFT number of pixels to shift after one iteration in Y data stream - * @param UV_SHIFT - * @param UV_VERT_SUB - */ -#define YUV_CONVERT(FUNC, CONVERT, VANILLA_OUT, NUM_PIXELS, OUT_SHIFT, Y_SHIFT, UV_SHIFT, UV_VERT_SUB)\ -static void \ -(FUNC)(const OggPlayYUVChannels* yuv, OggPlayRGBChannels* rgb) \ -{ \ - int i,j, w, h, r; \ - unsigned char* restrict ptry; \ - unsigned char* restrict ptru; \ - unsigned char* restrict ptrv; \ - unsigned char* restrict ptro; \ - unsigned char *dst, *py, *pu, *pv; \ - \ - ptro = rgb->ptro; \ - ptry = yuv->ptry; \ - ptru = yuv->ptru; \ - ptrv = yuv->ptrv; \ - \ - w = yuv->y_width / NUM_PIXELS; \ - h = yuv->y_height; \ - r = yuv->y_width % NUM_PIXELS; \ - for (i = 0; i < h; ++i) \ - { \ - py = ptry; \ - pu = ptru; \ - pv = ptrv; \ - dst = ptro; \ - for (j = 0; j < w; ++j, \ - dst += OUT_SHIFT, \ - py += Y_SHIFT, \ - pu += UV_SHIFT, \ - pv += UV_SHIFT) \ - { \ - /* use the given conversion function */ \ - CONVERT \ - } \ - /* \ - * the video frame is not the multiple of NUM_PIXELS, \ - * thus we have to deal with remaning pixels using \ - * vanilla implementation. \ - */ \ - if (r) { \ - if (r==1 && yuv->y_width&1) { \ - pu -= 1; pv -= 1; \ - } \ - \ - for \ - ( \ - j=(yuv->y_width-r); j < yuv->y_width; \ - ++j, \ - dst += 4, \ - py += 1 \ - ) \ - { \ - LOOKUP_COEFFS \ - VANILLA_YUV2RGB_PIXEL(py[0], ruv, guv, buv) \ - VANILLA_OUT(dst, r, g, b) \ - if \ - ( \ - (j%2 && !(j+1==yuv->y_width-1 && yuv->y_width&1)) \ - || \ - UV_VERT_SUB==1 \ - ) { \ - pu += 1; pv += 1; \ - } \ - } \ - } \ - \ - ptro += rgb->rgb_width * 4; \ - ptry += yuv->y_width; \ - \ - if \ - ( \ - (i & 0x1 && !(i+1==h-1 && h&1)) \ - || \ - UV_VERT_SUB==1 \ - ) \ - { \ - ptru += yuv->uv_width; \ - ptrv += yuv->uv_width; \ - } \ - } \ - CLEANUP \ -} - -#endif - diff --git a/media/liboggplay/src/liboggplay/os2_semaphore.c b/media/liboggplay/src/liboggplay/os2_semaphore.c deleted file mode 100644 index 80bb6faaa32..00000000000 --- a/media/liboggplay/src/liboggplay/os2_semaphore.c +++ /dev/null @@ -1,163 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Mozilla browser. - * - * The Initial Developer of the Original Code is - * Richard Walsh - * Portions created by the Initial Developer are Copyright (c) 2008 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** * - */ -/*****************************************************************************/ -/* - * This is a conservative implementation of a posix counting semaphore. - * It relies on the state of the underlying OS/2 event semaphore to - * control whether sem_wait() blocks or returns immediately, and only - * uses its count to change the sem's state from posted to reset. - * (A more "activist" approach would use the count to decide whether - * to return immediately or to call DosWaitEventSem().) - * - */ -/*****************************************************************************/ - -#include -#define INCL_DOS -#include -#include "os2_semaphore.h" - -#ifndef ERROR_SEM_BUSY -#define ERROR_SEM_BUSY 301 -#endif - -#define SEM_WAIT 20000 - -/*****************************************************************************/ - -int sem_init(sem_t *sem, int pshared, unsigned value) -{ - OS2SEM * psem; - - if (!sem) - return -1; - *sem = 0; - - psem = (OS2SEM*)malloc(sizeof(OS2SEM)); - if (!psem) - return -1; - - if (DosCreateMutexSem(0, &psem->hmtx, 0, 0)) { - free(psem); - return -1; - } - - if (DosCreateEventSem(0, &psem->hev, 0, (value ? 1 : 0))) { - DosCloseMutexSem(psem->hmtx); - free(psem); - return -1; - } - - psem->cnt = value; - *sem = psem; - return 0; -} - -/*****************************************************************************/ - -int sem_wait(sem_t *sem) -{ - OS2SEM * psem; - ULONG cnt; - - if (!sem || !*sem) - return -1; - psem = *sem; - - if (DosWaitEventSem(psem->hev, -1)) - return -1; - - if (DosRequestMutexSem(psem->hmtx, SEM_WAIT)) - return -1; - - if (psem->cnt) - psem->cnt--; - if (!psem->cnt) - DosResetEventSem(psem->hev, &cnt); - DosReleaseMutexSem(psem->hmtx); - - return 0; -} - -/*****************************************************************************/ - -int sem_post(sem_t *sem) -{ - OS2SEM * psem; - - if (!sem || !*sem) - return -1; - psem = *sem; - - if (!DosRequestMutexSem(psem->hmtx, SEM_WAIT)) { - psem->cnt++; - DosPostEventSem(psem->hev); - DosReleaseMutexSem(psem->hmtx); - return 0; - } - - return -1; -} - -/*****************************************************************************/ - -int sem_destroy(sem_t *sem) -{ - OS2SEM * psem; - - if (!sem || !*sem) - return -1; - psem = *sem; - - if (DosCloseMutexSem(psem->hmtx) == ERROR_SEM_BUSY) { - DosRequestMutexSem(psem->hmtx, SEM_WAIT); - DosReleaseMutexSem(psem->hmtx); - DosCloseMutexSem(psem->hmtx); - } - - if (DosCloseEventSem(psem->hev) == ERROR_SEM_BUSY) { - DosPostEventSem(psem->hev); - DosSleep(1); - DosCloseEventSem(psem->hev); - } - - free(psem); - return 0; -} - -/*****************************************************************************/ - diff --git a/media/liboggplay/src/liboggplay/os2_semaphore.h b/media/liboggplay/src/liboggplay/os2_semaphore.h deleted file mode 100644 index c94ba7574d4..00000000000 --- a/media/liboggplay/src/liboggplay/os2_semaphore.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Mozilla browser. - * - * The Initial Developer of the Original Code is - * Richard Walsh - * Portions created by the Initial Developer are Copyright (c) 2008 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** * - */ -/*****************************************************************************/ - -#ifndef _os2_semaphore_ -#define _os2_semaphore_ - -typedef struct _OS2SEM { - HMTX hmtx; - HEV hev; - ULONG cnt; -} OS2SEM; - -typedef OS2SEM * sem_t; - -int sem_init(sem_t *sem, int pshared, unsigned value); -int sem_wait(sem_t *sem); -int sem_post(sem_t *sem); -int sem_destroy(sem_t *sem); - -#endif -/*****************************************************************************/ - diff --git a/media/liboggplay/src/liboggplay/std_semaphore.h b/media/liboggplay/src/liboggplay/std_semaphore.h deleted file mode 100644 index 0a3c83f7519..00000000000 --- a/media/liboggplay/src/liboggplay/std_semaphore.h +++ /dev/null @@ -1,147 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Initial Developer of the Original Code is - * CSIRO - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Shane Stephens, Michael Martin - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _STD_SEMAPHORE_H -#define _STD_SEMAPHORE_H - -/** - * @def SEM_CREATE(p,s) - * - * Macro that creates a semaphore. - * - * @param p semaphore handle - * @param s initial value of the semaphore - * @retval 0 on success - * @retval non-zero on error - */ - -/** - * @def SEM_SIGNAL(p) - * - * The macro increments the given semaphore. - * - * @param p semaphore handle. - * @retval 0 on success - * @retval non-zero on error - */ - -/** - * @def SEM_WAIT(p) - * - * Macro that decrements (locks) the semaphore. - * - * @param p semaphore handle - */ - -/** - * @def SEM_CLOSE(p) - * - * Macro that closes a given semaphore. - * - * @param p semaphore handle - * @retval 0 on success - * @retval non-zero on error - */ - -#if defined(linux) || defined(SOLARIS) || defined(AIX) || defined(__FreeBSD__) -#include -#if defined(__FreeBSD__) -#define SEM_CREATE(p,s) sem_init(&(p), 0, s) -#else -#define SEM_CREATE(p,s) sem_init(&(p), 1, s) -#endif -#define SEM_SIGNAL(p) sem_post(&(p)) -#define SEM_WAIT(p) sem_wait(&(p)) -#define SEM_CLOSE(p) sem_destroy(&(p)) -typedef sem_t semaphore; -#elif defined(WIN32) -#include -#define SEM_CREATE(p,s) (!(p = CreateSemaphore(NULL, (long)(s), (long)(s), NULL))) -#define SEM_SIGNAL(p) (!ReleaseSemaphore(p, 1, NULL)) -#define SEM_WAIT(p) WaitForSingleObject(p, INFINITE) -#define SEM_CLOSE(p) (!CloseHandle(p)) -typedef HANDLE semaphore; -#elif defined(OS2) -#include "os2_semaphore.h" -#define SEM_CREATE(p,s) sem_init(&(p), 1, s) -#define SEM_SIGNAL(p) sem_post(&(p)) -#define SEM_WAIT(p) sem_wait(&(p)) -#define SEM_CLOSE(p) sem_destroy(&(p)) -typedef sem_t semaphore; -#elif defined(__APPLE__) -#include -#define SEM_CREATE(p,s) MPCreateSemaphore(s, s, &(p)) -#define SEM_SIGNAL(p) MPSignalSemaphore(p) -#define SEM_WAIT(p) MPWaitOnSemaphore(p, kDurationForever) -#define SEM_CLOSE(p) MPDeleteSemaphore(p) -typedef MPSemaphoreID semaphore; -#endif -#endif - -/* -#if defined(XP_UX) - sem_init(&(pointers->sem), 1, LIBOGGPLAY_BUFFER_SIZE); -#elif defined(XP_WIN) - pointers->sem = CreateSemaphore(NULL, (long)LIBOGGPLAY_BUFFER_SIZE, - (long)LIBOGGPLAY_BUFFER_SIZE, NULL); -#elif defined(XP_MACOSX) - MPCreateSemaphore(LIBOGGPLAY_BUFFER_SIZE, LIBOGGPLAY_BUFFER_SIZE, - &(pointers->sem)); -#endif - -#if defined(XP_UX) - sem_post(&(ptrs->sem)); -#elif defined(XP_WIN) - ReleaseSemaphore(ptrs->sem, 1, NULL); -#elif defined(XP_MACOSX) - MPSignalSemaphore(ptrs->sem); -#endif - -#if defined(XP_UX) - sem_wait(&(pointers->sem)); -#elif defined(XP_WIN) - WaitForSingleObject(pointers->sem, INFINITE); -#elif defined(XP_MACOSX) - MPWaitOnSemaphore(pointers->sem, kDurationForever); -#endif - -#if defined(XP_UX) - sem_destroy(&(pointers->sem)); -#elif defined(XP_WIN) - CloseHandle(pointers->sem); -#elif defined(XP_MACOSX) - MPDeleteSemaphore(pointers->sem); -#endif -*/ - diff --git a/media/liboggplay/src/liboggplay/x86/oggplay_yuv2rgb_x86.c b/media/liboggplay/src/liboggplay/x86/oggplay_yuv2rgb_x86.c deleted file mode 100644 index 76c6ce166d2..00000000000 --- a/media/liboggplay/src/liboggplay/x86/oggplay_yuv2rgb_x86.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** - * YUV to RGB conversion using x86 CPU extensions - */ -#include "oggplay_private.h" -#include "oggplay_yuv2rgb_template.h" -#include "cpu.h" - -#if defined(_MSC_VER) -# if defined(_M_AMD64) - /* MSVC with x64 doesn't support inline assembler */ -#include -# endif -#include "yuv2rgb_x86_vs.h" -#elif defined(__GNUC__) -#include "yuv2rgb_x86.h" -#endif - -typedef union -{ - long long q[2]; - unsigned long long uq[2]; - int d[4]; - unsigned int ud[4]; - short w[8]; - unsigned short uw[8]; - char b[16]; - unsigned char ub[16]; - float s[4]; -} ATTR_ALIGN(16) simd_t; - -#define UV_128 0x0080008000800080LL -#define Y_16 0x1010101010101010LL -#define Y_Co 0x253f253f253f253fLL -#define GU_Co 0xf37df37df37df37dLL -#define GV_Co 0xe5fce5fce5fce5fcLL -#define BU_Co 0x4093409340934093LL -#define RV_Co 0x3312331233123312LL -#define Y_MASK 0x00ff00ff00ff00ffLL -#define ALFA 0xffffffffffffffffLL - -/** - * coefficients and constants for yuv to rgb SIMD conversion - */ -static const simd_t simd_table[9] = { - {{UV_128, UV_128}}, - {{GU_Co, GU_Co}}, - {{GV_Co, GV_Co}}, - {{BU_Co, BU_Co}}, - {{RV_Co, RV_Co}}, - {{Y_16, Y_16}}, - {{Y_Co, Y_Co}}, - {{Y_MASK, Y_MASK}}, - {{ALFA, ALFA}} -}; - -/* MMX intristics are not supported by VS in x64 mode, thus disable it */ -#if !(defined(_MSC_VER) && defined(_M_AMD64)) -/** - * the conversion functions using MMX instructions - */ - -/* template for the MMX conversion functions */ -#define YUV_CONVERT_MMX(FUNC, CONVERT, CONV_BY_PIXEL, UV_SHIFT, UV_VERT_SUB) YUV_CONVERT(FUNC, CONVERT, CONV_BY_PIXEL, 8, 32, 8, UV_SHIFT, UV_VERT_SUB) - -#define CLEANUP emms() -#define OUT_RGBA_32 OUTPUT_RGBA_32(movq, mm, 8, 16, 24) -#define OUT_ARGB_32 OUTPUT_ARGB_32(movq, mm, 8, 16, 24) -#define OUT_BGRA_32 OUTPUT_BGRA_32(movq, mm, 8, 16, 24) -#define MOVNTQ MMX_MOVNTQ - -/* yuv420 -> */ -#define CONVERT(OUTPUT_FUNC) LOAD_YUV_PLANAR_2(movq, mm) \ - YUV_2_RGB(movq, mm) \ - OUTPUT_FUNC - -YUV_CONVERT_MMX(yuv420_to_rgba_mmx, CONVERT(OUT_RGBA_32), VANILLA_RGBA_OUT, 4, 2) -YUV_CONVERT_MMX(yuv420_to_bgra_mmx, CONVERT(OUT_BGRA_32), VANILLA_BGRA_OUT, 4, 2) -YUV_CONVERT_MMX(yuv420_to_argb_mmx, CONVERT(OUT_ARGB_32), VANILLA_ARGB_OUT, 4, 2) - -YUV_CONVERT_MMX(yuv422_to_rgba_mmx, CONVERT(OUT_RGBA_32), VANILLA_RGBA_OUT, 4, 1) -YUV_CONVERT_MMX(yuv422_to_bgra_mmx, CONVERT(OUT_BGRA_32), VANILLA_BGRA_OUT, 4, 1) -YUV_CONVERT_MMX(yuv422_to_argb_mmx, CONVERT(OUT_ARGB_32), VANILLA_ARGB_OUT, 4, 1) - -YUV_CONVERT_MMX(yuv444_to_rgba_mmx, CONVERT(OUT_RGBA_32), VANILLA_RGBA_OUT, 8, 1) -YUV_CONVERT_MMX(yuv444_to_bgra_mmx, CONVERT(OUT_BGRA_32), VANILLA_BGRA_OUT, 8, 1) -YUV_CONVERT_MMX(yuv444_to_argb_mmx, CONVERT(OUT_ARGB_32), VANILLA_ARGB_OUT, 8, 1) - -#undef MOVNTQ - - -/* template for the SSE conversion functions */ -#define MOVNTQ SSE_MOVNTQ - -YUV_CONVERT_MMX(yuv420_to_rgba_sse, CONVERT(OUT_RGBA_32), VANILLA_RGBA_OUT, 4, 2) -YUV_CONVERT_MMX(yuv420_to_bgra_sse, CONVERT(OUT_BGRA_32), VANILLA_BGRA_OUT, 4, 2) -YUV_CONVERT_MMX(yuv420_to_argb_sse, CONVERT(OUT_ARGB_32), VANILLA_ARGB_OUT, 4, 2) - -YUV_CONVERT_MMX(yuv422_to_rgba_sse, CONVERT(OUT_RGBA_32), VANILLA_RGBA_OUT, 4, 1) -YUV_CONVERT_MMX(yuv422_to_bgra_sse, CONVERT(OUT_BGRA_32), VANILLA_BGRA_OUT, 4, 1) -YUV_CONVERT_MMX(yuv422_to_argb_sse, CONVERT(OUT_ARGB_32), VANILLA_ARGB_OUT, 4, 1) - -YUV_CONVERT_MMX(yuv444_to_rgba_sse, CONVERT(OUT_RGBA_32), VANILLA_RGBA_OUT, 8, 1) -YUV_CONVERT_MMX(yuv444_to_bgra_sse, CONVERT(OUT_BGRA_32), VANILLA_BGRA_OUT, 8, 1) -YUV_CONVERT_MMX(yuv444_to_argb_sse, CONVERT(OUT_ARGB_32), VANILLA_ARGB_OUT, 8, 1) - -#undef CONVERT -#undef CLEANUP -#undef OUT_RGBA_32 -#undef OUT_ARGB_32 -#undef OUT_BGRA_32 -#undef MOVNTQ -#endif - - -/** - * the conversion functions using SSE2 instructions - */ - -/* template for the SSE2 conversion functions */ -#define YUV_CONVERT_SSE2(FUNC, CONVERT, CONV_BY_PIX, UV_SHIFT, UV_VERT_SUB) YUV_CONVERT(FUNC, CONVERT, CONV_BY_PIX, 16, 64, 16, UV_SHIFT, UV_VERT_SUB) - -#define OUT_RGBA_32 OUTPUT_RGBA_32(movdqa, xmm, 16, 32, 48) -#define OUT_ARGB_32 OUTPUT_ARGB_32(movdqa, xmm, 16, 32, 48) -#define OUT_BGRA_32 OUTPUT_BGRA_32(movdqa, xmm, 16, 32, 48) -#define MOVNTQ SSE2_MOVNTQ -#define CLEANUP - -/* yuv420 -> */ -#if defined(_MSC_VER) && defined(_M_AMD64) -#define CONVERT(OUTPUT_FUNC) __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; \ - LOAD_YUV_PLANAR_2(movdqu, xmm) \ - YUV_2_RGB(movdqa, xmm) \ - OUTPUT_FUNC -#else -#define CONVERT(OUTPUT_FUNC) LOAD_YUV_PLANAR_2(movdqu, xmm) \ - YUV_2_RGB(movdqa, xmm) \ - OUTPUT_FUNC -#endif - -YUV_CONVERT_SSE2(yuv420_to_rgba_sse2, CONVERT(OUT_RGBA_32), VANILLA_RGBA_OUT, 8, 2) -YUV_CONVERT_SSE2(yuv420_to_bgra_sse2, CONVERT(OUT_BGRA_32), VANILLA_BGRA_OUT, 8, 2) -YUV_CONVERT_SSE2(yuv420_to_argb_sse2, CONVERT(OUT_ARGB_32), VANILLA_ARGB_OUT, 8, 2) - -YUV_CONVERT_SSE2(yuv422_to_rgba_sse2, CONVERT(OUT_RGBA_32), VANILLA_RGBA_OUT, 8, 1) -YUV_CONVERT_SSE2(yuv422_to_bgra_sse2, CONVERT(OUT_BGRA_32), VANILLA_BGRA_OUT, 8, 1) -YUV_CONVERT_SSE2(yuv422_to_argb_sse2, CONVERT(OUT_ARGB_32), VANILLA_ARGB_OUT, 8, 1) - -YUV_CONVERT_SSE2(yuv444_to_rgba_sse2, CONVERT(OUT_RGBA_32), VANILLA_RGBA_OUT, 16, 1) -YUV_CONVERT_SSE2(yuv444_to_bgra_sse2, CONVERT(OUT_BGRA_32), VANILLA_BGRA_OUT, 16, 1) -YUV_CONVERT_SSE2(yuv444_to_argb_sse2, CONVERT(OUT_ARGB_32), VANILLA_ARGB_OUT, 16, 1) - -#undef CONVERT -#undef OUT_RGBA_32 -#undef OUT_ARGB_32 -#undef OUT_BGRA_32 -#undef MOVNTQ -#undef CLEANUP - diff --git a/media/liboggplay/src/liboggplay/x86/yuv2rgb_x86.h b/media/liboggplay/src/liboggplay/x86/yuv2rgb_x86.h deleted file mode 100644 index bcfe214d038..00000000000 --- a/media/liboggplay/src/liboggplay/x86/yuv2rgb_x86.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef __YUV2RGB_X86_H__ -#define __YUV2RGB_X86_H__ - -# ifdef ATTRIBUTE_ALIGNED_MAX -#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align))) -# else -#define ATTR_ALIGN(align) -# endif - -#define emms() __asm__ __volatile__ ( "emms;" ); -#define MMX_MOVNTQ "movq" -#define SSE_MOVNTQ "movntq" -#define SSE2_MOVNTQ "movdqu" - -#define YUV_2_RGB(mov_instr, reg_type) \ - __asm__ __volatile__ ( \ - "punpcklbw %%"#reg_type"4, %%"#reg_type"0;" /* mm0 = u3 u2 u1 u0 */\ - "punpcklbw %%"#reg_type"4, %%"#reg_type"1;" /* mm1 = v3 v2 v1 v0 */\ - "psubsw (%0), %%"#reg_type"0;" /* u -= 128 */\ - "psubsw (%0), %%"#reg_type"1;" /* v -= 128 */\ - "psllw $3, %%"#reg_type"0;" /* promote precision */\ - "psllw $3, %%"#reg_type"1;" /* promote precision */\ - #mov_instr " %%"#reg_type"0, %%"#reg_type"2;" /* mm2 = u3 u2 u1 u0 */\ - #mov_instr " %%"#reg_type"1, %%"#reg_type"3;" /* mm3 = v3 v2 v1 v0 */\ - "pmulhw 16(%0), %%"#reg_type"2;" /* mm2 = u * u_green */\ - "pmulhw 32(%0), %%"#reg_type"3;" /* mm3 = v * v_green */\ - "pmulhw 48(%0), %%"#reg_type"0;" /* mm0 = chroma_b */\ - "pmulhw 64(%0), %%"#reg_type"1;" /* mm1 = chroma_r */\ - "paddsw %%"#reg_type"3, %%"#reg_type"2;" /* mm2 = chroma_g */\ - "psubusb 80(%0), %%"#reg_type"6;" /* Y -= 16 */\ - #mov_instr " %%"#reg_type"6, %%"#reg_type"7;" /* mm7 = Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */\ - "pand 112(%0), %%"#reg_type"6;" /* mm6 = Y6 Y4 Y2 Y0 */\ - "psrlw $8, %%"#reg_type"7;" /* mm7 = Y7 Y5 Y3 Y1 */\ - "psllw $3, %%"#reg_type"6;" /* promote precision */\ - "psllw $3, %%"#reg_type"7;" /* promote precision */\ - "pmulhw 96(%0), %%"#reg_type"6;" /* mm6 = luma_rgb even */\ - "pmulhw 96(%0), %%"#reg_type"7;" /* mm7 = luma_rgb odd */\ - #mov_instr " %%"#reg_type"0, %%"#reg_type"3;" /* mm3 = chroma_b */\ - #mov_instr " %%"#reg_type"1, %%"#reg_type"4;" /* mm4 = chroma_r */\ - #mov_instr " %%"#reg_type"2, %%"#reg_type"5;" /* mm5 = chroma_g */\ - "paddsw %%"#reg_type"6, %%"#reg_type"0;" /* mm0 = B6 B4 B2 B0 */\ - "paddsw %%"#reg_type"7, %%"#reg_type"3;" /* mm3 = B7 B5 B3 B1 */\ - "paddsw %%"#reg_type"6, %%"#reg_type"1;" /* mm1 = R6 R4 R2 R0 */\ - "paddsw %%"#reg_type"7, %%"#reg_type"4;" /* mm4 = R7 R5 R3 R1 */\ - "paddsw %%"#reg_type"6, %%"#reg_type"2;" /* mm2 = G6 G4 G2 G0 */\ - "paddsw %%"#reg_type"7, %%"#reg_type"5;" /* mm5 = G7 G5 G3 G1 */\ - "packuswb %%"#reg_type"0, %%"#reg_type"0;" /* saturate to 0-255 */\ - "packuswb %%"#reg_type"1, %%"#reg_type"1;" /* saturate to 0-255 */\ - "packuswb %%"#reg_type"2, %%"#reg_type"2;" /* saturate to 0-255 */\ - "packuswb %%"#reg_type"3, %%"#reg_type"3;" /* saturate to 0-255 */\ - "packuswb %%"#reg_type"4, %%"#reg_type"4;" /* saturate to 0-255 */\ - "packuswb %%"#reg_type"5, %%"#reg_type"5;" /* saturate to 0-255 */\ - "punpcklbw %%"#reg_type"3, %%"#reg_type"0;" /* mm0 = B7 B6 B5 B4 B3 B2 B1 B0 */\ - "punpcklbw %%"#reg_type"4, %%"#reg_type"1;" /* mm1 = R7 R6 R5 R4 R3 R2 R1 R0 */\ - "punpcklbw %%"#reg_type"5, %%"#reg_type"2;" /* mm2 = G7 G6 G5 G4 G3 G2 G1 G0 */\ - ::"r" (simd_table)); - -#define OUTPUT_BGRA_32(mov_instr, reg_type, offset0, offset1, offset2) \ - __asm__ __volatile__ ( \ - /* r0=B, r1=R, r2=G */ \ - #mov_instr " 128(%1), %%"#reg_type"3;\n\t"\ - #mov_instr " %%"#reg_type"0, %%"#reg_type"4;\n\t"\ - #mov_instr " %%"#reg_type"1, %%"#reg_type"5;\n\t"\ - "punpcklbw %%"#reg_type"2, %%"#reg_type"0;\n\t" /* GB GB GB GB low */\ - "punpcklbw %%"#reg_type"3, %%"#reg_type"1;\n\t" /* FR FR FR FR low */\ - "punpckhbw %%"#reg_type"2, %%"#reg_type"4;\n\t" /* GB GB GB GB high */\ - "punpckhbw %%"#reg_type"3, %%"#reg_type"5;\n\t" /* FR FR FR FR high */\ - #mov_instr " %%"#reg_type"0, %%"#reg_type"6;\n\t"\ - #mov_instr " %%"#reg_type"4, %%"#reg_type"7;\n\t"\ - "punpcklwd %%"#reg_type"1, %%"#reg_type"0;\n\t" /* FRGB FRGB 0 */\ - "punpckhwd %%"#reg_type"1, %%"#reg_type"6;\n\t" /* FRGB FRGB 1 */\ - "punpcklwd %%"#reg_type"5, %%"#reg_type"4;\n\t" /* FRGB FRGB 2 */\ - "punpckhwd %%"#reg_type"5, %%"#reg_type"7;\n\t" /* FRGB FRGB 3 */\ - MOVNTQ " %%"#reg_type"0, (%0);\n\t"\ - MOVNTQ " %%"#reg_type"6, "#offset0"(%0);\n\t"\ - MOVNTQ " %%"#reg_type"4, "#offset1"(%0);\n\t"\ - MOVNTQ " %%"#reg_type"7, "#offset2"(%0);\n\t"\ - :: "r" (dst), "r" (simd_table)); - - -#define OUTPUT_ARGB_32(mov_instr, reg_type, offset0, offset1, offset2) \ - __asm__ __volatile__ ( \ - /* r0=B, r1=R, r2=G */ \ - #mov_instr " 128(%1), %%"#reg_type"3;\n\t"\ - #mov_instr " %%"#reg_type"3, %%"#reg_type"4;\n\t"\ - #mov_instr " %%"#reg_type"2, %%"#reg_type"5;\n\t"\ - "punpcklbw %%"#reg_type"0, %%"#reg_type"2;\n\t" /* BG BG BG BG low */\ - "punpcklbw %%"#reg_type"1, %%"#reg_type"3;\n\t" /* RF RF RF RF low */\ - "punpckhbw %%"#reg_type"0, %%"#reg_type"5;\n\t" /* BG BG BG BG high */\ - "punpckhbw %%"#reg_type"1, %%"#reg_type"4;\n\t" /* RF RF RF RF high */\ - #mov_instr " %%"#reg_type"3, %%"#reg_type"0;\n\t"\ - #mov_instr " %%"#reg_type"4, %%"#reg_type"1;\n\t"\ - "punpcklwd %%"#reg_type"2, %%"#reg_type"3;\n\t" /* BGRF BGRF 0 */\ - "punpckhwd %%"#reg_type"2, %%"#reg_type"0;\n\t" /* BGRF BGRF 1 */\ - "punpcklwd %%"#reg_type"5, %%"#reg_type"4;\n\t" /* BGRF BGRF 2 */\ - "punpckhwd %%"#reg_type"5, %%"#reg_type"1;\n\t" /* BGRF BGRF 3 */\ - MOVNTQ " %%"#reg_type"3, (%0);\n\t"\ - MOVNTQ " %%"#reg_type"0, "#offset0"(%0);\n\t"\ - MOVNTQ " %%"#reg_type"4, "#offset1"(%0);\n\t"\ - MOVNTQ " %%"#reg_type"1, "#offset2"(%0);\n\t"\ - :: "r" (dst), "r" (simd_table)); - -#define OUTPUT_RGBA_32(mov_instr, reg_type, offset0, offset1, offset2) \ - __asm__ __volatile__ ( \ - /* r0=B, r1=R, r2=G */ \ - #mov_instr " 128(%1), %%"#reg_type"3;\n\t"\ - #mov_instr " %%"#reg_type"1, %%"#reg_type"4;\n\t"\ - #mov_instr " %%"#reg_type"0, %%"#reg_type"5;\n\t"\ - "punpcklbw %%"#reg_type"2, %%"#reg_type"1;\n\t" /* GR GR GR GR low */\ - "punpcklbw %%"#reg_type"3, %%"#reg_type"0;\n\t" /* 0B 0B 0B 0B low */\ - "punpckhbw %%"#reg_type"2, %%"#reg_type"4;\n\t" /* GR GR GR GR high */\ - "punpckhbw %%"#reg_type"3, %%"#reg_type"5;\n\t" /* 0B 0B 0B 0B high */\ - #mov_instr " %%"#reg_type"1, %%"#reg_type"6;\n\t"\ - #mov_instr " %%"#reg_type"4, %%"#reg_type"7;\n\t"\ - "punpcklwd %%"#reg_type"0, %%"#reg_type"1;\n\t" /* 0BGR 0BGR 0 */\ - "punpckhwd %%"#reg_type"0, %%"#reg_type"6;\n\t" /* 0BGR 0BGR 1 */\ - "punpcklwd %%"#reg_type"5, %%"#reg_type"4;\n\t" /* 0BGR 0BGR 2 */\ - "punpckhwd %%"#reg_type"5, %%"#reg_type"7;\n\t" /* 0BGR 0BGR 3 */\ - MOVNTQ " %%"#reg_type"1, (%0);\n\t"\ - MOVNTQ " %%"#reg_type"6, "#offset0"(%0);\n\t"\ - MOVNTQ " %%"#reg_type"4, "#offset1"(%0);\n\t"\ - MOVNTQ " %%"#reg_type"7, "#offset2"(%0);\n\t"\ - :: "r" (dst), "r" (simd_table)); - -#define LOAD_YUV_PLANAR_2(mov_instr, reg_type) \ - __asm__ __volatile__ ( \ - #mov_instr " %0, %%"#reg_type"6;\n\t" \ - #mov_instr " %1, %%"#reg_type"0;\n\t" \ - #mov_instr " %2, %%"#reg_type"1;\n\t" \ - "pxor %%"#reg_type"4, %%"#reg_type"4;\n\t" \ - :: "m" (*py), "m" (*pu), "m" (*pv)); - - -#endif /* __YUV2RGB_X86_H__ */ - diff --git a/media/liboggplay/src/liboggplay/x86/yuv2rgb_x86_vs.h b/media/liboggplay/src/liboggplay/x86/yuv2rgb_x86_vs.h deleted file mode 100644 index 6978678f854..00000000000 --- a/media/liboggplay/src/liboggplay/x86/yuv2rgb_x86_vs.h +++ /dev/null @@ -1,242 +0,0 @@ -#ifndef __OGGPLAY_YUV2RGB_VS_H__ -#define __OGGPLAY_YUV2RGB_VS_H__ - -#define ATTR_ALIGN(_align) __declspec(align(_align)) - -#define emms() __asm emms -#define MMX_MOVNTQ movq -#define SSE_MOVNTQ movntq -#define SSE2_MOVNTQ movdqu - -#if defined(_M_IX86) -#define LOAD_YUV_PLANAR_2(mov_instr, reg_type) \ - __asm { \ - __asm mov eax, py \ - __asm mov edx, pu \ - __asm mov_instr reg_type##6, [eax] \ - __asm mov_instr reg_type##0, [edx] \ - __asm mov eax, pv \ - __asm mov_instr reg_type##1, [eax] \ - __asm pxor reg_type##4, reg_type##4 \ - } -#elif defined(_M_AMD64) -#define LOAD_YUV_PLANAR_2(mov_instr, reg_type) \ - { \ - xmm6 = _mm_loadu_si128((__m128i*)py); \ - xmm0 = _mm_loadu_si128((__m128i*)pu); \ - xmm1 = _mm_loadu_si128((__m128i*)pv); \ - xmm4 = _mm_setzero_si128(); \ - } -#endif - -#if defined(_M_IX86) -#define OUTPUT_RGBA_32(mov_instr, reg_type, offset0, offset1, offset2) \ - __asm { \ - __asm mov eax, dst \ - __asm mov_instr reg_type##3, [simd_table+128] \ - __asm mov_instr reg_type##4, reg_type##1 \ - __asm mov_instr reg_type##5, reg_type##0 \ - __asm punpcklbw reg_type##1, reg_type##2 \ - __asm punpcklbw reg_type##0, reg_type##3 \ - __asm punpckhbw reg_type##4, reg_type##2 \ - __asm punpckhbw reg_type##5, reg_type##3 \ - __asm mov_instr reg_type##6, reg_type##1 \ - __asm mov_instr reg_type##7, reg_type##4 \ - __asm punpcklwd reg_type##1, reg_type##0 \ - __asm punpckhwd reg_type##6, reg_type##0 \ - __asm punpcklwd reg_type##4, reg_type##5 \ - __asm punpckhwd reg_type##7, reg_type##5 \ - __asm MOVNTQ [eax], reg_type##1 \ - __asm MOVNTQ [eax+offset0], reg_type##6 \ - __asm MOVNTQ [eax+offset1], reg_type##4 \ - __asm MOVNTQ [eax+offset2], reg_type##7 \ - } -#elif defined(_M_AMD64) -#define OUTPUT_RGBA_32(mov_instr, reg_type, offset0, offset1, offset2) \ - { \ - xmm3 = _mm_load_si128((__m128i*)simd_table+8); \ - xmm4 = _mm_unpackhi_epi8(xmm1, xmm2); \ - xmm1 = _mm_unpacklo_epi8(xmm1, xmm2); \ - xmm5 = _mm_unpackhi_epi8(xmm0, xmm3); \ - xmm0 = _mm_unpacklo_epi8(xmm0, xmm3); \ - xmm6 = _mm_unpackhi_epi8(xmm1, xmm0); \ - xmm1 = _mm_unpacklo_epi8(xmm1, xmm0); \ - xmm7 = _mm_unpackhi_epi8(xmm4, xmm5); \ - xmm4 = _mm_unpacklo_epi8(xmm4, xmm5); \ - _mm_storeu_si128(dst, xmm1); \ - _mm_storeu_si128(dst + offset0, xmm6); \ - _mm_storeu_si128(dst + offset1, xmm4); \ - _mm_storeu_si128(dst + offset2, xmm7); \ - } -#endif - -#if defined(_M_IX86) -#define OUTPUT_ARGB_32(mov_instr, reg_type, offset0, offset1, offset2) \ - __asm { \ - __asm mov eax, dst \ - __asm mov_instr reg_type##3, [simd_table+128] \ - __asm mov_instr reg_type##4, reg_type##3 \ - __asm mov_instr reg_type##5, reg_type##2 \ - __asm punpcklbw reg_type##2, reg_type##0 \ - __asm punpcklbw reg_type##3, reg_type##1 \ - __asm punpckhbw reg_type##5, reg_type##0 \ - __asm punpckhbw reg_type##4, reg_type##1 \ - __asm mov_instr reg_type##0, reg_type##3 \ - __asm mov_instr reg_type##1, reg_type##4 \ - __asm punpcklwd reg_type##3, reg_type##2 \ - __asm punpckhwd reg_type##0, reg_type##2 \ - __asm punpcklwd reg_type##4, reg_type##5 \ - __asm punpckhwd reg_type##1, reg_type##5 \ - __asm MOVNTQ [eax], reg_type##3 \ - __asm MOVNTQ [eax+offset0], reg_type##0 \ - __asm MOVNTQ [eax+offset1], reg_type##4 \ - __asm MOVNTQ [eax+offset2], reg_type##1 \ - } -#elif defined(_M_AMD64) -#define OUTPUT_ARGB_32(mov_instr, reg_type, offset0, offset1, offset2) \ - { \ - xmm3 = _mm_load_si128((__m128i*)simd_table+8); \ - xmm5 = _mm_unpackhi_epi8(xmm2, xmm0); \ - xmm2 = _mm_unpacklo_epi8(xmm2, xmm0); \ - xmm4 = _mm_unpackhi_epi8(xmm3, xmm1); \ - xmm3 = _mm_unpacklo_epi8(xmm3, xmm1); \ - xmm0 = _mm_unpackhi_epi16(xmm3, xmm2); \ - xmm3 = _mm_unpacklo_epi16(xmm3, xmm2); \ - xmm1 = _mm_unpackhi_epi16(xmm4, xmm5); \ - xmm4 = _mm_unpacklo_epi16(xmm4, xmm5); \ - _mm_storeu_si128(dst, xmm3); \ - _mm_storeu_si128(dst + offset0, xmm0); \ - _mm_storeu_si128(dst + offset1, xmm4); \ - _mm_storeu_si128(dst + offset2, xmm1); \ - } -#endif - -#if defined(_M_IX86) -#define OUTPUT_BGRA_32(mov_instr, reg_type, offset0, offset1, offset2) \ - __asm { \ - __asm mov eax, dst \ - __asm mov_instr reg_type##3, [simd_table+128] \ - __asm mov_instr reg_type##4, reg_type##0 \ - __asm mov_instr reg_type##5, reg_type##1 \ - __asm punpcklbw reg_type##0, reg_type##2 \ - __asm punpcklbw reg_type##1, reg_type##3 \ - __asm punpckhbw reg_type##4, reg_type##2 \ - __asm punpckhbw reg_type##5, reg_type##3 \ - __asm mov_instr reg_type##6, reg_type##0 \ - __asm mov_instr reg_type##7, reg_type##4 \ - __asm punpcklwd reg_type##0, reg_type##1 \ - __asm punpckhwd reg_type##6, reg_type##1 \ - __asm punpcklwd reg_type##4, reg_type##5 \ - __asm punpckhwd reg_type##7, reg_type##5 \ - __asm MOVNTQ [eax], reg_type##0 \ - __asm MOVNTQ [eax+offset0], reg_type##6 \ - __asm MOVNTQ [eax+offset1], reg_type##4 \ - __asm MOVNTQ [eax+offset2], reg_type##7 \ - } -#elif defined(_M_AMD64) -#define OUTPUT_BGRA_32(mov_instr, reg_type, offset0, offset1, offset2) \ - { \ - xmm3 = _mm_load_si128((__m128i*)simd_table+8); \ - xmm4 = _mm_unpackhi_epi8(xmm0, xmm2); \ - xmm0 = _mm_unpacklo_epi8(xmm0, xmm2); \ - xmm5 = _mm_unpackhi_epi8(xmm1, xmm3); \ - xmm1 = _mm_unpacklo_epi8(xmm1, xmm3); \ - xmm6 = _mm_unpackhi_epi8(xmm0, xmm1); \ - xmm0 = _mm_unpacklo_epi8(xmm0, xmm1); \ - xmm7 = _mm_unpackhi_epi8(xmm4, xmm5); \ - xmm4 = _mm_unpacklo_epi8(xmm4, xmm5); \ - _mm_storeu_si128(dst, xmm0); \ - _mm_storeu_si128(dst + offset0, xmm6); \ - _mm_storeu_si128(dst + offset1, xmm4); \ - _mm_storeu_si128(dst + offset2, xmm7); \ - } -#endif - -#if defined(_M_IX86) -#define YUV_2_RGB(mov_instr, reg_type) \ - __asm { \ - __asm punpcklbw reg_type##0, reg_type##4 /* mm0 = u3 u2 u1 u0 */\ - __asm punpcklbw reg_type##1, reg_type##4 /* mm1 = v3 v2 v1 v0 */\ - __asm psubsw reg_type##0, [simd_table] /* u -= 128 */\ - __asm psubsw reg_type##1, [simd_table] /* v -= 128 */\ - __asm psllw reg_type##0, 3 /* promote precision */\ - __asm psllw reg_type##1, 3 /* promote precision */\ - __asm mov_instr reg_type##2, reg_type##0 /* mm2 = u3 u2 u1 u0 */\ - __asm mov_instr reg_type##3, reg_type##1 /* mm3 = v3 v2 v1 v0 */\ - __asm pmulhw reg_type##2, [simd_table+16] /* mm2 = u * u_green */\ - __asm pmulhw reg_type##3, [simd_table+32] /* mm3 = v * v_green */\ - __asm pmulhw reg_type##0, [simd_table+48] /* mm0 = chroma_b */\ - __asm pmulhw reg_type##1, [simd_table+64] /* mm1 = chroma_r */\ - __asm paddsw reg_type##2, reg_type##3 /* mm2 = chroma_g */\ - __asm psubusb reg_type##6, [simd_table+80] /* Y -= 16 */\ - __asm mov_instr reg_type##7, reg_type##6 /* mm7 = Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */\ - __asm pand reg_type##6, [simd_table+112] /* mm6 = Y6 Y4 Y2 Y0 */\ - __asm psrlw reg_type##7, 8 /* mm7 = Y7 Y5 Y3 Y1 */\ - __asm psllw reg_type##6, 3 /* promote precision */\ - __asm psllw reg_type##7, 3 /* promote precision */\ - __asm pmulhw reg_type##6, [simd_table+96] /* mm6 = luma_rgb even */\ - __asm pmulhw reg_type##7, [simd_table+96] /* mm7 = luma_rgb odd */\ - __asm mov_instr reg_type##3, reg_type##0 /* mm3 = chroma_b */\ - __asm mov_instr reg_type##4, reg_type##1 /* mm4 = chroma_r */\ - __asm mov_instr reg_type##5, reg_type##2 /* mm5 = chroma_g */\ - __asm paddsw reg_type##0, reg_type##6 /* mm0 = B6 B4 B2 B0 */\ - __asm paddsw reg_type##3, reg_type##7 /* mm3 = B7 B5 B3 B1 */\ - __asm paddsw reg_type##1, reg_type##6 /* mm1 = R6 R4 R2 R0 */\ - __asm paddsw reg_type##4, reg_type##7 /* mm4 = R7 R5 R3 R1 */\ - __asm paddsw reg_type##2, reg_type##6 /* mm2 = G6 G4 G2 G0 */\ - __asm paddsw reg_type##5, reg_type##7 /* mm5 = G7 G5 G3 G1 */\ - __asm packuswb reg_type##0, reg_type##0 /* saturate to 0-255 */\ - __asm packuswb reg_type##1, reg_type##1 /* saturate to 0-255 */\ - __asm packuswb reg_type##2, reg_type##2 /* saturate to 0-255 */\ - __asm packuswb reg_type##3, reg_type##3 /* saturate to 0-255 */\ - __asm packuswb reg_type##4, reg_type##4 /* saturate to 0-255 */\ - __asm packuswb reg_type##5, reg_type##5 /* saturate to 0-255 */\ - __asm punpcklbw reg_type##0, reg_type##3 /* mm0 = B7 B6 B5 B4 B3 B2 B1 B0 */\ - __asm punpcklbw reg_type##1, reg_type##4 /* mm1 = R7 R6 R5 R4 R3 R2 R1 R0 */\ - __asm punpcklbw reg_type##2, reg_type##5 /* mm2 = G7 G6 G5 G4 G3 G2 G1 G0 */\ - } -#elif defined(_M_AMD64) -#define YUV_2_RGB(mov_instr, reg_type) \ - { \ - xmm0 = _mm_unpacklo_epi8(xmm0, xmm4); /* mm0 = u3 u2 u1 u0 */\ - xmm1 = _mm_unpacklo_epi8(xmm1, xmm4); /* mm1 = v3 v2 v1 v0 */\ - xmm0 = _mm_subs_epi16(xmm0, _mm_load_si128((__m128i*)simd_table)); /* u -= 128 */\ - xmm1 = _mm_subs_epi16(xmm1, _mm_load_si128((__m128i*)simd_table)); /* v -= 128 */\ - xmm0 = _mm_slli_epi16(xmm0, 3); /* promote precision */\ - xmm1 = _mm_slli_epi16(xmm1, 3); /* promote precision */\ - xmm2 = _mm_mulhi_epi16(xmm0, _mm_load_si128((__m128i*)simd_table+1)); /* mm2 = u * u_green */\ - xmm3 = _mm_mulhi_epi16(xmm1, _mm_load_si128((__m128i*)simd_table+2)); /* mm3 = v * v_green */\ - xmm0 = _mm_mulhi_epi16(xmm0, _mm_load_si128((__m128i*)simd_table+3)); /* mm0 = chroma_b */\ - xmm1 = _mm_mulhi_epi16(xmm1, _mm_load_si128((__m128i*)simd_table+4)); /* mm1 = chroma_r */\ - xmm2 = _mm_adds_epi16(xmm2, xmm3); /* mm2 = chroma_g */\ - xmm6 = _mm_subs_epu8(xmm6, _mm_load_si128((__m128i*)simd_table+5)); /* Y -= 16 */\ - xmm7 = xmm6; /* mm7 = Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */\ - xmm6 = _mm_and_si128(xmm6, _mm_load_si128((__m128i*)simd_table+7); /* mm6 = Y6 Y4 Y2 Y0 */\ - xmm7 = _mm_srli_epi16(xmm7, 8); /* mm7 = Y7 Y5 Y3 Y1 */\ - xmm6 = _mm_slli_epi16(xmm6, 3); /* promote precision */\ - xmm7 = _mm_slli_epi16(xmm7, 3); /* promote precision */\ - xmm6 = _mm_mulhi_epi16(xmm6, _mm_load_si128((__m128i*)simd_table+6)); /* mm6 = luma_rgb even */\ - xmm7 = _mm_mulhi_epi16(xmm7, _mm_load_si128((__m128i*)simd_table+6)); /* mm7 = luma_rgb odd */\ - xmm3 = xmm0; /* mm3 = chroma_b */\ - xmm4 = xmm1; /* mm4 = chroma_r */\ - xmm5 = xmm2; /* mm5 = chroma_g */\ - xmm0 = _mm_adds_epi16(xmm0, xmm6); /* mm0 = B6 B4 B2 B0 */\ - xmm3 = _mm_adds_epi16(xmm3, xmm7); /* mm3 = B7 B5 B3 B1 */\ - xmm1 = _mm_adds_epi16(xmm1, xmm6); /* mm1 = R6 R4 R2 R0 */\ - xmm4 = _mm_adds_epi16(xmm4, xmm7); /* mm4 = R7 R5 R3 R1 */\ - xmm2 = _mm_adds_epi16(xmm2, xmm6); /* mm2 = G6 G4 G2 G0 */\ - xmm5 = _mm_adds_epi16(xmm5, xmm7); /* mm5 = G7 G5 G3 G1 */\ - xmm0 = _mm_packus_epi16(xmm0, xmm0); /* saturate to 0-255 */\ - xmm1 = _mm_packus_epi16(xmm1, xmm1); /* saturate to 0-255 */\ - xmm2 = _mm_packus_epi16(xmm2, xmm2); /* saturate to 0-255 */\ - xmm3 = _mm_packus_epi16(xmm3, xmm3); /* saturate to 0-255 */\ - xmm4 = _mm_packus_epi16(xmm4, xmm4); /* saturate to 0-255 */\ - xmm5 = _mm_packus_epi16(xmm5, xmm5); /* saturate to 0-255 */\ - xmm0 = _mm_unpacklo_epi8(xmm0, xmm3); /* mm0 = B7 B6 B5 B4 B3 B2 B1 B0 */\ - xmm1 = _mm_unpacklo_epi8(xmm1, xmm4); /* mm1 = R7 R6 R5 R4 R3 R2 R1 R0 */\ - xmm2 = _mm_unpacklo_epi8(xmm2, xmm5); /* mm2 = G7 G6 G5 G4 G3 G2 G1 G0 */\ - } -#endif - -#endif - diff --git a/media/liboggplay/update.sh b/media/liboggplay/update.sh deleted file mode 100644 index 1199bd782af..00000000000 --- a/media/liboggplay/update.sh +++ /dev/null @@ -1,65 +0,0 @@ -# Usage: ./update.sh -# -# Copies the needed files from a directory containing the original -# liboggplay source that we need for the Mozilla HTML5 media support. -sed 's/#define ATTRIBUTE_ALIGNED_MAX .*//g' $1/config.h >./src/liboggplay/config.h -echo "#undef HAVE_GLUT" >>./src/liboggplay/config.h -cp $1/include/oggplay/oggplay_callback_info.h ./include/oggplay/oggplay_callback_info.h -cp $1/include/oggplay/oggplay_query.h ./include/oggplay/oggplay_query.h -cp $1/include/oggplay/oggplay_seek.h ./include/oggplay/oggplay_seek.h -cp $1/include/oggplay/oggplay_enums.h ./include/oggplay/oggplay_enums.h -cp $1/include/oggplay/oggplay_tools.h ./include/oggplay/oggplay_tools.h -cp $1/win32/config_win32.h ./include/oggplay/config_win32.h -cp $1/include/oggplay/oggplay.h ./include/oggplay/oggplay.h -cp $1/include/oggplay/oggplay_reader.h ./include/oggplay/oggplay_reader.h -cp $1/README ./README -cp $1/COPYING ./COPYING -cp $1/src/liboggplay/oggplay_buffer.c ./src/liboggplay/oggplay_buffer.c -cp $1/src/liboggplay/oggplay_tcp_reader.h ./src/liboggplay/oggplay_tcp_reader.h -cp $1/src/liboggplay/oggplay_callback_info.c ./src/liboggplay/oggplay_callback_info.c -cp $1/src/liboggplay/oggplay_tools.c ./src/liboggplay/oggplay_tools.c -cp $1/src/liboggplay/oggplay_yuv2rgb.c ./src/liboggplay/oggplay_yuv2rgb.c -cp $1/src/liboggplay/oggplay_seek.c ./src/liboggplay/oggplay_seek.c -cp $1/src/liboggplay/oggplay_buffer.h ./src/liboggplay/oggplay_buffer.h -cp $1/src/liboggplay/oggplay_file_reader.c ./src/liboggplay/oggplay_file_reader.c -cp $1/src/liboggplay/oggplay_data.h ./src/liboggplay/oggplay_data.h -cp $1/src/liboggplay/oggplay_callback.c ./src/liboggplay/oggplay_callback.c -cp $1/src/liboggplay/oggplay_file_reader.h ./src/liboggplay/oggplay_file_reader.h -cp $1/src/liboggplay/std_semaphore.h ./src/liboggplay/std_semaphore.h -cp $1/src/liboggplay/oggplay.c ./src/liboggplay/oggplay.c -cp $1/src/liboggplay/oggplay_callback.h ./src/liboggplay/oggplay_callback.h -cp $1/src/liboggplay/oggplay_tcp_reader.c ./src/liboggplay/oggplay_tcp_reader.c -cp $1/src/liboggplay/oggplay_query.c ./src/liboggplay/oggplay_query.c -cp $1/src/liboggplay/cpu.c ./src/liboggplay/cpu.c -cp $1/src/liboggplay/cpu.h ./src/liboggplay/cpu.h -cp $1/src/liboggplay/oggplay_yuv2rgb_template.h ./src/liboggplay/oggplay_yuv2rgb_template.h -cp $1/src/liboggplay/x86/oggplay_yuv2rgb_x86.c ./src/liboggplay/x86/oggplay_yuv2rgb_x86.c -cp $1/src/liboggplay/x86/yuv2rgb_x86.h ./src/liboggplay/x86/yuv2rgb_x86.h -cp $1/src/liboggplay/x86/yuv2rgb_x86_vs.h ./src/liboggplay/x86/yuv2rgb_x86_vs.h -sed 's/#include "config_win32.h"//g' $1/src/liboggplay/oggplay_private.h >./src/liboggplay/oggplay_private.h1 -sed 's/#include /#ifdef WIN32\ -#include "config_win32.h"\ -#else\ -#include \ -#endif/g' ./src/liboggplay/oggplay_private.h1 >./src/liboggplay/oggplay_private.h -rm ./src/liboggplay/oggplay_private.h1 -sed s/\#ifdef\ HAVE_INTTYPES_H/\#if\ HAVE_INTTYPES_H/g $1/src/liboggplay/oggplay_data.c >./src/liboggplay/oggplay_data.c -patch -p3 < endian.patch -patch -p3 < bug481921.patch -patch -p3 < aspect_ratio.patch -patch -p3 < bug493678.patch -patch -p3 < seek_to_key_frame.patch -patch -p3 < bug487519.patch -rm -f src/liboggplay/os2_semaphore.c -rm -f src/liboggplay/os2_semaphore.h -patch -p3 < oggplay_os2.patch -patch -p3 < bug496529.patch -patch -p3 < bug500311.patch -patch -p3 < faster_seek.patch -patch -p3 < fix-17ef4ca82df28.patch -patch -p3 < handle-read-errors.patch -patch -p3 < fishsound_reset.patch -patch -p3 < bug504843.patch -patch -p3 < bug520493.patch -patch -p3 < bug515217.patch -patch -p3 < bug523816.patch diff --git a/media/liboggz/AUTHORS b/media/liboggz/AUTHORS deleted file mode 100644 index 0b32fcbb603..00000000000 --- a/media/liboggz/AUTHORS +++ /dev/null @@ -1,53 +0,0 @@ -Conrad Parker - - Design, general implementation - -Shane Stephens - - Calculated granulepos, seeking improvements - -Silvia Pfeiffer - - Design, MS Windows porting - -Andre Pang - - Design, Mac OS X porting - -David Kuehling - - oggzrip tool - -Tahseen Mohammad - - Skeleton support in oggzinfo - -Kangyuan Niu - - oggz-comment tool - -Ian Malone - - oggz_comment_generate(), oggz_comment_set_vendor(), - oggz_packet_destroy(), FLAC header fixes - -ogg.k.ogg.k - - Kate support, many bugfixes - -Mike Smith - - examples/fix-eos.c, page-level validation in oggz-validate - -Ralph Giles - - Build system fixes - -Erik de Castro Lopo - - compiler flags and warnings - -Thomas van der Stichele - - build system fixes, uninstalled support - -Colin Ward - - Symbian build system - -Marcin Lubonski -Alex Krumm-Heller -Zentaro Kavanagh - - MS Windows porting and packaging, Windows specific bugfixes. - -Angus Lees -Jamie Wilkinson -John Ferlito - - Debian packaging - diff --git a/media/liboggz/COPYING b/media/liboggz/COPYING deleted file mode 100644 index 0be71ec661c..00000000000 --- a/media/liboggz/COPYING +++ /dev/null @@ -1,29 +0,0 @@ - Copyright (C) 2003 CSIRO Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the CSIRO nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/media/liboggz/ChangeLog b/media/liboggz/ChangeLog deleted file mode 100644 index 9f89375dbd1..00000000000 --- a/media/liboggz/ChangeLog +++ /dev/null @@ -1,464 +0,0 @@ -Thu Apr 10 11:14:43 JST 2009 Conrad Parker - - * Version 0.9.9 - - This release adds Dirac support, security fixes, improved low-memory - behaviour, and a new 'oggz' wrapper tool with bash completion. - - Security: - * Handle allocation failure due to out of memory throughout, for Mozilla - bug 468280. Adds new error return OGGZ_ERR_OUT_OF_MEMORY - * skeleton.c::ogg_from_fisbone(): avoid memcpy of NULL - fp->message_header_fields. Fixes ticket:408, reported by j^ - * Mozilla bug 463756: return an error when a hole (ie. missing sequence - number) is detected in the headers of a track - * Remove dead code from oggz_read.c for ticket:439, reported by Coverity - * Check for NULL return value of val in cgi.c - (ticket:438, reported by Coverity) - * Add NULL return checks - (ticket:440, reported by Coverity) - * Check for integer overflows in calculations for realloc and when using - strlen returns. For Mozilla bug 480014 - * Don't map all errors to OGGZ_ERR_STOP_ERR - Required for Mozilla bug 481933 - Exposes detected HOLE_IN_DATA as return value from oggz_read(), - oggz_read_input(), and add documentation for extra return values - * Apply patch by Jim Blandy from Mozilla bug 480521 - Avoid overflow in comment lengths - - oggz-chop: - * Added "X-Accept-TimeURI: application/ogg" HTTP response header to - oggz-chop CGI output. - * Added video/ogg and audio/ogg to example apache config for oggz-chop - CGI (Ivo) - * Added a check if PATH_TRANSLATED is defined, warn about CGI - configuration error otherwise (to stderr, ie. we - * Added customization for DocumentRoot, for servers that don't provide - PATH_TRANSLATED - - Documentation: - * oggz_constants.h: document use of OGGZ_PREFIX and OGGZ_SUFFIX - - Build: - * Build fixes for Mac OS X (rillian) - * Allow compilation of the library on win32 using Visual Studio 2003 - and 2005. The project files have been updated to fix previous errors - with compiling using both of these IDEs. - Patch by Barry Duncan, and regenerated by ogg.k.ogg.k - - Internal: - * Add oggz_content_type() public API function: - Returns a human-readable string representation of a content type - * Add API functions for getting and seting preroll: - oggz_get_preroll(), oggz_set_preroll() - Set preroll in oggz_auto.c for vorbis and speex - * Kate updates (ogg.k.ogg.k) - * Parse BOS page before calling first page reader callback. - Fixes ticket:416, "oggz-chop writes wrong granulerate in fisbone" - * Apply patch from dryeo, "off_t not always in stdio.h" - Closes ticket:413 - * Apply patch from dryeo, "OS/2 also needs to set stdin/stdout to - binary" Closes ticket:414 - * Apply patch by j^, Closes ticket:406 "oggzinfo Video-Height is - wrong" - * Fix oggz-comment writing bad data into streams - Patch by ogg.k.ogg.k: - * Updated shared version info to 6:0:5 - - -Fri Jul 4 19:06:54 JST 2008 Conrad Parker - - * Version 0.9.8 - - This release adds a new oggz-chop tool, which can be used to serve time - ranges of Ogg media over HTTP. - - It also includes support for the Ogg mapping of the experimental Kate - codec (http://wiki.xiph.org/index.php/OggKate). - - Tools: - * Added new oggz-chop tool: Extract the part of an Ogg file between - given start and/or end times. See below for usage information. - * oggz-sort: Detect and fix page granulepos that should be -1 but - isn't; fixes file error "on page with no completed packets, must be - -1" reported by oggz-validate. (Timothy B. Terriberry) - * oggz-validate: Handle tracking of bos and eos when checking pages, - not packets. - * oggz-validate: Generalized A/V header ordering to handle more audio - types (PCM, FLAC0, FLAC, CELT) - * oggz-comment: Fixed a crash when writing output to stdout, eg. by - running "oggz-comment file.ogv -a". Reported by j^ - * oggz-comment: Fixed a bug where files with skeleton could not have - their comments modified or listed. Reported by j^ - * oggzinfo: Fixed crash if a skeleton track refers to a track not - found in the physical stream. (ogg.k.ogg.k) - * oggzinfo: Fixed an overflow in standard deviation calculation, - and avoided a divide by zero, in the unlikely case where we have - only one packet. (ogg.k.ogg.k) - * oggzinfo: remove memory leak from allocated message headers - (ogg.k.ogg.k) - * oggzinfo: Fixed byte offsets for reporting skeleton basetime. - * oggzinfo: Corrected calculation of Content-Duration to take the - Presentation-Time reported in skeleton - * oggzinfo: Display percentage overhead of Ogg framing for each - track. (ogg.k.ogg.k) - * oggz-basetime: Use new API call oggz_stream_get_numheaders(), - rather than hardcoding to 3. (ogg.k.ogg.k) - * oggzdiff: Allow diffing files with the same name if they are in - different directories. (ogg.k.ogg.k) - - Documentation: - * Added a usage example to oggzrip man page, showing how to create an - Ogg Vorbis I file from any file containing a vorbis audio track. Adapted - from: http://lists.xiph.org/pipermail/vorbis-dev/2008-April/019320.html - * Clarified documentation of oggz_table_insert() - * Added link to celt-codec.org in oggz_seek docs - - Build: - * Fixed out-of-tree builds in configure and Makefile.am throughout - - Internal: - * Added support for the Kate codec throughout (ogg.k.ogg.k) - * tools/skeleton.c: add fisbone_clear() function, for deallocating - message headers. (ogg.k.ogg.k) - -Fri Feb 15 16:52:21 JST 2008 Conrad Parker - - * Version 0.9.7 - - This release adds a new oggz-sort tool, includes fixes for serialno - generation on 64bit (LP64) platforms, and adds decoding of FLAC - vorbiscomment packets and basic support for the Ogg mapping of the - experimental CELT codec. It also includes various API additions, - documentation updates and new example code. - - Tools: - * Added new oggz-sort tool: Sort the pages of an Ogg file in order - of presentation time. (See below for rationale and usage). - * 'oggzdiff --revert' fixes for long oggzdump packetinfo lines - * oggz-comment: Modified to copy data pages verbatim. - * oggzinfo: Fixed for skeleton interpretation on big-endian hosts. - * oggzinfo: Various cleanups in skeleton.c (ogg.k.ogg.k) - - Documentation: - * Updated known (non-experimental) content types in all man pages. - * Added information about the use of oggz_tell_granulepos() in - OggzReadCallbacks for retrieving calculated granulepos values. - - Examples: - * Added modify-headers example, demonstrating how to write a program - which modifies Ogg header packets but leaves data pages intact. - - liboggz API: - * Added oggz_comments_copy(). - * Added oggz_comments_generate(), which does not require a - packet_type argument. Deprecate oggz_comment_generate(). - * Added oggz_stream_get_numheaders(), implemented for all known codecs - * oggz_serialno_new() now only generates serialnos which will fit - within a 32bit integer. - * oggz_write_feed() now fails with OGGZ_ERR_BAD_SERIALNO if it is - passed a serialno outside of the 32bit range. - * Added OGGZ_CONTENT_CELT to the public OggzStreamContent enum. - - Internal: - * Fixed a bunch of x86-64 compiler warnings. (Erik de Castro Lopo) - * Updated acinclude.m4 to latest ogg.m4. (Ivo Gonçalves) - * Added basic support for (experimental) Ogg mapping for CELT codec. - * libtool shared version info updated to 5:0:4 - - -Sun Jan 13 13:27:57 JST 2008 - - * Version 0.9.6 - - This release adds a new oggz-comment tool, and improvements to - liboggz's determination of timestamps and seeking. Specifically, - liboggz now inspects the encoded data in order reconstruct the - expected granulepos (corresponding to a timestamp) for every packet - in an Ogg stream. This allows applications to use reliable - timestamps, even though these are only sparsely recorded in most - Ogg streams. - - Tools: - * Added new oggz-comment tool (Kangyuan Niu) - * Added Skeleton support to oggzinfo (Tahseen Mohammad) - * Report FLAC samplerate, channels in oggzinfo (Conrad Parker) - - Documentation: - * Improved oggzmerge documentation (Debian bug #280550) - - liboggz API: - * Added content type detection and retrieval functions - oggz_stream_get_content(), oggz_stream_get_content_type() - (Shane Stephens) - * Added oggz_tell_granulepos function to query liboggz for - granulepos values. (Shane Stephens) - * Added Vorbiscomment API oggz_comment_*() for manipulating comments - in Ogg Vorbis, Speex, Theora, FLAC files (Conrad Parker, Ian Malone) - * Added oggz_get_numtracks() (Conrad Parker) - - Internal: - * Added automatic calculation of missing granulepos values - in Vorbis, Speex, Theora (Shane Stephens) and FLAC (Conrad Parker) - * Seeking improvements (Shane Stephens) - * Corrections for C standards support (Erik de Castro Lopo) - * GNU Autotools build system updates (Ralph Giles, Thomas van der - Stichele) - * Updated Win32 build system (Alex Krumm-Heller, Marcin Lubonski) - * libtool shared version info updated to 4:0:3 - -2007-01-12 Thomas Vander Stichele - - * Makefile.am: - dist uninstalled pc file - * oggz-uninstalled.pc.in: - added - * configure.ac: - increase package version so liboggplay can require > 0.9.5 - - -Mon Mar 13 14:58:23 EST 2006 Conrad Parker - - * Version 0.9.5 - - * Fixed and updated Windows (Visual Studio) support - - added missing exported symbols, projects for oggz tools. - (Alex Krumm-Heller, Silvia Pfeiffer) - - * Support for OggPCM (Draft 2, Main header) - - OggPCM is an experimental specification for storing uncompressed - PCM audio in Ogg bitstreams. - - - liboggz: Recognition of OggPCM timestamps, and support for - seeking in files that contain OggPCM logical bitstreams. - - oggzinfo: Display OggPCM header details - - oggzdump, oggzrip: New [--content-type pcm, -c pcm] option - to filter on OggPCM - - oggz-validate: Validate framing of OggPCM logical bitstreams - - This version is installed on http://validator.annodex.org/ for - online validation of OggPCM files. - - For more information about OggPCM, see: - http://wiki.xiph.org/index.php/OggPCM - - * ./configure support for large (>2GB) files - This version adds build configuration support for large files, - allowing liboggz to operate on files >2GB. This version does - not introduce any API changes; interfaces such as oggz_tell() - continue to use off_t externally. However, sequential reading - and validation of large files is now possible. - - * bug fixes and cleanups: - - oggz-validate, oggzmerge, oggzdump, oggz-scan, oggzinfo: handle - unknown content types (Ian Malone) - - remove deprecated oggzed example - - various code and documentation build cleanups - - -Tue Feb 14 10:14:09 EST 2006 Conrad Parker - - * Version 0.9.4 - - * liboggz: Added new oggz_run() convenience function - - equivalent to calling oggz_read() or oggz_write() in a loop, - but only returns upon completion or error - - added new oggz_run_set_blocksize() function - - updated libtool shared version info to 3:0:2 - - * liboggz: Improved callback handling - - added delayed callback error handling for oggz_read*() and - oggz_write*() functions. When a reading or writing operation is - stopped by a user callback returning OGGZ_STOP_OK or OGGZ_STOP_ERR, - that return value is cached and reported by the subsequent call - to oggz_read*() or oggz_write*() (unless no data has been read or - written, in which case it is reported immediately as before). This - ensures that a user callback returning OGGZ_STOP_OK or - OGGZ_STOP_ERR is always explicitly acknowledged without requiring - the application to track its own errors. - - * Improvements to oggz-validate: - - added ability to run oggz-validate on stdin, using "-" as filename - - added --prefix, --suffix and --partial options to suppress errors - when only validating the specified portion of a complete stream - - add --max-errors num option to specify the maximum number of - errors to bail out after, or 0 to show all errors (ticket:154) - - if an input file fails oggz_open(), continue processing other - files on the commandline rather than exiting immediately - - improved documentation of errors detected by oggz-validate - - added --help-errors (-E) option to just list known errors, - without other help text around - - * oggzmerge: When merging Vorbis and Theora streams, ensure the - Theora header appears first in the output file in conformance with - the Ogg Theora bitstream specification. (ticket:189) - -2005-11-17 Thomas Vander Stichele - - * configure.ac: - * doc/Makefile.am: - Work also with docbook2man as installed on Fedora - -Fri Oct 7 16:59:32 EST 2005 Conrad Parker - - * Version 0.9.3 - * New oggz-scan tool (silvia) - oggz-scan displays timestamps of characteristic features in an Ogg - file. 'oggz-scan --keyframes file.ogg' displays timestamps of - unforced Theora keyframes, which are a useful rough approximation of - shot boundaries. Results can be output as plain text, CMML or HTML. - * Improvements to oggz-validate: - - added page-level validation, ensuring that a page that ends zero - packets has the correct granulepos, -1. (MikeS) - - added a check that any Theora bos pages come before Vorbis and - Speex bos pages. (ticket:156) (conrad) - - correct handling of chained files (ticket: 162) (conrad) - * win32 build fix for oggz tools (j^) - * liboggz: replace internal typedef of oggz_off_t, use off_t instead - of long (ticket:161) (Grayfox) - * examples/fix-eos: discard trailing incomplete packets from the end - of the stream. (MikeS) - * remove autogenerated manpages (ticket:155) (conrad, silvia) - -Mon Jul 11 22:14:14 CST 2005 Conrad Parker - - * Version 0.9.2 - * added rewrite-pages example code stub to build tools from - * added fix-eos example tool to fix missing EOS flags (MikeS) - * Build system improvements (thomasvs) - * oggzinfo: Fix calculation of content duration. (ticket:117) - * oggzmerge: Fix an interleaving error in oggzmerge. (ticket:121) - * oggzrip: fix memory corruption detected by glibc on Fedora Core - (reported/fixed by thomasvs) - * oggz-validate: report streams with missing *** eos (ticket:146) - * oggz-validate: report and fail on non-Ogg files (ticket:147) - * Removed need for ./configure --disable-shared when running tests - under valgrind - -2005-06-13 Thomas Vander Stichele - - * autogen.sh: - * m4/as-ac-expand.m4: - add m4 dir and use it - add an expand macro - * configure.ac: - uniformize configure's output across the annodex stack - -2005-06-13 Thomas Vander Stichele - - * doc/Makefile.am: - the doxygen stamp file is a build marker and should not be installed - -2005-06-09 Thomas Vander Stichele - - * src/tools/oggz-basetime.c: (filter_page), (read_page): - Don't adjust granulepos of the three header packets' pages - -2005-06-07 Thomas Vander Stichele - - * src/tools/oggzrip.c: - fixes memory corruption detected by glibc on Fedora Core - -2005-06-07 Thomas Vander Stichele - - * include/oggz/Makefile.am: - don't override includedir - -Fri Apr 8 23:52:31 EST 2005 Conrad Parker - - * Version 0.9.1 - * Added new oggzinfo tool - * Added new oggz-validate tool - * oggzdump now displays packet lengths (in bytes, kB, MB, GB ;-) - and timestamps (rather than just byte offsets). - * oggzdump now interprets theora granulepos as a split of keyframe|pframe - * oggzdump now also has a --content-type (or -c) option for - specifying the name of a particular bitstream to dump - * r1176: fix some typos in oggzdiff which prevented multiple hide - options from being specified - * r1092: fix a bug in raw seeking, where doing a raw seek by bytes - and back again by time (to the original time point) hadn't - invalidated the cached time offset, hence the second seek was - considered unnecessary and skipped. This change correctly - invalidates the cached time offset when doing a raw byte seek. - * oggzrip filtering decisions are now made at the start of each logical - bitstream, not at every packet. Additionally, the hardcoded limit of - extracting no more than 64 logical bitstreams from the input file was removed. - -Mon Feb 14 16:51:28 PST 2005 Conrad Parker - - * Version 0.9.0 - * updates for keyframe seeking in Theora and files with Ogg Skeleton - metaheaders (http://wiki.xiph.org/index.php/OggSkeleton) - * added missing header file definitions for oggz_get_granulerate() - and oggz_get_granuleshift() - * build fix for Symbian, adding missing file oggz_seek.c (Colin Ward) - * general code cleanups - * updated libtool shared version info to 2:0:1 - -Mon Feb 7 13:18:33 EST 2005 Conrad Parker - - * Version 0.8.6 - * new oggzrip tool, for ripping individual tracks from Ogg files; - by David Kuehling - * added inbuilt parsing of FLAC headers for seeking hints, by - Tobias Gehrig. This allows Ogg FLAC files to be used with oggzmerge - and similar tools. - * fixed oggzmerge binary open bug on Win32 (Colin Ward) - * updated Win32 project by Orum - * added inbuilt parsing of Ogg Skeleton and CMML binary headers - * simplified documentation related to seeking - * added oggz_{get,set}_{granulerate,granuleshift}() query functions - * Applied patch from Erik de Castro Lopo. Now builds on MingGW: - + add pkg-config check for Ogg - + add vorbis and speex CFLAGS to various Makefile.am's - -Wed Oct 6 15:49:25 EST 2004 Conrad Parker - - * Version 0.8.5 - * new oggzmerge tool, for time-wise interleaving of bitstreams. - Via OggzAuto, merges files containing any number of Vorbis, Speex, - Theora and Annodex bitstreams automatically. - * updated support for Win32 - * added OggzReadPage API - * many improvements to seeking behaviour - * added seek-stress example program - * fixed theora keyframe shift interpretation in oggz_auto - -Wed Sep 8 15:23:04 EST 2004 Conrad Parker - - * Version 0.8.4 - * added support for building on Symbian OS (by Colin Ward) - * new OGGZ_ERR_IO_AGAIN handling for network reads - * added test for reading packets one-by-one - * expanded --help output for oggzdump tool - * added option to run test suite under valgrind - -Fri Jan 21 17:38:33 EST 2005 Conrad Parker - - * added FLAC header parsing from Tobias Gehrig - * added CMML header parsing - -Fri May 28 11:08:34 EST 2004 Conrad Parker - - * removed use of floating point in liboggz - -Fri May 21 16:48:34 EST 2004 Conrad Parker - - * Version 0.8.3 - * Theora header parsing updated for Theora alpha3 - * fixes for win32 build procedure - * improved API documentation for seeking, OGGZ_AUTO and OggzIO - -Thu Mar 11 11:00:00 EST 2004 Silvia Pfeiffer - * Version 0.8.2 - * fixed up the Makefiles to not include the CVS subdirectories - -Sun Mar 07 16:00:00 EST 2004 Silvia Pfeiffer - * Version 0.8.1 - * includes Windows port with Makefile & VC6 workspace & .NET solution - -Thu Oct 16 21:55:07 EST 2003 Conrad Parker - - * split liboggz out from libannodex sources, started ChangeLog diff --git a/media/liboggz/Makefile.in b/media/liboggz/Makefile.in deleted file mode 100644 index 0f1eb23bf4d..00000000000 --- a/media/liboggz/Makefile.in +++ /dev/null @@ -1,51 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = oggz - -DIRS = \ - include \ - src \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/media/liboggz/README b/media/liboggz/README deleted file mode 100644 index 8f6ce203268..00000000000 --- a/media/liboggz/README +++ /dev/null @@ -1,193 +0,0 @@ -Documentation files for Oggz ----------------------------- - - PATCHES: Instructions for generating patches - README: this file - README.symbian: Instructions for building for Symbian - README.win32: Instructions for building on Win32 - -Run: ----- - - $ oggz help - -for documentation of the various oggz commands. - -About Oggz -========== - -Oggz comprises liboggz and the tool oggz, which provides commands to -inspect, edit and validate Ogg files. The oggz-chop tool can also be -used to serve time ranges of Ogg media over HTTP by any web server that -supports CGI. - -liboggz is a C library for reading and writing Ogg files and streams. -It offers various improvements over the reference libogg, including -support for seeking, validation and timestamp interpretation. Ogg is -an interleaving data container developed by Monty at Xiph.Org, -originally to support the Ogg Vorbis audio format but now used for -many free codecs including Dirac, FLAC, Speex and Theora. - -Dependencies ------------- - -Oggz depends only on libogg, available in most free software -distributions, or in source form at: http://xiph.org/downloads/ - -Support is built-in for parsing the headers of and seeking to time -positions in Ogg Dirac, FLAC, Speex, Theora and Vorbis. Oggz is also -compatible with Annodex streams, and supports seeking on all tracks -described in an Ogg Skeleton track. - -Installation ------------- - -Release archives can be installed using the conventional commands: - - $ ./configure - $ make check - $ sudo make install - -sequence. Configuration details are in the file INSTALL. If you obtained -this source by svn, first run "./autogen.sh" to create the configure script, -then run the above commands. - -Read the file README.win32 for installing under MS Windows, and -README.symbian for information about building for Symbian devices. - -Source layout -------------- - - doc/ - doc/liboggz autocreated by the doxygen tool from comments - contained in the public C header files - - include/ public C header files - - src/ - src/liboggz/ library source code. - src/tools/ command line tools - src/examples/ example programs using liboggz - src/tests/ unit and functional tests - - symbian/ files necessary to compile the library for Symbian - win32/ files necessary to compile the library and tools for - Microsoft Windows - -Programming with liboggz ------------------------- - -liboggz supports the flexibility afforded by the Ogg file format while -presenting the following API niceties: - - * Full API documentation - - * Comprehensive test suite of read, write and seeking behavior. - The entire test suite can be run under valgrind if available. - - * Developed and tested on GNU/Linux, Darwin/MacOSX, Win32 and - Symbian OS. May work on other Unix-like systems via GNU autoconf. - For Win32: nmake Makefiles, Visual Studio .NET 2003 solution files - and Visual C++ 6.0 workspace files are provided in the source - distribution. - - * Strict adherence to the formatting requirements of Ogg bitstreams, - to ensure that only valid bitstreams are generated; writes can fail - if you try to write illegally structured packets. - - * A simple, callback based open/read/close or open/write/close - interface to raw Ogg files. - - * Writing automatically interleaves with packet queuing, and provides - callback based notification when this queue is empty - - * A customisable seeking abstraction for seeking on multitrack Ogg - data. Seeking works easily and reliably on multitrack and multi-codec - streams, and can transparently parse Theora, Speex, Vorbis, FLAC, - PCM, CMML and Ogg Skeleton headers without requiring linking to those - libraries. This allows efficient use on servers and other devices - that need to parse and seek within Ogg files, but do not need to do - a full media decode. - -Full documentation of the liboggz API, customization and installation, -and mux and demux examples can be read online at: - - http://www.xiph.org/oggz/doc/ - -oggz tool ---------- - -Usage: oggz [options] filename ... - -oggz is a commandline tool for manipulating Ogg files. It supports -multiplexed files conformant with RFC3533. Oggz can parse headers for CELT, -CMML, Dirac, FLAC, Kate, PCM, Speex, Theora and Vorbis, and can read and write -Ogg Skeleton logical bitstreams. - -Commands: - help Display help for a specific subcommand (eg. "oggz help chop") - -Reporting: - codecs Display the codecs present in an Ogg file - diff Hexdump the packets of two Ogg files and output differences. - dump Hexdump packets of an Ogg file, or revert an Ogg file from - such a hexdump. - info Display information about one or more Ogg files and their - bitstreams. - scan Scan an Ogg file and output characteristic landmarks. - validate Validate the Ogg framing of one or more files. - -Extraction: - rip Extract one or more logical bitstreams from an Ogg file. - -Editing: - chop Extract the part of an Ogg file between given start and/or - end times. - comment List or edit comments in an Ogg file. - merge Merge Ogg files together, interleaving pages in order of - presentation time. - sort Sort the pages of an Ogg file in order of presentation time. - -Miscellaneous: - known-codecs List codecs known by this version of oggz - -The script bash-completion/oggz enables completion of tool options and codec -names when using the bash shell. Source it from your .profile, or install it -in /etc/bash_completion.d to enable it system-wide. - - -oggz-chop: General usage and CGI installation ---------------------------------------------- - -oggz-chop extracts the part of an Ogg file between given start and/or end -times. The output file contains copies of the headers of the input file, and -all the codec data required to correctly decode the content between the start -and end times specified on the commandline. For codecs with data dependencies -like video keyframes, the keyframe prior to the starting time will be included -in the output. - -An Apache server can be configured to use oggz-chop to handle all Ogg files -(or, all Ogg files in a particular directory). An example Apache configuration -is in the liboggz source tree, along with a script for installing it on a -Debian server. - -The oggz-chop binary checks if it is being run as a CGI script (by checking -some environment variables), and if so acts based on the CGI query parameter -t=, much like mod_annodex. It accepts all the time specifications that -mod_annodex accepts (npt and various smpte framerates), and start and end -times separated by a /. - -License -------- - -Oggz is Free Software, available under a BSD style license. - -More information is available online at the Oggz homepage: - - http://xiph.org/oggz/ - -enjoy :) - --- -Conrad Parker -http://www.annodex.net/ diff --git a/media/liboggz/README_MOZILLA b/media/liboggz/README_MOZILLA deleted file mode 100644 index 539e3db4396..00000000000 --- a/media/liboggz/README_MOZILLA +++ /dev/null @@ -1,39 +0,0 @@ -The source from this directory was copied from the liboggz git -source repository using the update.sh script. The only changes made -were those applied by update.sh, which applies patches described -below, and the addition/upate of Makefile.in files for the -Mozilla build system. - -The git commit id used was cf5feeaab69b05 from git://git.xiph.org/liboggz.git - -The wince.patch addresses the lack of posix file IO support on windows ce, -see bug 461844 for details. - -key_frame_seek.patch fixes bug 463358. - -offset_next.patch fixes bug 495366. - -bug487519.patch: Fix for bug 487519. - -bug496063.patch: Fix for infinite loop during seek while shutting down. - -faster_seek.patch: Fix for bug 501031, make seeking faster over HTTP. - -bug516847.patch: Fix for bug 516847 (duplicate frame handling). - -bug518169.patch: Fix bug 518169, fix faster_seek.patch. - -bug504843.patch: Propogate read errors from oggz_read_sync(). - -bug519155.patch: Fix oggz seek's reset so that it can rollback on fail correctly. - -bug498380.patch: Remove bogus assert. - -bug520493.patch: Fix oggz seek so that it doesn't exit too early, and to use - more accurate page offsets while bisecting. - -bug523335.patch: Abort oggz seek bisection when the underlying stream closes. - -bug533822.patch: Clear packets queued for granulepos calcuation when resetting streams. - -bug526097.patch: Length check mode_sizes array in vorbis auto metrics calculation. diff --git a/media/liboggz/bug487519.patch b/media/liboggz/bug487519.patch deleted file mode 100644 index baf1267d6f8..00000000000 --- a/media/liboggz/bug487519.patch +++ /dev/null @@ -1,234 +0,0 @@ -diff --git a/media/liboggz/src/liboggz/oggz_dlist.c b/media/liboggz/src/liboggz/oggz_dlist.c ---- a/media/liboggz/src/liboggz/oggz_dlist.c -+++ b/media/liboggz/src/liboggz/oggz_dlist.c -@@ -133,70 +133,81 @@ oggz_dlist_prepend(OggzDList *dlist, voi - new_elem->prev = dlist->head; - new_elem->next = dlist->head->next; - new_elem->prev->next = new_elem; - new_elem->next->prev = new_elem; - - return 0; - } - --void -+int - oggz_dlist_iter(OggzDList *dlist, OggzDListIterFunc func) { - - OggzDListElem *p; - - for (p = dlist->head->next; p != dlist->tail; p = p->next) { -- if (func(p->data) == DLIST_ITER_CANCEL) { -+ int r = func(p->data); -+ if (r == DLIST_ITER_ERROR) { -+ return -1; -+ } -+ -+ if (r == DLIST_ITER_CANCEL) { - break; - } - } - -+ return 0; - } - - void - oggz_dlist_reverse_iter(OggzDList *dlist, OggzDListIterFunc func) { - - OggzDListElem *p; - - for (p = dlist->tail->prev; p != dlist->head; p = p->prev) { - if (func(p->data) == DLIST_ITER_CANCEL) { - break; - } - } - } - --void -+int - oggz_dlist_deliter(OggzDList *dlist, OggzDListIterFunc func) { - - OggzDListElem *p, *q; -+ int result = 0; - - for (p = dlist->head->next; p != dlist->tail; p = q) { -- if (func(p->data) == DLIST_ITER_CANCEL) { -+ int r = func(p->data); -+ if (r == DLIST_ITER_ERROR) { -+ result = -1; -+ } -+ -+ if (r == DLIST_ITER_CANCEL) { - break; - } - - q = p->next; - p->prev->next = p->next; - p->next->prev = p->prev; - - oggz_free(p); - } -- -+ return result; - } - - void - oggz_dlist_reverse_deliter(OggzDList *dlist, OggzDListIterFunc func) { - - OggzDListElem *p, *q; - - for (p = dlist->tail->prev; p != dlist->head; p = q) { - if (func(p->data) == DLIST_ITER_CANCEL) { - break; - } -- - q = p->prev; - p->prev->next = p->next; - p->next->prev = p->prev; - - oggz_free(p); - } - - } -diff --git a/media/liboggz/src/liboggz/oggz_dlist.h b/media/liboggz/src/liboggz/oggz_dlist.h ---- a/media/liboggz/src/liboggz/oggz_dlist.h -+++ b/media/liboggz/src/liboggz/oggz_dlist.h -@@ -31,17 +31,17 @@ - */ - - #ifndef __OGGZ_DLIST_H__ - #define __OGGZ_DLIST_H__ - - struct _OggzDList; - typedef struct _OggzDList OggzDList; - --typedef enum {DLIST_ITER_CANCEL, DLIST_ITER_CONTINUE} OggzDListIterResponse; -+typedef enum {DLIST_ITER_ERROR=-1, DLIST_ITER_CANCEL=0, DLIST_ITER_CONTINUE=1} OggzDListIterResponse; - - typedef OggzDListIterResponse (*OggzDListIterFunc) (void *elem); - - OggzDList * - oggz_dlist_new (void); - - void - oggz_dlist_delete(OggzDList *dlist); -@@ -50,21 +50,21 @@ int - oggz_dlist_is_empty(OggzDList *dlist); - - int - oggz_dlist_append(OggzDList *dlist, void *elem); - - int - oggz_dlist_prepend(OggzDList *dlist, void *elem); - --void -+int - oggz_dlist_iter(OggzDList *dlist, OggzDListIterFunc func); - - void - oggz_dlist_reverse_iter(OggzDList *dlist, OggzDListIterFunc func); - --void -+int - oggz_dlist_deliter(OggzDList *dlist, OggzDListIterFunc func); - - void - oggz_dlist_reverse_deliter(OggzDList *dlist, OggzDListIterFunc func); - - #endif -diff --git a/media/liboggz/src/liboggz/oggz_read.c b/media/liboggz/src/liboggz/oggz_read.c ---- a/media/liboggz/src/liboggz/oggz_read.c -+++ b/media/liboggz/src/liboggz/oggz_read.c -@@ -292,21 +292,25 @@ oggz_read_deliver_packet(void *elem) { - unit_stored = p->reader->current_unit; - - p->reader->current_granulepos = p->calced_granulepos; - - p->reader->current_unit = - oggz_get_unit (p->oggz, p->serialno, p->calced_granulepos); - - if (p->stream->read_packet) { -- p->stream->read_packet(p->oggz, &(p->packet), p->serialno, -- p->stream->read_user_data); -+ if (p->stream->read_packet(p->oggz, &(p->packet), p->serialno, -+ p->stream->read_user_data) != 0) { -+ return DLIST_ITER_ERROR; -+ } - } else if (p->reader->read_packet) { -- p->reader->read_packet(p->oggz, &(p->packet), p->serialno, -- p->reader->read_user_data); -+ if (p->reader->read_packet(p->oggz, &(p->packet), p->serialno, -+ p->reader->read_user_data) != 0) { -+ return DLIST_ITER_ERROR; -+ } - } - - p->reader->current_granulepos = gp_stored; - p->reader->current_unit = unit_stored; - - oggz_read_free_pbuffer_entry(p); - - return DLIST_ITER_CONTINUE; -@@ -448,17 +452,19 @@ oggz_read_sync (OGGZ * oggz) - * move backward through the list assigning gp values based upon - * the granulepos we just recieved. Then move forward through - * the list delivering any packets at the beginning with valid - * gp values - */ - ogg_int64_t gp_stored = stream->last_granulepos; - stream->last_packet = &packet; - oggz_dlist_reverse_iter(oggz->packet_buffer, oggz_read_update_gp); -- oggz_dlist_deliter(oggz->packet_buffer, oggz_read_deliver_packet); -+ if (oggz_dlist_deliter(oggz->packet_buffer, oggz_read_deliver_packet) == -1) { -+ return OGGZ_ERR_HOLE_IN_DATA; -+ } - - /* - * fix up the stream granulepos - */ - stream->last_granulepos = gp_stored; - - if (!oggz_dlist_is_empty(oggz->packet_buffer)) { - OggzBufferedPacket *p = oggz_read_new_pbuffer_entry( -@@ -486,17 +492,20 @@ oggz_read_sync (OGGZ * oggz) - if (!op->b_o_s) stream->delivered_non_b_o_s = 1; - } - else - break; - } - } - - /* If we've got a stop already, don't read more data in */ -- if (cb_ret == OGGZ_STOP_OK || cb_ret == OGGZ_STOP_ERR) return cb_ret; -+ if (cb_ret == OGGZ_STOP_OK || -+ cb_ret == OGGZ_STOP_ERR || -+ cb_ret == OGGZ_ERR_HOLE_IN_DATA) -+ return cb_ret; - - if(oggz_read_get_next_page (oggz, &og) < 0) - return OGGZ_READ_EMPTY; /* eof. leave uninitialized */ - - serialno = ogg_page_serialno (&og); - reader->current_serialno = serialno; /* XXX: maybe not necessary */ - - stream = oggz_get_stream (oggz, serialno); -@@ -588,18 +597,19 @@ oggz_read (OGGZ * oggz, long n) - - if (bytes_read > 0) { - ogg_sync_wrote (&reader->ogg_sync, bytes_read); - - remaining -= bytes_read; - nread += bytes_read; - - cb_ret = oggz_read_sync (oggz); -- if (cb_ret == OGGZ_ERR_OUT_OF_MEMORY) -+ if (cb_ret == OGGZ_ERR_OUT_OF_MEMORY || cb_ret == OGGZ_ERR_HOLE_IN_DATA) { - return cb_ret; -+ } - } - } - - if (cb_ret == OGGZ_STOP_ERR) oggz_purge (oggz); - - /* Don't return 0 unless it's actually an EOF condition */ - if (nread == 0) { - switch (bytes_read) { diff --git a/media/liboggz/bug496063.patch b/media/liboggz/bug496063.patch deleted file mode 100644 index cc4c3963f5a..00000000000 --- a/media/liboggz/bug496063.patch +++ /dev/null @@ -1,41 +0,0 @@ -diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c ---- a/media/liboggz/src/liboggz/oggz_seek.c -+++ b/media/liboggz/src/liboggz/oggz_seek.c -@@ -472,16 +472,18 @@ oggz_scan_for_page (OGGZ * oggz, ogg_pag - serialno = ogg_page_serialno (og); - granule_at = ogg_page_granulepos (og); - unit_at = oggz_get_unit (oggz, serialno, granule_at); - - break; - #else - do { - offset_at = oggz_get_prev_start_page(oggz, og, &granule_at, &serialno); -+ if (offset_at < 0) -+ break; - unit_at = oggz_get_unit(oggz, serialno, granule_at); - } while (unit_at > unit_target); - return offset_at; - #endif - } else if (unit_at == unit_target) { - #ifdef DEBUG - printf (" scan: (%lld) == (%lld)\n", unit_at, unit_target); - #endif -@@ -761,16 +763,18 @@ oggz_bounded_seek_set (OGGZ * oggz, - if (unit_end == unit_begin) break; - } else { - break; - } - } - - do { - offset_at = oggz_get_prev_start_page (oggz, og, &granule_at, &serialno); -+ if (offset_at < 0) -+ break; - unit_at = oggz_get_unit (oggz, serialno, granule_at); - } while (unit_at > unit_target); - - if (offset_at < 0) { - oggz_reset (oggz, offset_orig, -1, SEEK_SET); - return -1; - } - diff --git a/media/liboggz/bug498380.patch b/media/liboggz/bug498380.patch deleted file mode 100644 index cdfa1ab3d3e..00000000000 --- a/media/liboggz/bug498380.patch +++ /dev/null @@ -1,68 +0,0 @@ -diff --git a/media/liboggz/src/liboggz/oggz.c b/media/liboggz/src/liboggz/oggz.c ---- a/media/liboggz/src/liboggz/oggz.c -+++ b/media/liboggz/src/liboggz/oggz.c -@@ -210,17 +210,17 @@ oggz_close (OGGZ * oggz) - oggz_write_close (oggz); - } else if (OGGZ_CONFIG_READ) { - oggz_read_close (oggz); - } - - oggz_vector_foreach (oggz->streams, oggz_stream_clear); - oggz_vector_delete (oggz->streams); - -- assert(oggz_dlist_is_empty(oggz->packet_buffer)); -+ oggz_dlist_deliter(oggz->packet_buffer, oggz_read_free_pbuffers); - oggz_dlist_delete(oggz->packet_buffer); - - if (oggz->metric_internal) - oggz_free (oggz->metric_user_data); - - if (oggz->file != NULL) { - if (fclose (oggz->file) == EOF) { - return OGGZ_ERR_SYSTEM; -diff --git a/media/liboggz/src/liboggz/oggz_private.h b/media/liboggz/src/liboggz/oggz_private.h ---- a/media/liboggz/src/liboggz/oggz_private.h -+++ b/media/liboggz/src/liboggz/oggz_private.h -@@ -314,9 +314,12 @@ long oggz_comments_encode (OGGZ * oggz, - - /* oggz_io */ - size_t oggz_io_read (OGGZ * oggz, void * buf, size_t n); - size_t oggz_io_write (OGGZ * oggz, void * buf, size_t n); - int oggz_io_seek (OGGZ * oggz, long offset, int whence); - long oggz_io_tell (OGGZ * oggz); - int oggz_io_flush (OGGZ * oggz); - -+/* oggz_read */ -+OggzDListIterResponse oggz_read_free_pbuffers(void *elem); -+ - #endif /* __OGGZ_PRIVATE_H__ */ -diff --git a/media/liboggz/src/liboggz/oggz_read.c b/media/liboggz/src/liboggz/oggz_read.c ---- a/media/liboggz/src/liboggz/oggz_read.c -+++ b/media/liboggz/src/liboggz/oggz_read.c -@@ -248,16 +248,26 @@ void - oggz_read_free_pbuffer_entry(OggzBufferedPacket *p) { - - oggz_free(p->packet.packet); - oggz_free(p); - - } - - OggzDListIterResponse -+oggz_read_free_pbuffers(void *elem) -+{ -+ OggzBufferedPacket *p = (OggzBufferedPacket *)elem; -+ -+ oggz_read_free_pbuffer_entry(p); -+ -+ return DLIST_ITER_CONTINUE; -+} -+ -+OggzDListIterResponse - oggz_read_update_gp(void *elem) { - - OggzBufferedPacket *p = (OggzBufferedPacket *)elem; - - if (p->calced_granulepos == -1 && p->stream->last_granulepos != -1) { - int content = oggz_stream_get_content(p->oggz, p->serialno); - - /* Cancel the iteration (backwards through buffered packets) diff --git a/media/liboggz/bug504843.patch b/media/liboggz/bug504843.patch deleted file mode 100644 index 09ea9f4fd70..00000000000 --- a/media/liboggz/bug504843.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/media/liboggz/src/liboggz/oggz_read.c b/media/liboggz/src/liboggz/oggz_read.c ---- a/media/liboggz/src/liboggz/oggz_read.c -+++ b/media/liboggz/src/liboggz/oggz_read.c -@@ -492,19 +492,17 @@ oggz_read_sync (OGGZ * oggz) - if (!op->b_o_s) stream->delivered_non_b_o_s = 1; - } - else - break; - } - } - - /* If we've got a stop already, don't read more data in */ -- if (cb_ret == OGGZ_STOP_OK || -- cb_ret == OGGZ_STOP_ERR || -- cb_ret == OGGZ_ERR_HOLE_IN_DATA) -+ if (cb_ret < 0 || cb_ret == OGGZ_STOP_OK) - return cb_ret; - - if(oggz_read_get_next_page (oggz, &og) < 0) - return OGGZ_READ_EMPTY; /* eof. leave uninitialized */ - - serialno = ogg_page_serialno (&og); - reader->current_serialno = serialno; /* XXX: maybe not necessary */ - diff --git a/media/liboggz/bug516847.patch b/media/liboggz/bug516847.patch deleted file mode 100644 index b1f59b2340a..00000000000 --- a/media/liboggz/bug516847.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/media/liboggz/src/liboggz/oggz_auto.c b/media/liboggz/src/liboggz/oggz_auto.c ---- a/media/liboggz/src/liboggz/oggz_auto.c -+++ b/media/liboggz/src/liboggz/oggz_auto.c -@@ -559,17 +559,17 @@ typedef struct { - static ogg_int64_t - auto_calc_theora(ogg_int64_t now, oggz_stream_t *stream, ogg_packet *op) { - - long keyframe_no; - int keyframe_shift; - unsigned char first_byte; - auto_calc_theora_info_t *info; - -- first_byte = op->packet[0]; -+ first_byte = op->bytes == 0 ? 0x40 : op->packet[0]; - - info = (auto_calc_theora_info_t *)stream->calculate_data; - - /* header packet */ - if (first_byte & 0x80) - { - if (info == NULL) { - stream->calculate_data = oggz_malloc(sizeof(auto_calc_theora_info_t)); diff --git a/media/liboggz/bug518169.patch b/media/liboggz/bug518169.patch deleted file mode 100644 index 44a4e017347..00000000000 --- a/media/liboggz/bug518169.patch +++ /dev/null @@ -1,56 +0,0 @@ -diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c ---- a/media/liboggz/src/liboggz/oggz_seek.c -+++ b/media/liboggz/src/liboggz/oggz_seek.c -@@ -614,6 +614,12 @@ oggz_offset_end (OGGZ * oggz) - return offset_end; - } - -+static int -+is_header_page(ogg_page* page) -+{ -+ return page && page->header[5] & 0x2; -+} -+ - ogg_int64_t - oggz_bounded_seek_set (OGGZ * oggz, - ogg_int64_t unit_target, -@@ -683,8 +689,18 @@ oggz_bounded_seek_set (OGGZ * oggz, - if (unit_begin == -1 && oggz_seek_raw (oggz, offset_begin, SEEK_SET) >= 0) { - ogg_int64_t granulepos = 0; - unit_begin = 0; -- // Start time needs to be the end time of the first non-header page. -- while (oggz_get_next_start_page (oggz, og) >= 0 && unit_begin <= 0) { -+ -+ // Take the start time of the range as the end time of the next page. Note -+ // that if unit_target lies inside that page, its timestamp will be less -+ // than the page's end time, and it will be considered outside of the range. -+ // If the next page is a header page, we're at the start of the media, -+ // and in such a case we can't take the next content-page's granulepos's -+ // timestamp as unit_begin, as if the target lies inside this page, we'll -+ // miss it. Assume unit_begin is 0 in that case. See Mozilla bug 518169. -+ while (oggz_get_next_start_page (oggz, og) >= 0 && -+ !is_header_page(og) && -+ unit_begin <= 0) -+ { - serialno = ogg_page_serialno (og); - granulepos = ogg_page_granulepos (og); - unit_begin = oggz_get_unit (oggz, serialno, granulepos); -@@ -693,6 +709,7 @@ oggz_bounded_seek_set (OGGZ * oggz, - - /* Fail if target isn't in specified range. */ - if (unit_target < unit_begin || unit_target > unit_end) { -+ oggz_reset (oggz, offset_orig, unit_at, SEEK_SET); - return -1; - } - -@@ -773,6 +790,10 @@ oggz_bounded_seek_set (OGGZ * oggz, - - /* Reader is now approximately at the seek target. */ - -+ offset_at = oggz_reset (oggz, offset_at, unit_at, SEEK_SET); -+ if (offset_at == -1) -+ return -1; -+ - return (long)reader->current_unit; - } - diff --git a/media/liboggz/bug519155.patch b/media/liboggz/bug519155.patch deleted file mode 100644 index f6bd7e2aefd..00000000000 --- a/media/liboggz/bug519155.patch +++ /dev/null @@ -1,73 +0,0 @@ -diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c ---- a/media/liboggz/src/liboggz/oggz_seek.c -+++ b/media/liboggz/src/liboggz/oggz_seek.c -@@ -154,17 +154,17 @@ oggz_reset_seek (OGGZ * oggz, oggz_off_t - if (offset_at == -1) return -1; - - oggz->offset = offset_at; - - #ifdef DEBUG - printf ("reset to %" PRI_OGGZ_OFF_T "d\n", offset_at); - #endif - -- if (unit != -1) reader->current_unit = unit; -+ reader->current_unit = unit; - - return offset_at; - } - - static long - oggz_reset (OGGZ * oggz, oggz_off_t offset, ogg_int64_t unit, int whence) - { - oggz_reset_streams (oggz); -@@ -800,38 +800,49 @@ oggz_bounded_seek_set (OGGZ * oggz, - static ogg_int64_t - oggz_seek_end (OGGZ * oggz, ogg_int64_t unit_offset) - { - oggz_off_t offset_orig, offset_at, offset_end; - ogg_int64_t granulepos; - ogg_int64_t unit_end; - long serialno; - ogg_page * og; -+ OggzReader * reader = &oggz->x.reader; - - og = &oggz->current_page; - - offset_orig = oggz->offset; - - offset_at = oggz_seek_raw (oggz, 0, SEEK_END); - if (offset_at == -1) return -1; - - offset_end = oggz_get_prev_start_page (oggz, og, &granulepos, &serialno); - - if (offset_end < 0) { - oggz_reset (oggz, offset_orig, -1, SEEK_SET); - return -1; - } - - unit_end = oggz_get_unit (oggz, serialno, granulepos); -- -+ - #ifdef DEBUG - printf ("*** oggz_seek_end: found packet (%lld) at @%" PRI_OGGZ_OFF_T "d [%lld]\n", - unit_end, offset_end, granulepos); - #endif - -+ if (unit_end == -1) { -+ /* Failed to get time at the end, reset and fail. */ -+ oggz_reset (oggz, offset_orig, -1, SEEK_SET); -+ return -1; -+ } -+ -+ reader->current_unit = unit_end; -+ if (unit_offset == 0) { -+ return unit_end; -+ } - return oggz_bounded_seek_set (oggz, unit_end + unit_offset, 0, -1, 0); - } - - off_t - oggz_seek (OGGZ * oggz, oggz_off_t offset, int whence) - { - OggzReader * reader; - ogg_int64_t units = -1; diff --git a/media/liboggz/bug520493.patch b/media/liboggz/bug520493.patch deleted file mode 100644 index 3546e2a35c7..00000000000 --- a/media/liboggz/bug520493.patch +++ /dev/null @@ -1,46 +0,0 @@ -diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c ---- a/media/liboggz/src/liboggz/oggz_seek.c -+++ b/media/liboggz/src/liboggz/oggz_seek.c -@@ -762,40 +762,36 @@ oggz_bounded_seek_set (OGGZ * oggz, - - if (abs(unit_at - unit_target) < fuzz_margin) { - // Within fuzz_margin of target, stop. - break; - } - - #ifdef DEBUG - printf ("oggz_bounded_seek_set: offset_next %" PRI_OGGZ_OFF_T "d\n", offset_next); --#endif -- if (unit_at == unit_last_iter) break; -- --#ifdef DEBUG - printf ("oggz_bounded_seek_set: [D] want u%lld, got page u%lld @%" PRI_OGGZ_OFF_T "d g%lld\n", - unit_target, unit_at, offset_at, granule_at); - #endif - - if (unit_at < unit_target) { -- offset_begin = offset_at; -+ offset_begin = offset_next; - unit_begin = unit_at; - if (unit_end == unit_begin) break; - } else if (unit_at > unit_target) { - offset_end = offset_at-1; - unit_end = unit_at; - if (unit_end == unit_begin) break; - } else { - break; - } - } - - /* Reader is now approximately at the seek target. */ - -- offset_at = oggz_reset (oggz, offset_at, unit_at, SEEK_SET); -+ offset_at = oggz_reset (oggz, offset_next, unit_at, SEEK_SET); - if (offset_at == -1) - return -1; - - return (long)reader->current_unit; - } - - static ogg_int64_t - oggz_seek_end (OGGZ * oggz, ogg_int64_t unit_offset) diff --git a/media/liboggz/bug523335.patch b/media/liboggz/bug523335.patch deleted file mode 100644 index c7f1954c963..00000000000 --- a/media/liboggz/bug523335.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c ---- a/media/liboggz/src/liboggz/oggz_seek.c -+++ b/media/liboggz/src/liboggz/oggz_seek.c -@@ -750,9 +750,11 @@ oggz_bounded_seek_set (OGGZ * oggz, - if (offset_guess > offset_end) { - offset_guess = offset_end; - offset_at = oggz_seek_raw (oggz, offset_guess, SEEK_SET); -+ if (offset_at == -1) return -1; - offset_next = oggz_get_prev_start_page (oggz, og, &granule_at, &serialno); - } else { - offset_at = oggz_seek_raw (oggz, offset_guess, SEEK_SET); -+ if (offset_at == -1) return -1; - offset_next = oggz_get_next_start_page (oggz, og); - serialno = ogg_page_serialno (og); - granule_at = ogg_page_granulepos (og); diff --git a/media/liboggz/bug526097.patch b/media/liboggz/bug526097.patch deleted file mode 100644 index c7503c121d7..00000000000 --- a/media/liboggz/bug526097.patch +++ /dev/null @@ -1,301 +0,0 @@ -diff --git a/media/liboggz/bug526097.patch b/media/liboggz/bug526097.patch ---- a/media/liboggz/bug526097.patch -+++ b/media/liboggz/bug526097.patch -@@ -1,147 +0,0 @@ --diff --git a/media/liboggz/src/liboggz/oggz_auto.c b/media/liboggz/src/liboggz/oggz_auto.c ----- a/media/liboggz/src/liboggz/oggz_auto.c --+++ b/media/liboggz/src/liboggz/oggz_auto.c --@@ -675,16 +675,17 @@ auto_rcalc_theora(ogg_int64_t next_packe -- typedef struct { -- int nln_increments[4]; -- int nsn_increment; -- int short_size; -- int long_size; -- int encountered_first_data_packet; -- int last_was_long; -- int log2_num_modes; --+ int mode_sizes_length; -- int mode_sizes[1]; -- } auto_calc_vorbis_info_t; -- -- -- static ogg_int64_t -- auto_calc_vorbis(ogg_int64_t now, oggz_stream_t *stream, ogg_packet *op) { -- -- auto_calc_vorbis_info_t *info; --@@ -708,16 +709,17 @@ auto_calc_vorbis(ogg_int64_t now, oggz_s -- info->nln_increments[3] = long_size >> 1; -- info->nln_increments[2] = 3 * (long_size >> 2) - (short_size >> 2); -- info->nln_increments[1] = (long_size >> 2) + (short_size >> 2); -- info->nln_increments[0] = info->nln_increments[3]; -- info->short_size = short_size; -- info->long_size = long_size; -- info->nsn_increment = short_size >> 1; -- info->encountered_first_data_packet = 0; --+ info->mode_sizes_length = 0; -- -- /* this is a header packet */ -- return 0; -- } -- -- /* -- * marker for header packets -- */ --@@ -860,16 +862,17 @@ auto_calc_vorbis(ogg_int64_t now, oggz_s -- /* Check that size to be realloc'd doesn't overflow */ -- size_realloc_bytes = sizeof(auto_calc_vorbis_info_t) + (size - 1) * sizeof(int); -- if (size_realloc_bytes < sizeof (auto_calc_vorbis_info_t)) return -1; -- -- /* Store mode size information in our info struct */ -- info = realloc(stream->calculate_data, size_realloc_bytes); -- if (info == NULL) return -1; -- --+ info->mode_sizes_length = size + 1; -- stream->calculate_data = info; -- -- i = -1; -- while ((1 << (++i)) < size); -- info->log2_num_modes = i; -- -- mode_size_ptr = info->mode_sizes; -- --@@ -882,85 +885,37 @@ auto_calc_vorbis(ogg_int64_t now, oggz_s -- current_pos += 5; -- } -- -- } -- -- return 0; -- } -- --- info = (auto_calc_vorbis_info_t *)stream->calculate_data; --- -- return -1; --- --- { --- /* --- * we're in a data packet! First we need to get the mode of the packet, --- * and from the mode, the size --- */ --- int mode; --- int size; --- ogg_int64_t result; --- --- mode = (op->packet[0] >> 1) & ((1 << info->log2_num_modes) - 1); --- size = info->mode_sizes[mode]; --- --- /* --- * if we have a working granulepos, we use it, but only if we can't --- * calculate a valid gp value. --- */ --- if (now > -1 && stream->last_granulepos == -1) { --- info->encountered_first_data_packet = 1; --- info->last_was_long = size; --- return now; --- } --- --- if (info->encountered_first_data_packet == 0) { --- info->encountered_first_data_packet = 1; --- info->last_was_long = size; --- return -1; --- } --- --- /* --- * otherwise, if we haven't yet had a working granulepos, we return --- * -1 --- */ --- if (stream->last_granulepos == -1) { --- info->last_was_long = size; --- return -1; --- } --- --- result = stream->last_granulepos + --- ( --- (info->last_was_long ? info->long_size : info->short_size) --- + --- (size ? info->long_size : info->short_size) --- ) / 4; --- info->last_was_long = size; --- --- return result; --- --- } --- -- } -- -- ogg_int64_t -- auto_rcalc_vorbis(ogg_int64_t next_packet_gp, oggz_stream_t *stream, -- ogg_packet *this_packet, ogg_packet *next_packet) { -- -- auto_calc_vorbis_info_t *info = -- (auto_calc_vorbis_info_t *)stream->calculate_data; -- -- int mode = -- (this_packet->packet[0] >> 1) & ((1 << info->log2_num_modes) - 1); --+ if (info->mode_sizes_length == 0 || mode < 0 || mode >= info->mode_sizes_length) --+ return 0; -- int this_size = info->mode_sizes[mode] ? info->long_size : info->short_size; -- int next_size; -- ogg_int64_t r; -- -- mode = (next_packet->packet[0] >> 1) & ((1 << info->log2_num_modes) - 1); --+ if (info->mode_sizes_length == 0 || mode < 0 || mode >= info->mode_sizes_length) --+ return 0; -- next_size = info->mode_sizes[mode] ? info->long_size : info->short_size; -- -- r = next_packet_gp - ((this_size + next_size) / 4); -- if (r < 0) return 0L; -- return r; -- -- } -- -diff --git a/media/liboggz/src/liboggz/oggz_auto.c b/media/liboggz/src/liboggz/oggz_auto.c ---- a/media/liboggz/src/liboggz/oggz_auto.c -+++ b/media/liboggz/src/liboggz/oggz_auto.c -@@ -675,16 +675,17 @@ auto_rcalc_theora(ogg_int64_t next_packe - typedef struct { - int nln_increments[4]; - int nsn_increment; - int short_size; - int long_size; - int encountered_first_data_packet; - int last_was_long; - int log2_num_modes; -+ int mode_sizes_length; - int mode_sizes[1]; - } auto_calc_vorbis_info_t; - - - static ogg_int64_t - auto_calc_vorbis(ogg_int64_t now, oggz_stream_t *stream, ogg_packet *op) { - - auto_calc_vorbis_info_t *info; -@@ -708,16 +709,17 @@ auto_calc_vorbis(ogg_int64_t now, oggz_s - info->nln_increments[3] = long_size >> 1; - info->nln_increments[2] = 3 * (long_size >> 2) - (short_size >> 2); - info->nln_increments[1] = (long_size >> 2) + (short_size >> 2); - info->nln_increments[0] = info->nln_increments[3]; - info->short_size = short_size; - info->long_size = long_size; - info->nsn_increment = short_size >> 1; - info->encountered_first_data_packet = 0; -+ info->mode_sizes_length = 0; - - /* this is a header packet */ - return 0; - } - - /* - * marker for header packets - */ -@@ -860,16 +862,17 @@ auto_calc_vorbis(ogg_int64_t now, oggz_s - /* Check that size to be realloc'd doesn't overflow */ - size_realloc_bytes = sizeof(auto_calc_vorbis_info_t) + (size - 1) * sizeof(int); - if (size_realloc_bytes < sizeof (auto_calc_vorbis_info_t)) return -1; - - /* Store mode size information in our info struct */ - info = realloc(stream->calculate_data, size_realloc_bytes); - if (info == NULL) return -1; - -+ info->mode_sizes_length = size + 1; - stream->calculate_data = info; - - i = -1; - while ((1 << (++i)) < size); - info->log2_num_modes = i; - - mode_size_ptr = info->mode_sizes; - -@@ -882,85 +885,37 @@ auto_calc_vorbis(ogg_int64_t now, oggz_s - current_pos += 5; - } - - } - - return 0; - } - -- info = (auto_calc_vorbis_info_t *)stream->calculate_data; -- - return -1; -- -- { -- /* -- * we're in a data packet! First we need to get the mode of the packet, -- * and from the mode, the size -- */ -- int mode; -- int size; -- ogg_int64_t result; -- -- mode = (op->packet[0] >> 1) & ((1 << info->log2_num_modes) - 1); -- size = info->mode_sizes[mode]; -- -- /* -- * if we have a working granulepos, we use it, but only if we can't -- * calculate a valid gp value. -- */ -- if (now > -1 && stream->last_granulepos == -1) { -- info->encountered_first_data_packet = 1; -- info->last_was_long = size; -- return now; -- } -- -- if (info->encountered_first_data_packet == 0) { -- info->encountered_first_data_packet = 1; -- info->last_was_long = size; -- return -1; -- } -- -- /* -- * otherwise, if we haven't yet had a working granulepos, we return -- * -1 -- */ -- if (stream->last_granulepos == -1) { -- info->last_was_long = size; -- return -1; -- } -- -- result = stream->last_granulepos + -- ( -- (info->last_was_long ? info->long_size : info->short_size) -- + -- (size ? info->long_size : info->short_size) -- ) / 4; -- info->last_was_long = size; -- -- return result; -- -- } -- - } - - ogg_int64_t - auto_rcalc_vorbis(ogg_int64_t next_packet_gp, oggz_stream_t *stream, - ogg_packet *this_packet, ogg_packet *next_packet) { - - auto_calc_vorbis_info_t *info = - (auto_calc_vorbis_info_t *)stream->calculate_data; -+ int this_size, next_size; -+ ogg_int64_t r; - - int mode = - (this_packet->packet[0] >> 1) & ((1 << info->log2_num_modes) - 1); -- int this_size = info->mode_sizes[mode] ? info->long_size : info->short_size; -- int next_size; -- ogg_int64_t r; -+ if (info->mode_sizes_length == 0 || mode < 0 || mode >= info->mode_sizes_length) -+ return 0; -+ this_size = info->mode_sizes[mode] ? info->long_size : info->short_size; - - mode = (next_packet->packet[0] >> 1) & ((1 << info->log2_num_modes) - 1); -+ if (info->mode_sizes_length == 0 || mode < 0 || mode >= info->mode_sizes_length) -+ return 0; - next_size = info->mode_sizes[mode] ? info->long_size : info->short_size; - - r = next_packet_gp - ((this_size + next_size) / 4); - if (r < 0) return 0L; - return r; - - } - diff --git a/media/liboggz/bug533822.patch b/media/liboggz/bug533822.patch deleted file mode 100644 index 05a40573975..00000000000 --- a/media/liboggz/bug533822.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c ---- a/media/liboggz/src/liboggz/oggz_seek.c -+++ b/media/liboggz/src/liboggz/oggz_seek.c -@@ -135,16 +135,17 @@ oggz_stream_reset (void * data) - } - - return 0; - } - - static void - oggz_reset_streams (OGGZ * oggz) - { -+ oggz_dlist_deliter(oggz->packet_buffer, oggz_read_free_pbuffers); - oggz_vector_foreach (oggz->streams, oggz_stream_reset); - } - - static long - oggz_reset_seek (OGGZ * oggz, oggz_off_t offset, ogg_int64_t unit, int whence) - { - OggzReader * reader = &oggz->x.reader; - diff --git a/media/liboggz/faster_seek.patch b/media/liboggz/faster_seek.patch deleted file mode 100644 index 04068545a92..00000000000 --- a/media/liboggz/faster_seek.patch +++ /dev/null @@ -1,481 +0,0 @@ -diff --git a/media/liboggz/include/oggz/oggz_seek.h b/media/liboggz/include/oggz/oggz_seek.h ---- a/media/liboggz/include/oggz/oggz_seek.h -+++ b/media/liboggz/include/oggz/oggz_seek.h -@@ -471,40 +471,40 @@ long oggz_seek_byorder (OGGZ * oggz, voi - * \param offset The offset of the start of data - * \returns 0 on success, -1 on failure. - */ - int oggz_set_data_start (OGGZ * oggz, oggz_off_t offset); - /** \} - */ - - /** -- * Seeks Oggz to time unit_target, but with the bounds of the offset range -- * [offset_begin, offset_end]. This is useful when seeking in network streams -- * where only parts of a media are buffered, and retrieving unbuffered -- * parts is expensive. -+ * Seeks to within fuzz_margin milliseconds of time unit_target, within the -+ * bounds of the offset range [offset_begin, offset_end]. This is useful when -+ * seeking in network streams where only parts of a media are buffered, and -+ * retrieving unbuffered parts is expensive. - * \param oggz An OGGZ handle previously opened for reading - * \param unit_target The seek target, in milliseconds, or custom units - * \param offset_begin Start of offset range to seek inside, in bytes - * \param offset_end End of offset range to seek inside, in bytes, - pass -1 for end of media -+ * \param fuzz_margin The seek stops when it's within this many milliseconds -+ of unit_target - * \returns The new position, in milliseconds or custom units - * \retval -1 on failure (unit_target is not within range) - */ - ogg_int64_t - oggz_bounded_seek_set (OGGZ * oggz, - ogg_int64_t unit_target, - ogg_int64_t offset_begin, -- ogg_int64_t offset_end); -+ ogg_int64_t offset_end, -+ int fuzz_margin); - - /** -- * Seeks to the first key frame before unit_target, in the range -- * [offset_begin, offset_end]. serial_nos contains an array of size serial_nos -- * of serialnos of the streams which need to be seeked. -+ * Seeks to before the first key frame before unit_target, in the range -+ * [offset_begin, offset_end]. - */ - ogg_int64_t - oggz_keyframe_seek_set(OGGZ * oggz, -- long* serial_nos, -- int num_serialno, - ogg_int64_t unit_target, - ogg_int64_t offset_begin, - ogg_int64_t offset_end); - - #endif /* __OGGZ_SEEK_H__ */ -diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c ---- a/media/liboggz/src/liboggz/oggz_seek.c -+++ b/media/liboggz/src/liboggz/oggz_seek.c -@@ -491,65 +491,61 @@ oggz_scan_for_page (OGGZ * oggz, ogg_pag - } - } - - return offset_at; - } - - #define GUESS_MULTIPLIER (1<<16) - --static oggz_off_t -+static ogg_int64_t - guess (ogg_int64_t unit_at, ogg_int64_t unit_target, - ogg_int64_t unit_begin, ogg_int64_t unit_end, -- oggz_off_t offset_begin, oggz_off_t offset_end) -+ ogg_int64_t offset_begin, ogg_int64_t offset_end) - { - ogg_int64_t guess_ratio; -- oggz_off_t offset_guess; -- -- if (unit_at == unit_begin) return offset_begin; -+ ogg_int64_t offset_guess; - - if (unit_end != -1) { - guess_ratio = - GUESS_MULTIPLIER * (unit_target - unit_begin) / - (unit_end - unit_begin); - } else { - guess_ratio = - GUESS_MULTIPLIER * (unit_target - unit_begin) / - (unit_at - unit_begin); - } - -+ offset_guess = offset_begin + -+ (((offset_end - offset_begin) * guess_ratio) / -+ GUESS_MULTIPLIER); -+ - #ifdef DEBUG -- printf ("oggz_seek::guess: guess_ratio %lld = (%lld - %lld) / (%lld - %lld)\n", -- guess_ratio, unit_target, unit_begin, unit_at, unit_begin); -+ printf("guess: [o=%lld t=%lld]-[o=%lld t=%lld] guess_ratio=%lf offset_guess=%lu\n", -+ offset_begin, unit_begin, offset_end, unit_end, -+ ((double)guess_ratio / (double)GUESS_MULTIPLIER), offset_guess); - #endif -- -- offset_guess = offset_begin + -- (oggz_off_t)(((offset_end - offset_begin) * guess_ratio) / -- GUESS_MULTIPLIER); -- -+ - return offset_guess; - } - --static oggz_off_t --oggz_seek_guess (ogg_int64_t unit_at, ogg_int64_t unit_target, -- ogg_int64_t unit_begin, ogg_int64_t unit_end, -- oggz_off_t offset_at, -- oggz_off_t offset_begin, oggz_off_t offset_end) -+static ogg_int64_t -+oggz_seek_guess (ogg_int64_t unit_at, -+ ogg_int64_t unit_target, -+ ogg_int64_t unit_begin, -+ ogg_int64_t unit_end, -+ oggz_off_t offset_at, -+ oggz_off_t offset_begin, -+ oggz_off_t offset_end) - { - oggz_off_t offset_guess; -- -- if (unit_at == unit_begin) { -- offset_guess = offset_begin + (offset_end - offset_begin)/2; -- } else if (unit_end == -1) { -+ if (unit_end == -1) { - offset_guess = guess (unit_at, unit_target, unit_begin, unit_end, - offset_begin, offset_at); - } else if (unit_end <= unit_begin) { --#ifdef DEBUG -- printf ("oggz_seek_guess: unit_end <= unit_begin (ERROR)\n"); --#endif - offset_guess = -1; - } else { - offset_guess = guess (unit_at, unit_target, unit_begin, unit_end, - offset_begin, offset_end); - } - - #ifdef DEBUG - printf ("oggz_seek_guess: guessed %" PRI_OGGZ_OFF_T "d\n", offset_guess); -@@ -617,21 +613,22 @@ oggz_offset_end (OGGZ * oggz) - - return offset_end; - } - - ogg_int64_t - oggz_bounded_seek_set (OGGZ * oggz, - ogg_int64_t unit_target, - ogg_int64_t offset_begin, -- ogg_int64_t offset_end) -+ ogg_int64_t offset_end, -+ int fuzz_margin) - { - OggzReader * reader; -- oggz_off_t offset_orig, offset_at, offset_guess; -- oggz_off_t offset_next; -+ ogg_int64_t offset_orig, offset_at, offset_guess; -+ ogg_int64_t offset_next; - ogg_int64_t granule_at; - ogg_int64_t unit_at, unit_begin = -1, unit_end = -1, unit_last_iter = -1; - long serialno; - ogg_page * og; - int hit_eof = 0; - - if (oggz == NULL) { - return -1; -@@ -679,27 +676,30 @@ oggz_bounded_seek_set (OGGZ * oggz, - ogg_int64_t granulepos; - - if (oggz_get_prev_start_page (oggz, og, &granulepos, &serialno) >= 0) { - unit_end = oggz_get_unit (oggz, serialno, granulepos); - } - } - - if (unit_begin == -1 && oggz_seek_raw (oggz, offset_begin, SEEK_SET) >= 0) { -- ogg_int64_t granulepos; -- if (oggz_get_next_start_page (oggz, og) >= 0) { -+ ogg_int64_t granulepos = 0; -+ unit_begin = 0; -+ // Start time needs to be the end time of the first non-header page. -+ while (oggz_get_next_start_page (oggz, og) >= 0 && unit_begin <= 0) { - serialno = ogg_page_serialno (og); - granulepos = ogg_page_granulepos (og); - unit_begin = oggz_get_unit (oggz, serialno, granulepos); - } - } - - /* Fail if target isn't in specified range. */ -- if (unit_target < unit_begin || unit_target > unit_end) -+ if (unit_target < unit_begin || unit_target > unit_end) { - return -1; -+ } - - /* Reduce the search range if possible using read cursor position. */ - if (unit_at > unit_begin && unit_at < unit_end) { - if (unit_target < unit_at) { - unit_end = unit_at; - offset_end = offset_at; - } else { - unit_begin = unit_at; -@@ -738,16 +738,21 @@ oggz_bounded_seek_set (OGGZ * oggz, - offset_at = oggz_seek_raw (oggz, offset_guess, SEEK_SET); - offset_next = oggz_get_next_start_page (oggz, og); - serialno = ogg_page_serialno (og); - granule_at = ogg_page_granulepos (og); - } - - unit_at = oggz_get_unit (oggz, serialno, granule_at); - -+ if (abs(unit_at - unit_target) < fuzz_margin) { -+ // Within fuzz_margin of target, stop. -+ break; -+ } -+ - #ifdef DEBUG - printf ("oggz_bounded_seek_set: offset_next %" PRI_OGGZ_OFF_T "d\n", offset_next); - #endif - if (unit_at == unit_last_iter) break; - - #ifdef DEBUG - printf ("oggz_bounded_seek_set: [D] want u%lld, got page u%lld @%" PRI_OGGZ_OFF_T "d g%lld\n", - unit_target, unit_at, offset_at, granule_at); -@@ -761,34 +766,17 @@ oggz_bounded_seek_set (OGGZ * oggz, - offset_end = offset_at-1; - unit_end = unit_at; - if (unit_end == unit_begin) break; - } else { - break; - } - } - -- do { -- offset_at = oggz_get_prev_start_page (oggz, og, &granule_at, &serialno); -- if (offset_at < 0) -- break; -- unit_at = oggz_get_unit (oggz, serialno, granule_at); -- } while (unit_at > unit_target); -- -- if (offset_at < 0) { -- oggz_reset (oggz, offset_orig, -1, SEEK_SET); -- return -1; -- } -- -- offset_at = oggz_reset (oggz, offset_at, unit_at, SEEK_SET); -- if (offset_at == -1) return -1; -- --#ifdef DEBUG -- printf ("oggz_bounded_seek_set: FOUND (%lld)\n", unit_at); --#endif -+ /* Reader is now approximately at the seek target. */ - - return (long)reader->current_unit; - } - - static ogg_int64_t - oggz_seek_end (OGGZ * oggz, ogg_int64_t unit_offset) - { - oggz_off_t offset_orig, offset_at, offset_end; -@@ -813,17 +801,17 @@ oggz_seek_end (OGGZ * oggz, ogg_int64_t - - unit_end = oggz_get_unit (oggz, serialno, granulepos); - - #ifdef DEBUG - printf ("*** oggz_seek_end: found packet (%lld) at @%" PRI_OGGZ_OFF_T "d [%lld]\n", - unit_end, offset_end, granulepos); - #endif - -- return oggz_bounded_seek_set (oggz, unit_end + unit_offset, 0, -1); -+ return oggz_bounded_seek_set (oggz, unit_end + unit_offset, 0, -1, 0); - } - - off_t - oggz_seek (OGGZ * oggz, oggz_off_t offset, int whence) - { - OggzReader * reader; - ogg_int64_t units = -1; - -@@ -872,21 +860,21 @@ oggz_seek_units (OGGZ * oggz, ogg_int64_ - #endif - return -1; - } - - reader = &oggz->x.reader; - - switch (whence) { - case SEEK_SET: -- r = oggz_bounded_seek_set (oggz, units, 0, -1); -+ r = oggz_bounded_seek_set (oggz, units, 0, -1, 0); - break; - case SEEK_CUR: - units += reader->current_unit; -- r = oggz_bounded_seek_set (oggz, units, 0, -1); -+ r = oggz_bounded_seek_set (oggz, units, 0, -1, 0); - break; - case SEEK_END: - r = oggz_seek_end (oggz, units); - break; - default: - /*oggz_set_error (oggz, OGGZ_EINVALID);*/ - r = -1; - break; -@@ -934,130 +922,70 @@ oggz_seek_byorder (OGGZ * oggz, void * t - long - oggz_seek_packets (OGGZ * oggz, long serialno, long packets, int whence) - { - return OGGZ_ERR_DISABLED; - } - - #endif - --// Returns 1 if any of the elements of array |a|, which is of length |n|, --// contain the value |val|. Otherwise returns 0. --static int --is_any(ogg_int64_t* a, int n, ogg_int64_t val) --{ -- int i; -- for (i=0; igranuleshift == 0) -+ return 0; -+ -+ // Max number of frames keyframe could possibly be offset. -+ keyframe_diff = (1 << stream->granuleshift) - 1; -+ -+ // Length of frame in ms. -+ frame_duration = stream->granulerate_d / stream->granulerate_n; -+ -+ return frame_duration * keyframe_diff; - } - --// Returns the index of the element in array |a|, which is of length |n|, --// which contains the value |val|, or -1 of it's not present. --static int --find(long* a, int n, ogg_int64_t val) --{ -- int i; -- for (i=0; istreams); -+ for (i = 0; i < size; i++) { -+ stream = (oggz_stream_t *)oggz_vector_nth_p (oggz->streams, i); -+ if (!stream) continue; -+ x = get_keyframe_offset(stream); -+ if (x > max) -+ max = x; - } -- return -1; --} -- --// Returns the element with the smallest value in array |a|, which is --// of length |n|. --static ogg_int64_t --minimum(ogg_int64_t* a, int n) { -- ogg_int64_t m = 0x7FFFFFFFFFFFFFFF; -- int i; -- for (i=0; ioffset; -- -- key_frames = oggz_malloc(sizeof(ogg_int64_t) * num_serialno); -- if (!key_frames) { -- // Malloc failure. We can still exit with the seek finishing at a non -- // key frame. -- return unit_at; -- } -- memset(key_frames, -1, sizeof(ogg_int64_t) * num_serialno); -- -- // Find the key frame offset for every stream. -- og = &oggz->current_page; -- while (is_any(key_frames, num_serialno, -1)) { -- do { -- offset_next = oggz_get_prev_start_page (oggz, og, &granule_at, &serialno); -- if (offset_next <= 0 || granule_at == 0) { -- // At beginning of file, or some other failure. Return with -- // non-key frame seek if possible. -- oggz_free(key_frames); -- offset_at = oggz_reset (oggz, offset_at, unit_at, SEEK_SET); -- return (offset_at == -1) ? -1 : unit_at; -- } -- } while (granule_at < 0); -- -- idx = find(serial_nos, num_serialno, serialno); -- if (idx == -1 || key_frames[idx] != -1) -- continue; -- -- granule_shift = oggz_get_granuleshift(oggz, serialno); -- key_granule_at = (granule_at >> granule_shift) << granule_shift; -- key_unit_at = oggz_get_unit(oggz, serialno, key_granule_at); -- -- if (key_unit_at < unit_target) -- key_frames[idx] = key_unit_at; -- } -- -- // Seek to 100ms before the earliest of all the streams' key frames. -- // This is so that after the seek, the decoder will defintately return frames -- // at or before get the key frame. Without this, some decoders will return -- // frames which start after the specified time - after the key frame. -- key_unit_at = minimum(key_frames, num_serialno); -- unit_at = oggz_bounded_seek_set(oggz, -- MAX((key_unit_at - 100), 0), -- offset_begin, -- offset_end); -- oggz_free(key_frames); -- -+ offset_end, -+ fuzz); - return unit_at; - } diff --git a/media/liboggz/include/Makefile.in b/media/liboggz/include/Makefile.in deleted file mode 100644 index e4b6ac87aed..00000000000 --- a/media/liboggz/include/Makefile.in +++ /dev/null @@ -1,47 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = oggz -DIRS = oggz - -include $(topsrcdir)/config/rules.mk diff --git a/media/liboggz/include/oggz/Makefile.in b/media/liboggz/include/oggz/Makefile.in deleted file mode 100644 index 979dd527007..00000000000 --- a/media/liboggz/include/oggz/Makefile.in +++ /dev/null @@ -1,61 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -EXPORTS_NAMESPACES = oggz - -EXPORTS_oggz = \ - oggz.h \ - oggz_comments.h \ - oggz_constants.h \ - oggz_deprecated.h \ - oggz_io.h \ - oggz_off_t.h \ - oggz_off_t_generated.h \ - oggz_read.h \ - oggz_seek.h \ - oggz_stream.h \ - oggz_table.h \ - oggz_write.h \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/media/liboggz/include/oggz/config.h b/media/liboggz/include/oggz/config.h deleted file mode 100644 index e772a10bc85..00000000000 --- a/media/liboggz/include/oggz/config.h +++ /dev/null @@ -1,10 +0,0 @@ -#if defined(WIN32) && !defined(__GNUC__) -#include "config_win32.h" -#else -#include "config_gcc.h" -#include "prcpucfg.h" -#ifdef IS_BIG_ENDIAN -#define WORDS_BIGENDIAN -#endif -#endif -#undef DEBUG diff --git a/media/liboggz/include/oggz/config_gcc.h b/media/liboggz/include/oggz/config_gcc.h deleted file mode 100644 index 3dcfdc48be4..00000000000 --- a/media/liboggz/include/oggz/config_gcc.h +++ /dev/null @@ -1,130 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define if the compiler implements enums as signed values. */ -/* #undef ALLOW_SIGNED_ENUMS */ - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the 'getopt_long' function */ -#define HAVE_GETOPT_LONG - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if the system has the type `ssize_t'. */ -#define HAVE_SSIZE_T 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Define to build experimental code */ -/* #undef OGGZ_CONFIG_EXPERIMENTAL */ - -/* Do not build reading support */ -#define OGGZ_CONFIG_READ 1 - -/* Do not build writing support */ -#define OGGZ_CONFIG_WRITE 1 - -/* Set to maximum allowed value of sf_count_t type. */ -#define OGGZ_OFF_MAX 0x7FFFFFFFFFFFFFFFLL - -/* Define if is const-correct */ -/* #undef OGG_H_CONST_CORRECT */ - -/* Name of package */ -#define PACKAGE "liboggz" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* The size of `loff_t', as computed by sizeof. */ -#define SIZEOF_LOFF_T 8 - -/* The size of `off64_t', as computed by sizeof. */ -#define SIZEOF_OFF64_T 0 - -/* The size of `off_t', as computed by sizeof. */ -#define SIZEOF_OFF_T 8 - -/* Set to sizeof (long) if unknown. */ -#define SIZEOF_OGGZ_OFF_T 8 - -/* The size of `ssize_t', as computed by sizeof. */ -#define SIZEOF_SSIZE_T 4 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "0.9.9" - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -/* #undef WORDS_BIGENDIAN */ - -/* Number of bits in a file offset, on hosts where this is settable. */ -#define _FILE_OFFSET_BITS 64 - -/* Define to make fseeko etc. visible, on some hosts. */ -#define _LARGEFILE_SOURCE 1 - -/* Define for large files, on AIX-style hosts. */ -/* #undef _LARGE_FILES */ - -/* Some systems need _XOPEN_SOURCE for timezone */ -/* #undef _XOPEN_SOURCE */ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `long int' if does not define. */ -/* #undef off_t */ - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ diff --git a/media/liboggz/include/oggz/config_win32.h b/media/liboggz/include/oggz/config_win32.h deleted file mode 100644 index 233a70f8a45..00000000000 --- a/media/liboggz/include/oggz/config_win32.h +++ /dev/null @@ -1,138 +0,0 @@ -/* config.h. Generated by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the 'getopt_long' function */ -#undef HAVE_GETOPT_LONG - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `memmove' function. */ -#undef HAVE_MEMMOVE - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `random' function. */ -#undef HAVE_RANDOM - -/* Define to 1 if your system has a GNU libc compatible `realloc' function, - and to 0 otherwise. */ -#undef HAVE_REALLOC - -/* Define to 1 if the system has the type `ssize_t'. */ -#define HAVE_SSIZE_T 1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to build experimental code */ -/* #undef OGGZ_CONFIG_EXPERIMENTAL */ - -/* Do not build reading support */ -#define OGGZ_CONFIG_READ 1 - -/* Do not build writing support */ -#define OGGZ_CONFIG_WRITE 1 - -/* Set to maximum allowed value of sf_count_t type. */ -#define OGGZ_OFF_MAX 0x7FFFFFFFFFFFFFFFLL - -/* Name of package */ -#define PACKAGE "liboggz" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* The size of a `loff_t', as computed by sizeof. */ -/* #undef SIZEOF_LOFF_T */ - -/* The size of a `off64_t', as computed by sizeof. */ -/* #undef SIZEOF_OFF64_T */ - -/* The size of a `off_t', as computed by sizeof. */ -/* #define SIZEOF_OFF_T 8 */ - -/* Set to sizeof (long) if unknown. */ -/* #define SIZEOF_OGGZ_OFF_T 8 */ - -/* The size of a `ssize_t', as computed by sizeof. */ -/* #define SIZEOF_SSIZE_T 4 */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Set to long if unknown. */ -#define TYPEOF_OGGZ_OFF_T off_t - -/* Version number of package */ -#define VERSION "0.9.8" - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -/* #undef WORDS_BIGENDIAN */ - -/* Number of bits in a file offset, on hosts where this is settable. */ -/* #undef _FILE_OFFSET_BITS */ - -/* Define to make fseeko etc. visible, on some hosts. */ -/* #undef _LARGEFILE_SOURCE */ - -/* Define for large files, on AIX-style hosts. */ -/* #undef _LARGE_FILES */ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to `long' if does not define. */ -/* #undef off_t */ - -/* Define to rpl_realloc if the replacement function should be used. */ -#undef realloc - -/* Define to `unsigned' if does not define. */ -#undef size_t - -/* Define for MSVC as is unavailable there */ -typedef unsigned char uint8_t; - -#define inline __inline // MSVC \ No newline at end of file diff --git a/media/liboggz/include/oggz/oggz.h b/media/liboggz/include/oggz/oggz.h deleted file mode 100644 index 20c2322fe9c..00000000000 --- a/media/liboggz/include/oggz/oggz.h +++ /dev/null @@ -1,588 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_H__ -#define __OGGZ_H__ - -#include -#include - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** \mainpage - * - * \section intro Oggz makes programming with Ogg easy! - * - * This is the documentation for the Oggz C API. Oggz provides a simple - * programming interface for reading and writing Ogg files and streams. - * Ogg is an interleaving data container developed by Monty - * at Xiph.Org, originally to - * support the Ogg Vorbis audio format. - * - * liboggz supports the flexibility afforded by the Ogg file format while - * presenting the following API niceties: - * - * - Strict adherence to the formatting requirements of Ogg - * \link basics bitstreams \endlink, to ensure that only valid bitstreams - * are generated - * - A simple, callback based open/read/close or open/write/close - * \link oggz.h interface \endlink to raw Ogg files - * - A customisable \link seek_api seeking \endlink abstraction for - * seeking on multitrack Ogg data - * - A packet queue for feeding incoming packets for writing, with callback - * based notification when this queue is empty - * - A means of overriding the \link oggz_io.h IO functions \endlink used by - * Oggz, for easier integration with media frameworks and similar systems. - * - A handy \link oggz_table.h table \endlink structure for storing - * information on each logical bitstream - * - * \subsection contents Contents - * - * - \link basics Basics \endlink: - * Information about Ogg required to understand liboggz - * - * - \link oggz.h oggz.h \endlink: - * Documentation of the Oggz C API - * - * - \link configuration Configuration \endlink: - * Customizing liboggz to only read or write. - * - * - \link building Building \endlink: - * Information related to building software that uses liboggz. - * - * \section Licensing - * - * liboggz is provided under the following BSD-style open source license: - * - * \include COPYING - * - */ - -/** \defgroup basics Ogg basics - * - * \section Scope - * - * This section provides a minimal introduction to Ogg concepts, covering - * only that which is required to use liboggz. - * - * For more detailed information, see the - * Ogg homepage - * or IETF RFC 3533 - * The Ogg File Format version 0. - * - * \section Terminology - * - * The monospace text below is quoted directly from RFC 3533. - * For each concept introduced, tips related to liboggz are provided - * in bullet points. - * - * \subsection bitstreams Physical and Logical Bitstreams - * - * The raw data of an Ogg stream, as read directly from a file or network - * socket, is called a physical bitstream. - * -
-   The result of an Ogg encapsulation is called the "Physical (Ogg)
-   Bitstream".  It encapsulates one or several encoder-created
-   bitstreams, which are called "Logical Bitstreams".  A logical
-   bitstream, provided to the Ogg encapsulation process, has a
-   structure, i.e., it is split up into a sequence of so-called
-   "Packets".  The packets are created by the encoder of that logical
-   bitstream and represent meaningful entities for that encoder only
-   (e.g., an uncompressed stream may use video frames as packets).
-
- * - * \subsection pages Packets and Pages - * - * Within the Ogg format, packets are written into \a pages. You can think - * of pages like pages in a book, and packets as items of the actual text. - * Consider, for example, individual poems or short stories as the packets. - * Pages are of course all the same size, and a few very short packets could - * be written into a single page. On the other hand, a very long packet will - * use many pages. - * - * - liboggz handles the details of writing packets into pages, and of - * reading packets from pages; your application deals only with - * ogg_packet structures. - * - Each ogg_packet structure contains a block of data and its - * length in bytes, plus other information related to the stream structure - * as explained below. - * - * \subsection serialno - * - * Each logical bitstream is uniquely identified by a serial number or - * \a serialno. - * - * - Packets are always associated with a \a serialno. This is not actually - * part of the ogg_packet structure, so wherever you see an - * ogg_packet in the liboggz API, you will see an accompanying - * \a serialno. - * -
-   This unique serial number is created randomly and does not have any
-   connection to the content or encoder of the logical bitstream it
-   represents.
-
- * - * - Use oggz_serialno_new() to generate a new serial number for each - * logical bitstream you write. - * - Use an \link oggz_table.h OggzTable \endlink, keyed by \a serialno, - * to store and retrieve data related to each logical bitstream. - * - * \subsection boseos b_o_s and e_o_s -
-   bos page: The initial page (beginning of stream) of a logical
-      bitstream which contains information to identify the codec type
-      and other decoding-relevant information.
-
-   eos page: The final page (end of stream) of a logical bitstream.
-
- * - * - Every ogg_packet contains \a b_o_s and \a e_o_s flags. - * Of course each of these will be set only once per logical bitstream. - * See the Structuring section below for rules on setting \a b_o_s and - * \a e_o_s when interleaving logical bitstreams. - * - This documentation will refer to \a bos and \a eos packets - * (not pages) as that is more closely represented by the API. - * The \a bos packet is the only packet on the \a bos page, and the - * \a eos packet is the last packet on the \a eos page. - * - * \subsection granulepos -
-   granule position: An increasing position number for a specific
-      logical bitstream stored in the page header.  Its meaning is
-      dependent on the codec for that logical bitstream
-
- * - * - Every ogg_packet contains a \a granulepos. The \a granulepos - * of each packet is used mostly for \link seek_api seeking. \endlink - * - * \section Structuring - * - * The general structure of an Ogg stream is governed by various rules. - * - * \subsection secondaries Secondary header packets - * - * Some data sources require initial setup information such as comments - * and codebooks to be present near the beginning of the stream (directly - * following the b_o_s packets. - * -
-   Ogg also allows but does not require secondary header packets after
-   the bos page for logical bitstreams and these must also precede any
-   data packets in any logical bitstream.  These subsequent header
-   packets are framed into an integral number of pages, which will not
-   contain any data packets.  So, a physical bitstream begins with the
-   bos pages of all logical bitstreams containing one initial header
-   packet per page, followed by the subsidiary header packets of all
-   streams, followed by pages containing data packets.
-
- * - * - liboggz handles the framing of \a packets into low-level \a pages. To - * ensure that the pages used by secondary headers contain no data packets, - * set the \a flush parameter of oggz_write_feed() to \a OGGZ_FLUSH_AFTER - * when queueing the last of the secondary headers. - * - or, equivalently, set \a flush to \a OGGZ_FLUSH_BEFORE when queueing - * the first of the data packets. - * - * \subsection boseosseq Sequencing b_o_s and e_o_s packets - * - * The following rules apply for sequencing \a bos and \a eos packets in - * a physical bitstream: -
-   ... All bos pages of all logical bitstreams MUST appear together at
-   the beginning of the Ogg bitstream.
-
-   ... eos pages for the logical bitstreams need not all occur
-   contiguously.  Eos pages may be 'nil' pages, that is, pages
-   containing no content but simply a page header with position
-   information and the eos flag set in the page header.
-
- * - * - oggz_write_feed() will fail with a return value of - * \a OGGZ_ERR_BOS if an attempt is made to queue a late \a bos packet - * - * \subsection interleaving Interleaving logical bitstreams -
-   It is possible to consecutively chain groups of concurrently
-   multiplexed bitstreams.  The groups, when unchained, MUST stand on
-   their own as a valid concurrently multiplexed bitstream.  The
-   following diagram shows a schematic example of such a physical
-   bitstream that obeys all the rules of both grouped and chained
-   multiplexed bitstreams.
-
-               physical bitstream with pages of
-          different logical bitstreams grouped and chained
-      -------------------------------------------------------------
-      |*A*|*B*|*C*|A|A|C|B|A|B|#A#|C|...|B|C|#B#|#C#|*D*|D|...|#D#|
-      -------------------------------------------------------------
-       bos bos bos             eos           eos eos bos       eos
-
-   In this example, there are two chained physical bitstreams, the first
-   of which is a grouped stream of three logical bitstreams A, B, and C.
-   The second physical bitstream is chained after the end of the grouped
-   bitstream, which ends after the last eos page of all its grouped
-   logical bitstreams.  As can be seen, grouped bitstreams begin
-   together - all of the bos pages MUST appear before any data pages.
-   It can also be seen that pages of concurrently multiplexed bitstreams
-   need not conform to a regular order.  And it can be seen that a
-   grouped bitstream can end long before the other bitstreams in the
-   group end.
-
- * - * - oggz_write_feed() will fail, returning an explicit error value, if - * an attempt is made to queue a packet in violation of these rules. - * - * \section References - * - * This introduction to the Ogg format is derived from - * IETF RFC 3533 - * The Ogg File Format version 0 in accordance with the - * following copyright statement pertaining to the text of RFC 3533: - * -
-   Copyright (C) The Internet Society (2003).  All Rights Reserved.
-
-   This document and translations of it may be copied and furnished to
-   others, and derivative works that comment on or otherwise explain it
-   or assist in its implementation may be prepared, copied, published
-   and distributed, in whole or in part, without restriction of any
-   kind, provided that the above copyright notice and this paragraph are
-   included on all such copies and derivative works.  However, this
-   document itself may not be modified in any way, such as by removing
-   the copyright notice or references to the Internet Society or other
-   Internet organizations, except as needed for the purpose of
-   developing Internet standards in which case the procedures for
-   copyrights defined in the Internet Standards process must be
-   followed, or as required to translate it into languages other than
-   English.
-
-   The limited permissions granted above are perpetual and will not be
-   revoked by the Internet Society or its successors or assigns.
-
-   This document and the information contained herein is provided on an
-   "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
-   TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
-   BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
-   HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
-   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-
- * - */ - -/** \defgroup configuration Configuration - * \section configure ./configure - * - * It is possible to customize the functionality of liboggz - * by using various ./configure flags when - * building it from source. You can build a smaller - * version of liboggz to only read or write. - * By default, both reading and writing support is built. - * - * For general information about using ./configure, see the file - * \link install INSTALL \endlink - * - * \subsection no_encode Removing writing support - * - * Configuring with \a --disable-write will remove all support for writing: - * - All internal write related functions will not be built - * - Any attempt to call oggz_new(), oggz_open() or oggz_open_stdio() - * with \a flags == OGGZ_WRITE will fail, returning NULL - * - Any attempt to call oggz_write(), oggz_write_output(), oggz_write_feed(), - * oggz_write_set_hungry_callback(), or oggz_write_get_next_page_size() - * will return OGGZ_ERR_DISABLED - * - * \subsection no_decode Removing reading support - * - * Configuring with \a --disable-read will remove all support for reading: - * - All internal reading related functions will not be built - * - Any attempt to call oggz_new(), oggz_open() or oggz_open_stdio() - * with \a flags == OGGZ_READ will fail, returning NULL - * - Any attempt to call oggz_read(), oggz_read_input(), - * oggz_set_read_callback(), oggz_seek(), or oggz_seek_units() will return - * OGGZ_ERR_DISABLED - * - */ - -/** \defgroup install Installation - * \section install INSTALL - * - * \include INSTALL - */ - -/** \defgroup building Building against liboggz - * - * - * \section autoconf Using GNU autoconf - * - * If you are using GNU autoconf, you do not need to call pkg-config - * directly. Use the following macro to determine if liboggz is - * available: - * -
- PKG_CHECK_MODULES(OGGZ, oggz >= 0.6.0,
-                   HAVE_OGGZ="yes", HAVE_OGGZ="no")
- if test "x$HAVE_OGGZ" = "xyes" ; then
-   AC_SUBST(OGGZ_CFLAGS)
-   AC_SUBST(OGGZ_LIBS)
- fi
- 
- * - * If liboggz is found, HAVE_OGGZ will be set to "yes", and - * the autoconf variables OGGZ_CFLAGS and OGGZ_LIBS will - * be set appropriately. - * - * \section pkg-config Determining compiler options with pkg-config - * - * If you are not using GNU autoconf in your project, you can use the - * pkg-config tool directly to determine the correct compiler options. - * -
- OGGZ_CFLAGS=`pkg-config --cflags oggz`
-
- OGGZ_LIBS=`pkg-config --libs oggz`
- 
- * - */ - -/** \file - * The liboggz C API. - * - * \section general Generic semantics - * - * All access is managed via an OGGZ handle. This can be instantiated - * in one of three ways: - * - * - oggz_open() - Open a full pathname - * - oggz_open_stdio() - Use an already opened FILE * - * - oggz_new() - Create an anonymous OGGZ object, which you can later - * handle via memory buffers - * - * To finish using an OGGZ handle, it should be closed with oggz_close(). - * - * \section reading Reading Ogg data - * - * To read from Ogg files or streams you must instantiate an OGGZ handle - * with flags set to OGGZ_READ, and provide an OggzReadPacket - * callback with oggz_set_read_callback(). - * See the \ref read_api section for details. - * - * \section writing Writing Ogg data - * - * To write to Ogg files or streams you must instantiate an OGGZ handle - * with flags set to OGGZ_WRITE, and provide an OggzWritePacket - * callback with oggz_set_write_callback(). - * See the \ref write_api section for details. - * - * \section seeking Seeking on Ogg data - * - * To seek while reading Ogg files or streams you must instantiate an OGGZ - * handle for reading, and ensure that an \link metric OggzMetric \endlink - * function is defined to translate packet positions into units such as time. - * See the \ref seek_api section for details. - * - * \section io Overriding the IO methods - * - * When an OGGZ handle is instantiated by oggz_open() or oggz_open_stdio(), - * Oggz uses stdio functions internally to access the raw data. However for - * some applications, the raw data cannot be accessed via stdio -- this - * commonly occurs when integrating with media frameworks. For such - * applications, you can provide Oggz with custom IO methods that it should - * use to access the raw data. Oggz will then use these custom methods, - * rather than using stdio methods, to access the raw data internally. - * - * For details, see \link oggz_io.h \endlink. - * - * \section headers Headers - * - * oggz.h provides direct access to libogg types such as ogg_packet, defined - * in . - */ - -/** - * An opaque handle to an Ogg file. This is returned by oggz_open() or - * oggz_new(), and is passed to all other oggz_* functions. - */ -typedef void OGGZ; - -/** - * Create a new OGGZ object - * \param flags OGGZ_READ or OGGZ_WRITE - * \returns A new OGGZ object - * \retval NULL on system error; check errno for details - */ -OGGZ * oggz_new (int flags); - -/** - * Open an Ogg file, creating an OGGZ handle for it - * \param filename The file to open - * \param flags OGGZ_READ or OGGZ_WRITE - * \return A new OGGZ handle - * \retval NULL System error; check errno for details - */ -OGGZ * oggz_open (const char * filename, int flags); - -/** - * Create an OGGZ handle associated with a stdio stream - * \param file An open FILE handle - * \param flags OGGZ_READ or OGGZ_WRITE - * \returns A new OGGZ handle - * \retval NULL System error; check errno for details - */ -OGGZ * oggz_open_stdio (FILE * file, int flags); - -/** - * Ensure any associated io streams are flushed. - * \param oggz An OGGZ handle - * \retval 0 Success - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_SYSTEM System error; check errno for details - */ -int oggz_flush (OGGZ * oggz); - -/** - * Run an OGGZ until completion, or error. - * This is a convenience function which repeatedly calls oggz_read() or - * oggz_write() as appropriate. - * For an OGGZ opened for reading, an OggzReadPacket or OggzReadPage callback - * should have been set before calling this function. - * For an OGGZ opened for writing, either an OggzHungry callback should have - * been set before calling this function, or you can use this function to - * write out all unwritten Ogg pages which are pending. - * \param oggz An OGGZ handle previously opened for either reading or writing - * \retval 0 Success - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_SYSTEM System error; check errno for details - * \retval OGGZ_ERR_STOP_OK Operation was stopped by a user callback - * returning OGGZ_STOP_OK - * \retval OGGZ_ERR_STOP_ERR Operation was stopped by a user callback - * returning OGGZ_STOP_ERR - * \retval OGGZ_ERR_RECURSIVE_WRITE Attempt to initiate writing from - * within an OggzHungry callback - */ -long oggz_run (OGGZ * oggz); - -/** - * Set the blocksize to use internally for oggz_run() - * \param oggz An OGGZ handle previously opened for either reading or writing - * \param blocksize The blocksize to use within oggz_run() - * \retval 0 Success - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Invalid blocksize (\a run_blocksize <= 0) - */ -int oggz_run_set_blocksize (OGGZ * oggz, long blocksize); - -/** - * Close an OGGZ handle - * \param oggz An OGGZ handle - * \retval 0 Success - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_SYSTEM System error; check errno for details - */ -int oggz_close (OGGZ * oggz); - -/** - * Determine if a given logical bitstream is at bos (beginning of stream). - * \param oggz An OGGZ handle - * \param serialno Identify a logical bitstream within \a oggz, or -1 to - * query if all logical bitstreams in \a oggz are at bos - * \retval 1 The given stream is at bos - * \retval 0 The given stream is not at bos - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz. - */ -int oggz_get_bos (OGGZ * oggz, long serialno); - -/** - * Determine if a given logical bitstream is at eos (end of stream). - * \param oggz An OGGZ handle - * \param serialno Identify a logical bitstream within \a oggz, or -1 to - * query if all logical bitstreams in \a oggz are at eos - * \retval 1 The given stream is at eos - * \retval 0 The given stream is not at eos - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz. - */ -int oggz_get_eos (OGGZ * oggz, long serialno); - -/** - * Query the number of tracks (logical bitstreams). When reading, this - * number is incremented every time a new track is found, so the returned - * value is only correct once the OGGZ is no longer at bos (beginning of - * stream): see oggz_get_bos() for determining this. - * \param oggz An OGGZ handle - * \return The number of tracks in OGGZ - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz. - */ -int oggz_get_numtracks (OGGZ * oggz); - -/** - * Request a new serialno, as required for a new stream, ensuring the serialno - * is not yet used for any other streams managed by this OGGZ. - * \param oggz An OGGZ handle - * \returns A new serialno, not already occuring in any logical bitstreams - * in \a oggz. - */ -long oggz_serialno_new (OGGZ * oggz); - -/** - * Return human-readable string representation of a content type - * - * \retval string the name of the content type - * \retval NULL \a content invalid - */ -const char * -oggz_content_type (OggzStreamContent content); - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -#endif /* __OGGZ_H__ */ diff --git a/media/liboggz/include/oggz/oggz_comments.h b/media/liboggz/include/oggz/oggz_comments.h deleted file mode 100644 index b6ba0c6cccb..00000000000 --- a/media/liboggz/include/oggz/oggz_comments.h +++ /dev/null @@ -1,293 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_COMMENT_H__ -#define __OGGZ_COMMENT_H__ - -/** \file - * Reading of comments. - * - * Vorbis, Speex and Theora bitstreams - * use a comment format called "Vorbiscomment", defined - * here. - * Many standard comment names (such as TITLE, COPYRIGHT and GENRE) are - * defined in that document. - * - * The following general features of Vorbiscomment are relevant to this API: - * - Each stream has one comment packet, which occurs before any encoded - * audio data in the stream. - * - When reading, Oggz will decode the comment block before calling - * the second read() callback for each stream. Hence, retrieving comment - * data is possible once the read() callback has been called a second time. - * - When writing, Oggz allows you to set up the comments in memory, and - * provides a single function to generate a corresponding ogg_packet. - * It is your responsibility to then actually write that packet in sequence. - * - * Each comment block contains one Vendor string, which can be retrieved - * with oggz_comment_get_vendor(). - * - * The rest of a comment block consists of \a name = \a value pairs, with - * the following restrictions: - * - Both the \a name and \a value must be non-empty - * - The \a name is case-insensitive and must consist of ASCII within the - * range 0x20 to 0x7D inclusive, 0x3D ('=') excluded. - * - The \a name is not unique; multiple entries may exist with equivalent - * \a name within a Vorbiscomment block. - * - The \a value may be any UTF-8 string. - * - * \section comments_get Reading comments - * - * Oggz contains API methods to iterate through all comments associated - * with the logical bitstreams of an OGGZ* handle (oggz_comment_first() and - * oggz_comment_next(), and to iterate through comments matching a - * particular name (oggz_comment_first_byname() and - * oggz_comment_next_byname()). Given that multiple comments may exist - * with the same \a name, you should not use - * oggz_comment_first_byname() as a simple "get" function. - * - * \section comments_set Writing comments - * - * For writing, Oggz contains API methods for adding comments - * (oggz_comment_add() and oggz_comment_add_byname()), - * for removing comments - * (oggz_comment_remove() and oggz_comment_remove_byname()) - * and for setting the vendor string (oggz_comment_set_vendor()). - */ - -#include - -/** - * A comment. - */ -typedef struct { - /** The name of the comment, eg. "AUTHOR" */ - char * name; - - /** The value of the comment, as UTF-8 */ - char * value; -} OggzComment; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Retrieve the vendor string. - * \param oggz A OGGZ* handle - * \param serialno Identify a logical bitstream within \a oggz - * \returns A read-only copy of the vendor string. - * \retval NULL No vendor string is associated with \a oggz, - * or \a oggz is NULL, or \a serialno does not identify an - * existing logical bitstream in \a oggz. - */ -const char * -oggz_comment_get_vendor (OGGZ * oggz, long serialno); - -/** - * Set the vendor string - * \param oggz A OGGZ* handle - * \param serialno Identify a logical bitstream within \a oggz - * \param vendor_string The contents of the vendor string to add - * \retval 0 Success - * \retval OGGZ_ERR_BAD \a oggz is not a valid OGGZ* handle - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory - * \note The vendor string should identify the library used to produce - * the stream, e.g. libvorbis 1.0 used "Xiph.Org libVorbis I 20020717". - * If copying a bitstream it should be the same as the source. - */ -int -oggz_comment_set_vendor (OGGZ * oggz, long serialno, - const char * vendor_string); - -/** - * Retrieve the first comment. - * \param oggz A OGGZ* handle - * \param serialno Identify a logical bitstream within \a oggz - * \returns A read-only copy of the first comment. - * \retval NULL No comments exist for this OGGZ* object, or \a serialno - * does not identify an existing logical bitstream in \a oggz. - */ -const OggzComment * -oggz_comment_first (OGGZ * oggz, long serialno); - -/** - * Retrieve the next comment. - * \param oggz A OGGZ* handle - * \param serialno Identify a logical bitstream within \a oggz - * \param comment The previous comment. - * \returns A read-only copy of the comment immediately following the given - * comment. - * \retval NULL \a serialno does not identify an existing - * logical bitstream in \a oggz. - */ -const OggzComment * -oggz_comment_next (OGGZ * oggz, long serialno, const OggzComment * comment); - -/** - * Retrieve the first comment with a given name. - * \param oggz A OGGZ* handle - * \param serialno Identify a logical bitstream within \a oggz - * \param name the name of the comment to retrieve. - * \returns A read-only copy of the first comment matching the given \a name. - * \retval NULL No match was found, or \a serialno does not identify an - * existing logical bitstream in \a oggz. - * \note If \a name is NULL, the behaviour is the same as for - * oggz_comment_first() - */ -const OggzComment * -oggz_comment_first_byname (OGGZ * oggz, long serialno, char * name); - -/** - * Retrieve the next comment following and with the same name as a given - * comment. - * \param oggz A OGGZ* handle - * \param serialno Identify a logical bitstream within \a oggz - * \param comment A comment - * \returns A read-only copy of the next comment with the same name as - * \a comment. - * \retval NULL No further comments with the same name exist for this - * OGGZ* object, or \a serialno does not identify an existing - * logical bitstream in \a oggz. - */ -const OggzComment * -oggz_comment_next_byname (OGGZ * oggz, long serialno, - const OggzComment * comment); - -/** - * Add a comment - * \param oggz A OGGZ* handle (created with mode OGGZ_WRITE) - * \param serialno Identify a logical bitstream within \a oggz - * \param comment The comment to add - * \retval 0 Success - * \retval OGGZ_ERR_BAD \a oggz is not a valid OGGZ* handle - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory - */ -int -oggz_comment_add (OGGZ * oggz, long serialno, OggzComment * comment); - -/** - * Add a comment by name and value. - * \param oggz A OGGZ* handle (created with mode OGGZ_WRITE) - * \param serialno Identify a logical bitstream within \a oggz - * \param name The name of the comment to add - * \param value The contents of the comment to add - * \retval 0 Success - * \retval OGGZ_ERR_BAD \a oggz is not a valid OGGZ* handle - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory - */ -int -oggz_comment_add_byname (OGGZ * oggz, long serialno, - const char * name, const char * value); - -/** - * Remove a comment - * \param oggz A OGGZ* handle (created with OGGZ_WRITE) - * \param serialno Identify a logical bitstream within \a oggz - * \param comment The comment to remove. - * \retval 1 Success: comment removed - * \retval 0 No-op: comment not found, nothing to remove - * \retval OGGZ_ERR_BAD \a oggz is not a valid OGGZ* handle - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz. - */ -int -oggz_comment_remove (OGGZ * oggz, long serialno, OggzComment * comment); - -/** - * Remove all comments with a given name. - * \param oggz A OGGZ* handle (created with OGGZ_WRITE) - * \param serialno Identify a logical bitstream within \a oggz - * \param name The name of the comments to remove - * \retval ">= 0" The number of comments removed - * \retval OGGZ_ERR_BAD \a oggz is not a valid OGGZ* handle - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz. - */ -int -oggz_comment_remove_byname (OGGZ * oggz, long serialno, char * name); - -/** - * Output a comment packet for the specified stream - * \param oggz A OGGZ* handle (created with OGGZ_WRITE) - * \param serialno Identify a logical bitstream within \a oggz - * \param FLAC_final_metadata_block Set this to zero unless the packet_type is - * FLAC, and there are no further metadata blocks to follow. See note below - * for details. - * \returns A comment packet for the stream. When no longer needed it - * should be freed with oggz_packet_destroy(). - * \retval NULL content type does not support comments, not enough memory - * or comment was too long for FLAC - * \note FLAC streams may contain multiple metadata blocks of different types. - * When encapsulated in Ogg the first of these must be a Vorbis comment packet - * but PADDING, APPLICATION, SEEKTABLE, CUESHEET and PICTURE may follow. - * The last metadata block must have its first bit set to 1. Since liboggz does - * not know whether you will supply more metadata blocks you must tell it if - * this is the last (or only) metadata block by setting - * FLAC_final_metadata_block to 1. - * \n As FLAC metadata blocks are limited in size to 16MB minus 1 byte, this - * function will refuse to produce longer comment packets for FLAC. - * \n See http://flac.sourceforge.net/format.html for more details. - */ -ogg_packet * -oggz_comments_generate(OGGZ * oggz, long serialno, - int FLAC_final_metadata_block); - -/* - * Copy comments between two streams. - * \param src A OGGZ* handle - * \param src_serialno Identify a logical bitstream within \a src - * \param dest A OGGZ* handle (created with OGGZ_WRITE) - * \param dest_serialno Identify a logical bitstream within \a dest - * \retval OGGZ_ERR_BAD \a oggz is not a valid OGGZ* handle - * \retval OGGZ_ERR_INVALID Operation not suitable for \a dest - */ -int -oggz_comments_copy (OGGZ * src, long src_serialno, - OGGZ * dest, long dest_serialno); - -/** - * Free a packet and its payload. - * \param packet A packet previously returned from a function such - * as oggz_comment_generate(). User generated packets should not be passed. - */ -void oggz_packet_destroy (ogg_packet *packet); - -#ifdef __cplusplus -} -#endif - -#endif /* __OGGZ_COMMENTS_H__ */ diff --git a/media/liboggz/include/oggz/oggz_constants.h b/media/liboggz/include/oggz/oggz_constants.h deleted file mode 100644 index da553c6bcbe..00000000000 --- a/media/liboggz/include/oggz/oggz_constants.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_CONSTANTS_H__ -#define __OGGZ_CONSTANTS_H__ - -/** \file - * General constants used by liboggz. - */ - -/** - * Flags to oggz_new(), oggz_open(), and oggz_openfd(). - * Can be or'ed together in the following combinations: - * - OGGZ_READ | OGGZ_AUTO - * - OGGZ_WRITE | OGGZ_NONSTRICT | OGGZ_PREFIX | OGGZ_SUFFIX - */ -enum OggzFlags { - /** Read only */ - OGGZ_READ = 0x00, - - /** Write only */ - OGGZ_WRITE = 0x01, - - /** Disable strict adherence to mapping constraints, eg for - * handling an incomplete stream */ - OGGZ_NONSTRICT = 0x10, - - /** - * Scan for known headers while reading, and automatically set - * metrics appropriately. Opening a file for reading with - * \a flags = OGGZ_READ | OGGZ_AUTO will allow seeking on Speex, - * Vorbis, FLAC, Theora, CMML and all Annodex streams in units of - * milliseconds, once all bos pages have been delivered. */ - OGGZ_AUTO = 0x20, - - /** - * Write Prefix: Assume that we are only writing the prefix of an - * Ogg stream, ie. disable checking for conformance with end-of-stream - * constraints. - */ - OGGZ_PREFIX = 0x40, - - /** - * Write Suffix: Assume that we are only writing the suffix of an - * Ogg stream, ie. disable checking for conformance with - * beginning-of-stream constraints. - */ - OGGZ_SUFFIX = 0x80 - -}; - -enum OggzStopCtl { - /** Continue calling read callbacks */ - OGGZ_CONTINUE = 0, - - /** Stop calling callbacks, but retain buffered packet data */ - OGGZ_STOP_OK = 1, - - /** Stop calling callbacks, and purge buffered packet data */ - OGGZ_STOP_ERR = -1 -}; - -/** - * Flush options for oggz_write_feed; can be or'ed together - */ -enum OggzFlushOpts { - /** Flush all streams before beginning this packet */ - OGGZ_FLUSH_BEFORE = 0x01, - - /** Flush after this packet */ - OGGZ_FLUSH_AFTER = 0x02 -}; - -/** - * Definition of stream content types - */ -typedef enum OggzStreamContent { - OGGZ_CONTENT_THEORA = 0, - OGGZ_CONTENT_VORBIS, - OGGZ_CONTENT_SPEEX, - OGGZ_CONTENT_PCM, - OGGZ_CONTENT_CMML, - OGGZ_CONTENT_ANX2, - OGGZ_CONTENT_SKELETON, - OGGZ_CONTENT_FLAC0, - OGGZ_CONTENT_FLAC, - OGGZ_CONTENT_ANXDATA, - OGGZ_CONTENT_CELT, - OGGZ_CONTENT_KATE, - OGGZ_CONTENT_DIRAC, - OGGZ_CONTENT_UNKNOWN -} OggzStreamContent; - -/** - * Definitions of error return values - */ -enum OggzError { - /** No error */ - OGGZ_ERR_OK = 0, - - /** generic error */ - OGGZ_ERR_GENERIC = -1, - - /** oggz is not a valid OGGZ */ - OGGZ_ERR_BAD_OGGZ = -2, - - /** The requested operation is not suitable for this OGGZ */ - OGGZ_ERR_INVALID = -3, - - /** oggz contains no logical bitstreams */ - OGGZ_ERR_NO_STREAMS = -4, - - /** Operation is inappropriate for oggz in current bos state */ - OGGZ_ERR_BOS = -5, - - /** Operation is inappropriate for oggz in current eos state */ - OGGZ_ERR_EOS = -6, - - /** Operation requires a valid metric, but none has been set */ - OGGZ_ERR_BAD_METRIC = -7, - - /** System specific error; check errno for details */ - OGGZ_ERR_SYSTEM = -10, - - /** Functionality disabled at build time */ - OGGZ_ERR_DISABLED = -11, - - /** Seeking operation is not possible for this OGGZ */ - OGGZ_ERR_NOSEEK = -13, - - /** Reading was stopped by an OggzReadCallback returning OGGZ_STOP_OK - * or writing was stopped by an OggzWriteHungry callback returning - * OGGZ_STOP_OK */ - OGGZ_ERR_STOP_OK = -14, - - /** Reading was stopped by an OggzReadCallback returning OGGZ_STOP_ERR - * or writing was stopped by an OggzWriteHungry callback returning - * OGGZ_STOP_ERR */ - OGGZ_ERR_STOP_ERR = -15, - - /** no data available from IO, try again */ - OGGZ_ERR_IO_AGAIN = -16, - - /** Hole (sequence number gap) detected in input data */ - OGGZ_ERR_HOLE_IN_DATA = -17, - - /** Out of memory */ - OGGZ_ERR_OUT_OF_MEMORY = -18, - - /** The requested serialno does not exist in this OGGZ */ - OGGZ_ERR_BAD_SERIALNO = -20, - - /** Packet disallowed due to invalid byte length */ - OGGZ_ERR_BAD_BYTES = -21, - - /** Packet disallowed due to invalid b_o_s (beginning of stream) flag */ - OGGZ_ERR_BAD_B_O_S = -22, - - /** Packet disallowed due to invalid e_o_s (end of stream) flag */ - OGGZ_ERR_BAD_E_O_S = -23, - - /** Packet disallowed due to invalid granulepos */ - OGGZ_ERR_BAD_GRANULEPOS = -24, - - /** Packet disallowed due to invalid packetno */ - OGGZ_ERR_BAD_PACKETNO = -25, - - /** Comment violates VorbisComment restrictions */ - /* 129 == 0x81 is the frame marker for Theora's comments page ;-) */ - OGGZ_ERR_COMMENT_INVALID = -129, - - /** Guard provided by user has non-zero value */ - OGGZ_ERR_BAD_GUARD = -210, - - /** Attempt to call oggz_write() or oggz_write_output() from within - * a hungry() callback */ - OGGZ_ERR_RECURSIVE_WRITE = -266 -}; - -#endif /* __OGGZ_CONSTANTS_H__ */ diff --git a/media/liboggz/include/oggz/oggz_deprecated.h b/media/liboggz/include/oggz/oggz_deprecated.h deleted file mode 100644 index 08434cbc148..00000000000 --- a/media/liboggz/include/oggz/oggz_deprecated.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_DEPRECATED_H__ -#define __OGGZ_DEPRECATED_H__ - -/** \file - * Deprecated interfaces - */ - -/** - * DEPRECATED CONSTANT. - * OGGZ_ERR_USER_STOPPED was introduced during development (post 0.8.3), - * and is similar in functionality to and numerically equal to (ie. ABI - * compatible with) OGGZ_ERR_STOP_OK in . - * It was badly named, as the preferred functionality distinguishes between - * a user's OggzReadCallback returning OGGZ_STOP_OK or OGGZ_STOP_ERR; your - * code should distinguish between these two too :-) Hence, don't use this - * (unreleased) name in new code. - */ -#define OGGZ_ERR_USER_STOPPED OGGZ_ERR_STOP_OK - -/** - * DEPRECATED CONSTANT. - * OGGZ_ERR_READ_STOP_OK, OGGZ_ERR_READ_STOP_ERR were introduced to allow - * the user to differentiate between a cancelled oggz_read_*() returning - * due to error or an ok condition. - * From 0.9.4 similar functionality was added for oggz_write_*(), hence this - * constant was renamed. - */ -#define OGGZ_ERR_READ_STOP_OK OGGZ_ERR_STOP_OK - -/** - * DEPRECATED CONSTANT. - * OGGZ_ERR_READ_STOP_OK, OGGZ_ERR_READ_STOP_ERR were introduced to allow - * the user to differentiate between a cancelled oggz_read_*() returning - * due to error or an ok condition. - * From 0.9.4 similar functionality was added for oggz_write_*(), hence this - * constant was renamed. - */ -#define OGGZ_ERR_READ_STOP_ERR OGGZ_ERR_STOP_ERR - -/** - * DEPRECATED FUNCTION - * This function has been replaced with the more clearly named - * oggz_set_granulerate(). - * Specify that a logical bitstream has a linear metric - * \param oggz An OGGZ handle - * \param serialno Identify the logical bitstream in \a oggz to attach - * this linear metric to. A value of -1 indicates that the metric should - * be attached to all unattached logical bitstreams in \a oggz. - * \param granule_rate_numerator The numerator of the granule rate - * \param granule_rate_denominator The denominator of the granule rate - * \returns 0 Success - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz. - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - */ -int oggz_set_metric_linear (OGGZ * oggz, long serialno, - ogg_int64_t granule_rate_numerator, - ogg_int64_t granule_rate_denominator); - -/** - * DEPRECATED FUNCTION - * This function has been replaced with oggz_comments_generate(), which - * does not require the packet_type argument. Instead, the packet type is - * determined by the content type of the stream, which was discovered when - * the bos packet was passed to oggz_write_feed. - * - * Output a comment packet for the specified stream. - * \param oggz A OGGZ* handle (created with OGGZ_WRITE) - * \param serialno Identify a logical bitstream within \a oggz - * \param packet_type Type of comment packet to generate, - * FLAC, OggPCM, Speex, Theora and Vorbis are supported - * \param FLAC_final_metadata_block Set this to zero unless the packet_type is - * FLAC, and there are no further metadata blocks to follow. See note below - * for details. - * \returns A comment packet for the stream. When no longer needed it - * should be freed with oggz_packet_destroy(). - * \retval NULL content type does not support comments, not enough memory - * or comment was too long for FLAC - * \note FLAC streams may contain multiple metadata blocks of different types. - * When encapsulated in Ogg the first of these must be a Vorbis comment packet - * but PADDING, APPLICATION, SEEKTABLE, CUESHEET and PICTURE may follow. - * The last metadata block must have its first bit set to 1. Since liboggz does - * not know whether you will supply more metadata blocks you must tell it if - * this is the last (or only) metadata block by setting - * FLAC_final_metadata_block to 1. - * \n As FLAC metadata blocks are limited in size to 16MB minus 1 byte, this - * function will refuse to produce longer comment packets for FLAC. - * \n See http://flac.sourceforge.net/format.html for more details. - */ -ogg_packet * -oggz_comment_generate(OGGZ * oggz, long serialno, - OggzStreamContent packet_type, - int FLAC_final_metadata_block); - -#endif /* __OGGZ_DEPRECATED_H__ */ diff --git a/media/liboggz/include/oggz/oggz_io.h b/media/liboggz/include/oggz/oggz_io.h deleted file mode 100644 index 116fb497a7b..00000000000 --- a/media/liboggz/include/oggz/oggz_io.h +++ /dev/null @@ -1,236 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_IO_H__ -#define __OGGZ_IO_H__ - -/** \file - * Overriding the functions used for input and output of raw data. - * - * OggzIO provides a way of overriding the functions Oggz uses to access - * its raw input or output data. This is required in many situations where - * the raw stream cannot be accessed via stdio, but can be accessed by - * other means. This is typically useful within media frameworks, where - * accessing and moving around in the data is possible only using methods - * provided by the framework. - * - * The functions you provide for overriding IO will be used by Oggz - * whenever you call oggz_read() or oggz_write(). They will also be - * used repeatedly by Oggz when you call oggz_seek(). - * - * \note Opening a file with oggz_open() or oggz_open_stdio() is equivalent - * to calling oggz_new() and setting stdio based functions for data IO. - */ - -/** - * This is the signature of a function which you provide for Oggz - * to call when it needs to acquire raw input data. - * - * \param user_handle A generic pointer you have provided earlier - * \param n The length in bytes that Oggz wants to read - * \param buf The buffer that you read data into - * \retval "> 0" The number of bytes successfully read into the buffer - * \retval 0 to indicate that there is no more data to read (End of file) - * \retval "< 0" An error condition - */ -typedef size_t (*OggzIORead) (void * user_handle, void * buf, size_t n); - -/** - * This is the signature of a function which you provide for Oggz - * to call when it needs to output raw data. - * - * \param user_handle A generic pointer you have provided earlier - * \param n The length in bytes of the data - * \param buf A buffer containing data to write - * \retval ">= 0" The number of bytes successfully written (may be less than - * \a n if a write error has occurred) - * \retval "< 0" An error condition - */ -typedef size_t (*OggzIOWrite) (void * user_handle, void * buf, size_t n); - -/** - * This is the signature of a function which you provide for Oggz - * to call when it needs to seek on the raw input or output data. - * - * \param user_handle A generic pointer you have provided earlier - * \param offset The offset in bytes to seek to - * \param whence SEEK_SET, SEEK_CUR or SEEK_END (as for stdio.h) - * \retval ">= 0" The offset seeked to - * \retval "< 0" An error condition - * - * \note If you provide an OggzIOSeek function, you MUST also provide - * an OggzIOTell function, or else all your seeks will fail. - */ -typedef int (*OggzIOSeek) (void * user_handle, long offset, int whence); - -/** - * This is the signature of a function which you provide for Oggz - * to call when it needs to determine the current offset of the raw - * input or output data. - * - * \param user_handle A generic pointer you have provided earlier - * \retval ">= 0" The offset - * \retval "< 0" An error condition - */ -typedef long (*OggzIOTell) (void * user_handle); - -/** - * This is the signature of a function which you provide for Oggz - * to call when it needs to flush the output data. The behaviour - * of this function is similar to that of fflush() in stdio. - * - * \param user_handle A generic pointer you have provided earlier - * \retval 0 Success - * \retval "< 0" An error condition - */ -typedef int (*OggzIOFlush) (void * user_handle); - - -/** - * Set a function for Oggz to call when it needs to read input data. - * - * \param oggz An OGGZ handle - * \param read Your reading function - * \param user_handle Any arbitrary data you wish to pass to the function - * \retval 0 Success - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ; \a oggz not - * open for reading. - * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory - */ -int oggz_io_set_read (OGGZ * oggz, OggzIORead read, void * user_handle); - -/** - * Retrieve the user_handle associated with the function you have provided - * for reading input data. - * - * \param oggz An OGGZ handle - * \returns the associated user_handle - */ -void * oggz_io_get_read_user_handle (OGGZ * oggz); - -/** - * Set a function for Oggz to call when it needs to write output data. - * - * \param oggz An OGGZ handle - * \param write Your writing function - * \param user_handle Any arbitrary data you wish to pass to the function - * \retval 0 Success - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ; \a oggz not - * open for writing. - * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory - */ -int oggz_io_set_write (OGGZ * oggz, OggzIOWrite write, void * user_handle); - -/** - * Retrieve the user_handle associated with the function you have provided - * for writing output data. - * - * \param oggz An OGGZ handle - * \returns the associated user_handle - */ -void * oggz_io_get_write_user_handle (OGGZ * oggz); - -/** - * Set a function for Oggz to call when it needs to seek on its raw data. - * - * \param oggz An OGGZ handle - * \param seek Your seeking function - * \param user_handle Any arbitrary data you wish to pass to the function - * \retval 0 Success - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory - * - * \note If you provide an OggzIOSeek function, you MUST also provide - * an OggzIOTell function, or else all your seeks will fail. - */ -int oggz_io_set_seek (OGGZ * oggz, OggzIOSeek seek, void * user_handle); - -/** - * Retrieve the user_handle associated with the function you have provided - * for seeking on input or output data. - * - * \param oggz An OGGZ handle - * \returns the associated user_handle - */ -void * oggz_io_get_seek_user_handle (OGGZ * oggz); - -/** - * Set a function for Oggz to call when it needs to determine the offset - * within its input data (if OGGZ_READ) or output data (if OGGZ_WRITE). - * - * \param oggz An OGGZ handle - * \param tell Your tell function - * \param user_handle Any arbitrary data you wish to pass to the function - * \retval 0 Success - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory - */ -int oggz_io_set_tell (OGGZ * oggz, OggzIOTell tell, void * user_handle); - -/** - * Retrieve the user_handle associated with the function you have provided - * for determining the current offset in input or output data. - * - * \param oggz An OGGZ handle - * \returns the associated user_handle - */ -void * oggz_io_get_tell_user_handle (OGGZ * oggz); - -/** - * Set a function for Oggz to call when it needs to flush its output. The - * meaning of this is similar to that of fflush() in stdio. - * - * \param oggz An OGGZ handle - * \param flush Your flushing function - * \param user_handle Any arbitrary data you wish to pass to the function - * \retval 0 Success - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ; \a oggz not - * open for writing. - * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory - */ -int oggz_io_set_flush (OGGZ * oggz, OggzIOFlush flush, void * user_handle); - -/** - * Retrieve the user_handle associated with the function you have provided - * for flushing output. - * - * \param oggz An OGGZ handle - * \returns the associated user_handle - */ -void * oggz_io_get_flush_user_handle (OGGZ * oggz); - -#endif /* __OGGZ_IO_H__ */ diff --git a/media/liboggz/include/oggz/oggz_off_t.h b/media/liboggz/include/oggz/oggz_off_t.h deleted file mode 100644 index ed8dbf6141e..00000000000 --- a/media/liboggz/include/oggz/oggz_off_t.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2007 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_OFF_T_H__ -#define __OGGZ_OFF_T_H__ - -/** \file - * Architecture-dependent type and printf format for file position. - * Allows Large File Sizes on systems supporting 64-bit off_t types. - */ - -#ifdef _WIN32 -#ifdef WINCE - typedef long off_t; -#endif - - /* MSVC/Borland & Cygwin */ - typedef off_t oggz_off_t; - -#define PRI_OGGZ_OFF_T "l" - -#else -#include -#endif - -#endif /* __OGGZ_OFF_T__ */ diff --git a/media/liboggz/include/oggz/oggz_off_t_generated.h b/media/liboggz/include/oggz/oggz_off_t_generated.h deleted file mode 100644 index 5eab7e65ab6..00000000000 --- a/media/liboggz/include/oggz/oggz_off_t_generated.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2007 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_OFF_T_GENERATED_H__ -#define __OGGZ_OFF_T_GENERATED_H__ - -/** \file - * Architecture-dependent type for oggz_off_t. - * - * This file should never be included directly by user code. Please include - * either of or instead. - * - * This file was generated when liboggz was built. - * - * Note that this file is only generated when using GNU autoconf. - * This file is not used on Win32 systems. - */ - -/** - * This typedef was determined on the system on which the documentation - * was generated. - * - * To query this on your system, do eg. - * -
-   echo "gcc -E oggz.h | grep oggz_off_t
- 
- * - */ - -#include - -#if defined(__APPLE__) || defined(SOLARIS) || defined(OS2) -typedef off_t oggz_off_t; -#else -typedef loff_t oggz_off_t; -#endif - -#define PRI_OGGZ_OFF_T "PRId64" - -#endif /* __OGGZ_OFF_T_GENERATED__ */ diff --git a/media/liboggz/include/oggz/oggz_read.h b/media/liboggz/include/oggz/oggz_read.h deleted file mode 100644 index c78201f6f2d..00000000000 --- a/media/liboggz/include/oggz/oggz_read.h +++ /dev/null @@ -1,236 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_READ_H__ -#define __OGGZ_READ_H__ - -/** \file - * Interfaces for reading Ogg files and streams - */ - -/** \defgroup read_api Oggz Read API - * - * Oggz parses Ogg bitstreams, forming ogg_packet structures, and calling - * your OggzReadPacket callback(s). - * - * You provide Ogg data to Oggz with oggz_read() or oggz_read_input(), and - * independently process it in OggzReadPacket callbacks. - * It is possible to set a different callback per \a serialno (ie. for each - * logical bitstream in the Ogg bitstream - see the \ref basics section for - * more detail). - * - * When using an OGGZ* opened with the OGGZ_AUTO flag set, Oggz will - * internally calculate the granulepos for each packet, even though these - * are not all recorded in the file: only the last packet ending on a page - * will have its granulepos recorded in the page header. - * Within a OggzReadPacket callback, calling oggz_tell_granulepos() will - * retrieve the calculated granulepos. - * - * See \ref seek_api for information on seeking on interleaved Ogg data, - * and for working with calculated granulepos values. - * - * \{ - */ - -/** - * This is the signature of a callback which you must provide for Oggz - * to call whenever it finds a new packet in the Ogg stream associated - * with \a oggz. - * - * \param oggz The OGGZ handle - * \param op The full ogg_packet (see ) - * \param serialno Identify the logical bistream in \a oggz that contains - * \a op - * \param user_data A generic pointer you have provided earlier - * \returns 0 to continue, non-zero to instruct Oggz to stop. - * - * \note It is possible to provide different callbacks per logical - * bitstream -- see oggz_set_read_callback() for more information. - */ -typedef int (*OggzReadPacket) (OGGZ * oggz, ogg_packet * op, long serialno, - void * user_data); - -/** - * Set a callback for Oggz to call when a new Ogg packet is found in the - * stream. - * - * \param oggz An OGGZ handle previously opened for reading - * \param serialno Identify the logical bitstream in \a oggz to attach - * this callback to, or -1 to attach this callback to all unattached - * logical bitstreams in \a oggz. - * \param read_packet Your callback function - * \param user_data Arbitrary data you wish to pass to your callback - * \retval 0 Success - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz. - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory - * - * \note Values of \a serialno other than -1 allows you to specify different - * callback functions for each logical bitstream. - * - * \note It is safe to call this callback from within an OggzReadPacket - * function, in order to specify that subsequent packets should be handled - * by a different OggzReadPacket function. - */ -int oggz_set_read_callback (OGGZ * oggz, long serialno, - OggzReadPacket read_packet, void * user_data); - -/** - * This is the signature of a callback which you must provide for Oggz - * to call whenever it finds a new page in the Ogg stream associated - * with \a oggz. - * - * \param oggz The OGGZ handle - * \param op The full ogg_page (see ) - * \param user_data A generic pointer you have provided earlier - * \returns 0 to continue, non-zero to instruct Oggz to stop. - */ -typedef int (*OggzReadPage) (OGGZ * oggz, const ogg_page * og, - long serialno, void * user_data); - -/** - * Set a callback for Oggz to call when a new Ogg page is found in the - * stream. - * - * \param oggz An OGGZ handle previously opened for reading - * \param serialno Identify the logical bitstream in \a oggz to attach - * this callback to, or -1 to attach this callback to all unattached - * logical bitstreams in \a oggz. - * \param read_page Your OggzReadPage callback function - * \param user_data Arbitrary data you wish to pass to your callback - * \retval 0 Success - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory - * - * \note Values of \a serialno other than -1 allows you to specify different - * callback functions for each logical bitstream. - * - * \note It is safe to call this callback from within an OggzReadPage - * function, in order to specify that subsequent pages should be handled - * by a different OggzReadPage function. - */ -int oggz_set_read_page (OGGZ * oggz, long serialno, - OggzReadPage read_page, void * user_data); - - -/** - * Read n bytes into \a oggz, calling any read callbacks on the fly. - * \param oggz An OGGZ handle previously opened for reading - * \param n A count of bytes to ingest - * \retval "> 0" The number of bytes successfully ingested. - * \retval 0 End of file - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_SYSTEM System error; check errno for details - * \retval OGGZ_ERR_STOP_OK Reading was stopped by a user callback - * returning OGGZ_STOP_OK - * \retval OGGZ_ERR_STOP_ERR Reading was stopped by a user callback - * returning OGGZ_STOP_ERR - * \retval OGGZ_ERR_HOLE_IN_DATA Hole (sequence number gap) detected in input data - * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory - */ -long oggz_read (OGGZ * oggz, long n); - -/** - * Input data into \a oggz. - * \param oggz An OGGZ handle previously opened for reading - * \param buf A memory buffer - * \param n A count of bytes to input - * \retval "> 0" The number of bytes successfully ingested. - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_STOP_OK Reading was stopped by a user callback - * returning OGGZ_STOP_OK - * \retval OGGZ_ERR_STOP_ERR Reading was stopped by a user callback - * returning OGGZ_STOP_ERR - * \retval OGGZ_ERR_HOLE_IN_DATA Hole (sequence number gap) detected in input data - * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory - */ -long oggz_read_input (OGGZ * oggz, unsigned char * buf, long n); - -/** \} - */ - -/** - * Erase any input buffered in Oggz. This discards any input read from the - * underlying IO system but not yet delivered as ogg_packets. - * - * \param oggz An OGGZ handle - * \retval 0 Success - * \retval OGGZ_ERR_SYSTEM Error seeking on underlying IO. - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - */ -int oggz_purge (OGGZ * oggz); - -/** - * Determine the content type of the oggz stream referred to by \a serialno - * - * \param oggz An OGGZ handle - * \param serialno An ogg stream serialno - * \retval OGGZ_CONTENT_THEORA..OGGZ_CONTENT_UNKNOWN content successfully - * identified - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not refer to an existing - * stream - */ -OggzStreamContent oggz_stream_get_content (OGGZ * oggz, long serialno); - -/** - * Return human-readable string representation of content type of oggz stream - * referred to by \a serialno - * - * \param oggz An OGGZ handle - * \param serialno An ogg stream serialno - * \retval string the name of the content type - * \retval NULL \a oggz or \a serialno invalid - */ -const char * oggz_stream_get_content_type (OGGZ *oggz, long serialno); - -/** - * Determine the number of headers of the oggz stream referred to by - * \a serialno - * - * \param oggz An OGGZ handle - * \param serialno An ogg stream serialno - * \retval OGGZ_CONTENT_THEORA..OGGZ_CONTENT_UNKNOWN content successfully - * identified - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not refer to an existing - * stream - */ -int oggz_stream_get_numheaders (OGGZ * oggz, long serialno); - -#endif /* __OGGZ_READ_H__ */ diff --git a/media/liboggz/include/oggz/oggz_seek.h b/media/liboggz/include/oggz/oggz_seek.h deleted file mode 100644 index cf0d499e2e0..00000000000 --- a/media/liboggz/include/oggz/oggz_seek.h +++ /dev/null @@ -1,510 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_SEEK_H__ -#define __OGGZ_SEEK_H__ - -/** \file - * Seeking within files - */ - -/** \defgroup seek_api Oggz Seek API - * - * Oggz can seek on multitrack, multicodec bitstreams. - * - * \section seek_time Time seeking - * - * Support is built-in for seeking to time positions in - * CELT, - * CMML. - * FLAC, - * OggPCM, - * Speex, - * Theora - * and Vorbis. - * Oggz is also compatible with - * Annodex streams, and supports seeking - * on all tracks described in an - * Ogg Skeleton track. - * - * You need to open the file with the OGGZ_AUTO flag set: - * - * - Create an OGGZ handle for reading with \a flags = OGGZ_READ | OGGZ_AUTO - * - Read data, ensuring that you have received all b_o_s pages before - * attempting to seek. - * - * Oggz will silently parse known codec headers and associate metrics - * appropriately; if you attempt to seek before you have received all - * b_o_s pages, Oggz will not have had a chance to parse the codec headers - * and associate metrics. - * It is safe to seek once you have received a packet with \a b_o_s == 0; - * see the \link basics Ogg basics \endlink section for more details. - * - * \note Oggz parses these codec headers internally, and so liboggz is \b not - * linked to libspeex, libvorbis, libflac, libtheora, libcmml or libannodex. - * - * For other data streams, you will need to provide a metric function; - * see the section on \link metric Using OggzMetrics \endlink for details - * of setting up and seeking with metrics. - * - * \section seek_bytes Byte seeking - * - * oggz_seek() provides low-level seeking to byte positions. - * - * \section seek_info More detail - * - * For a full description of the seeking methods possible in Ogg, see - * \link seek_semantics Semantics of seeking in Ogg bitstreams \endlink. - * - * \{ - */ - -/** - * Query the current offset in milliseconds, or custom units as - * specified by a Metric function you have provided. - * \param oggz An OGGZ handle - * \returns the offset in milliseconds, or custom units - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - */ -ogg_int64_t oggz_tell_units (OGGZ * oggz); - -/** - * Seek to an offset in milliseconds, or custom units as specified - * by a Metric function you have provided. - * \param oggz An OGGZ handle - * \param units A number of milliseconds, or custom units - * \param whence As defined in : SEEK_SET, SEEK_CUR or SEEK_END - * \returns the new file offset, or -1 on failure. - */ -ogg_int64_t oggz_seek_units (OGGZ * oggz, ogg_int64_t units, int whence); - -/** - * Provide the exact stored granulepos (from the page header) if relevant to - * the current packet, or a constructed granulepos if the stored granulepos - * does not belong to this packet, or -1 if this codec does not have support - * for granulepos interpolation - * \param oggz An OGGZ handle - * \returns the granulepos of the \a current packet (if available) - */ -ogg_int64_t -oggz_tell_granulepos (OGGZ * oggz); - -/** - * Query the file offset in bytes corresponding to the data read. - * \param oggz An OGGZ handle - * \returns The current offset of oggz. - * - * \note When reading, the value returned by oggz_tell() reflects the - * data offset of the start of the most recent packet processed, so that - * when called from an OggzReadPacket callback it reflects the byte - * offset of the start of the packet. As Oggz may have internally read - * ahead, this may differ from the current offset of the associated file - * descriptor. - */ -oggz_off_t oggz_tell (OGGZ * oggz); - -/** - * Seek to a specific byte offset - * \param oggz An OGGZ handle - * \param offset a byte offset - * \param whence As defined in : SEEK_SET, SEEK_CUR or SEEK_END - * \returns the new file offset, or -1 on failure. - */ -oggz_off_t oggz_seek (OGGZ * oggz, oggz_off_t offset, int whence); - -#ifdef _UNIMPLEMENTED -long oggz_seek_packets (OGGZ * oggz, long serialno, long packets, int whence); -#endif - -/** \} - */ - -/** \defgroup seek_semantics Semantics of seeking in Ogg bitstreams - * - * \section seek_semantics_intro Introduction - * - * [*** This line works around a bug in doxygen ***] - * - * [*** This line works around a bug in doxygen ***] - * - * The seeking semantics of the Ogg file format were outlined by Monty in - * a - * post to theora-dev in September 2002. Quoting from that post, we - * have the following assumptions: - * - * - Ogg is not a non-linear format. ... It is a media transport format - * designed to do nothing more than deliver content, in a stream, and - * have all the pieces arrive on time and in sync. - * - The Ogg layer does not know the specifics of the codec data it's - * multiplexing into a stream. It knows nothing beyond 'Oooo, packets!', - * that the packets belong to different buckets, that the packets go in - * order, and that packets have position markers. Ogg does not even have - * a concept of 'time'; it only knows about the sequentially increasing, - * unitless position markers. It is up to higher layers which have - * access to the codec APIs to assign and convert units of framing or - * time. - * - * (For more details on the structure of Ogg streams, see the - * \link basics Ogg Basics \endlink section). - * - * For data such as media, for which it is possible to provide a mapping - * such as 'time', Oggz can efficiently navigate through an Ogg stream - * by use of an OggzMetric callback, thus allowing automatic seeking to - * points in 'time'. - * - * For common codecs you can ask Oggz to set this for you automatically by - * instantiating the OGGZ handle with the OGGZ_AUTO flag set. For others - * you can specify a multiplier with oggz_set_metric_linear(), or a generic - * non-linear metric with oggz_set_metric(). - * - */ - -/** \defgroup metric Using OggzMetric - * - * \section metric_intro Introduction - * - * An OggzMetric is a helper function for Oggz's seeking mechanism. - * - * If every position in an Ogg stream can be described by a metric such as - * time, then it is possible to define a function that, given a serialno and - * granulepos, returns a measurement in units such as milliseconds. Oggz - * will use this function repeatedly while seeking in order to navigate - * through the Ogg stream. - * - * The meaning of the units is arbitrary, but must be consistent across all - * logical bitstreams. This allows Oggz to seek accurately through Ogg - * bitstreams containing multiple logical bitstreams such as tracks of media. - * - * \section setting How to set metrics - * - * You don't need to set metrics for Speex, Vorbis, FLAC, Theora, CMML or - * Annodex. - * These can be handled \link seek_api automatically \endlink by Oggz. - * - * For most others it is simply a matter of providing a "granulerate": - * a frame or sampling rate, if each packet's granulepos represents a - * sample number. - * - * - Set the \a granule_rate_numerator and \a granule_rate_denominator - * appropriately using oggz_set_granulerate() - * - * Some codecs use a "granuleshift" to divide a granulepos into two halves; - * the first describing a dependency on a previous packet, the second - * giving the offset since that packet. This is used to mark keyframes and - * intermediate frames. - * - * - Set the \a granuleshift appropriately using oggz_set_granuleshift() - * - * \subsection custom Custom Metrics - * - * For streams with non-linear granulepos, you need to set a custom metric: - * - * - Implement an OggzMetric callback - * - Set the OggzMetric callback using oggz_set_metric() - * - * \section using Seeking with OggzMetrics - * - * To seek, use oggz_seek_units(). Oggz will perform a ratio search - * through the Ogg bitstream, using the OggzMetric callback to determine - * its position relative to the desired unit. - * - * \note - * - * Many data streams begin with headers describing such things as codec - * setup parameters. One of the assumptions Monty makes is: - * - * - Given pre-cached decode headers, a player may seek into a stream at - * any point and begin decode. - * - * Thus, the first action taken by applications dealing with such data is - * to read in and cache the decode headers; thereafter the application can - * safely seek to arbitrary points in the data. - * - * This impacts seeking because the portion of the bitstream containing - * decode headers should not be considered part of the metric space. To - * inform Oggz not to seek earlier than the end of the decode headers, - * use oggz_set_data_start(). - * - * \{ - */ - -/** - * Retrieve the preroll of a logical bitstream. - * \param oggz An OGGZ handle - * \param serialno Identify the logical bitstream in \a oggz - * \returns The preroll of the specified logical bitstream. - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz. - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - */ -int oggz_get_preroll (OGGZ * oggz, long serialno); - -/** - * Specify the preroll of a logical bitstream. - * \param oggz An OGGZ handle - * \param serialno Identify the logical bitstream in \a oggz to attach - * this preroll to. - * \param preroll The preroll - * \returns 0 Success - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz. - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - */ -int oggz_set_preroll (OGGZ * oggz, long serialno, int preroll); - -/** - * Retrieve the granuleshift of a logical bitstream. - * \param oggz An OGGZ handle - * \param serialno Identify the logical bitstream in \a oggz - * \returns The granuleshift of the specified logical bitstream. - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz. - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - */ -int oggz_get_granuleshift (OGGZ * oggz, long serialno); - -/** - * Specify the granuleshift of a logical bitstream. - * \param oggz An OGGZ handle - * \param serialno Identify the logical bitstream in \a oggz to attach - * this granuleshift metric to. A value of -1 indicates that the metric should - * be attached to all unattached logical bitstreams in \a oggz. - * \param granuleshift The granuleshift - * \returns 0 Success - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz. - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - */ -int oggz_set_granuleshift (OGGZ * oggz, long serialno, int granuleshift); - -/** - * Retrieve the granulerate of a logical bitstream. - * \param oggz An OGGZ handle - * \param serialno Identify the logical bitstream in \a oggz - * \param granulerate_n Return location for the granulerate numerator - * \param granulerate_d Return location for the granulerate denominator - * \returns 0 Success - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz. - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * - */ -int oggz_get_granulerate (OGGZ * oggz, long serialno, - ogg_int64_t * granulerate_n, - ogg_int64_t * granulerate_d); - -/** - * Specify the granulerate of a logical bitstream. - * \param oggz An OGGZ handle - * \param serialno Identify the logical bitstream in \a oggz to attach - * this linear metric to. A value of -1 indicates that the metric should - * be attached to all unattached logical bitstreams in \a oggz. - * \param granule_rate_numerator The numerator of the granule rate - * \param granule_rate_denominator The denominator of the granule rate - * \returns 0 Success - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz. - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - */ -int oggz_set_granulerate (OGGZ * oggz, long serialno, - ogg_int64_t granule_rate_numerator, - ogg_int64_t granule_rate_denominator); - -/** - * This is the signature of a function to correlate Ogg streams. - * If every position in an Ogg stream can be described by a metric (eg. time) - * then define this function that returns some arbitrary unit value. - * This is the normal use of Oggz for media streams. The meaning of units is - * arbitrary, but must be consistent across all logical bitstreams; for - * example a conversion of the time offset of a given packet into nanoseconds - * or a similar stream-specific subdivision may be appropriate. - * - * \param oggz An OGGZ handle - * \param serialno Identifies a logical bitstream within \a oggz - * \param granulepos A granulepos within the logical bitstream identified - * by \a serialno - * \param user_data Arbitrary data you wish to pass to your callback - * \returns A conversion of the (serialno, granulepos) pair into a measure - * in units which is consistent across all logical bitstreams within \a oggz - */ -typedef ogg_int64_t (*OggzMetric) (OGGZ * oggz, long serialno, - ogg_int64_t granulepos, void * user_data); - -/** - * Set the OggzMetric to use for an OGGZ handle - * - * \param oggz An OGGZ handle - * \param serialno Identify the logical bitstream in \a oggz to attach - * this metric to. A value of -1 indicates that this metric - * should be attached to all unattached logical bitstreams - * in \a oggz. - * \param metric An OggzMetric callback - * \param user_data arbitrary data to pass to the metric callback - * - * \returns 0 Success - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz, and is not -1 - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * - * \note Specifying values of \a serialno other than -1 allows you to pass - * logical bitstream specific user_data to the same metric. - * \note Alternatively, you may use a different \a metric for each - * \a serialno, but all metrics used must return mutually consistent - * unit measurements. - */ -int oggz_set_metric (OGGZ * oggz, long serialno, OggzMetric metric, - void * user_data); - -#ifdef _UNIMPLEMENTED -/** \defgroup order OggzOrder - * - * - A mechanism to aid seeking across non-metric spaces for which a partial - * order exists (ie. data that is not synchronised by a measure such as time, - * but is nevertheless somehow seekably structured), is also planned. - * - * \subsection OggzOrder - * - * Suppose there is a partial order < and a corresponding equivalence - * relation = defined on the space of packets in the Ogg stream of 'OGGZ'. - * An OggzOrder simply provides a comparison in terms of '<' and '=' for - * ogg_packets against a target. - * - * To use OggzOrder: - * - * - Implement an OggzOrder callback - * - Set the OggzOrder callback for an OGGZ handle with oggz_set_order() - * - To seek, use oggz_seek_byorder(). Oggz will use a combination bisection - * search and scan of the Ogg bitstream, using the OggzOrder callback to - * match against the desired 'target'. - * - * Otherwise, for more general ogg streams for which a partial order can be - * defined, define a function matching this specification. - * - * Parameters: - * - * OGGZ: the OGGZ object - * op: an ogg packet in the stream - * target: a user defined object - * - * Return values: - * - * -1 , if 'op' would occur before the position represented by 'target' - * 0 , if the position of 'op' is equivalent to that of 'target' - * 1 , if 'op' would occur after the position represented by 'target' - * 2 , if the relationship between 'op' and 'target' is undefined. - * - * Symbolically: - * - * Suppose there is a partial order < and a corresponding equivalence - * relation = defined on the space of packets in the Ogg stream of 'OGGZ'. - * Let p represent the position of the packet 'op', and t be the position - * represented by 'target'. - * - * Then a function implementing OggzPacketOrder should return as follows: - * - * -1 , p < t - * 0 , p = t - * 1 , t < p - * 2 , otherwise - * - * Hacker's hint: if there are no circumstances in which you would return - * a value of 2, there is a linear order; it may be possible to define a - * Metric rather than an Order. - * - */ -typedef int (*OggzOrder) (OGGZ * oggz, ogg_packet * op, void * target, - void * user_data); -/** - * \retval 0 Success - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz, and is not -1 - */ -int oggz_set_order (OGGZ * oggz, long serialno, OggzOrder order, - void * user_data); - -long oggz_seek_byorder (OGGZ * oggz, void * target); - -#endif /* _UNIMPLEMENTED */ - -/** - * Tell Oggz to remember the given offset as the start of data. - * This informs the seeking mechanism that when seeking back to unit 0, - * go to the given offset, not to the start of the file, which is usually - * codec headers. - * The usual usage is: -
-    oggz_set_data_start (oggz, oggz_tell (oggz));
-
- * \param oggz An OGGZ handle previously opened for reading - * \param offset The offset of the start of data - * \returns 0 on success, -1 on failure. - */ -int oggz_set_data_start (OGGZ * oggz, oggz_off_t offset); -/** \} - */ - -/** - * Seeks to within fuzz_margin milliseconds of time unit_target, within the - * bounds of the offset range [offset_begin, offset_end]. This is useful when - * seeking in network streams where only parts of a media are buffered, and - * retrieving unbuffered parts is expensive. - * \param oggz An OGGZ handle previously opened for reading - * \param unit_target The seek target, in milliseconds, or custom units - * \param offset_begin Start of offset range to seek inside, in bytes - * \param offset_end End of offset range to seek inside, in bytes, - pass -1 for end of media - * \param fuzz_margin The seek stops when it's within this many milliseconds - of unit_target - * \returns The new position, in milliseconds or custom units - * \retval -1 on failure (unit_target is not within range) - */ -ogg_int64_t -oggz_bounded_seek_set (OGGZ * oggz, - ogg_int64_t unit_target, - ogg_int64_t offset_begin, - ogg_int64_t offset_end, - int fuzz_margin); - -/** - * Seeks to before the first key frame before unit_target, in the range - * [offset_begin, offset_end]. - */ -ogg_int64_t -oggz_keyframe_seek_set(OGGZ * oggz, - ogg_int64_t unit_target, - ogg_int64_t offset_begin, - ogg_int64_t offset_end); - -#endif /* __OGGZ_SEEK_H__ */ diff --git a/media/liboggz/include/oggz/oggz_stream.h b/media/liboggz/include/oggz/oggz_stream.h deleted file mode 100644 index 778f0e307e4..00000000000 --- a/media/liboggz/include/oggz/oggz_stream.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2007 Annodex Association - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Annodex Association nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ASSOCIATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_STREAM_H__ -#define __OGGZ_STREAM_H__ - -/** \file - * Interfaces for querying Ogg streams - */ - -/** - * Determine the content type of the oggz stream referred to by \a serialno - * - * \param oggz An OGGZ handle - * \param serialno An ogg stream serialno - * \retval OGGZ_CONTENT_THEORA..OGGZ_CONTENT_UNKNOWN content successfully - * identified - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not refer to an existing - * stream - */ -OggzStreamContent oggz_stream_get_content (OGGZ * oggz, long serialno); - -/** - * Return human-readable string representation of content type of oggz stream - * referred to by \a serialno - * - * \param oggz An OGGZ handle - * \param serialno An ogg stream serialno - * \retval string the name of the content type - * \retval NULL \a oggz or \a serialno invalid - */ -const char * oggz_stream_get_content_type (OGGZ *oggz, long serialno); - -/** - * Determine the number of headers of the oggz stream referred to by - * \a serialno - * - * \param oggz An OGGZ handle - * \param serialno An ogg stream serialno - * \retval OGGZ_CONTENT_THEORA..OGGZ_CONTENT_UNKNOWN content successfully - * identified - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not refer to an existing - * stream - */ -int oggz_stream_get_numheaders (OGGZ * oggz, long serialno); - -#endif /* __OGGZ_STREAM_H__ */ diff --git a/media/liboggz/include/oggz/oggz_table.h b/media/liboggz/include/oggz/oggz_table.h deleted file mode 100644 index 1accd8c99e2..00000000000 --- a/media/liboggz/include/oggz/oggz_table.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_TABLE_H__ -#define __OGGZ_TABLE_H__ - -/** \file - * A lookup table. - * - * OggzTable is provided for convenience to allow the storage of - * serialno-specific data. - */ - -/** - * A table of key-value pairs. - */ -typedef void OggzTable; - -/** - * Instantiate a new OggzTable - * \returns A new OggzTable - * \retval NULL Could not allocate memory for table - */ -OggzTable * -oggz_table_new (void); - -/** - * Delete an OggzTable - * \param table An OggzTable - */ -void -oggz_table_delete (OggzTable * table); - -/** - * Insert an element into a table. If a previous value existed for this key, - * it is overwritten with the new data element. - * \param table An OggzTable - * \param key Key to access this data element - * \param data The new element to add - * \retval data If the element was successfully added - * \retval NULL If adding the element failed due to a realloc() error - */ -void * -oggz_table_insert (OggzTable * table, long key, void * data); - -/** - * Remove the element of an OggzTable indexed by a given key - * \param table An OggzTable - * \param key a key - * \retval 0 Success - * \retval -1 Not found - */ -int -oggz_table_remove (OggzTable * table, long key); - -/** - * Retrieve the element of an OggzTable indexed by a given key - * \param table An OggzTable - * \param key a key - * \returns The element indexed by \a key - * \retval NULL \a table is undefined, or no element is indexed by \a key - */ -void * -oggz_table_lookup (OggzTable * table, long key); - -/** - * Query the number of elements in an OggzTable - * \param table An OggzTable - * \returns the number of elements in \a table - */ -int -oggz_table_size (OggzTable * table); - -/** - * Retrieve the nth element of an OggzTable, and optionally its key - * \param table An OggzTable - * \param n An index into the \a table - * \param key Return pointer for key corresponding to nth data element - * of \a table. Ignored if NULL. - * \returns The nth data element of \a table - * \retval NULL \a table is undefined, or \a n is out of range - */ -void * -oggz_table_nth (OggzTable * table, int n, long * key); - -#endif /* __OGGZ_TABLE_H__ */ diff --git a/media/liboggz/include/oggz/oggz_write.h b/media/liboggz/include/oggz/oggz_write.h deleted file mode 100644 index 13ac71ecf96..00000000000 --- a/media/liboggz/include/oggz/oggz_write.h +++ /dev/null @@ -1,241 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_WRITE_H__ -#define __OGGZ_WRITE_H__ - -/** \file - * Interfaces for writing Ogg files and streams - */ - -/** \defgroup force_feed Writing by force feeding Oggz - * - * Force feeding involves synchronously: - * - Creating an \a ogg_packet structure - * - Adding it to the packet queue with oggz_write_feed() - * - Calling oggz_write() or oggz_write_output(), repeatedly as necessary, - * to generate the Ogg bitstream. - * - * This process is illustrated in the following diagram: - * - * \image html forcefeed.png - * \image latex forcefeed.eps "Force Feeding Oggz" width=10cm - * - * The following example code generates a stream of ten packets, each - * containing a single byte ('A', 'B', ... , 'J'): - * - * \include write-feed.c - */ - -/** \defgroup hungry Writing with OggzHungry callbacks - * - * You can add packets to the Oggz packet queue only when it is "hungry" - * by providing an OggzHungry callback. - * - * An OggzHungry callback will: - * - Create an \a ogg_packet structure - * - Add it to the packet queue with oggz_write_feed() - * - * Once you have set such a callback with oggz_write_set_hungry_callback(), - * simply call oggz_write() or oggz_write_output() repeatedly, and Oggz - * will call your callback to provide packets when it is hungry. - * - * This process is illustrated in the following diagram: - * - * \image html hungry.png - * \image latex hungry.eps "Using OggzHungry" width=10cm - * - * The following example code generates a stream of ten packets, each - * containing a single byte ('A', 'B', ... , 'J'): - * - * \include write-hungry.c - */ - -/** \defgroup write_api Oggz Write API - * - * Oggz maintains a packet queue, such that you can independently add - * packets to the queue and write an Ogg bitstream. - * There are two complementary methods for adding packets to the - * packet queue. - * - * - by \link force_feed force feeding Oggz \endlink - * - by using \link hungry OggzHungry \endlink callbacks - * - * As each packet is enqueued, its validity is checked against the framing - * constraints outlined in the \link basics Ogg basics \endlink section. - * If it does not pass these constraints, oggz_write_feed() will fail with - * an appropriate error code. - * - * \note - * - When writing, you can ensure that a packet starts on a new page - * by setting the \a flush parameter of oggz_write_feed() to - * \a OGGZ_FLUSH_BEFORE when enqueuing it. - * Similarly you can ensure that the last page a packet is written into - * won't contain any following packets by setting the \a flush parameter - * of oggz_write_feed() to \a OGGZ_FLUSH_AFTER. - * - The \a OGGZ_FLUSH_BEFORE and \a OGGZ_FLUSH_AFTER flags can be bitwise - * OR'd together to ensure that the packet will not share any pages with - * any other packets, either before or after. - * - * \{ - */ - -/** - * This is the signature of a callback which Oggz will call when \a oggz - * is \link hungry hungry \endlink. - * - * \param oggz The OGGZ handle - * \param empty A value of 1 indicates that the packet queue is currently - * empty. A value of 0 indicates that the packet queue is not empty. - * \param user_data A generic pointer you have provided earlier - * \retval 0 Continue - * \retval non-zero Instruct Oggz to stop. - */ -typedef int (*OggzWriteHungry) (OGGZ * oggz, int empty, void * user_data); - -/** - * Set a callback for Oggz to call when \a oggz - * is \link hungry hungry \endlink. - * - * \param oggz An OGGZ handle previously opened for writing - * \param hungry Your callback function - * \param only_when_empty When to call: a value of 0 indicates that - * Oggz should call \a hungry() after each and every packet is written; - * a value of 1 indicates that Oggz should call \a hungry() only when - * its packet queue is empty - * \param user_data Arbitrary data you wish to pass to your callback - * \retval 0 Success - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \note Passing a value of 0 for \a only_when_empty allows you to feed - * new packets into \a oggz's packet queue on the fly. - */ -int oggz_write_set_hungry_callback (OGGZ * oggz, - OggzWriteHungry hungry, - int only_when_empty, - void * user_data); -/** - * Add a packet to \a oggz's packet queue. - * \param oggz An OGGZ handle previously opened for writing - * \param op An ogg_packet with all fields filled in - * \param serialno Identify the logical bitstream in \a oggz to add the - * packet to - * \param flush Bitmask of OGGZ_FLUSH_BEFORE, OGGZ_FLUSH_AFTER - * \param guard A guard for nocopy, NULL otherwise - * \retval 0 Success - * \retval OGGZ_ERR_BAD_GUARD \a guard specified has non-zero initialization - * \retval OGGZ_ERR_BOS Packet would be bos packet of a new logical bitstream, - * but oggz has already written one or more non-bos packets in - * other logical bitstreams, - * and \a oggz is not flagged OGGZ_NONSTRICT - * \retval OGGZ_ERR_EOS The logical bitstream identified by \a serialno is - * already at eos, - * and \a oggz is not flagged OGGZ_NONSTRICT - * \retval OGGZ_ERR_BAD_BYTES \a op->bytes is invalid, - * and \a oggz is not flagged OGGZ_NONSTRICT - * \retval OGGZ_ERR_BAD_B_O_S \a op->b_o_s is invalid, - * and \a oggz is not flagged OGGZ_NONSTRICT - * \retval OGGZ_ERR_BAD_GRANULEPOS \a op->granulepos is less than that of - * an earlier packet within this logical bitstream, - * and \a oggz is not flagged OGGZ_NONSTRICT - * \retval OGGZ_ERR_BAD_PACKETNO \a op->packetno is less than that of an - * earlier packet within this logical bitstream, - * and \a oggz is not flagged OGGZ_NONSTRICT - * \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing - * logical bitstream in \a oggz, - * and \a oggz is not flagged OGGZ_NONSTRICT - * or \a serialno is equal to -1, or \a serialno does not fit in - * 32 bits, ie. within the range (-(2^31), (2^31)-1) - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_OUT_OF_MEMORY Unable to allocate memory to queue packet - * - * \note If \a op->b_o_s is initialized to \a -1 before calling - * oggz_write_feed(), Oggz will fill it in with the appropriate - * value; ie. 1 for the first packet of a new stream, and 0 otherwise. - */ -int oggz_write_feed (OGGZ * oggz, ogg_packet * op, long serialno, int flush, - int * guard); - -/** - * Output data from an OGGZ handle. Oggz will call your write callback - * as needed. - * - * \param oggz An OGGZ handle previously opened for writing - * \param buf A memory buffer - * \param n A count of bytes to output - * \retval "> 0" The number of bytes successfully output - * \retval 0 End of stream - * \retval OGGZ_ERR_RECURSIVE_WRITE Attempt to initiate writing from - * within an OggzHungry callback - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_STOP_OK Writing was stopped by an OggzHungry callback - * returning OGGZ_STOP_OK - * \retval OGGZ_ERR_STOP_ERR Reading was stopped by an OggzHungry callback - * returning OGGZ_STOP_ERR - */ -long oggz_write_output (OGGZ * oggz, unsigned char * buf, long n); - -/** - * Write n bytes from an OGGZ handle. Oggz will call your write callback - * as needed. - * - * \param oggz An OGGZ handle previously opened for writing - * \param n A count of bytes to be written - * \retval "> 0" The number of bytes successfully output - * \retval 0 End of stream - * \retval OGGZ_ERR_RECURSIVE_WRITE Attempt to initiate writing from - * within an OggzHungry callback - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - * \retval OGGZ_ERR_STOP_OK Writing was stopped by an OggzHungry callback - * returning OGGZ_STOP_OK - * \retval OGGZ_ERR_STOP_ERR Reading was stopped by an OggzHungry callback - * returning OGGZ_STOP_ERR - */ -long oggz_write (OGGZ * oggz, long n); - -/** - * Query the number of bytes in the next page to be written. - * - * \param oggz An OGGZ handle previously opened for writing - * \retval ">= 0" The number of bytes in the next page - * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ - * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ - */ -long oggz_write_get_next_page_size (OGGZ * oggz); - -/** \} - */ - -#endif /* __OGGZ_WRITE_H__ */ diff --git a/media/liboggz/key_frame_seek.patch b/media/liboggz/key_frame_seek.patch deleted file mode 100644 index 28e9bcb45b2..00000000000 --- a/media/liboggz/key_frame_seek.patch +++ /dev/null @@ -1,161 +0,0 @@ -diff --git a/media/liboggz/include/oggz/oggz_seek.h b/media/liboggz/include/oggz/oggz_seek.h ---- a/media/liboggz/include/oggz/oggz_seek.h -+++ b/media/liboggz/include/oggz/oggz_seek.h -@@ -489,9 +489,22 @@ int oggz_set_data_start (OGGZ * oggz, og - * \retval -1 on failure (unit_target is not within range) - */ - ogg_int64_t - oggz_bounded_seek_set (OGGZ * oggz, - ogg_int64_t unit_target, - ogg_int64_t offset_begin, - ogg_int64_t offset_end); - -+/** -+ * Seeks to the first key frame before unit_target, in the range -+ * [offset_begin, offset_end]. serial_nos contains an array of size serial_nos -+ * of serialnos of the streams which need to be seeked. -+ */ -+ogg_int64_t -+oggz_keyframe_seek_set(OGGZ * oggz, -+ long* serial_nos, -+ int num_serialno, -+ ogg_int64_t unit_target, -+ ogg_int64_t offset_begin, -+ ogg_int64_t offset_end); -+ - #endif /* __OGGZ_SEEK_H__ */ -diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c ---- a/media/liboggz/src/liboggz/oggz_seek.c -+++ b/media/liboggz/src/liboggz/oggz_seek.c -@@ -931,8 +931,131 @@ oggz_seek_byorder (OGGZ * oggz, void * t - - long - oggz_seek_packets (OGGZ * oggz, long serialno, long packets, int whence) - { - return OGGZ_ERR_DISABLED; - } - - #endif -+ -+// Returns 1 if any of the elements of array |a|, which is of length |n|, -+// contain the value |val|. Otherwise returns 0. -+static int -+is_any(ogg_int64_t* a, int n, ogg_int64_t val) -+{ -+ int i; -+ for (i=0; ioffset; -+ -+ key_frames = oggz_malloc(sizeof(ogg_int64_t) * num_serialno); -+ if (!key_frames) { -+ // Malloc failure. We can still exit with the seek finishing at a non -+ // key frame. -+ return unit_at; -+ } -+ memset(key_frames, -1, sizeof(ogg_int64_t) * num_serialno); -+ -+ // Find the key frame offset for every stream. -+ og = &oggz->current_page; -+ while (is_any(key_frames, num_serialno, -1)) { -+ do { -+ offset_next = oggz_get_prev_start_page (oggz, og, &granule_at, &serialno); -+ if (offset_next <= 0 || granule_at == 0) { -+ // At beginning of file, or some other failure. Return with -+ // non-key frame seek if possible. -+ oggz_free(key_frames); -+ offset_at = oggz_reset (oggz, offset_at, unit_at, SEEK_SET); -+ return (offset_at == -1) ? -1 : unit_at; -+ } -+ } while (granule_at < 0); -+ -+ idx = find(serial_nos, num_serialno, serialno); -+ if (idx == -1 || key_frames[idx] != -1) -+ continue; -+ -+ granule_shift = oggz_get_granuleshift(oggz, serialno); -+ key_granule_at = (granule_at >> granule_shift) << granule_shift; -+ key_unit_at = oggz_get_unit(oggz, serialno, key_granule_at); -+ -+ if (key_unit_at < unit_target) -+ key_frames[idx] = key_unit_at; -+ } -+ -+ // Seek to 100ms before the earliest of all the streams' key frames. -+ // This is so that after the seek, the decoder will defintately return frames -+ // at or before get the key frame. Without this, some decoders will return -+ // frames which start after the specified time - after the key frame. -+ key_unit_at = minimum(key_frames, num_serialno); -+ unit_at = oggz_bounded_seek_set(oggz, -+ MAX((key_unit_at - 100), 0), -+ offset_begin, -+ offset_end); -+ oggz_free(key_frames); -+ -+ return unit_at; -+} diff --git a/media/liboggz/offset_next.patch b/media/liboggz/offset_next.patch deleted file mode 100644 index c5df41a9b35..00000000000 --- a/media/liboggz/offset_next.patch +++ /dev/null @@ -1,168 +0,0 @@ -diff --git a/media/liboggz/src/liboggz/oggz_read.c b/media/liboggz/src/liboggz/oggz_read.c ---- a/media/liboggz/src/liboggz/oggz_read.c -+++ b/media/liboggz/src/liboggz/oggz_read.c -@@ -176,43 +176,46 @@ oggz_set_read_page (OGGZ * oggz, long se - * returns >= 0 if found; return value is offset of page start - * returns -1 on error - * returns -2 if EOF was encountered - */ - static oggz_off_t - oggz_read_get_next_page (OGGZ * oggz, ogg_page * og) - { - OggzReader * reader = &oggz->x.reader; -- long more; -+ long more = 0, page_offset = 0; - int found = 0; - - /* Increment oggz->offset by length of the last page processed */ - oggz->offset += reader->current_page_bytes; - - do { - more = ogg_sync_pageseek (&reader->ogg_sync, og); - - if (more == 0) { - /* No page available */ -+ reader->current_page_bytes = 0; - return -2; - } else if (more < 0) { - #ifdef DEBUG_VERBOSE - printf ("get_next_page: skipped %ld bytes\n", -more); - #endif -- oggz->offset += (-more); -+ page_offset += (-more); - } else { - #ifdef DEBUG_VERBOSE - printf ("get_next_page: page has %ld bytes\n", more); - #endif - reader->current_page_bytes = more; - found = 1; - } - - } while (!found); - -+ oggz->offset += page_offset; -+ - return oggz->offset; - } - - typedef struct { - ogg_packet packet; - ogg_int64_t calced_granulepos; - oggz_stream_t * stream; - OggzReader * reader; -diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c ---- a/media/liboggz/src/liboggz/oggz_seek.c -+++ b/media/liboggz/src/liboggz/oggz_seek.c -@@ -115,16 +115,18 @@ oggz_seek_raw (OGGZ * oggz, oggz_off_t o - offset_at = oggz_io_tell (oggz); - - oggz->offset = offset_at; - - ogg_sync_reset (&reader->ogg_sync); - - oggz_vector_foreach(oggz->streams, oggz_seek_reset_stream); - -+ reader->current_page_bytes = 0; -+ - return offset_at; - } - - static int - oggz_stream_reset (void * data) - { - oggz_stream_t * stream = (oggz_stream_t *) data; - -@@ -196,74 +198,70 @@ oggz_purge (OGGZ * oggz) - * returns -2 if EOF was encountered - */ - static oggz_off_t - oggz_get_next_page (OGGZ * oggz, ogg_page * og) - { - OggzReader * reader = &oggz->x.reader; - char * buffer; - long bytes = 0, more; -- oggz_off_t page_offset = 0, ret; -+ oggz_off_t page_offset = 0; - int found = 0; - -+ /* Increment oggz->offset by length of the last page processed */ -+ oggz->offset += reader->current_page_bytes; -+ - do { - more = ogg_sync_pageseek (&reader->ogg_sync, og); - - if (more == 0) { -- page_offset = 0; -- - buffer = ogg_sync_buffer (&reader->ogg_sync, CHUNKSIZE); - if ((bytes = (long) oggz_io_read (oggz, buffer, CHUNKSIZE)) == 0) { -- if (oggz->file && feof (oggz->file)) { -+ if (oggz->file && feof (oggz->file)) { - #ifdef DEBUG_VERBOSE -- printf ("get_next_page: feof (oggz->file), returning -2\n"); -+ printf ("get_next_page: feof (oggz->file), returning -2\n"); - #endif -- clearerr (oggz->file); -- return -2; -- } -+ clearerr (oggz->file); -+ reader->current_page_bytes = 0; -+ return -2; -+ } - } - if (bytes == OGGZ_ERR_SYSTEM) { -- /*oggz_set_error (oggz, OGGZ_ERR_SYSTEM);*/ -- return -1; -+ reader->current_page_bytes = 0; -+ return -1; - } - - if (bytes == 0) { - #ifdef DEBUG_VERBOSE -- printf ("get_next_page: bytes == 0, returning -2\n"); -+ printf ("get_next_page: bytes == 0, returning -2\n"); - #endif -- return -2; -+ reader->current_page_bytes = 0; -+ return -2; - } - - ogg_sync_wrote(&reader->ogg_sync, bytes); - - } else if (more < 0) { - #ifdef DEBUG_VERBOSE - printf ("get_next_page: skipped %ld bytes\n", -more); - #endif -- page_offset -= more; -+ page_offset += (-more); - } else { - #ifdef DEBUG_VERBOSE - printf ("get_next_page: page has %ld bytes\n", more); - #endif -+ reader->current_page_bytes = more; - found = 1; - } - - } while (!found); - -- /* Calculate the byte offset of the page which was found */ -- if (bytes > 0) { -- oggz->offset = oggz_tell_raw (oggz) - bytes + page_offset; -- } else { -- /* didn't need to do any reading -- accumulate the page_offset */ -- oggz->offset += page_offset; -- } -- -- ret = oggz->offset + more; -+ oggz->offset += page_offset; - -- return ret; -+ return oggz->offset; - } - - static oggz_off_t - oggz_get_next_start_page (OGGZ * oggz, ogg_page * og) - { - oggz_off_t page_offset; - int found = 0; - diff --git a/media/liboggz/oggz_os2.patch b/media/liboggz/oggz_os2.patch deleted file mode 100644 index d69a36c6ef3..00000000000 --- a/media/liboggz/oggz_os2.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/media/liboggz/include/oggz/oggz_off_t_generated.h b/media/liboggz/include/oggz/oggz_off_t_generated.h ---- a/media/liboggz/include/oggz/oggz_off_t_generated.h -+++ b/media/liboggz/include/oggz/oggz_off_t_generated.h -@@ -54,17 +54,17 @@ -
-    echo "gcc -E oggz.h | grep oggz_off_t
-  
- * - */ - - #include - --#if defined(__APPLE__) || defined(SOLARIS) -+#if defined(__APPLE__) || defined(SOLARIS) || defined(OS2) - typedef off_t oggz_off_t; - #else - typedef loff_t oggz_off_t; - #endif - - #define PRI_OGGZ_OFF_T "PRId64" - - #endif /* __OGGZ_OFF_T_GENERATED__ */ diff --git a/media/liboggz/seek.patch b/media/liboggz/seek.patch deleted file mode 100644 index 997d412bd0f..00000000000 --- a/media/liboggz/seek.patch +++ /dev/null @@ -1,62 +0,0 @@ -diff --git a/mozilla/media/liboggz/src/liboggz/oggz_seek.c b/mozilla/media/liboggz/src/liboggz/oggz_seek.c -index f933d4d..23ffb57 100644 ---- a/mozilla/media/liboggz/src/liboggz/oggz_seek.c -+++ b/mozilla/media/liboggz/src/liboggz/oggz_seek.c -@@ -486,16 +486,18 @@ oggz_scan_for_page (OGGZ * oggz, ogg_page * og, ogg_int64_t unit_target, - serialno = ogg_page_serialno (og); - granule_at = ogg_page_granulepos (og); - unit_at = oggz_get_unit (oggz, serialno, granule_at); - - break; - #else - do { - offset_at = oggz_get_prev_start_page(oggz, og, &granule_at, &serialno); -+ if (offset_at == -1) -+ return -1; - unit_at = oggz_get_unit(oggz, serialno, granule_at); - } while (unit_at > unit_target); - return offset_at; - #endif - } else if (unit_at == unit_target) { - #ifdef DEBUG - printf (" scan: (%lld) == (%lld)\n", unit_at, unit_target); - #endif -@@ -552,16 +554,19 @@ oggz_seek_guess (ogg_int64_t unit_at, ogg_int64_t unit_target, - printf ("oggz_seek_guess: unit_end <= unit_begin (ERROR)\n"); - #endif - offset_guess = -1; - } else { - offset_guess = guess (unit_at, unit_target, unit_begin, unit_end, - offset_begin, offset_end); - } - -+ if (offset_end != -1 && guess >= offset_end) -+ offset_guess = offset_begin + (offset_end - offset_begin)/2; -+ - #ifdef DEBUG - printf ("oggz_seek_guess: guessed %" PRI_OGGZ_OFF_T "d\n", offset_guess); - #endif - - return offset_guess; - } - - static oggz_off_t -@@ -759,16 +764,18 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target) - } else { - break; - } - } - - found: - do { - offset_at = oggz_get_prev_start_page (oggz, og, &granule_at, &serialno); -+ if (offset_at == -1) -+ break; - unit_at = oggz_get_unit (oggz, serialno, granule_at); - } while (unit_at > unit_target); - - if (offset_at < 0) { - oggz_reset (oggz, offset_orig, -1, SEEK_SET); - return -1; - } - diff --git a/media/liboggz/src/Makefile.in b/media/liboggz/src/Makefile.in deleted file mode 100644 index 30c3197ce87..00000000000 --- a/media/liboggz/src/Makefile.in +++ /dev/null @@ -1,47 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = oggz -DIRS = liboggz - -include $(topsrcdir)/config/rules.mk diff --git a/media/liboggz/src/liboggz/Makefile.in b/media/liboggz/src/liboggz/Makefile.in deleted file mode 100644 index 85558bdeaa5..00000000000 --- a/media/liboggz/src/liboggz/Makefile.in +++ /dev/null @@ -1,66 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla code. -# -# The Initial Developer of the Original Code is the Mozilla Corporation. -# Portions created by the Initial Developer are Copyright (C) 2007 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Double -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = oggz -LIBRARY_NAME = oggz -FORCE_STATIC_LIB= 1 - -CSRCS = \ - dirac.c \ - metric_internal.c \ - oggz.c \ - oggz_auto.c \ - oggz_comments.c \ - oggz_dlist.c \ - oggz_io.c \ - oggz_read.c \ - oggz_seek.c \ - oggz_stream.c \ - oggz_table.c \ - oggz_vector.c \ - oggz_write.c \ - $(NULL) - -include $(topsrcdir)/config/rules.mk - -LOCAL_INCLUDES += -I$(srcdir)/../../include/oggz diff --git a/media/liboggz/src/liboggz/dirac.c b/media/liboggz/src/liboggz/dirac.c deleted file mode 100644 index eb616f6b751..00000000000 --- a/media/liboggz/src/liboggz/dirac.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - dirac.c -*/ - -#include "config.h" - -#ifdef HAVE_STDINT_H -#include -#endif - -#include "dirac.h" - - -typedef struct -dirac_bs_s -{ - uint8_t *p_start; - uint8_t *p; - uint8_t *p_end; - - int i_left; /* i_count number of available bits */ -} dirac_bs_t; - -static inline void -dirac_bs_init( dirac_bs_t *s, void *p_data, int i_data ) -{ - s->p_start = p_data; - s->p = p_data; - s->p_end = s->p + i_data; - s->i_left = 8; -} - -static inline ogg_uint32_t -dirac_bs_read( dirac_bs_t *s, int i_count ) -{ - static ogg_uint32_t i_mask[33] = - { 0x00, - 0x01, 0x03, 0x07, 0x0f, - 0x1f, 0x3f, 0x7f, 0xff, - 0x1ff, 0x3ff, 0x7ff, 0xfff, - 0x1fff, 0x3fff, 0x7fff, 0xffff, - 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff, - 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff, - 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff, - 0x1fffffff,0x3fffffff,0x7fffffff,0xffffffff}; - int i_shr; - ogg_uint32_t i_result = 0; - - while( i_count > 0 ) - { - if( s->p >= s->p_end ) - { - break; - } - - if( ( i_shr = s->i_left - i_count ) >= 0 ) - { - /* more in the buffer than requested */ - i_result |= ( *s->p >> i_shr )&i_mask[i_count]; - s->i_left -= i_count; - if( s->i_left == 0 ) - { - s->p++; - s->i_left = 8; - } - return( i_result ); - } - else - { - /* less in the buffer than requested */ - i_result |= (*s->p&i_mask[s->i_left]) << -i_shr; - i_count -= s->i_left; - s->p++; - s->i_left = 8; - } - } - - return( i_result ); -} - -static inline void -dirac_bs_skip( dirac_bs_t *s, int i_count ) -{ - s->i_left -= i_count; - - while( s->i_left <= 0 ) - { - s->p++; - s->i_left += 8; - } -} - -static ogg_uint32_t -dirac_uint ( dirac_bs_t *p_bs ) -{ - ogg_uint32_t count = 0, value = 0; - while( !dirac_bs_read ( p_bs, 1 ) ) { - count++; - value <<= 1; - value |= dirac_bs_read ( p_bs, 1 ); - } - - return (1<major_version = dirac_uint( &bs ); /* major_version */ - info->minor_version = dirac_uint( &bs ); /* minor_version */ - info->profile = dirac_uint( &bs ); /* profile */ - info->level = dirac_uint( &bs ); /* level */ - info->video_format = video_format = dirac_uint( &bs ); /* index */ - - if (video_format >= (sizeof(dirac_fsize_tbl) / sizeof(dirac_fsize_tbl[0]))) { - return -1; - } - - info->width = dirac_fsize_tbl[video_format].width; - info->height = dirac_fsize_tbl[video_format].height; - if (dirac_bool( &bs )) { - info->width = dirac_uint( &bs ); /* frame_width */ - info->height = dirac_uint( &bs ); /* frame_height */ - } - - if (dirac_bool( &bs )) { - info->chroma_format = dirac_uint( &bs ); /* chroma_format */ - } - - if (dirac_bool( &bs )) { /* custom_scan_format_flag */ - int scan_format = dirac_uint( &bs ); /* scan_format */ - if (scan_format < 2) { - info->interlaced = scan_format; - } else { /* other scan_format values are reserved */ - info->interlaced = 0; - } - } else { /* no custom scan_format, use the preset value */ - info->interlaced = dirac_source_sampling[video_format]; - } - /* field order is set by video_format and cannot be custom */ - info->top_field_first = dirac_top_field_first[video_format]; - - info->fps_numerator = dirac_frate_tbl[dirac_vidfmt_frate[video_format]].fps_numerator; - info->fps_denominator = dirac_frate_tbl[dirac_vidfmt_frate[video_format]].fps_denominator; - if (dirac_bool( &bs )) { - ogg_uint32_t frame_rate_index = dirac_uint( &bs ); - info->fps_numerator = dirac_frate_tbl[frame_rate_index].fps_numerator; - info->fps_denominator = dirac_frate_tbl[frame_rate_index].fps_denominator; - if (frame_rate_index == 0) { - info->fps_numerator = dirac_uint( &bs ); - info->fps_denominator = dirac_uint( &bs ); - } - } - - return 0; -} diff --git a/media/liboggz/src/liboggz/dirac.h b/media/liboggz/src/liboggz/dirac.h deleted file mode 100644 index 6732d27a249..00000000000 --- a/media/liboggz/src/liboggz/dirac.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * dirac.h - */ - -#ifndef _DIRAC_H -#define _DIRAC_H - -#include - -typedef struct { - ogg_uint32_t major_version; - ogg_uint32_t minor_version; - ogg_uint32_t profile; - ogg_uint32_t level; - ogg_uint32_t chroma_format; - ogg_uint32_t video_format; - - ogg_uint32_t width; - ogg_uint32_t height; - ogg_uint32_t fps_numerator; - ogg_uint32_t fps_denominator; - - ogg_uint32_t interlaced; - ogg_uint32_t top_field_first; -} dirac_info; - -/** - * \return -1 Error: parse failure, invalid size index - * \return 0 Success - */ -extern int dirac_parse_info (dirac_info *info, unsigned char *data, long len); - -#endif diff --git a/media/liboggz/src/liboggz/metric_internal.c b/media/liboggz/src/liboggz/metric_internal.c deleted file mode 100644 index 55ff8c41429..00000000000 --- a/media/liboggz/src/liboggz/metric_internal.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#include "oggz_private.h" - -#include "oggz/oggz_stream.h" - -static ogg_int64_t -oggz_metric_dirac (OGGZ * oggz, long serialno, - ogg_int64_t granulepos, void * user_data) -{ - oggz_stream_t * stream; - ogg_int64_t iframe, pframe; - ogg_uint32_t pt; - ogg_uint16_t dist; - ogg_uint16_t delay; - ogg_int64_t dt; - ogg_int64_t units; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return -1; - - iframe = granulepos >> stream->granuleshift; - pframe = granulepos - (iframe << stream->granuleshift); - pt = (iframe + pframe) >> 9; - delay = pframe >> 9; - dt = (ogg_int64_t)pt - delay; - - units = dt * stream->granulerate_d / stream->granulerate_n; - -#ifdef DEBUG - printf ("oggz_..._granuleshift: serialno %010lu Got frame or field %lld (%lld + %lld): %lld units\n", - serialno, dt, iframe, pframe, units); -#endif - - return units; -} - -static ogg_int64_t -oggz_metric_default_granuleshift (OGGZ * oggz, long serialno, - ogg_int64_t granulepos, void * user_data) -{ - oggz_stream_t * stream; - ogg_int64_t iframe, pframe; - ogg_int64_t units; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return -1; - - iframe = granulepos >> stream->granuleshift; - pframe = granulepos - (iframe << stream->granuleshift); - granulepos = iframe + pframe; - if (granulepos > 0) granulepos -= stream->first_granule; - - units = granulepos * stream->granulerate_d / stream->granulerate_n; - -#ifdef DEBUG - printf ("oggz_..._granuleshift: serialno %010lu Got frame %lld (%lld + %lld): %lld units\n", - serialno, granulepos, iframe, pframe, units); -#endif - - return units; -} - -static ogg_int64_t -oggz_metric_default_linear (OGGZ * oggz, long serialno, ogg_int64_t granulepos, - void * user_data) -{ - oggz_stream_t * stream; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return -1; - - return (stream->granulerate_d * granulepos / stream->granulerate_n); -} - -static int -oggz_metric_update (OGGZ * oggz, long serialno) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - /* we divide by the granulerate, ie. mult by gr_d/gr_n, so ensure - * numerator is non-zero */ - if (stream->granulerate_n == 0) { - stream->granulerate_n= 1; - stream->granulerate_d = 0; - } - - if (stream->granuleshift == 0) { - return oggz_set_metric_internal (oggz, serialno, - oggz_metric_default_linear, - NULL, 1); - } else if (oggz_stream_get_content (oggz, serialno) == OGGZ_CONTENT_DIRAC) { - return oggz_set_metric_internal (oggz, serialno, - oggz_metric_dirac, - NULL, 1); - } else { - return oggz_set_metric_internal (oggz, serialno, - oggz_metric_default_granuleshift, - NULL, 1); - } -} - -int -oggz_set_granuleshift (OGGZ * oggz, long serialno, int granuleshift) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - stream->granuleshift = granuleshift; - - return oggz_metric_update (oggz, serialno); -} - -int -oggz_get_granuleshift (OGGZ * oggz, long serialno) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - return stream->granuleshift; -} - -int -oggz_set_granulerate (OGGZ * oggz, long serialno, - ogg_int64_t granule_rate_numerator, - ogg_int64_t granule_rate_denominator) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - stream->granulerate_n = granule_rate_numerator; - stream->granulerate_d = granule_rate_denominator; - - return oggz_metric_update (oggz, serialno); -} - -int -oggz_get_granulerate (OGGZ * oggz, long serialno, - ogg_int64_t * granulerate_n, - ogg_int64_t * granulerate_d) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - *granulerate_n = stream->granulerate_n; - *granulerate_d = stream->granulerate_d / OGGZ_AUTO_MULT; - - return 0; -} - -int -oggz_set_first_granule (OGGZ * oggz, long serialno, - ogg_int64_t first_granule) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - stream->first_granule = first_granule; - - return oggz_metric_update (oggz, serialno); -} - -/** DEPRECATED **/ -int -oggz_set_metric_linear (OGGZ * oggz, long serialno, - ogg_int64_t granule_rate_numerator, - ogg_int64_t granule_rate_denominator) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - stream->granulerate_n = granule_rate_numerator; - stream->granulerate_d = granule_rate_denominator; - stream->granuleshift = 0; - - return oggz_metric_update (oggz, serialno); -} - diff --git a/media/liboggz/src/liboggz/oggz.c b/media/liboggz/src/liboggz/oggz.c deleted file mode 100644 index cea51d4a2bb..00000000000 --- a/media/liboggz/src/liboggz/oggz.c +++ /dev/null @@ -1,670 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#include -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include -#include -#include -#include - -#include - -#include "oggz_compat.h" -#include "oggz_private.h" -#include "oggz_vector.h" - -/* Definitions for oggz_run() */ -long oggz_read (OGGZ * oggz, long n); -long oggz_write (OGGZ * oggz, long n); - -/*#define DEBUG*/ - -static int -oggz_flags_disabled (int flags) -{ - if (flags & OGGZ_WRITE) { - if (!OGGZ_CONFIG_WRITE) return OGGZ_ERR_DISABLED; - } else { - if (!OGGZ_CONFIG_READ) return OGGZ_ERR_DISABLED; - } - - return 0; -} - -OGGZ * -oggz_new (int flags) -{ - OGGZ * oggz; - - if (oggz_flags_disabled (flags)) return NULL; - - oggz = (OGGZ *) oggz_malloc (sizeof (OGGZ)); - if (oggz == NULL) return NULL; - - oggz->flags = flags; - oggz->file = NULL; - oggz->io = NULL; - - oggz->offset = 0; - oggz->offset_data_begin = 0; - - oggz->run_blocksize = 1024; - oggz->cb_next = 0; - - oggz->streams = oggz_vector_new (); - if (oggz->streams == NULL) { - goto err_oggz_new; - } - - oggz->all_at_eos = 0; - - oggz->metric = NULL; - oggz->metric_user_data = NULL; - oggz->metric_internal = 0; - - oggz->order = NULL; - oggz->order_user_data = NULL; - - oggz->packet_buffer = oggz_dlist_new (); - if (oggz->packet_buffer == NULL) { - goto err_streams_new; - } - - if (OGGZ_CONFIG_WRITE && (oggz->flags & OGGZ_WRITE)) { - if (oggz_write_init (oggz) == NULL) - goto err_packet_buffer_new; - } else if (OGGZ_CONFIG_READ) { - oggz_read_init (oggz); - } - - return oggz; - -err_packet_buffer_new: - oggz_free (oggz->packet_buffer); -err_streams_new: - oggz_free (oggz->streams); -err_oggz_new: - oggz_free (oggz); - return NULL; -} - -OGGZ * -oggz_open (char * filename, int flags) -{ - OGGZ * oggz = NULL; - FILE * file = NULL; - - if (oggz_flags_disabled (flags)) return NULL; - - if (flags & OGGZ_WRITE) { - file = fopen (filename, "wb"); - } else { - file = fopen (filename, "rb"); - } - if (file == NULL) return NULL; - - if ((oggz = oggz_new (flags)) == NULL) { - fclose (file); - return NULL; - } - - oggz->file = file; - - return oggz; -} - -OGGZ * -oggz_open_stdio (FILE * file, int flags) -{ - OGGZ * oggz = NULL; - - if (oggz_flags_disabled (flags)) return NULL; - - if ((oggz = oggz_new (flags)) == NULL) - return NULL; - - oggz->file = file; - - return oggz; -} - -int -oggz_flush (OGGZ * oggz) -{ - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (OGGZ_CONFIG_WRITE && (oggz->flags & OGGZ_WRITE)) { - oggz_write_flush (oggz); - } - - return oggz_io_flush (oggz); -} - -static int -oggz_stream_clear (void * data) -{ - oggz_stream_t * stream = (oggz_stream_t *) data; - - oggz_comments_free (stream); - - if (stream->ogg_stream.serialno != -1) - ogg_stream_clear (&stream->ogg_stream); - - if (stream->metric_internal) - oggz_free (stream->metric_user_data); - - if (stream->calculate_data != NULL) - oggz_free (stream->calculate_data); - - oggz_free (stream); - - return 0; -} - -int -oggz_close (OGGZ * oggz) -{ - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (OGGZ_CONFIG_WRITE && (oggz->flags & OGGZ_WRITE)) { - oggz_write_close (oggz); - } else if (OGGZ_CONFIG_READ) { - oggz_read_close (oggz); - } - - oggz_vector_foreach (oggz->streams, oggz_stream_clear); - oggz_vector_delete (oggz->streams); - - oggz_dlist_deliter(oggz->packet_buffer, oggz_read_free_pbuffers); - oggz_dlist_delete(oggz->packet_buffer); - - if (oggz->metric_internal) - oggz_free (oggz->metric_user_data); - - if (oggz->file != NULL) { - if (fclose (oggz->file) == EOF) { - return OGGZ_ERR_SYSTEM; - } - } - - if (oggz->io != NULL) { - oggz_io_flush (oggz); - oggz_free (oggz->io); - } - - oggz_free (oggz); - - return 0; -} - -oggz_off_t -oggz_tell (OGGZ * oggz) -{ - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - return oggz->offset; -} - -ogg_int64_t -oggz_tell_units (OGGZ * oggz) -{ - OggzReader * reader; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (oggz->flags & OGGZ_WRITE) { - return OGGZ_ERR_INVALID; - } - - reader = &oggz->x.reader; - - if (OGGZ_CONFIG_READ) { - return reader->current_unit; - } else { - return OGGZ_ERR_DISABLED; - } -} - -ogg_int64_t -oggz_tell_granulepos (OGGZ * oggz) -{ - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (oggz->flags & OGGZ_WRITE) { - return OGGZ_ERR_INVALID; - } - - if (OGGZ_CONFIG_READ) { - return oggz->x.reader.current_granulepos; - } else { - return OGGZ_ERR_DISABLED; - } -} - -long -oggz_run (OGGZ * oggz) -{ - long n = OGGZ_ERR_DISABLED; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (OGGZ_CONFIG_WRITE && (oggz->flags & OGGZ_WRITE)) { - while ((n = oggz_write (oggz, oggz->run_blocksize)) > 0); - } else if (OGGZ_CONFIG_READ) { - while ((n = oggz_read (oggz, oggz->run_blocksize)) > 0); - } - - return n; -} - -int -oggz_run_set_blocksize (OGGZ * oggz, long blocksize) -{ - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (blocksize <= 0) return OGGZ_ERR_INVALID; - - oggz->run_blocksize = blocksize; - - return 0; -} - -/******** oggz_stream management ********/ - -static int -oggz_find_stream (void * data, long serialno) -{ - oggz_stream_t * stream = (oggz_stream_t *) data; - - return (stream->ogg_stream.serialno == serialno); -} - -oggz_stream_t * -oggz_get_stream (OGGZ * oggz, long serialno) -{ - if (serialno == -1) return NULL; - - return oggz_vector_find_with (oggz->streams, oggz_find_stream, serialno); -} - -oggz_stream_t * -oggz_add_stream (OGGZ * oggz, long serialno) -{ - oggz_stream_t * stream; - - stream = oggz_malloc (sizeof (oggz_stream_t)); - if (stream == NULL) return NULL; - - ogg_stream_init (&stream->ogg_stream, (int)serialno); - - if (oggz_comments_init (stream) == -1) { - oggz_free (stream); - return NULL; - } - - stream->content = OGGZ_CONTENT_UNKNOWN; - stream->numheaders = 3; /* Default to 3 headers for Ogg logical bitstreams */ - stream->preroll = 0; - stream->granulerate_n = 1; - stream->granulerate_d = 1; - stream->first_granule = 0; - stream->basegranule = 0; - stream->granuleshift = 0; - - stream->delivered_non_b_o_s = 0; - stream->b_o_s = 1; - stream->e_o_s = 0; - stream->granulepos = 0; - stream->packetno = -1; /* will be incremented on first read or write */ - - stream->metric = NULL; - stream->metric_user_data = NULL; - stream->metric_internal = 0; - stream->order = NULL; - stream->order_user_data = NULL; - stream->read_packet = NULL; - stream->read_user_data = NULL; - stream->read_page = NULL; - stream->read_page_user_data = NULL; - - stream->calculate_data = NULL; - - oggz_vector_insert_p (oggz->streams, stream); - - return stream; -} - -int -oggz_get_bos (OGGZ * oggz, long serialno) -{ - oggz_stream_t * stream; - int i, size; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (serialno == -1) { - size = oggz_vector_size (oggz->streams); - for (i = 0; i < size; i++) { - stream = (oggz_stream_t *)oggz_vector_nth_p (oggz->streams, i); -#if 1 - /* If this stream has delivered a non bos packet, return FALSE */ - if (stream->delivered_non_b_o_s) return 0; -#else - /* If this stream has delivered its bos packet, return FALSE */ - if (!stream->b_o_s) return 0; -#endif - } - return 1; - } else { - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) - return OGGZ_ERR_BAD_SERIALNO; - - return stream->b_o_s; - } -} - -int -oggz_get_eos (OGGZ * oggz, long serialno) -{ - oggz_stream_t * stream; - int i, size; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (serialno == -1) { - size = oggz_vector_size (oggz->streams); - for (i = 0; i < size; i++) { - stream = (oggz_stream_t *)oggz_vector_nth_p (oggz->streams, i); - if (!stream->e_o_s) return 0; - } - return 1; - } else { - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) - return OGGZ_ERR_BAD_SERIALNO; - - return stream->e_o_s; - } -} - -int -oggz_set_eos (OGGZ * oggz, long serialno) -{ - oggz_stream_t * stream; - int i, size; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (serialno == -1) { - size = oggz_vector_size (oggz->streams); - for (i = 0; i < size; i++) { - stream = (oggz_stream_t *) oggz_vector_nth_p (oggz->streams, i); - stream->e_o_s = 1; - } - oggz->all_at_eos = 1; - } else { - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) - return OGGZ_ERR_BAD_SERIALNO; - - stream->e_o_s = 1; - - if (oggz_get_eos (oggz, -1)) - oggz->all_at_eos = 1; - } - - return 0; -} - -int -oggz_get_numtracks (OGGZ * oggz) -{ - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - return oggz_vector_size (oggz->streams); -} - -/* Generate a pseudorandom serialno on request, ensuring that the number - * selected is not -1 or the serialno of an existing logical bitstream. - * NB. This inlines a simple linear congruential generator to avoid problems - * of portability of rand() vs. the POSIX random()/initstate()/getstate(), and - * in the case of rand() in order to avoid interfering with the random number - * sequence. - * Adapated from a patch by Erik de Castro Lopo, July 2007. - */ -long -oggz_serialno_new (OGGZ * oggz) -{ - /* Ensure that the returned value is within the range of an int, so that - * it passes cleanly through ogg_stream_init(). In any case, the size of - * a serialno in the Ogg page header is 32 bits; it should never have been - * declared a long in ogg.h's ogg_packet in the first place. */ - static ogg_int32_t serialno = 0; - int k; - - if (serialno == 0) serialno = time(NULL); - - do { - for (k = 0; k < 3 || serialno == 0; k++) - serialno = 11117 * serialno + 211231; - } while (serialno == -1 || oggz_get_stream (oggz, serialno) != NULL); - - /* Cast the result back to a long for API consistency */ - return (long)serialno; -} - -/******** OggzMetric management ********/ - -int -oggz_set_metric_internal (OGGZ * oggz, long serialno, - OggzMetric metric, void * user_data, int internal) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (serialno == -1) { - if (oggz->metric_internal && oggz->metric_user_data) - oggz_free (oggz->metric_user_data); - oggz->metric = metric; - oggz->metric_user_data = user_data; - oggz->metric_internal = internal; - } else { - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - if (stream->metric_internal && stream->metric_user_data) - oggz_free (stream->metric_user_data); - stream->metric = metric; - stream->metric_user_data = user_data; - stream->metric_internal = internal; - } - - return 0; -} - -int -oggz_set_metric (OGGZ * oggz, long serialno, - OggzMetric metric, void * user_data) -{ - return oggz_set_metric_internal (oggz, serialno, metric, user_data, 0); -} - -/* - * Check if a stream in an oggz has a metric - */ -int -oggz_stream_has_metric (OGGZ * oggz, long serialno) -{ - oggz_stream_t * stream; - - if (oggz->metric != NULL) return 1; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - if (stream->metric != NULL) return 1; - - return 0; -} - -/* - * Check if an oggz has metrics for all streams - */ -int -oggz_has_metrics (OGGZ * oggz) -{ - int i, size; - oggz_stream_t * stream; - - if (oggz->metric != NULL) return 1; - - size = oggz_vector_size (oggz->streams); - for (i = 0; i < size; i++) { - stream = (oggz_stream_t *)oggz_vector_nth_p (oggz->streams, i); - if (stream->metric == NULL) return 0; - } - - return 1; -} - -ogg_int64_t -oggz_get_unit (OGGZ * oggz, long serialno, ogg_int64_t granulepos) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (granulepos == -1) return -1; - - if (serialno == -1) { - if (oggz->metric) - return oggz->metric (oggz, serialno, granulepos, - oggz->metric_user_data); - } else { - stream = oggz_get_stream (oggz, serialno); - if (!stream) return -1; - - if (stream->metric) { - return stream->metric (oggz, serialno, granulepos, - stream->metric_user_data); - } else if (oggz->metric) { - return oggz->metric (oggz, serialno, granulepos, - oggz->metric_user_data); - } - } - - return -1; -} - -int -oggz_set_order (OGGZ * oggz, long serialno, - OggzOrder order, void * user_data) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (oggz->flags & OGGZ_WRITE) { - return OGGZ_ERR_INVALID; - } - - if (serialno == -1) { - oggz->order = order; - oggz->order_user_data = user_data; - } else { - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - stream->order = order; - stream->order_user_data = user_data; - } - - return 0; -} - -/* Map callback return values to error return values */ -int -oggz_map_return_value_to_error (int cb_ret) -{ - switch (cb_ret) { - case OGGZ_CONTINUE: - return OGGZ_ERR_OK; - case OGGZ_STOP_OK: - return OGGZ_ERR_STOP_OK; - case OGGZ_STOP_ERR: - return OGGZ_ERR_STOP_ERR; - default: - return cb_ret; - } -} - -const char * -oggz_content_type (OggzStreamContent content) -{ - /* 20080805: - * Re: http://lists.xiph.org/pipermail/ogg-dev/2008-July/001108.html - * - * "The ISO C standard, in section 6.7.2.2 "enumeration specifiers", - * paragraph 4, says - * - * Each enumerated type shall be compatible with *char*, a signed - * integer type, or an unsigned integer type. The choice of type is - * implementation-defined, but shall be capable of representing the - * values of all the members of the declaration." - * - * -- http://gcc.gnu.org/ml/gcc-bugs/2000-09/msg00271.html - * - * Hence, we cannot remove the (content < 0) guard, even though current - * GCC gives a warning for it -- other compilers (including earlier GCC - * versions) may use a signed type for enum OggzStreamContent. - */ - if ( -#ifdef ALLOW_SIGNED_ENUMS - content < OGGZ_CONTENT_THEORA || -#endif - content >= OGGZ_CONTENT_UNKNOWN) - return NULL; - - return oggz_auto_codec_ident[content].content_type; -} diff --git a/media/liboggz/src/liboggz/oggz_auto.c b/media/liboggz/src/liboggz/oggz_auto.c deleted file mode 100644 index 771200c0a9f..00000000000 --- a/media/liboggz/src/liboggz/oggz_auto.c +++ /dev/null @@ -1,1192 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggz_auto.c - * - * Conrad Parker - */ - -#include "config.h" - -#include -#include - -#include "oggz_private.h" -#include "oggz_byteorder.h" -#include "dirac.h" - -#include "oggz/oggz_stream.h" - -/*#define DEBUG*/ - -/* Allow use of internal metrics; ie. the user_data for these gets free'd - * when the metric is overwritten, or on close */ -int oggz_set_metric_internal (OGGZ * oggz, long serialno, OggzMetric metric, - void * user_data, int internal); - -int oggz_set_metric_linear (OGGZ * oggz, long serialno, - ogg_int64_t granule_rate_numerator, - ogg_int64_t granule_rate_denominator); - -static int -oggz_stream_set_numheaders (OGGZ * oggz, long serialno, int numheaders) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - stream->numheaders = numheaders; - - return 0; -} - -static int -auto_speex (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - unsigned char * header = data; - ogg_int64_t granule_rate = 0; - int numheaders; - - if (length < 68) return 0; - - granule_rate = (ogg_int64_t) int32_le_at(&header[36]); -#ifdef DEBUG - printf ("Got speex rate %d\n", (int)granule_rate); -#endif - - oggz_set_granulerate (oggz, serialno, granule_rate, OGGZ_AUTO_MULT); - - oggz_set_preroll (oggz, serialno, 3); - - numheaders = (ogg_int64_t) int32_le_at(&header[68]) + 2; - oggz_stream_set_numheaders (oggz, serialno, numheaders); - - return 1; -} - -static int -auto_vorbis (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - unsigned char * header = data; - ogg_int64_t granule_rate = 0; - - if (length < 30) return 0; - - granule_rate = (ogg_int64_t) int32_le_at(&header[12]); -#ifdef DEBUG - printf ("Got vorbis rate %d\n", (int)granule_rate); -#endif - - oggz_set_granulerate (oggz, serialno, granule_rate, OGGZ_AUTO_MULT); - - oggz_set_preroll (oggz, serialno, 2); - - oggz_stream_set_numheaders (oggz, serialno, 3); - - return 1; -} - -#if USE_THEORA_PRE_ALPHA_3_FORMAT -static int intlog(int num) { - int ret=0; - while(num>0){ - num=num/2; - ret=ret+1; - } - return(ret); -} -#endif - -#define THEORA_VERSION(maj,min,rev) ((maj<<16)+(min<<8)+rev) - -static int -auto_theora (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - unsigned char * header = data; - int version; - ogg_int32_t fps_numerator, fps_denominator; - char keyframe_granule_shift = 0; - int keyframe_shift; - - /* TODO: this should check against 42 for the relevant version numbers */ - if (length < 41) return 0; - - version = THEORA_VERSION(header[7], header[8], header[9]); - - fps_numerator = int32_be_at(&header[22]); - fps_denominator = int32_be_at(&header[26]); - - /* Very old theora versions used a value of 0 to mean 1. - * Unfortunately theora hasn't incremented its version field, - * hence we hardcode this workaround for old or broken streams. - */ - if (fps_numerator == 0) fps_numerator = 1; - -#if USE_THEORA_PRE_ALPHA_3_FORMAT - /* old header format, used by Theora alpha2 and earlier */ - keyframe_granule_shift = (header[36] & 0xf8) >> 3; - keyframe_shift = intlog (keyframe_granule_shift - 1); -#else - keyframe_granule_shift = (char) ((header[40] & 0x03) << 3); - keyframe_granule_shift |= (header[41] & 0xe0) >> 5; /* see TODO above */ - keyframe_shift = keyframe_granule_shift; -#endif - -#ifdef DEBUG - printf ("Got theora fps %d/%d, keyframe_shift %d\n", - fps_numerator, fps_denominator, keyframe_shift); -#endif - - oggz_set_granulerate (oggz, serialno, (ogg_int64_t)fps_numerator, - OGGZ_AUTO_MULT * (ogg_int64_t)fps_denominator); - oggz_set_granuleshift (oggz, serialno, keyframe_shift); - - if (version > THEORA_VERSION(3,2,0)) - oggz_set_first_granule (oggz, serialno, 1); - - oggz_stream_set_numheaders (oggz, serialno, 3); - - return 1; -} - -static int -auto_annodex (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - /* Apply a zero metric */ - oggz_set_granulerate (oggz, serialno, 0, 1); - - return 1; -} - -static int -auto_anxdata (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - unsigned char * header = data; - ogg_int64_t granule_rate_numerator = 0, granule_rate_denominator = 0; - - if (length < 28) return 0; - - granule_rate_numerator = int64_le_at(&header[8]); - granule_rate_denominator = int64_le_at(&header[16]); -#ifdef DEBUG - printf ("Got AnxData rate %lld/%lld\n", granule_rate_numerator, - granule_rate_denominator); -#endif - - oggz_set_granulerate (oggz, serialno, - granule_rate_numerator, - OGGZ_AUTO_MULT * granule_rate_denominator); - - return 1; -} - -static int -auto_flac0 (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - unsigned char * header = data; - ogg_int64_t granule_rate = 0; - - granule_rate = (ogg_int64_t) (header[14] << 12) | (header[15] << 4) | - ((header[16] >> 4)&0xf); -#ifdef DEBUG - printf ("Got flac rate %d\n", (int)granule_rate); -#endif - - oggz_set_granulerate (oggz, serialno, granule_rate, OGGZ_AUTO_MULT); - - oggz_stream_set_numheaders (oggz, serialno, 3); - - return 1; -} - -static int -auto_flac (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - unsigned char * header = data; - ogg_int64_t granule_rate = 0; - int numheaders; - - if (length < 51) return 0; - - granule_rate = (ogg_int64_t) (header[27] << 12) | (header[28] << 4) | - ((header[29] >> 4)&0xf); -#ifdef DEBUG - printf ("Got flac rate %d\n", (int)granule_rate); -#endif - - oggz_set_granulerate (oggz, serialno, granule_rate, OGGZ_AUTO_MULT); - - numheaders = int16_be_at(&header[7]); - oggz_stream_set_numheaders (oggz, serialno, numheaders); - - return 1; -} - -/** - * Recognizer for OggPCM2: - * http://wiki.xiph.org/index.php/OggPCM2 - */ -static int -auto_oggpcm2 (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - unsigned char * header = data; - ogg_int64_t granule_rate; - - if (length < 28) return 0; - - granule_rate = (ogg_int64_t) int32_be_at(&header[16]); -#ifdef DEBUG - printf ("Got OggPCM2 rate %d\n", (int)granule_rate); -#endif - - oggz_set_granulerate (oggz, serialno, granule_rate, OGGZ_AUTO_MULT); - - oggz_stream_set_numheaders (oggz, serialno, 3); - - return 1; -} - -static int -auto_celt (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - unsigned char * header = data; - ogg_int64_t granule_rate = 0; - int numheaders; - - if (length < 56) return 0; - - granule_rate = (ogg_int64_t) int32_le_at(&header[40]); -#ifdef DEBUG - printf ("Got celt sample rate %d\n", (int)granule_rate); -#endif - - oggz_set_granulerate (oggz, serialno, granule_rate, OGGZ_AUTO_MULT); - - numheaders = (ogg_int64_t) int32_le_at(&header[52]) + 2; - oggz_stream_set_numheaders (oggz, serialno, numheaders); - - return 1; -} - -static int -auto_cmml (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - unsigned char * header = data; - ogg_int64_t granule_rate_numerator = 0, granule_rate_denominator = 0; - int granuleshift; - - if (length < 28) return 0; - - granule_rate_numerator = int64_le_at(&header[12]); - granule_rate_denominator = int64_le_at(&header[20]); - if (length > 28) - granuleshift = (int)header[28]; - else - granuleshift = 0; - -#ifdef DEBUG - printf ("Got CMML rate %lld/%lld\n", granule_rate_numerator, - granule_rate_denominator); -#endif - - oggz_set_granulerate (oggz, serialno, - granule_rate_numerator, - OGGZ_AUTO_MULT * granule_rate_denominator); - oggz_set_granuleshift (oggz, serialno, granuleshift); - - oggz_stream_set_numheaders (oggz, serialno, 3); - - return 1; -} - -static int -auto_kate (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - unsigned char * header = data; - ogg_int32_t gps_numerator, gps_denominator; - unsigned char granule_shift = 0; - int numheaders; - - if (length < 64) return 0; - - gps_numerator = int32_le_at(&header[24]); - gps_denominator = int32_le_at(&header[28]); - - granule_shift = (header[15]); - numheaders = (header[11]); - -#ifdef DEBUG - printf ("Got kate gps %d/%d, granule shift %d\n", - gps_numerator, gps_denominator, granule_shift); -#endif - - oggz_set_granulerate (oggz, serialno, gps_numerator, - OGGZ_AUTO_MULT * gps_denominator); - oggz_set_granuleshift (oggz, serialno, granule_shift); - - oggz_stream_set_numheaders (oggz, serialno, numheaders); - - return 1; -} - -static int -auto_dirac (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - int granule_shift = 22; /* not a typo */ - dirac_info *info; - - info = oggz_malloc(sizeof(dirac_info)); - if (info == NULL) return -1; - - if (dirac_parse_info(info, data, length) == -1) - return -1; - - /* the granulerate is twice the frame rate (in order to handle interlace) */ - oggz_set_granulerate (oggz, serialno, - 2 * (ogg_int64_t)info->fps_numerator, - OGGZ_AUTO_MULT * (ogg_int64_t)info->fps_denominator); - oggz_set_granuleshift (oggz, serialno, granule_shift); - - oggz_stream_set_numheaders (oggz, serialno, 0); - - oggz_free(info); - return 1; -} - -static int -auto_fisbone (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - unsigned char * header = data; - long fisbone_serialno; /* The serialno referred to in this fisbone */ - ogg_int64_t granule_rate_numerator = 0, granule_rate_denominator = 0; - int granuleshift, numheaders; - - if (length < 48) return 0; - - fisbone_serialno = (long) int32_le_at(&header[12]); - - /* Don't override an already assigned metric */ - if (oggz_stream_has_metric (oggz, fisbone_serialno)) return 1; - - granule_rate_numerator = int64_le_at(&header[20]); - granule_rate_denominator = int64_le_at(&header[28]); - granuleshift = (int)header[48]; - -#ifdef DEBUG - printf ("Got fisbone granulerate %lld/%lld, granuleshift %d for serialno %010lu\n", - granule_rate_numerator, granule_rate_denominator, granuleshift, - fisbone_serialno); -#endif - - oggz_set_granulerate (oggz, fisbone_serialno, - granule_rate_numerator, - OGGZ_AUTO_MULT * granule_rate_denominator); - oggz_set_granuleshift (oggz, fisbone_serialno, granuleshift); - - /* Increment the number of headers for this stream */ - numheaders = oggz_stream_get_numheaders (oggz, serialno); - oggz_stream_set_numheaders (oggz, serialno, numheaders+1); - - return 1; -} - -static int -auto_fishead (OGGZ * oggz, long serialno, unsigned char * data, long length, void * user_data) -{ - oggz_set_granulerate (oggz, serialno, 0, 1); - - /* For skeleton, numheaders will get incremented as each header is seen */ - oggz_stream_set_numheaders (oggz, serialno, 1); - - return 1; -} - -/* - * The first two speex packets are header and comment packets (granulepos = 0) - */ - -typedef struct { - int headers_encountered; - int packet_size; - int encountered_first_data_packet; -} auto_calc_speex_info_t; - -static ogg_int64_t -auto_calc_speex(ogg_int64_t now, oggz_stream_t *stream, ogg_packet *op) { - - /* - * on the first (b_o_s) packet, set calculate_data to be the number - * of speex frames per packet - */ - - auto_calc_speex_info_t *info - = (auto_calc_speex_info_t *)stream->calculate_data; - - if (stream->calculate_data == NULL) { - stream->calculate_data = oggz_malloc(sizeof(auto_calc_speex_info_t)); - if (stream->calculate_data == NULL) return -1; - info = stream->calculate_data; - info->encountered_first_data_packet = 0; - info->packet_size = - (*(int *)(op->packet + 64)) * (*(int *)(op->packet + 56)); - info->headers_encountered = 1; - return 0; - } - - if (info->headers_encountered < 2) { - info->headers_encountered += 1; - } else { - info->encountered_first_data_packet = 1; - } - - if (now > -1) { - return now; - } - - if (info->encountered_first_data_packet) { - if (stream->last_granulepos > 0) { - return stream->last_granulepos + info->packet_size; - } - - return -1; - } - - return 0; - -} - -/* - * The first two CELT packets are header and comment packets (granulepos = 0) - */ - -typedef struct { - int headers_encountered; - int packet_size; - int encountered_first_data_packet; -} auto_calc_celt_info_t; - -static ogg_int64_t -auto_calc_celt (ogg_int64_t now, oggz_stream_t *stream, ogg_packet *op) { - - /* - * on the first (b_o_s) packet, set calculate_data to be the number - * of celt frames per packet - */ - - auto_calc_celt_info_t *info - = (auto_calc_celt_info_t *)stream->calculate_data; - - if (stream->calculate_data == NULL) { - stream->calculate_data = oggz_malloc(sizeof(auto_calc_celt_info_t)); - if (stream->calculate_data == NULL) return -1; - - info = stream->calculate_data; - info->encountered_first_data_packet = 0; - - /* In general, the number of frames per packet depends on the mode. - * Currently (20080213) both available modes, mono and stereo, have 256 - * frames per packet. - */ - info->packet_size = 256; - - info->headers_encountered = 1; - return 0; - } - - if (info->headers_encountered < 2) { - info->headers_encountered += 1; - } else { - info->encountered_first_data_packet = 1; - } - - if (now > -1) { - return now; - } - - if (info->encountered_first_data_packet) { - if (stream->last_granulepos > 0) { - return stream->last_granulepos + info->packet_size; - } - - return -1; - } - - return 0; - -} -/* - * Header packets are marked by a set MSB in the first byte. Inter packets - * are marked by a set 2MSB in the first byte. Intra packets (keyframes) - * are any that are left over ;-) - * - * (see http://theora.org/doc/Theora.pdf for the theora specification) - */ - -typedef struct { - int encountered_first_data_packet; -} auto_calc_theora_info_t; - - -static ogg_int64_t -auto_calc_theora(ogg_int64_t now, oggz_stream_t *stream, ogg_packet *op) { - - long keyframe_no; - int keyframe_shift; - unsigned char first_byte; - auto_calc_theora_info_t *info; - - first_byte = op->bytes == 0 ? 0x40 : op->packet[0]; - - info = (auto_calc_theora_info_t *)stream->calculate_data; - - /* header packet */ - if (first_byte & 0x80) - { - if (info == NULL) { - stream->calculate_data = oggz_malloc(sizeof(auto_calc_theora_info_t)); - if (stream->calculate_data == NULL) return -1; - info = stream->calculate_data; - } - info->encountered_first_data_packet = 0; - return (ogg_int64_t)0; - } - - /* known granulepos */ - if (now > (ogg_int64_t)(-1)) { - info->encountered_first_data_packet = 1; - return now; - } - - /* last granulepos unknown */ - if (stream->last_granulepos == -1) { - info->encountered_first_data_packet = 1; - return (ogg_int64_t)-1; - } - - /* - * first data packet is -1 if gp not set - */ - if (!info->encountered_first_data_packet) { - info->encountered_first_data_packet = 1; - return (ogg_int64_t)-1; - } - - /* inter-coded packet */ - if (first_byte & 0x40) - { - return stream->last_granulepos + 1; - } - - keyframe_shift = stream->granuleshift; - /* - * retrieve last keyframe number - */ - keyframe_no = (int)(stream->last_granulepos >> keyframe_shift); - /* - * add frames since last keyframe number - */ - keyframe_no += (stream->last_granulepos & ((1 << keyframe_shift) - 1)) + 1; - return ((ogg_int64_t)keyframe_no) << keyframe_shift; - - -} - -static ogg_int64_t -auto_rcalc_theora(ogg_int64_t next_packet_gp, oggz_stream_t *stream, - ogg_packet *this_packet, ogg_packet *next_packet) { - - int keyframe = (int)(next_packet_gp >> stream->granuleshift); - int offset = (int)(next_packet_gp - (keyframe << stream->granuleshift)); - - /* assume kf is 60 frames ago. NOTE: This is going to cause problems, - * but I can't think of what else to do. The position of the last kf - * is fundamentally unknowable. - */ - if (offset == 0) { - return ((keyframe - 60L) << stream->granuleshift) + 59; - } - else { - return (((ogg_int64_t)keyframe) << stream->granuleshift) + (offset - 1); - } - -} - - -/* - * Vorbis packets can be short or long, and each packet overlaps the previous - * and next packets. The granulepos of a packet is always the last sample - * that is completely decoded at the end of decoding that packet - i.e. the - * last packet before the first overlapping packet. If the sizes of packets - * are 's' and 'l', then the increment will depend on the previous and next - * packet types: - * v prev<<1 | next - * lll: l/2 3 - * lls: 3l/4 - s/4 2 - * lsl: s/2 - * lss: s/2 - * sll: l/4 + s/4 1 - * sls: l/2 0 - * ssl: s/2 - * sss: s/2 - * - * The previous and next packet types can be inferred from the current packet - * (additional information is not required) - * - * The two blocksizes can be determined from the first header packet, by reading - * byte 28. 1 << (packet[28] >> 4) == long_size. - * 1 << (packet[28] & 0xF) == short_size. - * - * (see http://xiph.org/vorbis/doc/Vorbis_I_spec.html for specification) - */ - -typedef struct { - int nln_increments[4]; - int nsn_increment; - int short_size; - int long_size; - int encountered_first_data_packet; - int last_was_long; - int log2_num_modes; - int mode_sizes_length; - int mode_sizes[1]; -} auto_calc_vorbis_info_t; - - -static ogg_int64_t -auto_calc_vorbis(ogg_int64_t now, oggz_stream_t *stream, ogg_packet *op) { - - auto_calc_vorbis_info_t *info; - int ii; - - if (stream->calculate_data == NULL) { - /* - * on the first (b_o_s) packet, determine the long and short sizes, - * and then calculate l/2, l/4 - s/4, 3 * l/4 - s/4, l/2 - s/2 and s/2 - */ - int short_size; - int long_size; - - long_size = 1 << (op->packet[28] >> 4); - short_size = 1 << (op->packet[28] & 0xF); - - stream->calculate_data = oggz_malloc(sizeof(auto_calc_vorbis_info_t)); - if (stream->calculate_data == NULL) return -1; - - info = (auto_calc_vorbis_info_t *)stream->calculate_data; - info->nln_increments[3] = long_size >> 1; - info->nln_increments[2] = 3 * (long_size >> 2) - (short_size >> 2); - info->nln_increments[1] = (long_size >> 2) + (short_size >> 2); - info->nln_increments[0] = info->nln_increments[3]; - info->short_size = short_size; - info->long_size = long_size; - info->nsn_increment = short_size >> 1; - info->encountered_first_data_packet = 0; - info->mode_sizes_length = 0; - - /* this is a header packet */ - return 0; - } - - /* - * marker for header packets - */ - if (op->packet[0] & 0x1) { - /* - * the code pages, a whole bunch of other fairly useless stuff, AND, - * RIGHT AT THE END (of a bunch of variable-length compressed rubbish that - * basically has only one actual set of values that everyone uses BUT YOU - * CAN'T BE SURE OF THAT, OH NO YOU CAN'T) is the only piece of data that's - * actually useful to us - the packet modes (because it's inconceivable to - * think people might want _just that_ and nothing else, you know, for - * seeking and stuff). - * - * Fortunately, because of the mandate that non-used bits must be zero - * at the end of the packet, we might be able to sneakily work backwards - * and find out the information we need (namely a mapping of modes to - * packet sizes) - */ - if (op->packet[0] == 5) { - unsigned char *current_pos = &op->packet[op->bytes - 1]; - int offset; - int size; - int size_check; - int *mode_size_ptr; - int i; - size_t size_realloc_bytes; - - /* - * This is the format of the mode data at the end of the packet for all - * Vorbis Version 1 : - * - * [ 6:number_of_modes ] - * [ 1:size | 16:window_type(0) | 16:transform_type(0) | 8:mapping ] - * [ 1:size | 16:window_type(0) | 16:transform_type(0) | 8:mapping ] - * [ 1:size | 16:window_type(0) | 16:transform_type(0) | 8:mapping ] - * [ 1:framing(1) ] - * - * e.g.: - * - * <- - * 0 0 0 0 0 1 0 0 - * 0 0 1 0 0 0 0 0 - * 0 0 1 0 0 0 0 0 - * 0 0 1|0 0 0 0 0 - * 0 0 0 0|0|0 0 0 - * 0 0 0 0 0 0 0 0 - * 0 0 0 0|0 0 0 0 - * 0 0 0 0 0 0 0 0 - * 0 0 0 0|0 0 0 0 - * 0 0 0|1|0 0 0 0 | - * 0 0 0 0 0 0 0 0 V - * 0 0 0|0 0 0 0 0 - * 0 0 0 0 0 0 0 0 - * 0 0 1|0 0 0 0 0 - * 0 0|1|0 0 0 0 0 - * - * - * i.e. each entry is an important bit, 32 bits of 0, 8 bits of blah, a - * bit of 1. - * Let's find our last 1 bit first. - * - */ - - size = 0; - - offset = 8; - while (!((1 << --offset) & *current_pos)) { - if (offset == 0) { - offset = 8; - current_pos -= 1; - } - } - - while (1) - { - - /* - * from current_pos-5:(offset+1) to current_pos-1:(offset+1) should - * be zero - */ - offset = (offset + 7) % 8; - if (offset == 7) - current_pos -= 1; - - if - ( - ((current_pos[-5] & ~((1 << (offset + 1)) - 1)) != 0) - || - current_pos[-4] != 0 - || - current_pos[-3] != 0 - || - current_pos[-2] != 0 - || - ((current_pos[-1] & ((1 << (offset + 1)) - 1)) != 0) - ) - { - break; - } - - size += 1; - - current_pos -= 5; - - } - - /* Give ourselves a chance to recover if we went back too far by using - * the size check. */ - for (ii=0; ii < 2; ii++) { - if (offset > 4) { - size_check = (current_pos[0] >> (offset - 5)) & 0x3F; - } else { - /* mask part of byte from current_pos */ - size_check = (current_pos[0] & ((1 << (offset + 1)) - 1)); - /* shift to appropriate position */ - size_check <<= (5 - offset); - /* or in part of byte from current_pos - 1 */ - size_check |= (current_pos[-1] & ~((1 << (offset + 3)) - 1)) >> - (offset + 3); - } - - size_check += 1; - if (size_check == size) { - break; - } - offset = (offset + 1) % 8; - if (offset == 0) - current_pos += 1; - current_pos += 5; - size -= 1; - } - -#ifdef DEBUG - if (size_check != size) - { - printf("WARNING: size parsing failed for VORBIS mode packets\n"); - } -#endif - - /* Check that size to be realloc'd doesn't overflow */ - size_realloc_bytes = sizeof(auto_calc_vorbis_info_t) + (size - 1) * sizeof(int); - if (size_realloc_bytes < sizeof (auto_calc_vorbis_info_t)) return -1; - - /* Store mode size information in our info struct */ - info = realloc(stream->calculate_data, size_realloc_bytes); - if (info == NULL) return -1; - - info->mode_sizes_length = size + 1; - stream->calculate_data = info; - - i = -1; - while ((1 << (++i)) < size); - info->log2_num_modes = i; - - mode_size_ptr = info->mode_sizes; - - for(i = 0; i < size; i++) - { - offset = (offset + 1) % 8; - if (offset == 0) - current_pos += 1; - *mode_size_ptr++ = (current_pos[0] >> offset) & 0x1; - current_pos += 5; - } - - } - - return 0; - } - - return -1; -} - -ogg_int64_t -auto_rcalc_vorbis(ogg_int64_t next_packet_gp, oggz_stream_t *stream, - ogg_packet *this_packet, ogg_packet *next_packet) { - - auto_calc_vorbis_info_t *info = - (auto_calc_vorbis_info_t *)stream->calculate_data; - int this_size, next_size; - ogg_int64_t r; - - int mode = - (this_packet->packet[0] >> 1) & ((1 << info->log2_num_modes) - 1); - if (info->mode_sizes_length == 0 || mode < 0 || mode >= info->mode_sizes_length) - return 0; - this_size = info->mode_sizes[mode] ? info->long_size : info->short_size; - - mode = (next_packet->packet[0] >> 1) & ((1 << info->log2_num_modes) - 1); - if (info->mode_sizes_length == 0 || mode < 0 || mode >= info->mode_sizes_length) - return 0; - next_size = info->mode_sizes[mode] ? info->long_size : info->short_size; - - r = next_packet_gp - ((this_size + next_size) / 4); - if (r < 0) return 0L; - return r; - -} - -/** - * FLAC - * Defined at: http://flac.sourceforge.net/ogg_mapping.html - * - Native FLAC audio frames appear as subsequent packets in the stream. - * Each packet corresponds to one FLAC audio frame. - * - FLAC packets may span page boundaries. - * - * The frame header defines block size - * http://flac.sourceforge.net/format.html#frame_header - * - * Note that most FLAC packets will have a granulepos, but rare cases exist - * where they don't. See for example - * http://rafb.net/paste/results/Pkib5w72.html - */ - -typedef struct { - ogg_int64_t previous_gp; - int encountered_first_data_packet; -} auto_calc_flac_info_t; - -static ogg_int64_t -auto_calc_flac (ogg_int64_t now, oggz_stream_t *stream, ogg_packet *op) -{ - auto_calc_flac_info_t *info; - - if (stream->calculate_data == NULL) { - stream->calculate_data = oggz_malloc(sizeof(auto_calc_flac_info_t)); - if (stream->calculate_data == NULL) return -1; - - info = (auto_calc_flac_info_t *)stream->calculate_data; - info->previous_gp = 0; - info->encountered_first_data_packet = 0; - - /* this is a header packet */ - goto out; - } - - info = (auto_calc_flac_info_t *)stream->calculate_data; - - /* FLAC audio frames begin with marker 0xFF */ - if (op->packet[0] == 0xff) - info->encountered_first_data_packet = 1; - - if (now == -1 && op->packet[0] == 0xff && op->bytes > 2) { - unsigned char bs; - int block_size; - - bs = (op->packet[2] & 0xf0) >> 4; - - switch (bs) { - case 0x0: /* 0000 : get from STREAMINFO metadata block */ - block_size = -1; - break; - case 0x1: /* 0001 : 192 samples */ - block_size = 192; - break; - /* 0010-0101 : 576 * (2^(n-2)) samples, i.e. 576/1152/2304/4608 */ - case 0x2: - block_size = 576; - break; - case 0x3: - block_size = 1152; - break; - case 0x4: - block_size = 2304; - break; - case 0x5: - block_size = 4608; - break; - case 0x6: /* 0110 : get 8 bit (blocksize-1) from end of header */ - block_size = -1; - break; - case 0x7: /* 0111 : get 16 bit (blocksize-1) from end of header */ - block_size = -1; - break; - /* 1000-1111 : 256 * (2^(n-8)) samples, i.e. 256/512/1024/2048/4096/8192/16384/32768 */ - case 0x8: - block_size = 256; - break; - case 0x9: - block_size = 512; - break; - case 0xa: - block_size = 1024; - break; - case 0xb: - block_size = 2048; - break; - case 0xc: - block_size = 4096; - break; - case 0xd: - block_size = 8192; - break; - case 0xe: - block_size = 16384; - break; - case 0xf: - block_size = 32768; - break; - default: - block_size = -1; - break; - } - - if (block_size != -1) { - now = info->previous_gp + block_size; - } - } else if (now == -1 && info->encountered_first_data_packet == 0) { - /* this is a header packet */ - now = 0; - } - -out: - info->previous_gp = now; - return now; -} - -const oggz_auto_contenttype_t oggz_auto_codec_ident[] = { - {"\200theora", 7, "Theora", auto_theora, auto_calc_theora, auto_rcalc_theora}, - {"\001vorbis", 7, "Vorbis", auto_vorbis, auto_calc_vorbis, auto_rcalc_vorbis}, - {"Speex", 5, "Speex", auto_speex, auto_calc_speex, NULL}, - {"PCM ", 8, "PCM", auto_oggpcm2, NULL, NULL}, - {"CMML\0\0\0\0", 8, "CMML", auto_cmml, NULL, NULL}, - {"Annodex", 8, "Annodex", auto_annodex, NULL, NULL}, - {"fishead", 7, "Skeleton", auto_fishead, NULL, NULL}, - {"fLaC", 4, "Flac0", auto_flac0, auto_calc_flac, NULL}, - {"\177FLAC", 5, "Flac", auto_flac, auto_calc_flac, NULL}, - {"AnxData", 7, "AnxData", auto_anxdata, NULL, NULL}, - {"CELT ", 8, "CELT", auto_celt, auto_calc_celt, NULL}, - {"\200kate\0\0\0", 8, "Kate", auto_kate, NULL, NULL}, - {"BBCD\0", 5, "Dirac", auto_dirac, NULL, NULL}, - {"", 0, "Unknown", NULL, NULL, NULL} -}; - -static int -oggz_auto_identify (OGGZ * oggz, long serialno, unsigned char * data, long len) -{ - int i; - - for (i = 0; i < OGGZ_CONTENT_UNKNOWN; i++) - { - const oggz_auto_contenttype_t *codec = oggz_auto_codec_ident + i; - - if (len >= codec->bos_str_len && - memcmp (data, codec->bos_str, codec->bos_str_len) == 0) { - - oggz_stream_set_content (oggz, serialno, i); - - return 1; - } - } - - oggz_stream_set_content (oggz, serialno, OGGZ_CONTENT_UNKNOWN); - return 0; -} - -int -oggz_auto_identify_page (OGGZ * oggz, ogg_page *og, long serialno) -{ - return oggz_auto_identify (oggz, serialno, og->body, og->body_len); -} - -int -oggz_auto_identify_packet (OGGZ * oggz, ogg_packet * op, long serialno) -{ - return oggz_auto_identify (oggz, serialno, op->packet, op->bytes); -} - -int -oggz_auto_read_bos_page (OGGZ * oggz, ogg_page * og, long serialno, - void * user_data) -{ - int content = 0; - - content = oggz_stream_get_content(oggz, serialno); - if (content < 0 || content >= OGGZ_CONTENT_UNKNOWN) { - return 0; - } else if (content == OGGZ_CONTENT_SKELETON && !ogg_page_bos(og)) { - return auto_fisbone(oggz, serialno, og->body, og->body_len, user_data); - } else { - return oggz_auto_codec_ident[content].reader(oggz, serialno, og->body, og->body_len, user_data); - } -} - -int -oggz_auto_read_bos_packet (OGGZ * oggz, ogg_packet * op, long serialno, - void * user_data) -{ - int content = 0; - - content = oggz_stream_get_content(oggz, serialno); - if (content < 0 || content >= OGGZ_CONTENT_UNKNOWN) { - return 0; - } else if (content == OGGZ_CONTENT_SKELETON && !op->b_o_s) { - return auto_fisbone(oggz, serialno, op->packet, op->bytes, user_data); - } else { - return oggz_auto_codec_ident[content].reader(oggz, serialno, op->packet, op->bytes, user_data); - } -} - -ogg_int64_t -oggz_auto_calculate_granulepos(int content, ogg_int64_t now, - oggz_stream_t *stream, ogg_packet *op) { - if (oggz_auto_codec_ident[content].calculator != NULL) { - ogg_int64_t r = oggz_auto_codec_ident[content].calculator(now, stream, op); - return r; - } - - return now; -} - -ogg_int64_t -oggz_auto_calculate_gp_backwards(int content, ogg_int64_t next_packet_gp, - oggz_stream_t *stream, ogg_packet *this_packet, ogg_packet *next_packet) { - - if (oggz_auto_codec_ident[content].r_calculator != NULL) { - return oggz_auto_codec_ident[content].r_calculator(next_packet_gp, - stream, this_packet, next_packet); - } - - return 0; - -} - -int -oggz_auto_read_comments (OGGZ * oggz, oggz_stream_t * stream, long serialno, - ogg_packet * op) -{ - int offset = -1; - long len = -1; - - switch (stream->content) { - case OGGZ_CONTENT_VORBIS: - if (op->bytes > 7 && memcmp (op->packet, "\003vorbis", 7) == 0) - offset = 7; - break; - case OGGZ_CONTENT_SPEEX: - offset = 0; break; - case OGGZ_CONTENT_THEORA: - if (op->bytes > 7 && memcmp (op->packet, "\201theora", 7) == 0) - offset = 7; - break; - case OGGZ_CONTENT_KATE: - if (op->bytes > 9 && memcmp (op->packet, "\201kate\0\0\0", 8) == 0) { - /* we skip the reserved 0 byte after the signature */ - offset = 9; - } - break; - case OGGZ_CONTENT_FLAC: - if (op->bytes > 4 && (op->packet[0] & 0x7) == 4) { - len = (op->packet[1]<<16) + (op->packet[2]<<8) + op->packet[3]; - offset = 4; - } - break; - default: - break; - } - - /* The length of the comments to decode is the rest of the packet, - * unless otherwise determined (ie. for FLAC) */ - if (len == -1) - len = op->bytes - offset; - - if (offset >= 0) { - oggz_comments_decode (oggz, serialno, op->packet+offset, len); - } - - return 0; -} - diff --git a/media/liboggz/src/liboggz/oggz_auto.h b/media/liboggz/src/liboggz/oggz_auto.h deleted file mode 100644 index dd0e0d7e07a..00000000000 --- a/media/liboggz/src/liboggz/oggz_auto.h +++ /dev/null @@ -1,479 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggz_auto.h - * - * Conrad Parker - */ - -#ifndef __OGGZ_AUTO_H__ -#define __OGGZ_AUTO_H__ - -#include - -/** - * Speex - * - * Default field type: LITTLE ENDIAN unsigned integer - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| speex_string: Identifier char[8]: 'Speex ' | 0-3 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 4-7 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| speex_version: char[20] | 8-11 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 12-15 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 16-19 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 20-23 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 24-27 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| speex_version_id | 28-31 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| header_size | 32-35 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| rate | 36-39 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| mode | 40-43 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| mode_bitstream_version | 44-47 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| nb_channels | 48-51 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| bitrate | 52-55 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| frame_size | 56-59 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| vbr | 60-63 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| frames_per_packet | 64-67 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| extra_headers | 68-71 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| reserved1 | 72-75 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| reserved2 | 76-79 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - */ - -/** - * Vorbis - * - * Default field type: LITTLE ENDIAN unsigned integer - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| packtype | Identifier char[6]: 'vorbis' | 0-3 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | version | 4-7 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | channels | 8-11 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| rate | 12-15 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| bitrate_upper | 16-19 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| bitrate_nominal | 20-23 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| bitrate_lower | 24-27 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| l2bs0 | l2bs1 |e| 28-31 -+-+-+-+-+-+-+-+-+-+ - - */ - -/** - * Theora - * - * Default field type: BIG ENDIAN unsigned integer - * - -Field names in full caps refer to fields described in the Theora I -specification. Lowercase refers to theora_info struct members from -libtheora. - -This is the Theora header for theora-alpha3: - -(VMAJ=3, VMIN=2, VREV=0) - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| packtype | Identifier char[6]: 'theora' | 0-3 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | VMAJ | 4-7 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| VMIN | VREV | FMBW: width >> 4 | 8-11 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| FMBH: height >> 4 | PICW: frame_width | 12-15 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | PICH: frame_height | 16-19 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| PICX: offset_x| PICY: offset_y| FRN: fps_numerator | 20-23 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | FRD: fps_denominator | 24-27 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | PARN: aspect_numerator | 28-31 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | PARD: aspect_denominator | 32-35 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| CS: colorspace| NOMBR: target_bitrate | 36-39 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| QUAL | KFGSHIFT| PF| resv| 40-43 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - -This was the Theora header for theora-alpha2: - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| packtype | Identifier char[6]: 'theora' | 0-3 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | Version major | 4-7 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Version minor | Version sub | width >> 4 | 8-11 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| height >> 4 | frame_width | 12-15 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | frame_height | 16-19 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| offset_x | offset_y | fps_numerator | 20-23 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | fps_denominator | 24-27 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | aspect_numerator | 28-31 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | aspect_denominator | 32-35 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| kgshift | colorspace | target_bitrate | 36-39 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | quality | 40-43 -+-+-+-+-+-+-+-+-+-+-+-+ - - */ - - -/** - * CMML - * - * Default field type: LITTLE ENDIAN unsigned integer - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Identifier 'CMML\0\0\0\0' | 0-3 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 4-7 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Version major | Version minor | 8-11 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Granulerate numerator | 12-15 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 16-19 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Granulerate denominator | 20-23 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 24-27 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Granuleshift | 28-31 -+-+-+-+-+-+-+-+-+ - -*/ - -/** - * Skeleton BOS page ("fishead", Annodex version 3.0) - * - * Default field type: LITTLE ENDIAN unsigned integer - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Identifier 'fishead\0' | 0-3 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 4-7 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Version major | Version minor | 8-11 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Presentationtime numerator | 12-15 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 16-19 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Presentationtime denominator | 20-23 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 24-27 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Basetime numerator | 28-31 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 32-35 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Basetime denominator | 36-39 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 40-43 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| UTC | 44-47 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 48-51 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 52-55 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 56-59 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 60-63 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -*/ - -/** - * Skeleton track info ("fisbone", Annodex version 3.0) - * - * Default field type: LITTLE ENDIAN unsigned integer - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Identifier 'fisbone\0' | 0-3 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 4-7 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Offset to message header fields | 8-11 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Serial number | 12-15 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Number of secondary header pages | 16-19 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Granulerate numerator | 20-23 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 24-27 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Granulerate denominator | 28-31 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 32-35 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Basegranule | 36-39 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 40-43 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Preroll | 44-47 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Granuleshift | Padding/future use | 48-51 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Message header fields ... | 52- -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - -*/ - -/** - * Annodex (Annodex version 2.0) OBSOLETE - * - * Default field type: LITTLE ENDIAN unsigned integer - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Identifier char[8]: 'Annodex\0' | 0-3 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 4-7 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Version major | Version minor | 8-11 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Timebase numerator | 12-15 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 16-19 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Timebase denominator | 20-23 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 24-27 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| UTC | 28-31 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 32-35 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 36-39 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 40-43 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 44-47 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - */ - -/** - * AnxData (Annodex version 2.0) OBSOLETE - * - * Default field type: LITTLE ENDIAN unsigned integer - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Identifier char[8]: 'AnxData\0' | 0-3 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 4-7 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Granule rate numerator | 8-11 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 12-15 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Granule rate denominator | 16-19 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 20-23 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Number of secondary header pages | 24-27 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Headers ... | 28- -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - */ - -/** - * OggPCM Draft 2 - * - * http://wiki.xiph.org/index.php/OggPCM2 - * - * Default field type: BIG ENDIAN unsigned integer - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Identifier char[8]: 'PCM ' | 0-3 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 4-7 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Version major | Version minor | 8-11 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| PCM Format | 12-15 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Sampling rate [Hz] | 16-19 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Num. sig. bits| Num. channels | Max. num. frames per packet | 20-23 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Number of extra header packets | 24-27 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - */ - -/* - * CELT (experimental) - * last updated 20080213 - * - * Default field type: LITTLE ENDIAN unsigned integer - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| codec_id: Identifier char[8]: 'CELT ' | 0-3 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 4-7 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| codec_version: char[20] | 8-11 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 12-15 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 16-19 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 20-23 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | 24-27 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| version_id | 28-31 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| header_size | 32-35 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| mode | 36-39 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| sample_rate | 40-43 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| nb_channels | 44-47 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| bytes_per_packet | 48-51 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| extra_headers | 52-55 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - */ - -/** - * Kate bitstream version 0.x - * - * Default field type: LITTLE ENDIAN unsigned integer - - 0 1 2 3 | - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| packtype | Identifier char[7]: 'kate\0\0\0' | 0-3 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| kate magic continued | 4-7 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| reserved - 0 | version major | version minor | num headers | 8-11 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| text encoding | directionality| reserved - 0 | granule shift | 12-15 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| cw sh | canvas width | ch sh | canvcas height | 16-19 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| reserved - 0 | 20-23 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| granule rate numerator | 24-27 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| granule rate denominator | 28-31 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| language (NUL terminated) | 32-35 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| language (continued) | 36-39 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| language (continued) | 40-43 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| language (continued) | 44-47 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| category (NUL terminated) | 48-51 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| category (continued) | 52-55 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| category (continued) | 56-59 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| category (continued) | 60-63 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - since bitstream 0.3: cw sh, canvas width, ch sh, canvas height - - */ - -int oggz_auto_identify (OGGZ *oggz, ogg_page *og, long serialno); - -#endif /* __OGGZ_AUTO_H__ */ diff --git a/media/liboggz/src/liboggz/oggz_byteorder.h b/media/liboggz/src/liboggz/oggz_byteorder.h deleted file mode 100644 index 1973c62ae7a..00000000000 --- a/media/liboggz/src/liboggz/oggz_byteorder.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_BYTEORDER_H__ -#define __OGGZ_BYTEORDER_H__ - -#include "config.h" - -#ifdef _UNUSED_ -static unsigned short -_le_16 (unsigned short s) -{ - unsigned short ret=s; -#ifdef WORDS_BIGENDIAN - ret = (s>>8) & 0x00ffU; - ret += (s<<8) & 0xff00U; -#endif - return ret; -} -#endif /* _UNUSED_ */ - -static ogg_uint32_t -_le_32 (ogg_uint32_t i) -{ - ogg_uint32_t ret=i; -#ifdef WORDS_BIGENDIAN - ret = (i>>24); - ret += (i>>8) & 0x0000ff00; - ret += (i<<8) & 0x00ff0000; - ret += (i<<24); -#endif - return ret; -} - -static unsigned short -_be_16 (unsigned short s) -{ - unsigned short ret=s; -#ifndef WORDS_BIGENDIAN - ret = (s>>8) & 0x00ffU; - ret += (s<<8) & 0xff00U; -#endif - return ret; -} - -static ogg_uint32_t -_be_32 (ogg_uint32_t i) -{ - ogg_uint32_t ret=i; -#ifndef WORDS_BIGENDIAN - ret = (i>>24); - ret += (i>>8) & 0x0000ff00; - ret += (i<<8) & 0x00ff0000; - ret += (i<<24); -#endif - return ret; -} - -static ogg_int64_t -_le_64 (ogg_int64_t l) -{ - ogg_int64_t ret=l; - unsigned char *ucptr = (unsigned char *)&ret; -#ifdef WORDS_BIGENDIAN - unsigned char temp; - - temp = ucptr [0] ; - ucptr [0] = ucptr [7] ; - ucptr [7] = temp ; - - temp = ucptr [1] ; - ucptr [1] = ucptr [6] ; - ucptr [6] = temp ; - - temp = ucptr [2] ; - ucptr [2] = ucptr [5] ; - ucptr [5] = temp ; - - temp = ucptr [3] ; - ucptr [3] = ucptr [4] ; - ucptr [4] = temp ; - -#endif - return (*(ogg_int64_t *)ucptr); -} - -static ogg_int32_t -int32_be_at (unsigned char *c) -{ - return (c [0] << 24) | (c [1] << 16) | (c [2] << 8) | c [3] ; -} - -static unsigned short -int16_be_at (unsigned char *c) -{ - return (c [0] << 8) | c [1]; -} - -static ogg_int32_t -int32_le_at (unsigned char *c) -{ - return c [0] | (c [1] << 8) | (c [2] << 16) | (c [3] << 24); -} - -static ogg_int64_t -int64_le_at (unsigned char *c) -{ - ogg_uint32_t a = c [0] | (c [1] << 8) | (c [2] << 16) | (c [3] << 24); - ogg_uint32_t b = c [4] | (c [5] << 8) | (c [6] << 16) | (c [7] << 24); - - return (((ogg_int64_t)b) << 32) | a; -} - -#endif /* __OGGZ_BYTEORDER_H__ */ diff --git a/media/liboggz/src/liboggz/oggz_comments.c b/media/liboggz/src/liboggz/oggz_comments.c deleted file mode 100644 index 36b997fc0ad..00000000000 --- a/media/liboggz/src/liboggz/oggz_comments.c +++ /dev/null @@ -1,918 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#include -#include -#include -#include /* ULONG_MAX */ -#ifndef WIN32 -#include -#endif - -#include - -#include "oggz_private.h" -#include "oggz_vector.h" - -#include "oggz/oggz_stream.h" - -/*#define DEBUG*/ - -#ifdef WIN32 -#define strcasecmp _stricmp -#endif - -/* Ensure comment vector length can be expressed in 32 bits - * including space for the trailing NUL */ -#define MAX_COMMENT_LENGTH 0xFFFFFFFE -#define oggz_comment_clamp(c) MIN((c),MAX_COMMENT_LENGTH) - -static size_t -oggz_comment_len (const char * s) -{ - size_t len; - - if (s == NULL) return 0; - - len = strlen (s); - return oggz_comment_clamp(len); -} - -static char * -oggz_strdup (const char * s) -{ - char * ret; - if (s == NULL) return NULL; - ret = oggz_malloc (oggz_comment_len(s) + 1); - if (ret == NULL) return NULL; - - return strcpy (ret, s); -} - -static char * -oggz_strdup_len (const char * s, size_t len) -{ - char * ret; - if (s == NULL) return NULL; - if (len == 0) return NULL; - len = oggz_comment_clamp(len); - ret = oggz_malloc (len + 1); - if (!ret) return NULL; - if (strncpy (ret, s, len) == NULL) { - oggz_free (ret); - return NULL; - } - - ret[len] = '\0'; - return ret; -} - -static char * -oggz_index_len (const char * s, char c, int len) -{ - int i; - - for (i = 0; *s && i < len; i++, s++) { - if (*s == c) return (char *)s; - } - - return NULL; -} - -/* - Comments will be stored in the Vorbis style. - It is describled in the "Structure" section of - http://www.xiph.org/ogg/vorbis/doc/v-comment.html - -The comment header is decoded as follows: - 1) [vendor_length] = read an unsigned integer of 32 bits - 2) [vendor_string] = read a UTF-8 vector as [vendor_length] octets - 3) [user_comment_list_length] = read an unsigned integer of 32 bits - 4) iterate [user_comment_list_length] times { - 5) [length] = read an unsigned integer of 32 bits - 6) this iteration's user comment = read a UTF-8 vector as [length] octets - } - 7) [framing_bit] = read a single bit as boolean - 8) if ( [framing_bit] unset or end of packet ) then ERROR - 9) done. - - If you have troubles, please write to ymnk@jcraft.com. - */ - -#define readint(buf, base) (((buf[base+3]<<24)&0xff000000)| \ - ((buf[base+2]<<16)&0xff0000)| \ - ((buf[base+1]<<8)&0xff00)| \ - (buf[base]&0xff)) -#define writeint(buf, base, val) buf[base+3]=(char)(((val)>>24)&0xff); \ - buf[base+2]=(char)(((val)>>16)&0xff); \ - buf[base+1]=(char)(((val)>>8)&0xff); \ - buf[base]=(char)((val)&0xff); - -/* The FLAC header will encode the length of the comments in - 24bit BE format. -*/ -#define writeint24be(buf, base, val) buf[base]=(char)(((val)>>16)&0xff); \ - buf[base+1]=(char)(((val)>>8)&0xff); \ - buf[base+2]=(char)((val)&0xff); - -static int -oggz_comment_validate_byname (const char * name, const char * value) -{ - const char * c; - - if (!name || !value) return 0; - - for (c = name; *c; c++) { - if (*c < 0x20 || *c > 0x7D || *c == 0x3D) { -#ifdef DEBUG - printf ("XXX char %c in %s invalid\n", *c, name); -#endif - return 0; - } - } - - /* XXX: we really should validate value as UTF-8 here, but ... */ - - return 1; -} - -static OggzComment * -oggz_comment_new (const char * name, const char * value) -{ - OggzComment * comment; - - if (!oggz_comment_validate_byname (name, value)) return NULL; - /* Ensures that name != NULL, value != NULL, and validates strings */ - - comment = oggz_malloc (sizeof (OggzComment)); - if (comment == NULL) return NULL; - - comment->name = oggz_strdup (name); - if (comment->name == NULL) { - oggz_free (comment); - return NULL; - } - - comment->value = oggz_strdup (value); - if (comment->value == NULL) { - oggz_free (comment->name); - oggz_free (comment); - return NULL; - } - - return comment; -} - -static void -oggz_comment_free (OggzComment * comment) -{ - if (!comment) return; - if (comment->name) oggz_free (comment->name); - if (comment->value) oggz_free (comment->value); - oggz_free (comment); -} - -static int -oggz_comment_cmp (const OggzComment * comment1, const OggzComment * comment2) -{ - if (comment1 == comment2) return 1; - if (!comment1 || !comment2) return 0; - - if (strcasecmp (comment1->name, comment2->name)) return 0; - if (strcmp (comment1->value, comment2->value)) return 0; - - return 1; -} - -static int -_oggz_comment_set_vendor (OGGZ * oggz, long serialno, - const char * vendor_string) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - if (stream->vendor) oggz_free (stream->vendor); - - if ((stream->vendor = oggz_strdup (vendor_string)) == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - - return 0; -} - -/* Public API */ - -const char * -oggz_comment_get_vendor (OGGZ * oggz, long serialno) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return NULL; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return NULL; - - return stream->vendor; -} - -int -oggz_comment_set_vendor (OGGZ * oggz, long serialno, const char * vendor_string) -{ - oggz_stream_t * stream; - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) - stream = oggz_add_stream (oggz, serialno); - if (stream == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - - if (oggz->flags & OGGZ_WRITE) { - if (OGGZ_CONFIG_WRITE) { - - return _oggz_comment_set_vendor (oggz, serialno, vendor_string); - - } else { - return OGGZ_ERR_DISABLED; - } - } else { - return OGGZ_ERR_INVALID; - } -} - - -const OggzComment * -oggz_comment_first (OGGZ * oggz, long serialno) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return NULL; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return NULL; - - return oggz_vector_nth_p (stream->comments, 0); -} - -const OggzComment * -oggz_comment_first_byname (OGGZ * oggz, long serialno, char * name) -{ - oggz_stream_t * stream; - OggzComment * comment; - int i; - - if (oggz == NULL) return NULL; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return NULL; - - if (name == NULL) return oggz_vector_nth_p (stream->comments, 0); - - if (!oggz_comment_validate_byname (name, "")) - return NULL; - - for (i = 0; i < oggz_vector_size (stream->comments); i++) { - comment = (OggzComment *) oggz_vector_nth_p (stream->comments, i); - if (comment->name && !strcasecmp (name, comment->name)) - return comment; - } - - return NULL; -} - -const OggzComment * -oggz_comment_next (OGGZ * oggz, long serialno, const OggzComment * comment) -{ - oggz_stream_t * stream; - int i; - - if (oggz == NULL || comment == NULL) return NULL; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return NULL; - - i = oggz_vector_find_index_p (stream->comments, comment); - - return oggz_vector_nth_p (stream->comments, i+1); -} - -const OggzComment * -oggz_comment_next_byname (OGGZ * oggz, long serialno, - const OggzComment * comment) -{ - oggz_stream_t * stream; - OggzComment * v_comment; - int i; - - if (oggz == NULL || comment == NULL) return NULL; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return NULL; - - i = oggz_vector_find_index_p (stream->comments, comment); - - for (i++; i < oggz_vector_size (stream->comments); i++) { - v_comment = (OggzComment *) oggz_vector_nth_p (stream->comments, i); - if (v_comment->name && !strcasecmp (comment->name, v_comment->name)) - return v_comment; - } - - return NULL; -} - -static OggzComment * -_oggz_comment_add_byname (oggz_stream_t * stream, const char * name, const char * value) -{ - OggzComment * comment, * new_comment; - int i; - - /* Check that the same name=value pair is not already present */ - for (i = 0; i < oggz_vector_size (stream->comments); i++) { - comment = (OggzComment *) oggz_vector_nth_p (stream->comments, i); - if (comment->name && !strcasecmp (name, comment->name)) { - if (comment->value == NULL) { - if (value == NULL) return comment; - } else if ((value && !strcmp (value, comment->value)) || - (value == NULL && comment->value == NULL)) { - return comment; - } - } - } - - /* Allocate new comment and insert it */ - if ((new_comment = oggz_comment_new (name, value)) == NULL) - return NULL; - - return oggz_vector_insert_p (stream->comments, new_comment); -} - -int -oggz_comment_add (OGGZ * oggz, long serialno, const OggzComment * comment) -{ - oggz_stream_t * stream; - OggzComment * new_comment; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) - stream = oggz_add_stream (oggz, serialno); - if (stream == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - - if (oggz->flags & OGGZ_WRITE) { - if (OGGZ_CONFIG_WRITE) { - - if (!oggz_comment_validate_byname (comment->name, comment->value)) - return OGGZ_ERR_COMMENT_INVALID; - - if (_oggz_comment_add_byname (stream, comment->name, comment->value) == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - - return 0; - } else { - return OGGZ_ERR_DISABLED; - } - } else { - return OGGZ_ERR_INVALID; - } -} - -int -oggz_comment_add_byname (OGGZ * oggz, long serialno, - const char * name, const char * value) -{ - oggz_stream_t * stream; - OggzComment * new_comment; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) - stream = oggz_add_stream (oggz, serialno); - if (stream == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - - if (oggz->flags & OGGZ_WRITE) { - if (OGGZ_CONFIG_WRITE) { - - if (!oggz_comment_validate_byname (name, value)) - return OGGZ_ERR_COMMENT_INVALID; - - if (_oggz_comment_add_byname (stream, name, value) == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - - return 0; - } else { - return OGGZ_ERR_DISABLED; - } - } else { - return OGGZ_ERR_INVALID; - } -} - -int -oggz_comment_remove (OGGZ * oggz, long serialno, OggzComment * comment) -{ - oggz_stream_t * stream; - OggzComment * v_comment; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - if (oggz->flags & OGGZ_WRITE) { - if (OGGZ_CONFIG_WRITE) { - v_comment = oggz_vector_find_p (stream->comments, comment); - - if (v_comment == NULL) return 0; - - oggz_vector_remove_p (stream->comments, v_comment); - oggz_comment_free (v_comment); - - return 1; - - } else { - return OGGZ_ERR_DISABLED; - } - } else { - return OGGZ_ERR_INVALID; - } -} - -int -oggz_comment_remove_byname (OGGZ * oggz, long serialno, char * name) -{ - oggz_stream_t * stream; - OggzComment * comment; - int i, ret = 0; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - if (oggz->flags & OGGZ_WRITE) { - if (OGGZ_CONFIG_WRITE) { - for (i = 0; i < oggz_vector_size (stream->comments); i++) { - comment = (OggzComment *) oggz_vector_nth_p (stream->comments, i); - if (!strcasecmp (name, comment->name)) { - oggz_comment_remove (oggz, serialno, comment); - i--; - ret++; - } - } - return ret; - } else { - return OGGZ_ERR_DISABLED; - } - } else { - return OGGZ_ERR_INVALID; - } -} - -int -oggz_comments_copy (OGGZ * src, long src_serialno, - OGGZ * dest, long dest_serialno) -{ - const OggzComment * comment; - - if (src == NULL || dest == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (dest->flags & OGGZ_WRITE) { - if (OGGZ_CONFIG_WRITE) { - oggz_comment_set_vendor (dest, dest_serialno, - oggz_comment_get_vendor (src, src_serialno)); - - for (comment = oggz_comment_first (src, src_serialno); comment; - comment = oggz_comment_next (src, src_serialno, comment)) { - oggz_comment_add (dest, dest_serialno, comment); - } - } else { - return OGGZ_ERR_DISABLED; - } - } else { - return OGGZ_ERR_INVALID; - } - - return 0; -} - -/* Internal API */ -int -oggz_comments_init (oggz_stream_t * stream) -{ - stream->vendor = NULL; - stream->comments = oggz_vector_new (); - if (stream->comments == NULL) return -1; - - oggz_vector_set_cmp (stream->comments, (OggzCmpFunc) oggz_comment_cmp, NULL); - - return 0; -} - -int -oggz_comments_free (oggz_stream_t * stream) -{ - oggz_vector_foreach (stream->comments, (OggzFunc)oggz_comment_free); - oggz_vector_delete (stream->comments); - stream->comments = NULL; - - if (stream->vendor) oggz_free (stream->vendor); - stream->vendor = NULL; - - return 0; -} - -int -oggz_comments_decode (OGGZ * oggz, long serialno, - unsigned char * comments, long length) -{ - oggz_stream_t * stream; - char *c= (char *)comments; - int i, nb_fields, n; - size_t len; - char *end; - char * name, * value, * nvalue = NULL; - OggzComment * comment; - - if (length<8) - return -1; - - end = c+length; - len=readint(c, 0); - - c+=4; - if (len>(size_t)(end-c)) return -1; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - /* Vendor */ - if (len > 0) { - if ((nvalue = oggz_strdup_len (c, len)) == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - - if (_oggz_comment_set_vendor (oggz, serialno, nvalue) == OGGZ_ERR_OUT_OF_MEMORY) { - oggz_free (nvalue); - return OGGZ_ERR_OUT_OF_MEMORY; - } - - oggz_free (nvalue); - } - -#ifdef DEBUG - fwrite(c, 1, len, stderr); fputc ('\n', stderr); -#endif - c+=len; - - if (c+4>end) return -1; - - /* This value gets checked effectively by the 'for' condition - and the checks within the loop for c running off the end. */ - nb_fields=readint(c, 0); - c+=4; - for (i=0;iend) return -1; - - len=readint(c, 0); - - c+=4; - if (len>(size_t)(end-c)) return -1; - - name = c; - value = oggz_index_len (c, '=', len); - if (value) { - *value = '\0'; - value++; - - n = c+len - value; - if ((nvalue = oggz_strdup_len (value, n)) == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - -#ifdef DEBUG - printf ("oggz_comments_decode: %s -> %s (length %d)\n", - name, nvalue, n); -#endif - if (_oggz_comment_add_byname (stream, name, nvalue) == NULL) { - oggz_free (nvalue); - return OGGZ_ERR_OUT_OF_MEMORY; - } - - oggz_free (nvalue); - } else { - if ((nvalue = oggz_strdup_len (name, len)) == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - - if (_oggz_comment_add_byname (stream, nvalue, NULL) == NULL) { - oggz_free (nvalue); - return OGGZ_ERR_OUT_OF_MEMORY; - } - - oggz_free (nvalue); - } - - c+=len; - } - -#ifdef DEBUG - printf ("oggz_comments_decode: done\n"); -#endif - - return 0; -} - -/* - * Pre-condition: at least one of accum, delta are non-zero, - * ie. don't call accum_length (0, 0); - * \retval 0 Failure: integer overflow - */ -static unsigned long -accum_length (unsigned long * accum, unsigned long delta) -{ - /* Pre-condition: don't call accum_length (0, 0) */ - assert (*accum != 0 || delta != 0); - - /* Check for integer overflow */ - if (delta > ULONG_MAX - (*accum)) - return 0; - - *accum += delta; - - return *accum; -} - -long -oggz_comments_encode (OGGZ * oggz, long serialno, - unsigned char * buf, long length) -{ - oggz_stream_t * stream; - char * c = (char *)buf; - const OggzComment * comment; - int nb_fields = 0, vendor_length = 0; - unsigned long actual_length = 0, remaining = length, field_length; - - /* Deal with sign of length first */ - if (length < 0) return 0; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - /* Vendor string */ - if (stream->vendor) - vendor_length = oggz_comment_len (stream->vendor); - if (accum_length (&actual_length, 4 + vendor_length) == 0) - return 0; -#ifdef DEBUG - printf ("oggz_comments_encode: vendor = %s\n", stream->vendor); -#endif - - /* user comment list length */ - if (accum_length (&actual_length, 4) == 0) - return 0; - - - for (comment = oggz_comment_first (oggz, serialno); comment; - comment = oggz_comment_next (oggz, serialno, comment)) { - /* [size]"name" */ - if (accum_length (&actual_length, 4 + oggz_comment_len (comment->name)) == 0) - return 0; - if (comment->value) { - /* "=value" */ - if (accum_length (&actual_length, 1 + oggz_comment_len (comment->value)) == 0) - return 0; - } - -#ifdef DEBUG - printf ("oggz_comments_encode: %s = %s\n", - comment->name, comment->value); -#endif - - nb_fields++; - } - - /* framing bit */ - if (accum_length (&actual_length, 1) == 0) - return 0; - - /* NB. actual_length is not modified from here onwards */ - - if (buf == NULL) return actual_length; - - remaining -= 4; - if (remaining <= 0) return actual_length; - writeint (c, 0, vendor_length); - c += 4; - - if (stream->vendor) { - field_length = oggz_comment_len (stream->vendor); - memcpy (c, stream->vendor, MIN (field_length, remaining)); - c += field_length; remaining -= field_length; - if (remaining <= 0) return actual_length; - } - - remaining -= 4; - if (remaining <= 0) return actual_length; - writeint (c, 0, nb_fields); - c += 4; - - for (comment = oggz_comment_first (oggz, serialno); comment; - comment = oggz_comment_next (oggz, serialno, comment)) { - - field_length = oggz_comment_len (comment->name); /* [size]"name" */ - if (comment->value) - field_length += 1 + oggz_comment_len (comment->value); /* "=value" */ - - remaining -= 4; - if (remaining <= 0) return actual_length; - writeint (c, 0, field_length); - c += 4; - - field_length = oggz_comment_len (comment->name); - memcpy (c, comment->name, MIN (field_length, remaining)); - c += field_length; remaining -= field_length; - if (remaining <= 0) return actual_length; - - if (comment->value) { - remaining --; - if (remaining <= 0) return actual_length; - *c = '='; - c++; - - field_length = oggz_comment_len (comment->value); - memcpy (c, comment->value, MIN (field_length, remaining)); - c += field_length; remaining -= field_length; - if (remaining <= 0) return actual_length; - } - } - - if (remaining <= 0) return actual_length; - *c = 0x01; - - return actual_length; -} - -/* NB. Public use of this function is deprecated; the simpler - * oggz_comments_generate() automatically determines the packet_type */ -ogg_packet * -oggz_comment_generate(OGGZ * oggz, long serialno, - OggzStreamContent packet_type, - int FLAC_final_metadata_block) -{ - ogg_packet *c_packet; - - unsigned char *buffer; - unsigned const char *preamble; - long preamble_length, comment_length, buf_size; - - /* Some types use preambles in the comment packet. FLAC is notable; - n9-32 should contain the length of the comment data as 24bit unsigned - BE, and the first octet should be ORed with 0x80 if this is the last - (only) metadata block. Any user doing FLAC has to know how to do the - encapsulation anyway. */ - const unsigned char preamble_vorbis[7] = - {0x03, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73}; - const unsigned char preamble_theora[7] = - {0x81, 0x74, 0x68, 0x65, 0x6f, 0x72, 0x61}; - const unsigned char preamble_flac[4] = - {0x04, 0x00, 0x00, 0x00}; - const unsigned char preamble_kate[9] = - {0x81, 0x6b, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00}; - - - switch(packet_type) { - case OGGZ_CONTENT_VORBIS: - preamble_length = sizeof preamble_vorbis; - preamble = preamble_vorbis; - break; - case OGGZ_CONTENT_THEORA: - preamble_length = sizeof preamble_theora; - preamble = preamble_theora; - break; - case OGGZ_CONTENT_FLAC: - preamble_length = sizeof preamble_flac; - preamble = preamble_flac; - break; - case OGGZ_CONTENT_KATE: - preamble_length = sizeof preamble_kate; - preamble = preamble_kate; - break; - case OGGZ_CONTENT_PCM: - case OGGZ_CONTENT_SPEEX: - preamble_length = 0; - preamble = 0; - /* No preamble for these */ - break; - default: - return NULL; - } - - comment_length = oggz_comments_encode (oggz, serialno, 0, 0); - if(comment_length <= 0) { - return NULL; - } - - buf_size = preamble_length + comment_length; - - if(packet_type == OGGZ_CONTENT_FLAC && comment_length >= 0x00ffffff) { - return NULL; - } - - c_packet = oggz_malloc(sizeof *c_packet); - if(c_packet) { - memset(c_packet, 0, sizeof *c_packet); - c_packet->packetno = 1; - c_packet->packet = oggz_malloc(buf_size); - } - - if(c_packet && c_packet->packet) { - buffer = c_packet->packet; - if(preamble_length) { - memcpy(buffer, preamble, preamble_length); - if(packet_type == OGGZ_CONTENT_FLAC) { - /* Use comment_length-1 as we will be stripping the Vorbis - framing byte. */ - /* MACRO */ - writeint24be(c_packet->packet, 1, (comment_length-1) ); - if(FLAC_final_metadata_block) - { - c_packet->packet[0] |= 0x80; - } - } - buffer += preamble_length; - } - oggz_comments_encode (oggz, serialno, buffer, comment_length); - c_packet->bytes = buf_size; - /* The framing byte for Vorbis shouldn't affect any of the other - types, but strip it anyway. */ - if(packet_type != OGGZ_CONTENT_VORBIS) - { - c_packet->bytes -= 1; - } - } else { - oggz_free(c_packet); - c_packet = 0; - } - - return c_packet; -} - -/* In Flac, OggPCM, Speex, Theora Vorbis, and Kate the comment packet will - be second in the stream, i.e. packetno=1, and it will have granulepos=0 */ -ogg_packet * -oggz_comments_generate(OGGZ * oggz, long serialno, - int FLAC_final_metadata_block) -{ - OggzStreamContent packet_type; - - packet_type = oggz_stream_get_content (oggz, serialno); - - return oggz_comment_generate (oggz, serialno, packet_type, - FLAC_final_metadata_block); -} - -void oggz_packet_destroy(ogg_packet *packet) { - if(packet) { - if(packet->packet) - { - oggz_free(packet->packet); - } - oggz_free(packet); - } - return; -} diff --git a/media/liboggz/src/liboggz/oggz_compat.h b/media/liboggz/src/liboggz/oggz_compat.h deleted file mode 100644 index c0da1a37921..00000000000 --- a/media/liboggz/src/liboggz/oggz_compat.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#ifndef WIN32 -# define oggz_stat_regular(mode) (S_ISREG((mode)) || S_ISLNK((mode))) -#else -# define oggz_stat_regular(mode) ((mode) & S_IFREG) -#endif diff --git a/media/liboggz/src/liboggz/oggz_dlist.c b/media/liboggz/src/liboggz/oggz_dlist.c deleted file mode 100644 index 5702c529fe9..00000000000 --- a/media/liboggz/src/liboggz/oggz_dlist.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" -#include - -#include "oggz_dlist.h" -#include "oggz_macros.h" - -typedef struct OggzDListElem { - struct OggzDListElem * next; - struct OggzDListElem * prev; - void * data; -} OggzDListElem; - -struct _OggzDList { - OggzDListElem * head; - OggzDListElem * tail; -}; - -OggzDList * -oggz_dlist_new (void) { - - OggzDList *dlist; - OggzDListElem *dummy_front, *dummy_back; - - dlist = oggz_malloc(sizeof(OggzDList)); - if (dlist == NULL) return NULL; - - dummy_front = oggz_malloc(sizeof(OggzDListElem)); - if (dummy_front == NULL) { - oggz_free (dlist); - return NULL; - } - - dummy_back = oggz_malloc(sizeof(OggzDListElem)); - if (dummy_back == NULL) { - oggz_free (dummy_front); - oggz_free (dlist); - return NULL; - } - - dummy_front->next = dummy_back; - dummy_front->prev = NULL; - - dummy_back->prev = dummy_front; - dummy_back->next = NULL; - - dlist->head = dummy_front; - dlist->tail = dummy_back; - - return dlist; -} - -void -oggz_dlist_delete(OggzDList *dlist) { - - OggzDListElem *p; - - for (p = dlist->head->next; p != NULL; p = p->next) { - oggz_free(p->prev); - } - - oggz_free(dlist->tail); - oggz_free(dlist); - -} - -int -oggz_dlist_is_empty(OggzDList *dlist) { - return (dlist->head->next == dlist->tail); -} - -int -oggz_dlist_append(OggzDList *dlist, void *elem) { - - OggzDListElem *new_elem; - - if (dlist == NULL) return -1; - - new_elem = oggz_malloc(sizeof(OggzDListElem)); - if (new_elem == NULL) return -1; - - new_elem->data = elem; - new_elem->next = dlist->tail; - new_elem->prev = dlist->tail->prev; - new_elem->prev->next = new_elem; - new_elem->next->prev = new_elem; - - return 0; -} - -int -oggz_dlist_prepend(OggzDList *dlist, void *elem) { - - OggzDListElem *new_elem; - - if (dlist == NULL) return -1; - - new_elem = oggz_malloc(sizeof(OggzDListElem)); - if (new_elem == NULL) return -1; - - new_elem->data = elem; - new_elem->prev = dlist->head; - new_elem->next = dlist->head->next; - new_elem->prev->next = new_elem; - new_elem->next->prev = new_elem; - - return 0; -} - -int -oggz_dlist_iter(OggzDList *dlist, OggzDListIterFunc func) { - - OggzDListElem *p; - - for (p = dlist->head->next; p != dlist->tail; p = p->next) { - int r = func(p->data); - if (r == DLIST_ITER_ERROR) { - return -1; - } - - if (r == DLIST_ITER_CANCEL) { - break; - } - } - - return 0; -} - -void -oggz_dlist_reverse_iter(OggzDList *dlist, OggzDListIterFunc func) { - - OggzDListElem *p; - - for (p = dlist->tail->prev; p != dlist->head; p = p->prev) { - if (func(p->data) == DLIST_ITER_CANCEL) { - break; - } - } -} - -int -oggz_dlist_deliter(OggzDList *dlist, OggzDListIterFunc func) { - - OggzDListElem *p, *q; - int result = 0; - - for (p = dlist->head->next; p != dlist->tail; p = q) { - int r = func(p->data); - if (r == DLIST_ITER_ERROR) { - result = -1; - } - - if (r == DLIST_ITER_CANCEL) { - break; - } - - q = p->next; - p->prev->next = p->next; - p->next->prev = p->prev; - - oggz_free(p); - } - return result; -} - -void -oggz_dlist_reverse_deliter(OggzDList *dlist, OggzDListIterFunc func) { - - OggzDListElem *p, *q; - - for (p = dlist->tail->prev; p != dlist->head; p = q) { - if (func(p->data) == DLIST_ITER_CANCEL) { - break; - } - q = p->prev; - p->prev->next = p->next; - p->next->prev = p->prev; - - oggz_free(p); - } - -} diff --git a/media/liboggz/src/liboggz/oggz_dlist.h b/media/liboggz/src/liboggz/oggz_dlist.h deleted file mode 100644 index 8955250e672..00000000000 --- a/media/liboggz/src/liboggz/oggz_dlist.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_DLIST_H__ -#define __OGGZ_DLIST_H__ - -struct _OggzDList; -typedef struct _OggzDList OggzDList; - -typedef enum {DLIST_ITER_ERROR=-1, DLIST_ITER_CANCEL=0, DLIST_ITER_CONTINUE=1} OggzDListIterResponse; - -typedef OggzDListIterResponse (*OggzDListIterFunc) (void *elem); - -OggzDList * -oggz_dlist_new (void); - -void -oggz_dlist_delete(OggzDList *dlist); - -int -oggz_dlist_is_empty(OggzDList *dlist); - -int -oggz_dlist_append(OggzDList *dlist, void *elem); - -int -oggz_dlist_prepend(OggzDList *dlist, void *elem); - -int -oggz_dlist_iter(OggzDList *dlist, OggzDListIterFunc func); - -void -oggz_dlist_reverse_iter(OggzDList *dlist, OggzDListIterFunc func); - -int -oggz_dlist_deliter(OggzDList *dlist, OggzDListIterFunc func); - -void -oggz_dlist_reverse_deliter(OggzDList *dlist, OggzDListIterFunc func); - -#endif diff --git a/media/liboggz/src/liboggz/oggz_io.c b/media/liboggz/src/liboggz/oggz_io.c deleted file mode 100644 index 4cf550bdd63..00000000000 --- a/media/liboggz/src/liboggz/oggz_io.c +++ /dev/null @@ -1,328 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggz_io.c - * - * Conrad Parker - */ - -#include "config.h" - -#include -#include -#include -#include - -#include "oggz_compat.h" -#include "oggz_private.h" - -/*#define DEBUG*/ - -size_t -oggz_io_read (OGGZ * oggz, void * buf, size_t n) -{ - OggzIO * io; - size_t bytes; - - if (oggz->file != NULL) { - if ((bytes = fread (buf, 1, n, oggz->file)) == 0) { - if (ferror (oggz->file)) { - return (size_t) OGGZ_ERR_SYSTEM; - } - } - } - - else if ((io = oggz->io) != NULL) { - if (io->read == NULL) return (size_t) -1; - bytes = io->read (io->read_user_handle, buf, n); - } - - else return (size_t) OGGZ_ERR_INVALID; - - return bytes; -} - -size_t -oggz_io_write (OGGZ * oggz, void * buf, size_t n) -{ - OggzIO * io; - size_t bytes; - - if (oggz->file != NULL) { - bytes = fwrite (buf, 1, n, oggz->file); - } - - else if ((io = oggz->io) != NULL) { - if (io->write == NULL) return (size_t) -1; - bytes = io->write (io->write_user_handle, buf, n); - } - - else { - return (size_t) OGGZ_ERR_INVALID; - } - - return bytes; -} - -int -oggz_io_seek (OGGZ * oggz, long offset, int whence) -{ - OggzIO * io; - - if (oggz->file != NULL) { - if (fseek (oggz->file, offset, whence) == -1) { - if (errno == ESPIPE) { - /*oggz_set_error (oggz, OGGZ_ERR_NOSEEK);*/ - } else { - /*oggz_set_error (oggz, OGGZ_ERR_SYSTEM);*/ - } - return OGGZ_ERR_SYSTEM; - } - } - - else if ((io = oggz->io) != NULL) { - if (io->seek == NULL) return -1; - if (io->seek (io->seek_user_handle, offset, whence) == -1) - return -1; - } - - else return OGGZ_ERR_INVALID; - - return 0; -} - -long -oggz_io_tell (OGGZ * oggz) -{ - OggzIO * io; - long offset; - - if (oggz->file != NULL) { - if ((offset = ftell (oggz->file)) == -1) { - if (errno == ESPIPE) { - /*oggz_set_error (oggz, OGGZ_ERR_NOSEEK);*/ - } else { - /*oggz_set_error (oggz, OGGZ_ERR_SYSTEM);*/ - } - return -1; - } - } - - else if ((io = oggz->io) != NULL) { - if (io->tell == NULL) return -1; - if ((offset = io->tell (io->tell_user_handle)) == -1) - return -1; - } - - else return OGGZ_ERR_INVALID; - - return offset; -} - -int -oggz_io_flush (OGGZ * oggz) -{ - OggzIO * io; - - if (oggz->file != NULL) { - if (fflush (oggz->file) == EOF) { - /* check errno for write-related errors */ - return OGGZ_ERR_SYSTEM; - } - } - - else if ((io = oggz->io) != NULL) { - if (io->flush == NULL) return OGGZ_ERR_INVALID; - - if (io->flush (io->flush_user_handle) == -1) { - return -1; - } - } - - else return OGGZ_ERR_INVALID; - - return 0; -} - -/* get/set functions */ - -static int -oggz_io_init (OGGZ * oggz) -{ - oggz->io = (OggzIO *) oggz_malloc (sizeof (OggzIO)); - if (oggz->io == NULL) return -1; - - memset (oggz->io, 0, sizeof (OggzIO)); - - return 0; -} - -int -oggz_io_set_read (OGGZ * oggz, OggzIORead read, void * user_handle) -{ - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - if (oggz->file != NULL) return OGGZ_ERR_INVALID; - - if (oggz->io == NULL) { - if (oggz_io_init (oggz) == -1) - return OGGZ_ERR_OUT_OF_MEMORY; - } - - oggz->io->read = read; - oggz->io->read_user_handle = user_handle; - - return 0; -} - -void * -oggz_io_get_read_user_handle (OGGZ * oggz) -{ - if (oggz == NULL) return NULL; - if (oggz->file != NULL) return NULL; - - if (oggz->io == NULL) return NULL; - - return oggz->io->read_user_handle; -} - -int -oggz_io_set_write (OGGZ * oggz, OggzIOWrite write, void * user_handle) -{ - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - if (oggz->file != NULL) return OGGZ_ERR_INVALID; - - if (oggz->io == NULL) { - if (oggz_io_init (oggz) == -1) - return OGGZ_ERR_OUT_OF_MEMORY; - } - - oggz->io->write = write; - oggz->io->write_user_handle = user_handle; - - return 0; -} - -void * -oggz_io_get_write_user_handle (OGGZ * oggz) -{ - if (oggz == NULL) return NULL; - if (oggz->file != NULL) return NULL; - - if (oggz->io == NULL) return NULL; - - return oggz->io->write_user_handle; -} - -int -oggz_io_set_seek (OGGZ * oggz, OggzIOSeek seek, void * user_handle) -{ - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - if (oggz->file != NULL) return OGGZ_ERR_INVALID; - - if (oggz->io == NULL) { - if (oggz_io_init (oggz) == -1) - return OGGZ_ERR_OUT_OF_MEMORY; - } - - oggz->io->seek = seek; - oggz->io->seek_user_handle = user_handle; - - return 0; -} - -void * -oggz_io_get_seek_user_handle (OGGZ * oggz) -{ - if (oggz == NULL) return NULL; - if (oggz->file != NULL) return NULL; - - if (oggz->io == NULL) return NULL; - - return oggz->io->seek_user_handle; -} - -int -oggz_io_set_tell (OGGZ * oggz, OggzIOTell tell, void * user_handle) -{ - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - if (oggz->file != NULL) return OGGZ_ERR_INVALID; - - if (oggz->io == NULL) { - if (oggz_io_init (oggz) == -1) - return OGGZ_ERR_OUT_OF_MEMORY; - } - - oggz->io->tell = tell; - oggz->io->tell_user_handle = user_handle; - - return 0; -} - -void * -oggz_io_get_tell_user_handle (OGGZ * oggz) -{ - if (oggz == NULL) return NULL; - if (oggz->file != NULL) return NULL; - - if (oggz->io == NULL) return NULL; - - return oggz->io->tell_user_handle; -} - -int -oggz_io_set_flush (OGGZ * oggz, OggzIOFlush flush, void * user_handle) -{ - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - if (oggz->file != NULL) return OGGZ_ERR_INVALID; - - if (oggz->io == NULL) { - if (oggz_io_init (oggz) == -1) - return OGGZ_ERR_OUT_OF_MEMORY; - } - - oggz->io->flush = flush; - oggz->io->flush_user_handle = user_handle; - - return 0; -} - -void * -oggz_io_get_flush_user_handle (OGGZ * oggz) -{ - if (oggz == NULL) return NULL; - if (oggz->file != NULL) return NULL; - - if (oggz->io == NULL) return NULL; - - return oggz->io->flush_user_handle; -} diff --git a/media/liboggz/src/liboggz/oggz_macros.h b/media/liboggz/src/liboggz/oggz_macros.h deleted file mode 100644 index 6709219d12b..00000000000 --- a/media/liboggz/src/liboggz/oggz_macros.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_MACROS_H__ -#define __OGGZ_MACROS_H__ - -#include -#include - -/* Use the malloc and free used by ogg; defaults are those from stdlib */ -#define oggz_malloc _ogg_malloc -#define oggz_realloc _ogg_realloc -#define oggz_free _ogg_free - -#undef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) - -#undef MAX -#define MAX(a,b) ((a)>(b)?(a):(b)) - -/* -** Inspiration : http://sourcefrog.net/weblog/software/languages/C/unused.html -*/ -#ifdef UNUSED -#elif defined (__GNUC__) -# define UNUSED(x) UNUSED_ ## x __attribute__ ((unused)) -#elif defined (__LCLINT__) -# define UNUSED(x) /*@unused@*/ x -#else -# define UNUSED(x) x -#endif - -#ifdef __GNUC__ -# define WARN_UNUSED __attribute__ ((warn_unused_result)) -#else -# define WARN_UNUSED -#endif - -#endif /* __OGGZ_MACROS_H__ */ diff --git a/media/liboggz/src/liboggz/oggz_private.h b/media/liboggz/src/liboggz/oggz_private.h deleted file mode 100644 index 3ae91490e43..00000000000 --- a/media/liboggz/src/liboggz/oggz_private.h +++ /dev/null @@ -1,325 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_PRIVATE_H__ -#define __OGGZ_PRIVATE_H__ - -#include -#include - -#include -#include -#include - -#include "oggz_macros.h" -#include "oggz_vector.h" -#include "oggz_dlist.h" - -#define OGGZ_AUTO_MULT 1000Ull - -typedef struct _OGGZ OGGZ; -typedef struct _OggzComment OggzComment; -typedef struct _OggzIO OggzIO; -typedef struct _OggzReader OggzReader; -typedef struct _OggzWriter OggzWriter; - - -typedef int (*OggzReadPacket) (OGGZ * oggz, ogg_packet * op, long serialno, - void * user_data); -typedef int (*OggzReadPage) (OGGZ * oggz, const ogg_page * og, long serialno, - void * user_data); - -/* oggz_stream */ -#include "oggz_stream_private.h" - -typedef ogg_int64_t (*OggzMetric) (OGGZ * oggz, long serialno, - ogg_int64_t granulepos, - void * user_data); - -typedef int (*OggzOrder) (OGGZ * oggz, ogg_packet * op, void * target, - void * user_data); - -typedef int (*OggzWriteHungry) (OGGZ * oggz, int empty, void * user_data); - -/* oggz_io */ -typedef size_t (*OggzIORead) (void * user_handle, void * buf, size_t n); -typedef size_t (*OggzIOWrite) (void * user_handle, void * buf, size_t n); -typedef int (*OggzIOSeek) (void * user_handle, long offset, int whence); -typedef long (*OggzIOTell) (void * user_handle); -typedef int (*OggzIOFlush) (void * user_handle); - -struct _oggz_stream_t { - ogg_stream_state ogg_stream; - - /** STATIC INFO */ - int content; - int numheaders; - int preroll; - ogg_int64_t granulerate_n; - ogg_int64_t granulerate_d; - ogg_int64_t first_granule; - ogg_int64_t basegranule; - int granuleshift; - - /* The comments */ - char * vendor; - OggzVector * comments; - - /** CURRENT STATE **/ - /* non b_o_s packet has been written (not just queued) */ - int delivered_non_b_o_s; - - int b_o_s; /* beginning of stream */ - int e_o_s; /* end of stream */ - ogg_int64_t granulepos; - ogg_int64_t packetno; - - /** CALLBACKS **/ - OggzMetric metric; - void * metric_user_data; - int metric_internal; - - OggzOrder order; - void * order_user_data; - - OggzReadPacket read_packet; - void * read_user_data; - - OggzReadPage read_page; - void * read_page_user_data; - - /* calculated granulepos values, not extracted values */ - ogg_int64_t last_granulepos; - ogg_int64_t page_granulepos; - void * calculate_data; - ogg_packet * last_packet; -}; - -struct _OggzReader { - ogg_sync_state ogg_sync; - - /* XXX: these two can prolly be removed again :) */ - ogg_stream_state ogg_stream; - long current_serialno; - - OggzReadPacket read_packet; - void * read_user_data; - - OggzReadPage read_page; - void * read_page_user_data; - - ogg_int64_t current_unit; - ogg_int64_t current_granulepos; - - long current_page_bytes; -#if 0 - oggz_off_t offset_page_end; /* offset of end of current page */ -#endif -}; - -/** - * Bundle a packet with the stream it is being queued for; used in - * the packet_queue vector - */ -typedef struct { - ogg_packet op; - oggz_stream_t * stream; - int flush; - int * guard; -} oggz_writer_packet_t; - -enum oggz_writer_state { - OGGZ_MAKING_PACKETS = 0, - OGGZ_WRITING_PAGES = 1 -}; - -struct _OggzWriter { - oggz_writer_packet_t * next_zpacket; /* stashed in case of FLUSH_BEFORE */ - OggzVector * packet_queue; - - OggzWriteHungry hungry; - void * hungry_user_data; - int hungry_only_when_empty; - - int writing; /* already mid-write; check for recursive writes */ - int state; /* OGGZ_MAKING_PACKETS or OGGZ_WRITING_PAGES */ - - int flushing; /* whether current packet is being flushed or just paged out */ - -#if 0 - int eog; /* end of page */ - int eop; /* end of packet */ -#endif - int eos; /* end of stream */ - - oggz_writer_packet_t * current_zpacket; - - int packet_offset; /* n bytes already copied out of current packet */ - int page_offset; /* n bytes already copied out of current page */ - - ogg_stream_state * current_stream; - - int no_more_packets; /* used only in the local oggz_write loop to indicate - end of stream */ - -}; - -struct _OggzIO { - OggzIORead read; - void * read_user_handle; - - OggzIOWrite write; - void * write_user_handle; - - OggzIOSeek seek; - void * seek_user_handle; - - OggzIOTell tell; - void * tell_user_handle; - - OggzIOFlush flush; - void * flush_user_handle; -}; - -struct _OggzComment { - /** The name of the comment, eg. "AUTHOR" */ - char * name; - - /** The value of the comment, as UTF-8 */ - char * value; -}; - -struct _OGGZ { - int flags; - FILE * file; - OggzIO * io; - - ogg_packet current_packet; - ogg_page current_page; - - oggz_off_t offset; /* offset of current page start */ - oggz_off_t offset_data_begin; /* offset of unit 0 page start */ - - long run_blocksize; /* blocksize to use for oggz_run() */ - int cb_next; - - OggzVector * streams; - int all_at_eos; /* all streams are at eos */ - - OggzMetric metric; - void * metric_user_data; - int metric_internal; - - OggzOrder order; - void * order_user_data; - - union { - OggzReader reader; - OggzWriter writer; - } x; - - OggzDList * packet_buffer; -}; - -OGGZ * oggz_read_init (OGGZ * oggz); -OGGZ * oggz_read_close (OGGZ * oggz); - -OGGZ * oggz_write_init (OGGZ * oggz); -int oggz_write_flush (OGGZ * oggz); -OGGZ * oggz_write_close (OGGZ * oggz); - -int oggz_map_return_value_to_error (int cb_ret); - -int oggz_get_bos (OGGZ * oggz, long serialno); -ogg_int64_t oggz_get_unit (OGGZ * oggz, long serialno, ogg_int64_t granulepos); - -int oggz_set_metric_internal (OGGZ * oggz, long serialno, OggzMetric metric, - void * user_data, int internal); -int oggz_has_metrics (OGGZ * oggz); - -int oggz_purge (OGGZ * oggz); - -/* metric_internal */ - -int -oggz_set_granulerate (OGGZ * oggz, long serialno, - ogg_int64_t granule_rate_numerator, - ogg_int64_t granule_rate_denominator); - -int -oggz_get_granulerate (OGGZ * oggz, long serialno, - ogg_int64_t * granulerate_n, - ogg_int64_t * granulerate_d); - -int oggz_set_granuleshift (OGGZ * oggz, long serialno, int granuleshift); -int oggz_get_granuleshift (OGGZ * oggz, long serialno); - -int oggz_set_first_granule (OGGZ * oggz, long serialno, ogg_int64_t first_granule); - -int oggz_set_preroll (OGGZ * oggz, long serialno, int preroll); -int oggz_get_preroll (OGGZ * oggz, long serialno); - -/* oggz_auto */ - -int -oggz_auto_read_bos_page (OGGZ * oggz, ogg_page * og, long serialno, - void * user_data); -int -oggz_auto_read_bos_packet (OGGZ * oggz, ogg_packet * op, long serialno, - void * user_data); - -int -oggz_auto_read_comments (OGGZ * oggz, oggz_stream_t * stream, long serialno, - ogg_packet * op); - -int oggz_auto_identify_page (OGGZ *oggz, ogg_page *og, long serialno); -int oggz_auto_identify_packet (OGGZ * oggz, ogg_packet * op, long serialno); - -/* comments */ -int oggz_comments_init (oggz_stream_t * stream); -int oggz_comments_free (oggz_stream_t * stream); -int oggz_comments_decode (OGGZ * oggz, long serialno, - unsigned char * comments, long length); -long oggz_comments_encode (OGGZ * oggz, long serialno, - unsigned char * buf, long length); - -/* oggz_io */ -size_t oggz_io_read (OGGZ * oggz, void * buf, size_t n); -size_t oggz_io_write (OGGZ * oggz, void * buf, size_t n); -int oggz_io_seek (OGGZ * oggz, long offset, int whence); -long oggz_io_tell (OGGZ * oggz); -int oggz_io_flush (OGGZ * oggz); - -/* oggz_read */ -OggzDListIterResponse oggz_read_free_pbuffers(void *elem); - -#endif /* __OGGZ_PRIVATE_H__ */ diff --git a/media/liboggz/src/liboggz/oggz_read.c b/media/liboggz/src/liboggz/oggz_read.c deleted file mode 100644 index b123a1df498..00000000000 --- a/media/liboggz/src/liboggz/oggz_read.c +++ /dev/null @@ -1,740 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggz_read.c - * - * Conrad Parker - */ - -#include "config.h" - -#if OGGZ_CONFIG_READ - -#include -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include -#include -#include -#include - -#include - -#include "oggz_compat.h" -#include "oggz_private.h" - -#include "oggz/oggz_stream.h" - -/* #define DEBUG */ -/* #define DEBUG_VERBOSE */ - -#define CHUNKSIZE 65536 - -#define OGGZ_READ_EMPTY (-404) - -OGGZ * -oggz_read_init (OGGZ * oggz) -{ - OggzReader * reader = &oggz->x.reader; - - ogg_sync_init (&reader->ogg_sync); - ogg_stream_init (&reader->ogg_stream, (int)-1); - reader->current_serialno = -1; - - reader->read_packet = NULL; - reader->read_user_data = NULL; - - reader->read_page = NULL; - reader->read_page_user_data = NULL; - - reader->current_unit = 0; - - reader->current_page_bytes = 0; - - return oggz; -} - -OGGZ * -oggz_read_close (OGGZ * oggz) -{ - OggzReader * reader = &oggz->x.reader; - - ogg_stream_clear (&reader->ogg_stream); - ogg_sync_clear (&reader->ogg_sync); - - return oggz; -} - -int -oggz_set_read_callback (OGGZ * oggz, long serialno, - OggzReadPacket read_packet, void * user_data) -{ - OggzReader * reader; - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - reader = &oggz->x.reader; - - if (oggz->flags & OGGZ_WRITE) { - return OGGZ_ERR_INVALID; - } - - if (serialno == -1) { - reader->read_packet = read_packet; - reader->read_user_data = user_data; - } else { - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) - stream = oggz_add_stream (oggz, serialno); - if (stream == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - - stream->read_packet = read_packet; - stream->read_user_data = user_data; - } - - return 0; -} - -int -oggz_set_read_page (OGGZ * oggz, long serialno, OggzReadPage read_page, - void * user_data) -{ - OggzReader * reader; - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - reader = &oggz->x.reader; - - if (oggz->flags & OGGZ_WRITE) { - return OGGZ_ERR_INVALID; - } - - if (serialno == -1) { - reader->read_page = read_page; - reader->read_page_user_data = user_data; - } else { - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) - stream = oggz_add_stream (oggz, serialno); - if (stream == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - - stream->read_page = read_page; - stream->read_page_user_data = user_data; - } - - return 0; -} - -/* - * oggz_read_get_next_page (oggz, og, do_read) - * - * This differs from oggz_get_next_page() in oggz_seek.c in that it - * does not attempt to call oggz_io_read() if the sync buffer is empty. - * - * retrieves the next page. - * returns >= 0 if found; return value is offset of page start - * returns -1 on error - * returns -2 if EOF was encountered - */ -static oggz_off_t -oggz_read_get_next_page (OGGZ * oggz, ogg_page * og) -{ - OggzReader * reader = &oggz->x.reader; - long more = 0, page_offset = 0; - int found = 0; - - /* Increment oggz->offset by length of the last page processed */ - oggz->offset += reader->current_page_bytes; - - do { - more = ogg_sync_pageseek (&reader->ogg_sync, og); - - if (more == 0) { - /* No page available */ - reader->current_page_bytes = 0; - return -2; - } else if (more < 0) { -#ifdef DEBUG_VERBOSE - printf ("get_next_page: skipped %ld bytes\n", -more); -#endif - page_offset += (-more); - } else { -#ifdef DEBUG_VERBOSE - printf ("get_next_page: page has %ld bytes\n", more); -#endif - reader->current_page_bytes = more; - found = 1; - } - - } while (!found); - - oggz->offset += page_offset; - - return oggz->offset; -} - -typedef struct { - ogg_packet packet; - ogg_int64_t calced_granulepos; - oggz_stream_t * stream; - OggzReader * reader; - OGGZ * oggz; - long serialno; -} OggzBufferedPacket; - -OggzBufferedPacket * -oggz_read_new_pbuffer_entry(OGGZ *oggz, ogg_packet *packet, - ogg_int64_t granulepos, long serialno, oggz_stream_t * stream, - OggzReader *reader) { - - OggzBufferedPacket *p = oggz_malloc(sizeof(OggzBufferedPacket)); - if (p == NULL) return NULL; - - memcpy(&(p->packet), packet, sizeof(ogg_packet)); - p->packet.packet = oggz_malloc(packet->bytes); - memcpy(p->packet.packet, packet->packet, packet->bytes); - - p->calced_granulepos = granulepos; - p->stream = stream; - p->serialno = serialno; - p->reader = reader; - p->oggz = oggz; - - return p; -} - -void -oggz_read_free_pbuffer_entry(OggzBufferedPacket *p) { - - oggz_free(p->packet.packet); - oggz_free(p); - -} - -OggzDListIterResponse -oggz_read_free_pbuffers(void *elem) -{ - OggzBufferedPacket *p = (OggzBufferedPacket *)elem; - - oggz_read_free_pbuffer_entry(p); - - return DLIST_ITER_CONTINUE; -} - -OggzDListIterResponse -oggz_read_update_gp(void *elem) { - - OggzBufferedPacket *p = (OggzBufferedPacket *)elem; - - if (p->calced_granulepos == -1 && p->stream->last_granulepos != -1) { - int content = oggz_stream_get_content(p->oggz, p->serialno); - - /* Cancel the iteration (backwards through buffered packets) - * if we don't know the codec */ - if (content < 0 || content >= OGGZ_CONTENT_UNKNOWN) - return DLIST_ITER_CANCEL; - - p->calced_granulepos = - oggz_auto_calculate_gp_backwards(content, p->stream->last_granulepos, - p->stream, &(p->packet), p->stream->last_packet); - - p->stream->last_granulepos = p->calced_granulepos; - p->stream->last_packet = &(p->packet); - } - - return DLIST_ITER_CONTINUE; - -} - -OggzDListIterResponse -oggz_read_deliver_packet(void *elem) { - - OggzBufferedPacket *p = (OggzBufferedPacket *)elem; - ogg_int64_t gp_stored; - ogg_int64_t unit_stored; - - if (p->calced_granulepos == -1) { - return DLIST_ITER_CANCEL; - } - - gp_stored = p->reader->current_granulepos; - unit_stored = p->reader->current_unit; - - p->reader->current_granulepos = p->calced_granulepos; - - p->reader->current_unit = - oggz_get_unit (p->oggz, p->serialno, p->calced_granulepos); - - if (p->stream->read_packet) { - if (p->stream->read_packet(p->oggz, &(p->packet), p->serialno, - p->stream->read_user_data) != 0) { - return DLIST_ITER_ERROR; - } - } else if (p->reader->read_packet) { - if (p->reader->read_packet(p->oggz, &(p->packet), p->serialno, - p->reader->read_user_data) != 0) { - return DLIST_ITER_ERROR; - } - } - - p->reader->current_granulepos = gp_stored; - p->reader->current_unit = unit_stored; - - oggz_read_free_pbuffer_entry(p); - - return DLIST_ITER_CONTINUE; -} - -static int -oggz_read_sync (OGGZ * oggz) -{ - OggzReader * reader = &oggz->x.reader; - - oggz_stream_t * stream; - ogg_stream_state * os; - ogg_packet * op; - long serialno; - - ogg_packet packet; - ogg_page og; - - int cb_ret = 0; - - /*os = &reader->ogg_stream;*/ - op = &packet; - - /* handle one packet. Try to fetch it from current stream state */ - /* extract packets from page */ - while(cb_ret == 0) { - - if (reader->current_serialno != -1) { - /* process a packet if we can. If the machine isn't loaded, - neither is a page */ - while(cb_ret == 0) { - ogg_int64_t granulepos; - int result; - - serialno = reader->current_serialno; - - stream = oggz_get_stream (oggz, serialno); - - if (stream == NULL) { - /* new stream ... check bos etc. */ - if ((stream = oggz_add_stream (oggz, serialno)) == NULL) { - /* error -- could not add stream */ - return OGGZ_ERR_OUT_OF_MEMORY; - } - } - os = &stream->ogg_stream; - - result = ogg_stream_packetout(os, op); - - /* - * libogg flags "holes in the data" (which are really inconsistencies - * in the page sequence number) by returning -1. - */ - if(result == -1) { -#ifdef DEBUG - printf ("oggz_read_sync: hole in the data\n"); -#endif - /* We can't tolerate holes in headers, so bail out. NB. as stream->packetno - * has not yet been incremented, the current value refers to how many packets - * have been processed prior to this one. */ - if (stream->packetno < 2) return OGGZ_ERR_HOLE_IN_DATA; - - /* Holes in content occur in some files and pretty much don't matter, - * so we silently swallow the notification and reget the packet. - */ - result = ogg_stream_packetout(os, op); - if (result == -1) { - /* If the result is *still* -1 then something strange is - * happening. - */ -#ifdef DEBUG - printf ("Multiple holes in data!"); -#endif - return OGGZ_ERR_HOLE_IN_DATA; - } - } - - if(result > 0){ - int content; - - stream->packetno++; - - /* got a packet. process it */ - granulepos = op->granulepos; - - content = oggz_stream_get_content(oggz, serialno); - if (content < 0 || content >= OGGZ_CONTENT_UNKNOWN) { - reader->current_granulepos = granulepos; - } else { - /* if we have no metrics for this stream yet, then generate them */ - if ((!stream->metric || content == OGGZ_CONTENT_SKELETON) && - (oggz->flags & OGGZ_AUTO)) { - oggz_auto_read_bos_packet (oggz, op, serialno, NULL); - } - - /* attempt to determine granulepos for this packet */ - if (oggz->flags & OGGZ_AUTO) { - reader->current_granulepos = - oggz_auto_calculate_granulepos (content, granulepos, stream, op); - /* make sure that we accept any "real" gaps in the granulepos */ - if (granulepos != -1 && reader->current_granulepos < granulepos) { - reader->current_granulepos = granulepos; - } - } else { - reader->current_granulepos = granulepos; - } - } - - stream->last_granulepos = reader->current_granulepos; - - /* set unit on last packet of page */ - if - ( - (oggz->metric || stream->metric) && reader->current_granulepos != -1 - ) - { - reader->current_unit = - oggz_get_unit (oggz, serialno, reader->current_granulepos); - } - - if (stream->packetno == 1) { - oggz_auto_read_comments (oggz, stream, serialno, op); - } - - if (oggz->flags & OGGZ_AUTO) { - - /* - * while we are getting invalid granulepos values, store the - * incoming packets in a dlist */ - if (reader->current_granulepos == -1) { - OggzBufferedPacket *p = oggz_read_new_pbuffer_entry( - oggz, &packet, reader->current_granulepos, - serialno, stream, reader); - - oggz_dlist_append(oggz->packet_buffer, p); - continue; - } else if (!oggz_dlist_is_empty(oggz->packet_buffer)) { - /* - * move backward through the list assigning gp values based upon - * the granulepos we just recieved. Then move forward through - * the list delivering any packets at the beginning with valid - * gp values - */ - ogg_int64_t gp_stored = stream->last_granulepos; - stream->last_packet = &packet; - oggz_dlist_reverse_iter(oggz->packet_buffer, oggz_read_update_gp); - if (oggz_dlist_deliter(oggz->packet_buffer, oggz_read_deliver_packet) == -1) { - return OGGZ_ERR_HOLE_IN_DATA; - } - - /* - * fix up the stream granulepos - */ - stream->last_granulepos = gp_stored; - - if (!oggz_dlist_is_empty(oggz->packet_buffer)) { - OggzBufferedPacket *p = oggz_read_new_pbuffer_entry( - oggz, &packet, reader->current_granulepos, - serialno, stream, reader); - - oggz_dlist_append(oggz->packet_buffer, p); - continue; - } - } - } - - if (stream->read_packet) { - cb_ret = - stream->read_packet (oggz, op, serialno, stream->read_user_data); - } else if (reader->read_packet) { - cb_ret = - reader->read_packet (oggz, op, serialno, reader->read_user_data); - } - - /* Mark this stream as having delivered a non b_o_s packet if so. - * In the case where there is no packet reading callback, this is - * also valid as the page reading callback has already been called. - */ - if (!op->b_o_s) stream->delivered_non_b_o_s = 1; - } - else - break; - } - } - - /* If we've got a stop already, don't read more data in */ - if (cb_ret < 0 || cb_ret == OGGZ_STOP_OK) - return cb_ret; - - if(oggz_read_get_next_page (oggz, &og) < 0) - return OGGZ_READ_EMPTY; /* eof. leave uninitialized */ - - serialno = ogg_page_serialno (&og); - reader->current_serialno = serialno; /* XXX: maybe not necessary */ - - stream = oggz_get_stream (oggz, serialno); - - if (stream == NULL) { - /* new stream ... check bos etc. */ - if ((stream = oggz_add_stream (oggz, serialno)) == NULL) { - /* error -- could not add stream */ - return OGGZ_ERR_OUT_OF_MEMORY; - } - - /* identify stream type */ - oggz_auto_identify_page (oggz, &og, serialno); - - /* read bos data */ - if (oggz->flags & OGGZ_AUTO) - oggz_auto_read_bos_page (oggz, &og, serialno, NULL); - } - else if (oggz_stream_get_content(oggz, serialno) == OGGZ_CONTENT_ANXDATA) - { - /* - * re-identify ANXDATA streams as these are now content streams - */ - oggz_auto_identify_page (oggz, &og, serialno); - } - - os = &stream->ogg_stream; - - { - ogg_int64_t granulepos; - - granulepos = ogg_page_granulepos (&og); - stream->page_granulepos = granulepos; - - if ((oggz->metric || stream->metric) && granulepos != -1) { - reader->current_unit = oggz_get_unit (oggz, serialno, granulepos); - } else if (granulepos == 0) { - reader->current_unit = 0; - } - } - - if (stream->read_page) { - cb_ret = - stream->read_page (oggz, &og, serialno, stream->read_page_user_data); - } else if (reader->read_page) { - cb_ret = - reader->read_page (oggz, &og, serialno, reader->read_page_user_data); - } - - ogg_stream_pagein(os, &og); - } - - return cb_ret; -} - -long -oggz_read (OGGZ * oggz, long n) -{ - OggzReader * reader; - char * buffer; - long bytes, bytes_read = 1, remaining = n, nread = 0; - int cb_ret = 0; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (oggz->flags & OGGZ_WRITE) { - return OGGZ_ERR_INVALID; - } - - if ((cb_ret = oggz->cb_next) != OGGZ_CONTINUE) { - oggz->cb_next = 0; - return oggz_map_return_value_to_error (cb_ret); - } - - reader = &oggz->x.reader; - - cb_ret = oggz_read_sync (oggz); - if (cb_ret == OGGZ_ERR_OUT_OF_MEMORY) - return cb_ret; - - while (cb_ret != OGGZ_STOP_ERR && cb_ret != OGGZ_STOP_OK && - bytes_read > 0 && remaining > 0) { - bytes = MIN (remaining, CHUNKSIZE); - buffer = ogg_sync_buffer (&reader->ogg_sync, bytes); - bytes_read = (long) oggz_io_read (oggz, buffer, bytes); - if (bytes_read == OGGZ_ERR_SYSTEM) { - return OGGZ_ERR_SYSTEM; - } - - if (bytes_read > 0) { - ogg_sync_wrote (&reader->ogg_sync, bytes_read); - - remaining -= bytes_read; - nread += bytes_read; - - cb_ret = oggz_read_sync (oggz); - if (cb_ret == OGGZ_ERR_OUT_OF_MEMORY || cb_ret == OGGZ_ERR_HOLE_IN_DATA) { - return cb_ret; - } - } - } - - if (cb_ret == OGGZ_STOP_ERR) oggz_purge (oggz); - - /* Don't return 0 unless it's actually an EOF condition */ - if (nread == 0) { - switch (bytes_read) { - case OGGZ_ERR_IO_AGAIN: - case OGGZ_ERR_SYSTEM: - return bytes_read; break; - default: break; - } - - if (cb_ret == OGGZ_READ_EMPTY) { - return 0; - } else { - return oggz_map_return_value_to_error (cb_ret); - } - - } else { - if (cb_ret == OGGZ_READ_EMPTY) cb_ret = OGGZ_CONTINUE; - oggz->cb_next = cb_ret; - } - - return nread; -} - -/* generic */ -long -oggz_read_input (OGGZ * oggz, unsigned char * buf, long n) -{ - OggzReader * reader; - char * buffer; - long bytes, remaining = n, nread = 0; - int cb_ret = 0; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (oggz->flags & OGGZ_WRITE) { - return OGGZ_ERR_INVALID; - } - - if ((cb_ret = oggz->cb_next) != OGGZ_CONTINUE) { - oggz->cb_next = 0; - return oggz_map_return_value_to_error (cb_ret); - } - - reader = &oggz->x.reader; - - cb_ret = oggz_read_sync (oggz); - if (cb_ret == OGGZ_ERR_OUT_OF_MEMORY) - return cb_ret; - - while (cb_ret != OGGZ_STOP_ERR && cb_ret != OGGZ_STOP_OK && - /* !oggz->eos && */ remaining > 0) { - bytes = MIN (remaining, 4096); - buffer = ogg_sync_buffer (&reader->ogg_sync, bytes); - memcpy (buffer, buf, bytes); - ogg_sync_wrote (&reader->ogg_sync, bytes); - - buf += bytes; - remaining -= bytes; - nread += bytes; - - cb_ret = oggz_read_sync (oggz); - if (cb_ret == OGGZ_ERR_OUT_OF_MEMORY) - return cb_ret; - } - - if (cb_ret == OGGZ_STOP_ERR) oggz_purge (oggz); - - if (nread == 0) { - /* Don't return 0 unless it's actually an EOF condition */ - if (cb_ret == OGGZ_READ_EMPTY) { - return OGGZ_ERR_STOP_OK; - } else { - return oggz_map_return_value_to_error (cb_ret); - } - } else { - if (cb_ret == OGGZ_READ_EMPTY) cb_ret = OGGZ_CONTINUE; - oggz->cb_next = cb_ret; - } - - return nread; -} - - -#else /* OGGZ_CONFIG_READ */ - -#include -#include "oggz_private.h" - -OGGZ * -oggz_read_init (OGGZ * oggz) -{ - return NULL; -} - -OGGZ * -oggz_read_close (OGGZ * oggz) -{ - return NULL; -} - -int -oggz_set_read_callback (OGGZ * oggz, long serialno, - OggzReadPacket read_packet, void * user_data) -{ - return OGGZ_ERR_DISABLED; -} - -long -oggz_read (OGGZ * oggz, long n) -{ - return OGGZ_ERR_DISABLED; -} - -long -oggz_read_input (OGGZ * oggz, unsigned char * buf, long n) -{ - return OGGZ_ERR_DISABLED; -} - -#endif diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c deleted file mode 100644 index 01b90cbb5f3..00000000000 --- a/media/liboggz/src/liboggz/oggz_seek.c +++ /dev/null @@ -1,1022 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * oggz_seek.c - * - * Conrad Parker - */ - -#include "config.h" - -#if OGGZ_CONFIG_READ - -#include -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include -#include -#include -#include - -#include - -#include "oggz_compat.h" -#include "oggz_private.h" - -/*#define DEBUG*/ -/*#define DEBUG_VERBOSE*/ - -#define CHUNKSIZE 4096 - -/* - * The typical usage is: - * - * oggz_set_data_start (oggz, oggz_tell (oggz)); - */ -int -oggz_set_data_start (OGGZ * oggz, oggz_off_t offset) -{ - if (oggz == NULL) return -1; - - if (offset < 0) return -1; - - oggz->offset_data_begin = offset; - - return 0; -} - -static oggz_off_t -oggz_tell_raw (OGGZ * oggz) -{ - oggz_off_t offset_at; - - offset_at = oggz_io_tell (oggz); - - return offset_at; -} - -/* - * seeks and syncs - */ - -int -oggz_seek_reset_stream(void *data) { - ((oggz_stream_t *)data)->last_granulepos = -1L; - return 0; -} - -static oggz_off_t -oggz_seek_raw (OGGZ * oggz, oggz_off_t offset, int whence) -{ - OggzReader * reader = &oggz->x.reader; - oggz_off_t offset_at; - - if (oggz_io_seek (oggz, offset, whence) == -1) { - return -1; - } - - offset_at = oggz_io_tell (oggz); - - oggz->offset = offset_at; - - ogg_sync_reset (&reader->ogg_sync); - - oggz_vector_foreach(oggz->streams, oggz_seek_reset_stream); - - reader->current_page_bytes = 0; - - return offset_at; -} - -static int -oggz_stream_reset (void * data) -{ - oggz_stream_t * stream = (oggz_stream_t *) data; - - if (stream->ogg_stream.serialno != -1) { - ogg_stream_reset (&stream->ogg_stream); - } - - return 0; -} - -static void -oggz_reset_streams (OGGZ * oggz) -{ - oggz_dlist_deliter(oggz->packet_buffer, oggz_read_free_pbuffers); - oggz_vector_foreach (oggz->streams, oggz_stream_reset); -} - -static long -oggz_reset_seek (OGGZ * oggz, oggz_off_t offset, ogg_int64_t unit, int whence) -{ - OggzReader * reader = &oggz->x.reader; - - oggz_off_t offset_at; - - offset_at = oggz_seek_raw (oggz, offset, whence); - if (offset_at == -1) return -1; - - oggz->offset = offset_at; - -#ifdef DEBUG - printf ("reset to %" PRI_OGGZ_OFF_T "d\n", offset_at); -#endif - - reader->current_unit = unit; - - return offset_at; -} - -static long -oggz_reset (OGGZ * oggz, oggz_off_t offset, ogg_int64_t unit, int whence) -{ - oggz_reset_streams (oggz); - return oggz_reset_seek (oggz, offset, unit, whence); -} - -int -oggz_purge (OGGZ * oggz) -{ - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (oggz->flags & OGGZ_WRITE) { - return OGGZ_ERR_INVALID; - } - - oggz_reset_streams (oggz); - - if (oggz->file && oggz_reset (oggz, oggz->offset, -1, SEEK_SET) < 0) { - return OGGZ_ERR_SYSTEM; - } - - return 0; -} - -/* - * oggz_get_next_page (oggz, og, do_read) - * - * retrieves the next page. - * returns >= 0 if found; return value is offset of page start - * returns -1 on error - * returns -2 if EOF was encountered - */ -static oggz_off_t -oggz_get_next_page (OGGZ * oggz, ogg_page * og) -{ - OggzReader * reader = &oggz->x.reader; - char * buffer; - long bytes = 0, more; - oggz_off_t page_offset = 0; - int found = 0; - - /* Increment oggz->offset by length of the last page processed */ - oggz->offset += reader->current_page_bytes; - - do { - more = ogg_sync_pageseek (&reader->ogg_sync, og); - - if (more == 0) { - buffer = ogg_sync_buffer (&reader->ogg_sync, CHUNKSIZE); - if ((bytes = (long) oggz_io_read (oggz, buffer, CHUNKSIZE)) == 0) { - if (oggz->file && feof (oggz->file)) { -#ifdef DEBUG_VERBOSE - printf ("get_next_page: feof (oggz->file), returning -2\n"); -#endif - clearerr (oggz->file); - reader->current_page_bytes = 0; - return -2; - } - } - if (bytes == OGGZ_ERR_SYSTEM) { - reader->current_page_bytes = 0; - return -1; - } - - if (bytes == 0) { -#ifdef DEBUG_VERBOSE - printf ("get_next_page: bytes == 0, returning -2\n"); -#endif - reader->current_page_bytes = 0; - return -2; - } - - ogg_sync_wrote(&reader->ogg_sync, bytes); - - } else if (more < 0) { -#ifdef DEBUG_VERBOSE - printf ("get_next_page: skipped %ld bytes\n", -more); -#endif - page_offset += (-more); - } else { -#ifdef DEBUG_VERBOSE - printf ("get_next_page: page has %ld bytes\n", more); -#endif - reader->current_page_bytes = more; - found = 1; - } - - } while (!found); - - oggz->offset += page_offset; - - return oggz->offset; -} - -static oggz_off_t -oggz_get_next_start_page (OGGZ * oggz, ogg_page * og) -{ - oggz_off_t page_offset; - int found = 0; - - do { - page_offset = oggz_get_next_page (oggz, og); - - /* Return this value if one of the following conditions is met: - * - * page_offset < 0 : error or EOF - * page_offset == 0 : start of stream - * !ogg_page_continued : page contains start of a packet - * ogg_page_packets > 1: page contains start of a packet - */ - /*if (page_offset <= 0 || !ogg_page_continued (og) || - ogg_page_packets (og) > 1)*/ - if (page_offset <= 0 || ogg_page_granulepos(og) > -1) - found = 1; - } - while (!found); - - return page_offset; -} - -static oggz_off_t -oggz_get_prev_start_page (OGGZ * oggz, ogg_page * og, - ogg_int64_t * granule, long * serialno) -{ - oggz_off_t offset_at, offset_start; - oggz_off_t page_offset, found_offset = 0; - ogg_int64_t unit_at; - ogg_int64_t granule_at = -1; - -#if 0 - offset_at = oggz_tell_raw (oggz); - if (offset_at == -1) return -1; -#else - offset_at = oggz->offset; -#endif - - offset_start = offset_at; - - do { - - offset_start = offset_start - CHUNKSIZE; - if (offset_start < 0) offset_start = 0; - - offset_start = oggz_seek_raw (oggz, offset_start, SEEK_SET); - if (offset_start == -1) return -1; - -#ifdef DEBUG - - printf ("get_prev_start_page: [A] offset_at: @%" PRI_OGGZ_OFF_T "d\toffset_start: @%" PRI_OGGZ_OFF_T "d\n", - offset_at, offset_start); - - printf ("get_prev_start_page: seeked to %" PRI_OGGZ_OFF_T "d\n", offset_start); -#endif - - page_offset = 0; - - do { - page_offset = oggz_get_next_start_page (oggz, og); - if (page_offset == -1) { -#ifdef DEBUG - printf ("get_prev_start_page: page_offset = -1\n"); -#endif - return -1; - } - if (page_offset == -2) { -#ifdef DEBUG - printf ("*** get_prev_start_page: page_offset = -2\n"); -#endif - break; - } - - granule_at = ogg_page_granulepos (og); - -#ifdef DEBUG_VERBOSE - printf ("get_prev_start_page: GOT page (%lld) @%" PRI_OGGZ_OFF_T "d\tat @%" PRI_OGGZ_OFF_T "d\n", - granule_at, page_offset, offset_at); -#endif - - /* Need to stash the granule and serialno of this page because og - * will be overwritten by the time we realise this was the desired - * prev page */ - if (page_offset >= 0 && page_offset < offset_at) { - found_offset = page_offset; - *granule = granule_at; - *serialno = ogg_page_serialno (og); - } - - } while (page_offset >= 0 && page_offset < offset_at); - -#ifdef DEBUG - printf ("get_prev_start_page: [B] offset_at: @%" PRI_OGGZ_OFF_T "d\toffset_start: @%" PRI_OGGZ_OFF_T "d\n" - "found_offset: @%" PRI_OGGZ_OFF_T "d\tpage_offset: @%" PRI_OGGZ_OFF_T "d\n", - offset_at, offset_start, found_offset, page_offset); -#endif - /* reset the file offset */ - /*offset_at = offset_start;*/ - - } while (found_offset == 0 && offset_start > 0); - - unit_at = oggz_get_unit (oggz, *serialno, *granule); - offset_at = oggz_reset (oggz, found_offset, unit_at, SEEK_SET); - -#ifdef DEBUG - printf ("get_prev_start_page: [C] offset_at: @%" PRI_OGGZ_OFF_T "d\t" - "found_offset: @%" PRI_OGGZ_OFF_T "d\tunit_at: %lld\n", - offset_at, found_offset, unit_at); -#endif - - if (offset_at == -1) return -1; - - if (offset_at >= 0) - return found_offset; - else - return -1; -} - -static oggz_off_t -oggz_scan_for_page (OGGZ * oggz, ogg_page * og, ogg_int64_t unit_target, - oggz_off_t offset_begin, oggz_off_t offset_end) -{ - oggz_off_t offset_at, offset_next; - oggz_off_t offset_prev = -1; - ogg_int64_t granule_at; - ogg_int64_t unit_at; - long serialno; - -#ifdef DEBUG - printf (" SCANNING from %" PRI_OGGZ_OFF_T "d...", offset_begin); -#endif - - for ( ; ; ) { - offset_at = oggz_seek_raw (oggz, offset_begin, SEEK_SET); - if (offset_at == -1) return -1; - -#ifdef DEBUG - printf (" scan @%" PRI_OGGZ_OFF_T "d\n", offset_at); -#endif - - offset_next = oggz_get_next_start_page (oggz, og); - - if (offset_next < 0) { - return offset_next; - } - - if (offset_next == 0 && offset_begin != 0) { -#ifdef DEBUG - printf (" ... scanned past EOF\n"); -#endif - return -1; - } - if (offset_next > offset_end) { -#ifdef DEBUG - printf (" ... scanned to page %ld\n", (long)ogg_page_granulepos (og)); -#endif - -#if 0 - if (offset_prev != -1) { - offset_at = oggz_seek_raw (oggz, offset_prev, SEEK_SET); - if (offset_at == -1) return -1; - - offset_next = oggz_get_next_start_page (oggz, og); - if (offset_next < 0) return offset_next; - - serialno = ogg_page_serialno (og); - granule_at = ogg_page_granulepos (og); - unit_at = oggz_get_unit (oggz, serialno, granule_at); - - return offset_at; - } else { - return -1; - } -#else - serialno = ogg_page_serialno (og); - granule_at = ogg_page_granulepos (og); - unit_at = oggz_get_unit (oggz, serialno, granule_at); - - return offset_at; -#endif - } - - offset_at = offset_next; - - serialno = ogg_page_serialno (og); - granule_at = ogg_page_granulepos (og); - unit_at = oggz_get_unit (oggz, serialno, granule_at); - - if (unit_at < unit_target) { -#ifdef DEBUG - printf (" scan: (%lld) < (%lld)\n", unit_at, unit_target); -#endif - offset_prev = offset_next; - offset_begin = offset_next+1; - } else if (unit_at > unit_target) { -#ifdef DEBUG - printf (" scan: (%lld) > (%lld)\n", unit_at, unit_target); -#endif -#if 0 - /* hole ? */ - offset_at = oggz_seek_raw (oggz, offset_begin, SEEK_SET); - if (offset_at == -1) return -1; - - offset_next = oggz_get_next_start_page (oggz, og); - if (offset_next < 0) return offset_next; - - serialno = ogg_page_serialno (og); - granule_at = ogg_page_granulepos (og); - unit_at = oggz_get_unit (oggz, serialno, granule_at); - - break; -#else - do { - offset_at = oggz_get_prev_start_page(oggz, og, &granule_at, &serialno); - if (offset_at < 0) - break; - unit_at = oggz_get_unit(oggz, serialno, granule_at); - } while (unit_at > unit_target); - return offset_at; -#endif - } else if (unit_at == unit_target) { -#ifdef DEBUG - printf (" scan: (%lld) == (%lld)\n", unit_at, unit_target); -#endif - break; - } - } - - return offset_at; -} - -#define GUESS_MULTIPLIER (1<<16) - -static ogg_int64_t -guess (ogg_int64_t unit_at, ogg_int64_t unit_target, - ogg_int64_t unit_begin, ogg_int64_t unit_end, - ogg_int64_t offset_begin, ogg_int64_t offset_end) -{ - ogg_int64_t guess_ratio; - ogg_int64_t offset_guess; - - if (unit_end != -1) { - guess_ratio = - GUESS_MULTIPLIER * (unit_target - unit_begin) / - (unit_end - unit_begin); - } else { - guess_ratio = - GUESS_MULTIPLIER * (unit_target - unit_begin) / - (unit_at - unit_begin); - } - - offset_guess = offset_begin + - (((offset_end - offset_begin) * guess_ratio) / - GUESS_MULTIPLIER); - -#ifdef DEBUG - printf("guess: [o=%lld t=%lld]-[o=%lld t=%lld] guess_ratio=%lf offset_guess=%lu\n", - offset_begin, unit_begin, offset_end, unit_end, - ((double)guess_ratio / (double)GUESS_MULTIPLIER), offset_guess); -#endif - - return offset_guess; -} - -static ogg_int64_t -oggz_seek_guess (ogg_int64_t unit_at, - ogg_int64_t unit_target, - ogg_int64_t unit_begin, - ogg_int64_t unit_end, - oggz_off_t offset_at, - oggz_off_t offset_begin, - oggz_off_t offset_end) -{ - oggz_off_t offset_guess; - if (unit_end == -1) { - offset_guess = guess (unit_at, unit_target, unit_begin, unit_end, - offset_begin, offset_at); - } else if (unit_end <= unit_begin) { - offset_guess = -1; - } else { - offset_guess = guess (unit_at, unit_target, unit_begin, unit_end, - offset_begin, offset_end); - } - -#ifdef DEBUG - printf ("oggz_seek_guess: guessed %" PRI_OGGZ_OFF_T "d\n", offset_guess); -#endif - - return offset_guess; -} - -static oggz_off_t -oggz_offset_end (OGGZ * oggz) -{ -#ifndef WINCE - int fd; - struct stat statbuf; -#endif - oggz_off_t offset_end = -1; - - if (oggz->file != NULL) { -#ifndef WINCE - if ((fd = fileno (oggz->file)) == -1) { - /*oggz_set_error (oggz, OGGZ_ERR_SYSTEM);*/ - return -1; - } - - if (fstat (fd, &statbuf) == -1) { - /*oggz_set_error (oggz, OGGZ_ERR_SYSTEM);*/ - return -1; - } - - if (oggz_stat_regular (statbuf.st_mode)) { - offset_end = statbuf.st_size; -#ifdef DEBUG - printf ("oggz_offset_end: stat size %" PRI_OGGZ_OFF_T "d\n", offset_end); -#endif - } else { - /*oggz_set_error (oggz, OGGZ_ERR_NOSEEK);*/ - - /* XXX: should be able to just carry on and guess, as per io */ - /*return -1;*/ - } -#else - int current = ftell(oggz->file); - fseek (oggz->file, 0, SEEK_END); - offset_end = ftell (oggz->file); - fseek (oggz->file, current, SEEK_SET); -#endif - } else { - oggz_off_t offset_save; - - if (oggz->io == NULL || oggz->io->seek == NULL) { - /* No file, and no io seek method */ - return -1; - } - - /* Get the offset of the end by querying the io seek method */ - offset_save = oggz_io_tell (oggz); - if (oggz_io_seek (oggz, 0, SEEK_END) == -1) { - return -1; - } - offset_end = oggz_io_tell (oggz); - if (oggz_io_seek (oggz, offset_save, SEEK_SET) == -1) { - return -1; /* fubar */ - } - } - - return offset_end; -} - -static int -is_header_page(ogg_page* page) -{ - return page && page->header[5] & 0x2; -} - -ogg_int64_t -oggz_bounded_seek_set (OGGZ * oggz, - ogg_int64_t unit_target, - ogg_int64_t offset_begin, - ogg_int64_t offset_end, - int fuzz_margin) -{ - OggzReader * reader; - ogg_int64_t offset_orig, offset_at, offset_guess; - ogg_int64_t offset_next; - ogg_int64_t granule_at; - ogg_int64_t unit_at, unit_begin = -1, unit_end = -1, unit_last_iter = -1; - long serialno; - ogg_page * og; - int hit_eof = 0; - - if (oggz == NULL) { - return -1; - } - - if (unit_target > 0 && !oggz_has_metrics (oggz)) { -#ifdef DEBUG - printf ("oggz_bounded_seek_set: No metric defined, FAIL\n"); -#endif - return -1; - } - - if (offset_end == -1 && (offset_end = oggz_offset_end (oggz)) == -1) { -#ifdef DEBUG - printf ("oggz_bounded_seek_set: oggz_offset_end == -1, FAIL\n"); -#endif - return -1; - } - - reader = &oggz->x.reader; - - if (unit_target == reader->current_unit) { -#ifdef DEBUG - printf ("oggz_bounded_seek_set: unit_target == reader->current_unit, SKIP\n"); -#endif - return (long)reader->current_unit; - } - - if (unit_target == 0) { - offset_at = oggz_reset (oggz, oggz->offset_data_begin, 0, SEEK_SET); - if (offset_at == -1) return -1; - return 0; - } - - offset_at = oggz_tell_raw (oggz); - if (offset_at == -1) return -1; - - offset_orig = oggz->offset; - - unit_at = reader->current_unit; - - og = &oggz->current_page; - - if (unit_end == -1 && oggz_seek_raw (oggz, offset_end, SEEK_SET) >= 0) { - ogg_int64_t granulepos; - - if (oggz_get_prev_start_page (oggz, og, &granulepos, &serialno) >= 0) { - unit_end = oggz_get_unit (oggz, serialno, granulepos); - } - } - - if (unit_begin == -1 && oggz_seek_raw (oggz, offset_begin, SEEK_SET) >= 0) { - ogg_int64_t granulepos = 0; - unit_begin = 0; - - // Take the start time of the range as the end time of the next page. Note - // that if unit_target lies inside that page, its timestamp will be less - // than the page's end time, and it will be considered outside of the range. - // If the next page is a header page, we're at the start of the media, - // and in such a case we can't take the next content-page's granulepos's - // timestamp as unit_begin, as if the target lies inside this page, we'll - // miss it. Assume unit_begin is 0 in that case. See Mozilla bug 518169. - while (oggz_get_next_start_page (oggz, og) >= 0 && - !is_header_page(og) && - unit_begin <= 0) - { - serialno = ogg_page_serialno (og); - granulepos = ogg_page_granulepos (og); - unit_begin = oggz_get_unit (oggz, serialno, granulepos); - } - } - - /* Fail if target isn't in specified range. */ - if (unit_target < unit_begin || unit_target > unit_end) { - oggz_reset (oggz, offset_orig, unit_at, SEEK_SET); - return -1; - } - - /* Reduce the search range if possible using read cursor position. */ - if (unit_at > unit_begin && unit_at < unit_end) { - if (unit_target < unit_at) { - unit_end = unit_at; - offset_end = offset_at; - } else { - unit_begin = unit_at; - offset_begin = offset_at; - } - } - - og = &oggz->current_page; - - for ( ; ; ) { - - unit_last_iter = unit_at; - hit_eof = 0; - -#ifdef DEBUG - printf ("oggz_bounded_seek_set: [A] want u%lld: (u%lld - u%lld) [@%" PRI_OGGZ_OFF_T "d - @%" PRI_OGGZ_OFF_T "d]\n", - unit_target, unit_begin, unit_end, offset_begin, offset_end); -#endif - - offset_guess = oggz_seek_guess (unit_at, unit_target, - unit_begin, unit_end, - offset_at, - offset_begin, offset_end); - if (offset_guess == -1) break; - - if (offset_guess == offset_at) { - /* Already there, looping */ - break; - } - - if (offset_guess > offset_end) { - offset_guess = offset_end; - offset_at = oggz_seek_raw (oggz, offset_guess, SEEK_SET); - if (offset_at == -1) return -1; - offset_next = oggz_get_prev_start_page (oggz, og, &granule_at, &serialno); - } else { - offset_at = oggz_seek_raw (oggz, offset_guess, SEEK_SET); - if (offset_at == -1) return -1; - offset_next = oggz_get_next_start_page (oggz, og); - serialno = ogg_page_serialno (og); - granule_at = ogg_page_granulepos (og); - } - - unit_at = oggz_get_unit (oggz, serialno, granule_at); - - if (abs(unit_at - unit_target) < fuzz_margin) { - // Within fuzz_margin of target, stop. - break; - } - -#ifdef DEBUG - printf ("oggz_bounded_seek_set: offset_next %" PRI_OGGZ_OFF_T "d\n", offset_next); - printf ("oggz_bounded_seek_set: [D] want u%lld, got page u%lld @%" PRI_OGGZ_OFF_T "d g%lld\n", - unit_target, unit_at, offset_at, granule_at); -#endif - - if (unit_at < unit_target) { - offset_begin = offset_next; - unit_begin = unit_at; - if (unit_end == unit_begin) break; - } else if (unit_at > unit_target) { - offset_end = offset_at-1; - unit_end = unit_at; - if (unit_end == unit_begin) break; - } else { - break; - } - } - - /* Reader is now approximately at the seek target. */ - - offset_at = oggz_reset (oggz, offset_next, unit_at, SEEK_SET); - if (offset_at == -1) - return -1; - - return (long)reader->current_unit; -} - -static ogg_int64_t -oggz_seek_end (OGGZ * oggz, ogg_int64_t unit_offset) -{ - oggz_off_t offset_orig, offset_at, offset_end; - ogg_int64_t granulepos; - ogg_int64_t unit_end; - long serialno; - ogg_page * og; - OggzReader * reader = &oggz->x.reader; - - og = &oggz->current_page; - - offset_orig = oggz->offset; - - offset_at = oggz_seek_raw (oggz, 0, SEEK_END); - if (offset_at == -1) return -1; - - offset_end = oggz_get_prev_start_page (oggz, og, &granulepos, &serialno); - - if (offset_end < 0) { - oggz_reset (oggz, offset_orig, -1, SEEK_SET); - return -1; - } - - unit_end = oggz_get_unit (oggz, serialno, granulepos); - -#ifdef DEBUG - printf ("*** oggz_seek_end: found packet (%lld) at @%" PRI_OGGZ_OFF_T "d [%lld]\n", - unit_end, offset_end, granulepos); -#endif - - if (unit_end == -1) { - /* Failed to get time at the end, reset and fail. */ - oggz_reset (oggz, offset_orig, -1, SEEK_SET); - return -1; - } - - reader->current_unit = unit_end; - if (unit_offset == 0) { - return unit_end; - } - return oggz_bounded_seek_set (oggz, unit_end + unit_offset, 0, -1, 0); -} - -off_t -oggz_seek (OGGZ * oggz, oggz_off_t offset, int whence) -{ - OggzReader * reader; - ogg_int64_t units = -1; - - if (oggz == NULL) return -1; - - if (oggz->flags & OGGZ_WRITE) { - return -1; - } - - if (offset == 0 && whence == SEEK_SET) units = 0; - - reader = &oggz->x.reader; - - if (!(offset == 0 && whence == SEEK_CUR)) { - /* Invalidate current_unit */ - reader->current_unit = -1; - } - - return (off_t)oggz_reset (oggz, offset, units, whence); -} - -ogg_int64_t -oggz_seek_units (OGGZ * oggz, ogg_int64_t units, int whence) -{ - OggzReader * reader; - - ogg_int64_t r; - - if (oggz == NULL) { -#ifdef DEBUG - printf ("oggz_seek_units: oggz NULL, FAIL\n"); -#endif - return -1; - } - - if (oggz->flags & OGGZ_WRITE) { -#ifdef DEBUG - printf ("oggz_seek_units: is OGGZ_WRITE, FAIL\n"); -#endif - return -1; - } - - if (!oggz_has_metrics (oggz)) { -#ifdef DEBUG - printf ("oggz_seek_units: !has_metrics, FAIL\n"); -#endif - return -1; - } - - reader = &oggz->x.reader; - - switch (whence) { - case SEEK_SET: - r = oggz_bounded_seek_set (oggz, units, 0, -1, 0); - break; - case SEEK_CUR: - units += reader->current_unit; - r = oggz_bounded_seek_set (oggz, units, 0, -1, 0); - break; - case SEEK_END: - r = oggz_seek_end (oggz, units); - break; - default: - /*oggz_set_error (oggz, OGGZ_EINVALID);*/ - r = -1; - break; - } - - reader->current_granulepos = -1; - return r; -} - -long -oggz_seek_byorder (OGGZ * oggz, void * target) -{ - return -1; -} - -long -oggz_seek_packets (OGGZ * oggz, long serialno, long packets, int whence) -{ - return -1; -} - -#else - -#include -#include "oggz_private.h" - -off_t -oggz_seek (OGGZ * oggz, oggz_off_t offset, int whence) -{ - return OGGZ_ERR_DISABLED; -} - -long -oggz_seek_units (OGGZ * oggz, ogg_int64_t units, int whence) -{ - return OGGZ_ERR_DISABLED; -} - -long -oggz_seek_byorder (OGGZ * oggz, void * target) -{ - return OGGZ_ERR_DISABLED; -} - -long -oggz_seek_packets (OGGZ * oggz, long serialno, long packets, int whence) -{ - return OGGZ_ERR_DISABLED; -} - -#endif - -// Returns the maximum time in milliseconds by which a key frame could be -// offset for a given stream. Ogg granulepos encode time as: -// ((key_frame_number << granule_shift) + frame_offset). -// Therefore the maximum possible time by which any frame could be offset -// from a keyframe is the duration of (1 << granule_shift) - 1) frames. -static ogg_int64_t -get_keyframe_offset(oggz_stream_t* stream) { - ogg_int64_t frame_duration; - ogg_int64_t keyframe_diff; - - if (stream->granuleshift == 0) - return 0; - - // Max number of frames keyframe could possibly be offset. - keyframe_diff = (1 << stream->granuleshift) - 1; - - // Length of frame in ms. - frame_duration = stream->granulerate_d / stream->granulerate_n; - - return frame_duration * keyframe_diff; -} - -// Returns the maximum possible time by which a keyframe could be offset in -// milliseconds, for all streams in the media. -static ogg_int64_t -get_max_keyframe_offset(OGGZ* oggz) { - int i=0, size = 0, max_gshift = 0; - ogg_int64_t max = 0, x; - oggz_stream_t* stream = 0; - size = oggz_vector_size (oggz->streams); - for (i = 0; i < size; i++) { - stream = (oggz_stream_t *)oggz_vector_nth_p (oggz->streams, i); - if (!stream) continue; - x = get_keyframe_offset(stream); - if (x > max) - max = x; - } - return max; -} - -ogg_int64_t -oggz_keyframe_seek_set(OGGZ * oggz, - ogg_int64_t unit_target, - ogg_int64_t offset_begin, - ogg_int64_t offset_end) -{ - ogg_int64_t unit_at; - ogg_int64_t max_keyframe_offset; - const ogg_int64_t fuzz = 500; - ogg_int64_t keyframe_unit_target; - - max_keyframe_offset = get_max_keyframe_offset(oggz); - - keyframe_unit_target = MAX(0, unit_target - max_keyframe_offset - fuzz); - - unit_at = oggz_bounded_seek_set(oggz, - keyframe_unit_target, - offset_begin, - offset_end, - fuzz); - return unit_at; -} diff --git a/media/liboggz/src/liboggz/oggz_stream.c b/media/liboggz/src/liboggz/oggz_stream.c deleted file mode 100644 index 30cdce14ddf..00000000000 --- a/media/liboggz/src/liboggz/oggz_stream.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#include "oggz_private.h" - -int -oggz_stream_set_content (OGGZ * oggz, long serialno, int content) -{ - oggz_stream_t * stream; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - stream->content = content; - - return 0; -} - -OggzStreamContent -oggz_stream_get_content (OGGZ * oggz, long serialno) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - return stream->content; -} - -const char * -oggz_stream_get_content_type (OGGZ *oggz, long serialno) -{ - int content = oggz_stream_get_content(oggz, serialno); - - if (content == OGGZ_ERR_BAD_SERIALNO || content == OGGZ_ERR_BAD_OGGZ) - { - return NULL; - } - - return oggz_auto_codec_ident[content].content_type; -} - -int -oggz_stream_get_numheaders (OGGZ * oggz, long serialno) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - return stream->numheaders; -} - -int -oggz_set_preroll (OGGZ * oggz, long serialno, int preroll) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - stream->preroll = preroll; - - return 0; -} - -int -oggz_get_preroll (OGGZ * oggz, long serialno) -{ - oggz_stream_t * stream; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO; - - return stream->preroll; -} diff --git a/media/liboggz/src/liboggz/oggz_stream.h b/media/liboggz/src/liboggz/oggz_stream.h deleted file mode 100644 index 46b13fe5793..00000000000 --- a/media/liboggz/src/liboggz/oggz_stream.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_STREAM_H__ -#define __OGGZ_STREAM_H__ - -typedef struct _oggz_stream_t oggz_stream_t; - -typedef struct { - const char *bos_str; - int bos_str_len; - const char *content_type; - OggzReadPacket reader; - ogg_int64_t (*calculator)(ogg_int64_t now, oggz_stream_t *stream, - ogg_packet *op); - ogg_int64_t (*r_calculator)(ogg_int64_t next_packet_gp, - oggz_stream_t *stream, ogg_packet *this_packet, - ogg_packet *next_packet); -} oggz_auto_contenttype_t; - -extern const oggz_auto_contenttype_t oggz_auto_codec_ident[]; - - -oggz_stream_t * oggz_get_stream (OGGZ * oggz, long serialno); -oggz_stream_t * oggz_add_stream (OGGZ * oggz, long serialno); - -int oggz_stream_has_metric (OGGZ * oggz, long serialno); -int oggz_stream_set_content (OGGZ * oggz, long serialno, int content); -OggzStreamContent oggz_stream_get_content (OGGZ * oggz, long serialno); -const char * oggz_stream_get_content_type (OGGZ *oggz, long serialno); -ogg_int64_t -oggz_auto_calculate_granulepos(int content, ogg_int64_t now, - oggz_stream_t *stream, ogg_packet *op); - -ogg_int64_t -oggz_auto_calculate_gp_backwards(int content, ogg_int64_t next_packet_gp, - oggz_stream_t *stream, ogg_packet *this_packet, ogg_packet *next_packet); - -#endif /* __OGGZ_STREAM_H__ */ diff --git a/media/liboggz/src/liboggz/oggz_stream_private.h b/media/liboggz/src/liboggz/oggz_stream_private.h deleted file mode 100644 index ba5431d95ee..00000000000 --- a/media/liboggz/src/liboggz/oggz_stream_private.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_STREAM_PRIVATE_H__ -#define __OGGZ_STREAM_PRIVATE_H__ - -typedef struct _oggz_stream_t oggz_stream_t; - -typedef int (*OggzReadBOS) (OGGZ * oggz, long serialno, - unsigned char * data, long length, - void * user_data); - -typedef struct { - const char *bos_str; - int bos_str_len; - const char *content_type; - OggzReadBOS reader; - ogg_int64_t (*calculator)(ogg_int64_t now, oggz_stream_t *stream, - ogg_packet *op); - ogg_int64_t (*r_calculator)(ogg_int64_t next_packet_gp, - oggz_stream_t *stream, ogg_packet *this_packet, - ogg_packet *next_packet); -} oggz_auto_contenttype_t; - -extern const oggz_auto_contenttype_t oggz_auto_codec_ident[]; - - -oggz_stream_t * oggz_get_stream (OGGZ * oggz, long serialno); -oggz_stream_t * oggz_add_stream (OGGZ * oggz, long serialno); - -int oggz_stream_has_metric (OGGZ * oggz, long serialno); -int oggz_stream_set_content (OGGZ * oggz, long serialno, int content); - -ogg_int64_t -oggz_auto_calculate_granulepos(int content, ogg_int64_t now, - oggz_stream_t *stream, ogg_packet *op); - -ogg_int64_t -oggz_auto_calculate_gp_backwards(int content, ogg_int64_t next_packet_gp, - oggz_stream_t *stream, ogg_packet *this_packet, ogg_packet *next_packet); - -#endif /* __OGGZ_STREAM_PRIVATE_H__ */ diff --git a/media/liboggz/src/liboggz/oggz_table.c b/media/liboggz/src/liboggz/oggz_table.c deleted file mode 100644 index 7a64c020828..00000000000 --- a/media/liboggz/src/liboggz/oggz_table.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#include -#include "oggz_macros.h" -#include "oggz_vector.h" - -typedef struct _OggzTable OggzTable; - -struct _OggzTable { - OggzVector * keys; - OggzVector * data; -}; - -OggzTable * -oggz_table_new (void) -{ - OggzTable * table; - - table = oggz_malloc (sizeof (OggzTable)); - if (table == NULL) return NULL; - - table->keys = oggz_vector_new (); - table->data = oggz_vector_new (); - - return table; -} - -void -oggz_table_delete (OggzTable * table) -{ - if (table == NULL) return; - - oggz_vector_delete (table->keys); - oggz_vector_delete (table->data); - oggz_free (table); -} - -void * -oggz_table_lookup (OggzTable * table, long key) -{ - int i, size; - - if (table == NULL) return NULL; - - size = oggz_vector_size (table->keys); - for (i = 0; i < size; i++) { - if (oggz_vector_nth_l (table->keys, i) == key) { - return oggz_vector_nth_p (table->data, i); - } - } - - return NULL; -} - -void * -oggz_table_insert (OggzTable * table, long key, void * data) -{ - void * old_data; - - if ((old_data = oggz_table_lookup (table, key)) != NULL) { - if (oggz_vector_remove_l (table->keys, key) == NULL) - return NULL; - - if (oggz_vector_remove_p (table->data, old_data) == NULL) { - /* XXX: This error condition can only happen if the previous - * removal succeeded, and this removal failed, ie. there was - * an error reallocing table->data->data downwards. */ - return NULL; - } - } - - if (oggz_vector_insert_l (table->keys, key) == -1) - return NULL; - - if (oggz_vector_insert_p (table->data, data) == NULL) { - oggz_vector_remove_l (table->keys, key); - return NULL; - } - - return data; -} - -int -oggz_table_remove (OggzTable * table, long key) -{ - void * old_data; - - if ((old_data = oggz_table_lookup (table, key)) != NULL) { - if (oggz_vector_remove_l (table->keys, key) == NULL) - return -1; - - if (oggz_vector_remove_p (table->data, old_data) == NULL) { - /* XXX: This error condition can only happen if the previous - * removal succeeded, and this removal failed, ie. there was - * an error reallocing table->data->data downwards. */ - return -1; - } - } - - return 0; -} - -int -oggz_table_size (OggzTable * table) -{ - if (table == NULL) return 0; - return oggz_vector_size (table->data); -} - -void * -oggz_table_nth (OggzTable * table, int n, long * key) -{ - if (table == NULL) return NULL; - if (key) *key = oggz_vector_nth_l (table->keys, n); - return oggz_vector_nth_p (table->data, n); -} diff --git a/media/liboggz/src/liboggz/oggz_vector.c b/media/liboggz/src/liboggz/oggz_vector.c deleted file mode 100644 index 8f43fed9eac..00000000000 --- a/media/liboggz/src/liboggz/oggz_vector.c +++ /dev/null @@ -1,416 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#include -#include -#include - -#include "oggz_macros.h" - -typedef int (*OggzFunc) (void * data); -typedef int (*OggzFunc1) (void * data, void * arg); -typedef int (*OggzFindFunc) (void * data, long serialno); -typedef int (*OggzCmpFunc) (const void * a, const void * b, void * user_data); - -typedef struct _OggzVector OggzVector; - -typedef union { - void * p; - long l; -} oggz_data_t; - -struct _OggzVector { - int max_elements; - int nr_elements; - oggz_data_t * data; - OggzCmpFunc compare; - void * compare_user_data; -}; - -/* - * A vector of void * or long; iff it's a vector of void * objects, it - * can be optionally sorted. (The sorting is used to implement the - * packet queue; the vector of longs is used to implement OggzTable) - * - * if you set a comparison function (oggz_vector_set_cmp()), the vector - * will be sorted and new elements will be inserted in sorted order. - * - * if you don't set a comparison function, new elements will be appended - * at the tail - * - * to unset the comparison function, call oggz_vector_set_cmp (NULL,NULL) - */ - -OggzVector * -oggz_vector_new (void) -{ - OggzVector * vector; - - vector = oggz_malloc (sizeof (OggzVector)); - if (vector == NULL) return NULL; - - vector->max_elements = 0; - vector->nr_elements = 0; - vector->data = NULL; - vector->compare = NULL; - vector->compare_user_data = NULL; - - return vector; -} - -static void -oggz_vector_clear (OggzVector * vector) -{ - if (vector->data) - { - oggz_free (vector->data); - vector->data = NULL; - } - - vector->nr_elements = 0; - vector->max_elements = 0; -} - -void -oggz_vector_delete (OggzVector * vector) -{ - oggz_vector_clear (vector); - oggz_free (vector); -} - -int -oggz_vector_size (OggzVector * vector) -{ - if (vector == NULL) return 0; - - return vector->nr_elements; -} - -void * -oggz_vector_nth_p (OggzVector * vector, int n) -{ - if (vector == NULL) return NULL; - - if (n >= vector->nr_elements) return NULL; - - return vector->data[n].p; -} - -long -oggz_vector_nth_l (OggzVector * vector, int n) -{ - if (vector == NULL) return -1L; - - if (n >= vector->nr_elements) return -1L; - - return vector->data[n].l; -} - -void * -oggz_vector_find_p (OggzVector * vector, const void * data) -{ - void * d; - int i; - - if (vector->compare == NULL) return NULL; - - for (i = 0; i < vector->nr_elements; i++) { - d = vector->data[i].p; - if (vector->compare (d, data, vector->compare_user_data)) - return d; - } - - return NULL; -} - -int -oggz_vector_find_index_p (OggzVector * vector, const void * data) -{ - void * d; - int i; - - if (vector->compare == NULL) return -1; - - for (i = 0; i < vector->nr_elements; i++) { - d = vector->data[i].p; - if (vector->compare (d, data, vector->compare_user_data)) - return i; - } - - return -1; -} - -void * -oggz_vector_find_with (OggzVector * vector, OggzFindFunc func, long serialno) -{ - void * d; - int i; - - for (i = 0; i < vector->nr_elements; i++) { - d = vector->data[i].p; - if (func (d, serialno)) - return d; - } - - return NULL; -} - -int -oggz_vector_foreach (OggzVector * vector, OggzFunc func) -{ - int i; - - for (i = 0; i < vector->nr_elements; i++) { - func (vector->data[i].p); - } - - return 0; -} - -int -oggz_vector_foreach1 (OggzVector * vector, OggzFunc1 func, void *arg) -{ - int i; - - for (i = 0; i < vector->nr_elements; i++) { - func (vector->data[i].p, arg); - } - - return 0; -} - -static void -_array_swap (oggz_data_t v[], int i, int j) -{ - void * t; - - t = v[i].p; - v[i].p = v[j].p; - v[j].p = t; -} - -/** - * Helper function for oggz_vector_insert (). Sorts the vector by - * insertion sort, assuming the tail element has just been added and the - * rest of the vector is sorted. - * \param vector An OggzVector - * \pre The vector has just had a new element added to its tail - * \pre All elements other than the tail element are already sorted. - */ -static void -oggz_vector_tail_insertion_sort (OggzVector * vector) -{ - int i; - - if (vector->compare == NULL) return; - - for (i = vector->nr_elements-1; i > 0; i--) { - if (vector->compare (vector->data[i-1].p, vector->data[i].p, - vector->compare_user_data) > 0) { - _array_swap (vector->data, i, i-1); - } else { - break; - } - } - - return; -} - -static OggzVector * -oggz_vector_grow (OggzVector * vector) -{ - void * new_elements; - int new_max_elements; - - vector->nr_elements++; - - if (vector->nr_elements > vector->max_elements) { - if (vector->max_elements == 0) { - new_max_elements = 1; - } else { - new_max_elements = vector->max_elements * 2; - } - - new_elements = - oggz_realloc (vector->data, (size_t)new_max_elements * sizeof (oggz_data_t)); - - if (new_elements == NULL) { - vector->nr_elements--; - return NULL; - } - - vector->max_elements = new_max_elements; - vector->data = new_elements; - } - - return vector; -} - -void * -oggz_vector_insert_p (OggzVector * vector, void * data) -{ - if (oggz_vector_grow (vector) == NULL) - return NULL; - - vector->data[vector->nr_elements-1].p = data; - - oggz_vector_tail_insertion_sort (vector); - - return data; - -} - -long -oggz_vector_insert_l (OggzVector * vector, long ldata) -{ - if (oggz_vector_grow (vector) == NULL) - return -1; - - vector->data[vector->nr_elements-1].l = ldata; - - return ldata; -} - -static void -oggz_vector_qsort (OggzVector * vector, int left, int right) -{ - int i, last; - oggz_data_t * v = vector->data; - - if (left >= right) return; - - _array_swap (v, left, (left + right)/2); - last = left; - for (i = left+1; i <= right; i++) { - if (vector->compare (v[i].p, v[left].p, vector->compare_user_data) < 0) - _array_swap (v, ++last, i); - } - _array_swap (v, left, last); - oggz_vector_qsort (vector, left, last-1); - oggz_vector_qsort (vector, last+1, right); -} - -int -oggz_vector_set_cmp (OggzVector * vector, OggzCmpFunc compare, - void * user_data) -{ - vector->compare = compare; - vector->compare_user_data = user_data; - - if (compare) { - oggz_vector_qsort (vector, 0, vector->nr_elements-1); - } - - return 0; -} - - -static void * -oggz_vector_remove_nth (OggzVector * vector, int n) -{ - int i; - oggz_data_t * new_elements; - int new_max_elements; - - vector->nr_elements--; - - if (vector->nr_elements == 0) { - oggz_vector_clear (vector); - } else { - for (i = n; i < vector->nr_elements; i++) { - vector->data[i] = vector->data[i+1]; - } - - if (vector->nr_elements < vector->max_elements/2) { - new_max_elements = vector->max_elements/2; - - new_elements = - oggz_realloc (vector->data, - (size_t)new_max_elements * sizeof (oggz_data_t)); - - if (new_elements == NULL) { - vector->data = NULL; - return NULL; - } - - vector->max_elements = new_max_elements; - vector->data = new_elements; - } - } - - return vector; -} - -OggzVector * -oggz_vector_remove_p (OggzVector * vector, void * data) -{ - int i; - - for (i = 0; i < vector->nr_elements; i++) { - if (vector->data[i].p == data) { - return oggz_vector_remove_nth (vector, i); - } - } - - return vector; -} - -OggzVector * -oggz_vector_remove_l (OggzVector * vector, long ldata) -{ - int i; - - for (i = 0; i < vector->nr_elements; i++) { - if (vector->data[i].l == ldata) { - return oggz_vector_remove_nth (vector, i); - } - } - - return vector; -} - -void * -oggz_vector_pop (OggzVector * vector) -{ - void * data; - - if (vector == NULL || vector->data == NULL) return NULL; - - data = vector->data[0].p; - - oggz_vector_remove_nth (vector, 0); - - return data; - -} diff --git a/media/liboggz/src/liboggz/oggz_vector.h b/media/liboggz/src/liboggz/oggz_vector.h deleted file mode 100644 index d0cf4150788..00000000000 --- a/media/liboggz/src/liboggz/oggz_vector.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef __OGGZ_VECTOR_H__ -#define __OGGZ_VECTOR_H__ - -typedef void OggzVector; - -typedef int (*OggzFunc) (void * data); -typedef int (*OggzFunc1) (void * data, void *arg); -typedef int (*OggzFindFunc) (void * data, long serialno); -typedef int (*OggzCmpFunc) (const void * a, const void * b, void * user_data); - -/** - * Create a new vector object. - * \retval a pointer to the new vector. - * \retval NULL on failure. - */ -OggzVector * -oggz_vector_new (void); - -/** - * Destroy a vector object. - */ -void -oggz_vector_delete (OggzVector * vector); - -void * -oggz_vector_find_p (OggzVector * vector, const void * data); - -int -oggz_vector_find_index_p (OggzVector * vector, const void * data); - -void * -oggz_vector_find_with (OggzVector * vector, OggzFindFunc func, long serialno); - -void * -oggz_vector_nth_p (OggzVector * vector, int n); - -long -oggz_vector_nth_l (OggzVector * vector, int n); - -/** - * Call a function on each element of a vector, in order. - * \param vector The OggzVector to iterate over - * \param func The OggzFunc to be called on each element - * \retval 0 on success - */ -int -oggz_vector_foreach (OggzVector * vector, OggzFunc func); - -/** - * Call a function with a userdata pointer on each element - * of a vector, in order. This allows the function to access - * shared data when operating on the element sequence. - * \param vector The OggzVector to iterate over - * \param func The OggzFunc1 to be called on each element - * \param arg The userdata pointer to be passed to the function - * along with the vector member - * \retval 0 on success - */ -int -oggz_vector_foreach1 (OggzVector * vector, OggzFunc1 func, void *arg); - -/** - * Return the number of elements in a vector. - * \param vector The vector to query - * \retval The number of elements - */ -int -oggz_vector_size (OggzVector * vector); - -/** - * Add an element to a vector. If the vector has a comparison function, - * the new element is inserted in sorted order, otherwise it is appended - * to the tail. Use this function to add pointer elements to the vector. - * Use ogg_vector_insert_l for long values. - * \param vector An OggzVector - * \param data The new element to add - * \retval data If the element was successfully added - * \retval NULL If adding the element failed due to a realloc() error - */ -void * -oggz_vector_insert_p (OggzVector * vector, void * data); - -/** - * Add an element to a vector. If the vector has a comparison function, - * the new element is inserted in sorted order, otherwise it is appended - * to the tail. Use this function to add long value elements to the - * vector. Use ogg_vector_insert_p for pointer values. - * \param vector An OggzVector - * \param ldata The new element to add - * \retval ldata If the element was successfully added - * \retval -1L If adding the element failed - */ -long -oggz_vector_insert_l (OggzVector * vector, long ldata); - -/** - * Remove a (void *) element of a vector - * \retval \a vector on success - * \retval NULL on failure (realloc error) - */ -OggzVector * -oggz_vector_remove_p (OggzVector * vector, void * data); - -/** - * Remove a (long) element of a vector - * \retval \a vector on success - * \retval NULL on failure (realloc error) - */ -OggzVector * -oggz_vector_remove_l (OggzVector * vector, long ldata); - -/** - * Set a comparison function for a vector. - * Vectors can be sorted, or stored in append order, depending on - * whether they have a comparison function defined. When a comparison - * function is first set, it will be used to sort the entire vector, - * and subsequence insertions will maintain the sort. If no comparison - * function is set, new elements are appended at the end of the vector. - * Call oggz_vector_set_cmp(vector, NULL, NULL) to remove the current - * comparison function. This does not affect the member order. - * \param vector the vector to associate the comparison function with - * \param compare the OggzCmpFunc to use for comparisons - * \param user_data private data pointer for the compare function - * \retval 0 on success - */ -int -oggz_vector_set_cmp (OggzVector * vector, OggzCmpFunc compare, - void * user_data); - -/** - * Pop a member off a vector. - * \retval pointer to the popped member - * \retval NULL if the vector is empty - */ -void * -oggz_vector_pop (OggzVector * vector); - -#endif /* __OGGZ_VECTOR_H__ */ diff --git a/media/liboggz/src/liboggz/oggz_write.c b/media/liboggz/src/liboggz/oggz_write.c deleted file mode 100644 index ca6a1ecfed3..00000000000 --- a/media/liboggz/src/liboggz/oggz_write.c +++ /dev/null @@ -1,988 +0,0 @@ -/* - Copyright (C) 2003 Commonwealth Scientific and Industrial Research - Organisation (CSIRO) Australia - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of CSIRO Australia nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "config.h" - -#if OGGZ_CONFIG_WRITE - -#include -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include -#include -#include -#include - -#include - -#include "oggz_private.h" -#include "oggz_vector.h" - -/* #define DEBUG */ - -/* Define to 0 or 1 */ -#define ALWAYS_FLUSH 0 - -#define OGGZ_WRITE_EMPTY (-707) - -/* #define ZPACKET_CMP */ - -#ifdef ZPACKET_CMP -static int -oggz_zpacket_cmp (oggz_writer_packet_t * a, oggz_writer_packet_t * b, - void * user_data) -{ - OGGZ * oggz = (OGGZ *)user_data; - long serialno_a, serialno_b; - ogg_int64_t unit_a, unit_b; - - serialno_a = a->stream->ogg_stream.serialno; - serialno_b = b->stream->ogg_stream.serialno; - - unit_a = oggz_get_unit (oggz, serialno_a, a->op.granulepos); - unit_b = oggz_get_unit (oggz, serialno_b, b->op.granulepos); - - if (unit_a < unit_b) return -1; - else return (unit_a > unit_b); -} -#endif - -OGGZ * -oggz_write_init (OGGZ * oggz) -{ - OggzWriter * writer = &oggz->x.writer; - - writer->next_zpacket = NULL; - - writer->packet_queue = oggz_vector_new (); - if (writer->packet_queue == NULL) return NULL; - -#ifdef ZPACKET_CMP - /* XXX: comparison function should only kick in when a metric is set */ - oggz_vector_set_cmp (writer->packet_queue, - (OggzCmpFunc)oggz_zpacket_cmp, oggz); -#endif - - writer->hungry = NULL; - writer->hungry_user_data = NULL; - writer->hungry_only_when_empty = 0; - - writer->writing = 0; - writer->no_more_packets = 0; - writer->state = OGGZ_MAKING_PACKETS; - - writer->flushing = 0; -#if 0 - writer->eog = 1; - writer->eop = 1; /* init ready to start next packet */ -#endif - writer->eos = 0; - - writer->current_zpacket = NULL; - - writer->packet_offset = 0; - writer->page_offset = 0; - - writer->current_stream = NULL; - - return oggz; -} - -static int -oggz_writer_packet_free (oggz_writer_packet_t * zpacket) -{ - if (!zpacket) return 0; - - if (zpacket->guard) { - /* managed by user; flag guard */ - *zpacket->guard = 1; - } else { - /* managed by oggz; free copied data */ - oggz_free (zpacket->op.packet); - } - oggz_free (zpacket); - - return 0; -} - -int -oggz_write_flush (OGGZ * oggz) -{ - OggzWriter * writer = &oggz->x.writer; - ogg_stream_state * os; - ogg_page * og; - int ret = 0; - - os = writer->current_stream; - og = &oggz->current_page; - - if (os != NULL) - ret = ogg_stream_flush (os, og); - - return ret; -} - -OGGZ * -oggz_write_close (OGGZ * oggz) -{ - OggzWriter * writer = &oggz->x.writer; - - oggz_write_flush (oggz); - - oggz_writer_packet_free (writer->current_zpacket); - oggz_writer_packet_free (writer->next_zpacket); - - oggz_vector_foreach (writer->packet_queue, - (OggzFunc)oggz_writer_packet_free); - oggz_vector_delete (writer->packet_queue); - - return oggz; -} - -/******** Packet queueing ********/ - -int -oggz_write_set_hungry_callback (OGGZ * oggz, OggzWriteHungry hungry, - int only_when_empty, void * user_data) -{ - OggzWriter * writer; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (!(oggz->flags & OGGZ_WRITE)) { - return OGGZ_ERR_INVALID; - } - - writer = &oggz->x.writer; - - writer->hungry = hungry; - writer->hungry_user_data = user_data; - writer->hungry_only_when_empty = only_when_empty; - - return 0; -} - -int -oggz_write_feed (OGGZ * oggz, ogg_packet * op, long serialno, int flush, - int * guard) -{ - OggzWriter * writer; - oggz_stream_t * stream; - oggz_writer_packet_t * packet; - ogg_packet * new_op; - unsigned char * new_buf = NULL; - int b_o_s, e_o_s, bos_auto; - int strict, prefix, suffix; - -#ifdef DEBUG - printf ("oggz_write_feed: IN\n"); -#endif - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - if (!(oggz->flags & OGGZ_WRITE)) { - return OGGZ_ERR_INVALID; - } - - writer = &oggz->x.writer; - - if (guard && *guard != 0) return OGGZ_ERR_BAD_GUARD; - - /* Check that the serialno is in the valid range for an Ogg page header, - * ie. that it fits within 32 bits and does not equal the special value -1 */ - if ((long)((ogg_int32_t)serialno) != serialno || serialno == -1) { -#ifdef DEBUG - printf ("oggz_write_feed: serialno %010lu\n", serialno); -#endif - return OGGZ_ERR_BAD_SERIALNO; - } - -#ifdef DEBUG - printf ("oggz_write_feed: (%010lu) FLUSH: %d\n", serialno, flush); -#endif - - /* Cache strict, prefix, suffix */ - strict = !(oggz->flags & OGGZ_NONSTRICT); - prefix = (oggz->flags & OGGZ_PREFIX); - suffix = (oggz->flags & OGGZ_SUFFIX); - - /* Set bos, eos to canonical values */ - bos_auto = (op->b_o_s == -1) ? 1 : 0; - b_o_s = op->b_o_s ? 1 : 0; - e_o_s = op->e_o_s ? 1 : 0; - - stream = oggz_get_stream (oggz, serialno); - if (stream == NULL) { - if (bos_auto) b_o_s = 1; - - if (strict && b_o_s && !oggz_get_bos (oggz, -1)) { - return OGGZ_ERR_BOS; - } - - if (b_o_s || !strict || suffix) { - stream = oggz_add_stream (oggz, serialno); - if (stream == NULL) - return OGGZ_ERR_OUT_OF_MEMORY; - oggz_auto_identify_packet (oggz, op, serialno); - } else { - return OGGZ_ERR_BAD_SERIALNO; - } - } else { - if (bos_auto) b_o_s = 0; - - if (!suffix && strict && stream->e_o_s) - return OGGZ_ERR_EOS; - } - - /* Check packet against mapping restrictions */ - if (strict) { - if (op->bytes < 0) return OGGZ_ERR_BAD_BYTES; - if (!suffix && b_o_s != stream->b_o_s) return OGGZ_ERR_BAD_B_O_S; - if (op->granulepos != -1 && op->granulepos < stream->granulepos && - /* Allow negative granulepos immediately after headers, for Dirac: */ - !(stream->granulepos == 0 && op->granulepos < 0)) - return OGGZ_ERR_BAD_GRANULEPOS; - - /* Allow packetno == -1 to indicate oggz should fill it in; otherwise: - * if op is the first packet in the stream, initialize the stream's - * packetno to the given one, otherwise check it for strictness. - * For stream suffixes, believe the packetno value */ - if (op->packetno != -1) { - if (b_o_s || suffix) { - stream->packetno = op->packetno; - } else if (op->packetno <= stream->packetno) { - return OGGZ_ERR_BAD_PACKETNO; - } - } - } - - /* OK -- Update stream's memory of packet details */ - - if (!stream->metric && (oggz->flags & OGGZ_AUTO)) { - oggz_auto_read_bos_packet (oggz, op, serialno, NULL); - } - - stream->b_o_s = 0; /* The stream is henceforth no longer at bos */ - stream->e_o_s = e_o_s; /* We believe the eos value */ - stream->granulepos = op->granulepos; /* and the granulepos */ - - /* If the user specified a packetno of -1, fill it in automatically; - * otherwise, use the user-specified value */ - stream->packetno = (op->packetno != -1) ? op->packetno : stream->packetno+1; - - /* Now set up the packet and add it to the queue */ - if (guard == NULL) { - new_buf = oggz_malloc ((size_t)op->bytes); - if (new_buf == NULL) return OGGZ_ERR_OUT_OF_MEMORY; - - memcpy (new_buf, op->packet, (size_t)op->bytes); - } else { - new_buf = op->packet; - } - - packet = oggz_malloc (sizeof (oggz_writer_packet_t)); - if (packet == NULL) { - if (guard == NULL && new_buf != NULL) oggz_free (new_buf); - return OGGZ_ERR_OUT_OF_MEMORY; - } - - new_op = &packet->op; - new_op->packet = new_buf; - new_op->bytes = op->bytes; - new_op->b_o_s = b_o_s; - new_op->e_o_s = e_o_s; - new_op->granulepos = op->granulepos; - new_op->packetno = stream->packetno; - - packet->stream = stream; - packet->flush = flush; - packet->guard = guard; - -#ifdef DEBUG - printf ("oggz_write_feed: made packet bos %ld eos %ld (%ld bytes) FLUSH: %d\n", - new_op->b_o_s, new_op->e_o_s, new_op->bytes, packet->flush); -#endif - - if (oggz_vector_insert_p (writer->packet_queue, packet) == NULL) { - oggz_free (packet); - if (!guard) oggz_free (new_buf); - return -1; - } - - writer->no_more_packets = 0; - -#ifdef DEBUG - printf ("oggz_write_feed: enqueued packet, queue size %d\n", - oggz_vector_size (writer->packet_queue)); -#endif - - return 0; -} - -/******** Page creation ********/ - -/* - * - - ____ __________________\___ ____ - / \ / Page ready / \ / \ - | \ /=========\ /=========\ / | - Page | || Make || || Write || | Page - !ready V || packet || || page || V ready - | / \=========/ \=========/ \ | - \____/ \___/__________________/ \____/ - \ Page !ready - * - */ - - -/* - * oggz_page_init (oggz) - * - * Initialises the next page of the current packet. - * - * If this returns 0, the page is not ready for writing. - */ -static long -oggz_page_init (OGGZ * oggz) -{ - OggzWriter * writer; - ogg_stream_state * os; - ogg_page * og; - int ret; - - if (oggz == NULL) return -1; - - writer = &oggz->x.writer; - os = writer->current_stream; - og = &oggz->current_page; - - if (ALWAYS_FLUSH || writer->flushing) { -#ifdef DEBUG - printf ("oggz_page_init: ATTEMPT FLUSH: "); -#endif - ret = oggz_write_flush (oggz); - } else { -#ifdef DEBUG - printf ("oggz_page_init: ATTEMPT pageout: "); -#endif - ret = ogg_stream_pageout (os, og); - } - - if (ret) { - writer->page_offset = 0; - } - -#ifdef DEBUG - printf ("%s\n", ret ? "OK" : "NO"); -#endif - - return ret; -} - -/* - * oggz_packet_init (oggz, buf, n) - * - * Initialises the next packet with data from buf, length n - */ -static long -oggz_packet_init (OGGZ * oggz, oggz_writer_packet_t * next_zpacket) -{ - OggzWriter * writer; - oggz_stream_t * stream; - ogg_stream_state * os; - ogg_packet * op; - - if (oggz == NULL) return -1L; - - writer = &oggz->x.writer; - writer->current_zpacket = next_zpacket; - op = &next_zpacket->op; - -#ifdef DEBUG - printf ("oggz_packet_init: %ld bytes\n", (long)op->bytes); -#endif - - stream = next_zpacket->stream; - - /* Mark this stream as having delivered a non b_o_s packet if so */ - if (!op->b_o_s) stream->delivered_non_b_o_s = 1; - - os = &stream->ogg_stream; - ogg_stream_packetin (os, op); - - writer->flushing = (next_zpacket->flush & OGGZ_FLUSH_AFTER); -#ifdef DEBUG - printf ("oggz_packet_init: set flush to %d\n", writer->flushing); -#endif - writer->current_stream = os; - writer->packet_offset = 0; - - return 0; -} - -static long -oggz_page_copyout (OGGZ * oggz, unsigned char * buf, long n) -{ - OggzWriter * writer; - long h, b; - ogg_page * og; - - if (oggz == NULL) return -1L; - - writer = &oggz->x.writer; - og = &oggz->current_page; - - h = MIN (n, og->header_len - writer->page_offset); - if (h > 0) { - memcpy (buf, og->header + writer->page_offset, h); - writer->page_offset += h; - n -= h; - buf += h; - } else { - h = 0; - } - - b = MIN (n, og->header_len + og->body_len - writer->page_offset); - if (b > 0) { -#ifdef DEBUG - { - unsigned char * c = &og->body[writer->page_offset - og->header_len]; - printf ("oggz_page_copyout [%d] (@%ld): %c%c%c%c ...\n", - ogg_page_serialno (og), (long) ogg_page_granulepos (og), - c[0], c[1], c[2], c[3]); - } -#endif - memcpy (buf, og->body + (writer->page_offset - og->header_len), b); - writer->page_offset += b; - n -= b; - buf += b; - } else { - b = 0; - } - - return h + b; -} - -static long -oggz_page_writeout (OGGZ * oggz, long n) -{ - OggzWriter * writer; - long h, b, nwritten; - ogg_page * og; - -#ifdef OGGZ_WRITE_DIRECT - int fd; -#endif - - if (oggz == NULL) return -1L; - - writer = &oggz->x.writer; - og = &oggz->current_page; - -#ifdef OGGZ_WRITE_DIRECT - fd = fileno (oggz->file); -#endif - - h = MIN (n, og->header_len - writer->page_offset); - if (h > 0) { -#ifdef OGGZ_WRITE_DIRECT - nwritten = write (fd, og->header + writer->page_offset, h); -#else - nwritten = (long)oggz_io_write (oggz, og->header + writer->page_offset, h); -#endif - -#ifdef DEBUG - if (nwritten < h) { - printf ("oggz_page_writeout: %ld < %ld\n", nwritten, h); - } -#endif - writer->page_offset += h; - n -= h; - } else { - h = 0; - } - - b = MIN (n, og->header_len + og->body_len - writer->page_offset); - if (b > 0) { -#ifdef DEBUG - { - unsigned char * c = &og->body[writer->page_offset - og->header_len]; - printf ("oggz_page_writeout [%d] (@%ld): %c%c%c%c ...\n", - ogg_page_serialno (og), (long) ogg_page_granulepos (og), - c[0], c[1], c[2], c[3]); - } -#endif -#ifdef OGGZ_WRITE_DIRECT - nwritten = write (fd, - og->body + (writer->page_offset - og->header_len), b); -#else - nwritten = (long)oggz_io_write (oggz, og->body + (writer->page_offset - og->header_len), b); -#endif -#ifdef DEBUG - if (nwritten < b) { - printf ("oggz_page_writeout: %ld < %ld\n", nwritten, b); - } -#endif - writer->page_offset += b; - n -= b; - } else { - b = 0; - } - - return h + b; -} - -static int -oggz_dequeue_packet (OGGZ * oggz, oggz_writer_packet_t ** next_zpacket) -{ - OggzWriter * writer = &oggz->x.writer; - int ret = 0; - - if (writer->next_zpacket != NULL) { -#ifdef DEBUG - printf ("oggz_dequeue_packet: queue EMPTY\n"); -#endif - *next_zpacket = writer->next_zpacket; - writer->next_zpacket = NULL; - } else { - *next_zpacket = oggz_vector_pop (writer->packet_queue); - - if (*next_zpacket == NULL) { - if (writer->hungry) { - ret = writer->hungry (oggz, 1, writer->hungry_user_data); - *next_zpacket = oggz_vector_pop (writer->packet_queue); -#ifdef DEBUG - printf ("oggz_dequeue_packet: called hungry and popped, new queue size %d\n", - oggz_vector_size (writer->packet_queue)); -#endif - -#ifdef DEBUG - } else { - printf ("oggz_dequeue_packet: no packet, no hungry, queue size %d\n", - oggz_vector_size (writer->packet_queue)); -#endif - } -#ifdef DEBUG - } else { - printf ("oggz_dequeue_packet: dequeued packet, queue size %d\n", - oggz_vector_size (writer->packet_queue)); -#endif - } - - } - -#ifdef DEBUG - printf("oggz_dequeue_packeT: returning %d\n", ret); -#endif - return ret; -} - -static long -oggz_writer_make_packet (OGGZ * oggz) -{ - OggzWriter * writer = &oggz->x.writer; - oggz_writer_packet_t * zpacket, * next_zpacket = NULL; - int cb_ret = 0; - -#ifdef DEBUG - printf ("oggz_writer_make_packet: IN\n"); -#endif - - /* finished with current packet; unguard */ - zpacket = writer->current_zpacket; - oggz_writer_packet_free (zpacket); - writer->current_zpacket = NULL; - - /* if the user wants the hungry callback after every packet, give - * it to them, marking emptiness appropriately - */ - if (writer->hungry && !writer->hungry_only_when_empty) { - int empty = (oggz_vector_size (writer->packet_queue) == 0); - cb_ret = writer->hungry (oggz, empty, writer->hungry_user_data); - } - - if (cb_ret == 0) { - /* dequeue and init the next packet */ - cb_ret = oggz_dequeue_packet (oggz, &next_zpacket); - if (next_zpacket == NULL) { -#ifdef DEBUG - printf ("oggz_writer_make_packet: packet queue empty\n"); -#endif - /*writer->eos = 1;*/ - } else { - if ((writer->current_stream != NULL) && - (next_zpacket->flush & OGGZ_FLUSH_BEFORE)) { - writer->flushing = 1; -#ifdef DEBUG - printf ("oggz_writer_make_packet: set flush to %d\n", - writer->flushing); -#endif - next_zpacket->flush &= OGGZ_FLUSH_AFTER; - writer->next_zpacket = next_zpacket; - } else { - oggz_packet_init (oggz, next_zpacket); - } - } - } - -#ifdef DEBUG - printf("oggz_writer_make_packet: cb_ret is %d\n", cb_ret); -#endif - - if (cb_ret == 0 && next_zpacket == NULL) return OGGZ_WRITE_EMPTY; - - return cb_ret; -} - -long -oggz_write_output (OGGZ * oggz, unsigned char * buf, long n) -{ - OggzWriter * writer; - long bytes, bytes_written = 1, remaining = n, nwritten = 0; - int active = 1, cb_ret = 0; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - writer = &oggz->x.writer; - - if (!(oggz->flags & OGGZ_WRITE)) { - return OGGZ_ERR_INVALID; - } - - if (writer->writing) return OGGZ_ERR_RECURSIVE_WRITE; - writer->writing = 1; - -#ifdef DEBUG - printf ("oggz_write_output: IN\n"); -#endif - - if ((cb_ret = oggz->cb_next) != OGGZ_CONTINUE) { - oggz->cb_next = 0; - writer->writing = 0; - writer->no_more_packets = 0; - if (cb_ret == OGGZ_WRITE_EMPTY) cb_ret = 0; - return oggz_map_return_value_to_error (cb_ret); - } - - while (active && remaining > 0) { - bytes = MIN (remaining, 1024); - -#ifdef DEBUG - printf ("oggz_write_output: write loop (%ld , %ld remain) ...\n", bytes, - remaining); -#endif - - while (writer->state == OGGZ_MAKING_PACKETS) { -#ifdef DEBUG - printf ("oggz_write_output: MAKING_PACKETS\n"); -#endif - if ((cb_ret = oggz_writer_make_packet (oggz)) != OGGZ_CONTINUE) { -#ifdef DEBUG - printf ("oggz_write_output: no packets (cb_ret is %d)\n", cb_ret); -#endif - if (cb_ret == OGGZ_WRITE_EMPTY) { - writer->flushing = 1; - writer->no_more_packets = 1; - } - /* At this point, in contrast to oggz_write(), we break out of this - * loop unconditionally. - */ - active = 0; - break; - } - if (oggz_page_init (oggz)) { - writer->state = OGGZ_WRITING_PAGES; - } else { -#ifdef DEBUG - printf ("oggz_write_output: unable to make page...\n"); -#endif - if (writer->no_more_packets) { - active = 0; - break; - } - } - } - - if (writer->state == OGGZ_WRITING_PAGES) { - bytes_written = oggz_page_copyout (oggz, buf, bytes); - - if (bytes_written == -1) { - active = 0; - cb_ret = OGGZ_ERR_SYSTEM; /* XXX: catch next */ - } else if (bytes_written == 0) { - if (writer->no_more_packets) { - active = 0; - break; - } else if (!oggz_page_init (oggz)) { -#ifdef DEBUG - printf ("oggz_write_output: bytes_written == 0, DONE\n"); -#endif - writer->state = OGGZ_MAKING_PACKETS; - } - } - - buf += bytes_written; - - remaining -= bytes_written; - nwritten += bytes_written; - } - } - -#ifdef DEBUG - printf ("oggz_write_output: OUT %ld\n", nwritten); -#endif - - writer->writing = 0; - - if (nwritten == 0) { - if (cb_ret == OGGZ_WRITE_EMPTY) cb_ret = 0; - return oggz_map_return_value_to_error (cb_ret); - } else { - oggz->cb_next = cb_ret; - } - - return nwritten; -} - -long -oggz_write (OGGZ * oggz, long n) -{ - OggzWriter * writer; - long bytes, bytes_written = 1, remaining = n, nwritten = 0; - int active = 1, cb_ret = 0; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - writer = &oggz->x.writer; - - if (!(oggz->flags & OGGZ_WRITE)) { - return OGGZ_ERR_INVALID; - } - - if (writer->writing) return OGGZ_ERR_RECURSIVE_WRITE; - writer->writing = 1; - -#ifdef DEBUG - printf ("oggz_write: IN\n"); -#endif - - if ((cb_ret = oggz->cb_next) != OGGZ_CONTINUE) { - oggz->cb_next = 0; - writer->writing = 0; - writer->no_more_packets = 0; - if (cb_ret == OGGZ_WRITE_EMPTY) cb_ret = 0; - return oggz_map_return_value_to_error (cb_ret); - } - - while (active && remaining > 0) { - bytes = MIN (remaining, 1024); - -#ifdef DEBUG - printf ("oggz_write: write loop (%ld , %ld remain) ...\n", bytes, - remaining); -#endif - - while (writer->state == OGGZ_MAKING_PACKETS) { -#ifdef DEBUG - printf ("oggz_write: MAKING PACKETS\n"); -#endif - if ((cb_ret = oggz_writer_make_packet (oggz)) != OGGZ_CONTINUE) { -#ifdef DEBUG - printf ("oggz_write: no packets (cb_ret is %d)\n", cb_ret); -#endif - /* - * if we're out of packets because we're at the end of the file, - * we can't finish just yet. Instead we need to force a page flush, - * and write the page out. So we set flushing and no_more_packets to - * 1. This causes oggz_page_init to flush the page, then we - * will switch the state to OGGZ_WRITING_PAGES, which will trigger - * the writing code below. - */ - if (cb_ret == OGGZ_WRITE_EMPTY) { -#ifdef DEBUG - printf ("oggz_write: Inferred end of data, forcing a page flush.\n"); -#endif - writer->flushing = 1; - writer->no_more_packets = 1; - cb_ret = OGGZ_CONTINUE; - } else { -#ifdef DEBUG - printf ("oggz_write: Stopped by user callback.\n"); -#endif - active = 0; - break; - } - } - if (oggz_page_init (oggz)) { - writer->state = OGGZ_WRITING_PAGES; - } else { -#ifdef DEBUG - printf ("oggz_write: unable to make page...\n"); -#endif - if (writer->no_more_packets) { - active = 0; - break; - } - } - } - - if (writer->state == OGGZ_WRITING_PAGES) { - bytes_written = oggz_page_writeout (oggz, bytes); -#ifdef DEBUG - printf ("oggz_write: MAKING PAGES; wrote %ld bytes\n", bytes_written); -#endif - - if (bytes_written == -1) { - active = 0; - return OGGZ_ERR_SYSTEM; /* XXX: catch next */ - } else if (bytes_written == 0) { - /* - * OK so we've completely written the current page. If no_more_packets - * is set then that means there's no more pages after this one, so - * we set active to 0, break out of the loop, pack up our things and - * go home. - */ - if (writer->no_more_packets) { - active = 0; - break; - } else if (!oggz_page_init (oggz)) { -#ifdef DEBUG - printf ("oggz_write: bytes_written == 0, DONE\n"); -#endif - writer->state = OGGZ_MAKING_PACKETS; - } - } - - remaining -= bytes_written; - nwritten += bytes_written; - } - } - -#ifdef DEBUG - printf ("oggz_write: OUT %ld\n", nwritten); -#endif - - writer->writing = 0; - - if (nwritten == 0) { - if (cb_ret == OGGZ_WRITE_EMPTY) cb_ret = 0; - return oggz_map_return_value_to_error (cb_ret); - } else { - oggz->cb_next = cb_ret; - } - - return nwritten; -} - -long -oggz_write_get_next_page_size (OGGZ * oggz) -{ - OggzWriter * writer; - ogg_page * og; - - if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; - - writer = &oggz->x.writer; - - if (!(oggz->flags & OGGZ_WRITE)) { - return OGGZ_ERR_INVALID; - } - - og = &oggz->current_page; - - return (og->header_len + og->body_len - (long)writer->page_offset); -} - -#else /* OGGZ_CONFIG_WRITE */ - -#include -#include "oggz_private.h" - -OGGZ * -oggz_write_init (OGGZ * oggz) -{ - return NULL; -} - -int -oggz_write_flush (OGGZ * oggz) -{ - return OGGZ_ERR_DISABLED; -} - -OGGZ * -oggz_write_close (OGGZ * oggz) -{ - return NULL; -} - -int -oggz_write_set_hungry_callback (OGGZ * oggz, OggzWriteHungry hungry, - int only_when_empty, void * user_data) -{ - return OGGZ_ERR_DISABLED; -} - -int -oggz_write_feed (OGGZ * oggz, ogg_packet * op, long serialno, int flush, - int * guard) -{ - return OGGZ_ERR_DISABLED; -} - -long -oggz_write_output (OGGZ * oggz, unsigned char * buf, long n) -{ - return OGGZ_ERR_DISABLED; -} - -long -oggz_write (OGGZ * oggz, long n) -{ - return OGGZ_ERR_DISABLED; -} - -long -oggz_write_get_next_page_size (OGGZ * oggz) -{ - return OGGZ_ERR_DISABLED; -} - -#endif diff --git a/media/liboggz/update.sh b/media/liboggz/update.sh deleted file mode 100644 index c89cd804a60..00000000000 --- a/media/liboggz/update.sh +++ /dev/null @@ -1,70 +0,0 @@ -# Usage: cp $1/update.sh -# -# Copies the needed files from a directory containing the original -# liboggz source that we need for the Mozilla HTML5 media support. -cp $1/config.h ./include/oggz/config_gcc.h -cp $1/win32/config.h ./include/oggz/config_win32.h -cat >./include/oggz/config.h < - #endif -diff --git a/media/liboggz/src/liboggz/oggz_seek.c b/media/liboggz/src/liboggz/oggz_seek.c ---- a/media/liboggz/src/liboggz/oggz_seek.c -+++ b/media/liboggz/src/liboggz/oggz_seek.c -@@ -556,21 +556,24 @@ oggz_seek_guess (ogg_int64_t unit_at, og - #endif - - return offset_guess; - } - - static oggz_off_t - oggz_offset_end (OGGZ * oggz) - { -+#ifndef WINCE - int fd; - struct stat statbuf; -+#endif - oggz_off_t offset_end = -1; - - if (oggz->file != NULL) { -+#ifndef WINCE - if ((fd = fileno (oggz->file)) == -1) { - /*oggz_set_error (oggz, OGGZ_ERR_SYSTEM);*/ - return -1; - } - - if (fstat (fd, &statbuf) == -1) { - /*oggz_set_error (oggz, OGGZ_ERR_SYSTEM);*/ - return -1; -@@ -582,16 +585,22 @@ oggz_offset_end (OGGZ * oggz) - printf ("oggz_offset_end: stat size %" PRI_OGGZ_OFF_T "d\n", offset_end); - #endif - } else { - /*oggz_set_error (oggz, OGGZ_ERR_NOSEEK);*/ - - /* XXX: should be able to just carry on and guess, as per io */ - /*return -1;*/ - } -+#else -+ int current = ftell(oggz->file); -+ fseek (oggz->file, 0, SEEK_END); -+ offset_end = ftell (oggz->file); -+ fseek (oggz->file, current, SEEK_SET); -+#endif - } else { - oggz_off_t offset_save; - - if (oggz->io == NULL || oggz->io->seek == NULL) { - /* No file, and no io seek method */ - return -1; - } - diff --git a/media/libsydneyaudio/update.sh b/media/libsydneyaudio/update.sh index 5c455b0d543..43ccd02bbab 100644 --- a/media/libsydneyaudio/update.sh +++ b/media/libsydneyaudio/update.sh @@ -1,7 +1,7 @@ -# Usage: ./update.sh +# Usage: ./update.sh # # Copies the needed files from a directory containing the original -# liboggplay source that we need for the Mozilla HTML5 media support. +# libsydneyaudio source that we need for the Mozilla HTML5 media support. cp $1/include/sydney_audio.h include/sydney_audio.h cp $1/src/*.c src/ cp $1/AUTHORS ./AUTHORS diff --git a/toolkit/content/license.html b/toolkit/content/license.html index 8d6b3cba260..c3eca51d5e5 100644 --- a/toolkit/content/license.html +++ b/toolkit/content/license.html @@ -2199,51 +2199,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -
- -

CSIRO Australia License

- -

This license applies to files in the directories: -

    -
  • media/libfishsound/
  • -
  • media/liboggplay/
  • -
  • media/liboggz/
  • -
-

- -
-Copyright (C) 2003 CSIRO Australia
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-   
-- Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-   
-- Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-   
-- Neither the name of the CSIRO nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-   
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- - -

Dutch Spellchecking Dictionary License

diff --git a/toolkit/toolkit-makefiles.sh b/toolkit/toolkit-makefiles.sh index 26bfdb6d942..91bfe3b3345 100644 --- a/toolkit/toolkit-makefiles.sh +++ b/toolkit/toolkit-makefiles.sh @@ -324,37 +324,12 @@ MAKEFILES_libtheora=" media/libtheora/include/theora/Makefile " -MAKEFILES_liboggz=" - media/liboggz/Makefile - media/liboggz/src/Makefile - media/liboggz/src/liboggz/Makefile - media/liboggz/include/Makefile - media/liboggz/include/oggz/Makefile -" - MAKEFILES_libogg=" media/libogg/Makefile media/libogg/src/Makefile media/libogg/include/Makefile media/libogg/include/ogg/Makefile " - -MAKEFILES_libfishsound=" - media/libfishsound/Makefile - media/libfishsound/src/Makefile - media/libfishsound/src/libfishsound/Makefile - media/libfishsound/include/Makefile - media/libfishsound/include/fishsound/Makefile -" - -MAKEFILES_liboggplay=" - media/liboggplay/Makefile - media/liboggplay/src/Makefile - media/liboggplay/src/liboggplay/Makefile - media/liboggplay/include/Makefile - media/liboggplay/include/oggplay/Makefile -" - MAKEFILES_libsydneyaudio=" media/libsydneyaudio/Makefile media/libsydneyaudio/include/Makefile @@ -1263,10 +1238,7 @@ if [ "$MOZ_OGG" ]; then add_makefiles " $MAKEFILES_libvorbis $MAKEFILES_libtheora - $MAKEFILES_liboggz $MAKEFILES_libogg - $MAKEFILES_libfishsound - $MAKEFILES_liboggplay content/media/ogg/Makefile " fi diff --git a/toolkit/toolkit-tiers.mk b/toolkit/toolkit-tiers.mk index ef897fe0314..9d0cd3f4b52 100644 --- a/toolkit/toolkit-tiers.mk +++ b/toolkit/toolkit-tiers.mk @@ -151,10 +151,7 @@ endif ifdef MOZ_OGG tier_platform_dirs += \ - media/libfishsound \ media/libogg \ - media/liboggplay \ - media/liboggz \ media/libtheora \ media/libvorbis \ $(NULL)