Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
59a3e76c
Commit
59a3e76c
authored
Nov 23, 2013
by
Ilkka Ollakka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
canvas: use visible width/height on calculations
parent
61466e06
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
32 deletions
+33
-32
modules/video_filter/canvas.c
modules/video_filter/canvas.c
+33
-32
No files found.
modules/video_filter/canvas.c
View file @
59a3e76c
...
@@ -138,8 +138,8 @@ struct filter_sys_t
...
@@ -138,8 +138,8 @@ struct filter_sys_t
static
int
Activate
(
vlc_object_t
*
p_this
)
static
int
Activate
(
vlc_object_t
*
p_this
)
{
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
unsigned
i_canvas_width
;
/* width of output canvas */
unsigned
i_canvas_width
;
/*
visible
width of output canvas */
unsigned
i_canvas_height
;
/* height of output canvas */
unsigned
i_canvas_height
;
/*
visible
height of output canvas */
unsigned
i_canvas_aspect
;
/* canvas PictureAspectRatio */
unsigned
i_canvas_aspect
;
/* canvas PictureAspectRatio */
es_format_t
fmt
;
/* target format after up/down conversion */
es_format_t
fmt
;
/* target format after up/down conversion */
char
psz_croppadd
[
100
];
char
psz_croppadd
[
100
];
...
@@ -182,14 +182,14 @@ static int Activate( vlc_object_t *p_this )
...
@@ -182,14 +182,14 @@ static int Activate( vlc_object_t *p_this )
if
(
p_filter
->
fmt_in
.
video
.
i_sar_num
)
if
(
p_filter
->
fmt_in
.
video
.
i_sar_num
)
i_fmt_in_aspect
=
(
int64_t
)
p_filter
->
fmt_in
.
video
.
i_sar_num
*
i_fmt_in_aspect
=
(
int64_t
)
p_filter
->
fmt_in
.
video
.
i_sar_num
*
p_filter
->
fmt_in
.
video
.
i_width
*
p_filter
->
fmt_in
.
video
.
i_
visible_
width
*
VOUT_ASPECT_FACTOR
/
VOUT_ASPECT_FACTOR
/
p_filter
->
fmt_in
.
video
.
i_sar_den
/
p_filter
->
fmt_in
.
video
.
i_sar_den
/
p_filter
->
fmt_in
.
video
.
i_height
;
p_filter
->
fmt_in
.
video
.
i_
visible_
height
;
else
else
i_fmt_in_aspect
=
(
int64_t
)
p_filter
->
fmt_in
.
video
.
i_width
*
i_fmt_in_aspect
=
(
int64_t
)
p_filter
->
fmt_in
.
video
.
i_
visible_
width
*
VOUT_ASPECT_FACTOR
/
VOUT_ASPECT_FACTOR
/
p_filter
->
fmt_in
.
video
.
i_height
;
p_filter
->
fmt_in
.
video
.
i_
visible_
height
;
psz_aspect
=
var_CreateGetNonEmptyString
(
p_filter
,
CFG_PREFIX
"aspect"
);
psz_aspect
=
var_CreateGetNonEmptyString
(
p_filter
,
CFG_PREFIX
"aspect"
);
if
(
psz_aspect
)
if
(
psz_aspect
)
...
@@ -213,10 +213,10 @@ static int Activate( vlc_object_t *p_this )
...
@@ -213,10 +213,10 @@ static int Activate( vlc_object_t *p_this )
* has the same sample aspect ratio as the subpicture */
* has the same sample aspect ratio as the subpicture */
/* aspect = subpic_sar * canvas_width / canvas_height
/* aspect = subpic_sar * canvas_width / canvas_height
* where subpic_sar = subpic_ph * subpic_par / subpic_pw */
* where subpic_sar = subpic_ph * subpic_par / subpic_pw */
i_canvas_aspect
=
(
uint64_t
)
p_filter
->
fmt_in
.
video
.
i_height
i_canvas_aspect
=
(
uint64_t
)
p_filter
->
fmt_in
.
video
.
i_
visible_
height
*
i_fmt_in_aspect
*
i_fmt_in_aspect
*
i_canvas_width
*
i_canvas_width
/
(
i_canvas_height
*
p_filter
->
fmt_in
.
video
.
i_width
);
/
(
i_canvas_height
*
p_filter
->
fmt_in
.
video
.
i_
visible_
width
);
}
}
b_padd
=
var_CreateGetBool
(
p_filter
,
CFG_PREFIX
"padd"
);
b_padd
=
var_CreateGetBool
(
p_filter
,
CFG_PREFIX
"padd"
);
...
@@ -238,8 +238,8 @@ static int Activate( vlc_object_t *p_this )
...
@@ -238,8 +238,8 @@ static int Activate( vlc_object_t *p_this )
es_format_Copy
(
&
fmt
,
&
p_filter
->
fmt_in
);
es_format_Copy
(
&
fmt
,
&
p_filter
->
fmt_in
);
/* one dimension will end up with one of the following: */
/* one dimension will end up with one of the following: */
fmt
.
video
.
i_width
=
i_canvas_width
;
fmt
.
video
.
i_
visible_
width
=
i_canvas_width
;
fmt
.
video
.
i_height
=
i_canvas_height
;
fmt
.
video
.
i_
visible_
height
=
i_canvas_height
;
if
(
b_padd
)
if
(
b_padd
)
{
{
...
@@ -252,12 +252,12 @@ static int Activate( vlc_object_t *p_this )
...
@@ -252,12 +252,12 @@ static int Activate( vlc_object_t *p_this )
* width = upconverted_subpic_height * subpic_par / canvas_sar
* width = upconverted_subpic_height * subpic_par / canvas_sar
* where canvas_sar = canvas_width / (canvas_height * canvas_par)
* where canvas_sar = canvas_width / (canvas_height * canvas_par)
* then simplify */
* then simplify */
fmt
.
video
.
i_width
=
i_canvas_width
fmt
.
video
.
i_
visible_
width
=
i_canvas_width
*
i_fmt_in_aspect
*
i_fmt_in_aspect
/
i_canvas_aspect
;
/
i_canvas_aspect
;
if
(
fmt
.
video
.
i_
width
&
1
)
fmt
.
video
.
i
_width
-=
1
;
if
(
fmt
.
video
.
i_
visible_width
&
1
)
fmt
.
video
.
i_visible
_width
-=
1
;
i_padd
=
(
i_canvas_width
-
fmt
.
video
.
i_width
)
/
2
;
i_padd
=
(
i_canvas_width
-
fmt
.
video
.
i_
visible_
width
)
/
2
;
i_offset
=
(
i_padd
&
1
);
i_offset
=
(
i_padd
&
1
);
snprintf
(
psz_croppadd
,
100
,
"croppadd{paddleft=%d,paddright=%d}"
,
snprintf
(
psz_croppadd
,
100
,
"croppadd{paddleft=%d,paddright=%d}"
,
i_padd
-
i_offset
,
i_padd
+
i_offset
);
i_padd
-
i_offset
,
i_padd
+
i_offset
);
...
@@ -266,12 +266,12 @@ static int Activate( vlc_object_t *p_this )
...
@@ -266,12 +266,12 @@ static int Activate( vlc_object_t *p_this )
{
{
/* The canvas has a taller aspect than the subpicture:
/* The canvas has a taller aspect than the subpicture:
* ie, letterbox the [scaled] subpicture */
* ie, letterbox the [scaled] subpicture */
fmt
.
video
.
i_height
=
i_canvas_height
fmt
.
video
.
i_
visible_
height
=
i_canvas_height
*
i_canvas_aspect
*
i_canvas_aspect
/
i_fmt_in_aspect
;
/
i_fmt_in_aspect
;
if
(
fmt
.
video
.
i_
height
&
1
)
fmt
.
video
.
i
_height
-=
1
;
if
(
fmt
.
video
.
i_
visible_height
&
1
)
fmt
.
video
.
i_visible
_height
-=
1
;
i_padd
=
(
i_canvas_height
-
fmt
.
video
.
i_height
)
/
2
;
i_padd
=
(
i_canvas_height
-
fmt
.
video
.
i_
visible_
height
)
/
2
;
i_offset
=
(
i_padd
&
1
);
i_offset
=
(
i_padd
&
1
);
snprintf
(
psz_croppadd
,
100
,
"croppadd{paddtop=%d,paddbottom=%d}"
,
snprintf
(
psz_croppadd
,
100
,
"croppadd{paddtop=%d,paddbottom=%d}"
,
i_padd
-
i_offset
,
i_padd
+
i_offset
);
i_padd
-
i_offset
,
i_padd
+
i_offset
);
...
@@ -284,12 +284,12 @@ static int Activate( vlc_object_t *p_this )
...
@@ -284,12 +284,12 @@ static int Activate( vlc_object_t *p_this )
{
{
/* The canvas has a narrower aspect than the subpicture:
/* The canvas has a narrower aspect than the subpicture:
* ie, crop the [scaled] subpicture horizontally */
* ie, crop the [scaled] subpicture horizontally */
fmt
.
video
.
i_width
=
i_canvas_width
fmt
.
video
.
i_
visible_
width
=
i_canvas_width
*
i_fmt_in_aspect
*
i_fmt_in_aspect
/
i_canvas_aspect
;
/
i_canvas_aspect
;
if
(
fmt
.
video
.
i_
width
&
1
)
fmt
.
video
.
i
_width
-=
1
;
if
(
fmt
.
video
.
i_
visible_width
&
1
)
fmt
.
video
.
i_visible
_width
-=
1
;
i_padd
=
(
fmt
.
video
.
i_width
-
i_canvas_width
)
/
2
;
i_padd
=
(
fmt
.
video
.
i_
visible_
width
-
i_canvas_width
)
/
2
;
i_offset
=
(
i_padd
&
1
);
i_offset
=
(
i_padd
&
1
);
snprintf
(
psz_croppadd
,
100
,
"croppadd{cropleft=%d,cropright=%d}"
,
snprintf
(
psz_croppadd
,
100
,
"croppadd{cropleft=%d,cropright=%d}"
,
i_padd
-
i_offset
,
i_padd
+
i_offset
);
i_padd
-
i_offset
,
i_padd
+
i_offset
);
...
@@ -298,12 +298,12 @@ static int Activate( vlc_object_t *p_this )
...
@@ -298,12 +298,12 @@ static int Activate( vlc_object_t *p_this )
{
{
/* The canvas has a shorter aspect than the subpicture:
/* The canvas has a shorter aspect than the subpicture:
* ie, crop the [scaled] subpicture vertically */
* ie, crop the [scaled] subpicture vertically */
fmt
.
video
.
i_height
=
i_canvas_height
fmt
.
video
.
i_
visible_
height
=
i_canvas_height
*
i_canvas_aspect
*
i_canvas_aspect
/
i_fmt_in_aspect
;
/
i_fmt_in_aspect
;
if
(
fmt
.
video
.
i_
height
&
1
)
fmt
.
video
.
i
_height
-=
1
;
if
(
fmt
.
video
.
i_
visible_height
&
1
)
fmt
.
video
.
i_visible
_height
-=
1
;
i_padd
=
(
fmt
.
video
.
i_height
-
i_canvas_height
)
/
2
;
i_padd
=
(
fmt
.
video
.
i_
visible_
height
-
i_canvas_height
)
/
2
;
i_offset
=
(
i_padd
&
1
);
i_offset
=
(
i_padd
&
1
);
snprintf
(
psz_croppadd
,
100
,
"croppadd{croptop=%d,cropbottom=%d}"
,
snprintf
(
psz_croppadd
,
100
,
"croppadd{croptop=%d,cropbottom=%d}"
,
i_padd
-
i_offset
,
i_padd
+
i_offset
);
i_padd
-
i_offset
,
i_padd
+
i_offset
);
...
@@ -314,8 +314,8 @@ static int Activate( vlc_object_t *p_this )
...
@@ -314,8 +314,8 @@ static int Activate( vlc_object_t *p_this )
* probably not, as some codecs can make use of that information
* probably not, as some codecs can make use of that information
* and it should be a scaled version of the input clean area
* and it should be a scaled version of the input clean area
* -- davidf */
* -- davidf */
fmt
.
video
.
i_
visible_width
=
fmt
.
video
.
i
_width
;
fmt
.
video
.
i_
width
=
p_filter
->
fmt_in
.
video
.
i_width
*
fmt
.
video
.
i_visible_width
/
p_filter
->
fmt_in
.
video
.
i_visible
_width
;
fmt
.
video
.
i_
visible_height
=
fmt
.
video
.
i
_height
;
fmt
.
video
.
i_
height
=
p_filter
->
fmt_in
.
video
.
i_height
*
fmt
.
video
.
i_visible_height
/
p_filter
->
fmt_in
.
video
.
i_visible
_height
;
filter_chain_Reset
(
p_sys
->
p_chain
,
&
p_filter
->
fmt_in
,
&
fmt
);
filter_chain_Reset
(
p_sys
->
p_chain
,
&
p_filter
->
fmt_in
,
&
fmt
);
/* Append scaling module */
/* Append scaling module */
...
@@ -326,18 +326,19 @@ static int Activate( vlc_object_t *p_this )
...
@@ -326,18 +326,19 @@ static int Activate( vlc_object_t *p_this )
fmt
=
*
filter_chain_GetFmtOut
(
p_sys
->
p_chain
);
fmt
=
*
filter_chain_GetFmtOut
(
p_sys
->
p_chain
);
es_format_Copy
(
&
p_filter
->
fmt_out
,
&
fmt
);
es_format_Copy
(
&
p_filter
->
fmt_out
,
&
fmt
);
p_filter
->
fmt_out
.
video
.
i_sar_num
=
vlc_ureduce
(
&
p_filter
->
fmt_out
.
video
.
i_sar_num
,
i_canvas_aspect
*
p_filter
->
fmt_out
.
video
.
i_height
;
&
p_filter
->
fmt_out
.
video
.
i_sar_den
,
p_filter
->
fmt_out
.
video
.
i_sar_den
=
i_canvas_aspect
*
p_filter
->
fmt_out
.
video
.
i_visible_height
,
VOUT_ASPECT_FACTOR
*
p_filter
->
fmt_out
.
video
.
i_width
;
VOUT_ASPECT_FACTOR
*
p_filter
->
fmt_out
.
video
.
i_visible_width
,
0
);
if
(
p_filter
->
fmt_out
.
video
.
i_width
!=
i_canvas_width
if
(
p_filter
->
fmt_out
.
video
.
i_
visible_
width
!=
i_canvas_width
||
p_filter
->
fmt_out
.
video
.
i_height
!=
i_canvas_height
)
||
p_filter
->
fmt_out
.
video
.
i_
visible_
height
!=
i_canvas_height
)
{
{
msg_Warn
(
p_filter
,
"Looks like something went wrong. "
msg_Warn
(
p_filter
,
"Looks like something went wrong. "
"Output size is %dx%d while we asked for %dx%d"
,
"Output size is %dx%d while we asked for %dx%d"
,
p_filter
->
fmt_out
.
video
.
i_width
,
p_filter
->
fmt_out
.
video
.
i_
visible_
width
,
p_filter
->
fmt_out
.
video
.
i_height
,
p_filter
->
fmt_out
.
video
.
i_
visible_
height
,
i_canvas_width
,
i_canvas_height
);
i_canvas_width
,
i_canvas_height
);
}
}
...
...
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