diff -Nwaur ipp-old\decoder.cs ipp-new\decoder.cs
--- ipp-old\decoder.cs	Wed May 27 00:36:51 2009
+++ ipp-new\decoder.cs	Thu Jun 11 16:50:18 2009
@@ -28,14 +28,12 @@
       const int CPU_CACHE_LINE      = 32;
       const int DCTSIZE2            = 64;
 
-      byte[]   m_rbf;
-      ushort[] m_qbf;
-      byte*    m_raw;
+      public byte[]   m_rbf;
+      public ushort[] m_qbf;
       //int      m_initialized;
 
       public int m_id;
       public int m_precision;
-      public ushort* m_qnt;
       
       public CJPEGDecoderQuantTable()
       {
@@ -44,8 +42,6 @@
          //m_initialized = 0;
          m_rbf = new byte[DCTSIZE2+(CPU_CACHE_LINE-1)];
          m_qbf = new ushort[DCTSIZE2+(CPU_CACHE_LINE-1)];
-         fixed( byte* p=m_rbf )  m_raw = p;
-         fixed( ushort* p=m_qbf) m_qnt = p;
       }
 
       public JERRCODE Init(int id, byte[] raw)
@@ -54,9 +50,12 @@
          m_id        = id & 0x0f;
          m_precision = 0; // 8-bit hardcoded
          m_rbf = raw;
-         fixed( byte* s=raw )
+		 fixed (byte* s = raw, m_raw = m_rbf)
+		 {
             ipp.sp.ippsCopy_8u(s, m_raw, raw.Length);
+			 fixed (ushort* m_qnt = m_qbf)
          status = jp.ippiQuantInvTableInit_JPEG_8u16u(m_raw, m_qnt);
+		 }
          if( IppStatus.ippStsNoErr != status )
          {
             return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -68,8 +67,7 @@
 
    unsafe class CJPEGDecoderHuffmanTable
    {
-      public IppiDecodeHuffmanSpec* m_table;
-      byte[] m_buf;
+      public byte[] m_buf;
       byte[] m_bits;
       byte[] m_vals;
       bool m_bEmpty;
@@ -84,7 +82,6 @@
          m_vals = new byte[256];
          m_id     = 0;
          m_hclass = 0;
-         m_table  = null;
          m_bEmpty = true;
          m_bValid = false;
       }
@@ -104,7 +101,7 @@
             return JERRCODE.JPEG_INTERNAL_ERROR;
          }
          m_buf = new byte[size];
-         fixed( byte* p=m_buf ) m_table = (IppiDecodeHuffmanSpec*)p;
+
          m_bEmpty = false;
          return JERRCODE.JPEG_OK;
       }
@@ -126,7 +123,8 @@
          m_vals = vals;
          fixed( byte* b=m_bits, v=m_vals ) 
          {
-            status = ipp.jp.ippiDecodeHuffmanSpecInit_JPEG_8u(b, v, m_table);
+			 fixed (byte* m_table = m_buf)
+				 status = ipp.jp.ippiDecodeHuffmanSpecInit_JPEG_8u(b, v, (IppiDecodeHuffmanSpec*)m_table);
          }
          if( IppStatus.ippStsNoErr != status )
          {
@@ -155,12 +153,11 @@
 
    unsafe class CJPEGDecoderHuffmanState
    {
-      byte[] m_buf;
-      public IppiDecodeHuffmanState* m_state;
+      public byte[] m_buf;
 
       public CJPEGDecoderHuffmanState()
       {
-         m_state = null;
+         
       }
 
       ~CJPEGDecoderHuffmanState()
@@ -178,7 +175,7 @@
             return JERRCODE.JPEG_INTERNAL_ERROR;
          }
          m_buf = new byte[size];
-         fixed( byte* p=m_buf ) m_state = (IppiDecodeHuffmanState*)p;
+         
          return JERRCODE.JPEG_OK;
       }
 
