Exemple #1
0
VX_API_ENTRY vx_status VX_API_CALL vxReleaseReference(vx_reference *ref)
{
    if(vxIsValidReference(*ref))
    {
        return vxReleaseReferenceInt((vx_reference *)ref, (*ref)->type, VX_EXTERNAL, NULL);
    } else {
        return VX_ERROR_INVALID_REFERENCE;
    }
}
Exemple #2
0
VX_API_ENTRY vx_status VX_API_CALL vxSetReferenceName(vx_reference ref, const vx_char *name)
{
    vx_status status = VX_ERROR_INVALID_REFERENCE;
    if (vxIsValidReference(ref))
    {
        strncpy(ref->name, name, strnlen(name, VX_MAX_REFERENCE_NAME));
        status = VX_SUCCESS;
    }
    return status;
}
VX_API_ENTRY vx_context VX_API_CALL vxGetContext(vx_reference reference)
{
    vx_context context = NULL;
    if (vxIsValidReference(reference) == vx_true_e)
    {
        context = reference->context;
    }
    else if (vxIsValidContext((vx_context)reference) == vx_true_e)
    {
        context = (vx_context)reference;
    }
    else
    {
        VX_PRINT(VX_ZONE_ERROR, "%p is not a valid reference\n", reference);
        VX_BACKTRACE(VX_ZONE_ERROR);
    }
    return context;
}
VX_API_ENTRY vx_status VX_API_CALL vxHint(vx_reference reference, vx_enum hint, const void* data, vx_size data_size)
{
    vx_status status = VX_SUCCESS;

    /* reference param should be a valid OpenVX reference*/
    if (vxIsValidContext((vx_context)reference) == vx_false_e && vxIsValidReference(reference) == vx_false_e)
        return VX_ERROR_INVALID_REFERENCE;

    switch (hint)
    {
        /*! \todo add hints to the sample implementation */

        default:
            status = VX_ERROR_NOT_SUPPORTED;
            break;
    }

    return status;
}
VX_API_ENTRY vx_status VX_API_CALL vxDirective(vx_reference reference, vx_enum directive) {
    vx_status status = VX_SUCCESS;
    vx_context context;
    if (vxIsValidReference(reference) == vx_false_e)
        return VX_ERROR_INVALID_REFERENCE;
    context = reference->context;
    if (vxIsValidContext(context) == vx_false_e)
        return VX_ERROR_INVALID_REFERENCE;
    switch (directive)
    {
        case VX_DIRECTIVE_DISABLE_LOGGING:
            context->log_enabled = vx_false_e;
            break;
        case VX_DIRECTIVE_ENABLE_LOGGING:
            context->log_enabled = vx_true_e;
            break;
        default:
            status = VX_ERROR_NOT_SUPPORTED;
            break;
    }
    return status;
}
Exemple #6
0
vx_status vxQueryReference(vx_reference r, vx_enum attribute, void *ptr, vx_size size)
{
    vx_status status = VX_SUCCESS;
    vx_reference_t *ref = (vx_reference_t *)r;

    /* if it is not a reference and not a context */
    if ((vxIsValidReference(ref) == vx_false_e) &&
        (vxIsValidContext((vx_context_t *)ref) == vx_false_e)) {
        return VX_ERROR_INVALID_REFERENCE;
    }
    switch (attribute)
    {
        case VX_REF_ATTRIBUTE_COUNT:
            if (VX_CHECK_PARAM(ptr, size, vx_uint32, 0x3))
            {
                *(vx_uint32 *)ptr = ref->external_count;
            }
            else
            {
                status = VX_ERROR_INVALID_PARAMETERS;
            }
            break;
        case VX_REF_ATTRIBUTE_TYPE:
            if (VX_CHECK_PARAM(ptr, size, vx_enum, 0x3))
            {
                *(vx_enum *)ptr = ref->type;
            }
            else
            {
                status = VX_ERROR_INVALID_PARAMETERS;
            }
            break;
        default:
            status = VX_ERROR_NOT_SUPPORTED;
            break;
    }
    return status;
}
Exemple #7
0
VX_API_ENTRY vx_status VX_API_CALL vxSetParameterByIndex(vx_node node, vx_uint32 index, vx_reference value)
{
    vx_status status = VX_SUCCESS;
    vx_enum type = 0;
    vx_enum data_type = 0;

    if (vxIsValidSpecificReference(&node->base, VX_TYPE_NODE) == vx_false_e)
    {
        VX_PRINT(VX_ZONE_ERROR, "Supplied node was not actually a node\n");
        status = VX_ERROR_INVALID_REFERENCE;
        goto exit;
    }

    VX_PRINT(VX_ZONE_PARAMETER, "Attempting to set parameter[%u] on %s (enum:%d) to "VX_FMT_REF"\n",
                    index,
                    node->kernel->name,
                    node->kernel->enumeration,
                    value);

    /* is the index out of bounds? */
    if ((index >= node->kernel->signature.num_parameters) || (index >= VX_INT_MAX_PARAMS))
    {
        VX_PRINT(VX_ZONE_ERROR, "Invalid index %u\n", index);
        status = VX_ERROR_INVALID_VALUE;
        goto exit;
    }

    /* if it's an optional parameter, it's ok to be NULL */
    if ((value == 0) && (node->kernel->signature.states[index] == VX_PARAMETER_STATE_OPTIONAL))
    {
        status = VX_SUCCESS;
        goto exit;
    }

    /* if it's required, it's got to exist */
    if (vxIsValidReference((vx_reference_t *)value) == vx_false_e)
    {
        VX_PRINT(VX_ZONE_ERROR, "Supplied value was not actually a reference\n");
        status = VX_ERROR_INVALID_REFERENCE;
        goto exit;
    }

    /* if it was a valid reference then get the type from it */
    vxQueryReference(value, VX_REF_ATTRIBUTE_TYPE, &type, sizeof(type));
    VX_PRINT(VX_ZONE_PARAMETER, "Query returned type %08x for ref "VX_FMT_REF"\n", type, value);
    /* Check that signature type matches reference type*/
    if (node->kernel->signature.types[index] != type)
    {
        /* Check special case where signature is a specific scalar type.
           This can happen if the vxAddParameterToKernel() passes one of the scalar
           vx_type_e types instead of the more generic VX_TYPE_SCALAR since the spec
           doesn't specify that only VX_TYPE_SCALAR should be used for scalar types in
           this function. */
        if((type == VX_TYPE_SCALAR) &&
           (vxQueryScalar((vx_scalar)value, VX_SCALAR_ATTRIBUTE_TYPE, &data_type, sizeof(data_type)) == VX_SUCCESS))
        {
            if(data_type != node->kernel->signature.types[index])
            {
                VX_PRINT(VX_ZONE_ERROR, "Invalid scalar type 0x%08x!\n", data_type);
                status = VX_ERROR_INVALID_TYPE;
                goto exit;
            }
        }
        else
        {
            VX_PRINT(VX_ZONE_ERROR, "Invalid type 0x%08x!\n", type);
            status = VX_ERROR_INVALID_TYPE;
            goto exit;
        }
    }

    if (node->parameters[index])
    {
        if (node->parameters[index]->delay!=NULL) {
            // we already have a delay element here */
            vx_bool res = vxRemoveAssociationToDelay(node->parameters[index], node, index);
            if (res == vx_false_e) {
                VX_PRINT(VX_ZONE_ERROR, "Internal error removing delay association\n");
                status = VX_ERROR_INVALID_REFERENCE;
                goto exit;
            }
        }
    }

    if (value->delay!=NULL) {
        /* the new parameter is a delay element */
        vx_bool res = vxAddAssociationToDelay(value, node, index);
        if (res == vx_false_e) {
            VX_PRINT(VX_ZONE_ERROR, "Internal error adding delay association\n");
            status = VX_ERROR_INVALID_REFERENCE;
            goto exit;
        }
    }

    /* actual change of the node parameter */
    vxNodeSetParameter(node, index, value);

    /* if the node has a child graph, find out which parameter is this */
    if (node->child)
    {
        vx_uint32 p = 0;
        for (p = 0; p < node->child->numParams; p++)
        {
            if ((node->child->parameters[p].node == node) &&
                (node->child->parameters[p].index == index))
            {
                status = vxSetGraphParameterByIndex((vx_graph)node->child, p, value);
                break;
            }
        }
    }

exit:
    if (status == VX_SUCCESS)
    {
        VX_PRINT(VX_ZONE_PARAMETER, "Assigned Node[%u] %p type:%08x ref="VX_FMT_REF"\n",
                 index, node, type, value);
    }
    else
    {
        VX_PRINT(VX_ZONE_ERROR, "Specified: parameter[%u] type:%08x => "VX_FMT_REF"\n",
                        index, type, value);
        VX_PRINT(VX_ZONE_ERROR, "Required: parameter[%u] dir:%d type:%08x\n",
            index,
            node->kernel->signature.directions[index],
            node->kernel->signature.types[index]);
    }
    return status;
}
VX_API_ENTRY vx_status VX_API_CALL vxSetMetaFormatFromReference(vx_meta_format meta, vx_reference examplar)
{
    vx_status status = VX_SUCCESS;

    if (vxIsValidSpecificReference(&meta->base, VX_TYPE_META_FORMAT) == vx_false_e)
        return VX_ERROR_INVALID_REFERENCE;

    if (vxIsValidReference(examplar) == vx_false_e)
        return VX_ERROR_INVALID_REFERENCE;

    switch (examplar->type)
    {
    case VX_TYPE_IMAGE:
    {
        vx_image image = (vx_image)examplar;
        meta->type = VX_TYPE_IMAGE;
        meta->dim.image.width = image->width;
        meta->dim.image.height = image->height;
        meta->dim.image.format = image->format;
        break;
    }
    case VX_TYPE_ARRAY:
    {
        vx_array array = (vx_array)examplar;
        meta->type = VX_TYPE_ARRAY;
        meta->dim.array.item_type = array->item_type;
        meta->dim.array.capacity = array->capacity;
        break;
    }
    case VX_TYPE_PYRAMID:
    {
        vx_pyramid pyramid = (vx_pyramid)examplar;
        meta->type = VX_TYPE_PYRAMID;
        meta->dim.pyramid.width = pyramid->width;
        meta->dim.pyramid.height = pyramid->height;
        meta->dim.pyramid.format = pyramid->format;
        meta->dim.pyramid.levels = pyramid->numLevels;
        meta->dim.pyramid.scale = pyramid->scale;
        break;
    }
    case VX_TYPE_SCALAR:
    {
        vx_scalar scalar = (vx_scalar)examplar;
        meta->type = VX_TYPE_SCALAR;
        meta->dim.scalar.type = scalar->data_type;
        break;
    }
    case VX_TYPE_MATRIX:
    {
        vx_matrix matrix = (vx_matrix)examplar;
        meta->type = VX_TYPE_MATRIX;
        meta->dim.matrix.type = matrix->data_type;
        meta->dim.matrix.cols = matrix->columns;
        meta->dim.matrix.rows = matrix->rows;
        break;
    }
    case VX_TYPE_DISTRIBUTION:
    {
        vx_distribution distribution = (vx_distribution)examplar;
        meta->type = VX_TYPE_DISTRIBUTION;
        meta->dim.distribution.bins = distribution->memory.dims[0][VX_DIM_X];
        meta->dim.distribution.offset = distribution->offset_x;
        meta->dim.distribution.range = distribution->range_x;
        break;
    }
    case VX_TYPE_REMAP:
    {
        vx_remap remap = (vx_remap)examplar;
        meta->type = VX_TYPE_REMAP;
        meta->dim.remap.src_width = remap->src_width;
        meta->dim.remap.src_height = remap->src_height;
        meta->dim.remap.dst_width = remap->dst_width;
        meta->dim.remap.dst_height = remap->dst_height;
        break;
    }
    case VX_TYPE_LUT:
    {
        vx_lut_t *lut = (vx_lut_t *)examplar;
        meta->type = VX_TYPE_LUT;
        meta->dim.lut.type = lut->item_type;
        meta->dim.lut.count = lut->num_items;
        break;
    }
    case VX_TYPE_THRESHOLD:
    {
        vx_threshold threshold = (vx_threshold)examplar;
        meta->type = VX_TYPE_THRESHOLD;
        meta->dim.threshold.type = threshold->thresh_type;
        break;
    }
    default:
        status = VX_ERROR_INVALID_REFERENCE;
        break;
    }

    return status;
}