* @brief Copy a scanline from a source file and expand to a canonical format. * * Outputs are always 4 component RGBA, stored as U8 (LDR) or FP16 (HDR). * * @param[out] dst The start of the line to store to. * @param src The start of the line to load. * @param pixel_count The number of pixels in the scanline. * @param method The conversion functio
| 425 | * @param method The conversion function. |
| 426 | */ |
| 427 | static void copy_scanline( |
| 428 | void* dst, |
| 429 | const void* src, |
| 430 | size_t pixel_count, |
| 431 | scanline_transfer method |
| 432 | ) { |
| 433 | |
| 434 | #define id(x) (x) |
| 435 | #define u16_sf16(x) float_to_float16(x * (1.0f/65535.0f)) |
| 436 | #define f32_sf16(x) float_to_float16(x) |
| 437 | |
| 438 | #define COPY_R(dsttype, srctype, convfunc, oneval) \ |
| 439 | do { \ |
| 440 | const srctype* s = reinterpret_cast<const srctype*>(src); \ |
| 441 | dsttype* d = reinterpret_cast<dsttype*>(dst); \ |
| 442 | for (size_t i = 0; i < pixel_count; i++) \ |
| 443 | { \ |
| 444 | d[4 * i ] = convfunc(s[i]); \ |
| 445 | d[4 * i + 1] = 0; \ |
| 446 | d[4 * i + 2] = 0; \ |
| 447 | d[4 * i + 3] = oneval; \ |
| 448 | } \ |
| 449 | } while (0); \ |
| 450 | break |
| 451 | |
| 452 | #define COPY_RG(dsttype, srctype, convfunc, oneval) \ |
| 453 | do { \ |
| 454 | const srctype* s = reinterpret_cast<const srctype*>(src); \ |
| 455 | dsttype* d = reinterpret_cast<dsttype*>(dst); \ |
| 456 | for (size_t i = 0; i < pixel_count; i++) \ |
| 457 | { \ |
| 458 | d[4 * i ] = convfunc(s[2 * i ]); \ |
| 459 | d[4 * i + 1] = convfunc(s[2 * i + 1]); \ |
| 460 | d[4 * i + 2] = 0; \ |
| 461 | d[4 * i + 3] = oneval; \ |
| 462 | } \ |
| 463 | } while (0); \ |
| 464 | break |
| 465 | |
| 466 | #define COPY_RGB(dsttype, srctype, convfunc, oneval) \ |
| 467 | do { \ |
| 468 | const srctype* s = reinterpret_cast<const srctype*>(src); \ |
| 469 | dsttype* d = reinterpret_cast<dsttype*>(dst); \ |
| 470 | for (size_t i = 0; i < pixel_count; i++) \ |
| 471 | { \ |
| 472 | d[4 * i ] = convfunc(s[3 * i ]); \ |
| 473 | d[4 * i + 1] = convfunc(s[3 * i + 1]); \ |
| 474 | d[4 * i + 2] = convfunc(s[3 * i + 2]); \ |
| 475 | d[4 * i + 3] = oneval; \ |
| 476 | } \ |
| 477 | } while (0); \ |
| 478 | break |
| 479 | |
| 480 | #define COPY_BGR(dsttype, srctype, convfunc, oneval) \ |
| 481 | do { \ |
| 482 | const srctype* s = reinterpret_cast<const srctype*>(src); \ |
| 483 | dsttype* d = reinterpret_cast<dsttype*>(dst); \ |
| 484 | for (size_t i = 0; i < pixel_count; i++)\ |
no outgoing calls
no test coverage detected