Re: [x265] A compiler warning and a question

2014-07-10 Thread Mario *LigH* Rohkrämer

Am 09.07.2014, 20:28 Uhr, schrieb Steve Borho st...@borho.org:

On Wed, Jul 9, 2014 at 3:04 AM, Mario *LigH* Rohkrämer cont...@ligh.de  
wrote:


I made a trivial shell script to compile each both architectures (32 +  
64
bit) and precisions (8 + 16 bpc) in a sequence. I noticed that the  
compiling

order can be different for different runs. Sometimes target common is
handled first, sometimes encoder. Probably nothing to worry about,  
just

curious why it can be random.


If all of the Makefiles were generated by the same version of cmake,
I'm stumped by that.

It is harmless and inexplicable at the same time.  It might be
interesting to diff the Makefiles in the various folders and see if
anything interesting sticks out.  We're certainly not doing anything
deliberate to change the build order for the various configurations.

--
Steve
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel



Thanks. As long as the result works, this is a least concern.

--

Fun and success!
Mario *LigH* Rohkrämer
mailto:cont...@ligh.de

___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH RFC] enable scalingList feature

2014-07-10 Thread sumalatha
# HG changeset patch
# User Sumalatha Polureddysumala...@multicorewareinc.com
# Date 1404995390 -19800
# Node ID 5c1e6ffb351792d0664ddb3935151f5859866d99
# Parent  30e20a7b6fddd26864ddf4dc5f4e62fa5005f86b
enable scalingList feature

diff -r 30e20a7b6fdd -r 5c1e6ffb3517 source/Lib/TLibCommon/TComSlice.cpp
--- a/source/Lib/TLibCommon/TComSlice.cpp   Wed Jul 09 20:33:52 2014 -0500
+++ b/source/Lib/TLibCommon/TComSlice.cpp   Thu Jul 10 17:59:50 2014 +0530
@@ -715,18 +715,6 @@
 destroy();
 }
 
-/** set default quantization matrix to array
-*/
-void TComSlice::setDefaultScalingList()
-{
-for (uint32_t sizeId = 0; sizeId  SCALING_LIST_SIZE_NUM; sizeId++)
-{
-for (uint32_t listId = 0; listId  g_scalingListNum[sizeId]; listId++)
-{
-getScalingList()-processDefaultMarix(sizeId, listId);
-}
-}
-}
 
 /** check if use default quantization matrix
  * \returns true if use default quantization matrix in all size
diff -r 30e20a7b6fdd -r 5c1e6ffb3517 source/Lib/TLibCommon/TComSlice.h
--- a/source/Lib/TLibCommon/TComSlice.h Wed Jul 09 20:33:52 2014 -0500
+++ b/source/Lib/TLibCommon/TComSlice.h Thu Jul 10 17:59:50 2014 +0530
@@ -1484,7 +1484,6 @@
 
 TComScalingList*   getScalingList(){ return m_scalingList; }
 
-void  setDefaultScalingList();
 bool  checkDefaultScalingList();
 void  setCabacInitFlag(bool val)   { m_cabacInitFlag = val; }   //! 
set CABAC initial flag
 
diff -r 30e20a7b6fdd -r 5c1e6ffb3517 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cppWed Jul 09 20:33:52 2014 -0500
+++ b/source/encoder/encoder.cppThu Jul 10 17:59:50 2014 +0530
@@ -106,6 +106,7 @@
 }
 }
 
+setDefaultScalingList();
 /* Allocate thread local data shared by all frame encoders */
 ThreadPool *pool = ThreadPool::getThreadPool();
 const int poolThreadCount = pool ? pool-getThreadCount() : 1;
@@ -247,6 +248,19 @@
 }
 }
 
