caedes' Notes

2015-03-23

Comparing Performance: stb_image vs libjpeg(-turbo), libpng and lodepng

Filed under: Linux,Programming — caedes @ 02:06
Tags: , , , , , , , , ,

NOTE: This post has moved to https://blog.gibson.sh/2015/03/23/comparing-performance-stb_image-vs-libjpeg-turbo-libpng-and-lodepng/
The original article is kept here for now, but is not maintained in any way.

I recently tried out Sean Barrett’s stb_image and was blown away by how fucking easy it is to use.
Integrating it into your project is trivial: Just add the header and somewhere do:

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"

That’s all. (If you wanna use it in multiple files you just #include "stb_image.h" there without the #define.)

And the API is trivial too:

int width, height, bytesPerPixel;
unsigned char* pixeldata = stbi_load("bla.jpg", &width, &height, &bytesPerPixel, 0);
// if you have already read the image file data into a buffer:
unsigned char* pixeldata2 = stbi_load_from_memory(bufferWithImageData, bufferLength, &width, &height, &bytesPerPixel, 0);
if(pixeldata2 == NULL)
printf("Some error happened: %sn", stbi_failure_reason());

There’s also a simple callback-API which allows you to define some callbacks that stb_image will call to get the data, handy if you’re using some kind of virtual filesystem or want to load the data from .zip files or something.
And it supports lots of common image file types including JPEG, PNG, TGA, BMP, GIF and PSD.

So I wondered if there are any downsides regarding speed.
In short: (On my machine) it’s faster than libjpeg, a bit slower than libjpeg-turbo, twice as fast as lodepng (another one-file-png decoder which also has a nice API) and a bit slower than libpng. For smaller images stb_image’s performance is even closer to libpng/libjpeg-turbo. GCC produces faster code than Clang. All in all I find the performance acceptable and will use stb_image more in the future (my first “victim” was Yamagi Quake II).

The average times decoding a 4000x3000pixel image in milliseconds for GCC and clang with different optimization levels:
(more…)

Advertisement

2014-01-02

How to boot Linux and Windows (7) via UEFI

Filed under: Linux — caedes @ 03:55
Tags: , , , , , , , , , , ,

NOTE: This post has moved to https://blog.gibson.sh/2014/01/02/how-to-boot-linux-and-windows-7-via-uefi/
The original article is kept here for now, but is not maintained in any way.

Don’t.
It’s a fucking pain in the ass.
Buy a 2TB for your Windows installation, you have to use GPT partitions (instead of the old MBR style which only supports 2TB with ugly hacks and can’t have a continuous partition from 2TB) – and Windows can only boot from GPT partitions in UEFI mode.
To make things more challenging, Windows doesn’t offer creating a GPT partition table and partitions in the graphical installer (at least for Win7), so one has to use cmd.exe.
But don’t worry, the Linux part also sucks :-)
I’ll describe how I got Windows to install using GPT partitions on a 3TB harddisk, how to make an existing Linux (Debian Wheezy) installation boot via EFI (using grub-efi) and how I got my Mainboard (ASUS Z87-A) to boot this and GRUB to chainload (UEFI) Windows.
(more…)

2010-06-30

Bug-Hunting: Browsers fail to load research.microsoft.com

Filed under: Bug-Hunting — caedes @ 01:44
Tags: , , , , ,

NOTE: This post has moved to https://blog.gibson.sh/2010/06/30/bug-hunting-browsers-fail-to-load-research.microsoft.com/
The original article is kept here for now, but is not maintained in any way.

This is a follow-up to debian bug #541658 for Iceweasel: “cannot open research.microsoft.com”.
It turned out that this bug applies to all (tested) browsers with cookie-support (Iceweasel, Opera, Chrome, Arora, Kazehakase), but only very few people are experiencing it. If you’re one of them please get in touch via the comments :-)
First I’ll tell how to reproduce the bug, then I’ll sum up the facts I already collected in that bugreport and then I’ll document my further attempts to narrow down the problem.

UPDATE: The reason for that strange behaviour was found and I filed a new bugreport: No. #587789
UPDATE 2: Debians Kernel maintainer considers this expected behavior and told me to file a bugreport upstream and I did: Netfilter bug #622.
UPDATE 3: I think Microsoft has fixed their server. Of course the Linux kernel should be fixed anyway but there doesn’t seem to be much interest in doing so :-/
(more…)

2010-05-11

Shutting down (e)SATA disks under Linux

Filed under: Linux — caedes @ 22:55
Tags: , , , , , , ,

NOTE: This post has moved to https://blog.gibson.sh/2010/05/11/shutting-down-esata-disks-under-linux/
The original article is kept here for now, but is not maintained in any way.

I’m using a eSATA external harddrive and want to be able to safely unplug it without shutting down my PC. While just removing the drive after unmounting worked so far, I’m not sure if it’s really safe – I’d really prefer to cleanly disconnect it and spinning it down before pulling the plug.
I googled that and stumbled upon http://www.sakana.fr/blog/2009/05/04/linux-sata-hot-plug-unplug/ which seems to be a clean and safe way to do it, so I just wrote a script to do that.
(more…)

2010-05-05

Unlock gnome-keyring on Login with SLiM and PAM

Filed under: Linux — caedes @ 02:41
Tags: , , , , ,

NOTE: This post has moved to https://blog.gibson.sh/2010/05/05/unlock-gnome-keyring-on-login-with-slim-and-pam/
The original article is kept here for now, but is not maintained in any way.

My favorite desktop environment is XFCE, because it’s fast, doesn’t need much memory¹ and still is convenient (automounting of CDs and memory sticks, easy unmounting by clicking, a real desktop, etc).
I also use SLiM as a display manager because it is slim and looks much better than xdm.

On my Laptop I also use GNOME’s NetworkManager because I haven’t yet found a better and less bloat alternative for handling wireless networks and VPNs.
NetworkManager is able to store your passwords (WPA-keys etc) in the GNOME Keyring so you don’t need to enter them each time your laptop connects to a wireless network. But you still have to enter the password to unlock the keyring.. unless you let PAM handle that on login.
(more…)

2010-01-08

Remote administration/tech-support with (reverse) VNC

Filed under: Linux — caedes @ 02:55
Tags: , , , , ,

NOTE: This post has moved to https://blog.gibson.sh/2010/01/08/remote-administrationtech-support-with-reverse-vnc/
The original article is kept here for now, but is not maintained in any way.

Like most computer-savvy people I am frequently asked to give tech support to my family etc. Because telling them on the telephone what to do is a major pain in the ass, VNC is my weapon of choice, if SSH isn’t sufficiant (got to show how something is done, SSH impossible/hard because the other side uses Windows or is behind a NAT, …).

I’ll describe how to set up a normal and reverse VNC-connections using x11vnc and TightVNC.

(more…)

2009-10-02

MCabber – Settings and rebinding of PageUp/PageDown

Filed under: Linux — caedes @ 00:34
Tags: , ,

NOTE: This post has moved to https://blog.gibson.sh/2009/10/01/mcabber-settings-rebinding-pageup-down/
The original article is kept here for now, but is not maintained in any way.

After years of using centericq for ICQ and Jabber I switched to gajim (ICQ via transport), because centericq didn’t have any useable UTF8 support. I was never really satisfied with gajim though, because I happen to switch between my PC and my Notebook multiple times a day, resulting in inconsistent chat-histories etc – a console based solution in a screen is so much nicer.

So I tried MCabber, that turned out to be really great once you’ve configured it to your needs. After installing MCabber (most Linux/BSD distributions should have a package or port) you’ll want to configure it to your needs.
(more…)

Blog at WordPress.com.