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
6d9f52b2
Commit
6d9f52b2
authored
Mar 11, 2011
by
Mans Rullgard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ac3: move ff_ac3_bit_alloc_calc_bap to ac3dsp
Signed-off-by:
Mans Rullgard
<
mans@mansr.com
>
parent
d3834587
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
71 additions
and
57 deletions
+71
-57
configure
configure
+1
-1
ac3.c
libavcodec/ac3.c
+11
-35
ac3.h
libavcodec/ac3.h
+0
-19
ac3dec.c
libavcodec/ac3dec.c
+2
-1
ac3dec.h
libavcodec/ac3dec.h
+2
-0
ac3dsp.c
libavcodec/ac3dsp.c
+27
-0
ac3dsp.h
libavcodec/ac3dsp.h
+19
-0
ac3enc.c
libavcodec/ac3enc.c
+1
-1
ac3tab.h
libavcodec/ac3tab.h
+8
-0
No files found.
configure
View file @
6d9f52b2
...
...
@@ -1238,7 +1238,7 @@ rdft_select="fft"
aac_decoder_select
=
"mdct rdft sinewin"
aac_encoder_select
=
"mdct sinewin"
aac_latm_decoder_select
=
"aac_decoder aac_latm_parser"
ac3_decoder_select
=
"mdct ac3_parser"
ac3_decoder_select
=
"mdct ac3
dsp ac3
_parser"
ac3_encoder_select
=
"mdct ac3dsp"
ac3_fixed_encoder_select
=
"ac3dsp"
alac_encoder_select
=
"lpc"
...
...
libavcodec/ac3.c
View file @
6d9f52b2
...
...
@@ -31,7 +31,7 @@
/**
* Starting frequency coefficient bin for each critical band.
*/
static
const
uint8_t
band_start_tab
[
AC3_CRITICAL_BANDS
+
1
]
=
{
const
uint8_t
ff_ac3_
band_start_tab
[
AC3_CRITICAL_BANDS
+
1
]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
21
,
22
,
23
,
24
,
25
,
26
,
27
,
28
,
31
,
...
...
@@ -44,7 +44,7 @@ static const uint8_t band_start_tab[AC3_CRITICAL_BANDS+1] = {
/**
* Map each frequency coefficient bin to the critical band that contains it.
*/
static
const
uint8_t
bin_to_band_tab
[
253
]
=
{
const
uint8_t
ff_ac3_
bin_to_band_tab
[
253
]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
21
,
22
,
23
,
24
,
...
...
@@ -70,7 +70,7 @@ static const uint8_t bin_to_band_tab[253] = {
};
#else
/* CONFIG_HARDCODED_TABLES */
static
uint8_t
bin_to_band_tab
[
253
];
uint8_t
ff_ac3_
bin_to_band_tab
[
253
];
#endif
static
inline
int
calc_lowcomp1
(
int
a
,
int
b0
,
int
b1
,
int
c
)
...
...
@@ -106,10 +106,10 @@ void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
/* PSD integration */
bin
=
start
;
band
=
bin_to_band_tab
[
start
];
band
=
ff_ac3_
bin_to_band_tab
[
start
];
do
{
int
v
=
psd
[
bin
++
];
int
band_end
=
FFMIN
(
band_start_tab
[
band
+
1
],
end
);
int
band_end
=
FFMIN
(
ff_ac3_
band_start_tab
[
band
+
1
],
end
);
for
(;
bin
<
band_end
;
bin
++
)
{
int
max
=
FFMAX
(
v
,
psd
[
bin
]);
/* logadd */
...
...
@@ -117,7 +117,7 @@ void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
v
=
max
+
ff_ac3_log_add_tab
[
adr
];
}
band_psd
[
band
++
]
=
v
;
}
while
(
end
>
band_start_tab
[
band
]);
}
while
(
end
>
ff_ac3_
band_start_tab
[
band
]);
}
int
ff_ac3_bit_alloc_calc_mask
(
AC3BitAllocParameters
*
s
,
int16_t
*
band_psd
,
...
...
@@ -132,8 +132,8 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
int
lowcomp
,
fastleak
,
slowleak
;
/* excitation function */
band_start
=
bin_to_band_tab
[
start
];
band_end
=
bin_to_band_tab
[
end
-
1
]
+
1
;
band_start
=
ff_ac3_
bin_to_band_tab
[
start
];
band_end
=
ff_ac3_
bin_to_band_tab
[
end
-
1
]
+
1
;
if
(
band_start
==
0
)
{
lowcomp
=
0
;
...
...
@@ -212,30 +212,6 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
return
0
;
}
void
ff_ac3_bit_alloc_calc_bap
(
int16_t
*
mask
,
int16_t
*
psd
,
int
start
,
int
end
,
int
snr_offset
,
int
floor
,
const
uint8_t
*
bap_tab
,
uint8_t
*
bap
)
{
int
bin
,
band
;
/* special case, if snr offset is -960, set all bap's to zero */
if
(
snr_offset
==
-
960
)
{
memset
(
bap
,
0
,
AC3_MAX_COEFS
);
return
;
}
bin
=
start
;
band
=
bin_to_band_tab
[
start
];
do
{
int
m
=
(
FFMAX
(
mask
[
band
]
-
snr_offset
-
floor
,
0
)
&
0x1FE0
)
+
floor
;
int
band_end
=
FFMIN
(
band_start_tab
[
band
+
1
],
end
);
for
(;
bin
<
band_end
;
bin
++
)
{
int
address
=
av_clip
((
psd
[
bin
]
-
m
)
>>
5
,
0
,
63
);
bap
[
bin
]
=
bap_tab
[
address
];
}
}
while
(
end
>
band_start_tab
[
band
++
]);
}
/**
* Initialize some tables.
* note: This function must remain thread safe because it is called by the
...
...
@@ -244,12 +220,12 @@ void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
av_cold
void
ff_ac3_common_init
(
void
)
{
#if !CONFIG_HARDCODED_TABLES
/* compute
bin_to_band_tab from
band_start_tab */
/* compute
ff_ac3_bin_to_band_tab from ff_ac3_
band_start_tab */
int
bin
=
0
,
band
;
for
(
band
=
0
;
band
<
AC3_CRITICAL_BANDS
;
band
++
)
{
int
band_end
=
band_start_tab
[
band
+
1
];
int
band_end
=
ff_ac3_
band_start_tab
[
band
+
1
];
while
(
bin
<
band_end
)
bin_to_band_tab
[
bin
++
]
=
band
;
ff_ac3_
bin_to_band_tab
[
bin
++
]
=
band
;
}
#endif
/* !CONFIG_HARDCODED_TABLES */
}
libavcodec/ac3.h
View file @
6d9f52b2
...
...
@@ -175,23 +175,4 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
uint8_t
*
dba_lengths
,
uint8_t
*
dba_values
,
int16_t
*
mask
);
/**
* Calculate bit allocation pointers.
* The SNR is the difference between the masking curve and the signal. AC-3
* uses this value for each frequency bin to allocate bits. The snroffset
* parameter is a global adjustment to the SNR for all bins.
*
* @param[in] mask masking curve
* @param[in] psd signal power for each frequency bin
* @param[in] start starting bin location
* @param[in] end ending bin location
* @param[in] snr_offset SNR adjustment
* @param[in] floor noise floor
* @param[in] bap_tab look-up table for bit allocation pointers
* @param[out] bap bit allocation pointers
*/
void
ff_ac3_bit_alloc_calc_bap
(
int16_t
*
mask
,
int16_t
*
psd
,
int
start
,
int
end
,
int
snr_offset
,
int
floor
,
const
uint8_t
*
bap_tab
,
uint8_t
*
bap
);
#endif
/* AVCODEC_AC3_H */
libavcodec/ac3dec.c
View file @
6d9f52b2
...
...
@@ -184,6 +184,7 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
ff_mdct_init
(
&
s
->
imdct_512
,
9
,
1
,
1
.
0
);
ff_kbd_window_init
(
s
->
window
,
5
.
0
,
256
);
dsputil_init
(
&
s
->
dsp
,
avctx
);
ff_ac3dsp_init
(
&
s
->
ac3dsp
,
avctx
->
flags
&
CODEC_FLAG_BITEXACT
);
ff_fmt_convert_init
(
&
s
->
fmt_conv
,
avctx
);
av_lfg_init
(
&
s
->
dith_state
,
0
);
...
...
@@ -1213,7 +1214,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
/* Compute bit allocation */
const
uint8_t
*
bap_tab
=
s
->
channel_uses_aht
[
ch
]
?
ff_eac3_hebap_tab
:
ff_ac3_bap_tab
;
ff_ac3_
bit_alloc_calc_bap
(
s
->
mask
[
ch
],
s
->
psd
[
ch
],
s
->
ac3dsp
.
bit_alloc_calc_bap
(
s
->
mask
[
ch
],
s
->
psd
[
ch
],
s
->
start_freq
[
ch
],
s
->
end_freq
[
ch
],
s
->
snr_offset
[
ch
],
s
->
bit_alloc_params
.
floor
,
...
...
libavcodec/ac3dec.h
View file @
6d9f52b2
...
...
@@ -52,6 +52,7 @@
#include "libavutil/lfg.h"
#include "ac3.h"
#include "ac3dsp.h"
#include "get_bits.h"
#include "dsputil.h"
#include "fft.h"
...
...
@@ -192,6 +193,7 @@ typedef struct {
///@defgroup opt optimization
DSPContext
dsp
;
///< for optimization
AC3DSPContext
ac3dsp
;
FmtConvertContext
fmt_conv
;
///< optimized conversion functions
float
mul_bias
;
///< scaling for float_to_int16 conversion
///@}
...
...
libavcodec/ac3dsp.c
View file @
6d9f52b2
...
...
@@ -20,6 +20,7 @@
*/
#include "avcodec.h"
#include "ac3.h"
#include "ac3dsp.h"
static
void
ac3_exponent_min_c
(
uint8_t
*
exp
,
int
num_reuse_blocks
,
int
nb_coefs
)
...
...
@@ -101,6 +102,31 @@ static void float_to_fixed24_c(int32_t *dst, const float *src, unsigned int len)
}
while
(
len
>
0
);
}
static
void
ac3_bit_alloc_calc_bap_c
(
int16_t
*
mask
,
int16_t
*
psd
,
int
start
,
int
end
,
int
snr_offset
,
int
floor
,
const
uint8_t
*
bap_tab
,
uint8_t
*
bap
)
{
int
bin
,
band
;
/* special case, if snr offset is -960, set all bap's to zero */
if
(
snr_offset
==
-
960
)
{
memset
(
bap
,
0
,
AC3_MAX_COEFS
);
return
;
}
bin
=
start
;
band
=
ff_ac3_bin_to_band_tab
[
start
];
do
{
int
m
=
(
FFMAX
(
mask
[
band
]
-
snr_offset
-
floor
,
0
)
&
0x1FE0
)
+
floor
;
int
band_end
=
FFMIN
(
ff_ac3_band_start_tab
[
band
+
1
],
end
);
for
(;
bin
<
band_end
;
bin
++
)
{
int
address
=
av_clip
((
psd
[
bin
]
-
m
)
>>
5
,
0
,
63
);
bap
[
bin
]
=
bap_tab
[
address
];
}
}
while
(
end
>
ff_ac3_band_start_tab
[
band
++
]);
}
av_cold
void
ff_ac3dsp_init
(
AC3DSPContext
*
c
,
int
bit_exact
)
{
c
->
ac3_exponent_min
=
ac3_exponent_min_c
;
...
...
@@ -108,6 +134,7 @@ av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
c
->
ac3_lshift_int16
=
ac3_lshift_int16_c
;
c
->
ac3_rshift_int32
=
ac3_rshift_int32_c
;
c
->
float_to_fixed24
=
float_to_fixed24_c
;
c
->
bit_alloc_calc_bap
=
ac3_bit_alloc_calc_bap_c
;
if
(
ARCH_ARM
)
ff_ac3dsp_init_arm
(
c
,
bit_exact
);
...
...
libavcodec/ac3dsp.h
View file @
6d9f52b2
...
...
@@ -81,6 +81,25 @@ typedef struct AC3DSPContext {
* constraints: multiple of 32 greater than zero
*/
void
(
*
float_to_fixed24
)(
int32_t
*
dst
,
const
float
*
src
,
unsigned
int
len
);
/**
* Calculate bit allocation pointers.
* The SNR is the difference between the masking curve and the signal. AC-3
* uses this value for each frequency bin to allocate bits. The snroffset
* parameter is a global adjustment to the SNR for all bins.
*
* @param[in] mask masking curve
* @param[in] psd signal power for each frequency bin
* @param[in] start starting bin location
* @param[in] end ending bin location
* @param[in] snr_offset SNR adjustment
* @param[in] floor noise floor
* @param[in] bap_tab look-up table for bit allocation pointers
* @param[out] bap bit allocation pointers
*/
void
(
*
bit_alloc_calc_bap
)(
int16_t
*
mask
,
int16_t
*
psd
,
int
start
,
int
end
,
int
snr_offset
,
int
floor
,
const
uint8_t
*
bap_tab
,
uint8_t
*
bap
);
}
AC3DSPContext
;
void
ff_ac3dsp_init
(
AC3DSPContext
*
c
,
int
bit_exact
);
...
...
libavcodec/ac3enc.c
View file @
6d9f52b2
...
...
@@ -1047,7 +1047,7 @@ static int bit_alloc(AC3EncodeContext *s, int snr_offset)
whenever we reuse exponents. */
block
=
s
->
blocks
[
blk
].
exp_ref_block
[
ch
];
if
(
s
->
exp_strategy
[
ch
][
blk
]
!=
EXP_REUSE
)
{
ff_ac3_
bit_alloc_calc_bap
(
block
->
mask
[
ch
],
block
->
psd
[
ch
],
0
,
s
->
ac3dsp
.
bit_alloc_calc_bap
(
block
->
mask
[
ch
],
block
->
psd
[
ch
],
0
,
s
->
nb_coefs
[
ch
],
snr_offset
,
s
->
bit_alloc
.
floor
,
ff_ac3_bap_tab
,
block
->
bap
[
ch
]);
...
...
libavcodec/ac3tab.h
View file @
6d9f52b2
...
...
@@ -25,6 +25,12 @@
#include "libavutil/common.h"
#include "ac3.h"
#if CONFIG_HARDCODED_TABLES
# define HCONST const
#else
# define HCONST
#endif
extern
const
uint16_t
ff_ac3_frame_size_tab
[
38
][
3
];
extern
const
uint8_t
ff_ac3_channels_tab
[
8
];
extern
const
uint16_t
ff_ac3_channel_layout_tab
[
8
];
...
...
@@ -44,6 +50,8 @@ extern const uint16_t ff_ac3_db_per_bit_tab[4];
extern
const
int16_t
ff_ac3_floor_tab
[
8
];
extern
const
uint16_t
ff_ac3_fast_gain_tab
[
8
];
extern
const
uint16_t
ff_eac3_default_chmap
[
8
];
extern
const
uint8_t
ff_ac3_band_start_tab
[
AC3_CRITICAL_BANDS
+
1
];
extern
HCONST
uint8_t
ff_ac3_bin_to_band_tab
[
253
];
/** Custom channel map locations bitmask
* Other channels described in documentation:
...
...
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