MCPcopy Create free account
hub / github.com/RenderKit/embree / DecodePixelData

Function DecodePixelData

tutorials/common/image/tinyexr.h:3672–4284  ·  view source on GitHub ↗

TODO(syoyo): Refactor function arguments.

Source from the content-addressed store, hash-verified

3670
3671// TODO(syoyo): Refactor function arguments.
3672static bool DecodePixelData(/* out */ unsigned char **out_images,
3673 const int *requested_pixel_types,
3674 const unsigned char *data_ptr, size_t data_len,
3675 int compression_type, int line_order, int width,
3676 int height, int x_stride, int y, int line_no,
3677 int num_lines, size_t pixel_data_size,
3678 size_t num_attributes,
3679 const EXRAttribute *attributes, size_t num_channels,
3680 const EXRChannelInfo *channels,
3681 const std::vector<size_t> &channel_offset_list) {
3682 if (compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { // PIZ
3683#if TINYEXR_USE_PIZ
3684 if ((width == 0) || (num_lines == 0) || (pixel_data_size == 0)) {
3685 // Invalid input #90
3686 return false;
3687 }
3688
3689 // Allocate original data size.
3690 std::vector<unsigned char> outBuf(static_cast<size_t>(
3691 static_cast<size_t>(width * num_lines) * pixel_data_size));
3692 size_t tmpBufLen = outBuf.size();
3693
3694 bool ret = tinyexr::DecompressPiz(
3695 reinterpret_cast<unsigned char *>(&outBuf.at(0)), data_ptr, tmpBufLen,
3696 data_len, static_cast<int>(num_channels), channels, width, num_lines);
3697
3698 if (!ret) {
3699 return false;
3700 }
3701
3702 // For PIZ_COMPRESSION:
3703 // pixel sample data for channel 0 for scanline 0
3704 // pixel sample data for channel 1 for scanline 0
3705 // pixel sample data for channel ... for scanline 0
3706 // pixel sample data for channel n for scanline 0
3707 // pixel sample data for channel 0 for scanline 1
3708 // pixel sample data for channel 1 for scanline 1
3709 // pixel sample data for channel ... for scanline 1
3710 // pixel sample data for channel n for scanline 1
3711 // ...
3712 for (size_t c = 0; c < static_cast<size_t>(num_channels); c++) {
3713 if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) {
3714 for (size_t v = 0; v < static_cast<size_t>(num_lines); v++) {
3715 const unsigned short *line_ptr = reinterpret_cast<unsigned short *>(
3716 &outBuf.at(v * pixel_data_size * static_cast<size_t>(width) +
3717 channel_offset_list[c] * static_cast<size_t>(width)));
3718 for (size_t u = 0; u < static_cast<size_t>(width); u++) {
3719 FP16 hf;
3720
3721 // hf.u = line_ptr[u];
3722 // use `cpy` to avoid unaligned memory access when compiler's
3723 // optimization is on.
3724 tinyexr::cpy2(&(hf.u), line_ptr + u);
3725
3726 tinyexr::swap2(reinterpret_cast<unsigned short *>(&hf.u));
3727
3728 if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) {
3729 unsigned short *image =

Callers 2

DecodeTiledPixelDataFunction · 0.85
DecodeChunkFunction · 0.85

Calls 12

DecompressPizFunction · 0.85
cpy2Function · 0.85
swap2Function · 0.85
half_to_floatFunction · 0.85
cpy4Function · 0.85
swap4Function · 0.85
DecompressZipFunction · 0.85
DecompressRleFunction · 0.85
FindZFPCompressionParamFunction · 0.85
DecompressZfpFunction · 0.85
sizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected