[FFmpeg-devel] [PATCH 1/2] Bink version 'b' video decoder

Peter Ross pross
Fri Feb 11 12:45:51 CET 2011


On Thu, Feb 10, 2011 at 08:16:18PM +0100, Vitor Sessak wrote:
> On 02/10/2011 05:26 AM, Peter Ross wrote:
> >On Wed, Feb 09, 2011 at 09:54:00PM +0100, Vitor Sessak wrote:
> >>On 02/09/2011 01:04 PM, Peter Ross wrote:
> >>>Based on original patch by Kostya Shishkov
> >>>---
> >>>  libavcodec/bink.c     |  340 ++++++++++++++++++++++++++++++++++++++++++++++---
> >>>  libavcodec/binkdata.h |   41 ++++++
> >>>  2 files changed, 364 insertions(+), 17 deletions(-)
> >>>
> >>>diff --git a/libavcodec/bink.c b/libavcodec/bink.c
> >>>index 64a10b7..32330fe 100644
> >>
> >>[...]
> >>
> >>>+/**
> >>>+ * Caclulate quantization tables for version b
> >>>+ */
> >>>+static av_cold void binkb_calc_quant()
> >>>+{
> >>>+    float s[64];
> >>>+    int i, j;
> >>>+
> >>>+    for (j = 0; j<   8; j++) {
> >>>+        for (i = 0; i<   8; i++) {
> >>>+            if (j&&   j != 4)
> >>>+               if (i&&   i != 4)
> >>>+                   s[j*8 + i] = cos(j * M_PI/16.0f) * cos(i * M_PI/16.0f) * 2.0f;
> >>>+               else
> >>>+                   s[j*8 + i] = cos(j * M_PI/16.0f) * sqrt(2.0f);
> >>>+            else
> >>>+               if (i&&   i != 4)
> >>>+                   s[j*8 + i] = cos(i * M_PI/16.0f) * sqrt(2.0f);
> >>>+               else
> >>>+                   s[j*8 + i] = 1.0f;
> >>>+        }
> >>>+    }
> >>>+
> >>>+    for (j = 0; j<   16; j++) {
> >>>+        for (i = 0; i<   64; i++) {
> >>>+            binkb_intra_quant[j][i] = (1L<<12) * binkb_intra_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
> >>>+            binkb_inter_quant[j][i] = (1L<<12) * binkb_inter_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
> >>>+        }
> >>>+    }
> >>>+}
> >>
> >>Can you run the following test:
> >>
> >>
> >>     for (j = 0; j<   16; j++) {
> >>         for (i = 0; i<   64; i++) {
> >>             int x = ( 1 + (1<<20))/((float)(1<<20))) * (1L<<12) *
> >>binkb_intra_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
> >>             int y = (-1 + (1<<20))/((float)(1<<20))) * (1L<<12) *
> >>binkb_intra_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
> >>             if (i != y)
> >>                 av_log(NULL, "%d %d\n", i, j);
> >>         }
> >>    }
> >>
> >>and analogously for binkb_inter_quant? If there are any values that
> >>are not stable to fp rounding, it is enough to hardcode them...
> >
> >Hard coding the quant tables will add 8k to libavcodec. Anyway heres the output:
> 
> I was thinking more of hardcoding only the values that were printed,
> but I didn't expect them to be so many.
> 
> >av_log(0,0, "intra\n");
> >for (j = 0; j<  16; j++) {
> >     for (i = 0; i<  64; i++) {
> >         int x = ( 1 + (1<<20))/((float)(1<<20)) * (1L<<12) * binkb_intra_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
> >         int y = (-1 + (1<<20))/((float)(1<<20)) * (1L<<12) * binkb_intra_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
> >         if (x != y)
> >             av_log(0, 0, "%d %d\n", i, j);
> >     }
> >}
> >
> >av_log(0,0, "inter\n");
> >for (j = 0; j<  16; j++) {
> >     for (i = 0; i<  64; i++) {
> >         int x = ( 1 + (1<<20))/((float)(1<<20)) * (1L<<12) * binkb_inter_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
> >         int y = (-1 + (1<<20))/((float)(1<<20)) * (1L<<12) * binkb_inter_seed[i] * binkb_num[j]/(float)binkb_den[j] * s[i];
> >         if (x != y)
> >             av_log(0, 0, "%d %d\n", i, j);
> >     }
> >}
> 
> What if you use doubles and replace 1<<20 by 1<<48?

