From cba2022045efa0b8403609c22eaab9849f51d623 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Mon, 3 May 2004 13:25:22 +0000 Subject: [PATCH] gst/audioconvert/gstaudioconvert.c: refactor/comment code Original commit message from CVS: * gst/audioconvert/gstaudioconvert.c: (_fixate_caps_to_int): refactor/comment code --- ChangeLog | 5 +++++ gst/audioconvert/gstaudioconvert.c | 29 +++++++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index f8455c0c70..b83e599057 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-05-03 Thomas Vander Stichele + + * gst/audioconvert/gstaudioconvert.c: (_fixate_caps_to_int): + refactor/comment code + 2004-05-02 Ronald Bultje * gst/asfdemux/Makefile.am: diff --git a/gst/audioconvert/gstaudioconvert.c b/gst/audioconvert/gstaudioconvert.c index 5412969eb9..2d444ecee9 100644 --- a/gst/audioconvert/gstaudioconvert.c +++ b/gst/audioconvert/gstaudioconvert.c @@ -418,37 +418,42 @@ gst_audio_convert_link (GstPad * pad, const GstCaps * caps) return GST_PAD_LINK_OK; } +/* tries to fixate the given field of the given caps to the given int value */ gboolean _fixate_caps_to_int (GstCaps ** caps, const gchar * field, gint value) { - GstCaps *try, *intersection; + GstCaps *try, *isect_lower, *isect_higher; gboolean ret = FALSE; guint i; + /* First try to see if we can fixate by intersecting given caps with + * simple audio caps with ranges starting/ending with value */ try = gst_caps_new_simple ("audio/x-raw-int", field, GST_TYPE_INT_RANGE, G_MININT, value - 1, NULL); gst_caps_append (try, gst_caps_new_simple ("audio/x-raw-float", field, GST_TYPE_INT_RANGE, G_MININT, value - 1, NULL)); - intersection = gst_caps_intersect (*caps, try); - if (!gst_caps_is_empty (intersection)) { - gst_caps_free (try); + isect_lower = gst_caps_intersect (*caps, try); + gst_caps_free (try); + + if (!gst_caps_is_empty (isect_lower)) { try = gst_caps_new_simple ("audio/x-raw-int", field, GST_TYPE_INT_RANGE, value, G_MAXINT, NULL); gst_caps_append (try, gst_caps_new_simple ("audio/x-raw-float", field, GST_TYPE_INT_RANGE, value, G_MAXINT, NULL)); - gst_caps_free (intersection); - intersection = gst_caps_intersect (*caps, try); - if (!gst_caps_is_empty (intersection)) { + isect_higher = gst_caps_intersect (*caps, try); + /* FIXME: why choose to end up with the higher range, and not the fixed + * value ? */ + if (!gst_caps_is_empty (isect_higher)) { gst_caps_free (*caps); - *caps = intersection; + *caps = isect_higher; ret = TRUE; } else { - gst_caps_free (intersection); + gst_caps_free (isect_higher); } - } else { - gst_caps_free (intersection); } - gst_caps_free (try); + gst_caps_free (isect_lower); + + /* FIXME: why don't we already return here when ret == TRUE ? */ for (i = 0; i < gst_caps_get_size (*caps); i++) { GstStructure *structure = gst_caps_get_structure (*caps, i);