[FFmpeg-devel] lavc/cfhd: added correct decompanding to codebook0

Submitted by Gagandeep Singh on June 21, 2018, 10:33 a.m.

Details

Message ID 20180621103310.13097-1-deepgagan231197@gmail.com
State New
Headers show

Commit Message

Gagandeep Singh June 21, 2018, 10:33 a.m.
output of samples using codebook 0 improved
---
 libavcodec/cfhd.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer June 21, 2018, 5:34 p.m.
On Thu, Jun 21, 2018 at 04:03:10PM +0530, Gagandeep Singh wrote:
> output of samples using codebook 0 improved
> ---
>  libavcodec/cfhd.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)

this depends on your previous patch, you should mention this, because
people will not know how to apply this otherwise (it doesnt apply to
master without the previous patch)

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index bf80cb9c07..226b135c07 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -115,7 +115,30 @@  static inline int dequant_and_decompand(int level, int quantisation, int codeboo
 {
     if (lossless)
         return level;
-    if (codebook == 0 || codebook == 1) {
+    if (codebook == 0) {
+        if (level >= 40 && level < 264) {
+            if (level >= 54) {
+                level  -= 54;
+                level <<= 2;
+                level  += 54;
+            }
+            level  -= 40;
+            level <<= 2;
+            level  += 40;
+        } else if (level <= -40) {
+            level = -level;
+            if (level >= 54) {
+                level  -= 54;
+                level <<= 2;
+                level  += 54;
+            }
+            level  -= 40;
+            level <<= 2;
+            level  += 40;
+            level   = -level;
+        }
+        return level * quantisation;
+    } else if (codebook == 1) {
         int64_t abslevel = abs(level);
         if (level < 264)
             return (abslevel + ((768 * abslevel * abslevel * abslevel) / (255 * 255 * 255))) *