From fc0d9bd2430dd53eaf8f403b685516ada5e0d4aa Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 5 Jan 2012 14:06:33 +0100 Subject: [PATCH] ffmpeg: port to new channel mapping --- ext/ffmpeg/gstffmpegcodecmap.c | 18 ++++++++++++++---- ext/ffmpeg/gstffmpegcodecmap.h | 1 - 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ext/ffmpeg/gstffmpegcodecmap.c b/ext/ffmpeg/gstffmpegcodecmap.c index 5acd990bb2..e4f5210be2 100644 --- a/ext/ffmpeg/gstffmpegcodecmap.c +++ b/ext/ffmpeg/gstffmpegcodecmap.c @@ -83,7 +83,7 @@ static const struct CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, { CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, { CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, { - CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, { + CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE1}, { CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, { CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, { CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, { @@ -142,7 +142,8 @@ gst_ff_channel_layout_to_gst (guint64 channel_layout, guint channels) none_layout = TRUE; } - if (!none_layout && !gst_audio_check_channel_positions (pos, nchannels)) { + if (!none_layout + && !gst_audio_check_valid_channel_positions (pos, nchannels, TRUE)) { GST_ERROR ("Invalid channel layout %" G_GUINT64_FORMAT " - assuming NONE layout", channel_layout); none_layout = TRUE; @@ -150,7 +151,7 @@ gst_ff_channel_layout_to_gst (guint64 channel_layout, guint channels) if (none_layout) { if (nchannels == 1) { - pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_MONO; + pos[0] = GST_AUDIO_CHANNEL_POSITION_MONO; } else if (nchannels == 2) { pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT; pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT; @@ -338,9 +339,13 @@ gst_ff_aud_caps_new (AVCodecContext * context, enum CodecID codec_id, /* fixed, non-probing context */ if (context != NULL && context->channels != -1) { + GstAudioInfo info; GstAudioChannelPosition *pos; guint64 channel_layout = context->channel_layout; + gst_audio_info_init (&info); + + if (channel_layout == 0) { const guint64 default_channel_set[] = { 0, 0, CH_LAYOUT_SURROUND, CH_LAYOUT_QUAD, CH_LAYOUT_5POINT0, @@ -366,7 +371,12 @@ gst_ff_aud_caps_new (AVCodecContext * context, enum CodecID codec_id, 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); + guint64 mask; + + if (gst_audio_channel_positions_to_mask (pos, context->channels, &mask)) { + gst_caps_set_simple (caps, "channel-mask", GST_TYPE_BITMASK, &mask, + NULL); + } g_free (pos); } } else { diff --git a/ext/ffmpeg/gstffmpegcodecmap.h b/ext/ffmpeg/gstffmpegcodecmap.h index a19dbd9e5c..164c5e4441 100644 --- a/ext/ffmpeg/gstffmpegcodecmap.h +++ b/ext/ffmpeg/gstffmpegcodecmap.h @@ -28,7 +28,6 @@ #include #include -#include /* * _codecid_to_caps () gets the GstCaps that belongs to