Beispiel #1
0
        public void UpsampleH(nj_component_t c)
        {
            int xmax = c.width - 3;

            byte[] outv;
            int    lin = 0, lout = 0;
            int    x, y;

            outv = new byte[(c.width * c.height) << 1];
            if (outv == null)
            {
                njThrow(nj_result_t.NJ_OUT_OF_MEM);
            }
            for (y = c.height; y != 0; --y)
            {
                outv[lout]     = CF(CF2A * c.pixels[lin] + CF2B * c.pixels[lin + 1]);
                outv[lout + 1] = CF(CF3X * c.pixels[lin] + CF3Y * c.pixels[lin + 1] + CF3Z * c.pixels[lin + 2]);
                outv[lout + 2] = CF(CF3A * c.pixels[lin] + CF3B * c.pixels[lin + 1] + CF3C * c.pixels[lin + 2]);
                for (x = 0; x < xmax; ++x)
                {
                    outv[lout + (x << 1) + 3] = CF(CF4A * c.pixels[lin + x] + CF4B * c.pixels[lin + x + 1] + CF4C * c.pixels[lin + x + 2] + CF4D * c.pixels[lin + x + 3]);
                    outv[lout + (x << 1) + 4] = CF(CF4D * c.pixels[lin + x] + CF4C * c.pixels[lin + x + 1] + CF4B * c.pixels[lin + x + 2] + CF4A * c.pixels[lin + x + 3]);
                }
                lin            += c.stride;
                lout           += c.width << 1;
                outv[lout + -3] = CF(CF3A * c.pixels[lin - 1] + CF3B * c.pixels[lin - 2] + CF3C * c.pixels[lin - 3]);
                outv[lout + -2] = CF(CF3X * c.pixels[lin - 1] + CF3Y * c.pixels[lin - 2] + CF3Z * c.pixels[lin - 3]);
                outv[lout + -1] = CF(CF2A * c.pixels[lin - 1] + CF2B * c.pixels[lin - 2]);
            }
            c.width <<= 1;
            c.stride  = c.width;
            c.pixels  = outv;
        }
Beispiel #2
0
        public void UpsampleV(nj_component_t c)
        {
            int w = c.width, s1 = c.stride, s2 = s1 + s1;

            byte[] outv;
            int    cin, cout;
            int    x, y;

            outv = new byte[(c.width * c.height) << 1];
            if (outv == null)
            {
                njThrow(nj_result_t.NJ_OUT_OF_MEM);
            }
            for (x = 0; x < w; ++x)
            {
                cin        = x;
                cout       = x;
                outv[cout] = CF(CF2A * c.pixels[cin] + CF2B * c.pixels[cin + s1]); cout += w;
                outv[cout] = CF(CF3X * c.pixels[cin] + CF3Y * c.pixels[cin + s1] + CF3Z * c.pixels[cin + s2]); cout += w;
                outv[cout] = CF(CF3A * c.pixels[cin] + CF3B * c.pixels[cin + s1] + CF3C * c.pixels[cin + s2]); cout += w;
                cin       += s1;
                for (y = c.height - 3; y != 0; --y)
                {
                    outv[cout] = CF(CF4A * c.pixels[cin + -s1] + CF4B * c.pixels[cin] + CF4C * c.pixels[cin + s1] + CF4D * c.pixels[cin + s2]); cout += w;
                    outv[cout] = CF(CF4D * c.pixels[cin + -s1] + CF4C * c.pixels[cin] + CF4B * c.pixels[cin + s1] + CF4A * c.pixels[cin + s2]); cout += w;
                    cin       += s1;
                }
                cin       += s1;
                outv[cout] = CF(CF3A * c.pixels[cin] + CF3B * c.pixels[cin - s1] + CF3C * c.pixels[cin - s2]); cout += w;
                outv[cout] = CF(CF3X * c.pixels[cin] + CF3Y * c.pixels[cin - s1] + CF3Z * c.pixels[cin - s2]); cout += w;
                outv[cout] = CF(CF2A * c.pixels[cin] + CF2B * c.pixels[cin - s1]);
            }
            c.height <<= 1;
            c.stride   = c.width;
            c.pixels   = outv;
        }
Beispiel #3
0
        public void DecodeBlock(nj_component_t c, int outv)
        {
            byte discard = 0;
            byte code = 0;
            int  value, coef = 0;

            nj.block    = new int[64];
            c.dcpred   += GetVLC(nj.vlctab[c.dctabsel], ref discard);
            nj.block[0] = (c.dcpred) * nj.qtab[c.qtsel][0];
            do
            {
                value = GetVLC(nj.vlctab[c.actabsel], ref code);
                if (code == 0)
                {
                    break;             // EOB
                }
                if ((code & 0x0F) == 0 && (code != 0xF0))
                {
                    njThrow(nj_result_t.NJ_SYNTAX_ERROR);
                }
                coef += (code >> 4) + 1;
                if (coef > 63)
                {
                    njThrow(nj_result_t.NJ_SYNTAX_ERROR);
                }
                nj.block[(int)njZZ[coef]] = value * nj.qtab[c.qtsel][coef];
            } while (coef < 63);
            for (coef = 0; coef < 64; coef += 8)
            {
                njRowIDCT(nj.block, coef);
            }
            for (coef = 0; coef < 8; ++coef)
            {
                njColIDCT(nj.block, coef, c.pixels, outv + coef, c.stride);
            }
        }