mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
fdkaacenc: Refactor layout selection code
No functional change. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1359>
This commit is contained in:
parent
5e68124981
commit
76c171509e
1 changed files with 30 additions and 24 deletions
|
@ -161,19 +161,19 @@ gst_fdkaacenc_get_caps (GstAudioEncoder * enc, GstCaps * filter)
|
||||||
caps = gst_caps_new_empty ();
|
caps = gst_caps_new_empty ();
|
||||||
|
|
||||||
for (layout = channel_layouts; layout->channels; layout++) {
|
for (layout = channel_layouts; layout->channels; layout++) {
|
||||||
guint64 channel_mask;
|
gint channels = layout->channels;
|
||||||
GstCaps *tmp =
|
GstCaps *tmp =
|
||||||
gst_caps_make_writable (gst_pad_get_pad_template_caps
|
gst_caps_make_writable (gst_pad_get_pad_template_caps
|
||||||
(GST_AUDIO_ENCODER_SINK_PAD (enc)));
|
(GST_AUDIO_ENCODER_SINK_PAD (enc)));
|
||||||
|
|
||||||
if (layout->channels == 1) {
|
if (channels == 1) {
|
||||||
gst_caps_set_simple (tmp, "channels", G_TYPE_INT, layout->channels, NULL);
|
gst_caps_set_simple (tmp, "channels", G_TYPE_INT, channels, NULL);
|
||||||
} else {
|
} else {
|
||||||
gst_audio_channel_positions_to_mask (layout->positions,
|
guint64 channel_mask;
|
||||||
layout->channels, FALSE, &channel_mask);
|
gst_audio_channel_positions_to_mask (layout->positions, channels, FALSE,
|
||||||
gst_caps_set_simple (tmp, "channels", G_TYPE_INT,
|
&channel_mask);
|
||||||
layout->channels, "channel-mask", GST_TYPE_BITMASK,
|
gst_caps_set_simple (tmp, "channels", G_TYPE_INT, channels,
|
||||||
channel_mask, NULL);
|
"channel-mask", GST_TYPE_BITMASK, channel_mask, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_caps_append (caps, tmp);
|
gst_caps_append (caps, tmp);
|
||||||
|
@ -256,27 +256,33 @@ gst_fdkaacenc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
|
||||||
self->need_reorder = FALSE;
|
self->need_reorder = FALSE;
|
||||||
self->aac_positions = NULL;
|
self->aac_positions = NULL;
|
||||||
} else {
|
} else {
|
||||||
guint64 in_channel_mask, out_channel_mask;
|
gint in_channels = GST_AUDIO_INFO_CHANNELS (info);
|
||||||
|
const GstAudioChannelPosition *in_positions =
|
||||||
|
&GST_AUDIO_INFO_POSITION (info, 0);
|
||||||
|
guint64 in_channel_mask;
|
||||||
const GstFdkAacChannelLayout *layout;
|
const GstFdkAacChannelLayout *layout;
|
||||||
|
|
||||||
|
gst_audio_channel_positions_to_mask (in_positions, in_channels, FALSE,
|
||||||
|
&in_channel_mask);
|
||||||
|
|
||||||
for (layout = channel_layouts; layout->channels; layout++) {
|
for (layout = channel_layouts; layout->channels; layout++) {
|
||||||
if (layout->channels != GST_AUDIO_INFO_CHANNELS (info))
|
gint channels = layout->channels;
|
||||||
|
const GstAudioChannelPosition *positions = layout->positions;
|
||||||
|
guint64 channel_mask;
|
||||||
|
|
||||||
|
if (channels != in_channels)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
gst_audio_channel_positions_to_mask (&GST_AUDIO_INFO_POSITION (info, 0),
|
gst_audio_channel_positions_to_mask (positions, channels, FALSE,
|
||||||
GST_AUDIO_INFO_CHANNELS (info), FALSE, &in_channel_mask);
|
&channel_mask);
|
||||||
gst_audio_channel_positions_to_mask (layout->positions,
|
if (channel_mask != in_channel_mask)
|
||||||
layout->channels, FALSE, &out_channel_mask);
|
continue;
|
||||||
if (in_channel_mask == out_channel_mask) {
|
|
||||||
channel_mode = layout->mode;
|
channel_mode = layout->mode;
|
||||||
self->need_reorder =
|
self->need_reorder = memcmp (positions, in_positions,
|
||||||
memcmp (layout->positions,
|
channels * sizeof *positions) != 0;
|
||||||
&GST_AUDIO_INFO_POSITION (info, 0),
|
self->aac_positions = positions;
|
||||||
GST_AUDIO_INFO_CHANNELS (info) *
|
break;
|
||||||
sizeof (GstAudioChannelPosition)) != 0;
|
|
||||||
self->aac_positions = layout->positions;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!layout->channels) {
|
if (!layout->channels) {
|
||||||
|
|
Loading…
Reference in a new issue