[x265-commits] [x265] bring SyntaxElementWriter into common/, remove trace file...

Steve Borho steve at borho.org
Fri Jul 11 04:06:59 CEST 2014


details:   http://hg.videolan.org/x265/rev/64dc40d52519
branches:  
changeset: 7293:64dc40d52519
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 13:59:19 2014 -0500
description:
bring SyntaxElementWriter into common/, remove trace file macros

File tracing has been essentially broken since frame parallelism was introduced
(not to mention multiple encoder instances in a process) and is going to be
soon even more impossible when the second encodeCU() pass is removed. It's best
to remove this old HM feature so people don't get stuck trying to use it.

Stream analyzers like Parabola and Elecard are now mature enough that these
trace files are not very helpful. If you *really* want the old style trace
file, enable tracing in the HM decoder and decode your bitstream with it.

I left the strings in the WRITE_* macros in place because they make those calls
reasonably self-documenting. The compiler will throw them away harmlessly.
Subject: [x265] bitstream: convert macros into inline members for better compile-time checking

details:   http://hg.videolan.org/x265/rev/b96714bdda85
branches:  
changeset: 7294:b96714bdda85
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 14:07:03 2014 -0500
description:
bitstream: convert macros into inline members for better compile-time checking
Subject: [x265] bitstream: hoist trivial methods to the header so they may be easier inlined

details:   http://hg.videolan.org/x265/rev/57a4c1c2274e
branches:  
changeset: 7295:57a4c1c2274e
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 14:13:30 2014 -0500
description:
bitstream: hoist trivial methods to the header so they may be easier inlined
Subject: [x265] cu, search: remove redundant m_rdGoOnSbacCoder pointer

details:   http://hg.videolan.org/x265/rev/d6c423c66e4d
branches:  
changeset: 7296:d6c423c66e4d
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 17:33:14 2014 -0500
description:
cu, search: remove redundant m_rdGoOnSbacCoder pointer

m_rdGoOnSbacCoder was always either pointing to the same SBac as m_sbacCoder
(for calls to compressCU()) or it was supposed to be unused (for calls to
encodeCU)
Subject: [x265] ppa: cleanup event names and remove uninteresting events

details:   http://hg.videolan.org/x265/rev/0a0fe4d52711
branches:  
changeset: 7297:0a0fe4d52711
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 17:43:44 2014 -0500
description:
ppa: cleanup event names and remove uninteresting events
Subject: [x265] frameencoder: remove unnecessary include of TEncSearch.h

details:   http://hg.videolan.org/x265/rev/7649ffe940e1
branches:  
changeset: 7298:7649ffe940e1
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 17:44:04 2014 -0500
description:
frameencoder: remove unnecessary include of TEncSearch.h
Subject: [x265] cturow: rename m_rdGoOnSbacCoder to m_sbacCoder; there is only one

details:   http://hg.videolan.org/x265/rev/9e50b8b7503b
branches:  
changeset: 7299:9e50b8b7503b
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 17:48:12 2014 -0500
description:
cturow: rename m_rdGoOnSbacCoder to m_sbacCoder; there is only one
Subject: [x265] framefilter: rename row0 coder

details:   http://hg.videolan.org/x265/rev/e658be3fe5a3
branches:  
changeset: 7300:e658be3fe5a3
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 17:52:35 2014 -0500
description:
framefilter: rename row0 coder
Subject: [x265] entropy: clarify the SBac's bit counting mode

details:   http://hg.videolan.org/x265/rev/e3e077965c39
branches:  
changeset: 7301:e3e077965c39
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 19:29:46 2014 -0500
description:
entropy: clarify the SBac's bit counting mode

The SBac class has always had the ability to be a bit counter without any other
external data structures. With this change, the SBac defaults to being a bit
counting SBac until it is given a Bitstream object to write into.  The class
no longer accepts a BitCounter object, since it would only add more overhead
to the bit counting.

TEncCu no longer needs o be told whether it is writing into a bit counting
SBac or not, it can ask the SBac to find out.

The BitCounting class is only used for SEI writing, and may disappear in order
to remove the vtable from the critical path of entropy coding.

