Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
2efb594f
Commit
2efb594f
authored
10 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
PCM: remove partial sample buffer. Not needed
parent
c1b8e879
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
audio/pcm_decode.c
+53
-78
53 additions, 78 deletions
audio/pcm_decode.c
with
53 additions
and
78 deletions
audio/pcm_decode.c
+
53
−
78
View file @
2efb594f
...
...
@@ -125,8 +125,7 @@ struct pcm_decode_s
uint8_t
subsample
;
/* Fast forward rate: See AUDIO_SUBSAMPLE_* defns */
uint8_t
skip
;
/* Number of samples to be skipped */
uint8_t
npartial
;
/* Size of the partial sample */
uint8_t
partial
[
4
];
/* Holds the partial sample */
uint8_t
npartial
;
/* Size of the partially copied sample */
/* REVISIT: I think we could get rid of all of this special buffer
* processing. It seems like we should be able to do the sub-sampling
...
...
@@ -817,7 +816,7 @@ static FAR struct ap_buffer_s *pcm_subsample(FAR struct pcm_decode_s *priv,
skipsize
=
priv
->
align
*
(
priv
->
subsample
-
1
);
/* Let's deal with any partial sample
data
from the last buffer */
/* Let's deal with any partial sample
s
from the last buffer */
if
(
priv
->
npartial
>
0
)
{
...
...
@@ -832,37 +831,28 @@ static FAR struct ap_buffer_s *pcm_subsample(FAR struct pcm_decode_s *priv,
if
(
priv
->
npartial
+
srcsize
<
priv
->
align
)
{
dest
=
&
priv
->
partial
[
priv
->
npartial
];
src
=
&
apb
->
samp
[
apb
->
curbyte
];
memcpy
(
dest
,
src
,
srcsize
);
/* Update the partial sample size */
priv
->
npartial
+=
srcsize
;
apb
->
curbyte
+=
srcsize
;
goto
exit_apb_empty
;
}
/* No, we do at least have enough to complete the partial sample */
/* Copy the first part of the partial sample that was saved from
* the last buffer.
*/
/* And just return the buffer with no modification */
src
=
priv
->
partial
;
for
(
i
=
0
;
i
<
priv
->
npartial
;
i
++
)
{
*
dest
++
=
*
src
++
;
return
apb
;
}
priv
->
npartial
=
0
;
/* Now copy data from new audio buffer to complete the sample
*/
/* No, we do at least have enough to complete the sample. Copy copy data
* from the new audio buffer to complete the sample.
*/
src
=
&
apb
->
samp
[
apb
->
curbyte
];
for
(
i
=
0
;
i
<
priv
->
align
;
i
++
)
for
(
i
=
priv
->
npartial
;
i
<
priv
->
align
;
i
++
)
{
*
dest
++
=
*
src
++
;
apb
->
curbyte
++
;
}
priv
->
npartial
=
0
;
/* Update the number of bytes in the working buffer and reset the skip
* value
*/
...
...
@@ -904,55 +894,41 @@ static FAR struct ap_buffer_s *pcm_subsample(FAR struct pcm_decode_s *priv,
}
}
/* We have skipped over the required number of bytes and we are ready
* to take the next sample. Is there space for a whole sample in the
* buffer?
*/
/* Copy the sample from the audio buffer into the working buffer. */
else
if
(
srcsize
<
priv
->
align
)
else
{
/* No.. copy the partial sample to the partial sample buffer */
unsigned
int
copysize
;
dest
=
priv
->
partial
;
for
(
i
=
0
;
i
<
srcsize
;
i
++
)
{
*
dest
++
=
*
src
++
;
}
priv
->
npartial
=
srcsize
;
apb
->
curbyte
+=
srcsize
;
/* Do we have space for the whole sample? */
/* We are finished with this audio buffer. On the next buffer,
* the fact that skip == 0 and that priv->npartial > 0 will kick
* off the re-synchronization logic at the beginning of this
* function.
*/
goto
exit_apb_empty
;
}
if
(
srcsize
<
priv
->
align
)
{
/* No.. this is a partial copy */
/* Plenty of space! Copy the sample from the audio buffer into the
* working buffer.
*/
copysize
=
srcsize
;
priv
->
npartial
=
srcsize
;
}
else
{
copysize
=
priv
->
align
;
priv
->
skip
=
skipsize
;
}
else
{
/* Now copy the sample from new audio buffer to working buffer */
for
(
i
=
0
;
i
<
priv
->
align
;
i
++
)
for
(
i
=
0
;
i
<
copysize
;
i
++
)
{
*
dest
++
=
*
src
++
;
}
/* Update indices and sizes and reset the skip value */
apb
->
curbyte
+=
priv
->
align
;
srcsize
-=
priv
->
align
;
work
->
nbytes
+=
priv
->
align
;
destsize
-=
priv
->
align
;
apb
->
curbyte
+=
copysize
;
srcsize
-=
copysize
;
priv
->
skip
=
skipsize
;
work
->
nbytes
+=
copysize
;
destsize
-=
copysize
;
}
}
...
...
@@ -1001,43 +977,42 @@ static FAR struct ap_buffer_s *pcm_subsample(FAR struct pcm_decode_s *priv,
}
}
/* We have skipped over the required number of bytes and we are
* ready to take the next sample. Is there space for a whole
* sample in the buffer?
*/
/* Copy the sample from the end of the audio buffer to the beginning. */
else
if
(
srcsize
<
priv
->
align
)
else
{
/* No.. copy the partial sample to the partial sample buffer */
unsigned
int
copysize
;
/* Do we have space for the whole sample? */
dest
=
priv
->
partial
;
for
(
i
=
0
;
i
<
srcsize
;
i
++
)
if
(
srcsize
<
priv
->
align
)
{
*
dest
++
=
*
src
++
;
}
/* No.. this is a partial copy */
priv
->
npartial
=
srcsize
;
break
;
}
copysize
=
srcsize
;
priv
->
npartial
=
srcsize
;
}
else
{
/* Copy the whole sample and re-arm the skip size */
/* Plenty of space! Copy the sample from the end of the audio
* buffer to the beginning.
*/
copysize
=
priv
->
align
;
priv
->
skip
=
skipsize
;
}
else
{
/* Now copy the sample from new audio buffer to working buffer */
for
(
i
=
0
;
i
<
priv
->
align
;
i
++
)
for
(
i
=
0
;
i
<
copysize
;
i
++
)
{
*
dest
++
=
*
src
++
;
}
/* Update indices and sizes and reset the skip value */
/* Updates bytes available in the source buffer and bytes
* remaining in the dest buffer.
*/
srcsize
-=
priv
->
align
;
destsize
-=
priv
->
align
;
priv
->
skip
=
skipsize
;
srcsize
-=
copysize
;
destsize
-=
copysize
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment