Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ESP32-audioI2S
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ESP32-audioI2S
Commits
2b7125c1
Commit
2b7125c1
authored
May 18, 2024
by
schreibfaul1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync OggS
now working:
http://hd.stream.frequence3.net/frequence3.flac
parent
07ca78a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
13 deletions
+22
-13
src/flac_decoder/flac_decoder.cpp
src/flac_decoder/flac_decoder.cpp
+20
-12
src/flac_decoder/flac_decoder.h
src/flac_decoder/flac_decoder.h
+2
-1
No files found.
src/flac_decoder/flac_decoder.cpp
View file @
2b7125c1
...
...
@@ -4,7 +4,7 @@
* adapted to ESP32
*
* Created on: Jul 03,2020
* Updated on:
Apr 12
,2024
* Updated on:
May 18
,2024
*
* Author: Wolle
*
...
...
@@ -215,17 +215,19 @@ void FLACDecoderReset(){ // set var to default
}
//----------------------------------------------------------------------------------------------------------------------
int
FLACFindSyncWord
(
unsigned
char
*
buf
,
int
nBytes
)
{
int
i
;
i
=
FLAC_specialIndexOf
(
buf
,
"OggS"
,
nBytes
);
if
(
i
==
0
){
// flag has ogg wrapper
return
0
;
}
/* find byte-aligned sync code - need 14 matching bits */
for
(
i
=
0
;
i
<
nBytes
-
1
;
i
++
)
{
if
((
buf
[
i
+
0
]
&
0xFF
)
==
0xFF
&&
(
buf
[
i
+
1
]
&
0xFC
)
==
0xF8
)
{
// <14> Sync code '11111111111110xx'
FLACDecoderReset
();
return
i
;
int
i
=
FLAC_specialIndexOf
(
buf
,
"OggS"
,
nBytes
);
if
(
i
==
0
)
return
0
;
// flag has ogg wrapper
if
(
s_f_oggWrapper
)
return
i
;
else
{
/* find byte-aligned sync code - need 14 matching bits */
for
(
i
=
0
;
i
<
nBytes
-
1
;
i
++
)
{
if
((
buf
[
i
+
0
]
&
0xFF
)
==
0xFF
&&
(
buf
[
i
+
1
]
&
0xFC
)
==
0xF8
)
{
// <14> Sync code '11111111111110xx'
FLACDecoderReset
();
return
i
;
}
}
}
return
-
1
;
...
...
@@ -451,6 +453,7 @@ int parseMetaDataBlockHeader(uint8_t *inbuf, int16_t nBytes){
bitsPerSample
=
(
*
(
inbuf
+
pos
+
12
)
&
0x01
)
<<
5
;
bitsPerSample
+=
((
*
(
inbuf
+
pos
+
13
)
&
0xF0
)
>>
4
)
+
1
;
FLACMetadataBlock
->
bitsPerSample
=
bitsPerSample
;
//log_i("bitsPerSample %i", bitsPerSample);
totalSamplesInStream
=
(
uint64_t
)(
*
(
inbuf
+
pos
+
17
)
&
0x0F
)
<<
32
;
...
...
@@ -762,6 +765,11 @@ int8_t FLACDecodeNative(uint8_t *inbuf, int *bytesLeft, short *outbuf){
}
//----------------------------------------------------------------------------------------------------------------------
int8_t
flacDecodeFrame
(
uint8_t
*
inbuf
,
int
*
bytesLeft
){
if
(
FLAC_specialIndexOf
(
inbuf
,
"OggS"
,
*
bytesLeft
)
==
0
){
// async? => new sync is OggS => reset and decode (not page 0 or 1)
FLACDecoderReset
();
s_flacPageNr
=
2
;
return
OGG_SYNC_FOUND
;
}
readUint
(
14
+
1
,
bytesLeft
);
// synccode + reserved bit
FLACFrameHeader
->
blockingStrategy
=
readUint
(
1
,
bytesLeft
);
FLACFrameHeader
->
blockSizeCode
=
readUint
(
4
,
bytesLeft
);
...
...
src/flac_decoder/flac_decoder.h
View file @
2b7125c1
...
...
@@ -2,7 +2,7 @@
* flac_decoder.h
*
* Created on: Jul 03,2020
* Updated on:
Apr 12
,2024
* Updated on:
May 18
,2024
*
* Author: wolle
*
...
...
@@ -27,6 +27,7 @@ enum : uint8_t {FLACDECODER_INIT, FLACDECODER_READ_IN, FLACDECODER_WRITE_OUT};
enum
:
uint8_t
{
DECODE_FRAME
,
DECODE_SUBFRAMES
,
OUT_SAMPLES
};
enum
:
int8_t
{
FLAC_PARSE_OGG_DONE
=
100
,
FLAC_DECODE_FRAMES_LOOP
=
100
,
OGG_SYNC_FOUND
=
+
2
,
GIVE_NEXT_LOOP
=
+
1
,
ERR_FLAC_NONE
=
0
,
ERR_FLAC_BLOCKSIZE_TOO_BIG
=
-
1
,
...
...
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