Radeon HDTV Underscan
I just wasted an entire day trying to get rid of the black bars (underscan) I was seeing when connecting my Radeon HD 4870 to my Samsung LE32A566P HDTV. I tired all sorts of settings in both the TV and PC until finally comming across this article. Pay close attention to harthansen's posts. He mentions this..
Quote:Harthansen
What should really be mentioned is that in Desktops & Displays. You have toright click on the little icon of your TV at the bottom and go to configure. This is the only way to access many functions of the video card, like scaling options. It took me an hour to figure that out.
Here's an image showing what he means..
You can then find the underscan option in the 'Scaling' tab. It looks like this..
It turns out that for whatever retarded reason CCC (Catalyst Control Center) defaults to 5% underscan. This is what causes the black bars. All you have to do is move the underscan slider to 0% (as in the above picture) and all is fixed.
Now go, have fun times with your fully utilised HDTV!
Edited 2 time(s). Last edit at 01/10/2010 12:35PM by Kaloth.
Post by Kaloth on 01/10/2010 12:34PM
0 comment(s)
Bluetooth GPRS & Linux
Intro
Recently, I installed a custom distro of Ubuntu Linux, on my Asus EEE PC 701 netbook, called EasyPeasy. It's a great little distro and much more satisfying to use than Windows XP, which really doesn't play nicely with SSDs and small screens. However, one thing that it took me a while to get working was access to the Internet via my mobile phone. What follows is, I hope, a useful guide to anyone following in my footsteps.
Where to Start?
I started by plugging in my USB Bluetooth dongle. Immediately the Bluetooth icon appeared in the system tray. Searching for and pairing with my phone goes equally smoothly. I could then drag and drop files between my phone and netbook. So far so good, maybe Linux had finally made the jump in usability that I'd waited for all these years? The answer is a resounding 'almost'. Unfortunately the default GNOME Bluetooth Applet (v1.8 in this distro) give the ability to copy files too and from the attached device but little else. From here on it's all config files and terminal commands..
The Basics..
If you've not done this sort of thing before then read this section, otherwise feel free to skip to the next section.
First of all your PC is going to need to open a PPP connection to your phone that it can transfer data over. To do this you're going to have to create an RFCOMM device and a PPP script. Next you'll need to tell your PC how to tell your phone what you want it to do (eg: 'give me a GRPS internet connection using my PAYT profile') with AT commands (aka: Hayes' Commands). Don't worry! I'm going to show you the commands that you'll need
Setting up communication with your phone
First pair your PC with your phone (I'm not going to cover that here as it seems very straight forward in modern Linux distos). Next we need to find out what reference ID your PC uses for your phone and which communication channel is being used for it. You can find out both of these by running the following command from the Ubuntu terminal app..
sudo sdptool browse
The output will look something like this..
Inquiring ...
Browsing 00:1E:45:B1:58:35 ...
Service Description: Sony Ericsson W880
Service RecHandle: 0x10000
Service Class ID List:
"PnP Information" (0x1200)
Service Name: Dial-up Networking
Service RecHandle: 0x10002
Service Class ID List:
"Dialup Networking" (0x1103)
"Generic Networking" (0x1201)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 2
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100
I've highlighted the device ID and channel number although it should be obvious

.
Now open up your favorite editor with root access. I used
JEdit, here's an example command for doing that..
sudo jedit
Open (or create if it doesn't exist) a file called '/etc/bluetooth/rfcomm.conf' and place the following into it (taking care to substitute the channel and device ID of your phone)..
rfcomm0
{
bind yes;
device 00:1E:45:B1:58:35;
channel 2;
comment "sonymobile";
}
Now restart your PC so that Linux can read your new config and create the device that represents your phone (ie: rfcomm0).
Important: If you don't restart you will encounter errors in the next bit!
How to create a PPP connection to your phone.
Open (or create if it doesn't exist) a file called '/etc/ppp/peers/mobilenet'. Into it place the following..
# Keep pppd attached to the terminal:
# Comment this to get daemon mode pppd
nodetach
# Debug info from pppd:
# Comment this off, if you don't need more info
debug
# Show password in debug messages
show-password
# Connect script:
# scripts to initialize the GPRS modem and start the connection,
# wvdial command is for Orange SPV while other phones should work with chat
connect "/usr/sbin/chat -v -f /etc/chatscripts/mobilenet"
#connect /etc/chatscripts/BluetoothDialup
#connect "/usr/bin/wvdial --chat --config /etc/ppp/peers/gprs-wvdial.conf radiolinja_usb_orange_spv"
# Disconnect script:
# AT commands used to 'hangup' the GPRS connection.
#disconnect /etc/ppp/peers/gprs-disconnect-chat
# Serial device to which the GPRS phone is connected:
# /dev/ttyS0 for serial port (COM1 in Windows),
# /dev/ircomm0 for IrDA,
# /dev/ttyUB0 for Bluetooth (Bluez with rfcomm running) and
# /dev/ttyUSB0 for USB
#/dev/ttyS0 # serial port one
#/dev/ttyS1 # serial port two
#/dev/ircomm0 # IrDA serial port one
/dev/rfcomm0 # Bluetooth serial port one
#/dev/ttyUSB0 # USB serial device, for example Orange SPV
# Serial port line speed
115200 # fast enough
#57600 # perhaps usefull with IrDA
# Hardware flow control:
# Use hardware flow control with cable, Bluetooth and USB but not with IrDA.
crtscts # serial cable, Bluetooth and USB
#nocrtscts # IrDA
# Ignore carrier detect signal from the modem:
local
# IP addresses:
# - accept peers idea of our local address and set address peer as 10.0.0.1
# (any address would do, since IPCP gives 0.0.0.0 to it)
# - if you use the 10. network at home or something and pppd rejects it,
# change the address to something else
:10.0.0.1
#
# Disable the previous setting if you are using office.vodafone.nl as access point
# pppd must not propose any IP address to the peer!
noipdefault
# Accept peers idea of our local address
ipcp-accept-local
# Add the ppp interface as default route to the IP routing table
defaultroute
# DNS servers from the phone:
# some phones support this, some don't.
usepeerdns
# ppp compression:
# ppp compression may be used between the phone and the pppd, but the
# serial connection is usually not the bottleneck in GPRS, so the
# compression is useless (and with some phones need to disabled before
# the LCP negotiations succeed).
novj
nobsdcomp
novjccomp
nopcomp
noaccomp
# The phone is not required to authenticate:
noauth
# Username and password:
# If username and password are required by the APN, put here the username
# and put the username-password combination to the secrets file:
# /etc/ppp/pap-secrets for PAP and /etc/ppp/chap-secrets for CHAP
# authentication. See pppd man pages for details.
# Example, Radiolinja operator pap-secrets:
# "rlnet" * "internet" *
user "web"
#user "Orange"
# Asyncmap:
# some phones may require this option.
#asyncmap 0xa0000
# No magic:
# some phones may require this option.
#nomagic
# Require PAP authentication:
# some phones may require this option.
#require-pap
This is a slightly modified version of a script that I found
here. One bit that you may need to change is the user name. Also note that if PAP is required for you phone you'll need to put a password in the '/etc/ppp/pap-secrets' file.
The next stage is to create a ppp chat script of AT commands to tell your phone what you want it to do. Unfortunately this part of the process varies depending on your provider. What follows works for Vodafone UK but may need some tweeking for other providers.
Put the following in a file called '/etc/chatscripts/mobilenet'.
TIMEOUT 45
ECHO ON
ABORT '\nBUSY\r'
ABORT '\nERROR\r'
ABORT '\nNO ANSWER\r'
ABORT '\nNO CARRIER\r'
ABORT '\nNO DIALTONE\r'
ABORT '\nRINGING\r\n\r\nRINGING\r'
'' \rAT
OK-+++\c-OK ATH0
OK 'AT+CGDCONT?'
The output should contain a response from you phone telling you the deatils of the installed connection profiles. To run the script use the following command with your phone connected via Bluetooth..
sudo pon mobilenet
The output will look something like this..
AT
OK
ATH0
OK
AT+CGDCONT?
+CGDCONT: 1,"IP","wap.vodafone.co.uk","0.0.0.0",0,0
+CGDCONT: 2,"IP","pp.vodafone.co.uk","0.0.0.0",0,0
+CGDCONT: 3,"IP","internet","0.0.0.0",0,0
+CGDCONT: 4,"IP","pp.vodafone.co.uk","0.0.0.0",0,0
Choose the profile you want to use and the remember it's number (eg: 4). Next add the following to the bottom of the above script..
TIMEOUT 30
OK ATD*99***4#
CONNECT ""
Note the '4' in the special phone number that we dial on the second to last line. This is the profile number, substitute it for the profile number you want to use. now run the script again and you should be connected!
sudo pon mobilenet
AT
OK
ATH0
OK
AT+CGDCONT?
+CGDCONT: 1,"IP","wap.vodafone.co.uk","0.0.0.0",0,0
+CGDCONT: 2,"IP","pp.vodafone.co.uk","0.0.0.0",0,0
+CGDCONT: 3,"IP","internet","0.0.0.0",0,0
+CGDCONT: 4,"IP","pp.vodafone.co.uk","0.0.0.0",0,0
OK
ATD*99***4#
CONNECT
Script /usr/sbin/chat -v -f /etc/chatscripts/mobilenet finished (pid 4540), status = 0x0
Serial connection established.
using channel 2
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm0
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xde7e6580>]
rcvd [LCP ConfReq id=0x2 <accomp> <pcomp> <asyncmap 0x0> <magic 0xf11fd4c8>]
sent [LCP ConfRej id=0x2 <accomp> <pcomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xde7e6580>]
rcvd [LCP ConfReq id=0x3 <asyncmap 0x0> <magic 0xf11fd4c8>]
sent [LCP ConfAck id=0x3 <asyncmap 0x0> <magic 0xf11fd4c8>]
sent [LCP EchoReq id=0x0 magic=0xde7e6580]
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15>]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
rcvd [LCP EchoRep id=0x0 magic=0xf11fd4c8]
rcvd [LCP ProtRej id=0x1 80 fd 01 01 00 0c 1a 04 78 00 18 04 78 00]
Protocol-Reject for 'Compression Control Protocol' (0x80fd) received
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfNak id=0x1 <addr 10.0.0.1>]
rcvd [IPCP ConfNak id=0x1 <addr 10.177.189.131> <ms-dns1 10.206.65.68> <ms-dns2 10.206.65.68>]
sent [IPCP ConfReq id=0x2 <addr 10.177.189.131> <ms-dns1 10.206.65.68> <ms-dns2 10.206.65.68>]
rcvd [IPCP ConfReq id=0x2]
sent [IPCP ConfAck id=0x2]
rcvd [IPCP ConfAck id=0x2 <addr 10.177.189.131> <ms-dns1 10.206.65.68> <ms-dns2 10.206.65.68>]
not replacing existing default route via 192.168.1.1
Cannot determine ethernet address for proxy ARP
local IP address 10.177.189.131
remote IP address 10.0.0.1
primary DNS address 10.206.65.68
secondary DNS address 10.206.65.68
Script /etc/ppp/ip-up started (pid 4547)
Script /etc/ppp/ip-up finished (pid 4547), status = 0x0
I hope this was all helpful. Any questions or suggestions for improving the article are welcome
Edited 4 time(s). Last edit at 10/26/2009 07:47PM by Kaloth.
Post by Kaloth on 10/26/2009 07:19PM
0 comment(s)
NOS - Now with composition desktop effects...
After getting most of NOS working it seemed to me that there was something major missing. "Transparency!" I cried, I must have semi-transparent menus!
Ok, so maybe I'm over-exaggerating things a little but you have to admit that it's one of the visual niceties that makes bb4win and other blackbox systems so nice to use. So I set about hacking up Swing to create a composition desktop. The result is fully programmable (via the java.awt.Composite interface) composition effects on any NOSWindow object. Also, because each NOSWindow now has an individual back buffer, the annoying z-fighting issues inherent in the way that Swing JPanels are rendered have been avoided and live-previews of minimised windows can be displayed (ie: a bit like the Vista taskbar).
Style: Biohazard by xMonKeyx
Background: Reminiscence 3 by mayhs82
It works beautifully even when animated windows are present on the desktop. Obviously there is a cost in both memory and CPU usage, but so far this appears to be minimal.
I know that I've said this before, but I plan to release NOS into the wild next weekend. All that remains for me to do is a bit of a code clean-up and possibly an improvement of the HTTP file transfer code. The later would involve writing my own HTTP 1.1 communications class instead of using the built in java.net.HttpURLConnection object which creates a new connection to the server for every transmission ala HTTP 1.0. Moving to a single static connection would vastly increase turn-around and decrease system load when browsing files and other activities which require lots of communication with the server.
Edited 3 time(s). Last edit at 09/18/2008 02:58PM by Kaloth.
Post by Kaloth on 09/15/2008 10:04AM
0 comment(s)
NOS - Almost ready for the masses...
I've been busy writing some more apps for NOS as well as ironing out a few bugs and adding some new features. The screen shot below shows the new mini web browser application (just uses the built in JEditorPane, can only view very simple webpages) and, not that you can tell in the screenshot, 3d animated desktop backgrounds. I estimate that I should have a full version of this ready for public use in about a week if all goes well.
Style: Gruppled by Craig Laparo
Background: Island 3D MAML Scene by Kaloth
The animated desktop backgrounds are created using my very own software 3D engine called MAML. If you have Java installed you will see an example at the top of this page displaying a few random 3d models. MAML looks like XML and is a little like VRML in the way that it works (ie: hierarchical modelling). You can find some more examples of MAML
here.
Edited 1 time(s). Last edit at 07/23/2008 04:31PM by Kaloth.
Post by Kaloth on 07/23/2008 04:28PM
0 comment(s)
NOS - Nomadic Operating System
NOS is my attempt at writing a nomadic desktop environment. It uses Java as the base technology so that it can be used on a wide variety of machines. Users each have their own file system backed by a set of php scripts on a web server. This allows them to upload their own applications and files in any way they want. The main desktop environment is implemented to look like the popular Blackbox environment (bb4win, xoblite, bblean) and includes a full blackbox style interpreter that can make use of the hundreds of styles available on the net (boxshots). I hope to release this project to the public in the near future, let me know if you're interested as I'm looking for some beta testers to try out and provide feedback on what I have so far
Style: Ember by Blockhead
Background: Fzeema by Blockhead
Edited 2 time(s). Last edit at 07/15/2008 08:42AM by Kaloth.
Post by Kaloth on 07/14/2008 09:32PM
0 comment(s)
Sin City Image Filter (Colour Isolation)
I've often wondered how they produced that funky looking image effect used in the film Sin City. What choice is a computer wielding geek left with but to implement their own version of it!
So, what they appear to do is pick a colour that they want to isolate in the final image (eg: red) and then desaturate (ie: fade to grey scale) all the other colours.
A great way to isolate a colour is to convert your image to YUV (see handy wikipedia page) and use distance measurement in the UV plane to work out how close to your desired colour, irrespective of brightness (Y plane), the current pixel is. Then back in RGB space all you have to do is desaturate your pixel based on the distance value you calculated in YUV space. It took a bit of tweaking to get the relationship between distance in the UV plane and desaturation looking nice. This is the formulae I came up with...
scale = max(0.0f, min(1.0f, (D - T)/S));
avg = (int)(((in_r + in_g + in_b) / 3) * scale );
out_r = (int)( in_r * ( 1.0f - scale ) + avg );
out_g = (int)( in_g * ( 1.0f - scale ) + avg );
out_b = (int)( in_b * ( 1.0f - scale ) + avg );
Where D is the distance in UV, T is the tolerance level and S is the spread. By 'spread' I mean the smoothness of the gradient between fully saturated and fully unsaturated.
The end result is quite good if you then ramp up the contrast loads as well


Edited 4 time(s). Last edit at 06/11/2008 01:35PM by Kaloth.
Post by Kaloth on 06/10/2008 01:17PM
0 comment(s)
Water
I've recently been playing about with the idea of water simulation. My idea was to simulate the surface of a body of water in 3D using the abstraction of a mesh with springs attached to each of the vertices.
In a spring system the amount of acceleration can be calculated from the distance to the equilibrium point. So in other words the more stretched the spring is the more it wants to be back at the equilibrium point.
This on it's own works nicely but only simulates each vertex of the surface individually. I needed a way to link the surface together as a whole and therefore create a wave system. To do this I simply do a bit of post processing and move each of the vertices to the average of it's neighbours. This means that displacements (and therefore accelerations) ripple out from their sources. The final result is quite pleasing to the eye...
You can see the animation in action
here
Edited 4 time(s). Last edit at 04/12/2008 09:33PM by Kaloth.
Post by Kaloth on 10/19/2007 10:33AM
0 comment(s)
Video and Subs...
Sub Filtering
PNG uses a process it calls 'filtering' to prepare image data for scanline compression. Various filter functions are used on a per-scanline basis, but the one I'll talk about here is call 'Sub'.
What the Sub filter does is to store the differences (using mod 256 arithmetic) between the bytes in each pixel instead of the absolute values. This means that for a 8bit grayscale image the following gradient...
0, 1, 2, 3, 4, 5, 6, 7, 8
becomes...
0, 1, 1, 1, 1, 1, 1, 1, 1
As you can probably imagine, the filtered data is much easier to compress than the original. This is how PNG manages to compress it's famous 48mb gradient image into 58kb.
Applying this filter to my image compression technique on a per-tile basis achieves the same affect. It is not however quite as good at compressing artificially constructed gradients because working on a per-tile basis means that the arrays of numbers contain quite a few jumps when we wrap around the stride of the tile. I'm happy with this however because in 'real' images (eg: photographs) I get comparable and often better compression ratios.
Video Encoding
One thing I wanted to use my image compression technique for was VNC between my PDA (Dell Axim x30 High) and desktop PC. My use of quadtrees means that a computer desktop screenshot is very highly compressed (>90% most of the time). But to achieve better compression I decided to use an incremental technique to send the VNC data.
Given that not much changes from frame to frame on a computer desktop I decided to send the difference between frames instead of absolute images. This means that whole swathes of the image get reduced down to blank pixels which can be encoded in a highly compressed manner using the quadtrees. Neat huh? The quadtrees effectively give me a very cheap form of motion detection.
Trying this out on my PDA gave framerates of 25fps in a standard desktop with notepad and a few other apps open. I also tried out a few games and got 15fps in Transport Tycoon, but only about 1-2fps in Oblivion. Oblivion goes so slowly because in most frames the entire screen changes, this means that the entire image has to be sent each time.
I hope to put my VNC ap on this site for download when I've ironed out the rough edges.
Edited 1 time(s). Last edit at 10/06/2007 11:50AM by Kaloth.
Post by Kaloth on 10/06/2007 11:39AM
0 comment(s)
Image Compression
I was looking at the specs for the PNG format the other day and realised that it's just GIF with support for true 32bit colour and an open compression format. Which lead me to thinking that there must be a way to improve on it
So, armed with quad trees and a gzip compressor class I set out to create a similar format that uses quadtrees to identify 'tiles' within an image that are the same colour.
The crux of my idea is to split the image into manageable tiles (eg: 32x32) and then create a quadtree from the top 32x32 level down to the 1x1 level. Then in a second pass work through the tree grouping all the neighbouring subtrees that contain the same colour. This means that for each 32x32 tile of an blank image I only store one 32bit colour.
If I then combine this with a pallet system akin to that of GIF & PNG it leads to (for a 2 tone image) 1 bit per 32x32 tile plus 2x32bit colours.
Next some header information is needed to tell the decompresser about each level of the tree. This is simply a byte per tree level where one nybble is used to indicate leaf nodes and the other the data type of the leaf nodes. The data type is required because the quadtree method actually inflates data if you have an image where all the neighbouring pixels are different colours (due to all the header info needed at each sub-level). So in this method a leaf can either be a single pixel or a group of contiguous pixels (ie: just like a standard bitmap).
So, all this means that in the end for a blank image of 64x64 in 32bit colour we have...
4 bytes - format identifier
1 byte - format version
4 bytes - pallet size
4 bytes - pallet colour 0
4*1 bytes - tile headers
4*1 bytes - tile colours
(note that the tile colour has to be rounded up to a byte in size to make decoding easier)
This becomes a total size of 25 bytes (prior to gzip compression). PNG gets a size of 301 bytes and BMP gets 16384 bytes. Not a bad improvement (99.85% vs 98.16% compression). For generic photographs and such the difference becomes much less, but my format still comes out on top of PNG for most cases
The one case where I consistently lose out to PNG is when an image contains a lot of gradients. In this case my quadtree technique doesn't gain me any compression and I'm left to rely on colour pallets and standard gzip compression.
I'll post some more examples and details of how I improved this to make a motion detecting video codec soon.
Edited 6 time(s). Last edit at 09/28/2007 11:45PM by Kaloth.
Post by Kaloth on 09/28/2007 11:06AM
0 comment(s)
(Intermission) In-Body Attachments
Attaching images to a post in Phorum is very easy once you've installed the correct mod, but updating all the templates to work with that mod is rather difficult. For example, the image below should appear in the post...
But, as you can see it is not visible. Hopefully I can get it to show up otherwise this blog is going to contain a lot more posts like this one....
ARG!
[EDIT] YAY! it works now

[/EDIT]
Edited 2 time(s). Last edit at 09/27/2007 04:27PM by Kaloth.
Post by Kaloth on 09/27/2007 12:18PM
0 comment(s)