Bug 7060 - oil_scalarmultiply_s32_ns
Summary: oil_scalarmultiply_s32_ns
Status: NEW
Alias: None
Product: liboil
Classification: Unclassified
Component: unknown (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: high enhancement
Assignee: David Schleef
QA Contact: David Schleef
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-29 05:47 UTC by Stefan Kost
Modified: 2008-03-07 06:38 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Stefan Kost 2006-05-29 05:47:14 UTC
please add oil_scalarmultiply_s32_ns like oil_scalarmultiply_f32_ns.

The functionallity should be similar to (taken from GstVolume):
  if (this->real_vol_i > VOLUME_UNITY_INT) {
    for (i = 0; i < num_samples; i++) {
      /* we use bitshifting instead of dividing by UNITY_INT for speed */
      val = (gint) * data;
      *data++ =
          (gint16) CLAMP ((this->real_vol_i * val) >> VOLUME_UNITY_BIT_SHIFT,
          VOLUME_MIN_INT16, VOLUME_MAX_INT16);
    }
  } else {
    for (i = 0; i < num_samples; i++) {
      /* we use bitshifting instead of dividing by UNITY_INT for speed */
      val = (gint) * data;
      *data++ = (gint16) ((this->real_vol_i * val) >> VOLUME_UNITY_BIT_SHIFT);
    }
  }

It would be okay to have two functions, one with CLAMP and one without.
Comment 1 Sebastian Dröge (slomo) 2008-03-07 06:38:48 UTC
What about having

oil_scalarmultiply_s32_ns (int32 *d, int32 *s1, int32 *s2_1, int32 *s2_2, int n)

which does

    if (*s2_1 < *s2_2)
      for (i = 0; i < n; i++) {
        d[i] = (s1[i] * (*s2_1)) / (*s2_2);
      }
    else
      for (i = 0; i < n; i++) {
        d[i] = CLAMP ((s1[i] * (*s2_1)) / (*s2_2), MININT32, MAXINT32);
      }

Only needs to take care of putting s1[i] * (*s2_1) into int64 (and docs should say that it does clipping).

IIRC MMX or MMXExt provides something to multiply and store in the next larger value type so it could be implemented for this at least... or was it some version of SSE? Whatever, if the API is fine I'll look it up again :)


Also this function could be made available for 8 and 16 bits maybe, not sure about 64 or 24 bits...


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.