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
dd1afff7
Commit
dd1afff7
authored
Feb 03, 2024
by
schreibfaul1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some var renamed
parent
5ac109cc
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
116 deletions
+131
-116
src/opus_decoder/celt.cpp
src/opus_decoder/celt.cpp
+92
-93
src/opus_decoder/opus_decoder.cpp
src/opus_decoder/opus_decoder.cpp
+19
-3
src/vorbis_decoder/vorbis_decoder.cpp
src/vorbis_decoder/vorbis_decoder.cpp
+20
-20
No files found.
src/opus_decoder/celt.cpp
View file @
dd1afff7
This diff is collapsed.
Click to expand it.
src/opus_decoder/opus_decoder.cpp
View file @
dd1afff7
...
...
@@ -21,6 +21,8 @@ uint8_t s_opusChannels = 0;
uint8_t
s_opusCountCode
=
0
;
uint16_t
s_opusSamplerate
=
0
;
uint32_t
s_opusSegmentLength
=
0
;
uint32_t
s_opusBlockPicLen
=
0
;
uint32_t
s_opusBlockPicPos
=
0
;
char
*
s_opusChbuf
=
NULL
;
int32_t
s_opusValidSamples
=
0
;
...
...
@@ -67,6 +69,7 @@ void OPUSsetDefaults(){
s_opusSegmentTableSize
=
0
;
s_opusSegmentTableRdPtr
=
-
1
;
s_opusCountCode
=
0
;
s_opusBlockPicPos
=
0
;
s_opusError
=
0
;
}
...
...
@@ -311,7 +314,17 @@ int parseOpusComment(uint8_t *inbuf, int nBytes){ // reference https://exif
idx
=
OPUS_specialIndexOf
(
inbuf
+
pos
,
"title="
,
10
);
if
(
idx
==
0
){
title
=
strndup
((
const
char
*
)(
inbuf
+
pos
+
6
),
commentStringLen
-
6
);
}
idx
=
OPUS_specialIndexOf
(
inbuf
+
pos
,
"metadata_block_picture="
,
25
);
if
(
idx
==
-
1
)
idx
=
OPUS_specialIndexOf
(
inbuf
+
pos
,
"METADATA_BLOCK_PICTURE="
,
25
);
if
(
idx
==
0
){
s_opusBlockPicLen
=
commentStringLen
-
23
;
s_opusBlockPicPos
+=
pos
+
23
;
uint16_t
blockPicLenUntilFrameEnd
=
commentStringLen
-
23
;
log_i
(
"metadata block picture found at pos %i, length %i, first blockLength %i"
,
s_opusBlockPicPos
,
s_opusBlockPicLen
,
blockPicLenUntilFrameEnd
);
s_opusBlockPicLen
-=
blockPicLenUntilFrameEnd
;
}
pos
+=
commentStringLen
;
}
if
(
artist
&&
title
){
strcpy
(
s_opusChbuf
,
artist
);
...
...
@@ -419,14 +432,17 @@ int OPUSparseOGG(uint8_t *inbuf, int *bytesLeft){ // reference https://www.xiph
bool
firstPage
=
headerType
&
0x02
;
// set: this is the first page of a logical bitstream (bos)
bool
lastPage
=
headerType
&
0x04
;
// set: this is the last page of a logical bitstream (eos)
// log_i("page %x", headerType );
uint16_t
headerSize
=
pageSegments
+
27
;
(
void
)
continuedPage
;
(
void
)
lastPage
;
*
bytesLeft
-=
headerSize
;
*
bytesLeft
-=
headerSize
;
s_opusBlockPicPos
+=
headerSize
;
if
(
firstPage
||
s_f_opusSubsequentPage
){
// OpusHead or OggComment may follows
ret
=
parseOpusHead
(
inbuf
+
headerSize
,
s_opusSegmentTable
[
0
]);
if
(
ret
==
1
)
*
bytesLeft
-=
s_opusSegmentTable
[
0
];
if
(
ret
<
0
){
*
bytesLeft
-
=
s_opusSegmentTable
[
0
];
return
ret
;}
if
(
ret
==
1
)
{
*
bytesLeft
-=
s_opusSegmentTable
[
0
];
s_opusBlockPicPos
+=
s_opusSegmentTable
[
0
];}
if
(
ret
<
0
){
*
bytesLeft
-=
s_opusSegmentTable
[
0
];
s_opusBlockPicPos
+
=
s_opusSegmentTable
[
0
];
return
ret
;}
ret
=
parseOpusComment
(
inbuf
+
headerSize
,
s_opusSegmentTable
[
0
]);
if
(
ret
==
1
)
*
bytesLeft
-=
s_opusSegmentTable
[
0
];
if
(
ret
<
0
){
*
bytesLeft
-=
s_opusSegmentTable
[
0
];
return
ret
;}
...
...
src/vorbis_decoder/vorbis_decoder.cpp
View file @
dd1afff7
...
...
@@ -15,7 +15,7 @@
* adapted for the ESP32 by schreibfaul1
*
* Created on: 13.02.2023
* Updated on: 0
8.01.2023
* Updated on: 0
3.02.2024
*/
//----------------------------------------------------------------------------------------------------------------------
// O G G I M P L.
...
...
@@ -40,7 +40,7 @@ bool s_f_oggLastPage = false;
bool
s_f_parseOggDone
=
true
;
bool
s_f_lastSegmentTable
=
false
;
uint16_t
s_identificatonHeaderLength
=
0
;
uint16_t
s_
c
ommentHeaderLength
=
0
;
uint16_t
s_
vorbisC
ommentHeaderLength
=
0
;
uint16_t
s_setupHeaderLength
=
0
;
uint8_t
s_pageNr
=
4
;
uint16_t
s_oggHeaderSize
=
0
;
...
...
@@ -54,8 +54,8 @@ char *s_vorbisChbuf = NULL;
int32_t
s_vorbisValidSamples
=
0
;
uint8_t
s_vorbisOldMode
=
0
;
uint32_t
s_blocksizes
[
2
];
uint32_t
s_
b
lockPicPos
=
0
;
uint32_t
s_
b
lockPicLen
=
0
;
uint32_t
s_
vorbisB
lockPicPos
=
0
;
uint32_t
s_
vorbisB
lockPicLen
=
0
;
uint32_t
s_commentLength
=
0
;
uint8_t
s_nrOfCodebooks
=
0
;
...
...
@@ -120,8 +120,8 @@ void VORBISsetDefaults(){
s_vorbisSegmentTableRdPtr
=
-
1
;
s_vorbisError
=
0
;
s_lastSegmentTableLen
=
0
;
s_
b
lockPicPos
=
0
;
s_
b
lockPicLen
=
0
;
s_
vorbisB
lockPicPos
=
0
;
s_
vorbisB
lockPicLen
=
0
;
VORBISDecoder_ClearBuffers
();
}
...
...
@@ -205,7 +205,7 @@ int VORBISDecode(uint8_t *inbuf, int *bytesLeft, short *outbuf){
// log_i("first packet (identification len) %i", len);
s_identificatonHeaderLength
=
len
;
ret
=
parseVorbisFirstPacket
(
inbuf
,
len
);
s_
b
lockPicPos
+=
28
;
s_
vorbisB
lockPicPos
+=
28
;
}
else
{
ret
=
ERR_VORBIS_NOT_AUDIO
;
// #651
...
...
@@ -213,16 +213,16 @@ int VORBISDecode(uint8_t *inbuf, int *bytesLeft, short *outbuf){
}
else
if
(
s_pageNr
==
2
){
// comment header
int
idx
=
VORBIS_specialIndexOf
(
inbuf
,
"vorbis"
,
10
);
s_
b
lockPicPos
+=
6
;
s_
vorbisB
lockPicPos
+=
6
;
if
(
idx
==
1
){
// log_i("second packet (comment len) %i", len);
s_
c
ommentHeaderLength
=
len
;
s_
vorbisC
ommentHeaderLength
=
len
;
ret
=
parseVorbisComment
(
inbuf
,
len
);
}
else
{
uint16_t
blockLen
=
len
;
// log_i("blockPicLen %i blockLen %i", s_blockPicLen, blockLen);
s_
b
lockPicLen
-=
blockLen
;
s_
vorbisB
lockPicLen
-=
blockLen
;
;
// commentlength is greater than (one or more) OggS frame(s)
}
// log_w("s_vorbisSegmentTableSize %d", s_vorbisSegmentTableSize);
...
...
@@ -443,7 +443,7 @@ int parseVorbisComment(uint8_t *inbuf, int16_t nBytes){ // reference https:
memcpy
(
s_vorbisChbuf
,
inbuf
+
11
,
vendorLength
);
s_vorbisChbuf
[
vendorLength
]
=
'\0'
;
pos
+=
4
+
vendorLength
;
s_
c
ommentHeaderLength
-=
(
7
+
4
+
vendorLength
);
s_
vorbisC
ommentHeaderLength
-=
(
7
+
4
+
vendorLength
);
// log_i("vendorLength %x", vendorLength);
// log_i("vendorString %s", s_vorbisChbuf);
...
...
@@ -451,7 +451,7 @@ int parseVorbisComment(uint8_t *inbuf, int16_t nBytes){ // reference https:
uint8_t
nrOfComments
=
*
(
inbuf
+
pos
);
// log_i("nrOfComments %i", nrOfComments);
pos
+=
4
;
s_
c
ommentHeaderLength
-=
4
;
s_
vorbisC
ommentHeaderLength
-=
4
;
int
idx
=
0
;
char
*
artist
=
NULL
;
...
...
@@ -481,14 +481,14 @@ int parseVorbisComment(uint8_t *inbuf, int16_t nBytes){ // reference https:
idx
=
VORBIS_specialIndexOf
((
uint8_t
*
)
s_vorbisChbuf
,
"metadata_block_picture="
,
25
);
if
(
idx
==
0
){
s_
b
lockPicLen
=
commentLength
-
23
;
s_
b
lockPicPos
+=
pos
+
23
;
uint16_t
blockPicLenUntilFrameEnd
=
s_
c
ommentHeaderLength
-
4
-
23
;
log_i
(
"metadata block picture found at pos %i, length %i, first blockLength %i"
,
s_
blockPicPos
,
s_b
lockPicLen
,
blockPicLenUntilFrameEnd
);
s_
b
lockPicLen
-=
blockPicLenUntilFrameEnd
;
s_
vorbisB
lockPicLen
=
commentLength
-
23
;
s_
vorbisB
lockPicPos
+=
pos
+
23
;
uint16_t
blockPicLenUntilFrameEnd
=
s_
vorbisC
ommentHeaderLength
-
4
-
23
;
log_i
(
"metadata block picture found at pos %i, length %i, first blockLength %i"
,
s_
vorbisBlockPicPos
,
s_vorbisB
lockPicLen
,
blockPicLenUntilFrameEnd
);
s_
vorbisB
lockPicLen
-=
blockPicLenUntilFrameEnd
;
}
pos
+=
commentLength
+
4
;
s_
c
ommentHeaderLength
-=
(
4
+
commentLength
);
s_
vorbisC
ommentHeaderLength
-=
(
4
+
commentLength
);
}
if
(
artist
&&
title
){
strcpy
(
s_vorbisChbuf
,
artist
);
...
...
@@ -622,7 +622,7 @@ int VORBISparseOGG(uint8_t *inbuf, int *bytesLeft){
if
(
s_f_oggContinuedPage
)
return
ERR_VORBIS_DECODER_ASYNC
;
inbuf
+=
idx
;
*
bytesLeft
-=
idx
;
s_
b
lockPicPos
+=
idx
;
s_
vorbisB
lockPicPos
+=
idx
;
}
int16_t
segmentTableWrPtr
=
-
1
;
...
...
@@ -682,7 +682,7 @@ int VORBISparseOGG(uint8_t *inbuf, int *bytesLeft){
}
*
bytesLeft
-=
headerSize
;
s_
b
lockPicPos
+=
headerSize
;
s_
vorbisB
lockPicPos
+=
headerSize
;
if
(
s_pageNr
<
4
&&
!
continuedPage
)
s_pageNr
++
;
s_f_oggFirstPage
=
firstPage
;
...
...
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