void image_copy_deinterleave_float()

in imageops.c [25:58]


void image_copy_deinterleave_float(ImageObject* self, float* output_buffer) {
    unsigned char* tmp_buffer = NULL;
    IppiSize roi = { self->width, self->height };

    tmp_buffer = malloc(self->height * self->width * self->channels);
    if (!tmp_buffer) {
        PyErr_NoMemory();
        goto cleanup;
    }

    image_copy_deinterleave(self, tmp_buffer);
    if (PyErr_Occurred()) {
      goto cleanup;
    }

    IppStatus ipp_status = ippiConvert_8u32f_C3R(
        tmp_buffer, self->width * self->channels,
        output_buffer, self->width * self->channels * sizeof(float),
        roi);
    if (ipp_status != ippStsNoErr) {
        PyErr_Format(PyExc_SystemError, "ippiConvert_8u32f_C3R failed with status %d", ipp_status);
    }

    Ipp32f value[3] = {255.0f, 255.0f, 255.0f};
    ipp_status = ippiDivC_32f_C3IR(
        value, output_buffer, self->width * self->channels * sizeof(float),
        roi);
    if (ipp_status != ippStsNoErr) {
        PyErr_Format(PyExc_SystemError, "ippiDivC_32f_C3IR failed with status %d", ipp_status);
    }

cleanup:
    free(tmp_buffer);
}