summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-04-05 18:11:28 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-04-10 11:30:01 -0400
commitd3c59d5003a483f1a23e225fc71c19bd1116d11c (patch)
tree3d63decab5e2dec4fd8f38eb4fae266de8f85537
parent95a8dac57b1bc21891387c554e0e8b872bef6103 (diff)
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.
-rw-r--r--avconv.c56
-rw-r--r--tests/ref/acodec/pcm_f32le2
-rw-r--r--tests/ref/acodec/pcm_f64le2
-rw-r--r--tests/ref/acodec/pcm_s24daud2
-rw-r--r--tests/ref/acodec/pcm_s24le2
-rw-r--r--tests/ref/acodec/pcm_s32le2
6 files changed, 61 insertions, 5 deletions
diff --git a/avconv.c b/avconv.c
index 2090565eca..2cefe5d549 100644
--- a/avconv.c
+++ b/avconv.c
@@ -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;
diff --git a/tests/ref/acodec/pcm_f32le b/tests/ref/acodec/pcm_f32le
index 38e5c0b719..eb6ea93687 100644
--- a/tests/ref/acodec/pcm_f32le
+++ b/tests/ref/acodec/pcm_f32le
@@ -1,4 +1,4 @@
-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
diff --git a/tests/ref/acodec/pcm_f64le b/tests/ref/acodec/pcm_f64le
index 42875a8d2f..2f0576bf91 100644
--- a/tests/ref/acodec/pcm_f64le
+++ b/tests/ref/acodec/pcm_f64le
@@ -1,4 +1,4 @@
-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
diff --git a/tests/ref/acodec/pcm_s24daud b/tests/ref/acodec/pcm_s24daud
index eab6f8d28e..fb7cad1d89 100644
--- a/tests/ref/acodec/pcm_s24daud
+++ b/tests/ref/acodec/pcm_s24daud
@@ -1,4 +1,4 @@
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
diff --git a/tests/ref/acodec/pcm_s24le b/tests/ref/acodec/pcm_s24le
index a724e8c189..0d86d1e7f7 100644
--- a/tests/ref/acodec/pcm_s24le
+++ b/tests/ref/acodec/pcm_s24le
@@ -1,4 +1,4 @@
-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
diff --git a/tests/ref/acodec/pcm_s32le b/tests/ref/acodec/pcm_s32le
index 86777505f5..2b81c29e6a 100644
--- a/tests/ref/acodec/pcm_s32le
+++ b/tests/ref/acodec/pcm_s32le
@@ -1,4 +1,4 @@
-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