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
b870bc9d
Commit
b870bc9d
authored
Apr 10, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use stack array rather than alloca
parent
6def57f0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
83 deletions
+26
-83
modules/audio_filter/converter/float.c
modules/audio_filter/converter/float.c
+2
-16
modules/audio_filter/resampler/bandlimited.c
modules/audio_filter/resampler/bandlimited.c
+4
-17
modules/audio_filter/resampler/linear.c
modules/audio_filter/resampler/linear.c
+2
-18
modules/audio_filter/resampler/ugly.c
modules/audio_filter/resampler/ugly.c
+3
-18
modules/demux/mkv/matroska_segment.cpp
modules/demux/mkv/matroska_segment.cpp
+15
-14
No files found.
modules/audio_filter/converter/float.c
View file @
b870bc9d
...
...
@@ -40,10 +40,6 @@
# include <unistd.h>
#endif
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
#include <vlc_aout.h>
/*****************************************************************************
...
...
@@ -556,13 +552,9 @@ static void Do_S16ToFL32_SW( aout_instance_t * p_aout, aout_filter_t * p_filter,
float
*
p_out
=
(
float
*
)
p_out_buf
->
p_buffer
+
i
-
1
;
#ifdef HAVE_SWAB
# ifdef HAVE_ALLOCA
int16_t
*
p_swabbed
=
alloca
(
i
*
sizeof
(
int16_t
)
);
# else
int16_t
*
p_swabbed
=
malloc
(
i
*
sizeof
(
int16_t
)
);
# endif
int16_t
p_swabbed
[
i
];
swab
(
p_in_buf
->
p_buffer
,
(
void
*
)
p_swabbed
,
i
*
sizeof
(
int16_t
)
);
swab
(
p_in_buf
->
p_buffer
,
p_swabbed
,
i
*
sizeof
(
int16_t
)
);
p_in
=
p_swabbed
+
i
-
1
;
#else
...
...
@@ -582,12 +574,6 @@ static void Do_S16ToFL32_SW( aout_instance_t * p_aout, aout_filter_t * p_filter,
p_in
--
;
p_out
--
;
}
#ifdef HAVE_SWAB
# ifndef HAVE_ALLOCA
free
(
p_swabbed
);
# endif
#endif
p_out_buf
->
i_nb_samples
=
p_in_buf
->
i_nb_samples
;
p_out_buf
->
i_nb_bytes
=
p_in_buf
->
i_nb_bytes
*
4
/
2
;
}
...
...
modules/audio_filter/resampler/bandlimited.c
View file @
b870bc9d
...
...
@@ -184,7 +184,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
p_filter
->
p_sys
;
float
*
p_
in
,
*
p_in_orig
,
*
p_
out
=
(
float
*
)
p_out_buf
->
p_buffer
;
float
*
p_out
=
(
float
*
)
p_out_buf
->
p_buffer
;
int
i_nb_channels
=
aout_FormatNbChannels
(
&
p_filter
->
input
);
int
i_in_nb
=
p_in_buf
->
i_nb_samples
;
...
...
@@ -253,17 +253,9 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
/* Prepare the source buffer */
i_in_nb
+=
(
p_sys
->
i_old_wing
*
2
);
#ifdef HAVE_ALLOCA
p_in
=
p_in_orig
=
(
float
*
)
alloca
(
i_in_nb
*
p_filter
->
input
.
i_bytes_per_frame
);
#else
p_in
=
p_in_orig
=
(
float
*
)
malloc
(
i_in_nb
*
p_filter
->
input
.
i_bytes_per_frame
);
#endif
if
(
p_in
==
NULL
)
{
return
;
}
float
p_in_orig
[
i_in_nb
*
p_filter
->
input
.
i_bytes_per_frame
/
4
],
*
p_in
=
p_in_orig
;
/* Copy all our samples in p_in */
if
(
p_sys
->
i_old_wing
)
...
...
@@ -460,11 +452,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
i_out * p_filter->input.i_bytes_per_frame );
#endif
/* Free the temp buffer */
#ifndef HAVE_ALLOCA
free
(
p_in_orig
);
#endif
/* Finalize aout buffer */
p_out_buf
->
i_nb_samples
=
i_out
;
p_out_buf
->
start_date
=
aout_DateGet
(
&
p_sys
->
end_date
);
...
...
modules/audio_filter/resampler/linear.c
View file @
b870bc9d
...
...
@@ -137,10 +137,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
p_filter
->
p_sys
;
#ifndef HAVE_ALLOCA
float
*
p_in_orig
;
#endif
float
*
p_in
,
*
p_out
=
(
float
*
)
p_out_buf
->
p_buffer
;
float
*
p_out
=
(
float
*
)
p_out_buf
->
p_buffer
;
float
*
p_prev_sample
=
(
float
*
)
p_sys
->
p_prev_sample
;
int
i_nb_channels
=
p_filter
->
input
.
i_channels
;
...
...
@@ -164,15 +161,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
return
;
}
#ifdef HAVE_ALLOCA
p_in
=
(
float
*
)
alloca
(
p_in_buf
->
i_nb_bytes
);
#else
p_in_orig
=
p_in
=
(
float
*
)
malloc
(
p_in_buf
->
i_nb_bytes
);
#endif
if
(
p_in
==
NULL
)
{
return
;
}
float
p_in_orig
[
p_in_buf
->
i_nb_bytes
/
4
],
*
p_in
=
p_in_orig
;
vlc_memcpy
(
p_in
,
p_in_buf
->
p_buffer
,
p_in_buf
->
i_nb_bytes
);
...
...
@@ -247,11 +236,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
p_out_buf
->
i_nb_bytes
=
p_out_buf
->
i_nb_samples
*
i_nb_channels
*
sizeof
(
int32_t
);
#ifndef HAVE_ALLOCA
free
(
p_in_orig
);
#endif
}
/*****************************************************************************
...
...
modules/audio_filter/resampler/ugly.c
View file @
b870bc9d
...
...
@@ -86,10 +86,7 @@ static int Create( vlc_object_t *p_this )
static
void
DoWork
(
aout_instance_t
*
p_aout
,
aout_filter_t
*
p_filter
,
aout_buffer_t
*
p_in_buf
,
aout_buffer_t
*
p_out_buf
)
{
int32_t
*
p_in
,
*
p_out
=
(
int32_t
*
)
p_out_buf
->
p_buffer
;
#ifndef HAVE_ALLOCA
int32_t
*
p_in_orig
;
#endif
int32_t
*
p_out
=
(
int32_t
*
)
p_out_buf
->
p_buffer
;
unsigned
int
i_nb_channels
=
aout_FormatNbChannels
(
&
p_filter
->
input
);
unsigned
int
i_in_nb
=
p_in_buf
->
i_nb_samples
;
...
...
@@ -104,15 +101,8 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
return
;
}
#ifdef HAVE_ALLOCA
p_in
=
(
int32_t
*
)
alloca
(
p_in_buf
->
i_nb_bytes
);
#else
p_in_orig
=
p_in
=
(
int32_t
*
)
malloc
(
p_in_buf
->
i_nb_bytes
);
#endif
if
(
p_in
==
NULL
)
{
return
;
}
int32_t
p_in_orig
[
p_in_buf
->
i_nb_bytes
/
sizeof
(
int32_t
)],
*
p_in
=
p_in_orig
;
vlc_memcpy
(
p_in
,
p_in_buf
->
p_buffer
,
p_in_buf
->
i_nb_bytes
);
...
...
@@ -138,9 +128,4 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
p_out_buf
->
start_date
=
p_in_buf
->
start_date
;
p_out_buf
->
end_date
=
p_out_buf
->
start_date
+
p_out_buf
->
i_nb_samples
*
1000000
/
p_filter
->
output
.
i_rate
;
#ifndef HAVE_ALLOCA
free
(
p_in_orig
);
#endif
}
modules/demux/mkv/matroska_segment.cpp
View file @
b870bc9d
...
...
@@ -997,7 +997,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
/* disabled due to the potential "S_KATE" namespace issue */
else
if
(
!
strcmp
(
tracks
[
i_track
]
->
psz_codec
,
"S_KATE"
)
)
{
int
i
,
i_offset
=
1
,
*
i_size
,
i_extra
,
num_headers
,
size_so_far
;
int
i
,
i_offset
=
1
,
i_extra
,
num_headers
,
size_so_far
;
uint8_t
*
p_extra
;
tracks
[
i_track
]
->
fmt
.
i_codec
=
VLC_FOURCC
(
'k'
,
'a'
,
't'
,
'e'
);
...
...
@@ -1009,25 +1009,25 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
num_headers
,
tracks
[
i_track
]
->
i_extra_data
);
/* this won't overflow the stack as is can allocate only 1020 bytes max */
i_size
=
(
int
*
)
alloca
(
num_headers
*
sizeof
(
int
))
;
uint16_t
pi_size
[
num_headers
]
;
/* Split the headers */
size_so_far
=
0
;
for
(
i
=
0
;
i
<
num_headers
-
1
;
i
++
)
{
i_size
[
i
]
=
0
;
p
i_size
[
i
]
=
0
;
while
(
i_offset
<
tracks
[
i_track
]
->
i_extra_data
)
{
i_size
[
i
]
+=
tracks
[
i_track
]
->
p_extra_data
[
i_offset
];
p
i_size
[
i
]
+=
tracks
[
i_track
]
->
p_extra_data
[
i_offset
];
if
(
tracks
[
i_track
]
->
p_extra_data
[
i_offset
++
]
!=
0xff
)
break
;
}
msg_Dbg
(
&
sys
.
demuxer
,
"kate header %d is %d bytes"
,
i
,
i_size
[
i
]);
size_so_far
+=
i_size
[
i
];
msg_Dbg
(
&
sys
.
demuxer
,
"kate header %d is %d bytes"
,
i
,
p
i_size
[
i
]);
size_so_far
+=
p
i_size
[
i
];
}
i_size
[
num_headers
-
1
]
=
tracks
[
i_track
]
->
i_extra_data
-
(
size_so_far
+
i_offset
);
msg_Dbg
(
&
sys
.
demuxer
,
"kate last header (%d) is %d bytes"
,
num_headers
-
1
,
i_size
[
num_headers
-
1
]);
p
i_size
[
num_headers
-
1
]
=
tracks
[
i_track
]
->
i_extra_data
-
(
size_so_far
+
i_offset
);
msg_Dbg
(
&
sys
.
demuxer
,
"kate last header (%d) is %d bytes"
,
num_headers
-
1
,
p
i_size
[
num_headers
-
1
]);
tracks
[
i_track
]
->
fmt
.
i_extra
=
1
+
num_headers
*
2
+
size_so_far
+
i_size
[
num_headers
-
1
];
tracks
[
i_track
]
->
fmt
.
i_extra
=
1
+
num_headers
*
2
+
size_so_far
+
p
i_size
[
num_headers
-
1
];
tracks
[
i_track
]
->
fmt
.
p_extra
=
malloc
(
tracks
[
i_track
]
->
fmt
.
i_extra
);
p_extra
=
(
uint8_t
*
)
tracks
[
i_track
]
->
fmt
.
p_extra
;
...
...
@@ -1036,12 +1036,13 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
++
i_extra
;
for
(
i
=
0
;
i
<
num_headers
;
i
++
)
{
*
(
p_extra
++
)
=
i_size
[
i
]
>>
8
;
*
(
p_extra
++
)
=
i_size
[
i
]
&
0xFF
;
*
(
p_extra
++
)
=
p
i_size
[
i
]
>>
8
;
*
(
p_extra
++
)
=
p
i_size
[
i
]
&
0xFF
;
memcpy
(
p_extra
,
tracks
[
i_track
]
->
p_extra_data
+
i_offset
+
i_extra
-
1
,
i_size
[
i
]
);
p_extra
+=
i_size
[
i
];
i_extra
+=
i_size
[
i
];
pi_size
[
i
]
);
#endif
p_extra
+=
pi_size
[
i
];
i_extra
+=
pi_size
[
i
];
}
}
else
if
(
!
strcmp
(
tracks
[
i_track
]
->
psz_codec
,
"S_TEXT/ASCII"
)
)
...
...
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