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);
309 if (bpc > 31) bpc = 31;
347 while (currentLevel > level) {
361 if (err != NoError) ReturnWithError(err);
386 #ifdef __PGFROISUPPORT__ 390 Read(rect, level, cb, data);
400 if ((*cb)(1.0,
true, data)) ReturnWithError(EscapePressed);
427 volatile OSError error = NoError;
428 #pragma omp parallel for default(shared) 431 if (error == NoError) {
433 if (err != NoError) error = err;
437 if (error != NoError) ReturnWithError(error);
449 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
458 #ifdef __PGFROISUPPORT__ 475 Read(level, cb, data);
485 if (levelDiff <= 0) {
512 for (UINT32 tileY=0; tileY < nTiles; tileY++) {
513 for (UINT32 tileX=0; tileX < nTiles; tileX++) {
515 if (tileIndices.
IsInside(tileX, tileY)) {
528 volatile OSError error = NoError;
529 #pragma omp parallel for default(shared) 532 if (error == NoError) {
534 if (err != NoError) error = err;
538 if (error != NoError) ReturnWithError(error);
550 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
577 else rect.
left -= dx;
578 if (rect.
top < dy) rect.
top = 0;
601 #endif // __PGFROISUPPORT__ 621 ASSERT(targetLen > 0);
632 ASSERT(len >= 0 && len <= targetLen);
656 ASSERT(targetLen > 0);
675 ASSERT(len >= 0 && len <= targetLen);
688 while(maxValue > 0) {
693 if (pot > bpc) pot = bpc;
694 if (pot > 31) pot = 31;
742 RgbToYuv(pitch, buff, bpp, channelMap, cb, data);
760 const int oddW = w%2;
767 for (
int i=0; i < h2; i++) {
768 for (
int j=0; j < w2; j++) {
770 buff[sampledPos] = (buff[loPos] + buff[loPos + 1] + buff[hiPos] + buff[hiPos + 1]) >> 2;
771 loPos += 2; hiPos += 2;
775 buff[sampledPos] = (buff[loPos] + buff[hiPos]) >> 1;
779 loPos += w; hiPos += w;
782 for (
int j=0; j < w2; j++) {
783 buff[sampledPos] = (buff[loPos] + buff[loPos+1]) >> 1;
784 loPos += 2; hiPos += 2;
788 buff[sampledPos] = buff[loPos];
806 while (s > maxThumbnailWidth) {
843 #ifdef __PGFROISUPPORT__ 881 if (userDataLength && userData) {
905 ReturnWithError(InsufficientMemory);
922 volatile OSError error = NoError;
924 #pragma omp parallel for default(shared) 927 if (error == NoError) {
932 temp =
new(std::nothrow)
DataT[size];
937 error = InsufficientMemory;
940 if (error == NoError) {
943 #ifdef __PGFROISUPPORT__ 950 if (err != NoError) error = err;
955 if (error != NoError) ReturnWithError(error);
963 #ifdef __PGFROISUPPORT__ 978 return (nBytes > 0) ? (UINT32)nBytes : 0;
994 #ifdef __PGFROISUPPORT__ 1001 const UINT32 lastTile = nTiles - 1;
1005 ASSERT(nTiles == 1);
1009 for (UINT32 tileY=0; tileY < nTiles; tileY++) {
1010 for (UINT32 tileX=0; tileX < nTiles; tileX++) {
1014 if (i == lastChannel && tileY == lastTile && tileX == lastTile) {
1074 double percent = pow(0.25, levels);
1085 for (UINT32 i=0; i < size; i++) {
1087 stream->Write(&count, &
m_channel[c][i]);
1093 if ((*cb)(1,
true, data)) ReturnWithError(EscapePressed);
1108 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1124 return nWrittenBytes;
1151 if (nWrittenBytes) *nWrittenBytes += nBytes;
1154 #ifdef __PGFROISUPPORT__ 1177 UINT32 nWrittenBytes = 0;
1201 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1215 return nWrittenBytes;
1217 #endif // __PGFROISUPPORT__ 1270 if (iFirstColor + nColors >
ColorTableLen) ReturnWithError(ColorTableError);
1272 for (UINT32 i=iFirstColor, j=0; j < nColors; i++, j++) {
1284 if (iFirstColor + nColors >
ColorTableLen) ReturnWithError(ColorTableError);
1286 for (UINT32 i=iFirstColor, j=0; j < nColors; i++, j++) {
1308 void CPGFImage::RgbToYuv(
int pitch, UINT8* buff, BYTE bpp,
int channelMap[], CallbackPtr cb,
void *data ) THROW_ {
1310 int yPos = 0, cnt = 0;
1313 int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(
sizeof(defMap)/
sizeof(defMap[0]) ==
MaxChannels);
1315 if (channelMap == NULL) channelMap = defMap;
1330 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1334 for (UINT32 j=0; j < w2; j++) {
1337 for (UINT32 j=w2; j < w; j++) {
1367 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1388 ASSERT(bpp%16 == 0);
1390 UINT16 *buff16 = (UINT16 *)buff;
1391 const int pitch16 = pitch/2;
1398 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1405 m_channel[c][yPos] = (buff16[cnt + channelMap[c]] >> shift) - yuvOffset16;
1428 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1434 b = buff[cnt + channelMap[0]];
1435 g = buff[cnt + channelMap[1]];
1436 r = buff[cnt + channelMap[2]];
1438 y[yPos] = ((b + (g << 1) + r) >> 2) -
YUVoffset8;
1452 ASSERT(bpp%16 == 0);
1454 UINT16 *buff16 = (UINT16 *)buff;
1455 const int pitch16 = pitch/2;
1467 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1473 b = buff16[cnt + channelMap[0]] >> shift;
1474 g = buff16[cnt + channelMap[1]] >> shift;
1475 r = buff16[cnt + channelMap[2]] >> shift;
1477 y[yPos] = ((b + (g << 1) + r) >> 2) - yuvOffset16;
1503 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1509 b = buff[cnt + channelMap[0]];
1510 g = buff[cnt + channelMap[1]];
1511 r = buff[cnt + channelMap[2]];
1513 y[yPos] = ((b + (g << 1) + r) >> 2) -
YUVoffset8;
1516 a[yPos++] = buff[cnt + channelMap[3]] -
YUVoffset8;
1527 ASSERT(bpp%16 == 0);
1529 UINT16 *buff16 = (UINT16 *)buff;
1530 const int pitch16 = pitch/2;
1543 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1549 b = buff16[cnt + channelMap[0]] >> shift;
1550 g = buff16[cnt + channelMap[1]] >> shift;
1551 r = buff16[cnt + channelMap[2]] >> shift;
1553 y[yPos] = ((b + (g << 1) + r) >> 2) - yuvOffset16;
1556 a[yPos++] = (buff16[cnt + channelMap[3]] >> shift) - yuvOffset16;
1563 #ifdef __PGF32SUPPORT__ 1573 UINT32 *buff32 = (UINT32 *)buff;
1574 const int pitch32 = pitch/4;
1580 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1585 y[yPos++] = (buff32[w] >> shift) - yuvOffset31;
1602 UINT8 rgb = 0, b, g, r;
1606 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1616 g = (rgb & 0xF0) >> 4;
1622 b = (rgb & 0xF0) >> 4;
1626 r = (rgb & 0xF0) >> 4;
1631 y[yPos] = ((b + (g << 1) + r) >> 2) -
YUVoffset4;
1650 UINT16 *buff16 = (UINT16 *)buff;
1651 UINT16 rgb, b, g, r;
1652 const int pitch16 = pitch/2;
1656 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1661 r = (rgb & 0xF800) >> 10;
1662 g = (rgb & 0x07E0) >> 5;
1663 b = (rgb & 0x001F) << 1;
1665 y[yPos] = ((b + (g << 1) + r) >> 2) -
YUVoffset6;
1697 void CPGFImage::GetBitmap(
int pitch, UINT8* buff, BYTE bpp,
int channelMap[] , CallbackPtr cb ,
void *data )
const THROW_ {
1701 UINT8* targetBuff = 0;
1702 UINT8* buffStart = 0;
1703 int targetPitch = 0;
1705 #ifdef __PGFROISUPPORT__ 1715 targetPitch = pitch;
1720 buff = buffStart =
new(std::nothrow) UINT8[pitch*h];
1721 if (!buff) ReturnWithError(InsufficientMemory);
1725 const bool wOdd = (1 == w%2);
1727 const double dP = 1.0/h;
1728 int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(
sizeof(defMap)/
sizeof(defMap[0]) ==
MaxChannels);
1729 if (channelMap == NULL) channelMap = defMap;
1730 int sampledPos = 0, yPos = 0;
1742 const UINT32 w2 = (w + 7)/8;
1745 for (i=0; i < h; i++) {
1747 for (j=0; j < w2; j++) {
1767 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1783 for (i=0; i < h; i++) {
1785 for (j=0; j < w; j++) {
1796 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1811 UINT16 *buff16 = (UINT16 *)buff;
1812 int pitch16 = pitch/2;
1815 for (i=0; i < h; i++) {
1817 for (j=0; j < w; j++) {
1819 buff16[cnt + channelMap[c]] =
Clamp16((
m_channel[c][yPos] + yuvOffset16) << shift);
1828 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1836 for (i=0; i < h; i++) {
1838 for (j=0; j < w; j++) {
1840 buff[cnt + channelMap[c]] =
Clamp8((
m_channel[c][yPos] + yuvOffset16) >> shift);
1849 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1865 UINT8 *buffg = &buff[channelMap[1]],
1866 *buffr = &buff[channelMap[2]],
1867 *buffb = &buff[channelMap[0]];
1869 int cnt, channels = bpp/8;
1871 for (i=0; i < h; i++) {
1872 if (i%2) sampledPos -= (w + 1)/2;
1874 for (j=0; j < w; j++) {
1876 uAvg = u[sampledPos];
1877 vAvg = v[sampledPos];
1880 buffr[cnt] =
Clamp8(uAvg + g);
1881 buffb[cnt] =
Clamp8(vAvg + g);
1884 if (j%2) sampledPos++;
1889 if (wOdd) sampledPos++;
1892 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1896 for (i=0; i < h; i++) {
1898 for (j = 0; j < w; j++) {
1903 buffr[cnt] =
Clamp8(uAvg + g);
1904 buffb[cnt] =
Clamp8(vAvg + g);
1914 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1933 if (bpp >= 48 && bpp%16 == 0) {
1935 UINT16 *buff16 = (UINT16 *)buff;
1936 int pitch16 = pitch/2;
1939 for (i=0; i < h; i++) {
1940 if (i%2) sampledPos -= (w + 1)/2;
1942 for (j=0; j < w; j++) {
1945 uAvg = u[sampledPos];
1946 vAvg = v[sampledPos];
1952 g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2);
1953 buff16[cnt + channelMap[1]] =
Clamp16(g << shift);
1954 buff16[cnt + channelMap[2]] =
Clamp16((uAvg + g) << shift);
1955 buff16[cnt + channelMap[0]] =
Clamp16((vAvg + g) << shift);
1958 if (j%2) sampledPos++;
1961 if (wOdd) sampledPos++;
1965 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
1973 for (i=0; i < h; i++) {
1974 if (i%2) sampledPos -= (w + 1)/2;
1976 for (j=0; j < w; j++) {
1979 uAvg = u[sampledPos];
1980 vAvg = v[sampledPos];
1986 g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2);
1987 buff[cnt + channelMap[1]] =
Clamp8(g >> shift);
1988 buff[cnt + channelMap[2]] =
Clamp8((uAvg + g) >> shift);
1989 buff[cnt + channelMap[0]] =
Clamp8((vAvg + g) >> shift);
1992 if (j%2) sampledPos++;
1995 if (wOdd) sampledPos++;
1999 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2016 for (i=0; i < h; i++) {
2017 if (i%2) sampledPos -= (w + 1)/2;
2019 for (j=0; j < w; j++) {
2022 uAvg = a[sampledPos];
2023 vAvg = b[sampledPos];
2033 if (j%2) sampledPos++;
2036 if (wOdd) sampledPos++;
2040 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2059 UINT16 *buff16 = (UINT16 *)buff;
2060 int pitch16 = pitch/2;
2063 for (i=0; i < h; i++) {
2064 if (i%2) sampledPos -= (w + 1)/2;
2066 for (j=0; j < w; j++) {
2069 uAvg = a[sampledPos];
2070 vAvg = b[sampledPos];
2075 buff16[cnt + channelMap[0]] =
Clamp16((l[yPos] + yuvOffset16) << shift);
2076 buff16[cnt + channelMap[1]] =
Clamp16((uAvg + yuvOffset16) << shift);
2077 buff16[cnt + channelMap[2]] =
Clamp16((vAvg + yuvOffset16) << shift);
2080 if (j%2) sampledPos++;
2083 if (wOdd) sampledPos++;
2087 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2095 for (i=0; i < h; i++) {
2096 if (i%2) sampledPos -= (w + 1)/2;
2098 for (j=0; j < w; j++) {
2101 uAvg = a[sampledPos];
2102 vAvg = b[sampledPos];
2107 buff[cnt + channelMap[0]] =
Clamp8((l[yPos] + yuvOffset16) >> shift);
2108 buff[cnt + channelMap[1]] =
Clamp8((uAvg + yuvOffset16) >> shift);
2109 buff[cnt + channelMap[2]] =
Clamp8((vAvg + yuvOffset16) >> shift);
2112 if (j%2) sampledPos++;
2115 if (wOdd) sampledPos++;
2119 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2139 for (i=0; i < h; i++) {
2140 if (i%2) sampledPos -= (w + 1)/2;
2142 for (j=0; j < w; j++) {
2145 uAvg = u[sampledPos];
2146 vAvg = v[sampledPos];
2154 buff[cnt + channelMap[1]] = g =
Clamp8(y[yPos] +
YUVoffset8 - ((uAvg + vAvg ) >> 2));
2155 buff[cnt + channelMap[2]] =
Clamp8(uAvg + g);
2156 buff[cnt + channelMap[0]] =
Clamp8(vAvg + g);
2157 buff[cnt + channelMap[3]] = aAvg;
2160 if (j%2) sampledPos++;
2163 if (wOdd) sampledPos++;
2167 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2188 UINT16 *buff16 = (UINT16 *)buff;
2189 int pitch16 = pitch/2;
2192 for (i=0; i < h; i++) {
2193 if (i%2) sampledPos -= (w + 1)/2;
2195 for (j=0; j < w; j++) {
2198 uAvg = u[sampledPos];
2199 vAvg = v[sampledPos];
2200 aAvg = a[sampledPos] + yuvOffset16;
2204 aAvg = a[yPos] + yuvOffset16;
2207 g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2);
2208 buff16[cnt + channelMap[1]] =
Clamp16(g << shift);
2209 buff16[cnt + channelMap[2]] =
Clamp16((uAvg + g) << shift);
2210 buff16[cnt + channelMap[0]] =
Clamp16((vAvg + g) << shift);
2211 buff16[cnt + channelMap[3]] =
Clamp16(aAvg << shift);
2214 if (j%2) sampledPos++;
2217 if (wOdd) sampledPos++;
2221 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2229 for (i=0; i < h; i++) {
2230 if (i%2) sampledPos -= (w + 1)/2;
2232 for (j=0; j < w; j++) {
2235 uAvg = u[sampledPos];
2236 vAvg = v[sampledPos];
2237 aAvg = a[sampledPos] + yuvOffset16;
2241 aAvg = a[yPos] + yuvOffset16;
2244 g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2);
2245 buff[cnt + channelMap[1]] =
Clamp8(g >> shift);
2246 buff[cnt + channelMap[2]] =
Clamp8((uAvg + g) >> shift);
2247 buff[cnt + channelMap[0]] =
Clamp8((vAvg + g) >> shift);
2248 buff[cnt + channelMap[3]] =
Clamp8(aAvg >> shift);
2251 if (j%2) sampledPos++;
2254 if (wOdd) sampledPos++;
2258 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2264 #ifdef __PGF32SUPPORT__ 2276 UINT32 *buff32 = (UINT32 *)buff;
2277 int pitch32 = pitch/4;
2279 for (i=0; i < h; i++) {
2280 for (j=0; j < w; j++) {
2281 buff32[j] =
Clamp31((y[yPos++] + yuvOffset31) << shift);
2287 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2290 }
else if (bpp == 16) {
2292 UINT16 *buff16 = (UINT16 *)buff;
2293 int pitch16 = pitch/2;
2295 if (usedBits < 16) {
2296 const int shift = 16 - usedBits;
2297 for (i=0; i < h; i++) {
2298 for (j=0; j < w; j++) {
2299 buff16[j] =
Clamp16((y[yPos++] + yuvOffset31) << shift);
2305 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2309 const int shift =
__max(0, usedBits - 16);
2310 for (i=0; i < h; i++) {
2311 for (j=0; j < w; j++) {
2312 buff16[j] =
Clamp16((y[yPos++] + yuvOffset31) >> shift);
2318 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2326 for (i=0; i < h; i++) {
2327 for (j=0; j < w; j++) {
2328 buff[j] =
Clamp8((y[yPos++] + yuvOffset31) >> shift);
2334 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2354 for (i=0; i < h; i++) {
2356 for (j=0; j < w; j++) {
2362 buff[cnt] = UINT8(
Clamp4(vAvg + yval) | (yval << 4));
2364 buff[cnt] =
Clamp4(uAvg + yval);
2366 buff[cnt] |=
Clamp4(vAvg + yval) << 4;
2368 buff[cnt] = UINT8(yval | (
Clamp4(uAvg + yval) << 4));
2376 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2392 UINT16 *buff16 = (UINT16 *)buff;
2393 int pitch16 = pitch/2;
2395 for (i=0; i < h; i++) {
2396 for (j=0; j < w; j++) {
2401 buff16[j] = (yval << 5) | ((Clamp6(uAvg + yval) >> 1) << 11) | (
Clamp6(vAvg + yval) >> 1);
2407 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2416 #ifdef __PGFROISUPPORT__ 2421 buff = buffStart + (levelRoi.
top - roi.
top)*pitch + (levelRoi.
left - roi.
left)*bypp;
2422 w = levelRoi.
Width()*bypp;
2425 for (i=0; i < h; i++) {
2426 for (j=0; j < w; j++) {
2427 targetBuff[j] = buff[j];
2429 targetBuff += targetPitch;
2459 const bool wOdd = (1 == w%2);
2460 const int dataBits =
DataTSize*8; ASSERT(dataBits == 16 || dataBits == 32);
2463 const double dP = 1.0/h;
2465 int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(
sizeof(defMap)/
sizeof(defMap[0]) ==
MaxChannels);
2466 if (channelMap == NULL) channelMap = defMap;
2467 int sampledPos = 0, yPos = 0;
2473 ASSERT(bpp%dataBits == 0);
2480 for (i=0; i < h; i++) {
2481 if (i%2) sampledPos -= (w + 1)/2;
2483 for (j=0; j < w; j++) {
2486 uAvg = u[sampledPos];
2487 vAvg = v[sampledPos];
2492 buff[cnt + channelMap[0]] = y[yPos];
2493 buff[cnt + channelMap[1]] = uAvg;
2494 buff[cnt + channelMap[2]] = vAvg;
2497 if (j%2) sampledPos++;
2500 if (wOdd) sampledPos++;
2504 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2509 ASSERT(bpp%dataBits == 0);
2518 for (i=0; i < h; i++) {
2519 if (i%2) sampledPos -= (w + 1)/2;
2521 for (j=0; j < w; j++) {
2524 uAvg = u[sampledPos];
2525 vAvg = v[sampledPos];
2526 aAvg =
Clamp8(a[sampledPos] + yuvOffset);
2530 aAvg =
Clamp8(a[yPos] + yuvOffset);
2533 buff[cnt + channelMap[0]] = y[yPos];
2534 buff[cnt + channelMap[1]] = uAvg;
2535 buff[cnt + channelMap[2]] = vAvg;
2536 buff[cnt + channelMap[3]] = aAvg;
2539 if (j%2) sampledPos++;
2542 if (wOdd) sampledPos++;
2546 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2569 const int dataBits =
DataTSize*8; ASSERT(dataBits == 16 || dataBits == 32);
2573 int yPos = 0, cnt = 0;
2575 int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(
sizeof(defMap)/
sizeof(defMap[0]) ==
MaxChannels);
2577 if (channelMap == NULL) channelMap = defMap;
2580 ASSERT(bpp%dataBits == 0);
2589 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2595 y[yPos] = buff[cnt + channelMap[0]];
2596 u[yPos] = buff[cnt + channelMap[1]];
2597 v[yPos] = buff[cnt + channelMap[2]];
2604 ASSERT(bpp%dataBits == 0);
2614 if ((*cb)(percent,
true, data)) ReturnWithError(EscapePressed);
2620 y[yPos] = buff[cnt + channelMap[0]];
2621 u[yPos] = buff[cnt + channelMap[1]];
2622 v[yPos] = buff[cnt + channelMap[2]];
2623 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)