+/** set default quantization matrix to array
+*/
+void Encoder::setDefaultScalingList()
+{
+for (uint32_t sizeId = 0; sizeId  SCALING_LIST_SIZE_NUM; sizeId++)
+{
+for (uint32_t listId = 0; listId  g_scalingListNum[sizeId]; listId++)
+{
+getScalingList()-processDefaultMarix(sizeId, listId);
+}
+}
+}
+
 /**
  \param   pic_in  input original YUV picture or NULL
  \param   pic_out pointer to reconstructed picture struct
@@ -1452,7 +1466,7 @@
 
 m_nonPackedConstraintFlag = false;
 m_frameOnlyConstraintFlag = false;
-m_useScalingListId = 0;
+m_useScalingListId = 1;
 m_minSpatialSegmentationIdc = 0;
 m_neutralChromaIndicationFlag = false;
 m_pocProportionalToTimingFlag = false;
diff -r 30e20a7b6fdd -r 5c1e6ffb3517 source/encoder/encoder.h
--- a/source/encoder/encoder.h  Wed Jul 09 20:33:52 2014 -0500
+++ b/source/encoder/encoder.h  Thu Jul 10 17:59:50 2014 +0530
@@ -204,6 +204,7 @@
 char* statsCSVString(EncStats stat, char* buffer);
 
 TComScalingList* getScalingList() { return m_scalingList; }
+void  setDefaultScalingList();
 
 void setThreadPool(ThreadPool* p) { m_threadPool = p; }
 
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [ANN] x265 1.2 released

2014-07-10 Thread Steve Borho
Hello,

x265 release 1.2 was tagged today. This was a regularly scheduled
release with improvements in performance, major improvements in memory
usage, and improved psy-rd behavior.

There were a few of new options introduced:

--cu-stats, x265_param.bLogCuStats - enabling logging of CU stats

--hrd, x265.bEmitHRDSEI - enable HRD SEI signaling

--ipratio/--pbratio were exposed to the CLI

--lambda-file - allows experimentation with lambda tables

Plus a number of options added for multi-pass encoding (incomplete). I
will document those in the next release after the feature is complete.

Full documentation for the features supported in the release can be
found at http://x265.readthedocs.org/en/1.2/.

-- 
Steve Borho
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH] rc: init second pass in multi pass encode

2014-07-10 Thread aarthi
# HG changeset patch
# User Aarthi Thirumalaiaar...@multicorewareinc.com
# Date 1404933617 -19800
#  Thu Jul 10 00:50:17 2014 +0530
# Node ID 418b68734fd83bf32dbdd4a097e51ce455267c3d
# Parent  cbfe2ac89d418f7cf9cc53ad31b7eb2c06fbcb85
rc: init second pass in multi pass encode

read stat file from previous pass and compute the blurred
complexity of each frame

diff -r cbfe2ac89d41 -r 418b68734fd8 source/common/common.cpp
--- a/source/common/common.cpp  Thu Jul 10 01:33:35 2014 -0500
+++ b/source/common/common.cpp  Thu Jul 10 00:50:17 2014 +0530
@@ -159,3 +159,51 @@
 
 return size;
 }
+
+char* x265_slurp_file(const char *filename)
+{
+if (!filename)
+return NULL;
+
+int bError = 0;
+size_t fSize;
+char *buf = NULL;
+
+FILE *fh = fopen(filename, rb);
+if (!fh)
+{
+x265_log(NULL, X265_LOG_ERROR, unable to open file %s \n, filename);
+return NULL;
+}
+
+bError |= fseek(fh, 0, SEEK_END)  0;
+bError |= (fSize = ftell(fh)) = 0;
+bError |= fseek(fh, 0, SEEK_SET)  0;
+if (bError)
+goto error;
+
+buf = X265_MALLOC(char, fSize + 2);
+if (!buf)
+{
+x265_log(NULL, X265_LOG_ERROR, unable to allocate memory \n);
+goto error;
+}
+
+bError |= fread(buf, 1, fSize, fh) != fSize;
+if (buf[fSize - 1] != '\n')
+buf[fSize++] = '\n';
+buf[fSize] = 0;
+fclose(fh);
+
+if (bError)
+{
+x265_log(NULL, X265_LOG_ERROR, unable to read the file\n);
+free(buf);
+buf = NULL;
+}
+return buf;
+
+error:
+fclose(fh);
+return NULL;
+}
diff -r cbfe2ac89d41 -r 418b68734fd8 source/common/common.h
--- a/source/common/common.hThu Jul 10 01:33:35 2014 -0500
+++ b/source/common/common.hThu Jul 10 00:50:17 2014 +0530
@@ -204,5 +204,5 @@
 double x265_qp2qScale(double qp);
 
 uint32_t x265_picturePlaneSize(int csp, int width, int height, int plane);
-
+char* x265_slurp_file(const char *filename);
 #endif // ifndef X265_COMMON_H
diff -r cbfe2ac89d41 -r 418b68734fd8 source/common/param.cpp
--- a/source/common/param.cpp   Thu Jul 10 01:33:35 2014 -0500
+++ b/source/common/param.cpp   Thu Jul 10 00:50:17 2014 +0530
@@ -1212,9 +1212,10 @@
 
 #define BOOL(param, cliopt) \
 s += sprintf(s,  %s, (param) ? cliopt : no-cliopt);
-
+s += sprintf(s, %dx%d, p-sourceWidth,p-sourceHeight);
+s += sprintf(s,  fps=%u/%u, p-fpsNum, p-fpsDenom);
+s += sprintf(s,  bitdepth=%d,p-internalBitDepth);
 BOOL(p-bEnableWavefront, wpp);
-s += sprintf(s,  fps=%d/%d, p-fpsNum, p-fpsDenom);
 s += sprintf(s,  ctu=%d, p-maxCUSize);
 s += sprintf(s,  tu-intra-depth=%d, p-tuQTMaxIntraDepth);
 s += sprintf(s,  tu-inter-depth=%d, p-tuQTMaxInterDepth);
@@ -1286,7 +1287,7 @@
 {
 s += sprintf(s,  ip_ratio=%.2f, p-rc.ipFactor);
 if (p-bframes)
-s += sprintf(s,  pb_ratio=%.2f, p-rc.pbFactor);
+s += sprintf(s,  pb_ratio=%.2f , p-rc.pbFactor);
 }
 #undef BOOL
 return buf;
diff -r cbfe2ac89d41 -r 418b68734fd8 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cppThu Jul 10 01:33:35 2014 -0500
+++ b/source/encoder/encoder.cppThu Jul 10 00:50:17 2014 +0530
@@ -1346,7 +1346,7 @@
 p-rc.aqStrength = 0.0;
 }
 
-if (p-lookaheadDepth == 0  p-rc.cuTree)
+if (p-lookaheadDepth == 0  p-rc.cuTree  !p-rc.bStatRead)
 {
 x265_log(p, X265_LOG_WARNING, cuTree disabled, requires lookahead to 
be enabled\n);
 p-rc.cuTree = 0;
diff -r cbfe2ac89d41 -r 418b68734fd8 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp   Thu Jul 10 01:33:35 2014 -0500
+++ b/source/encoder/frameencoder.cpp   Thu Jul 10 00:50:17 2014 +0530
@@ -490,6 +490,7 @@
 compressCTURows();
 
 if (m_param-rc.bStatWrite)
+{
 // accumulate intra,inter,skip cu count per frame for 2 pass
 for (int i = 0; i  m_numRows; i++)
 {
@@ -497,7 +498,11 @@
 m_frameStats.cuCount_p += m_rows[i].m_pCuCnt;
 m_frameStats.cuCount_skip += m_rows[i].m_skipCuCnt;
 }
-
+double totalCuCount = m_frameStats.cuCount_i + m_frameStats.cuCount_p 
+ m_frameStats.cuCount_skip;
+m_frameStats.cuCount_i /= totalCuCount;
+m_frameStats.cuCount_p /= totalCuCount;
+m_frameStats.cuCount_skip /= totalCuCount;
+}
 if (m_sps.getUseSAO())
 {
 SAOParam* saoParam = m_frame-getPicSym()-getSaoParam();
diff -r cbfe2ac89d41 -r 418b68734fd8 source/encoder/frameencoder.h
--- a/source/encoder/frameencoder.h Thu Jul 10 01:33:35 2014 -0500
+++ b/source/encoder/frameencoder.h Thu Jul 10 00:50:17 2014 +0530
@@ -61,7 +61,7 @@
 /* Texture bits (DCT coefs) */
 int coeffBits;
 int miscBits;
-/* CU type counts */
+/* CU type counts stored as percentage*/
 double  cuCount_i;
 double  cuCount_p;
 double  cuCount_skip;
diff -r cbfe2ac89d41 -r 418b68734fd8 

[x265] [PATCH] rc: add 2 pass logic in rateEstimateQscale

2014-07-10 Thread aarthi
# HG changeset patch
# User Aarthi Thirumalaiaar...@multicorewareinc.com
# Date 1405013200 -19800
#  Thu Jul 10 22:56:40 2014 +0530
# Node ID 13bf49f57f958db1c58177007a4d4eb500129095
# Parent  418b68734fd83bf32dbdd4a097e51ce455267c3d
rc: add 2 pass logic in rateEstimateQscale

adjust qscale of each frame based on distance to end of the video and
the difference between achieved and expected bits so far in the final pass.

diff -r 418b68734fd8 -r 13bf49f57f95 source/Lib/TLibCommon/TypeDef.h
--- a/source/Lib/TLibCommon/TypeDef.h   Thu Jul 10 00:50:17 2014 +0530
+++ b/source/Lib/TLibCommon/TypeDef.h   Thu Jul 10 22:56:40 2014 +0530
@@ -61,6 +61,8 @@
 I_SLICE
 };
 
+static const char sliceTypeToChar[] = { 'B', 'P', 'I' };
+
 /// chroma formats (according to semantics of chroma_format_idc)
 enum ChromaFormat
 {
diff -r 418b68734fd8 -r 13bf49f57f95 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cppThu Jul 10 00:50:17 2014 +0530
+++ b/source/encoder/encoder.cppThu Jul 10 22:56:40 2014 +0530
@@ -242,6 +242,8 @@
 rc-m_bufferFill = X265_MAX(rc-m_bufferFill, 0);
 rc-m_bufferFill += encoder-m_rce.bufferRate;
 rc-m_bufferFill = X265_MIN(rc-m_bufferFill, rc-m_bufferSize);
+if (rc-m_2pass)
+rc-m_predictedBits += 
(int64_t)encoder-m_rce.frameSizeEstimated;
 }
 encIdx = (encIdx + 1) % m_param-frameNumThreads;
 }
diff -r 418b68734fd8 -r 13bf49f57f95 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cppThu Jul 10 00:50:17 2014 +0530
+++ b/source/encoder/ratecontrol.cppThu Jul 10 22:56:40 2014 +0530
@@ -124,6 +124,24 @@
+ rce-miscBits;
 }
 
+inline void copyRceData(RateControlEntry* rce, RateControlEntry* rce2Pass)
+{
+rce-coeffBits = rce2Pass-coeffBits;
+rce-mvBits = rce2Pass-mvBits;
+rce-miscBits = rce2Pass-miscBits;
+rce-iCuCount = rce2Pass-iCuCount;
+rce-pCuCount = rce2Pass-pCuCount;
+rce-skipCuCount = rce2Pass-skipCuCount;
+rce-keptAsRef = rce2Pass-keptAsRef;
+rce-qScale = rce2Pass-qScale;
+rce-newQScale = rce2Pass-newQScale;
+rce-expectedBits = rce2Pass-expectedBits;
+rce-expectedVbv = rce2Pass-expectedVbv;
+rce-blurredComplexity = rce2Pass-blurredComplexity;
+rce-sliceType = rce2Pass-sliceType;
+}
+
+
 }  // end anonymous namespace
 /* Compute variance to derive AC energy of each block */
 static inline uint32_t acEnergyVar(Frame *pic, uint64_t sum_ssd, int shift, 
int i)
@@ -993,6 +1011,11 @@
 m_curSlice = pic-getSlice();
 m_sliceType = m_curSlice-getSliceType();
 rce-sliceType = m_sliceType;
