~ubuntu-branches/ubuntu/saucy/gst-libav1.0/saucy-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavcodec/s3tc.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-07-30 09:00:15 UTC
  • mfrom: (1.1.16) (7.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20130730090015-sc1ou2yssu7q5w4e
Tags: 1.1.3-1
* New upstream development snapshot:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.1.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
22
 */
23
23
 
24
 
#include "libavutil/intreadwrite.h"
 
24
#include "libavcodec/bytestream.h"
25
25
#include "avcodec.h"
26
26
#include "s3tc.h"
27
27
 
28
 
static inline void dxt1_decode_pixels(const uint8_t *s, uint32_t *d,
 
28
static inline void dxt1_decode_pixels(GetByteContext *gb, uint32_t *d,
29
29
                                      unsigned int qstride, unsigned int flag,
30
30
                                      uint64_t alpha) {
31
31
    unsigned int x, y, c0, c1, a = (!flag * 255u) << 24;
32
32
    unsigned int rb0, rb1, rb2, rb3, g0, g1, g2, g3;
33
33
    uint32_t colors[4], pixels;
34
34
 
35
 
    c0 = AV_RL16(s);
36
 
    c1 = AV_RL16(s+2);
 
35
    c0 = bytestream2_get_le16(gb);
 
36
    c1 = bytestream2_get_le16(gb);
37
37
 
38
38
    rb0  = (c0<<3 | c0<<8) & 0xf800f8;
39
39
    rb1  = (c1<<3 | c1<<8) & 0xf800f8;
61
61
 
62
62
    colors[2] = rb2 + g2 + a;
63
63
 
64
 
    pixels = AV_RL32(s+4);
 
64
    pixels = bytestream2_get_le32(gb);
65
65
    for (y=0; y<4; y++) {
66
66
        for (x=0; x<4; x++) {
67
67
            a        = (alpha & 0x0f) << 28;
74
74
    }
75
75
}
76
76
 
77
 
void ff_decode_dxt1(const uint8_t *s, uint8_t *dst,
 
77
void ff_decode_dxt1(GetByteContext *gb, uint8_t *dst,
78
78
                    const unsigned int w, const unsigned int h,
79
79
                    const unsigned int stride) {
80
80
    unsigned int bx, by, qstride = stride/4;
81
81
    uint32_t *d = (uint32_t *) dst;
82
82
 
83
83
    for (by=0; by < h/4; by++, d += stride-w)
84
 
        for (bx=0; bx < w/4; bx++, s+=8, d+=4)
85
 
            dxt1_decode_pixels(s, d, qstride, 0, 0LL);
 
84
        for (bx = 0; bx < w / 4; bx++, d += 4)
 
85
            dxt1_decode_pixels(gb, d, qstride, 0, 0LL);
86
86
}
87
87
 
88
 
void ff_decode_dxt3(const uint8_t *s, uint8_t *dst,
 
88
void ff_decode_dxt3(GetByteContext *gb, uint8_t *dst,
89
89
                    const unsigned int w, const unsigned int h,
90
90
                    const unsigned int stride) {
91
91
    unsigned int bx, by, qstride = stride/4;
92
92
    uint32_t *d = (uint32_t *) dst;
93
93
 
94
94
    for (by=0; by < h/4; by++, d += stride-w)
95
 
        for (bx=0; bx < w/4; bx++, s+=16, d+=4)
96
 
            dxt1_decode_pixels(s+8, d, qstride, 1, AV_RL64(s));
 
95
        for (bx = 0; bx < w / 4; bx++, d += 4)
 
96
            dxt1_decode_pixels(gb, d, qstride, 1, bytestream2_get_le64(gb));
97
97
}