Imagination PowerVR SDK Blog

Vertically flipping PVRTC compressed image data


#1
This question is also posted on StackOverflow:
http://stackoverflow.com/questions/12994863/vertically-flipping-pvrtc-compressed-image-data

I have some PVRTC 4bpp image data that needs to be flipped vertically in-place without decompression. The code I have written is mostly working but the flip currently introduces small artefacts and I'm unsure exactly why.

The PVRTC flip code first moves the 8-byte 4x4 compression blocks to their flipped position as calculated by the TwiddleUV() function from PVRTDecompress.cpp in the PowerVR SDK. This part appears to be correct.

Second, the code iterates through all the 8-byte compression blocks reversing the order of the second 4 bytes which contain the 4x4 modulation data stored in 2bpp. The first 4 bytes of the block contains color data which is left unchanged.

This seems to be very close to correct, but it leaves small artefacts in the flipped image that weren't there in the original and which manifest mostly as small greyish horizontal lines. If the flipping code is run twice then the artefacts go away and the image is unchanged from the original.

Can anyone with some PVRTC experience explain what else needs to be done to flip the compressed image data? I think the problem may be to do with the flipping of modulation data, but my forays into the PVRTC documentation haven't yielded the answer at this stage.

Many thanks,
Richard


#2

Hi Richard,

I’ve seen that Simon has been discussing this with you on StackOverflow post. Do you have any follow up questions?

Thanks,
Joe




#3

Hi Joe,


Given that a vertical flip will always alter the contents we will have to do something else instead. I had thought it wouldn’t be a big deal to do the flip, but I know better now!

Thanks,
Richard

#4

Hi Richard,

Is there any reason you can’t flip the original image before it is compressed? Can you flip the image by altering the texture coordinates used in the shaders, as Simon suggested?

Thanks,
Joe




#5

Yes I am fully aware of both those options! I was hoping to do it ‘manually’ in some offline texture processing tools, but we’ll just do it another way, no big deal.


Many thanks,
Richard