PVR: Difference between revisions
mNo edit summary |
m (→File format) |
||
Line 13: | Line 13: | ||
== File format == | == File format == | ||
The PVR (.pvr) format (Sony uses a custom header) consists of: | |||
The PVR (.pvr) format (PowerVR SDK REL_3.5) (Sony uses a custom header) consists of: | |||
{| class="wikitable" style="text-align: center;" | |||
|- | |||
| style="background-color:#505652; color:#FFFFFF;" |'''Header'''<br />52 bytes | |||
| style="background-color:#505652; color:#FFFFFF;" |'''Meta Data (optional)'''<br />variable | |||
| style="background-color:#505652; color:#FFFFFF;" |'''Texture Data'''<br />variable | |||
|- | |||
|} | |||
=== Header === | === Header === | ||
Line 41: | Line 50: | ||
| 0x14 || 0x04 || 00 00 00 00 || 0 || '''Channel Type:''' | | 0x14 || 0x04 || 00 00 00 00 || 0 || '''Channel Type:''' | ||
|- | |- | ||
| 0x18 || 0x08 || 00 01 00 00 || 256 || '''Height:''' | | 0x18 || 0x08 || 00 01 00 00 || 256 || '''Height:''' width of the texture stored in the texture data, in pixels. | ||
|- | |- | ||
| 0x1C || 0x04 || 00 01 00 00 || 256 || '''Width:''' | | 0x1C || 0x04 || 00 01 00 00 || 256 || '''Width:''' width of the texture stored in the texture data, in pixels. | ||
|- | |- | ||
| 0x20 || 0x04 || 01 00 00 00 || 1 || '''Depth:''' | | 0x20 || 0x04 || 01 00 00 00 || 1 || '''Depth:'''depth of the texture stored in the texture data, in pixels. | ||
|- | |- | ||
| 0x24 || 0x04 || 01 00 00 00 || 1 || '''Num. Surfaces:''' | | 0x24 || 0x04 || 01 00 00 00 || 1 || '''Num. Surfaces:'''number of surfaces within the texture array. | ||
|- | |- | ||
| 0x28 || 0x04 || 01 00 00 00 || 1 || '''Num. Faces:''' | | 0x28 || 0x04 || 01 00 00 00 || 1 || '''Num. Faces:'''number of faces in a cube map. | ||
|- | |- | ||
| 0x2C || 0x04 || 00 00 00 00 || 0 || '''Meta Data Size:''' | | 0x2C || 0x04 || 00 00 00 00 || 0 || '''Meta Data Size:''' allows for the creator of a PVR to store custom information within the PVR file relating to the storage. | ||
|- | |- | ||
|} | |} | ||
Line 218: | Line 227: | ||
|} | |} | ||
=== Meta Data Format === | |||
{| class="wikitable" style="text-align: center;" | |||
|- | |||
| style="background-color:#505652; color:#FFFFFF;" |'''FourCC'''<br />4 bytes | |||
| style="background-color:#505652; color:#FFFFFF;" |'''Key'''<br />4 bytes | |||
| style="background-color:#505652; color:#FFFFFF;" |'''Data Size'''<br />4 bytes | |||
| style="background-color:#505652; color:#FFFFFF;" |'''Data'''<br />variable | |||
| style="background-color:#505652; color:#FFFFFF;" |'''Padding'''<br />variable | |||
|- | |||
|} | |||
==== FourCC ==== | |||
is a four byte identifier (consisting of single byte characters or integers) whose value, combined with the value of ‘Key’, is used to determine how ‘Data’ should be handled.<br /> | |||
The values {‘P’, ‘V’, ‘R’, 0} to {‘P’, ‘V’, ‘R’, 255} (and their numerical equivalents) are reserved and must not be used except as described in Pre-defined Medata Data section.<br /> | |||
==== Pre-defined Medata Data ==== | |||
{| class="wikitable" style="text-align: center;" | |||
|- | |||
| style="background-color:#505652; color:#FFFFFF;" |'''FourCC''' | |||
| style="background-color:#505652; color:#FFFFFF;" |'''Key''' | |||
| style="background-color:#505652; color:#FFFFFF;" |'''Data Size''' | |||
| style="background-color:#505652; color:#FFFFFF;" |'''Data Description''' | |||
|- | |||
|colspan="5" style="text-align:center; background-color:lightblue;" | <span style="color:black;">Pre-defined metadata</span> | |||
|- | |||
| ‘P’, ‘V’, ‘R’, 3 || 0 || Variable || An array of integers describing the position and sizes of each texture within a texture atlas.<br /> <small>Each sequence of four integers represents the information for a single texture within the atlas and appear in the order:</small> | |||
1. X Position | |||
2. Y Position | |||
3. Width | |||
4. Height | |||
|- | |||
| ‘P’, ‘V’, ‘R’, 3 || 1 || 8 || Specifies that the file contains normal map information.<br /> | |||
<small> | |||
The 8 bytes are in the form of a 32bit float representing the scale of the normal map, followed by a four character array describing the order of the channels,<br /> for example {‘x’, ‘y’, ‘z’, ‘h’}. Use of ‘h’ as the representation for a given channel denotes that the channel in question contains the original height map. | |||
<small> | |||
|- | |||
| ‘P’, ‘V’, ‘R’, 3 || 2 || 6 || Specifies that the file contains a cube map and the order of the faces within that cube map.<br /> | |||
<small> | |||
The 6 bytes represent a six character string. This string shows the order the cube map faces are stored in the texture data, for example ‘XxYyZz’.<br /> | |||
Uppercase letters refer to a positive axis position while lowercase refer to a negative axis position. Not all axes must be present. | |||
<small> | |||
|- | |||
| ‘P’, ‘V’, ‘R’, 3 || 3 || 3 || Specifies the logical orientation of the texture within the texture data.<br /> | |||
<small> | |||
This does not affect the mapping from pixels to texture coordinates. Each byte is a Boolean value representing the orientation for a single axis in the order X, Y, Z.<br /> | |||
The values are as follows: | |||
<small> | |||
*X Axis Non-zero value = values increase to the left , Zero value = X values increase to the right | |||
*Y Axis Non-zero value = Y values increase upwards , Zero value = Y values increase downwards | |||
*Z Axis Non-zero value = Z values increase outwards , Zero value = Z values increase inwards | |||
|- | |||
| ‘P’, ‘V’, ‘R’, 3 || 4 || 12 || Specifies whether the texture has a border.<br /> | |||
<small> | |||
The 12 bytes are broken down into three unsigned 32bit integers. The three integers represent the size of the border of the image, in pixels, on the X, Y and Z axes, respectively.<br /> These values are used to offset texture reads by the size of the border in order to obtain the actual texture data. | |||
<br />It should be noted that only three border sizes are given, this means that the border size for X is applied to both the left and right of the image, Y to the top and bottom and Z to the front and back. | |||
</small> | |||
|- | |||
| ‘P’, ‘V’, ‘R’, 3 || 5 || variable || Specifies that this block contains padding data.<br /> | |||
<small> | |||
The size of data varies in order to align the texture data with a convenient block boundary.<br /> | |||
The contents of data are left undefined. This block should be skipped during parsing.<br /> | |||
</small> | |||
|- | |||
|} | |||
==== Key ==== | |||
is an unsigned 32bit integer, which, when coupled with ‘FourCC’ determines how ‘Data’ should be handled. | |||
==== Data Size ==== | |||
is an unsigned 32bit integer representing the size of ‘Data’ in bytes. | |||
==== Data Size ==== | |||
is an array of user defined information of size determined from ‘Data Size’ of a data type and purpose determined from the value of ‘FourCC’ and ‘Key’. | |||
=== Texture | === Texture Data === | ||
*http://web.onetel.net.uk/~simonnihal/assorted3d/fenney03texcomp.pdf PVRTC algorithm: Texture Compression using Low-Frequency Signal Modulation | *http://web.onetel.net.uk/~simonnihal/assorted3d/fenney03texcomp.pdf PVRTC algorithm: Texture Compression using Low-Frequency Signal Modulation | ||
*http://blog.imgtec.com/powervr/understanding-powervr-series5xt-pvrtc-pvrtc2-and-texture-compression-part-6 overview | *http://blog.imgtec.com/powervr/understanding-powervr-series5xt-pvrtc-pvrtc2-and-texture-compression-part-6 overview |
Revision as of 11:14, 28 July 2015
PowerVR Texture Compression files: PVRTC and PVRTC2 are a family of lossy, fixed-rate texture compression formats.
PowerVR is a division of Imagination Technologies (formerly VideoLogic) that develops hardware and software for 2D and 3D rendering, and more.
Features
- PVRTC supports both opaque (RGB) and translucent (RGBA) textures (unlike other formats such as S3TC that require a dedicated, larger form to support full alpha channels).
- competitive compression ratios.
File format
The PVR (.pvr) format (PowerVR SDK REL_3.5) (Sony uses a custom header) consists of:
Header 52 bytes |
Meta Data (optional) variable |
Texture Data variable |
Header
Offset (h) | Size (h) | Example (h) | Value (conversion) | Notes |
PVR header | ||||
0x00 | 0x04 | 50 56 52 03 | "PVR " | Version: Contains the version of the PVR header format. |
0x04 | 0x04 | 00 00 00 00 | Flags:
| |
0x08 | 0x08 | 72 67 62 61 08 08 08 08 | "rgba" | Pixel Format: rgba + bit rate per channel |
0x10 | 0x04 | 00 00 00 00 | Colour Space:
| |
0x14 | 0x04 | 00 00 00 00 | 0 | Channel Type: |
0x18 | 0x08 | 00 01 00 00 | 256 | Height: width of the texture stored in the texture data, in pixels. |
0x1C | 0x04 | 00 01 00 00 | 256 | Width: width of the texture stored in the texture data, in pixels. |
0x20 | 0x04 | 01 00 00 00 | 1 | Depth:depth of the texture stored in the texture data, in pixels. |
0x24 | 0x04 | 01 00 00 00 | 1 | Num. Surfaces:number of surfaces within the texture array. |
0x28 | 0x04 | 01 00 00 00 | 1 | Num. Faces:number of faces in a cube map. |
0x2C | 0x04 | 00 00 00 00 | 0 | Meta Data Size: allows for the creator of a PVR to store custom information within the PVR file relating to the storage. |
Pixel Format
If the most significant 4 bytes contain a value, the full 8 bytes are used to determine the pixel format.
The least significant 4 bytes contain the channel order, each byte containing a single character, or a null character if there are fewer than four channels, e.g., {‘r’, ‘g’, ‘b’, ‘a’} or {‘r’, ‘g’, ‘b’, ‘\0’}.
The most significant 4 bytes state the bit rate for each channel in the same order, each byte containing a single 8bit unsigned integer value, or zero if there are fewer than four channels, e.g., {8, 8, 8, 8} or {5, 6, 5, 0}.
Where the most significant 4 bytes have been set to ‘0’ and the least significant 4 bytes will contain a 32bit unsigned integer value identifying the pixel format
Formats | Value | |||
Identifier | ||||
PVRTC 2bpp RGB | 0 | |||
PVRTC 2bpp RGBA | 1 | |||
PVRTC 4bpp RGB | 2 | |||
PVRTC 4bpp RGBA | 3 | |||
PVRTC-II 2bpp | 4 | |||
PVRTC-II 4bpp | 5 | |||
ETC1 | 6 | |||
DXT1 | 7 | |||
DXT2 | 8 | |||
DXT3 | 9 | |||
DXT4 | 10 | |||
DXT5 | 11 | |||
BC1 | 7 | |||
BC2 | 9 | |||
BC3 | 11 | |||
BC4 | 12 | |||
BC5 | 13 | |||
BC6 | 14 | |||
BC7 | 15 | |||
UYVY | 16 | |||
YUY2 | 17 | |||
BW1bpp | 18 | |||
R9G9B9E5 Shared Exponent | 19 | |||
RGBG8888 | 20 | |||
GRGB8888 | 21 | |||
ETC2 RGB | 22 | |||
ETC2 RGBA | 23 | |||
ETC2 RGB A1 | 24 | |||
EAC R11 | 25 | |||
EAC RG11 | 26 | |||
ASTC_4x4 | 27 | |||
ASTC_5x4 | 28 | |||
ASTC_5x5 | 29 | |||
ASTC_6x5 | 30 | |||
ASTC_6x6 | 31 | |||
ASTC_8x5 | 32 | |||
ASTC_8x6 | 33 | |||
ASTC_8x8 | 34 | |||
ASTC_10x5 | 35 | |||
ASTC_10x6 | 36 | |||
ASTC_10x8 | 37 | |||
ASTC_10x10 | 38 | |||
ASTC_12x10 | 39 | |||
ASTC_12x12 | 40 | |||
ASTC_3x3x3 | 41 | |||
ASTC_4x3x3 | 42 | |||
ASTC_4x4x3 | 43 | |||
ASTC_4x4x4 | 44 | |||
ASTC_5x4x4 | 45 | |||
ASTC_5x5x4 | 46 | |||
ASTC_5x5x5 | 47 | |||
ASTC_6x5x5 | 48 | |||
ASTC_6x6x5 | 49 | |||
ASTC_6x6x6 | 50 |
Channel Type
the data type of the colour channels within the texture data.
Data Type | Value |
Unsigned Byte Normalised | 0 |
Signed Byte Normalised | 1 |
Unsigned Byte | 2 |
Signed Byte | 3 |
Unsigned Short Normalised | 4 |
Signed Short Normalised | 5 |
Unsigned Short | 6 |
Signed Short | 7 |
Unsigned Integer Normalised | 8 |
Signed Integer Normalised | 9 |
Unsigned Integer | 10 |
Signed Integer | 11 |
Float | 12 |
Meta Data Format
FourCC 4 bytes |
Key 4 bytes |
Data Size 4 bytes |
Data variable |
Padding variable |
FourCC
is a four byte identifier (consisting of single byte characters or integers) whose value, combined with the value of ‘Key’, is used to determine how ‘Data’ should be handled.
The values {‘P’, ‘V’, ‘R’, 0} to {‘P’, ‘V’, ‘R’, 255} (and their numerical equivalents) are reserved and must not be used except as described in Pre-defined Medata Data section.
Pre-defined Medata Data
FourCC | Key | Data Size | Data Description | |
Pre-defined metadata | ||||
‘P’, ‘V’, ‘R’, 3 | 0 | Variable | An array of integers describing the position and sizes of each texture within a texture atlas. Each sequence of four integers represents the information for a single texture within the atlas and appear in the order: 1. X Position 2. Y Position 3. Width 4. Height | |
‘P’, ‘V’, ‘R’, 3 | 1 | 8 | Specifies that the file contains normal map information.
The 8 bytes are in the form of a 32bit float representing the scale of the normal map, followed by a four character array describing the order of the channels, | |
‘P’, ‘V’, ‘R’, 3 | 2 | 6 | Specifies that the file contains a cube map and the order of the faces within that cube map.
The 6 bytes represent a six character string. This string shows the order the cube map faces are stored in the texture data, for example ‘XxYyZz’. | |
‘P’, ‘V’, ‘R’, 3 | 3 | 3 | Specifies the logical orientation of the texture within the texture data.
This does not affect the mapping from pixels to texture coordinates. Each byte is a Boolean value representing the orientation for a single axis in the order X, Y, Z.
| |
‘P’, ‘V’, ‘R’, 3 | 4 | 12 | Specifies whether the texture has a border.
The 12 bytes are broken down into three unsigned 32bit integers. The three integers represent the size of the border of the image, in pixels, on the X, Y and Z axes, respectively. | |
‘P’, ‘V’, ‘R’, 3 | 5 | variable | Specifies that this block contains padding data.
The size of data varies in order to align the texture data with a convenient block boundary. |
Key
is an unsigned 32bit integer, which, when coupled with ‘FourCC’ determines how ‘Data’ should be handled.
Data Size
is an unsigned 32bit integer representing the size of ‘Data’ in bytes.
Data Size
is an array of user defined information of size determined from ‘Data Size’ of a data type and purpose determined from the value of ‘FourCC’ and ‘Key’.
Texture Data
- http://web.onetel.net.uk/~simonnihal/assorted3d/fenney03texcomp.pdf PVRTC algorithm: Texture Compression using Low-Frequency Signal Modulation
- http://blog.imgtec.com/powervr/understanding-powervr-series5xt-pvrtc-pvrtc2-and-texture-compression-part-6 overview