Commit d3c59d50 authored by Justin Ruggles's avatar Justin Ruggles

avconv: use default channel layouts when they are unknown

If either input or output layout is known and the channel counts match,
use the known layout for both. Otherwise choose the default layout based on
av_get_default_channel_layout().

Changed some FATE references due to some WAVE files now having a non-zero
channel mask.
parent 95a8dac5
......@@ -2145,6 +2145,51 @@ static void print_sdp(OutputFile *output_files, int n)
av_freep(&avc);
}
static void get_default_channel_layouts(OutputStream *ost, InputStream *ist)
{
char layout_name[256];
AVCodecContext *enc = ost->st->codec;
AVCodecContext *dec = ist->st->codec;
if (!dec->channel_layout) {
if (enc->channel_layout && dec->channels == enc->channels) {
dec->channel_layout = enc->channel_layout;
} else {
dec->channel_layout = av_get_default_channel_layout(dec->channels);
if (!dec->channel_layout) {
av_log(NULL, AV_LOG_FATAL, "Unable to find default channel "
"layout for Input Stream #%d.%d\n", ist->file_index,
ist->st->index);
exit_program(1);
}
}
av_get_channel_layout_string(layout_name, sizeof(layout_name),
dec->channels, dec->channel_layout);
av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream "
"#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name);
}
if (!enc->channel_layout) {
if (dec->channels == enc->channels) {
enc->channel_layout = dec->channel_layout;
return;
} else {
enc->channel_layout = av_get_default_channel_layout(enc->channels);
}
if (!enc->channel_layout) {
av_log(NULL, AV_LOG_FATAL, "Unable to find default channel layout "
"for Output Stream #%d.%d\n", ost->file_index,
ost->st->index);
exit_program(1);
}
av_get_channel_layout_string(layout_name, sizeof(layout_name),
enc->channels, enc->channel_layout);
av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Output Stream "
"#%d.%d : %s\n", ost->file_index, ost->st->index, layout_name);
}
}
static int init_input_stream(int ist_index, OutputStream *output_streams, int nb_output_streams,
char *error, int error_len)
{
......@@ -2183,6 +2228,17 @@ static int init_input_stream(int ist_index, OutputStream *output_streams, int nb
}
assert_codec_experimental(ist->st->codec, 0);
assert_avoptions(ist->opts);
if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = &output_streams[i];
if (ost->source_index == ist_index) {
if (!ist->st->codec->channel_layout || !ost->st->codec->channel_layout)
get_default_channel_layouts(ost, ist);
break;
}
}
}
}
ist->last_dts = ist->st->avg_frame_rate.num ? - ist->st->codec->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
......
46f44f86a18984a832206ab9e29a79f2 *./tests/data/acodec/pcm_f32le.wav
653d82a64b7bd96ac193e105e9f92d4c *./tests/data/acodec/pcm_f32le.wav
2116880 ./tests/data/acodec/pcm_f32le.wav
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_f32le.acodec.out.wav
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400
ba17c6d1a270e1333e981f239bf7eb45 *./tests/data/acodec/pcm_f64le.wav
48b4cd378f47a50dc902aa03cc8280ed *./tests/data/acodec/pcm_f64le.wav
4233680 ./tests/data/acodec/pcm_f64le.wav
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_f64le.acodec.out.wav
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400
8168a5c1343553ef027541830f2cb879 *./tests/data/acodec/pcm_s24daud.302
10368730 ./tests/data/acodec/pcm_s24daud.302
f552afadfdfcd6348a07095da6382de5 *./tests/data/pcm_s24daud.acodec.out.wav
7ce988d6c5b2bf0ebf0216ba15bc5cee *./tests/data/pcm_s24daud.acodec.out.wav
stddev: 9416.28 PSNR: 16.85 MAXDIFF:42744 bytes: 6911796/ 1058400
a85380fb79b0d4fff38e24ac1e34bb94 *./tests/data/acodec/pcm_s24le.wav
18ea73985dbdf59e23f5aba66145e6fe *./tests/data/acodec/pcm_s24le.wav
1587668 ./tests/data/acodec/pcm_s24le.wav
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s24le.acodec.out.wav
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400
da6ed80f4f40f0082577dea80827e014 *./tests/data/acodec/pcm_s32le.wav
8d8849fa5c5d91b9cb74f5c74e937faf *./tests/data/acodec/pcm_s32le.wav
2116868 ./tests/data/acodec/pcm_s32le.wav
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s32le.acodec.out.wav
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400
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