[x265-commits] [x265] api: add an enum for extended SAR

Steve Borho steve at borho.org
Sat Feb 22 23:21:38 CET 2014


details:   http://hg.videolan.org/x265/rev/9d550a10215b
branches:  
changeset: 6251:9d550a10215b
user:      Steve Borho <steve at borho.org>
date:      Fri Feb 21 16:13:26 2014 -0600
description:
api: add an enum for extended SAR
Subject: [x265] encoder: warn about the incomplete nature of the range extensions

details:   http://hg.videolan.org/x265/rev/82b05314cc4c
branches:  
changeset: 6252:82b05314cc4c
user:      Steve Borho <steve at borho.org>
date:      Fri Feb 21 16:19:49 2014 -0600
description:
encoder: warn about the incomplete nature of the range extensions
Subject: [x265] common: refactor logic to avoid compiler warnings

details:   http://hg.videolan.org/x265/rev/a6cf678f7981
branches:  
changeset: 6253:a6cf678f7981
user:      Steve Borho <steve at borho.org>
date:      Sat Feb 22 14:00:19 2014 -0600
description:
common: refactor logic to avoid compiler warnings
Subject: [x265] cmake: make /WX optional for MSVC

details:   http://hg.videolan.org/x265/rev/050273a10519
branches:  
changeset: 6254:050273a10519
user:      Steve Borho <steve at borho.org>
date:      Sat Feb 22 14:18:13 2014 -0600
description:
cmake: make /WX optional for MSVC
Subject: [x265] common: avoid calling atobool() on non-boolean strings

details:   http://hg.videolan.org/x265/rev/f641d88f95dd
branches:  
changeset: 6255:f641d88f95dd
user:      Steve Borho <steve at borho.org>
date:      Sat Feb 22 14:22:57 2014 -0600
description:
common: avoid calling atobool() on non-boolean strings
Subject: [x265] NAL: use explicit reset method instead of copy constructor

details:   http://hg.videolan.org/x265/rev/155fdcd113fb
branches:  
changeset: 6256:155fdcd113fb
user:      Steve Borho <steve at borho.org>
date:      Sat Feb 22 14:56:04 2014 -0600
description:
NAL: use explicit reset method instead of copy constructor
Subject: [x265] NAL: cleanup write method

details:   http://hg.videolan.org/x265/rev/44a42cd7f186
branches:  
changeset: 6257:44a42cd7f186
user:      Steve Borho <steve at borho.org>
date:      Sat Feb 22 15:06:14 2014 -0600
description:
NAL: cleanup write method

This whole class hierarchy is way over-engineered
Subject: [x265] NAL: further simplifications

details:   http://hg.videolan.org/x265/rev/d8d61736f2fc
branches:  
changeset: 6258:d8d61736f2fc
user:      Steve Borho <steve at borho.org>
date:      Sat Feb 22 15:11:21 2014 -0600
description:
NAL: further simplifications
Subject: [x265] TComBitstream: nits

details:   http://hg.videolan.org/x265/rev/7fb5a8e1465a
branches:  
changeset: 6259:7fb5a8e1465a
user:      Steve Borho <steve at borho.org>
date:      Sat Feb 22 15:14:37 2014 -0600
description:
TComBitstream: nits
Subject: [x265] TEncSbac: cleanup header

details:   http://hg.videolan.org/x265/rev/c61a1bf68c57
branches:  
changeset: 6260:c61a1bf68c57
user:      Steve Borho <steve at borho.org>
date:      Sat Feb 22 15:21:16 2014 -0600
description:
TEncSbac: cleanup header
Subject: [x265] TEncSbac: nits

details:   http://hg.videolan.org/x265/rev/a640cde93d87
branches:  
changeset: 6261:a640cde93d87
user:      Steve Borho <steve at borho.org>
date:      Sat Feb 22 15:38:39 2014 -0600
description:
TEncSbac: nits
Subject: [x265] cli: add a line of logging describing reconstructed image file

details:   http://hg.videolan.org/x265/rev/8ec8aba042cc
branches:  
changeset: 6262:8ec8aba042cc
user:      Steve Borho <steve at borho.org>
date:      Sat Feb 22 15:50:53 2014 -0600
description:
cli: add a line of logging describing reconstructed image file
Subject: [x265] encoder: use cpu count, rather than pool size, to auto-detect frame threads