+if (m_param-rc.bStatRead)
+{
+assert(rce-encodeOrder = 0  rce-encodeOrder  m_numEntries);
+copyRceData(rce, m_rce2Pass[rce-encodeOrder]);
+}
 rce-isActive = true;
 if (m_sliceType == B_SLICE)
 rce-bframes = m_bframes;
@@ -1019,6 +1042,7 @@
 }
 rce-rowPred[0] = rce-rowPreds[m_sliceType][0];
 rce-rowPred[1] = rce-rowPreds[m_sliceType][1];
+m_predictedBits = m_totalBits;
 updateVbvPlan(enc);
 rce-bufferFill = m_bufferFill;
 }
@@ -1056,6 +1080,7 @@
 rce-qpaRc = pic-m_avgQpRc = pic-m_avgQpAq = m_qp;
 }
 m_framesDone++;
+rce-newQp = m_qp;
 /* set the final QP to slice structure */
 m_curSlice-setSliceQp(m_qp);
 }
@@ -1196,7 +1221,14 @@
 double RateControl::rateEstimateQscale(Frame* pic, RateControlEntry *rce)
 {
 double q;
-
+if (m_2pass)
+{
+if (m_sliceType != rce-sliceType)
+{
+x265_log(m_param, X265_LOG_ERROR, slice=%c but 2pass stats say 
%c\n,
+  sliceTypeToChar[m_sliceType], 
sliceTypeToChar[rce-sliceType]);
+}
+}
 if (m_sliceType == B_SLICE)
 {
 /* B-frames don't have independent rate control, but rather get the
@@ -1241,112 +1273,174 @@
 double qScale = x265_qp2qScale(q);
 rce-frameSizePlanned = predictSize(m_predBfromP, qScale, 
(double)m_leadingNoBSatd);
 rce-frameSizeEstimated = rce-frameSizePlanned;
+rce-newQScale = qScale;
 return qScale;
 }
 else
 {
 double abrBuffer = 2 * m_param-rc.rateTolerance * m_bitrate;
+if (m_2pass)
+{
+int64_t diff;
+if (!m_isVbv)
+{
+m_predictedBits = m_totalBits;
+if (rce-encodeOrder  m_param-frameNumThreads)
+m_predictedBits += (int64_t)(rce-encodeOrder * m_bitrate 
/ m_fps) ;
+else
+m_predictedBits += (int64_t)(m_param-frameNumThreads * 
m_bitrate / m_fps);
+}
 
+/* Adjust ABR buffer based on distance to the end of the video. */
+if (m_numEntries  rce-encodeOrder)
+{
+uint64_t finalBits = m_rce2Pass[m_numEntries - 1].expectedBits;
+double videoPos = (double)rce-expectedBits / finalBits;
+   

[x265] [PATCH 3 of 3] bitstream: hoist trivial methods to the header so they may be easier inlined

2014-07-10 Thread Steve Borho
# HG changeset patch
# User Steve Borho st...@borho.org
# Date 1405019610 18000
#  Thu Jul 10 14:13:30 2014 -0500
# Node ID 57a4c1c2274ec6b40f4a138523c6b67ffa853e09
# Parent  b96714bdda859e6be60c9e2056e3d5296e20d2dc
bitstream: hoist trivial methods to the header so they may be easier inlined

diff -r b96714bdda85 -r 57a4c1c2274e source/common/bitstream.cpp
--- a/source/common/bitstream.cpp   Thu Jul 10 14:07:03 2014 -0500
+++ b/source/common/bitstream.cpp   Thu Jul 10 14:13:30 2014 -0500
@@ -106,12 +106,6 @@
 writeAlignZero();
 }
 
-void SyntaxElementWriter::writeCode(uint32_t code, uint32_t length)
-{
-X265_CHECK(length, wrote zero length code\n);
-m_bitIf-write(code, length);
-}
-
 void SyntaxElementWriter::writeUvlc(uint32_t code)
 {
 uint32_t length = 1;
@@ -129,15 +123,3 @@
 m_bitIf-write(0, length  1);
 m_bitIf-write(code, (length + 1)  1);
 }
-
-void SyntaxElementWriter::writeSvlc(int32_t code)
-{
-uint32_t ucode = (code = 0) ? -code  1 : (code  1) - 1;
-
-writeUvlc(ucode);
-}
-
-void SyntaxElementWriter::writeFlag(uint32_t code)
-{
-m_bitIf-write(code, 1);
-}
diff -r b96714bdda85 -r 57a4c1c2274e source/common/bitstream.h
--- a/source/common/bitstream.h Thu Jul 10 14:07:03 2014 -0500
+++ b/source/common/bitstream.h Thu Jul 10 14:13:30 2014 -0500
@@ -147,10 +147,10 @@
 inline void WRITE_SVLC(int32_t  code,  const char *) { 
writeSvlc(code); }
 inline void WRITE_FLAG(uint32_t code,  const char *) { 
writeFlag(code); }
 
-void writeCode(uint32_t code, uint32_t length);
+void writeCode(uint32_t code, uint32_t length) { m_bitIf-write(code, 
length); }
 void writeUvlc(uint32_t code);
-void writeSvlc(int32_t code);
-void writeFlag(uint32_t code);
+void writeSvlc(int32_t code)   { uint32_t ucode = (code = 
0) ? -code  1 : (code  1) - 1; writeUvlc(ucode); }
+void writeFlag(uint32_t code)  { m_bitIf-write(code, 1); }
 };
 
 }
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH 2 of 3] bitstream: convert macros into inline members for better compile-time checking

2014-07-10 Thread Steve Borho
# HG changeset patch
# User Steve Borho st...@borho.org
# Date 1405019223 18000
#  Thu Jul 10 14:07:03 2014 -0500
# Node ID b96714bdda859e6be60c9e2056e3d5296e20d2dc
# Parent  64dc40d52519b0bcb19c04cf14d510243ff846fb
bitstream: convert macros into inline members for better compile-time checking

diff -r 64dc40d52519 -r b96714bdda85 source/common/bitstream.h
--- a/source/common/bitstream.h Thu Jul 10 13:59:19 2014 -0500
+++ b/source/common/bitstream.h Thu Jul 10 14:07:03 2014 -0500
@@ -133,11 +133,6 @@
 return bitSize[tmp  8] + 16;
 }
 
-#define WRITE_CODE(code, length, name) writeCode(code, length)
-#define WRITE_UVLC(code, name) writeUvlc(code)
-#define WRITE_SVLC(code, name) writeSvlc(code)
-#define WRITE_FLAG(code, name) writeFlag(code)
-
 class SyntaxElementWriter
 {
 public:
@@ -146,6 +141,12 @@
 
 SyntaxElementWriter() : m_bitIf(NULL) {}
 
+/* silently discard the name of the syntax element */
+inline void WRITE_CODE(uint32_t code, uint32_t length, const char *) { 
writeCode(code, length); }
+inline void WRITE_UVLC(uint32_t code,  const char *) { 
writeUvlc(code); }
+inline void WRITE_SVLC(int32_t  code,  const char *) { 
writeSvlc(code); }
+inline void WRITE_FLAG(uint32_t code,  const char *) { 
writeFlag(code); }
+
 void writeCode(uint32_t code, uint32_t length);
 void writeUvlc(uint32_t code);
 void writeSvlc(int32_t code);
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH 1 of 3] bring SyntaxElementWriter into common/, remove trace file macros

2014-07-10 Thread Steve Borho
# HG changeset patch
# User Steve Borho st...@borho.org
# Date 1405018759 18000
#  Thu Jul 10 13:59:19 2014 -0500
# Node ID 64dc40d52519b0bcb19c04cf14d510243ff846fb
# Parent  cbfe2ac89d418f7cf9cc53ad31b7eb2c06fbcb85
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.

