mirror of
https://github.com/mpv-player/mpv
synced 2025-02-22 07:46:55 +00:00
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
This commit is contained in:
parent
05deb158cf
commit
4366cc211c
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user