From 5f732126c331711cf80cc119fa675c9d3fc11d64 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Wed, 10 Sep 2014 16:06:19 +0300 Subject: [PATCH] Add cabac bit costs float table. --- src/rdo.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/rdo.h | 2 ++ 2 files changed, 71 insertions(+) diff --git a/src/rdo.c b/src/rdo.c index 78106fe2..5ffe95a6 100644 --- a/src/rdo.c +++ b/src/rdo.c @@ -57,6 +57,75 @@ const uint32_t entropy_bits[128] = 0x0050e, 0x29af6, 0x004cc, 0x2a497, 0x0048d, 0x2ae35, 0x00451, 0x2b7d6, 0x00418, 0x2c176, 0x003e2, 0x2cb15, 0x003af, 0x2d4b5, 0x0037f, 0x2de55 }; +// Entropy bits scaled so that 50% probability yields 1 bit. +const float f_entropy_bits[128] = +{ + 1.0, 1.0, + 0.92852783203125, 1.0751953125, + 0.86383056640625, 1.150390625, + 0.80499267578125, 1.225555419921875, + 0.751251220703125, 1.300750732421875, + 0.702056884765625, 1.375946044921875, + 0.656829833984375, 1.451141357421875, + 0.615203857421875, 1.526336669921875, + 0.576751708984375, 1.601531982421875, + 0.54119873046875, 1.67669677734375, + 0.508209228515625, 1.75189208984375, + 0.47760009765625, 1.82708740234375, + 0.449127197265625, 1.90228271484375, + 0.422637939453125, 1.97747802734375, + 0.39788818359375, 2.05267333984375, + 0.37481689453125, 2.127838134765625, + 0.353240966796875, 2.203033447265625, + 0.33306884765625, 2.278228759765625, + 0.31414794921875, 2.353424072265625, + 0.29644775390625, 2.428619384765625, + 0.279815673828125, 2.5037841796875, + 0.26422119140625, 2.5789794921875, + 0.24957275390625, 2.6541748046875, + 0.235809326171875, 2.7293701171875, + 0.222869873046875, 2.8045654296875, + 0.210662841796875, 2.879730224609375, + 0.199188232421875, 2.954925537109375, + 0.188385009765625, 3.030120849609375, + 0.17822265625, 3.105316162109375, + 0.168609619140625, 3.180511474609375, + 0.1595458984375, 3.255706787109375, + 0.1510009765625, 3.33087158203125, + 0.1429443359375, 3.40606689453125, + 0.135345458984375, 3.48126220703125, + 0.128143310546875, 3.55645751953125, + 0.121368408203125, 3.63165283203125, + 0.114959716796875, 3.706817626953125, + 0.10888671875, 3.782012939453125, + 0.1031494140625, 3.857208251953125, + 0.09771728515625, 3.932403564453125, + 0.09259033203125, 4.007598876953125, + 0.0877685546875, 4.082794189453125, + 0.083160400390625, 4.157958984375, + 0.078826904296875, 4.233154296875, + 0.07470703125, 4.308349609375, + 0.070831298828125, 4.383544921875, + 0.067138671875, 4.458740234375, + 0.06365966796875, 4.533935546875, + 0.06036376953125, 4.609100341796875, + 0.057220458984375, 4.684295654296875, + 0.05426025390625, 4.759490966796875, + 0.05145263671875, 4.834686279296875, + 0.048797607421875, 4.909881591796875, + 0.046295166015625, 4.985076904296875, + 0.043914794921875, 5.06024169921875, + 0.0416259765625, 5.13543701171875, + 0.03948974609375, 5.21063232421875, + 0.0374755859375, 5.285858154296875, + 0.035552978515625, 5.360992431640625, + 0.033721923828125, 5.43621826171875, + 0.031982421875, 5.51141357421875, + 0.03033447265625, 5.586578369140625, + 0.028778076171875, 5.661773681640625, + 0.027313232421875, 5.736968994140625, +}; + /** * \brief Helper function to find intra merge costs diff --git a/src/rdo.h b/src/rdo.h index 5f0c7514..5b969418 100644 --- a/src/rdo.h +++ b/src/rdo.h @@ -61,5 +61,7 @@ uint32_t get_coded_level ( encoder_state * encoder_state, double* coded_cost, do uint32_t c1_idx, uint32_t c2_idx, int32_t q_bits,double temp, int8_t last, int8_t type); +extern const float f_entropy_bits[128]; +#define CTX_ENTROPY_FBITS(ctx,val) f_entropy_bits[(ctx)->uc_state ^ val] #endif