Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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 }
00048
00049
00050 CJPEGEncoderHuffmanTable::~CJPEGEncoderHuffmanTable(void)
00051 {
00052 Destroy();
00053 return;
00054 }
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 }
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 }
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 }
00118
00119
00120
00121
00122 CJPEGEncoderHuffmanState::CJPEGEncoderHuffmanState(void)
00123 {
00124 m_state = 0;
00125 return;
00126 }
00127
00128
00129 CJPEGEncoderHuffmanState::~CJPEGEncoderHuffmanState(void)
00130 {
00131 Destroy();
00132 return;
00133 }
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 }
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 }
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 }
00184