@@ -190,7 +187,9 @@
       public JERRCODE Init()
       {
          IppStatus status;
-         status = ipp.jp.ippiDecodeHuffmanStateInit_JPEG_8u(m_state);
+		 fixed (byte* m_state = m_buf)
+			 status = ipp.jp.ippiDecodeHuffmanStateInit_JPEG_8u((IppiDecodeHuffmanState*)m_state);
+
          if( IppStatus.ippStsNoErr != status )
          {
             return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1258,11 +1257,10 @@
             m_ccomp[i].m_ss_buffer = new byte[ss_buf_size*2];
             if( 0 != ss_buf_size ) 
             {
-               fixed( byte* p=m_ccomp[i].m_ss_buffer )
-               {
-                  m_ccomp[i].m_curr_row = (short*)p;
-                  m_ccomp[i].m_prev_row = (short*)p + m_dst.width;
-               }
+				   m_ccomp[i].m_curr_row = m_ccomp[i].m_ss_buffer;
+				   m_ccomp[i].m_curr_row_offset = 0;
+                  m_ccomp[i].m_prev_row = m_ccomp[i].m_ss_buffer;
+				  m_ccomp[i].m_prev_row_offset = m_dst.width;
             }
             m_ccomp[i].m_cc_buffer = new byte[cc_buf_size];
             if( m_jpeg_sampling == JSS.JS_411 )
@@ -1317,17 +1315,17 @@
       unsafe JERRCODE DecodeHuffmanMCURowBL(short* pMCUBuf)
       {
          int       j, n, k, l;
-         byte*     src;
          int       srcLen;
          JERRCODE  jerr;
          IppStatus status;
 
-         fixed( byte* p=m_src.pData ) src = p;
          int* currPos;
          JMARKER* marker;
          fixed( int* p=&m_src.currPos ) currPos = p;
          fixed( JMARKER* p=&m_marker ) marker = p;
          srcLen = m_src.DataLen;
+		 fixed (byte* src = m_src.pData, m_state_ptr = m_state.m_buf)
+		 {
          for( j = 0; j < m_numxMCU; j++ )
          {
             if( 0 != m_jpeg_restart_interval )
@@ -1343,10 +1341,11 @@
             }
             for( n = 0; n < m_jpeg_ncomp; n++ )
             {
-               short* lastDC;
-               fixed( short* p=&m_ccomp[n].m_lastDC ) lastDC = p;
-               IppiDecodeHuffmanSpec* dctbl  = m_dctbl[m_ccomp[n].m_dc_selector].m_table;
-               IppiDecodeHuffmanSpec* actbl  = m_actbl[m_ccomp[n].m_ac_selector].m_table;
+					 fixed (byte* dctbl = m_dctbl[m_ccomp[n].m_dc_selector].m_buf, actbl = m_actbl[m_ccomp[n].m_ac_selector].m_buf)
+					 {
+						 fixed (short* lastDC = &m_ccomp[n].m_lastDC)
+						 {
+
                for( k = 0; k < m_ccomp[n].m_vsampling; k++ )
                {
                   for( l = 0; l < m_ccomp[n].m_hsampling; l++ )
@@ -1358,9 +1357,9 @@
                         pMCUBuf,
                         lastDC,
                         (int*)marker,
-                        dctbl,
-                        actbl,
-                        m_state.m_state);
+										(IppiDecodeHuffmanSpec*)dctbl,
+										(IppiDecodeHuffmanSpec*)actbl,
+										(IppiDecodeHuffmanState*)m_state_ptr);
                      if( IppStatus.ippStsNoErr > status )
                      {
                         return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1368,25 +1367,28 @@
                      pMCUBuf += DCTSIZE2;
                   } // for m_hsampling
                } // for m_vsampling
+						 } //for fixed short *
+					 } //for fixed byte*
             } // for m_jpeg_ncomp
             m_restarts_to_go--;
          } // for m_numxMCU
+		 } //fixed byte *
          return JERRCODE.JPEG_OK;
       }
 
       JERRCODE DecodeHuffmanMCURowLS(short* pMCUBuf)
       {
          int       j, n, k, l;
-         byte*     src;
          int       srcLen;
          JERRCODE  jerr;
          IppStatus status;
-         int*      currPos;
-         JMARKER*  marker;
 
-         fixed( int* p=&m_src.currPos ) currPos = p;
-         fixed( JMARKER* p=&m_marker ) marker = p;
-         fixed( byte* p=m_src.pData ) src = p;
+		 fixed (JMARKER* marker = &m_marker)
+		 {
+			 fixed (int* currPos = &m_src.currPos)
+			 {
+				 fixed (byte* src = m_src.pData, m_state_ptr = m_state.m_buf)
+				 {
          srcLen = m_src.DataLen;
          for( j = 0; j < m_numxMCU; j++ )
          {
@@ -1403,7 +1405,8 @@
             }
             for( n = 0; n < m_jpeg_ncomp; n++ )
             {
-               IppiDecodeHuffmanSpec* dctbl = m_dctbl[m_ccomp[n].m_dc_selector].m_table;
+							 fixed (byte* dctbl = m_dctbl[m_ccomp[n].m_dc_selector].m_buf)
+							 {
                for( k = 0; k < m_ccomp[n].m_vsampling; k++ )
                {
                   for( l = 0; l < m_ccomp[n].m_hsampling; l++ )
@@ -1414,8 +1417,8 @@
                         currPos,
                         pMCUBuf,
                         (int*)marker,
-                        dctbl,
-                        m_state.m_state);
+											(IppiDecodeHuffmanSpec*)dctbl,
+											(IppiDecodeHuffmanState*)m_state_ptr);
                      if( IppStatus.ippStsNoErr > status )
                      {
                         return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1423,9 +1426,13 @@
                      pMCUBuf++;
                   } // for m_hsampling
                } // for m_vsampling
+							 }//for fixed byte*
             } // for m_jpeg_ncomp
             m_restarts_to_go --;
          } // for m_numxMCU
+				 } //fixed src,m_state_ptr
+			 } //fixed currPos
+		 } //fixed JMARKER
          return JERRCODE.JPEG_OK;
       }
 
