Ptex
ptex
PtexIO.h
Go to the documentation of this file.
1
#ifndef PtexIO_h
2
#define PtexIO_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
39
#include "
Ptexture.h
"
40
41
PTEX_NAMESPACE_BEGIN
42
43
#pragma pack(push, 1)
44
struct
Header
{
45
uint32_t
magic
;
46
uint32_t
version
;
47
uint32_t
meshtype
;
48
uint32_t
datatype
;
49
int32_t
alphachan
;
50
uint16_t
nchannels
;
51
uint16_t
nlevels
;
52
uint32_t
nfaces
;
53
uint32_t
extheadersize
;
54
uint32_t
faceinfosize
;
55
uint32_t
constdatasize
;
56
uint32_t
levelinfosize
;
57
uint32_t
minorversion
;
58
uint64_t
leveldatasize
;
59
uint32_t
metadatazipsize
;
60
uint32_t
metadatamemsize
;
61
int
pixelSize
()
const
{
return
DataSize
(
DataType
(
datatype
)) *
nchannels
; }
62
bool
hasAlpha
()
const
{
return
alphachan
>= 0 &&
alphachan
<
nchannels
; }
63
};
64
struct
ExtHeader
{
65
uint16_t
ubordermode
;
66
uint16_t
pad
;
67
uint16_t
vbordermode
;
68
uint16_t
edgefiltermode
;
69
uint32_t
lmdheaderzipsize
;
70
uint32_t
lmdheadermemsize
;
71
uint64_t
lmddatasize
;
72
uint64_t
editdatasize
;
73
uint64_t
editdatapos
;
74
};
75
struct
LevelInfo
{
76
uint64_t
leveldatasize
;
77
uint32_t
levelheadersize
;
78
uint32_t
nfaces
;
79
LevelInfo
() :
leveldatasize
(0),
levelheadersize
(0),
nfaces
(0) {}
80
};
81
enum
Encoding
{
enc_constant
,
enc_zipped
,
enc_diffzipped
,
enc_tiled
};
82
struct
FaceDataHeader
{
83
uint32_t
data
;
// bits 0..29 = blocksize, bits 30..31 = encoding
84
uint32_t
blocksize
()
const
{
return
data
& 0x3fffffff; }
85
Encoding
encoding
()
const
{
return
Encoding
((
data
>> 30) & 0x3); }
86
uint32_t&
val
() {
return
*(uint32_t*)
this
; }
87
const
uint32_t&
val
()
const
{
return
*(
const
uint32_t*)
this
; }
88
void
set
(uint32_t blocksizeArg,
Encoding
encodingArg)
89
{
data
= (blocksizeArg & 0x3fffffff) | ((encodingArg & 0x3) << 30); }
90
FaceDataHeader
() :
data
(0) {}
91
};
92
enum
EditType
{
et_editfacedata
,
et_editmetadata
};
93
struct
EditFaceDataHeader
{
94
uint32_t
faceid
;
95
FaceInfo
faceinfo
;
96
FaceDataHeader
fdh
;
97
};
98
struct
EditMetaDataHeader
{
99
uint32_t
metadatazipsize
;
100
uint32_t
metadatamemsize
;
101
};
102
#pragma pack(pop)
103
104
const
uint32_t
Magic
=
'P'
| (
't'
<<8) | (
'e'
<<16) | (
'x'
<<24);
105
const
int
HeaderSize
=
sizeof
(
Header
);
106
const
int
ExtHeaderSize
=
sizeof
(
ExtHeader
);
107
const
int
LevelInfoSize
=
sizeof
(
LevelInfo
);
108
const
int
FaceDataHeaderSize
=
sizeof
(
FaceDataHeader
);
109
const
int
EditFaceDataHeaderSize
=
sizeof
(
EditFaceDataHeader
);
110
const
int
EditMetaDataHeaderSize
=
sizeof
(
EditMetaDataHeader
);
111
112
// these constants can be tuned for performance
113
const
int
IBuffSize
= 8192;
// default input buffer size
114
const
int
BlockSize
= 16384;
// target block size for file I/O
115
const
int
TileSize
= 65536;
// target tile size (uncompressed)
116
const
int
AllocaMax
= 16384;
// max size for using alloca
117
const
int
MetaDataThreshold
= 1024;
// cutoff for large meta data
118
119
inline
bool
LittleEndian
() {
120
short
word = 0x0201;
121
return
*(
char
*)&word == 1;
122
}
123
124
PTEX_NAMESPACE_END
125
126
#endif
et_editmetadata
@ et_editmetadata
Definition:
PtexIO.h:92
Header::leveldatasize
uint64_t leveldatasize
Definition:
PtexIO.h:58
LevelInfo::nfaces
uint32_t nfaces
Definition:
PtexIO.h:78
EditFaceDataHeader::faceinfo
FaceInfo faceinfo
Definition:
PtexIO.h:95
Header
Definition:
PtexIO.h:44
Header::pixelSize
int pixelSize() const
Definition:
PtexIO.h:61
FaceDataHeader::encoding
Encoding encoding() const
Definition:
PtexIO.h:85
ExtHeader::editdatapos
uint64_t editdatapos
Definition:
PtexIO.h:73
Header::magic
uint32_t magic
Definition:
PtexIO.h:45
PTEX_NAMESPACE_END
#define PTEX_NAMESPACE_END
Definition:
PtexVersion.h:62
LevelInfo::levelheadersize
uint32_t levelheadersize
Definition:
PtexIO.h:77
EditFaceDataHeader
Definition:
PtexIO.h:93
FaceDataHeader::set
void set(uint32_t blocksizeArg, Encoding encodingArg)
Definition:
PtexIO.h:88
EditFaceDataHeaderSize
const int EditFaceDataHeaderSize
Definition:
PtexIO.h:109
EditType
EditType
Definition:
PtexIO.h:92
ExtHeader::ubordermode
uint16_t ubordermode
Definition:
PtexIO.h:65
ExtHeader::edgefiltermode
uint16_t edgefiltermode
Definition:
PtexIO.h:68
FaceDataHeader::data
uint32_t data
Definition:
PtexIO.h:83
Header::nlevels
uint16_t nlevels
Definition:
PtexIO.h:51
Ptex::DataSize
int DataSize(DataType dt)
Look up size of given data type (in bytes).
Definition:
Ptexture.h:143
Header::minorversion
uint32_t minorversion
Definition:
PtexIO.h:57
ExtHeader::vbordermode
uint16_t vbordermode
Definition:
PtexIO.h:67
LittleEndian
bool LittleEndian()
Definition:
PtexIO.h:119
Header::constdatasize
uint32_t constdatasize
Definition:
PtexIO.h:55
FaceDataHeader::val
const uint32_t & val() const
Definition:
PtexIO.h:87
Header::metadatazipsize
uint32_t metadatazipsize
Definition:
PtexIO.h:59
EditMetaDataHeader::metadatamemsize
uint32_t metadatamemsize
Definition:
PtexIO.h:100
EditMetaDataHeader
Definition:
PtexIO.h:98
Ptex::DataType
DataType
Type of data stored in texture file.
Definition:
Ptexture.h:85
IBuffSize
const int IBuffSize
Definition:
PtexIO.h:113
ExtHeader::editdatasize
uint64_t editdatasize
Definition:
PtexIO.h:72
AllocaMax
const int AllocaMax
Definition:
PtexIO.h:116
LevelInfoSize
const int LevelInfoSize
Definition:
PtexIO.h:107
EditFaceDataHeader::fdh
FaceDataHeader fdh
Definition:
PtexIO.h:96
Encoding
Encoding
Definition:
PtexIO.h:81
HeaderSize
const int HeaderSize
Definition:
PtexIO.h:105
FaceDataHeaderSize
const int FaceDataHeaderSize
Definition:
PtexIO.h:108
ExtHeaderSize
const int ExtHeaderSize
Definition:
PtexIO.h:106
enc_constant
@ enc_constant
Definition:
PtexIO.h:81
PTEX_NAMESPACE_BEGIN
Definition:
PtexSeparableKernel.cpp:42
LevelInfo::LevelInfo
LevelInfo()
Definition:
PtexIO.h:79
ExtHeader::pad
uint16_t pad
Definition:
PtexIO.h:66
Header::datatype
uint32_t datatype
Definition:
PtexIO.h:48
ExtHeader
Definition:
PtexIO.h:64
Header::nfaces
uint32_t nfaces
Definition:
PtexIO.h:52
enc_zipped
@ enc_zipped
Definition:
PtexIO.h:81
et_editfacedata
@ et_editfacedata
Definition:
PtexIO.h:92
FaceDataHeader
Definition:
PtexIO.h:82
BlockSize
const int BlockSize
Definition:
PtexIO.h:114
Header::faceinfosize
uint32_t faceinfosize
Definition:
PtexIO.h:54
EditMetaDataHeader::metadatazipsize
uint32_t metadatazipsize
Definition:
PtexIO.h:99
FaceDataHeader::blocksize
uint32_t blocksize() const
Definition:
PtexIO.h:84
TileSize
const int TileSize
Definition:
PtexIO.h:115
Header::hasAlpha
bool hasAlpha() const
Definition:
PtexIO.h:62
LevelInfo::leveldatasize
uint64_t leveldatasize
Definition:
PtexIO.h:76
MetaDataThreshold
const int MetaDataThreshold
Definition:
PtexIO.h:117
LevelInfo
Definition:
PtexIO.h:75
ExtHeader::lmddatasize
uint64_t lmddatasize
Definition:
PtexIO.h:71
Header::version
uint32_t version
Definition:
PtexIO.h:46
ExtHeader::lmdheaderzipsize
uint32_t lmdheaderzipsize
Definition:
PtexIO.h:69
enc_diffzipped
@ enc_diffzipped
Definition:
PtexIO.h:81
Header::extheadersize
uint32_t extheadersize
Definition:
PtexIO.h:53
Magic
const uint32_t Magic
Definition:
PtexIO.h:104
enc_tiled
@ enc_tiled
Definition:
PtexIO.h:81
EditFaceDataHeader::faceid
uint32_t faceid
Definition:
PtexIO.h:94
FaceDataHeader::val
uint32_t & val()
Definition:
PtexIO.h:86
Header::levelinfosize
uint32_t levelinfosize
Definition:
PtexIO.h:56
Header::alphachan
int32_t alphachan
Definition:
PtexIO.h:49
Header::nchannels
uint16_t nchannels
Definition:
PtexIO.h:50
Ptexture.h
Public API classes for reading, writing, caching, and filtering Ptex files.
FaceDataHeader::FaceDataHeader
FaceDataHeader()
Definition:
PtexIO.h:90
EditMetaDataHeaderSize
const int EditMetaDataHeaderSize
Definition:
PtexIO.h:110
Header::meshtype
uint32_t meshtype
Definition:
PtexIO.h:47
ExtHeader::lmdheadermemsize
uint32_t lmdheadermemsize
Definition:
PtexIO.h:70
Header::metadatamemsize
uint32_t metadatamemsize
Definition:
PtexIO.h:60
Generated by
1.8.18