| 124 | } |
| 125 | |
| 126 | static void unpack_frame(AVCodecContext *avctx, AVFrame *p, const uint8_t *buf, |
| 127 | int elements, int endian) |
| 128 | { |
| 129 | int i, x, y; |
| 130 | DPXDecContext *dpx = avctx->priv_data; |
| 131 | |
| 132 | uint8_t *ptr[AV_NUM_DATA_POINTERS]; |
| 133 | unsigned int rgbBuffer = 0; |
| 134 | int n_datum = 0; |
| 135 | |
| 136 | for (i=0; i<AV_NUM_DATA_POINTERS; i++) |
| 137 | ptr[i] = p->data[i]; |
| 138 | |
| 139 | switch (avctx->bits_per_raw_sample) { |
| 140 | case 10: |
| 141 | for (x = 0; x < avctx->height; x++) { |
| 142 | uint16_t *dst[4] = {(uint16_t*)ptr[0], |
| 143 | (uint16_t*)ptr[1], |
| 144 | (uint16_t*)ptr[2], |
| 145 | (uint16_t*)ptr[3]}; |
| 146 | int shift = elements > 1 ? dpx->packing == 1 ? 22 : 20 : dpx->packing == 1 ? 2 : 0; |
| 147 | for (y = 0; y < avctx->width; y++) { |
| 148 | if (elements >= 3) |
| 149 | *dst[2]++ = read10in32(&buf, &rgbBuffer, |
| 150 | &n_datum, endian, shift); |
| 151 | if (elements == 1) |
| 152 | *dst[0]++ = read10in32_gray(&buf, &rgbBuffer, |
| 153 | &n_datum, endian, shift); |
| 154 | else |
| 155 | *dst[0]++ = read10in32(&buf, &rgbBuffer, |
| 156 | &n_datum, endian, shift); |
| 157 | if (elements >= 2) |
| 158 | *dst[1]++ = read10in32(&buf, &rgbBuffer, |
| 159 | &n_datum, endian, shift); |
| 160 | if (elements == 4) |
| 161 | *dst[3]++ = |
| 162 | read10in32(&buf, &rgbBuffer, |
| 163 | &n_datum, endian, shift); |
| 164 | } |
| 165 | if (!dpx->unpadded_10bit) |
| 166 | n_datum = 0; |
| 167 | for (i = 0; i < elements; i++) |
| 168 | ptr[i] += p->linesize[i]; |
| 169 | } |
| 170 | break; |
| 171 | case 12: |
| 172 | for (x = 0; x < avctx->height; x++) { |
| 173 | uint16_t *dst[4] = {(uint16_t*)ptr[0], |
| 174 | (uint16_t*)ptr[1], |
| 175 | (uint16_t*)ptr[2], |
| 176 | (uint16_t*)ptr[3]}; |
| 177 | int shift = dpx->packing == 1 ? 4 : 0; |
| 178 | for (y = 0; y < avctx->width; y++) { |
| 179 | if (dpx->packing) { |
| 180 | if (elements >= 3) |
| 181 | *dst[2]++ = read16(&buf, endian) >> shift & 0xFFF; |
| 182 | *dst[0]++ = read16(&buf, endian) >> shift & 0xFFF; |
| 183 | if (elements >= 2) |
no test coverage detected