1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-16 11:55:42 +00:00

Simplify convert_14bits_to_16bits function in ad_hwac3

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25167 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2007-11-26 19:01:34 +00:00
parent 84170d0b24
commit a4533bdb84

View File

@ -424,35 +424,27 @@ static int convert_14bits_to_16bits(const unsigned char *src,
int is_le)
{
uint16_t *p = (uint16_t *)dest;
uint16_t buf = 0;
int spacebits = 16;
int leftbits;
if (len <= 0) return 0;
while (len > 0) {
uint16_t v;
if (len == 1)
v = is_le ? src[0] : src[0] << 8;
else
v = is_le ? src[1] << 8 | src[0] : src[0] << 8 | src[1];
leftbits = 14;
v <<= 2;
src += 2;
len -= 2;
if (spacebits == 0) {
++p;
spacebits = 16;
buf |= v >> (16 - spacebits);
spacebits -= 14;
if (spacebits < 0) {
*p++ = buf;
spacebits += 16;
buf = v << (spacebits - 2);
}
if (spacebits == 16)
*p = 0;
if (spacebits < leftbits) {
leftbits -= spacebits;
*p |= (v & 0x3FFF) >> leftbits;
++p;
*p = 0;
spacebits = 16;
}
*p |= ((v << (16 - leftbits)) & 0xFFFF) >> (16 - spacebits);
spacebits -= leftbits;
}
if (spacebits < 16)
++p;
*p++ = buf;
return (unsigned char *)p - dest;
}