aboutsummaryrefslogtreecommitdiff
path: root/Src/replicant/nsmp3dec/bitsequence.h
diff options
context:
space:
mode:
authorJean-Francois Mauguit <jfmauguit@mac.com>2024-09-24 09:03:25 -0400
committerGitHub <noreply@github.com>2024-09-24 09:03:25 -0400
commitbab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/replicant/nsmp3dec/bitsequence.h
parent4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff)
parent20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff)
downloadwinamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/replicant/nsmp3dec/bitsequence.h')
-rw-r--r--Src/replicant/nsmp3dec/bitsequence.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/Src/replicant/nsmp3dec/bitsequence.h b/Src/replicant/nsmp3dec/bitsequence.h
new file mode 100644
index 00000000..df7b78b6
--- /dev/null
+++ b/Src/replicant/nsmp3dec/bitsequence.h
@@ -0,0 +1,69 @@
+/***************************************************************************\
+ *
+* MPEG Layer3-Audio Decoder
+* © 1997-2006 by Fraunhofer IIS
+ * All Rights Reserved
+ *
+ * filename: bitsequence.h
+ * project : MPEG Decoder
+ * author : Martin Sieler
+ * date : 1997-12-23
+ * contents/description: HEADER - bitsequence object
+ *
+ *
+\***************************************************************************/
+
+/*
+ * $Date: 2010/11/17 20:46:01 $
+ * $Id: bitsequence.h,v 1.1 2010/11/17 20:46:01 audiodsp Exp $
+ */
+
+#ifndef __BITSEQUENCE_H__
+#define __BITSEQUENCE_H__
+
+/* ------------------------ includes --------------------------------------*/
+
+#include "bitstream.h"
+
+/*-------------------------- defines --------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+
+//
+// Bitstream parser class.
+//
+// This helper class is basically a numerical value that can read itself from
+// a CBitStream interface for convenience. The decoder almost completely
+// does the bitstream parsing through CBitSequence rather than CBitStream
+// directly.
+//
+
+class CBitSequence
+{
+public:
+
+ CBitSequence(int nBits = 0) { m_nBits = nBits; m_nValue = 0; }
+ virtual ~CBitSequence() {}
+
+ void SetNumberOfBits(int nBits) { m_nBits = nBits; }
+ int GetNumberOfBits() const { return m_nBits; }
+
+ bool ReadFrom(CBitStream &Bs) { m_nValue = Bs.GetBits(m_nBits); return true; }
+ bool ReadFrom_Bit(CBitStream &Bs) { m_nValue = Bs.Get1Bit(); return true; }
+ bool ReadFrom(CBitStream &Bs, int nBits) { SetNumberOfBits(nBits); return ReadFrom(Bs); }
+
+ bool Equals(int nValue) const { return (m_nValue == nValue); }
+
+ int ToInt() const { return m_nValue; }
+ void FromInt(int nValue) { m_nValue = nValue; }
+
+protected:
+
+private:
+
+ int m_nBits;
+ int m_nValue;
+};
+
+/*-------------------------------------------------------------------------*/
+#endif