Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
7040cffd
Commit
7040cffd
authored
Jul 15, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update dr_mp3.
parent
22fdc3a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
46 deletions
+27
-46
extras/dr_mp3.h
extras/dr_mp3.h
+27
-46
No files found.
extras/dr_mp3.h
View file @
7040cffd
// MP3 audio decoder. Public domain. See "unlicense" statement at the end of this file.
// dr_mp3 - v0.2.
5 - 2018-06-22
// dr_mp3 - v0.2.
7 - 2018-07-13
//
// David Reid - mackron@gmail.com
//
...
...
@@ -99,21 +99,14 @@ typedef drmp3_uint32 drmp3_bool32;
// ==================
typedef
struct
{
int
frame_bytes
;
int
channels
;
int
hz
;
int
layer
;
int
bitrate_kbps
;
int
frame_bytes
,
channels
,
hz
,
layer
,
bitrate_kbps
;
}
drmp3dec_frame_info
;
typedef
struct
{
float
mdct_overlap
[
2
][
9
*
32
];
float
qmf_state
[
15
*
2
*
32
];
int
reserv
;
int
free_format_bytes
;
unsigned
char
header
[
4
];
unsigned
char
reserv_buf
[
511
];
float
mdct_overlap
[
2
][
9
*
32
],
qmf_state
[
15
*
2
*
32
];
int
reserv
,
free_format_bytes
;
unsigned
char
header
[
4
],
reserv_buf
[
511
];
}
drmp3dec
;
// Initializes a low level decoder.
...
...
@@ -462,44 +455,27 @@ static int drmp3_have_simd()
typedef
struct
{
const
drmp3_uint8
*
buf
;
int
pos
;
int
limit
;
int
pos
,
limit
;
}
drmp3_bs
;
typedef
struct
{
drmp3_uint8
total_bands
;
drmp3_uint8
stereo_bands
;
drmp3_uint8
bitalloc
[
64
];
drmp3_uint8
scfcod
[
64
];
float
scf
[
3
*
64
];
drmp3_uint8
total_bands
,
stereo_bands
,
bitalloc
[
64
],
scfcod
[
64
];
}
drmp3_L12_scale_info
;
typedef
struct
{
drmp3_uint8
tab_offset
;
drmp3_uint8
code_tab_width
;
drmp3_uint8
band_count
;
drmp3_uint8
tab_offset
,
code_tab_width
,
band_count
;
}
drmp3_L12_subband_alloc
;
typedef
struct
{
const
drmp3_uint8
*
sfbtab
;
drmp3_uint16
part_23_length
;
drmp3_uint16
big_values
;
drmp3_uint16
scalefac_compress
;
drmp3_uint8
global_gain
;
drmp3_uint8
block_type
;
drmp3_uint8
mixed_block_flag
;
drmp3_uint8
n_long_sfb
;
drmp3_uint8
n_short_sfb
;
drmp3_uint8
table_select
[
3
];
drmp3_uint8
region_count
[
3
];
drmp3_uint8
subblock_gain
[
3
];
drmp3_uint8
preflag
;
drmp3_uint8
scalefac_scale
;
drmp3_uint8
count1_table
;
drmp3_uint8
scfsi
;
drmp3_uint16
part_23_length
,
big_values
,
scalefac_compress
;
drmp3_uint8
global_gain
,
block_type
,
mixed_block_flag
,
n_long_sfb
,
n_short_sfb
;
drmp3_uint8
table_select
[
3
],
region_count
[
3
],
subblock_gain
[
3
];
drmp3_uint8
preflag
,
scalefac_scale
,
count1_table
,
scfsi
;
}
drmp3_L3_gr_info
;
typedef
struct
...
...
@@ -507,10 +483,8 @@ typedef struct
drmp3_bs
bs
;
drmp3_uint8
maindata
[
DRMP3_MAX_BITRESERVOIR_BYTES
+
DRMP3_MAX_L3_FRAME_PAYLOAD_BYTES
];
drmp3_L3_gr_info
gr_info
[
4
];
float
grbuf
[
2
][
576
];
float
scf
[
40
];
float
grbuf
[
2
][
576
],
scf
[
40
],
syn
[
18
+
15
][
2
*
32
];
drmp3_uint8
ist_pos
[
2
][
39
];
float
syn
[
18
+
15
][
2
*
32
];
}
drmp3dec_scratch
;
static
void
drmp3_bs_init
(
drmp3_bs
*
bs
,
const
drmp3_uint8
*
data
,
int
bytes
)
...
...
@@ -988,17 +962,19 @@ static void drmp3_L3_decode_scalefactors(const drmp3_uint8 *hdr, drmp3_uint8 *is
}
}
static
const
float
g_drmp3_pow43
[
129
+
16
]
=
{
0
,
-
1
,
-
2
.
519842
f
,
-
4
.
326749
f
,
-
6
.
349604
f
,
-
8
.
549880
f
,
-
10
.
902724
f
,
-
13
.
390518
f
,
-
16
.
000000
f
,
-
18
.
720754
f
,
-
21
.
544347
f
,
-
24
.
463781
f
,
-
27
.
473142
f
,
-
30
.
567351
f
,
-
33
.
741992
f
,
-
36
.
993181
f
,
0
,
1
,
2
.
519842
f
,
4
.
326749
f
,
6
.
349604
f
,
8
.
549880
f
,
10
.
902724
f
,
13
.
390518
f
,
16
.
000000
f
,
18
.
720754
f
,
21
.
544347
f
,
24
.
463781
f
,
27
.
473142
f
,
30
.
567351
f
,
33
.
741992
f
,
36
.
993181
f
,
40
.
317474
f
,
43
.
711787
f
,
47
.
173345
f
,
50
.
699631
f
,
54
.
288352
f
,
57
.
937408
f
,
61
.
644865
f
,
65
.
408941
f
,
69
.
227979
f
,
73
.
100443
f
,
77
.
024
898
f
,
81
.
000000
f
,
85
.
0244
91
f
,
89
.
097188
f
,
93
.
216975
f
,
97
.
382800
f
,
101
.
593667
f
,
105
.
848633
f
,
110
.
146801
f
,
114
.
487321
f
,
118
.
869381
f
,
123
.
292209
f
,
127
.
755065
f
,
132
.
257246
f
,
136
.
798076
f
,
141
.
376907
f
,
145
.
993119
f
,
150
.
646117
f
,
155
.
335327
f
,
160
.
0601
99
f
,
164
.
820202
f
,
169
.
614826
f
,
174
.
443577
f
,
179
.
305980
f
,
184
.
201575
f
,
189
.
129918
f
,
194
.
090580
f
,
199
.
083145
f
,
204
.
107210
f
,
209
.
162385
f
,
214
.
248292
f
,
219
.
364564
f
,
224
.
510845
f
,
229
.
686789
f
,
234
.
892058
f
,
240
.
126328
f
,
245
.
389280
f
,
250
.
680604
f
,
256
.
000000
f
,
261
.
347174
f
,
266
.
721841
f
,
272
.
123723
f
,
277
.
552547
f
,
283
.
00
8049
f
,
288
.
489971
f
,
293
.
998060
f
,
299
.
532071
f
,
305
.
091761
f
,
310
.
676898
f
,
316
.
287249
f
,
321
.
922592
f
,
327
.
582707
f
,
333
.
267377
f
,
338
.
976394
f
,
344
.
709550
f
,
350
.
466646
f
,
356
.
247482
f
,
362
.
051
866
f
,
367
.
879608
f
,
373
.
730522
f
,
379
.
604427
f
,
385
.
501143
f
,
391
.
420496
f
,
397
.
362314
f
,
403
.
326427
f
,
409
.
312672
f
,
415
.
320884
f
,
421
.
350905
f
,
427
.
402579
f
,
433
.
475750
f
,
439
.
570269
f
,
445
.
685987
f
,
451
.
822757
f
,
457
.
980436
f
,
464
.
158883
f
,
470
.
357960
f
,
476
.
577530
f
,
482
.
817459
f
,
489
.
077615
f
,
495
.
357868
f
,
501
.
658090
f
,
507
.
978156
f
,
514
.
317941
f
,
520
.
677324
f
,
527
.
0561
84
f
,
533
.
454404
f
,
539
.
871867
f
,
546
.
308458
f
,
552
.
764065
f
,
559
.
238575
f
,
565
.
731879
f
,
572
.
243870
f
,
578
.
774440
f
,
585
.
323483
f
,
591
.
890898
f
,
598
.
476581
f
,
605
.
080431
f
,
611
.
702349
f
,
618
.
342238
f
,
625
.
000000
f
,
631
.
675540
f
,
638
.
368763
f
,
645
.
07
9578
f
};
static
float
drmp3_L3_pow_43
(
int
x
)
{
static
const
float
g_pow43
[
129
]
=
{
0
,
1
,
2
.
519842
f
,
4
.
326749
f
,
6
.
349604
f
,
8
.
549880
f
,
10
.
902724
f
,
13
.
390518
f
,
16
.
000000
f
,
18
.
720754
f
,
21
.
544347
f
,
24
.
463781
f
,
27
.
473142
f
,
30
.
567351
f
,
33
.
741992
f
,
36
.
993181
f
,
40
.
317474
f
,
43
.
711787
f
,
47
.
173345
f
,
50
.
699631
f
,
54
.
288352
f
,
57
.
937408
f
,
61
.
644865
f
,
65
.
408941
f
,
69
.
227979
f
,
73
.
100443
f
,
77
.
024
898
f
,
81
.
000000
f
,
85
.
0244
91
f
,
89
.
097188
f
,
93
.
216975
f
,
97
.
382800
f
,
101
.
593667
f
,
105
.
848633
f
,
110
.
146801
f
,
114
.
487321
f
,
118
.
869381
f
,
123
.
292209
f
,
127
.
755065
f
,
132
.
257246
f
,
136
.
798076
f
,
141
.
376907
f
,
145
.
993119
f
,
150
.
646117
f
,
155
.
335327
f
,
160
.
0601
99
f
,
164
.
820202
f
,
169
.
614826
f
,
174
.
443577
f
,
179
.
305980
f
,
184
.
201575
f
,
189
.
129918
f
,
194
.
090580
f
,
199
.
083145
f
,
204
.
107210
f
,
209
.
162385
f
,
214
.
248292
f
,
219
.
364564
f
,
224
.
510845
f
,
229
.
686789
f
,
234
.
892058
f
,
240
.
126328
f
,
245
.
389280
f
,
250
.
680604
f
,
256
.
000000
f
,
261
.
347174
f
,
266
.
721841
f
,
272
.
123723
f
,
277
.
552547
f
,
283
.
00
8049
f
,
288
.
489971
f
,
293
.
998060
f
,
299
.
532071
f
,
305
.
091761
f
,
310
.
676898
f
,
316
.
287249
f
,
321
.
922592
f
,
327
.
582707
f
,
333
.
267377
f
,
338
.
976394
f
,
344
.
709550
f
,
350
.
466646
f
,
356
.
247482
f
,
362
.
051
866
f
,
367
.
879608
f
,
373
.
730522
f
,
379
.
604427
f
,
385
.
501143
f
,
391
.
420496
f
,
397
.
362314
f
,
403
.
326427
f
,
409
.
312672
f
,
415
.
320884
f
,
421
.
350905
f
,
427
.
402579
f
,
433
.
475750
f
,
439
.
570269
f
,
445
.
685987
f
,
451
.
822757
f
,
457
.
980436
f
,
464
.
158883
f
,
470
.
357960
f
,
476
.
577530
f
,
482
.
817459
f
,
489
.
077615
f
,
495
.
357868
f
,
501
.
658090
f
,
507
.
978156
f
,
514
.
317941
f
,
520
.
677324
f
,
527
.
0561
84
f
,
533
.
454404
f
,
539
.
871867
f
,
546
.
308458
f
,
552
.
764065
f
,
559
.
238575
f
,
565
.
731879
f
,
572
.
243870
f
,
578
.
774440
f
,
585
.
323483
f
,
591
.
890898
f
,
598
.
476581
f
,
605
.
080431
f
,
611
.
702349
f
,
618
.
342238
f
,
625
.
000000
f
,
631
.
675540
f
,
638
.
368763
f
,
645
.
07
9578
f
};
float
frac
;
int
sign
,
mult
=
256
;
if
(
x
<
129
)
{
return
g_
pow43
[
x
];
return
g_
drmp3_pow43
[
16
+
x
];
}
if
(
x
<
1024
)
...
...
@@ -1009,12 +985,11 @@ static float drmp3_L3_pow_43(int x)
sign
=
2
*
x
&
64
;
frac
=
(
float
)((
x
&
63
)
-
sign
)
/
((
x
&
~
63
)
+
sign
);
return
g_
pow43
[(
x
+
sign
)
>>
6
]
*
(
1
.
f
+
frac
*
((
4
.
f
/
3
)
+
frac
*
(
2
.
f
/
9
)))
*
mult
;
return
g_
drmp3_pow43
[
16
+
((
x
+
sign
)
>>
6
)
]
*
(
1
.
f
+
frac
*
((
4
.
f
/
3
)
+
frac
*
(
2
.
f
/
9
)))
*
mult
;
}
static
void
drmp3_L3_huffman
(
float
*
dst
,
drmp3_bs
*
bs
,
const
drmp3_L3_gr_info
*
gr_info
,
const
float
*
scf
,
int
layer3gr_limit
)
{
static
const
float
g_pow43_signed
[
32
]
=
{
0
,
0
,
1
,
-
1
,
2
.
519842
f
,
-
2
.
519842
f
,
4
.
326749
f
,
-
4
.
326749
f
,
6
.
349604
f
,
-
6
.
349604
f
,
8
.
549880
f
,
-
8
.
549880
f
,
10
.
902724
f
,
-
10
.
902724
f
,
13
.
390518
f
,
-
13
.
390518
f
,
16
.
000000
f
,
-
16
.
000000
f
,
18
.
720754
f
,
-
18
.
720754
f
,
21
.
544347
f
,
-
21
.
544347
f
,
24
.
463781
f
,
-
24
.
463781
f
,
27
.
473142
f
,
-
27
.
473142
f
,
30
.
567351
f
,
-
30
.
567351
f
,
33
.
741992
f
,
-
33
.
741992
f
,
36
.
993181
f
,
-
36
.
993181
f
};
static
const
drmp3_int16
tabs
[]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
785
,
785
,
785
,
785
,
784
,
784
,
784
,
784
,
513
,
513
,
513
,
513
,
513
,
513
,
513
,
513
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
-
255
,
1313
,
1298
,
1282
,
785
,
785
,
785
,
785
,
784
,
784
,
784
,
784
,
769
,
769
,
769
,
769
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
256
,
290
,
288
,
...
...
@@ -1083,7 +1058,7 @@ static void drmp3_L3_huffman(float *dst, drmp3_bs *bs, const drmp3_L3_gr_info *g
*
dst
=
one
*
drmp3_L3_pow_43
(
lsb
)
*
((
int32_t
)
bs_cache
<
0
?
-
1
:
1
);
}
else
{
*
dst
=
g_
pow43_signed
[
lsb
*
2
+
(
bs_cache
>>
31
)]
*
one
;
*
dst
=
g_
drmp3_pow43
[
16
+
lsb
-
16
*
(
bs_cache
>>
31
)]
*
one
;
}
DRMP3_FLUSH_BITS
(
lsb
?
1
:
0
);
}
...
...
@@ -2771,6 +2746,12 @@ void drmp3_free(void* p)
// REVISION HISTORY
// ===============
//
// v0.2.7 - 2018-07-13
// - Bring up to date with minimp3.
//
// v0.2.6 - 2018-07-12
// - Bring up to date with minimp3.
//
// v0.2.5 - 2018-06-22
// - Bring up to date with minimp3.
//
...
...
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