[x265] [PATCH] entropy: improve exp-Golomb code by CLZ
Ximing Cheng
chengximing1989 at foxmail.com
Tue Nov 10 17:56:01 CET 2015
# HG changeset patch
# User Ximing Cheng <ximingcheng at tencent.com>
# Date 1447174544 -28800
# Wed Nov 11 00:55:44 2015 +0800
# Node ID 792deb89b9d55be3f5402e03e749815caf80f93c
# Parent f11b17b4656a85a15dc82fd04485fbf920848e4d
entropy: improve exp-Golomb code by CLZ
diff -r f11b17b4656a -r 792deb89b9d5 source/common/bitstream.cpp
--- a/source/common/bitstream.cpp Fri Nov 06 16:04:23 2015 +0800
+++ b/source/common/bitstream.cpp Wed Nov 11 00:55:44 2015 +0800
@@ -1,5 +1,6 @@
#include "common.h"
#include "bitstream.h"
+#include "threading.h"
using namespace X265_NS;
@@ -112,16 +113,13 @@
void SyntaxElementWriter::writeUvlc(uint32_t code)
{
- uint32_t length = 1;
- uint32_t temp = ++code;
+ ++code;
- X265_CHECK(temp, "writing -1 code, will cause infinite loop\n");
+ X265_CHECK(code, "writing -1 code, will cause infinite loop\n");
- while (1 != temp)
- {
- temp >>= 1;
- length += 2;
- }
+ unsigned long idx;
+ CLZ(idx, code);
+ uint32_t length = (uint32_t)idx * 2 + 1;
// Take care of cases where length > 32
m_bitIf->write(0, length >> 1);
More information about the x265-devel
mailing list