/*
 * File: _coder_MLS_applyDeform_api.c
 *
 * MATLAB Coder version            : 3.4
 * C/C++ source code generated on  : 18-Feb-2019 15:40:18
 */

/* Include Files */
#include "tmwtypes.h"
#include "_coder_MLS_applyDeform_api.h"
#include "_coder_MLS_applyDeform_mex.h"

/* Variable Definitions */
emlrtCTX emlrtRootTLSGlobal = NULL;
emlrtContext emlrtContextGlobal = { true,/* bFirstTime */
  false,                               /* bInitialized */
  131451U,                             /* fVersionInfo */
  NULL,                                /* fErrorFunction */
  "MLS_applyDeform",                   /* fFunctionName */
  NULL,                                /* fRTCallStack */
  false,                               /* bDebugMode */
  { 2045744189U, 2170104910U, 2743257031U, 4284093946U },/* fSigWrd */
  NULL                                 /* fSigMem */
};

static const int32_T iv0[3] = { 480, 640, 3 };

static const int32_T iv1[3] = { 480, 640, 2 };

/* Function Declarations */
static uint8_T (*b_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u,
  const emlrtMsgIdentifier *parentId))[921600];
static void b_emlrt_marshallOut(const real_T u[614400], const mxArray *y);
static real_T (*c_emlrt_marshallIn(const emlrtStack *sp, const mxArray *f, const
  char_T *identifier))[614400];
static real_T (*d_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
  emlrtMsgIdentifier *parentId))[614400];
static real_T (*e_emlrt_marshallIn(const emlrtStack *sp, const mxArray *v, const
  char_T *identifier))[308];
static uint8_T (*emlrt_marshallIn(const emlrtStack *sp, const mxArray *oldImg,
  const char_T *identifier))[921600];
static const mxArray *emlrt_marshallOut(const uint8_T u[921600]);
static real_T (*f_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
  emlrtMsgIdentifier *parentId))[308];
static real_T (*g_emlrt_marshallIn(const emlrtStack *sp, const mxArray
  *grid_size, const char_T *identifier))[2];
static real_T (*h_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
  emlrtMsgIdentifier *parentId))[2];
static uint8_T (*i_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
  const emlrtMsgIdentifier *msgId))[921600];
static real_T (*j_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
  const emlrtMsgIdentifier *msgId))[614400];
static real_T (*k_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
  const emlrtMsgIdentifier *msgId))[308];
static real_T (*l_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
  const emlrtMsgIdentifier *msgId))[2];

/* Function Definitions */

/*
 * Arguments    : const emlrtStack *sp
 *                const mxArray *u
 *                const emlrtMsgIdentifier *parentId
 * Return Type  : uint8_T (*)[921600]
 */
static uint8_T (*b_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u,
  const emlrtMsgIdentifier *parentId))[921600]
{
  uint8_T (*y)[921600];
  y = i_emlrt_marshallIn(sp, emlrtAlias(u), parentId);
  emlrtDestroyArray(&u);
  return y;
}
/*
 * Arguments    : const real_T u[614400]
 *                const mxArray *y
 * Return Type  : void
 */
  static void b_emlrt_marshallOut(const real_T u[614400], const mxArray *y)
{
  emlrtMxSetData((mxArray *)y, (void *)&u[0]);
  emlrtSetDimensions((mxArray *)y, iv1, 3);
}

/*
 * Arguments    : const emlrtStack *sp
 *                const mxArray *f
 *                const char_T *identifier
 * Return Type  : real_T (*)[614400]
 */
static real_T (*c_emlrt_marshallIn(const emlrtStack *sp, const mxArray *f, const
  char_T *identifier))[614400]
{
  real_T (*y)[614400];
  emlrtMsgIdentifier thisId;
  thisId.fIdentifier = (const char *)identifier;
  thisId.fParent = NULL;
  thisId.bParentIsCell = false;
  y = d_emlrt_marshallIn(sp, emlrtAlias(f), &thisId);
  emlrtDestroyArray(&f);
  return y;
}
/*
 * Arguments    : const emlrtStack *sp
 *                const mxArray *u
 *                const emlrtMsgIdentifier *parentId
 * Return Type  : real_T (*)[614400]
 */
  static real_T (*d_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u,
  const emlrtMsgIdentifier *parentId))[614400]
{
  real_T (*y)[614400];
  y = j_emlrt_marshallIn(sp, emlrtAlias(u), parentId);
  emlrtDestroyArray(&u);
  return y;
}

