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
8a4b88a5
Commit
8a4b88a5
authored
Feb 16, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
encoder/wave: use the structs from RiffFormat.hxx
parent
d2371af1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
28 deletions
+20
-28
WaveEncoderPlugin.cxx
src/encoder/plugins/WaveEncoderPlugin.cxx
+20
-28
No files found.
src/encoder/plugins/WaveEncoderPlugin.cxx
View file @
8a4b88a5
...
...
@@ -19,6 +19,7 @@
#include "WaveEncoderPlugin.hxx"
#include "../EncoderAPI.hxx"
#include "tag/RiffFormat.hxx"
#include "util/ByteOrder.hxx"
#include "util/DynamicFifoBuffer.hxx"
...
...
@@ -26,8 +27,6 @@
#include <string.h>
static
constexpr
uint16_t
WAVE_FORMAT_PCM
=
1
;
class
WaveEncoder
final
:
public
Encoder
{
unsigned
bits
;
...
...
@@ -56,19 +55,10 @@ class PreparedWaveEncoder final : public PreparedEncoder {
};
struct
WaveHeader
{
uint32_t
id_riff
;
uint32_t
riff_size
;
uint32_t
id_wave
;
uint32_t
id_fmt
;
uint32_t
fmt_size
;
uint16_t
format
;
uint16_t
channels
;
uint32_t
freq
;
uint32_t
byterate
;
uint16_t
blocksize
;
uint16_t
bits
;
uint32_t
id_data
;
uint32_t
data_size
;
RiffFileHeader
file_header
;
RiffChunkHeader
fmt_header
;
RiffFmtChunk
fmt
;
RiffChunkHeader
data_header
;
};
static_assert
(
sizeof
(
WaveHeader
)
==
44
);
...
...
@@ -82,23 +72,25 @@ MakeWaveHeader(int channels, int bits,
int
data_size
=
0x0FFFFFFF
;
/* constants */
header
.
id_riff
=
ToLE32
(
0x46464952
);
header
.
id_wave
=
ToLE32
(
0x45564157
);
header
.
id_fmt
=
ToLE32
(
0x20746d66
);
header
.
id_data
=
ToLE32
(
0x6174616
4
);
memcpy
(
header
.
file_header
.
id
,
"RIFF"
,
4
);
memcpy
(
header
.
file_header
.
format
,
"WAVE"
,
4
);
memcpy
(
header
.
fmt_header
.
id
,
"fmt "
,
4
);
memcpy
(
header
.
data_header
.
id
,
"data"
,
4
);
/* wave format */
header
.
f
ormat
=
ToLE16
(
WAVE_FORMAT
_PCM
);
header
.
channels
=
ToLE16
(
channels
);
header
.
bits
=
ToLE16
(
bits
);
header
.
f
req
=
ToLE32
(
freq
);
header
.
blocksize
=
ToLE16
(
block_size
);
header
.
byte
rate
=
ToLE32
(
freq
*
block_size
);
header
.
f
mt
.
tag
=
ToLE16
(
RiffFmtChunk
::
TAG
_PCM
);
header
.
fmt
.
channels
=
ToLE16
(
channels
);
header
.
fmt
.
bits_per_sample
=
ToLE16
(
bits
);
header
.
f
mt
.
sample_rate
=
ToLE32
(
freq
);
header
.
fmt
.
block_align
=
ToLE16
(
block_size
);
header
.
fmt
.
byte_
rate
=
ToLE32
(
freq
*
block_size
);
/* chunk sizes (fake data length) */
header
.
fmt_size
=
ToLE32
(
16
);
header
.
data_size
=
ToLE32
(
data_size
);
header
.
riff_size
=
ToLE32
(
4
+
(
8
+
16
)
+
(
8
+
data_size
));
header
.
fmt_header
.
size
=
ToLE32
(
sizeof
(
header
.
fmt
));
header
.
data_header
.
size
=
ToLE32
(
data_size
);
header
.
file_header
.
size
=
ToLE32
(
4
+
sizeof
(
header
.
fmt_header
)
+
sizeof
(
header
.
fmt
)
+
sizeof
(
header
.
data_header
)
+
data_size
);
return
header
;
}
...
...
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