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
fd3dc7e5
Commit
fd3dc7e5
authored
Oct 28, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/dsdlib: convert struct dsdlib_id to a class
parent
c37edfd3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
34 deletions
+35
-34
DsdLib.cxx
src/decoder/DsdLib.cxx
+3
-4
DsdLib.hxx
src/decoder/DsdLib.hxx
+6
-4
DsdiffDecoderPlugin.cxx
src/decoder/DsdiffDecoderPlugin.cxx
+20
-20
DsfDecoderPlugin.cxx
src/decoder/DsfDecoderPlugin.cxx
+6
-6
No files found.
src/decoder/DsdLib.cxx
View file @
fd3dc7e5
...
@@ -41,13 +41,12 @@
...
@@ -41,13 +41,12 @@
#endif
#endif
bool
bool
dsdlib_id_equals
(
const
struct
dsdlib_id
*
id
,
const
char
*
s
)
DsdId
::
Equals
(
const
char
*
s
)
const
{
{
assert
(
id
!=
nullptr
);
assert
(
s
!=
nullptr
);
assert
(
s
!=
nullptr
);
assert
(
strlen
(
s
)
==
sizeof
(
id
->
value
));
assert
(
strlen
(
s
)
==
sizeof
(
value
));
return
memcmp
(
id
->
value
,
s
,
sizeof
(
id
->
value
))
==
0
;
return
memcmp
(
value
,
s
,
sizeof
(
value
))
==
0
;
}
}
bool
bool
...
...
src/decoder/DsdLib.hxx
View file @
fd3dc7e5
...
@@ -20,18 +20,20 @@
...
@@ -20,18 +20,20 @@
#ifndef MPD_DECODER_DSDLIB_HXX
#ifndef MPD_DECODER_DSDLIB_HXX
#define MPD_DECODER_DSDLIB_HXX
#define MPD_DECODER_DSDLIB_HXX
#include "Compiler.h"
#include <stdlib.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdint.h>
struct
Decoder
;
struct
Decoder
;
struct
InputStream
;
struct
InputStream
;
struct
dsdlib_i
d
{
struct
DsdI
d
{
char
value
[
4
];
char
value
[
4
];
};
bool
gcc_pure
dsdlib_id_equals
(
const
struct
dsdlib_id
*
id
,
const
char
*
s
);
bool
Equals
(
const
char
*
s
)
const
;
};
bool
bool
dsdlib_read
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdlib_read
(
Decoder
*
decoder
,
InputStream
&
is
,
...
...
src/decoder/DsdiffDecoderPlugin.cxx
View file @
fd3dc7e5
...
@@ -42,13 +42,13 @@
...
@@ -42,13 +42,13 @@
#include <stdio.h>
/* for SEEK_SET, SEEK_CUR */
#include <stdio.h>
/* for SEEK_SET, SEEK_CUR */
struct
DsdiffHeader
{
struct
DsdiffHeader
{
struct
dsdlib_i
d
id
;
DsdI
d
id
;
uint32_t
size_high
,
size_low
;
uint32_t
size_high
,
size_low
;
struct
dsdlib_i
d
format
;
DsdI
d
format
;
};
};
struct
DsdiffChunkHeader
{
struct
DsdiffChunkHeader
{
struct
dsdlib_i
d
id
;
DsdI
d
id
;
uint32_t
size_high
,
size_low
;
uint32_t
size_high
,
size_low
;
/**
/**
...
@@ -92,7 +92,7 @@ dsdiff_init(const config_param ¶m)
...
@@ -92,7 +92,7 @@ dsdiff_init(const config_param ¶m)
static
bool
static
bool
dsdiff_read_id
(
Decoder
*
decoder
,
InputStream
&
is
,
dsdiff_read_id
(
Decoder
*
decoder
,
InputStream
&
is
,
struct
dsdlib_i
d
*
id
)
DsdI
d
*
id
)
{
{
return
dsdlib_read
(
decoder
,
is
,
id
,
sizeof
(
*
id
));
return
dsdlib_read
(
decoder
,
is
,
id
,
sizeof
(
*
id
));
}
}
...
@@ -135,7 +135,7 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
...
@@ -135,7 +135,7 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
if
(
chunk_end_offset
>
end_offset
)
if
(
chunk_end_offset
>
end_offset
)
return
false
;
return
false
;
if
(
dsdlib_id_equals
(
&
header
.
id
,
"FS "
))
{
if
(
header
.
id
.
Equals
(
"FS "
))
{
uint32_t
sample_rate
;
uint32_t
sample_rate
;
if
(
!
dsdiff_read_payload
(
decoder
,
is
,
&
header
,
if
(
!
dsdiff_read_payload
(
decoder
,
is
,
&
header
,
&
sample_rate
,
&
sample_rate
,
...
@@ -143,7 +143,7 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
...
@@ -143,7 +143,7 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
return
false
;
return
false
;
metadata
->
sample_rate
=
FromBE32
(
sample_rate
);
metadata
->
sample_rate
=
FromBE32
(
sample_rate
);
}
else
if
(
dsdlib_id_equals
(
&
header
.
id
,
"CHNL"
))
{
}
else
if
(
header
.
id
.
Equals
(
"CHNL"
))
{
uint16_t
channels
;
uint16_t
channels
;
if
(
header
.
GetSize
()
<
sizeof
(
channels
)
||
if
(
header
.
GetSize
()
<
sizeof
(
channels
)
||
!
dsdlib_read
(
decoder
,
is
,
!
dsdlib_read
(
decoder
,
is
,
...
@@ -152,15 +152,15 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
...
@@ -152,15 +152,15 @@ dsdiff_read_prop_snd(Decoder *decoder, InputStream &is,
return
false
;
return
false
;
metadata
->
channels
=
FromBE16
(
channels
);
metadata
->
channels
=
FromBE16
(
channels
);
}
else
if
(
dsdlib_id_equals
(
&
header
.
id
,
"CMPR"
))
{
}
else
if
(
header
.
id
.
Equals
(
"CMPR"
))
{
struct
dsdlib_i
d
type
;
DsdI
d
type
;
if
(
header
.
GetSize
()
<
sizeof
(
type
)
||
if
(
header
.
GetSize
()
<
sizeof
(
type
)
||
!
dsdlib_read
(
decoder
,
is
,
!
dsdlib_read
(
decoder
,
is
,
&
type
,
sizeof
(
type
))
||
&
type
,
sizeof
(
type
))
||
!
dsdlib_skip_to
(
decoder
,
is
,
chunk_end_offset
))
!
dsdlib_skip_to
(
decoder
,
is
,
chunk_end_offset
))
return
false
;
return
false
;
if
(
!
dsdlib_id_equals
(
&
type
,
"DSD "
))
if
(
!
type
.
Equals
(
"DSD "
))
/* only uncompressed DSD audio data
/* only uncompressed DSD audio data
is implemented */
is implemented */
return
false
;
return
false
;
...
@@ -186,12 +186,12 @@ dsdiff_read_prop(Decoder *decoder, InputStream &is,
...
@@ -186,12 +186,12 @@ dsdiff_read_prop(Decoder *decoder, InputStream &is,
uint64_t
prop_size
=
prop_header
->
GetSize
();
uint64_t
prop_size
=
prop_header
->
GetSize
();
InputStream
::
offset_type
end_offset
=
is
.
GetOffset
()
+
prop_size
;
InputStream
::
offset_type
end_offset
=
is
.
GetOffset
()
+
prop_size
;
struct
dsdlib_i
d
prop_id
;
DsdI
d
prop_id
;
if
(
prop_size
<
sizeof
(
prop_id
)
||
if
(
prop_size
<
sizeof
(
prop_id
)
||
!
dsdiff_read_id
(
decoder
,
is
,
&
prop_id
))
!
dsdiff_read_id
(
decoder
,
is
,
&
prop_id
))
return
false
;
return
false
;
if
(
dsdlib_id_equals
(
&
prop_id
,
"SND "
))
if
(
prop_id
.
Equals
(
"SND "
))
return
dsdiff_read_prop_snd
(
decoder
,
is
,
metadata
,
end_offset
);
return
dsdiff_read_prop_snd
(
decoder
,
is
,
metadata
,
end_offset
);
else
else
/* ignore unknown PROP chunk */
/* ignore unknown PROP chunk */
...
@@ -264,23 +264,23 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is,
...
@@ -264,23 +264,23 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is,
uint64_t
chunk_size
=
chunk_header
->
GetSize
();
uint64_t
chunk_size
=
chunk_header
->
GetSize
();
/* DIIN chunk, is directly followed by other chunks */
/* DIIN chunk, is directly followed by other chunks */
if
(
dsdlib_id_equals
(
&
chunk_header
->
id
,
"DIIN"
))
if
(
chunk_header
->
id
.
Equals
(
"DIIN"
))
chunk_size
=
0
;
chunk_size
=
0
;
/* DIAR chunk - DSDIFF native tag for Artist */
/* DIAR chunk - DSDIFF native tag for Artist */
if
(
dsdlib_id_equals
(
&
chunk_header
->
id
,
"DIAR"
))
{
if
(
chunk_header
->
id
.
Equals
(
"DIAR"
))
{
chunk_size
=
chunk_header
->
GetSize
();
chunk_size
=
chunk_header
->
GetSize
();
metadata
->
diar_offset
=
is
.
GetOffset
();
metadata
->
diar_offset
=
is
.
GetOffset
();
}
}
/* DITI chunk - DSDIFF native tag for Title */
/* DITI chunk - DSDIFF native tag for Title */
if
(
dsdlib_id_equals
(
&
chunk_header
->
id
,
"DITI"
))
{
if
(
chunk_header
->
id
.
Equals
(
"DITI"
))
{
chunk_size
=
chunk_header
->
GetSize
();
chunk_size
=
chunk_header
->
GetSize
();
metadata
->
diti_offset
=
is
.
GetOffset
();
metadata
->
diti_offset
=
is
.
GetOffset
();
}
}
#ifdef HAVE_ID3TAG
#ifdef HAVE_ID3TAG
/* 'ID3 ' chunk, offspec. Used by sacdextract */
/* 'ID3 ' chunk, offspec. Used by sacdextract */
if
(
dsdlib_id_equals
(
&
chunk_header
->
id
,
"ID3 "
))
{
if
(
chunk_header
->
id
.
Equals
(
"ID3 "
))
{
chunk_size
=
chunk_header
->
GetSize
();
chunk_size
=
chunk_header
->
GetSize
();
metadata
->
id3_offset
=
is
.
GetOffset
();
metadata
->
id3_offset
=
is
.
GetOffset
();
metadata
->
id3_size
=
chunk_size
;
metadata
->
id3_size
=
chunk_size
;
...
@@ -331,8 +331,8 @@ dsdiff_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -331,8 +331,8 @@ dsdiff_read_metadata(Decoder *decoder, InputStream &is,
{
{
DsdiffHeader
header
;
DsdiffHeader
header
;
if
(
!
dsdlib_read
(
decoder
,
is
,
&
header
,
sizeof
(
header
))
||
if
(
!
dsdlib_read
(
decoder
,
is
,
&
header
,
sizeof
(
header
))
||
!
dsdlib_id_equals
(
&
header
.
id
,
"FRM8"
)
||
!
header
.
id
.
Equals
(
"FRM8"
)
||
!
dsdlib_id_equals
(
&
header
.
format
,
"DSD "
))
!
header
.
format
.
Equals
(
"DSD "
))
return
false
;
return
false
;
while
(
true
)
{
while
(
true
)
{
...
@@ -340,11 +340,11 @@ dsdiff_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -340,11 +340,11 @@ dsdiff_read_metadata(Decoder *decoder, InputStream &is,
chunk_header
))
chunk_header
))
return
false
;
return
false
;
if
(
dsdlib_id_equals
(
&
chunk_header
->
id
,
"PROP"
))
{
if
(
chunk_header
->
id
.
Equals
(
"PROP"
))
{
if
(
!
dsdiff_read_prop
(
decoder
,
is
,
metadata
,
if
(
!
dsdiff_read_prop
(
decoder
,
is
,
metadata
,
chunk_header
))
chunk_header
))
return
false
;
return
false
;
}
else
if
(
dsdlib_id_equals
(
&
chunk_header
->
id
,
"DSD "
))
{
}
else
if
(
chunk_header
->
id
.
Equals
(
"DSD "
))
{
const
uint64_t
chunk_size
=
chunk_header
->
GetSize
();
const
uint64_t
chunk_size
=
chunk_header
->
GetSize
();
metadata
->
chunk_size
=
chunk_size
;
metadata
->
chunk_size
=
chunk_size
;
return
true
;
return
true
;
...
@@ -454,7 +454,7 @@ dsdiff_stream_decode(Decoder &decoder, InputStream &is)
...
@@ -454,7 +454,7 @@ dsdiff_stream_decode(Decoder &decoder, InputStream &is)
while
(
true
)
{
while
(
true
)
{
chunk_size
=
chunk_header
.
GetSize
();
chunk_size
=
chunk_header
.
GetSize
();
if
(
dsdlib_id_equals
(
&
chunk_header
.
id
,
"DSD "
))
{
if
(
chunk_header
.
id
.
Equals
(
"DSD "
))
{
if
(
!
dsdiff_decode_chunk
(
decoder
,
is
,
if
(
!
dsdiff_decode_chunk
(
decoder
,
is
,
metadata
.
channels
,
metadata
.
channels
,
chunk_size
))
chunk_size
))
...
...
src/decoder/DsfDecoderPlugin.cxx
View file @
fd3dc7e5
...
@@ -54,7 +54,7 @@ struct DsfMetaData {
...
@@ -54,7 +54,7 @@ struct DsfMetaData {
struct
DsfHeader
{
struct
DsfHeader
{
/** DSF header id: "DSD " */
/** DSF header id: "DSD " */
struct
dsdlib_i
d
id
;
DsdI
d
id
;
/** DSD chunk size, including id = 28 */
/** DSD chunk size, including id = 28 */
uint32_t
size_low
,
size_high
;
uint32_t
size_low
,
size_high
;
/** total file size */
/** total file size */
...
@@ -66,7 +66,7 @@ struct DsfHeader {
...
@@ -66,7 +66,7 @@ struct DsfHeader {
/** DSF file fmt chunk */
/** DSF file fmt chunk */
struct
DsfFmtChunk
{
struct
DsfFmtChunk
{
/** id: "fmt " */
/** id: "fmt " */
struct
dsdlib_i
d
id
;
DsdI
d
id
;
/** fmt chunk size, including id, normally 52 */
/** fmt chunk size, including id, normally 52 */
uint32_t
size_low
,
size_high
;
uint32_t
size_low
,
size_high
;
/** version of this format = 1 */
/** version of this format = 1 */
...
@@ -90,7 +90,7 @@ struct DsfFmtChunk {
...
@@ -90,7 +90,7 @@ struct DsfFmtChunk {
};
};
struct
DsfDataChunk
{
struct
DsfDataChunk
{
struct
dsdlib_i
d
id
;
DsdI
d
id
;
/** "data" chunk size, includes header (id+size) */
/** "data" chunk size, includes header (id+size) */
uint32_t
size_low
,
size_high
;
uint32_t
size_low
,
size_high
;
};
};
...
@@ -105,7 +105,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -105,7 +105,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
uint64_t
chunk_size
;
uint64_t
chunk_size
;
DsfHeader
dsf_header
;
DsfHeader
dsf_header
;
if
(
!
dsdlib_read
(
decoder
,
is
,
&
dsf_header
,
sizeof
(
dsf_header
))
||
if
(
!
dsdlib_read
(
decoder
,
is
,
&
dsf_header
,
sizeof
(
dsf_header
))
||
!
ds
dlib_id_equals
(
&
dsf_header
.
id
,
"DSD "
))
!
ds
f_header
.
id
.
Equals
(
"DSD "
))
return
false
;
return
false
;
chunk_size
=
(
uint64_t
(
FromLE32
(
dsf_header
.
size_high
))
<<
32
)
|
chunk_size
=
(
uint64_t
(
FromLE32
(
dsf_header
.
size_high
))
<<
32
)
|
...
@@ -123,7 +123,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -123,7 +123,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
/* read the 'fmt ' chunk of the DSF file */
/* read the 'fmt ' chunk of the DSF file */
DsfFmtChunk
dsf_fmt_chunk
;
DsfFmtChunk
dsf_fmt_chunk
;
if
(
!
dsdlib_read
(
decoder
,
is
,
&
dsf_fmt_chunk
,
sizeof
(
dsf_fmt_chunk
))
||
if
(
!
dsdlib_read
(
decoder
,
is
,
&
dsf_fmt_chunk
,
sizeof
(
dsf_fmt_chunk
))
||
!
ds
dlib_id_equals
(
&
dsf_fmt_chunk
.
id
,
"fmt "
))
!
ds
f_fmt_chunk
.
id
.
Equals
(
"fmt "
))
return
false
;
return
false
;
uint64_t
fmt_chunk_size
;
uint64_t
fmt_chunk_size
;
...
@@ -152,7 +152,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
...
@@ -152,7 +152,7 @@ dsf_read_metadata(Decoder *decoder, InputStream &is,
/* read the 'data' chunk of the DSF file */
/* read the 'data' chunk of the DSF file */
DsfDataChunk
data_chunk
;
DsfDataChunk
data_chunk
;
if
(
!
dsdlib_read
(
decoder
,
is
,
&
data_chunk
,
sizeof
(
data_chunk
))
||
if
(
!
dsdlib_read
(
decoder
,
is
,
&
data_chunk
,
sizeof
(
data_chunk
))
||
!
d
sdlib_id_equals
(
&
data_chunk
.
id
,
"data"
))
!
d
ata_chunk
.
id
.
Equals
(
"data"
))
return
false
;
return
false
;
/* data size of DSF files are padded to multiple of 4096,
/* data size of DSF files are padded to multiple of 4096,
...
...
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