| 134 | | static av_always_inline void |
| 135 | | yuv2plane1_16_c_template(const int32_t *src, uint16_t *dest, int dstW, |
| 136 | | int big_endian, int output_bits) |
| 137 | | { |
| 138 | | int i; |
| 139 | | int shift = 3; |
| 140 | | av_assert0(output_bits == 16); |
| 141 | | |
| 142 | | for (i = 0; i < dstW; i++) { |
| 143 | | int val = src[i] + (1 << (shift - 1)); |
| 144 | | output_pixel(&dest[i], val, 0, uint); |
| 145 | | } |
| | 134 | #define yuv2NBPS16(bits, BE_LE, is_be, typeX_t) \ |
| | 135 | static void yuv2plane1_ ## bits ## BE_LE ## _c(const int16_t *src, \ |
| | 136 | uint8_t *dest, int dstW, \ |
| | 137 | const uint8_t *dither, int offset) \ |
| | 138 | { \ |
| | 139 | int i; \ |
| | 140 | int shift = 3; \ |
| | 141 | av_assert0(bits == 16); \ |
| | 142 | \ |
| | 143 | for (i = 0; i < dstW; i++) { \ |
| | 144 | int val = ((typeX_t *)src)[i] + (1 << (shift - 1)); \ |
| | 145 | output_pixel(is_be, &((uint16_t *)dest)[i], val, 0, uint); \ |
| | 146 | } \ |
| | 147 | } \ |
| | 148 | static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \ |
| | 149 | const int16_t **src, uint8_t *dest, int dstW, \ |
| | 150 | const uint8_t *dither, int offset) \ |
| | 151 | { \ |
| | 152 | int i; \ |
| | 153 | int shift = 15; \ |
| | 154 | av_assert0(bits == 16); \ |
| | 155 | \ |
| | 156 | for (i = 0; i < dstW; i++) { \ |
| | 157 | int val = 1 << (shift - 1); \ |
| | 158 | int j; \ |
| | 159 | \ |
| | 160 | /* range of val is [0,0x7FFFFFFF], so 31 bits, but with lanczos/spline \ |
| | 161 | * filters (or anything with negative coeffs, the range can be slightly \ |
| | 162 | * wider in both directions. To account for this overflow, we subtract \ |
| | 163 | * a constant so it always fits in the signed range (assuming a \ |
| | 164 | * reasonable filterSize), and re-add that at the end. */ \ |
| | 165 | val -= 0x40000000; \ |
| | 166 | for (j = 0; j < filterSize; j++) \ |
| | 167 | val += ((typeX_t **)src)[j][i] * filter[j]; \ |
| | 168 | \ |
| | 169 | output_pixel(is_be, &((uint16_t *)dest)[i], val, 0x8000, int); \ |
| | 170 | } \ |
| 148 | | static av_always_inline void |
| 149 | | yuv2planeX_16_c_template(const int16_t *filter, int filterSize, |
| 150 | | const int32_t **src, uint16_t *dest, int dstW, |
| 151 | | int big_endian, int output_bits) |
| 152 | | { |
| 153 | | int i; |
| 154 | | int shift = 15; |
| 155 | | av_assert0(output_bits == 16); |
| | 173 | yuv2NBPS16(16, BE, 1, int32_t) |
| | 174 | yuv2NBPS16(16, LE, 0, int32_t) |
| 157 | | for (i = 0; i < dstW; i++) { |
| 158 | | int val = 1 << (shift - 1); |
| 159 | | int j; |
| 160 | | |
| 161 | | /* range of val is [0,0x7FFFFFFF], so 31 bits, but with lanczos/spline |
| 162 | | * filters (or anything with negative coeffs, the range can be slightly |
| 163 | | * wider in both directions. To account for this overflow, we subtract |
| 164 | | * a constant so it always fits in the signed range (assuming a |
| 165 | | * reasonable filterSize), and re-add that at the end. */ |
| 166 | | val -= 0x40000000; |
| 167 | | for (j = 0; j < filterSize; j++) |
| 168 | | val += src[j][i] * filter[j]; |
| 169 | | |
| 170 | | output_pixel(&dest[i], val, 0x8000, int); |
| 171 | | } |
| 172 | | } |
| 173 | | |
| 183 | | static av_always_inline void |
| 184 | | yuv2plane1_10_c_template(const int16_t *src, uint16_t *dest, int dstW, |
| 185 | | int big_endian, int output_bits) |
| 186 | | { |
| 187 | | int i; |
| 188 | | int shift = 15 - output_bits; |
| 189 | | |
| 190 | | for (i = 0; i < dstW; i++) { |
| 191 | | int val = src[i] + (1 << (shift - 1)); |
| 192 | | output_pixel(&dest[i], val); |
| 193 | | } |
| 194 | | } |
| 195 | | |
| 196 | | static av_always_inline void |
| 197 | | yuv2planeX_10_c_template(const int16_t *filter, int filterSize, |
| 198 | | const int16_t **src, uint16_t *dest, int dstW, |
| 199 | | int big_endian, int output_bits) |
| 200 | | { |
| 201 | | int i; |
| 202 | | int shift = 11 + 16 - output_bits; |
| 203 | | |
| 204 | | for (i = 0; i < dstW; i++) { |
| 205 | | int val = 1 << (shift - 1); |
| 206 | | int j; |
| 207 | | |
| 208 | | for (j = 0; j < filterSize; j++) |
| 209 | | val += src[j][i] * filter[j]; |
| 210 | | |
| 211 | | output_pixel(&dest[i], val); |
| 212 | | } |
| 213 | | } |
| 214 | | |
| 215 | | #undef output_pixel |
| 216 | | |
| 217 | | #define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t) \ |
| | 185 | #define yuv2NBPS10(bits, BE_LE, is_be, typeX_t) \ |
| 229 | | yuv2planeX_## template_size ## _c_template(filter, \ |
| 230 | | filterSize, (const typeX_t **) src, \ |
| 231 | | (uint16_t *) dest, dstW, is_be, bits); \ |
| | 202 | int i; \ |
| | 203 | int shift = 11 + 16 - bits; \ |
| | 204 | \ |
| | 205 | for (i = 0; i < dstW; i++) { \ |
| | 206 | int val = 1 << (shift - 1); \ |
| | 207 | int j; \ |
| | 208 | \ |
| | 209 | for (j = 0; j < filterSize; j++) \ |
| | 210 | val += ((const typeX_t **)src)[j][i] * filter[j]; \ |
| | 211 | \ |
| | 212 | output_pixel(is_be, bits, &((uint16_t *)dest)[i], val); \ |
| | 213 | } \ |
| 233 | | yuv2NBPS( 9, BE, 1, 10, int16_t) |
| 234 | | yuv2NBPS( 9, LE, 0, 10, int16_t) |
| 235 | | yuv2NBPS(10, BE, 1, 10, int16_t) |
| 236 | | yuv2NBPS(10, LE, 0, 10, int16_t) |
| 237 | | yuv2NBPS(16, BE, 1, 16, int32_t) |
| 238 | | yuv2NBPS(16, LE, 0, 16, int32_t) |
| | 216 | yuv2NBPS10( 9, BE, 1, int16_t) |
| | 217 | yuv2NBPS10( 9, LE, 0, int16_t) |
| | 218 | yuv2NBPS10(10, BE, 1, int16_t) |
| | 219 | yuv2NBPS10(10, LE, 0, int16_t) |
| | 220 | |
| | 221 | #undef output_pixel |
| | 222 | |