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
67cc0941
Commit
67cc0941
authored
Aug 23, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/dsf: implement seeking
parent
f2a75fbf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
NEWS
NEWS
+1
-0
DsfDecoderPlugin.cxx
src/decoder/plugins/DsfDecoderPlugin.cxx
+25
-1
No files found.
NEWS
View file @
67cc0941
...
...
@@ -42,6 +42,7 @@ ver 0.19 (not yet released)
- audiofile: support scanning remote files
- audiofile: log libaudiofile errors
- dsdiff, dsf: report bit rate
- dsf: implement seeking
- dsf: support DSD512
- dsf: support multi-channel files
- dsf: fix big-endian bugs
...
...
src/decoder/plugins/DsfDecoderPlugin.cxx
View file @
67cc0941
...
...
@@ -243,6 +243,12 @@ InterleaveDsfBlock(uint8_t *gcc_restrict dest, const uint8_t *gcc_restrict src,
InterleaveDsfBlockGeneric
(
dest
,
src
,
channels
);
}
static
offset_type
TimeToBlock
(
double
t
,
unsigned
sample_rate
)
{
return
offset_type
(
t
*
sample_rate
/
DSF_BLOCK_BITS
);
}
/**
* Decode one complete DSF 'data' chunk i.e. a complete song
*/
...
...
@@ -253,9 +259,27 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
bool
bitreverse
)
{
const
size_t
block_size
=
channels
*
DSF_BLOCK_SIZE
;
const
offset_type
start_offset
=
is
.
GetOffset
();
auto
cmd
=
decoder_get_command
(
decoder
);
for
(
offset_type
i
=
0
;
i
<
n_blocks
&&
cmd
!=
DecoderCommand
::
STOP
;)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
double
t
=
decoder_seek_where
(
decoder
);
offset_type
block
=
TimeToBlock
(
t
,
sample_rate
);
if
(
block
>=
n_blocks
)
{
decoder_command_finished
(
decoder
);
break
;
}
offset_type
offset
=
start_offset
+
block
*
block_size
;
if
(
dsdlib_skip_to
(
&
decoder
,
is
,
offset
))
{
decoder_command_finished
(
decoder
);
i
=
block
;
}
else
decoder_seek_error
(
decoder
);
}
/* worst-case buffer size */
uint8_t
buffer
[
MAX_CHANNELS
*
DSF_BLOCK_SIZE
];
if
(
!
decoder_read_full
(
&
decoder
,
is
,
buffer
,
block_size
))
...
...
@@ -298,7 +322,7 @@ dsf_stream_decode(Decoder &decoder, InputStream &is)
(
float
)
metadata
.
sample_rate
;
/* success: file was recognized */
decoder_initialized
(
decoder
,
audio_format
,
false
,
songtime
);
decoder_initialized
(
decoder
,
audio_format
,
is
.
IsSeekable
()
,
songtime
);
dsf_decode_chunk
(
decoder
,
is
,
metadata
.
channels
,
metadata
.
sample_rate
,
...
...
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