48 OSError GetLastPGFError() {
49 OSError tmp = _PGF_Error_;
50 _PGF_Error_ = NoError;
57 struct DebugBGRImage {
58 int width, height, pitch;
77 #ifdef __PGFROISUPPORT__
209 if (!
m_channel[c]) ReturnWithError(InsufficientMemory);
212 for (uint32_t i=0; i < size; i++) {
215 if (count !=
DataTSize) ReturnWithError(MissingData);
326 if (bpc > 31) bpc = 31;
364 #ifdef __PGFROISUPPORT__
371 while (currentLevel > level) {
385 if (err != NoError) ReturnWithError(err);
410 #ifdef __PGFROISUPPORT__
414 Read(rect, level, cb, data);
424 if ((*cb)(1.0,
true, data)) ReturnWithError(EscapePressed);
453 volatile OSError error = NoError;
454 #ifdef LIBPGF_USE_OPENMP
455 #pragma omp parallel for default(shared)
459 if (error == NoError) {
461 if (err != NoError) error = err;
465 if (error != NoError) ReturnWithError(error);
477 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
483 #ifdef __PGFROISUPPORT__
500 Read(level, cb, data);
514 if (levelDiff <= 0) {
537 for (uint32_t tileY=0; tileY < nTiles; tileY++) {
538 for (uint32_t tileX=0; tileX < nTiles; tileX++) {
553 volatile OSError error = NoError;
554 #ifdef LIBPGF_USE_OPENMP
555 #pragma omp parallel for default(shared)
559 if (error == NoError) {
561 if (err != NoError) error = err;
565 if (error != NoError) ReturnWithError(error);
577 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
595 return PGFRect(rLeft, rTop, rRight - rLeft, rBottom - rTop);
666 ASSERT(targetLen > 0);
677 ASSERT(len >= 0 && len <= targetLen);
714 ASSERT(targetLen > 0);
733 ASSERT(len >= 0 && len <= targetLen);
746 while(maxValue > 0) {
751 if (pot > bpc) pot = bpc;
752 if (pot > 31) pot = 31;
801 RgbToYuv(pitch, buff, bpp, channelMap, cb, data);
820 const int oddW = w%2;
827 for (
int i=0; i < h2; i++) {
828 for (
int j=0; j < w2; j++) {
830 buff[sampledPos] = (buff[loPos] + buff[loPos + 1] + buff[hiPos] + buff[hiPos + 1]) >> 2;
831 loPos += 2; hiPos += 2;
835 buff[sampledPos] = (buff[loPos] + buff[hiPos]) >> 1;
839 loPos += w; hiPos += w;
842 for (
int j=0; j < w2; j++) {
843 buff[sampledPos] = (buff[loPos] + buff[loPos+1]) >> 1;
844 loPos += 2; hiPos += 2;
848 buff[sampledPos] = buff[loPos];
866 while (s > maxThumbnailWidth) {
904 #ifdef __PGFROISUPPORT__
945 if (userDataLength && userData) {
970 ReturnWithError(InsufficientMemory);
988 volatile OSError error = NoError;
990 #ifdef LIBPGF_USE_OPENMP
991 #pragma omp parallel for default(shared)
994 DataT *temp =
nullptr;
995 if (error == NoError) {
1000 temp =
new(std::nothrow)
DataT[size];
1006 error = InsufficientMemory;
1009 if (error == NoError) {
1016 #ifdef __PGFROISUPPORT__
1023 if (err != NoError) error = err;
1027 error = InsufficientMemory;
1032 if (error != NoError) {
1037 ReturnWithError(error);
1046 #ifdef __PGFROISUPPORT__
1061 return (nBytes > 0) ? (uint32_t)nBytes : 0;
1077 #ifdef __PGFROISUPPORT__
1084 const uint32_t lastTile = nTiles - 1;
1088 ASSERT(nTiles == 1);
1092 for (uint32_t tileY=0; tileY < nTiles; tileY++) {
1093 for (uint32_t tileX=0; tileX < nTiles; tileX++) {
1098 if (i == lastChannel && tileY == lastTile && tileX == lastTile) {
1159 double percent = pow(0.25, levels);
1170 for (uint32_t i=0; i < size; i++) {
1178 if ((*cb)(1,
true, data)) ReturnWithError(EscapePressed);
1193 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1209 return nWrittenBytes;
1236 if (nWrittenBytes) *nWrittenBytes += nBytes;
1239 #ifdef __PGFROISUPPORT__
1262 uint32_t nWrittenBytes = 0;
1286 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1300 return nWrittenBytes;
1355 if (iFirstColor + nColors >
ColorTableLen) ReturnWithError(ColorTableError);
1357 for (uint32_t i=iFirstColor, j=0; j < nColors; i++, j++) {
1369 if (iFirstColor + nColors >
ColorTableLen) ReturnWithError(ColorTableError);
1371 for (uint32_t i=iFirstColor, j=0; j < nColors; i++, j++) {
1393 void CPGFImage::RgbToYuv(
int pitch, uint8_t* buff, uint8_t bpp,
int channelMap[], CallbackPtr cb,
void *data ) {
1395 uint32_t yPos = 0, cnt = 0;
1398 int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(
sizeof(defMap)/
sizeof(defMap[0]) ==
MaxChannels);
1400 if (channelMap ==
nullptr) channelMap = defMap;
1416 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1420 for (uint32_t j = 0; j < w2; j++) {
1421 uint8_t
byte = buff[j];
1422 for (
int k = 0; k < 8; k++) {
1423 uint8_t bit = (
byte & 0x80) >> 7;
1424 if (cnt < w) y[yPos++] = bit;
1463 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1484 ASSERT(bpp%16 == 0);
1486 uint16_t *buff16 = (uint16_t *)buff;
1487 const int pitch16 = pitch/2;
1494 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1501 m_channel[c][yPos] = (buff16[cnt + channelMap[c]] >> shift) - yuvOffset16;
1524 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1530 b = buff[cnt + channelMap[0]];
1531 g = buff[cnt + channelMap[1]];
1532 r = buff[cnt + channelMap[2]];
1534 y[yPos] = ((b + (g << 1) + r) >> 2) -
YUVoffset8;
1548 ASSERT(bpp%16 == 0);
1550 uint16_t *buff16 = (uint16_t *)buff;
1551 const int pitch16 = pitch/2;
1563 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1569 b = buff16[cnt + channelMap[0]] >> shift;
1570 g = buff16[cnt + channelMap[1]] >> shift;
1571 r = buff16[cnt + channelMap[2]] >> shift;
1573 y[yPos] = ((b + (g << 1) + r) >> 2) - yuvOffset16;
1599 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1605 b = buff[cnt + channelMap[0]];
1606 g = buff[cnt + channelMap[1]];
1607 r = buff[cnt + channelMap[2]];
1609 y[yPos] = ((b + (g << 1) + r) >> 2) -
YUVoffset8;
1612 a[yPos++] = buff[cnt + channelMap[3]] -
YUVoffset8;
1623 ASSERT(bpp%16 == 0);
1625 uint16_t *buff16 = (uint16_t *)buff;
1626 const int pitch16 = pitch/2;
1639 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1645 b = buff16[cnt + channelMap[0]] >> shift;
1646 g = buff16[cnt + channelMap[1]] >> shift;
1647 r = buff16[cnt + channelMap[2]] >> shift;
1649 y[yPos] = ((b + (g << 1) + r) >> 2) - yuvOffset16;
1652 a[yPos++] = (buff16[cnt + channelMap[3]] >> shift) - yuvOffset16;
1659 #ifdef __PGF32SUPPORT__
1669 uint32_t *buff32 = (uint32_t *)buff;
1670 const int pitch32 = pitch/4;
1676 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1681 y[yPos++] = (buff32[w] >> shift) - yuvOffset31;
1698 uint8_t rgb = 0, b, g, r;
1702 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1712 g = (rgb & 0xF0) >> 4;
1718 b = (rgb & 0xF0) >> 4;
1722 r = (rgb & 0xF0) >> 4;
1727 y[yPos] = ((b + (g << 1) + r) >> 2) -
YUVoffset4;
1746 uint16_t *buff16 = (uint16_t *)buff;
1747 uint16_t rgb, b, g, r;
1748 const int pitch16 = pitch/2;
1752 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1757 r = (rgb & 0xF800) >> 10;
1758 g = (rgb & 0x07E0) >> 5;
1759 b = (rgb & 0x001F) << 1;
1761 y[yPos] = ((b + (g << 1) + r) >> 2) -
YUVoffset6;
1793 void CPGFImage::GetBitmap(
int pitch, uint8_t* buff, uint8_t bpp,
int channelMap[] , CallbackPtr cb ,
void *data )
const {
1799 uint32_t roiOffsetX = 0;
1800 uint32_t roiOffsetY = 0;
1801 uint32_t yOffset = 0;
1802 uint32_t uOffset = 0;
1804 #ifdef __PGFROISUPPORT__
1813 w = levelRoi.
Width();
1815 roiOffsetX = levelRoi.
left - roi.
left;
1816 roiOffsetY = levelRoi.
top - roi.
top;
1817 yOffset = roiOffsetX + roiOffsetY*yw;
1828 const double dP = 1.0/h;
1829 int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(
sizeof(defMap)/
sizeof(defMap[0]) ==
MaxChannels);
1830 if (channelMap ==
nullptr) channelMap = defMap;
1842 const uint32_t w2 = (w + 7)/8;
1848 for (i = 0; i < h; i++) {
1850 for (j = 0; j < w2; j++) {
1852 for (
int k = 0; k < 8; k++) {
1856 bit = y[yOffset + cnt] & 1;
1868 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1875 yOffset = roiOffsetX/8 + roiOffsetY*yw;
1876 for (i = 0; i < h; i++) {
1877 for (j = 0; j < w2; j++) {
1885 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1902 for (i=0; i < h; i++) {
1903 uint32_t yPos = yOffset;
1905 for (j=0; j < w; j++) {
1917 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1928 uint32_t cnt, channels;
1932 uint16_t *buff16 = (uint16_t *)buff;
1933 int pitch16 = pitch/2;
1936 for (i=0; i < h; i++) {
1937 uint32_t yPos = yOffset;
1939 for (j=0; j < w; j++) {
1941 buff16[cnt + channelMap[c]] =
Clamp16((
m_channel[c][yPos] + yuvOffset16) << shift);
1951 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1959 for (i=0; i < h; i++) {
1960 uint32_t yPos = yOffset;
1962 for (j=0; j < w; j++) {
1964 buff[cnt + channelMap[c]] =
Clamp8((
m_channel[c][yPos] + yuvOffset16) >> shift);
1974 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1990 uint8_t *buffg = &buff[channelMap[1]],
1991 *buffr = &buff[channelMap[2]],
1992 *buffb = &buff[channelMap[0]];
1994 uint32_t cnt, channels = bpp/8;
1997 for (i=0; i < h; i++) {
1998 uint32_t uPos = uOffset;
1999 uint32_t yPos = yOffset;
2001 for (j=0; j < w; j++) {
2007 buffr[cnt] =
Clamp8(uAvg + g);
2008 buffb[cnt] =
Clamp8(vAvg + g);
2013 if (i & 1) uOffset += uw;
2021 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2026 for (i=0; i < h; i++) {
2028 uint32_t yPos = yOffset;
2029 for (j = 0; j < w; j++) {
2034 buffr[cnt] =
Clamp8(uAvg + g);
2035 buffb[cnt] =
Clamp8(vAvg + g);
2046 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2062 uint32_t cnt, channels;
2065 if (bpp >= 48 && bpp%16 == 0) {
2067 uint16_t *buff16 = (uint16_t *)buff;
2068 int pitch16 = pitch/2;
2071 for (i=0; i < h; i++) {
2072 uint32_t uPos = uOffset;
2073 uint32_t yPos = yOffset;
2075 for (j=0; j < w; j++) {
2079 g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2);
2080 buff16[cnt + channelMap[1]] =
Clamp16(g << shift);
2081 buff16[cnt + channelMap[2]] =
Clamp16((uAvg + g) << shift);
2082 buff16[cnt + channelMap[0]] =
Clamp16((vAvg + g) << shift);
2093 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2101 for (i=0; i < h; i++) {
2102 uint32_t uPos = uOffset;
2103 uint32_t yPos = yOffset;
2105 for (j=0; j < w; j++) {
2109 g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2);
2110 buff[cnt + channelMap[1]] =
Clamp8(g >> shift);
2111 buff[cnt + channelMap[2]] =
Clamp8((uAvg + g) >> shift);
2112 buff[cnt + channelMap[0]] =
Clamp8((vAvg + g) >> shift);
2123 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2140 for (i=0; i < h; i++) {
2141 uint32_t uPos = uOffset;
2142 uint32_t yPos = yOffset;
2144 for (j=0; j < w; j++) {
2160 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2175 uint32_t cnt, channels;
2179 uint16_t *buff16 = (uint16_t *)buff;
2180 int pitch16 = pitch/2;
2183 for (i=0; i < h; i++) {
2184 uint32_t uPos = uOffset;
2185 uint32_t yPos = yOffset;
2187 for (j=0; j < w; j++) {
2190 buff16[cnt + channelMap[0]] =
Clamp16((l[yPos] + yuvOffset16) << shift);
2191 buff16[cnt + channelMap[1]] =
Clamp16((uAvg + yuvOffset16) << shift);
2192 buff16[cnt + channelMap[2]] =
Clamp16((vAvg + yuvOffset16) << shift);
2203 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2211 for (i=0; i < h; i++) {
2212 uint32_t uPos = uOffset;
2213 uint32_t yPos = yOffset;
2215 for (j=0; j < w; j++) {
2218 buff[cnt + channelMap[0]] =
Clamp8((l[yPos] + yuvOffset16) >> shift);
2219 buff[cnt + channelMap[1]] =
Clamp8((uAvg + yuvOffset16) >> shift);
2220 buff[cnt + channelMap[2]] =
Clamp8((vAvg + yuvOffset16) >> shift);
2231 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2251 for (i=0; i < h; i++) {
2252 uint32_t uPos = uOffset;
2253 uint32_t yPos = yOffset;
2255 for (j=0; j < w; j++) {
2260 buff[cnt + channelMap[1]] = g =
Clamp8(y[yPos] +
YUVoffset8 - ((uAvg + vAvg ) >> 2));
2261 buff[cnt + channelMap[2]] =
Clamp8(uAvg + g);
2262 buff[cnt + channelMap[0]] =
Clamp8(vAvg + g);
2263 buff[cnt + channelMap[3]] = aAvg;
2274 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2291 uint32_t cnt, channels;
2295 uint16_t *buff16 = (uint16_t *)buff;
2296 int pitch16 = pitch/2;
2299 for (i=0; i < h; i++) {
2300 uint32_t uPos = uOffset;
2301 uint32_t yPos = yOffset;
2303 for (j=0; j < w; j++) {
2306 aAvg = a[uPos] + yuvOffset16;
2308 g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2);
2309 buff16[cnt + channelMap[1]] =
Clamp16(g << shift);
2310 buff16[cnt + channelMap[2]] =
Clamp16((uAvg + g) << shift);
2311 buff16[cnt + channelMap[0]] =
Clamp16((vAvg + g) << shift);
2312 buff16[cnt + channelMap[3]] =
Clamp16(aAvg << shift);
2323 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2331 for (i=0; i < h; i++) {
2332 uint32_t uPos = uOffset;
2333 uint32_t yPos = yOffset;
2335 for (j=0; j < w; j++) {
2338 aAvg = a[uPos] + yuvOffset16;
2340 g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2);
2341 buff[cnt + channelMap[1]] =
Clamp8(g >> shift);
2342 buff[cnt + channelMap[2]] =
Clamp8((uAvg + g) >> shift);
2343 buff[cnt + channelMap[0]] =
Clamp8((vAvg + g) >> shift);
2344 buff[cnt + channelMap[3]] =
Clamp8(aAvg >> shift);
2355 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2361 #ifdef __PGF32SUPPORT__
2372 uint32_t *buff32 = (uint32_t *)buff;
2373 int pitch32 = pitch/4;
2375 for (i=0; i < h; i++) {
2376 uint32_t yPos = yOffset;
2377 for (j = 0; j < w; j++) {
2378 buff32[j] =
Clamp31((y[yPos++] + yuvOffset31) << shift);
2385 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2388 }
else if (bpp == 16) {
2390 uint16_t *buff16 = (uint16_t *)buff;
2391 int pitch16 = pitch/2;
2393 if (usedBits < 16) {
2394 const int shift = 16 - usedBits;
2395 for (i=0; i < h; i++) {
2396 uint32_t yPos = yOffset;
2397 for (j = 0; j < w; j++) {
2398 buff16[j] =
Clamp16((y[yPos++] + yuvOffset31) << shift);
2405 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2409 const int shift =
__max(0, usedBits - 16);
2410 for (i=0; i < h; i++) {
2411 uint32_t yPos = yOffset;
2412 for (j = 0; j < w; j++) {
2413 buff16[j] =
Clamp16((y[yPos++] + yuvOffset31) >> shift);
2420 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2428 for (i=0; i < h; i++) {
2429 uint32_t yPos = yOffset;
2430 for (j = 0; j < w; j++) {
2431 buff[j] =
Clamp8((y[yPos++] + yuvOffset31) >> shift);
2438 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2458 for (i=0; i < h; i++) {
2459 uint32_t yPos = yOffset;
2461 for (j=0; j < w; j++) {
2467 buff[cnt] = uint8_t(
Clamp4(vAvg + yval) | (yval << 4));
2469 buff[cnt] =
Clamp4(uAvg + yval);
2471 buff[cnt] |=
Clamp4(vAvg + yval) << 4;
2473 buff[cnt] = uint8_t(yval | (
Clamp4(uAvg + yval) << 4));
2483 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2499 uint16_t *buff16 = (uint16_t *)buff;
2500 int pitch16 = pitch/2;
2502 for (i=0; i < h; i++) {
2503 uint32_t yPos = yOffset;
2504 for (j = 0; j < w; j++) {
2509 buff16[j] = (yval << 5) | ((
Clamp6(uAvg + yval) >> 1) << 11) | (
Clamp6(vAvg + yval) >> 1);
2516 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2528 roiimage.height = h;
2530 roiimage.pitch = pitch;
2531 roiimage.data = buff;
2533 roiimage.pitch = -pitch;
2534 roiimage.data = buff + (h - 1)*pitch;
2556 const uint32_t w =
m_width[0];
2558 const bool wOdd = (1 == w%2);
2559 const int dataBits =
DataTSize*8; ASSERT(dataBits == 16 || dataBits == 32);
2562 const double dP = 1.0/h;
2564 int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(
sizeof(defMap)/
sizeof(defMap[0]) ==
MaxChannels);
2565 if (channelMap ==
nullptr) channelMap = defMap;
2566 int sampledPos = 0, yPos = 0;
2572 ASSERT(bpp%dataBits == 0);
2579 for (i=0; i < h; i++) {
2580 if (i%2) sampledPos -= (w + 1)/2;
2582 for (j=0; j < w; j++) {
2585 uAvg = u[sampledPos];
2586 vAvg = v[sampledPos];
2591 buff[cnt + channelMap[0]] = y[yPos];
2592 buff[cnt + channelMap[1]] = uAvg;
2593 buff[cnt + channelMap[2]] = vAvg;
2596 if (j%2) sampledPos++;
2599 if (wOdd) sampledPos++;
2603 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2608 ASSERT(bpp%dataBits == 0);
2617 for (i=0; i < h; i++) {
2618 if (i%2) sampledPos -= (w + 1)/2;
2620 for (j=0; j < w; j++) {
2623 uAvg = u[sampledPos];
2624 vAvg = v[sampledPos];
2625 aAvg =
Clamp8(a[sampledPos] + yuvOffset);
2629 aAvg =
Clamp8(a[yPos] + yuvOffset);
2632 buff[cnt + channelMap[0]] = y[yPos];
2633 buff[cnt + channelMap[1]] = uAvg;
2634 buff[cnt + channelMap[2]] = vAvg;
2635 buff[cnt + channelMap[3]] = aAvg;
2638 if (j%2) sampledPos++;
2641 if (wOdd) sampledPos++;
2645 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2668 const int dataBits =
DataTSize*8; ASSERT(dataBits == 16 || dataBits == 32);
2672 int yPos = 0, cnt = 0;
2674 int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(
sizeof(defMap)/
sizeof(defMap[0]) ==
MaxChannels);
2676 if (channelMap ==
nullptr) channelMap = defMap;
2679 ASSERT(bpp%dataBits == 0);
2688 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2694 y[yPos] = buff[cnt + channelMap[0]];
2695 u[yPos] = buff[cnt + channelMap[1]];
2696 v[yPos] = buff[cnt + channelMap[2]];
2703 ASSERT(bpp%dataBits == 0);
2713 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2719 y[yPos] = buff[cnt + channelMap[0]];
2720 u[yPos] = buff[cnt + channelMap[1]];
2721 v[yPos] = buff[cnt + channelMap[2]];
2722 a[yPos] = buff[cnt + channelMap[3]] - yuvOffset;
void Skip(uint64_t offset)
uint32_t ReadEncodedData(uint8_t *target, uint32_t len) const
void SetStreamPosToData()
Resets stream position to beginning of data block.
void DecodeInterleaved(CWaveletTransform *wtChannel, int level, int quantParam)
CDecoder(CPGFStream *stream, PGFPreHeader &preHeader, PGFHeader &header, PGFPostHeader &postHeader, uint32_t *&levelLength, uint64_t &userDataPos, bool useOMP, uint32_t userDataPolicy)
uint32_t GetEncodedHeaderLength() const
void SetStreamPosToStart()
Resets stream position to beginning of PGF pre-header.
CEncoder(CPGFStream *stream, PGFPreHeader preHeader, PGFHeader header, const PGFPostHeader &postHeader, uint64_t &userDataPos, bool useOMP)
void FavorSpeedOverSize()
Encoder favors speed over compression size.
int64_t ComputeHeaderLength() const
uint32_t WriteLevelLength(uint32_t *&levelLength)
void SetEncodedLevel(int currentLevel)
void SetStreamPosToStart()
Resets stream position to beginning of PGF pre-header.
uint32_t UpdateLevelLength()
void UpdatePostHeaderSize(PGFPreHeader preHeader)
int64_t ComputeBufferLength() const
int64_t ComputeOffset() const
uint32_t WriteImage(CPGFStream *stream, CallbackPtr cb=nullptr, void *data=nullptr)
void SetHeader(const PGFHeader &header, uint8_t flags=0, const uint8_t *userData=0, uint32_t userDataLength=0)
CWaveletTransform * m_wtChannel[MaxChannels]
wavelet transformed color channels
uint8_t Clamp8(DataT v) const
void ImportBitmap(int pitch, uint8_t *buff, uint8_t bpp, int channelMap[]=nullptr, CallbackPtr cb=nullptr, void *data=nullptr)
void Write(CPGFStream *stream, uint32_t *nWrittenBytes=nullptr, CallbackPtr cb=nullptr, void *data=nullptr)
CPGFImage()
Standard constructor.
PGFRect m_roi
region of interest
PGFPreHeader m_preHeader
PGF pre-header.
uint32_t * m_levelLength
length of each level in bytes; first level starts immediately after this array
uint16_t Clamp16(DataT v) const
bool ROIisSupported() const
void ImportYUV(int pitch, DataT *buff, uint8_t bpp, int channelMap[]=nullptr, CallbackPtr cb=nullptr, void *data=nullptr)
void Reconstruct(int level=0)
const RGBQUAD * GetColorTable() const
void Open(CPGFStream *stream)
static uint8_t CodecMajorVersion(uint8_t version=PGFVersion)
Return major version.
void ResetStreamPos(bool startOfData)
uint32_t GetEncodedLevelLength(int level) const
static bool ImportIsSupported(uint8_t mode)
PGFHeader m_header
PGF file header.
uint8_t UsedBitsPerChannel() const
uint32_t GetEncodedHeaderLength() const
uint32_t ReadEncodedData(int level, uint8_t *target, uint32_t targetLen) const
void SetMaxValue(uint32_t maxValue)
void SetColorTable(uint32_t iFirstColor, uint32_t nColors, const RGBQUAD *prgbColors)
uint16_t Clamp6(DataT v) const
void RgbToYuv(int pitch, uint8_t *rgbBuff, uint8_t bpp, int channelMap[], CallbackPtr cb, void *data)
uint32_t m_height[MaxChannels]
height of each channel at current level
uint32_t Clamp31(DataT v) const
uint32_t m_userDataPolicy
user data (metadata) policy during open
double m_percent
progress [0..1]
RefreshCB m_cb
pointer to refresh callback procedure
uint64_t m_userDataPos
stream position of user data
uint32_t UpdatePostHeaderSize()
void GetBitmap(int pitch, uint8_t *buff, uint8_t bpp, int channelMap[]=nullptr, CallbackPtr cb=nullptr, void *data=nullptr) const
virtual ~CPGFImage()
Destructor.
uint32_t m_width[MaxChannels]
width of each channel at current level
uint32_t ReadEncodedHeader(uint8_t *target, uint32_t targetLen) const
void * m_cbArg
refresh callback argument
bool m_streamReinitialized
stream has been reinitialized
PGFPostHeader m_postHeader
PGF post-header.
void GetYUV(int pitch, DataT *buff, uint8_t bpp, int channelMap[]=nullptr, CallbackPtr cb=nullptr, void *data=nullptr) const
PGFRect ComputeLevelROI() const
void Read(int level=0, CallbackPtr cb=nullptr, void *data=nullptr)
bool m_downsample
chrominance channels are downsampled
static uint32_t LevelSizeL(uint32_t size, int level)
CEncoder * m_encoder
PGF encoder.
bool m_favorSpeedOverSize
favor encoding speed over compression ratio
CDecoder * m_decoder
PGF decoder.
ProgressMode m_progressMode
progress mode used in Read and Write; Relative is default mode
bool m_useOMPinEncoder
use Open MP in encoder
const uint8_t * GetUserData(uint32_t &cachedSize, uint32_t *pTotalSize=nullptr) const
void SetROI(PGFRect rect)
uint8_t m_quant
quantization parameter
void Downsample(int nChannel)
bool m_useOMPinDecoder
use Open MP in decoder
uint32_t WriteHeader(CPGFStream *stream)
PGFRect GetAlignedROI(int c=0) const
int m_currentLevel
transform level of current image
DataT * m_channel[MaxChannels]
untransformed channels in YUV format
uint8_t Clamp4(DataT v) const
Abstract stream base class.
virtual void Write(int *count, void *buffer)=0
virtual void Read(int *count, void *buffer)=0
void ExtractTile(CEncoder &encoder, bool tile=false, uint32_t tileX=0, uint32_t tileY=0)
void Dequantize(int quantParam)
void PlaceTile(CDecoder &decoder, int quantParam, bool tile=false, uint32_t tileX=0, uint32_t tileY=0)
constexpr Policy CacheAll
constexpr int PGFVersion
current standard version
constexpr DataT YUVoffset6
constexpr size_t HeaderSize
constexpr DataT YUVoffset16
constexpr size_t MaxUserDataSize
constexpr int MaxChannels
maximum number of (color) channels
constexpr const char * PGFMagic
PGF identification.
constexpr int MaxLevel
maximum number of transform levels
constexpr int MaxQuality
maximum quality
constexpr int ColorTableLen
size of color lookup table (clut)
constexpr uint32_t FilterSize
constexpr DataT YUVoffset8
constexpr DataT YUVoffset4
constexpr int Version5
new coding scheme since major version 5
constexpr int Version7
Codec major and minor version number stored in PGFHeader.
constexpr size_t DataTSize
constexpr int Version6
hSize in PGFPreHeader uses 32 bits instead of 16 bits
constexpr int Version2
data structure PGFHeader of major version 2
constexpr int DownsampleThreshold
if quality is larger than this threshold than downsampling is used
constexpr size_t ColorTableSize
char magic[3]
PGF identification = "PGF".
uint8_t version
PGF version.
PGFRect()
Standard constructor.
PGFVersionNumber(uint8_t _major, uint8_t _year, uint8_t _week)