// File: /workspace/github_c_makefile_star2_O2/zpole[P]IICV/vl/covdet.c
// Function: vl_covdet_new
VlCovDet *
vl_covdet_new (VlCovDetMethod method)
{
  VlCovDet * self = vl_calloc(sizeof(VlCovDet),1) ;
  self->method = method ;
  self->octaveResolution = 3 ;
  self->firstOctave = -1 ;
  switch (self->method) {
    case VL_COVDET_METHOD_DOG :
      self->peakThreshold = VL_COVDET_DOG_DEF_PEAK_THRESHOLD ;
      self->edgeThreshold = VL_COVDET_DOG_DEF_EDGE_THRESHOLD ;
      self->lapPeakThreshold = 0  ; /* not used */
      break ;
    case VL_COVDET_METHOD_HARRIS_LAPLACE:
    case VL_COVDET_METHOD_MULTISCALE_HARRIS:
      self->peakThreshold = VL_COVDET_HARRIS_DEF_PEAK_THRESHOLD ;
      self->edgeThreshold = VL_COVDET_HARRIS_DEF_EDGE_THRESHOLD ;
      self->lapPeakThreshold = VL_COVDET_LAP_DEF_PEAK_THRESHOLD ;
      break ;
    case VL_COVDET_METHOD_HESSIAN :
    case VL_COVDET_METHOD_HESSIAN_LAPLACE:
    case VL_COVDET_METHOD_MULTISCALE_HESSIAN:
      self->peakThreshold = VL_COVDET_HESSIAN_DEF_PEAK_THRESHOLD ;
      self->edgeThreshold = VL_COVDET_HESSIAN_DEF_EDGE_THRESHOLD ;
      self->lapPeakThreshold = VL_COVDET_LAP_DEF_PEAK_THRESHOLD ;
      break;
    default:
      assert(0) ;
  }

  self->nonExtremaSuppression = 0.5 ;
  self->features = NULL ;
  self->numFeatures = 0 ;
  self->numFeatureBufferSize = 0 ;
  self->patch = NULL ;
  self->patchBufferSize = 0 ;
  self->transposed = VL_FALSE ;
  self->aaAccurateSmoothing = VL_COVDET_AA_ACCURATE_SMOOTHING ;

  {
    vl_index const w = VL_COVDET_AA_PATCH_RESOLUTION ;
    vl_index i,j ;
    double step = (2.0 * VL_COVDET_AA_PATCH_EXTENT) / (2*w+1) ;
    double sigma = VL_COVDET_AA_RELATIVE_INTEGRATION_SIGMA ;
    for (j = -w ; j <= w ; ++j) {
      for (i = -w ; i <= w ; ++i) {
        double dx = i*step/sigma ;
        double dy = j*step/sigma ;
        self->aaMask[(i+w) + (2*w+1)*(j+w)] = exp(-0.5*(dx*dx+dy*dy)) ;
      }
    }
  }

  {
    /*
     Covers one octave of Laplacian filters, from sigma=1 to sigma=2.
     The spatial sampling step is 0.5.
     */
    vl_index s ;
    for (s = 0 ; s < VL_COVDET_LAP_NUM_LEVELS ; ++s) {
      double sigmaLap = pow(2.0, -0.5 +
                            (double)s / (VL_COVDET_LAP_NUM_LEVELS - 1)) ;
      double const sigmaImage = 1.0 / sqrt(2.0) ;
      double const step = 0.5 * sigmaImage ;
      double const sigmaDelta = sqrt(sigmaLap*sigmaLap - sigmaImage*sigmaImage) ;
      vl_size const w = VL_COVDET_LAP_PATCH_RESOLUTION ;
      vl_size const num = 2 * w + 1  ;
      float * pt = self->laplacians + s * (num * num) ;

      memset(pt, 0, num * num * sizeof(float)) ;

#define at(x,y) pt[(x+w)+(y+w)*(2*w+1)]
      at(0,0) = - 4.0 ;
      at(-1,0) = 1.0 ;
      at(+1,0) = 1.0 ;
      at(0,1) = 1.0 ;
      at(0,-1) = 1.0 ;
#undef at

      vl_imsmooth_f(pt, num,
                    pt, num, num, num,
                    sigmaDelta / step, sigmaDelta / step) ;

#if 0
      {
        char name [200] ;
        snprintf(name, 200, "/tmp/%f-lap.pgm", sigmaDelta) ;
        vl_pgm_write_f(name, pt, num, num) ;
      }
#endif

    }
  }
  return self ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %edi, %ebp
pushq $0x1
popq %rsi
movl $0x12568, %edi          # imm = 0x12568
callq 0x9960
movq %rax, %rbx
movl %ebp, 0x10(%rax)
movq $0x3, 0x30(%rax)
orq $-0x1, 0x38(%rax)
decl %ebp
cmpl $0x5, %ebp
ja 0xb6cc
movl %ebp, %eax
leaq 0x21c1d(%rip), %rcx     # 0x2d2c0
movsd (%rcx,%rax,8), %xmm0
leaq 0x21c41(%rip), %rcx     # 0x2d2f0
movsd (%rcx,%rax,8), %xmm1
movsd %xmm0, 0x18(%rbx)
movabsq $0x4024000000000000, %rax # imm = 0x4024000000000000
movq %rax, 0x20(%rbx)
movsd %xmm1, 0x28(%rbx)
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, 0x40(%rbx)
andl $0x0, 0x100(%rbx)
leaq 0x4fd0(%rbx), %r14
xorpd %xmm0, %xmm0
movupd %xmm0, 0x50(%rbx)
movupd %xmm0, 0x60(%rbx)
movupd %xmm0, 0x6c(%rbx)
pushq $-0x14
popq %r15
cmpq $0x15, %r15
je 0xb779
cvtsi2sd %r15, %xmm0
mulsd 0x21ace(%rip), %xmm0    # 0x2d1e0
divsd 0x21ace(%rip), %xmm0    # 0x2d1e8
mulsd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %r12d, %r12d
cmpq $0x29, %r12
je 0xb76d
leaq -0x14(%r12), %rax
cvtsi2sd %rax, %xmm0
mulsd 0x21aa1(%rip), %xmm0    # 0x2d1e0
divsd 0x21aa1(%rip), %xmm0    # 0x2d1e8
mulsd %xmm0, %xmm0
addsd 0x8(%rsp), %xmm0
mulsd 0x21a97(%rip), %xmm0    # 0x2d1f0
callq 0x9ae0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%r14,%r12,4)
incq %r12
jmp 0xb727
incq %r15
addq $0xa4, %r14
jmp 0xb6ff
movq %rbx, %r14
addq $0x7b18, %r14           # imm = 0x7B18
xorl %r12d, %r12d
movl $0x3f800000, %ebp       # imm = 0x3F800000
pushq $0x21
popq %r15
cmpq $0xa, %r12
je 0xb847
cvtsi2sd %r12, %xmm0
divsd 0x21a52(%rip), %xmm0    # 0x2d1f8
addsd 0x21a42(%rip), %xmm0    # 0x2d1f0
callq 0x9040
mulsd %xmm0, %xmm0
addsd 0x21a41(%rip), %xmm0    # 0x2d200
ucomisd 0x21839(%rip), %xmm0    # 0x2d000
jb 0xb7cf
sqrtsd %xmm0, %xmm0
jmp 0xb7d4
callq 0x9a00
movsd %xmm0, 0x8(%rsp)
movl $0x1104, %edx           # imm = 0x1104
movq %r14, %rdi
xorl %esi, %esi
callq 0x9420
movsd 0x218ff(%rip), %xmm0    # 0x2d0f0
movsd %xmm0, 0x87c(%r14)
movl %ebp, 0x884(%r14)
movl %ebp, 0x904(%r14)
movl %ebp, 0x7fc(%r14)
movsd 0x8(%rsp), %xmm0
divsd 0x219eb(%rip), %xmm0    # 0x2d208
movq %r14, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r15, %rcx
movq %r15, %r8
movq %r15, %r9
movapd %xmm0, %xmm1
callq 0x97d0
incq %r12
addq $0x1104, %r14           # imm = 0x1104
jmp 0xb78f
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq