Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
external
ffmpeg
Commits
52fd16a2
Commit
52fd16a2
authored
Mar 11, 2011
by
Mans Rullgard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ac3enc: move compute_mantissa_size() to ac3dsp
Signed-off-by:
Mans Rullgard
<
mans@mansr.com
>
parent
6f718471
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
26 deletions
+29
-26
libavcodec/ac3dsp.c
libavcodec/ac3dsp.c
+23
-0
libavcodec/ac3dsp.h
libavcodec/ac3dsp.h
+5
-0
libavcodec/ac3enc.c
libavcodec/ac3enc.c
+1
-26
No files found.
libavcodec/ac3dsp.c
View file @
52fd16a2
...
...
@@ -127,6 +127,28 @@ static void ac3_bit_alloc_calc_bap_c(int16_t *mask, int16_t *psd,
}
while
(
end
>
ff_ac3_band_start_tab
[
band
++
]);
}
static
int
ac3_compute_mantissa_size_c
(
int
mant_cnt
[
5
],
uint8_t
*
bap
,
int
nb_coefs
)
{
int
bits
,
b
,
i
;
bits
=
0
;
for
(
i
=
0
;
i
<
nb_coefs
;
i
++
)
{
b
=
bap
[
i
];
if
(
b
<=
4
)
{
// bap=1 to bap=4 will be counted in compute_mantissa_size_final
mant_cnt
[
b
]
++
;
}
else
if
(
b
<=
13
)
{
// bap=5 to bap=13 use (bap-1) bits
bits
+=
b
-
1
;
}
else
{
// bap=14 uses 14 bits and bap=15 uses 16 bits
bits
+=
(
b
==
14
)
?
14
:
16
;
}
}
return
bits
;
}
av_cold
void
ff_ac3dsp_init
(
AC3DSPContext
*
c
,
int
bit_exact
)
{
c
->
ac3_exponent_min
=
ac3_exponent_min_c
;
...
...
@@ -135,6 +157,7 @@ av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
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
;
c
->
compute_mantissa_size
=
ac3_compute_mantissa_size_c
;
if
(
ARCH_ARM
)
ff_ac3dsp_init_arm
(
c
,
bit_exact
);
...
...
libavcodec/ac3dsp.h
View file @
52fd16a2
...
...
@@ -100,6 +100,11 @@ typedef struct AC3DSPContext {
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
);
/**
* Calculate the number of bits needed to encode a set of mantissas.
*/
int
(
*
compute_mantissa_size
)(
int
mant_cnt
[
5
],
uint8_t
*
bap
,
int
nb_coefs
);
}
AC3DSPContext
;
void
ff_ac3dsp_init
(
AC3DSPContext
*
c
,
int
bit_exact
);
...
...
libavcodec/ac3enc.c
View file @
52fd16a2
...
...
@@ -927,31 +927,6 @@ static void count_frame_bits(AC3EncodeContext *s)
}
/**
* Calculate the number of bits needed to encode a set of mantissas.
*/
static
int
compute_mantissa_size
(
int
mant_cnt
[
5
],
uint8_t
*
bap
,
int
nb_coefs
)
{
int
bits
,
b
,
i
;
bits
=
0
;
for
(
i
=
0
;
i
<
nb_coefs
;
i
++
)
{
b
=
bap
[
i
];
if
(
b
<=
4
)
{
// bap=1 to bap=4 will be counted in compute_mantissa_size_final
mant_cnt
[
b
]
++
;
}
else
if
(
b
<=
13
)
{
// bap=5 to bap=13 use (bap-1) bits
bits
+=
b
-
1
;
}
else
{
// bap=14 uses 14 bits and bap=15 uses 16 bits
bits
+=
(
b
==
14
)
?
14
:
16
;
}
}
return
bits
;
}
/**
* Finalize the mantissa bit count by adding in the grouped mantissas.
*/
...
...
@@ -1052,7 +1027,7 @@ static int bit_alloc(AC3EncodeContext *s, int snr_offset)
s
->
bit_alloc
.
floor
,
ff_ac3_bap_tab
,
block
->
bap
[
ch
]);
}
mantissa_bits
+=
compute_mantissa_size
(
mant_cnt
,
block
->
bap
[
ch
],
s
->
nb_coefs
[
ch
]);
mantissa_bits
+=
s
->
ac3dsp
.
compute_mantissa_size
(
mant_cnt
,
block
->
bap
[
ch
],
s
->
nb_coefs
[
ch
]);
}
mantissa_bits
+=
compute_mantissa_size_final
(
mant_cnt
);
}
...
...
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