I am trying to get video playback working in DirectX9 using the libtheoraplayer.
The video is playing fine (performance is fantastic), except the colours are all wrong!
I am loading the video clip with the theora output mode set to TH_XRGB. I therefore create a texture to paste this data to in DirectX with the flag D3DFMT_X8R8G8B8 specified.
So I am assuming that TheoraPLayback lib will provide me with data: 4 bytes per pixel, the first byte we don't care about, then then Red, then the Green then the Blue.
However, when I playback I get a weird colour effect, as though the pixel values I have been returned are wrong:
I have obviously got the widths/strides etc correct as the video fills the texture exactly, but it seems the pixel colour information is wrong?
Can anybody see if I am doing it wrong, or confirm that they have got video working with the same theora output mode and DirectX texture format I am trying to use?
Thanks for any help!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have tried to use TH_XBGR... my gfx card does not support D3DFMT_X8B8G8R8, only D3DFMT_A8R8G8B8 and D3DFMT_X8R8G8B8. So as a test I manually twizzled the colour values given from frame->getBuffer() like this just to see if that gave me the correctly coloured image:
for (int y = 0; y < dataHeight; y++)
{
unsigned char* toTwizzle = pixelData;
The performance of the playback is fantastic, (hardly dents my FPS counter at all!). So I would really like to get it going... do you have any other ideas?
Cheers for any help!
Last edit: runningbug 2015-01-19
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
oh yeah, that one :) that's why I made all those supported formats :)
And yeah, part of why this library is so useful is because the video decoding is done in separate threads thus not incurring a noticeable penalty on your main thread's FPS. you will notice a speed decrease if you use a lot of videos (or large videos) or are on a single core CPU.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am trying to get video playback working in DirectX9 using the libtheoraplayer.
The video is playing fine (performance is fantastic), except the colours are all wrong!
I am loading the video clip with the theora output mode set to TH_XRGB. I therefore create a texture to paste this data to in DirectX with the flag D3DFMT_X8R8G8B8 specified.
So I am assuming that TheoraPLayback lib will provide me with data: 4 bytes per pixel, the first byte we don't care about, then then Red, then the Green then the Blue.
However, when I playback I get a weird colour effect, as though the pixel values I have been returned are wrong:
http://www.dropbox.com/s/4m754e8124luswz/libtheoraplayer.jpg
Here is the code I am using to draw to the texture's surface: (texture of the format D3DFMT_X8R8G8B8)
WritePixelData(unsigned char pixelData, int dataWidth, int dataHeight)
{
D3DLOCKED_RECT lockedRect;
IDirect3DSurface9 surface;
_texture->GetSurfaceLevel(0, &surface);
}
I have obviously got the widths/strides etc correct as the video fills the texture exactly, but it seems the pixel colour information is wrong?
Can anybody see if I am doing it wrong, or confirm that they have got video working with the same theora output mode and DirectX texture format I am trying to use?
Thanks for any help!
Hi,
just try using TH_XBGR, that's what I use in my projects on dx9. dx9 has some weird texture byte ordering...
Hi kspes,
Thanks for the quick reply!
I have tried to use TH_XBGR... my gfx card does not support D3DFMT_X8B8G8R8, only D3DFMT_A8R8G8B8 and D3DFMT_X8R8G8B8. So as a test I manually twizzled the colour values given from frame->getBuffer() like this just to see if that gave me the correctly coloured image:
for (int y = 0; y < dataHeight; y++)
{
unsigned char* toTwizzle = pixelData;
But the colours are still wrong...
The performance of the playback is fantastic, (hardly dents my FPS counter at all!). So I would really like to get it going... do you have any other ideas?
Cheers for any help!
Last edit: runningbug 2015-01-19
Hi,
I have sorted this. It was a problem my end... I was using TH_XRGB when I meant to use TH_BGRX!
Thanks for your help.
oh yeah, that one :) that's why I made all those supported formats :)
And yeah, part of why this library is so useful is because the video decoding is done in separate threads thus not incurring a noticeable penalty on your main thread's FPS. you will notice a speed decrease if you use a lot of videos (or large videos) or are on a single core CPU.