summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-07-11 18:51:12 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-07-11 18:51:12 +0000
commit4366cc211cb7ab9ed2bc3d25de5bd8ea507f445e (patch)
tree8853e61a24928ea40109726263a7c07976325ca3 /libmpcodecs
parent05deb158cf85d7fc7894685a91d067e78110e082 (diff)
downloadmpv-4366cc211cb7ab9ed2bc3d25de5bd8ea507f445e.tar.bz2
mpv-4366cc211cb7ab9ed2bc3d25de5bd8ea507f445e.tar.xz
Simplify ad_msadpmc.c: Use AV_RL16, merge sign extension into LE_16 read and
use (int16_t) to let the compiler do the sign extension. Reduces code size on x86_64, gcc 4.3.1 by 248 bytes. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27257 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/ad_msadpcm.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/libmpcodecs/ad_msadpcm.c b/libmpcodecs/ad_msadpcm.c
index 1ebf646845..5f3d330b42 100644
--- a/libmpcodecs/ad_msadpcm.c
+++ b/libmpcodecs/ad_msadpcm.c
@@ -13,6 +13,7 @@
#include "config.h"
#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
#include "mpbswap.h"
#include "ad_internal.h"
@@ -45,7 +46,7 @@ static const int ms_adapt_coeff2[] =
#define MS_ADPCM_PREAMBLE_SIZE 6
-#define LE_16(x) ((x)[0]+(256*((x)[1])))
+#define LE_16(x) ((int16_t)AV_RL16(x))
// clamp a number between 0 and 88
#define CLAMP_0_TO_88(x) x = av_clip(x, 0, 88);
@@ -53,8 +54,6 @@ static const int ms_adapt_coeff2[] =
#define CLAMP_S16(x) x = av_clip_int16(x);
// clamp a number above 16
#define CLAMP_ABOVE_16(x) if (x < 16) x = 16;
-// sign extend a 16-bit value
-#define SE_16BIT(x) if (x & 0x8000) x -= 0x10000;
// sign extend a 4-bit value
#define SE_4BIT(x) if (x & 0x8) x -= 0x10;
@@ -129,32 +128,26 @@ static int ms_adpcm_decode_block(unsigned short *output, unsigned char *input,
idelta[0] = LE_16(&input[stream_ptr]);
stream_ptr += 2;
- SE_16BIT(idelta[0]);
if (channels == 2)
{
idelta[1] = LE_16(&input[stream_ptr]);
stream_ptr += 2;
- SE_16BIT(idelta[1]);
}
sample1[0] = LE_16(&input[stream_ptr]);
stream_ptr += 2;
- SE_16BIT(sample1[0]);
if (channels == 2)
{
sample1[1] = LE_16(&input[stream_ptr]);
stream_ptr += 2;
- SE_16BIT(sample1[1]);
}
sample2[0] = LE_16(&input[stream_ptr]);
stream_ptr += 2;
- SE_16BIT(sample2[0]);
if (channels == 2)
{
sample2[1] = LE_16(&input[stream_ptr]);
stream_ptr += 2;
- SE_16BIT(sample2[1]);
}
if (channels == 1)