summaryrefslogtreecommitdiff
path: root/libavcodec/s3tc.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2012-03-12 17:37:02 +0000
committerRonald S. Bultje <rsbultje@gmail.com>2012-03-12 11:37:47 -0700
commit919f3554387e043bdfe10c6369356d1104882183 (patch)
tree9580cd2767ab1dccf6bad417c6205091dcd3beca /libavcodec/s3tc.c
parent85aded741e03b17b0cc5c588b1f5acbcb25d7996 (diff)
txd: port to bytestream2 API
Protects against overreads. Signed-off-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavcodec/s3tc.c')
-rw-r--r--libavcodec/s3tc.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/libavcodec/s3tc.c b/libavcodec/s3tc.c
index d0c4eb80e1..62dc356792 100644
--- a/libavcodec/s3tc.c
+++ b/libavcodec/s3tc.c
@@ -21,19 +21,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libavutil/intreadwrite.h"
+#include "libavcodec/bytestream.h"
#include "avcodec.h"
#include "s3tc.h"
-static inline void dxt1_decode_pixels(const uint8_t *s, uint32_t *d,
+static inline void dxt1_decode_pixels(GetByteContext *gb, uint32_t *d,
unsigned int qstride, unsigned int flag,
uint64_t alpha) {
unsigned int x, y, c0, c1, a = (!flag * 255u) << 24;
unsigned int rb0, rb1, rb2, rb3, g0, g1, g2, g3;
uint32_t colors[4], pixels;
- c0 = AV_RL16(s);
- c1 = AV_RL16(s+2);
+ c0 = bytestream2_get_le16(gb);
+ c1 = bytestream2_get_le16(gb);
rb0 = (c0<<3 | c0<<8) & 0xf800f8;
rb1 = (c1<<3 | c1<<8) & 0xf800f8;
@@ -61,7 +61,7 @@ static inline void dxt1_decode_pixels(const uint8_t *s, uint32_t *d,
colors[2] = rb2 + g2 + a;
- pixels = AV_RL32(s+4);
+ pixels = bytestream2_get_le32(gb);
for (y=0; y<4; y++) {
for (x=0; x<4; x++) {
a = (alpha & 0x0f) << 28;
@@ -74,24 +74,24 @@ static inline void dxt1_decode_pixels(const uint8_t *s, uint32_t *d,
}
}
-void ff_decode_dxt1(const uint8_t *s, uint8_t *dst,
+void ff_decode_dxt1(GetByteContext *gb, 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);
+ for (bx = 0; bx < w / 4; bx++, d += 4)
+ dxt1_decode_pixels(gb, d, qstride, 0, 0LL);
}
-void ff_decode_dxt3(const uint8_t *s, uint8_t *dst,
+void ff_decode_dxt3(GetByteContext *gb, 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));
+ for (bx = 0; bx < w / 4; bx++, d += 4)
+ dxt1_decode_pixels(gb, d, qstride, 1, bytestream2_get_le64(gb));
}