Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
c5978915
Commit
c5978915
authored
Apr 29, 2013
by
Rafaël Carré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sout avcodec: simplify OpenEncoder retry
parent
c27af088
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
55 deletions
+48
-55
modules/codec/avcodec/encoder.c
modules/codec/avcodec/encoder.c
+48
-55
No files found.
modules/codec/avcodec/encoder.c
View file @
c5978915
...
...
@@ -740,73 +740,66 @@ int OpenEncoder( vlc_object_t *p_this )
vlc_avcodec_unlock
();
if
(
ret
)
{
if
(
p_enc
->
fmt_in
.
i_cat
==
AUDIO_ES
&&
(
p_context
->
channels
>
2
||
i_codec_id
=
=
AV_CODEC_ID_MP2
||
i_codec_id
=
=
AV_CODEC_ID_MP3
)
)
if
(
p_enc
->
fmt_in
.
i_cat
!=
AUDIO_ES
||
(
p_context
->
channels
<=
2
&&
i_codec_id
!
=
AV_CODEC_ID_MP2
&&
i_codec_id
!
=
AV_CODEC_ID_MP3
)
)
{
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)"
)
;
}
msg_Err
(
p_enc
,
"cannot open encoder"
);
dialog_Fatal
(
p_enc
,
_
(
"Streaming / Transcoding failed"
),
"%s"
,
_
(
"VLC could not open the encoder."
)
)
;
free
(
p_sys
);
return
VLC_EGENERIC
;
}
if
(
i_codec_id
==
AV_CODEC_ID_MP2
||
i_codec_id
==
AV_CODEC_ID_MP3
)
{
int
i_frequency
,
i
;
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)"
);
}
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
;
}
if
(
i_codec_id
==
AV_CODEC_ID_MP2
||
i_codec_id
==
AV_CODEC_ID_MP3
)
{
int
i_frequency
,
i
;
es_format_t
*
fmt
=
&
p_enc
->
fmt_out
;
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
;
}
}
for
(
i_frequency
=
0
;
i_frequency
<
6
;
i_frequency
++
)
if
(
fmt
->
audio
.
i_rate
==
mpa_freq_tab
[
i_frequency
]
)
break
;
p_context
->
codec
=
NULL
;
vlc_avcodec_lock
();
ret
=
avcodec_open2
(
p_context
,
p_codec
,
NULL
/* options */
);
vlc_avcodec_unlock
();
if
(
ret
)
if
(
i_frequency
==
6
)
{
msg_Err
(
p_enc
,
"cannot open encoder"
);
dialog_Fatal
(
p_enc
,
_
(
"Streaming / Transcoding failed"
),
"%s"
,
_
(
"VLC could not open the encoder."
)
);
msg_Err
(
p_enc
,
"MPEG audio doesn't support frequency=%d"
,
fmt
->
audio
.
i_rate
);
free
(
p_sys
);
return
VLC_EGENERIC
;
}
for
(
i
=
1
;
i
<
14
;
i
++
)
if
(
fmt
->
i_bitrate
/
1000
<=
mpa_bitrate_tab
[
i_frequency
/
3
][
i
])
break
;
if
(
fmt
->
i_bitrate
/
1000
!=
mpa_bitrate_tab
[
i_frequency
/
3
][
i
])
{
msg_Warn
(
p_enc
,
"MPEG audio doesn't support bitrate=%d, using %d"
,
fmt
->
i_bitrate
,
mpa_bitrate_tab
[
i_frequency
/
3
][
i
]
*
1000
);
fmt
->
i_bitrate
=
mpa_bitrate_tab
[
i_frequency
/
3
][
i
]
*
1000
;
p_context
->
bit_rate
=
fmt
->
i_bitrate
;
}
}
else
p_context
->
codec
=
NULL
;
vlc_avcodec_lock
();
ret
=
avcodec_open2
(
p_context
,
p_codec
,
NULL
/* options */
);
vlc_avcodec_unlock
();
if
(
ret
)
{
msg_Err
(
p_enc
,
"cannot open encoder"
);
dialog_Fatal
(
p_enc
,
_
(
"Streaming / Transcoding failed"
),
"%s"
,
_
(
"VLC could not open the encoder."
)
);
dialog_Fatal
(
p_enc
,
_
(
"Streaming / Transcoding failed"
),
"%s"
,
_
(
"VLC could not open the encoder."
)
);
free
(
p_sys
);
return
VLC_EGENERIC
;
}
...
...
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