From 4375cd94fff9a6d9c5b2bb131681826d0b79d5a9 Mon Sep 17 00:00:00 2001
From: Frank Bossen <fbossen@gmail.com>
Date: Fri, 20 Jan 2023 06:41:13 -0500
Subject: [PATCH] Minor style improvements in AnnexBread

---
 source/App/StreamMergeApp/StreamMergeApp.h   | 22 +++++-----
 source/App/SubpicMergeApp/SubpicMergeApp.cpp |  2 +-
 source/Lib/DecoderLib/AnnexBread.h           | 46 ++++++++------------
 source/Lib/DecoderLib/DecLib.cpp             |  4 +-
 4 files changed, 33 insertions(+), 41 deletions(-)

diff --git a/source/App/StreamMergeApp/StreamMergeApp.h b/source/App/StreamMergeApp/StreamMergeApp.h
index deca3e26dc..a5a97c3b98 100644
--- a/source/App/StreamMergeApp/StreamMergeApp.h
+++ b/source/App/StreamMergeApp/StreamMergeApp.h
@@ -144,7 +144,7 @@ public:
   * returns true if an EOF will be encountered within the next
   * n bytes.
   */
-  bool eofBeforeNBytes(uint32_t n, std::istream& m_Input)
+  bool eofBeforeNBytes(uint32_t n, std::istream &m_input)
   {
     CHECK(n > 4, "Unsupported look-ahead value");
     if (m_numFutureBytes >= n)
@@ -157,8 +157,8 @@ public:
     {
       for (uint32_t i = 0; i < n; i++)
       {
-        m_futureBytes = (m_futureBytes << 8) | m_Input.get();
-          m_numFutureBytes++;
+        m_futureBytes = (m_futureBytes << 8) | m_input.get();
+        m_numFutureBytes++;
       }
     }
     catch (...)
@@ -180,9 +180,9 @@ public:
   * is undefined.
   *
   */
-  uint32_t peekBytes(uint32_t n, std::istream& m_Input)
+  uint32_t peekBytes(uint32_t n, std::istream &m_input)
   {
-    eofBeforeNBytes(n, m_Input);
+    eofBeforeNBytes(n, m_input);
     return m_futureBytes >> 8 * (m_numFutureBytes - n);
   }
 
@@ -192,17 +192,17 @@ public:
   * If bytestream is already at EOF prior to a call to readByte(),
   * an exception std::ios_base::failure is thrown.
   */
-  uint8_t readByte(std::istream& m_Input)
+  uint8_t readByte(std::istream &m_input)
   {
     if (!m_numFutureBytes)
     {
-      uint8_t byte = m_Input.get();
+      uint8_t byte = m_input.get();
       return byte;
     }
     m_numFutureBytes--;
-    uint8_t wanted_byte = m_futureBytes >> 8 * m_numFutureBytes;
+    uint8_t wantedByte = m_futureBytes >> 8 * m_numFutureBytes;
     m_futureBytes &= ~(0xff << 8 * m_numFutureBytes);
-    return wanted_byte;
+    return wantedByte;
   }
 
   /**
@@ -210,12 +210,12 @@ public:
   * bytestream are interpreted as bigendian when assembling
   * the return value.
   */
-  uint32_t readBytes(uint32_t n, std::istream& m_Input)
+  uint32_t readBytes(uint32_t n, std::istream &m_input)
   {
     uint32_t val = 0;
     for (uint32_t i = 0; i < n; i++)
     {
-      val = (val << 8) | readByte(m_Input);
+      val = (val << 8) | readByte(m_input);
     }
     return val;
   }
diff --git a/source/App/SubpicMergeApp/SubpicMergeApp.cpp b/source/App/SubpicMergeApp/SubpicMergeApp.cpp
index 1f38b24834..0ac8812b73 100644
--- a/source/App/SubpicMergeApp/SubpicMergeApp.cpp
+++ b/source/App/SubpicMergeApp/SubpicMergeApp.cpp
@@ -147,7 +147,7 @@ bool SubpicMergeApp::isNewPicture(std::ifstream *bitstreamFile, InputByteStream
   // save stream position for backup
 #if RExt__DECODER_DEBUG_STATISTICS
   CodingStatistics::CodingStatisticsData* backupStats = new CodingStatistics::CodingStatisticsData(CodingStatistics::GetStatistics());
-  std::streampos location = bitstreamFile->tellg() - std::streampos(bytestream->GetNumBufferedBytes());
+  std::streampos location = bitstreamFile->tellg() - std::streampos(bytestream->getNumBufferedBytes());
 #else
   std::streampos location = bitstreamFile->tellg();
 #endif
diff --git a/source/Lib/DecoderLib/AnnexBread.h b/source/Lib/DecoderLib/AnnexBread.h
index 999ca7c89a..7d1c152065 100644
--- a/source/Lib/DecoderLib/AnnexBread.h
+++ b/source/Lib/DecoderLib/AnnexBread.h
@@ -38,10 +38,7 @@
 
 #pragma once
 
-#ifndef __ANNEXBREAD__
-#define __ANNEXBREAD__
-
-#include <stdint.h>
+#include <cstdint>
 #include <istream>
 #include <vector>
 
@@ -62,10 +59,7 @@ public:
    *
    * Side-effects: the exception mask of istream is set to eofbit
    */
-  InputByteStream(std::istream& istream)
-  : m_NumFutureBytes(0)
-  , m_FutureBytes(0)
-  , m_Input(istream)
+  InputByteStream(std::istream &istream) : m_numFutureBytes(0), m_futureBytes(0), m_input(istream)
   {
     istream.exceptions(std::istream::eofbit | std::istream::badbit);
   }
@@ -76,8 +70,8 @@ public:
    */
   void reset()
   {
-    m_NumFutureBytes = 0;
-    m_FutureBytes = 0;
+    m_numFutureBytes = 0;
+    m_futureBytes    = 0;
   }
 
   /**
@@ -87,18 +81,18 @@ public:
   bool eofBeforeNBytes(uint32_t n)
   {
     CHECK(n > 4, "Unsupported look-ahead value");
-    if (m_NumFutureBytes >= n)
+    if (m_numFutureBytes >= n)
     {
       return false;
     }
 
-    n -= m_NumFutureBytes;
+    n -= m_numFutureBytes;
     try
     {
       for (uint32_t i = 0; i < n; i++)
       {
-        m_FutureBytes = (m_FutureBytes << 8) | m_Input.get();
-        m_NumFutureBytes++;
+        m_futureBytes = (m_futureBytes << 8) | m_input.get();
+        m_numFutureBytes++;
       }
     }
     catch (...)
@@ -123,7 +117,7 @@ public:
   uint32_t peekBytes(uint32_t n)
   {
     eofBeforeNBytes(n);
-    return m_FutureBytes >> 8*(m_NumFutureBytes - n);
+    return m_futureBytes >> 8 * (m_numFutureBytes - n);
   }
 
   /**
@@ -134,15 +128,15 @@ public:
    */
   uint8_t readByte()
   {
-    if (!m_NumFutureBytes)
+    if (m_numFutureBytes == 0)
     {
-      uint8_t byte = m_Input.get();
+      uint8_t byte = m_input.get();
       return byte;
     }
-    m_NumFutureBytes--;
-    uint8_t wanted_byte = m_FutureBytes >> 8*m_NumFutureBytes;
-    m_FutureBytes &= ~(0xff << 8*m_NumFutureBytes);
-    return wanted_byte;
+    m_numFutureBytes--;
+    const uint8_t wantedByte = m_futureBytes >> 8 * m_numFutureBytes;
+    m_futureBytes &= ~(0xff << 8 * m_numFutureBytes);
+    return wantedByte;
   }
 
   /**
@@ -161,13 +155,13 @@ public:
   }
 
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-  uint32_t GetNumBufferedBytes() const { return m_NumFutureBytes; }
+  uint32_t getNumBufferedBytes() const { return m_numFutureBytes; }
 #endif
 
 private:
-  uint32_t m_NumFutureBytes; /* number of valid bytes in m_FutureBytes */
-  uint32_t m_FutureBytes; /* bytes that have been peeked */
-  std::istream& m_Input; /* Input stream to read from */
+  uint32_t      m_numFutureBytes; /* number of valid bytes in m_futureBytes */
+  uint32_t      m_futureBytes;    /* bytes that have been peeked */
+  std::istream &m_input;          /* Input stream to read from */
 };
 
 /**
@@ -195,5 +189,3 @@ struct AnnexBStats
 bool byteStreamNALUnit(InputByteStream& bs, std::vector<uint8_t>& nalUnit, AnnexBStats& stats);
 
 //! \}
-
-#endif
diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp
index a4f0e08205..6570c12ec8 100644
--- a/source/Lib/DecoderLib/DecLib.cpp
+++ b/source/Lib/DecoderLib/DecLib.cpp
@@ -3971,7 +3971,7 @@ bool DecLib::isNewPicture(std::ifstream *bitstreamFile, class InputByteStream *b
   // save stream position for backup
 #if RExt__DECODER_DEBUG_STATISTICS
   CodingStatistics::CodingStatisticsData* backupStats = new CodingStatistics::CodingStatisticsData(CodingStatistics::GetStatistics());
-  std::streampos location = bitstreamFile->tellg() - std::streampos(bytestream->GetNumBufferedBytes());
+  std::streampos location = bitstreamFile->tellg() - std::streampos(bytestream->getNumBufferedBytes());
 #else
   std::streampos location = bitstreamFile->tellg();
 #endif
@@ -4080,7 +4080,7 @@ bool DecLib::isNewAccessUnit( bool newPicture, std::ifstream *bitstreamFile, cla
   // save stream position for backup
 #if RExt__DECODER_DEBUG_STATISTICS
   CodingStatistics::CodingStatisticsData* backupStats = new CodingStatistics::CodingStatisticsData(CodingStatistics::GetStatistics());
-  std::streampos location = bitstreamFile->tellg() - std::streampos(bytestream->GetNumBufferedBytes());
+  std::streampos location = bitstreamFile->tellg() - std::streampos(bytestream->getNumBufferedBytes());
 #else
   std::streampos location = bitstreamFile->tellg();
 #endif
-- 
GitLab