Skip to content

Commit

Permalink
simplify decoding code.
Browse files Browse the repository at this point in the history
  • Loading branch information
aikiriao committed Jun 18, 2024
1 parent 622e2b7 commit e7c748e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions libs/srla_coder/src/srla_coder.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,18 @@ static uint32_t Rice_GetCode(struct BitStream *stream, uint32_t k)
#if defined(SRLACODER_USE_MACROS)
#define RecursiveRice_GetCode(stream, k1, k2, uval)\
do {\
uint32_t __quot;\
uint32_t quot__;\
\
SRLA_ASSERT((stream) != NULL);\
SRLA_ASSERT((uval) != NULL);\
SRLA_ASSERT((k1) == ((k2) + 1));\
\
/* 商部の取得 */\
BitReader_GetZeroRunLength((stream), &__quot);\
BitReader_GetZeroRunLength((stream), &quot__);\
\
/* 剰余部の取得 */\
BitReader_GetBits((stream), (uval), !(__quot) ? (k1) : (k2));\
__quot = !(__quot) ? ~0U : __quot;\
(*uval) |= ((__quot + 1) << (k2));\
BitReader_GetBits(stream, uval, (k2) + !(quot__));\
(*uval) |= ((quot__ + !!(quot__)) << (k2));\
} while (0);
#else
static void RecursiveRice_GetCode(struct BitStream *stream, uint32_t k1, uint32_t k2, uint32_t *uval)
Expand All @@ -238,9 +237,8 @@ static void RecursiveRice_GetCode(struct BitStream *stream, uint32_t k1, uint32_
BitReader_GetZeroRunLength(stream, &quot);

/* 剰余部の取得 */
BitReader_GetBits(stream, uval, !quot ? k1 : k2);
quot = !(quot) ? ~0U : quot;
(*uval) |= ((quot + 1) << (k2));
BitReader_GetBits(stream, uval, k2 + !(quot));
(*uval) |= ((quot + !!(quot)) << (k2));
}
#endif

Expand Down

0 comments on commit e7c748e

Please sign in to comment.