diff -r cbfe2ac89d41 -r 64dc40d52519 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 13:59:19 2014 -0500
@@ -459,21 +459,8 @@
 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 64dc40d52519 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 13:59:19 2014 -0500
@@ -157,40 +157,6 @@
 
 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_START1
-#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_Nif ((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 64dc40d52519 
source/Lib/TLibEncoder/SyntaxElementWriter.cpp
--- a/source/Lib/TLibEncoder/SyntaxElementWriter.cppThu Jul 10 01:33:35 
2014 -0500
+++ /dev/null   Thu Jan 01 00:00:00 1970 +
@@ -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 

[x265] [PATCH 4 of 4] entropy: clarify the SBac's bit counting mode

2014-07-10 Thread Steve Borho
# HG changeset patch
# User Steve Borho st...@borho.org
# Date 1405038586 18000
#  Thu Jul 10 19:29:46 2014 -0500
# Node ID e3e077965c39a56a24e09189652e1de3c5a0e3ea
# Parent  e658be3fe5a3cdcdb1b3ac21c6b795b5d01c69a0
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.

diff -r e658be3fe5a3 -r e3e077965c39 source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp Thu Jul 10 17:52:35 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.cpp Thu Jul 10 19:29:46 2014 -0500
@@ -75,7 +75,6 @@
 m_rdCost  = NULL;
 m_sbacCoder   = NULL;
 m_rdSbacCoders= NULL;
-m_bBitCounting= false;
 }
 
 /**
@@ -422,13 +421,12 @@
 
 /** \param  cu  pointer of CU data class
  */
-void TEncCu::encodeCU(TComDataCU* cu, bool bIsCounting)
+void TEncCu::encodeCU(TComDataCU* cu)
 {
 if (cu-getSlice()-getPPS()-getUseDQP())
 m_bEncodeDQP = true;
 
 // Encode CU data
-m_bBitCounting = bIsCounting;
 xEncodeCU(cu, 0, 0, false);
 }
 
@@ -1072,19 +1070,15 @@
 }
 
 int numberOfWrittenBits = 0;
-if (m_bBitCounting)
-{
+if (m_sbacCoder-isBitCounter())
 numberOfWrittenBits = m_sbacCoder-getNumberOfWrittenBits();
-}
 
 if (granularityBoundary)
 {
 slice-setSliceBits((uint32_t)(slice-getSliceBits() + 
numberOfWrittenBits));
 slice-setSliceSegmentBits(slice-getSliceSegmentBits() + 
numberOfWrittenBits);
-if (m_bBitCounting)
-{
+if (m_sbacCoder-isBitCounter())
 m_sbacCoder-resetBits();
-}
 }
 }
 
diff -r e658be3fe5a3 -r e3e077965c39 source/Lib/TLibEncoder/TEncCu.h
--- a/source/Lib/TLibEncoder/TEncCu.h   Thu Jul 10 17:52:35 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.h   Thu Jul 10 19:29:46 2014 -0500
@@ -120,7 +120,6 @@
 TComTrQuant* m_trQuant;
 RDCost*  m_rdCost;
 SBac*m_sbacCoder;
-bool m_bBitCounting;
 
 // RD SBac pointers
 SBac   (*m_rdSbacCoders)[CI_NUM];
@@ -139,7 +138,7 @@
 bool create(uint8_t totalDepth, uint32_t maxWidth);
 void destroy();
 void compressCU(TComDataCU* cu);
-void encodeCU(TComDataCU* cu, bool bIsCounting);
+void encodeCU(TComDataCU* cu);
 
 protected:
 
diff -r e658be3fe5a3 -r e3e077965c39 source/encoder/cturow.cpp
--- a/source/encoder/cturow.cpp Thu Jul 10 17:52:35 2014 -0500
+++ b/source/encoder/cturow.cpp Thu Jul 10 19:29:46 2014 -0500
@@ -72,17 +72,13 @@
 tld.m_cuCoder.m_sbacCoder = m_sbacCoder;
 tld.m_cuCoder.m_rdSbacCoders = m_rdSbacCoders;
 
-BitCounter bc;
-m_sbacCoder.setBitstream(bc);
-
 tld.m_cuCoder.compressCU(cu); // Does all the CU analysis
 
 tld.m_search.m_sbacCoder = m_rdSbacCoders[0][CI_CURR_BEST];
 tld.m_cuCoder.m_sbacCoder = m_rdSbacCoders[0][CI_CURR_BEST];
-m_rdSbacCoders[0][CI_CURR_BEST].setBitstream(bc);
-bc.resetBits();
+m_rdSbacCoders[0][CI_CURR_BEST].resetBits();
 
-tld.m_cuCoder.encodeCU(cu, true);  // Count bits
+tld.m_cuCoder.encodeCU(cu);
 
 if (bSaveSBac)
 // Save CABAC state for next row
diff -r e658be3fe5a3 -r e3e077965c39 source/encoder/cturow.h
--- a/source/encoder/cturow.h   Thu Jul 10 17:52:35 2014 -0500
+++ b/source/encoder/cturow.h   Thu Jul 10 19:29:46 2014 -0500
@@ -72,14 +72,6 @@
 double  m_pCuCnt;
 double  m_skipCuCnt;
 