diffstat:

 source/Lib/TLibCommon/TComRom.cpp              |   13 -
 source/Lib/TLibCommon/TComRom.h                |   34 ----
 source/Lib/TLibEncoder/SyntaxElementWriter.cpp |  138 ------------------
 source/Lib/TLibEncoder/SyntaxElementWriter.h   |   94 ------------
 source/Lib/TLibEncoder/TEncCu.cpp              |   25 +--
 source/Lib/TLibEncoder/TEncCu.h                |    4 +-
 source/Lib/TLibEncoder/TEncSearch.cpp          |   72 ++++----
 source/Lib/TLibEncoder/TEncSearch.h            |    4 +-
 source/PPA/ppaCPUEvents.h                      |   42 ++---
 source/common/bitstream.cpp                    |   18 ++
 source/common/bitstream.h                      |   20 ++
 source/encoder/CMakeLists.txt                  |    2 -
 source/encoder/compress.cpp                    |    4 +-
 source/encoder/cturow.cpp                      |   14 +-
 source/encoder/cturow.h                        |   12 +-
 source/encoder/encoder.cpp                     |    9 -
 source/encoder/entropy.cpp                     |  187 +------------------------
 source/encoder/entropy.h                       |    6 +-
 source/encoder/frameencoder.cpp                |   22 +--
 source/encoder/frameencoder.h                  |    1 -
 source/encoder/framefilter.cpp                 |    8 +-
 source/encoder/framefilter.h                   |    5 +-
 source/encoder/sei.cpp                         |   34 +---
 source/encoder/sei.h                           |   19 +--
 source/output/y4m.cpp                          |    4 -
 source/output/yuv.cpp                          |    4 -
 26 files changed, 136 insertions(+), 659 deletions(-)

diffs (truncated from 1707 to 300 lines):

