Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
d1b93486
Commit
d1b93486
authored
Sep 11, 2008
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new canvas option to crop instead of padd to fit in canvas.
parent
ac732954
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
19 deletions
+63
-19
modules/video_filter/canvas.c
modules/video_filter/canvas.c
+63
-19
No files found.
modules/video_filter/canvas.c
View file @
d1b93486
...
...
@@ -53,6 +53,10 @@ static int alloc_init( filter_t *, void * );
#define ASPECT_TEXT N_( "Aspect ratio" )
#define ASPECT_LONGTEXT N_( \
"Set aspect (like 4:3) of the video canvas" )
#define PADD_TEXT N_( "Padd video" )
#define PADD_LONGTEXT N_( \
"If enabled, video will be padded to fit in canvas after scaling. " \
"Otherwise, video will be cropped to fix in canvas after scaling." )
#define CFG_PREFIX "canvas-"
...
...
@@ -71,10 +75,13 @@ vlc_module_begin();
add_string
(
CFG_PREFIX
"aspect"
,
"4:3"
,
NULL
,
ASPECT_TEXT
,
ASPECT_LONGTEXT
,
false
);
add_bool
(
CFG_PREFIX
"padd"
,
true
,
NULL
,
PADD_TEXT
,
PADD_LONGTEXT
,
false
);
vlc_module_end
();
static
const
char
*
const
ppsz_filter_options
[]
=
{
"width"
,
"height"
,
"aspect"
,
NULL
"width"
,
"height"
,
"aspect"
,
"padd"
,
NULL
};
struct
filter_sys_t
...
...
@@ -94,6 +101,7 @@ static int Activate( vlc_object_t *p_this )
int
i_padd
,
i_offset
;
char
*
psz_aspect
,
*
psz_parser
;
int
i_aspect
;
bool
b_padd
;
if
(
!
p_filter
->
b_allow_fmt_out_change
)
{
...
...
@@ -145,6 +153,8 @@ static int Activate( vlc_object_t *p_this )
return
VLC_EGENERIC
;
}
b_padd
=
var_CreateGetBool
(
p_filter
,
CFG_PREFIX
"padd"
);
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
malloc
(
sizeof
(
filter_sys_t
)
);
if
(
!
p_sys
)
return
VLC_ENOMEM
;
...
...
@@ -166,28 +176,62 @@ static int Activate( vlc_object_t *p_this )
/
p_filter
->
fmt_in
.
video
.
i_width
;
fmt
.
video
.
i_height
=
(
fmt
.
video
.
i_height
*
i_aspect
)
/
p_filter
->
fmt_in
.
video
.
i_aspect
;
if
(
fmt
.
video
.
i_height
>
i_height
)
if
(
b_padd
)
{
fmt
.
video
.
i_height
=
i_height
;
fmt
.
video
.
i_width
=
(
p_filter
->
fmt_in
.
video
.
i_width
*
i_height
)
/
p_filter
->
fmt_in
.
video
.
i_height
;
fmt
.
video
.
i_width
=
(
fmt
.
video
.
i_width
*
p_filter
->
fmt_in
.
video
.
i_aspect
)
/
i_aspect
;
if
(
fmt
.
video
.
i_width
&
1
)
fmt
.
video
.
i_width
-=
1
;
i_padd
=
(
i_width
-
fmt
.
video
.
i_width
)
/
2
;
i_offset
=
(
i_padd
&
1
);
/* Gruik */
snprintf
(
psz_croppadd
,
100
,
"croppadd{paddleft=%d,paddright=%d}"
,
i_padd
-
i_offset
,
i_padd
+
i_offset
);
/* Padd */
if
(
fmt
.
video
.
i_height
>
i_height
)
{
fmt
.
video
.
i_height
=
i_height
;
fmt
.
video
.
i_width
=
(
p_filter
->
fmt_in
.
video
.
i_width
*
i_height
)
/
p_filter
->
fmt_in
.
video
.
i_height
;
fmt
.
video
.
i_width
=
(
fmt
.
video
.
i_width
*
p_filter
->
fmt_in
.
video
.
i_aspect
)
/
i_aspect
;
if
(
fmt
.
video
.
i_width
&
1
)
fmt
.
video
.
i_width
-=
1
;
i_padd
=
(
i_width
-
fmt
.
video
.
i_width
)
/
2
;
i_offset
=
(
i_padd
&
1
);
/* Gruik */
snprintf
(
psz_croppadd
,
100
,
"croppadd{paddleft=%d,paddright=%d}"
,
i_padd
-
i_offset
,
i_padd
+
i_offset
);
}
else
{
if
(
fmt
.
video
.
i_height
&
1
)
fmt
.
video
.
i_height
-=
1
;
i_padd
=
(
i_height
-
fmt
.
video
.
i_height
)
/
2
;
i_offset
=
(
i_padd
&
1
);
/* Gruik */
snprintf
(
psz_croppadd
,
100
,
"croppadd{paddtop=%d,paddbottom=%d}"
,
i_padd
-
i_offset
,
i_padd
+
i_offset
);
}
}
else
{
if
(
fmt
.
video
.
i_height
&
1
)
fmt
.
video
.
i_height
-=
1
;
i_padd
=
(
i_height
-
fmt
.
video
.
i_height
)
/
2
;
i_offset
=
(
i_padd
&
1
);
/* Gruik */
snprintf
(
psz_croppadd
,
100
,
"croppadd{paddtop=%d,paddbottom=%d}"
,
i_padd
-
i_offset
,
i_padd
+
i_offset
);
/* Crop */
if
(
fmt
.
video
.
i_height
<
i_height
)
{
fmt
.
video
.
i_height
=
i_height
;
fmt
.
video
.
i_width
=
(
p_filter
->
fmt_in
.
video
.
i_width
*
i_height
)
/
p_filter
->
fmt_in
.
video
.
i_height
;
fmt
.
video
.
i_width
=
(
fmt
.
video
.
i_width
*
p_filter
->
fmt_in
.
video
.
i_aspect
)
/
i_aspect
;
if
(
fmt
.
video
.
i_width
&
1
)
fmt
.
video
.
i_width
-=
1
;
i_padd
=
(
fmt
.
video
.
i_width
-
i_width
)
/
2
;
i_offset
=
(
i_padd
&
1
);
/* Gruik */
snprintf
(
psz_croppadd
,
100
,
"croppadd{cropleft=%d,cropright=%d}"
,
i_padd
-
i_offset
,
i_padd
+
i_offset
);
}
else
{
if
(
fmt
.
video
.
i_height
&
1
)
fmt
.
video
.
i_height
-=
1
;
i_padd
=
(
fmt
.
video
.
i_height
-
i_height
)
/
2
;
i_offset
=
(
i_padd
&
1
);
/* Gruik */
snprintf
(
psz_croppadd
,
100
,
"croppadd{croptop=%d,cropbottom=%d}"
,
i_padd
-
i_offset
,
i_padd
+
i_offset
);
}
}
fmt
.
video
.
i_visible_width
=
fmt
.
video
.
i_width
;
...
...
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