matroskademux: align raw audio memory to powers of two

https://bugzilla.gnome.org/show_bug.cgi?id=725008
This commit is contained in:
Tim-Philipp Müller 2014-02-27 00:43:48 +00:00
parent c3dc53e551
commit f3163fb45f

View file

@ -5200,6 +5200,18 @@ aac_profile_idx (const gchar * codec_id)
return profile;
}
static guint
round_up_pow2 (guint n)
{
n = n - 1;
n = n | (n >> 1);
n = n | (n >> 2);
n = n | (n >> 4);
n = n | (n >> 8);
n = n | (n >> 16);
return n + 1;
}
#define AAC_SYNC_EXTENSION_TYPE 0x02b7
static GstCaps *
@ -5265,8 +5277,7 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
*codec_name = g_strdup_printf ("Raw %d-bit PCM audio",
audiocontext->bitdepth);
context->alignment = GST_ROUND_UP_8 (audiocontext->bitdepth) / 8;
if (context->alignment > 1 && context->alignment % 2)
++context->alignment;
context->alignment = round_up_pow2 (context->alignment);
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_PCM_FLOAT)) {
const gchar *format;
if (audiocontext->bitdepth == 32)
@ -5280,8 +5291,7 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
*codec_name = g_strdup_printf ("Raw %d-bit floating-point audio",
audiocontext->bitdepth);
context->alignment = audiocontext->bitdepth / 8;
if (context->alignment > 1 && context->alignment % 2)
++context->alignment;
context->alignment = round_up_pow2 (context->alignment);
} else if (!strncmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_AC3,
strlen (GST_MATROSKA_CODEC_ID_AUDIO_AC3))) {
caps = gst_caps_new_simple ("audio/x-ac3",