diff options
author | Jan Schmidt <thaytan@noraisin.net> | 2009-11-20 20:28:06 +0100 |
---|---|---|
committer | Jan Schmidt <thaytan@noraisin.net> | 2009-11-22 12:28:12 +0100 |
commit | faa417cf34ca90c89155288d3e34b27736c07ade (patch) | |
tree | 27d563d7a55f69b05fe0d8009182a715e61498c3 | |
parent | b69fcc471ea268587a8796ddffc888f321933d0a (diff) |
caps: Use default audio channel layouts for some codecs
For a few white-listed codecs, use default fallback channel
layouts when ffmpeg doesn't inform us.
-rw-r--r-- | ext/ffmpeg/gstffmpegcodecmap.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/ext/ffmpeg/gstffmpegcodecmap.c b/ext/ffmpeg/gstffmpegcodecmap.c index 5427a53..f380d8c 100644 --- a/ext/ffmpeg/gstffmpegcodecmap.c +++ b/ext/ffmpeg/gstffmpegcodecmap.c @@ -321,14 +321,32 @@ gst_ff_aud_caps_new (AVCodecContext * context, enum CodecID codec_id, /* fixed, non-probing context */ if (context != NULL && context->channels != -1) { GstAudioChannelPosition *pos; + guint64 channel_layout = context->channel_layout; + + if (channel_layout == 0) { + const guint64 default_channel_set[] = { + 0, 0, CH_LAYOUT_SURROUND, CH_LAYOUT_QUAD, CH_LAYOUT_5POINT0, + CH_LAYOUT_5POINT1, 0, CH_LAYOUT_7POINT1 + }; + + switch (codec_id) { + case CODEC_ID_EAC3: + case CODEC_ID_AC3: + case CODEC_ID_DTS: + if (context->channels > 0 + && context->channels < G_N_ELEMENTS (default_channel_set)) + channel_layout = default_channel_set[context->channels - 1]; + break; + default: + break; + } + } caps = gst_caps_new_simple (mimetype, "rate", G_TYPE_INT, context->sample_rate, "channels", G_TYPE_INT, context->channels, NULL); - pos = - gst_ff_channel_layout_to_gst (context->channel_layout, - context->channels); + pos = gst_ff_channel_layout_to_gst (channel_layout, context->channels); if (pos != NULL) { gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos); g_free (pos); |