@@ -1452,10 +1459,8 @@
             // sampling 422
             if( m_ccomp[k].m_h_factor == 2 && m_ccomp[k].m_v_factor == 1 )
             {
-               // pad most left and most right column
-               byte* ss_buf, cc_buf;
-               fixed( byte* p=m_ccomp[k].m_ss_buffer ) ss_buf=p;
-               fixed( byte* p=m_ccomp[k].m_cc_buffer ) cc_buf=p;
+				fixed (byte* ss_buf = m_ccomp[k].m_ss_buffer, cc_buf = m_ccomp[k].m_cc_buffer)
+				{
                byte* p1 = ss_buf;
                byte* p2 = ss_buf + (m_ccWidth>>1) + 1;
                int step  = STEP_SS;
@@ -1471,18 +1476,19 @@
                byte* src = ss_buf + 1;
                byte* dst = cc_buf;
                status = ipp.jp.ippiSampleUpH2V1_JPEG_8u_C1R(src,STEP_SS,roiSrc,dst,m_ccWidth,roiDst);
+				}
                if( IppStatus.ippStsNoErr != status )
                {
                   return JERRCODE.JPEG_INTERNAL_ERROR;
                }
+					
             }
             // sampling 411
             if( m_ccomp[k].m_h_factor == 2 && m_ccomp[k].m_v_factor == 2 )
             {
                // pad most left and most right columns
-               byte* ss_buf, cc_buf;
-               fixed( byte* p=m_ccomp[k].m_ss_buffer ) ss_buf=p;
-               fixed( byte* p=m_ccomp[k].m_cc_buffer ) cc_buf=p;
+				fixed (byte* ss_buf = m_ccomp[k].m_ss_buffer, cc_buf = m_ccomp[k].m_cc_buffer)
+				{
                byte* p1 = ss_buf;
                byte* p2 = ss_buf + (m_ccWidth>>1) + 1;
                int step  = STEP_SS;
@@ -1505,25 +1511,28 @@
                   p1 = ss_buf + STEP_SS*(8+0);
                   p2 = ss_buf + STEP_SS*(8+1);
                   ipp.sp.ippsCopy_8u(p1,p2,STEP_SS);
-                  fixed( byte* p=m_ccomp[k].m_top_row ) p1=p;
-                  ipp.sp.ippsCopy_8u(p2,p1,STEP_SS);
+						fixed (byte* p = m_ccomp[k].m_top_row)
+							ipp.sp.ippsCopy_8u(p2, p, STEP_SS);
                }
                else
                {
-                  fixed( byte* p=m_ccomp[k].m_top_row ) p1=p;
+						fixed (byte* p = m_ccomp[k].m_top_row)
+						{
                   p2 = ss_buf;
-                  ipp.sp.ippsCopy_8u(p1,p2,STEP_SS);
+							ipp.sp.ippsCopy_8u(p, p2, STEP_SS);
                   p2 = ss_buf + STEP_SS*(8+0);
-                  ipp.sp.ippsCopy_8u(p2,p1,STEP_SS);
-                  p1 = ss_buf + STEP_SS*(8+0);
+							ipp.sp.ippsCopy_8u(p2, p, STEP_SS);
+							byte * p_oth = ss_buf + STEP_SS * (8 + 0);
                   p2 = ss_buf + STEP_SS*(8+1);
-                  ipp.sp.ippsCopy_8u(p1,p2,STEP_SS);
+							ipp.sp.ippsCopy_8u(p_oth, p2, STEP_SS);
+						}
                }
                status = ipp.jp.ippiSampleUpH2V2_JPEG_8u_C1R(src,STEP_SS,roiSrc,dst,m_ccWidth,roiDst);
                if( IppStatus.ippStsNoErr != status )
                {
                   return JERRCODE.JPEG_INTERNAL_ERROR;
                }
+				}
             }//411
          } // for m_jpeg_ncomp
          return JERRCODE.JPEG_OK;
@@ -1544,15 +1553,15 @@
                   ipp.ip.ippiCopy_8u_C1R(src, m_ccWidth, dst, m_ccWidth, roi);
             }
             // sampling 422
+			fixed (byte* p = m_ccomp[k].m_ss_buffer)
+			{
             if( m_ccomp[k].m_h_factor == 2 && m_ccomp[k].m_v_factor == 1 )
             {
                // pad most left and most right columns
-               byte* p1, p2;
-               fixed( byte* p=m_ccomp[k].m_ss_buffer )
-               {
-                  p1=p;
-                  p2=p + (m_ccWidth>>1) + 1;
-               }
+
+					byte* p1 = p;
+					byte* p2 = p + (m_ccWidth >> 1) + 1;
+
                int step = m_ccWidth;
                for( i = 0; i < m_ccHeight; i++ )
                {
@@ -1576,12 +1585,8 @@
             if( m_ccomp[k].m_h_factor == 2 && m_ccomp[k].m_v_factor == 2)
             {
                // pad most left and most right columns
-               byte* p1, p2;
-               fixed( byte* p=m_ccomp[k].m_ss_buffer )
-               {
-                  p1 = p;
-                  p2 = p + (m_ccWidth>>1) + 1;
-               }
+					byte* p1 = p;
+					byte* p2 = p + (m_ccWidth >> 1) + 1;
                int step  = m_ccWidth;
                for(i = 0; i < (m_ccHeight>>1); i++)
                {
@@ -1591,18 +1596,13 @@
                   p2 += step;
                }
                // replicate top row
-               fixed( byte* p=m_ccomp[k].m_ss_buffer )
-               {
                   p1 = p + m_ccWidth;
                   p2 = p;
-               }
                ipp.sp.ippsCopy_8u(p1, p2, m_ccWidth);
                // replicate bottom row
-               fixed( byte* p=m_ccomp[k].m_ss_buffer )
-               {
                   p1 = p + m_ccWidth*m_ccHeight-1;
                   p2 = p + m_ccWidth*m_ccHeight;
-               }
+
                ipp.sp.ippsCopy_8u(p1, p2, m_ccWidth);
                IppiSize roiSrc = new IppiSize(m_ccWidth>>1, m_ccHeight>>1);
                IppiSize roiDst = new IppiSize(m_dst.width, m_dst.height);
@@ -1615,6 +1615,7 @@
                   return JERRCODE.JPEG_INTERNAL_ERROR;
                }
             }
+			}
          } // for m_jpeg_ncomp
          return JERRCODE.JPEG_OK;
       }
@@ -1624,9 +1625,6 @@
          int       i, j, n, k, l;
          int       size;
          int       dst_step;
-         byte*     dst;
-         ushort*   qtbl;
-         short*    block;
          IppStatus status;
 
          dst_step = m_ccWidth;
@@ -1634,21 +1632,26 @@
          {
             size += (m_ccomp[n].m_hsampling * m_ccomp[n].m_vsampling);
          }
+		 fixed (short* p_coefbuf = m_coefbuf)
+		 {
          for( i = 0; i < m_numyMCU; i++ )
          {
             for( j = 0; j < m_numxMCU; j++ )
             {
-               fixed( short* p=m_coefbuf )
-                  block = p + (DCTSIZE2*size*(j+(i*m_numxMCU)));
+				short* block = p_coefbuf + (DCTSIZE2 * size * (j + (i * m_numxMCU)));
                for( n = 0; n < m_jpeg_ncomp; n++ )
                {
+					fixed (ushort* qtbl = m_qntbl[m_ccomp[n].m_q_selector].m_qbf)
+					{
+						fixed (byte* p_ss_buffer = m_ccomp[n].m_ss_buffer)
+						{
                   for( k = 0; k < m_ccomp[n].m_vsampling; k++ )
                   {
                      for( l = 0; l < m_ccomp[n].m_hsampling; l++ )
                      {
-                        qtbl = m_qntbl[m_ccomp[n].m_q_selector].m_qnt;
-                        fixed( byte* p=m_ccomp[n].m_ss_buffer )
-                           dst = p +
+
+
+									byte* dst = p_ss_buffer +
                               i*8*m_ccomp[n].m_vsampling*m_ccWidth +
                               j*8*m_ccomp[n].m_hsampling +
                               k*8*m_ccWidth;
@@ -1673,6 +1676,9 @@
                         block += DCTSIZE2;
                      } // for m_hsampling
                   } // for m_vsampling
+						} //for fixed p_ss_buffer
+					} //for fixed qtbl
+               }
                }
             }
          }
@@ -1706,13 +1712,16 @@
                   break;
                case 3:
                   src = new byte*[3];
