enchtbl.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 __ENCHTBL_H__
00031 #include "enchtbl.h"
00032 #endif
00033 
00034 
00035 
00036 
00037 CJPEGEncoderHuffmanTable::CJPEGEncoderHuffmanTable(void)
00038 {
00039   m_id     = 0;
00040   m_hclass = 0;
00041   m_table  = 0;
00042 
00043   ippsZero_8u(m_bits,sizeof(m_bits));
00044   ippsZero_8u(m_vals,sizeof(m_vals));
00045 
00046   return;
00047 } // ctor
00048 
00049 
00050 CJPEGEncoderHuffmanTable::~CJPEGEncoderHuffmanTable(void)
00051 {
00052   Destroy();
00053   return;
00054 } // dtor
00055 
00056 
00057 JERRCODE CJPEGEncoderHuffmanTable::Create(void)
00058 {
00059   int       size;
00060   IppStatus status;
00061 
00062   status = ippiEncodeHuffmanSpecGetBufSize_JPEG_8u(&size);
00063   if(ippStsNoErr != status)
00064   {
00065     LOG1("IPP Error: ippiEncodeHuffmanSpecGetBufSize_JPEG_8u() failed - ",status);
00066     return JPEG_INTERNAL_ERROR;
00067   }
00068 
00069   m_table = (IppiEncodeHuffmanSpec*)ippMalloc(size);
00070   if(0 == m_table)
00071   {
00072     LOG0("IPP Error: ippMalloc() failed");
00073     return JPEG_OUT_OF_MEMORY;
00074   }
00075 
00076   return JPEG_OK;
00077 } // CJPEGEncoderHuffmanTable::Create()
00078 
00079 
00080 JERRCODE CJPEGEncoderHuffmanTable::Destroy(void)
00081 {
00082   m_id     = 0;
00083   m_hclass = 0;
00084   m_table  = 0;
00085 
00086   ippsZero_8u(m_bits,sizeof(m_bits));
00087   ippsZero_8u(m_vals,sizeof(m_vals));
00088 
00089   if(0 != m_table)
00090   {
00091     ippFree(m_table);
00092         m_table = 0;
00093   }
00094 
00095   return JPEG_OK;
00096 } // CJPEGEncoderHuffmanTable::Destroy()
00097 
00098 
00099 JERRCODE CJPEGEncoderHuffmanTable::Init(int id,int hclass,Ipp8u* bits,Ipp8u* vals)
00100 {
00101   IppStatus status;
00102 
00103   m_id     = id     & 0x0f;
00104   m_hclass = hclass & 0x0f;
00105 
00106   ippsCopy_8u(bits,m_bits,16);
00107   ippsCopy_8u(vals,m_vals,256);
00108 
00109   status = ippiEncodeHuffmanSpecInit_JPEG_8u(m_bits,m_vals,m_table);
00110   if(ippStsNoErr != status)
00111   {
00112     LOG1("IPP Error: ippiEncodeHuffmanSpecInit_JPEG_8u() failes - ", status);
00113     return JPEG_INTERNAL_ERROR;
00114   }
00115 
00116   return JPEG_OK;
00117 } // CJPEGEncoderHuffmanTable::Init()
00118 
00119 
00120 
00121 
00122 CJPEGEncoderHuffmanState::CJPEGEncoderHuffmanState(void)
00123 {
00124   m_state = 0;
00125   return;
00126 } // ctor
00127 
00128 
00129 CJPEGEncoderHuffmanState::~CJPEGEncoderHuffmanState(void)
00130 {
00131   Destroy();
00132   return;
00133 } // dtor
00134 
00135 
00136 JERRCODE CJPEGEncoderHuffmanState::Create(void)
00137 {
00138   int       size;
00139   IppStatus status;
00140 
00141   status = ippiEncodeHuffmanStateGetBufSize_JPEG_8u(&size);
00142   if(ippStsNoErr != status)
00143   {
00144     LOG1("IPP Error: ippiEncodeHuffmanStateGetBufSize_JPEG_8u() failed - ",status);
00145     return JPEG_INTERNAL_ERROR;
00146   }
00147 
00148   m_state = (IppiEncodeHuffmanState*)ippMalloc(size);
00149   if(0 == m_state)
00150   {
00151     LOG0("IPP Error: ippMalloc() failed");
00152     return JPEG_OUT_OF_MEMORY;
00153   }
00154 
00155   return JPEG_OK;
00156 } // CJPEGEncoderHuffmanState::Create()
00157 
00158 
00159 JERRCODE CJPEGEncoderHuffmanState::Destroy(void)
00160 {
00161   if(0 != m_state)
00162   {
00163     ippFree(m_state);
00164     m_state = 0;
00165   }
00166 
00167   return JPEG_OK;
00168 } // CJPEGEncoderHuffmanState::Destroy()
00169 
00170 
00171 JERRCODE CJPEGEncoderHuffmanState::Init(void)
00172 {
00173   IppStatus status;
00174 
00175   status = ippiEncodeHuffmanStateInit_JPEG_8u(m_state);
00176   if(ippStsNoErr != status)
00177   {
00178     LOG1("IPP Error: ippiEncodeHuffmanStateInit_JPEG_8u() failed - ",status);
00179     return JPEG_INTERNAL_ERROR;
00180   }
00181 
00182   return JPEG_OK;
00183 } // CJPEGEncoderHuffmanState::Init()
00184 


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