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
a5ebe5d1
Commit
a5ebe5d1
authored
Jul 18, 2016
by
Luca Barbato
Committed by
Diego Biurrun
Jul 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ac3dec: Split spx-specific code from decode_audio_block()
Signed-off-by:
Diego Biurrun
<
diego@biurrun.de
>
parent
2ac00d2d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
90 deletions
+108
-90
ac3dec.c
libavcodec/ac3dec.c
+108
-90
No files found.
libavcodec/ac3dec.c
View file @
a5ebe5d1
...
...
@@ -746,75 +746,28 @@ static void decode_band_structure(GetBitContext *gbc, int blk, int eac3,
memcpy
(
band_sizes
,
bnd_sz
,
n_bands
);
}
/**
* Decode a single audio block from the AC-3 bitstream.
*/
static
int
decode_audio_block
(
AC3DecodeContext
*
s
,
int
blk
)
static
inline
int
spx_strategy
(
AC3DecodeContext
*
s
,
int
blk
)
{
GetBitContext
*
bc
=
&
s
->
gbc
;
int
fbw_channels
=
s
->
fbw_channels
;
int
channel_mode
=
s
->
channel_mode
;
int
i
,
bnd
,
seg
,
ch
;
int
different_transforms
;
int
downmix_output
;
int
cpl_in_use
;
GetBitContext
*
gbc
=
&
s
->
gbc
;
uint8_t
bit_alloc_stages
[
AC3_MAX_CHANNELS
]
=
{
0
};
/* block switch flags */
different_transforms
=
0
;
if
(
s
->
block_switch_syntax
)
{
for
(
ch
=
1
;
ch
<=
fbw_channels
;
ch
++
)
{
s
->
block_switch
[
ch
]
=
get_bits1
(
gbc
);
if
(
ch
>
1
&&
s
->
block_switch
[
ch
]
!=
s
->
block_switch
[
1
])
different_transforms
=
1
;
}
}
/* dithering flags */
if
(
s
->
dither_flag_syntax
)
{
for
(
ch
=
1
;
ch
<=
fbw_channels
;
ch
++
)
{
s
->
dither_flag
[
ch
]
=
get_bits1
(
gbc
);
}
}
/* dynamic range */
i
=
!
s
->
channel_mode
;
do
{
if
(
get_bits1
(
gbc
))
{
/* Allow asymmetric application of DRC when drc_scale > 1.
Amplification of quiet sounds is enhanced */
float
range
=
dynamic_range_tab
[
get_bits
(
gbc
,
8
)];
if
(
range
>
1
.
0
||
s
->
drc_scale
<=
1
.
0
)
s
->
dynamic_range
[
i
]
=
powf
(
range
,
s
->
drc_scale
);
else
s
->
dynamic_range
[
i
]
=
range
;
}
else
if
(
blk
==
0
)
{
s
->
dynamic_range
[
i
]
=
1
.
0
f
;
}
}
while
(
i
--
);
/* spectral extension strategy */
if
(
s
->
eac3
&&
(
!
blk
||
get_bits1
(
gbc
)))
{
s
->
spx_in_use
=
get_bits1
(
gbc
);
if
(
s
->
spx_in_use
)
{
int
dst_start_freq
,
dst_end_freq
,
src_start_freq
,
start_subband
,
end_subband
;
start_subband
,
end_subband
,
ch
;
/* determine which channels use spx */
if
(
s
->
channel_mode
==
AC3_CHMODE_MONO
)
{
s
->
channel_uses_spx
[
1
]
=
1
;
}
else
{
for
(
ch
=
1
;
ch
<=
fbw_channels
;
ch
++
)
s
->
channel_uses_spx
[
ch
]
=
get_bits1
(
g
bc
);
s
->
channel_uses_spx
[
ch
]
=
get_bits1
(
bc
);
}
/* get the frequency bins of the spx copy region and the spx start
and end subbands */
dst_start_freq
=
get_bits
(
g
bc
,
2
);
start_subband
=
get_bits
(
g
bc
,
3
)
+
2
;
dst_start_freq
=
get_bits
(
bc
,
2
);
start_subband
=
get_bits
(
bc
,
3
)
+
2
;
if
(
start_subband
>
7
)
start_subband
+=
start_subband
-
7
;
end_subband
=
get_bits
(
g
bc
,
3
)
+
5
;
end_subband
=
get_bits
(
bc
,
3
)
+
5
;
if
(
end_subband
>
7
)
end_subband
+=
end_subband
-
7
;
dst_start_freq
=
dst_start_freq
*
12
+
25
;
...
...
@@ -837,30 +790,30 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
s
->
spx_src_start_freq
=
src_start_freq
;
s
->
spx_dst_end_freq
=
dst_end_freq
;
decode_band_structure
(
g
bc
,
blk
,
s
->
eac3
,
0
,
decode_band_structure
(
bc
,
blk
,
s
->
eac3
,
0
,
start_subband
,
end_subband
,
ff_eac3_default_spx_band_struct
,
&
s
->
num_spx_bands
,
s
->
spx_band_sizes
);
}
else
{
for
(
ch
=
1
;
ch
<=
fbw_channels
;
ch
++
)
{
s
->
channel_uses_spx
[
ch
]
=
0
;
s
->
first_spx_coords
[
ch
]
=
1
;
}
}
}
/* spectral extension coordinates */
if
(
s
->
spx_in_use
)
{
return
0
;
}
static
inline
void
spx_coordinates
(
AC3DecodeContext
*
s
)
{
GetBitContext
*
bc
=
&
s
->
gbc
;
int
fbw_channels
=
s
->
fbw_channels
;
int
ch
,
bnd
;
for
(
ch
=
1
;
ch
<=
fbw_channels
;
ch
++
)
{
if
(
s
->
channel_uses_spx
[
ch
])
{
if
(
s
->
first_spx_coords
[
ch
]
||
get_bits1
(
g
bc
))
{
if
(
s
->
first_spx_coords
[
ch
]
||
get_bits1
(
bc
))
{
float
spx_blend
;
int
bin
,
master_spx_coord
;
s
->
first_spx_coords
[
ch
]
=
0
;
spx_blend
=
get_bits
(
gbc
,
5
)
*
(
1
.
0
f
/
32
);
master_spx_coord
=
get_bits
(
g
bc
,
2
)
*
3
;
spx_blend
=
get_bits
(
bc
,
5
)
*
(
1
.
0
f
/
32
);
master_spx_coord
=
get_bits
(
bc
,
2
)
*
3
;
bin
=
s
->
spx_src_start_freq
;
for
(
bnd
=
0
;
bnd
<
s
->
num_spx_bands
;
bnd
++
)
{
...
...
@@ -878,8 +831,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
bin
+=
bandsize
;
/* decode spx coordinates */
spx_coord_exp
=
get_bits
(
g
bc
,
4
);
spx_coord_mant
=
get_bits
(
g
bc
,
2
);
spx_coord_exp
=
get_bits
(
bc
,
4
);
spx_coord_mant
=
get_bits
(
bc
,
2
);
if
(
spx_coord_exp
==
15
)
spx_coord_mant
<<=
1
;
else
spx_coord_mant
+=
4
;
spx_coord_mant
<<=
(
25
-
spx_coord_exp
-
master_spx_coord
);
...
...
@@ -894,8 +847,73 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
s
->
first_spx_coords
[
ch
]
=
1
;
}
}
}
/**
* Decode a single audio block from the AC-3 bitstream.
*/
static
int
decode_audio_block
(
AC3DecodeContext
*
s
,
int
blk
)
{
int
fbw_channels
=
s
->
fbw_channels
;
int
channel_mode
=
s
->
channel_mode
;
int
i
,
bnd
,
seg
,
ch
,
ret
;
int
different_transforms
;
int
downmix_output
;
int
cpl_in_use
;
GetBitContext
*
gbc
=
&
s
->
gbc
;
uint8_t
bit_alloc_stages
[
AC3_MAX_CHANNELS
]
=
{
0
};
/* block switch flags */
different_transforms
=
0
;
if
(
s
->
block_switch_syntax
)
{
for
(
ch
=
1
;
ch
<=
fbw_channels
;
ch
++
)
{
s
->
block_switch
[
ch
]
=
get_bits1
(
gbc
);
if
(
ch
>
1
&&
s
->
block_switch
[
ch
]
!=
s
->
block_switch
[
1
])
different_transforms
=
1
;
}
}
/* dithering flags */
if
(
s
->
dither_flag_syntax
)
{
for
(
ch
=
1
;
ch
<=
fbw_channels
;
ch
++
)
{
s
->
dither_flag
[
ch
]
=
get_bits1
(
gbc
);
}
}
/* dynamic range */
i
=
!
s
->
channel_mode
;
do
{
if
(
get_bits1
(
gbc
))
{
/* Allow asymmetric application of DRC when drc_scale > 1.
Amplification of quiet sounds is enhanced */
float
range
=
dynamic_range_tab
[
get_bits
(
gbc
,
8
)];
if
(
range
>
1
.
0
||
s
->
drc_scale
<=
1
.
0
)
s
->
dynamic_range
[
i
]
=
powf
(
range
,
s
->
drc_scale
);
else
s
->
dynamic_range
[
i
]
=
range
;
}
else
if
(
blk
==
0
)
{
s
->
dynamic_range
[
i
]
=
1
.
0
f
;
}
}
while
(
i
--
);
/* spectral extension strategy */
if
(
s
->
eac3
&&
(
!
blk
||
get_bits1
(
gbc
)))
{
s
->
spx_in_use
=
get_bits1
(
gbc
);
if
(
s
->
spx_in_use
)
{
if
((
ret
=
spx_strategy
(
s
,
blk
))
<
0
)
return
ret
;
}
else
{
for
(
ch
=
1
;
ch
<=
fbw_channels
;
ch
++
)
{
s
->
channel_uses_spx
[
ch
]
=
0
;
s
->
first_spx_coords
[
ch
]
=
1
;
}
}
}
/* spectral extension coordinates */
if
(
s
->
spx_in_use
)
spx_coordinates
(
s
);
/* coupling strategy */
if
(
s
->
eac3
?
s
->
cpl_strategy_exists
[
blk
]
:
get_bits1
(
gbc
))
{
memset
(
bit_alloc_stages
,
3
,
AC3_MAX_CHANNELS
);
...
...
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