details:   http://hg.videolan.org/x265/rev/734f106295df
branches:  
changeset: 6263:734f106295df
user:      Steve Borho <steve at borho.org>
date:      Sat Feb 22 15:59:39 2014 -0600
description:
encoder: use cpu count, rather than pool size, to auto-detect frame threads

Normally the pool size is the same as the detected cpu count, but when WPP is
disabled, the thread count is 1, and this was breaking auto-detection of frame
threads.  Now it will properly use -F4 on desktops when WPP is disabled.

diffstat:

 source/CMakeLists.txt                   |   19 +-
 source/Lib/TLibCommon/NAL.h             |   31 +--
 source/Lib/TLibCommon/TComBitStream.cpp |   11 +-
 source/Lib/TLibCommon/TComBitStream.h   |    2 +-
 source/Lib/TLibEncoder/NALwrite.cpp     |   23 +-
 source/Lib/TLibEncoder/NALwrite.h       |   24 +--
 source/Lib/TLibEncoder/TEncSbac.cpp     |  267 +++++++++++++++----------------
 source/Lib/TLibEncoder/TEncSbac.h       |  105 ++++-------
 source/common/common.cpp                |   43 ++--
 source/common/threadpool.cpp            |    5 +-
 source/common/threadpool.h              |    2 +
 source/encoder/encoder.cpp              |   15 +-
 source/encoder/frameencoder.cpp         |   10 +-
 source/output/output.h                  |    2 +
 source/output/y4m.h                     |    2 +
 source/output/yuv.h                     |    2 +
 source/x265.cpp                         |    4 +
 source/x265.h                           |    8 +-
 18 files changed, 279 insertions(+), 296 deletions(-)

diffs (truncated from 1356 to 300 lines):

diff -r 06d3b23ef3b6 -r 734f106295df source/CMakeLists.txt
--- a/source/CMakeLists.txt	Fri Feb 21 16:04:33 2014 -0600
+++ b/source/CMakeLists.txt	Sat Feb 22 15:59:39 2014 -0600
@@ -83,12 +83,14 @@ if(MSVC)
             string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
         endforeach()
     endif (STATIC_LINK_CRT)
-    # Enforce coding standards.  Full warnings and warnings as errors
-    add_definitions(/W4 /WX /D_CRT_SECURE_NO_WARNINGS)
+    add_definitions(/W4)  # Full warnings
     add_definitions(/Ob2) # always inline
     add_definitions(/Oi)  # enable intrinsics
     add_definitions(/MP)  # multithreaded build
 
+    # disable Microsofts suggestions for proprietary secure APIs
+    add_definitions(/D_CRT_SECURE_NO_WARNINGS)
+
     check_include_files(stdint.h HAVE_STDINT_H)
     if(NOT HAVE_STDINT_H)
         include_directories(compat/msvc)
@@ -113,10 +115,6 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
     execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
 endif()
 if (GCC)
-    option(WARNINGS_AS_ERRORS "Stop compiles on first warning" OFF)
-    if(WARNINGS_AS_ERRORS)
-        add_definitions(-Werror)
-    endif(WARNINGS_AS_ERRORS)
     if(X64 AND NOT WIN32)
         add_definitions(-fPIC)
     endif(X64 AND NOT WIN32)
@@ -156,6 +154,15 @@ else(HIGH_BIT_DEPTH)
     add_definitions(-DHIGH_BIT_DEPTH=0)
 endif(HIGH_BIT_DEPTH)
 
+option(WARNINGS_AS_ERRORS "Stop compiles on first warning" OFF)
+if(WARNINGS_AS_ERRORS)
+    if(GCC)
+        add_definitions(-Werror)
+    elseif(MSVC)
+        add_definitions(/WX)
+    endif()
+endif(WARNINGS_AS_ERRORS)
+
 option(LOG_CU_STATISTICS "Log Mode Decision Statistics at the CU Level" OFF)
 if(LOG_CU_STATISTICS)
     add_definitions(-DLOG_CU_STATISTICS=1)
