jpegbase.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 
00031 
00032 // raw quant tables must be in zigzag order
00033 const Ipp8u DefaultLuminanceQuant[64] =
00034 {
00035   16,  11,  12,  14,  12,  10,  16,  14,
00036   13,  14,  18,  17,  16,  19,  24,  40,
00037   26,  24,  22,  22,  24,  49,  35,  37,
00038   29,  40,  58,  51,  61,  60,  57,  51,
00039   56,  55,  64,  72,  92,  78,  64,  68,
00040   87,  69,  55,  56,  80, 109,  81,  87,
00041   95,  98, 103, 104, 103,  62,  77, 113,
00042  121, 112, 100, 120,  92, 101, 103,  99
00043 };
00044 
00045 
00046 // raw quant tables must be in zigzag order
00047 const Ipp8u DefaultChrominanceQuant[64] =
00048 {
00049   17,  18,  18,  24,  21,  24,  47,  26,
00050   26,  47,  99,  66,  56,  66,  99,  99,
00051   99,  99,  99,  99,  99,  99,  99,  99,
00052   99,  99,  99,  99,  99,  99,  99,  99,
00053   99,  99,  99,  99,  99,  99,  99,  99,
00054   99,  99,  99,  99,  99,  99,  99,  99,
00055   99,  99,  99,  99,  99,  99,  99,  99,
00056   99,  99,  99,  99,  99,  99,  99,  99
00057 };
00058 
00059 
00060 const Ipp8u DefaultLuminanceDCBits[] =
00061 {
00062   0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01,
00063   0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
00064 };
00065 
00066 
00067 const Ipp8u DefaultLuminanceDCValues[] =
00068 {
00069   0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
00070   0x08, 0x09, 0x0a, 0x0b
00071 };
00072 
00073 
00074 const Ipp8u DefaultChrominanceDCBits[] =
00075 {
00076   0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
00077   0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00
00078 };
00079 
00080 
00081 const Ipp8u DefaultChrominanceDCValues[] =
00082 {
00083   0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
00084   0x08, 0x09, 0x0a, 0x0b
00085 };
00086 
00087 
00088 const Ipp8u DefaultLuminanceACBits[] =
00089 {
00090   0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03,
00091   0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d
00092 };
00093 
00094 
00095 const Ipp8u DefaultLuminanceACValues[] =
00096 {
00097   0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
00098   0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
00099   0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
00100   0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
00101   0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
00102   0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
00103   0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
00104   0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
00105   0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
00106   0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
00107   0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
00108   0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
00109   0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
00110   0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
00111   0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
00112   0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
00113   0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
00114   0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
00115   0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
00116   0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
00117   0xf9, 0xfa
00118 };
00119 
00120 
00121 const Ipp8u DefaultChrominanceACBits[] =
00122 {
00123   0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04,
00124   0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77
00125 };
00126 
00127 
00128 const Ipp8u DefaultChrominanceACValues[] =
00129 {
00130   0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
00131   0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
00132   0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
00133   0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
00134   0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
00135   0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
00136   0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
00137   0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
00138   0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
00139   0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
00140   0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
00141   0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
00142   0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
00143   0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
00144   0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
00145   0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
00146   0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
00147   0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
00148   0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
00149   0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
00150   0xf9, 0xfa
00151 };
00152 
00153 
00154 const char* GetErrorStr(JERRCODE code)
00155 {
00156   char* str;
00157 
00158   switch(code)
00159   {
00160     case JPEG_OK:                 str = "no error"; break;
00161     case JPEG_NOT_IMPLEMENTED:    str = "not supported"; break;
00162     case JPEG_INTERNAL_ERROR:     str = "internal error"; break;
00163     case JPEG_BUFF_TOO_SMALL:     str = "buffer too small"; break;
00164     case JPEG_OUT_OF_MEMORY:      str = "out of memory"; break;
00165     case JPEG_BAD_SEGMENT_LENGTH: str = "bad segment length"; break;
00166     case JPEG_BAD_HUFF_TBL:       str = "bad huffman table"; break;
00167     case JPEG_BAD_QUANT_SEGMENT:  str = "bad quant segment"; break;
00168     case JPEG_BAD_SCAN_SEGMENT:   str = "bad scan segment"; break;
00169     case JPEG_BAD_FRAME_SEGMENT:  str = "bad frame segment"; break;
00170     case JPEG_BAD_COMPONENT_ID:   str = "bad component id"; break;
00171     case JPEG_BAD_SAMPLING:       str = "bad sampling factors"; break;
00172     case JPEG_BAD_RESTART:        str = "wrong restart marker"; break;
00173     default:                      str = "unknown code"; break;
00174   }
00175 
00176   return str;
00177 } // GetErrorStr()
00178 
00179 
00180 JERRCODE BITSTREAM::_WRITE_BYTE(int byte)
00181 {
00182   if(currPos == DataLen)
00183     return JPEG_BUFF_TOO_SMALL;
00184 
00185   pData[currPos] = (Ipp8u)byte;
00186   currPos++;
00187 
00188   return JPEG_OK;
00189 } // BITSTREAM::_WRITE_BYTE()
00190 
00191 
00192 JERRCODE BITSTREAM::_WRITE_WORD(int word)
00193 {
00194   JERRCODE jerr;
00195 
00196   jerr = _WRITE_BYTE(word >> 8);
00197   if(JPEG_OK != jerr)
00198     return jerr;
00199 
00200   jerr = _WRITE_BYTE(word);
00201   if(JPEG_OK != jerr)
00202     return jerr;
00203 
00204   return JPEG_OK;
00205 } // BITSTREAM::_WRITE_WORD()
00206 
00207 
00208 JERRCODE BITSTREAM::_READ_BYTE(int* byte)
00209 {
00210   if(currPos == DataLen)
00211     return JPEG_BUFF_TOO_SMALL;
00212 
00213   *byte = pData[currPos];
00214   currPos++;
00215 
00216   return JPEG_OK;
00217 } // BITSTREAM::_READ_BYTE()
00218 
00219 
00220 JERRCODE BITSTREAM::_READ_WORD(int* word)
00221 {
00222   int      hb;
00223   int      lb;
00224   JERRCODE jerr;
00225 
00226   jerr = _READ_BYTE(&hb);
00227   if(JPEG_OK != jerr)
00228     return jerr;
00229 
00230   jerr = _READ_BYTE(&lb);
00231   if(JPEG_OK != jerr)
00232     return jerr;
00233 
00234   *word = (hb << 8) + lb;
00235 
00236   return JPEG_OK;
00237 } // BITSTREAM::_READ_WORD() 
00238 


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