/*
 * Arguments    : const emlrtStack *sp
 *                const mxArray *v
 *                const char_T *identifier
 * Return Type  : real_T (*)[308]
 */
static real_T (*e_emlrt_marshallIn(const emlrtStack *sp, const mxArray *v, const
  char_T *identifier))[308]
{
  real_T (*y)[308];
  emlrtMsgIdentifier thisId;
  thisId.fIdentifier = (const char *)identifier;
  thisId.fParent = NULL;
  thisId.bParentIsCell = false;
  y = f_emlrt_marshallIn(sp, emlrtAlias(v), &thisId);
  emlrtDestroyArray(&v);
  return y;
}
/*
 * Arguments    : const emlrtStack *sp
 *                const mxArray *oldImg
 *                const char_T *identifier
 * Return Type  : uint8_T (*)[921600]
 */
  static uint8_T (*emlrt_marshallIn(const emlrtStack *sp, const mxArray *oldImg,
  const char_T *identifier))[921600]
{
  uint8_T (*y)[921600];
  emlrtMsgIdentifier thisId;
  thisId.fIdentifier = (const char *)identifier;
  thisId.fParent = NULL;
  thisId.bParentIsCell = false;
  y = b_emlrt_marshallIn(sp, emlrtAlias(oldImg), &thisId);
  emlrtDestroyArray(&oldImg);
  return y;
}

/*
 * Arguments    : const uint8_T u[921600]
 * Return Type  : const mxArray *
 */
static const mxArray *emlrt_marshallOut(const uint8_T u[921600])
{
  const mxArray *y;
  const mxArray *m0;
  static const int32_T iv2[3] = { 0, 0, 0 };

  y = NULL;
  m0 = emlrtCreateNumericArray(3, iv2, mxUINT8_CLASS, mxREAL);
  emlrtMxSetData((mxArray *)m0, (void *)&u[0]);
  emlrtSetDimensions((mxArray *)m0, iv0, 3);
  emlrtAssign(&y, m0);
  return y;
}

/*
 * Arguments    : const emlrtStack *sp
 *                const mxArray *u
 *                const emlrtMsgIdentifier *parentId
 * Return Type  : real_T (*)[308]
 */
static real_T (*f_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
  emlrtMsgIdentifier *parentId))[308]
{
  real_T (*y)[308];
  y = k_emlrt_marshallIn(sp, emlrtAlias(u), parentId);
  emlrtDestroyArray(&u);
  return y;
}
/*
 * Arguments    : const emlrtStack *sp
 *                const mxArray *grid_size
 *                const char_T *identifier
 * Return Type  : real_T (*)[2]
 */
  static real_T (*g_emlrt_marshallIn(const emlrtStack *sp, const mxArray
  *grid_size, const char_T *identifier))[2]
{
  real_T (*y)[2];
  emlrtMsgIdentifier thisId;
  thisId.fIdentifier = (const char *)identifier;
  thisId.fParent = NULL;
  thisId.bParentIsCell = false;
  y = h_emlrt_marshallIn(sp, emlrtAlias(grid_size), &thisId);
  emlrtDestroyArray(&grid_size);
  return y;
}

/*
 * Arguments    : const emlrtStack *sp
 *                const mxArray *u
 *                const emlrtMsgIdentifier *parentId
 * Return Type  : real_T (*)[2]
 */
static real_T (*h_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
  emlrtMsgIdentifier *parentId))[2]
{
  real_T (*y)[2];
  y = l_emlrt_marshallIn(sp, emlrtAlias(u), parentId);
  emlrtDestroyArray(&u);
  return y;
}
/*
 * Arguments    : const emlrtStack *sp
 *                const mxArray *src
 *                const emlrtMsgIdentifier *msgId
 * Return Type  : uint8_T (*)[921600]
 */
  static uint8_T (*i_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
  const emlrtMsgIdentifier *msgId))[921600]
{
  uint8_T (*ret)[921600];
  emlrtCheckBuiltInR2012b(sp, msgId, src, "uint8", false, 3U, iv0);
  ret = (uint8_T (*)[921600])emlrtMxGetData(src);
  emlrtDestroyArray(&src);
  return ret;
}

/*
 * Arguments    : const emlrtStack *sp
 *                const mxArray *src
 *                const emlrtMsgIdentifier *msgId
 * Return Type  : real_T (*)[614400]
 */
