| 46 | } |
| 47 | |
| 48 | static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride, |
| 49 | const uint8_t *table) |
| 50 | { |
| 51 | int i; |
| 52 | int j; |
| 53 | int out = 0; |
| 54 | int c; |
| 55 | int t; |
| 56 | |
| 57 | if(width&1) |
| 58 | return -1; |
| 59 | |
| 60 | /* first line contain absolute values, other lines contain deltas */ |
| 61 | while (out < width){ |
| 62 | c = ir2_get_code(&ctx->gb); |
| 63 | if(c >= 0x80) { /* we have a run */ |
| 64 | c -= 0x7F; |
| 65 | if(out + c*2 > width) |
| 66 | return -1; |
| 67 | for (i = 0; i < c * 2; i++) |
| 68 | dst[out++] = 0x80; |
| 69 | } else { /* copy two values from table */ |
| 70 | dst[out++] = table[c * 2]; |
| 71 | dst[out++] = table[(c * 2) + 1]; |
| 72 | } |
| 73 | } |
| 74 | dst += stride; |
| 75 | |
| 76 | for (j = 1; j < height; j++){ |
| 77 | out = 0; |
| 78 | while (out < width){ |
| 79 | c = ir2_get_code(&ctx->gb); |
| 80 | if(c >= 0x80) { /* we have a skip */ |
| 81 | c -= 0x7F; |
| 82 | if(out + c*2 > width) |
| 83 | return -1; |
| 84 | for (i = 0; i < c * 2; i++) { |
| 85 | dst[out] = dst[out - stride]; |
| 86 | out++; |
| 87 | } |
| 88 | } else { /* add two deltas from table */ |
| 89 | t = dst[out - stride] + (table[c * 2] - 128); |
| 90 | t= av_clip_uint8(t); |
| 91 | dst[out] = t; |
| 92 | out++; |
| 93 | t = dst[out - stride] + (table[(c * 2) + 1] - 128); |
| 94 | t= av_clip_uint8(t); |
| 95 | dst[out] = t; |
| 96 | out++; |
| 97 | } |
| 98 | } |
| 99 | dst += stride; |
| 100 | } |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | static int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride, |
| 105 | const uint8_t *table) |
no test coverage detected