| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * software RGB to RGB converter | ||
| 3 | * pluralize by software PAL8 to RGB converter | ||
| 4 | * software YUV to YUV converter | ||
| 5 | * software YUV to RGB converter | ||
| 6 | * Written by Nick Kurshev. | ||
| 7 | * palette & YUV & runtime CPU stuff by Michael (michaelni@gmx.at) | ||
| 8 | * | ||
| 9 | * This file is part of FFmpeg. | ||
| 10 | * | ||
| 11 | * FFmpeg is free software; you can redistribute it and/or | ||
| 12 | * modify it under the terms of the GNU Lesser General Public | ||
| 13 | * License as published by the Free Software Foundation; either | ||
| 14 | * version 2.1 of the License, or (at your option) any later version. | ||
| 15 | * | ||
| 16 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 19 | * Lesser General Public License for more details. | ||
| 20 | * | ||
| 21 | * You should have received a copy of the GNU Lesser General Public | ||
| 22 | * License along with FFmpeg; if not, write to the Free Software | ||
| 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <inttypes.h> | ||
| 27 | |||
| 28 | #include "libavutil/attributes.h" | ||
| 29 | #include "libavutil/bswap.h" | ||
| 30 | #include "config.h" | ||
| 31 | #include "rgb2rgb.h" | ||
| 32 | #include "swscale.h" | ||
| 33 | #include "swscale_internal.h" | ||
| 34 | |||
| 35 | void (*rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 36 | void (*rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 37 | void (*rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 38 | void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 39 | void (*rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 40 | void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 41 | void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 42 | void (*rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 43 | void (*rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 44 | |||
| 45 | void (*rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 46 | void (*rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 47 | void (*rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 48 | void (*rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 49 | void (*rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 50 | void (*rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 51 | void (*rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 52 | void (*rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 53 | |||
| 54 | void (*shuffle_bytes_0321)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 55 | void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 56 | void (*shuffle_bytes_1230)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 57 | void (*shuffle_bytes_3012)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 58 | void (*shuffle_bytes_3210)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 59 | void (*shuffle_bytes_3102)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 60 | void (*shuffle_bytes_2013)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 61 | void (*shuffle_bytes_2130)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 62 | void (*shuffle_bytes_1203)(const uint8_t *src, uint8_t *dst, int src_size); | ||
| 63 | |||
| 64 | |||
| 65 | void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, | ||
| 66 | const uint8_t *vsrc, uint8_t *dst, | ||
| 67 | int width, int height, | ||
| 68 | int lumStride, int chromStride, int dstStride); | ||
| 69 | void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, | ||
| 70 | const uint8_t *vsrc, uint8_t *dst, | ||
| 71 | int width, int height, | ||
| 72 | int lumStride, int chromStride, int dstStride); | ||
| 73 | void (*yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, | ||
| 74 | const uint8_t *vsrc, uint8_t *dst, | ||
| 75 | int width, int height, | ||
| 76 | int lumStride, int chromStride, int dstStride); | ||
| 77 | void (*yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, | ||
| 78 | const uint8_t *vsrc, uint8_t *dst, | ||
| 79 | int width, int height, | ||
| 80 | int lumStride, int chromStride, int dstStride); | ||
| 81 | void (*ff_rgb24toyv12)(const uint8_t *src, uint8_t *ydst, | ||
| 82 | uint8_t *udst, uint8_t *vdst, | ||
| 83 | int width, int height, | ||
| 84 | int lumStride, int chromStride, int srcStride, | ||
| 85 | const int32_t *rgb2yuv); | ||
| 86 | void (*planar2x)(const uint8_t *src, uint8_t *dst, int width, int height, | ||
| 87 | int srcStride, int dstStride); | ||
| 88 | void (*interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, | ||
| 89 | int width, int height, int src1Stride, | ||
| 90 | int src2Stride, int dstStride); | ||
| 91 | void (*deinterleaveBytes)(const uint8_t *src, uint8_t *dst1, uint8_t *dst2, | ||
| 92 | int width, int height, int srcStride, | ||
| 93 | int dst1Stride, int dst2Stride); | ||
| 94 | void (*uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | ||
| 95 | const uint8_t *src, int width, int height, | ||
| 96 | int lumStride, int chromStride, int srcStride); | ||
| 97 | void (*uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | ||
| 98 | const uint8_t *src, int width, int height, | ||
| 99 | int lumStride, int chromStride, int srcStride); | ||
| 100 | void (*yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | ||
| 101 | const uint8_t *src, int width, int height, | ||
| 102 | int lumStride, int chromStride, int srcStride); | ||
| 103 | void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | ||
| 104 | const uint8_t *src, int width, int height, | ||
| 105 | int lumStride, int chromStride, int srcStride); | ||
| 106 | |||
| 107 | #define BY ((int)( 0.098 * (1 << RGB2YUV_SHIFT) + 0.5)) | ||
| 108 | #define BV ((int)(-0.071 * (1 << RGB2YUV_SHIFT) + 0.5)) | ||
| 109 | #define BU ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5)) | ||
| 110 | #define GY ((int)( 0.504 * (1 << RGB2YUV_SHIFT) + 0.5)) | ||
| 111 | #define GV ((int)(-0.368 * (1 << RGB2YUV_SHIFT) + 0.5)) | ||
| 112 | #define GU ((int)(-0.291 * (1 << RGB2YUV_SHIFT) + 0.5)) | ||
| 113 | #define RY ((int)( 0.257 * (1 << RGB2YUV_SHIFT) + 0.5)) | ||
| 114 | #define RV ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5)) | ||
| 115 | #define RU ((int)(-0.148 * (1 << RGB2YUV_SHIFT) + 0.5)) | ||
| 116 | |||
| 117 | //plain C versions | ||
| 118 | #include "rgb2rgb_template.c" | ||
| 119 | |||
| 120 | /* | ||
| 121 | * RGB15->RGB16 original by Strepto/Astral | ||
| 122 | * ported to gcc & bugfixed : A'rpi | ||
| 123 | * MMXEXT, 3DNOW optimization by Nick Kurshev | ||
| 124 | * 32-bit C version, and and&add trick by Michael Niedermayer | ||
| 125 | */ | ||
| 126 | |||
| 127 | 5019 | av_cold void ff_sws_rgb2rgb_init(void) | |
| 128 | { | ||
| 129 | 5019 | rgb2rgb_init_c(); | |
| 130 | #if ARCH_AARCH64 | ||
| 131 | rgb2rgb_init_aarch64(); | ||
| 132 | #elif ARCH_RISCV | ||
| 133 | rgb2rgb_init_riscv(); | ||
| 134 | #elif ARCH_X86 | ||
| 135 | 5019 | rgb2rgb_init_x86(); | |
| 136 | #elif ARCH_LOONGARCH64 | ||
| 137 | rgb2rgb_init_loongarch(); | ||
| 138 | #endif | ||
| 139 | 5019 | } | |
| 140 | |||
| 141 | 51094 | void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size) | |
| 142 | { | ||
| 143 | 51094 | int i, num_pixels = src_size >> 2; | |
| 144 | |||
| 145 |
2/2✓ Branch 0 taken 119440500 times.
✓ Branch 1 taken 51094 times.
|
119491594 | for (i = 0; i < num_pixels; i++) { |
| 146 | #if HAVE_BIGENDIAN | ||
| 147 | /* RGB32 (= A,B,G,R) -> BGR24 (= B,G,R) */ | ||
| 148 | dst[3 * i + 0] = src[4 * i + 1]; | ||
| 149 | dst[3 * i + 1] = src[4 * i + 2]; | ||
| 150 | dst[3 * i + 2] = src[4 * i + 3]; | ||
| 151 | #else | ||
| 152 | 119440500 | dst[3 * i + 0] = src[4 * i + 2]; | |
| 153 | 119440500 | dst[3 * i + 1] = src[4 * i + 1]; | |
| 154 | 119440500 | dst[3 * i + 2] = src[4 * i + 0]; | |
| 155 | #endif | ||
| 156 | } | ||
| 157 | 51094 | } | |
| 158 | |||
| 159 | 72 | void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size) | |
| 160 | { | ||
| 161 | int i; | ||
| 162 | |||
| 163 |
2/2✓ Branch 0 taken 354744 times.
✓ Branch 1 taken 72 times.
|
354816 | for (i = 0; 3 * i < src_size; i++) { |
| 164 | #if HAVE_BIGENDIAN | ||
| 165 | /* RGB24 (= R, G, B) -> BGR32 (= A, R, G, B) */ | ||
| 166 | dst[4 * i + 0] = 255; | ||
| 167 | dst[4 * i + 1] = src[3 * i + 0]; | ||
| 168 | dst[4 * i + 2] = src[3 * i + 1]; | ||
| 169 | dst[4 * i + 3] = src[3 * i + 2]; | ||
| 170 | #else | ||
| 171 | 354744 | dst[4 * i + 0] = src[3 * i + 2]; | |
| 172 | 354744 | dst[4 * i + 1] = src[3 * i + 1]; | |
| 173 | 354744 | dst[4 * i + 2] = src[3 * i + 0]; | |
| 174 | 354744 | dst[4 * i + 3] = 255; | |
| 175 | #endif | ||
| 176 | } | ||
| 177 | 72 | } | |
| 178 | |||
| 179 | ✗ | void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size) | |
| 180 | { | ||
| 181 | ✗ | uint8_t *d = dst; | |
| 182 | ✗ | const uint16_t *s = (const uint16_t *)src; | |
| 183 | ✗ | const uint16_t *end = s + src_size / 2; | |
| 184 | |||
| 185 | ✗ | while (s < end) { | |
| 186 | ✗ | register uint16_t bgr = *s++; | |
| 187 | #if HAVE_BIGENDIAN | ||
| 188 | *d++ = 255; | ||
| 189 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | ||
| 190 | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); | ||
| 191 | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); | ||
| 192 | #else | ||
| 193 | ✗ | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); | |
| 194 | ✗ | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); | |
| 195 | ✗ | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |
| 196 | ✗ | *d++ = 255; | |
| 197 | #endif | ||
| 198 | } | ||
| 199 | ✗ | } | |
| 200 | |||
| 201 | ✗ | void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size) | |
| 202 | { | ||
| 203 | uint16_t rgb, r, g, b; | ||
| 204 | ✗ | uint16_t *d = (uint16_t *)dst; | |
| 205 | ✗ | const uint16_t *s = (const uint16_t *)src; | |
| 206 | ✗ | const uint16_t *end = s + src_size / 2; | |
| 207 | |||
| 208 | ✗ | while (s < end) { | |
| 209 | ✗ | rgb = *s++; | |
| 210 | ✗ | r = rgb & 0xF00; | |
| 211 | ✗ | g = rgb & 0x0F0; | |
| 212 | ✗ | b = rgb & 0x00F; | |
| 213 | ✗ | r = (r << 3) | ((r & 0x800) >> 1); | |
| 214 | ✗ | g = (g << 2) | ((g & 0x080) >> 2); | |
| 215 | ✗ | b = (b << 1) | ( b >> 3); | |
| 216 | ✗ | *d++ = r | g | b; | |
| 217 | } | ||
| 218 | ✗ | } | |
| 219 | |||
| 220 | 1944 | void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size) | |
| 221 | { | ||
| 222 | 1944 | uint8_t *d = dst; | |
| 223 | 1944 | const uint16_t *s = (const uint16_t *)src; | |
| 224 | 1944 | const uint16_t *end = s + src_size / 2; | |
| 225 | |||
| 226 |
2/2✓ Branch 0 taken 22091776 times.
✓ Branch 1 taken 1944 times.
|
22093720 | while (s < end) { |
| 227 | 22091776 | register uint16_t bgr = *s++; | |
| 228 | 22091776 | *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13); | |
| 229 | 22091776 | *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9); | |
| 230 | 22091776 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |
| 231 | } | ||
| 232 | 1944 | } | |
| 233 | |||
| 234 | ✗ | void rgb16tobgr16(const uint8_t *src, uint8_t *dst, int src_size) | |
| 235 | { | ||
| 236 | ✗ | int i, num_pixels = src_size >> 1; | |
| 237 | |||
| 238 | ✗ | for (i = 0; i < num_pixels; i++) { | |
| 239 | ✗ | unsigned rgb = ((const uint16_t *)src)[i]; | |
| 240 | ✗ | ((uint16_t *)dst)[i] = (rgb >> 11) | (rgb & 0x7E0) | (rgb << 11); | |
| 241 | } | ||
| 242 | ✗ | } | |
| 243 | |||
| 244 | ✗ | void rgb16tobgr15(const uint8_t *src, uint8_t *dst, int src_size) | |
| 245 | { | ||
| 246 | ✗ | int i, num_pixels = src_size >> 1; | |
| 247 | |||
| 248 | ✗ | for (i = 0; i < num_pixels; i++) { | |
| 249 | ✗ | unsigned rgb = ((const uint16_t *)src)[i]; | |
| 250 | ✗ | ((uint16_t *)dst)[i] = (rgb >> 11) | ((rgb & 0x7C0) >> 1) | ((rgb & 0x1F) << 10); | |
| 251 | } | ||
| 252 | ✗ | } | |
| 253 | |||
| 254 | ✗ | void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size) | |
| 255 | { | ||
| 256 | ✗ | uint8_t *d = dst; | |
| 257 | ✗ | const uint16_t *s = (const uint16_t *)src; | |
| 258 | ✗ | const uint16_t *end = s + src_size / 2; | |
| 259 | |||
| 260 | ✗ | while (s < end) { | |
| 261 | ✗ | register uint16_t bgr = *s++; | |
| 262 | #if HAVE_BIGENDIAN | ||
| 263 | *d++ = 255; | ||
| 264 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | ||
| 265 | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); | ||
| 266 | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); | ||
| 267 | #else | ||
| 268 | ✗ | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); | |
| 269 | ✗ | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); | |
| 270 | ✗ | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |
| 271 | ✗ | *d++ = 255; | |
| 272 | #endif | ||
| 273 | } | ||
| 274 | ✗ | } | |
| 275 | |||
| 276 | 122443 | void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size) | |
| 277 | { | ||
| 278 | 122443 | uint8_t *d = dst; | |
| 279 | 122443 | const uint16_t *s = (const uint16_t *)src; | |
| 280 | 122443 | const uint16_t *end = s + src_size / 2; | |
| 281 | |||
| 282 |
2/2✓ Branch 0 taken 124259296 times.
✓ Branch 1 taken 122443 times.
|
124381739 | while (s < end) { |
| 283 | 124259296 | register uint16_t bgr = *s++; | |
| 284 | 124259296 | *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12); | |
| 285 | 124259296 | *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7); | |
| 286 | 124259296 | *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2); | |
| 287 | } | ||
| 288 | 122443 | } | |
| 289 | |||
| 290 | ✗ | void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size) | |
| 291 | { | ||
| 292 | ✗ | int i, num_pixels = src_size >> 1; | |
| 293 | |||
| 294 | ✗ | for (i = 0; i < num_pixels; i++) { | |
| 295 | ✗ | unsigned rgb = ((const uint16_t *)src)[i]; | |
| 296 | ✗ | ((uint16_t *)dst)[i] = ((rgb & 0x7C00) >> 10) | ((rgb & 0x3E0) << 1) | (rgb << 11); | |
| 297 | } | ||
| 298 | ✗ | } | |
| 299 | |||
| 300 | ✗ | void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size) | |
| 301 | { | ||
| 302 | ✗ | int i, num_pixels = src_size >> 1; | |
| 303 | |||
| 304 | ✗ | for (i = 0; i < num_pixels; i++) { | |
| 305 | ✗ | unsigned rgb = ((const uint16_t *)src)[i]; | |
| 306 | ✗ | unsigned br = rgb & 0x7C1F; | |
| 307 | ✗ | ((uint16_t *)dst)[i] = (br >> 10) | (rgb & 0x3E0) | (br << 10); | |
| 308 | } | ||
| 309 | ✗ | } | |
| 310 | |||
| 311 | ✗ | void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size) | |
| 312 | { | ||
| 313 | ✗ | uint16_t *d = (uint16_t *)dst; | |
| 314 | ✗ | const uint16_t *s = (const uint16_t *)src; | |
| 315 | ✗ | int i, num_pixels = src_size >> 1; | |
| 316 | |||
| 317 | ✗ | for (i = 0; i < num_pixels; i++) { | |
| 318 | ✗ | unsigned rgb = s[i]; | |
| 319 | ✗ | d[i] = (rgb << 8 | rgb & 0xF0 | rgb >> 8) & 0xFFF; | |
| 320 | } | ||
| 321 | ✗ | } | |
| 322 | |||
| 323 | #define DEFINE_RGB48TOBGR48(need_bswap, swap) \ | ||
| 324 | void rgb48tobgr48_ ## need_bswap(const uint8_t *src, \ | ||
| 325 | uint8_t *dst, int src_size) \ | ||
| 326 | { \ | ||
| 327 | uint16_t *d = (uint16_t *)dst; \ | ||
| 328 | const uint16_t *s = (const uint16_t *)src; \ | ||
| 329 | int i, num_pixels = src_size >> 1; \ | ||
| 330 | \ | ||
| 331 | for (i = 0; i < num_pixels; i += 3) { \ | ||
| 332 | d[i ] = swap ? av_bswap16(s[i + 2]) : s[i + 2]; \ | ||
| 333 | d[i + 1] = swap ? av_bswap16(s[i + 1]) : s[i + 1]; \ | ||
| 334 | d[i + 2] = swap ? av_bswap16(s[i ]) : s[i ]; \ | ||
| 335 | } \ | ||
| 336 | } | ||
| 337 | |||
| 338 |
2/2✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 4 times.
|
36868 | DEFINE_RGB48TOBGR48(nobswap, 0) |
| 339 |
2/2✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 4 times.
|
36868 | DEFINE_RGB48TOBGR48(bswap, 1) |
| 340 | |||
| 341 | #define DEFINE_RGB64TOBGR48(need_bswap, swap) \ | ||
| 342 | void rgb64tobgr48_ ## need_bswap(const uint8_t *src, \ | ||
| 343 | uint8_t *dst, int src_size) \ | ||
| 344 | { \ | ||
| 345 | uint16_t *d = (uint16_t *)dst; \ | ||
| 346 | const uint16_t *s = (const uint16_t *)src; \ | ||
| 347 | int i, num_pixels = src_size >> 3; \ | ||
| 348 | \ | ||
| 349 | for (i = 0; i < num_pixels; i++) { \ | ||
| 350 | d[3 * i ] = swap ? av_bswap16(s[4 * i + 2]) : s[4 * i + 2]; \ | ||
| 351 | d[3 * i + 1] = swap ? av_bswap16(s[4 * i + 1]) : s[4 * i + 1]; \ | ||
| 352 | d[3 * i + 2] = swap ? av_bswap16(s[4 * i ]) : s[4 * i ]; \ | ||
| 353 | } \ | ||
| 354 | } | ||
| 355 | |||
| 356 |
2/2✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 2 times.
|
18434 | DEFINE_RGB64TOBGR48(nobswap, 0) |
| 357 |
2/2✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 2 times.
|
18434 | DEFINE_RGB64TOBGR48(bswap, 1) |
| 358 | |||
| 359 | #define DEFINE_RGB64TO48(need_bswap, swap) \ | ||
| 360 | void rgb64to48_ ## need_bswap(const uint8_t *src, \ | ||
| 361 | uint8_t *dst, int src_size) \ | ||
| 362 | { \ | ||
| 363 | uint16_t *d = (uint16_t *)dst; \ | ||
| 364 | const uint16_t *s = (const uint16_t *)src; \ | ||
| 365 | int i, num_pixels = src_size >> 3; \ | ||
| 366 | \ | ||
| 367 | for (i = 0; i < num_pixels; i++) { \ | ||
| 368 | d[3 * i ] = swap ? av_bswap16(s[4 * i ]) : s[4 * i ]; \ | ||
| 369 | d[3 * i + 1] = swap ? av_bswap16(s[4 * i + 1]) : s[4 * i + 1]; \ | ||
| 370 | d[3 * i + 2] = swap ? av_bswap16(s[4 * i + 2]) : s[4 * i + 2]; \ | ||
| 371 | } \ | ||
| 372 | } | ||
| 373 | |||
| 374 |
2/2✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 2 times.
|
18434 | DEFINE_RGB64TO48(nobswap, 0) |
| 375 |
2/2✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 2 times.
|
18434 | DEFINE_RGB64TO48(bswap, 1) |
| 376 | |||
| 377 | #define DEFINE_RGB48TOBGR64(need_bswap, swap) \ | ||
| 378 | void rgb48tobgr64_ ## need_bswap(const uint8_t *src, \ | ||
| 379 | uint8_t *dst, int src_size) \ | ||
| 380 | { \ | ||
| 381 | uint16_t *d = (uint16_t *)dst; \ | ||
| 382 | const uint16_t *s = (const uint16_t *)src; \ | ||
| 383 | int i, num_pixels = src_size / 6; \ | ||
| 384 | \ | ||
| 385 | for (i = 0; i < num_pixels; i++) { \ | ||
| 386 | d[4 * i ] = swap ? av_bswap16(s[3 * i + 2]) : s[3 * i + 2]; \ | ||
| 387 | d[4 * i + 1] = swap ? av_bswap16(s[3 * i + 1]) : s[3 * i + 1]; \ | ||
| 388 | d[4 * i + 2] = swap ? av_bswap16(s[3 * i ]) : s[3 * i ]; \ | ||
| 389 | d[4 * i + 3] = 0xFFFF; \ | ||
| 390 | } \ | ||
| 391 | } | ||
| 392 | |||
| 393 |
2/2✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 2 times.
|
18434 | DEFINE_RGB48TOBGR64(nobswap, 0) |
| 394 |
2/2✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 2 times.
|
18434 | DEFINE_RGB48TOBGR64(bswap, 1) |
| 395 | |||
| 396 | #define DEFINE_RGB48TO64(need_bswap, swap) \ | ||
| 397 | void rgb48to64_ ## need_bswap(const uint8_t *src, \ | ||
| 398 | uint8_t *dst, int src_size) \ | ||
| 399 | { \ | ||
| 400 | uint16_t *d = (uint16_t *)dst; \ | ||
| 401 | const uint16_t *s = (const uint16_t *)src; \ | ||
| 402 | int i, num_pixels = src_size / 6; \ | ||
| 403 | \ | ||
| 404 | for (i = 0; i < num_pixels; i++) { \ | ||
| 405 | d[4 * i ] = swap ? av_bswap16(s[3 * i ]) : s[3 * i ]; \ | ||
| 406 | d[4 * i + 1] = swap ? av_bswap16(s[3 * i + 1]) : s[3 * i + 1]; \ | ||
| 407 | d[4 * i + 2] = swap ? av_bswap16(s[3 * i + 2]) : s[3 * i + 2]; \ | ||
| 408 | d[4 * i + 3] = 0xFFFF; \ | ||
| 409 | } \ | ||
| 410 | } | ||
| 411 | |||
| 412 |
2/2✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 2 times.
|
18434 | DEFINE_RGB48TO64(nobswap, 0) |
| 413 |
2/2✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 2 times.
|
18434 | DEFINE_RGB48TO64(bswap, 1) |
| 414 | |||
| 415 | #define DEFINE_X2RGB10TO16(need_bswap, swap, bits, alpha) \ | ||
| 416 | void x2rgb10to ## bits ## _ ## need_bswap(const uint8_t *src, \ | ||
| 417 | uint8_t *dst, int src_size) \ | ||
| 418 | { \ | ||
| 419 | uint16_t *d = (uint16_t *)dst; \ | ||
| 420 | const uint32_t *s = (const uint32_t *)src; \ | ||
| 421 | int i, num_pixels = src_size >> 2; \ | ||
| 422 | unsigned component; \ | ||
| 423 | \ | ||
| 424 | for (i = 0; i < num_pixels; i++) { \ | ||
| 425 | unsigned p = AV_RL32(s + i); \ | ||
| 426 | component = (p >> 20) & 0x3FF; \ | ||
| 427 | d[(3 + alpha) * i + 0] = swap ? av_bswap16(component << 6 | component >> 4) \ | ||
| 428 | : component << 6 | component >> 4; \ | ||
| 429 | component = (p >> 10) & 0x3FF; \ | ||
| 430 | d[(3 + alpha) * i + 1] = swap ? av_bswap16(component << 6 | component >> 4) \ | ||
| 431 | : component << 6 | component >> 4; \ | ||
| 432 | component = p & 0x3FF; \ | ||
| 433 | d[(3 + alpha) * i + 2] = swap ? av_bswap16(component << 6 | component >> 4) \ | ||
| 434 | : component << 6 | component >> 4; \ | ||
| 435 | if (alpha) d[(3 + alpha) * i + 3] = 0xffff; \ | ||
| 436 | } \ | ||
| 437 | } | ||
| 438 | |||
| 439 |
2/2✓ Branch 0 taken 2644992 times.
✓ Branch 1 taken 235 times.
|
2645227 | DEFINE_X2RGB10TO16(nobswap, 0, 48, 0) |
| 440 |
2/2✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 1 times.
|
9217 | DEFINE_X2RGB10TO16(bswap, 1, 48, 0) |
| 441 | ✗ | DEFINE_X2RGB10TO16(nobswap, 0, 64, 1) | |
| 442 | ✗ | DEFINE_X2RGB10TO16(bswap, 1, 64, 1) | |
| 443 | |||
| 444 | #define DEFINE_X2RGB10TOBGR16(need_bswap, swap, bits, alpha) \ | ||
| 445 | void x2rgb10tobgr ## bits ## _ ## need_bswap(const uint8_t *src, \ | ||
| 446 | uint8_t *dst, int src_size) \ | ||
| 447 | { \ | ||
| 448 | uint16_t *d = (uint16_t *)dst; \ | ||
| 449 | const uint32_t *s = (const uint32_t *)src; \ | ||
| 450 | int i, num_pixels = src_size >> 2; \ | ||
| 451 | unsigned component; \ | ||
| 452 | \ | ||
| 453 | for (i = 0; i < num_pixels; i++) { \ | ||
| 454 | unsigned p = AV_RL32(s + i); \ | ||
| 455 | component = p & 0x3FF; \ | ||
| 456 | d[(3 + alpha) * i + 0] = swap ? av_bswap16(component << 6 | component >> 4) \ | ||
| 457 | : component << 6 | component >> 4; \ | ||
| 458 | component = (p >> 10) & 0x3FF; \ | ||
| 459 | d[(3 + alpha) * i + 1] = swap ? av_bswap16(component << 6 | component >> 4) \ | ||
| 460 | : component << 6 | component >> 4; \ | ||
| 461 | component = (p >> 20) & 0x3FF; \ | ||
| 462 | d[(3 + alpha) * i + 2] = swap ? av_bswap16(component << 6 | component >> 4) \ | ||
| 463 | : component << 6 | component >> 4; \ | ||
| 464 | if (alpha) d[(3 + alpha) * i + 3] = 0xffff; \ | ||
| 465 | } \ | ||
| 466 | } | ||
| 467 | |||
| 468 |
2/2✓ Branch 0 taken 2644992 times.
✓ Branch 1 taken 235 times.
|
2645227 | DEFINE_X2RGB10TOBGR16(nobswap, 0, 48, 0) |
| 469 |
2/2✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 1 times.
|
9217 | DEFINE_X2RGB10TOBGR16(bswap, 1, 48, 0) |
| 470 | ✗ | DEFINE_X2RGB10TOBGR16(nobswap, 0, 64, 1) | |
| 471 | ✗ | DEFINE_X2RGB10TOBGR16(bswap, 1, 64, 1) | |
| 472 |