Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
01f35453
Commit
01f35453
authored
Aug 05, 2007
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add dialogue normalization
Originally committed as revision 9948 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
8767b80f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
ac3dec.c
libavcodec/ac3dec.c
+16
-4
No files found.
libavcodec/ac3dec.c
View file @
01f35453
...
...
@@ -72,6 +72,9 @@ static const uint8_t qntztab[16] = {
/** dynamic range table. converts codes to scale factors. */
static
float
dynrng_tbl
[
256
];
/** dialogue normalization table */
static
float
dialnorm_tbl
[
32
];
/* Adjustmens in dB gain */
#define LEVEL_MINUS_3DB 0.7071067811865476
#define LEVEL_MINUS_4POINT5DB 0.5946035575013605
...
...
@@ -159,6 +162,7 @@ typedef struct {
int
out_channels
;
///< number of output channels
float
downmix_coeffs
[
AC3_MAX_CHANNELS
][
2
];
///< stereo downmix coefficients
float
dialnorm
[
2
];
///< dialogue normalization
float
dynrng
;
//dynamic range gain
float
dynrng2
;
//dynamic range gain for 1+1 mode
float
cplco
[
AC3_MAX_CHANNELS
][
18
];
//coupling coordinates
...
...
@@ -269,6 +273,14 @@ static void ac3_tables_init(void)
dynrng_tbl
[
i
]
=
powf
(
2
.
0
f
,
v
)
*
((
i
&
0x1F
)
|
0x20
);
}
/* generate dialogue normalization table
references: Section 5.4.2.8 dialnorm
Section 7.6 Dialogue Normalization */
for
(
i
=
1
;
i
<
32
;
i
++
)
{
dialnorm_tbl
[
i
]
=
expf
((
i
-
31
)
*
M_LN10
/
20
.
0
f
);
}
dialnorm_tbl
[
0
]
=
dialnorm_tbl
[
31
];
//generate scale factors
for
(
i
=
0
;
i
<
25
;
i
++
)
scale_factors
[
i
]
=
pow
(
2
.
0
,
-
i
);
...
...
@@ -362,7 +374,7 @@ static int ac3_parse_header(AC3DecodeContext *ctx)
/* read the rest of the bsi. read twice for dual mono mode. */
i
=
!
(
ctx
->
acmod
);
do
{
skip_bits
(
gb
,
5
);
//skip dialog
normalization
ctx
->
dialnorm
[
i
]
=
dialnorm_tbl
[
get_bits
(
gb
,
5
)];
// dialogue
normalization
if
(
get_bits1
(
gb
))
skip_bits
(
gb
,
8
);
//skip compression
if
(
get_bits1
(
gb
))
...
...
@@ -1007,13 +1019,13 @@ static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk)
if
(
ctx
->
acmod
==
AC3_ACMOD_STEREO
)
do_rematrixing
(
ctx
);
/* apply scaling to coefficients (headroom, dynrng) */
/* apply scaling to coefficients (headroom, d
ialnorm, d
ynrng) */
for
(
ch
=
1
;
ch
<=
ctx
->
nchans
;
ch
++
)
{
float
gain
=
2
.
0
f
*
ctx
->
mul_bias
;
if
(
ctx
->
acmod
==
AC3_ACMOD_DUALMONO
&&
ch
==
2
)
{
gain
*=
ctx
->
dynrng2
;
gain
*=
ctx
->
d
ialnorm
[
ch
-
1
]
*
ctx
->
d
ynrng2
;
}
else
{
gain
*=
ctx
->
dynrng
;
gain
*=
ctx
->
d
ialnorm
[
0
]
*
ctx
->
d
ynrng
;
}
for
(
i
=
0
;
i
<
ctx
->
endmant
[
ch
];
i
++
)
{
ctx
->
transform_coeffs
[
ch
][
i
]
*=
gain
;
...
...
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