Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
dc722c11
Commit
dc722c11
authored
17 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Support all the YUV modes that SDL supports. Try to find a hardware
accelerated one if possible.
parent
9c19f275
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/conio/sdl_con.c
+99
-21
99 additions, 21 deletions
src/conio/sdl_con.c
with
99 additions
and
21 deletions
src/conio/sdl_con.c
+
99
−
21
View file @
dc722c11
...
...
@@ -273,30 +273,91 @@ void RGBtoYUV(Uint8 r, Uint8 g, Uint8 b, Uint8 *yuv_array, int monochrome, int l
void
yuv_fillrect
(
SDL_Overlay
*
overlay
,
SDL_Rect
*
r
,
int
dac_entry
)
{
int
x
,
y
;
Uint8
*
Y
,
*
U
,
*
V
;
int
odd_line
;
int
uvlen
=
(
r
->
w
)
>>
1
;
int
uvoffset
=
overlay
->
pitches
[
1
]
*
((
r
->
y
+
1
)
>>
1
)
+
((
r
->
x
+
1
)
>>
1
);
odd_line
=
(
r
->
y
)
&
1
;
Y
=
overlay
->
pixels
[
0
]
+
overlay
->
pitches
[
0
]
*
(
r
->
y
)
+
(
r
->
x
);
U
=
overlay
->
pixels
[
2
]
+
uvoffset
;
V
=
overlay
->
pixels
[
1
]
+
uvoffset
;
for
(
y
=
0
;
y
<
r
->
h
;
y
++
)
int
uplane
,
vplane
;
/* Planar formats */
int
y0pack
,
y1pack
,
u0pack
,
v0pack
;
/* Packed formats */
yuv
.
changed
=
1
;
switch
(
overlay
->
format
)
{
case
SDL_IYUV_OVERLAY
:
/* Swap planes */
uplane
=
1
;
vplane
=
2
;
goto
planar
;
case
SDL_YV12_OVERLAY
:
uplane
=
2
;
vplane
=
1
;
goto
planar
;
case
SDL_YUY2_OVERLAY
:
y0pack
=
0
;
y1pack
=
2
;
u0pack
=
1
;
v0pack
=
3
;
goto
packed
;
case
SDL_UYVY_OVERLAY
:
y0pack
=
1
;
y1pack
=
3
;
u0pack
=
0
;
v0pack
=
2
;
goto
packed
;
case
SDL_YVYU_OVERLAY
:
y0pack
=
0
;
y1pack
=
2
;
u0pack
=
3
;
v0pack
=
1
;
goto
packed
;
break
;
}
return
;
planar:
{
memset
(
Y
,
yuv
.
colours
[
dac_entry
][
0
],
r
->
w
);
Y
+=
overlay
->
pitches
[
0
];
if
(
odd_line
)
{
U
+=
overlay
->
pitches
[
2
];
V
+=
overlay
->
pitches
[
1
];
int
x
,
y
;
Uint8
*
Y
,
*
U
,
*
V
;
int
odd_line
;
int
uvlen
=
(
r
->
w
)
>>
1
;
int
uvoffset
=
overlay
->
pitches
[
1
]
*
((
r
->
y
+
1
)
>>
1
)
+
((
r
->
x
+
1
)
>>
1
);
odd_line
=
(
r
->
y
)
&
1
;
Y
=
overlay
->
pixels
[
0
]
+
overlay
->
pitches
[
0
]
*
(
r
->
y
)
+
(
r
->
x
);
U
=
overlay
->
pixels
[
uplane
]
+
uvoffset
;
V
=
overlay
->
pixels
[
vplane
]
+
uvoffset
;
for
(
y
=
0
;
y
<
r
->
h
;
y
++
)
{
memset
(
Y
,
yuv
.
colours
[
dac_entry
][
0
],
r
->
w
);
Y
+=
overlay
->
pitches
[
0
];
if
(
odd_line
)
{
U
+=
overlay
->
pitches
[
uplane
];
V
+=
overlay
->
pitches
[
vplane
];
}
else
{
memset
(
U
,
yuv
.
colours
[
dac_entry
][
1
],
uvlen
);
memset
(
V
,
yuv
.
colours
[
dac_entry
][
2
],
uvlen
);
}
}
else
{
memset
(
U
,
yuv
.
colours
[
dac_entry
][
1
],
uvlen
);
memset
(
V
,
yuv
.
colours
[
dac_entry
][
2
],
uvlen
);
}
return
;
packed:
{
int
x
,
y
;
Uint32
colour
;
Uint8
*
colour_array
=&
colour
;
Uint32
*
offset
;
int
uvlen
=
(
r
->
w
)
>>
1
;
int
uvoffset
=
overlay
->
pitches
[
1
]
*
((
r
->
y
+
1
)
>>
1
)
+
((
r
->
x
+
1
)
>>
1
);
colour_array
[
y0pack
]
=
yuv
.
colours
[
dac_entry
][
0
];
colour_array
[
y1pack
]
=
yuv
.
colours
[
dac_entry
][
0
];
colour_array
[
u0pack
]
=
yuv
.
colours
[
dac_entry
][
1
];
colour_array
[
v0pack
]
=
yuv
.
colours
[
dac_entry
][
2
];
offset
=
(
Uint32
*
)(
overlay
->
pixels
[
0
]
+
overlay
->
pitches
[
0
]
*
(
r
->
y
));
offset
+=
r
->
x
;
for
(
y
=
0
;
y
<
r
->
h
;
y
++
)
{
for
(
x
=
0
;
x
<
r
->
w
;
x
+=
2
)
*
offset
[
x
>>
1
]
=
colour
;
}
}
yuv
.
changed
=
1
;
return
;
}
void
sdl_user_func
(
int
func
,
...)
...
...
@@ -1191,7 +1252,24 @@ void setup_surfaces(void)
sdl
.
mutexV
(
yuv
.
mutex
);
sdl
.
FreeYUVOverlay
(
yuv
.
overlay
);
}
yuv
.
overlay
=
sdl
.
CreateYUVOverlay
(
char_width
,
char_height
,
SDL_YV12_OVERLAY
,
win
);
yuv
.
overlay
=
sdl
.
CreateYUVOverlay
(
char_width
,
char_height
,
SDL_YUY2_OVERLAY
,
win
);
if
(
!
yuv
.
overlay
->
hw_overlay
)
{
sdl
.
FreeYUVOverlay
(
yuv
.
overlay
);
yuv
.
overlay
=
sdl
.
CreateYUVOverlay
(
char_width
,
char_height
,
SDL_UYVY_OVERLAY
,
win
);
if
(
!
yuv
.
overlay
->
hw_overlay
)
{
sdl
.
FreeYUVOverlay
(
yuv
.
overlay
);
yuv
.
overlay
=
sdl
.
CreateYUVOverlay
(
char_width
,
char_height
,
SDL_YVYU_OVERLAY
,
win
);
if
(
!
yuv
.
overlay
->
hw_overlay
)
{
sdl
.
FreeYUVOverlay
(
yuv
.
overlay
);
yuv
.
overlay
=
sdl
.
CreateYUVOverlay
(
char_width
,
char_height
,
SDL_YV12_OVERLAY
,
win
);
if
(
!
yuv
.
overlay
->
hw_overlay
)
{
sdl
.
FreeYUVOverlay
(
yuv
.
overlay
);
yuv
.
overlay
=
sdl
.
CreateYUVOverlay
(
char_width
,
char_height
,
SDL_IYUV_OVERLAY
,
win
);
}
}
}
}
//fprintf(stderr,"Mode: %d (%d)\n",yuv.overlay->format,yuv.overlay->hw_overlay);
sdl
.
mutexP
(
yuv
.
mutex
);
sdl
.
LockYUVOverlay
(
yuv
.
overlay
);
sdl_setup_yuv_colours
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment