From de6faf623d54d64ac69bc876749fe567001ef632 Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Thu, 16 Jan 2014 17:13:48 +0200 Subject: [PATCH] Imported entropy bits array from HM and added macro to access it --- src/cabac.h | 2 ++ src/context.c | 14 ++++++++++++++ src/context.h | 2 ++ src/encoder.c | 4 ++-- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/cabac.h b/src/cabac.h index 7f7b98c5..c0b9f4cd 100644 --- a/src/cabac.h +++ b/src/cabac.h @@ -75,6 +75,8 @@ void cabac_write_unary_max_symbol_ep(cabac_data *data, unsigned symbol, unsigned #define CTX_MPS(ctx) (ctx->uc_state & 1) #define CTX_UPDATE_LPS(ctx) { (ctx)->uc_state = g_auc_next_state_lps[ (ctx)->uc_state ]; } #define CTX_UPDATE_MPS(ctx) { (ctx)->uc_state = g_auc_next_state_mps[ (ctx)->uc_state ]; } +#define CTX_ENTROPY_BITS(ctx,val) entropy_bits[(ctx)->uc_state ^ val] + #ifdef VERBOSE #define CABAC_BIN(data, value, name) { \ uint32_t prev_state = (data)->ctx->uc_state; \ diff --git a/src/context.c b/src/context.c index f58433bd..ee9429c1 100644 --- a/src/context.c +++ b/src/context.c @@ -240,3 +240,17 @@ int32_t context_get_sig_ctx_inc(int32_t pattern_sig_ctx, uint32_t scan_idx, int3 return (( texture_type == 0 && ((pos_x>>2) + (pos_y>>2)) > 0 ) ? 3 : 0) + offset + cnt; } +/* + * Entropy bits to estimate coded bits in RDO / RDOQ (From HM 12.0) + */ +const uint32_t entropy_bits[128] = +{ + 0x08000, 0x08000, 0x076da, 0x089a0, 0x06e92, 0x09340, 0x0670a, 0x09cdf, 0x06029, 0x0a67f, 0x059dd, 0x0b01f, 0x05413, 0x0b9bf, 0x04ebf, 0x0c35f, + 0x049d3, 0x0ccff, 0x04546, 0x0d69e, 0x0410d, 0x0e03e, 0x03d22, 0x0e9de, 0x0397d, 0x0f37e, 0x03619, 0x0fd1e, 0x032ee, 0x106be, 0x02ffa, 0x1105d, + 0x02d37, 0x119fd, 0x02aa2, 0x1239d, 0x02836, 0x12d3d, 0x025f2, 0x136dd, 0x023d1, 0x1407c, 0x021d2, 0x14a1c, 0x01ff2, 0x153bc, 0x01e2f, 0x15d5c, + 0x01c87, 0x166fc, 0x01af7, 0x1709b, 0x0197f, 0x17a3b, 0x0181d, 0x183db, 0x016d0, 0x18d7b, 0x01595, 0x1971b, 0x0146c, 0x1a0bb, 0x01354, 0x1aa5a, + 0x0124c, 0x1b3fa, 0x01153, 0x1bd9a, 0x01067, 0x1c73a, 0x00f89, 0x1d0da, 0x00eb7, 0x1da79, 0x00df0, 0x1e419, 0x00d34, 0x1edb9, 0x00c82, 0x1f759, + 0x00bda, 0x200f9, 0x00b3c, 0x20a99, 0x00aa5, 0x21438, 0x00a17, 0x21dd8, 0x00990, 0x22778, 0x00911, 0x23118, 0x00898, 0x23ab8, 0x00826, 0x24458, + 0x007ba, 0x24df7, 0x00753, 0x25797, 0x006f2, 0x26137, 0x00696, 0x26ad7, 0x0063f, 0x27477, 0x005ed, 0x27e17, 0x0059f, 0x287b6, 0x00554, 0x29156, + 0x0050e, 0x29af6, 0x004cc, 0x2a497, 0x0048d, 0x2ae35, 0x00451, 0x2b7d6, 0x00418, 0x2c176, 0x003e2, 0x2cb15, 0x003af, 0x2d4b5, 0x0037f, 0x2de55 +}; diff --git a/src/context.h b/src/context.h index dd2a6ab0..8c949c8b 100644 --- a/src/context.h +++ b/src/context.h @@ -214,4 +214,6 @@ static const uint8_t INIT_ABS_FLAG[3][6] = }; +const uint32_t entropy_bits[ 128 ]; + #endif diff --git a/src/encoder.c b/src/encoder.c index 7474dfa7..d872b9e7 100644 --- a/src/encoder.c +++ b/src/encoder.c @@ -633,7 +633,7 @@ void encode_seq_parameter_set(encoder_control* encoder) //TODO: VUI? //encode_VUI(encoder); - WRITE_U(encoder->stream, 0, 1, "sps_extension_flag"); + WRITE_U(encoder->stream, 0, 1, "sps_extension_flag"); } void encode_vid_parameter_set(encoder_control* encoder) @@ -668,7 +668,7 @@ void encode_vid_parameter_set(encoder_control* encoder) //IF timing info //END IF - WRITE_U(encoder->stream, 0, 1, "vps_extension_flag"); + WRITE_U(encoder->stream, 0, 1, "vps_extension_flag"); } void encode_VUI(encoder_control* encoder)