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
5e2bfc33
Commit
5e2bfc33
authored
May 19, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sharpen: thread safety and don't retain useless value
parent
0925032f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
19 deletions
+21
-19
modules/video_filter/sharpen.c
modules/video_filter/sharpen.c
+21
-19
No files found.
modules/video_filter/sharpen.c
View file @
5e2bfc33
...
...
@@ -87,7 +87,7 @@ static const char *const ppsz_filter_options[] = {
struct
filter_sys_t
{
float
f_sigma
;
vlc_mutex_t
lock
;
int
tab_precalc
[
512
];
};
...
...
@@ -99,10 +99,8 @@ inline static int32_t clip( int32_t a )
return
(
a
>
255
)
?
255
:
(
a
<
0
)
?
0
:
a
;
}
static
void
init_precalc_table
(
filter_sys_t
*
p_filter
)
static
void
init_precalc_table
(
filter_sys_t
*
p_filter
,
float
sigma
)
{
float
sigma
=
p_filter
->
f_sigma
;
for
(
int
i
=
0
;
i
<
512
;
++
i
)
{
p_filter
->
tab_precalc
[
i
]
=
(
i
-
256
)
*
sigma
;
...
...
@@ -128,13 +126,13 @@ static int Create( vlc_object_t *p_this )
config_ChainParse
(
p_filter
,
FILTER_PREFIX
,
ppsz_filter_options
,
p_filter
->
p_cfg
);
p_filter
->
p_sys
->
f_sigma
=
var_CreateGetFloatCommand
(
p_filter
,
FILTER_PREFIX
"sigma"
);
float
sigma
=
var_CreateGetFloatCommand
(
p_filter
,
FILTER_PREFIX
"sigma"
);
init_precalc_table
(
p_filter
->
p_sys
,
sigma
);
vlc_mutex_init
(
&
p_filter
->
p_sys
->
lock
);
var_AddCallback
(
p_filter
,
FILTER_PREFIX
"sigma"
,
SharpenCallback
,
p_filter
->
p_sys
);
init_precalc_table
(
p_filter
->
p_sys
);
return
VLC_SUCCESS
;
}
...
...
@@ -147,9 +145,11 @@ static int Create( vlc_object_t *p_this )
static
void
Destroy
(
vlc_object_t
*
p_this
)
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
var_DelCallback
(
p_filter
,
FILTER_PREFIX
"sigma"
,
SharpenCallback
,
p_filter
->
p_sys
);
free
(
p_filter
->
p_sys
);
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
var_DelCallback
(
p_filter
,
FILTER_PREFIX
"sigma"
,
SharpenCallback
,
p_sys
);
vlc_mutex_destroy
(
&
p_sys
->
lock
);
free
(
p_sys
);
}
/*****************************************************************************
...
...
@@ -185,6 +185,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
i_src_pitch
=
p_pic
->
p
[
Y_PLANE
].
i_visible_pitch
;
/* perform convolution only on Y plane. Avoid border line. */
vlc_mutex_lock
(
&
p_filter
->
p_sys
->
lock
);
for
(
i
=
0
;
i
<
p_pic
->
p
[
Y_PLANE
].
i_visible_lines
;
i
++
)
{
if
(
(
i
==
0
)
||
(
i
==
p_pic
->
p
[
Y_PLANE
].
i_visible_lines
-
1
)
)
...
...
@@ -211,12 +212,12 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
(
p_src
[(
i
+
1
)
*
i_src_pitch
+
j
]
*
v1
)
+
(
p_src
[(
i
+
1
)
*
i_src_pitch
+
j
+
1
]
*
v1
);
pix
=
pix
>=
0
?
clip
(
pix
)
:
-
clip
(
pix
*
-
1
);
p_out
[
i
*
i_src_pitch
+
j
]
=
clip
(
p_src
[
i
*
i_src_pitch
+
j
]
+
p_filter
->
p_sys
->
tab_precalc
[
pix
+
256
]
);
pix
=
pix
>=
0
?
clip
(
pix
)
:
-
clip
(
pix
*
-
1
);
p_out
[
i
*
i_src_pitch
+
j
]
=
clip
(
p_src
[
i
*
i_src_pitch
+
j
]
+
p_filter
->
p_sys
->
tab_precalc
[
pix
+
256
]
);
}
}
vlc_mutex_unlock
(
&
p_filter
->
p_sys
->
lock
);
vlc_memcpy
(
p_outpic
->
p
[
U_PLANE
].
p_pixels
,
p_pic
->
p
[
U_PLANE
].
p_pixels
,
p_outpic
->
p
[
U_PLANE
].
i_lines
*
p_outpic
->
p
[
U_PLANE
].
i_pitch
);
...
...
@@ -232,10 +233,11 @@ static int SharpenCallback( vlc_object_t *p_this, char const *psz_var,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
{
VLC_UNUSED
(
p_this
);
VLC_UNUSED
(
oldval
);
VLC_UNUSED
(
p_this
);
VLC_UNUSED
(
oldval
);
VLC_UNUSED
(
psz_var
);
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
p_data
;
if
(
!
strcmp
(
psz_var
,
FILTER_PREFIX
"sigma"
)
)
p_sys
->
f_sigma
=
__MIN
(
2
.,
__MAX
(
0
.,
newval
.
f_float
)
);
init_precalc_table
(
p_sys
);
vlc_mutex_lock
(
&
p_sys
->
lock
);
init_precalc_table
(
p_sys
,
__MIN
(
2
.,
__MAX
(
0
.,
newval
.
f_float
)
));
vlc_mutex_unlock
(
&
p_sys
->
lock
);
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