There are less.

intra
0 0 (x:65536 y:65535)
4 0 (x:65536 y:65535)
32 0 (x:118784 y:118783)
36 0 (x:151552 y:151551)
0 3 (x:131072 y:131071)
4 3 (x:131072 y:131071)
32 3 (x:237568 y:237567)
36 3 (x:303104 y:303103)
0 6 (x:196608 y:196607)
4 6 (x:196608 y:196607)
32 6 (x:356352 y:356351)
36 6 (x:454656 y:454655)
0 7 (x:229376 y:229375)
4 7 (x:229376 y:229375)
32 7 (x:415744 y:415743)
36 7 (x:530432 y:530431)
0 8 (x:262144 y:262143)
4 8 (x:262144 y:262143)
32 8 (x:475136 y:475135)
36 8 (x:606208 y:606207)
0 9 (x:294912 y:294911)
4 9 (x:294912 y:294911)
32 9 (x:534528 y:534527)
36 9 (x:681984 y:681983)
0 10 (x:327680 y:327679)
4 10 (x:327680 y:327679)
32 10 (x:593920 y:593919)
36 10 (x:757760 y:757759)
0 11 (x:393216 y:393215)
4 11 (x:393216 y:393215)
32 11 (x:712704 y:712703)
36 11 (x:909312 y:909311)
0 12 (x:458752 y:458751)
4 12 (x:458752 y:458751)
32 12 (x:831488 y:831487)
36 12 (x:1060864 y:1060863)
0 13 (x:524288 y:524287)
4 13 (x:524288 y:524287)
32 13 (x:950272 y:950271)
36 13 (x:1212416 y:1212415)
0 14 (x:589824 y:589823)
4 14 (x:589824 y:589823)
32 14 (x:1069056 y:1069055)
36 14 (x:1363968 y:1363967)
0 15 (x:655360 y:655359)
4 15 (x:655360 y:655359)
32 15 (x:1187840 y:1187839)
36 15 (x:1515520 y:1515519)

inter
0 0 (x:65536 y:65535)
4 0 (x:73728 y:73727)
32 0 (x:94208 y:94207)
36 0 (x:98304 y:98303)
4 1 (x:98304 y:98303)
36 1 (x:131072 y:131071)
4 2 (x:122880 y:122879)
36 2 (x:163840 y:163839)
0 3 (x:131072 y:131071)
4 3 (x:147456 y:147455)
32 3 (x:188416 y:188415)
36 3 (x:196608 y:196607)
4 4 (x:172032 y:172031)
36 4 (x:229376 y:229375)
4 5 (x:196608 y:196607)
36 5 (x:262144 y:262143)
0 6 (x:196608 y:196607)
4 6 (x:221184 y:221183)
32 6 (x:282624 y:282623)
36 6 (x:294912 y:294911)
0 7 (x:229376 y:229375)
4 7 (x:258048 y:258047)
32 7 (x:329728 y:329727)
36 7 (x:344064 y:344063)
0 8 (x:262144 y:262143)
4 8 (x:294912 y:294911)
32 8 (x:376832 y:376831)
36 8 (x:393216 y:393215)
0 9 (x:294912 y:294911)
4 9 (x:331776 y:331775)
32 9 (x:423936 y:423935)
36 9 (x:442368 y:442367)
0 10 (x:327680 y:327679)
4 10 (x:368640 y:368639)
32 10 (x:471040 y:471039)
36 10 (x:491520 y:491519)
0 11 (x:393216 y:393215)
4 11 (x:442368 y:442367)
32 11 (x:565248 y:565247)
36 11 (x:589824 y:589823)
0 12 (x:458752 y:458751)
4 12 (x:516096 y:516095)
32 12 (x:659456 y:659455)
36 12 (x:688128 y:688127)
0 13 (x:524288 y:524287)
4 13 (x:589824 y:589823)
32 13 (x:753664 y:753663)
36 13 (x:786432 y:786431)
0 14 (x:589824 y:589823)
4 14 (x:663552 y:663551)
32 14 (x:847872 y:847871)
36 14 (x:884736 y:884735)
0 15 (x:655360 y:655359)
4 15 (x:737280 y:737279)
32 15 (x:942080 y:942079)
36 15 (x:983040 y:983039)

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110211/1f24903b/attachment.pgp>



More information about the ffmpeg-devel mailing list