-                  fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-                  fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-                  fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
+				  fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer)
+				  {
+					  src[0] = p1;
+					  src[1] = p2;
+					  src[2] = p3;
                   fixed( byte** pSrc = src )
                   {
                      status = ipp.ip.ippiCopy_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
                   }
+				  }
                   if( IppStatus.ippStsNoErr != status )
                   {
                      return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1720,14 +1729,17 @@
                   break;
                case 4:
                   src = new byte*[4];
-                  fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-                  fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-                  fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
-                  fixed( byte* p=m_ccomp[3].m_cc_buffer ) src[3]=p;
+				  fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer, p4 = m_ccomp[3].m_cc_buffer)
+				  {
+					  src[0] = p1;
+					  src[1] = p2;
+					  src[2] = p3;
+					  src[3] = p4;
                   fixed( byte** pSrc = src )
                   {
                      status = ipp.ip.ippiCopy_8u_P4C4R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
                   }
+				  }
                   if( IppStatus.ippStsNoErr != status )
                   {
                      return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1758,11 +1770,11 @@
                src[0]=p;
                src[1]=p;
                src[2]=p;
-            }
             fixed( byte** pSrc = src )
             {
                status = ipp.ip.ippiCopy_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1777,11 +1789,12 @@
                src[0]=p;
                src[1]=p;
                src[2]=p;
-            }
+
             fixed( byte** pSrc = src )
             {
                status = ipp.ip.ippiCopy_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1791,13 +1804,17 @@
          if( m_jpeg_color == JCOLOR.JC_RGB && m_dst.color == JCOLOR.JC_RGB )
          {
             src = new byte*[3];
-            fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-            fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-            fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
+			fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer)
+			{
+				src[0] = p1;
+				src[1] = p2;
+				src[2] = p3;
+
             fixed( byte** pSrc = src )
             {
                status = ipp.ip.ippiCopy_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1807,13 +1824,17 @@
          if( m_jpeg_color == JCOLOR.JC_RGB && m_dst.color == JCOLOR.JC_BGR )
          {
             src = new byte*[3];
-            fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[0]=p;
-            fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-            fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[2]=p;
+			fixed (byte* p1 = m_ccomp[2].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[0].m_cc_buffer)
+			{
+				src[0] = p1;
+				src[0] = p2;
+				src[0] = p3;
+
             fixed( byte** pSrc = src )
             {
                status = ipp.ip.ippiCopy_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1823,13 +1844,16 @@
          if( m_jpeg_color == JCOLOR.JC_YCBCR && m_dst.color == JCOLOR.JC_RGB )
          {
             src = new byte*[3];
-            fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-            fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-            fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
+			fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer)
+			{
+				src[0] = p1;
+				src[1] = p2;
+				src[2] = p3;
             fixed( byte** pSrc = src )
             {
                status = ipp.jp.ippiYCbCrToRGB_JPEG_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1839,13 +1863,16 @@
          if( m_jpeg_color == JCOLOR.JC_YCBCR && m_dst.color == JCOLOR.JC_BGR )
          {
             src = new byte*[3];
-            fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-            fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-            fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
+			fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer)
+			{
+				src[0] = p1;
+				src[1] = p2;
+				src[2] = p3;
             fixed( byte** pSrc = src )
             {
                status = ipp.jp.ippiYCbCrToBGR_JPEG_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1855,14 +1882,17 @@
          if( m_jpeg_color == JCOLOR.JC_CMYK && m_dst.color == JCOLOR.JC_CMYK )
          {
             src = new byte*[4];
-            fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-            fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-            fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
-            fixed( byte* p=m_ccomp[3].m_cc_buffer ) src[3]=p;
+			fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer, p4 = m_ccomp[3].m_cc_buffer)
+			{
+				src[0] = p1;
+				src[1] = p2;
+				src[2] = p3;
+				src[3] = p4;
             fixed( byte** pSrc = src )
             {
                status = ipp.ip.ippiCopy_8u_P4C4R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1872,14 +1902,17 @@
          if( m_jpeg_color == JCOLOR.JC_YCCK && m_dst.color == JCOLOR.JC_CMYK )
          {
             src = new byte*[4];
-            fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-            fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-            fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
-            fixed( byte* p=m_ccomp[3].m_cc_buffer ) src[3]=p;
+			fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer, p4 = m_ccomp[3].m_cc_buffer)
+			{
+				src[0] = p1;
+				src[1] = p2;
+				src[2] = p3;
+				src[3] = p4;
             fixed( byte** pSrc = src )
             {
                status = ipp.jp.ippiYCCKToCMYK_JPEG_8u_P4C4R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1910,13 +1943,16 @@
                   break;
                case 3:
                   src=new byte*[3];
-                  fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-                  fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-                  fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
+				  fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer)
+				  {
+					  src[0] = p1;
+					  src[1] = p2;
+					  src[2] = p3;
                   fixed( byte** pSrc = src )
                   {
                      status = ipp.ip.ippiCopy_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
                   }
+				  }
                   if( IppStatus.ippStsNoErr != status )
                   {
                      return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1924,14 +1960,17 @@
                   break;
                case 4:
                   src=new byte*[4];
-                  fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-                  fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-                  fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
-                  fixed( byte* p=m_ccomp[3].m_cc_buffer ) src[3]=p;
+				  fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer, p4 = m_ccomp[3].m_cc_buffer)
+				  {
+					  src[0] = p1;
+					  src[1] = p2;
+					  src[2] = p3;
+					  src[3] = p4;
                   fixed( byte** pSrc = src )
                   {
                      status = ipp.ip.ippiCopy_8u_P4C4R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
                   }
+				  }
                   if( IppStatus.ippStsNoErr != status )
                   {
                      return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1962,11 +2001,12 @@
                src[0]=p;
                src[1]=p;
                src[2]=p;
-            }
+
             fixed( byte** pSrc = src )
             {
                status = ipp.ip.ippiCopy_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1981,11 +2021,12 @@
                src[0]=p;
                src[1]=p;
                src[2]=p;
-            }
+
             fixed( byte** pSrc = src )
             {
                status = ipp.ip.ippiCopy_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -1995,13 +2036,17 @@
          if( m_jpeg_color == JCOLOR.JC_RGB && m_dst.color == JCOLOR.JC_RGB )
          {
             src=new byte*[3];
-            fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-            fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-            fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
+			fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer)
+			{
+				src[0] = p1;
+				src[1] = p2;
+				src[2] = p3;
+
             fixed( byte** pSrc = src )
             {
                status = ipp.ip.ippiCopy_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -2011,13 +2056,16 @@
          if( m_jpeg_color == JCOLOR.JC_RGB && m_dst.color == JCOLOR.JC_BGR )
          {
             src=new byte*[3];
-            fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[0]=p;
-            fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-            fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[2]=p;
+			fixed (byte* p1 = m_ccomp[2].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[0].m_cc_buffer)
+			{
+				src[0] = p1;
+				src[1] = p2;
+				src[2] = p3;
             fixed( byte** pSrc = src )
             {
                status = ipp.ip.ippiCopy_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -2027,13 +2075,16 @@
          if( m_jpeg_color == JCOLOR.JC_YCBCR && m_dst.color == JCOLOR.JC_RGB )
          {
             src=new byte*[3];
-            fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-            fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-            fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
+			fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer)
+			{
+				src[0] = p1;
+				src[1] = p2;
+				src[2] = p3;
             fixed( byte** pSrc = src )
             {
                status = ipp.jp.ippiYCbCrToRGB_JPEG_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -2043,13 +2094,16 @@
          if( m_jpeg_color == JCOLOR.JC_YCBCR && m_dst.color == JCOLOR.JC_BGR )
          {
             src=new byte*[3];
-            fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-            fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-            fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
+			fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer)
+			{
+				src[0] = p1;
+				src[1] = p2;
+				src[2] = p3;
             fixed( byte** pSrc = src )
             {
                status = ipp.jp.ippiYCbCrToBGR_JPEG_8u_P3C3R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -2059,14 +2113,17 @@
          if( m_jpeg_color == JCOLOR.JC_CMYK && m_dst.color == JCOLOR.JC_CMYK )
          {
             src=new byte*[4];
-            fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-            fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-            fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
-            fixed( byte* p=m_ccomp[3].m_cc_buffer ) src[3]=p;
+			fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer, p4 = m_ccomp[3].m_cc_buffer)
+			{
+				src[0] = p1;
+				src[1] = p2;
+				src[2] = p3;
+				src[3] = p4;
             fixed( byte** pSrc = src )
             {
                status = ipp.ip.ippiCopy_8u_P4C4R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -2076,14 +2133,17 @@
          if( m_jpeg_color == JCOLOR.JC_YCCK && m_dst.color == JCOLOR.JC_CMYK )
          {
             src=new byte*[4];
-            fixed( byte* p=m_ccomp[0].m_cc_buffer ) src[0]=p;
-            fixed( byte* p=m_ccomp[1].m_cc_buffer ) src[1]=p;
-            fixed( byte* p=m_ccomp[2].m_cc_buffer ) src[2]=p;
-            fixed( byte* p=m_ccomp[3].m_cc_buffer ) src[3]=p;
+			fixed (byte* p1 = m_ccomp[0].m_cc_buffer, p2 = m_ccomp[1].m_cc_buffer, p3 = m_ccomp[2].m_cc_buffer, p4 = m_ccomp[3].m_cc_buffer)
+			{
+				src[0] = p1;
+				src[1] = p2;
+				src[2] = p3;
+				src[3] = p4;
             fixed( byte** pSrc = src )
             {
                status = ipp.jp.ippiYCCKToCMYK_JPEG_8u_P4C4R(pSrc,m_ccWidth,dst,m_dst.lineStep,roi);
             }
+			}
             if( IppStatus.ippStsNoErr != status )
             {
                return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -2095,7 +2155,6 @@
       JERRCODE DCT_QNT_SSCC_MCURowBL(short* pMCUBuf, int mcu_row)
       {
          int       j, n, k, l;
-         byte*     dst      = null;
          int       dst_step = m_ccWidth;
          JERRCODE  jerr;
          IppStatus status;
@@ -2104,15 +2163,19 @@
          {
             for( n = 0; n < m_jpeg_ncomp; n++ )
             {
+				fixed (byte* cc_buf = m_ccomp[n].m_cc_buffer, ss_buf_ptr = m_ccomp[n].m_ss_buffer)
+				{
+					fixed (ushort* qtbl = m_qntbl[m_ccomp[n].m_q_selector].m_qbf)
+					{
+						byte* dst = null;
                byte* ss_buf = null;
                if( n != 0 && n != 3 )
                {
                   if( 0 != m_ccomp[n].m_ss_buffer.Length )
-                     fixed( byte* p=m_ccomp[n].m_ss_buffer ) ss_buf=p;
+								ss_buf = ss_buf_ptr;
                }
-               byte* cc_buf;
-               fixed( byte* p=m_ccomp[n].m_cc_buffer ) cc_buf=p;
-               ushort* qtbl = m_qntbl[m_ccomp[n].m_q_selector].m_qnt;
+
+
                int hsam  = m_ccomp[n].m_hsampling;
                int jhsam = j*8*hsam;
                for( k = 0; k < m_ccomp[n].m_vsampling; k++ )
@@ -2150,6 +2213,8 @@
                      pMCUBuf += DCTSIZE2;
                   } // for m_hsampling
                } // for m_vsampling
+					} //fixed qtbl
+				}//fixed cc_buf, ss_buf
             } // for m_jpeg_ncomp
          } // for m_numxMCU
          if( m_jpeg_sampling != JSS.JS_444 )
@@ -2175,9 +2240,10 @@
          byte*     pDst;
          IppiSize  roi;
          IppStatus status;
-
-         pCurrRow = m_ccomp[0].m_curr_row;
-         pPrevRow = m_ccomp[0].m_prev_row;
+		  fixed (byte* m_curr_row_ptr = m_ccomp[0].m_curr_row, m_prev_row_ptr = m_ccomp[0].m_prev_row)
+		  {
+			  pCurrRow = (short*)m_curr_row_ptr + m_ccomp[0].m_curr_row_offset;
+			  pPrevRow = (short*)m_prev_row_ptr + m_ccomp[0].m_prev_row_offset;
          roi = new IppiSize(m_dst.width, 1);
          pDst = m_dst.Data8u + mcu_row*m_dst.width;
          if( mcu_row != 0 )
@@ -2207,25 +2273,32 @@
          {
             return JERRCODE.JPEG_INTERNAL_ERROR;
          }
-         m_ccomp[0].m_curr_row = pPrevRow;
-         m_ccomp[0].m_prev_row = pCurrRow;
+			  int old_offset = m_ccomp[0].m_curr_row_offset;
+			  byte[] old_arr = m_ccomp[0].m_curr_row;
+			  m_ccomp[0].m_curr_row = m_ccomp[0].m_prev_row;
+			  m_ccomp[0].m_curr_row_offset = m_ccomp[0].m_prev_row_offset;
+			  m_ccomp[0].m_prev_row = old_arr;
+				m_ccomp[0].m_prev_row_offset = old_offset;
+
 
          return JERRCODE.JPEG_OK;
       }
+	  }
 
       JERRCODE DecodeScanBaseline()
       {
          int scount = 0;
          IppStatus status;
-         status = ipp.jp.ippiDecodeHuffmanStateInit_JPEG_8u(m_state.m_state);
+		 fixed (byte* m_state_ptr = m_state.m_buf)
+			 status = ipp.jp.ippiDecodeHuffmanStateInit_JPEG_8u((IppiDecodeHuffmanState*)m_state_ptr);
          if( IppStatus.ippStsNoErr != status )
          {
             return JERRCODE.JPEG_INTERNAL_ERROR;
          }
          m_marker = JMARKER.JM_NONE;
          int    i;
-         short* pMCUBuf;  // the pointer to Buffer for a current thread.
-         fixed( short* p=m_block_buffer ) pMCUBuf = p;
+		 fixed (short* pMCUBuf = m_block_buffer) // the pointer to Buffer for a current thread.
+		 {
          i = 0;
          while( i < m_numyMCU )
          {
@@ -2241,6 +2314,7 @@
             }
             i++;
          } // for m_numyMCU
+		 }
          return JERRCODE.JPEG_OK;
       }
 
@@ -2248,19 +2322,20 @@
       {
          int       i, j, k, n, l, c;
          int       size;
-         byte*     src;
          int       srcLen;
          JERRCODE  jerr;
          IppStatus status;
 
          m_scan_count++;
-         status = ipp.jp.ippiDecodeHuffmanStateInit_JPEG_8u(m_state.m_state);
+		 fixed (byte* m_state_ptr = m_state.m_buf)
+			 status = ipp.jp.ippiDecodeHuffmanStateInit_JPEG_8u((IppiDecodeHuffmanState*)m_state_ptr);
          if( IppStatus.ippStsNoErr != status )
          {
             return JERRCODE.JPEG_INTERNAL_ERROR;
          }
          m_marker = JMARKER.JM_NONE;
-         fixed( byte* p=m_src.pData ) src = p;
+		 fixed (byte* src = m_src.pData, m_state_ptr = m_state.m_buf)
+		 {
          srcLen = m_src.DataLen;
          for( size = 0, k = 0; k < m_jpeg_ncomp; k++ )
          {
@@ -2308,7 +2383,8 @@
                               }
                            }
                         }
-                        IppiDecodeHuffmanSpec* actbl = m_actbl[m_ccomp[m_curr_comp_no].m_ac_selector].m_table;
+								 fixed (byte* actbl = m_actbl[m_ccomp[m_curr_comp_no].m_ac_selector].m_buf)
+								 {
                         if( m_ah == 0 )
                         {
                            status = ipp.jp.ippiDecodeHuffman8x8_ACFirst_JPEG_1u16s_C1(
@@ -2320,8 +2396,8 @@
                               m_ss,
                               m_se,
                               m_al,
-                              actbl,
-                              m_state.m_state);
+											(IppiDecodeHuffmanSpec * )actbl,
+											(IppiDecodeHuffmanState*)m_state_ptr);
                            if( IppStatus.ippStsNoErr > status )
                            {
                               return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -2338,13 +2414,14 @@
                               m_ss,
                               m_se,
                               m_al,
-                              actbl,
-                              m_state.m_state);
+											(IppiDecodeHuffmanSpec*)actbl,
+											(IppiDecodeHuffmanState*)m_state_ptr);
                            if( IppStatus.ippStsNoErr > status )
                            {
                               return JERRCODE.JPEG_INTERNAL_ERROR;
                            }
                         }
+								 } //fixed actbl
                         block += DCTSIZE2;
                         m_restarts_to_go --;
                      } // for m_hsampling
@@ -2381,9 +2458,11 @@
                      // first DC scan
                      for( n = 0; n < m_jpeg_ncomp; n++ )
                      {
-                        short* lastDC;
-                        fixed( short* p=&m_ccomp[n].m_lastDC ) lastDC=p;
-                        IppiDecodeHuffmanSpec* dctbl = m_dctbl[m_ccomp[n].m_dc_selector].m_table;
+
+								 fixed (short* lastDC = &m_ccomp[n].m_lastDC)
+								 {
+									 fixed (byte* dctbl = m_dctbl[m_ccomp[n].m_dc_selector].m_buf)
+									 {
                         for( k = 0; k < m_ccomp[n].m_vsampling; k++ )
                         {
                            for( l = 0; l < m_ccomp[n].m_hsampling; l++ )
@@ -2396,8 +2475,8 @@
                                  lastDC,
                                  (int*)marker,
                                  m_al,
-                                 dctbl,
-                                 m_state.m_state);
+													(IppiDecodeHuffmanSpec*)dctbl,
+													(IppiDecodeHuffmanState*)m_state_ptr);
                               if( IppStatus.ippStsNoErr > status )
                               {
                                  return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -2405,6 +2484,8 @@
                               block += DCTSIZE2;
                            } // for m_hsampling
                         } // for m_vsampling
+									 }//fixed dctbl
+								 } //fixed lastDC
                      } // for m_jpeg_ncomp
                   }
                   else
@@ -2423,7 +2504,7 @@
                                  block,
                                  (int*)marker,
                                  m_al,
-                                 m_state.m_state);
+											(IppiDecodeHuffmanState*)m_state_ptr);
                               if( IppStatus.ippStsNoErr > status )
                               {
                                  return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -2441,6 +2522,7 @@
                m_dc_scan_completed = 1;
             }
          }
+		 } //fixed src, m_state_ptr
          return JERRCODE.JPEG_OK;
       }
 
@@ -2451,8 +2533,8 @@
          IppStatus status;
          int    i;
          short* pMCUBuf;
-
-         status = ipp.jp.ippiDecodeHuffmanStateInit_JPEG_8u(m_state.m_state);
+		 fixed (byte* m_state_ptr = m_state.m_buf)
+			 status = ipp.jp.ippiDecodeHuffmanStateInit_JPEG_8u((IppiDecodeHuffmanState*)m_state_ptr);
          if( IppStatus.ippStsNoErr != status )
          {
             return JERRCODE.JPEG_INTERNAL_ERROR;
@@ -2487,8 +2569,8 @@
       {
          JERRCODE  jerr;
          IppStatus status;
-
-         status = ipp.jp.ippiDecodeHuffmanStateInit_JPEG_8u(m_state.m_state);
+		 fixed (byte* m_state_ptr = m_state.m_buf)
+		 	status = ipp.jp.ippiDecodeHuffmanStateInit_JPEG_8u((IppiDecodeHuffmanState*)m_state_ptr);
          if( IppStatus.ippStsNoErr != status )
          {
             return JERRCODE.JPEG_INTERNAL_ERROR;
diff -Nwaur ipp-old\encoder.cs ipp-new\encoder.cs
--- ipp-old\encoder.cs	Fri Dec 05 19:29:28 2008
+++ ipp-new\encoder.cs	Tue Jun 09 00:36:53 2009
@@ -1718,8 +1718,10 @@
             m_ccomp[i].m_ss_buffer = new byte[ss_buf_size];
             // huffman buffer
             m_ccomp[i].m_top_row = new byte[ss_buf_size];
-            fixed( byte* p=m_ccomp[i].m_cc_buffer ) m_ccomp[i].m_curr_row=(short*)p;
-            fixed( byte* p=m_ccomp[i].m_ss_buffer ) m_ccomp[i].m_prev_row=(short*)p;
+			m_ccomp[i].m_curr_row = m_ccomp[i].m_cc_buffer;
+			m_ccomp[i].m_curr_row_offset = 0;
+			m_ccomp[i].m_prev_row = m_ccomp[i].m_ss_buffer;
+			m_ccomp[i].m_prev_row_offset = 0;
          }
          if( JMODE.JPEG_PROGRESSIVE == m_jpeg_mode )
          {
@@ -2666,8 +2668,11 @@
             pSrc     = m_src.Data8u + i*m_src.lineStep;
             fixed( byte* p=m_ccomp[0].m_top_row )
                pMCUBuf  = (short*)p;
-            pCurrRow = m_ccomp[0].m_curr_row;
-            pPrevRow = m_ccomp[0].m_prev_row;
+			 fixed (byte* m_curr_row_ptr = m_ccomp[0].m_curr_row, m_prev_row_ptr = m_ccomp[0].m_prev_row)
+			 {
+				 pCurrRow = (short*)m_curr_row_ptr + m_ccomp[0].m_curr_row_offset;
+				 pPrevRow = (short*)m_prev_row_ptr + m_ccomp[0].m_prev_row_offset;
+
 
             status = ipp.ip.ippiConvert_8u16s_C1R(pSrc, m_src.lineStep, pCurrRow, m_numxMCU, roi);
             if( IppStatus.ippStsNoErr > status )
@@ -2699,8 +2704,12 @@
                   return JERRCODE.JPEG_INTERNAL_ERROR;
                }
             }
-            m_ccomp[0].m_curr_row = pPrevRow;
-            m_ccomp[0].m_prev_row = pCurrRow;
+				 int old_offset = m_ccomp[0].m_curr_row_offset;
+				 byte[] old_arr = m_ccomp[0].m_curr_row;
+				 m_ccomp[0].m_curr_row = m_ccomp[0].m_prev_row;
+				 m_ccomp[0].m_curr_row_offset = m_ccomp[0].m_prev_row_offset;
+				 m_ccomp[0].m_prev_row = old_arr;
+				 m_ccomp[0].m_prev_row_offset = old_offset;
             for( j = 0; j < m_numxMCU; j++ )
             {
                pDCTbl = m_dctbl[m_ccomp[0].m_dc_selector].m_table;
@@ -2718,7 +2727,9 @@
                }
                pMCUBuf++;
             } // for numxMCU
+			 }//fixed mcur, mPrev
          }
+
          // flush IppiEncodeHuffmanState
          status = ipp.jp.ippiEncodeHuffmanOne_JPEG_16s1u_C1(
             null, pData, m_dst.DataLen, currPos, null, m_state.m_state, 1);
diff -Nwaur ipp-old\jpegbase.cs ipp-new\jpegbase.cs
--- ipp-old\jpegbase.cs	Fri Dec 05 19:29:28 2008
+++ ipp-new\jpegbase.cs	Thu Jun 11 16:51:10 2009
@@ -199,8 +199,10 @@
       public byte[] m_ss_buffer;
       public byte[] m_top_row;
       public byte[] m_bottom_row;
-      public short* m_curr_row;
-      public short* m_prev_row;
+	  public byte[] m_curr_row;
+	  public int m_curr_row_offset;
+	  public byte[] m_prev_row;
+	  public int m_prev_row_offset;
    };
 
 }
