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
edfcf9f5
Commit
edfcf9f5
authored
Aug 28, 2023
by
schreibfaul1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix Crash while decoding Ogg Vorbis file with long Type 5 header #578
parent
4af9f399
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
11 deletions
+19
-11
src/vorbis_decoder/vorbis_decoder.cpp
src/vorbis_decoder/vorbis_decoder.cpp
+19
-11
No files found.
src/vorbis_decoder/vorbis_decoder.cpp
View file @
edfcf9f5
...
...
@@ -15,7 +15,7 @@
* adapted for the ESP32 by schreibfaul1
*
* Created on: 13.02.2023
* Updated on: 2
3
.08.2023
* Updated on: 2
8
.08.2023
*/
//----------------------------------------------------------------------------------------------------------------------
// O G G I M P L.
...
...
@@ -79,8 +79,8 @@ vorbis_info_mode_t *s_mode_param = NULL;
vorbis_dsp_state_t
*
s_dsp_state
=
NULL
;
bool
VORBISDecoder_AllocateBuffers
(){
s_vorbisSegmentTable
=
(
uint16_t
*
)
malloc
(
256
*
sizeof
(
uint16_t
));
s_vorbisChbuf
=
(
char
*
)
malloc
(
256
);
s_vorbisSegmentTable
=
(
uint16_t
*
)
__calloc_heap_psram
(
256
,
sizeof
(
uint16_t
));
s_vorbisChbuf
=
(
char
*
)
__calloc_heap_psram
(
256
,
sizeof
(
char
)
);
s_lastSegmentTable
=
(
uint8_t
*
)
__malloc_heap_psram
(
1024
);
VORBISsetDefaults
();
return
true
;
...
...
@@ -200,7 +200,7 @@ int VORBISDecode(uint8_t *inbuf, int *bytesLeft, short *outbuf){
int
idx
=
VORBIS_specialIndexOf
(
inbuf
,
"vorbis"
,
10
);
s_oggPage3Len
=
len
;
if
(
idx
==
1
){
log_i
(
"third packet (setup len) %i"
,
len
);
//
log_i("third packet (setup len) %i", len);
s_setupHeaderLength
=
len
;
bitReader_setData
(
inbuf
,
len
);
...
...
@@ -247,12 +247,21 @@ int VORBISDecode(uint8_t *inbuf, int *bytesLeft, short *outbuf){
s_f_oggContinuedPage
=
false
;
}
else
{
// last segment without continued Page
bitReader_setData
(
s_lastSegmentTable
,
s_lastSegmentTableLen
);
ret
=
vorbis_dsp_synthesis
(
s_lastSegmentTable
,
s_lastSegmentTableLen
,
outbuf
);
uint16_t
outBuffSize
=
2048
*
2
;
s_vorbisValidSamples
=
vorbis_dsp_pcmout
(
outbuf
,
outBuffSize
);
s_lastSegmentTableLen
=
0
;
if
(
ret
==
OV_ENOTAUDIO
||
ret
==
0
)
ret
=
VORBIS_CONTINUE
;
// if no error send continue
if
(
s_lastSegmentTableLen
){
bitReader_setData
(
s_lastSegmentTable
,
s_lastSegmentTableLen
);
ret
=
vorbis_dsp_synthesis
(
s_lastSegmentTable
,
s_lastSegmentTableLen
,
outbuf
);
uint16_t
outBuffSize
=
2048
*
2
;
s_vorbisValidSamples
=
vorbis_dsp_pcmout
(
outbuf
,
outBuffSize
);
s_lastSegmentTableLen
=
0
;
if
(
ret
==
OV_ENOTAUDIO
||
ret
==
0
)
ret
=
VORBIS_CONTINUE
;
// if no error send continue
}
else
{
bitReader_setData
(
inbuf
,
len
);
ret
=
vorbis_dsp_synthesis
(
inbuf
,
len
,
outbuf
);
uint16_t
outBuffSize
=
2048
*
2
;
s_vorbisValidSamples
=
vorbis_dsp_pcmout
(
outbuf
,
outBuffSize
);
ret
=
0
;
}
}
}
else
{
// not s_f_parseOggDone
...
...
@@ -464,7 +473,6 @@ int parseVorbisCodebook(){
int
ret
=
0
;
s_nrOfCodebooks
=
bitReader
(
8
)
+
1
;
s_codebooks
=
(
codebook_t
*
)
__calloc_heap_psram
(
s_nrOfCodebooks
,
sizeof
(
*
s_codebooks
));
for
(
i
=
0
;
i
<
s_nrOfCodebooks
;
i
++
){
...
...
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