Commit c5978915 authored by Rafaël Carré's avatar Rafaël Carré

sout avcodec: simplify OpenEncoder retry

parent c27af088
......@@ -740,10 +740,17 @@ 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) )
{
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( p_context->channels > 2 )
{
p_context->channels = 2;
......@@ -754,37 +761,32 @@ int OpenEncoder( vlc_object_t *p_this )
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_frequency = 0; i_frequency < 6; i_frequency++ )
{
if ( p_enc->fmt_out.audio.i_rate
== mpa_freq_tab[i_frequency] )
if ( fmt->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 );
fmt->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] )
if (fmt->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] )
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",
p_enc->fmt_out.i_bitrate,
fmt->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;
fmt->i_bitrate = mpa_bitrate_tab[i_frequency / 3][i] * 1000;
p_context->bit_rate = fmt->i_bitrate;
}
}
......@@ -802,15 +804,6 @@ int OpenEncoder( vlc_object_t *p_this )
return VLC_EGENERIC;
}
}
else
{
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_FLAC )
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment