DocumentationOverviewBuilding ASL Documentation Library Wiki Docs Indices Browse Perforce More InfoRelease NotesWiki Site Search License Success Stories Contributors MediaDownloadPerforce Depots SupportASL SourceForge HomeMailing Lists Discussion Forums Report Bugs Suggest Features Contribute to ASL RSSShort-text newsFull-text news File releases Other Adobe ProjectsAdobe AirAdobe GIL Adobe Labs Adobe Media Gallery Adobe XMP Tamarin project (Mozilla Foundation) Other ResourcesBoostRIAForge SGI STL |
dng_resample.h00001 /*****************************************************************************/ 00002 // Copyright 2006-2007 Adobe Systems Incorporated 00003 // All Rights Reserved. 00004 // 00005 // NOTICE: Adobe permits you to use, modify, and distribute this file in 00006 // accordance with the terms of the Adobe license agreement accompanying it. 00007 /*****************************************************************************/ 00008 00009 /* $Id: //mondo/workarea/stern/camera_raw/dng_sdk/source/dng_resample.h#7 $ */ 00010 /* $DateTime: 2008/11/05 10:44:13 $ */ 00011 /* $Change: 519180 $ */ 00012 /* $Author: stern $ */ 00013 00014 /*****************************************************************************/ 00015 00016 #ifndef __dng_resample__ 00017 #define __dng_resample__ 00018 00019 /*****************************************************************************/ 00020 00021 #include "dng_assertions.h" 00022 #include "dng_auto_ptr.h" 00023 #include "dng_classes.h" 00024 #include "dng_memory.h" 00025 #include "dng_point.h" 00026 #include "dng_types.h" 00027 00028 /*****************************************************************************/ 00029 00030 class dng_resample_function 00031 { 00032 00033 public: 00034 00035 dng_resample_function () 00036 { 00037 } 00038 00039 virtual ~dng_resample_function () 00040 { 00041 } 00042 00043 virtual real64 Extent () const = 0; 00044 00045 virtual real64 Evaluate (real64 x) const = 0; 00046 00047 }; 00048 00049 /*****************************************************************************/ 00050 00051 class dng_resample_bicubic: public dng_resample_function 00052 { 00053 00054 public: 00055 00056 virtual real64 Extent () const; 00057 00058 virtual real64 Evaluate (real64 x) const; 00059 00060 static const dng_resample_function & Get (); 00061 00062 }; 00063 00064 /******************************************************************************/ 00065 00066 const uint32 kResampleSubsampleBits = 7; 00067 const uint32 kResampleSubsampleCount = 1 << kResampleSubsampleBits; 00068 const uint32 kResampleSubsampleMask = kResampleSubsampleCount - 1; 00069 00070 /*****************************************************************************/ 00071 00072 class dng_resample_coords 00073 { 00074 00075 protected: 00076 00077 int32 fOrigin; 00078 00079 AutoPtr<dng_memory_block> fCoords; 00080 00081 public: 00082 00083 dng_resample_coords (); 00084 00085 virtual ~dng_resample_coords (); 00086 00087 void Initialize (int32 srcOrigin, 00088 int32 dstOrigin, 00089 uint32 srcCount, 00090 uint32 dstCount, 00091 dng_memory_allocator &allocator); 00092 00093 const int32 * Coords (int32 index) const 00094 { 00095 return fCoords->Buffer_int32 () + (index - fOrigin); 00096 } 00097 00098 const int32 Pixel (int32 index) const 00099 { 00100 return Coords (index) [0] >> kResampleSubsampleBits; 00101 } 00102 00103 }; 00104 00105 /*****************************************************************************/ 00106 00107 class dng_resample_weights 00108 { 00109 00110 protected: 00111 00112 uint32 fRadius; 00113 00114 uint32 fWeightStep; 00115 00116 AutoPtr<dng_memory_block> fWeights32; 00117 AutoPtr<dng_memory_block> fWeights16; 00118 00119 public: 00120 00121 dng_resample_weights (); 00122 00123 virtual ~dng_resample_weights (); 00124 00125 void Initialize (real64 scale, 00126 const dng_resample_function &kernel, 00127 dng_memory_allocator &allocator); 00128 00129 uint32 Radius () const 00130 { 00131 return fRadius; 00132 } 00133 00134 uint32 Width () const 00135 { 00136 return fRadius * 2; 00137 } 00138 00139 int32 Offset () const 00140 { 00141 return 1 - (int32) fRadius; 00142 } 00143 00144 uint32 Step () const 00145 { 00146 return fWeightStep; 00147 } 00148 00149 const real32 *Weights32 (uint32 fract) const 00150 { 00151 00152 DNG_ASSERT (fWeights32->Buffer (), "Weights32 is NULL"); 00153 00154 return fWeights32->Buffer_real32 () + fract * fWeightStep; 00155 00156 } 00157 00158 const int16 *Weights16 (uint32 fract) const 00159 { 00160 00161 DNG_ASSERT (fWeights16->Buffer (), "Weights16 is NULL"); 00162 00163 return fWeights16->Buffer_int16 () + fract * fWeightStep; 00164 00165 } 00166 00167 }; 00168 00169 /*****************************************************************************/ 00170 00171 const uint32 kResampleSubsampleBits2D = 5; 00172 const uint32 kResampleSubsampleCount2D = 1 << kResampleSubsampleBits2D; 00173 const uint32 kResampleSubsampleMask2D = kResampleSubsampleCount2D - 1; 00174 00175 /*****************************************************************************/ 00176 00177 class dng_resample_weights_2d 00178 { 00179 00180 protected: 00181 00182 uint32 fRadius; 00183 00184 uint32 fRowStep; 00185 uint32 fColStep; 00186 00187 AutoPtr<dng_memory_block> fWeights32; 00188 AutoPtr<dng_memory_block> fWeights16; 00189 00190 public: 00191 00192 dng_resample_weights_2d (); 00193 00194 virtual ~dng_resample_weights_2d (); 00195 00196 void Initialize (const dng_resample_function &kernel, 00197 dng_memory_allocator &allocator); 00198 00199 uint32 Radius () const 00200 { 00201 return fRadius; 00202 } 00203 00204 uint32 Width () const 00205 { 00206 return fRadius * 2; 00207 } 00208 00209 int32 Offset () const 00210 { 00211 return 1 - (int32) fRadius; 00212 } 00213 00214 uint32 RowStep () const 00215 { 00216 return fRowStep; 00217 } 00218 00219 uint32 ColStep () const 00220 { 00221 return fColStep; 00222 } 00223 00224 const real32 *Weights32 (dng_point fract) const 00225 { 00226 00227 DNG_ASSERT (fWeights32->Buffer (), "Weights32 is NULL"); 00228 00229 const uint32 offset = fract.v * fRowStep + fract.h * fColStep; 00230 00231 return fWeights32->Buffer_real32 () + offset; 00232 00233 } 00234 00235 const int16 *Weights16 (dng_point fract) const 00236 { 00237 00238 DNG_ASSERT (fWeights16->Buffer (), "Weights16 is NULL"); 00239 00240 const uint32 offset = fract.v * fRowStep + fract.h * fColStep; 00241 00242 return fWeights16->Buffer_int16 () + offset; 00243 00244 } 00245 00246 }; 00247 00248 /*****************************************************************************/ 00249 00250 void ResampleImage (dng_host &host, 00251 const dng_image &srcImage, 00252 dng_image &dstImage, 00253 const dng_rect &srcBounds, 00254 const dng_rect &dstBounds, 00255 const dng_resample_function &kernel); 00256 00257 /*****************************************************************************/ 00258 00259 #endif 00260 00261 /*****************************************************************************/ |