-CTURow()
-{
-m_sbacCoder.m_bIsCounter = true;
-for (uint32_t depth = 0; depth  g_maxCUDepth + 1; depth++)
-for (int ciIdx = 0; ciIdx  CI_NUM; ciIdx++)
-m_rdSbacCoders[depth][ciIdx].m_bIsCounter = true;
-}
-
 void init(TComSlice *slice)
 {
 m_active = 0;
diff -r e658be3fe5a3 -r e3e077965c39 source/encoder/entropy.cpp
--- a/source/encoder/entropy.cppThu Jul 10 17:52:35 2014 -0500
+++ b/source/encoder/entropy.cppThu Jul 10 19:29:46 2014 -0500
@@ -63,7 +63,6 @@
 
 SBac::SBac()
 : m_fracBits(0)
-, m_bIsCounter(false)
 {
 memset(m_contextModels, 0, sizeof(m_contextModels));
 }
@@ -2503,14 +2502,6 @@
 
 void SBac::finish()
 {
-if (m_bIsCounter)
-{
-// TODO: why write 0 bits?
-m_bitIf-write(0, uint32_t(m_fracBits  15));
-m_fracBits = 32767;
-X265_CHECK(0, should not get here\n);
-}
-
 if (m_low  (21 + m_bitsLeft))
 {
 m_bitIf-writeByte(m_bufferedByte + 1);
@@ -2563,7 +2554,8 @@
 m_numBufferedBytes = 0;
 

[x265] [PATCH 2 of 4] frameencoder: remove unnecessary include of TEncSearch.h

2014-07-10 Thread Steve Borho
# HG changeset patch
# User Steve Borho st...@borho.org
# Date 1405032244 18000
#  Thu Jul 10 17:44:04 2014 -0500
# Node ID 7649ffe940e1500ff168e5a46622c1447202cdeb
# Parent  0a0fe4d52711b08cf502f084fffb17d0ba4ebdf0
frameencoder: remove unnecessary include of TEncSearch.h

diff -r 0a0fe4d52711 -r 7649ffe940e1 source/encoder/frameencoder.h
--- a/source/encoder/frameencoder.h Thu Jul 10 17:43:44 2014 -0500
+++ b/source/encoder/frameencoder.h Thu Jul 10 17:44:04 2014 -0500
@@ -31,7 +31,6 @@
 #include frame.h
 
 #include TLibEncoder/TEncCu.h
-#include TLibEncoder/TEncSearch.h
 #include TLibEncoder/TEncSampleAdaptiveOffset.h
 
 #include entropy.h
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH 3 of 4] cturow: rename m_rdGoOnSbacCoder to m_sbacCoder; there is only one

2014-07-10 Thread Steve Borho
# HG changeset patch
# User Steve Borho st...@borho.org
# Date 1405032492 18000
#  Thu Jul 10 17:48:12 2014 -0500
# Node ID 9e50b8b7503b3ae656926ec038427fb7ec59bed0
# Parent  7649ffe940e1500ff168e5a46622c1447202cdeb
cturow: rename m_rdGoOnSbacCoder to m_sbacCoder; there is only one

diff -r 7649ffe940e1 -r 9e50b8b7503b source/encoder/cturow.cpp
--- a/source/encoder/cturow.cpp Thu Jul 10 17:44:04 2014 -0500
+++ b/source/encoder/cturow.cpp Thu Jul 10 17:48:12 2014 -0500
@@ -67,13 +67,13 @@
 m_rdSbacCoders[0][CI_CURR_BEST].loadContexts(*bufferSbac);
 
 // setup thread local data structures to use this row's CABAC state
-tld.m_search.m_sbacCoder = m_rdGoOnSbacCoder;
+tld.m_search.m_sbacCoder = m_sbacCoder;
 tld.m_search.m_rdSbacCoders = m_rdSbacCoders;
-tld.m_cuCoder.m_sbacCoder = m_rdGoOnSbacCoder;
+tld.m_cuCoder.m_sbacCoder = m_sbacCoder;
 tld.m_cuCoder.m_rdSbacCoders = m_rdSbacCoders;
 
 BitCounter bc;
-m_rdGoOnSbacCoder.setBitstream(bc);
+m_sbacCoder.setBitstream(bc);
 
 tld.m_cuCoder.compressCU(cu); // Does all the CU analysis
 
diff -r 7649ffe940e1 -r 9e50b8b7503b source/encoder/cturow.h
--- a/source/encoder/cturow.h   Thu Jul 10 17:44:04 2014 -0500
+++ b/source/encoder/cturow.h   Thu Jul 10 17:48:12 2014 -0500
@@ -63,7 +63,7 @@
 
 SBacm_rowEntropyCoder; /* only used by 
frameEncoder::encodeSlice() */
 
-SBacm_rdGoOnSbacCoder;
+SBacm_sbacCoder;
 SBacm_bufferSbacCoder;
 SBacm_rdSbacCoders[MAX_CU_DEPTH + 1][CI_NUM];
 
@@ -74,7 +74,7 @@
 
 CTURow()
 {
-m_rdGoOnSbacCoder.m_bIsCounter = true;
+m_sbacCoder.m_bIsCounter = true;
 for (uint32_t depth = 0; depth  g_maxCUDepth + 1; depth++)
 for (int ciIdx = 0; ciIdx  CI_NUM; ciIdx++)
 m_rdSbacCoders[depth][ciIdx].m_bIsCounter = true;
@@ -83,7 +83,7 @@
 void init(TComSlice *slice)
 {
 m_active = 0;
-m_rdGoOnSbacCoder.resetEntropy(slice);
+m_sbacCoder.resetEntropy(slice);
 
 // Note: Reset status to avoid frame parallelism output mistake on 
different thread number
 for (uint32_t depth = 0; depth  g_maxCUDepth + 1; depth++)
diff -r 7649ffe940e1 -r 9e50b8b7503b source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp   Thu Jul 10 17:44:04 2014 -0500
+++ b/source/encoder/frameencoder.cpp   Thu Jul 10 17:48:12 2014 -0500
@@ -100,7 +100,7 @@
 }
 
 m_tld.init(*top);
-m_frameFilter.init(top, this, numRows, m_rows[0].m_rdGoOnSbacCoder);
+m_frameFilter.init(top, this, numRows, m_rows[0].m_sbacCoder);
 
 // initialize SPS
 top-initSPS(m_sps);
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH 1 of 4] cu, search: remove redundant m_rdGoOnSbacCoder pointer

2014-07-10 Thread Steve Borho
# HG changeset patch
# User Steve Borho st...@borho.org
# Date 1405031594 18000
#  Thu Jul 10 17:33:14 2014 -0500
# Node ID d6c423c66e4d5a06dc4dccbd9eade7a21f9c8adf
# Parent  57a4c1c2274ec6b40f4a138523c6b67ffa853e09
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)

diff -r 57a4c1c2274e -r d6c423c66e4d source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp Thu Jul 10 14:13:30 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.cpp Thu Jul 10 17:33:14 2014 -0500
@@ -75,7 +75,6 @@
 m_rdCost  = NULL;
 m_sbacCoder   = NULL;
 m_rdSbacCoders= NULL;
-m_rdGoOnSbacCoder = NULL;
 m_bBitCounting= false;
 }
 
@@ -1348,7 +1347,7 @@
 // Encode Coefficients
 bool bEncodeDQP = m_bEncodeDQP;
 m_sbacCoder-codeCoeff(outTempCU, 0, depth, outTempCU-getCUSize(0), 
bEncodeDQP);
-m_rdGoOnSbacCoder-store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
+m_sbacCoder-store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
 outTempCU-m_totalBits = m_sbacCoder-getNumberOfWrittenBits();
 outTempCU-m_coeffBits = outTempCU-m_totalBits - outTempCU-m_mvBits;
 
@@ -1397,7 +1396,7 @@
 // Encode Coefficients
 bool bCodeDQP = m_bEncodeDQP;
 m_sbacCoder-codeCoeff(outTempCU, 0, depth, outTempCU-getCUSize(0), 
bCodeDQP);
-m_rdGoOnSbacCoder-store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
+m_sbacCoder-store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
 outTempCU-m_totalBits = m_sbacCoder-getNumberOfWrittenBits();
 outTempCU-m_coeffBits = outTempCU-m_totalBits - outTempCU-m_mvBits;
 
diff -r 57a4c1c2274e -r d6c423c66e4d source/Lib/TLibEncoder/TEncCu.h
--- a/source/Lib/TLibEncoder/TEncCu.h   Thu Jul 10 14:13:30 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.h   Thu Jul 10 17:33:14 2014 -0500
@@ -124,7 +124,6 @@
 
 // RD SBac pointers
 SBac   (*m_rdSbacCoders)[CI_NUM];
-SBac*m_rdGoOnSbacCoder;
 
 uint8_t  m_totalDepth;
 
diff -r 57a4c1c2274e -r d6c423c66e4d source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp Thu Jul 10 14:13:30 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp Thu Jul 10 17:33:14 2014 -0500
@@ -68,7 +68,6 @@
 m_trQuant = NULL;
 m_sbacCoder = NULL;
 m_rdSbacCoders = NULL;
-m_rdGoOnSbacCoder = NULL;
 m_numLayers = 0;
 }
 
@@ -636,7 +635,7 @@
 if (checkTransformSkip || checkTQbypass)
 {
 //- store original entropy coding status -
-
m_rdGoOnSbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+m_sbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 
 uint32_t  singleDistYTmp = 0;
 uint32_t  singlePsyEnergyYTmp = 0;
@@ -694,10 +693,10 @@
 bestTQbypass = singleTQbypass;
 bestModeId   = modeId;
 if (bestModeId == firstCheckId)
-
m_rdGoOnSbacCoder-store(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
+
m_sbacCoder-store(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
 }
 if (modeId == firstCheckId)
-
m_rdGoOnSbacCoder-load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+
m_sbacCoder-load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 }
 
 cu-setTransformSkipSubParts(checkTransformSkip ? bestModeId : 0, 
TEXT_LUMA, absPartIdx, fullDepth);
@@ -708,7 +707,7 @@
 {
 xLoadIntraResultQT(cu, absPartIdx, log2TrSize, reconQt, 
reconQtStride);
 cu-setCbfSubParts(singleCbfY  trDepth, TEXT_LUMA, 
absPartIdx, fullDepth);
-
m_rdGoOnSbacCoder-load(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
+m_sbacCoder-load(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
 }
 else
 {
@@ -719,7 +718,7 @@
 }
 else
 {
-
m_rdGoOnSbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+m_sbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 
 //- code luma block with given intra prediction mode and store 
Cbf-
 cu-setTransformSkipSubParts(0, TEXT_LUMA, absPartIdx, fullDepth);
@@ -748,11 +747,11 @@
 //- store full entropy coding status, load original entropy coding 
status -
 if (bCheckFull)
 {
-
m_rdGoOnSbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_TEST]);
-
m_rdGoOnSbacCoder-load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+m_sbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_TEST]);
+m_sbacCoder-load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 }
 else
-
m_rdGoOnSbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
+

Re: [x265] [PATCH 1 of 4] cu, search: remove redundant m_rdGoOnSbacCoder pointer

2014-07-10 Thread Deepthi Nandakumar
This series is awesome...


On Fri, Jul 11, 2014 at 6:00 AM, Steve Borho st...@borho.org wrote:

 # HG changeset patch
 # User Steve Borho st...@borho.org
 # Date 1405031594 18000
 #  Thu Jul 10 17:33:14 2014 -0500
 # Node ID d6c423c66e4d5a06dc4dccbd9eade7a21f9c8adf
 # Parent  57a4c1c2274ec6b40f4a138523c6b67ffa853e09
 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)

 diff -r 57a4c1c2274e -r d6c423c66e4d source/Lib/TLibEncoder/TEncCu.cpp
 --- a/source/Lib/TLibEncoder/TEncCu.cpp Thu Jul 10 14:13:30 2014 -0500
 +++ b/source/Lib/TLibEncoder/TEncCu.cpp Thu Jul 10 17:33:14 2014 -0500
 @@ -75,7 +75,6 @@
  m_rdCost  = NULL;
  m_sbacCoder   = NULL;
  m_rdSbacCoders= NULL;
 -m_rdGoOnSbacCoder = NULL;
  m_bBitCounting= false;
  }

 @@ -1348,7 +1347,7 @@
  // Encode Coefficients
  bool bEncodeDQP = m_bEncodeDQP;
  m_sbacCoder-codeCoeff(outTempCU, 0, depth, outTempCU-getCUSize(0),
 bEncodeDQP);
 -m_rdGoOnSbacCoder-store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
 +m_sbacCoder-store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
  outTempCU-m_totalBits = m_sbacCoder-getNumberOfWrittenBits();
  outTempCU-m_coeffBits = outTempCU-m_totalBits - outTempCU-m_mvBits;

 @@ -1397,7 +1396,7 @@
  // Encode Coefficients
  bool bCodeDQP = m_bEncodeDQP;
  m_sbacCoder-codeCoeff(outTempCU, 0, depth, outTempCU-getCUSize(0),
 bCodeDQP);
 -m_rdGoOnSbacCoder-store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
 +m_sbacCoder-store(m_rdSbacCoders[depth][CI_TEMP_BEST]);
  outTempCU-m_totalBits = m_sbacCoder-getNumberOfWrittenBits();
  outTempCU-m_coeffBits = outTempCU-m_totalBits - outTempCU-m_mvBits;

 diff -r 57a4c1c2274e -r d6c423c66e4d source/Lib/TLibEncoder/TEncCu.h
 --- a/source/Lib/TLibEncoder/TEncCu.h   Thu Jul 10 14:13:30 2014 -0500
 +++ b/source/Lib/TLibEncoder/TEncCu.h   Thu Jul 10 17:33:14 2014 -0500
 @@ -124,7 +124,6 @@

  // RD SBac pointers
  SBac   (*m_rdSbacCoders)[CI_NUM];
 -SBac*m_rdGoOnSbacCoder;

  uint8_t  m_totalDepth;

 diff -r 57a4c1c2274e -r d6c423c66e4d source/Lib/TLibEncoder/TEncSearch.cpp
 --- a/source/Lib/TLibEncoder/TEncSearch.cpp Thu Jul 10 14:13:30 2014
 -0500
 +++ b/source/Lib/TLibEncoder/TEncSearch.cpp Thu Jul 10 17:33:14 2014
 -0500
 @@ -68,7 +68,6 @@
  m_trQuant = NULL;
  m_sbacCoder = NULL;
  m_rdSbacCoders = NULL;
 -m_rdGoOnSbacCoder = NULL;
  m_numLayers = 0;
  }

 @@ -636,7 +635,7 @@
  if (checkTransformSkip || checkTQbypass)
  {
  //- store original entropy coding status -
 -
  m_rdGoOnSbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 +
  m_sbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);

  uint32_t  singleDistYTmp = 0;
  uint32_t  singlePsyEnergyYTmp = 0;
 @@ -694,10 +693,10 @@
  bestTQbypass = singleTQbypass;
  bestModeId   = modeId;
  if (bestModeId == firstCheckId)
 -
  m_rdGoOnSbacCoder-store(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
 +
  m_sbacCoder-store(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
  }
  if (modeId == firstCheckId)
 -
  m_rdGoOnSbacCoder-load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 +
  m_sbacCoder-load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
  }

  cu-setTransformSkipSubParts(checkTransformSkip ? bestModeId
 : 0, TEXT_LUMA, absPartIdx, fullDepth);
 @@ -708,7 +707,7 @@
  {
  xLoadIntraResultQT(cu, absPartIdx, log2TrSize, reconQt,
 reconQtStride);
  cu-setCbfSubParts(singleCbfY  trDepth, TEXT_LUMA,
 absPartIdx, fullDepth);
 -
  m_rdGoOnSbacCoder-load(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
 +
  m_sbacCoder-load(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
  }
  else
  {
 @@ -719,7 +718,7 @@
  }
  else
  {
 -
  m_rdGoOnSbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 +
  m_sbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);

  //- code luma block with given intra prediction mode and
 store Cbf-
  cu-setTransformSkipSubParts(0, TEXT_LUMA, absPartIdx,
 fullDepth);
 @@ -748,11 +747,11 @@
  //- store full entropy coding status, load original entropy
 coding status -
  if (bCheckFull)
  {
 -
  m_rdGoOnSbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_TEST]);
 -
  m_rdGoOnSbacCoder-load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 +
  m_sbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_TEST]);
 +
  m_sbacCoder-load(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
  }
  else
 -
  m_rdGoOnSbacCoder-store(m_rdSbacCoders[fullDepth][CI_QT_TRAFO_ROOT]);
 +
  

[x265] [PATCH 3 of 4] compress: save CABAC context after intra decision

2014-07-10 Thread deepthi
# HG changeset patch
# User Deepthi Nandakumar deep...@multicorewareinc.com
# Date 1405045235 -19800
#  Fri Jul 11 07:50:35 2014 +0530
# Node ID 65d4f5b4fd3af574cd6ee13cf7bdf3b16329aa00
# Parent  b728ca41433f15a0fd630286cf579c7fcdb62820
compress: save CABAC context after intra decision.

Since CABAC encode happens only for rd  2

diff -r b728ca41433f -r 65d4f5b4fd3a source/encoder/compress.cpp
--- a/source/encoder/compress.cpp   Fri Jul 11 07:47:30 2014 +0530
+++ b/source/encoder/compress.cpp   Fri Jul 11 07:50:35 2014 +0530
@@ -527,6 +527,10 @@
 outBestCU = m_intraInInterCU[depth];
 std::swap(m_bestPredYuv[depth], 
m_modePredYuv[5][depth]);
 std::swap(m_bestRecoYuv[depth], 
m_tmpRecoYuv[depth]);
+if (m_param-rdLevel  2)
+{
+
m_rdSbacCoders[depth][CI_TEMP_BEST].store(m_rdSbacCoders[depth][CI_NEXT_BEST]);
+}
 }
 }
 }
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH 2 of 4] compress: save CABAC context after inter/merge decision

