Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/imbuf/intern/dds')
-rw-r--r--source/blender/imbuf/intern/dds/BlockDXT.cpp4
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp6
-rw-r--r--source/blender/imbuf/intern/dds/FlipDXT.cpp44
-rw-r--r--source/blender/imbuf/intern/dds/Stream.cpp16
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.cpp23
5 files changed, 47 insertions, 46 deletions
diff --git a/source/blender/imbuf/intern/dds/BlockDXT.cpp b/source/blender/imbuf/intern/dds/BlockDXT.cpp
index 4048a78e5cf..2d198135a66 100644
--- a/source/blender/imbuf/intern/dds/BlockDXT.cpp
+++ b/source/blender/imbuf/intern/dds/BlockDXT.cpp
@@ -34,6 +34,8 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE. */
+#include <BLI_sys_types.h> /* For `uint`. */
+
#include <BlockDXT.h>
#include <ColorBlock.h>
#include <Common.h>
@@ -576,7 +578,7 @@ void mem_read(Stream &mem, BlockDXT1 &block)
void mem_read(Stream &mem, AlphaBlockDXT3 &block)
{
- for (unsigned short &alpha : block.row) {
+ for (ushort &alpha : block.row) {
mem_read(mem, alpha);
}
}
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index ce5dd4927be..4e5dc9ce560 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -867,7 +867,7 @@ uint DDSHeader::d3d9Format() const
return findD3D9Format(pf.bitcount, pf.rmask, pf.gmask, pf.bmask, pf.amask);
}
-DirectDrawSurface::DirectDrawSurface(unsigned char *mem, uint size) : stream(mem, size), header()
+DirectDrawSurface::DirectDrawSurface(uchar *mem, uint size) : stream(mem, size), header()
{
mem_read(stream, header);
@@ -1112,7 +1112,7 @@ void *DirectDrawSurface::readData(uint &rsize)
uint size = stream.size - header_size;
rsize = size;
- unsigned char *data = (unsigned char *)malloc(sizeof(*data) * size);
+ uchar *data = (uchar *)malloc(sizeof(*data) * size);
stream.seek(header_size);
mem_read(stream, data, size);
@@ -1158,7 +1158,7 @@ void DirectDrawSurface::readLinearImage(Image *img)
for (uint y = 0; y < h; y++) {
for (uint x = 0; x < w; x++) {
uint c = 0;
- mem_read(stream, (unsigned char *)(&c), byteCount);
+ mem_read(stream, (uchar *)(&c), byteCount);
Color32 pixel(0, 0, 0, 0xFF);
pixel.r = PixelFormat::convert((c & header.pf.rmask) >> rshift, rsize, 8);
diff --git a/source/blender/imbuf/intern/dds/FlipDXT.cpp b/source/blender/imbuf/intern/dds/FlipDXT.cpp
index fc978bff788..3d2b7e51a46 100644
--- a/source/blender/imbuf/intern/dds/FlipDXT.cpp
+++ b/source/blender/imbuf/intern/dds/FlipDXT.cpp
@@ -104,19 +104,19 @@ static void FlipDXT5BlockFull(uint8_t *block)
* bits = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * (bits_3 +
* 256 * (bits_4 + 256 * bits_5))))
*
- * bits is a 48-bit unsigned integer, from which a three-bit control code
+ * bits is a 48-bit unsigned-integer, from which a three-bit control code
* is extracted for a texel at location (x,y) in the block using:
*
* code(x,y) = bits[3*(4*y+x)+1..3*(4*y+x)+0]
*
* where bit 47 is the most significant and bit 0 is the least
* significant bit. */
- unsigned int line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
- unsigned int line_2_3 = block[5] + 256 * (block[6] + 256 * block[7]);
+ uint line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
+ uint line_2_3 = block[5] + 256 * (block[6] + 256 * block[7]);
/* swap lines 0 and 1 in line_0_1. */
- unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
+ uint line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
/* swap lines 2 and 3 in line_2_3. */
- unsigned int line_3_2 = ((line_2_3 & 0x000fff) << 12) | ((line_2_3 & 0xfff000) >> 12);
+ uint line_3_2 = ((line_2_3 & 0x000fff) << 12) | ((line_2_3 & 0xfff000) >> 12);
block[2] = line_3_2 & 0xff;
block[3] = (line_3_2 & 0xff00) >> 8;
@@ -133,21 +133,21 @@ static void FlipDXT5BlockFull(uint8_t *block)
static void FlipDXT5BlockHalf(uint8_t *block)
{
/* See layout above. */
- unsigned int line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
- unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
+ uint line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
+ uint line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
block[2] = line_1_0 & 0xff;
block[3] = (line_1_0 & 0xff00) >> 8;
block[4] = (line_1_0 & 0xff0000) >> 16;
FlipDXT1BlockHalf(block + 8);
}
-int FlipDXTCImage(unsigned int width,
- unsigned int height,
- unsigned int levels,
+int FlipDXTCImage(uint width,
+ uint height,
+ uint levels,
int fourcc,
uint8_t *data,
int data_size,
- unsigned int *r_num_valid_levels)
+ uint *r_num_valid_levels)
{
*r_num_valid_levels = 0;
@@ -162,7 +162,7 @@ int FlipDXTCImage(unsigned int width,
FlipBlockFunction full_block_function;
FlipBlockFunction half_block_function;
- unsigned int block_bytes = 0;
+ uint block_bytes = 0;
switch (fourcc) {
case FOURCC_DXT1:
@@ -186,15 +186,15 @@ int FlipDXTCImage(unsigned int width,
*r_num_valid_levels = levels;
- unsigned int mip_width = width;
- unsigned int mip_height = height;
+ uint mip_width = width;
+ uint mip_height = height;
const uint8_t *data_end = data + data_size;
- for (unsigned int i = 0; i < levels; i++) {
- unsigned int blocks_per_row = (mip_width + 3) / 4;
- unsigned int blocks_per_col = (mip_height + 3) / 4;
- unsigned int blocks = blocks_per_row * blocks_per_col;
+ for (uint i = 0; i < levels; i++) {
+ uint blocks_per_row = (mip_width + 3) / 4;
+ uint blocks_per_col = (mip_height + 3) / 4;
+ uint blocks = blocks_per_row * blocks_per_col;
if (data + block_bytes * blocks > data_end) {
/* Stop flipping when running out of data to be modified, avoiding possible buffer overrun
@@ -209,23 +209,23 @@ int FlipDXTCImage(unsigned int width,
}
if (mip_height == 2) {
/* flip the first 2 lines in each block. */
- for (unsigned int i = 0; i < blocks_per_row; i++) {
+ for (uint i = 0; i < blocks_per_row; i++) {
half_block_function(data + i * block_bytes);
}
}
else {
/* flip each block. */
- for (unsigned int i = 0; i < blocks; i++) {
+ for (uint i = 0; i < blocks; i++) {
full_block_function(data + i * block_bytes);
}
/* Swap each block line in the first half of the image with the
* corresponding one in the second half.
* note that this is a no-op if mip_height is 4. */
- unsigned int row_bytes = block_bytes * blocks_per_row;
+ uint row_bytes = block_bytes * blocks_per_row;
uint8_t *temp_line = new uint8_t[row_bytes];
- for (unsigned int y = 0; y < blocks_per_col / 2; y++) {
+ for (uint y = 0; y < blocks_per_col / 2; y++) {
uint8_t *line1 = data + y * row_bytes;
uint8_t *line2 = data + (blocks_per_col - y - 1) * row_bytes;
diff --git a/source/blender/imbuf/intern/dds/Stream.cpp b/source/blender/imbuf/intern/dds/Stream.cpp
index 566891dac8b..44b7e6d8f42 100644
--- a/source/blender/imbuf/intern/dds/Stream.cpp
+++ b/source/blender/imbuf/intern/dds/Stream.cpp
@@ -4,6 +4,8 @@
* \ingroup imbdds
*/
+#include "BLI_sys_types.h" /* For `uint`. */
+
#include <Stream.h>
#include <cstdio> /* printf */
@@ -12,7 +14,7 @@
static const char *msg_error_seek = "DDS: trying to seek beyond end of stream (corrupt file?)";
static const char *msg_error_read = "DDS: trying to read beyond end of stream (corrupt file?)";
-inline bool is_read_within_bounds(const Stream &mem, unsigned int count)
+inline bool is_read_within_bounds(const Stream &mem, uint count)
{
if (mem.pos >= mem.size) {
/* No more data remained in the memory buffer. */
@@ -27,7 +29,7 @@ inline bool is_read_within_bounds(const Stream &mem, unsigned int count)
return true;
}
-unsigned int Stream::seek(unsigned int p)
+uint Stream::seek(uint p)
{
if (p > size) {
set_failed(msg_error_seek);
@@ -39,7 +41,7 @@ unsigned int Stream::seek(unsigned int p)
return pos;
}
-unsigned int mem_read(Stream &mem, unsigned long long &i)
+uint mem_read(Stream &mem, unsigned long long &i)
{
if (!is_read_within_bounds(mem, 8)) {
mem.set_failed(msg_error_seek);
@@ -50,7 +52,7 @@ unsigned int mem_read(Stream &mem, unsigned long long &i)
return 8;
}
-unsigned int mem_read(Stream &mem, unsigned int &i)
+uint mem_read(Stream &mem, uint &i)
{
if (!is_read_within_bounds(mem, 4)) {
mem.set_failed(msg_error_read);
@@ -61,7 +63,7 @@ unsigned int mem_read(Stream &mem, unsigned int &i)
return 4;
}
-unsigned int mem_read(Stream &mem, unsigned short &i)
+uint mem_read(Stream &mem, ushort &i)
{
if (!is_read_within_bounds(mem, 2)) {
mem.set_failed(msg_error_read);
@@ -72,7 +74,7 @@ unsigned int mem_read(Stream &mem, unsigned short &i)
return 2;
}
-unsigned int mem_read(Stream &mem, unsigned char &i)
+uint mem_read(Stream &mem, uchar &i)
{
if (!is_read_within_bounds(mem, 1)) {
mem.set_failed(msg_error_read);
@@ -83,7 +85,7 @@ unsigned int mem_read(Stream &mem, unsigned char &i)
return 1;
}
-unsigned int mem_read(Stream &mem, unsigned char *i, unsigned int count)
+uint mem_read(Stream &mem, uchar *i, uint count)
{
if (!is_read_within_bounds(mem, count)) {
mem.set_failed(msg_error_read);
diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp
index e9a13573116..213e10cf744 100644
--- a/source/blender/imbuf/intern/dds/dds_api.cpp
+++ b/source/blender/imbuf/intern/dds/dds_api.cpp
@@ -58,7 +58,7 @@ bool imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
return true;
}
-bool imb_is_a_dds(const unsigned char *mem, const size_t size)
+bool imb_is_a_dds(const uchar *mem, const size_t size)
{
if (size < 8) {
return false;
@@ -75,19 +75,16 @@ bool imb_is_a_dds(const unsigned char *mem, const size_t size)
return true;
}
-struct ImBuf *imb_load_dds(const unsigned char *mem,
- size_t size,
- int flags,
- char colorspace[IM_MAX_SPACE])
+struct ImBuf *imb_load_dds(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
struct ImBuf *ibuf = nullptr;
- DirectDrawSurface dds((unsigned char *)mem, size); /* reads header */
- unsigned char bits_per_pixel;
- unsigned int *rect;
+ DirectDrawSurface dds((uchar *)mem, size); /* reads header */
+ uchar bits_per_pixel;
+ uint *rect;
Image img;
- unsigned int numpixels = 0;
+ uint numpixels = 0;
int col;
- unsigned char *cp = (unsigned char *)&col;
+ uchar *cp = (uchar *)&col;
Color32 pixel;
Color32 *pixels = nullptr;
@@ -128,7 +125,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
bits_per_pixel = 24;
if (img.format() == Image::Format_ARGB) {
/* check that there is effectively an alpha channel */
- for (unsigned int i = 0; i < numpixels; i++) {
+ for (uint i = 0; i < numpixels; i++) {
pixel = pixels[i];
if (pixel.a != 255) {
bits_per_pixel = 32;
@@ -156,7 +153,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
rect = ibuf->rect;
cp[3] = 0xff; /* default alpha if alpha channel is not present */
- for (unsigned int i = 0; i < numpixels; i++) {
+ for (uint i = 0; i < numpixels; i++) {
pixel = pixels[i];
cp[0] = pixel.r; /* set R component of col */
cp[1] = pixel.g; /* set G component of col */
@@ -168,7 +165,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
}
if (ibuf->dds_data.fourcc != FOURCC_DDS) {
- ibuf->dds_data.data = (unsigned char *)dds.readData(ibuf->dds_data.size);
+ ibuf->dds_data.data = (uchar *)dds.readData(ibuf->dds_data.size);
/* flip compressed texture */
if (ibuf->dds_data.data) {