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
68dd76f1
Commit
68dd76f1
authored
Nov 19, 2009
by
Rémi Duraffort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
visual: save a huge number of allocation/deallocation.
parent
55348507
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
22 deletions
+34
-22
modules/visualization/visual/effects.c
modules/visualization/visual/effects.c
+30
-22
modules/visualization/visual/visual.c
modules/visualization/visual/visual.c
+1
-0
modules/visualization/visual/visual.h
modules/visualization/visual/visual.h
+3
-0
No files found.
modules/visualization/visual/effects.c
View file @
68dd76f1
...
...
@@ -100,25 +100,7 @@ int spectrum_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
int16_t
*
p_buffs
;
/* int16_t converted buffer */
int16_t
*
p_s16_buff
;
/* int16_t converted buffer */
p_s16_buff
=
malloc
(
p_buffer
->
i_nb_samples
*
p_effect
->
i_nb_chans
*
sizeof
(
int16_t
));
if
(
!
p_s16_buff
)
return
-
1
;
p_buffs
=
p_s16_buff
;
i_80_bands
=
config_GetInt
(
p_aout
,
"visual-80-bands"
);
i_peak
=
config_GetInt
(
p_aout
,
"visual-peaks"
);
if
(
i_80_bands
!=
0
)
{
xscale
=
xscale2
;
i_nb_bands
=
80
;
}
else
{
xscale
=
xscale1
;
i_nb_bands
=
20
;
}
/* Create p_data if needed */
if
(
!
p_data
)
{
p_effect
->
p_data
=
p_data
=
malloc
(
sizeof
(
spectrum_data
)
);
...
...
@@ -130,15 +112,43 @@ int spectrum_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
p_data
->
peaks
=
calloc
(
80
,
sizeof
(
int
)
);
p_data
->
prev_heights
=
calloc
(
80
,
sizeof
(
int
)
);
p_data
->
i_prev_nb_samples
=
0
;
p_data
->
p_prev_s16_buff
=
NULL
;
}
peaks
=
(
int
*
)
p_data
->
peaks
;
prev_heights
=
(
int
*
)
p_data
->
prev_heights
;
/* Allocate the buffer only if the number of samples change */
if
(
p_buffer
->
i_nb_samples
!=
p_data
->
i_prev_nb_samples
)
{
free
(
p_data
->
p_prev_s16_buff
);
p_data
->
p_prev_s16_buff
=
malloc
(
p_buffer
->
i_nb_samples
*
p_effect
->
i_nb_chans
*
sizeof
(
int16_t
));
p_data
->
i_prev_nb_samples
=
p_buffer
->
i_nb_samples
;
if
(
!
p_data
->
p_prev_s16_buff
)
return
-
1
;
}
p_buffs
=
p_s16_buff
=
p_data
->
p_prev_s16_buff
;
i_80_bands
=
config_GetInt
(
p_aout
,
"visual-80-bands"
);
i_peak
=
config_GetInt
(
p_aout
,
"visual-peaks"
);
if
(
i_80_bands
!=
0
)
{
xscale
=
xscale2
;
i_nb_bands
=
80
;
}
else
{
xscale
=
xscale1
;
i_nb_bands
=
20
;
}
height
=
malloc
(
i_nb_bands
*
sizeof
(
int
)
);
if
(
!
height
)
{
free
(
p_s16_buff
);
return
-
1
;
}
/* Convert the buffer to int16_t */
...
...
@@ -157,7 +167,6 @@ int spectrum_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
if
(
!
p_state
)
{
free
(
height
);
free
(
p_s16_buff
);
msg_Err
(
p_aout
,
"unable to initialize FFT transform"
);
return
-
1
;
}
...
...
@@ -321,7 +330,6 @@ int spectrum_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
fft_close
(
p_state
);
free
(
p_s16_buff
);
free
(
height
);
return
0
;
...
...
modules/visualization/visual/visual.c
View file @
68dd76f1
...
...
@@ -397,6 +397,7 @@ static void Close( vlc_object_t *p_this )
{
free
(
(
(
spectrum_data
*
)
p_effect
->
p_data
)
->
peaks
);
free
(
(
(
spectrum_data
*
)
p_effect
->
p_data
)
->
prev_heights
);
free
(
(
(
spectrum_data
*
)
p_effect
->
p_data
)
->
p_prev_s16_buff
);
}
free
(
p_effect
->
p_data
);
free
(
p_effect
->
psz_args
);
...
...
modules/visualization/visual/visual.h
View file @
68dd76f1
...
...
@@ -42,6 +42,9 @@ typedef struct spectrum_data
{
int
*
peaks
;
int
*
prev_heights
;
unsigned
i_prev_nb_samples
;
int16_t
*
p_prev_s16_buff
;
}
spectrum_data
;
...
...
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