[x265-commits] [x265] psyrd: use zero stride in psyCost C reference, minor opti...
Steve Borho
steve at borho.org
Wed Jun 18 05:14:18 CEST 2014
details: http://hg.videolan.org/x265/rev/f3fb2d2b0ba6
branches:
changeset: 7089:f3fb2d2b0ba6
user: Steve Borho <steve at borho.org>
date: Tue Jun 17 18:17:22 2014 -0500
description:
psyrd: use zero stride in psyCost C reference, minor optimization
Subject: [x265] sei: repair decoded picture hash SEI
details: http://hg.videolan.org/x265/rev/2be51b34e033
branches:
changeset: 7090:2be51b34e033
user: Steve Borho <steve at borho.org>
date: Tue Jun 17 19:27:36 2014 -0500
description:
sei: repair decoded picture hash SEI
Subject: [x265] sei: add m_ prefix to members of SEIDecodedPictureHash for consistency
details: http://hg.videolan.org/x265/rev/bb872c51a453
branches:
changeset: 7091:bb872c51a453
user: Steve Borho <steve at borho.org>
date: Tue Jun 17 19:28:47 2014 -0500
description:
sei: add m_ prefix to members of SEIDecodedPictureHash for consistency
Subject: [x265] sei: allow SEI classes to implement write() directly to avoid two-pass encode
details: http://hg.videolan.org/x265/rev/778385cde253
branches:
changeset: 7092:778385cde253
user: Steve Borho <steve at borho.org>
date: Tue Jun 17 19:41:36 2014 -0500
description:
sei: allow SEI classes to implement write() directly to avoid two-pass encode
Subject: [x265] writer: xConvertToUInt did not need to be a class member
details: http://hg.videolan.org/x265/rev/a2d63126b37c
branches:
changeset: 7093:a2d63126b37c
user: Steve Borho <steve at borho.org>
date: Tue Jun 17 19:55:33 2014 -0500
description:
writer: xConvertToUInt did not need to be a class member
Subject: [x265] pic: better name for picture timing SEI member
details: http://hg.videolan.org/x265/rev/d3ac1cbdc9c3
branches:
changeset: 7094:d3ac1cbdc9c3
user: Steve Borho <steve at borho.org>
date: Tue Jun 17 19:58:16 2014 -0500
description:
pic: better name for picture timing SEI member
Subject: [x265] sei: remove unused RESERVED hash method, avoid compiler warnings
details: http://hg.videolan.org/x265/rev/51aa9d1542ef
branches:
changeset: 7095:51aa9d1542ef
user: Steve Borho <steve at borho.org>
date: Tue Jun 17 21:15:59 2014 -0500
description:
sei: remove unused RESERVED hash method, avoid compiler warnings
diffstat:
source/Lib/TLibCommon/TComPic.h | 2 +-
source/Lib/TLibEncoder/SyntaxElementWriter.cpp | 7 +++-
source/Lib/TLibEncoder/SyntaxElementWriter.h | 2 -
source/common/pixel.cpp | 14 +++---
source/encoder/encoder.cpp | 6 +-
source/encoder/frameencoder.cpp | 15 ++++---
source/encoder/ratecontrol.cpp | 4 +-
source/encoder/sei.h | 52 +++++++++++++++++++-------
8 files changed, 65 insertions(+), 37 deletions(-)
diffs (270 lines):
diff -r 0c3d33212ebd -r 51aa9d1542ef source/Lib/TLibCommon/TComPic.h
--- a/source/Lib/TLibCommon/TComPic.h Tue Jun 17 12:47:57 2014 -0500
+++ b/source/Lib/TLibCommon/TComPic.h Tue Jun 17 21:15:59 2014 -0500
@@ -122,7 +122,7 @@ public:
double m_rateFactor; // calculated based on the Frame QP
int32_t m_forceqp; // Force to use the qp specified in qp file
- SEIPictureTiming m_sei; // TODO: move these to frame encoder, better name
+ SEIPictureTiming m_picTimingSei; // TODO: move these to frame encoder
HRDTiming m_hrdTiming;
TComPic();
diff -r 0c3d33212ebd -r 51aa9d1542ef source/Lib/TLibEncoder/SyntaxElementWriter.cpp
--- a/source/Lib/TLibEncoder/SyntaxElementWriter.cpp Tue Jun 17 12:47:57 2014 -0500
+++ b/source/Lib/TLibEncoder/SyntaxElementWriter.cpp Tue Jun 17 21:15:59 2014 -0500
@@ -118,9 +118,14 @@ void SyntaxElementWriter::xWriteUvlc(uin
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 = xConvertToUInt(code);
+ uint32_t ucode = toUInt(code);
xWriteUvlc(ucode);
}
diff -r 0c3d33212ebd -r 51aa9d1542ef source/Lib/TLibEncoder/SyntaxElementWriter.h
--- a/source/Lib/TLibEncoder/SyntaxElementWriter.h Tue Jun 17 12:47:57 2014 -0500
+++ b/source/Lib/TLibEncoder/SyntaxElementWriter.h Tue Jun 17 21:15:59 2014 -0500
@@ -87,8 +87,6 @@ protected:
void xWriteSvlcTr(int value, const char *symbolName);
void xWriteFlagTr(uint32_t value, const char *symbolName);
#endif
-
- inline uint32_t xConvertToUInt(int val) { return (val <= 0) ? -val << 1 : (val << 1) - 1; }
};
}
//! \}
diff -r 0c3d33212ebd -r 51aa9d1542ef source/common/pixel.cpp
--- a/source/common/pixel.cpp Tue Jun 17 12:47:57 2014 -0500
+++ b/source/common/pixel.cpp Tue Jun 17 21:15:59 2014 -0500
@@ -717,7 +717,7 @@ uint64_t pixel_var(pixel *pix, intptr_t
template<int size>
int psyCost(pixel *source, intptr_t sstride, pixel *recon, intptr_t rstride)
{
- static pixel zeroBuf[8 * 8] /* = { 0 } */;
+ static pixel zeroBuf[8] /* = { 0 } */;
if (size)
{
@@ -728,10 +728,10 @@ int psyCost(pixel *source, intptr_t sstr
for (int j = 0; j < dim; j+= 8)
{
/* AC energy, measured by sa8d (AC + DC) minus SAD (DC) */
- int sourceEnergy = sa8d_8x8(source + i * sstride + j, sstride, zeroBuf, 8) -
- (sad<8, 8>(source + i * sstride + j, sstride, zeroBuf, 8) >> 2);
- int reconEnergy = sa8d_8x8(recon + i * rstride + j, rstride, zeroBuf, 8) -
- (sad<8, 8>(recon + i * rstride + j, rstride, zeroBuf, 8) >> 2);
+ int sourceEnergy = sa8d_8x8(source + i * sstride + j, sstride, zeroBuf, 0) -
+ (sad<8, 8>(source + i * sstride + j, sstride, zeroBuf, 0) >> 2);
+ int reconEnergy = sa8d_8x8(recon + i * rstride + j, rstride, zeroBuf, 0) -
+ (sad<8, 8>(recon + i * rstride + j, rstride, zeroBuf, 0) >> 2);
totEnergy += abs(sourceEnergy - reconEnergy);
}
@@ -741,8 +741,8 @@ int psyCost(pixel *source, intptr_t sstr
else
{
/* 4x4 is too small for sa8d */
- int sourceEnergy = satd_4x4(source, sstride, zeroBuf, 8) - (sad<4, 4>(source, sstride, zeroBuf, 8) >> 2);
- int reconEnergy = satd_4x4(recon, rstride, zeroBuf, 8) - (sad<4, 4>(recon, rstride, zeroBuf, 8) >> 2);
+ int sourceEnergy = satd_4x4(source, sstride, zeroBuf, 8) - (sad<4, 4>(source, sstride, zeroBuf, 0) >> 2);
+ int reconEnergy = satd_4x4(recon, rstride, zeroBuf, 8) - (sad<4, 4>(recon, rstride, zeroBuf, 0) >> 2);
return abs(sourceEnergy - reconEnergy);
}
}
diff -r 0c3d33212ebd -r 51aa9d1542ef source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Tue Jun 17 12:47:57 2014 -0500
+++ b/source/encoder/encoder.cpp Tue Jun 17 21:15:59 2014 -0500
@@ -979,17 +979,17 @@ void Encoder::finishFrameStats(TComPic*
const char* digestStr = NULL;
if (m_param->decodedPictureHashSEI == 1)
{
- digestStr = digestToString(curEncoder->m_seiReconPictureDigest.digest, 16);
+ digestStr = digestToString(curEncoder->m_seiReconPictureDigest.m_digest, 16);
p += sprintf(buf + p, " [MD5:%s]", digestStr);
}
else if (m_param->decodedPictureHashSEI == 2)
{
- digestStr = digestToString(curEncoder->m_seiReconPictureDigest.digest, 2);
+ digestStr = digestToString(curEncoder->m_seiReconPictureDigest.m_digest, 2);
p += sprintf(buf + p, " [CRC:%s]", digestStr);
}
else if (m_param->decodedPictureHashSEI == 3)
{
- digestStr = digestToString(curEncoder->m_seiReconPictureDigest.digest, 4);
+ digestStr = digestToString(curEncoder->m_seiReconPictureDigest.m_digest, 4);
p += sprintf(buf + p, " [Checksum:%s]", digestStr);
}
}
diff -r 0c3d33212ebd -r 51aa9d1542ef source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp Tue Jun 17 12:47:57 2014 -0500
+++ b/source/encoder/frameencoder.cpp Tue Jun 17 21:15:59 2014 -0500
@@ -467,7 +467,7 @@ void FrameEncoder::compressFrame()
if (m_cfg->m_param->bEmitHRDSEI || !!m_cfg->m_param->interlaceMode)
{
- SEIPictureTiming *sei = &m_pic->m_sei;
+ SEIPictureTiming *sei = &m_pic->m_picTimingSei;
TComVUI *vui = slice->getSPS()->getVuiParameters();
TComHRD *hrd = vui->getHrdParameters();
int poc = slice->getPOC();
@@ -671,26 +671,26 @@ void FrameEncoder::compressFrame()
{
if (m_cfg->m_param->decodedPictureHashSEI == 1)
{
- m_seiReconPictureDigest.method = SEIDecodedPictureHash::MD5;
+ m_seiReconPictureDigest.m_method = SEIDecodedPictureHash::MD5;
for (int i = 0; i < 3; i++)
{
- MD5Final(&(m_pic->m_state[i]), m_seiReconPictureDigest.digest[i]);
+ MD5Final(&(m_pic->m_state[i]), m_seiReconPictureDigest.m_digest[i]);
}
}
else if (m_cfg->m_param->decodedPictureHashSEI == 2)
{
- m_seiReconPictureDigest.method = SEIDecodedPictureHash::CRC;
+ m_seiReconPictureDigest.m_method = SEIDecodedPictureHash::CRC;
for (int i = 0; i < 3; i++)
{
- crcFinish((m_pic->m_crc[i]), m_seiReconPictureDigest.digest[i]);
+ crcFinish((m_pic->m_crc[i]), m_seiReconPictureDigest.m_digest[i]);
}
}
else if (m_cfg->m_param->decodedPictureHashSEI == 3)
{
- m_seiReconPictureDigest.method = SEIDecodedPictureHash::CHECKSUM;
+ m_seiReconPictureDigest.m_method = SEIDecodedPictureHash::CHECKSUM;
for (int i = 0; i < 3; i++)
{
- checksumFinish(m_pic->m_checksum[i], m_seiReconPictureDigest.digest[i]);
+ checksumFinish(m_pic->m_checksum[i], m_seiReconPictureDigest.m_digest[i]);
}
}
m_nalList[m_nalCount] = new NALUnit;
@@ -698,6 +698,7 @@ void FrameEncoder::compressFrame()
{
m_bs.clear();
m_seiReconPictureDigest.write(m_bs, *slice->getSPS());
+ m_bs.writeByteAlignment();
m_nalList[m_nalCount++]->serialize(NAL_UNIT_SUFFIX_SEI, m_bs);
}
diff -r 0c3d33212ebd -r 51aa9d1542ef source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp Tue Jun 17 12:47:57 2014 -0500
+++ b/source/encoder/ratecontrol.cpp Tue Jun 17 21:15:59 2014 -0500
@@ -1264,7 +1264,7 @@ int RateControl::rateControlEnd(TComPic*
}
else
{
- pic->m_hrdTiming.cpbRemovalTime = m_nominalRemovalTime + (double)pic->m_sei.m_auCpbRemovalDelay * time->getNumUnitsInTick() / time->getTimeScale();
+ pic->m_hrdTiming.cpbRemovalTime = m_nominalRemovalTime + (double)pic->m_picTimingSei.m_auCpbRemovalDelay * time->getNumUnitsInTick() / time->getTimeScale();
double cpbEarliestAT = pic->m_hrdTiming.cpbRemovalTime - (double)m_sei.m_initialCpbRemovalDelay[0][0] / 90000;
if (!pic->m_lowres.bKeyframe)
{
@@ -1279,7 +1279,7 @@ int RateControl::rateControlEnd(TComPic*
uint32_t cpbsizeUnscale = (hrd->getCpbSizeValueMinus1(0, 0, 0) + 1) << (hrd->getCpbSizeScale() + CPB_SHIFT);
pic->m_hrdTiming.cpbFinalAT = m_prevCpbFinalAT = pic->m_hrdTiming.cpbInitialAT + actualBits / cpbsizeUnscale;
- pic->m_hrdTiming.dpbOutputTime = (double)pic->m_sei.m_picDpbOutputDelay * time->getNumUnitsInTick() / time->getTimeScale() + pic->m_hrdTiming.cpbRemovalTime;
+ pic->m_hrdTiming.dpbOutputTime = (double)pic->m_picTimingSei.m_picDpbOutputDelay * time->getNumUnitsInTick() / time->getTimeScale() + pic->m_hrdTiming.cpbRemovalTime;
}
}
rce->isActive = false;
diff -r 0c3d33212ebd -r 51aa9d1542ef source/encoder/sei.h
--- a/source/encoder/sei.h Tue Jun 17 12:47:57 2014 -0500
+++ b/source/encoder/sei.h Tue Jun 17 21:15:59 2014 -0500
@@ -36,6 +36,15 @@ class SEI : public SyntaxElementWriter
{
public:
+ /* SEI users call write() to marshal an SEI to a bitstream. SEI
+ * subclasses may implement write() or accept the default write()
+ * method which calls writeSEI() with a bitcounter to determine
+ * the size, then it encodes the header and calls writeSEI a
+ * second time for the real encode. */
+ virtual void write(TComOutputBitstream& bs, TComSPS& sps);
+
+protected:
+
enum PayloadType
{
BUFFERING_PERIOD = 0,
@@ -65,9 +74,7 @@ public:
virtual PayloadType payloadType() const = 0;
- virtual void writeSEI(TComSPS& sps) = 0;
-
- void write(TComOutputBitstream& bs, TComSPS& sps);
+ virtual void writeSEI(TComSPS&) {}
void writeByteAlign();
};
@@ -89,32 +96,49 @@ public:
MD5,
CRC,
CHECKSUM,
- RESERVED,
- } method;
+ } m_method;
- uint8_t digest[3][16];
+ uint8_t m_digest[3][16];
- void writeSEI(TComSPS&)
+ void write(TComOutputBitstream& bs, TComSPS&)
{
+ setBitstream(&bs);
+
LOG("=========== Decoded picture hash SEI message ===========\n");
- WRITE_CODE(method, 8, "hash_type");
+ WRITE_CODE(DECODED_PICTURE_HASH, 8, "payload_type");
+
+ switch (m_method)
+ {
+ case MD5:
+ WRITE_CODE(1 + 16 * 3, 8, "payload_size");
+ WRITE_CODE(MD5, 8, "hash_type");
+ break;
+ case CRC:
+ WRITE_CODE(1 + 2 * 3, 8, "payload_size");
+ WRITE_CODE(CRC, 8, "hash_type");
+ break;
+ case CHECKSUM:
+ WRITE_CODE(1 + 4 * 3, 8, "payload_size");
+ WRITE_CODE(CHECKSUM, 8, "hash_type");
+ break;
+ }
for (int yuvIdx = 0; yuvIdx < 3; yuvIdx++)
{
- if (method == MD5)
+ if (m_method == MD5)
{
for (uint32_t i = 0; i < 16; i++)
- WRITE_CODE(digest[yuvIdx][i], 8, "picture_md5");
+ WRITE_CODE(m_digest[yuvIdx][i], 8, "picture_md5");
}
- else if (method == CRC)
+ else if (m_method == CRC)
{
- uint32_t val = (digest[yuvIdx][0] << 8) + digest[yuvIdx][1];
+ uint32_t val = (m_digest[yuvIdx][0] << 8) + m_digest[yuvIdx][1];
WRITE_CODE(val, 16, "picture_crc");
}
- else if (method == CHECKSUM)
+ else if (m_method == CHECKSUM)
{
- uint32_t val = (digest[yuvIdx][0] << 24) + (digest[yuvIdx][1] << 16) + (digest[yuvIdx][2] << 8) + digest[yuvIdx][3];
+ uint32_t val = (m_digest[yuvIdx][0] << 24) + (m_digest[yuvIdx][1] << 16) + (m_digest[yuvIdx][2] << 8) + m_digest[yuvIdx][3];
WRITE_CODE(val, 32, "picture_checksum");
}
}
More information about the x265-commits
mailing list