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
a458b6af
Commit
a458b6af
authored
Jun 22, 2008
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New canvas video filter.
parent
43019afa
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
226 additions
and
0 deletions
+226
-0
configure.ac
configure.ac
+1
-0
modules/video_filter/Modules.am
modules/video_filter/Modules.am
+1
-0
modules/video_filter/canvas.c
modules/video_filter/canvas.c
+224
-0
No files found.
configure.ac
View file @
a458b6af
...
@@ -1133,6 +1133,7 @@ VLC_ADD_PLUGIN([extract])
...
@@ -1133,6 +1133,7 @@ VLC_ADD_PLUGIN([extract])
VLC_ADD_PLUGIN([sharpen])
VLC_ADD_PLUGIN([sharpen])
VLC_ADD_PLUGIN([seamcarving])
VLC_ADD_PLUGIN([seamcarving])
VLC_ADD_PLUGIN([croppadd])
VLC_ADD_PLUGIN([croppadd])
VLC_ADD_PLUGIN([canvas])
VLC_ADD_PLUGIN([blendbench])
VLC_ADD_PLUGIN([blendbench])
VLC_ADD_PLUGIN([blend])
VLC_ADD_PLUGIN([blend])
VLC_ADD_PLUGIN([scale])
VLC_ADD_PLUGIN([scale])
...
...
modules/video_filter/Modules.am
View file @
a458b6af
...
@@ -38,6 +38,7 @@ SOURCES_gaussianblur = gaussianblur.c
...
@@ -38,6 +38,7 @@ SOURCES_gaussianblur = gaussianblur.c
SOURCES_grain = grain.c
SOURCES_grain = grain.c
SOURCES_seamcarving = seamcarving.c
SOURCES_seamcarving = seamcarving.c
SOURCES_croppadd = croppadd.c
SOURCES_croppadd = croppadd.c
SOURCES_canvas = canvas.c
SOURCES_blendbench = blendbench.c
SOURCES_blendbench = blendbench.c
SOURCES_chain = chain.c
SOURCES_chain = chain.c
SOURCES_postproc = postproc.c
SOURCES_postproc = postproc.c
...
...
modules/video_filter/canvas.c
0 → 100644
View file @
a458b6af
/*****************************************************************************
* canvas.c : automatically resize and padd a video to fit in canvas
*****************************************************************************
* Copyright (C) 2008 the VideoLAN team
* $Id$
*
* Authors: Antoine Cellerier <dionoea at videolan dot org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <limits.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_filter.h>
#include <vlc_vout.h>
/*****************************************************************************
* Local and extern prototypes.
*****************************************************************************/
static
int
Activate
(
vlc_object_t
*
);
static
void
Destroy
(
vlc_object_t
*
);
static
picture_t
*
Filter
(
filter_t
*
,
picture_t
*
);
static
int
alloc_init
(
filter_t
*
,
void
*
);
#define WIDTH_TEXT N_( "Image width" )
#define WIDTH_LONGTEXT N_( \
"Image width" )
#define HEIGHT_TEXT N_( "Image height" )
#define HEIGHT_LONGTEXT N_( \
"Image height" )
#define CFG_PREFIX "canvas-"
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin
();
set_description
(
N_
(
"Automatically resize and padd a video"
)
);
set_capability
(
"video filter2"
,
0
);
set_callbacks
(
Activate
,
Destroy
);
add_integer_with_range
(
CFG_PREFIX
"width"
,
0
,
0
,
INT_MAX
,
NULL
,
WIDTH_TEXT
,
WIDTH_LONGTEXT
,
false
);
add_integer_with_range
(
CFG_PREFIX
"height"
,
0
,
0
,
INT_MAX
,
NULL
,
HEIGHT_TEXT
,
HEIGHT_LONGTEXT
,
false
);
vlc_module_end
();
static
const
char
*
const
ppsz_filter_options
[]
=
{
"width"
,
"height"
,
NULL
};
struct
filter_sys_t
{
filter_chain_t
*
p_chain
;
};
/*****************************************************************************
*
*****************************************************************************/
static
int
Activate
(
vlc_object_t
*
p_this
)
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
unsigned
int
i_width
,
i_height
;
es_format_t
fmt
;
char
psz_croppadd
[
100
];
int
i_padd
;
if
(
!
p_filter
->
b_allow_fmt_out_change
)
{
msg_Err
(
p_filter
,
"Picture format change isn't allowed"
);
return
VLC_EGENERIC
;
}
if
(
p_filter
->
fmt_in
.
video
.
i_chroma
!=
p_filter
->
fmt_out
.
video
.
i_chroma
)
{
msg_Err
(
p_filter
,
"Input and output chromas don't match"
);
return
VLC_EGENERIC
;
}
config_ChainParse
(
p_filter
,
CFG_PREFIX
,
ppsz_filter_options
,
p_filter
->
p_cfg
);
i_width
=
var_CreateGetInteger
(
p_filter
,
CFG_PREFIX
"width"
);
i_height
=
var_CreateGetInteger
(
p_filter
,
CFG_PREFIX
"height"
);
if
(
i_width
==
0
||
i_height
==
0
)
{
msg_Err
(
p_filter
,
"Width and height options must be set"
);
return
VLC_EGENERIC
;
}
if
(
i_width
&
1
||
i_height
&
1
)
{
msg_Err
(
p_filter
,
"Width and height options must be even integers"
);
return
VLC_EGENERIC
;
}
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
malloc
(
sizeof
(
filter_sys_t
)
);
if
(
!
p_sys
)
return
VLC_ENOMEM
;
p_filter
->
p_sys
=
p_sys
;
p_sys
->
p_chain
=
filter_chain_New
(
p_filter
,
"video filter2"
,
true
,
alloc_init
,
NULL
,
p_filter
);
if
(
!
p_sys
->
p_chain
)
{
msg_Err
(
p_filter
,
"Could not allocate filter chain"
);
free
(
p_sys
);
return
VLC_EGENERIC
;
}
es_format_Copy
(
&
fmt
,
&
p_filter
->
fmt_in
);
fmt
.
video
.
i_width
=
i_width
;
fmt
.
video
.
i_height
=
(
p_filter
->
fmt_in
.
video
.
i_height
*
i_width
)
/
p_filter
->
fmt_in
.
video
.
i_width
;
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
;
if
(
fmt
.
video
.
i_width
&
1
)
fmt
.
video
.
i_width
-=
1
;
i_padd
=
i_width
-
fmt
.
video
.
i_width
;
/* Gruik */
snprintf
(
psz_croppadd
,
100
,
"croppadd{paddleft=%d,paddright=%d}"
,
i_padd
/
2
,
(
i_padd
+
1
)
/
2
);
}
else
{
if
(
fmt
.
video
.
i_height
&
1
)
fmt
.
video
.
i_height
-=
1
;
i_padd
=
i_height
-
fmt
.
video
.
i_height
;
/* Gruik */
snprintf
(
psz_croppadd
,
100
,
"croppadd{paddtop=%d,paddbottom=%d}"
,
i_padd
/
2
,
(
i_padd
+
1
)
/
2
);
}
fmt
.
video
.
i_visible_width
=
fmt
.
video
.
i_width
;
fmt
.
video
.
i_visible_height
=
fmt
.
video
.
i_height
;
filter_chain_Reset
(
p_sys
->
p_chain
,
&
p_filter
->
fmt_in
,
&
fmt
);
/* Append scaling module */
filter_chain_AppendFilter
(
p_sys
->
p_chain
,
NULL
,
NULL
,
NULL
,
NULL
);
/* Append padding module */
filter_chain_AppendFromString
(
p_sys
->
p_chain
,
psz_croppadd
);
fmt
=
*
filter_chain_GetFmtOut
(
p_sys
->
p_chain
);
es_format_Copy
(
&
p_filter
->
fmt_out
,
&
fmt
);
if
(
p_filter
->
fmt_out
.
video
.
i_width
!=
i_width
||
p_filter
->
fmt_out
.
video
.
i_height
!=
i_height
)
{
msg_Warn
(
p_filter
,
"Looks like something went wrong. "
"Output size is %dx%d while we asked for %dx%d"
,
p_filter
->
fmt_out
.
video
.
i_width
,
p_filter
->
fmt_out
.
video
.
i_height
,
i_width
,
i_height
);
}
p_filter
->
pf_video_filter
=
Filter
;
return
VLC_SUCCESS
;
}
/*****************************************************************************
*
*****************************************************************************/
static
void
Destroy
(
vlc_object_t
*
p_this
)
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_chain_Delete
(
p_filter
->
p_sys
->
p_chain
);
free
(
p_filter
->
p_sys
);
}
/*****************************************************************************
*
*****************************************************************************/
static
picture_t
*
Filter
(
filter_t
*
p_filter
,
picture_t
*
p_pic
)
{
return
filter_chain_VideoFilter
(
p_filter
->
p_sys
->
p_chain
,
p_pic
);
}
/*****************************************************************************
*
*****************************************************************************/
static
picture_t
*
video_new
(
filter_t
*
p_filter
)
{
return
((
filter_t
*
)
p_filter
->
p_owner
)
->
pf_vout_buffer_new
(
(
filter_t
*
)
p_filter
->
p_owner
);
}
static
void
video_del
(
filter_t
*
p_filter
,
picture_t
*
p_pic
)
{
if
(
((
filter_t
*
)
p_filter
->
p_owner
)
->
pf_vout_buffer_del
)
((
filter_t
*
)
p_filter
->
p_owner
)
->
pf_vout_buffer_del
(
(
filter_t
*
)
p_filter
->
p_owner
,
p_pic
);
}
static
int
alloc_init
(
filter_t
*
p_filter
,
void
*
p_data
)
{
p_filter
->
p_owner
=
p_data
;
p_filter
->
pf_vout_buffer_new
=
video_new
;
p_filter
->
pf_vout_buffer_del
=
video_del
;
return
VLC_SUCCESS
;
}
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