Exemple #1
0
        unsafe static void fp16conv()
        {
            const int hdsz = 0x10;

            byte[] ff16 = File.ReadAllBytes(@"E:\r\cud\ncnn\src\bin\Release\400x532x3xfp16.ppp");
            int    lly  = ff16.Length / 2;

            byte[] otbuf = new byte[hdsz + lly];

            fixed(byte *srcbb = &ff16[0])
            {
                ushort *f = (ushort *)srcbb;

                for (int i = 0; i < lly; i++)
                {
                    uint zita = f[i];
                    zita = ((zita & 0x8000) << 16) | (((zita & 0x7c00) + 0x1C000) << 13) | ((zita & 0x03FF) << 13);

                    bswap bs = new bswap();
                    bs.buint = zita;
                    float bsf = bs.bfloat * 255.0f;

                    if (bsf < 0)
                    {
                        Console.WriteLine(bsf);
                        Console.ReadKey();
                    }

                    otbuf[hdsz + i] = (byte)((uint)bsf);
                }
            }

            File.WriteAllBytes("dxp3.pgm", otbuf);
        }
Exemple #2
0
        public static bswap CountInd(string g)
        {
            bswap bs = new bswap();

            for (int i = 0; i < 256; i++)
            {
                if (g[i * 2] != ' ' || g[i * 2 + 1] != ' ')
                {
                    if (g[i * 2] == '-')
                    {
                        bs.a = (byte)(i + 1);
                        bs.b = 1;
                        return(bs);
                    }
                    else
                    {
                        bs.a = (byte)(i);
                        return(bs);
                    }
                }
            }

            return(bs);
        }
Exemple #3
0
        public static StringGroup Parse(string[] g, int start, int endpos)
        {
            if (endpos < 0)
            {
                endpos = g.Length;
            }

            qStringGroup root  = new qStringGroup(-2);
            qStringGroup moth  = root;
            qStringGroup lastt = root;

            int curind = qStringGroup.CountInd(g[start]).a;

            for (int i = start; i < endpos; i++)
            {
                bswap nxindbs = qStringGroup.CountInd(g[i]);
                int   nxind   = nxindbs.a;

                g[i] = g[i].Substring(nxind * 2);
                qStringGroup nxsg = new qStringGroup(i);

                if (nxind > curind)
                {
                    moth = lastt;
                }
                else if (nxind < curind)
                {
                    moth = qStringGroup.GetNParent(moth, curind - nxind);
                }


                if (nxindbs.b == 1)
                {
                    if (moth.isArrayHead)
                    {
                        moth = moth.parent;
                    }

                    moth = qStringGroup.MakeZu(moth, nxsg);
                }
                else
                {
                    moth.substr.Add(nxsg);
                    qStringGroup.setmoth(moth, nxsg);
                }



                lastt  = nxsg;
                curind = nxind;
            }

            if (root.substr.Count == 1)
            {
                var vroot = root.substr[0];
                root.substr = null;
                root        = vroot;
                root.parent = null;
            }

            StringGroup Realroot = new StringGroup(g, root.topstr);

            q2str(g, root, Realroot);

            return(Realroot);
        }