Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
3ea8408d
Commit
3ea8408d
authored
Jan 31, 2009
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shine: protect against invalid bitrate and cleanup.
parent
7ecf78a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
15 deletions
+32
-15
modules/codec/shine/shine_mod.c
modules/codec/shine/shine_mod.c
+32
-15
No files found.
modules/codec/shine/shine_mod.c
View file @
3ea8408d
...
@@ -86,6 +86,16 @@ static int OpenEncoder( vlc_object_t *p_this )
...
@@ -86,6 +86,16 @@ static int OpenEncoder( vlc_object_t *p_this )
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
if
(
p_enc
->
fmt_out
.
i_bitrate
<=
0
)
{
msg_Err
(
p_enc
,
"unknown bitrate"
);
return
VLC_EGENERIC
;
}
msg_Dbg
(
p_enc
,
"bitrate %d, samplerate %d, channels %d"
,
p_enc
->
fmt_out
.
i_bitrate
,
p_enc
->
fmt_out
.
audio
.
i_rate
,
p_enc
->
fmt_out
.
audio
.
i_channels
);
p_sys
=
p_enc
->
p_sys
=
malloc
(
sizeof
(
encoder_sys_t
)
);
p_sys
=
p_enc
->
p_sys
=
malloc
(
sizeof
(
encoder_sys_t
)
);
if
(
!
p_sys
)
if
(
!
p_sys
)
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
...
@@ -118,12 +128,12 @@ static block_t *GetPCM( encoder_t *p_enc, aout_buffer_t *p_block )
...
@@ -118,12 +128,12 @@ static block_t *GetPCM( encoder_t *p_enc, aout_buffer_t *p_block )
{
{
unsigned
int
i_buffer
=
0
;
unsigned
int
i_buffer
=
0
;
p_pcm_block
=
block_New
(
p_enc
,
pcm_chunk_size
);
p_pcm_block
=
block_New
(
p_enc
,
pcm_chunk_size
);
if
(
!
p_pcm_block
)
break
;
if
(
!
p_pcm_block
)
break
;
if
(
p_sys
->
i_buffer
)
if
(
p_sys
->
i_buffer
)
{
{
vlc_memcpy
(
p_pcm_block
->
p_buffer
,
p_sys
->
p_buffer
,
vlc_memcpy
(
p_pcm_block
->
p_buffer
,
p_sys
->
p_buffer
,
p_sys
->
i_buffer
);
p_sys
->
i_buffer
);
i_buffer
=
p_sys
->
i_buffer
;
i_buffer
=
p_sys
->
i_buffer
;
p_sys
->
i_buffer
=
0
;
p_sys
->
i_buffer
=
0
;
...
@@ -131,7 +141,7 @@ static block_t *GetPCM( encoder_t *p_enc, aout_buffer_t *p_block )
...
@@ -131,7 +141,7 @@ static block_t *GetPCM( encoder_t *p_enc, aout_buffer_t *p_block )
}
}
vlc_memcpy
(
p_pcm_block
->
p_buffer
+
i_buffer
,
vlc_memcpy
(
p_pcm_block
->
p_buffer
+
i_buffer
,
p_block
->
p_buffer
,
pcm_chunk_size
-
i_buffer
);
p_block
->
p_buffer
,
pcm_chunk_size
-
i_buffer
);
p_block
->
p_buffer
+=
pcm_chunk_size
-
i_buffer
;
p_block
->
p_buffer
+=
pcm_chunk_size
-
i_buffer
;
p_block
->
i_nb_bytes
-=
pcm_chunk_size
-
i_buffer
;
p_block
->
i_nb_bytes
-=
pcm_chunk_size
-
i_buffer
;
...
@@ -142,18 +152,23 @@ static block_t *GetPCM( encoder_t *p_enc, aout_buffer_t *p_block )
...
@@ -142,18 +152,23 @@ static block_t *GetPCM( encoder_t *p_enc, aout_buffer_t *p_block )
/* We hadn't enough data to make a block, put it in standby */
/* We hadn't enough data to make a block, put it in standby */
if
(
p_block
->
i_nb_bytes
)
if
(
p_block
->
i_nb_bytes
)
{
{
p_sys
->
p_buffer
=
p_sys
->
i_buffer
?
uint8_t
*
p_tmp
;
realloc
(
p_sys
->
p_buffer
,
p_block
->
i_nb_bytes
+
p_sys
->
i_buffer
)
:
malloc
(
p_block
->
i_nb_bytes
);
if
(
p_sys
->
i_buffer
>
0
)
p_tmp
=
realloc
(
p_sys
->
p_buffer
,
p_block
->
i_nb_bytes
+
p_sys
->
i_buffer
);
else
p_tmp
=
malloc
(
p_block
->
i_nb_bytes
);
if
(
!
p_
sys
->
p_buffer
)
if
(
!
p_
tmp
)
{
{
p_sys
->
i_buffer
=
0
;
p_sys
->
i_buffer
=
0
;
free
(
p_sys
->
p_buffer
);
p_sys
->
p_buffer
=
NULL
;
return
NULL
;
return
NULL
;
}
}
p_sys
->
p_buffer
=
p_tmp
;
vlc_memcpy
(
p_sys
->
p_buffer
+
p_sys
->
i_buffer
,
vlc_memcpy
(
p_sys
->
p_buffer
+
p_sys
->
i_buffer
,
p_block
->
p_buffer
,
p_block
->
i_nb_bytes
);
p_block
->
p_buffer
,
p_block
->
i_nb_bytes
);
p_sys
->
i_buffer
+=
p_block
->
i_nb_bytes
;
p_sys
->
i_buffer
+=
p_block
->
i_nb_bytes
;
p_block
->
i_nb_bytes
=
0
;
p_block
->
i_nb_bytes
=
0
;
...
@@ -166,14 +181,16 @@ buffered:
...
@@ -166,14 +181,16 @@ buffered:
static
block_t
*
EncodeFrame
(
encoder_t
*
p_enc
,
aout_buffer_t
*
p_block
)
static
block_t
*
EncodeFrame
(
encoder_t
*
p_enc
,
aout_buffer_t
*
p_block
)
{
{
encoder_sys_t
*
p_sys
=
(
encoder_sys_t
*
)
p_enc
->
p_sys
;
block_t
*
p_pcm_block
;
block_t
*
p_pcm_block
;
block_t
*
p_chain
=
NULL
;
block_t
*
p_chain
=
NULL
;
unsigned
int
i_samples
=
p_block
->
i_nb_bytes
/
4
/* s16l stereo */
;
unsigned
int
i_samples
=
p_block
->
i_nb_bytes
>>
2
/* s16l stereo */
;
mtime_t
start_date
=
p_block
->
start_date
;
mtime_t
start_date
=
p_block
->
start_date
;
start_date
-=
i_samples
*
1000000
/
p_enc
->
fmt_out
.
audio
.
i_rate
;
start_date
-=
(
mtime_t
)
i_samples
*
(
mtime_t
)
1000000
/
(
mtime_t
)
p_enc
->
fmt_out
.
audio
.
i_rate
;
do
{
do
{
if
(
!
(
p_pcm_block
=
GetPCM
(
p_enc
,
p_block
)
)
)
p_pcm_block
=
GetPCM
(
p_enc
,
p_block
);
if
(
!
p_pcm_block
)
break
;
break
;
p_block
=
NULL
;
/* we don't need it anymore */
p_block
=
NULL
;
/* we don't need it anymore */
...
@@ -189,8 +206,7 @@ static block_t *EncodeFrame( encoder_t *p_enc, aout_buffer_t *p_block )
...
@@ -189,8 +206,7 @@ static block_t *EncodeFrame( encoder_t *p_enc, aout_buffer_t *p_block )
if
(
!
p_mp3_block
)
if
(
!
p_mp3_block
)
break
;
break
;
vlc_memcpy
(
p_mp3_block
->
p_buffer
,
chunk
->
enc_data
,
vlc_memcpy
(
p_mp3_block
->
p_buffer
,
chunk
->
enc_data
,
chunk
->
enc_size
);
chunk
->
enc_size
);
/* date management */
/* date management */
p_mp3_block
->
i_length
=
SAMP_PER_FRAME1
*
1000000
/
p_mp3_block
->
i_length
=
SAMP_PER_FRAME1
*
1000000
/
...
@@ -202,6 +218,7 @@ static block_t *EncodeFrame( encoder_t *p_enc, aout_buffer_t *p_block )
...
@@ -202,6 +218,7 @@ static block_t *EncodeFrame( encoder_t *p_enc, aout_buffer_t *p_block )
p_mp3_block
->
i_samples
=
SAMP_PER_FRAME1
;
p_mp3_block
->
i_samples
=
SAMP_PER_FRAME1
;
block_ChainAppend
(
&
p_chain
,
p_mp3_block
);
block_ChainAppend
(
&
p_chain
,
p_mp3_block
);
}
while
(
p_pcm_block
);
}
while
(
p_pcm_block
);
return
p_chain
;
return
p_chain
;
...
...
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