Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
b23dea27
Commit
b23dea27
authored
Nov 25, 2013
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavd/sdl: allow to change window size
parent
0464d272
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
sdl.c
libavdevice/sdl.c
+23
-4
No files found.
libavdevice/sdl.c
View file @
b23dea27
...
@@ -124,11 +124,13 @@ static void compute_overlay_rect(AVFormatContext *s)
...
@@ -124,11 +124,13 @@ static void compute_overlay_rect(AVFormatContext *s)
overlay_rect
->
y
=
(
sdl
->
window_height
-
overlay_rect
->
h
)
/
2
;
overlay_rect
->
y
=
(
sdl
->
window_height
-
overlay_rect
->
h
)
/
2
;
}
}
#define SDL_BASE_FLAGS (SDL_SWSURFACE|SDL_RESIZABLE)
static
int
event_thread
(
void
*
arg
)
static
int
event_thread
(
void
*
arg
)
{
{
AVFormatContext
*
s
=
arg
;
AVFormatContext
*
s
=
arg
;
SDLContext
*
sdl
=
s
->
priv_data
;
SDLContext
*
sdl
=
s
->
priv_data
;
int
flags
=
SDL_
SWSURFACE
|
(
sdl
->
window_fullscreen
?
SDL_FULLSCREEN
:
0
);
int
flags
=
SDL_
BASE_FLAGS
|
(
sdl
->
window_fullscreen
?
SDL_FULLSCREEN
:
0
);
AVStream
*
st
=
s
->
streams
[
0
];
AVStream
*
st
=
s
->
streams
[
0
];
AVCodecContext
*
encctx
=
st
->
codec
;
AVCodecContext
*
encctx
=
st
->
codec
;
...
@@ -195,6 +197,22 @@ init_end:
...
@@ -195,6 +197,22 @@ init_end:
case
SDL_QUIT
:
case
SDL_QUIT
:
sdl
->
quit
=
1
;
sdl
->
quit
=
1
;
break
;
break
;
case
SDL_VIDEORESIZE
:
sdl
->
window_width
=
event
.
resize
.
w
;
sdl
->
window_height
=
event
.
resize
.
h
;
SDL_LockMutex
(
sdl
->
mutex
);
sdl
->
surface
=
SDL_SetVideoMode
(
sdl
->
window_width
,
sdl
->
window_height
,
24
,
SDL_BASE_FLAGS
);
if
(
!
sdl
->
surface
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Failed to set SDL video mode: %s
\n
"
,
SDL_GetError
());
sdl
->
quit
=
1
;
}
else
{
compute_overlay_rect
(
s
);
}
SDL_UnlockMutex
(
sdl
->
mutex
);
break
;
default:
default:
break
;
break
;
}
}
...
@@ -292,15 +310,15 @@ static int sdl_write_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -292,15 +310,15 @@ static int sdl_write_packet(AVFormatContext *s, AVPacket *pkt)
AVPicture
pict
;
AVPicture
pict
;
int
i
;
int
i
;
if
(
sdl
->
quit
)
if
(
sdl
->
quit
)
{
sdl_write_trailer
(
s
);
return
AVERROR
(
EIO
);
return
AVERROR
(
EIO
);
}
avpicture_fill
(
&
pict
,
pkt
->
data
,
encctx
->
pix_fmt
,
encctx
->
width
,
encctx
->
height
);
avpicture_fill
(
&
pict
,
pkt
->
data
,
encctx
->
pix_fmt
,
encctx
->
width
,
encctx
->
height
);
SDL_LockMutex
(
sdl
->
mutex
);
SDL_LockMutex
(
sdl
->
mutex
);
SDL_FillRect
(
sdl
->
surface
,
&
sdl
->
surface
->
clip_rect
,
SDL_FillRect
(
sdl
->
surface
,
&
sdl
->
surface
->
clip_rect
,
SDL_MapRGB
(
sdl
->
surface
->
format
,
0
,
0
,
0
));
SDL_MapRGB
(
sdl
->
surface
->
format
,
0
,
0
,
0
));
SDL_UnlockMutex
(
sdl
->
mutex
);
SDL_LockYUVOverlay
(
sdl
->
overlay
);
SDL_LockYUVOverlay
(
sdl
->
overlay
);
for
(
i
=
0
;
i
<
3
;
i
++
)
{
for
(
i
=
0
;
i
<
3
;
i
++
)
{
sdl
->
overlay
->
pixels
[
i
]
=
pict
.
data
[
i
];
sdl
->
overlay
->
pixels
[
i
]
=
pict
.
data
[
i
];
...
@@ -312,6 +330,7 @@ static int sdl_write_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -312,6 +330,7 @@ static int sdl_write_packet(AVFormatContext *s, AVPacket *pkt)
SDL_UpdateRect
(
sdl
->
surface
,
SDL_UpdateRect
(
sdl
->
surface
,
sdl
->
overlay_rect
.
x
,
sdl
->
overlay_rect
.
y
,
sdl
->
overlay_rect
.
x
,
sdl
->
overlay_rect
.
y
,
sdl
->
overlay_rect
.
w
,
sdl
->
overlay_rect
.
h
);
sdl
->
overlay_rect
.
w
,
sdl
->
overlay_rect
.
h
);
SDL_UnlockMutex
(
sdl
->
mutex
);
return
0
;
return
0
;
}
}
...
...
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