Finally, (some of) my effects for everyone

Warning, long post
With a blogging rate < 1 post/year you will forgive me if the single one I write is a bit long. If you're impatient jump directly to the screencast ;-) .

What happened to gleffects?
You may have noticed the astonishingly cool super awesome effects I wrote for Cheese during my Summer of Code never made their way into Cheese itself.

Writing the effects with GLSL was and still is super fun.
It’s amazing what you can do even with a cheap gpu.
A couple of months ago, thanks to my lovely nvidia gpu heating up to the point of desoldering itself from the mainboard and making my laptop unusable ((Maybe some day I’ll tell you how I did solder reflowing and temporarily fixed the laptop with a heatgun)), I ported most of the effects to work on my little i915 based netbook. It’s quite satisfying to see convolution filters (gaussian blur, sobel edge detector, glow) process 640×480 textures at a nice framerate on such a small and underpowered device.

I believe we definitely need to take advantage of this big power in GStreamer and we’re slowly going towards the right direction.

But…
As cool as it can be, at the moment, gst-plugins-gl is still little more than a hackish proof of concept. It’s difficult to use in an application especially if you want to have mixed gl and normal buffers. Each frame needs to be uploaded to the video memory, processed with GL and downloaded back into ram for further gstreamer processing (e.g. video recording). So you need dedicated code paths that wouldn’t be needed if GL video was a first class citizen in a gstreamer pipeline.

The thing is even worse if you want to use GL in the UI, like we’re finally doing in Cheese. Gst-plugins-gl and Clutter run in separated threads, they use different GLX contexts and although there are ways to share textures (either with glxcontext sharelists or with texture from pixmap) between the two, they are tricky and fragile.

That and, most of all, the little time my studies leave me, kept the effects far away from Cheese all this time.

What changed?
Nothing.

So what?
Some days ago, during one of those moments after an exam when you feel so bored to suddenly have nothing to do but don’t want to start studying for the next one and desperately look for something to hack on, I noticed warptv.
It’s an effect we had in Cheese since the beginning. It applies a time dependent distortion to the image. A distortion, nothing that special, just like some of the funniest filters from gleffects, without gl.

So I went to look at the code and found out it was pretty simple to reimplement all distortion filters in gleffects using GstVideoFilter class.

No gpu, won’t it be slow?
While the shaders in gst-plugins-gl are able to calculate new coordinates for each pixel on the fly, to obtain acceptable speed on the cpu you have to precalculate a distortion map in an outer loop.
That’s all, the end result is the same and probably the cpu one is even faster because you don’t have the texture upload overhead.

There is a minor drawback ((Two actually, the gpu also does out of bound pixel clamping for free)) though: with the gpu you work on floating point coordinates and if your transformed pixel falls at fractional coordinates the hardware will calculate its color interpolating from the four nearest pixels.
With the cpu no one helps you and you have to either map the transformed fractional pixel to the color of its nearest neighbour (fast but jagged and ugly results) or implement bilinear interpolation yourself (nice but slow).

Cool, where I can see the results?
At first I ported all distortion filters from gleffects to a new plugin called cheeseeffects but soon discovered that Thiago already did something similar with geometrictransform plugin. So ported all the filters ((Minus the ones already there: squeeze, there called pinch, and twirl)) to his base class, fixed some of my old math and made effect parameters customizable. Unfortunately geometrictransform only does nearest neighbor interpolation, but I plan to port the bilinear interpolation routine I wrote in the first iteration sooner or later.

Done with distortion ones I also ported the color lookup table effects (heat, sepia, xpro and xray) into a new plugin, coloreffects.

I said see, where’s the screencast?
Okay okay, here’s your obligatory screencast!

Effect live previews from new Cheese effect selector

As you can see the effects look almost like the gl ones, but there is no gl involved. No need for a powerful gpu, no need for good video drivers, no need for GLSL! The screencast is taken on my netbook directly from the new effect selector Yuvi wrote for his Summer of Code and the low framerate is caused only by the recording app. The effect previews run pretty smoothly here.

Where can I get it?
Everything, thanks to Sebastian Dröge for the super quick review, is already in GStreamer Bad Plugins, you can test it if you want from today’s prerelease tarballs and will be for sure in the new Cheese.

PS
As you may have noticed there is a new Donate button in the sidebar.
Quite often someone suggested me to put one, for my work in Cheese, but never liked the idea that much…
Nonetheless, I’m an unemployed student and all the time I spend hacking in free software, albeit fun and exciting, is time subtracted from my studies.

Also as I said earlier, since some month I’m forced to work on a netbook as my laptop is dead and cannot afford a new one at the moment. I definitely wouldn’t mind some help there :-)

So, if you appreciate my work, feel free to donate ;-)
Thank you!

Dear lazyweb

Well, not so lazy… I’ve spent a couple of hours looking into this but didn’t find a solution.

Is there a way to set default size of a widget (or better just of a GtkDrawingArea) without limiting its minimum size?

It seems that the only way to have a drawing area of the size I’d want is to set a size request.

Thanks!

HP Support: FAIL

Hey I’m back on planet gnome isn’t it cool? Many thanks to Lucas and Jeff!

Some of you may already know that I’ve been laptop less in the past three months. Since about mid September display started to behave odd: it randomly turns off the lamps until I close and reopen the lid, then after about half a minute it turns off again, then again on, and so on. Sometimes it even starts blinking like a crazy stroboscope :D .
Long story short, here is a little video of the crazy display. Awesome, isn’it?

Unfortunately this little issue is a bit difficult to reproduce, sometimes it does it the whole day, and believe me, it’s quite irritating, sometimes it doesn’t for several days… Sometimes it does it only early in the morning (cold lamps?).

I contacted HP Support and they argued it could be a motherboard issue.
A motherboard issue, at least in Italy is under a 2-year pick-up-and-return warranty.
So they sent it to their repair center (actually an external one: A-NOVO Italia, Saronno) and sent it back after about two of weeks with a nice HP headed sheet stating they didn’t find any issue at all and just restored the operative system (a laptop coming with a motherboard issue and they did just that?). They also installed and ran a couple of benchmarks and other test software that said everything was ok, and I guess nothing more.

Guess what… display started blinking again 2 days after.
I contacted again HP, already a bit upset, I talked with another technician and he said his colleague was surely wrong. I had no motherboard issue but just some lamp or hinge one. It was covered by one year warranty with the producer and one with the seller.

Ok, I then went to the seller and told them about the previous story.
They sent the laptop to the very same repair center with a long description saying that it was a bit an unpredictable issue, that it was just been there some week before and suggesting to test it carefully this time. It was the December 1st.

Three days ago I was called to take back the laptop. Same HP headed sheet, all tests were successful, no issue found. Oh, they did a BIOS update, damn you receive a laptop for repair twice with the very same issue and you just run some test and do a BIOS update? Seriously, a BIOS update?!

Needless to say screen started blinking again soon. You can see it in that video taken a couple of hours ago and I can see it in front of me right now.

I don’t know if I feel more upset or frustrated… still I cannot believe how a repair center can suck this way… they didn’t even try to replace the lamps! they didn’t even unmount the display to check the cables!