Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Introduction to MMX Programming

, 25 Jul 2013
An article shows an example of image processing using the Intel MMX™ technology
#pragma once

#include <emmintrin.h>		// MMX, SSE, SSE2 intrinsic support


// Image processing operations with 8 bits per pixel image
//
// For each image processing operation there are 3 functions:
// C++, C++ with MMX, Assembly with MMX
//
// Note about emms instruction:
// This program doesn't use float operations. However, it uses
// emms in the start and end of each MMX block.  I think it is 
// a good idea to use emms always if this instruction is not part
// of some program loop.
//
class CImg8Operations
{
public:
    CImg8Operations(void);
    ~CImg8Operations(void);

    // Invert image
    typedef void (CImg8Operations:: *INVERT_IMAGE)(BYTE* pSource, BYTE* pDest, int nNumberOfPixels);

    void InvertImageCPlusPlus(BYTE* pSource, BYTE* pDest, int nNumberOfPixels);
    void InvertImageC_MMX(BYTE* pSource, BYTE* pDest, int nNumberOfPixels);
    void InvertImageAssembly_MMX(BYTE* pSource, BYTE* pDest, int nNumberOfPixels);

    // Reduce brightness
    typedef void (CImg8Operations:: *CHANGE_BRIGHTNESS)(BYTE* pSource, BYTE* pDest, int nNumberOfPixels,
                                                        int nChange);

    void ChangeBrightnessCPlusPlus(BYTE* pSource, BYTE* pDest, int nNumberOfPixels, int nChange);
    void ChangeBrightnessC_MMX(BYTE* pSource, BYTE* pDest, int nNumberOfPixels, int nChange);
    void ChangeBrightnessAssembly_MMX(BYTE* pSource, BYTE* pDest, int nNumberOfPixels, int nChange);



protected:
    __m64 Get_m64(__int64 n);

};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Alex Fr
Software Developer
Israel Israel
No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 25 Jul 2013
Article Copyright 2003 by Alex Fr
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid