Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
e1524883
Commit
e1524883
authored
Mar 20, 2011
by
Konrad Rzepecki
Committed by
Alexandre Julliard
Mar 29, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Implement WINED3DFMT_YUY2 to WINED3DFMT_B5G6R5_UNORM conversion function.
parent
37aadc9e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
surface_base.c
dlls/wined3d/surface_base.c
+44
-0
No files found.
dlls/wined3d/surface_base.c
View file @
e1524883
...
@@ -782,6 +782,49 @@ static void convert_yuy2_x8r8g8b8(const BYTE *src, BYTE *dst,
...
@@ -782,6 +782,49 @@ static void convert_yuy2_x8r8g8b8(const BYTE *src, BYTE *dst,
}
}
}
}
static
void
convert_yuy2_r5g6b5
(
const
BYTE
*
src
,
BYTE
*
dst
,
DWORD
pitch_in
,
DWORD
pitch_out
,
unsigned
int
w
,
unsigned
int
h
)
{
unsigned
int
x
,
y
;
int
c2
,
d
,
e
,
r2
=
0
,
g2
=
0
,
b2
=
0
;
TRACE
(
"Converting %ux%u pixels, pitches %u %u
\n
"
,
w
,
h
,
pitch_in
,
pitch_out
);
for
(
y
=
0
;
y
<
h
;
++
y
)
{
const
BYTE
*
src_line
=
src
+
y
*
pitch_in
;
WORD
*
dst_line
=
(
WORD
*
)(
dst
+
y
*
pitch_out
);
for
(
x
=
0
;
x
<
w
;
++
x
)
{
/* YUV to RGB conversion formulas from http://en.wikipedia.org/wiki/YUV:
* C = Y - 16; D = U - 128; E = V - 128;
* R = cliptobyte((298 * C + 409 * E + 128) >> 8);
* G = cliptobyte((298 * C - 100 * D - 208 * E + 128) >> 8);
* B = cliptobyte((298 * C + 516 * D + 128) >> 8);
* Two adjacent YUY2 pixels are stored as four bytes: Y0 U Y1 V .
* U and V are shared between the pixels.
*/
if
(
!
(
x
&
1
))
/* for every even pixel, read new U and V */
{
d
=
(
int
)
src_line
[
1
]
-
128
;
e
=
(
int
)
src_line
[
3
]
-
128
;
r2
=
409
*
e
+
128
;
g2
=
-
100
*
d
-
208
*
e
+
128
;
b2
=
516
*
d
+
128
;
}
c2
=
298
*
((
int
)
src_line
[
0
]
-
16
);
dst_line
[
x
]
=
(
cliptobyte
((
c2
+
r2
)
>>
8
)
>>
3
)
<<
11
/* red */
|
(
cliptobyte
((
c2
+
g2
)
>>
8
)
>>
2
)
<<
5
/* green */
|
(
cliptobyte
((
c2
+
b2
)
>>
8
)
>>
3
);
/* blue */
/* Scale RGB values to 0..255 range,
* then clip them if still not in range (may be negative),
* then shift them within DWORD if necessary.
*/
src_line
+=
2
;
}
}
}
struct
d3dfmt_convertor_desc
struct
d3dfmt_convertor_desc
{
{
enum
wined3d_format_id
from
,
to
;
enum
wined3d_format_id
from
,
to
;
...
@@ -794,6 +837,7 @@ static const struct d3dfmt_convertor_desc convertors[] =
...
@@ -794,6 +837,7 @@ static const struct d3dfmt_convertor_desc convertors[] =
{
WINED3DFMT_B5G6R5_UNORM
,
WINED3DFMT_B8G8R8X8_UNORM
,
convert_r5g6b5_x8r8g8b8
},
{
WINED3DFMT_B5G6R5_UNORM
,
WINED3DFMT_B8G8R8X8_UNORM
,
convert_r5g6b5_x8r8g8b8
},
{
WINED3DFMT_B8G8R8A8_UNORM
,
WINED3DFMT_B8G8R8X8_UNORM
,
convert_a8r8g8b8_x8r8g8b8
},
{
WINED3DFMT_B8G8R8A8_UNORM
,
WINED3DFMT_B8G8R8X8_UNORM
,
convert_a8r8g8b8_x8r8g8b8
},
{
WINED3DFMT_YUY2
,
WINED3DFMT_B8G8R8X8_UNORM
,
convert_yuy2_x8r8g8b8
},
{
WINED3DFMT_YUY2
,
WINED3DFMT_B8G8R8X8_UNORM
,
convert_yuy2_x8r8g8b8
},
{
WINED3DFMT_YUY2
,
WINED3DFMT_B5G6R5_UNORM
,
convert_yuy2_r5g6b5
},
};
};
static
inline
const
struct
d3dfmt_convertor_desc
*
find_convertor
(
enum
wined3d_format_id
from
,
enum
wined3d_format_id
to
)
static
inline
const
struct
d3dfmt_convertor_desc
*
find_convertor
(
enum
wined3d_format_id
from
,
enum
wined3d_format_id
to
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment