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
e0b33d47
Commit
e0b33d47
authored
Apr 15, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ac3enc: simplify stereo rematrixing decision options
parent
a28b0587
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
35 deletions
+25
-35
encoders.texi
doc/encoders.texi
+12
-0
ac3enc.c
libavcodec/ac3enc.c
+13
-35
No files found.
doc/encoders.texi
View file @
e0b33d47
...
...
@@ -353,4 +353,16 @@ HDCD A/D Converter
@end table
@subheading Other AC-3 Encoding Options
@table @option
@item -stereo_rematrixing @var{boolean}
Stereo Rematrixing. Enables/Disables use of rematrixing for stereo input. This
is an optional AC-3 feature that increases quality by selectively encoding
the left/right channels as mid/side. This option is enabled by default, and it
is highly recommended that it be left as enabled except for testing purposes.
@end table
@c man end ENCODERS
libavcodec/ac3enc.c
View file @
e0b33d47
...
...
@@ -52,12 +52,6 @@
/** Maximum number of exponent groups. +1 for separate DC exponent. */
#define AC3_MAX_EXP_GROUPS 85
/* stereo rematrixing algorithms */
#define AC3_REMATRIXING_IS_STATIC 0x1
#define AC3_REMATRIXING_SUMS 0
#define AC3_REMATRIXING_NONE 1
#define AC3_REMATRIXING_ALWAYS 3
#if CONFIG_AC3ENC_FLOAT
#define MAC_COEF(d,a,b) ((d)+=(a)*(b))
typedef
float
SampleType
;
...
...
@@ -103,6 +97,7 @@ typedef struct AC3EncOptions {
/* other encoding options */
int
allow_per_frame_metadata
;
int
stereo_rematrixing
;
}
AC3EncOptions
;
/**
...
...
@@ -170,7 +165,7 @@ typedef struct AC3EncodeContext {
int
bandwidth_code
[
AC3_MAX_CHANNELS
];
///< bandwidth code (0 to 60) (chbwcod)
int
nb_coefs
[
AC3_MAX_CHANNELS
];
int
rematrixing
;
///< determines how rematrixing strategy is calculat
ed
int
rematrixing
_enabled
;
///< stereo rematrixing enabl
ed
int
num_rematrixing_bands
;
///< number of rematrixing bands
/* bitrate allocation control */
...
...
@@ -269,6 +264,8 @@ static const AVOption options[] = {
{
"ad_conv_type"
,
"A/D Converter Type"
,
OFFSET
(
ad_converter_type
),
FF_OPT_TYPE_INT
,
-
1
,
-
1
,
1
,
AC3ENC_PARAM
,
"ad_conv_type"
},
{
"standard"
,
"Standard (default)"
,
0
,
FF_OPT_TYPE_CONST
,
0
,
INT_MIN
,
INT_MAX
,
AC3ENC_PARAM
,
"ad_conv_type"
},
{
"hdcd"
,
"HDCD"
,
0
,
FF_OPT_TYPE_CONST
,
1
,
INT_MIN
,
INT_MAX
,
AC3ENC_PARAM
,
"ad_conv_type"
},
/* Other Encoding Options */
{
"stereo_rematrixing"
,
"Stereo Rematrixing"
,
OFFSET
(
stereo_rematrixing
),
FF_OPT_TYPE_INT
,
1
,
0
,
1
,
AC3ENC_PARAM
},
{
NULL
}
};
...
...
@@ -430,28 +427,6 @@ static void apply_mdct(AC3EncodeContext *s)
}
/**
* Initialize stereo rematrixing.
* If the strategy does not change for each frame, set the rematrixing flags.
*/
static
void
rematrixing_init
(
AC3EncodeContext
*
s
)
{
if
(
s
->
channel_mode
==
AC3_CHMODE_STEREO
)
s
->
rematrixing
=
AC3_REMATRIXING_SUMS
;
else
s
->
rematrixing
=
AC3_REMATRIXING_NONE
;
/* NOTE: AC3_REMATRIXING_ALWAYS might be used in
the future in conjunction with channel coupling. */
if
(
s
->
rematrixing
&
AC3_REMATRIXING_IS_STATIC
)
{
int
flag
=
(
s
->
rematrixing
==
AC3_REMATRIXING_ALWAYS
);
s
->
blocks
[
0
].
new_rematrixing_strategy
=
1
;
memset
(
s
->
blocks
[
0
].
rematrixing_flags
,
flag
,
sizeof
(
s
->
blocks
[
0
].
rematrixing_flags
));
}
}
/**
* Determine rematrixing flags for each block and band.
*/
...
...
@@ -461,16 +436,18 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
int
blk
,
bnd
,
i
;
AC3Block
*
block
,
*
block0
;
s
->
num_rematrixing_bands
=
4
;
if
(
s
->
rematrixing
&
AC3_REMATRIXING_IS_STATIC
)
if
(
s
->
channel_mode
!=
AC3_CHMODE_STEREO
)
return
;
s
->
num_rematrixing_bands
=
4
;
nb_coefs
=
FFMIN
(
s
->
nb_coefs
[
0
],
s
->
nb_coefs
[
1
]);
for
(
blk
=
0
;
blk
<
AC3_MAX_BLOCKS
;
blk
++
)
{
block
=
&
s
->
blocks
[
blk
];
block
->
new_rematrixing_strategy
=
!
blk
;
if
(
!
s
->
rematrixing_enabled
)
continue
;
for
(
bnd
=
0
;
bnd
<
s
->
num_rematrixing_bands
;
bnd
++
)
{
/* calculate calculate sum of squared coeffs for one band in one block */
int
start
=
ff_ac3_rematrix_band_tab
[
bnd
];
...
...
@@ -514,7 +491,7 @@ static void apply_rematrixing(AC3EncodeContext *s)
int
start
,
end
;
uint8_t
*
flags
;
if
(
s
->
rematrixing
==
AC3_REMATRIXING_NONE
)
if
(
!
s
->
rematrixing_enabled
)
return
;
nb_coefs
=
FFMIN
(
s
->
nb_coefs
[
0
],
s
->
nb_coefs
[
1
]);
...
...
@@ -2088,6 +2065,9 @@ static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)
if
(
ret
)
return
ret
;
s
->
rematrixing_enabled
=
s
->
options
.
stereo_rematrixing
&&
(
s
->
channel_mode
==
AC3_CHMODE_STEREO
);
return
0
;
}
...
...
@@ -2246,8 +2226,6 @@ static av_cold int ac3_encode_init(AVCodecContext *avctx)
set_bandwidth
(
s
);
rematrixing_init
(
s
);
exponent_init
(
s
);
bit_alloc_init
(
s
);
...
...
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