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
cac3c159
Commit
cac3c159
authored
Jul 29, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm_dsd: convert to C++
parent
43166130
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
54 additions
and
64 deletions
+54
-64
Makefile.am
Makefile.am
+2
-2
PcmConvert.cxx
src/pcm/PcmConvert.cxx
+4
-7
PcmConvert.hxx
src/pcm/PcmConvert.hxx
+2
-2
PcmDsd.cxx
src/pcm/PcmDsd.cxx
+28
-28
PcmDsd.hxx
src/pcm/PcmDsd.hxx
+11
-17
PcmDsdUsb.cxx
src/pcm/PcmDsdUsb.cxx
+3
-3
PcmDsdUsb.hxx
src/pcm/PcmDsdUsb.hxx
+3
-4
PcmExport.cxx
src/pcm/PcmExport.cxx
+1
-1
No files found.
Makefile.am
View file @
cac3c159
...
...
@@ -307,8 +307,8 @@ libpcm_a_SOURCES = \
src/pcm/PcmExport.cxx src/pcm/PcmExport.hxx
\
src/pcm/PcmConvert.cxx src/pcm/PcmConvert.hxx
\
src/pcm/dsd2pcm/dsd2pcm.c src/pcm/dsd2pcm/dsd2pcm.h
\
src/pcm/
pcm_dsd.c src/pcm/pcm_dsd.h
\
src/pcm/
pcm_dsd_usb.c src/pcm/pcm_dsd_usb.h
\
src/pcm/
PcmDsd.cxx src/pcm/PcmDsd.hxx
\
src/pcm/
PcmDsdUsb.cxx src/pcm/PcmDsdUsb.hxx
\
src/pcm/PcmVolume.cxx src/pcm/PcmVolume.hxx
\
src/pcm/PcmMix.cxx src/pcm/PcmMix.hxx
\
src/pcm/PcmChannels.cxx src/pcm/PcmChannels.hxx
\
...
...
src/pcm/PcmConvert.cxx
View file @
cac3c159
...
...
@@ -36,7 +36,6 @@ PcmConvert::PcmConvert()
{
memset
(
this
,
0
,
sizeof
(
*
this
));
pcm_dsd_init
(
&
dsd
);
pcm_resample_init
(
&
resample
);
pcm_buffer_init
(
&
format_buffer
);
...
...
@@ -45,7 +44,6 @@ PcmConvert::PcmConvert()
PcmConvert
::~
PcmConvert
()
{
pcm_dsd_deinit
(
&
dsd
);
pcm_resample_deinit
(
&
resample
);
pcm_buffer_deinit
(
&
format_buffer
);
...
...
@@ -55,7 +53,7 @@ PcmConvert::~PcmConvert()
void
PcmConvert
::
Reset
()
{
pcm_dsd_reset
(
&
dsd
);
dsd
.
Reset
(
);
pcm_resample_reset
(
&
resample
);
}
...
...
@@ -278,10 +276,9 @@ PcmConvert::Convert(const audio_format *src_format,
struct
audio_format
float_format
;
if
(
src_format
->
format
==
SAMPLE_FORMAT_DSD
)
{
size_t
f_size
;
const
float
*
f
=
pcm_dsd_to_float
(
&
dsd
,
src_format
->
channels
,
false
,
(
const
uint8_t
*
)
src
,
src_size
,
&
f_size
);
const
float
*
f
=
dsd
.
ToFloat
(
src_format
->
channels
,
false
,
(
const
uint8_t
*
)
src
,
src_size
,
&
f_size
);
if
(
f
==
NULL
)
{
g_set_error_literal
(
error_r
,
pcm_convert_quark
(),
0
,
"DSD to PCM conversion failed"
);
...
...
src/pcm/PcmConvert.hxx
View file @
cac3c159
...
...
@@ -21,9 +21,9 @@
#define PCM_CONVERT_HXX
#include "PcmDither.hxx"
#include "PcmDsd.hxx"
extern
"C"
{
#include "pcm_dsd.h"
#include "pcm_resample.h"
#include "pcm_buffer.h"
}
...
...
@@ -38,7 +38,7 @@ struct audio_format;
* conversions.
*/
class
PcmConvert
{
struct
pcm_d
sd
dsd
;
PcmD
sd
dsd
;
struct
pcm_resample_state
resample
;
...
...
src/pcm/
pcm_dsd.c
→
src/pcm/
PcmDsd.cxx
View file @
cac3c159
/*
* Copyright (C) 2003-201
2
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,48 +18,48 @@
*/
#include "config.h"
#include "
pcm_dsd.h
"
#include "
PcmDsd.hxx
"
#include "dsd2pcm/dsd2pcm.h"
#include <glib.h>
#include <algorithm>
#include <string.h>
void
pcm_dsd_init
(
struct
pcm_dsd
*
dsd
)
PcmDsd
::
PcmDsd
()
{
pcm_buffer_init
(
&
dsd
->
buffer
);
pcm_buffer_init
(
&
buffer
);
memset
(
dsd
->
dsd2pcm
,
0
,
sizeof
(
dsd
->
dsd2pcm
)
);
std
::
fill_n
(
dsd2pcm
,
G_N_ELEMENTS
(
dsd2pcm
),
nullptr
);
}
void
pcm_dsd_deinit
(
struct
pcm_dsd
*
dsd
)
PcmDsd
::~
PcmDsd
()
{
pcm_buffer_deinit
(
&
dsd
->
buffer
);
pcm_buffer_deinit
(
&
buffer
);
for
(
unsigned
i
=
0
;
i
<
G_N_ELEMENTS
(
dsd
->
dsd
2pcm
);
++
i
)
if
(
dsd
->
dsd2pcm
[
i
]
!=
NULL
)
dsd2pcm_destroy
(
dsd
->
dsd
2pcm
[
i
]);
for
(
unsigned
i
=
0
;
i
<
G_N_ELEMENTS
(
dsd2pcm
);
++
i
)
if
(
dsd
2pcm
[
i
]
!=
nullptr
)
dsd2pcm_destroy
(
dsd2pcm
[
i
]);
}
void
pcm_dsd_reset
(
struct
pcm_dsd
*
dsd
)
PcmDsd
::
Reset
(
)
{
for
(
unsigned
i
=
0
;
i
<
G_N_ELEMENTS
(
dsd
->
dsd
2pcm
);
++
i
)
if
(
dsd
->
dsd2pcm
[
i
]
!=
NULL
)
dsd2pcm_reset
(
dsd
->
dsd
2pcm
[
i
]);
for
(
unsigned
i
=
0
;
i
<
G_N_ELEMENTS
(
dsd2pcm
);
++
i
)
if
(
dsd
2pcm
[
i
]
!=
nullptr
)
dsd2pcm_reset
(
dsd2pcm
[
i
]);
}
const
float
*
pcm_dsd_to_float
(
struct
pcm_dsd
*
dsd
,
unsigned
channels
,
bool
lsbfirst
,
const
uint8_t
*
src
,
size_t
src_size
,
size_t
*
dest_size_r
)
PcmDsd
::
ToFloat
(
unsigned
channels
,
bool
lsbfirst
,
const
uint8_t
*
src
,
size_t
src_size
,
size_t
*
dest_size_r
)
{
assert
(
dsd
!=
NULL
);
assert
(
src
!=
NULL
);
assert
(
src
!=
nullptr
);
assert
(
src_size
>
0
);
assert
(
src_size
%
channels
==
0
);
assert
(
channels
<=
G_N_ELEMENTS
(
dsd
->
dsd
2pcm
));
assert
(
channels
<=
G_N_ELEMENTS
(
dsd2pcm
));
const
unsigned
num_samples
=
src_size
;
const
unsigned
num_frames
=
src_size
/
channels
;
...
...
@@ -67,16 +67,16 @@ pcm_dsd_to_float(struct pcm_dsd *dsd, unsigned channels, bool lsbfirst,
float
*
dest
;
const
size_t
dest_size
=
num_samples
*
sizeof
(
*
dest
);
*
dest_size_r
=
dest_size
;
dest
=
pcm_buffer_get
(
&
dsd
->
buffer
,
dest_size
);
dest
=
(
float
*
)
pcm_buffer_get
(
&
buffer
,
dest_size
);
for
(
unsigned
c
=
0
;
c
<
channels
;
++
c
)
{
if
(
dsd
->
dsd2pcm
[
c
]
==
NULL
)
{
dsd
->
dsd
2pcm
[
c
]
=
dsd2pcm_init
();
if
(
dsd
->
dsd2pcm
[
c
]
==
NULL
)
return
NULL
;
if
(
dsd
2pcm
[
c
]
==
nullptr
)
{
dsd2pcm
[
c
]
=
dsd2pcm_init
();
if
(
dsd
2pcm
[
c
]
==
nullptr
)
return
nullptr
;
}
dsd2pcm_translate
(
dsd
->
dsd
2pcm
[
c
],
num_frames
,
dsd2pcm_translate
(
dsd2pcm
[
c
],
num_frames
,
src
+
c
,
channels
,
lsbfirst
,
dest
+
c
,
channels
);
}
...
...
src/pcm/
pcm_dsd.h
→
src/pcm/
PcmDsd.hxx
View file @
cac3c159
/*
* Copyright (C) 2003-201
2
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,36 +17,30 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_PCM_DSD_H
#define MPD_PCM_DSD_H
#ifndef MPD_PCM_DSD_H
XX
#define MPD_PCM_DSD_H
XX
#include "check.h"
#include "pcm_buffer.h"
#include <stdbool.h>
#include <stdint.h>
/**
* Wrapper for the dsd2pcm library.
*/
struct
pcm_d
sd
{
struct
PcmD
sd
{
struct
pcm_buffer
buffer
;
struct
dsd2pcm_ctx_s
*
dsd2pcm
[
32
];
};
void
pcm_dsd_init
(
struct
pcm_dsd
*
dsd
);
void
pcm_dsd_deinit
(
struct
pcm_dsd
*
dsd
);
PcmDsd
();
~
PcmDsd
(
);
void
pcm_dsd_reset
(
struct
pcm_dsd
*
dsd
);
void
Reset
();
const
float
*
pcm_dsd_to_float
(
struct
pcm_dsd
*
dsd
,
unsigned
channels
,
bool
lsbfirst
,
const
uint8_t
*
src
,
size_t
src_size
,
size_t
*
dest_size_r
)
;
const
float
*
ToFloat
(
unsigned
channels
,
bool
lsbfirst
,
const
uint8_t
*
src
,
size_t
src_size
,
size_t
*
dest_size_r
);
}
;
#endif
src/pcm/
pcm_dsd_usb.c
→
src/pcm/
PcmDsdUsb.cxx
View file @
cac3c159
/*
* Copyright (C) 2003-201
2
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,7 +18,7 @@
*/
#include "config.h"
#include "
pcm_dsd_usb.h
"
#include "
PcmDsdUsb.hxx
"
#include "pcm_buffer.h"
#include "audio_format.h"
...
...
@@ -58,7 +58,7 @@ pcm_dsd_to_usb(struct pcm_buffer *buffer, unsigned channels,
const
size_t
dest_size
=
num_samples
*
4
;
*
dest_size_r
=
dest_size
;
uint32_t
*
const
dest0
=
pcm_buffer_get
(
buffer
,
dest_size
),
uint32_t
*
const
dest0
=
(
uint32_t
*
)
pcm_buffer_get
(
buffer
,
dest_size
),
*
dest
=
dest0
;
for
(
unsigned
i
=
num_frames
/
2
;
i
>
0
;
--
i
)
{
...
...
src/pcm/
pcm_dsd_usb.h
→
src/pcm/
PcmDsdUsb.hxx
View file @
cac3c159
/*
* Copyright (C) 2003-201
2
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,12 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_PCM_DSD_USB_H
#define MPD_PCM_DSD_USB_H
#ifndef MPD_PCM_DSD_USB_H
XX
#define MPD_PCM_DSD_USB_H
XX
#include "check.h"
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
...
...
src/pcm/PcmExport.cxx
View file @
cac3c159
...
...
@@ -19,9 +19,9 @@
#include "config.h"
#include "PcmExport.hxx"
#include "PcmDsdUsb.hxx"
extern
"C"
{
#include "pcm_dsd_usb.h"
#include "pcm_pack.h"
#include "util/byte_reverse.h"
}
...
...
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