| 74 | } CinepakContext; |
| 75 | |
| 76 | static void cinepak_decode_codebook (cvid_codebook *codebook, |
| 77 | int chunk_id, int size, const uint8_t *data) |
| 78 | { |
| 79 | const uint8_t *eod = (data + size); |
| 80 | uint32_t flag, mask; |
| 81 | int i, n; |
| 82 | uint8_t *p; |
| 83 | |
| 84 | /* check if this chunk contains 4- or 6-element vectors */ |
| 85 | n = (chunk_id & 0x04) ? 4 : 6; |
| 86 | flag = 0; |
| 87 | mask = 0; |
| 88 | |
| 89 | p = codebook[0]; |
| 90 | for (i=0; i < 256; i++) { |
| 91 | if ((chunk_id & 0x01) && !(mask >>= 1)) { |
| 92 | if ((data + 4) > eod) |
| 93 | break; |
| 94 | |
| 95 | flag = AV_RB32 (data); |
| 96 | data += 4; |
| 97 | mask = 0x80000000; |
| 98 | } |
| 99 | |
| 100 | if (!(chunk_id & 0x01) || (flag & mask)) { |
| 101 | int k, kk; |
| 102 | |
| 103 | if ((data + n) > eod) |
| 104 | break; |
| 105 | |
| 106 | for (k = 0; k < 4; ++k) { |
| 107 | int r = *data++; |
| 108 | for (kk = 0; kk < 3; ++kk) |
| 109 | *p++ = r; |
| 110 | } |
| 111 | if (n == 6) { |
| 112 | int r, g, b, u, v; |
| 113 | u = *(int8_t *)data++; |
| 114 | v = *(int8_t *)data++; |
| 115 | p -= 12; |
| 116 | for(k=0; k<4; ++k) { |
| 117 | r = *p++ + v*2; |
| 118 | g = *p++ - (u/2) - v; |
| 119 | b = *p + u*2; |
| 120 | p -= 2; |
| 121 | *p++ = av_clip_uint8(r); |
| 122 | *p++ = av_clip_uint8(g); |
| 123 | *p++ = av_clip_uint8(b); |
| 124 | } |
| 125 | } |
| 126 | } else { |
| 127 | p += 12; |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | static int cinepak_decode_vectors (CinepakContext *s, cvid_strip *strip, |
| 133 | int chunk_id, int size, const uint8_t *data) |
no outgoing calls
no test coverage detected