Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Steve Lhomme
VLC
Commits
3b555903
Commit
3b555903
authored
Oct 15, 2020
by
Steve Lhomme
Browse files
video_filter: add epileptic filter
An extra inverted picture is sent for every picture given.
parent
b0951e57
Changes
2
Hide whitespace changes
Inline
Side-by-side
modules/video_filter/Makefile.am
View file @
3b555903
...
...
@@ -18,6 +18,7 @@ libcanvas_plugin_la_SOURCES = video_filter/canvas.c
libcolorthres_plugin_la_SOURCES
=
video_filter/colorthres.c
libcolorthres_plugin_la_LIBADD
=
$(LIBM)
libcroppadd_plugin_la_SOURCES
=
video_filter/croppadd.c
libepileptic_plugin_la_SOURCES
=
video_filter/epileptic.c
liberase_plugin_la_SOURCES
=
video_filter/erase.c
libextract_plugin_la_SOURCES
=
video_filter/extract.c
libextract_plugin_la_LIBADD
=
$(LIBM)
...
...
@@ -79,6 +80,7 @@ video_filter_LTLIBRARIES = \
libcolorthres_plugin.la
\
libcroppadd_plugin.la
\
libedgedetection_plugin.la
\
libepileptic_plugin.la
\
liberase_plugin.la
\
libextract_plugin.la
\
libgradient_plugin.la
\
...
...
modules/video_filter/epileptic.c
0 → 100644
View file @
3b555903
/*****************************************************************************
* epileptic.c : Video filter inserting an inverting picture to every frame
*****************************************************************************
* Copyright © 2020 VLC authors, VideoLAN and VideoLabs
*
* Authors: Steve Lhomme <robux4@ycbcr.xyz>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include
<vlc_common.h>
#include
<vlc_plugin.h>
#include
<vlc_filter.h>
#include
<vlc_modules.h>
static
int
Create
(
filter_t
*
);
vlc_module_begin
()
set_description
(
N_
(
"Epileptic effect video filter"
)
)
set_shortname
(
N_
(
"Epileptic effect"
))
set_category
(
CAT_VIDEO
)
set_subcategory
(
SUBCAT_VIDEO_VFILTER
)
add_shortcut
(
"epileptic"
)
set_callback_video_filter
(
Create
)
vlc_module_end
()
typedef
struct
{
filter_t
*
inverter
;
}
filter_sys_t
;
static
filter_t
*
CreateInverter
(
vlc_object_t
*
object
,
const
video_format_t
*
fmt
)
{
filter_t
*
filter
=
vlc_object_create
(
object
,
sizeof
(
*
filter
));
if
(
!
filter
)
return
NULL
;
es_format_InitFromVideo
(
&
filter
->
fmt_in
,
fmt
);
es_format_InitFromVideo
(
&
filter
->
fmt_out
,
fmt
);
filter
->
p_module
=
module_need
(
filter
,
"video filter"
,
"invert"
,
false
);
if
(
!
filter
->
p_module
)
{
vlc_object_delete
(
filter
);
return
NULL
;
}
assert
(
filter
->
ops
!=
NULL
);
return
filter
;
}
static
picture_t
*
Filter
(
filter_t
*
p_filter
,
picture_t
*
p_pic
)
{
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
picture_Hold
(
p_pic
);
// the inverter will release the source
picture_t
*
inverted
=
p_sys
->
inverter
->
ops
->
filter_video
(
p_sys
->
inverter
,
p_pic
);
if
(
inverted
)
{
inverted
->
date
+=
vlc_tick_from_samples
(
p_filter
->
fmt_out
.
video
.
i_frame_rate_base
,
p_filter
->
fmt_out
.
video
.
i_frame_rate
);
vlc_picture_chain_AppendChain
(
p_pic
,
inverted
);
}
return
p_pic
;
}
static
void
Close
(
filter_t
*
p_filter
)
{
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
filter_Close
(
p_sys
->
inverter
);
module_unneed
(
p_sys
->
inverter
,
p_sys
->
inverter
->
p_module
);
vlc_object_delete
(
p_sys
->
inverter
);
}
static
struct
vlc_filter_operations
filter_ops
=
{
.
filter_video
=
Filter
,
.
close
=
Close
,
};
static
int
Create
(
filter_t
*
p_filter
)
{
if
(
!
p_filter
->
b_allow_fmt_out_change
)
return
VLC_EGENERIC
;
if
(
p_filter
->
fmt_out
.
video
.
i_frame_rate
==
0
)
{
msg_Err
(
p_filter
,
"input frame rate needed"
);
return
VLC_EGENERIC
;
}
filter_sys_t
*
p_sys
=
vlc_obj_malloc
(
VLC_OBJECT
(
p_filter
),
sizeof
(
*
p_filter
));
if
(
unlikely
(
p_sys
==
NULL
))
return
VLC_EGENERIC
;
p_sys
->
inverter
=
CreateInverter
(
VLC_OBJECT
(
p_filter
),
&
p_filter
->
fmt_in
.
video
);
if
(
p_sys
->
inverter
==
NULL
)
{
vlc_obj_free
(
VLC_OBJECT
(
p_filter
),
p_sys
);
return
VLC_ENOMOD
;
}
p_filter
->
fmt_out
.
video
.
i_frame_rate
*=
2
;
p_filter
->
p_sys
=
p_sys
;
p_filter
->
ops
=
&
filter_ops
;
return
VLC_SUCCESS
;
}
Write
Preview
Supports
Markdown
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