2014-07-10 Thread deepthi
# HG changeset patch
# User Deepthi Nandakumar deep...@multicorewareinc.com
# Date 1405045050 -19800
#  Fri Jul 11 07:47:30 2014 +0530
# Node ID b728ca41433f15a0fd630286cf579c7fcdb62820
# Parent  52cda492abf57f7d81fbccbe7e667bfba0946d54
compress: save CABAC context after inter/merge decision

diff -r 52cda492abf5 -r b728ca41433f source/encoder/compress.cpp
--- a/source/encoder/compress.cpp   Fri Jul 11 07:42:46 2014 +0530
+++ b/source/encoder/compress.cpp   Fri Jul 11 07:47:30 2014 +0530
@@ -488,6 +488,10 @@
 std::swap(m_bestPredYuv[depth], 
m_modePredYuv[3][depth]);
 std::swap(m_bestRecoYuv[depth], 
m_bestMergeRecoYuv[depth]);
 }
+else
+{
+
m_rdSbacCoders[depth][CI_TEMP_BEST].store(m_rdSbacCoders[depth][CI_NEXT_BEST]);
+}
 }
 
 /* Check for Intra in inter frames only if its a P-slice*/
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH 4 of 4] compress: save CABAC context for rd = 2 after inter/intra encodes

2014-07-10 Thread deepthi
# HG changeset patch
# User Deepthi Nandakumar deep...@multicorewareinc.com
# Date 1405045376 -19800
#  Fri Jul 11 07:52:56 2014 +0530
# Node ID 1c8573c886b1d532fae4cdb154d0ac82d1f31a43
# Parent  65d4f5b4fd3af574cd6ee13cf7bdf3b16329aa00
compress: save CABAC context for rd = 2 after inter/intra encodes

diff -r 65d4f5b4fd3a -r 1c8573c886b1 source/encoder/compress.cpp
--- a/source/encoder/compress.cpp   Fri Jul 11 07:50:35 2014 +0530
+++ b/source/encoder/compress.cpp   Fri Jul 11 07:52:56 2014 +0530
@@ -552,10 +552,12 @@
 
 m_search-encodeResAndCalcRdInterCU(outBestCU, 
m_origYuv[depth], m_bestPredYuv[depth], m_tmpResiYuv[depth],
 
m_bestResiYuv[depth], m_bestRecoYuv[depth], false, true);
+
m_rdSbacCoders[depth][CI_TEMP_BEST].store(m_rdSbacCoders[depth][CI_NEXT_BEST]);
 }
 else if (outBestCU-getPredictionMode(0) == MODE_INTRA)
 {
 xEncodeIntraInInter(outBestCU, m_origYuv[depth], 
m_bestPredYuv[depth], m_tmpResiYuv[depth],  m_bestRecoYuv[depth]);
+
m_rdSbacCoders[depth][CI_TEMP_BEST].store(m_rdSbacCoders[depth][CI_NEXT_BEST]);
 }
 }
 else if (m_param-rdLevel == 1)
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH 1 of 4] compress: save CABAC context in merge modes for lower RD levels

2014-07-10 Thread deepthi
# HG changeset patch
# User Deepthi Nandakumar deep...@multicorewareinc.com
# Date 1405044766 -19800
#  Fri Jul 11 07:42:46 2014 +0530
# Node ID 52cda492abf57f7d81fbccbe7e667bfba0946d54
# Parent  e3e077965c39a56a24e09189652e1de3c5a0e3ea
compress: save CABAC context in merge modes for lower RD levels.

diff -r e3e077965c39 -r 52cda492abf5 source/encoder/compress.cpp
--- a/source/encoder/compress.cpp   Thu Jul 10 19:29:46 2014 -0500
+++ b/source/encoder/compress.cpp   Fri Jul 11 07:42:46 2014 +0530
@@ -320,8 +320,8 @@
 {
 //No-residue mode
 m_search-encodeResAndCalcRdInterCU(outBestCU, 
m_origYuv[depth], bestPredYuv, m_tmpResiYuv[depth], m_bestResiYuv[depth], 
m_tmpRecoYuv[depth], true, true);
-
 std::swap(yuvReconBest, m_tmpRecoYuv[depth]);
+
m_rdSbacCoders[depth][CI_TEMP_BEST].store(m_rdSbacCoders[depth][CI_NEXT_BEST]);
 }
 
 //Encode with residue
@@ -333,6 +333,7 @@
 {
 std::swap(outBestCU, outTempCU);
 std::swap(yuvReconBest, m_tmpRecoYuv[depth]);
+
m_rdSbacCoders[depth][CI_TEMP_BEST].store(m_rdSbacCoders[depth][CI_NEXT_BEST]);
 }
 }
 }
___
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel


[x265] [PATCH 1 of 2] derive TEncCu from TEncSearch

2014-07-10 Thread Steve Borho
# HG changeset patch
# User Steve Borho st...@borho.org
# Date 1405049544 18000
#  Thu Jul 10 22:32:24 2014 -0500
# Node ID 3685d607012f345079e7ae2cf1949338a23683d0
# Parent  e3e077965c39a56a24e09189652e1de3c5a0e3ea
derive TEncCu from TEncSearch

TEncSearch methods are only callable from TEncCu methods. and there is much
duplication in their data members. This removes a lot of redundancy and removes
a lot of pointer dereferences

diff -r e3e077965c39 -r 3685d607012f source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp Thu Jul 10 19:29:46 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.cpp Thu Jul 10 22:32:24 2014 -0500
@@ -66,17 +66,26 @@
 m_bestMergeRecoYuv = NULL;
 m_origYuv = NULL;
 for (int i = 0; i  MAX_PRED_TYPES; i++)
-{
 m_modePredYuv[i] = NULL;
-}
 
-m_search  = NULL;
-m_trQuant = NULL;
-m_rdCost  = NULL;
 m_sbacCoder   = NULL;
 m_rdSbacCoders= NULL;
 }
 
+bool TEncCu::init(Encoder* top, RDCost* rdCost, TComTrQuant* trQuant)
+{
+m_trQuant = trQuant;
+m_rdCost  = rdCost;
+
+m_CUTransquantBypass = top-m_CUTransquantBypassFlagValue;
+m_param = top-m_param;
+m_bEnableRDOQ = top-m_bEnableRDOQ;
+m_bFrameParallel = top-m_totalFrameThreads  1;
+m_numLayers = top-m_quadtreeTULog2MaxSize - top-m_quadtreeTULog2MinSize 
+ 1;
+
+return initSearch();
+}
+
 /**
  \paramtotalDepth  total number of allowable depth
  \parammaxWidthlargest CU width
@@ -302,14 +311,6 @@
 m_origYuv = NULL;
 }
 
-/** \parampcEncTop  pointer of encoder class
- */
-void TEncCu::init(Encoder* top)
-{
-m_param = top-m_param;
-m_CUTransquantBypass = top-m_CUTransquantBypassFlagValue;
-}
-
 // 

 // Public member functions
 // 

