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-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/dng_sdk_1_2/dng_sdk/source/dng_pixel_buffer.h#1 $ */ 00010 /* $DateTime: 2008/03/09 14:29:54 $ */ 00011 /* $Change: 431850 $ */ 00012 /* $Author: tknoll $ */ 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 // For integer pixel types, the maximum value. If zero, it means 00115 // the maximum value that fits in the integer size. Ignored for 00116 // non-integer pixel types. 00117 00118 uint32 fPixelRange; 00119 00120 // Pointer to buffer's data. 00121 00122 void *fData; 00123 00124 // Do we have write-access to this data? 00125 00126 bool fDirty; 00127 00128 private: 00129 00130 void * InternalPixel (int32 row, 00131 int32 col, 00132 uint32 plane = 0) const 00133 { 00134 00135 return (void *) 00136 (((uint8 *) fData) + (int32)fPixelSize * 00137 (fRowStep * (row - fArea.t) + 00138 fColStep * (col - fArea.l) + 00139 fPlaneStep * (int32)(plane - fPlane ))); 00140 00141 } 00142 00143 #if qDebugPixelType 00144 00145 void CheckPixelType (uint32 pixelType) const; 00146 00147 #endif 00148 00149 public: 00150 00151 dng_pixel_buffer (); 00152 00153 dng_pixel_buffer (const dng_pixel_buffer &buffer); 00154 00155 dng_pixel_buffer & operator= (const dng_pixel_buffer &buffer); 00156 00157 virtual ~dng_pixel_buffer (); 00158 00161 00162 uint32 PixelRange () const; 00163 00166 00167 const dng_rect & Area () const 00168 { 00169 return fArea; 00170 } 00171 00174 00175 uint32 Planes () const 00176 { 00177 return fPlanes; 00178 } 00179 00182 00183 int32 RowStep () const 00184 { 00185 return fRowStep; 00186 } 00187 00190 00191 int32 PlaneStep () const 00192 { 00193 return fPlaneStep; 00194 } 00195 00201 00202 const void * ConstPixel (int32 row, 00203 int32 col, 00204 uint32 plane = 0) const 00205 { 00206 00207 return InternalPixel (row, col, plane); 00208 00209 } 00210 00216 00217 void * DirtyPixel (int32 row, 00218 int32 col, 00219 uint32 plane = 0) 00220 { 00221 00222 DNG_ASSERT (fDirty, "Dirty access to const pixel buffer"); 00223 00224 return InternalPixel (row, col, plane); 00225 00226 } 00227 00233 00234 const uint8 * ConstPixel_uint8 (int32 row, 00235 int32 col, 00236 uint32 plane = 0) const 00237 { 00238 00239 ASSERT_PIXEL_TYPE (ttByte); 00240 00241 return (const uint8 *) ConstPixel (row, col, plane); 00242 00243 } 00244 00250 00251 uint8 * DirtyPixel_uint8 (int32 row, 00252 int32 col, 00253 uint32 plane = 0) 00254 { 00255 00256 ASSERT_PIXEL_TYPE (ttByte); 00257 00258 return (uint8 *) DirtyPixel (row, col, plane); 00259 00260 } 00261 00267 00268 const int8 * ConstPixel_int8 (int32 row, 00269 int32 col, 00270 uint32 plane = 0) const 00271 { 00272 00273 ASSERT_PIXEL_TYPE (ttSByte); 00274 00275 return (const int8 *) ConstPixel (row, col, plane); 00276 00277 } 00278 00284 00285 int8 * DirtyPixel_int8 (int32 row, 00286 int32 col, 00287 uint32 plane = 0) 00288 { 00289 00290 ASSERT_PIXEL_TYPE (ttSByte); 00291 00292 return (int8 *) DirtyPixel (row, col, plane); 00293 00294 } 00295 00301 00302 const uint16 * ConstPixel_uint16 (int32 row, 00303 int32 col, 00304 uint32 plane = 0) const 00305 { 00306 00307 ASSERT_PIXEL_TYPE (ttShort); 00308 00309 return (const uint16 *) ConstPixel (row, col, plane); 00310 00311 } 00312 00318 00319 uint16 * DirtyPixel_uint16 (int32 row, 00320 int32 col, 00321 uint32 plane = 0) 00322 { 00323 00324 ASSERT_PIXEL_TYPE (ttShort); 00325 00326 return (uint16 *) DirtyPixel (row, col, plane); 00327 00328 } 00329 00335 00336 const int16 * ConstPixel_int16 (int32 row, 00337 int32 col, 00338 uint32 plane = 0) const 00339 { 00340 00341 ASSERT_PIXEL_TYPE (ttSShort); 00342 00343 return (const int16 *) ConstPixel (row, col, plane); 00344 00345 } 00346 00352 00353 int16 * DirtyPixel_int16 (int32 row, 00354 int32 col, 00355 uint32 plane = 0) 00356 { 00357 00358 ASSERT_PIXEL_TYPE (ttSShort); 00359 00360 return (int16 *) DirtyPixel (row, col, plane); 00361 00362 } 00363 00369 00370 const uint32 * ConstPixel_uint32 (int32 row, 00371 int32 col, 00372 uint32 plane = 0) const 00373 { 00374 00375 ASSERT_PIXEL_TYPE (ttLong); 00376 00377 return (const uint32 *) ConstPixel (row, col, plane); 00378 00379 } 00380 00386 00387 uint32 * DirtyPixel_uint32 (int32 row, 00388 int32 col, 00389 uint32 plane = 0) 00390 { 00391 00392 ASSERT_PIXEL_TYPE (ttLong); 00393 00394 return (uint32 *) DirtyPixel (row, col, plane); 00395 00396 } 00397 00403 00404 const int32 * ConstPixel_int32 (int32 row, 00405 int32 col, 00406 uint32 plane = 0) const 00407 { 00408 00409 ASSERT_PIXEL_TYPE (ttSLong); 00410 00411 return (const int32 *) ConstPixel (row, col, plane); 00412 00413 } 00414 00420 00421 int32 * DirtyPixel_int32 (int32 row, 00422 int32 col, 00423 uint32 plane = 0) 00424 { 00425 00426 ASSERT_PIXEL_TYPE (ttSLong); 00427 00428 return (int32 *) DirtyPixel (row, col, plane); 00429 00430 } 00431 00437 00438 const real32 * ConstPixel_real32 (int32 row, 00439 int32 col, 00440 uint32 plane = 0) const 00441 { 00442 00443 ASSERT_PIXEL_TYPE (ttFloat); 00444 00445 return (const real32 *) ConstPixel (row, col, plane); 00446 00447 } 00448 00454 00455 real32 * DirtyPixel_real32 (int32 row, 00456 int32 col, 00457 uint32 plane = 0) 00458 { 00459 00460 ASSERT_PIXEL_TYPE (ttFloat); 00461 00462 return (real32 *) DirtyPixel (row, col, plane); 00463 00464 } 00465 00471 00472 void SetConstant (const dng_rect &area, 00473 uint32 plane, 00474 uint32 planes, 00475 uint32 value); 00476 00482 00483 void SetConstant_uint8 (const dng_rect &area, 00484 uint32 plane, 00485 uint32 planes, 00486 uint8 value) 00487 { 00488 00489 DNG_ASSERT (fPixelType == ttByte, "Mismatched pixel type"); 00490 00491 SetConstant (area, plane, planes, (uint32) value); 00492 00493 } 00494 00500 00501 void SetConstant_uint16 (const dng_rect &area, 00502 uint32 plane, 00503 uint32 planes, 00504 uint16 value) 00505 { 00506 00507 DNG_ASSERT (fPixelType == ttShort, "Mismatched pixel type"); 00508 00509 SetConstant (area, plane, planes, (uint32) value); 00510 00511 } 00512 00518 00519 void SetConstant_int16 (const dng_rect &area, 00520 uint32 plane, 00521 uint32 planes, 00522 int16 value) 00523 { 00524 00525 DNG_ASSERT (fPixelType == ttSShort, "Mismatched pixel type"); 00526 00527 SetConstant (area, plane, planes, (uint32) (uint16) value); 00528 00529 } 00530 00536 00537 void SetConstant_uint32 (const dng_rect &area, 00538 uint32 plane, 00539 uint32 planes, 00540 uint32 value) 00541 { 00542 00543 DNG_ASSERT (fPixelType == ttLong, "Mismatched pixel type"); 00544 00545 SetConstant (area, plane, planes, value); 00546 00547 } 00548 00554 00555 void SetConstant_real32 (const dng_rect &area, 00556 uint32 plane, 00557 uint32 planes, 00558 real32 value) 00559 { 00560 00561 DNG_ASSERT (fPixelType == ttFloat, "Mismatched pixel type"); 00562 00563 union 00564 { 00565 uint32 i; 00566 real32 f; 00567 } x; 00568 00569 x.f = value; 00570 00571 SetConstant (area, plane, planes, x.i); 00572 00573 } 00574 00580 00581 void SetZero (const dng_rect &area, 00582 uint32 plane, 00583 uint32 planes); 00584 00591 00592 void CopyArea (const dng_pixel_buffer &src, 00593 const dng_rect &area, 00594 uint32 srcPlane, 00595 uint32 dstPlane, 00596 uint32 planes); 00597 00603 00604 void CopyArea (const dng_pixel_buffer &src, 00605 const dng_rect &area, 00606 uint32 plane, 00607 uint32 planes) 00608 { 00609 00610 CopyArea (src, area, plane, plane, planes); 00611 00612 } 00613 00618 00619 static dng_point RepeatPhase (const dng_rect &srcArea, 00620 const dng_rect &dstArea); 00621 00626 00627 void RepeatArea (const dng_rect &srcArea, 00628 const dng_rect &dstArea); 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 00655 00656 bool EqualArea (const dng_pixel_buffer &rhs, 00657 const dng_rect &area, 00658 uint32 plane, 00659 uint32 planes) const; 00660 00661 }; 00662 00663 /*****************************************************************************/ 00664 00665 #endif 00666 00667 /*****************************************************************************/ | |||
