Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
d242e5e8
Commit
d242e5e8
authored
May 19, 2010
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed crop behavior (with a ratio) after AR changes.
parent
0e70f9ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
28 deletions
+42
-28
src/video_output/display.c
src/video_output/display.c
+38
-1
src/video_output/video_output.c
src/video_output/video_output.c
+4
-27
No files found.
src/video_output/display.c
View file @
d242e5e8
...
...
@@ -673,6 +673,29 @@ static void VoutDisplayFitWindow(vout_display_t *vd, bool default_size)
vlc_mutex_unlock
(
&
osys
->
lock
);
}
static
void
VoutDisplayCropRatio
(
unsigned
*
x
,
unsigned
*
y
,
unsigned
*
width
,
unsigned
*
height
,
const
video_format_t
*
source
,
unsigned
num
,
unsigned
den
)
{
unsigned
scaled_width
=
(
uint64_t
)
source
->
i_visible_height
*
num
*
source
->
i_sar_den
/
den
/
source
->
i_sar_num
;
unsigned
scaled_height
=
(
uint64_t
)
source
->
i_visible_width
*
den
*
source
->
i_sar_num
/
num
/
source
->
i_sar_den
;
if
(
scaled_width
<
source
->
i_visible_width
)
{
*
x
=
(
source
->
i_visible_width
-
scaled_width
)
/
2
;
*
y
=
0
;
*
width
=
scaled_width
;
*
height
=
source
->
i_visible_height
;
}
else
{
*
x
=
0
;
*
y
=
(
source
->
i_visible_height
-
scaled_height
)
/
2
;
*
width
=
source
->
i_visible_width
;
*
height
=
scaled_height
;
}
*
x
+=
source
->
i_x_offset
;
*
y
+=
source
->
i_y_offset
;
}
void
vout_ManageDisplay
(
vout_display_t
*
vd
,
bool
allow_reset_pictures
)
{
vout_display_owner_sys_t
*
osys
=
vd
->
owner
.
sys
;
...
...
@@ -888,12 +911,24 @@ void vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
65536
);
vout_SendEventSourceAspect
(
osys
->
vout
,
dar_num
,
dar_den
);
}
/* If a crop ratio is requested, recompute the parameters */
if
(
osys
->
crop
.
num
>
0
&&
osys
->
crop
.
den
>
0
)
osys
->
ch_crop
=
true
;
}
/* */
if
(
osys
->
ch_crop
)
{
video_format_t
source
=
vd
->
source
;
unsigned
crop_num
=
osys
->
crop
.
num
;
unsigned
crop_den
=
osys
->
crop
.
den
;
if
(
crop_num
>
0
&&
crop_den
>
0
)
{
video_format_t
fmt
=
osys
->
source
;
fmt
.
i_sar_num
=
source
.
i_sar_num
;
fmt
.
i_sar_den
=
source
.
i_sar_den
;
VoutDisplayCropRatio
(
&
osys
->
crop
.
x
,
&
osys
->
crop
.
y
,
&
osys
->
crop
.
width
,
&
osys
->
crop
.
height
,
&
fmt
,
crop_num
,
crop_den
);
}
source
.
i_x_offset
=
osys
->
crop
.
x
;
source
.
i_y_offset
=
osys
->
crop
.
y
;
...
...
@@ -1043,7 +1078,9 @@ void vout_SetDisplayCrop(vout_display_t *vd,
vout_display_owner_sys_t
*
osys
=
vd
->
owner
.
sys
;
if
(
osys
->
crop
.
x
!=
x
||
osys
->
crop
.
y
!=
y
||
osys
->
crop
.
width
!=
width
||
osys
->
crop
.
height
!=
height
)
{
osys
->
crop
.
width
!=
width
||
osys
->
crop
.
height
!=
height
||
(
crop_num
>
0
&&
crop_den
>
0
&&
(
crop_num
!=
osys
->
crop
.
num
||
crop_den
!=
osys
->
crop
.
den
)))
{
osys
->
crop
.
x
=
x
;
osys
->
crop
.
y
=
y
;
...
...
src/video_output/video_output.c
View file @
d242e5e8
...
...
@@ -839,33 +839,10 @@ static void ThreadExecuteCropRatio(vout_thread_t *vout,
unsigned
num
,
unsigned
den
)
{
const
video_format_t
*
source
=
&
vout
->
p
->
original
;
int
x
,
y
;
int
width
,
height
;
if
(
num
<=
0
||
den
<=
0
)
{
num
=
0
;
den
=
0
;
x
=
0
;
y
=
0
;
width
=
source
->
i_visible_width
;
height
=
source
->
i_visible_height
;
}
else
{
unsigned
scaled_width
=
(
uint64_t
)
source
->
i_visible_height
*
num
*
source
->
i_sar_den
/
den
/
source
->
i_sar_num
;
unsigned
scaled_height
=
(
uint64_t
)
source
->
i_visible_width
*
den
*
source
->
i_sar_num
/
num
/
source
->
i_sar_den
;
if
(
scaled_width
<
source
->
i_visible_width
)
{
x
=
(
source
->
i_visible_width
-
scaled_width
)
/
2
;
y
=
0
;
width
=
scaled_width
;
height
=
source
->
i_visible_height
;
}
else
{
x
=
0
;
y
=
(
source
->
i_visible_height
-
scaled_height
)
/
2
;
width
=
source
->
i_visible_width
;
height
=
scaled_height
;
}
}
ThreadExecuteCropWindow
(
vout
,
num
,
den
,
x
,
y
,
width
,
height
);
ThreadExecuteCropWindow
(
vout
,
num
,
den
,
0
,
0
,
source
->
i_visible_width
,
source
->
i_visible_height
);
}
static
int
ThreadInit
(
vout_thread_t
*
vout
)
...
...
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