} IpvideoContext;
-#define CHECK_STREAM_PTR(n) \
- if (s->stream_end - s->stream_ptr < n) { \
+#define CHECK_STREAM_PTR(stream_ptr, stream_end, n) \
+ if (stream_end - stream_ptr < n) { \
av_log(s->avctx, AV_LOG_ERROR, "Interplay video warning: stream_ptr out of bounds (%p >= %p)\n", \
- s->stream_ptr + n, s->stream_end); \
+ stream_ptr + n, stream_end); \
return -1; \
}
int x, y;
/* copy block from 2 frames ago using a motion vector; need 1 more byte */
- CHECK_STREAM_PTR(1);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 1);
B = *s->stream_ptr++;
if (B < 56) {
/* copy 8x8 block from current frame from an up/left block */
/* need 1 more byte for motion */
- CHECK_STREAM_PTR(1);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 1);
B = *s->stream_ptr++;
if (B < 56) {
unsigned char B, BL, BH;
/* copy a block from the previous frame; need 1 more byte */
- CHECK_STREAM_PTR(1);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 1);
B = *s->stream_ptr++;
BL = B & 0x0F;
/* copy a block from the previous frame using an expanded range;
* need 2 more bytes */
- CHECK_STREAM_PTR(2);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 2);
x = *s->stream_ptr++;
y = *s->stream_ptr++;
unsigned int flags;
/* 2-color encoding */
- CHECK_STREAM_PTR(2);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 2);
P[0] = *s->stream_ptr++;
P[1] = *s->stream_ptr++;
if (P[0] <= P[1]) {
/* need 8 more bytes from the stream */
- CHECK_STREAM_PTR(8);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 8);
for (y = 0; y < 8; y++) {
flags = *s->stream_ptr++ | 0x100;
} else {
/* need 2 more bytes from the stream */
- CHECK_STREAM_PTR(2);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 2);
flags = bytestream_get_le16(&s->stream_ptr);
for (y = 0; y < 8; y += 2) {
/* 2-color encoding for each 4x4 quadrant, or 2-color encoding on
* either top and bottom or left and right halves */
- CHECK_STREAM_PTR(2);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 2);
P[0] = *s->stream_ptr++;
P[1] = *s->stream_ptr++;
if (P[0] <= P[1]) {
- CHECK_STREAM_PTR(14);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 14);
s->stream_ptr -= 2;
for (y = 0; y < 16; y++) {
} else {
/* need 10 more bytes */
- CHECK_STREAM_PTR(10);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 10);
if (s->stream_ptr[4] <= s->stream_ptr[5]) {
unsigned char P[4];
/* 4-color encoding */
- CHECK_STREAM_PTR(4);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 4);
memcpy(P, s->stream_ptr, 4);
s->stream_ptr += 4;
if (P[2] <= P[3]) {
/* 1 of 4 colors for each pixel, need 16 more bytes */
- CHECK_STREAM_PTR(16);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 16);
for (y = 0; y < 8; y++) {
/* get the next set of 8 2-bit flags */
uint32_t flags;
/* 1 of 4 colors for each 2x2 block, need 4 more bytes */
- CHECK_STREAM_PTR(4);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 4);
flags = bytestream_get_le32(&s->stream_ptr);
uint64_t flags;
/* 1 of 4 colors for each 2x1 or 1x2 block, need 8 more bytes */
- CHECK_STREAM_PTR(8);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 8);
flags = bytestream_get_le64(&s->stream_ptr);
if (P[2] <= P[3]) {
/* 4-color encoding for each 4x4 quadrant, or 4-color encoding on
* either top and bottom or left and right halves */
- CHECK_STREAM_PTR(24);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 24);
if (s->stream_ptr[0] <= s->stream_ptr[1]) {
/* 4-color encoding for each quadrant; need 32 bytes */
- CHECK_STREAM_PTR(32);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 32);
for (y = 0; y < 16; y++) {
// new values for each 4x4 block
int y;
/* 64-color encoding (each pixel in block is a different color) */
- CHECK_STREAM_PTR(64);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 64);
for (y = 0; y < 8; y++) {
memcpy(s->pixel_ptr, s->stream_ptr, 8);
int x, y;
/* 16-color block encoding: each 2x2 block is a different color */
- CHECK_STREAM_PTR(16);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 16);
for (y = 0; y < 8; y += 2) {
for (x = 0; x < 8; x += 2) {
unsigned char P[2];
/* 4-color block encoding: each 4x4 block is a different color */
- CHECK_STREAM_PTR(4);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 4);
for (y = 0; y < 8; y++) {
if (!(y & 3)) {
unsigned char pix;
/* 1-color encoding: the whole block is 1 solid color */
- CHECK_STREAM_PTR(1);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 1);
pix = *s->stream_ptr++;
for (y = 0; y < 8; y++) {
unsigned char sample[2];
/* dithered encoding */
- CHECK_STREAM_PTR(2);
+ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 2);
sample[0] = *s->stream_ptr++;
sample[1] = *s->stream_ptr++;