diff -r 06d3b23ef3b6 -r 734f106295df source/Lib/TLibCommon/NAL.h
--- a/source/Lib/TLibCommon/NAL.h	Fri Feb 21 16:04:33 2014 -0600
+++ b/source/Lib/TLibCommon/NAL.h	Sat Feb 22 15:59:39 2014 -0600
@@ -36,37 +36,27 @@
 
 #include "CommonDef.h"
 #include "x265.h"
-#include <sstream>
 
 namespace x265 {
 // private namespace
 
-class TComOutputBitstream;
-
 /**
  * Represents a single NALunit header and the associated RBSPayload
  */
 struct NALUnit
 {
-    NalUnitType m_nalUnitType; ///< nal_unit_type
-    uint32_t        m_temporalId; ///< temporal_id
-    uint32_t        m_reservedZero6Bits; ///< reserved_zero_6bits
+    NalUnitType m_nalUnitType;       ///< nal_unit_type
+    uint32_t    m_temporalId;        ///< temporal_id
+    uint32_t    m_reservedZero6Bits; ///< reserved_zero_6bits
 
-    /** construct an NALunit structure with given header values. */
-    NALUnit(NalUnitType nalUnitType,
-            int         temporalId = 0,
-            int         reservedZero6Bits = 0)
-        : m_nalUnitType(nalUnitType)
-        , m_temporalId(temporalId)
-        , m_reservedZero6Bits(reservedZero6Bits)
-    {}
-
-    /** default constructor - no initialization; must be perfomed by user */
-    NALUnit() {}
+    NALUnit(NalUnitType nalUnitType)
+    {
+        m_nalUnitType = nalUnitType;
+        m_temporalId = 0;
+        m_reservedZero6Bits = 0;
+    }
 };
 
-struct OutputNALUnit;
-
 /**
  * A single NALunit, with complete payload in EBSP format.
  */
@@ -80,9 +70,8 @@ struct NALUnitEBSP : public NALUnit
      * the NALUnit header, then the rbsp_bytes including any
      * emulation_prevention_three_byte symbols.
      */
-    void init(OutputNALUnit& nalu);
+    void init(const struct OutputNALUnit& nalu);
 };
 }
-//! \}
 
 #endif // ifndef X265_NAL_H
diff -r 06d3b23ef3b6 -r 734f106295df source/Lib/TLibCommon/TComBitStream.cpp
--- a/source/Lib/TLibCommon/TComBitStream.cpp	Fri Feb 21 16:04:33 2014 -0600
+++ b/source/Lib/TLibCommon/TComBitStream.cpp	Sat Feb 22 15:59:39 2014 -0600
@@ -72,7 +72,7 @@ char* TComOutputBitstream::getByteStream
     return (char*)m_fifo;
 }
 
-uint32_t TComOutputBitstream::getByteStreamLength()
+uint32_t TComOutputBitstream::getByteStreamLength() const
 {
     return m_fsize;
 }
