Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
f78527d1
Commit
f78527d1
authored
Aug 23, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/dsf: use the block count internally
parent
1f642238
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
DsfDecoderPlugin.cxx
src/decoder/plugins/DsfDecoderPlugin.cxx
+10
-10
No files found.
src/decoder/plugins/DsfDecoderPlugin.cxx
View file @
f78527d1
...
...
@@ -42,11 +42,12 @@
#include <string.h>
static
constexpr
unsigned
DSF_BLOCK_SIZE
=
4096
;
static
constexpr
unsigned
DSF_BLOCK_BITS
=
DSF_BLOCK_SIZE
*
8
;
struct
DsfMetaData
{
unsigned
sample_rate
,
channels
;
bool
bitreverse
;
offset_type
chunk_size
;
offset_type
n_blocks
;
#ifdef HAVE_ID3TAG
offset_type
id3_offset
;
#endif
...
...
@@ -170,7 +171,8 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
if
(
data_size
>
playable_size
)
data_size
=
playable_size
;
metadata
->
chunk_size
=
data_size
;
const
size_t
block_size
=
channels
*
DSF_BLOCK_SIZE
;
metadata
->
n_blocks
=
data_size
/
block_size
;
metadata
->
channels
=
channels
;
metadata
->
sample_rate
=
samplefreq
;
#ifdef HAVE_ID3TAG
...
...
@@ -247,7 +249,7 @@ InterleaveDsfBlock(uint8_t *gcc_restrict dest, const uint8_t *gcc_restrict src,
static
bool
dsf_decode_chunk
(
Decoder
&
decoder
,
InputStream
&
is
,
unsigned
channels
,
unsigned
sample_rate
,
offset_type
chunk_size
,
offset_type
n_blocks
,
bool
bitreverse
)
{
/* worst-case buffer size */
...
...
@@ -255,8 +257,6 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
const
size_t
block_size
=
channels
*
DSF_BLOCK_SIZE
;
const
offset_type
n_blocks
=
chunk_size
/
block_size
;
for
(
offset_type
i
=
0
;
i
<
n_blocks
;)
{
if
(
!
decoder_read_full
(
&
decoder
,
is
,
buffer
,
block_size
))
return
false
;
...
...
@@ -306,8 +306,8 @@ dsf_stream_decode(Decoder &decoder, InputStream &is)
return
;
}
/* Calculate song time from DSD chunk size and sample frequency */
offset_type
chunk_size
=
metadata
.
chunk_size
;
float
songtime
=
((
chunk_size
/
metadata
.
channels
)
*
8
)
/
const
auto
n_blocks
=
metadata
.
n_blocks
;
float
songtime
=
float
(
n_blocks
*
DSF_BLOCK_BITS
)
/
(
float
)
metadata
.
sample_rate
;
/* success: file was recognized */
...
...
@@ -315,7 +315,7 @@ dsf_stream_decode(Decoder &decoder, InputStream &is)
if
(
!
dsf_decode_chunk
(
decoder
,
is
,
metadata
.
channels
,
metadata
.
sample_rate
,
chunk_size
,
n_blocks
,
metadata
.
bitreverse
))
return
;
}
...
...
@@ -338,8 +338,8 @@ dsf_scan_stream(InputStream &is,
return
false
;
/* calculate song time and add as tag */
unsigned
songtime
=
(
(
metadata
.
chunk_size
/
metadata
.
channels
)
*
8
)
/
metadata
.
sample_rate
;
unsigned
songtime
=
(
metadata
.
n_blocks
*
DSF_BLOCK_BITS
)
/
metadata
.
sample_rate
;
tag_handler_invoke_duration
(
handler
,
handler_ctx
,
songtime
);
#ifdef HAVE_ID3TAG
...
...
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