@@ -1202,7 +1203,7 @@
 {
 for (uint32_t mergeCand = 0; mergeCand  maxNumMergeCand; ++mergeCand)
 {
-if (m_search-m_bFrameParallel 
+if (m_bFrameParallel 
 (mvFieldNeighbours[mergeCand][0].mv.y = (m_param-searchRange 
+ 1) * 4 ||
  mvFieldNeighbours[mergeCand][1].mv.y = (m_param-searchRange 
+ 1) * 4))
 {
@@ -1223,16 +1224,16 @@
 
outTempCU-getCUMvField(REF_PIC_LIST_1)-setAllMvField(mvFieldNeighbours[mergeCand][1],
 SIZE_2Nx2N, 0, 0); // interprets depth relative to outTempCU level
 
 // do MC
-m_search-motionCompensation(outTempCU, 
m_tmpPredYuv[depth], REF_PIC_LIST_X, 0);
+motionCompensation(outTempCU, m_tmpPredYuv[depth], 
REF_PIC_LIST_X, 0);
 // estimate residual and encode everything
-m_search-encodeResAndCalcRdInterCU(outTempCU,
-m_origYuv[depth],
-m_tmpPredYuv[depth],
-m_tmpResiYuv[depth],
-m_bestResiYuv[depth],
-m_tmpRecoYuv[depth],
-!!noResidual,
-true);
+encodeResAndCalcRdInterCU(outTempCU,
+  m_origYuv[depth],
+  m_tmpPredYuv[depth],
+  m_tmpResiYuv[depth],
+  m_bestResiYuv[depth],
+  m_tmpRecoYuv[depth],
+  !!noResidual,
+  true);
 
 /* Todo: Fix the satd cost estimates. Why is merge being 
chosen in high motion areas: estimated distortion is too low? */
 if (!noResidual  !outTempCU-getQtRootCbf(0))
@@ -1302,9 +1303,9 @@
 outTempCU-setPredModeSubParts(MODE_INTER, 0, depth);
 outTempCU-setCUTransquantBypassSubParts(m_CUTransquantBypass, 0, depth);
 
-if (m_search-predInterSearch(outTempCU, m_tmpPredYuv[depth], bUseMRG, 
true))
+if (predInterSearch(outTempCU, m_tmpPredYuv[depth], bUseMRG, true))
 {
-m_search-encodeResAndCalcRdInterCU(outTempCU, m_origYuv[depth], 
m_tmpPredYuv[depth], m_tmpResiYuv[depth], m_bestResiYuv[depth], 
m_tmpRecoYuv[depth], false, true);
+encodeResAndCalcRdInterCU(outTempCU, m_origYuv[depth], 
m_tmpPredYuv[depth], m_tmpResiYuv[depth], m_bestResiYuv[depth], 
m_tmpRecoYuv[depth], false, true);
 xCheckDQP(outTempCU);
 xCheckBestMode(outBestCU, outTempCU, depth);
 }
@@ -1320,9 

[x265] zero stride for zeroPel[]

2014-07-10 Thread Satoshi Nakagawa
# HG changeset patch
# User Satoshi Nakagawa nakagawa...@oki.com
# Date 1405052989 -32400
#  Fri Jul 11 13:29:49 2014 +0900
# Node ID 18a6ee92620f1f7266dfbeff3b9010aae356d796
# Parent  e3e077965c39a56a24e09189652e1de3c5a0e3ea
zero stride for zeroPel[]

diff -r e3e077965c39 -r 18a6ee92620f source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp Thu Jul 10 19:29:46 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp Fri Jul 11 13:29:49 2014 +0900
@@ -47,7 +47,7 @@
 
 using namespace x265;
 
-ALIGN_VAR_32(const pixel, RDCost::zeroPel[MAX_CU_SIZE * MAX_CU_SIZE]) = { 0 };
+ALIGN_VAR_32(const pixel, RDCost::zeroPel[MAX_CU_SIZE]) = { 0 };
 
 TEncSearch::TEncSearch()
 {
@@ -2404,7 +2404,7 @@
 {
 int size = g_convertToBit[cuSize];
 zeroPsyEnergyY = m_rdCost-psyCost(size, fencYuv-getLumaAddr(), 
fencYuv-getStride(),
-(pixel*)RDCost::zeroPel, MAX_CU_SIZE); // need to check 
whether zero distortion is similar to psyenergy of fenc
+(pixel*)RDCost::zeroPel, 0); // need to check whether zero 
distortion is similar to psyenergy of fenc
 zeroCost = m_rdCost-calcPsyRdCost(zeroDistortion, zeroResiBits, 
zeroPsyEnergyY);
 }
 else
@@ -2813,13 +2813,13 @@
 }
 
 int partSize = partitionFromSize(trSize);
-uint32_t distY = 
primitives.sse_sp[partSize](resiYuv-getLumaAddr(absPartIdx), resiYuv-m_width, 
(pixel*)RDCost::zeroPel, trSize);
+uint32_t distY = 
primitives.sse_sp[partSize](resiYuv-getLumaAddr(absPartIdx), resiYuv-m_width, 
(pixel*)RDCost::zeroPel, 0);
 uint32_t psyEnergyY = 0;
 if (m_rdCost-psyRdEnabled())
 {
-int size = g_convertToBit[trSize];
+int size = log2TrSize - 2;
 psyEnergyY = m_rdCost-psyCost(size, 
fencYuv-getLumaAddr(absPartIdx), fencYuv-getStride(),
-(pixel*)RDCost::zeroPel, trSize); // need to check whether 
zero distortion is similar to psyenergy of fenc
+(pixel*)RDCost::zeroPel, 0); // need to check whether zero 
distortion is similar to psyenergy of fenc
 }
 int16_t *curResiY = m_qtTempShortYuv[qtLayer].getLumaAddr(absPartIdx);
 X265_CHECK(m_qtTempShortYuv[qtLayer].m_width == MAX_CU_SIZE, width 
not full CU\n);
@@ -2845,7 +2845,7 @@
 uint32_t stride = fencYuv-getStride();
 //= reconstruction =
 primitives.luma_add_ps[partSize](reconIPred, reconIPredStride, 
pred, curResiY, stride, strideResiY);
-int size = g_convertToBit[trSize];
+int size = log2TrSize - 2;
 nonZeroPsyEnergyY = m_rdCost-psyCost(size, 
fencYuv-getLumaAddr(absPartIdx), fencYuv-getStride(),
 cu-getPic()-getPicYuvRec()-getLumaAddr(cu-getAddr(), 
zorder), cu-getPic()-getPicYuvRec()-getStride());
 }
@@ -2922,12 +2922,10 @@
 int16_t *curResiU = 
m_qtTempShortYuv[qtLayer].getCbAddr(absPartIdxC);
 int16_t *curResiV = 
m_qtTempShortYuv[qtLayer].getCrAddr(absPartIdxC);
 
-distU = 
m_rdCost-scaleChromaDistCb(primitives.sse_sp[partSizeC](resiYuv-getCbAddr(absPartIdxC),
 resiYuv-m_cwidth, (pixel*)RDCost::zeroPel, trSizeC));
-
+distU = 
m_rdCost-scaleChromaDistCb(primitives.sse_sp[partSizeC](resiYuv-getCbAddr(absPartIdxC),
 resiYuv-m_cwidth, (pixel*)RDCost::zeroPel, 0));
 if (outZeroDist)
-{
 *outZeroDist += distU;
-}
+
 if (numSigU[tuIterator.section])
 {
 int curChromaQpOffset = 
cu-getSlice()-getPPS()-getChromaCbQpOffset() + 
cu-getSlice()-getSliceQpDeltaCb();
@@ -2938,7 +2936,6 @@
  curResiU, 
strideResiC);
 const uint32_t nonZeroDistU = 
m_rdCost-scaleChromaDistCb(dist);
 uint32_t nonZeroPsyEnergyU = 0;
-
 if (m_rdCost-psyRdEnabled())
 {
 pixel*   pred = predYuv-getCbAddr(absPartIdxC);
@@ -2948,7 +2945,7 @@
 uint32_t stride = fencYuv-getCStride();
 //= reconstruction =
 primitives.luma_add_ps[partSizeC](reconIPred, 
reconIPredStride, pred, curResiU, stride, strideResiC);
-int size = g_convertToBit[trSizeC];
+int size = log2TrSizeC - 2;
 nonZeroPsyEnergyU = m_rdCost-psyCost(size, 
fencYuv-getCbAddr(absPartIdxC), fencYuv-getCStride(),
 
cu-getPic()-getPicYuvRec()-getCbAddr(cu-getAddr(), zorder), 
cu-getPic()-getPicYuvRec()-getCStride());
 }
@@ -3007,7 +3004,7 @@
 if (!numSigU[tuIterator.section])
 primitives.blockfill_s[sizeIdxC](curResiU, strideResiC, 0);
 
-