Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
0464d272
Commit
0464d272
authored
Nov 25, 2013
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavd/sdl: move compute_overlay_rect() before event_thread()
It will be used in event_thread() in a pending patch.
parent
7467b4f7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
40 deletions
+40
-40
sdl.c
libavdevice/sdl.c
+40
-40
No files found.
libavdevice/sdl.c
View file @
0464d272
...
...
@@ -84,6 +84,46 @@ static int sdl_write_trailer(AVFormatContext *s)
return
0
;
}
static
void
compute_overlay_rect
(
AVFormatContext
*
s
)
{
AVRational
sar
,
dar
;
/* sample and display aspect ratios */
SDLContext
*
sdl
=
s
->
priv_data
;
AVStream
*
st
=
s
->
streams
[
0
];
AVCodecContext
*
encctx
=
st
->
codec
;
SDL_Rect
*
overlay_rect
=
&
sdl
->
overlay_rect
;
/* compute overlay width and height from the codec context information */
sar
=
st
->
sample_aspect_ratio
.
num
?
st
->
sample_aspect_ratio
:
(
AVRational
){
1
,
1
};
dar
=
av_mul_q
(
sar
,
(
AVRational
){
encctx
->
width
,
encctx
->
height
});
/* we suppose the screen has a 1/1 sample aspect ratio */
if
(
sdl
->
window_width
&&
sdl
->
window_height
)
{
/* fit in the window */
if
(
av_cmp_q
(
dar
,
(
AVRational
){
sdl
->
window_width
,
sdl
->
window_height
})
>
0
)
{
/* fit in width */
overlay_rect
->
w
=
sdl
->
window_width
;
overlay_rect
->
h
=
av_rescale
(
overlay_rect
->
w
,
dar
.
den
,
dar
.
num
);
}
else
{
/* fit in height */
overlay_rect
->
h
=
sdl
->
window_height
;
overlay_rect
->
w
=
av_rescale
(
overlay_rect
->
h
,
dar
.
num
,
dar
.
den
);
}
}
else
{
if
(
sar
.
num
>
sar
.
den
)
{
overlay_rect
->
w
=
encctx
->
width
;
overlay_rect
->
h
=
av_rescale
(
overlay_rect
->
w
,
dar
.
den
,
dar
.
num
);
}
else
{
overlay_rect
->
h
=
encctx
->
height
;
overlay_rect
->
w
=
av_rescale
(
overlay_rect
->
h
,
dar
.
num
,
dar
.
den
);
}
sdl
->
window_width
=
overlay_rect
->
w
;
sdl
->
window_height
=
overlay_rect
->
h
;
}
overlay_rect
->
x
=
(
sdl
->
window_width
-
overlay_rect
->
w
)
/
2
;
overlay_rect
->
y
=
(
sdl
->
window_height
-
overlay_rect
->
h
)
/
2
;
}
static
int
event_thread
(
void
*
arg
)
{
AVFormatContext
*
s
=
arg
;
...
...
@@ -163,46 +203,6 @@ init_end:
return
0
;
}
static
void
compute_overlay_rect
(
AVFormatContext
*
s
)
{
AVRational
sar
,
dar
;
/* sample and display aspect ratios */
SDLContext
*
sdl
=
s
->
priv_data
;
AVStream
*
st
=
s
->
streams
[
0
];
AVCodecContext
*
encctx
=
st
->
codec
;
SDL_Rect
*
overlay_rect
=
&
sdl
->
overlay_rect
;
/* compute overlay width and height from the codec context information */
sar
=
st
->
sample_aspect_ratio
.
num
?
st
->
sample_aspect_ratio
:
(
AVRational
){
1
,
1
};
dar
=
av_mul_q
(
sar
,
(
AVRational
){
encctx
->
width
,
encctx
->
height
});
/* we suppose the screen has a 1/1 sample aspect ratio */
if
(
sdl
->
window_width
&&
sdl
->
window_height
)
{
/* fit in the window */
if
(
av_cmp_q
(
dar
,
(
AVRational
){
sdl
->
window_width
,
sdl
->
window_height
})
>
0
)
{
/* fit in width */
overlay_rect
->
w
=
sdl
->
window_width
;
overlay_rect
->
h
=
av_rescale
(
overlay_rect
->
w
,
dar
.
den
,
dar
.
num
);
}
else
{
/* fit in height */
overlay_rect
->
h
=
sdl
->
window_height
;
overlay_rect
->
w
=
av_rescale
(
overlay_rect
->
h
,
dar
.
num
,
dar
.
den
);
}
}
else
{
if
(
sar
.
num
>
sar
.
den
)
{
overlay_rect
->
w
=
encctx
->
width
;
overlay_rect
->
h
=
av_rescale
(
overlay_rect
->
w
,
dar
.
den
,
dar
.
num
);
}
else
{
overlay_rect
->
h
=
encctx
->
height
;
overlay_rect
->
w
=
av_rescale
(
overlay_rect
->
h
,
dar
.
num
,
dar
.
den
);
}
sdl
->
window_width
=
overlay_rect
->
w
;
sdl
->
window_height
=
overlay_rect
->
h
;
}
overlay_rect
->
x
=
(
sdl
->
window_width
-
overlay_rect
->
w
)
/
2
;
overlay_rect
->
y
=
(
sdl
->
window_height
-
overlay_rect
->
h
)
/
2
;
}
static
int
sdl_write_header
(
AVFormatContext
*
s
)
{
SDLContext
*
sdl
=
s
->
priv_data
;
...
...
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