git-svn-id: http://webrtc.googlecode.com/svn/trunk@4 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
106
modules/audio_coding/codecs/PCM16B/main/interface/pcm16b.h
Normal file
106
modules/audio_coding/codecs/PCM16B/main/interface/pcm16b.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_MAIN_INTERFACE_PCM16B_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_MAIN_INTERFACE_PCM16B_H_
|
||||
/*
|
||||
* Define the fixpoint numeric formats
|
||||
*/
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* WebRtcPcm16b_EncodeW16(...)
|
||||
*
|
||||
* "Encode" a sample vector to 16 bit linear (Encoded standard is big endian)
|
||||
*
|
||||
* Input:
|
||||
* - speechIn16b : Input speech vector
|
||||
* - len : Number of samples in speech vector
|
||||
*
|
||||
* Output:
|
||||
* - speechOut16b : Encoded data vector (big endian 16 bit)
|
||||
*
|
||||
* Returned value : Size in bytes of speechOut16b
|
||||
*/
|
||||
|
||||
WebRtc_Word16 WebRtcPcm16b_EncodeW16(WebRtc_Word16 *speechIn16b,
|
||||
WebRtc_Word16 len,
|
||||
WebRtc_Word16 *speechOut16b);
|
||||
|
||||
/****************************************************************************
|
||||
* WebRtcPcm16b_Encode(...)
|
||||
*
|
||||
* "Encode" a sample vector to 16 bit linear (Encoded standard is big endian)
|
||||
*
|
||||
* Input:
|
||||
* - speech16b : Input speech vector
|
||||
* - len : Number of samples in speech vector
|
||||
*
|
||||
* Output:
|
||||
* - speech8b : Encoded data vector (big endian 16 bit)
|
||||
*
|
||||
* Returned value : Size in bytes of speech8b
|
||||
*/
|
||||
|
||||
WebRtc_Word16 WebRtcPcm16b_Encode(WebRtc_Word16 *speech16b,
|
||||
WebRtc_Word16 len,
|
||||
unsigned char *speech8b);
|
||||
|
||||
/****************************************************************************
|
||||
* WebRtcPcm16b_DecodeW16(...)
|
||||
*
|
||||
* "Decode" a vector to 16 bit linear (Encoded standard is big endian)
|
||||
*
|
||||
* Input:
|
||||
* - speechIn16b : Encoded data vector (big endian 16 bit)
|
||||
* - len : Number of bytes in speechIn16b
|
||||
*
|
||||
* Output:
|
||||
* - speechOut16b : Decoded speech vector
|
||||
*
|
||||
* Returned value : Samples in speechOut16b
|
||||
*/
|
||||
|
||||
WebRtc_Word16 WebRtcPcm16b_DecodeW16(void *inst,
|
||||
WebRtc_Word16 *speechIn16b,
|
||||
WebRtc_Word16 len,
|
||||
WebRtc_Word16 *speechOut16b,
|
||||
WebRtc_Word16* speechType);
|
||||
|
||||
/****************************************************************************
|
||||
* WebRtcPcm16b_Decode(...)
|
||||
*
|
||||
* "Decode" a vector to 16 bit linear (Encoded standard is big endian)
|
||||
*
|
||||
* Input:
|
||||
* - speech8b : Encoded data vector (big endian 16 bit)
|
||||
* - len : Number of bytes in speech8b
|
||||
*
|
||||
* Output:
|
||||
* - speech16b : Decoded speech vector
|
||||
*
|
||||
* Returned value : Samples in speech16b
|
||||
*/
|
||||
|
||||
|
||||
WebRtc_Word16 WebRtcPcm16b_Decode(unsigned char *speech8b,
|
||||
WebRtc_Word16 len,
|
||||
WebRtc_Word16 *speech16b);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PCM16B */
|
100
modules/audio_coding/codecs/PCM16B/main/source/pcm16b.c
Normal file
100
modules/audio_coding/codecs/PCM16B/main/source/pcm16b.c
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#include "pcm16b.h"
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
#ifdef WEBRTC_BIG_ENDIAN
|
||||
#include "signal_processing_library.h"
|
||||
#endif
|
||||
|
||||
#define HIGHEND 0xFF00
|
||||
#define LOWEND 0xFF
|
||||
|
||||
|
||||
|
||||
/* Encoder with WebRtc_Word16 Output */
|
||||
WebRtc_Word16 WebRtcPcm16b_EncodeW16(WebRtc_Word16 *speechIn16b,
|
||||
WebRtc_Word16 len,
|
||||
WebRtc_Word16 *speechOut16b)
|
||||
{
|
||||
#ifdef WEBRTC_BIG_ENDIAN
|
||||
WEBRTC_SPL_MEMCPY_W16(speechOut16b, speechIn16b, len);
|
||||
#else
|
||||
int i;
|
||||
for (i=0;i<len;i++) {
|
||||
speechOut16b[i]=(((WebRtc_UWord16)speechIn16b[i])>>8)|((((WebRtc_UWord16)speechIn16b[i])<<8)&0xFF00);
|
||||
}
|
||||
#endif
|
||||
return(len<<1);
|
||||
}
|
||||
|
||||
|
||||
/* Encoder with char Output (old version) */
|
||||
WebRtc_Word16 WebRtcPcm16b_Encode(WebRtc_Word16 *speech16b,
|
||||
WebRtc_Word16 len,
|
||||
unsigned char *speech8b)
|
||||
{
|
||||
WebRtc_Word16 samples=len*2;
|
||||
WebRtc_Word16 pos;
|
||||
WebRtc_Word16 short1;
|
||||
WebRtc_Word16 short2;
|
||||
for (pos=0;pos<len;pos++) {
|
||||
short1=HIGHEND & speech16b[pos];
|
||||
short2=LOWEND & speech16b[pos];
|
||||
short1=short1>>8;
|
||||
speech8b[pos*2]=(unsigned char) short1;
|
||||
speech8b[pos*2+1]=(unsigned char) short2;
|
||||
}
|
||||
return(samples);
|
||||
}
|
||||
|
||||
|
||||
/* Decoder with WebRtc_Word16 Input instead of char when the WebRtc_Word16 Encoder is used */
|
||||
WebRtc_Word16 WebRtcPcm16b_DecodeW16(void *inst,
|
||||
WebRtc_Word16 *speechIn16b,
|
||||
WebRtc_Word16 len,
|
||||
WebRtc_Word16 *speechOut16b,
|
||||
WebRtc_Word16* speechType)
|
||||
{
|
||||
#ifdef WEBRTC_BIG_ENDIAN
|
||||
WEBRTC_SPL_MEMCPY_W8(speechOut16b, speechIn16b, ((len*sizeof(WebRtc_Word16)+1)>>1));
|
||||
#else
|
||||
int i;
|
||||
int samples=len>>1;
|
||||
|
||||
for (i=0;i<samples;i++) {
|
||||
speechOut16b[i]=(((WebRtc_UWord16)speechIn16b[i])>>8)|(((WebRtc_UWord16)(speechIn16b[i]&0xFF))<<8);
|
||||
}
|
||||
#endif
|
||||
|
||||
*speechType=1;
|
||||
return(len>>1);
|
||||
}
|
||||
|
||||
/* "old" version of the decoder that uses char as input (not used in NetEq any more) */
|
||||
WebRtc_Word16 WebRtcPcm16b_Decode(unsigned char *speech8b,
|
||||
WebRtc_Word16 len,
|
||||
WebRtc_Word16 *speech16b)
|
||||
{
|
||||
WebRtc_Word16 samples=len>>1;
|
||||
WebRtc_Word16 pos;
|
||||
WebRtc_Word16 shortval;
|
||||
for (pos=0;pos<samples;pos++) {
|
||||
shortval=((unsigned short) speech8b[pos*2]);
|
||||
shortval=(shortval<<8)&HIGHEND;
|
||||
shortval=shortval|(((unsigned short) speech8b[pos*2+1])&LOWEND);
|
||||
speech16b[pos]=shortval;
|
||||
}
|
||||
return(samples);
|
||||
}
|
||||
|
37
modules/audio_coding/codecs/PCM16B/main/source/pcm16b.gyp
Normal file
37
modules/audio_coding/codecs/PCM16B/main/source/pcm16b.gyp
Normal file
@@ -0,0 +1,37 @@
|
||||
# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
{
|
||||
'includes': [
|
||||
'../../../../../../common_settings.gypi', # Common settings
|
||||
],
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'PCM16B',
|
||||
'type': '<(library)',
|
||||
'include_dirs': [
|
||||
'../interface',
|
||||
],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [
|
||||
'../interface',
|
||||
],
|
||||
},
|
||||
'sources': [
|
||||
'../interface/pcm16b.h',
|
||||
'pcm16b.c',
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# tab-width:2
|
||||
# indent-tabs-mode:nil
|
||||
# End:
|
||||
# vim: set expandtab tabstop=2 shiftwidth=2:
|
Reference in New Issue
Block a user