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
b3452771
Commit
b3452771
authored
Jun 15, 2011
by
Carl Eugen Hoyos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix multi-channel AAC encoding.
Fixes ticket 55.
parent
b1c450be
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
aacenc.c
libavcodec/aacenc.c
+19
-1
libfaac.c
libavcodec/libfaac.c
+10
-0
No files found.
libavcodec/aacenc.c
View file @
b3452771
...
...
@@ -135,6 +135,15 @@ static const uint8_t aac_chan_configs[6][5] = {
{
4
,
TYPE_SCE
,
TYPE_CPE
,
TYPE_CPE
,
TYPE_LFE
},
// 6 channels - front center + stereo + back stereo + LFE
};
static
const
uint8_t
channel_maps
[][
AAC_MAX_CHANNELS
]
=
{
{
0
},
{
0
,
1
},
{
2
,
0
,
1
},
{
2
,
0
,
1
,
3
},
{
2
,
0
,
1
,
3
,
4
},
{
2
,
0
,
1
,
4
,
5
,
3
},
};
/**
* Make AAC audio config object.
* @see 1.6.2.1 "Syntax - AudioSpecificConfig"
...
...
@@ -499,15 +508,24 @@ static int aac_encode_frame(AVCodecContext *avctx,
return
0
;
if
(
data
)
{
if
(
!
s
->
psypp
)
{
if
(
avctx
->
channels
<=
2
)
{
memcpy
(
s
->
samples
+
1024
*
avctx
->
channels
,
data
,
1024
*
avctx
->
channels
*
sizeof
(
s
->
samples
[
0
]));
}
else
{
for
(
i
=
0
;
i
<
1024
;
i
++
)
for
(
ch
=
0
;
ch
<
avctx
->
channels
;
ch
++
)
s
->
samples
[(
i
+
1024
)
*
avctx
->
channels
+
ch
]
=
((
int16_t
*
)
data
)[
i
*
avctx
->
channels
+
channel_maps
[
avctx
->
channels
-
1
][
ch
]];
}
}
else
{
start_ch
=
0
;
samples2
=
s
->
samples
+
1024
*
avctx
->
channels
;
for
(
i
=
0
;
i
<
chan_map
[
0
];
i
++
)
{
tag
=
chan_map
[
i
+
1
];
chans
=
tag
==
TYPE_CPE
?
2
:
1
;
ff_psy_preprocess
(
s
->
psypp
,
(
uint16_t
*
)
data
+
start_ch
,
ff_psy_preprocess
(
s
->
psypp
,
(
uint16_t
*
)
data
+
channel_maps
[
avctx
->
channels
-
1
][
start_ch
],
samples2
+
start_ch
,
start_ch
,
chans
);
start_ch
+=
chans
;
}
...
...
libavcodec/libfaac.c
View file @
b3452771
...
...
@@ -31,6 +31,13 @@ typedef struct FaacAudioContext {
faacEncHandle
faac_handle
;
}
FaacAudioContext
;
static
const
int
channel_maps
[][
6
]
=
{
{
2
,
0
,
1
},
//< C L R
{
2
,
0
,
1
,
3
},
//< C L R Cs
{
2
,
0
,
1
,
3
,
4
},
//< C L R Ls Rs
{
2
,
0
,
1
,
4
,
5
,
3
},
//< C L R Ls Rs LFE
};
static
av_cold
int
Faac_encode_init
(
AVCodecContext
*
avctx
)
{
FaacAudioContext
*
s
=
avctx
->
priv_data
;
...
...
@@ -86,6 +93,9 @@ static av_cold int Faac_encode_init(AVCodecContext *avctx)
}
faac_cfg
->
outputFormat
=
1
;
faac_cfg
->
inputFormat
=
FAAC_INPUT_16BIT
;
if
(
avctx
->
channels
>
2
)
memcpy
(
faac_cfg
->
channel_map
,
channel_maps
[
avctx
->
channels
-
3
],
avctx
->
channels
*
sizeof
(
int
));
avctx
->
frame_size
=
samples_input
/
avctx
->
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