source: src/spectral/dct_ipp.c @ 1f112cc

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5
Last change on this file since 1f112cc was 1f112cc, checked in by Paul Brossier <piem@piem.org>, 6 years ago

src/spectral/dct_*.c: remove unused cvec.h

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*
2  Copyright (C) 2017 Paul Brossier <piem@aubio.org>
3
4  This file is part of aubio.
5
6  aubio is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10
11  aubio is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15
16  You should have received a copy of the GNU General Public License
17  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#include "aubio_priv.h"
22#include "fvec.h"
23#include "spectral/dct.h"
24
25#if defined(HAVE_INTEL_IPP)
26
27#if !HAVE_AUBIO_DOUBLE
28#define aubio_IppFloat                 Ipp32f
29#define aubio_ippsDCTFwdSpec           IppsDCTFwdSpec_32f
30#define aubio_ippsDCTInvSpec           IppsDCTInvSpec_32f
31#define aubio_ippsDCTFwdGetSize        ippsDCTFwdGetSize_32f
32#define aubio_ippsDCTInvGetSize        ippsDCTInvGetSize_32f
33#define aubio_ippsDCTFwdInit           ippsDCTFwdInit_32f
34#define aubio_ippsDCTInvInit           ippsDCTInvInit_32f
35#define aubio_ippsDCTFwd               ippsDCTFwd_32f
36#define aubio_ippsDCTInv               ippsDCTInv_32f
37#else /* HAVE_AUBIO_DOUBLE */
38#define aubio_IppFloat                 Ipp64f
39#define aubio_ippsDCTFwdSpec           IppsDCTFwdSpec_64f
40#define aubio_ippsDCTInvSpec           IppsDCTInvSpec_64f
41#define aubio_ippsDCTFwdGetSize        ippsDCTFwdGetSize_64f
42#define aubio_ippsDCTInvGetSize        ippsDCTInvGetSize_64f
43#define aubio_ippsDCTFwdInit           ippsDCTFwdInit_64f
44#define aubio_ippsDCTInvInit           ippsDCTInvInit_64f
45#define aubio_ippsDCTFwd               ippsDCTFwd_64f
46#define aubio_ippsDCTInv               ippsDCTInv_64f
47#endif
48
49struct _aubio_dct_t {
50  uint_t size;
51  Ipp8u* pSpec;
52  Ipp8u* pSpecBuffer;
53  Ipp8u* pBuffer;
54  aubio_ippsDCTFwdSpec* pFwdDCTSpec;
55  aubio_ippsDCTInvSpec* pInvDCTSpec;
56};
57
58aubio_dct_t * new_aubio_dct (uint_t size) {
59  aubio_dct_t * s = AUBIO_NEW(aubio_dct_t);
60
61  const IppHintAlgorithm qualityHint = ippAlgHintAccurate; // ippAlgHintFast;
62  int pSpecSize, pSpecBufferSize, pBufferSize;
63  IppStatus status;
64
65  if ((sint_t)size <= 1) {
66    AUBIO_ERR("dct: can only create with sizes greater than 1, requested %d\n",
67        size);
68    goto beach;
69  }
70
71  status = aubio_ippsDCTFwdGetSize(size, qualityHint, &pSpecSize,
72      &pSpecBufferSize, &pBufferSize);
73  if (status != ippStsNoErr) {
74    AUBIO_ERR("dct: failed to initialize dct. IPP error: %d\n", status);
75    goto beach;
76  }
77
78  //AUBIO_INF("dct: fwd initialized with %d %d %d\n", pSpecSize, pSpecBufferSize,
79  //    pBufferSize);
80
81  s->pSpec = ippsMalloc_8u(pSpecSize);
82  if (pSpecSize > 0) {
83    s->pSpecBuffer = ippsMalloc_8u(pSpecBufferSize);
84  } else {
85    s->pSpecBuffer = NULL;
86  }
87  s->pBuffer = ippsMalloc_8u(pBufferSize);
88
89  status = aubio_ippsDCTInvGetSize(size, qualityHint, &pSpecSize,
90      &pSpecBufferSize, &pBufferSize);
91  if (status != ippStsNoErr) {
92    AUBIO_ERR("dct: failed to initialize dct. IPP error: %d\n", status);
93    goto beach;
94  }
95
96  //AUBIO_INF("dct: inv initialized with %d %d %d\n", pSpecSize, pSpecBufferSize,
97  //    pBufferSize);
98
99  status = aubio_ippsDCTFwdInit(&(s->pFwdDCTSpec), size, qualityHint, s->pSpec,
100      s->pSpecBuffer);
101  if (status != ippStsNoErr) {
102    AUBIO_ERR("dct: failed to initialize fwd dct. IPP error: %d\n", status);
103    goto beach;
104  }
105
106  status = aubio_ippsDCTInvInit(&(s->pInvDCTSpec), size, qualityHint, s->pSpec,
107      s->pSpecBuffer);
108  if (status != ippStsNoErr) {
109    AUBIO_ERR("dct: failed to initialize inv dct. IPP error: %d\n", status);
110    goto beach;
111  }
112
113  s->size = size;
114
115  return s;
116
117beach:
118  del_aubio_dct(s);
119  return NULL;
120}
121
122void del_aubio_dct(aubio_dct_t *s) {
123  ippFree(s->pSpec);
124  ippFree(s->pSpecBuffer);
125  ippFree(s->pBuffer);
126  AUBIO_FREE(s);
127}
128
129void aubio_dct_do(aubio_dct_t *s, const fvec_t *input, fvec_t *output) {
130
131  aubio_ippsDCTFwd((const aubio_IppFloat*)input->data,
132      (aubio_IppFloat*)output->data, s->pFwdDCTSpec, s->pBuffer);
133
134}
135
136void aubio_dct_rdo(aubio_dct_t *s, const fvec_t *input, fvec_t *output) {
137
138  aubio_ippsDCTInv((const aubio_IppFloat*)input->data,
139      (aubio_IppFloat*)output->data, s->pInvDCTSpec, s->pBuffer);
140
141}
142
143#endif //defined(HAVE_INTEL_IPP)
Note: See TracBrowser for help on using the repository browser.