Jump to content

PVR Format


Recommended Posts

In older threads, (here, here) it was mentioned that pvr is not yet documented for IESDP. Since Avenger pointed out a document that, when downloaded, required no NDA to be agreed to, I think I'll post the info here, but in a new thread in case someone wants to close this thread if necessary.


It's worth mentioning that this information is readily available (I think) if you register on imgtec's website and download their SDK.


Power VR header:

In a PVR file, the header is 52 bytes long, or 0x34h long.


Offset    Size       Name           Description
0x0000    4 [DWORD]  Version        Either 0x03525650 is source and destination systems match endianness
                                   or 0x50565203 if they do match

0x0004    4 [DWORD]  Flags          0x0000 if no flags set
                                   0x0002 if colors within the texture

0x0008    8 [union]  Pixel Format   This field is somewhat awkward.
                                   It can either be one of several predetermined enumerated values (a DWORD)
                                   OR a 4-character array and a 4-byte array(8 bytes).
                                   If the most significant 4 bytes of the 64-bit (8-byte) value are all 0,
                                   then it indicates that it is the enumeration; otherwise it is the character array.

                                   Enumerated values are as follows:
                                   Value  Pixel Type
                                   0      PVRTC 2bpp RGB
                                   1      PVRTC 2bpp RGBA
                                   2      PVRTC 4bpp RGB
                                   3      PVRTC 4bpp RGBA
                                   4      PVRTC-II 2bpp
                                   5      PVRTC-II 4bpp
                                   6      ETC1
                                   7      DXT1 / BC1
                                   8      DXT2
                                   9      DXT3 / BC2
                                   10     DXT4
                                   11     DXT5 / BC3
                                   12     BC4
                                   13     BC5
                                   14     BC6
                                   15     BC7
                                   16     UYVY
                                   17     YUY2
                                   18     BW1bpp
                                   19     R9G9B9E5 Shared Exponent
                                   20     RGBG8888
                                   21     GRGB8888
                                   22     ETC2 RGB
                                   23     ETC2 RGBA
                                   24     ETC2 RGB A1
                                   25     EAC R11 Unsigned
                                   26     EAC R11 Signed
                                   27     EAC RG11 Unsigned
                                   28     EAC RG11 Signed

                                   Note that of the above, BG:EE and BG2:EE only appear to use DXT1 and DXT5.

                                   OTHERWISE, the 8-byte character array indicates the pixel format as follows:
                                   The least significant 4 bytes indicate channel order, such as in this example:
                                   { 'b', 'g', 'r', 'a' } or { 'b', 'g', 'r', '\0' }
                                   The most significant 4 bytes then indicate the width of each channel in bits, as follows:
                                   { 4, 4, 4, 4 } or { 2, 2, 2, 2 }, or {5, 5, 5, 0 }
                                   (the most likely values being 8s for full bytes)

                                   Quoth Avenger: "pvr files could have a hell of a number of pixel formats"

0x0010  4 [DWORD]    Color Space    This is an enumerated field, currently two values:

                                   Value   Color Space
                                   0       Linear RGB
                                   1       Standard RGB

0x0014  4 [DWORD]    Channel Type   This is another enumerated field:

                                   Value   Data Type
                                   0       Unsigned Byte Normalized
                                   1       Signed Byte Normalized
                                   2       Unsigned Byte
                                   3       Signed Byte
                                   4       Unsigned Short Normalized
                                   5       Signed Short Normalized
                                   6       Unsigned Short
                                   7       Signed Short
                                   8       Unsigned Integer Normalized
                                   9       Signed Integer Normalized
                                   10      Unsigned Integer
                                   11      Signed Integer
                                   12      Float (no size specified)

                                   To be honest, I'm not sure what kind of normalization these values might indicate.
                                   I have observed normalized indicators, but data seemed identical to non-normalized data.

0x0018  4 [DWORD]    Height         Height of the image

0x001C  4 [DWORD]    Width          Width of the image

0x0020  4 [DWORD]    Depth          Depth of the image, in pixels

                                   Since this format targets 3D as well as 2D,
                                   I admit my ignorance of how this would be used.

0x0024  4 [DWORD]    Surface Count  The number of surfaces to this texture, used for texture arrays

0x0028  4 [DWORD]    Face Count     The number of faces to this texture, used for cube maps

0x002C  4 [DWORD]    MIP-Map Count  The number of MIP-Map levels, including a top level (again, I'm ignorant of what this means)

0x0030  4 [DWORD]    Metadata Size  The size, in bytes, of meta data that immediately follows this header



Power VR meta data blocks:

Offset  Size         Name           Description
0x0000  4 [DWORD]    FourCC         Four-character identifier of the type of meta data.

                                   The following 255 arrays are reserved of PowerVR use:
                                   { 'P', 'V', 'R', 0x00 }
                                   { 'P', 'V', 'R', 0x01 }
                                   { 'P', 'V', 'R', 0x02 }
                                   { 'P', 'V', 'R', 0xFF }

0x0004  4 [DWORD]    Key            A secondary identifier indicating how the data should be interpreted

0x0008  4 [DWORD]    Size           The length of the meta data's data

0x000C  4 [DWORD]    Data           The binary data of the meta data


These immediately follow the header. The meta data is read in a loop until you hit the meta data size specified in the header.

I don't believe that meta data is extensively used for BGs:EE.


Power VR data:

This is the raw data for the pixels, interpreted dependent on the pixel type, color space, and other options indicated in the header.


Pseudo-code for interpreting data is as follows:

for (int mip = 0; mip < header.MIP-Map Count; ++mip)
   for (int surface = 0; surface < header.Surface Count; ++surface)
       for (int face = 0; face < header.Face Count; ++face)
           for (int slice = 0; slice < header.Depth; ++slice)
               for (int row = 0; row < header.Height; ++row)
                   for (int pixel = 0; pixel < header.Width; ++pixel)
                       //read X bytes, dependent on the header's Pixel Format

Link to comment


This topic is now archived and is closed to further replies.

  • Create New...