Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
62e5a2bc
Commit
62e5a2bc
authored
Aug 01, 2005
by
Christophe Massiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* modules/codec/twolame.c, modules/codec/ffmpeg/encoder.c: Added sanity
checks for frequencies and bitrates in MPEG audio.
parent
2c50013e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
5 deletions
+98
-5
modules/codec/ffmpeg/encoder.c
modules/codec/ffmpeg/encoder.c
+57
-4
modules/codec/twolame.c
modules/codec/twolame.c
+41
-1
No files found.
modules/codec/ffmpeg/encoder.c
View file @
62e5a2bc
...
...
@@ -157,6 +157,15 @@ static const char *ppsz_enc_options[] = {
"chroma-elim-threshold"
,
NULL
};
static
const
uint16_t
mpa_bitrate_tab
[
2
][
15
]
=
{
{
0
,
32
,
48
,
56
,
64
,
80
,
96
,
112
,
128
,
160
,
192
,
224
,
256
,
320
,
384
},
{
0
,
8
,
16
,
24
,
32
,
40
,
48
,
56
,
64
,
80
,
96
,
112
,
128
,
144
,
160
}
};
static
const
uint16_t
mpa_freq_tab
[
6
]
=
{
44100
,
48000
,
32000
,
22050
,
24000
,
16000
};
/*****************************************************************************
* OpenEncoder: probe the encoder
*****************************************************************************/
...
...
@@ -516,17 +525,61 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
if
(
avcodec_open
(
p_context
,
p_codec
)
)
{
if
(
p_enc
->
fmt_in
.
i_cat
==
AUDIO_ES
&&
p_context
->
channels
>
2
)
if
(
p_enc
->
fmt_in
.
i_cat
==
AUDIO_ES
&&
(
p_context
->
channels
>
2
||
i_codec_id
==
CODEC_ID_MP2
||
i_codec_id
==
CODEC_ID_MP3
)
)
{
p_context
->
channels
=
2
;
p_enc
->
fmt_in
.
audio
.
i_channels
=
2
;
// FIXME
if
(
p_context
->
channels
>
2
)
{
p_context
->
channels
=
2
;
p_enc
->
fmt_in
.
audio
.
i_channels
=
2
;
// FIXME
msg_Warn
(
p_enc
,
"stereo mode selected (codec limitation)"
);
}
if
(
i_codec_id
==
CODEC_ID_MP2
||
i_codec_id
==
CODEC_ID_MP3
)
{
int
i_frequency
,
i
;
for
(
i_frequency
=
0
;
i_frequency
<
6
;
i_frequency
++
)
{
if
(
p_enc
->
fmt_out
.
audio
.
i_rate
==
mpa_freq_tab
[
i_frequency
]
)
break
;
}
if
(
i_frequency
==
6
)
{
msg_Err
(
p_enc
,
"MPEG audio doesn't support frequency=%d"
,
p_enc
->
fmt_out
.
audio
.
i_rate
);
free
(
p_sys
);
return
VLC_EGENERIC
;
}
for
(
i
=
1
;
i
<
14
;
i
++
)
{
if
(
p_enc
->
fmt_out
.
i_bitrate
/
1000
<=
mpa_bitrate_tab
[
i_frequency
/
3
][
i
]
)
break
;
}
if
(
p_enc
->
fmt_out
.
i_bitrate
/
1000
!=
mpa_bitrate_tab
[
i_frequency
/
3
][
i
]
)
{
msg_Warn
(
p_enc
,
"MPEG audio doesn't support bitrate=%d, using %d"
,
p_enc
->
fmt_out
.
i_bitrate
,
mpa_bitrate_tab
[
i_frequency
/
3
][
i
]
*
1000
);
p_enc
->
fmt_out
.
i_bitrate
=
mpa_bitrate_tab
[
i_frequency
/
3
][
i
]
*
1000
;
p_context
->
bit_rate
=
p_enc
->
fmt_out
.
i_bitrate
;
}
}
p_context
->
codec
=
NULL
;
if
(
avcodec_open
(
p_context
,
p_codec
)
)
{
msg_Err
(
p_enc
,
"cannot open encoder"
);
free
(
p_sys
);
return
VLC_EGENERIC
;
}
msg_Warn
(
p_enc
,
"stereo mode selected (codec limitation)"
);
}
else
{
...
...
modules/codec/twolame.c
View file @
62e5a2bc
...
...
@@ -106,11 +106,21 @@ struct encoder_sys_t
/*****************************************************************************
* OpenEncoder: probe the encoder and return score
*****************************************************************************/
static
const
uint16_t
mpa_bitrate_tab
[
2
][
15
]
=
{
{
0
,
32
,
48
,
56
,
64
,
80
,
96
,
112
,
128
,
160
,
192
,
224
,
256
,
320
,
384
},
{
0
,
8
,
16
,
24
,
32
,
40
,
48
,
56
,
64
,
80
,
96
,
112
,
128
,
144
,
160
}
};
static
const
uint16_t
mpa_freq_tab
[
6
]
=
{
44100
,
48000
,
32000
,
22050
,
24000
,
16000
};
static
int
OpenEncoder
(
vlc_object_t
*
p_this
)
{
encoder_t
*
p_enc
=
(
encoder_t
*
)
p_this
;
encoder_sys_t
*
p_sys
;
vlc_value_t
val
;
int
i_frequency
;
if
(
p_enc
->
fmt_out
.
i_codec
!=
VLC_FOURCC
(
'm'
,
'p'
,
'g'
,
'a'
)
&&
p_enc
->
fmt_out
.
i_codec
!=
VLC_FOURCC
(
'm'
,
'p'
,
'2'
,
'a'
)
&&
...
...
@@ -126,6 +136,18 @@ static int OpenEncoder( vlc_object_t *p_this )
return
VLC_EGENERIC
;
}
for
(
i_frequency
=
0
;
i_frequency
<
6
;
i_frequency
++
)
{
if
(
p_enc
->
fmt_out
.
audio
.
i_rate
==
mpa_freq_tab
[
i_frequency
]
)
break
;
}
if
(
i_frequency
==
6
)
{
msg_Err
(
p_enc
,
"MPEG audio doesn't support frequency=%d"
,
p_enc
->
fmt_out
.
audio
.
i_rate
);
return
VLC_EGENERIC
;
}
/* Allocate the memory needed to store the decoder's structure */
if
(
(
p_sys
=
(
encoder_sys_t
*
)
malloc
(
sizeof
(
encoder_sys_t
))
)
==
NULL
)
{
...
...
@@ -159,7 +181,25 @@ static int OpenEncoder( vlc_object_t *p_this )
}
else
{
twolame_set_bitrate
(
p_sys
->
p_twolame
,
p_enc
->
fmt_out
.
i_bitrate
/
1000
);
int
i
;
for
(
i
=
1
;
i
<
14
;
i
++
)
{
if
(
p_enc
->
fmt_out
.
i_bitrate
/
1000
<=
mpa_bitrate_tab
[
i_frequency
/
3
][
i
]
)
break
;
}
if
(
p_enc
->
fmt_out
.
i_bitrate
/
1000
!=
mpa_bitrate_tab
[
i_frequency
/
3
][
i
]
)
{
msg_Warn
(
p_enc
,
"MPEG audio doesn't support bitrate=%d, using %d"
,
p_enc
->
fmt_out
.
i_bitrate
,
mpa_bitrate_tab
[
i_frequency
/
3
][
i
]
*
1000
);
p_enc
->
fmt_out
.
i_bitrate
=
mpa_bitrate_tab
[
i_frequency
/
3
][
i
]
*
1000
;
}
twolame_set_bitrate
(
p_sys
->
p_twolame
,
p_enc
->
fmt_out
.
i_bitrate
/
1000
);
}
if
(
p_enc
->
fmt_in
.
audio
.
i_channels
==
1
)
...
...
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