• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef LOG_TAG
17 #define LOG_TAG "HpaePcmProcess"
18 #endif
19 
20 #include "hpae_pcm_process.h"
21 #include "simd_utils.h"
22 #include "audio_engine_log.h"
23 
24 namespace OHOS {
25 namespace AudioStandard {
26 namespace HPAE {
operator =(const std::vector<float> & other)27 HpaePcmProcess &HpaePcmProcess::operator = (const std::vector<float>& other)
28 {
29     errNo_ = memcpy_s(pcmDataPtr_, sizeof(float) * size_, other.data(), sizeof(float) * other.size());
30     CHECK_AND_RETURN_RET_LOG(errNo_ == 0, *this, "memcpy_s failed, errNo: %{public}d", errNo_);
31     return *this;
32 }
33 
operator =(const HpaePcmProcess & other)34 HpaePcmProcess &HpaePcmProcess::operator = (const HpaePcmProcess& other)
35 {
36     if (this != &other) {
37         errNo_ = memcpy_s(pcmDataPtr_, sizeof(float) * size_, other.Begin(), sizeof(float) * other.Size());
38         CHECK_AND_RETURN_RET_LOG(errNo_ == 0, *this, "memcpy_s failed, errNo: %{public}d", errNo_);
39     }
40     return *this;
41 }
42 
operator +=(const HpaePcmProcess & other)43 HpaePcmProcess &HpaePcmProcess::operator+=(const HpaePcmProcess &other)
44 {
45     float *curData = Begin();
46     const float *otherData = other.Begin();
47     SimdPointByPointAdd(size_, otherData, curData, curData);
48     return *this;
49 }
50 
operator -=(const HpaePcmProcess & other)51 HpaePcmProcess &HpaePcmProcess::operator-=(const HpaePcmProcess &other)
52 {
53     float *curData = Begin();
54     const float *otherData = other.Begin();
55     SimdPointByPointSub(size_, curData, otherData, curData);
56     return *this;
57 }
58 
operator *=(const HpaePcmProcess & other)59 HpaePcmProcess &HpaePcmProcess::operator*=(const HpaePcmProcess &other)
60 {
61     float *curData = Begin();
62     const float *otherData = other.Begin();
63     SimdPointByPointMul(size_, otherData, curData, curData);
64     return *this;
65 }
66 
Reset()67 void HpaePcmProcess::Reset()
68 {
69     errNo_ = memset_s(Begin(), sizeof(float) * size_, 0, sizeof(float) * size_);
70     CHECK_AND_RETURN_LOG(errNo_ == 0, "memcpy_s failed, errNo: %{public}d", errNo_);
71 }
72 }  // namespace HPAE
73 }  // namespace AudioStandard
74 }  // namespace OHOS