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
deda40ce
Commit
deda40ce
authored
Nov 21, 2014
by
Tristan Matthews
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packetizer: flac: reduce memory allocations
parent
a32f9e2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
modules/packetizer/flac.c
modules/packetizer/flac.c
+14
-7
No files found.
modules/packetizer/flac.c
View file @
deda40ce
...
...
@@ -90,6 +90,8 @@ struct decoder_sys_t
size_t
i_frame_size
;
uint16_t
crc
;
unsigned
int
i_rate
,
i_channels
,
i_bits_per_sample
;
size_t
i_buf
;
uint8_t
*
p_buf
;
};
static
const
int
pi_channels_maps
[
9
]
=
...
...
@@ -603,19 +605,21 @@ static block_t *Packetize(decoder_t *p_dec, block_t **pp_block)
{
/* Calculate the initial CRC for the minimal frame size,
* We'll update it as we look for the next start code. */
uint8_t
*
buf
=
malloc
(
p_sys
->
i_frame_size
);
if
(
!
buf
)
return
NULL
;
if
(
p_sys
->
i_buf
<
p_sys
->
i_frame_size
)
{
p_sys
->
p_buf
=
realloc
(
p_sys
->
p_buf
,
p_sys
->
i_frame_size
);
if
(
!
p_sys
->
p_buf
)
return
NULL
;
p_sys
->
i_buf
=
p_sys
->
i_frame_size
;
}
if
(
block_PeekOffsetBytes
(
&
p_sys
->
bytestream
,
0
,
buf
,
p_sys
->
i_frame_size
))
{
free
(
buf
);
if
(
block_PeekOffsetBytes
(
&
p_sys
->
bytestream
,
0
,
p_sys
->
p_buf
,
p_sys
->
i_frame_size
))
{
return
NULL
;
}
uint16_t
crc
=
0
;
for
(
unsigned
i
=
0
;
i
<
p_sys
->
i_frame_size
;
i
++
)
crc
=
flac_crc16
(
crc
,
buf
[
i
]);
free
(
buf
);
crc
=
flac_crc16
(
crc
,
p_sys
->
p_buf
[
i
]);
p_sys
->
crc
=
crc
;
/* Check if next expected frame contains the sync word */
...
...
@@ -752,6 +756,8 @@ static int Open(vlc_object_t *p_this)
p_sys
->
i_state
=
STATE_NOSYNC
;
p_sys
->
b_stream_info
=
false
;
p_sys
->
i_pts
=
VLC_TS_INVALID
;
p_sys
->
i_buf
=
0
;
p_sys
->
p_buf
=
NULL
;
block_BytestreamInit
(
&
p_sys
->
bytestream
);
/* */
...
...
@@ -773,5 +779,6 @@ static void Close(vlc_object_t *p_this)
es_format_Clean
(
&
p_dec
->
fmt_out
);
block_BytestreamRelease
(
&
p_sys
->
bytestream
);
free
(
p_sys
->
p_buf
);
free
(
p_sys
);
}
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