Bug 805254. Part 11: Move Vorbis-specific definitons into a new file VorbisUtils.h. r=kinetik
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 25 Oct 2012 23:09:41 +1300
changeset 111627 c3fcdbf501049aec59009d7804e05d793abaeacc
parent 111626 68faa49eec3d23194b0fe68a2d8266e5b8096779
child 111628 1eb3bd54b7bd6ed60456e790540917cad9fa7b4b
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewerskinetik
bugs805254
milestone19.0a1
Bug 805254. Part 11: Move Vorbis-specific definitons into a new file VorbisUtils.h. r=kinetik
content/media/Makefile.in
content/media/VorbisUtils.h
content/media/nsBuiltinDecoderReader.h
content/media/ogg/nsOggReader.cpp
content/media/webm/nsWebMReader.cpp
--- a/content/media/Makefile.in
+++ b/content/media/Makefile.in
@@ -29,16 +29,17 @@ EXPORTS = \
   nsMediaCache.h \
   nsMediaDecoder.h \
   SharedBuffer.h \
   StreamBuffer.h \
   TimeVarying.h \
   VideoFrameContainer.h \
   VideoUtils.h \
   VideoSegment.h \
+  VorbisUtils.h \
   $(NULL)
 
 CPPSRCS = \
   AudioSegment.cpp \
   FileBlockCache.cpp \
   MediaResource.cpp \
   MediaStreamGraph.cpp \
   nsAudioAvailableEventManager.cpp \
new file mode 100644
--- /dev/null
+++ b/content/media/VorbisUtils.h
@@ -0,0 +1,27 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef VORBISUTILS_H_
+#define VORBISUTILS_H_
+
+#ifdef MOZ_SAMPLE_TYPE_S16
+#include <ogg/os_types.h>
+typedef ogg_int32_t VorbisPCMValue;
+
+#define MOZ_CLIP_TO_15(x) ((x)<-32768?-32768:(x)<=32767?(x):32767)
+// Convert the output of vorbis_synthesis_pcmout to a AudioDataValue
+#define MOZ_CONVERT_VORBIS_SAMPLE(x) \
+ (static_cast<AudioDataValue>(MOZ_CLIP_TO_15((x)>>9)))
+
+#else /* MOZ_SAMPLE_TYPE_FLOAT32 */
+
+typedef float VorbisPCMValue;
+
+#define MOZ_CONVERT_VORBIS_SAMPLE(x) (x)
+
+#endif
+
+#endif /* VORBISUTILS_H_ */
--- a/content/media/nsBuiltinDecoderReader.h
+++ b/content/media/nsBuiltinDecoderReader.h
@@ -49,33 +49,16 @@ public:
 
   // True if we have an active audio bitstream.
   bool mHasAudio;
 
   // True if we have an active video bitstream.
   bool mHasVideo;
 };
 
-#ifdef MOZ_SAMPLE_TYPE_S16
-#include <ogg/os_types.h>
-typedef ogg_int32_t VorbisPCMValue;
-
-#define MOZ_CLIP_TO_15(x) ((x)<-32768?-32768:(x)<=32767?(x):32767)
-// Convert the output of vorbis_synthesis_pcmout to a AudioDataValue
-#define MOZ_CONVERT_VORBIS_SAMPLE(x) \
- (static_cast<AudioDataValue>(MOZ_CLIP_TO_15((x)>>9)))
-
-#else /* MOZ_SAMPLE_TYPE_FLOAT32 */
-
-typedef float VorbisPCMValue;
-
-#define MOZ_CONVERT_VORBIS_SAMPLE(x) (x)
-
-#endif
-
 // Holds chunk a decoded audio frames.
 class AudioData {
 public:
   typedef mozilla::SharedBuffer SharedBuffer;
   typedef mozilla::AudioDataValue AudioDataValue;
 
   AudioData(int64_t aOffset,
             int64_t aTime,
--- a/content/media/ogg/nsOggReader.cpp
+++ b/content/media/ogg/nsOggReader.cpp
@@ -12,16 +12,17 @@
 #ifdef MOZ_OPUS
 #include "opus/opus.h"
 extern "C" {
 #include "opus/opus_multistream.h"
 }
 #endif
 #include "nsTimeRanges.h"
 #include "mozilla/TimeStamp.h"
+#include "VorbisUtils.h"
 
 using namespace mozilla;
 
 // On B2G estimate the buffered ranges rather than calculating them explicitly.
 // This prevents us doing I/O on the main thread, which is prohibited in B2G.
 #ifdef MOZ_WIDGET_GONK
 #define OGG_ESTIMATE_BUFFERED 1
 #endif
--- a/content/media/webm/nsWebMReader.cpp
+++ b/content/media/webm/nsWebMReader.cpp
@@ -6,16 +6,17 @@
 #include "nsError.h"
 #include "nsBuiltinDecoderStateMachine.h"
 #include "nsBuiltinDecoder.h"
 #include "MediaResource.h"
 #include "nsWebMReader.h"
 #include "nsWebMBufferedParser.h"
 #include "VideoUtils.h"
 #include "nsTimeRanges.h"
+#include "VorbisUtils.h"
 
 #define VPX_DONT_DEFINE_STDINT_TYPES
 #include "vpx/vp8dx.h"
 #include "vpx/vpx_decoder.h"
 
 using namespace mozilla;
 using namespace mozilla::layers;