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
60b30f42
Commit
60b30f42
authored
Nov 20, 2009
by
Rémi Duraffort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
visual: save again some allocation/deallocation cycles.
parent
a034cdf6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
20 deletions
+43
-20
modules/visualization/visual/effects.c
modules/visualization/visual/effects.c
+31
-20
modules/visualization/visual/visual.c
modules/visualization/visual/visual.c
+5
-0
modules/visualization/visual/visual.h
modules/visualization/visual/visual.h
+7
-0
No files found.
modules/visualization/visual/effects.c
View file @
60b30f42
...
...
@@ -396,11 +396,38 @@ int spectrometer_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
;
/* Create the data struct if needed */
spectrometer_data
*
p_data
=
p_effect
->
p_data
;
if
(
!
p_data
)
{
p_data
=
malloc
(
sizeof
(
spectrometer_data
)
);
if
(
!
p_data
)
return
-
1
;
p_data
->
peaks
=
calloc
(
80
,
sizeof
(
int
)
);
if
(
!
p_data
->
peaks
)
{
free
(
p_data
);
return
-
1
;
}
p_data
->
i_prev_nb_samples
=
0
;
p_data
->
p_prev_s16_buff
=
NULL
;
p_effect
->
p_data
=
(
void
*
)
p_data
;
}
peaks
=
p_data
->
peaks
;
/* 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
;
p_buffs
=
p_s16_buff
;
i_original
=
config_GetInt
(
p_aout
,
"spect-show-original"
);
i_80_bands
=
config_GetInt
(
p_aout
,
"spect-80-bands"
);
i_separ
=
config_GetInt
(
p_aout
,
"spect-separ"
);
...
...
@@ -425,23 +452,9 @@ int spectrometer_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
i_nb_bands
=
20
;
}
if
(
!
p_effect
->
p_data
)
{
p_effect
->
p_data
=
calloc
(
80
,
sizeof
(
int
)
);
if
(
!
p_effect
->
p_data
)
{
free
(
p_s16_buff
);
return
-
1
;
}
}
peaks
=
(
int
*
)
p_effect
->
p_data
;
height
=
malloc
(
i_nb_bands
*
sizeof
(
int
)
);
if
(
!
height
)
{
free
(
p_s16_buff
);
return
-
1
;
}
/* Convert the buffer to int16_t */
/* Pasted from float32tos16.c */
...
...
@@ -460,7 +473,6 @@ int spectrometer_Run(visual_effect_t * p_effect, vlc_object_t *p_aout,
{
msg_Err
(
p_aout
,
"unable to initialize FFT transform"
);
free
(
height
);
free
(
p_s16_buff
);
return
-
1
;
}
p_buffs
=
p_s16_buff
;
...
...
@@ -772,7 +784,6 @@ int spectrometer_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 @
60b30f42
...
...
@@ -399,6 +399,11 @@ static void Close( vlc_object_t *p_this )
free
(
(
(
spectrum_data
*
)
p_effect
->
p_data
)
->
prev_heights
);
free
(
(
(
spectrum_data
*
)
p_effect
->
p_data
)
->
p_prev_s16_buff
);
}
if
(
!
strncmp
(
p_effect
->
psz_name
,
"spectrometer"
,
strlen
(
"spectrometer"
)
)
)
{
free
(
((
spectrometer_data
*
)
p_effect
->
p_data
)
->
peaks
);
free
(
((
spectrometer_data
*
)
p_effect
->
p_data
)
->
p_prev_s16_buff
);
}
free
(
p_effect
->
p_data
);
free
(
p_effect
->
psz_args
);
free
(
p_effect
);
...
...
modules/visualization/visual/visual.h
View file @
60b30f42
...
...
@@ -47,6 +47,13 @@ typedef struct spectrum_data
int16_t
*
p_prev_s16_buff
;
}
spectrum_data
;
typedef
struct
{
int
*
peaks
;
unsigned
i_prev_nb_samples
;
int16_t
*
p_prev_s16_buff
;
}
spectrometer_data
;
/*****************************************************************************
* aout_filter_sys_t: visualizer audio filter method descriptor
...
...
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