for (x = 0; x < w; x++) {
int diff, context, sign;
+ if (!(x & 1023)) {
+ if (is_input_end(s))
+ return AVERROR_INVALIDDATA;
+ }
+
context = RENAME(get_context)(p, sample[1] + x, sample[0] + x, sample[1] + x);
if (context < 0) {
context = -context;
run_mode = 2;
}
}
+ if (sample[1][x - 1] == sample[0][x - 1]) {
+ while (run_count > 1 && w-x > 1) {
+ sample[1][x] = sample[0][x];
+ x++;
+ run_count--;
+ }
+ } else {
+ while (run_count > 1 && w-x > 1) {
+ sample[1][x] = RENAME(predict)(sample[1] + x, sample[0] + x);
+ x++;
+ run_count--;
+ }
+ }
run_count--;
if (run_count < 0) {
run_mode = 0;
return 0;
}
-static void RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[4], int w, int h, int stride[4])
+static int RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[4], int w, int h, int stride[4])
{
int x, y, p;
TYPE *sample[4][2];
for (y = 0; y < h; y++) {
for (p = 0; p < 3 + transparency; p++) {
+ int ret;
TYPE *temp = sample[p][0]; // FIXME: try a normal buffer
sample[p][0] = sample[p][1];
sample[p][1][-1]= sample[p][0][0 ];
sample[p][0][ w]= sample[p][0][w-1];
if (lbd && s->slice_coding_mode == 0)
- RENAME(decode_line)(s, w, sample[p], (p + 1)/2, 9);
+ ret = RENAME(decode_line)(s, w, sample[p], (p + 1)/2, 9);
else
- RENAME(decode_line)(s, w, sample[p], (p + 1)/2, bits + (s->slice_coding_mode != 1));
+ ret = RENAME(decode_line)(s, w, sample[p], (p + 1)/2, bits + (s->slice_coding_mode != 1));
+ if (ret < 0)
+ return ret;
}
for (x = 0; x < w; x++) {
int g = sample[0][1][x];
if (lbd)
*((uint32_t*)(src[0] + x*4 + stride[0]*y)) = b + ((unsigned)g<<8) + ((unsigned)r<<16) + ((unsigned)a<<24);
- else if (sizeof(TYPE) == 4) {
+ else if (sizeof(TYPE) == 4 || transparency) {
*((uint16_t*)(src[0] + x*2 + stride[0]*y)) = g;
*((uint16_t*)(src[1] + x*2 + stride[1]*y)) = b;
*((uint16_t*)(src[2] + x*2 + stride[2]*y)) = r;
*((uint16_t*)(src[0] + x*2 + stride[0]*y)) = b;
*((uint16_t*)(src[1] + x*2 + stride[1]*y)) = g;
*((uint16_t*)(src[2] + x*2 + stride[2]*y)) = r;
- if (transparency)
- *((uint16_t*)(src[3] + x*2 + stride[3]*y)) = a;
}
}
}
+ return 0;
}