Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2011-07-23 20:27:02 +0400
committerHendrik Leppkes <h.leppkes@gmail.com>2011-07-24 16:46:32 +0400
commitcd2222cba3f97f0e660e534a8c9d9214492fdd58 (patch)
tree7d22cd10b4e1d3c8e9381f4a6c75eb7766e0d623 /demuxer/Demuxers
parentdc6223b43550500c61b2143d78c7935d66acc3a0 (diff)
Moved ByteParser helper class into DSUtilLite
Diffstat (limited to 'demuxer/Demuxers')
-rw-r--r--demuxer/Demuxers/ByteParser.cpp93
-rw-r--r--demuxer/Demuxers/ByteParser.h76
-rw-r--r--demuxer/Demuxers/Demuxers.vcxproj2
-rw-r--r--demuxer/Demuxers/Demuxers.vcxproj.filters6
4 files changed, 0 insertions, 177 deletions
diff --git a/demuxer/Demuxers/ByteParser.cpp b/demuxer/Demuxers/ByteParser.cpp
deleted file mode 100644
index 8597edd9..00000000
--- a/demuxer/Demuxers/ByteParser.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2011 Hendrik Leppkes
- * http://www.1f0.de
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2
- */
-
-#include "stdafx.h"
-#include "ByteParser.h"
-
-CByteParser::CByteParser(const BYTE *pData, uint32_t length)
- : m_pData(pData), m_pCurrent(pData), m_pEnd(pData+length), m_dwLen(length), m_bitBuffer(0), m_bitLen(0)
-{
-}
-
-CByteParser::~CByteParser()
-{
-}
-
-uint32_t CByteParser::BitRead(uint8_t numBits, bool peek)
-{
- ASSERT(numBits <= 32);
- ASSERT(numBits <= (m_bitLen + (8 * (m_pEnd - m_pCurrent))));
-
- if (numBits == 0) { return 0; }
-
- bool atEnd = false;
- // Read more data in the buffer
- while(m_bitLen < numBits) {
- m_bitBuffer <<= 8;
- m_bitBuffer += !atEnd ? *m_pCurrent : 0;
- // Just a safety check so we don't cross the array boundary
- if (m_pCurrent < m_pEnd) { m_pCurrent++; } else { atEnd = true; }
- m_bitLen += 8;
- }
-
- // Number of superfluous bits in the buffer
- int bitlen = m_bitLen - numBits;
-
- // Compose the return value
- // Shift the value so the superfluous bits fall off, and then crop the result with an AND
- uint32_t ret = (m_bitBuffer >> bitlen) & ((1ui64 << numBits) - 1);
-
- // If we're not peeking, then update the buffer and remove the data we just read
- if(!peek) {
- m_bitBuffer &= ((1ui64 << bitlen) - 1);
- m_bitLen = bitlen;
- }
-
- return ret;
-}
-
-// Exponential Golomb Coding (with k = 0)
-// As used in H.264/MPEG-4 AVC
-// http://en.wikipedia.org/wiki/Exponential-Golomb_coding
-
-uint64_t CByteParser::UExpGolombRead() {
- int n = -1;
- for(BYTE b = 0; !b; n++) {
- b = BitRead(1);
- }
- return (1ui64 << n) - 1 + BitRead(n);
-}
-
-int64_t CByteParser::SExpGolombRead() {
- uint64_t k = UExpGolombRead();
- // Negative numbers are interleaved in the series
- // k: 0, 1, 2, 3, 4, 5, 6, ...
- // Actual: 0, 1, -1, 2, -2, 3, -3, ....
- // So all even numbers are negative (last bit = 0)
- return ((k&1) ? 1 : -1) * ((k + 1) >> 1);
-}
-
-void CByteParser::Seek(DWORD pos)
-{
- m_pCurrent = m_pData + min(m_dwLen, pos);
- BitFlush();
-}
diff --git a/demuxer/Demuxers/ByteParser.h b/demuxer/Demuxers/ByteParser.h
deleted file mode 100644
index 695a7acd..00000000
--- a/demuxer/Demuxers/ByteParser.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 Hendrik Leppkes
- * http://www.1f0.de
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2
- */
-
-#pragma once
-
-/**
-* Byte Parser Utility Class
-*/
-class CByteParser
-{
-public:
- /** Construct a Byte Parser to parse the given BYTE array with the given length */
- CByteParser(const BYTE *pData, uint32_t length);
- virtual ~CByteParser();
-
- /** Read 1 to 32 Bits from the Byte Array. If peek is set, the data will just be returned, and the buffer not advanced. */
- uint32_t BitRead(uint8_t numBits, bool peek = false);
-
- /** Read a unsigned number in Exponential Golomb encoding (with k = 0) */
- uint64_t UExpGolombRead();
- /** Read a signed number in Exponential Golomb encoding (with k = 0) */
- int64_t SExpGolombRead();
-
- /** Seek to the position (in bytes) in the byte array */
- void Seek(DWORD pos);
-
- /** Pointer to the start of the byte array */
- const BYTE *Start() const { return m_pData; }
- /** Pointer to the end of the byte array */
- const BYTE *End() const { return m_pEnd; }
-
- /** Overall length (in bytes) of the byte array */
- uint32_t Length() const { return m_dwLen; }
- /** Current byte position in the array. Any incomplete bytes ( buffer < 8 bits ) will not be counted */
- uint32_t Pos() const { return uint32_t(m_pCurrent - m_pData) - (m_bitLen>>3); }
- /** Number of bytes remaining in the array */
- uint32_t Remaining() const { return Length() - Pos(); }
-
- /** Flush any bits currently in the buffer */
- void BitFlush() { m_bitLen = 0; m_bitBuffer = 0; }
- /** Skip bits until the next byte border */
- void BitByteAlign() { BitRead(m_bitLen & 7); }
-
-private:
- // Pointer to the start of the data buffer
- const BYTE * const m_pData;
-
- // Pointer to the current position in the data buffer
- const BYTE *m_pCurrent;
- // Pointer to the end in the data buffer
- const BYTE * const m_pEnd;
-
- const uint32_t m_dwLen;
-
- uint64_t m_bitBuffer;
- uint8_t m_bitLen;
-};
diff --git a/demuxer/Demuxers/Demuxers.vcxproj b/demuxer/Demuxers/Demuxers.vcxproj
index d14cb4cd..60b0ff31 100644
--- a/demuxer/Demuxers/Demuxers.vcxproj
+++ b/demuxer/Demuxers/Demuxers.vcxproj
@@ -122,7 +122,6 @@
<ItemGroup>
<ClInclude Include="BaseDemuxer.h" />
<ClInclude Include="BDDemuxer.h" />
- <ClInclude Include="ByteParser.h" />
<ClInclude Include="ExtradataParser.h" />
<ClInclude Include="LAVFAudioHelper.h" />
<ClInclude Include="LAVFDemuxer.h" />
@@ -135,7 +134,6 @@
<ItemGroup>
<ClCompile Include="BaseDemuxer.cpp" />
<ClCompile Include="BDDemuxer.cpp" />
- <ClCompile Include="ByteParser.cpp" />
<ClCompile Include="ExtradataParser.cpp" />
<ClCompile Include="LAVFAudioHelper.cpp" />
<ClCompile Include="LAVFDemuxer.cpp" />
diff --git a/demuxer/Demuxers/Demuxers.vcxproj.filters b/demuxer/Demuxers/Demuxers.vcxproj.filters
index d2a6da50..9440bb3b 100644
--- a/demuxer/Demuxers/Demuxers.vcxproj.filters
+++ b/demuxer/Demuxers/Demuxers.vcxproj.filters
@@ -33,9 +33,6 @@
<ClInclude Include="StreamInfo.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="ByteParser.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="ExtradataParser.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -68,9 +65,6 @@
<ClCompile Include="StreamInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="ByteParser.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="ExtradataParser.cpp">
<Filter>Source Files</Filter>
</ClCompile>