c67b89c5 |
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
|
c67b89c5 |
#include "avcodec.h"
#include "s3tc.h"
static inline void dxt1_decode_pixels(const uint8_t *s, uint32_t *d,
unsigned int qstride, unsigned int flag,
uint64_t alpha) {
unsigned int x, y, c0, c1, a = (!flag * 255) << 24;
unsigned int rb0, rb1, rb2, rb3, g0, g1, g2, g3;
uint32_t colors[4], pixels;
|
c67b89c5 |
for (y=0; y<4; y++) {
for (x=0; x<4; x++) {
a = (alpha & 0x0f) << 28;
a += a >> 4;
d[x] = a + colors[pixels&3];
pixels >>= 2;
alpha >>= 4;
}
d += qstride;
}
}
void ff_decode_dxt1(const uint8_t *s, uint8_t *dst,
const unsigned int w, const unsigned int h,
const unsigned int stride) {
unsigned int bx, by, qstride = stride/4;
uint32_t *d = (uint32_t *) dst;
for (by=0; by < h/4; by++, d += stride-w)
for (bx=0; bx < w/4; bx++, s+=8, d+=4)
dxt1_decode_pixels(s, d, qstride, 0, 0LL);
}
void ff_decode_dxt3(const uint8_t *s, uint8_t *dst,
const unsigned int w, const unsigned int h,
const unsigned int stride) {
unsigned int bx, by, qstride = stride/4;
uint32_t *d = (uint32_t *) dst;
for (by=0; by < h/4; by++, d += stride-w)
for (bx=0; bx < w/4; bx++, s+=16, d+=4)
dxt1_decode_pixels(s+8, d, qstride, 1, AV_RL64(s));
} |