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
dbeb2d03
Commit
dbeb2d03
authored
Apr 02, 2024
by
schreibfaul1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix flac wrong compressionsratio
parent
a7d74dd3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
src/flac_decoder/flac_decoder.cpp
src/flac_decoder/flac_decoder.cpp
+11
-7
src/flac_decoder/flac_decoder.h
src/flac_decoder/flac_decoder.h
+1
-1
No files found.
src/flac_decoder/flac_decoder.cpp
View file @
dbeb2d03
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
* adapted to ESP32
* adapted to ESP32
*
*
* Created on: Jul 03,2020
* Created on: Jul 03,2020
* Updated on:
Mar 28
,2024
* Updated on:
Apr 02
,2024
*
*
* Author: Wolle
* Author: Wolle
*
*
...
@@ -705,15 +705,16 @@ int8_t FLACDecodeNative(uint8_t *inbuf, int *bytesLeft, short *outbuf){
...
@@ -705,15 +705,16 @@ int8_t FLACDecodeNative(uint8_t *inbuf, int *bytesLeft, short *outbuf){
int
ret
=
flacDecodeFrame
(
inbuf
,
bytesLeft
);
int
ret
=
flacDecodeFrame
(
inbuf
,
bytesLeft
);
if
(
ret
!=
0
)
return
ret
;
if
(
ret
!=
0
)
return
ret
;
if
(
*
bytesLeft
<
MAX_BLOCKSIZE
)
return
FLAC_DECODE_FRAMES_LOOP
;
// need more data
if
(
*
bytesLeft
<
MAX_BLOCKSIZE
)
return
FLAC_DECODE_FRAMES_LOOP
;
// need more data
sbl
+=
bl
-
*
bytesLeft
;
}
}
if
(
s_flacStatus
==
DECODE_SUBFRAMES
){
if
(
s_flacStatus
==
DECODE_SUBFRAMES
){
// Decode each channel's subframe, then skip footer
// Decode each channel's subframe, then skip footer
int
ret
=
decodeSubframes
(
bytesLeft
);
int
ret
=
decodeSubframes
(
bytesLeft
);
sbl
=
bl
-
*
bytesLeft
;
if
(
ret
!=
0
)
return
ret
;
if
(
ret
!=
0
)
return
ret
;
s_flacStatus
=
OUT_SAMPLES
;
s_flacStatus
=
OUT_SAMPLES
;
sbl
+=
bl
-
*
bytesLeft
;
}
}
if
(
s_flacStatus
==
OUT_SAMPLES
){
// Write the decoded samples
if
(
s_flacStatus
==
OUT_SAMPLES
){
// Write the decoded samples
...
@@ -734,10 +735,13 @@ int8_t FLACDecodeNative(uint8_t *inbuf, int *bytesLeft, short *outbuf){
...
@@ -734,10 +735,13 @@ int8_t FLACDecodeNative(uint8_t *inbuf, int *bytesLeft, short *outbuf){
s_flacValidSamples
=
blockSize
*
FLACMetadataBlock
->
numChannels
;
s_flacValidSamples
=
blockSize
*
FLACMetadataBlock
->
numChannels
;
offset
+=
blockSize
;
offset
+=
blockSize
;
s_flacCompressionRatio
=
(
float
)
sbl
/
(
s_flacValidSamples
*
FLACMetadataBlock
->
numChannels
);
if
(
sbl
>
0
){
s_flacCompressionRatio
=
(
float
)((
s_flacValidSamples
*
2
)
*
FLACMetadataBlock
->
numChannels
)
/
sbl
;
// valid samples are 16 bit
sbl
=
0
;
s_flacBitrate
=
FLACMetadataBlock
->
sampleRate
*
FLACMetadataBlock
->
bitsPerSample
*
FLACMetadataBlock
->
numChannels
;
s_flacBitrate
=
FLACMetadataBlock
->
sampleRate
*
FLACMetadataBlock
->
bitsPerSample
*
FLACMetadataBlock
->
numChannels
;
s_flacBitrate
/=
s_flacCompressionRatio
;
s_flacBitrate
/=
s_flacCompressionRatio
;
// log_e("s_flacBitrate %i, s_flacCompressionRatio %f, FLACMetadataBlock->sampleRate %i ", s_flacBitrate, s_flacCompressionRatio, FLACMetadataBlock->sampleRate);
}
if
(
offset
!=
s_blockSize
)
return
GIVE_NEXT_LOOP
;
if
(
offset
!=
s_blockSize
)
return
GIVE_NEXT_LOOP
;
if
(
offset
>
s_blockSize
)
{
log_e
(
"offset has a wrong value"
);
}
if
(
offset
>
s_blockSize
)
{
log_e
(
"offset has a wrong value"
);
}
offset
=
0
;
offset
=
0
;
...
...
src/flac_decoder/flac_decoder.h
View file @
dbeb2d03
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* flac_decoder.h
* flac_decoder.h
*
*
* Created on: Jul 03,2020
* Created on: Jul 03,2020
* Updated on:
Mar 28
,2024
* Updated on:
Apr 02
,2024
*
*
* Author: wolle
* Author: wolle
*
*
...
...
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