Source/astc_image_load_store.cpp
void fill_image_padding_area(astc_codec_image * img)
{
	if (img->padding == 0)
	{
		return;
	}

	int x, y, z, i;
	int exsize = img->xsize + 2 * img->padding;
	int eysize = img->ysize + 2 * img->padding;
	int ezsize = (img->zsize == 1) ? 1 : (img->zsize + 2 * img->padding);

	int xmin = img->padding;
	int ymin = img->padding;
	int zmin = (img->zsize == 1) ? 0 : img->padding;
	int xmax = img->xsize + img->padding - 1;
	int ymax = img->ysize + img->padding - 1;
	int zmax = (img->zsize == 1) ? 0 : img->zsize + img->padding - 1;

	// This is a very simple implementation. Possible optimizations include:
	// * Testing if texel is outside the edge.
	// * Looping over texels that we know are outside the edge.
	if (img->data8)
	{
		for (z = 0; z < ezsize; z++)
		{
			int zc = MIN(MAX(z, zmin), zmax);
			for (y = 0; y < eysize; y++)
			{
				int yc = MIN(MAX(y, ymin), ymax);
				for (x = 0; x < exsize; x++)
				{
					int xc = MIN(MAX(x, xmin), xmax);
					for (i = 0; i < 4; i++)
					{
						img->data8[z][y][4 * x + i] = img->data8[zc][yc][4 * xc + i];
					}
				}
			}
		}
	}
	else if (img->data16)
	{
		for (z = 0; z < ezsize; z++)
		{
			int zc = MIN(MAX(z, zmin), zmax);
			for (y = 0; y < eysize; y++)
			{
				int yc = MIN(MAX(y, ymin), ymax);
				for (x = 0; x < exsize; x++)
				{
					int xc = MIN(MAX(x, xmin), xmax);
					for (i = 0; i < 4; i++)
					{
						img->data16[z][y][4 * x + i] = img->data16[zc][yc][4 * xc + i];
					}
				}
			}
		}
	}
}
// fill the padding area of the input-file buffer with clamp-to-edge data
// Done inefficiently, in that it will overwrite all the interior data at least once;
// this is not considered a problem, since this makes up a very small part of total
// running time.
fill the padding area of the input-file buffer with clamp-to-edge data
Done inefficiently, in that it will overwrite all the interior data at least once;
this is not considered a problem, since this makes up a very small part of total
running time.
fill the padding area of the input - file buffer with clamp - to - edge data Done inefficiently in that it will overwrite all the interior data at least once ; this is not considered a problem since this makes up a very small part of total running time .
void fill_image_padding_area(astc_codec_image * img)
{
	if (img->padding == 0)
	{
		return;
	}
	int x, y, z, i;
	int exsize = img->xsize + 2 * img->padding;
	int eysize = img->ysize + 2 * img->padding;
	int ezsize = (img->zsize == 1) ? 1 : (img->zsize + 2 * img->padding);
	int xmin = img->padding;
	int ymin = img->padding;
	int zmin = (img->zsize == 1) ? 0 : img->padding;
	int xmax = img->xsize + img->padding - 1;
	int ymax = img->ysize + img->padding - 1;
	int zmax = (img->zsize == 1) ? 0 : img->zsize + img->padding - 1;
	if (img->data8)
	{
		for (z = 0; z < ezsize; z++)
		{
			int zc = MIN(MAX(z, zmin), zmax);
			for (y = 0; y < eysize; y++)
			{
				int yc = MIN(MAX(y, ymin), ymax);
				for (x = 0; x < exsize; x++)
				{
					int xc = MIN(MAX(x, xmin), xmax);
					for (i = 0; i < 4; i++)
					{
						img->data8[z][y][4 * x + i] = img->data8[zc][yc][4 * xc + i];
					}
				}
			}
		}
	}
	else if (img->data16)
	{
		for (z = 0; z < ezsize; z++)
		{
			int zc = MIN(MAX(z, zmin), zmax);
			for (y = 0; y < eysize; y++)
			{
				int yc = MIN(MAX(y, ymin), ymax);
				for (x = 0; x < exsize; x++)
				{
					int xc = MIN(MAX(x, xmin), xmax);
					for (i = 0; i < 4; i++)
					{
						img->data16[z][y][4 * x + i] = img->data16[zc][yc][4 * xc + i];
					}
				}
			}
		}
	}
}
void fill_image_padding_area ( astc_codec_image * img ) { if ( img -> padding == 0 ) { return ; } int x , y , z , i ; int exsize = img -> xsize + 2 * img -> padding ; int eysize = img -> ysize + 2 * img -> padding ; int ezsize = ( img -> zsize == 1 ) ? 1 : ( img -> zsize + 2 * img -> padding ) ; int xmin = img -> padding ; int ymin = img -> padding ; int zmin = ( img -> zsize == 1 ) ? 0 : img -> padding ; int xmax = img -> xsize + img -> padding - 1 ; int ymax = img -> ysize + img -> padding - 1 ; int zmax = ( img -> zsize == 1 ) ? 0 : img -> zsize + img -> padding - 1 ; if ( img -> data8 ) { for ( z = 0 ; z < ezsize ; z ++ ) { int zc = MIN ( MAX ( z , zmin ) , zmax ) ; for ( y = 0 ; y < eysize ; y ++ ) { int yc = MIN ( MAX ( y , ymin ) , ymax ) ; for ( x = 0 ; x < exsize ; x ++ ) { int xc = MIN ( MAX ( x , xmin ) , xmax ) ; for ( i = 0 ; i < 4 ; i ++ ) { img -> data8 [ z ] [ y ] [ 4 * x + i ] = img -> data8 [ zc ] [ yc ] [ 4 * xc + i ] ; } } } } } else if ( img -> data16 ) { for ( z = 0 ; z < ezsize ; z ++ ) { int zc = MIN ( MAX ( z , zmin ) , zmax ) ; for ( y = 0 ; y < eysize ; y ++ ) { int yc = MIN ( MAX ( y , ymin ) , ymax ) ; for ( x = 0 ; x < exsize ; x ++ ) { int xc = MIN ( MAX ( x , xmin ) , xmax ) ; for ( i = 0 ; i < 4 ; i ++ ) { img -> data16 [ z ] [ y ] [ 4 * x + i ] = img -> data16 [ zc ] [ yc ] [ 4 * xc + i ] ; } } } } } }
fill the padding area of the input-file buffer with clamp-to-edge data
Done inefficiently, in that it will overwrite all the interior data at least once;
this is not considered a problem, since this makes up a very small part of total
running time.
fill the padding area of the input - file buffer with clamp - to - edge data Done inefficiently in that it will overwrite all the interior data at least once ; this is not considered a problem since this makes up a very small part of total running time .
// This is a very simple implementation. Possible optimizations include: // * Testing if texel is outside the edge. // * Looping over texels that we know are outside the edge.