static int parse_iplconvkernel(IplConvKernel **kernel, char *buf, void *log_ctx)

{

    char shape_filename[128] = "", shape_str[32] = "rect";

    int cols = 0, rows = 0, anchor_x = 0, anchor_y = 0, shape = CV_SHAPE_RECT;

    int *values = NULL, ret;



    sscanf(buf, "%dx%d+%dx%d/%32[^=]=%127s", &cols, &rows, &anchor_x, &anchor_y, shape_str, shape_filename);



    if      (!strcmp(shape_str, "rect"   )) shape = CV_SHAPE_RECT;

    else if (!strcmp(shape_str, "cross"  )) shape = CV_SHAPE_CROSS;

    else if (!strcmp(shape_str, "ellipse")) shape = CV_SHAPE_ELLIPSE;

    else if (!strcmp(shape_str, "custom" )) {

        shape = CV_SHAPE_CUSTOM;

        if ((ret = read_shape_from_file(&cols, &rows, &values, shape_filename, log_ctx)) < 0)

            return ret;

    } else {

        av_log(log_ctx, AV_LOG_ERROR,

               "Shape unspecified or type '%s' unknown.\n", shape_str);

        return AVERROR(EINVAL);

    }



    if (rows <= 0 || cols <= 0) {

        av_log(log_ctx, AV_LOG_ERROR,

               "Invalid non-positive values for shape size %dx%d\n", cols, rows);

        return AVERROR(EINVAL);

    }



    if (anchor_x < 0 || anchor_y < 0 || anchor_x >= cols || anchor_y >= rows) {

        av_log(log_ctx, AV_LOG_ERROR,

               "Shape anchor %dx%d is not inside the rectangle with size %dx%d.\n",

               anchor_x, anchor_y, cols, rows);

        return AVERROR(EINVAL);

    }



    *kernel = cvCreateStructuringElementEx(cols, rows, anchor_x, anchor_y, shape, values);

    av_freep(&values);

    if (!*kernel)

        return AVERROR(ENOMEM);



    av_log(log_ctx, AV_LOG_VERBOSE, "Structuring element: w:%d h:%d x:%d y:%d shape:%s\n",

           rows, cols, anchor_x, anchor_y, shape_str);

    return 0;

}

static int parse_iplconvkernel(IplConvKernel **kernel, char *buf, void *log_ctx)

{

    char shape_filename[128] = "", shape_str[32] = "rect";

    int cols = 0, rows = 0, anchor_x = 0, anchor_y = 0, shape = CV_SHAPE_RECT;

    int *values = NULL, ret;



    sscanf(buf, "%dx%d+%dx%d/%32[^=]=%127s", &cols, &rows, &anchor_x, &anchor_y, shape_str, shape_filename);



    if      (!strcmp(shape_str, "rect"   )) shape = CV_SHAPE_RECT;

    else if (!strcmp(shape_str, "cross"  )) shape = CV_SHAPE_CROSS;

    else if (!strcmp(shape_str, "ellipse")) shape = CV_SHAPE_ELLIPSE;

    else if (!strcmp(shape_str, "custom" )) {

        shape = CV_SHAPE_CUSTOM;

        if ((ret = read_shape_from_file(&cols, &rows, &values, shape_filename, log_ctx)) < 0)

            return ret;

    } else {

        av_log(log_ctx, AV_LOG_ERROR,

               "Shape unspecified or type '%s' unknown.\n", shape_str);

        return AVERROR(EINVAL);

    }



    if (rows <= 0 || cols <= 0) {

        av_log(log_ctx, AV_LOG_ERROR,

               "Invalid non-positive values for shape size %dx%d\n", cols, rows);

        return AVERROR(EINVAL);

    }



    if (anchor_x < 0 || anchor_y < 0 || anchor_x >= cols || anchor_y >= rows) {

        av_log(log_ctx, AV_LOG_ERROR,

               "Shape anchor %dx%d is not inside the rectangle with size %dx%d.\n",

               anchor_x, anchor_y, cols, rows);

        return AVERROR(EINVAL);

    }



    *kernel = cvCreateStructuringElementEx(cols, rows, anchor_x, anchor_y, shape, values);

    av_freep(&values);

    if (!*kernel)

        return AVERROR(ENOMEM);



    av_log(log_ctx, AV_LOG_VERBOSE, "Structuring element: w:%d h:%d x:%d y:%d shape:%s\n",

           rows, cols, anchor_x, anchor_y, shape_str);

    return 0;

}

    int *values = NULL, ret;         return AVERROR(EINVAL);         return AVERROR(EINVAL);         return AVERROR(EINVAL);     av_freep(&values);     if (!*kernel)         return AVERROR(ENOMEM);     return 0;
static int FUNC_0(IplConvKernel **VAR_0, char *VAR_1, void *VAR_2)

{

    char VAR_3[128] = "", VAR_4[32] = "rect";

    int VAR_5 = 0, VAR_6 = 0, VAR_7 = 0, VAR_8 = 0, VAR_9 = CV_SHAPE_RECT;

    int *VAR_10 = NULL, VAR_11;



    sscanf(VAR_1, "%dx%d+%dx%d/%32[^=]=%127s", &VAR_5, &VAR_6, &VAR_7, &VAR_8, VAR_4, VAR_3);



    if      (!strcmp(VAR_4, "rect"   )) VAR_9 = CV_SHAPE_RECT;

    else if (!strcmp(VAR_4, "cross"  )) VAR_9 = CV_SHAPE_CROSS;

    else if (!strcmp(VAR_4, "ellipse")) VAR_9 = CV_SHAPE_ELLIPSE;

    else if (!strcmp(VAR_4, "custom" )) {

        VAR_9 = CV_SHAPE_CUSTOM;

        if ((VAR_11 = read_shape_from_file(&VAR_5, &VAR_6, &VAR_10, VAR_3, VAR_2)) < 0)

            return VAR_11;

    } else {

        av_log(VAR_2, AV_LOG_ERROR,

               "Shape unspecified or type '%s' unknown.\n", VAR_4);

        return AVERROR(EINVAL);

    }



    if (VAR_6 <= 0 || VAR_5 <= 0) {

        av_log(VAR_2, AV_LOG_ERROR,

               "Invalid non-positive VAR_10 for VAR_9 size %dx%d\n", VAR_5, VAR_6);

        return AVERROR(EINVAL);

    }



    if (VAR_7 < 0 || VAR_8 < 0 || VAR_7 >= VAR_5 || VAR_8 >= VAR_6) {

        av_log(VAR_2, AV_LOG_ERROR,

               "Shape anchor %dx%d is not inside the rectangle with size %dx%d.\n",

               VAR_7, VAR_8, VAR_5, VAR_6);

        return AVERROR(EINVAL);

    }



    *VAR_0 = cvCreateStructuringElementEx(VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10);

    av_freep(&VAR_10);

    if (!*VAR_0)

        return AVERROR(ENOMEM);



    av_log(VAR_2, AV_LOG_VERBOSE, "Structuring element: w:%d h:%d x:%d y:%d VAR_9:%s\n",

           VAR_6, VAR_5, VAR_7, VAR_8, VAR_4);

    return 0;

}

static int FUNC_0(IplConvKernel **VAR_0, char *VAR_1, void *VAR_2)
{ char VAR_3[128] = "", VAR_4[32] = "rect"; int VAR_5 = 0, VAR_6 = 0, VAR_7 = 0, VAR_8 = 0, VAR_9 = CV_SHAPE_RECT; int *VAR_10 = NULL, VAR_11; sscanf(VAR_1, "%dx%d+%dx%d/%32[^=]=%127s", &VAR_5, &VAR_6, &VAR_7, &VAR_8, VAR_4, VAR_3); if      (!strcmp(VAR_4, "rect"   )) VAR_9 = CV_SHAPE_RECT; else if (!strcmp(VAR_4, "cross"  )) VAR_9 = CV_SHAPE_CROSS; else if (!strcmp(VAR_4, "ellipse")) VAR_9 = CV_SHAPE_ELLIPSE; else if (!strcmp(VAR_4, "custom" )) { VAR_9 = CV_SHAPE_CUSTOM; if ((VAR_11 = read_shape_from_file(&VAR_5, &VAR_6, &VAR_10, VAR_3, VAR_2)) < 0)
return VAR_11; } else { av_log(VAR_2, AV_LOG_ERROR,
"Shape unspecified or type '%s' unknown.\n", VAR_4); return AVERROR(EINVAL); } if (VAR_6 <= 0 || VAR_5 <= 0) { av_log(VAR_2, AV_LOG_ERROR,
"Invalid non-positive VAR_10 for VAR_9 size %dx%d\n", VAR_5, VAR_6); return AVERROR(EINVAL); } if (VAR_7 < 0 || VAR_8 < 0 || VAR_7 >= VAR_5 || VAR_8 >= VAR_6) { av_log(VAR_2, AV_LOG_ERROR,
"Shape anchor %dx%d is not inside the rectangle with size %dx%d.\n",
VAR_7, VAR_8, VAR_5, VAR_6); return AVERROR(EINVAL); } *VAR_0 = cvCreateStructuringElementEx(VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10); av_freep(&VAR_10); if (!*VAR_0)
return AVERROR(ENOMEM); av_log(VAR_2, AV_LOG_VERBOSE, "Structuring element: w:%d h:%d x:%d y:%d VAR_9:%s\n",
VAR_6, VAR_5, VAR_7, VAR_8, VAR_4); return 0; }