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
53107041
Commit
53107041
authored
Dec 15, 2011
by
Nathan Caldwell
Committed by
Alex Converse
Jan 23, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aacenc: cosmetics: move init() and end() to the bottom of the file.
Signed-off-by:
Alex Converse
<
alex.converse@gmail.com
>
parent
17ae6081
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
102 deletions
+102
-102
aacenc.c
libavcodec/aacenc.c
+102
-102
No files found.
libavcodec/aacenc.c
View file @
53107041
...
@@ -166,108 +166,6 @@ static void put_audio_specific_config(AVCodecContext *avctx)
...
@@ -166,108 +166,6 @@ static void put_audio_specific_config(AVCodecContext *avctx)
flush_put_bits
(
&
pb
);
flush_put_bits
(
&
pb
);
}
}
static
av_cold
int
aac_encode_end
(
AVCodecContext
*
avctx
)
{
AACEncContext
*
s
=
avctx
->
priv_data
;
ff_mdct_end
(
&
s
->
mdct1024
);
ff_mdct_end
(
&
s
->
mdct128
);
ff_psy_end
(
&
s
->
psy
);
if
(
s
->
psypp
)
ff_psy_preprocess_end
(
s
->
psypp
);
av_freep
(
&
s
->
samples
);
av_freep
(
&
s
->
cpe
);
return
0
;
}
static
av_cold
int
dsp_init
(
AVCodecContext
*
avctx
,
AACEncContext
*
s
)
{
int
ret
=
0
;
dsputil_init
(
&
s
->
dsp
,
avctx
);
// window init
ff_kbd_window_init
(
ff_aac_kbd_long_1024
,
4
.
0
,
1024
);
ff_kbd_window_init
(
ff_aac_kbd_short_128
,
6
.
0
,
128
);
ff_init_ff_sine_windows
(
10
);
ff_init_ff_sine_windows
(
7
);
if
(
ret
=
ff_mdct_init
(
&
s
->
mdct1024
,
11
,
0
,
1
.
0
))
return
ret
;
if
(
ret
=
ff_mdct_init
(
&
s
->
mdct128
,
8
,
0
,
1
.
0
))
return
ret
;
return
0
;
}
static
av_cold
int
alloc_buffers
(
AVCodecContext
*
avctx
,
AACEncContext
*
s
)
{
FF_ALLOC_OR_GOTO
(
avctx
,
s
->
samples
,
2
*
1024
*
avctx
->
channels
*
sizeof
(
s
->
samples
[
0
]),
alloc_fail
);
FF_ALLOCZ_OR_GOTO
(
avctx
,
s
->
cpe
,
sizeof
(
ChannelElement
)
*
s
->
chan_map
[
0
],
alloc_fail
);
FF_ALLOCZ_OR_GOTO
(
avctx
,
avctx
->
extradata
,
5
+
FF_INPUT_BUFFER_PADDING_SIZE
,
alloc_fail
);
return
0
;
alloc_fail:
return
AVERROR
(
ENOMEM
);
}
static
av_cold
int
aac_encode_init
(
AVCodecContext
*
avctx
)
{
AACEncContext
*
s
=
avctx
->
priv_data
;
int
i
,
ret
=
0
;
const
uint8_t
*
sizes
[
2
];
uint8_t
grouping
[
AAC_MAX_CHANNELS
];
int
lengths
[
2
];
avctx
->
frame_size
=
1024
;
for
(
i
=
0
;
i
<
16
;
i
++
)
if
(
avctx
->
sample_rate
==
avpriv_mpeg4audio_sample_rates
[
i
])
break
;
ERROR_IF
(
i
==
16
,
"Unsupported sample rate %d
\n
"
,
avctx
->
sample_rate
);
ERROR_IF
(
avctx
->
channels
>
AAC_MAX_CHANNELS
,
"Unsupported number of channels: %d
\n
"
,
avctx
->
channels
);
ERROR_IF
(
avctx
->
profile
!=
FF_PROFILE_UNKNOWN
&&
avctx
->
profile
!=
FF_PROFILE_AAC_LOW
,
"Unsupported profile %d
\n
"
,
avctx
->
profile
);
ERROR_IF
(
1024
.
0
*
avctx
->
bit_rate
/
avctx
->
sample_rate
>
6144
*
avctx
->
channels
,
"Too many bits per frame requested
\n
"
);
s
->
samplerate_index
=
i
;
s
->
chan_map
=
aac_chan_configs
[
avctx
->
channels
-
1
];
if
(
ret
=
dsp_init
(
avctx
,
s
))
goto
fail
;
if
(
ret
=
alloc_buffers
(
avctx
,
s
))
goto
fail
;
avctx
->
extradata_size
=
5
;
put_audio_specific_config
(
avctx
);
sizes
[
0
]
=
swb_size_1024
[
i
];
sizes
[
1
]
=
swb_size_128
[
i
];
lengths
[
0
]
=
ff_aac_num_swb_1024
[
i
];
lengths
[
1
]
=
ff_aac_num_swb_128
[
i
];
for
(
i
=
0
;
i
<
s
->
chan_map
[
0
];
i
++
)
grouping
[
i
]
=
s
->
chan_map
[
i
+
1
]
==
TYPE_CPE
;
if
(
ret
=
ff_psy_init
(
&
s
->
psy
,
avctx
,
2
,
sizes
,
lengths
,
s
->
chan_map
[
0
],
grouping
))
goto
fail
;
s
->
psypp
=
ff_psy_preprocess_init
(
avctx
);
s
->
coder
=
&
ff_aac_coders
[
2
];
s
->
lambda
=
avctx
->
global_quality
?
avctx
->
global_quality
:
120
;
ff_aac_tableinit
();
return
0
;
fail:
aac_encode_end
(
avctx
);
return
ret
;
}
static
void
apply_window_and_mdct
(
AVCodecContext
*
avctx
,
AACEncContext
*
s
,
static
void
apply_window_and_mdct
(
AVCodecContext
*
avctx
,
AACEncContext
*
s
,
SingleChannelElement
*
sce
,
short
*
audio
)
SingleChannelElement
*
sce
,
short
*
audio
)
{
{
...
@@ -697,6 +595,108 @@ static int aac_encode_frame(AVCodecContext *avctx,
...
@@ -697,6 +595,108 @@ static int aac_encode_frame(AVCodecContext *avctx,
return
put_bits_count
(
&
s
->
pb
)
>>
3
;
return
put_bits_count
(
&
s
->
pb
)
>>
3
;
}
}
static
av_cold
int
aac_encode_end
(
AVCodecContext
*
avctx
)
{
AACEncContext
*
s
=
avctx
->
priv_data
;
ff_mdct_end
(
&
s
->
mdct1024
);
ff_mdct_end
(
&
s
->
mdct128
);
ff_psy_end
(
&
s
->
psy
);
if
(
s
->
psypp
)
ff_psy_preprocess_end
(
s
->
psypp
);
av_freep
(
&
s
->
samples
);
av_freep
(
&
s
->
cpe
);
return
0
;
}
static
av_cold
int
dsp_init
(
AVCodecContext
*
avctx
,
AACEncContext
*
s
)
{
int
ret
=
0
;
dsputil_init
(
&
s
->
dsp
,
avctx
);
// window init
ff_kbd_window_init
(
ff_aac_kbd_long_1024
,
4
.
0
,
1024
);
ff_kbd_window_init
(
ff_aac_kbd_short_128
,
6
.
0
,
128
);
ff_init_ff_sine_windows
(
10
);
ff_init_ff_sine_windows
(
7
);
if
(
ret
=
ff_mdct_init
(
&
s
->
mdct1024
,
11
,
0
,
1
.
0
))
return
ret
;
if
(
ret
=
ff_mdct_init
(
&
s
->
mdct128
,
8
,
0
,
1
.
0
))
return
ret
;
return
0
;
}
static
av_cold
int
alloc_buffers
(
AVCodecContext
*
avctx
,
AACEncContext
*
s
)
{
FF_ALLOC_OR_GOTO
(
avctx
,
s
->
samples
,
2
*
1024
*
avctx
->
channels
*
sizeof
(
s
->
samples
[
0
]),
alloc_fail
);
FF_ALLOCZ_OR_GOTO
(
avctx
,
s
->
cpe
,
sizeof
(
ChannelElement
)
*
s
->
chan_map
[
0
],
alloc_fail
);
FF_ALLOCZ_OR_GOTO
(
avctx
,
avctx
->
extradata
,
5
+
FF_INPUT_BUFFER_PADDING_SIZE
,
alloc_fail
);
return
0
;
alloc_fail:
return
AVERROR
(
ENOMEM
);
}
static
av_cold
int
aac_encode_init
(
AVCodecContext
*
avctx
)
{
AACEncContext
*
s
=
avctx
->
priv_data
;
int
i
,
ret
=
0
;
const
uint8_t
*
sizes
[
2
];
uint8_t
grouping
[
AAC_MAX_CHANNELS
];
int
lengths
[
2
];
avctx
->
frame_size
=
1024
;
for
(
i
=
0
;
i
<
16
;
i
++
)
if
(
avctx
->
sample_rate
==
avpriv_mpeg4audio_sample_rates
[
i
])
break
;
ERROR_IF
(
i
==
16
,
"Unsupported sample rate %d
\n
"
,
avctx
->
sample_rate
);
ERROR_IF
(
avctx
->
channels
>
AAC_MAX_CHANNELS
,
"Unsupported number of channels: %d
\n
"
,
avctx
->
channels
);
ERROR_IF
(
avctx
->
profile
!=
FF_PROFILE_UNKNOWN
&&
avctx
->
profile
!=
FF_PROFILE_AAC_LOW
,
"Unsupported profile %d
\n
"
,
avctx
->
profile
);
ERROR_IF
(
1024
.
0
*
avctx
->
bit_rate
/
avctx
->
sample_rate
>
6144
*
avctx
->
channels
,
"Too many bits per frame requested
\n
"
);
s
->
samplerate_index
=
i
;
s
->
chan_map
=
aac_chan_configs
[
avctx
->
channels
-
1
];
if
(
ret
=
dsp_init
(
avctx
,
s
))
goto
fail
;
if
(
ret
=
alloc_buffers
(
avctx
,
s
))
goto
fail
;
avctx
->
extradata_size
=
5
;
put_audio_specific_config
(
avctx
);
sizes
[
0
]
=
swb_size_1024
[
i
];
sizes
[
1
]
=
swb_size_128
[
i
];
lengths
[
0
]
=
ff_aac_num_swb_1024
[
i
];
lengths
[
1
]
=
ff_aac_num_swb_128
[
i
];
for
(
i
=
0
;
i
<
s
->
chan_map
[
0
];
i
++
)
grouping
[
i
]
=
s
->
chan_map
[
i
+
1
]
==
TYPE_CPE
;
if
(
ret
=
ff_psy_init
(
&
s
->
psy
,
avctx
,
2
,
sizes
,
lengths
,
s
->
chan_map
[
0
],
grouping
))
goto
fail
;
s
->
psypp
=
ff_psy_preprocess_init
(
avctx
);
s
->
coder
=
&
ff_aac_coders
[
2
];
s
->
lambda
=
avctx
->
global_quality
?
avctx
->
global_quality
:
120
;
ff_aac_tableinit
();
return
0
;
fail:
aac_encode_end
(
avctx
);
return
ret
;
}
#define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
#define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
static
const
AVOption
aacenc_options
[]
=
{
static
const
AVOption
aacenc_options
[]
=
{
{
"stereo_mode"
,
"Stereo coding method"
,
offsetof
(
AACEncContext
,
options
.
stereo_mode
),
AV_OPT_TYPE_INT
,
{.
dbl
=
0
},
-
1
,
1
,
AACENC_FLAGS
,
"stereo_mode"
},
{
"stereo_mode"
,
"Stereo coding method"
,
offsetof
(
AACEncContext
,
options
.
stereo_mode
),
AV_OPT_TYPE_INT
,
{.
dbl
=
0
},
-
1
,
1
,
AACENC_FLAGS
,
"stereo_mode"
},
...
...
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