Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly x86 > Re: MMX speedup...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 8 Topic 4646 of 4824
Post > Topic >>

Re: MMX speedup for Floyd Steinberg error diffusion

by rep_movsd <spamtrap@[EMAIL PROTECTED] > May 13, 2008 at 05:27 AM

Hi

In the meantime, the diffuse function turned into the fastest of the 5
functions that are called for each frame.

Now I went on to optimize my octree quantizer.
It consists of adding each pixel color to an octree and pruning it
everytime the number of leaves get > than the number of desired
colors.

Since each pixel involves walking down the tree until its leaf is
reached, i reasoned that it may make sense to process multiple pixels
of the same color at a time (i. e. sort the image beforehand, so the
pixels are clustered ).

However even with a radix sort with highly unrolled loops, the
overhead isnt worth the benefit.
I tried using a hash map, gathering pixel color counts for each
scanline, but still too slow.

Amazingly, the following :

    ULONG clr = *pDIB, cnt = 0;
    for(int y = 0; y < uHeight; ++y)
    {
        for(int x = 0; x < uWidth; ++x)
        {
            if(*pDIB == clr)
            {
                ++cnt;
            }
            else
            {
                addColor(clr, cnt);
                cnt = 1;
                clr = *pDIB;
            }
            ++pDIB;
        }

        while(m_uLeafCount > m_uMaxColors)
            reduceTree();
    }

is faster than the following

    ULONG clr = *pDIB, cnt = 0;
    for(int y = 0; y < uHeight; ++y)
    {
        for(int x = 0; x < uWidth; ++x)
        {
            addColor(clr, *pDIB);
            ++pDIB;
        }
        while(m_uLeafCount > m_uMaxColors)
            reduceTree();
    }

even without the input array being sorted!!!
I can only surmise that nearby pixels tend to be equal many a time....

Is there any algorithm that can bring similar values in an array
together, but isnt as intensive as a complete sorting?
Any blazingly fast histogram algorithm can help here.

Vivek
 




 8 Posts in Topic:
Re: MMX speedup for Floyd Steinberg error diffusion
"Novosad, Stephan R.  2008-05-12 07:06:05 
Re: MMX speedup for Floyd Steinberg error diffusion
Terje Mathisen <spamt  2008-05-13 10:07:00 
Re: MMX speedup for Floyd Steinberg error diffusion
rep_movsd <spamtrap@[  2008-05-13 05:14:35 
Re: MMX speedup for Floyd Steinberg error diffusion
Terje Mathisen <spamt  2008-05-13 20:56:48 
Re: MMX speedup for Floyd Steinberg error diffusion
"Wolfgang Kern"  2008-05-15 14:04:40 
Re: MMX speedup for Floyd Steinberg error diffusion
rep_movsd <spamtrap@[  2008-05-13 05:27:28 
Re: MMX speedup for Floyd Steinberg error diffusion
Jim Leonard <spamtrap  2008-05-13 10:42:45 
Arbitrary palette dithering (Was: Re: MMX speedup for Floyd Stei
Terje Mathisen <spamt  2008-05-14 16:57:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 4:41:56 CDT 2008.