dechtbl.cpp
Go to the documentation of this file.
00001 /*
00002 //
00003 //               INTEL CORPORATION PROPRIETARY INFORMATION
00004 //  This software is supplied under the terms of a license agreement or
00005 //  nondisclosure agreement with Intel Corporation and may not be copied
00006 //  or disclosed except in accordance with the terms of that agreement.
00007 //    Copyright (c) 2001-2004 Intel Corporation. All Rights Reserved.
00008 //
00009 //  Intel® Integrated Performance Primitives JPEG Viewer Sample for Windows*
00010 //
00011 //  By downloading and installing this sample, you hereby agree that the
00012 //  accompanying Materials are being provided to you under the terms and
00013 //  conditions of the End User License Agreement for the Intel® Integrated
00014 //  Performance Primitives product previously accepted by you. Please refer
00015 //  to the file ipplic.htm located in the root directory of your Intel® IPP product
00016 //  installation for more information.
00017 //
00018 //  JPEG is an international standard promoted by ISO/IEC and other organizations.
00019 //  Implementations of these standards, or the standard enabled platforms may
00020 //  require licenses from various entities, including Intel Corporation.
00021 //
00022 //
00023 */
00024 
00025 #include "precomp.h"
00026 
00027 #ifndef __JPEGBASE_H__
00028 #include "jpegbase.h"
00029 #endif
00030 #ifndef __DECHTBL_H__
00031 #include "dechtbl.h"
00032 #endif
00033 
00034 
00035 
00036 
00037 CJPEGDecoderHuffmanTable::CJPEGDecoderHuffmanTable(void)
00038 {
00039   m_id     = 0;
00040   m_hclass = 0;
00041   m_table  = 0;
00042   m_bEmpty = 1;
00043   m_bValid = 0;
00044 
00045   ippsZero_8u(m_bits,sizeof(m_bits));
00046   ippsZero_8u(m_vals,sizeof(m_vals));
00047 
00048   return;
00049 } // ctor
00050 
00051 
00052 CJPEGDecoderHuffmanTable::~CJPEGDecoderHuffmanTable(void)
00053 {
00054   Destroy();
00055   return;
00056 } // dtor
00057 
00058 
00059 JERRCODE CJPEGDecoderHuffmanTable::Create(void)
00060 {
00061   int       size;
00062   IppStatus status;
00063 
00064   status = ippiDecodeHuffmanSpecGetBufSize_JPEG_8u(&size);
00065   if(ippStsNoErr != status)
00066   {
00067     LOG1("IPP Error: ippiDecodeHuffmanSpecGetBufSize_JPEG_8u() failed - ",status);
00068     return JPEG_INTERNAL_ERROR;
00069   }
00070 
00071   m_table = (IppiDecodeHuffmanSpec*)ippMalloc(size);
00072   if(0 == m_table)
00073   {
00074     LOG0("IPP Error: ippMalloc() failed");
00075     return JPEG_OUT_OF_MEMORY;
00076   }
00077 
00078   m_bEmpty = 0;
00079 
00080   return JPEG_OK;
00081 } // CJPEGDecoderHuffmanTable::Create()
00082 
00083 
00084 JERRCODE CJPEGDecoderHuffmanTable::Destroy(void)
00085 {
00086   m_id     = 0;
00087   m_hclass = 0;
00088   m_table  = 0;
00089 
00090   ippsZero_8u(m_bits,sizeof(m_bits));
00091   ippsZero_8u(m_vals,sizeof(m_vals));
00092 
00093   if(0 != m_table)
00094   {
00095     ippFree(m_table);
00096     m_table = 0;
00097   }
00098 
00099   m_bEmpty = 1;
00100 
00101   return JPEG_OK;
00102 } // CJPEGDecoderHuffmanTable::Destroy()
00103 
00104 
00105 JERRCODE CJPEGDecoderHuffmanTable::Init(int id,int hclass,Ipp8u* bits,Ipp8u* vals)
00106 {
00107   IppStatus status;
00108 
00109   m_id     = id     & 0x0f;
00110   m_hclass = hclass & 0x0f;
00111 
00112   ippsCopy_8u(bits,m_bits,16);
00113   ippsCopy_8u(vals,m_vals,256);
00114 
00115   status = ippiDecodeHuffmanSpecInit_JPEG_8u(m_bits,m_vals,m_table);
00116   if(ippStsNoErr != status)
00117   {
00118     LOG1("IPP Error: ippiDecodeHuffmanSpecInit_JPEG_8u() failed - ",status);
00119     return JPEG_INTERNAL_ERROR;
00120   }
00121 
00122   m_bValid = 1;
00123 
00124   return JPEG_OK;
00125 } // CJPEGDecoderHuffmanTable::Init()
00126 
00127 
00128 
00129 
00130 CJPEGDecoderHuffmanState::CJPEGDecoderHuffmanState(void)
00131 {
00132   m_state = 0;
00133   return;
00134 } // ctor
00135 
00136 
00137 CJPEGDecoderHuffmanState::~CJPEGDecoderHuffmanState(void)
00138 {
00139   Destroy();
00140   return;
00141 } // dtor
00142 
00143 
00144 JERRCODE CJPEGDecoderHuffmanState::Create(void)
00145 {
00146   int       size;
00147   IppStatus status;
00148 
00149   status = ippiDecodeHuffmanStateGetBufSize_JPEG_8u(&size);
00150   if(ippStsNoErr != status)
00151   {
00152     LOG1("IPP Error: ippiDecodeHuffmanStateGetBufSize_JPEG_8u() failed - ",status);
00153     return JPEG_INTERNAL_ERROR;
00154   }
00155 
00156   m_state = (IppiDecodeHuffmanState*)ippMalloc(size);
00157   if(0 == m_state)
00158   {
00159     LOG0("IPP Error: ippMalloc() failed");
00160     return JPEG_OUT_OF_MEMORY;
00161   }
00162 
00163   return JPEG_OK;
00164 } // CJPEGDecoderHuffmanState::Create()
00165 
00166 
00167 JERRCODE CJPEGDecoderHuffmanState::Destroy(void)
00168 {
00169   if(0 != m_state)
00170   {
00171     ippFree(m_state);
00172     m_state = 0;
00173   }
00174 
00175   return JPEG_OK;
00176 } // CJPEGDecoderHuffmanState::Destroy()
00177 
00178 
00179 JERRCODE CJPEGDecoderHuffmanState::Init(void)
00180 {
00181   IppStatus status;
00182 
00183   status = ippiDecodeHuffmanStateInit_JPEG_8u(m_state);
00184   if(ippStsNoErr != status)
00185   {
00186     LOG1("IPP Error: ippiDecodeHuffmanStateInit_JPEG_8u() failed - ",status);
00187     return JPEG_INTERNAL_ERROR;
00188   }
00189 
00190   return JPEG_OK;
00191 } // CJPEGDecoderHuffmanState::Init()


canon_vbc50i
Author(s): Cedric Pradalier
autogenerated on Sun Oct 5 2014 23:47:45