| 1 |
/*****************************************************************************/ |
| 2 |
// Copyright 2006-2019 Adobe Systems Incorporated |
| 3 |
// All Rights Reserved. |
| 4 |
// |
| 5 |
// NOTICE: Adobe permits you to use, modify, and distribute this file in |
| 6 |
// accordance with the terms of the Adobe license agreement accompanying it. |
| 7 |
/*****************************************************************************/ |
| 8 |
|
| 9 |
#ifndef __dng_reference__ |
| 10 |
#define __dng_reference__ |
| 11 |
|
| 12 |
/*****************************************************************************/ |
| 13 |
|
| 14 |
#include "dng_bottlenecks.h" |
| 15 |
#include "dng_simd_type.h" |
| 16 |
#include "dng_flags.h" |
| 17 |
|
| 18 |
/*****************************************************************************/ |
| 19 |
|
| 20 |
void RefZeroBytes (void *dPtr, |
| 21 |
uint32 count); |
| 22 |
|
| 23 |
void RefCopyBytes (const void *sPtr, |
| 24 |
void *dPtr, |
| 25 |
uint32 count); |
| 26 |
|
| 27 |
/*****************************************************************************/ |
| 28 |
|
| 29 |
void RefSwapBytes16 (uint16 *dPtr, |
| 30 |
uint32 count); |
| 31 |
|
| 32 |
void RefSwapBytes32 (uint32 *dPtr, |
| 33 |
uint32 count); |
| 34 |
|
| 35 |
/*****************************************************************************/ |
| 36 |
|
| 37 |
void RefSetArea8 (uint8 *dPtr, |
| 38 |
uint8 value, |
| 39 |
uint32 rows, |
| 40 |
uint32 cols, |
| 41 |
uint32 planes, |
| 42 |
int32 rowStep, |
| 43 |
int32 colStep, |
| 44 |
int32 planeStep); |
| 45 |
|
| 46 |
template <SIMDType simd, typename destType> |
| 47 |
void RefSetArea (destType *dPtr, |
| 48 |
destType value, |
| 49 |
uint32 rows, |
| 50 |
uint32 cols, |
| 51 |
uint32 planes, |
| 52 |
int32 rowStep, |
| 53 |
int32 colStep, |
| 54 |
int32 planeStep); |
| 55 |
|
| 56 |
/*****************************************************************************/ |
| 57 |
|
| 58 |
void RefCopyArea8 (const uint8 *sPtr, |
| 59 |
uint8 *dPtr, |
| 60 |
uint32 rows, |
| 61 |
uint32 cols, |
| 62 |
uint32 planes, |
| 63 |
int32 sRowStep, |
| 64 |
int32 sColStep, |
| 65 |
int32 sPlaneStep, |
| 66 |
int32 dRowStep, |
| 67 |
int32 dColStep, |
| 68 |
int32 dPlaneStep); |
| 69 |
|
| 70 |
void RefCopyArea16 (const uint16 *sPtr, |
| 71 |
uint16 *dPtr, |
| 72 |
uint32 rows, |
| 73 |
uint32 cols, |
| 74 |
uint32 planes, |
| 75 |
int32 sRowStep, |
| 76 |
int32 sColStep, |
| 77 |
int32 sPlaneStep, |
| 78 |
int32 dRowStep, |
| 79 |
int32 dColStep, |
| 80 |
int32 dPlaneStep); |
| 81 |
|
| 82 |
void RefCopyArea32 (const uint32 *sPtr, |
| 83 |
uint32 *dPtr, |
| 84 |
uint32 rows, |
| 85 |
uint32 cols, |
| 86 |
uint32 planes, |
| 87 |
int32 sRowStep, |
| 88 |
int32 sColStep, |
| 89 |
int32 sPlaneStep, |
| 90 |
int32 dRowStep, |
| 91 |
int32 dColStep, |
| 92 |
int32 dPlaneStep); |
| 93 |
|
| 94 |
void RefCopyArea8_16 (const uint8 *sPtr, |
| 95 |
uint16 *dPtr, |
| 96 |
uint32 rows, |
| 97 |
uint32 cols, |
| 98 |
uint32 planes, |
| 99 |
int32 sRowStep, |
| 100 |
int32 sColStep, |
| 101 |
int32 sPlaneStep, |
| 102 |
int32 dRowStep, |
| 103 |
int32 dColStep, |
| 104 |
int32 dPlaneStep); |
| 105 |
|
| 106 |
void RefCopyArea8_S16 (const uint8 *sPtr, |
| 107 |
int16 *dPtr, |
| 108 |
uint32 rows, |
| 109 |
uint32 cols, |
| 110 |
uint32 planes, |
| 111 |
int32 sRowStep, |
| 112 |
int32 sColStep, |
| 113 |
int32 sPlaneStep, |
| 114 |
int32 dRowStep, |
| 115 |
int32 dColStep, |
| 116 |
int32 dPlaneStep); |
| 117 |
|
| 118 |
void RefCopyArea8_32 (const uint8 *sPtr, |
| 119 |
uint32 *dPtr, |
| 120 |
uint32 rows, |
| 121 |
uint32 cols, |
| 122 |
uint32 planes, |
| 123 |
int32 sRowStep, |
| 124 |
int32 sColStep, |
| 125 |
int32 sPlaneStep, |
| 126 |
int32 dRowStep, |
| 127 |
int32 dColStep, |
| 128 |
int32 dPlaneStep); |
| 129 |
|
| 130 |
template <SIMDType simd> |
| 131 |
void RefCopyArea16_S16 (const uint16 *sPtr, |
| 132 |
int16 *dPtr, |
| 133 |
uint32 rows, |
| 134 |
uint32 cols, |
| 135 |
uint32 planes, |
| 136 |
int32 sRowStep, |
| 137 |
int32 sColStep, |
| 138 |
int32 sPlaneStep, |
| 139 |
int32 dRowStep, |
| 140 |
int32 dColStep, |
| 141 |
int32 dPlaneStep); |
| 142 |
|
| 143 |
void RefCopyArea16_32 (const uint16 *sPtr, |
| 144 |
uint32 *dPtr, |
| 145 |
uint32 rows, |
| 146 |
uint32 cols, |
| 147 |
uint32 planes, |
| 148 |
int32 sRowStep, |
| 149 |
int32 sColStep, |
| 150 |
int32 sPlaneStep, |
| 151 |
int32 dRowStep, |
| 152 |
int32 dColStep, |
| 153 |
int32 dPlaneStep); |
| 154 |
|
| 155 |
void RefCopyArea8_R32 (const uint8 *sPtr, |
| 156 |
real32 *dPtr, |
| 157 |
uint32 rows, |
| 158 |
uint32 cols, |
| 159 |
uint32 planes, |
| 160 |
int32 sRowStep, |
| 161 |
int32 sColStep, |
| 162 |
int32 sPlaneStep, |
| 163 |
int32 dRowStep, |
| 164 |
int32 dColStep, |
| 165 |
int32 dPlaneStep, |
| 166 |
uint32 pixelRange); |
| 167 |
|
| 168 |
void RefCopyArea16_R32 (const uint16 *sPtr, |
| 169 |
real32 *dPtr, |
| 170 |
uint32 rows, |
| 171 |
uint32 cols, |
| 172 |
uint32 planes, |
| 173 |
int32 sRowStep, |
| 174 |
int32 sColStep, |
| 175 |
int32 sPlaneStep, |
| 176 |
int32 dRowStep, |
| 177 |
int32 dColStep, |
| 178 |
int32 dPlaneStep, |
| 179 |
uint32 pixelRange); |
| 180 |
|
| 181 |
void RefCopyAreaS16_R32 (const int16 *sPtr, |
| 182 |
real32 *dPtr, |
| 183 |
uint32 rows, |
| 184 |
uint32 cols, |
| 185 |
uint32 planes, |
| 186 |
int32 sRowStep, |
| 187 |
int32 sColStep, |
| 188 |
int32 sPlaneStep, |
| 189 |
int32 dRowStep, |
| 190 |
int32 dColStep, |
| 191 |
int32 dPlaneStep, |
| 192 |
uint32 pixelRange); |
| 193 |
|
| 194 |
void RefCopyAreaR32_8 (const real32 *sPtr, |
| 195 |
uint8 *dPtr, |
| 196 |
uint32 rows, |
| 197 |
uint32 cols, |
| 198 |
uint32 planes, |
| 199 |
int32 sRowStep, |
| 200 |
int32 sColStep, |
| 201 |
int32 sPlaneStep, |
| 202 |
int32 dRowStep, |
| 203 |
int32 dColStep, |
| 204 |
int32 dPlaneStep, |
| 205 |
uint32 pixelRange); |
| 206 |
|
| 207 |
void RefCopyAreaR32_16 (const real32 *sPtr, |
| 208 |
uint16 *dPtr, |
| 209 |
uint32 rows, |
| 210 |
uint32 cols, |
| 211 |
uint32 planes, |
| 212 |
int32 sRowStep, |
| 213 |
int32 sColStep, |
| 214 |
int32 sPlaneStep, |
| 215 |
int32 dRowStep, |
| 216 |
int32 dColStep, |
| 217 |
int32 dPlaneStep, |
| 218 |
uint32 pixelRange); |
| 219 |
|
| 220 |
void RefCopyAreaR32_S16 (const real32 *sPtr, |
| 221 |
int16 *dPtr, |
| 222 |
uint32 rows, |
| 223 |
uint32 cols, |
| 224 |
uint32 planes, |
| 225 |
int32 sRowStep, |
| 226 |
int32 sColStep, |
| 227 |
int32 sPlaneStep, |
| 228 |
int32 dRowStep, |
| 229 |
int32 dColStep, |
| 230 |
int32 dPlaneStep, |
| 231 |
uint32 pixelRange); |
| 232 |
|
| 233 |
/*****************************************************************************/ |
| 234 |
|
| 235 |
void RefRepeatArea8 (const uint8 *sPtr, |
| 236 |
uint8 *dPtr, |
| 237 |
uint32 rows, |
| 238 |
uint32 cols, |
| 239 |
uint32 planes, |
| 240 |
int32 rowStep, |
| 241 |
int32 colStep, |
| 242 |
int32 planeStep, |
| 243 |
uint32 repeatV, |
| 244 |
uint32 repeatH, |
| 245 |
uint32 phaseV, |
| 246 |
uint32 phaseH); |
| 247 |
|
| 248 |
void RefRepeatArea16 (const uint16 *sPtr, |
| 249 |
uint16 *dPtr, |
| 250 |
uint32 rows, |
| 251 |
uint32 cols, |
| 252 |
uint32 planes, |
| 253 |
int32 rowStep, |
| 254 |
int32 colStep, |
| 255 |
int32 planeStep, |
| 256 |
uint32 repeatV, |
| 257 |
uint32 repeatH, |
| 258 |
uint32 phaseV, |
| 259 |
uint32 phaseH); |
| 260 |
|
| 261 |
void RefRepeatArea32 (const uint32 *sPtr, |
| 262 |
uint32 *dPtr, |
| 263 |
uint32 rows, |
| 264 |
uint32 cols, |
| 265 |
uint32 planes, |
| 266 |
int32 rowStep, |
| 267 |
int32 colStep, |
| 268 |
int32 planeStep, |
| 269 |
uint32 repeatV, |
| 270 |
uint32 repeatH, |
| 271 |
uint32 phaseV, |
| 272 |
uint32 phaseH); |
| 273 |
|
| 274 |
/*****************************************************************************/ |
| 275 |
|
| 276 |
void RefShiftRight16 (uint16 *dPtr, |
| 277 |
uint32 rows, |
| 278 |
uint32 cols, |
| 279 |
uint32 planes, |
| 280 |
int32 rowStep, |
| 281 |
int32 colStep, |
| 282 |
int32 planeStep, |
| 283 |
uint32 shift); |
| 284 |
|
| 285 |
/*****************************************************************************/ |
| 286 |
|
| 287 |
void RefBilinearRow16 (const uint16 *sPtr, |
| 288 |
uint16 *dPtr, |
| 289 |
uint32 cols, |
| 290 |
uint32 patPhase, |
| 291 |
uint32 patCount, |
| 292 |
const uint32 * kernCounts, |
| 293 |
const int32 * const * kernOffsets, |
| 294 |
const uint16 * const * kernWeights, |
| 295 |
uint32 sShift); |
| 296 |
|
| 297 |
void RefBilinearRow32 (const real32 *sPtr, |
| 298 |
real32 *dPtr, |
| 299 |
uint32 cols, |
| 300 |
uint32 patPhase, |
| 301 |
uint32 patCount, |
| 302 |
const uint32 * kernCounts, |
| 303 |
const int32 * const * kernOffsets, |
| 304 |
const real32 * const * kernWeights, |
| 305 |
uint32 sShift); |
| 306 |
|
| 307 |
/*****************************************************************************/ |
| 308 |
|
| 309 |
void RefBaselineABCtoRGB (const real32 *sPtrA, |
| 310 |
const real32 *sPtrB, |
| 311 |
const real32 *sPtrC, |
| 312 |
real32 *dPtrR, |
| 313 |
real32 *dPtrG, |
| 314 |
real32 *dPtrB, |
| 315 |
uint32 count, |
| 316 |
const dng_vector &cameraWhite, |
| 317 |
const dng_matrix &cameraToRGB); |
| 318 |
|
| 319 |
void RefBaselineABCDtoRGB (const real32 *sPtrA, |
| 320 |
const real32 *sPtrB, |
| 321 |
const real32 *sPtrC, |
| 322 |
const real32 *sPtrD, |
| 323 |
real32 *dPtrR, |
| 324 |
real32 *dPtrG, |
| 325 |
real32 *dPtrB, |
| 326 |
uint32 count, |
| 327 |
const dng_vector &cameraWhite, |
| 328 |
const dng_matrix &cameraToRGB); |
| 329 |
|
| 330 |
/*****************************************************************************/ |
| 331 |
|
| 332 |
void RefBaselineHueSatMap (const real32 *sPtrR, |
| 333 |
const real32 *sPtrG, |
| 334 |
const real32 *sPtrB, |
| 335 |
real32 *dPtrR, |
| 336 |
real32 *dPtrG, |
| 337 |
real32 *dPtrB, |
| 338 |
uint32 count, |
| 339 |
const dng_hue_sat_map &lut, |
| 340 |
const dng_1d_table *encodeTable, |
| 341 |
const dng_1d_table *decodeTable, |
| 342 |
const bool supportOverrange); |
| 343 |
|
| 344 |
/*****************************************************************************/ |
| 345 |
|
| 346 |
void RefBaselineRGBtoGray (const real32 *sPtrR, |
| 347 |
const real32 *sPtrG, |
| 348 |
const real32 *sPtrB, |
| 349 |
real32 *dPtrG, |
| 350 |
uint32 count, |
| 351 |
const dng_matrix &matrix, |
| 352 |
const bool supportOverrange); |
| 353 |
|
| 354 |
void RefBaselineRGBtoRGB (const real32 *sPtrR, |
| 355 |
const real32 *sPtrG, |
| 356 |
const real32 *sPtrB, |
| 357 |
real32 *dPtrR, |
| 358 |
real32 *dPtrG, |
| 359 |
real32 *dPtrB, |
| 360 |
uint32 count, |
| 361 |
const dng_matrix &matrix, |
| 362 |
const bool supportOverrange); |
| 363 |
|
| 364 |
/*****************************************************************************/ |
| 365 |
|
| 366 |
void RefBaseline1DTable (const real32 *sPtr, |
| 367 |
real32 *dPtr, |
| 368 |
uint32 count, |
| 369 |
const dng_1d_table &table); |
| 370 |
|
| 371 |
/*****************************************************************************/ |
| 372 |
|
| 373 |
void RefBaselineRGBTone (const real32 *sPtrR, |
| 374 |
const real32 *sPtrG, |
| 375 |
const real32 *sPtrB, |
| 376 |
real32 *dPtrR, |
| 377 |
real32 *dPtrG, |
| 378 |
real32 *dPtrB, |
| 379 |
uint32 count, |
| 380 |
const dng_1d_table &table); |
| 381 |
|
| 382 |
/*****************************************************************************/ |
| 383 |
|
| 384 |
void RefResampleDown16 (const uint16 *sPtr, |
| 385 |
uint16 *dPtr, |
| 386 |
uint32 sCount, |
| 387 |
int32 sRowStep, |
| 388 |
const int16 *wPtr, |
| 389 |
uint32 wCount, |
| 390 |
uint32 pixelRange); |
| 391 |
|
| 392 |
void RefResampleDown32 (const real32 *sPtr, |
| 393 |
real32 *dPtr, |
| 394 |
uint32 sCount, |
| 395 |
int32 sRowStep, |
| 396 |
const real32 *wPtr, |
| 397 |
uint32 wCount); |
| 398 |
|
| 399 |
/*****************************************************************************/ |
| 400 |
|
| 401 |
void RefResampleAcross16 (const uint16 *sPtr, |
| 402 |
uint16 *dPtr, |
| 403 |
uint32 dCount, |
| 404 |
const int32 *coord, |
| 405 |
const int16 *wPtr, |
| 406 |
uint32 wCount, |
| 407 |
uint32 wStep, |
| 408 |
uint32 pixelRange); |
| 409 |
|
| 410 |
void RefResampleAcross32 (const real32 *sPtr, |
| 411 |
real32 *dPtr, |
| 412 |
uint32 dCount, |
| 413 |
const int32 *coord, |
| 414 |
const real32 *wPtr, |
| 415 |
uint32 wCount, |
| 416 |
uint32 wStep); |
| 417 |
|
| 418 |
/*****************************************************************************/ |
| 419 |
|
| 420 |
bool RefEqualBytes (const void *sPtr, |
| 421 |
const void *dPtr, |
| 422 |
uint32 count); |
| 423 |
|
| 424 |
bool RefEqualArea8 (const uint8 *sPtr, |
| 425 |
const uint8 *dPtr, |
| 426 |
uint32 rows, |
| 427 |
uint32 cols, |
| 428 |
uint32 planes, |
| 429 |
int32 sRowStep, |
| 430 |
int32 sColStep, |
| 431 |
int32 sPlaneStep, |
| 432 |
int32 dRowStep, |
| 433 |
int32 dColStep, |
| 434 |
int32 dPlaneStep); |
| 435 |
|
| 436 |
bool RefEqualArea16 (const uint16 *sPtr, |
| 437 |
const uint16 *dPtr, |
| 438 |
uint32 rows, |
| 439 |
uint32 cols, |
| 440 |
uint32 planes, |
| 441 |
int32 sRowStep, |
| 442 |
int32 sColStep, |
| 443 |
int32 sPlaneStep, |
| 444 |
int32 dRowStep, |
| 445 |
int32 dColStep, |
| 446 |
int32 dPlaneStep); |
| 447 |
|
| 448 |
bool RefEqualArea32 (const uint32 *sPtr, |
| 449 |
const uint32 *dPtr, |
| 450 |
uint32 rows, |
| 451 |
uint32 cols, |
| 452 |
uint32 planes, |
| 453 |
int32 sRowStep, |
| 454 |
int32 sColStep, |
| 455 |
int32 sPlaneStep, |
| 456 |
int32 dRowStep, |
| 457 |
int32 dColStep, |
| 458 |
int32 dPlaneStep); |
| 459 |
|
| 460 |
/*****************************************************************************/ |
| 461 |
|
| 462 |
void RefVignetteMask16 (uint16 *mPtr, |
| 463 |
uint32 rows, |
| 464 |
uint32 cols, |
| 465 |
int32 rowStep, |
| 466 |
int64 offsetH, |
| 467 |
int64 offsetV, |
| 468 |
int64 stepH, |
| 469 |
int64 stepV, |
| 470 |
uint32 tBits, |
| 471 |
const uint16 *table); |
| 472 |
|
| 473 |
/*****************************************************************************/ |
| 474 |
|
| 475 |
void RefVignette16 (int16 *sPtr, |
| 476 |
const uint16 *mPtr, |
| 477 |
uint32 rows, |
| 478 |
uint32 cols, |
| 479 |
uint32 planes, |
| 480 |
int32 sRowStep, |
| 481 |
int32 sPlaneStep, |
| 482 |
int32 mRowStep, |
| 483 |
uint32 mBits); |
| 484 |
|
| 485 |
/*****************************************************************************/ |
| 486 |
|
| 487 |
void RefVignette32 (real32 *sPtr, |
| 488 |
const uint16 *mPtr, |
| 489 |
uint32 rows, |
| 490 |
uint32 cols, |
| 491 |
uint32 planes, |
| 492 |
int32 sRowStep, |
| 493 |
int32 sPlaneStep, |
| 494 |
int32 mRowStep, |
| 495 |
uint32 mBits, |
| 496 |
uint16 blackLevel); |
| 497 |
|
| 498 |
/*****************************************************************************/ |
| 499 |
|
| 500 |
void RefMapArea16 (uint16 *dPtr, |
| 501 |
uint32 count0, |
| 502 |
uint32 count1, |
| 503 |
uint32 count2, |
| 504 |
int32 step0, |
| 505 |
int32 step1, |
| 506 |
int32 step2, |
| 507 |
const uint16 *map); |
| 508 |
|
| 509 |
/*****************************************************************************/ |
| 510 |
|
| 511 |
void RefBaselineMapPoly32 (real32 *dPtr, |
| 512 |
const int32 rowStep, |
| 513 |
const uint32 rows, |
| 514 |
const uint32 cols, |
| 515 |
const uint32 rowPitch, |
| 516 |
const uint32 colPitch, |
| 517 |
const real32 *coefficients, |
| 518 |
const uint32 degree, |
| 519 |
uint16 blackLevel); |
| 520 |
|
| 521 |
/*****************************************************************************/ |
| 522 |
|
| 523 |
void RefBaselineProfileGainTableMap (const real32 *rSrcPtr, |
| 524 |
const real32 *gSrcPtr, |
| 525 |
const real32 *bSrcPtr, |
| 526 |
real32 *rDstPtr, |
| 527 |
real32 *gDstPtr, |
| 528 |
real32 *bDstPtr, |
| 529 |
const uint32 cols, |
| 530 |
const int32 top, |
| 531 |
const int32 left, |
| 532 |
const dng_rect &imageArea, |
| 533 |
const real32 exposureWeightGain, |
| 534 |
const dng_gain_table_map &gainTableMap, |
| 535 |
const bool supportOverrange); |
| 536 |
|
| 537 |
/*****************************************************************************/ |
| 538 |
|
| 539 |
void RefRGBtoRGBTable3D (real32 *rPtr, |
| 540 |
real32 *gPtr, |
| 541 |
real32 *bPtr, |
| 542 |
const real32 *mPtr, |
| 543 |
uint32 rows, |
| 544 |
uint32 cols, |
| 545 |
int32 rowStep, |
| 546 |
int32 mRowStep, |
| 547 |
uint32 divisions, |
| 548 |
const uint16 *samples, |
| 549 |
real32 amount, |
| 550 |
uint32 gamut, |
| 551 |
const dng_matrix *encodeMatrix, |
| 552 |
const dng_matrix *decodeMatrix, |
| 553 |
const dng_1d_table *encodeGamma, |
| 554 |
const dng_1d_table *decodeGamma, |
| 555 |
const bool supportOverrange); |
| 556 |
|
| 557 |
/*****************************************************************************/ |
| 558 |
|
| 559 |
void RefRGBtoRGBTable1D (real32 *rPtr, |
| 560 |
real32 *gPtr, |
| 561 |
real32 *bPtr, |
| 562 |
const real32 *mPtr, |
| 563 |
uint32 rows, |
| 564 |
uint32 cols, |
| 565 |
int32 rowStep, |
| 566 |
int32 mRowStep, |
| 567 |
const dng_1d_table &table0, |
| 568 |
const dng_1d_table &table1, |
| 569 |
const dng_1d_table &table2, |
| 570 |
uint32 gamut, |
| 571 |
const dng_matrix *encodeMatrix, |
| 572 |
const dng_matrix *decodeMatrix, |
| 573 |
const bool supportOverrange); |
| 574 |
|
| 575 |
/*****************************************************************************/ |
| 576 |
|
| 577 |
void RefMaskedRGBTables32 (real32 *ptr0, |
| 578 |
real32 *ptr1, |
| 579 |
real32 *ptr2, |
| 580 |
const real32 *tablePtr0, |
| 581 |
const real32 *tablePtr1, |
| 582 |
const real32 *tablePtr2, |
| 583 |
const real32 *maskPtr, |
| 584 |
uint32 numTransforms, |
| 585 |
int32 pRowStep, |
| 586 |
int32 tRowStep, |
| 587 |
int32 tPlaneStep, |
| 588 |
uint32 rows, |
| 589 |
uint32 cols); |
| 590 |
|
| 591 |
/*****************************************************************************/ |
| 592 |
|
| 593 |
#endif // __dng_reference__ |
| 594 |
|
| 595 |
/*****************************************************************************/ |