Skip to content

{ Category Archives } Uncategorized

Fast clamp

Sometimes one needs to bound a value between two limits, min and max. This operation is called clamp. Let’s consider the clamp of an integer to the interval [0, 255]. int clamp(int x) { return x 255 ? 255 : x; } JPEG decoding requires three such clamp operations per decoded pixel, so we’d like [...]

The first Galaxy Nexus challenge too hard for anybody

Google posted the first Galaxy Nexus challenge, which proved too difficult for anybody to solve. After 3 hours of waiting for a solution, Google gave in and posted a spoiler hint Dots are like flag messages, which makes the challenge pretty much trivial. It looks like the initial task was too hard (nobody was solving [...]

Thanks to Eric Sink for his new book

I just received by international mail the printed edition of Version Control by Example by Eric Sink, offered as a gift. Thanks!

Fast RGB pixel average on ARM

Here I present a small trick, how to compute extremely fast the average of two RGBA_8888 values on an ARM processor, and how to implement it easily in C++/gcc (e.g. using the Android NDK). We have two 4-byte values representing two pixels, in format RGBA_8888. Let’s ignore the Alpha channel, assuming both have alpha=0xff (opaque). [...]

Android ARM: PLD preload magic

I just discovered the incredible performance boost that can be achieved by using the PLD (“Preload Data”) ARM assembler instruction. What I needed to do is convert image pixel data from RGB to RGBA format — from 3bytes/pixel to 4bytes/pixel; fullscreen in real time during animation. But the general situation is anytime you need to [...]

Floating point exact representation of integers

There are two main floating point formats: single-precision (float in Java) which stores a value in 4bytes, and double-precision (double) using 8bytes. The question is what range of integers can be represented exactly by these floating point formats? In other words, what is the maximum value for which such a statement holds: long v; (long)(float) [...]

Apple is bad

I’ll never buy an Apple product again. I find the patent situation in the US profoundly sick. Microsoft is making money on the back of Android with patent fees. Apple and Microsoft team up together to buy the Nortel patents for 4.5billion, to be used against competitor Android. Apple suing HTC and Motorola over Android. [...]

RenderFX: color vs. power

Android render effects is a way to globally change the colors used when rendering, for example by using only the Red channel (disabling Green and Blue). It was first presented on Jeff Sharkey’s blog, and it is now implemented and available in CyanogenMod. Instead of using the three color channels (RGB) you may chose to [...]

Cyanogen Rules

I use a Nexus One phone. I have been using it for more than one year. I’ve written apps for it. Yet until yesterday I didn’t know it has an FM receiver. Yes, the Nexus One has a perfectly good functional FM receiver. The hardware (FM radio) is there in the phone. It’s just that [...]

How to work around Android’s 24 MB memory limit

The Android framework enforces a per-process 24 MB memory limit. On some older devices, such as the G1, the limit is even lower at 16 MB. What’s more, the memory used by Bitmaps is included in the limit. For an application manipulating images it is pretty easy to reach this limit and get the process [...]