mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 02:15:31 +00:00
audio: Properly handle signedness in gst_audio_format_build_integer()
This commit is contained in:
parent
45c4a19472
commit
b4858253dc
2 changed files with 19 additions and 1 deletions
|
@ -153,17 +153,21 @@ gst_audio_format_build_integer (gboolean sign, gint endianness,
|
|||
/* must be int */
|
||||
if (!GST_AUDIO_FORMAT_INFO_IS_INTEGER (finfo))
|
||||
continue;
|
||||
|
||||
/* width and depth must match */
|
||||
if (width != GST_AUDIO_FORMAT_INFO_WIDTH (finfo))
|
||||
continue;
|
||||
if (depth != GST_AUDIO_FORMAT_INFO_DEPTH (finfo))
|
||||
continue;
|
||||
|
||||
/* if there is endianness, it must match */
|
||||
e = GST_AUDIO_FORMAT_INFO_ENDIANNESS (finfo);
|
||||
if (e && e != endianness)
|
||||
continue;
|
||||
|
||||
/* check sign */
|
||||
if (sign && !GST_AUDIO_FORMAT_INFO_IS_SIGNED (finfo))
|
||||
if ((sign && !GST_AUDIO_FORMAT_INFO_IS_SIGNED (finfo)) ||
|
||||
(!sign && GST_AUDIO_FORMAT_INFO_IS_SIGNED (finfo)))
|
||||
continue;
|
||||
|
||||
return GST_AUDIO_FORMAT_INFO_FORMAT (finfo);
|
||||
|
|
|
@ -551,6 +551,19 @@ GST_START_TEST (test_channel_layout_value_intersect)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_audio_info)
|
||||
{
|
||||
GstAudioFormat fmt;
|
||||
|
||||
fmt = gst_audio_format_build_integer (TRUE, G_BYTE_ORDER, 8, 8);
|
||||
fail_unless (fmt == GST_AUDIO_FORMAT_S8);
|
||||
|
||||
fmt = gst_audio_format_build_integer (FALSE, G_BYTE_ORDER, 8, 8);
|
||||
fail_unless (fmt == GST_AUDIO_FORMAT_U8);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
audio_suite (void)
|
||||
{
|
||||
|
@ -559,6 +572,7 @@ audio_suite (void)
|
|||
TCase *tc_chain = tcase_create ("general");
|
||||
|
||||
suite_add_tcase (s, tc_chain);
|
||||
tcase_add_test (tc_chain, test_audio_info);
|
||||
tcase_add_test (tc_chain, test_multichannel_checks);
|
||||
tcase_add_test (tc_chain, test_buffer_clipping_time);
|
||||
tcase_add_test (tc_chain, test_buffer_clipping_samples);
|
||||
|
|
Loading…
Reference in a new issue