Revert 6961 "common_audio/signal_processing: Remove macro WEBRTC..."

> common_audio/signal_processing: Remove macro WEBRTC_SPL_MEMCPY_W8
> 
> This macro is nothing but memcpy() and further used at one single place in webrtc, so it makes no sense to keep it. Replaced the operation where it is used.
> 
> BUG=3348,3353
> TESTED=locally on linux and trybots
> R=kwiberg@webrtc.org, tina.legrand@webrtc.org
> 
> Review URL: https://webrtc-codereview.appspot.com/16359004

TBR=bjornv@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/22499004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6962 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
bjornv@webrtc.org
2014-08-25 10:32:22 +00:00
parent 4f01017e2d
commit 4a616be12b
4 changed files with 35 additions and 25 deletions

View File

@@ -109,6 +109,8 @@
extern "C" { extern "C" {
#endif #endif
#define WEBRTC_SPL_MEMCPY_W8(v1, v2, length) \
memcpy(v1, v2, (length) * sizeof(char))
#define WEBRTC_SPL_MEMCPY_W16(v1, v2, length) \ #define WEBRTC_SPL_MEMCPY_W16(v1, v2, length) \
memcpy(v1, v2, (length) * sizeof(int16_t)) memcpy(v1, v2, (length) * sizeof(int16_t))

View File

@@ -165,9 +165,11 @@ TEST_F(SplTest, MathOperationsTest) {
TEST_F(SplTest, BasicArrayOperationsTest) { TEST_F(SplTest, BasicArrayOperationsTest) {
const int kVectorSize = 4; const int kVectorSize = 4;
int B[] = {4, 12, 133, 1100}; int B[] = {4, 12, 133, 1100};
uint8_t b8[kVectorSize];
int16_t b16[kVectorSize]; int16_t b16[kVectorSize];
int32_t b32[kVectorSize]; int32_t b32[kVectorSize];
uint8_t bTmp8[kVectorSize];
int16_t bTmp16[kVectorSize]; int16_t bTmp16[kVectorSize];
int32_t bTmp32[kVectorSize]; int32_t bTmp32[kVectorSize];
@@ -196,9 +198,14 @@ TEST_F(SplTest, BasicArrayOperationsTest) {
EXPECT_EQ(1, b32[kk]); EXPECT_EQ(1, b32[kk]);
} }
for (int kk = 0; kk < kVectorSize; ++kk) { for (int kk = 0; kk < kVectorSize; ++kk) {
bTmp8[kk] = (int8_t)kk;
bTmp16[kk] = (int16_t)kk; bTmp16[kk] = (int16_t)kk;
bTmp32[kk] = (int32_t)kk; bTmp32[kk] = (int32_t)kk;
} }
WEBRTC_SPL_MEMCPY_W8(b8, bTmp8, kVectorSize);
for (int kk = 0; kk < kVectorSize; ++kk) {
EXPECT_EQ(b8[kk], bTmp8[kk]);
}
WEBRTC_SPL_MEMCPY_W16(b16, bTmp16, kVectorSize); WEBRTC_SPL_MEMCPY_W16(b16, bTmp16, kVectorSize);
for (int kk = 0; kk < kVectorSize; ++kk) { for (int kk = 0; kk < kVectorSize; ++kk) {
EXPECT_EQ(b16[kk], bTmp16[kk]); EXPECT_EQ(b16[kk], bTmp16[kk]);

View File

@@ -27,7 +27,7 @@ extern "C" {
* *
* Input: * Input:
* - speechIn16b : Input speech vector * - speechIn16b : Input speech vector
* - length_samples : Number of samples in speech vector * - len : Number of samples in speech vector
* *
* Output: * Output:
* - speechOut16b : Encoded data vector (big endian 16 bit) * - speechOut16b : Encoded data vector (big endian 16 bit)
@@ -35,9 +35,9 @@ extern "C" {
* Returned value : Size in bytes of speechOut16b * Returned value : Size in bytes of speechOut16b
*/ */
int16_t WebRtcPcm16b_EncodeW16(int16_t *speechIn16b, int16_t WebRtcPcm16b_EncodeW16(const int16_t* speechIn16b,
int16_t length_samples, int16_t len,
int16_t *speechOut16b); int16_t* speechOut16b);
/**************************************************************************** /****************************************************************************
* WebRtcPcm16b_Encode(...) * WebRtcPcm16b_Encode(...)
@@ -65,7 +65,7 @@ int16_t WebRtcPcm16b_Encode(int16_t *speech16b,
* *
* Input: * Input:
* - speechIn16b : Encoded data vector (big endian 16 bit) * - speechIn16b : Encoded data vector (big endian 16 bit)
* - length_bytes : Number of bytes in speechIn16b * - len : Number of bytes in speechIn16b
* *
* Output: * Output:
* - speechOut16b : Decoded speech vector * - speechOut16b : Decoded speech vector
@@ -75,7 +75,7 @@ int16_t WebRtcPcm16b_Encode(int16_t *speech16b,
int16_t WebRtcPcm16b_DecodeW16(void *inst, int16_t WebRtcPcm16b_DecodeW16(void *inst,
int16_t *speechIn16b, int16_t *speechIn16b,
int16_t length_bytes, int16_t len,
int16_t *speechOut16b, int16_t *speechOut16b,
int16_t* speechType); int16_t* speechType);

View File

@@ -12,31 +12,32 @@
#include "pcm16b.h" #include "pcm16b.h"
#include <stdlib.h> #include <stdlib.h>
#ifdef WEBRTC_ARCH_BIG_ENDIAN
#include <string.h>
#endif
#include "typedefs.h" #include "typedefs.h"
#ifdef WEBRTC_ARCH_BIG_ENDIAN
#include "signal_processing_library.h"
#endif
#define HIGHEND 0xFF00 #define HIGHEND 0xFF00
#define LOWEND 0xFF #define LOWEND 0xFF
/* Encoder with int16_t Output */ /* Encoder with int16_t Output */
int16_t WebRtcPcm16b_EncodeW16(int16_t *speechIn16b, int16_t WebRtcPcm16b_EncodeW16(const int16_t* speechIn16b,
int16_t length_samples, int16_t len,
int16_t *speechOut16b) int16_t* speechOut16b)
{ {
#ifdef WEBRTC_ARCH_BIG_ENDIAN #ifdef WEBRTC_ARCH_BIG_ENDIAN
memcpy(speechOut16b, speechIn16b, length_samples * sizeof(int16_t)); WEBRTC_SPL_MEMCPY_W16(speechOut16b, speechIn16b, len);
#else #else
int i; int i;
for (i = 0; i < length_samples; i++) { for (i=0;i<len;i++) {
speechOut16b[i]=(((uint16_t)speechIn16b[i])>>8)|((((uint16_t)speechIn16b[i])<<8)&0xFF00); speechOut16b[i]=(((uint16_t)speechIn16b[i])>>8)|((((uint16_t)speechIn16b[i])<<8)&0xFF00);
} }
#endif #endif
return length_samples << 1; return(len<<1);
} }
@@ -63,15 +64,15 @@ int16_t WebRtcPcm16b_Encode(int16_t *speech16b,
/* Decoder with int16_t Input instead of char when the int16_t Encoder is used */ /* Decoder with int16_t Input instead of char when the int16_t Encoder is used */
int16_t WebRtcPcm16b_DecodeW16(void *inst, int16_t WebRtcPcm16b_DecodeW16(void *inst,
int16_t *speechIn16b, int16_t *speechIn16b,
int16_t length_bytes, int16_t len,
int16_t *speechOut16b, int16_t *speechOut16b,
int16_t* speechType) int16_t* speechType)
{ {
#ifdef WEBRTC_ARCH_BIG_ENDIAN #ifdef WEBRTC_ARCH_BIG_ENDIAN
memcpy(speechOut16b, speechIn16b, length_bytes); WEBRTC_SPL_MEMCPY_W8(speechOut16b, speechIn16b, ((len*sizeof(int16_t)+1)>>1));
#else #else
int i; int i;
int samples = length_bytes >> 1; int samples=len>>1;
for (i=0;i<samples;i++) { for (i=0;i<samples;i++) {
speechOut16b[i]=(((uint16_t)speechIn16b[i])>>8)|(((uint16_t)(speechIn16b[i]&0xFF))<<8); speechOut16b[i]=(((uint16_t)speechIn16b[i])>>8)|(((uint16_t)(speechIn16b[i]&0xFF))<<8);
@@ -83,7 +84,7 @@ int16_t WebRtcPcm16b_DecodeW16(void *inst,
// Avoid warning. // Avoid warning.
(void)(inst = NULL); (void)(inst = NULL);
return length_bytes >> 1; return(len>>1);
} }
/* "old" version of the decoder that uses char as input (not used in NetEq any more) */ /* "old" version of the decoder that uses char as input (not used in NetEq any more) */