Skip to content

Commit

Permalink
small decoder optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
aikiriao committed Jun 15, 2024
1 parent 66e95b0 commit 9b9edca
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions libs/srla_coder/src/srla_coder.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,20 @@ static uint32_t Rice_GetCode(struct BitStream *stream, uint32_t k)
\
SRLA_ASSERT(stream != NULL);\
SRLA_ASSERT(uval != NULL);\
SRLA_ASSERT(k1 == (k2 + 1));\
\
/* 商部の取得 */\
/* ランレングスが0の場合が多いため1bit先に取得してチェック */\
BitReader_GetBits(stream, &__quot, 1);\
BitReader_GetZeroRunLength(stream, &__quot);\
\
if (__quot) {\
if (!__quot) {\
/* ランレングス=0で1段目のパラメータで復号 */\
BitReader_GetBits(stream, uval, k1);\
break;\
}\
\
/* ランレングスが1以上ならば改めてランレングス取得 */\
BitReader_GetZeroRunLength(stream, &__quot);\
/* ランレングスが1以上ならば2段目のパラメータで復号 */\
BitReader_GetBits(stream, uval, k2);\
(*uval) += (1U << k1) + (__quot << k2);\
(*uval) |= ((__quot + 1) << k2);\
} while (0);
#else
static void RecursiveRice_GetCode(struct BitStream *stream, uint32_t k1, uint32_t k2, uint32_t *uval)
Expand All @@ -238,21 +237,21 @@ static void RecursiveRice_GetCode(struct BitStream *stream, uint32_t k1, uint32_

SRLA_ASSERT(stream != NULL);
SRLA_ASSERT(uval != NULL);
SRLA_ASSERT(k1 == (k2 + 1));

/* 商部の取得 */
/* ランレングスが0の場合が多いため1bit先に取得してチェック */
BitReader_GetBits(stream, &quot, 1);
BitReader_GetZeroRunLength(stream, &quot);

if (quot) {
if (!quot) {
/* ランレングス=0で1段目のパラメータで復号 */
BitReader_GetBits(stream, uval, k1);
return;
}

/* ランレングスが1以上ならば改めてランレングス取得 */
BitReader_GetZeroRunLength(stream, &quot);
/* ランレングスが1以上ならば2段目のパラメータで復号 */

BitReader_GetBits(stream, uval, k2);
(*uval) += (1U << k1) + (quot << k2);
(*uval) |= ((quot + 1) << k2);
}
#endif

Expand Down

0 comments on commit 9b9edca

Please sign in to comment.