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
2c28bcba
Commit
2c28bcba
authored
Aug 20, 2008
by
Rémi Duraffort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix potential memleaks (free the module if it can't be loaded)
parent
131a15b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
26 deletions
+35
-26
modules/audio_filter/scaletempo.c
modules/audio_filter/scaletempo.c
+35
-26
No files found.
modules/audio_filter/scaletempo.c
View file @
2c28bcba
...
@@ -288,12 +288,15 @@ static int reinit_buffers( aout_filter_t *p_filter )
...
@@ -288,12 +288,15 @@ static int reinit_buffers( aout_filter_t *p_filter )
/* overlap */
/* overlap */
unsigned
frames_overlap
=
frames_stride
*
p
->
percent_overlap
;
unsigned
frames_overlap
=
frames_stride
*
p
->
percent_overlap
;
if
(
frames_overlap
<
1
)
{
/* if no overlap */
if
(
frames_overlap
<
1
)
{
/* if no overlap */
p
->
bytes_overlap
=
0
;
p
->
bytes_overlap
=
0
;
p
->
bytes_standing
=
p
->
bytes_stride
;
p
->
bytes_standing
=
p
->
bytes_stride
;
p
->
samples_standing
=
p
->
bytes_standing
/
p
->
bytes_per_sample
;
p
->
samples_standing
=
p
->
bytes_standing
/
p
->
bytes_per_sample
;
p
->
output_overlap
=
NULL
;
p
->
output_overlap
=
NULL
;
}
else
{
}
else
{
unsigned
prev_overlap
=
p
->
bytes_overlap
;
unsigned
prev_overlap
=
p
->
bytes_overlap
;
p
->
bytes_overlap
=
frames_overlap
*
p
->
bytes_per_frame
;
p
->
bytes_overlap
=
frames_overlap
*
p
->
bytes_per_frame
;
p
->
samples_overlap
=
frames_overlap
*
p
->
samples_per_frame
;
p
->
samples_overlap
=
frames_overlap
*
p
->
samples_per_frame
;
...
@@ -301,50 +304,55 @@ static int reinit_buffers( aout_filter_t *p_filter )
...
@@ -301,50 +304,55 @@ static int reinit_buffers( aout_filter_t *p_filter )
p
->
samples_standing
=
p
->
bytes_standing
/
p
->
bytes_per_sample
;
p
->
samples_standing
=
p
->
bytes_standing
/
p
->
bytes_per_sample
;
p
->
buf_overlap
=
malloc
(
p
->
bytes_overlap
);
p
->
buf_overlap
=
malloc
(
p
->
bytes_overlap
);
p
->
table_blend
=
malloc
(
p
->
samples_overlap
*
4
);
/* sizeof (int32|float) */
p
->
table_blend
=
malloc
(
p
->
samples_overlap
*
4
);
/* sizeof (int32|float) */
if
(
!
p
->
buf_overlap
||
!
p
->
table_blend
)
{
if
(
!
p
->
buf_overlap
||
!
p
->
table_blend
)
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
}
if
(
p
->
bytes_overlap
>
prev_overlap
)
if
(
p
->
bytes_overlap
>
prev_overlap
)
{
memset
(
(
uint8_t
*
)
p
->
buf_overlap
+
prev_overlap
,
0
,
p
->
bytes_overlap
-
prev_overlap
);
memset
(
(
uint8_t
*
)
p
->
buf_overlap
+
prev_overlap
,
0
,
p
->
bytes_overlap
-
prev_overlap
);
}
float
*
pb
=
p
->
table_blend
;
float
*
pb
=
p
->
table_blend
;
float
t
=
(
float
)
frames_overlap
;
float
t
=
(
float
)
frames_overlap
;
for
(
i
=
0
;
i
<
frames_overlap
;
i
++
)
{
for
(
i
=
0
;
i
<
frames_overlap
;
i
++
)
{
float
v
=
i
/
t
;
float
v
=
i
/
t
;
for
(
j
=
0
;
j
<
p
->
samples_per_frame
;
j
++
)
{
for
(
j
=
0
;
j
<
p
->
samples_per_frame
;
j
++
)
*
pb
++
=
v
;
*
pb
++
=
v
;
}
}
}
p
->
output_overlap
=
output_overlap_float
;
p
->
output_overlap
=
output_overlap_float
;
}
}
/* best overlap */
/* best overlap */
p
->
frames_search
=
(
frames_overlap
<=
1
)
?
0
:
p
->
ms_search
*
p
->
sample_rate
/
1000
.
0
;
p
->
frames_search
=
(
frames_overlap
<=
1
)
?
0
:
p
->
ms_search
*
p
->
sample_rate
/
1000
.
0
;
if
(
p
->
frames_search
<
1
)
{
/* if no search */
if
(
p
->
frames_search
<
1
)
{
/* if no search */
p
->
best_overlap_offset
=
NULL
;
p
->
best_overlap_offset
=
NULL
;
}
else
{
}
else
{
unsigned
bytes_pre_corr
=
(
p
->
samples_overlap
-
p
->
samples_per_frame
)
*
4
;
/* sizeof (int32|float) */
unsigned
bytes_pre_corr
=
(
p
->
samples_overlap
-
p
->
samples_per_frame
)
*
4
;
/* sizeof (int32|float) */
p
->
buf_pre_corr
=
malloc
(
bytes_pre_corr
);
p
->
buf_pre_corr
=
malloc
(
bytes_pre_corr
);
p
->
table_window
=
malloc
(
bytes_pre_corr
);
p
->
table_window
=
malloc
(
bytes_pre_corr
);
if
(
!
p
->
buf_pre_corr
||
!
p
->
table_window
)
{
if
(
!
p
->
buf_pre_corr
||
!
p
->
table_window
)
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
}
float
*
pw
=
p
->
table_window
;
float
*
pw
=
p
->
table_window
;
for
(
i
=
1
;
i
<
frames_overlap
;
i
++
)
{
for
(
i
=
1
;
i
<
frames_overlap
;
i
++
)
{
float
v
=
i
*
(
frames_overlap
-
i
);
float
v
=
i
*
(
frames_overlap
-
i
);
for
(
j
=
0
;
j
<
p
->
samples_per_frame
;
j
++
)
{
for
(
j
=
0
;
j
<
p
->
samples_per_frame
;
j
++
)
*
pw
++
=
v
;
*
pw
++
=
v
;
}
}
}
p
->
best_overlap_offset
=
best_overlap_offset_float
;
p
->
best_overlap_offset
=
best_overlap_offset_float
;
}
}
unsigned
new_size
=
(
p
->
frames_search
+
frames_stride
+
frames_overlap
)
*
p
->
bytes_per_frame
;
unsigned
new_size
=
(
p
->
frames_search
+
frames_stride
+
frames_overlap
)
*
p
->
bytes_per_frame
;
if
(
p
->
bytes_queued
>
new_size
)
{
if
(
p
->
bytes_queued
>
new_size
)
if
(
p
->
bytes_to_slide
>
p
->
bytes_queued
)
{
{
if
(
p
->
bytes_to_slide
>
p
->
bytes_queued
)
{
p
->
bytes_to_slide
-=
p
->
bytes_queued
;
p
->
bytes_to_slide
-=
p
->
bytes_queued
;
p
->
bytes_queued
=
0
;
p
->
bytes_queued
=
0
;
}
else
{
}
else
{
unsigned
new_queued
=
__MIN
(
p
->
bytes_queued
-
p
->
bytes_to_slide
,
new_size
);
unsigned
new_queued
=
__MIN
(
p
->
bytes_queued
-
p
->
bytes_to_slide
,
new_size
);
memmove
(
p
->
buf_queue
,
memmove
(
p
->
buf_queue
,
p
->
buf_queue
+
p
->
bytes_queued
-
new_queued
,
p
->
buf_queue
+
p
->
bytes_queued
-
new_queued
,
...
@@ -355,9 +363,8 @@ static int reinit_buffers( aout_filter_t *p_filter )
...
@@ -355,9 +363,8 @@ static int reinit_buffers( aout_filter_t *p_filter )
}
}
p
->
bytes_queue_max
=
new_size
;
p
->
bytes_queue_max
=
new_size
;
p
->
buf_queue
=
malloc
(
p
->
bytes_queue_max
);
p
->
buf_queue
=
malloc
(
p
->
bytes_queue_max
);
if
(
!
p
->
buf_queue
)
{
if
(
!
p
->
buf_queue
)
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
}
p
->
bytes_stride_scaled
=
p
->
bytes_stride
*
p
->
scale
;
p
->
bytes_stride_scaled
=
p
->
bytes_stride
*
p
->
scale
;
p
->
frames_stride_scaled
=
p
->
bytes_stride_scaled
/
p
->
bytes_per_frame
;
p
->
frames_stride_scaled
=
p
->
bytes_stride_scaled
/
p
->
bytes_per_frame
;
...
@@ -400,9 +407,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -400,9 +407,7 @@ static int Open( vlc_object_t *p_this )
}
}
if
(
!
b_fit
)
if
(
!
b_fit
)
{
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
p_filter
->
pf_do_work
=
DoWork
;
p_filter
->
pf_do_work
=
DoWork
;
p_filter
->
b_in_place
=
false
;
p_filter
->
b_in_place
=
false
;
...
@@ -410,9 +415,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -410,9 +415,7 @@ static int Open( vlc_object_t *p_this )
/* Allocate structure */
/* Allocate structure */
p_sys
=
p_filter
->
p_sys
=
malloc
(
sizeof
(
aout_filter_sys_t
)
);
p_sys
=
p_filter
->
p_sys
=
malloc
(
sizeof
(
aout_filter_sys_t
)
);
if
(
!
p_sys
)
if
(
!
p_sys
)
{
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
}
p_sys
->
scale
=
1
.
0
;
p_sys
->
scale
=
1
.
0
;
p_sys
->
sample_rate
=
p_filter
->
input
.
i_rate
;
p_sys
->
sample_rate
=
p_filter
->
input
.
i_rate
;
...
@@ -446,7 +449,13 @@ static int Open( vlc_object_t *p_this )
...
@@ -446,7 +449,13 @@ static int Open( vlc_object_t *p_this )
p_sys
->
bytes_queued
=
0
;
p_sys
->
bytes_queued
=
0
;
p_sys
->
bytes_to_slide
=
0
;
p_sys
->
bytes_to_slide
=
0
;
p_sys
->
frames_stride_error
=
0
;
p_sys
->
frames_stride_error
=
0
;
return
reinit_buffers
(
p_filter
);
if
(
reinit_buffers
(
p_filter
)
!=
VLC_SUCCESS
)
{
Close
(
p_this
);
return
VLC_EGENERIC
;
}
return
VLC_SUCCESS
;
}
}
static
void
Close
(
vlc_object_t
*
p_this
)
static
void
Close
(
vlc_object_t
*
p_this
)
...
...
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