@@ -145,19 +145,16 @@ void TComOutputBitstream::writeAlignOne(
 
 void TComOutputBitstream::writeAlignZero()
 {
-    if (0 == m_num_held_bits)
-    {
+    if (!m_num_held_bits)
         return;
-    }
+
     push_back(m_held_bits);
     m_held_bits = 0;
     m_num_held_bits = 0;
 }
 
 /**
- - add substream to the end of the current bitstream
- .
- \param  pcSubstream  substream to be added
+ * add substream to the end of the current bitstream
  */
 void TComOutputBitstream::addSubstream(TComOutputBitstream* substream)
 {
diff -r 06d3b23ef3b6 -r 734f106295df source/Lib/TLibCommon/TComBitStream.h
--- a/source/Lib/TLibCommon/TComBitStream.h	Fri Feb 21 16:04:33 2014 -0600
+++ b/source/Lib/TLibCommon/TComBitStream.h	Sat Feb 22 15:59:39 2014 -0600
@@ -128,7 +128,7 @@ public:
     /**
      * Return the number of valid bytes available from  getByteStream()
      */
-    uint32_t getByteStreamLength();
+    uint32_t getByteStreamLength() const;
 
     /**
      * Reset all internal state.
diff -r 06d3b23ef3b6 -r 734f106295df source/Lib/TLibEncoder/NALwrite.cpp
--- a/source/Lib/TLibEncoder/NALwrite.cpp	Fri Feb 21 16:04:33 2014 -0600
+++ b/source/Lib/TLibEncoder/NALwrite.cpp	Sat Feb 22 15:59:39 2014 -0600
@@ -47,18 +47,19 @@ static const char emulation_prevention_t
 /**
  * write nalu to bytestream out, performing RBSP anti startcode
  * emulation as required.  nalu.m_RBSPayload must be byte aligned.
+ * caller is responsible for freeing returned allocated pointer
  */
-void write(uint8_t*& out, OutputNALUnit& nalu, uint32_t &packetSize)
+uint8_t *write(const OutputNALUnit& nalu, uint32_t &packetSize)
 {
     packetSize = 0;
     TComOutputBitstream bsNALUHeader;
-    bsNALUHeader.write(0, 1);                 // forbidden_zero_bit
-    bsNALUHeader.write(nalu.m_nalUnitType, 6); // nal_unit_type
-    bsNALUHeader.write(nalu.m_reservedZero6Bits, 6);                 // nuh_reserved_zero_6bits
-    bsNALUHeader.write(nalu.m_temporalId + 1, 3); // nuh_temporal_id_plus1
+    bsNALUHeader.write(0, 1);                        // forbidden_zero_bit
+    bsNALUHeader.write(nalu.m_nalUnitType, 6);       // nal_unit_type
+    bsNALUHeader.write(nalu.m_reservedZero6Bits, 6); // nuh_reserved_zero_6bits
+    bsNALUHeader.write(nalu.m_temporalId + 1, 3);    // nuh_temporal_id_plus1
 
     packetSize += bsNALUHeader.getByteStreamLength();
-    out = (uint8_t*)malloc(packetSize);
+    uint8_t *out = (uint8_t*)malloc(packetSize);
     ::memcpy(out, bsNALUHeader.getByteStream(), packetSize);
 
     /* write out rsbp_byte's, inserting any required
@@ -114,10 +115,10 @@ void write(uint8_t*& out, OutputNALUnit&
         packetSize += nalsize;
 
         /* 7.4.1.1
-        * ... when the last byte of the RBSP data is equal to 0x00 (which can
-        * only occur when the RBSP ends in a cabac_zero_word), a final byte equal
-        * to 0x03 is appended to the end of the data.
-        */
+         * ... when the last byte of the RBSP data is equal to 0x00 (which can
+         * only occur when the RBSP ends in a cabac_zero_word), a final byte equal
+         * to 0x03 is appended to the end of the data.
+         */
         if (out[packetSize - 1] == 0x00)
         {
             out[i] = 3;
@@ -125,6 +126,8 @@ void write(uint8_t*& out, OutputNALUnit&
         }
         X265_FREE(emulation);
     }
+
+    return out;
 }
 
 /**
diff -r 06d3b23ef3b6 -r 734f106295df source/Lib/TLibEncoder/NALwrite.h
--- a/source/Lib/TLibEncoder/NALwrite.h	Fri Feb 21 16:04:33 2014 -0600
+++ b/source/Lib/TLibEncoder/NALwrite.h	Sat Feb 22 15:59:39 2014 -0600
@@ -34,8 +34,6 @@
 #ifndef X265_NALWRITE_H
 #define X265_NALWRITE_H
 
-#include <ostream>
-
 #include "TLibCommon/TypeDef.h"
 #include "TLibCommon/TComBitStream.h"
 #include "TLibCommon/NAL.h"
@@ -43,9 +41,6 @@
 namespace x265 {
 // private namespace
 
-//! \ingroup TLibEncoder
-//! \{
-
 /**
  * A convenience wrapper to NALUnit that also provides a
  * bitstream object.
@@ -57,35 +52,30 @@ struct OutputNALUnit : public NALUnit
      * storage for a bitstream.  Upon construction the NALunit header is
      * written to the bitstream.
      */
-    OutputNALUnit(NalUnitType nalUnitType,
-                  uint32_t    temporalID = 0,
-                  uint32_t    reserved_zero_6bits = 0)
-        : NALUnit(nalUnitType, temporalID, reserved_zero_6bits)
+    OutputNALUnit(NalUnitType nalUnitType)
+        : NALUnit(nalUnitType)
         , m_bitstream()
     {}
 
-    OutputNALUnit& operator =(const NALUnit& src)
+    void resetToType(NalUnitType nalUnitType)
     {
+        m_nalUnitType = nalUnitType;
         m_bitstream.clear();
-        static_cast<NALUnit*>(this)->operator =(src);
-        return *this;
     }
 
     TComOutputBitstream m_bitstream;
 };
 
-void write(uint8_t*& out, OutputNALUnit& nalu, uint32_t& packetSize);
+uint8_t *write(const OutputNALUnit& nalu, uint32_t& packetSize);
 void writeRBSPTrailingBits(TComOutputBitstream& bs);
 
-void inline NALUnitEBSP::init(OutputNALUnit& nalu)
+void inline NALUnitEBSP::init(const OutputNALUnit& nalu)
 {
     m_nalUnitType = nalu.m_nalUnitType;
     m_temporalId = nalu.m_temporalId;
     m_reservedZero6Bits = nalu.m_reservedZero6Bits;
-    write(m_nalUnitData, nalu, m_packetSize);
+    m_nalUnitData = write(nalu, m_packetSize);
 }
 }
 
-//! \}
-
 #endif // ifndef X265_NALWRITE_H
diff -r 06d3b23ef3b6 -r 734f106295df source/Lib/TLibEncoder/TEncSbac.cpp
--- a/source/Lib/TLibEncoder/TEncSbac.cpp	Fri Feb 21 16:04:33 2014 -0600
+++ b/source/Lib/TLibEncoder/TEncSbac.cpp	Sat Feb 22 15:59:39 2014 -0600
@@ -107,7 +107,7 @@ uint8_t sbacInit(int qp, int initValue)
     int  slope      = (initValue >> 4) * 5 - 45;
     int  offset     = ((initValue & 15) << 3) - 16;
     int  initState  =  X265_MIN(X265_MAX(1, (((slope * qp) >> 4) + offset)), 126);
-    uint32_t mpState    = (initState >= 64);
+    uint32_t mpState = (initState >= 64);
     uint8_t m_state = ((mpState ? (initState - 64) : (63 - initState)) << 1) + mpState;
 
     return m_state;
@@ -138,7 +138,7 @@ static uint32_t calcCost(ContextModel *c
         // Map the 64 CABAC states to their corresponding probability values
         static const double aStateToProbLPS[] = { 0.50000000, 0.47460857, 0.45050660, 0.42762859, 0.40591239, 0.38529900, 0.36573242, 0.34715948, 0.32952974, 0.31279528, 0.29691064, 0.28183267, 0.26752040, 0.25393496, 0.24103941, 0.22879875, 0.21717969, 0.20615069, 0.19568177, 0.18574449, 0.17631186, 0.16735824, 0.15885931, 0.15079198, 0.14313433, 0.13586556, 0.12896592, 0.12241667, 0.11620000, 0.11029903, 0.10469773, 0.09938088, 0.09433404, 0.08954349, 0.08499621, 0.08067986, 0.07658271, 0.07269362, 0.06900203, 0.06549791, 0.06217174, 0.05901448, 0.05601756, 0.05317283, 0.05047256, 0.04790942, 0.04547644, 0.04316702, 0.04097487, 0.03889405, 0.03691890, 0.03504406, 0.03326442, 0.03157516, 0.02997168, 0.02844963, 0.02700488, 0.02563349, 0.02433175, 0.02309612, 0.02192323, 0.02080991, 0.01975312, 0.01875000 };
 
-        double probLPS          = aStateToProbLPS[sbacGetState(contextModel[n].m_state)];
+        double probLPS = aStateToProbLPS[sbacGetState(contextModel[n].m_state)];
         double prob0, prob1;
         if (sbacGetMps(contextModel[n].m_state) == 1)
         {
@@ -234,8 +234,8 @@ void TEncSbac::determineCabacInitIdx()
     {
         SliceType aSliceTypeChoices[] = { B_SLICE, P_SLICE };
 
-        uint32_t bestCost             = MAX_UINT;
-        SliceType bestSliceType   = aSliceTypeChoices[0];


More information about the x265-commits mailing list