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
e2adb82e
Commit
e2adb82e
authored
Aug 19, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/DsdLib: use offset_type instead of uint64_t
parent
bb472206
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
27 deletions
+26
-27
DsdLib.cxx
src/decoder/plugins/DsdLib.cxx
+3
-3
DsdLib.hxx
src/decoder/plugins/DsdLib.hxx
+3
-2
DsdiffDecoderPlugin.cxx
src/decoder/plugins/DsdiffDecoderPlugin.cxx
+9
-10
DsfDecoderPlugin.cxx
src/decoder/plugins/DsfDecoderPlugin.cxx
+11
-12
No files found.
src/decoder/plugins/DsdLib.cxx
View file @
e2adb82e
...
@@ -50,12 +50,12 @@ DsdId::Equals(const char *s) const
...
@@ -50,12 +50,12 @@ DsdId::Equals(const char *s) const
*/
*/
bool
bool
dsdlib_skip_to
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdlib_skip_to
(
Decoder
*
decoder
,
InputStream
&
is
,
uint64_t
offset
)
offset_type
offset
)
{
{
if
(
is
.
IsSeekable
())
if
(
is
.
IsSeekable
())
return
is
.
Seek
(
offset
,
IgnoreError
());
return
is
.
Seek
(
offset
,
IgnoreError
());
if
(
uint64_t
(
is
.
GetOffset
()
)
>
offset
)
if
(
is
.
GetOffset
(
)
>
offset
)
return
false
;
return
false
;
return
dsdlib_skip
(
decoder
,
is
,
offset
-
is
.
GetOffset
());
return
dsdlib_skip
(
decoder
,
is
,
offset
-
is
.
GetOffset
());
...
@@ -66,7 +66,7 @@ dsdlib_skip_to(Decoder *decoder, InputStream &is,
...
@@ -66,7 +66,7 @@ dsdlib_skip_to(Decoder *decoder, InputStream &is,
*/
*/
bool
bool
dsdlib_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdlib_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
uint64_t
delta
)
offset_type
delta
)
{
{
if
(
delta
==
0
)
if
(
delta
==
0
)
return
true
;
return
true
;
...
...
src/decoder/plugins/DsdLib.hxx
View file @
e2adb82e
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#define MPD_DECODER_DSDLIB_HXX
#define MPD_DECODER_DSDLIB_HXX
#include "system/ByteOrder.hxx"
#include "system/ByteOrder.hxx"
#include "input/Offset.hxx"
#include "Compiler.h"
#include "Compiler.h"
#include <stddef.h>
#include <stddef.h>
...
@@ -60,11 +61,11 @@ public:
...
@@ -60,11 +61,11 @@ public:
bool
bool
dsdlib_skip_to
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdlib_skip_to
(
Decoder
*
decoder
,
InputStream
&
is
,
uint64_t
offset
);
offset_type
offset
);
bool
bool
dsdlib_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdlib_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
uint64_t
delta
);
offset_type
delta
);
/**
/**
* Check if the sample frequency is a valid DSD frequency.
* Check if the sample frequency is a valid DSD frequency.
...
...
src/decoder/plugins/DsdiffDecoderPlugin.cxx
View file @
e2adb82e
...
@@ -66,7 +66,7 @@ struct dsdiff_native_tag {
...
@@ -66,7 +66,7 @@ struct dsdiff_native_tag {
struct
DsdiffMetaData
{
struct
DsdiffMetaData
{
unsigned
sample_rate
,
channels
;
unsigned
sample_rate
,
channels
;
bool
bitreverse
;
bool
bitreverse
;
uint64_t
chunk_size
;
offset_type
chunk_size
;
};
};
static
bool
lsbitfirst
;
static
bool
lsbitfirst
;
...
@@ -113,7 +113,7 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
...
@@ -113,7 +113,7 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
offset_type
end_offset
)
offset_type
end_offset
)
{
{
DsdiffChunkHeader
header
;
DsdiffChunkHeader
header
;
while
(
offset_type
(
is
.
GetOffset
()
+
sizeof
(
header
)
)
<=
end_offset
)
{
while
(
is
.
GetOffset
()
+
sizeof
(
header
)
<=
end_offset
)
{
if
(
!
dsdiff_read_chunk_header
(
decoder
,
is
,
&
header
))
if
(
!
dsdiff_read_chunk_header
(
decoder
,
is
,
&
header
))
return
false
;
return
false
;
...
@@ -252,7 +252,7 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is,
...
@@ -252,7 +252,7 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is,
and record their position and size */
and record their position and size */
do
{
do
{
uint64_t
chunk_size
=
chunk_header
->
GetSize
();
offset_type
chunk_size
=
chunk_header
->
GetSize
();
/* DIIN chunk, is directly followed by other chunks */
/* DIIN chunk, is directly followed by other chunks */
if
(
chunk_header
->
id
.
Equals
(
"DIIN"
))
if
(
chunk_header
->
id
.
Equals
(
"DIIN"
))
...
@@ -328,12 +328,12 @@ dsdiff_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -328,12 +328,12 @@ dsdiff_read_metadata(Decoder *decoder, InputStream &is,
chunk_header
))
chunk_header
))
return
false
;
return
false
;
}
else
if
(
chunk_header
->
id
.
Equals
(
"DSD "
))
{
}
else
if
(
chunk_header
->
id
.
Equals
(
"DSD "
))
{
const
uint64_t
chunk_size
=
chunk_header
->
GetSize
();
const
offset_type
chunk_size
=
chunk_header
->
GetSize
();
metadata
->
chunk_size
=
chunk_size
;
metadata
->
chunk_size
=
chunk_size
;
return
true
;
return
true
;
}
else
{
}
else
{
/* ignore unknown chunk */
/* ignore unknown chunk */
const
uint64_t
chunk_size
=
chunk_header
->
GetSize
();
const
offset_type
chunk_size
=
chunk_header
->
GetSize
();
const
offset_type
chunk_end_offset
=
const
offset_type
chunk_end_offset
=
is
.
GetOffset
()
+
chunk_size
;
is
.
GetOffset
()
+
chunk_size
;
...
@@ -356,7 +356,7 @@ bit_reverse_buffer(uint8_t *p, uint8_t *end)
...
@@ -356,7 +356,7 @@ bit_reverse_buffer(uint8_t *p, uint8_t *end)
static
bool
static
bool
dsdiff_decode_chunk
(
Decoder
&
decoder
,
InputStream
&
is
,
dsdiff_decode_chunk
(
Decoder
&
decoder
,
InputStream
&
is
,
unsigned
channels
,
unsigned
sample_rate
,
unsigned
channels
,
unsigned
sample_rate
,
uint64_t
chunk_size
)
offset_type
chunk_size
)
{
{
uint8_t
buffer
[
8192
];
uint8_t
buffer
[
8192
];
...
@@ -370,9 +370,8 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
...
@@ -370,9 +370,8 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
/* see how much aligned data from the remaining chunk
/* see how much aligned data from the remaining chunk
fits into the local buffer */
fits into the local buffer */
size_t
now_size
=
buffer_size
;
size_t
now_size
=
buffer_size
;
if
(
chunk_size
<
(
uint64_t
)
now_size
)
{
if
(
chunk_size
<
(
offset_type
)
now_size
)
{
unsigned
now_frames
=
unsigned
now_frames
=
chunk_size
/
frame_size
;
(
unsigned
)
chunk_size
/
frame_size
;
now_size
=
now_frames
*
frame_size
;
now_size
=
now_frames
*
frame_size
;
}
}
...
@@ -425,7 +424,7 @@ dsdiff_stream_decode(Decoder &decoder, InputStream &is)
...
@@ -425,7 +424,7 @@ dsdiff_stream_decode(Decoder &decoder, InputStream &is)
}
}
/* calculate song time from DSD chunk size and sample frequency */
/* calculate song time from DSD chunk size and sample frequency */
uint64_t
chunk_size
=
metadata
.
chunk_size
;
offset_type
chunk_size
=
metadata
.
chunk_size
;
float
songtime
=
((
chunk_size
/
metadata
.
channels
)
*
8
)
/
float
songtime
=
((
chunk_size
/
metadata
.
channels
)
*
8
)
/
(
float
)
metadata
.
sample_rate
;
(
float
)
metadata
.
sample_rate
;
...
...
src/decoder/plugins/DsfDecoderPlugin.cxx
View file @
e2adb82e
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
struct
DsfMetaData
{
struct
DsfMetaData
{
unsigned
sample_rate
,
channels
;
unsigned
sample_rate
,
channels
;
bool
bitreverse
;
bool
bitreverse
;
uint64_t
chunk_size
;
offset_type
chunk_size
;
#ifdef HAVE_ID3TAG
#ifdef HAVE_ID3TAG
offset_type
id3_offset
;
offset_type
id3_offset
;
uint64_t
id3_size
;
uint64_t
id3_size
;
...
@@ -104,12 +104,12 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -104,12 +104,12 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
!
dsf_header
.
id
.
Equals
(
"DSD "
))
!
dsf_header
.
id
.
Equals
(
"DSD "
))
return
false
;
return
false
;
const
uint64_t
chunk_size
=
dsf_header
.
size
.
Read
();
const
offset_type
chunk_size
=
dsf_header
.
size
.
Read
();
if
(
sizeof
(
dsf_header
)
!=
chunk_size
)
if
(
sizeof
(
dsf_header
)
!=
chunk_size
)
return
false
;
return
false
;
#ifdef HAVE_ID3TAG
#ifdef HAVE_ID3TAG
const
uint64_t
metadata_offset
=
dsf_header
.
pmeta
.
Read
();
const
offset_type
metadata_offset
=
dsf_header
.
pmeta
.
Read
();
#endif
#endif
/* read the 'fmt ' chunk of the DSF file */
/* read the 'fmt ' chunk of the DSF file */
...
@@ -148,7 +148,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -148,7 +148,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
/* data size of DSF files are padded to multiple of 4096,
/* data size of DSF files are padded to multiple of 4096,
we use the actual data size as chunk size */
we use the actual data size as chunk size */
uint64_t
data_size
=
data_chunk
.
size
.
Read
();
offset_type
data_size
=
data_chunk
.
size
.
Read
();
if
(
data_size
<
sizeof
(
data_chunk
))
if
(
data_size
<
sizeof
(
data_chunk
))
return
false
;
return
false
;
...
@@ -156,7 +156,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -156,7 +156,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
/* data_size cannot be bigger or equal to total file size */
/* data_size cannot be bigger or equal to total file size */
if
(
is
.
KnownSize
())
{
if
(
is
.
KnownSize
())
{
const
uint64_t
size
=
(
uint64_t
)
is
.
GetSize
();
const
offset_type
size
=
is
.
GetSize
();
if
(
data_size
>=
size
)
if
(
data_size
>=
size
)
return
false
;
return
false
;
}
}
...
@@ -165,7 +165,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -165,7 +165,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
bound, because some DSF files contain junk at the end of
bound, because some DSF files contain junk at the end of
the "data" chunk */
the "data" chunk */
const
uint64_t
samplecnt
=
dsf_fmt_chunk
.
scnt
.
Read
();
const
uint64_t
samplecnt
=
dsf_fmt_chunk
.
scnt
.
Read
();
const
uint64_t
playable_size
=
samplecnt
*
2
/
8
;
const
offset_type
playable_size
=
samplecnt
*
2
/
8
;
if
(
data_size
>
playable_size
)
if
(
data_size
>
playable_size
)
data_size
=
playable_size
;
data_size
=
playable_size
;
...
@@ -173,7 +173,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -173,7 +173,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
metadata
->
channels
=
(
unsigned
)
dsf_fmt_chunk
.
channelnum
;
metadata
->
channels
=
(
unsigned
)
dsf_fmt_chunk
.
channelnum
;
metadata
->
sample_rate
=
samplefreq
;
metadata
->
sample_rate
=
samplefreq
;
#ifdef HAVE_ID3TAG
#ifdef HAVE_ID3TAG
metadata
->
id3_offset
=
(
offset_type
)
metadata_offset
;
metadata
->
id3_offset
=
metadata_offset
;
#endif
#endif
/* check bits per sample format, determine if bitreverse is needed */
/* check bits per sample format, determine if bitreverse is needed */
metadata
->
bitreverse
=
dsf_fmt_chunk
.
bitssample
==
1
;
metadata
->
bitreverse
=
dsf_fmt_chunk
.
bitssample
==
1
;
...
@@ -218,7 +218,7 @@ dsf_to_pcm_order(uint8_t *dest, uint8_t *scratch, size_t nrbytes)
...
@@ -218,7 +218,7 @@ dsf_to_pcm_order(uint8_t *dest, uint8_t *scratch, size_t nrbytes)
static
bool
static
bool
dsf_decode_chunk
(
Decoder
&
decoder
,
InputStream
&
is
,
dsf_decode_chunk
(
Decoder
&
decoder
,
InputStream
&
is
,
unsigned
channels
,
unsigned
sample_rate
,
unsigned
channels
,
unsigned
sample_rate
,
uint64_t
chunk_size
,
offset_type
chunk_size
,
bool
bitreverse
)
bool
bitreverse
)
{
{
uint8_t
buffer
[
8192
];
uint8_t
buffer
[
8192
];
...
@@ -237,9 +237,8 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
...
@@ -237,9 +237,8 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
/* see how much aligned data from the remaining chunk
/* see how much aligned data from the remaining chunk
fits into the local buffer */
fits into the local buffer */
size_t
now_size
=
buffer_size
;
size_t
now_size
=
buffer_size
;
if
(
chunk_size
<
(
uint64_t
)
now_size
)
{
if
(
chunk_size
<
now_size
)
{
unsigned
now_frames
=
unsigned
now_frames
=
chunk_size
/
frame_size
;
(
unsigned
)
chunk_size
/
frame_size
;
now_size
=
now_frames
*
frame_size
;
now_size
=
now_frames
*
frame_size
;
}
}
...
@@ -291,7 +290,7 @@ dsf_stream_decode(Decoder &decoder, InputStream &is)
...
@@ -291,7 +290,7 @@ dsf_stream_decode(Decoder &decoder, InputStream &is)
return
;
return
;
}
}
/* Calculate song time from DSD chunk size and sample frequency */
/* Calculate song time from DSD chunk size and sample frequency */
uint64_t
chunk_size
=
metadata
.
chunk_size
;
offset_type
chunk_size
=
metadata
.
chunk_size
;
float
songtime
=
((
chunk_size
/
metadata
.
channels
)
*
8
)
/
float
songtime
=
((
chunk_size
/
metadata
.
channels
)
*
8
)
/
(
float
)
metadata
.
sample_rate
;
(
float
)
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