The Following User Says Thank You to lcuk For This Useful Post: | ||
|
2008-07-06
, 14:22
|
|
Posts: 3,524 |
Thanked: 2,958 times |
Joined on Oct 2007
@ Delta Quadrant
|
#22
|
Now, sdl and automatic translations - your pondering is slightly off.
YUV data is actually 12bit, but it is not stored in a single short integer 16bit memory block. The YUV data available by the Xv library is planar based with a whole 8bit greyscale chunky bitplane (w*h bytes) followed by 2 1/2 resolution chunky planes for chroma channels each of ((w/2)*(h/2)).
This means that to specify a color you need the full 24bit YUV value.
The colors are fully detailed but the number of pixels to draw on aren't.
So to get maximum coverage your rgb16->yuv table would have to store the whole 65k * 3 192kb
To use a table for the inverse would require mapping the whole 16.7million possible YUV colors for a pixel to a 16bit short per pixel...
Now, looking specifically at SDL, most games etc will load their assets as images and just be dealing with blitting them onto the screen at specified locations based on the game control code.
Loading an SDL image will create an SDL bitmap in a compatible format for the display mode you have created.
This means that any ImageFileRGB->ImageYUV would be done once at loading as long as the blit routines could work with YUV surface and YUV image..
This is not been a priority for me, I have learnt more about coding my way and did not understand enough about x11 or sdl when I started all this, it would certainly be interesting if it could be done.
I find the battery on my 810 to be quite resiliant, I dont play music on it or use it for wifi during the daytime and I keep my screen off maximum brightness and I am able to pull out and use my nokia for coding/compiling/sketching/looking/playing/reading whenever I need it.
During linuxtag I was sketching and doodling the whole trip and my nokia outlasted others, we all went out to the pub and my nokia which hadnt been charged all day was the only one still working and able to play numpty (at full "performance" speed might I add)..
|
2008-07-06
, 15:03
|
|
Posts: 1,635 |
Thanked: 1,816 times |
Joined on Apr 2008
@ Manchester, England
|
#23
|
Thanks for the enlightenment. It's always a bit of a pisser to find that a single wrong assumption is enough to capsize an idea.
This is mildly mind-asploding. Are you saying that in order to set a YUV 'pixel' one has to write to three separate memory blocks of varying size (or equivalently three offsets of the same block)?
Or is this automatically done using XVideo extension?
After looking over the Xv manpage I found the functions XvGetStill and XvGetVideo that accept drawable data, clip the data, and spit it out the hardware. I'm assuming that they accept the 'drawable' in YUV format. This is what I assume libQbase is doing.
So does the developer concern shclimself (or shclurself -- to be genderless and politically correct) with the chunky planes? How large are each individual Y, U, and V value?
Feel free to answer none of these questions. Seriously, I won't take offense at all. I'm intensely curious and it can get annoying.
Actually, 16bit to 24bit isn't that bad *if* it is indeed a mathematical function (one to one). The total size of the lookup would be 65Kcolours * 3Bytes (24bits) == 196K lookup.
Mapping the YUV to the the "2.5 resolution" chunky plane is the confusing bit. Are you suggesting that because of the 2.5 resolution, somehow more than one value would have to be stored for each mapped colour? Or is it simply a problem of splitting the result among the different planes?
The inverse operation, though, is quite terrible (as you rightly suggested). The lookup problem can be mitigated somewhat by bit shifting each Y, U and V components to achieve a smaller approximation (and index) of the original colour and then mapping that YUV result to its RGB equivalent. The many shifts for each pixel would likely have steep computational consequences, and would have to be tested to determine what the consequences are. This is all moot as thankfully YUV to RGB isn't the primary concern.
This would be useful for a great many of cases, but something would have to be done for applications that quickly want to write individual pixels. I remember some 'demos' of ray tracers implemented in SDL and the sort that would certainly require pixel level control.
Nor should it be! I'm impressed by your work and understanding. I'd love to contribute, if only with ideas.
I fully endorse just jumping in and trying something out without collecting all of the facts. Unique solutions tend to be developed that way and a deeper understanding of what you're working with can be gained.
That's amazing, and exactly what I want to hear. Even most lappies running basic applications can't boast life like this. As long as I don't have to constantly worry whether my tablet is going to die on me, I'm well happy.
How do you type on the N810? Using the built in keypad? How well does this work? I suspect using a wireless bluetooth keyboard would drain the battery (though the keyboard would likely be sending information to the bluetooth receiver more than the other way around, so I could be wrong).
The Following User Says Thank You to lcuk For This Useful Post: | ||
|
2008-07-06
, 17:26
|
|
Posts: 3,524 |
Thanked: 2,958 times |
Joined on Oct 2007
@ Delta Quadrant
|
#24
|
I simply call XvShmPutImage to push the already allocated blank canvas to the LCD. This call will raise an event in the X11 event chain for my window to say when transfer has completed. If I try writing to the canvas data during this time then extreme tearing occurs.
I have attemped in the past to call the same function from within SDL during its refresh process (sdl uses the same underlying shared memory setup, just a different format).
I still don't quite understand the mathematical function you are on about, if you are suggesting using a function to calc offset then do the lookup to then write it to the destination then that would be orders of magnitude longer than the quickest assembler operations on register variables - just use an optimised function to convert as required.
you can do the matrix transformation in strips anyway and grabbing data 4 pixels at a time and modifying the target pixels in bulk would help.
|
2008-07-06
, 17:45
|
|
Posts: 1,635 |
Thanked: 1,816 times |
Joined on Apr 2008
@ Manchester, England
|
#25
|
|
2008-07-06
, 18:17
|
|
Posts: 3,524 |
Thanked: 2,958 times |
Joined on Oct 2007
@ Delta Quadrant
|
#26
|
|
2008-07-06
, 18:28
|
|
Posts: 1,635 |
Thanked: 1,816 times |
Joined on Apr 2008
@ Manchester, England
|
#27
|
The Following 4 Users Say Thank You to lcuk For This Useful Post: | ||
|
2008-07-06
, 19:09
|
|
Posts: 3,524 |
Thanked: 2,958 times |
Joined on Oct 2007
@ Delta Quadrant
|
#28
|
|
2008-07-07
, 01:03
|
Posts: 393 |
Thanked: 112 times |
Joined on Jul 2007
|
#29
|
|
2008-07-08
, 22:20
|
|
Posts: 3,524 |
Thanked: 2,958 times |
Joined on Oct 2007
@ Delta Quadrant
|
#30
|
There are fixed point RGB->YUV approximations which should yield good results:
http://en.wikipedia.org/wiki/YUV#Num...approximations
Wonder whther CLUTs are faster or slower than a few mults and bit shifts.
The Following User Says Thank You to Capt'n Corrupt For This Useful Post: | ||
I find the battery on my 810 to be quite resiliant, I dont play music on it or use it for wifi during the daytime and I keep my screen off maximum brightness and I am able to pull out and use my nokia for coding/compiling/sketching/looking/playing/reading whenever I need it.
During linuxtag I was sketching and doodling the whole trip and my nokia outlasted others, we all went out to the pub and my nokia which hadnt been charged all day was the only one still working and able to play numpty (at full "performance" speed might I add)..
Now, sdl and automatic translations - your pondering is slightly off.
YUV data is actually 12bit, but it is not stored in a single short integer 16bit memory block.
The YUV data available by the Xv library is planar based with a whole 8bit greyscale chunky bitplane (w*h bytes) followed by 2 1/2 resolution chunky planes for chroma channels each of ((w/2)*(h/2)).
This means that to specify a color you need the full 24bit YUV value.
The colors are fully detailed but the number of pixels to draw on aren't.
So to get maximum coverage your rgb16->yuv table would have to store the whole 65k * 3 192kb
To use a table for the inverse would require mapping the whole 16.7million possible YUV colors for a pixel to a 16bit short per pixel...
Coupled with the fact most atomic SDL operations do not require pixel based lookups or assignments makes me think this table looks a little infeasible but its good to discuss and talk through suggestions.
Looking at performing the conversion via a function would be better and I believe there are already quite rapid integer only examples available.
Now, looking specifically at SDL, most games etc will load their assets as images and just be dealing with blitting them onto the screen at specified locations based on the game control code.
Loading an SDL image will create an SDL bitmap in a compatible format for the display mode you have created.
This means that any ImageFileRGB->ImageYUV would be done once at loading as long as the blit routines could work with YUV surface and YUV image..
I think the SDL underlying structure supports YUV or was intended to originally, I seem to recall seeing branches for YUV.
If it does, I personally see no reason why a new backend interface couldn't be hacked to make SDL talk to X11+xv...
This is not been a priority for me, I have learnt more about coding my way and did not understand enough about x11 or sdl when I started all this, it would certainly be interesting if it could be done.