Ptex

PtexReader.h
Go to the documentation of this file.
1#ifndef PtexReader_h
2#define PtexReader_h
3
4/*
5 PTEX SOFTWARE
6 Copyright 2014 Disney Enterprises, Inc. All rights reserved
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are
10 met:
11
12 * Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14
15 * Redistributions in binary form must reproduce the above copyright
16 notice, this list of conditions and the following disclaimer in
17 the documentation and/or other materials provided with the
18 distribution.
19
20 * The names "Disney", "Walt Disney Pictures", "Walt Disney Animation
21 Studios" or the names of its contributors may NOT be used to
22 endorse or promote products derived from this software without
23 specific prior written permission from Walt Disney Pictures.
24
25 Disclaimer: THIS SOFTWARE IS PROVIDED BY WALT DISNEY PICTURES AND
26 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
27 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
28 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT AND TITLE ARE DISCLAIMED.
29 IN NO EVENT SHALL WALT DISNEY PICTURES, THE COPYRIGHT HOLDER OR
30 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND BASED ON ANY
34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
37*/
38#include <stdio.h>
39#include <vector>
40#include <string>
41#include <map>
42#include <errno.h>
43#include "Ptexture.h"
44#include "PtexIO.h"
45#include "PtexUtils.h"
46
47#include "PtexHashMap.h"
48
49 struct libdeflate_decompressor;
50
51 PTEX_NAMESPACE_BEGIN
52
53 class PtexReader : public PtexTexture {
54 public:
55 PtexReader(bool premultiply, PtexInputHandler* inputHandler, PtexErrorHandler* errorHandler);
56 virtual ~PtexReader();
57 virtual void release() { delete this; }
58 bool needToOpen() const { return _needToOpen; }
59 bool open(const char* path, Ptex::String& error);
60 void prune();
61 void purge();
62 void setPendingPurge() { _pendingPurge = true; }
63 bool pendingPurge() const { return _pendingPurge; }
64 bool tryClose();
65 bool ok() const { return _ok; }
66 bool isOpen() { return _fp; }
67 void invalidate() {
68 _ok = false;
69 _needToOpen = false;
70 }
71
72 void increaseMemUsed(size_t amount) { if (amount) AtomicAdd(&_memUsed, amount); }
73 void logOpen() { AtomicIncrement(&_opens); }
74 void logBlockRead() { AtomicIncrement(&_blockReads); }
75
76 virtual const char* path() { return _path.c_str(); }
77
78 virtual Info getInfo() {
79 Info info;
80 info.meshType = MeshType(_header.meshtype);
81 info.dataType = DataType(_header.datatype);
82 info.uBorderMode = BorderMode(_extheader.ubordermode);
83 info.vBorderMode = BorderMode(_extheader.vbordermode);
84 info.edgeFilterMode = EdgeFilterMode(_extheader.edgefiltermode);
85 info.alphaChannel = _header.alphachan;
86 info.numChannels = _header.nchannels;
87 info.numFaces = _header.nfaces;
88 return info;
89 }
90
91 virtual Ptex::MeshType meshType() { return MeshType(_header.meshtype); }
92 virtual Ptex::DataType dataType() { return DataType(_header.datatype); }
93 virtual Ptex::BorderMode uBorderMode() { return BorderMode(_extheader.ubordermode); }
94 virtual Ptex::BorderMode vBorderMode() { return BorderMode(_extheader.vbordermode); }
95 virtual Ptex::EdgeFilterMode edgeFilterMode() { return EdgeFilterMode(_extheader.edgefiltermode); }
96 virtual int alphaChannel() { return _header.alphachan; }
97 virtual int numChannels() { return _header.nchannels; }
98 virtual int numFaces() { return _header.nfaces; }
99 virtual bool hasEdits() { return false; }
100 virtual bool hasMipMaps() { return _header.nlevels > 1; }
101
102 virtual PtexMetaData* getMetaData();
103 virtual const Ptex::FaceInfo& getFaceInfo(int faceid);
104 virtual void getData(int faceid, void* buffer, int stride);
105 virtual void getData(int faceid, void* buffer, int stride, Res res);
106 virtual PtexFaceData* getData(int faceid);
107 virtual PtexFaceData* getData(int faceid, Res res);
108 virtual void* getConstantData(int faceid) final { return _constdata + faceid * _pixelsize; }
109 virtual void getPixel(int faceid, int u, int v,
110 float* result, int firstchan, int nchannels);
111 virtual void getPixel(int faceid, int u, int v,
112 float* result, int firstchan, int nchannels,
113 Ptex::Res res);
114 void getCompressedData(int faceid, int level, FaceDataHeader& fdh, std::vector<std::byte>& data);
115
116 DataType datatype() const { return DataType(_header.datatype); }
117 int nchannels() const { return _header.nchannels; }
118 int pixelsize() const { return _pixelsize; }
119 const Header& header() const { return _header; }
120 const ExtHeader& extheader() const { return _extheader; }
121 const LevelInfo& levelinfo(int level) const { return _levelinfo[level]; }
122
123 class MetaData : public PtexMetaData {
124 public:
125 MetaData(PtexReader* reader)
126 : _reader(reader) {}
127 ~MetaData() {}
128 virtual void release() {}
129
130 virtual int numKeys() { return int(_entries.size()); }
131 virtual void getKey(int index, const char*& key, MetaDataType& type)
132 {
133 if (index < 0 || index >= int(_entries.size())) {
134 return;
135 }
136 Entry* e = _entries[index];
137 key = e->key;
138 type = e->type;
139 }
140
141 virtual bool findKey(const char* key, int& index, MetaDataType& type)
142 {
143 MetaMap::iterator iter = _map.find(key);
144 if (iter==_map.end()) {
145 index = -1;
146 return false;
147 }
148 index = iter->second.index;
149 type = iter->second.type;
150 return true;
151 }
152
153 virtual void getValue(const char* key, const char*& value)
154 {
155 int index = -1;
156 MetaDataType type;
157 if (!findKey(key, index, type)) {
158 value = 0;
159 return;
160 }
161 Entry* e = getEntry(index);
162 if (e && e->type == mdt_string) value = (const char*) e->data;
163 else value = 0;
164 }
165
166 virtual void getValue(int index, const char*& value)
167 {
168 if (index < 0 || index >= int(_entries.size())) { value = 0; return; }
169 Entry* e = getEntry(index);
170 if (e && e->type == mdt_string) value = (const char*) e->data;
171 else value = 0;
172 }
173
174 template<typename T>
175 void getValue(int index, MetaDataType requestedType, const T*& value, int& count)
176 {
177 if (index < 0 || index >= int(_entries.size())) {
178 value = 0;
179 count = 0;
180 return;
181 }
182 Entry* e = getEntry(index);
183 if (e && e->type == requestedType) {
184 value = (const T*) e->data;
185 count = int(e->datasize/sizeof(T));
186 }
187 else { value = 0; count = 0; }
188 }
189
190 template<typename T>
191 void getValue(const char* key, MetaDataType requestedType, const T*& value, int& count)
192 {
193 int index = -1;
194 MetaDataType type;
195 findKey(key, index, type);
196 getValue<T>(index, requestedType, value, count);
197 }
198
199 virtual void getValue(const char* key, const int8_t*& value, int& count)
200 {
201 getValue<int8_t>(key, mdt_int8, value, count);
202 }
203
204 virtual void getValue(int index, const int8_t*& value, int& count)
205 {
206 getValue<int8_t>(index, mdt_int8, value, count);
207 }
208
209 virtual void getValue(const char* key, const int16_t*& value, int& count)
210 {
211 getValue<int16_t>(key, mdt_int16, value, count);
212 }
213
214 virtual void getValue(int index, const int16_t*& value, int& count)
215 {
216 getValue<int16_t>(index, mdt_int16, value, count);
217 }
218
219 virtual void getValue(const char* key, const int32_t*& value, int& count)
220 {
221 getValue<int32_t>(key, mdt_int32, value, count);
222 }
223
224 virtual void getValue(int index, const int32_t*& value, int& count)
225 {
226 getValue<int32_t>(index, mdt_int32, value, count);
227 }
228
229 virtual void getValue(const char* key, const float*& value, int& count)
230 {
231 getValue<float>(key, mdt_float, value, count);
232 }
233
234 virtual void getValue(int index, const float*& value, int& count)
235 {
236 getValue<float>(index, mdt_float, value, count);
237 }
238
239 virtual void getValue(const char* key, const double*& value, int& count)
240 {
241 getValue<double>(key, mdt_double, value, count);
242 }
243
244 virtual void getValue(int index, const double*& value, int& count)
245 {
246 getValue<double>(index, mdt_double, value, count);
247 }
248
249 void addEntry(uint8_t keysize, const char* key, uint8_t datatype,
250 uint32_t datasize, const void* data, size_t& metaDataMemUsed)
251 {
252 Entry* e = newEntry(keysize, key, datatype, datasize, metaDataMemUsed);
253 e->data = new char[datasize];
254 memcpy(e->data, data, datasize);
255 metaDataMemUsed += datasize;
256 }
257
258 void addLmdEntry(uint8_t keysize, const char* key, uint8_t datatype,
259 uint32_t datasize, FilePos filepos, uint32_t zipsize,
260 size_t& metaDataMemUsed)
261 {
262 Entry* e = newEntry(keysize, key, datatype, datasize, metaDataMemUsed);
263 e->isLmd = true;
264 e->lmdData = 0;
265 e->lmdPos = filepos;
266 e->lmdZipSize = zipsize;
267 }
268
269 size_t selfDataSize()
270 {
271 return sizeof(*this) + sizeof(Entry*) * _entries.capacity();
272 }
273
274 protected:
275 class LargeMetaData
276 {
277 public:
278 LargeMetaData(int size)
279 : _data(new char [size]) {}
280 virtual ~LargeMetaData() { delete [] _data; }
281 void* data() { return _data; }
282 private:
283 LargeMetaData(const LargeMetaData&);
284 char* _data;
285 };
286
287 struct Entry {
288 const char* key; // ptr to map key string
289 MetaDataType type; // meta data type
290 uint32_t datasize; // size of data in bytes
291 char* data; // if lmd, data only valid when lmd is loaded and ref'ed
292 bool isLmd; // true if data is a large meta data block
293 LargeMetaData* lmdData; // large meta data (lazy-loaded)
294 FilePos lmdPos; // large meta data file position
295 uint32_t lmdZipSize; // large meta data size on disk
296 uint32_t index; // index in vector
297
298 Entry() :
299 key(0), type(MetaDataType(0)), datasize(0), data(0),
300 isLmd(0), lmdData(0), lmdPos(0), lmdZipSize(0) {}
301 ~Entry() { clear(); }
302 void clear() {
303 if (isLmd) {
304 isLmd = 0;
305 if (lmdData) { delete lmdData; lmdData = 0; }
306 lmdPos = 0;
307 lmdZipSize = 0;
308 }
309 else {
310 if (data) { delete [] data; }
311 }
312 data = 0;
313 }
314 };
315
316 Entry* newEntry(uint8_t keysize, const char* key, uint8_t datatype, uint32_t datasize, size_t& metaDataMemUsed)
317 {
318 std::pair<MetaMap::iterator,bool> result =
319 _map.insert(std::make_pair(std::string(key, keysize), Entry()));
320 Entry* e = &result.first->second;
321 bool newentry = result.second;
322 uint32_t index = 0;
323 if (newentry) {
324 index = uint32_t(_entries.size());
325 _entries.push_back(e);
326 }
327 else {
328 index = e->index;
329 e->clear();
330 }
331 e->key = result.first->first.c_str();
332 e->type = MetaDataType(datatype);
333 e->datasize = datasize;
334 e->index = index;
335 metaDataMemUsed += sizeof(std::string) + keysize + 1 + sizeof(Entry);
336 return e;
337 }
338
339 PTEXAPI Entry* getEntry(int index);
340
341 PtexReader* _reader;
342 typedef std::map<std::string, Entry> MetaMap;
343 MetaMap _map;
344 std::vector<Entry*> _entries;
345 };
346
347
348 class ConstDataPtr : public PtexFaceData {
349 public:
350 ConstDataPtr(void* data, int pixelsize)
351 : _data(data), _pixelsize(pixelsize) {}
352 virtual void release() { delete this; }
353 virtual Ptex::Res res() { return 0; }
354 virtual bool isConstant() { return true; }
355 virtual void getPixel(int, int, void* result)
356 { memcpy(result, _data, _pixelsize); }
357 virtual void* getData() { return _data; }
358 virtual bool isTiled() { return false; }
359 virtual Ptex::Res tileRes() { return 0; }
360 virtual PtexFaceData* getTile(int) { return 0; }
361
362 protected:
363 void* _data;
364 int _pixelsize;
365 };
366
367
368 class FaceData : public PtexFaceData {
369 public:
370 FaceData(Res resArg)
371 : _res(resArg) {}
372 virtual ~FaceData() {}
373 virtual void release() { }
374 virtual Ptex::Res res() { return _res; }
375 virtual FaceData* reduce(PtexReader*, Res newres, PtexUtils::ReduceFn, size_t& newMemUsed) = 0;
376 protected:
377 Res _res;
378 };
379
380 class PackedFace : public FaceData {
381 public:
382 PackedFace(Res resArg, int pixelsize, int size)
383 : FaceData(resArg),
384 _pixelsize(pixelsize), _data(new char [size]) {}
385 void* data() { return _data; }
386 virtual bool isConstant() { return false; }
387 virtual void getPixel(int u, int v, void* result)
388 {
389 memcpy(result, _data + (v*_res.u() + u) * _pixelsize, _pixelsize);
390 }
391 virtual void* getData() { return _data; }
392 virtual bool isTiled() { return false; }
393 virtual Ptex::Res tileRes() { return _res; }
394 virtual PtexFaceData* getTile(int) { return 0; }
395 virtual FaceData* reduce(PtexReader*, Res newres, PtexUtils::ReduceFn, size_t& newMemUsed);
396
397 protected:
398 virtual ~PackedFace() { delete [] _data; }
399
400 int _pixelsize;
401 char* _data;
402 };
403
404 class ConstantFace : public PackedFace {
405 public:
406 ConstantFace(int pixelsize)
407 : PackedFace(0, pixelsize, pixelsize) {}
408 virtual bool isConstant() { return true; }
409 virtual void getPixel(int, int, void* result) { memcpy(result, _data, _pixelsize); }
410 virtual FaceData* reduce(PtexReader*, Res newres, PtexUtils::ReduceFn, size_t& newMemUsed);
411 };
412
413 class ErrorFace : public ConstantFace {
414 bool _deleteOnRelease;
415 public:
416 ErrorFace(void* errorPixel, int pixelsize, bool deleteOnRelease)
417 : ConstantFace(pixelsize), _deleteOnRelease(deleteOnRelease)
418 {
419 memcpy(_data, errorPixel, pixelsize);
420 }
421 virtual void release() { if (_deleteOnRelease) delete this; }
422 };
423
424 class TiledFaceBase : public FaceData {
425 public:
426 TiledFaceBase(PtexReader* reader, Res resArg, Res tileresArg)
427 : FaceData(resArg),
428 _reader(reader),
429 _tileres(tileresArg)
430 {
431 _dt = reader->datatype();
432 _nchan = reader->nchannels();
433 _pixelsize = DataSize(_dt)*_nchan;
434 _ntilesu = _res.ntilesu(tileresArg);
435 _ntilesv = _res.ntilesv(tileresArg);
436 _ntiles = _ntilesu*_ntilesv;
437 _tiles.resize(_ntiles);
438 }
439
440 virtual void release() { }
441 virtual bool isConstant() { return false; }
442 virtual void getPixel(int u, int v, void* result);
443 virtual void* getData() { return 0; }
444 virtual bool isTiled() { return true; }
445 virtual Ptex::Res tileRes() { return _tileres; }
446 virtual FaceData* reduce(PtexReader*, Res newres, PtexUtils::ReduceFn, size_t& newMemUsed);
447 Res tileres() const { return _tileres; }
448 int ntilesu() const { return _ntilesu; }
449 int ntilesv() const { return _ntilesv; }
450 int ntiles() const { return _ntiles; }
451
452 protected:
453 size_t baseExtraMemUsed() { return _tiles.size() * sizeof(_tiles[0]); }
454
455 virtual ~TiledFaceBase() {
456 for (std::vector<FaceData*>::iterator i = _tiles.begin(); i != _tiles.end(); ++i) {
457 if (*i) delete *i;
458 }
459 }
460
461 PtexReader* _reader;
462 Res _tileres;
463 DataType _dt;
464 int _nchan;
465 int _ntilesu;
466 int _ntilesv;
467 int _ntiles;
468 int _pixelsize;
469 std::vector<FaceData*> _tiles;
470 };
471
472
473 class TiledFace : public TiledFaceBase {
474 public:
475 TiledFace(PtexReader* reader, Res resArg, Res tileresArg, int levelid)
476 : TiledFaceBase(reader, resArg, tileresArg),
477 _levelid(levelid)
478 {
479 _fdh.resize(_ntiles),
480 _offsets.resize(_ntiles);
481 }
482 virtual PtexFaceData* getTile(int tile)
483 {
484 FaceData*& f = _tiles[tile];
485 if (!f) readTile(tile, f);
486 return f;
487 }
488 void readTile(int tile, FaceData*& data);
489 size_t memUsed() {
490 return sizeof(*this) + baseExtraMemUsed() + _fdh.size() * (sizeof(_fdh[0]) + sizeof(_offsets[0]));
491 }
492
493 protected:
494 friend class PtexReader;
495 int _levelid;
496 std::vector<FaceDataHeader> _fdh;
497 std::vector<FilePos> _offsets;
498 };
499
500
501 class TiledReducedFace : public TiledFaceBase {
502 public:
503 TiledReducedFace(PtexReader* reader, Res resArg, Res tileresArg,
504 TiledFaceBase* parentface, PtexUtils::ReduceFn reducefn)
505 : TiledFaceBase(reader, resArg, tileresArg),
506 _parentface(parentface),
507 _reducefn(reducefn)
508 {
509 }
510 ~TiledReducedFace()
511 {
512 }
513 virtual PtexFaceData* getTile(int tile);
514
515 size_t memUsed() { return sizeof(*this) + baseExtraMemUsed(); }
516
517 protected:
518 TiledFaceBase* _parentface;
519 PtexUtils::ReduceFn* _reducefn;
520 };
521
522
523 class Level {
524 public:
525 std::vector<FaceDataHeader> fdh;
526 std::vector<FilePos> offsets;
527 std::vector<FaceData*> faces;
528
529 Level(int nfaces)
530 : fdh(nfaces),
531 offsets(nfaces),
532 faces(nfaces) {}
533
534 ~Level() {
535 for (std::vector<FaceData*>::iterator i = faces.begin(); i != faces.end(); ++i) {
536 if (*i) delete *i;
537 }
538 }
539
540 size_t memUsed() {
541 return sizeof(*this) + fdh.size() * (sizeof(fdh[0]) +
542 sizeof(offsets[0]) +
543 sizeof(faces[0]));
544 }
545 };
546
547
548 protected:
549 void setError(const char* error, bool ioError = false)
550 {
551 std::string msg = error;
552 msg += " PtexFile: ";
553 msg += _path;
554 msg += "\n";
555 if (ioError) {
556 msg += _io->lastError();
557 msg += "\n";
558 }
559 if (_err) _err->reportError(msg.c_str());
560 else std::cerr << msg;
561 _ok = 0;
562 }
563
564 void setIOError(const char* error)
565 {
566 setError(error, true);
567 }
568
569 FilePos tell() { return _pos; }
570 void seek(FilePos pos)
571 {
572 if (!_fp && !reopenFP()) return;
573 logBlockRead();
574 if (pos != _pos) {
575 _io->seek(_fp, pos);
576 _pos = pos;
577 }
578 }
579
580 void closeFP();
581 bool reopenFP();
582 bool readBlock(void* data, int size);
583 bool readZipBlock(void* data, int zipsize, int unzipsize);
584 Level* getLevel(int levelid)
585 {
586 Level*& level = _levels[levelid];
587 if (!level) readLevel(levelid, level);
588 return level;
589 }
590
591 FaceData* getFace(int levelid, Level* level, int faceid, Res res)
592 {
593 FaceData*& face = level->faces[faceid];
594 if (!face) readFace(levelid, level, faceid, res);
595 return face;
596 }
597
598 void readFaceInfo();
599 void readLevelInfo();
600 void readConstData();
601 void readLevel(int levelid, Level*& level);
602 void readFace(int levelid, Level* level, int faceid, Res res);
603 void readFaceData(FilePos pos, FaceDataHeader fdh, Res res, int levelid, FaceData*& face);
604 void readMetaData();
605 void readMetaDataBlock(MetaData* metadata, FilePos pos, int zipsize, int memsize, size_t& metaDataMemUsed);
606 void readLargeMetaDataHeaders(MetaData* metadata, FilePos pos, int zipsize, int memsize, size_t& metaDataMemUsed);
607
608 FaceData* errorData(bool deleteOnRelease=false)
609 {
610 return new ErrorFace(&_errorPixel[0], _pixelsize, deleteOnRelease);
611 }
612
613 void computeFaceTileOffsets(FilePos pos, int noffsets, const FaceDataHeader* fdh, FilePos* offsets)
614 {
615 FilePos* end = offsets + noffsets;
616 while (offsets != end) { *offsets++ = pos; pos += fdh->blocksize(); fdh++; }
617 }
618
619 class DefaultInputHandler : public PtexInputHandler
620 {
621 char* buffer;
622 public:
623 DefaultInputHandler() : buffer(0) {}
624 virtual Handle open(const char* path) {
625 FILE* fp = fopen(path, "rb");
626 if (fp) {
627 buffer = new char [IBuffSize];
628 setvbuf(fp, buffer, _IOFBF, IBuffSize);
629 }
630 else buffer = 0;
631 return (Handle) fp;
632 }
633 virtual void seek(Handle handle, int64_t pos) { fseeko((FILE*)handle, pos, SEEK_SET); }
634 virtual size_t read(void* bufferArg, size_t size, Handle handle) {
635 return fread(bufferArg, size, 1, (FILE*)handle) == 1 ? size : 0;
636 }
637 virtual bool close(Handle handle) {
638 bool ok = handle && (fclose((FILE*)handle) == 0);
639 if (buffer) { delete [] buffer; buffer = 0; }
640 return ok;
641 }
642 virtual const char* lastError() { return strerror(errno); }
643 };
644
645 Mutex readlock;
646 DefaultInputHandler _defaultIo; // Default IO handler
647 PtexInputHandler* _io; // IO handler
648 PtexErrorHandler* _err; // Error handler
649 bool _premultiply; // true if reader should premultiply the alpha chan
650 bool _ok; // flag set to false if open or read error occurred
651 bool _needToOpen; // true if file needs to be opened (or reopened after a purge)
652 bool _pendingPurge; // true if a purge attempt was made but file was busy
653 PtexInputHandler::Handle _fp; // file pointer
654 FilePos _pos; // current seek position
655 std::string _path; // current file path
656 Header _header; // the header
657 ExtHeader _extheader; // extended header
658 FilePos _faceinfopos; // file positions of data sections
659 FilePos _constdatapos; // ...
660 FilePos _levelinfopos;
661 FilePos _leveldatapos;
662 FilePos _metadatapos;
663 FilePos _lmdheaderpos;
664 FilePos _lmddatapos;
665 int _pixelsize; // size of a pixel in bytes
666 uint8_t* _constdata; // constant pixel value per face
667 MetaData* _metadata; // meta data (read on demand)
668
669 std::vector<FaceInfo> _faceinfo; // per-face header info
670 std::vector<uint32_t> _rfaceids; // faceids sorted in reduction order
671 std::vector<LevelInfo> _levelinfo; // per-level header info
672 std::vector<FilePos> _levelpos; // file position of each level's data
673 std::vector<Level*> _levels; // level data (read on demand)
674
675 class ReductionKey {
676 int64_t _val;
677 public:
678 ReductionKey() : _val(-1) {}
679 ReductionKey(uint32_t faceid, Res res)
680 : _val( int64_t(faceid)<<32 | uint32_t(16777619*((res.val()<<16) ^ faceid)) ) {}
681
682 void copy(volatile ReductionKey& key) volatile
683 {
684 _val = key._val;
685 }
686
687 void move(volatile ReductionKey& key) volatile
688 {
689 _val = key._val;
690 }
691
692 bool matches(const ReductionKey& key) const volatile
693 {
694 return _val == key._val;
695 }
696 bool isEmpty() const volatile { return _val==-1; }
697 uint32_t hash() const volatile
698 {
699 return uint32_t(_val);
700 }
701 };
702 typedef PtexHashMap<ReductionKey, FaceData*> ReductionMap;
703 ReductionMap _reductions;
704 std::vector<char> _errorPixel; // referenced by errorData()
705
706 libdeflate_decompressor* _decompressor;
707 size_t _baseMemUsed;
708 volatile size_t _memUsed;
709 volatile size_t _opens;
710 volatile size_t _blockReads;
711};
712
713 PTEX_NAMESPACE_END
714
715#endif
PTEXAPI
#define PTEXAPI
Definition PtexExports.h:60
PtexHashMap.h
Contains PtexHashMap, a lightweight multi-threaded hash table.
PtexIO.h
IBuffSize
const int IBuffSize
Definition PtexIO.h:106
FilePos
off_t FilePos
Definition PtexPlatform.h:101
AtomicAdd
PTEX_INLINE T AtomicAdd(volatile T *target, T value)
Definition PtexPlatform.h:211
AtomicIncrement
PTEX_INLINE T AtomicIncrement(volatile T *target)
Definition PtexPlatform.h:227
PtexUtils.h
PTEX_NAMESPACE_END
#define PTEX_NAMESPACE_END
Definition PtexVersion.h:62
Ptexture.h
Public API classes for reading, writing, caching, and filtering Ptex files.
Mutex
Definition PtexPlatform.h:139
PtexErrorHandler
Custom handler interface redirecting Ptex error messages.
Definition Ptexture.h:667
PtexFaceData
Per-face texture data accessor.
Definition Ptexture.h:409
PtexHashMap
Definition PtexHashMap.h:133
PtexInputHandler
Custom handler interface for intercepting and redirecting Ptex input stream calls.
Definition Ptexture.h:628
PtexInputHandler::Handle
void * Handle
Definition Ptexture.h:633
PtexMetaData
Meta data accessor.
Definition Ptexture.h:331
PtexReader::ConstDataPtr::isConstant
virtual bool isConstant()
True if this data block is constant.
Definition PtexReader.h:354
PtexReader::ConstDataPtr::_data
void * _data
Definition PtexReader.h:363
PtexReader::ConstDataPtr::res
virtual Ptex::Res res()
Resolution of the texture held by this data block.
Definition PtexReader.h:353
PtexReader::ConstDataPtr::release
virtual void release()
Release resources held by this pointer (pointer becomes invalid).
Definition PtexReader.h:352
PtexReader::ConstDataPtr::isTiled
virtual bool isTiled()
True if this data block is tiled.
Definition PtexReader.h:358
PtexReader::ConstDataPtr::getData
virtual void * getData()
Access the data from this data block.
Definition PtexReader.h:357
PtexReader::ConstDataPtr::getPixel
virtual void getPixel(int, int, void *result)
Read a single texel from the data block.
Definition PtexReader.h:355
PtexReader::ConstDataPtr::_pixelsize
int _pixelsize
Definition PtexReader.h:364
PtexReader::ConstDataPtr::tileRes
virtual Ptex::Res tileRes()
Resolution of each tile in this data block.
Definition PtexReader.h:359
PtexReader::ConstDataPtr::getTile
virtual PtexFaceData * getTile(int)
Access a tile from the data block.
Definition PtexReader.h:360
PtexReader::ConstDataPtr::ConstDataPtr
ConstDataPtr(void *data, int pixelsize)
Definition PtexReader.h:350
PtexReader::ConstantFace::getPixel
virtual void getPixel(int, int, void *result)
Read a single texel from the data block.
Definition PtexReader.h:409
PtexReader::ConstantFace::ConstantFace
ConstantFace(int pixelsize)
Definition PtexReader.h:406
PtexReader::ConstantFace::isConstant
virtual bool isConstant()
True if this data block is constant.
Definition PtexReader.h:408
PtexReader::ConstantFace::reduce
virtual FaceData * reduce(PtexReader *, Res newres, PtexUtils::ReduceFn, size_t &newMemUsed)
Definition PtexReader.cpp:950
PtexReader::DefaultInputHandler
Definition PtexReader.h:620
PtexReader::DefaultInputHandler::buffer
char * buffer
Definition PtexReader.h:621
PtexReader::DefaultInputHandler::seek
virtual void seek(Handle handle, int64_t pos)
Seek to an absolute byte position in the input stream.
Definition PtexReader.h:633
PtexReader::DefaultInputHandler::DefaultInputHandler
DefaultInputHandler()
Definition PtexReader.h:623
PtexReader::DefaultInputHandler::close
virtual bool close(Handle handle)
Close a file.
Definition PtexReader.h:637
PtexReader::DefaultInputHandler::read
virtual size_t read(void *bufferArg, size_t size, Handle handle)
Read a number of bytes from the file.
Definition PtexReader.h:634
PtexReader::DefaultInputHandler::open
virtual Handle open(const char *path)
Open a file in read mode.
Definition PtexReader.h:624
PtexReader::DefaultInputHandler::lastError
virtual const char * lastError()
Return the last error message encountered.
Definition PtexReader.h:642
PtexReader::ErrorFace
Definition PtexReader.h:413
PtexReader::ErrorFace::_deleteOnRelease
bool _deleteOnRelease
Definition PtexReader.h:414
PtexReader::ErrorFace::release
virtual void release()
Release resources held by this pointer (pointer becomes invalid).
Definition PtexReader.h:421
PtexReader::ErrorFace::ErrorFace
ErrorFace(void *errorPixel, int pixelsize, bool deleteOnRelease)
Definition PtexReader.h:416
PtexReader::FaceData
Definition PtexReader.h:368
PtexReader::FaceData::res
virtual Ptex::Res res()
Resolution of the texture held by this data block.
Definition PtexReader.h:374
PtexReader::FaceData::reduce
virtual FaceData * reduce(PtexReader *, Res newres, PtexUtils::ReduceFn, size_t &newMemUsed)=0
PtexReader::FaceData::release
virtual void release()
Release resources held by this pointer (pointer becomes invalid).
Definition PtexReader.h:373
PtexReader::FaceData::~FaceData
virtual ~FaceData()
Definition PtexReader.h:372
PtexReader::FaceData::_res
Res _res
Definition PtexReader.h:377
PtexReader::FaceData::FaceData
FaceData(Res resArg)
Definition PtexReader.h:370
PtexReader::Level
Definition PtexReader.h:523
PtexReader::Level::Level
Level(int nfaces)
Definition PtexReader.h:529
PtexReader::Level::offsets
std::vector< FilePos > offsets
Definition PtexReader.h:526
PtexReader::Level::fdh
std::vector< FaceDataHeader > fdh
Definition PtexReader.h:525
PtexReader::Level::faces
std::vector< FaceData * > faces
Definition PtexReader.h:527
PtexReader::Level::memUsed
size_t memUsed()
Definition PtexReader.h:540
PtexReader::Level::~Level
~Level()
Definition PtexReader.h:534
PtexReader::MetaData::LargeMetaData
Definition PtexReader.h:276
PtexReader::MetaData::LargeMetaData::data
void * data()
Definition PtexReader.h:281
PtexReader::MetaData::LargeMetaData::LargeMetaData
LargeMetaData(int size)
Definition PtexReader.h:278
PtexReader::MetaData::LargeMetaData::LargeMetaData
LargeMetaData(const LargeMetaData &)
PtexReader::MetaData::LargeMetaData::_data
char * _data
Definition PtexReader.h:284
PtexReader::MetaData::LargeMetaData::~LargeMetaData
virtual ~LargeMetaData()
Definition PtexReader.h:280
PtexReader::MetaData
Definition PtexReader.h:123
PtexReader::MetaData::getValue
virtual void getValue(int index, const int8_t *&value, int &count)
Query the value of a given meta data entry by index.
Definition PtexReader.h:204
PtexReader::MetaData::selfDataSize
size_t selfDataSize()
Definition PtexReader.h:269
PtexReader::MetaData::release
virtual void release()
Release resources held by this pointer (pointer becomes invalid).
Definition PtexReader.h:128
PtexReader::MetaData::newEntry
Entry * newEntry(uint8_t keysize, const char *key, uint8_t datatype, uint32_t datasize, size_t &metaDataMemUsed)
Definition PtexReader.h:316
PtexReader::MetaData::getKey
virtual void getKey(int index, const char *&key, MetaDataType &type)
Definition PtexReader.h:131
PtexReader::MetaData::getValue
virtual void getValue(int index, const double *&value, int &count)
Query the value of a given meta data entry by index.
Definition PtexReader.h:244
PtexReader::MetaData::getValue
virtual void getValue(const char *key, const int8_t *&value, int &count)
Query the value of a given meta data entry.
Definition PtexReader.h:199
PtexReader::MetaData::getValue
virtual void getValue(int index, const char *&value)
Query the value of a given meta data entry by index.
Definition PtexReader.h:166
PtexReader::MetaData::~MetaData
~MetaData()
Definition PtexReader.h:127
PtexReader::MetaData::addEntry
void addEntry(uint8_t keysize, const char *key, uint8_t datatype, uint32_t datasize, const void *data, size_t &metaDataMemUsed)
Definition PtexReader.h:249
PtexReader::MetaData::getValue
virtual void getValue(int index, const float *&value, int &count)
Query the value of a given meta data entry by index.
Definition PtexReader.h:234
PtexReader::MetaData::getValue
void getValue(const char *key, MetaDataType requestedType, const T *&value, int &count)
Definition PtexReader.h:191
PtexReader::MetaData::findKey
virtual bool findKey(const char *key, int &index, MetaDataType &type)
Definition PtexReader.h:141
PtexReader::MetaData::getValue
virtual void getValue(int index, const int16_t *&value, int &count)
Query the value of a given meta data entry by index.
Definition PtexReader.h:214
PtexReader::MetaData::MetaData
MetaData(PtexReader *reader)
Definition PtexReader.h:125
PtexReader::MetaData::getValue
virtual void getValue(const char *key, const int32_t *&value, int &count)
Query the value of a given meta data entry.
Definition PtexReader.h:219
PtexReader::MetaData::numKeys
virtual int numKeys()
Query number of meta data entries stored in file.
Definition PtexReader.h:130
PtexReader::MetaData::getValue
virtual void getValue(int index, const int32_t *&value, int &count)
Query the value of a given meta data entry by index.
Definition PtexReader.h:224
PtexReader::MetaData::getValue
virtual void getValue(const char *key, const double *&value, int &count)
Query the value of a given meta data entry.
Definition PtexReader.h:239
PtexReader::MetaData::_reader
PtexReader * _reader
Definition PtexReader.h:341
PtexReader::MetaData::_map
MetaMap _map
Definition PtexReader.h:343
PtexReader::MetaData::getValue
virtual void getValue(const char *key, const char *&value)
Query the value of a given meta data entry.
Definition PtexReader.h:153
PtexReader::MetaData::MetaMap
std::map< std::string, Entry > MetaMap
Definition PtexReader.h:342
PtexReader::MetaData::getValue
virtual void getValue(const char *key, const float *&value, int &count)
Query the value of a given meta data entry.
Definition PtexReader.h:229
PtexReader::MetaData::addLmdEntry
void addLmdEntry(uint8_t keysize, const char *key, uint8_t datatype, uint32_t datasize, FilePos filepos, uint32_t zipsize, size_t &metaDataMemUsed)
Definition PtexReader.h:258
PtexReader::MetaData::getValue
void getValue(int index, MetaDataType requestedType, const T *&value, int &count)
Definition PtexReader.h:175
PtexReader::MetaData::getEntry
Entry * getEntry(int index)
Definition PtexReader.cpp:345
PtexReader::MetaData::_entries
std::vector< Entry * > _entries
Definition PtexReader.h:344
PtexReader::MetaData::getValue
virtual void getValue(const char *key, const int16_t *&value, int &count)
Query the value of a given meta data entry.
Definition PtexReader.h:209
PtexReader::PackedFace::~PackedFace
virtual ~PackedFace()
Definition PtexReader.h:398
PtexReader::PackedFace::data
void * data()
Definition PtexReader.h:385
PtexReader::PackedFace::getTile
virtual PtexFaceData * getTile(int)
Access a tile from the data block.
Definition PtexReader.h:394
PtexReader::PackedFace::PackedFace
PackedFace(Res resArg, int pixelsize, int size)
Definition PtexReader.h:382
PtexReader::PackedFace::isTiled
virtual bool isTiled()
True if this data block is tiled.
Definition PtexReader.h:392
PtexReader::PackedFace::_pixelsize
int _pixelsize
Definition PtexReader.h:400
PtexReader::PackedFace::tileRes
virtual Ptex::Res tileRes()
Resolution of each tile in this data block.
Definition PtexReader.h:393
PtexReader::PackedFace::_data
char * _data
Definition PtexReader.h:401
PtexReader::PackedFace::reduce
virtual FaceData * reduce(PtexReader *, Res newres, PtexUtils::ReduceFn, size_t &newMemUsed)
Definition PtexReader.cpp:933
PtexReader::PackedFace::isConstant
virtual bool isConstant()
True if this data block is constant.
Definition PtexReader.h:386
PtexReader::PackedFace::getPixel
virtual void getPixel(int u, int v, void *result)
Read a single texel from the data block.
Definition PtexReader.h:387
PtexReader::PackedFace::getData
virtual void * getData()
Access the data from this data block.
Definition PtexReader.h:391
PtexReader::ReductionKey::_val
int64_t _val
Definition PtexReader.h:676
PtexReader::ReductionKey::isEmpty
bool isEmpty() const volatile
Definition PtexReader.h:696
PtexReader::ReductionKey::ReductionKey
ReductionKey(uint32_t faceid, Res res)
Definition PtexReader.h:679
PtexReader::ReductionKey::move
void move(volatile ReductionKey &key) volatile
Definition PtexReader.h:687
PtexReader::ReductionKey::hash
uint32_t hash() const volatile
Definition PtexReader.h:697
PtexReader::ReductionKey::ReductionKey
ReductionKey()
Definition PtexReader.h:678
PtexReader::ReductionKey::copy
void copy(volatile ReductionKey &key) volatile
Definition PtexReader.h:682
PtexReader::ReductionKey::matches
bool matches(const ReductionKey &key) const volatile
Definition PtexReader.h:692
PtexReader::TiledFaceBase::TiledFaceBase
TiledFaceBase(PtexReader *reader, Res resArg, Res tileresArg)
Definition PtexReader.h:426
PtexReader::TiledFaceBase::baseExtraMemUsed
size_t baseExtraMemUsed()
Definition PtexReader.h:453
PtexReader::TiledFaceBase::_tiles
std::vector< FaceData * > _tiles
Definition PtexReader.h:469
PtexReader::TiledFaceBase::isTiled
virtual bool isTiled()
True if this data block is tiled.
Definition PtexReader.h:444
PtexReader::TiledFaceBase::reduce
virtual FaceData * reduce(PtexReader *, Res newres, PtexUtils::ReduceFn, size_t &newMemUsed)
Definition PtexReader.cpp:963
PtexReader::TiledFaceBase::tileres
Res tileres() const
Definition PtexReader.h:447
PtexReader::TiledFaceBase::ntilesu
int ntilesu() const
Definition PtexReader.h:448
PtexReader::TiledFaceBase::_dt
DataType _dt
Definition PtexReader.h:463
PtexReader::TiledFaceBase::getData
virtual void * getData()
Access the data from this data block.
Definition PtexReader.h:443
PtexReader::TiledFaceBase::_ntilesv
int _ntilesv
Definition PtexReader.h:466
PtexReader::TiledFaceBase::_ntilesu
int _ntilesu
Definition PtexReader.h:465
PtexReader::TiledFaceBase::_nchan
int _nchan
Definition PtexReader.h:464
PtexReader::TiledFaceBase::ntilesv
int ntilesv() const
Definition PtexReader.h:449
PtexReader::TiledFaceBase::_ntiles
int _ntiles
Definition PtexReader.h:467
PtexReader::TiledFaceBase::release
virtual void release()
Release resources held by this pointer (pointer becomes invalid).
Definition PtexReader.h:440
PtexReader::TiledFaceBase::_tileres
Res _tileres
Definition PtexReader.h:462
PtexReader::TiledFaceBase::tileRes
virtual Ptex::Res tileRes()
Resolution of each tile in this data block.
Definition PtexReader.h:445
PtexReader::TiledFaceBase::ntiles
int ntiles() const
Definition PtexReader.h:450
PtexReader::TiledFaceBase::_pixelsize
int _pixelsize
Definition PtexReader.h:468
PtexReader::TiledFaceBase::isConstant
virtual bool isConstant()
True if this data block is constant.
Definition PtexReader.h:441
PtexReader::TiledFaceBase::_reader
PtexReader * _reader
Definition PtexReader.h:461
PtexReader::TiledFaceBase::getPixel
virtual void getPixel(int u, int v, void *result)
Read a single texel from the data block.
Definition PtexReader.cpp:1088
PtexReader::TiledFaceBase::~TiledFaceBase
virtual ~TiledFaceBase()
Definition PtexReader.h:455
PtexReader::TiledFace::_fdh
std::vector< FaceDataHeader > _fdh
Definition PtexReader.h:496
PtexReader::TiledFace::TiledFace
TiledFace(PtexReader *reader, Res resArg, Res tileresArg, int levelid)
Definition PtexReader.h:475
PtexReader::TiledFace::_levelid
int _levelid
Definition PtexReader.h:495
PtexReader::TiledFace::PtexReader
friend class PtexReader
Definition PtexReader.h:494
PtexReader::TiledFace::memUsed
size_t memUsed()
Definition PtexReader.h:489
PtexReader::TiledFace::getTile
virtual PtexFaceData * getTile(int tile)
Access a tile from the data block.
Definition PtexReader.h:482
PtexReader::TiledFace::readTile
void readTile(int tile, FaceData *&data)
Definition PtexReader.cpp:567
PtexReader::TiledFace::_offsets
std::vector< FilePos > _offsets
Definition PtexReader.h:497
PtexReader::TiledReducedFace::_parentface
TiledFaceBase * _parentface
Definition PtexReader.h:518
PtexReader::TiledReducedFace::getTile
virtual PtexFaceData * getTile(int tile)
Access a tile from the data block.
Definition PtexReader.cpp:1099
PtexReader::TiledReducedFace::~TiledReducedFace
~TiledReducedFace()
Definition PtexReader.h:510
PtexReader::TiledReducedFace::_reducefn
PtexUtils::ReduceFn * _reducefn
Definition PtexReader.h:519
PtexReader::TiledReducedFace::memUsed
size_t memUsed()
Definition PtexReader.h:515
PtexReader::TiledReducedFace::TiledReducedFace
TiledReducedFace(PtexReader *reader, Res resArg, Res tileresArg, TiledFaceBase *parentface, PtexUtils::ReduceFn reducefn)
Definition PtexReader.h:503
PtexReader::readLevelInfo
void readLevelInfo()
Definition PtexReader.cpp:300
PtexReader::_reductions
ReductionMap _reductions
Definition PtexReader.h:703
PtexReader::reopenFP
bool reopenFP()
Definition PtexReader.cpp:242
PtexReader::ok
bool ok() const
Definition PtexReader.h:65
PtexReader::datatype
DataType datatype() const
Definition PtexReader.h:116
PtexReader::_premultiply
bool _premultiply
Definition PtexReader.h:649
PtexReader::_constdatapos
FilePos _constdatapos
Definition PtexReader.h:659
PtexReader::readMetaDataBlock
void readMetaDataBlock(MetaData *metadata, FilePos pos, int zipsize, int memsize, size_t &metaDataMemUsed)
Definition PtexReader.cpp:411
PtexReader::extheader
const ExtHeader & extheader() const
Definition PtexReader.h:120
PtexReader::getConstantData
virtual void * getConstantData(int faceid) final
Access the constant (or average) data value for a given face.
Definition PtexReader.h:108
PtexReader::numFaces
virtual int numFaces()
Number of faces stored in file.
Definition PtexReader.h:98
PtexReader::setPendingPurge
void setPendingPurge()
Definition PtexReader.h:62
PtexReader::readFaceInfo
void readFaceInfo()
Definition PtexReader.cpp:279
PtexReader::vBorderMode
virtual Ptex::BorderMode vBorderMode()
Mode for filtering texture access beyond mesh border.
Definition PtexReader.h:94
PtexReader::_path
std::string _path
Definition PtexReader.h:655
PtexReader::_constdata
uint8_t * _constdata
Definition PtexReader.h:666
PtexReader::_levelpos
std::vector< FilePos > _levelpos
Definition PtexReader.h:672
PtexReader::getPixel
virtual void getPixel(int faceid, int u, int v, float *result, int firstchan, int nchannels)
Access a single texel from the highest resolution texture .
Definition PtexReader.cpp:825
PtexReader::getInfo
virtual Info getInfo()
Definition PtexReader.h:78
PtexReader::setIOError
void setIOError(const char *error)
Definition PtexReader.h:564
PtexReader::_opens
volatile size_t _opens
Definition PtexReader.h:709
PtexReader::isOpen
bool isOpen()
Definition PtexReader.h:66
PtexReader::release
virtual void release()
Release resources held by this pointer (pointer becomes invalid).
Definition PtexReader.h:57
PtexReader::increaseMemUsed
void increaseMemUsed(size_t amount)
Definition PtexReader.h:72
PtexReader::path
virtual const char * path()
Path that file was opened with.
Definition PtexReader.h:76
PtexReader::computeFaceTileOffsets
void computeFaceTileOffsets(FilePos pos, int noffsets, const FaceDataHeader *fdh, FilePos *offsets)
Definition PtexReader.h:613
PtexReader::getFace
FaceData * getFace(int levelid, Level *level, int faceid, Res res)
Definition PtexReader.h:591
PtexReader::purge
void purge()
Definition PtexReader.cpp:117
PtexReader::tell
FilePos tell()
Definition PtexReader.h:569
PtexReader::getLevel
Level * getLevel(int levelid)
Definition PtexReader.h:584
PtexReader::errorData
FaceData * errorData(bool deleteOnRelease=false)
Definition PtexReader.h:608
PtexReader::~PtexReader
virtual ~PtexReader()
Definition PtexReader.cpp:94
PtexReader::_needToOpen
bool _needToOpen
Definition PtexReader.h:651
PtexReader::uBorderMode
virtual Ptex::BorderMode uBorderMode()
Mode for filtering texture access beyond mesh border.
Definition PtexReader.h:93
PtexReader::readConstData
void readConstData()
Definition PtexReader.cpp:321
PtexReader::getMetaData
virtual PtexMetaData * getMetaData()
Access meta data.
Definition PtexReader.cpp:337
PtexReader::needToOpen
bool needToOpen() const
Definition PtexReader.h:58
PtexReader::alphaChannel
virtual int alphaChannel()
Index of alpha channel (if any).
Definition PtexReader.h:96
PtexReader::_extheader
ExtHeader _extheader
Definition PtexReader.h:657
PtexReader::_leveldatapos
FilePos _leveldatapos
Definition PtexReader.h:661
PtexReader::getData
virtual void getData(int faceid, void *buffer, int stride)
Access texture data for a face at highest-resolution.
Definition PtexReader.cpp:643
PtexReader::_err
PtexErrorHandler * _err
Definition PtexReader.h:648
PtexReader::header
const Header & header() const
Definition PtexReader.h:119
PtexReader::_faceinfopos
FilePos _faceinfopos
Definition PtexReader.h:658
PtexReader::_levelinfo
std::vector< LevelInfo > _levelinfo
Definition PtexReader.h:671
PtexReader::readBlock
bool readBlock(void *data, int size)
Definition PtexReader.cpp:466
PtexReader::ReductionMap
PtexHashMap< ReductionKey, FaceData * > ReductionMap
Definition PtexReader.h:702
PtexReader::PtexReader
PtexReader(bool premultiply, PtexInputHandler *inputHandler, PtexErrorHandler *errorHandler)
Definition PtexReader.cpp:73
PtexReader::hasMipMaps
virtual bool hasMipMaps()
True if the file has mipmaps.
Definition PtexReader.h:100
PtexReader::_io
PtexInputHandler * _io
Definition PtexReader.h:647
PtexReader::getFaceInfo
virtual const Ptex::FaceInfo & getFaceInfo(int faceid)
Access resolution and adjacency information about a face.
Definition PtexReader.cpp:269
PtexReader::_metadatapos
FilePos _metadatapos
Definition PtexReader.h:662
PtexReader::readLargeMetaDataHeaders
void readLargeMetaDataHeaders(MetaData *metadata, FilePos pos, int zipsize, int memsize, size_t &metaDataMemUsed)
Definition PtexReader.cpp:437
PtexReader::closeFP
void closeFP()
Definition PtexReader.cpp:233
PtexReader::_pixelsize
int _pixelsize
Definition PtexReader.h:665
PtexReader::_pendingPurge
bool _pendingPurge
Definition PtexReader.h:652
PtexReader::pendingPurge
bool pendingPurge() const
Definition PtexReader.h:63
PtexReader::readlock
Mutex readlock
Definition PtexReader.h:645
PtexReader::setError
void setError(const char *error, bool ioError=false)
Definition PtexReader.h:549
PtexReader::readFace
void readFace(int levelid, Level *level, int faceid, Res res)
Definition PtexReader.cpp:559
PtexReader::_levelinfopos
FilePos _levelinfopos
Definition PtexReader.h:660
PtexReader::_lmdheaderpos
FilePos _lmdheaderpos
Definition PtexReader.h:663
PtexReader::hasEdits
virtual bool hasEdits()
Obsolete (returns false).
Definition PtexReader.h:99
PtexReader::nchannels
int nchannels() const
Definition PtexReader.h:117
PtexReader::_lmddatapos
FilePos _lmddatapos
Definition PtexReader.h:664
PtexReader::prune
void prune()
Definition PtexReader.cpp:106
PtexReader::_rfaceids
std::vector< uint32_t > _rfaceids
Definition PtexReader.h:670
PtexReader::_memUsed
volatile size_t _memUsed
Definition PtexReader.h:708
PtexReader::_defaultIo
DefaultInputHandler _defaultIo
Definition PtexReader.h:646
PtexReader::_blockReads
volatile size_t _blockReads
Definition PtexReader.h:710
PtexReader::_header
Header _header
Definition PtexReader.h:656
PtexReader::readFaceData
void readFaceData(FilePos pos, FaceDataHeader fdh, Res res, int levelid, FaceData *&face)
Definition PtexReader.cpp:573
PtexReader::_decompressor
libdeflate_decompressor * _decompressor
Definition PtexReader.h:706
PtexReader::seek
void seek(FilePos pos)
Definition PtexReader.h:570
PtexReader::_metadata
MetaData * _metadata
Definition PtexReader.h:667
PtexReader::_levels
std::vector< Level * > _levels
Definition PtexReader.h:673
PtexReader::_baseMemUsed
size_t _baseMemUsed
Definition PtexReader.h:707
PtexReader::_faceinfo
std::vector< FaceInfo > _faceinfo
Definition PtexReader.h:669
PtexReader::invalidate
void invalidate()
Definition PtexReader.h:67
PtexReader::meshType
virtual Ptex::MeshType meshType()
Type of mesh for which texture data is defined.
Definition PtexReader.h:91
PtexReader::edgeFilterMode
virtual Ptex::EdgeFilterMode edgeFilterMode()
Mode for filtering textures across edges.
Definition PtexReader.h:95
PtexReader::pixelsize
int pixelsize() const
Definition PtexReader.h:118
PtexReader::_fp
PtexInputHandler::Handle _fp
Definition PtexReader.h:653
PtexReader::readZipBlock
bool readZipBlock(void *data, int zipsize, int unzipsize)
Definition PtexReader.cpp:480
PtexReader::getCompressedData
void getCompressedData(int faceid, int level, FaceDataHeader &fdh, std::vector< std::byte > &data)
Definition PtexReader.cpp:892
PtexReader::readMetaData
void readMetaData()
Definition PtexReader.cpp:383
PtexReader::logBlockRead
void logBlockRead()
Definition PtexReader.h:74
PtexReader::logOpen
void logOpen()
Definition PtexReader.h:73
PtexReader::readLevel
void readLevel(int levelid, Level *&level)
Definition PtexReader.cpp:499
PtexReader::dataType
virtual Ptex::DataType dataType()
Type of data stored in file.
Definition PtexReader.h:92
PtexReader::_errorPixel
std::vector< char > _errorPixel
Definition PtexReader.h:704
PtexReader::numChannels
virtual int numChannels()
Number of channels stored in file.
Definition PtexReader.h:97
PtexReader::_pos
FilePos _pos
Definition PtexReader.h:654
PtexReader::open
bool open(const char *path, Ptex::String &error)
Definition PtexReader.cpp:137
PtexReader::levelinfo
const LevelInfo & levelinfo(int level) const
Definition PtexReader.h:121
PtexReader::tryClose
bool tryClose()
Definition PtexReader.cpp:222
PtexReader::_ok
bool _ok
Definition PtexReader.h:650
PtexTexture
Interface for reading data from a ptex file.
Definition Ptexture.h:460
Ptex::String
Memory-managed string.
Definition Ptexture.h:299
PTEX_NAMESPACE_BEGIN
Definition PtexSeparableKernel.cpp:42
PtexUtils::ReduceFn
void ReduceFn(const void *src, int sstride, int ures, int vres, void *dst, int dstride, DataType dt, int nchannels)
Definition PtexUtils.h:167
Ptex::DataType
DataType
Type of data stored in texture file.
Definition Ptexture.h:72
Ptex::MeshType
MeshType
Type of base mesh for which the textures are defined.
Definition Ptexture.h:66
Ptex::BorderMode
BorderMode
How to handle mesh border when filtering.
Definition Ptexture.h:86
Ptex::EdgeFilterMode
EdgeFilterMode
How to handle transformation across edges when filtering.
Definition Ptexture.h:80
ExtHeader
Definition PtexIO.h:64
FaceDataHeader
Definition PtexIO.h:82
FaceDataHeader::blocksize
uint32_t blocksize() const
Definition PtexIO.h:85
Header
Definition PtexIO.h:44
LevelInfo
Definition PtexIO.h:75
PtexReader::MetaData::Entry
Definition PtexReader.h:287
PtexReader::MetaData::Entry::key
const char * key
Definition PtexReader.h:288
PtexReader::MetaData::Entry::type
MetaDataType type
Definition PtexReader.h:289
PtexReader::MetaData::Entry::lmdPos
FilePos lmdPos
Definition PtexReader.h:294
PtexReader::MetaData::Entry::clear
void clear()
Definition PtexReader.h:302
PtexReader::MetaData::Entry::~Entry
~Entry()
Definition PtexReader.h:301
PtexReader::MetaData::Entry::lmdZipSize
uint32_t lmdZipSize
Definition PtexReader.h:295
PtexReader::MetaData::Entry::isLmd
bool isLmd
Definition PtexReader.h:292
PtexReader::MetaData::Entry::Entry
Entry()
Definition PtexReader.h:298
PtexReader::MetaData::Entry::datasize
uint32_t datasize
Definition PtexReader.h:290
PtexReader::MetaData::Entry::lmdData
LargeMetaData * lmdData
Definition PtexReader.h:293
PtexReader::MetaData::Entry::index
uint32_t index
Definition PtexReader.h:296
PtexReader::MetaData::Entry::data
char * data
Definition PtexReader.h:291
PtexTexture::Info
Get most commonly used info in a single call for convenience / efficiency.
Definition Ptexture.h:489
PtexTexture::Info::numChannels
int numChannels
Definition Ptexture.h:496
PtexTexture::Info::uBorderMode
BorderMode uBorderMode
Definition Ptexture.h:492
PtexTexture::Info::vBorderMode
BorderMode vBorderMode
Definition Ptexture.h:493
PtexTexture::Info::edgeFilterMode
EdgeFilterMode edgeFilterMode
Definition Ptexture.h:494
PtexTexture::Info::alphaChannel
int alphaChannel
Definition Ptexture.h:495
PtexTexture::Info::dataType
DataType dataType
Definition Ptexture.h:491
PtexTexture::Info::numFaces
int numFaces
Definition Ptexture.h:497
PtexTexture::Info::meshType
MeshType meshType
Definition Ptexture.h:490
Ptex::FaceInfo
Information about a face, as stored in the Ptex file header.
Definition Ptexture.h:232
Ptex::Res
Pixel resolution of a given texture.
Definition Ptexture.h:159