[x265] [PATCH 1 of 2] framepp: let sao use own context
Min Chen
chenm003 at 163.com
Sat Sep 7 07:12:32 CEST 2013
# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1378530725 -28800
# Node ID 4bcc6891ab95a5e34c3e2b27137ffaaa224a9987
# Parent 385c0b29be4fe35f78746574fd26608e125fd314
framepp: let sao use own context
diff -r 385c0b29be4f -r 4bcc6891ab95 source/Lib/TLibEncoder/TEncBinCoderCABAC.h
--- a/source/Lib/TLibEncoder/TEncBinCoderCABAC.h Fri Sep 06 15:29:50 2013 -0500
+++ b/source/Lib/TLibEncoder/TEncBinCoderCABAC.h Sat Sep 07 13:12:05 2013 +0800
@@ -88,6 +88,7 @@
void testAndWriteOut();
void writeOut();
+public:
TComBitIf* m_pcTComBitIf;
UInt m_uiLow;
UInt m_uiRange;
diff -r 385c0b29be4f -r 4bcc6891ab95 source/Lib/TLibEncoder/TEncSbac.h
--- a/source/Lib/TLibEncoder/TEncSbac.h Fri Sep 06 15:29:50 2013 -0500
+++ b/source/Lib/TLibEncoder/TEncSbac.h Sat Sep 07 13:12:05 2013 +0800
@@ -121,7 +121,7 @@
void codeDFSvlc(int /*iCode*/, const char* /*pSymbolName*/) { printf("Not supported in codeDFSvlc()\n"); assert(0); exit(1); }
-protected:
+public:
TComBitIf* m_pcBitIf;
TComSlice* m_pcSlice;
diff -r 385c0b29be4f -r 4bcc6891ab95 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp Fri Sep 06 15:29:50 2013 -0500
+++ b/source/encoder/frameencoder.cpp Sat Sep 07 13:12:05 2013 +0800
@@ -106,7 +106,7 @@
m_pool = NULL;
}
- m_frameFilter.init(top, numRows, getEntropyCoder(0), getRDGoOnSbacCoder(0));
+ m_frameFilter.init(top, numRows, getRDGoOnSbacCoder(0));
// initialize SPS
top->xInitSPS(&m_sps);
diff -r 385c0b29be4f -r 4bcc6891ab95 source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp Fri Sep 06 15:29:50 2013 -0500
+++ b/source/encoder/framefilter.cpp Sat Sep 07 13:12:05 2013 +0800
@@ -37,8 +37,6 @@
, m_cfg(NULL)
, m_pic(NULL)
, active_lft(0)
- , m_entropyCoder(NULL)
- , m_rdGoOnSbacCoder(NULL)
{}
void FrameFilter::destroy()
@@ -75,14 +73,13 @@
return false;
}
-void FrameFilter::init(TEncTop *top, int numRows, TEncEntropy* entropyCoder, TEncSbac* rdGoOnSbacCoder)
+void FrameFilter::init(TEncTop *top, int numRows, TEncSbac* rdGoOnSbacCoder)
{
m_cfg = top;
m_numRows = numRows;
- // NOTE: for sao only, DON'T use before first row finished
- m_entropyCoder = entropyCoder;
- m_rdGoOnSbacCoder = rdGoOnSbacCoder;
+ // NOTE: for sao only, I write this code because I want to exact match with HM's bug bitstream
+ m_rdGoOnSbacCoderRow0 = rdGoOnSbacCoder;
if (top->param.bEnableLoopFilter)
{
@@ -103,6 +100,11 @@
row_ready = -1;
row_done = -1;
active_lft = 0;
+
+ m_rdGoOnSbacCoder.init(&m_rdGoOnBinCodersCABAC);
+ m_entropyCoder.setEntropyCoder(&m_rdGoOnSbacCoder, pic->getSlice());
+ m_entropyCoder.setBitstream(&m_bitCounter);
+
if (m_cfg->param.bEnableLoopFilter)
{
m_sao.resetStats();
@@ -148,11 +150,12 @@
// Called by worker threads
- // NOTE: We are here only active both of loopfilter and sao, and row 0 always finished, so we can safe to reuse row[0]'s data
+ // NOTE: We are here only active both of loopfilter and sao, the row 0 always finished, so we can safe to copy row[0]'s data
if (row == 0)
{
- // CHECK_ME: I think the SAO uses a temp Sbac only, so I always use [0], am I right?
- m_sao.startSaoEnc(m_pic, m_entropyCoder, m_rdGoOnSbacCoder);
+ // NOTE: not need, seems HM's bug, I want to keep output exact matched.
+ m_rdGoOnBinCodersCABAC.m_fracBits = ((TEncBinCABACCounter*)((TEncSbac*)m_rdGoOnSbacCoderRow0->m_pcBinIf))->m_fracBits;
+ m_sao.startSaoEnc(m_pic, &m_entropyCoder, &m_rdGoOnSbacCoder);
}
const uint32_t numCols = m_pic->getPicSym()->getFrameWidthInCU();
diff -r 385c0b29be4f -r 4bcc6891ab95 source/encoder/framefilter.h
--- a/source/encoder/framefilter.h Fri Sep 06 15:29:50 2013 -0500
+++ b/source/encoder/framefilter.h Sat Sep 07 13:12:05 2013 +0800
@@ -47,7 +47,7 @@
virtual ~FrameFilter() {}
- void init(TEncTop *top, int numRows, TEncEntropy* entropyCoder, TEncSbac* rdGoOnSbacCoder);
+ void init(TEncTop *top, int numRows, TEncSbac* rdGoOnSbacCoder);
void destroy();
@@ -71,10 +71,15 @@
TComLoopFilter m_loopFilter;
TEncSampleAdaptiveOffset m_sao;
- TEncEntropy* m_entropyCoder;
- TEncSbac* m_rdGoOnSbacCoder;
int m_numRows;
+ // SAO
+ TEncEntropy m_entropyCoder;
+ TEncSbac m_rdGoOnSbacCoder;
+ TEncBinCABACCounter m_rdGoOnBinCodersCABAC;
+ TComBitCounter m_bitCounter;
+ TEncSbac* m_rdGoOnSbacCoderRow0; // for bitstream exact only, depends on HM's bug
+
// TODO: if you want thread priority logic, add col here
volatile int row_ready;
volatile int row_done;
More information about the x265-devel
mailing list