static real_T (*j_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
  const emlrtMsgIdentifier *msgId))[614400]
{
  real_T (*ret)[614400];
  emlrtCheckBuiltInR2012b(sp, msgId, src, "double", false, 3U, iv1);
  ret = (real_T (*)[614400])emlrtMxGetData(src);
  emlrtDestroyArray(&src);
  return ret;
}
/*
 * Arguments    : const emlrtStack *sp
 *                const mxArray *src
 *                const emlrtMsgIdentifier *msgId
 * Return Type  : real_T (*)[308]
 */
  static real_T (*k_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
  const emlrtMsgIdentifier *msgId))[308]
{
  real_T (*ret)[308];
  static const int32_T dims[2] = { 154, 2 };

  emlrtCheckBuiltInR2012b(sp, msgId, src, "double", false, 2U, dims);
  ret = (real_T (*)[308])emlrtMxGetData(src);
  emlrtDestroyArray(&src);
  return ret;
}

/*
 * Arguments    : const emlrtStack *sp
 *                const mxArray *src
 *                const emlrtMsgIdentifier *msgId
 * Return Type  : real_T (*)[2]
 */
static real_T (*l_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
  const emlrtMsgIdentifier *msgId))[2]
{
  real_T (*ret)[2];
  static const int32_T dims[2] = { 1, 2 };

  emlrtCheckBuiltInR2012b(sp, msgId, src, "double", false, 2U, dims);
  ret = (real_T (*)[2])emlrtMxGetData(src);
  emlrtDestroyArray(&src);
  return ret;
}
/*
 * Arguments    : const mxArray *prhs[4]
 *                const mxArray *plhs[2]
 * Return Type  : void
 */
  void MLS_applyDeform_api(const mxArray *prhs[4], const mxArray *plhs[2])
{
  uint8_T (*newImg)[921600];
  uint8_T (*oldImg)[921600];
  real_T (*f)[614400];
  real_T (*v)[308];
  real_T (*grid_size)[2];
  emlrtStack st = { NULL,              /* site */
    NULL,                              /* tls */
    NULL                               /* prev */
  };

  st.tls = emlrtRootTLSGlobal;
  newImg = (uint8_T (*)[921600])mxMalloc(sizeof(uint8_T [921600]));
  prhs[1] = emlrtProtectR2012b(prhs[1], 1, true, -1);

  /* Marshall function inputs */
  oldImg = emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "oldImg");
  f = c_emlrt_marshallIn(&st, emlrtAlias(prhs[1]), "f");
  v = e_emlrt_marshallIn(&st, emlrtAlias(prhs[2]), "v");
  grid_size = g_emlrt_marshallIn(&st, emlrtAlias(prhs[3]), "grid_size");

  /* Invoke the target function */
  MLS_applyDeform(*oldImg, *f, *v, *grid_size, *newImg);

  /* Marshall function outputs */
  plhs[0] = emlrt_marshallOut(*newImg);
  b_emlrt_marshallOut(*f, prhs[1]);
  plhs[1] = prhs[1];
}

/*
 * Arguments    : void
 * Return Type  : void
 */
void MLS_applyDeform_atexit(void)
{
  emlrtStack st = { NULL,              /* site */
    NULL,                              /* tls */
    NULL                               /* prev */
  };

  mexFunctionCreateRootTLS();
  st.tls = emlrtRootTLSGlobal;
  emlrtEnterRtStackR2012b(&st);
  emlrtLeaveRtStackR2012b(&st);
  emlrtDestroyRootTLS(&emlrtRootTLSGlobal);
  MLS_applyDeform_xil_terminate();
}

/*
 * Arguments    : void
 * Return Type  : void
 */
void MLS_applyDeform_initialize(void)
{
  emlrtStack st = { NULL,              /* site */
    NULL,                              /* tls */
    NULL                               /* prev */
  };

  mexFunctionCreateRootTLS();
  st.tls = emlrtRootTLSGlobal;
  emlrtClearAllocCountR2012b(&st, false, 0U, 0);
  emlrtEnterRtStackR2012b(&st);
  emlrtFirstTimeR2012b(emlrtRootTLSGlobal);
}

/*
 * Arguments    : void
 * Return Type  : void
 */
void MLS_applyDeform_terminate(void)
{
  emlrtStack st = { NULL,              /* site */
    NULL,                              /* tls */
    NULL                               /* prev */
  };

  st.tls = emlrtRootTLSGlobal;
  emlrtLeaveRtStackR2012b(&st);
  emlrtDestroyRootTLS(&emlrtRootTLSGlobal);
}

/*
 * File trailer for _coder_MLS_applyDeform_api.c
 *
 * [EOF]
 */
