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 __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 }
00050
00051
00052 CJPEGDecoderHuffmanTable::~CJPEGDecoderHuffmanTable(void)
00053 {
00054 Destroy();
00055 return;
00056 }
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 }
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 }
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 }
00126
00127
00128
00129
00130 CJPEGDecoderHuffmanState::CJPEGDecoderHuffmanState(void)
00131 {
00132 m_state = 0;
00133 return;
00134 }
00135
00136
00137 CJPEGDecoderHuffmanState::~CJPEGDecoderHuffmanState(void)
00138 {
00139 Destroy();
00140 return;
00141 }
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 }
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 }
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 }