diff -r cbfe2ac89d41 -r e3e077965c39 source/Lib/TLibCommon/TComRom.cpp
--- a/source/Lib/TLibCommon/TComRom.cpp	Thu Jul 10 01:33:35 2014 -0500
+++ b/source/Lib/TLibCommon/TComRom.cpp	Thu Jul 10 19:29:46 2014 -0500
@@ -459,21 +459,8 @@ const uint8_t g_chromaScale[NUM_CHROMA_F
 const uint8_t g_chroma422IntraAngleMappingTable[36] =
 { 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31, DM_CHROMA_IDX };
 
-// ====================================================================================================================
-// Misc.
-// ====================================================================================================================
-
 uint8_t g_convertToBit[MAX_CU_SIZE + 1];
 
-#if ENC_DEC_TRACE
-FILE*  g_hTrace = NULL;
-const bool g_bEncDecTraceEnable  = true;
-const bool g_bEncDecTraceDisable = false;
-bool   g_HLSTraceEnable = true;
-bool   g_bJustDoIt = false;
-uint64_t g_nSymbolCounter = 0;
-#endif
-
 // ====================================================================================================================
 // Scanning order & context model mapping
 // ====================================================================================================================
diff -r cbfe2ac89d41 -r e3e077965c39 source/Lib/TLibCommon/TComRom.h
--- a/source/Lib/TLibCommon/TComRom.h	Thu Jul 10 01:33:35 2014 -0500
+++ b/source/Lib/TLibCommon/TComRom.h	Thu Jul 10 19:29:46 2014 -0500
@@ -157,40 +157,6 @@ extern const uint8_t g_goRiceRange[5];  
 
 extern uint8_t g_convertToBit[MAX_CU_SIZE + 1]; // from width to log2(width)-2
 
-#ifndef ENC_DEC_TRACE
-# define ENC_DEC_TRACE 0
-#endif
-
-#if ENC_DEC_TRACE
-extern FILE*  g_hTrace;
-extern bool   g_bJustDoIt;
-extern const bool g_bEncDecTraceEnable;
-extern const bool g_bEncDecTraceDisable;
-extern bool   g_HLSTraceEnable;
-extern uint64_t g_nSymbolCounter;
-
-#define COUNTER_START    1
-#define COUNTER_END      0 //( uint64_t(1) << 63 )
-
-#define DTRACE_CABAC_F(x)     if ((g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END) || g_bJustDoIt) fprintf(g_hTrace, "%f", x);
-#define DTRACE_CABAC_V(x)     if ((g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END) || g_bJustDoIt) fprintf(g_hTrace, "%d", x);
-#define DTRACE_CABAC_VL(x)    if ((g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END) || g_bJustDoIt) fprintf(g_hTrace, "%ld", x);
-#define DTRACE_CABAC_T(x)     if ((g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END) || g_bJustDoIt) fprintf(g_hTrace, "%s", x);
-#define DTRACE_CABAC_X(x)     if ((g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END) || g_bJustDoIt) fprintf(g_hTrace, "%x", x);
-#define DTRACE_CABAC_R(x, y)  if ((g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END) || g_bJustDoIt) fprintf(g_hTrace, x,    y);
-#define DTRACE_CABAC_N        if ((g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END) || g_bJustDoIt) fprintf(g_hTrace, "\n");
-#else // if ENC_DEC_TRACE
-
-#define DTRACE_CABAC_F(x)
-#define DTRACE_CABAC_V(x)
-#define DTRACE_CABAC_VL(x)
-#define DTRACE_CABAC_T(x)
-#define DTRACE_CABAC_X(x)
-#define DTRACE_CABAC_R(x, y)
-#define DTRACE_CABAC_N
-
-#endif // if ENC_DEC_TRACE
-
 #define SCALING_LIST_NUM 6         ///< list number for quantization matrix
 #define SCALING_LIST_NUM_32x32 2   ///< list number for quantization matrix 32x32
 #define SCALING_LIST_REM_NUM 6     ///< remainder of QP/6
diff -r cbfe2ac89d41 -r e3e077965c39 source/Lib/TLibEncoder/SyntaxElementWriter.cpp
--- a/source/Lib/TLibEncoder/SyntaxElementWriter.cpp	Thu Jul 10 01:33:35 2014 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/* The copyright in this software is being made available under the BSD
- * License, included below. This software may be subject to other third party
- * and contributor rights, including patent rights, and no such rights are
- * granted under this license.
- *
- * Copyright (c) 2010-2013, ITU/ISO/IEC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
- *    be used to endorse or promote products derived from this software without
- *    specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** \file     SyntaxElementWriter.cpp
-    \brief    CAVLC encoder class
-*/
-
-#include "common.h"
-#include "SyntaxElementWriter.h"
-
-using namespace x265;
-
-//! \ingroup TLibEncoder
-//! \{
-
-#if ENC_DEC_TRACE
-
-void  SyntaxElementWriter::xWriteCodeTr(uint32_t value, uint32_t  length, const char *symbolName)
-{
-    xWriteCode(value, length);
-    if (g_HLSTraceEnable)
-    {
-        fprintf(g_hTrace, "%8ld  ", g_nSymbolCounter++);
-        if (length < 10)
-        {
-            fprintf(g_hTrace, "%-50s u(%d)  : %d\n", symbolName, length, value);
-        }
-        else
-        {
-            fprintf(g_hTrace, "%-50s u(%d) : %d\n", symbolName, length, value);
-        }
-    }
-}
-
-void  SyntaxElementWriter::xWriteUvlcTr(uint32_t value, const char *symbolName)
-{
-    xWriteUvlc(value);
-    if (g_HLSTraceEnable)
-    {
-        fprintf(g_hTrace, "%8ld  ", g_nSymbolCounter++);
-        fprintf(g_hTrace, "%-50s ue(v) : %d\n", symbolName, value);
-    }
-}
-
-void  SyntaxElementWriter::xWriteSvlcTr(int value, const char *symbolName)
-{
-    xWriteSvlc(value);
-    if (g_HLSTraceEnable)
-    {
-        fprintf(g_hTrace, "%8ld  ", g_nSymbolCounter++);
-        fprintf(g_hTrace, "%-50s se(v) : %d\n", symbolName, value);
-    }
-}
-
-void  SyntaxElementWriter::xWriteFlagTr(uint32_t value, const char *symbolName)
-{
-    xWriteFlag(value);
-    if (g_HLSTraceEnable)
-    {
-        fprintf(g_hTrace, "%8ld  ", g_nSymbolCounter++);
-        fprintf(g_hTrace, "%-50s u(1)  : %d\n", symbolName, value);
-    }
-}
-
-#endif // if ENC_DEC_TRACE
-
-void SyntaxElementWriter::xWriteCode(uint32_t code, uint32_t len)
-{
-    X265_CHECK(len, "wrote zero length code\n");
-    m_bitIf->write(code, len);
-}
-
-void SyntaxElementWriter::xWriteUvlc(uint32_t code)
-{
-    uint32_t len = 1;
-    uint32_t temp = ++code;
-
-    X265_CHECK(temp, "writing -1 code\n");
-
-    while (1 != temp)
-    {
-        temp >>= 1;
-        len += 2;
-    }
-
-    // Take care of cases where len > 32
-    m_bitIf->write(0, len >> 1);
-    m_bitIf->write(code, (len + 1) >> 1);
-}
-
-inline uint32_t toUInt(int val)
-{
-    return (val <= 0) ? -val << 1 : (val << 1) - 1;
-}
-
-void SyntaxElementWriter::xWriteSvlc(int code)
-{
-    uint32_t ucode = toUInt(code);
-
-    xWriteUvlc(ucode);
-}
-
-void SyntaxElementWriter::xWriteFlag(uint32_t code)
-{
-    m_bitIf->write(code, 1);
-}
-
-//! \}
diff -r cbfe2ac89d41 -r e3e077965c39 source/Lib/TLibEncoder/SyntaxElementWriter.h
--- a/source/Lib/TLibEncoder/SyntaxElementWriter.h	Thu Jul 10 01:33:35 2014 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/* The copyright in this software is being made available under the BSD
- * License, included below. This software may be subject to other third party
- * and contributor rights, including patent rights, and no such rights are
- * granted under this license.
- *
- * Copyright (c) 2010-2013, ITU/ISO/IEC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
- *    be used to endorse or promote products derived from this software without
- *    specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** \file     SyntaxElementWriter.h
-    \brief    CAVLC encoder class (header)
-*/
-
-#ifndef X265_SYNTAXELEMENTWRITER_H
-#define X265_SYNTAXELEMENTWRITER_H
-
-#include "common.h"
-#include "bitstream.h"
-#include "TLibCommon/TComRom.h"
-
-//! \ingroup TLibEncoder
-//! \{
-
-#if ENC_DEC_TRACE
-
-#define WRITE_CODE(value, length, name)    xWriteCodeTr(value, length, name)
-#define WRITE_UVLC(value,         name)    xWriteUvlcTr(value,         name)
-#define WRITE_SVLC(value,         name)    xWriteSvlcTr(value,         name)
-#define WRITE_FLAG(value,         name)    xWriteFlagTr(value,         name)
-
-#else
-
-#define WRITE_CODE(value, length, name)     xWriteCode(value, length)
-#define WRITE_UVLC(value,         name)     xWriteUvlc(value)
-#define WRITE_SVLC(value,         name)     xWriteSvlc(value)
-#define WRITE_FLAG(value,         name)     xWriteFlag(value)
-
-#endif // if ENC_DEC_TRACE
-
-namespace x265 {
-// private namespace
-
-class SyntaxElementWriter
-{
-protected:
-
-    BitInterface* m_bitIf;
-
-    SyntaxElementWriter()
-        : m_bitIf(NULL)
-    {}
-
-    void  setBitstream(BitInterface* p)  { m_bitIf = p; }
-
-    void  xWriteCode(uint32_t code, uint32_t len);
-    void  xWriteUvlc(uint32_t code);
-    void  xWriteSvlc(int code);
-    void  xWriteFlag(uint32_t code);
-
-#if ENC_DEC_TRACE
-    void  xWriteCodeTr(uint32_t value, uint32_t  length, const char *symbolName);


More information about the x265-commits mailing list