24 #include <libopenraw/consts.h>
33 using namespace Debug;
35 Unpack::Unpack(uint32_t w, uint32_t t)
41 size_t Unpack::block_size()
const
44 if(m_type == IFD::COMPRESS_NIKON_PACK || m_type == IFD::COMPRESS_OLYMPUS) {
45 bs = (m_w / 2 * 3) + (m_w / 10);
58 or_error Unpack::unpack_be12to16(uint16_t *dest,
size_t destsize,
const uint8_t *src,
59 size_t size,
size_t & out)
const
62 uint16_t *dest16 =
reinterpret_cast<uint16_t *
>(dest);
63 size_t pad = (m_type == IFD::COMPRESS_NIKON_PACK) ? 1 : 0;
64 size_t n = size / (15 + pad);
65 size_t rest = size % (15 + pad);
66 size_t ret = n * 20 + rest / 3 * 4;
73 if ((size % 16) != 0) {
74 LOGERR(
"be12to16 incorrect padding.\n");
78 if ((rest % 3) != 0) {
79 LOGERR(
"be12to16 incorrect rest.\n");
83 for (
size_t i = 0; i < n + 1; i++) {
84 size_t m = (i == n) ? rest / 3 : 5;
85 if ((dest16 - dest) + (m * 4) > destsize) {
87 LOGERR(
"overflow !\n");
90 for (
size_t j = 0; j < m; j++) {
99 *dest16 = (t & (0xfff << 12)) >> 12;
117 or_error Unpack::unpack_le12to16(uint16_t *dest,
size_t destsize,
const uint8_t *src,
118 size_t size,
size_t & out)
const
121 uint16_t *dest16 =
reinterpret_cast<uint16_t *
>(dest);
122 size_t pad = (m_type == IFD::COMPRESS_OLYMPUS) ? 1 : 0;
123 size_t n = size / (15 + pad);
124 size_t rest = size % (15 + pad);
125 size_t ret = n * 20 + rest / 3 * 4;
132 if ((size % 16) != 0) {
133 LOGERR(
"le12to16 incorrect padding.\n");
137 if ((rest % 3) != 0) {
138 LOGERR(
"le12to16 incorrect rest.\n");
142 for (
size_t i = 0; i < n + 1; i++) {
143 size_t m = (i == n) ? rest / 3 : 5;
144 if ((dest16 - dest) + (m * 4) > destsize) {
146 LOGERR(
"overflow !\n");
149 for (
size_t j = 0; j < m; j++) {
152 uint16_t b1 = *src++;
153 uint16_t b2 = *src++;
154 uint16_t b3 = *src++;
157 *dest16 = ((b2 & 0xf) << 8) | b1;
160 *dest16 = (b3 << 4) | (b2 >> 4);
or_error
Error codes returned by libopenraw.
Global namespace for libopenraw.