[FFmpeg-devel,GSOC,2/3] lavc/cfhd:corrected decompanding for table 9 used in cfhd

Submitted by Gagandeep Singh on Sept. 6, 2018, 6:06 a.m.

Details

Message ID CAOi=zRvQCN-VzO5zj6jQw1+KJO_MFSKNvxw5QcHFdDQcWrEguA@mail.gmail.com
State New
Headers show

Commit Message

Gagandeep Singh Sept. 6, 2018, 6:06 a.m.
On Fri, Aug 17, 2018 at 11:34 AM Gagandeep Singh <deepgagan231197@gmail.com>
wrote:

>
>
> On Thu, Aug 16, 2018 at 2:37 AM Kieran Kunhya <kierank@obe.tv> wrote:
>
>> On Tue, 14 Aug 2018 at 08:43 Gagandeep Singh <deepgagan231197@gmail.com>
>> wrote:
>>
>> > Second patch for fixing decompanding in table 9.
>> >
>> > Gagandeep Singh
>> >
>>
>> Seems ok
>>
>> Kieran
>>
>
> Thanks!!
>
> Gagandeep Singh
>

Hi,
This patch is to be applied along with the other updated patches.

Thanks
Gagandeep Singh

> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>

Comments

Michael Niedermayer Sept. 6, 2018, 8:57 a.m.
On Thu, Sep 06, 2018 at 11:36:22AM +0530, Gagandeep Singh wrote:
> On Fri, Aug 17, 2018 at 11:34 AM Gagandeep Singh <deepgagan231197@gmail.com>
> wrote:
> 
> >
> >
> > On Thu, Aug 16, 2018 at 2:37 AM Kieran Kunhya <kierank@obe.tv> wrote:
> >
> >> On Tue, 14 Aug 2018 at 08:43 Gagandeep Singh <deepgagan231197@gmail.com>
> >> wrote:
> >>
> >> > Second patch for fixing decompanding in table 9.
> >> >
> >> > Gagandeep Singh
> >> >
> >>
> >> Seems ok
> >>
> >> Kieran
> >>
> >
> > Thanks!!
> >
> > Gagandeep Singh
> >
> 
> Hi,
> This patch is to be applied along with the other updated patches.
> 
> Thanks
> Gagandeep Singh
> 
> > _______________________________________________
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel@ffmpeg.org
> >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> >

>  cfhd.c |   25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 44fe9de4bb44ecd39071a9e543b7f8a718a41915  decompanding_fix.patch
> From 4f0c812aaf50738e579bde0bb12b9f2391eb15e5 Mon Sep 17 00:00:00 2001
> From: Gagandeep Singh <deepgagan231197@gmail.com>
> Date: Thu, 6 Sep 2018 11:12:16 +0530
> Subject: [GSOC][PATCH 2/3] lavc/cfhd: correct decompanding for old codebook (table 9)
> 
> ---
>  libavcodec/cfhd.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
> index 3929b54f31..e78fa81655 100644
> --- a/libavcodec/cfhd.c
> +++ b/libavcodec/cfhd.c
> @@ -114,7 +114,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;

this can be simplified:
level = (level<<2) - 3*54;

thx


[...]

Patch hide | download patch | download mbox

From 4f0c812aaf50738e579bde0bb12b9f2391eb15e5 Mon Sep 17 00:00:00 2001
From: Gagandeep Singh <deepgagan231197@gmail.com>
Date: Thu, 6 Sep 2018 11:12:16 +0530
Subject: [GSOC][PATCH 2/3] lavc/cfhd: correct decompanding for old codebook (table 9)

---
 libavcodec/cfhd.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index 3929b54f31..e78fa81655 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -114,7 +114,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))) *
-- 
2.17.1