35 #define YUVoffset4 8 // 2^3 36 #define YUVoffset6 32 // 2^5 37 #define YUVoffset8 128 // 2^7 38 #define YUVoffset16 32768 // 2^15 46 OSError GetLastPGFError() {
47 OSError tmp = _PGF_Error_;
48 _PGF_Error_ = NoError;
62 , m_favorSpeedOverSize(false)
63 , m_useOMPinEncoder(true)
64 , m_useOMPinDecoder(true)
65 , m_skipUserData(false)
67 , m_streamReinitialized(false)
194 if (!
m_channel[c]) ReturnWithError(InsufficientMemory);
197 for (UINT32 i=0; i < size; i++) {
200 if (count !=
DataTSize) ReturnWithError(MissingData);
308 if (bpc > 31) bpc = 31;
348 while (currentLevel > level) {
362 if (err != NoError) ReturnWithError(err);
387 #ifdef __PGFROISUPPORT__ 391 Read(rect, level, cb, data);
401 if ((*cb)(1.0,
true, data)) ReturnWithError(EscapePressed);
428 volatile OSError error = NoError;
429 #pragma omp parallel for default(shared) 432 if (error == NoError) {
434 if (err != NoError) error = err;
438 if (error != NoError) ReturnWithError(error);
450 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
459 #ifdef __PGFROISUPPORT__ 476 Read(level, cb, data);
486 if (levelDiff <= 0) {
513 for (UINT32 tileY=0; tileY < nTiles; tileY++) {
514 for (UINT32 tileX=0; tileX < nTiles; tileX++) {
516 if (tileIndices.
IsInside(tileX, tileY)) {
529 volatile OSError error = NoError;
530 #pragma omp parallel for default(shared) 533 if (error == NoError) {
535 if (err != NoError) error = err;
539 if (error != NoError) ReturnWithError(error);
551 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
578 else rect.
left -= dx;
579 if (rect.
top < dy) rect.
top = 0;
602 #endif // __PGFROISUPPORT__ 622 ASSERT(targetLen > 0);
633 ASSERT(len >= 0 && len <= targetLen);
657 ASSERT(targetLen > 0);
676 ASSERT(len >= 0 && len <= targetLen);
689 while(maxValue > 0) {
694 if (pot > bpc) pot = bpc;
695 if (pot > 31) pot = 31;
743 RgbToYuv(pitch, buff, bpp, channelMap, cb, data);
761 const int oddW = w%2;
768 for (
int i=0; i < h2; i++) {
769 for (
int j=0; j < w2; j++) {
771 buff[sampledPos] = (buff[loPos] + buff[loPos + 1] + buff[hiPos] + buff[hiPos + 1]) >> 2;
772 loPos += 2; hiPos += 2;
776 buff[sampledPos] = (buff[loPos] + buff[hiPos]) >> 1;
780 loPos += w; hiPos += w;
783 for (
int j=0; j < w2; j++) {
784 buff[sampledPos] = (buff[loPos] + buff[loPos+1]) >> 1;
785 loPos += 2; hiPos += 2;
789 buff[sampledPos] = buff[loPos];
807 while (s > maxThumbnailWidth) {
844 #ifdef __PGFROISUPPORT__ 882 if (userDataLength && userData) {
906 ReturnWithError(InsufficientMemory);
923 volatile OSError error = NoError;
925 #pragma omp parallel for default(shared) 928 if (error == NoError) {
933 temp =
new(std::nothrow)
DataT[size];
938 error = InsufficientMemory;
941 if (error == NoError) {
944 #ifdef __PGFROISUPPORT__ 951 if (err != NoError) error = err;
956 if (error != NoError) ReturnWithError(error);
964 #ifdef __PGFROISUPPORT__ 979 return (nBytes > 0) ? (UINT32)nBytes : 0;
995 #ifdef __PGFROISUPPORT__ 1002 const UINT32 lastTile = nTiles - 1;
1006 ASSERT(nTiles == 1);
1010 for (UINT32 tileY=0; tileY < nTiles; tileY++) {
1011 for (UINT32 tileX=0; tileX < nTiles; tileX++) {
1015 if (i == lastChannel && tileY == lastTile && tileX == lastTile) {
1075 double percent = pow(0.25, levels);
1086 for (UINT32 i=0; i < size; i++) {
1088 stream->Write(&count, &
m_channel[c][i]);
1094 if ((*cb)(1,
true, data)) ReturnWithError(EscapePressed);
1109 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1125 return nWrittenBytes;
1152 if (nWrittenBytes) *nWrittenBytes += nBytes;
1155 #ifdef __PGFROISUPPORT__ 1178 UINT32 nWrittenBytes = 0;
1202 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1216 return nWrittenBytes;
1218 #endif // __PGFROISUPPORT__ 1271 if (iFirstColor + nColors >
ColorTableLen) ReturnWithError(ColorTableError);
1273 for (UINT32 i=iFirstColor, j=0; j < nColors; i++, j++) {
1285 if (iFirstColor + nColors >
ColorTableLen) ReturnWithError(ColorTableError);
1287 for (UINT32 i=iFirstColor, j=0; j < nColors; i++, j++) {
1309 void CPGFImage::RgbToYuv(
int pitch, UINT8* buff, BYTE bpp,
int channelMap[], CallbackPtr cb,
void *data ) THROW_ {
1311 int yPos = 0, cnt = 0;
1314 int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(
sizeof(defMap)/
sizeof(defMap[0]) ==
MaxChannels);
1316 if (channelMap == NULL) channelMap = defMap;
1331 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1335 for (UINT32 j=0; j < w2; j++) {
1338 for (UINT32 j=w2; j < w; j++) {
1368 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1389 ASSERT(bpp%16 == 0);
1391 UINT16 *buff16 = (UINT16 *)buff;
1392 const int pitch16 = pitch/2;
1399 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1406 m_channel[c][yPos] = (buff16[cnt + channelMap[c]] >> shift) - yuvOffset16;
1429 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1435 b = buff[cnt + channelMap[0]];
1436 g = buff[cnt + channelMap[1]];
1437 r = buff[cnt + channelMap[2]];
1439 y[yPos] = ((b + (g << 1) + r) >> 2) -
YUVoffset8;
1453 ASSERT(bpp%16 == 0);
1455 UINT16 *buff16 = (UINT16 *)buff;
1456 const int pitch16 = pitch/2;
1468 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1474 b = buff16[cnt + channelMap[0]] >> shift;
1475 g = buff16[cnt + channelMap[1]] >> shift;
1476 r = buff16[cnt + channelMap[2]] >> shift;
1478 y[yPos] = ((b + (g << 1) + r) >> 2) - yuvOffset16;
1504 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1510 b = buff[cnt + channelMap[0]];
1511 g = buff[cnt + channelMap[1]];
1512 r = buff[cnt + channelMap[2]];
1514 y[yPos] = ((b + (g << 1) + r) >> 2) -
YUVoffset8;
1517 a[yPos++] = buff[cnt + channelMap[3]] -
YUVoffset8;
1528 ASSERT(bpp%16 == 0);
1530 UINT16 *buff16 = (UINT16 *)buff;
1531 const int pitch16 = pitch/2;
1544 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1550 b = buff16[cnt + channelMap[0]] >> shift;
1551 g = buff16[cnt + channelMap[1]] >> shift;
1552 r = buff16[cnt + channelMap[2]] >> shift;
1554 y[yPos] = ((b + (g << 1) + r) >> 2) - yuvOffset16;
1557 a[yPos++] = (buff16[cnt + channelMap[3]] >> shift) - yuvOffset16;
1564 #ifdef __PGF32SUPPORT__ 1574 UINT32 *buff32 = (UINT32 *)buff;
1575 const int pitch32 = pitch/4;
1581 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1586 y[yPos++] = (buff32[w] >> shift) - yuvOffset31;
1603 UINT8 rgb = 0, b, g, r;
1607 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1617 g = (rgb & 0xF0) >> 4;
1623 b = (rgb & 0xF0) >> 4;
1627 r = (rgb & 0xF0) >> 4;
1632 y[yPos] = ((b + (g << 1) + r) >> 2) -
YUVoffset4;
1651 UINT16 *buff16 = (UINT16 *)buff;
1652 UINT16 rgb, b, g, r;
1653 const int pitch16 = pitch/2;
1657 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1662 r = (rgb & 0xF800) >> 10;
1663 g = (rgb & 0x07E0) >> 5;
1664 b = (rgb & 0x001F) << 1;
1666 y[yPos] = ((b + (g << 1) + r) >> 2) -
YUVoffset6;
1698 void CPGFImage::GetBitmap(
int pitch, UINT8* buff, BYTE bpp,
int channelMap[] , CallbackPtr cb ,
void *data )
const THROW_ {
1702 UINT8* targetBuff = 0;
1703 UINT8* buffStart = 0;
1704 int targetPitch = 0;
1706 #ifdef __PGFROISUPPORT__ 1716 targetPitch = pitch;
1721 buff = buffStart =
new(std::nothrow) UINT8[pitch*h];
1722 if (!buff) ReturnWithError(InsufficientMemory);
1726 const bool wOdd = (1 == w%2);
1728 const double dP = 1.0/h;
1729 int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(
sizeof(defMap)/
sizeof(defMap[0]) ==
MaxChannels);
1730 if (channelMap == NULL) channelMap = defMap;
1731 int sampledPos = 0, yPos = 0;
1743 const UINT32 w2 = (w + 7)/8;
1746 for (i=0; i < h; i++) {
1748 for (j=0; j < w2; j++) {
1768 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1784 for (i=0; i < h; i++) {
1786 for (j=0; j < w; j++) {
1797 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1812 UINT16 *buff16 = (UINT16 *)buff;
1813 int pitch16 = pitch/2;
1816 for (i=0; i < h; i++) {
1818 for (j=0; j < w; j++) {
1820 buff16[cnt + channelMap[c]] =
Clamp16((
m_channel[c][yPos] + yuvOffset16) << shift);
1829 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1837 for (i=0; i < h; i++) {
1839 for (j=0; j < w; j++) {
1841 buff[cnt + channelMap[c]] =
Clamp8((
m_channel[c][yPos] + yuvOffset16) >> shift);
1850 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1866 UINT8 *buffg = &buff[channelMap[1]],
1867 *buffr = &buff[channelMap[2]],
1868 *buffb = &buff[channelMap[0]];
1870 int cnt, channels = bpp/8;
1872 for (i=0; i < h; i++) {
1873 if (i%2) sampledPos -= (w + 1)/2;
1875 for (j=0; j < w; j++) {
1877 uAvg = u[sampledPos];
1878 vAvg = v[sampledPos];
1881 buffr[cnt] =
Clamp8(uAvg + g);
1882 buffb[cnt] =
Clamp8(vAvg + g);
1885 if (j%2) sampledPos++;
1890 if (wOdd) sampledPos++;
1893 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1897 for (i=0; i < h; i++) {
1899 for (j = 0; j < w; j++) {
1904 buffr[cnt] =
Clamp8(uAvg + g);
1905 buffb[cnt] =
Clamp8(vAvg + g);
1915 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1934 if (bpp >= 48 && bpp%16 == 0) {
1936 UINT16 *buff16 = (UINT16 *)buff;
1937 int pitch16 = pitch/2;
1940 for (i=0; i < h; i++) {
1941 if (i%2) sampledPos -= (w + 1)/2;
1943 for (j=0; j < w; j++) {
1946 uAvg = u[sampledPos];
1947 vAvg = v[sampledPos];
1953 g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2);
1954 buff16[cnt + channelMap[1]] =
Clamp16(g << shift);
1955 buff16[cnt + channelMap[2]] =
Clamp16((uAvg + g) << shift);
1956 buff16[cnt + channelMap[0]] =
Clamp16((vAvg + g) << shift);
1959 if (j%2) sampledPos++;
1962 if (wOdd) sampledPos++;
1966 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1974 for (i=0; i < h; i++) {
1975 if (i%2) sampledPos -= (w + 1)/2;
1977 for (j=0; j < w; j++) {
1980 uAvg = u[sampledPos];
1981 vAvg = v[sampledPos];
1987 g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2);
1988 buff[cnt + channelMap[1]] =
Clamp8(g >> shift);
1989 buff[cnt + channelMap[2]] =
Clamp8((uAvg + g) >> shift);
1990 buff[cnt + channelMap[0]] =
Clamp8((vAvg + g) >> shift);
1993 if (j%2) sampledPos++;
1996 if (wOdd) sampledPos++;
2000 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2017 for (i=0; i < h; i++) {
2018 if (i%2) sampledPos -= (w + 1)/2;
2020 for (j=0; j < w; j++) {
2023 uAvg = a[sampledPos];
2024 vAvg = b[sampledPos];
2034 if (j%2) sampledPos++;
2037 if (wOdd) sampledPos++;
2041 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2060 UINT16 *buff16 = (UINT16 *)buff;
2061 int pitch16 = pitch/2;
2064 for (i=0; i < h; i++) {
2065 if (i%2) sampledPos -= (w + 1)/2;
2067 for (j=0; j < w; j++) {
2070 uAvg = a[sampledPos];
2071 vAvg = b[sampledPos];
2076 buff16[cnt + channelMap[0]] =
Clamp16((l[yPos] + yuvOffset16) << shift);
2077 buff16[cnt + channelMap[1]] =
Clamp16((uAvg + yuvOffset16) << shift);
2078 buff16[cnt + channelMap[2]] =
Clamp16((vAvg + yuvOffset16) << shift);
2081 if (j%2) sampledPos++;
2084 if (wOdd) sampledPos++;
2088 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2096 for (i=0; i < h; i++) {
2097 if (i%2) sampledPos -= (w + 1)/2;
2099 for (j=0; j < w; j++) {
2102 uAvg = a[sampledPos];
2103 vAvg = b[sampledPos];
2108 buff[cnt + channelMap[0]] =
Clamp8((l[yPos] + yuvOffset16) >> shift);
2109 buff[cnt + channelMap[1]] =
Clamp8((uAvg + yuvOffset16) >> shift);
2110 buff[cnt + channelMap[2]] =
Clamp8((vAvg + yuvOffset16) >> shift);
2113 if (j%2) sampledPos++;
2116 if (wOdd) sampledPos++;
2120 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2140 for (i=0; i < h; i++) {
2141 if (i%2) sampledPos -= (w + 1)/2;
2143 for (j=0; j < w; j++) {
2146 uAvg = u[sampledPos];
2147 vAvg = v[sampledPos];
2155 buff[cnt + channelMap[1]] = g =
Clamp8(y[yPos] +
YUVoffset8 - ((uAvg + vAvg ) >> 2));
2156 buff[cnt + channelMap[2]] =
Clamp8(uAvg + g);
2157 buff[cnt + channelMap[0]] =
Clamp8(vAvg + g);
2158 buff[cnt + channelMap[3]] = aAvg;
2161 if (j%2) sampledPos++;
2164 if (wOdd) sampledPos++;
2168 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2189 UINT16 *buff16 = (UINT16 *)buff;
2190 int pitch16 = pitch/2;
2193 for (i=0; i < h; i++) {
2194 if (i%2) sampledPos -= (w + 1)/2;
2196 for (j=0; j < w; j++) {
2199 uAvg = u[sampledPos];
2200 vAvg = v[sampledPos];
2201 aAvg = a[sampledPos] + yuvOffset16;
2205 aAvg = a[yPos] + yuvOffset16;
2208 g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2);
2209 buff16[cnt + channelMap[1]] =
Clamp16(g << shift);
2210 buff16[cnt + channelMap[2]] =
Clamp16((uAvg + g) << shift);
2211 buff16[cnt + channelMap[0]] =
Clamp16((vAvg + g) << shift);
2212 buff16[cnt + channelMap[3]] =
Clamp16(aAvg << shift);
2215 if (j%2) sampledPos++;
2218 if (wOdd) sampledPos++;
2222 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2230 for (i=0; i < h; i++) {
2231 if (i%2) sampledPos -= (w + 1)/2;
2233 for (j=0; j < w; j++) {
2236 uAvg = u[sampledPos];
2237 vAvg = v[sampledPos];
2238 aAvg = a[sampledPos] + yuvOffset16;
2242 aAvg = a[yPos] + yuvOffset16;
2245 g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2);
2246 buff[cnt + channelMap[1]] =
Clamp8(g >> shift);
2247 buff[cnt + channelMap[2]] =
Clamp8((uAvg + g) >> shift);
2248 buff[cnt + channelMap[0]] =
Clamp8((vAvg + g) >> shift);
2249 buff[cnt + channelMap[3]] =
Clamp8(aAvg >> shift);
2252 if (j%2) sampledPos++;
2255 if (wOdd) sampledPos++;
2259 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2265 #ifdef __PGF32SUPPORT__ 2277 UINT32 *buff32 = (UINT32 *)buff;
2278 int pitch32 = pitch/4;
2280 for (i=0; i < h; i++) {
2281 for (j=0; j < w; j++) {
2282 buff32[j] =
Clamp31((y[yPos++] + yuvOffset31) << shift);
2288 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2291 }
else if (bpp == 16) {
2293 UINT16 *buff16 = (UINT16 *)buff;
2294 int pitch16 = pitch/2;
2296 if (usedBits < 16) {
2297 const int shift = 16 - usedBits;
2298 for (i=0; i < h; i++) {
2299 for (j=0; j < w; j++) {
2300 buff16[j] =
Clamp16((y[yPos++] + yuvOffset31) << shift);
2306 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2310 const int shift =
__max(0, usedBits - 16);
2311 for (i=0; i < h; i++) {
2312 for (j=0; j < w; j++) {
2313 buff16[j] =
Clamp16((y[yPos++] + yuvOffset31) >> shift);
2319 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2327 for (i=0; i < h; i++) {
2328 for (j=0; j < w; j++) {
2329 buff[j] =
Clamp8((y[yPos++] + yuvOffset31) >> shift);
2335 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2355 for (i=0; i < h; i++) {
2357 for (j=0; j < w; j++) {
2363 buff[cnt] = UINT8(
Clamp4(vAvg + yval) | (yval << 4));
2365 buff[cnt] =
Clamp4(uAvg + yval);
2367 buff[cnt] |=
Clamp4(vAvg + yval) << 4;
2369 buff[cnt] = UINT8(yval | (
Clamp4(uAvg + yval) << 4));
2377 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2393 UINT16 *buff16 = (UINT16 *)buff;
2394 int pitch16 = pitch/2;
2396 for (i=0; i < h; i++) {
2397 for (j=0; j < w; j++) {
2402 buff16[j] = (yval << 5) | ((Clamp6(uAvg + yval) >> 1) << 11) | (
Clamp6(vAvg + yval) >> 1);
2408 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2417 #ifdef __PGFROISUPPORT__ 2422 buff = buffStart + (levelRoi.
top - roi.
top)*pitch + (levelRoi.
left - roi.
left)*bypp;
2423 w = levelRoi.
Width()*bypp;
2426 for (i=0; i < h; i++) {
2427 for (j=0; j < w; j++) {
2428 targetBuff[j] = buff[j];
2430 targetBuff += targetPitch;
2460 const bool wOdd = (1 == w%2);
2461 const int dataBits =
DataTSize*8; ASSERT(dataBits == 16 || dataBits == 32);
2464 const double dP = 1.0/h;
2466 int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(
sizeof(defMap)/
sizeof(defMap[0]) ==
MaxChannels);
2467 if (channelMap == NULL) channelMap = defMap;
2468 int sampledPos = 0, yPos = 0;
2474 ASSERT(bpp%dataBits == 0);
2481 for (i=0; i < h; i++) {
2482 if (i%2) sampledPos -= (w + 1)/2;
2484 for (j=0; j < w; j++) {
2487 uAvg = u[sampledPos];
2488 vAvg = v[sampledPos];
2493 buff[cnt + channelMap[0]] = y[yPos];
2494 buff[cnt + channelMap[1]] = uAvg;
2495 buff[cnt + channelMap[2]] = vAvg;
2498 if (j%2) sampledPos++;
2501 if (wOdd) sampledPos++;
2505 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2510 ASSERT(bpp%dataBits == 0);
2519 for (i=0; i < h; i++) {
2520 if (i%2) sampledPos -= (w + 1)/2;
2522 for (j=0; j < w; j++) {
2525 uAvg = u[sampledPos];
2526 vAvg = v[sampledPos];
2527 aAvg =
Clamp8(a[sampledPos] + yuvOffset);
2531 aAvg =
Clamp8(a[yPos] + yuvOffset);
2534 buff[cnt + channelMap[0]] = y[yPos];
2535 buff[cnt + channelMap[1]] = uAvg;
2536 buff[cnt + channelMap[2]] = vAvg;
2537 buff[cnt + channelMap[3]] = aAvg;
2540 if (j%2) sampledPos++;
2543 if (wOdd) sampledPos++;
2547 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2570 const int dataBits =
DataTSize*8; ASSERT(dataBits == 16 || dataBits == 32);
2574 int yPos = 0, cnt = 0;
2576 int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(
sizeof(defMap)/
sizeof(defMap[0]) ==
MaxChannels);
2578 if (channelMap == NULL) channelMap = defMap;
2581 ASSERT(bpp%dataBits == 0);
2590 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2596 y[yPos] = buff[cnt + channelMap[0]];
2597 u[yPos] = buff[cnt + channelMap[1]];
2598 v[yPos] = buff[cnt + channelMap[2]];
2605 ASSERT(bpp%dataBits == 0);
2615 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2621 y[yPos] = buff[cnt + channelMap[0]];
2622 u[yPos] = buff[cnt + channelMap[1]];
2623 v[yPos] = buff[cnt + channelMap[2]];
2624 a[yPos] = buff[cnt + channelMap[3]] - yuvOffset;
bool m_favorSpeedOverSize
favor encoding speed over compression ratio
UINT64 m_userDataPos
stream position of user data
bool m_useOMPinDecoder
use Open MP in decoder
UINT8 version
PGF version.
#define PGFVersion
current standard version
void Dequantize(int quantParam)
UINT32 AlignWordPos(UINT32 pos)
#define MaxChannels
maximum number of (color) channels
static BYTE CurrentVersion(BYTE version=PGFVersion)
Return version.
Abstract stream base class.
void DecodeInterleaved(CWaveletTransform *wtChannel, int level, int quantParam) THROW_
UINT32 ReadEncodedData(int level, UINT8 *target, UINT32 targetLen) const THROW_
BYTE UsedBitsPerChannel() const
bool m_skipUserData
skip user data (metadata) during open
void ImportYUV(int pitch, DataT *buff, BYTE bpp, int channelMap[]=NULL, CallbackPtr cb=NULL, void *data=NULL) THROW_
UINT32 ReadEncodedData(UINT8 *target, UINT32 len) const THROW_
void ExtractTile(CEncoder &encoder, bool tile=false, UINT32 tileX=0, UINT32 tileY=0) THROW_
void RgbToYuv(int pitch, UINT8 *rgbBuff, BYTE bpp, int channelMap[], CallbackPtr cb, void *data) THROW_
void Write(CPGFStream *stream, UINT32 *nWrittenBytes=NULL, CallbackPtr cb=NULL, void *data=NULL) THROW_
CDecoder * m_decoder
PGF decoder.
void Open(CPGFStream *stream) THROW_
UINT32 GetEncodedLevelLength(int level) const
PGFHeader m_header
PGF file header.
bool m_streamReinitialized
stream has been reinitialized
BYTE m_quant
quantization parameter
void * m_cbArg
refresh callback argument
DataT * m_channel[MaxChannels]
untransformed channels in YUV format
PGFPreHeader m_preHeader
PGF pre-header.
UINT32 WriteLevelLength(UINT32 *&levelLength) THROW_
UINT32 GetEncodedHeaderLength() const
void GetBitmap(int pitch, UINT8 *buff, BYTE bpp, int channelMap[]=NULL, CallbackPtr cb=NULL, void *data=NULL) const THROW_
void SetStreamPosToData() THROW_
Reset stream position to beginning of data block.
void SetROI(PGFRect rect)
const RGBQUAD * GetColorTable() const
const UINT8 * GetUserData(UINT32 &size) const
void GetYUV(int pitch, DataT *buff, BYTE bpp, int channelMap[]=NULL, CallbackPtr cb=NULL, void *data=NULL) const THROW_
#define Version6
new HeaderSize: 32 bits instead of 16 bits
UINT16 Clamp6(DataT v) const
#define ColorTableLen
size of color lookup table (clut)
#define MaxLevel
maximum number of transform levels
ProgressMode m_progressMode
progress mode used in Read and Write; PM_Relative is default mode
CWaveletTransform * m_wtChannel[MaxChannels]
wavelet transformed color channels
void Read(int level=0, CallbackPtr cb=NULL, void *data=NULL) THROW_
char magic[3]
PGF identification = "PGF".
PGFPostHeader m_postHeader
PGF post-header.
UINT32 Clamp31(DataT v) const
UINT16 Clamp16(DataT v) const
INT64 ComputeBufferLength() const
UINT32 ReadEncodedHeader(UINT8 *target, UINT32 targetLen) const THROW_
bool m_downsample
chrominance channels are downsampled
#define DownsampleThreshold
if quality is larger than this threshold than downsampling is used
UINT32 UpdatePostHeaderSize() THROW_
UINT32 * m_levelLength
length of each level in bytes; first level starts immediately after this array
UINT32 m_width[MaxChannels]
width of each channel at current level
#define Version2
data structure PGFHeader of major version 2
UINT32 UpdateLevelLength() THROW_
CPGFImage()
Standard constructor: It is used to create a PGF instance for opening and reading.
void SetColorTable(UINT32 iFirstColor, UINT32 nColors, const RGBQUAD *prgbColors) THROW_
void ImportBitmap(int pitch, UINT8 *buff, BYTE bpp, int channelMap[]=NULL, CallbackPtr cb=NULL, void *data=NULL) THROW_
bool ROIisSupported() const
#define MaxQuality
maximum quality
void Reconstruct(int level=0) THROW_
bool m_useOMPinEncoder
use Open MP in encoder
INT64 ComputeHeaderLength() const
virtual ~CPGFImage()
Destructor: Destroy internal data structures.
UINT8 Clamp8(DataT v) const
UINT8 Clamp4(DataT v) const
void FavorSpeedOverSize()
Encoder favors speed over compression size.
UINT32 GetEncodedHeaderLength() const
double m_percent
progress [0..1]
static UINT32 LevelWidth(UINT32 width, int level)
void SetMaxValue(UINT32 maxValue)
UINT32 WriteHeader(CPGFStream *stream) THROW_
RefreshCB m_cb
pointer to refresh callback procedure
static bool ImportIsSupported(BYTE mode)
void PlaceTile(CDecoder &decoder, int quantParam, bool tile=false, UINT32 tileX=0, UINT32 tileY=0) THROW_
void Skip(UINT64 offset) THROW_
CEncoder * m_encoder
PGF encoder.
bool IsInside(UINT32 x, UINT32 y) const
#define Magic
PGF identification.
INT64 ComputeOffset() const
void ResetStreamPos() THROW_
Reset stream position to start of PGF pre-header.
void Downsample(int nChannel)
UINT32 WriteImage(CPGFStream *stream, CallbackPtr cb=NULL, void *data=NULL) THROW_
int m_currentLevel
transform level of current image
#define Version5
new coding scheme since major version 5
void SetHeader(const PGFHeader &header, BYTE flags=0, UINT8 *userData=0, UINT32 userDataLength=0) THROW_
UINT32 m_height[MaxChannels]
height of each channel at current level
void SetStreamPosToStart() THROW_
Reset stream position to beginning of PGF pre-header.
PGFRect m_roi
region of interest
void UpdatePostHeaderSize(PGFPreHeader preHeader) THROW_
void SetEncodedLevel(int currentLevel)
static UINT32 LevelHeight(UINT32 height, int level)