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_pixel_buffer.hGo to the documentation of this file.00001 /*****************************************************************************/ 00002 // Copyright 2006-2008 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_pixel_buffer.h#19 $ */ 00010 /* $DateTime: 2008/12/19 14:16:25 $ */ 00011 /* $Change: 528620 $ */ 00012 /* $Author: stern $ */ 00013 00018 /*****************************************************************************/ 00019 00020 #ifndef __dng_pixel_buffer__ 00021 #define __dng_pixel_buffer__ 00022 00023 /*****************************************************************************/ 00024 00025 #include "dng_assertions.h" 00026 #include "dng_rect.h" 00027 #include "dng_tag_types.h" 00028 00029 /*****************************************************************************/ 00030 00032 00033 void OptimizeOrder (const void *&sPtr, 00034 void *&dPtr, 00035 uint32 sPixelSize, 00036 uint32 dPixelSize, 00037 uint32 &count0, 00038 uint32 &count1, 00039 uint32 &count2, 00040 int32 &sStep0, 00041 int32 &sStep1, 00042 int32 &sStep2, 00043 int32 &dStep0, 00044 int32 &dStep1, 00045 int32 &dStep2); 00046 00047 void OptimizeOrder (const void *&sPtr, 00048 uint32 sPixelSize, 00049 uint32 &count0, 00050 uint32 &count1, 00051 uint32 &count2, 00052 int32 &sStep0, 00053 int32 &sStep1, 00054 int32 &sStep2); 00055 00056 void OptimizeOrder (void *&dPtr, 00057 uint32 dPixelSize, 00058 uint32 &count0, 00059 uint32 &count1, 00060 uint32 &count2, 00061 int32 &dStep0, 00062 int32 &dStep1, 00063 int32 &dStep2); 00064 00065 /*****************************************************************************/ 00066 00067 #define qDebugPixelType 0 00068 00069 #if qDebugPixelType 00070 00071 #define ASSERT_PIXEL_TYPE(typeVal) CheckPixelType (typeVal) 00072 00073 #else 00074 00075 #define ASSERT_PIXEL_TYPE(typeVal) DNG_ASSERT (fPixelType == typeVal, "Pixel type access mismatch") 00076 00077 #endif 00078 00079 /*****************************************************************************/ 00080 00085 00086 class dng_pixel_buffer 00087 { 00088 00089 public: 00090 00091 // Area this buffer holds. 00092 00093 dng_rect fArea; 00094 00095 // Range of planes this buffer holds. 00096 00097 uint32 fPlane; 00098 uint32 fPlanes; 00099 00100 // Steps between pixels. 00101 00102 int32 fRowStep; 00103 int32 fColStep; 00104 int32 fPlaneStep; 00105 00106 // Basic pixel type (TIFF tag type code). 00107 00108 uint32 fPixelType; 00109 00110 // Size of pixel type in bytes. 00111 00112 uint32 fPixelSize; 00113 00114 // Pointer to buffer's data. 00115 00116 void *fData; 00117 00118 // Do we have write-access to this data? 00119 00120 bool fDirty; 00121 00122 private: 00123 00124 void * InternalPixel (int32 row, 00125 int32 col, 00126 uint32 plane = 0) const 00127 { 00128 00129 return (void *) 00130 (((uint8 *) fData) + (int32)fPixelSize * 00131 (fRowStep * (row - fArea.t) + 00132 fColStep * (col - fArea.l) + 00133 fPlaneStep * (int32)(plane - fPlane ))); 00134 00135 } 00136 00137 #if qDebugPixelType 00138 00139 void CheckPixelType (uint32 pixelType) const; 00140 00141 #endif 00142 00143 public: 00144 00145 dng_pixel_buffer (); 00146 00147 dng_pixel_buffer (const dng_pixel_buffer &buffer); 00148 00149 dng_pixel_buffer & operator= (const dng_pixel_buffer &buffer); 00150 00151 virtual ~dng_pixel_buffer (); 00152 00155 00156 uint32 PixelRange () const; 00157 00160 00161 const dng_rect & Area () const 00162 { 00163 return fArea; 00164 } 00165 00168 00169 uint32 Planes () const 00170 { 00171 return fPlanes; 00172 } 00173 00176 00177 int32 RowStep () const 00178 { 00179 return fRowStep; 00180 } 00181 00184 00185 int32 PlaneStep () const 00186 { 00187 return fPlaneStep; 00188 } 00189 00195 00196 const void * ConstPixel (int32 row, 00197 int32 col, 00198 uint32 plane = 0) const 00199 { 00200 00201 return InternalPixel (row, col, plane); 00202 00203 } 00204 00210 00211 void * DirtyPixel (int32 row, 00212 int32 col, 00213 uint32 plane = 0) 00214 { 00215 00216 DNG_ASSERT (fDirty, "Dirty access to const pixel buffer"); 00217 00218 return InternalPixel (row, col, plane); 00219 00220 } 00221 00227 00228 const uint8 * ConstPixel_uint8 (int32 row, 00229 int32 col, 00230 uint32 plane = 0) const 00231 { 00232 00233 ASSERT_PIXEL_TYPE (ttByte); 00234 00235 return (const uint8 *) ConstPixel (row, col, plane); 00236 00237 } 00238 00244 00245 uint8 * DirtyPixel_uint8 (int32 row, 00246 int32 col, 00247 uint32 plane = 0) 00248 { 00249 00250 ASSERT_PIXEL_TYPE (ttByte); 00251 00252 return (uint8 *) DirtyPixel (row, col, plane); 00253 00254 } 00255 00261 00262 const int8 * ConstPixel_int8 (int32 row, 00263 int32 col, 00264 uint32 plane = 0) const 00265 { 00266 00267 ASSERT_PIXEL_TYPE (ttSByte); 00268 00269 return (const int8 *) ConstPixel (row, col, plane); 00270 00271 } 00272 00278 00279 int8 * DirtyPixel_int8 (int32 row, 00280 int32 col, 00281 uint32 plane = 0) 00282 { 00283 00284 ASSERT_PIXEL_TYPE (ttSByte); 00285 00286 return (int8 *) DirtyPixel (row, col, plane); 00287 00288 } 00289 00295 00296 const uint16 * ConstPixel_uint16 (int32 row, 00297 int32 col, 00298 uint32 plane = 0) const 00299 { 00300 00301 ASSERT_PIXEL_TYPE (ttShort); 00302 00303 return (const uint16 *) ConstPixel (row, col, plane); 00304 00305 } 00306 00312 00313 uint16 * DirtyPixel_uint16 (int32 row, 00314 int32 col, 00315 uint32 plane = 0) 00316 { 00317 00318 ASSERT_PIXEL_TYPE (ttShort); 00319 00320 return (uint16 *) DirtyPixel (row, col, plane); 00321 00322 } 00323 00329 00330 const int16 * ConstPixel_int16 (int32 row, 00331 int32 col, 00332 uint32 plane = 0) const 00333 { 00334 00335 ASSERT_PIXEL_TYPE (ttSShort); 00336 00337 return (const int16 *) ConstPixel (row, col, plane); 00338 00339 } 00340 00346 00347 int16 * DirtyPixel_int16 (int32 row, 00348 int32 col, 00349 uint32 plane = 0) 00350 { 00351 00352 ASSERT_PIXEL_TYPE (ttSShort); 00353 00354 return (int16 *) DirtyPixel (row, col, plane); 00355 00356 } 00357 00363 00364 const uint32 * ConstPixel_uint32 (int32 row, 00365 int32 col, 00366 uint32 plane = 0) const 00367 { 00368 00369 ASSERT_PIXEL_TYPE (ttLong); 00370 00371 return (const uint32 *) ConstPixel (row, col, plane); 00372 00373 } 00374 00380 00381 uint32 * DirtyPixel_uint32 (int32 row, 00382 int32 col, 00383 uint32 plane = 0) 00384 { 00385 00386 ASSERT_PIXEL_TYPE (ttLong); 00387 00388 return (uint32 *) DirtyPixel (row, col, plane); 00389 00390 } 00391 00397 00398 const int32 * ConstPixel_int32 (int32 row, 00399 int32 col, 00400 uint32 plane = 0) const 00401 { 00402 00403 ASSERT_PIXEL_TYPE (ttSLong); 00404 00405 return (const int32 *) ConstPixel (row, col, plane); 00406 00407 } 00408 00414 00415 int32 * DirtyPixel_int32 (int32 row, 00416 int32 col, 00417 uint32 plane = 0) 00418 { 00419 00420 ASSERT_PIXEL_TYPE (ttSLong); 00421 00422 return (int32 *) DirtyPixel (row, col, plane); 00423 00424 } 00425 00431 00432 const real32 * ConstPixel_real32 (int32 row, 00433 int32 col, 00434 uint32 plane = 0) const 00435 { 00436 00437 ASSERT_PIXEL_TYPE (ttFloat); 00438 00439 return (const real32 *) ConstPixel (row, col, plane); 00440 00441 } 00442 00448 00449 real32 * DirtyPixel_real32 (int32 row, 00450 int32 col, 00451 uint32 plane = 0) 00452 { 00453 00454 ASSERT_PIXEL_TYPE (ttFloat); 00455 00456 return (real32 *) DirtyPixel (row, col, plane); 00457 00458 } 00459 00465 00466 void SetConstant (const dng_rect &area, 00467 uint32 plane, 00468 uint32 planes, 00469 uint32 value); 00470 00476 00477 void SetConstant_uint8 (const dng_rect &area, 00478 uint32 plane, 00479 uint32 planes, 00480 uint8 value) 00481 { 00482 00483 DNG_ASSERT (fPixelType == ttByte, "Mismatched pixel type"); 00484 00485 SetConstant (area, plane, planes, (uint32) value); 00486 00487 } 00488 00494 00495 void SetConstant_uint16 (const dng_rect &area, 00496 uint32 plane, 00497 uint32 planes, 00498 uint16 value) 00499 { 00500 00501 DNG_ASSERT (fPixelType == ttShort, "Mismatched pixel type"); 00502 00503 SetConstant (area, plane, planes, (uint32) value); 00504 00505 } 00506 00512 00513 void SetConstant_int16 (const dng_rect &area, 00514 uint32 plane, 00515 uint32 planes, 00516 int16 value) 00517 { 00518 00519 DNG_ASSERT (fPixelType == ttSShort, "Mismatched pixel type"); 00520 00521 SetConstant (area, plane, planes, (uint32) (uint16) value); 00522 00523 } 00524 00530 00531 void SetConstant_uint32 (const dng_rect &area, 00532 uint32 plane, 00533 uint32 planes, 00534 uint32 value) 00535 { 00536 00537 DNG_ASSERT (fPixelType == ttLong, "Mismatched pixel type"); 00538 00539 SetConstant (area, plane, planes, value); 00540 00541 } 00542 00548 00549 void SetConstant_real32 (const dng_rect &area, 00550 uint32 plane, 00551 uint32 planes, 00552 real32 value) 00553 { 00554 00555 DNG_ASSERT (fPixelType == ttFloat, "Mismatched pixel type"); 00556 00557 union 00558 { 00559 uint32 i; 00560 real32 f; 00561 } x; 00562 00563 x.f = value; 00564 00565 SetConstant (area, plane, planes, x.i); 00566 00567 } 00568 00574 00575 void SetZero (const dng_rect &area, 00576 uint32 plane, 00577 uint32 planes); 00578 00585 00586 void CopyArea (const dng_pixel_buffer &src, 00587 const dng_rect &area, 00588 uint32 srcPlane, 00589 uint32 dstPlane, 00590 uint32 planes); 00591 00597 00598 void CopyArea (const dng_pixel_buffer &src, 00599 const dng_rect &area, 00600 uint32 plane, 00601 uint32 planes) 00602 { 00603 00604 CopyArea (src, area, plane, plane, planes); 00605 00606 } 00607 00612 00613 static dng_point RepeatPhase (const dng_rect &srcArea, 00614 const dng_rect &dstArea); 00615 00620 00621 void RepeatArea (const dng_rect &srcArea, 00622 const dng_rect &dstArea); 00623 00625 00626 void RepeatSubArea (const dng_rect subArea, 00627 uint32 repeatV = 1, 00628 uint32 repeatH = 1); 00629 00632 00633 void ShiftRight (uint32 shift); 00634 00637 00638 void FlipH (); 00639 00642 00643 void FlipV (); 00644 00647 00648 void FlipZ (); // Flip planes 00649 00656 00657 bool EqualArea (const dng_pixel_buffer &rhs, 00658 const dng_rect &area, 00659 uint32 plane, 00660 uint32 planes) const; 00661 00668 00669 real64 MaximumDifference (const dng_pixel_buffer &rhs, 00670 const dng_rect &area, 00671 uint32 plane, 00672 uint32 planes) const; 00673 00674 }; 00675 00676 /*****************************************************************************/ 00677 00678 #endif 00679 00680 /*****************************************************************************/ |