Skip to content

Commit 206d726

Browse files
committed
Added r210 colorspace
1 parent 5c80efe commit 206d726

File tree

4 files changed

+79
-6
lines changed

4 files changed

+79
-6
lines changed

DShowPlugin/DeviceSource.cpp

+72-6
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ String DeviceSource::ChooseShader()
260260
strShader << TEXT("YUVToRGB.pShader");
261261
else if(colorType == DeviceOutputType_YV12)
262262
strShader << TEXT("YVUToRGB.pShader");
263-
else if(colorType == DeviceOutputType_YVYU || colorType == DeviceOutputType_YUY2 || colorType == DeviceOutputType_UYVY || colorType == DeviceOutputType_HDYC)
263+
else if(colorType == DeviceOutputType_YVYU || colorType == DeviceOutputType_YUY2 || colorType == DeviceOutputType_UYVY || colorType == DeviceOutputType_HDYC || colorType == DeviceOutputType_v210)
264264
strShader << TEXT("UYVToRGB.pShader");
265265
else if(colorType == DeviceOutputType_r210)
266266
strShader << TEXT("r210.pShader");
@@ -691,6 +691,8 @@ bool DeviceSource::LoadFilters()
691691
}
692692
else if(bestOutput->videoType == VideoOutputType_r210)
693693
colorType = DeviceOutputType_r210;
694+
else if(bestOutput->videoType == VideoOutputType_v210)
695+
colorType = DeviceOutputType_v210;
694696
else
695697
{
696698
colorType = DeviceOutputType_RGB;
@@ -1404,8 +1406,13 @@ void DeviceSource::ChangeSize(bool bSucceeded, bool bForce)
14041406

14051407
switch(colorType) {
14061408
case DeviceOutputType_RGB:
1409+
lineSize = (renderCX * 4);
1410+
break;
14071411
case DeviceOutputType_r210:
1408-
lineSize = renderCX * 4;
1412+
lineSize = ((renderCX + 63) / 64) * 256;
1413+
break;
1414+
case DeviceOutputType_v210:
1415+
lineSize = ((renderCX + 47) / 48) * 128;
14091416
break;
14101417
case DeviceOutputType_I420:
14111418
case DeviceOutputType_YV12:
@@ -1523,10 +1530,10 @@ void DeviceSource::ChangeSize(bool bSucceeded, bool bForce)
15231530
else //if we're working with planar YUV, we can just use regular RGB textures instead
15241531
{
15251532
BOOL statictexture = false;
1526-
if (colorType == DeviceOutputType_YVYU || colorType == DeviceOutputType_YUY2 || colorType == DeviceOutputType_UYVY || colorType == DeviceOutputType_HDYC || colorType == DeviceOutputType_r210)
1533+
if (colorType == DeviceOutputType_YVYU || colorType == DeviceOutputType_YUY2 || colorType == DeviceOutputType_UYVY || colorType == DeviceOutputType_HDYC || colorType == DeviceOutputType_r210 || colorType == DeviceOutputType_v210)
15271534
{
15281535
DXGI_FORMAT format;
1529-
if (colorType == DeviceOutputType_r210){
1536+
if (colorType == DeviceOutputType_r210 || colorType == DeviceOutputType_v210){
15301537
msetd(textureData, 0x000000FF, renderCX*renderCY*4);
15311538
statictexture = false;
15321539
format = DXGI_FORMAT_R10G10B10A2_UNORM;
@@ -1778,6 +1785,7 @@ void DeviceSource::Preprocess()
17781785
ChangeSize();
17791786

17801787
//// AMD Radeon HD 7350 have texture corruption problem with dynamic texture map/unmap DXGI_FORMAT_R8G8_B8G8_UNORM
1788+
// for intel HD graphics 2000, UpdateSubresource runs faster then lock + memcpy + unlock?
17811789
//LPBYTE lpData;
17821790
//UINT pitch;
17831791
//if(texture->Map(lpData, pitch))
@@ -1789,7 +1797,7 @@ void DeviceSource::Preprocess()
17891797
//}
17901798

17911799
ID3D10Texture2D *texture1 = (ID3D10Texture2D*)((D3D10Texture*)texture)->GetD3DTexture();
1792-
GetD3D()->UpdateSubresource(texture1, 0, NULL, lastSample->lpData, linePitch, linePitch);
1800+
GetD3D()->UpdateSubresource(texture1, 0, NULL, lastSample->lpData, linePitch, linePitch); // needs statictexture = true to work
17931801

17941802
bReadyToDraw = true;
17951803
}
@@ -1811,6 +1819,64 @@ void DeviceSource::Preprocess()
18111819
bReadyToDraw = true;
18121820
}
18131821
}
1822+
else if(colorType == DeviceOutputType_v210)
1823+
{
1824+
ChangeSize();
1825+
LPBYTE lpData;
1826+
UINT pitch;
1827+
if(texture->Map(lpData, pitch))
1828+
{
1829+
for(UINT y = 0; y < renderCY; y++)
1830+
{
1831+
UINT *out = (UINT*)(&lpData[y*pitch]);
1832+
UINT *in = (UINT*)(&lastSample->lpData[y*linePitch]);
1833+
UINT x = 0;
1834+
while(x+5 < renderCX)
1835+
{
1836+
UINT in1 = in[0];
1837+
UINT in2 = in[1];
1838+
UINT in3 = in[2];
1839+
UINT in4 = in[3];
1840+
in += 4;
1841+
out[x] = in1;
1842+
out[x+1] = (in1 & 0xFFF003FF) | ((in2 << 10) & 0x000FFC00);
1843+
out[x+2] = ((in2 >> 10) & 0x000FFFFF) | (in3 << 20);
1844+
out[x+3] = ((in2 >> 10) & 0x000003FF) | (in3 << 20) | (in3 & 0x000FFC00);
1845+
out[x+4] = (in3 >> 20) | (in4 << 10);
1846+
out[x+5] = (in3 >> 20) | ((in4 << 10) & 0x3FF00000) | ((in4 >> 10) & 0xFFC00);
1847+
x += 6;
1848+
}
1849+
if(x < renderCX)
1850+
{
1851+
UINT in1 = in[0];
1852+
out[x] = in1;
1853+
if(x+1 < renderCX)
1854+
{
1855+
UINT in2 = in[1];
1856+
out[x+1] = (in1 & 0xFFF003FF) | ((in2 << 10) & 0x000FFC00);
1857+
if(x+2 < renderCX)
1858+
{
1859+
UINT in3 = in[2];
1860+
out[x+2] = ((in2 >> 10) & 0x000FFFFF) | (in3 << 20);
1861+
if(x+3 < renderCX)
1862+
{
1863+
out[x+3] = ((in2 >> 10) & 0x000003FF) | (in3 << 20) | (in3 & 0x000FFC00);
1864+
if(x+4 < renderCX)
1865+
{
1866+
UINT in4 = in[3];
1867+
out[x+4] = (in3 >> 20) | (in4 << 10);
1868+
if(x+5 < renderCX)
1869+
out[x+5] = (in3 >> 20) | ((in4 << 10) & 0x3FF00000) | ((in4 >> 10) & 0xFFC00);
1870+
}
1871+
}
1872+
}
1873+
}
1874+
}
1875+
}
1876+
texture->Unmap();
1877+
bReadyToDraw = true;
1878+
}
1879+
}
18141880

18151881
lastSample->Release();
18161882

@@ -2066,7 +2132,7 @@ void DeviceSource::SetInt(CTSTR lpName, int iVal)
20662132
keyColor = (DWORD)iVal;
20672133

20682134
keyBaseColor = Color4().MakeFromRGBA(keyColor);
2069-
Matrix4x4TransformVect(keyChroma, (colorType == DeviceOutputType_HDYC || colorType == DeviceOutputType_RGB) ? (float*)yuv709Mat : (float*)yuvMat, keyBaseColor);
2135+
Matrix4x4TransformVect(keyChroma, (colorType == DeviceOutputType_HDYC || colorType == DeviceOutputType_RGB || colorType == DeviceOutputType_r210) ? (float*)yuv709Mat : (float*)yuvMat, keyBaseColor);
20702136
keyChroma *= 2.0f;
20712137
if (colorType == DeviceOutputType_YVYU)
20722138
{

DShowPlugin/DeviceSource.h

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ enum DeviceColorType
2727
{
2828
DeviceOutputType_RGB,
2929
DeviceOutputType_r210,
30+
DeviceOutputType_v210,
3031

3132
//planar 4:2:0
3233
DeviceOutputType_I420,

DShowPlugin/MediaInfoStuff.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ VideoOutputType GetVideoOutputType(const AM_MEDIA_TYPE &media_type)
113113
type = VideoOutputType_ARGB32;
114114
else if(media_type.subtype == MEDIASUBTYPE_r210)
115115
type = VideoOutputType_r210;
116+
else if(media_type.subtype == MEDIASUBTYPE_v210)
117+
type = VideoOutputType_v210;
116118

117119
// Planar YUV formats
118120
else if(media_type.subtype == MEDIASUBTYPE_I420)
@@ -166,6 +168,7 @@ const int inputPriority[] =
166168
7,
167169
7,
168170
4,
171+
4,
169172

170173
12,
171174
12,

DShowPlugin/MediaInfoStuff.h

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ inline void DeleteMediaType(AM_MEDIA_TYPE *pmt)
3535

3636
const GUID MEDIASUBTYPE_I420 = {0x30323449, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
3737
const GUID MEDIASUBTYPE_r210 = {0x30313272, 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
38+
const GUID MEDIASUBTYPE_v210 = {'012v', 0x0000, 0x0010, { 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
3839

3940
enum VideoOutputType
4041
{
@@ -43,6 +44,7 @@ enum VideoOutputType
4344
VideoOutputType_RGB32,
4445
VideoOutputType_ARGB32,
4546
VideoOutputType_r210,
47+
VideoOutputType_v210,
4648

4749
VideoOutputType_I420,
4850
VideoOutputType_YV12,
@@ -72,6 +74,7 @@ static const CTSTR EnumToName[] =
7274
TEXT("RGB32"),
7375
TEXT("RGBA32"),
7476
TEXT("r210"),
77+
TEXT("v210"),
7578

7679
TEXT("I420"),
7780
TEXT("YV12"),

0 commit comments

Comments
 (0)