• entries
455
639
• views
422279

# GTL3 Testing continues

92 views

So, with a brief moment of calm and TF2 just not doing it for me I sat down to work out some of the bugs in GTL3 with regards to my testing.

The first problem I had was, based on commonality the PNG flips were all wrong; this was a simple coding error; I put 'false' when I meant 'true'.

The biggest issue was two of the TGA decoders not working properly; this turned out to be me being pwn'd hard by operator presidence; (row+1 * width) wasn't what I meant, ((row+1) * width) was [grin]

One last and very puzzling bug remains with the TGA RLE loaders; setting the origin to the bottom left doesn't produce the correct output.

The test image I have is 4 circles arranged thusly;

R G
B Y
(where R = Red, G = Green, B = Blue and Y = Yellow)

Everyone else outputs
Y B
G R
As expected.
The RLE TGA code however throw out;
G R
Y B

This is slightly puzzling.

The TGA Image is stored as
B Y
R G
in memory (this is the output from the 'no flip' path), so to get the correct output we need to flip it in the 'x' axis.
The decoder hits the correct code path, everything seems to setup correctly, yet for some reason the output is always;
G R
Y B

Which is a full flip o.O

I've probably got something wrong with the maths somewhere, but I'm getting too tired to get staring at it, so I'll throw it out here, see if anyone else spots the problem before me;

const int imgsize = width * height;while (count > 0){	int row = offset / width;	// get the row we are on i.e. 12 / 10 = row 1 (check interger divsion...)	int rowRemains = width - (offset % width);	int copyAmount = (count > rowRemains) ? rowRemains : count;	forward_mem_iter src_itor(src);	forward_mem_iter end_itor(src + copyAmount);	int rowoffset = ((row+1) * width) - (width - rowRemains) - 1;	reverse_mem_iter dest_itor(dest + rowoffset );	if (repeated)		PerformTransformedRepeatedCopy(src_itor,dest_itor,copyAmount);	else		PerformTransformedCopy(src_itor,end_itor,dest_itor);	count -= copyAmount;	offset += copyAmount;	src += copyAmount;}

Where 'count' is the element repeat amount or number of elements to copy.
"width" is the row width.
"height" is the image height.
"offset" is the offset in elements we are into the decoded image.
The memory iter objects are just standard iterators, with the reverse iter stepping backwards thru memory.
Dest is the START of the destination memory, this is NOT changed as the algo. progresses thus we have to workout the offset each time.

Idea:
Get to end of current row, then step backwards from that position by however much we have already written into that row. The '-1' is there to ensure we stay on the correct row.

The two Copy functions call std::fill_n and std::transform respectively under the hood.

Any ideas anyone?

## 1 Comment

Could be wrong, but this line:
int rowoffset = ((row+1) * width) - (width - rowRemains) - 1;


should maybe be:
int rowoffset = (row * width) + (width - rowRemains) - 1;


?

## Create an account

Register a new account