| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * software YUV to RGB converter | ||
| 3 | * | ||
| 4 | * Copyright (C) 2009 Konstantin Shishkov | ||
| 5 | * | ||
| 6 | * 1,4,8bpp support and context / deglobalize stuff | ||
| 7 | * by Michael Niedermayer (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 <stddef.h> | ||
| 27 | #include <stdint.h> | ||
| 28 | |||
| 29 | #include "libavutil/bswap.h" | ||
| 30 | #include "libavutil/mem.h" | ||
| 31 | #include "config.h" | ||
| 32 | #include "swscale.h" | ||
| 33 | #include "swscale_internal.h" | ||
| 34 | #include "libavutil/pixdesc.h" | ||
| 35 | |||
| 36 | /* Color space conversion coefficients for YCbCr -> RGB mapping. | ||
| 37 | * | ||
| 38 | * Entries are {crv, cbu, cgu, cgv} | ||
| 39 | * | ||
| 40 | * crv = (255 / 224) * 65536 * (1 - cr) / 0.5 | ||
| 41 | * cbu = (255 / 224) * 65536 * (1 - cb) / 0.5 | ||
| 42 | * cgu = (255 / 224) * 65536 * (cb / cg) * (1 - cb) / 0.5 | ||
| 43 | * cgv = (255 / 224) * 65536 * (cr / cg) * (1 - cr) / 0.5 | ||
| 44 | * | ||
| 45 | * where Y = cr * R + cg * G + cb * B and cr + cg + cb = 1. | ||
| 46 | */ | ||
| 47 | const int32_t ff_yuv2rgb_coeffs[11][4] = { | ||
| 48 | { 104597, 132201, 25675, 53279 }, /* no sequence_display_extension */ | ||
| 49 | { 117489, 138438, 13975, 34925 }, /* ITU-R Rec. 709 (1990) */ | ||
| 50 | { 104597, 132201, 25675, 53279 }, /* unspecified */ | ||
| 51 | { 104597, 132201, 25675, 53279 }, /* reserved */ | ||
| 52 | { 104448, 132798, 24759, 53109 }, /* FCC */ | ||
| 53 | { 104597, 132201, 25675, 53279 }, /* ITU-R Rec. 624-4 System B, G */ | ||
| 54 | { 104597, 132201, 25675, 53279 }, /* SMPTE 170M */ | ||
| 55 | { 117579, 136230, 16907, 35559 }, /* SMPTE 240M (1987) */ | ||
| 56 | { 0 }, /* YCgCo */ | ||
| 57 | { 110013, 140363, 12277, 42626 }, /* Bt-2020-NCL */ | ||
| 58 | { 110013, 140363, 12277, 42626 }, /* Bt-2020-CL */ | ||
| 59 | }; | ||
| 60 | |||
| 61 | 51532 | const int *sws_getCoefficients(int colorspace) | |
| 62 | { | ||
| 63 |
3/6✓ Branch 0 taken 51532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51532 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 51532 times.
|
51532 | if (colorspace > 10 || colorspace < 0 || colorspace == 8) |
| 64 | ✗ | colorspace = SWS_CS_DEFAULT; | |
| 65 | 51532 | return ff_yuv2rgb_coeffs[colorspace]; | |
| 66 | } | ||
| 67 | |||
| 68 | #define LOADCHROMA(l, i) \ | ||
| 69 | U = pu_##l[i]; \ | ||
| 70 | V = pv_##l[i]; \ | ||
| 71 | r = (void *)c->table_rV[V+YUVRGB_TABLE_HEADROOM]; \ | ||
| 72 | g = (void *)(c->table_gU[U+YUVRGB_TABLE_HEADROOM] + c->table_gV[V+YUVRGB_TABLE_HEADROOM]); \ | ||
| 73 | b = (void *)c->table_bU[U+YUVRGB_TABLE_HEADROOM]; | ||
| 74 | |||
| 75 | #define PUTRGB(l, i, abase) \ | ||
| 76 | Y = py_##l[2 * i]; \ | ||
| 77 | dst_##l[2 * i] = r[Y] + g[Y] + b[Y]; \ | ||
| 78 | Y = py_##l[2 * i + 1]; \ | ||
| 79 | dst_##l[2 * i + 1] = r[Y] + g[Y] + b[Y]; | ||
| 80 | |||
| 81 | #define PUTRGB24(l, i, abase) \ | ||
| 82 | Y = py_##l[2 * i]; \ | ||
| 83 | dst_##l[6 * i + 0] = r[Y]; \ | ||
| 84 | dst_##l[6 * i + 1] = g[Y]; \ | ||
| 85 | dst_##l[6 * i + 2] = b[Y]; \ | ||
| 86 | Y = py_##l[2 * i + 1]; \ | ||
| 87 | dst_##l[6 * i + 3] = r[Y]; \ | ||
| 88 | dst_##l[6 * i + 4] = g[Y]; \ | ||
| 89 | dst_##l[6 * i + 5] = b[Y]; | ||
| 90 | |||
| 91 | #define PUTBGR24(l, i, abase) \ | ||
| 92 | Y = py_##l[2 * i]; \ | ||
| 93 | dst_##l[6 * i + 0] = b[Y]; \ | ||
| 94 | dst_##l[6 * i + 1] = g[Y]; \ | ||
| 95 | dst_##l[6 * i + 2] = r[Y]; \ | ||
| 96 | Y = py_##l[2 * i + 1]; \ | ||
| 97 | dst_##l[6 * i + 3] = b[Y]; \ | ||
| 98 | dst_##l[6 * i + 4] = g[Y]; \ | ||
| 99 | dst_##l[6 * i + 5] = r[Y]; | ||
| 100 | |||
| 101 | #define PUTRGBA(l, i, abase) \ | ||
| 102 | Y = py_##l[2 * i]; \ | ||
| 103 | dst_##l[2 * i] = r[Y] + g[Y] + b[Y] + ((uint32_t)(pa_##l[2 * i]) << abase); \ | ||
| 104 | Y = py_##l[2 * i + 1]; \ | ||
| 105 | dst_##l[2 * i + 1] = r[Y] + g[Y] + b[Y] + ((uint32_t)(pa_##l[2 * i + 1]) << abase); | ||
| 106 | |||
| 107 | #define PUTRGB48(l, i, abase) \ | ||
| 108 | Y = py_##l[ 2 * i]; \ | ||
| 109 | dst_##l[12 * i + 0] = dst_##l[12 * i + 1] = r[Y]; \ | ||
| 110 | dst_##l[12 * i + 2] = dst_##l[12 * i + 3] = g[Y]; \ | ||
| 111 | dst_##l[12 * i + 4] = dst_##l[12 * i + 5] = b[Y]; \ | ||
| 112 | Y = py_##l[ 2 * i + 1]; \ | ||
| 113 | dst_##l[12 * i + 6] = dst_##l[12 * i + 7] = r[Y]; \ | ||
| 114 | dst_##l[12 * i + 8] = dst_##l[12 * i + 9] = g[Y]; \ | ||
| 115 | dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = b[Y]; | ||
| 116 | |||
| 117 | #define PUTBGR48(l, i, abase) \ | ||
| 118 | Y = py_##l[2 * i]; \ | ||
| 119 | dst_##l[12 * i + 0] = dst_##l[12 * i + 1] = b[Y]; \ | ||
| 120 | dst_##l[12 * i + 2] = dst_##l[12 * i + 3] = g[Y]; \ | ||
| 121 | dst_##l[12 * i + 4] = dst_##l[12 * i + 5] = r[Y]; \ | ||
| 122 | Y = py_##l[2 * i + 1]; \ | ||
| 123 | dst_##l[12 * i + 6] = dst_##l[12 * i + 7] = b[Y]; \ | ||
| 124 | dst_##l[12 * i + 8] = dst_##l[12 * i + 9] = g[Y]; \ | ||
| 125 | dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = r[Y]; | ||
| 126 | |||
| 127 | #define PUTGBRP(l, i, abase) \ | ||
| 128 | Y = py_##l[2 * i]; \ | ||
| 129 | dst_##l [2 * i + 0] = g[Y]; \ | ||
| 130 | dst1_##l[2 * i + 0] = b[Y]; \ | ||
| 131 | dst2_##l[2 * i + 0] = r[Y]; \ | ||
| 132 | Y = py_##l[2 * i + 1]; \ | ||
| 133 | dst_##l [2 * i + 1] = g[Y]; \ | ||
| 134 | dst1_##l[2 * i + 1] = b[Y]; \ | ||
| 135 | dst2_##l[2 * i + 1] = r[Y]; | ||
| 136 | |||
| 137 | #define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422, nb_dst_planes) \ | ||
| 138 | static int func_name(SwsInternal *c, const uint8_t *const src[], \ | ||
| 139 | const int srcStride[], int srcSliceY, int srcSliceH, \ | ||
| 140 | uint8_t *const dst[], const int dstStride[]) \ | ||
| 141 | { \ | ||
| 142 | int y; \ | ||
| 143 | \ | ||
| 144 | for (y = 0; y < srcSliceH; y += 2) { \ | ||
| 145 | int yd = y + srcSliceY; \ | ||
| 146 | dst_type *dst_1 = \ | ||
| 147 | (dst_type *)(dst[0] + (yd) * dstStride[0]); \ | ||
| 148 | dst_type *dst_2 = \ | ||
| 149 | (dst_type *)(dst[0] + (yd + 1) * dstStride[0]); \ | ||
| 150 | av_unused dst_type *dst1_1, *dst1_2, *dst2_1, *dst2_2; \ | ||
| 151 | av_unused dst_type *r, *g, *b; \ | ||
| 152 | const uint8_t *py_1 = src[0] + y * srcStride[0]; \ | ||
| 153 | const uint8_t *py_2 = py_1 + srcStride[0]; \ | ||
| 154 | av_unused const uint8_t *pu_1 = src[1] + (y >> !yuv422) * srcStride[1]; \ | ||
| 155 | av_unused const uint8_t *pv_1 = src[2] + (y >> !yuv422) * srcStride[2]; \ | ||
| 156 | av_unused const uint8_t *pu_2, *pv_2; \ | ||
| 157 | av_unused const uint8_t *pa_1, *pa_2; \ | ||
| 158 | unsigned int h_size = c->opts.dst_w >> 3; \ | ||
| 159 | if (nb_dst_planes > 1) { \ | ||
| 160 | dst1_1 = (dst_type *)(dst[1] + (yd) * dstStride[1]); \ | ||
| 161 | dst1_2 = (dst_type *)(dst[1] + (yd + 1) * dstStride[1]); \ | ||
| 162 | dst2_1 = (dst_type *)(dst[2] + (yd) * dstStride[2]); \ | ||
| 163 | dst2_2 = (dst_type *)(dst[2] + (yd + 1) * dstStride[2]); \ | ||
| 164 | } \ | ||
| 165 | if (yuv422) { \ | ||
| 166 | pu_2 = pu_1 + srcStride[1]; \ | ||
| 167 | pv_2 = pv_1 + srcStride[2]; \ | ||
| 168 | } \ | ||
| 169 | if (alpha) { \ | ||
| 170 | pa_1 = src[3] + y * srcStride[3]; \ | ||
| 171 | pa_2 = pa_1 + srcStride[3]; \ | ||
| 172 | } \ | ||
| 173 | while (h_size--) { \ | ||
| 174 | av_unused int U, V, Y; \ | ||
| 175 | |||
| 176 | #define ENDYUV2RGBLINE(dst_delta, ss, alpha, yuv422, nb_dst_planes) \ | ||
| 177 | pu_1 += 4 >> ss; \ | ||
| 178 | pv_1 += 4 >> ss; \ | ||
| 179 | if (yuv422) { \ | ||
| 180 | pu_2 += 4 >> ss; \ | ||
| 181 | pv_2 += 4 >> ss; \ | ||
| 182 | } \ | ||
| 183 | py_1 += 8 >> ss; \ | ||
| 184 | py_2 += 8 >> ss; \ | ||
| 185 | if (alpha) { \ | ||
| 186 | pa_1 += 8 >> ss; \ | ||
| 187 | pa_2 += 8 >> ss; \ | ||
| 188 | } \ | ||
| 189 | dst_1 += dst_delta >> ss; \ | ||
| 190 | dst_2 += dst_delta >> ss; \ | ||
| 191 | if (nb_dst_planes > 1) { \ | ||
| 192 | dst1_1 += dst_delta >> ss; \ | ||
| 193 | dst1_2 += dst_delta >> ss; \ | ||
| 194 | dst2_1 += dst_delta >> ss; \ | ||
| 195 | dst2_2 += dst_delta >> ss; \ | ||
| 196 | } \ | ||
| 197 | } \ | ||
| 198 | if (c->opts.dst_w & (4 >> ss)) { \ | ||
| 199 | av_unused int Y, U, V; \ | ||
| 200 | |||
| 201 | #define ENDYUV2RGBFUNC() \ | ||
| 202 | } \ | ||
| 203 | } \ | ||
| 204 | return srcSliceH; \ | ||
| 205 | } | ||
| 206 | |||
| 207 | #define YUV420FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta, nb_dst_planes) \ | ||
| 208 | YUV2RGBFUNC(func_name, dst_type, alpha, 0, nb_dst_planes) \ | ||
| 209 | LOADCHROMA(1, 0); \ | ||
| 210 | PUTFUNC(1, 0, abase); \ | ||
| 211 | PUTFUNC(2, 0, abase); \ | ||
| 212 | \ | ||
| 213 | LOADCHROMA(1, 1); \ | ||
| 214 | PUTFUNC(2, 1, abase); \ | ||
| 215 | PUTFUNC(1, 1, abase); \ | ||
| 216 | \ | ||
| 217 | LOADCHROMA(1, 2); \ | ||
| 218 | PUTFUNC(1, 2, abase); \ | ||
| 219 | PUTFUNC(2, 2, abase); \ | ||
| 220 | \ | ||
| 221 | LOADCHROMA(1, 3); \ | ||
| 222 | PUTFUNC(2, 3, abase); \ | ||
| 223 | PUTFUNC(1, 3, abase); \ | ||
| 224 | ENDYUV2RGBLINE(dst_delta, 0, alpha, 0, nb_dst_planes) \ | ||
| 225 | LOADCHROMA(1, 0); \ | ||
| 226 | PUTFUNC(1, 0, abase); \ | ||
| 227 | PUTFUNC(2, 0, abase); \ | ||
| 228 | \ | ||
| 229 | LOADCHROMA(1, 1); \ | ||
| 230 | PUTFUNC(2, 1, abase); \ | ||
| 231 | PUTFUNC(1, 1, abase); \ | ||
| 232 | ENDYUV2RGBLINE(dst_delta, 1, alpha, 0, nb_dst_planes) \ | ||
| 233 | LOADCHROMA(1, 0); \ | ||
| 234 | PUTFUNC(1, 0, abase); \ | ||
| 235 | PUTFUNC(2, 0, abase); \ | ||
| 236 | ENDYUV2RGBFUNC() | ||
| 237 | |||
| 238 | #define YUV422FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta, nb_dst_planes) \ | ||
| 239 | YUV2RGBFUNC(func_name, dst_type, alpha, 1, nb_dst_planes) \ | ||
| 240 | LOADCHROMA(1, 0); \ | ||
| 241 | PUTFUNC(1, 0, abase); \ | ||
| 242 | \ | ||
| 243 | LOADCHROMA(2, 0); \ | ||
| 244 | PUTFUNC(2, 0, abase); \ | ||
| 245 | \ | ||
| 246 | LOADCHROMA(2, 1); \ | ||
| 247 | PUTFUNC(2, 1, abase); \ | ||
| 248 | \ | ||
| 249 | LOADCHROMA(1, 1); \ | ||
| 250 | PUTFUNC(1, 1, abase); \ | ||
| 251 | \ | ||
| 252 | LOADCHROMA(1, 2); \ | ||
| 253 | PUTFUNC(1, 2, abase); \ | ||
| 254 | \ | ||
| 255 | LOADCHROMA(2, 2); \ | ||
| 256 | PUTFUNC(2, 2, abase); \ | ||
| 257 | \ | ||
| 258 | LOADCHROMA(2, 3); \ | ||
| 259 | PUTFUNC(2, 3, abase); \ | ||
| 260 | \ | ||
| 261 | LOADCHROMA(1, 3); \ | ||
| 262 | PUTFUNC(1, 3, abase); \ | ||
| 263 | ENDYUV2RGBLINE(dst_delta, 0, alpha, 1, nb_dst_planes) \ | ||
| 264 | LOADCHROMA(1, 0); \ | ||
| 265 | PUTFUNC(1, 0, abase); \ | ||
| 266 | \ | ||
| 267 | LOADCHROMA(2, 0); \ | ||
| 268 | PUTFUNC(2, 0, abase); \ | ||
| 269 | \ | ||
| 270 | LOADCHROMA(2, 1); \ | ||
| 271 | PUTFUNC(2, 1, abase); \ | ||
| 272 | \ | ||
| 273 | LOADCHROMA(1, 1); \ | ||
| 274 | PUTFUNC(1, 1, abase); \ | ||
| 275 | ENDYUV2RGBLINE(dst_delta, 1, alpha, 1, nb_dst_planes) \ | ||
| 276 | LOADCHROMA(1, 0); \ | ||
| 277 | PUTFUNC(1, 0, abase); \ | ||
| 278 | \ | ||
| 279 | LOADCHROMA(2, 0); \ | ||
| 280 | PUTFUNC(2, 0, abase); \ | ||
| 281 | ENDYUV2RGBFUNC() | ||
| 282 | |||
| 283 | #define YUV420FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta) \ | ||
| 284 | YUV2RGBFUNC(func_name, dst_type, 0, 0, 1) \ | ||
| 285 | LOADDITHER \ | ||
| 286 | \ | ||
| 287 | LOADCHROMA(1, 0); \ | ||
| 288 | PUTFUNC(1, 0, 0); \ | ||
| 289 | PUTFUNC(2, 0, 0 + 8); \ | ||
| 290 | \ | ||
| 291 | LOADCHROMA(1, 1); \ | ||
| 292 | PUTFUNC(2, 1, 2 + 8); \ | ||
| 293 | PUTFUNC(1, 1, 2); \ | ||
| 294 | \ | ||
| 295 | LOADCHROMA(1, 2); \ | ||
| 296 | PUTFUNC(1, 2, 4); \ | ||
| 297 | PUTFUNC(2, 2, 4 + 8); \ | ||
| 298 | \ | ||
| 299 | LOADCHROMA(1, 3); \ | ||
| 300 | PUTFUNC(2, 3, 6 + 8); \ | ||
| 301 | PUTFUNC(1, 3, 6); \ | ||
| 302 | ENDYUV2RGBLINE(dst_delta, 0, 0, 0, 1) \ | ||
| 303 | LOADDITHER \ | ||
| 304 | \ | ||
| 305 | LOADCHROMA(1, 0); \ | ||
| 306 | PUTFUNC(1, 0, 0); \ | ||
| 307 | PUTFUNC(2, 0, 0 + 8); \ | ||
| 308 | \ | ||
| 309 | LOADCHROMA(1, 1); \ | ||
| 310 | PUTFUNC(2, 1, 2 + 8); \ | ||
| 311 | PUTFUNC(1, 1, 2); \ | ||
| 312 | ENDYUV2RGBLINE(dst_delta, 1, 0, 0, 1) \ | ||
| 313 | LOADDITHER \ | ||
| 314 | \ | ||
| 315 | LOADCHROMA(1, 0); \ | ||
| 316 | PUTFUNC(1, 0, 0); \ | ||
| 317 | PUTFUNC(2, 0, 0 + 8); \ | ||
| 318 | ENDYUV2RGBFUNC() | ||
| 319 | |||
| 320 | #define YUV422FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta) \ | ||
| 321 | YUV2RGBFUNC(func_name, dst_type, 0, 1, 1) \ | ||
| 322 | LOADDITHER \ | ||
| 323 | \ | ||
| 324 | LOADCHROMA(1, 0); \ | ||
| 325 | PUTFUNC(1, 0, 0); \ | ||
| 326 | \ | ||
| 327 | LOADCHROMA(2, 0); \ | ||
| 328 | PUTFUNC(2, 0, 0 + 8); \ | ||
| 329 | \ | ||
| 330 | LOADCHROMA(2, 1); \ | ||
| 331 | PUTFUNC(2, 1, 2 + 8); \ | ||
| 332 | \ | ||
| 333 | LOADCHROMA(1, 1); \ | ||
| 334 | PUTFUNC(1, 1, 2); \ | ||
| 335 | \ | ||
| 336 | LOADCHROMA(1, 2); \ | ||
| 337 | PUTFUNC(1, 2, 4); \ | ||
| 338 | \ | ||
| 339 | LOADCHROMA(2, 2); \ | ||
| 340 | PUTFUNC(2, 2, 4 + 8); \ | ||
| 341 | \ | ||
| 342 | LOADCHROMA(2, 3); \ | ||
| 343 | PUTFUNC(2, 3, 6 + 8); \ | ||
| 344 | \ | ||
| 345 | LOADCHROMA(1, 3); \ | ||
| 346 | PUTFUNC(1, 3, 6); \ | ||
| 347 | ENDYUV2RGBLINE(dst_delta, 0, 0, 1, 1) \ | ||
| 348 | LOADDITHER \ | ||
| 349 | \ | ||
| 350 | LOADCHROMA(1, 0); \ | ||
| 351 | PUTFUNC(1, 0, 0); \ | ||
| 352 | \ | ||
| 353 | LOADCHROMA(2, 0); \ | ||
| 354 | PUTFUNC(2, 0, 0 + 8); \ | ||
| 355 | \ | ||
| 356 | LOADCHROMA(2, 1); \ | ||
| 357 | PUTFUNC(2, 1, 2 + 8); \ | ||
| 358 | \ | ||
| 359 | LOADCHROMA(1, 1); \ | ||
| 360 | PUTFUNC(1, 1, 2); \ | ||
| 361 | ENDYUV2RGBLINE(dst_delta, 1, 0, 1, 1) \ | ||
| 362 | LOADDITHER \ | ||
| 363 | \ | ||
| 364 | LOADCHROMA(1, 0); \ | ||
| 365 | PUTFUNC(1, 0, 0); \ | ||
| 366 | \ | ||
| 367 | LOADCHROMA(2, 0); \ | ||
| 368 | PUTFUNC(2, 0, 0 + 8); \ | ||
| 369 | ENDYUV2RGBFUNC() | ||
| 370 | |||
| 371 | #define LOADDITHER16 \ | ||
| 372 | const uint8_t *d16 = ff_dither_2x2_8[y & 1]; \ | ||
| 373 | const uint8_t *e16 = ff_dither_2x2_4[y & 1]; \ | ||
| 374 | const uint8_t *f16 = ff_dither_2x2_8[(y & 1)^1]; | ||
| 375 | |||
| 376 | #define PUTRGB16(l, i, o) \ | ||
| 377 | Y = py_##l[2 * i]; \ | ||
| 378 | dst_##l[2 * i] = r[Y + d16[0 + o]] + \ | ||
| 379 | g[Y + e16[0 + o]] + \ | ||
| 380 | b[Y + f16[0 + o]]; \ | ||
| 381 | Y = py_##l[2 * i + 1]; \ | ||
| 382 | dst_##l[2 * i + 1] = r[Y + d16[1 + o]] + \ | ||
| 383 | g[Y + e16[1 + o]] + \ | ||
| 384 | b[Y + f16[1 + o]]; | ||
| 385 | |||
| 386 | #define LOADDITHER15 \ | ||
| 387 | const uint8_t *d16 = ff_dither_2x2_8[y & 1]; \ | ||
| 388 | const uint8_t *e16 = ff_dither_2x2_8[(y & 1)^1]; | ||
| 389 | |||
| 390 | #define PUTRGB15(l, i, o) \ | ||
| 391 | Y = py_##l[2 * i]; \ | ||
| 392 | dst_##l[2 * i] = r[Y + d16[0 + o]] + \ | ||
| 393 | g[Y + d16[1 + o]] + \ | ||
| 394 | b[Y + e16[0 + o]]; \ | ||
| 395 | Y = py_##l[2 * i + 1]; \ | ||
| 396 | dst_##l[2 * i + 1] = r[Y + d16[1 + o]] + \ | ||
| 397 | g[Y + d16[0 + o]] + \ | ||
| 398 | b[Y + e16[1 + o]]; | ||
| 399 | |||
| 400 | #define LOADDITHER12 \ | ||
| 401 | const uint8_t *d16 = ff_dither_4x4_16[y & 3]; | ||
| 402 | |||
| 403 | #define PUTRGB12(l, i, o) \ | ||
| 404 | Y = py_##l[2 * i]; \ | ||
| 405 | dst_##l[2 * i] = r[Y + d16[0 + o]] + \ | ||
| 406 | g[Y + d16[0 + o]] + \ | ||
| 407 | b[Y + d16[0 + o]]; \ | ||
| 408 | Y = py_##l[2 * i + 1]; \ | ||
| 409 | dst_##l[2 * i + 1] = r[Y + d16[1 + o]] + \ | ||
| 410 | g[Y + d16[1 + o]] + \ | ||
| 411 | b[Y + d16[1 + o]]; | ||
| 412 | |||
| 413 | #define LOADDITHER8 \ | ||
| 414 | const uint8_t *d32 = ff_dither_8x8_32[yd & 7]; \ | ||
| 415 | const uint8_t *d64 = ff_dither_8x8_73[yd & 7]; | ||
| 416 | |||
| 417 | #define PUTRGB8(l, i, o) \ | ||
| 418 | Y = py_##l[2 * i]; \ | ||
| 419 | dst_##l[2 * i] = r[Y + d32[0 + o]] + \ | ||
| 420 | g[Y + d32[0 + o]] + \ | ||
| 421 | b[Y + d64[0 + o]]; \ | ||
| 422 | Y = py_##l[2 * i + 1]; \ | ||
| 423 | dst_##l[2 * i + 1] = r[Y + d32[1 + o]] + \ | ||
| 424 | g[Y + d32[1 + o]] + \ | ||
| 425 | b[Y + d64[1 + o]]; | ||
| 426 | |||
| 427 | #define LOADDITHER4D \ | ||
| 428 | const uint8_t * d64 = ff_dither_8x8_73[yd & 7]; \ | ||
| 429 | const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; \ | ||
| 430 | int acc; | ||
| 431 | |||
| 432 | #define PUTRGB4D(l, i, o) \ | ||
| 433 | Y = py_##l[2 * i]; \ | ||
| 434 | acc = r[Y + d128[0 + o]] + \ | ||
| 435 | g[Y + d64[0 + o]] + \ | ||
| 436 | b[Y + d128[0 + o]]; \ | ||
| 437 | Y = py_##l[2 * i + 1]; \ | ||
| 438 | acc |= (r[Y + d128[1 + o]] + \ | ||
| 439 | g[Y + d64[1 + o]] + \ | ||
| 440 | b[Y + d128[1 + o]]) << 4; \ | ||
| 441 | dst_##l[i] = acc; | ||
| 442 | |||
| 443 | #define LOADDITHER4DB \ | ||
| 444 | const uint8_t *d64 = ff_dither_8x8_73[yd & 7]; \ | ||
| 445 | const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; | ||
| 446 | |||
| 447 | #define PUTRGB4DB(l, i, o) \ | ||
| 448 | Y = py_##l[2 * i]; \ | ||
| 449 | dst_##l[2 * i] = r[Y + d128[0 + o]] + \ | ||
| 450 | g[Y + d64[0 + o]] + \ | ||
| 451 | b[Y + d128[0 + o]]; \ | ||
| 452 | Y = py_##l[2 * i + 1]; \ | ||
| 453 | dst_##l[2 * i + 1] = r[Y + d128[1 + o]] + \ | ||
| 454 | g[Y + d64[1 + o]] + \ | ||
| 455 | b[Y + d128[1 + o]]; | ||
| 456 | |||
| 457 | ✗ | YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0, 0, 1) | |
| 458 | ✗ | const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; | |
| 459 | ✗ | char out_1 = 0, out_2 = 0; | |
| 460 | ✗ | g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM]; | |
| 461 | |||
| 462 | #define PUTRGB1(out, src, i, o) \ | ||
| 463 | Y = src[2 * i]; \ | ||
| 464 | out += out + g[Y + d128[0 + o]]; \ | ||
| 465 | Y = src[2 * i + 1]; \ | ||
| 466 | out += out + g[Y + d128[1 + o]]; | ||
| 467 | |||
| 468 | ✗ | PUTRGB1(out_1, py_1, 0, 0); | |
| 469 | ✗ | PUTRGB1(out_2, py_2, 0, 0 + 8); | |
| 470 | |||
| 471 | ✗ | PUTRGB1(out_2, py_2, 1, 2 + 8); | |
| 472 | ✗ | PUTRGB1(out_1, py_1, 1, 2); | |
| 473 | |||
| 474 | ✗ | PUTRGB1(out_1, py_1, 2, 4); | |
| 475 | ✗ | PUTRGB1(out_2, py_2, 2, 4 + 8); | |
| 476 | |||
| 477 | ✗ | PUTRGB1(out_2, py_2, 3, 6 + 8); | |
| 478 | ✗ | PUTRGB1(out_1, py_1, 3, 6); | |
| 479 | |||
| 480 | ✗ | dst_1[0] = out_1; | |
| 481 | ✗ | dst_2[0] = out_2; | |
| 482 | |||
| 483 | ✗ | py_1 += 8; | |
| 484 | ✗ | py_2 += 8; | |
| 485 | ✗ | dst_1 += 1; | |
| 486 | ✗ | dst_2 += 1; | |
| 487 | } | ||
| 488 | ✗ | if (c->opts.dst_w & 7) { | |
| 489 | av_unused int Y, U, V; | ||
| 490 | ✗ | int pixels_left = c->opts.dst_w & 7; | |
| 491 | ✗ | const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; | |
| 492 | ✗ | char out_1 = 0, out_2 = 0; | |
| 493 | ✗ | g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM]; | |
| 494 | |||
| 495 | #define PUTRGB1_OR00(out, src, i, o) \ | ||
| 496 | if (pixels_left) { \ | ||
| 497 | PUTRGB1(out, src, i, o) \ | ||
| 498 | pixels_left--; \ | ||
| 499 | } else { \ | ||
| 500 | out <<= 2; \ | ||
| 501 | } | ||
| 502 | |||
| 503 | ✗ | PUTRGB1_OR00(out_1, py_1, 0, 0); | |
| 504 | ✗ | PUTRGB1_OR00(out_2, py_2, 0, 0 + 8); | |
| 505 | |||
| 506 | ✗ | PUTRGB1_OR00(out_2, py_2, 1, 2 + 8); | |
| 507 | ✗ | PUTRGB1_OR00(out_1, py_1, 1, 2); | |
| 508 | |||
| 509 | ✗ | PUTRGB1_OR00(out_1, py_1, 2, 4); | |
| 510 | ✗ | PUTRGB1_OR00(out_2, py_2, 2, 4 + 8); | |
| 511 | |||
| 512 | ✗ | PUTRGB1_OR00(out_2, py_2, 3, 6 + 8); | |
| 513 | ✗ | PUTRGB1_OR00(out_1, py_1, 3, 6); | |
| 514 | |||
| 515 | ✗ | dst_1[0] = out_1; | |
| 516 | ✗ | dst_2[0] = out_2; | |
| 517 | ✗ | ENDYUV2RGBFUNC() | |
| 518 | |||
| 519 | // YUV420 | ||
| 520 | ✗ | YUV420FUNC(yuv2rgb_c_48, uint8_t, 0, 0, PUTRGB48, 48, 1) | |
| 521 | ✗ | YUV420FUNC(yuv2rgb_c_bgr48, uint8_t, 0, 0, PUTBGR48, 48, 1) | |
| 522 |
6/8✓ Branch 0 taken 7840 times.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 80 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 40 times.
|
7960 | YUV420FUNC(yuv2rgb_c_32, uint32_t, 0, 0, PUTRGB, 8, 1) |
| 523 | #if HAVE_BIGENDIAN | ||
| 524 | YUV420FUNC(yuva2argb_c, uint32_t, 1, 24, PUTRGBA, 8, 1) | ||
| 525 | YUV420FUNC(yuva2rgba_c, uint32_t, 1, 0, PUTRGBA, 8, 1) | ||
| 526 | #else | ||
| 527 |
6/8✓ Branch 0 taken 4704 times.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 24 times.
|
4776 | YUV420FUNC(yuva2rgba_c, uint32_t, 1, 24, PUTRGBA, 8, 1) |
| 528 |
6/8✓ Branch 0 taken 3136 times.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 32 times.
✓ Branch 7 taken 16 times.
|
3184 | YUV420FUNC(yuva2argb_c, uint32_t, 1, 0, PUTRGBA, 8, 1) |
| 529 | #endif | ||
| 530 |
6/8✓ Branch 0 taken 4704 times.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 24 times.
|
4776 | YUV420FUNC(yuv2rgb_c_24_rgb, uint8_t, 0, 0, PUTRGB24, 24, 1) |
| 531 |
6/8✓ Branch 0 taken 4704 times.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 24 times.
|
4776 | YUV420FUNC(yuv2rgb_c_24_bgr, uint8_t, 0, 0, PUTBGR24, 24, 1) |
| 532 |
6/8✓ Branch 0 taken 4704 times.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 24 times.
|
4776 | YUV420FUNC(yuv420p_gbrp_c, uint8_t, 0, 0, PUTGBRP, 8, 3) |
| 533 |
6/8✓ Branch 0 taken 7840 times.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 80 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 40 times.
|
7960 | YUV420FUNC_DITHER(yuv2rgb_c_16_ordered_dither, uint16_t, LOADDITHER16, PUTRGB16, 8) |
| 534 |
6/8✓ Branch 0 taken 7840 times.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 80 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 40 times.
|
7960 | YUV420FUNC_DITHER(yuv2rgb_c_15_ordered_dither, uint16_t, LOADDITHER15, PUTRGB15, 8) |
| 535 | ✗ | YUV420FUNC_DITHER(yuv2rgb_c_12_ordered_dither, uint16_t, LOADDITHER12, PUTRGB12, 8) | |
| 536 | ✗ | YUV420FUNC_DITHER(yuv2rgb_c_8_ordered_dither, uint8_t, LOADDITHER8, PUTRGB8, 8) | |
| 537 | ✗ | YUV420FUNC_DITHER(yuv2rgb_c_4_ordered_dither, uint8_t, LOADDITHER4D, PUTRGB4D, 4) | |
| 538 | ✗ | YUV420FUNC_DITHER(yuv2rgb_c_4b_ordered_dither, uint8_t, LOADDITHER4DB, PUTRGB4DB, 8) | |
| 539 | |||
| 540 | // YUV422 | ||
| 541 | ✗ | YUV422FUNC(yuv422p_rgb48_c, uint8_t, 0, 0, PUTRGB48, 48, 1) | |
| 542 | ✗ | YUV422FUNC(yuv422p_bgr48_c, uint8_t, 0, 0, PUTBGR48, 48, 1) | |
| 543 |
6/8✓ Branch 0 taken 7840 times.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 80 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 40 times.
|
7960 | YUV422FUNC(yuv422p_rgb32_c, uint32_t, 0, 0, PUTRGB, 8, 1) |
| 544 | #if HAVE_BIGENDIAN | ||
| 545 | YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 24, PUTRGBA, 8, 1) | ||
| 546 | YUV422FUNC(yuva422p_rgba_c, uint32_t, 1, 0, PUTRGBA, 8, 1) | ||
| 547 | #else | ||
| 548 | ✗ | YUV422FUNC(yuva422p_rgba_c, uint32_t, 1, 24, PUTRGBA, 8, 1) | |
| 549 | ✗ | YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 0, PUTRGBA, 8, 1) | |
| 550 | #endif | ||
| 551 |
6/8✓ Branch 0 taken 2352 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 12 times.
|
2388 | YUV422FUNC(yuv422p_rgb24_c, uint8_t, 0, 0, PUTRGB24, 24, 1) |
| 552 |
6/8✓ Branch 0 taken 2352 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 12 times.
|
2388 | YUV422FUNC(yuv422p_bgr24_c, uint8_t, 0, 0, PUTBGR24, 24, 1) |
| 553 |
6/8✓ Branch 0 taken 2352 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 12 times.
|
2388 | YUV422FUNC(yuv422p_gbrp_c, uint8_t, 0, 0, PUTGBRP, 8, 3) |
| 554 |
6/8✓ Branch 0 taken 3920 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 40 times.
✓ Branch 6 taken 40 times.
✓ Branch 7 taken 20 times.
|
3980 | YUV422FUNC_DITHER(yuv422p_bgr16, uint16_t, LOADDITHER16, PUTRGB16, 8) |
| 555 |
6/8✓ Branch 0 taken 3920 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 40 times.
✓ Branch 6 taken 40 times.
✓ Branch 7 taken 20 times.
|
3980 | YUV422FUNC_DITHER(yuv422p_bgr15, uint16_t, LOADDITHER15, PUTRGB15, 8) |
| 556 | ✗ | YUV422FUNC_DITHER(yuv422p_bgr12, uint16_t, LOADDITHER12, PUTRGB12, 8) | |
| 557 | ✗ | YUV422FUNC_DITHER(yuv422p_bgr8, uint8_t, LOADDITHER8, PUTRGB8, 8) | |
| 558 | ✗ | YUV422FUNC_DITHER(yuv422p_bgr4, uint8_t, LOADDITHER4D, PUTRGB4D, 4) | |
| 559 | ✗ | YUV422FUNC_DITHER(yuv422p_bgr4_byte, uint8_t, LOADDITHER4DB, PUTRGB4DB, 8) | |
| 560 | |||
| 561 | 1848 | SwsFunc ff_yuv2rgb_get_func_ptr(SwsInternal *c) | |
| 562 | { | ||
| 563 | 1848 | SwsFunc t = NULL; | |
| 564 | |||
| 565 | #if ARCH_PPC | ||
| 566 | t = ff_yuv2rgb_init_ppc(c); | ||
| 567 | #elif ARCH_X86 | ||
| 568 | 1848 | t = ff_yuv2rgb_init_x86(c); | |
| 569 | #elif ARCH_LOONGARCH64 | ||
| 570 | t = ff_yuv2rgb_init_loongarch(c); | ||
| 571 | #elif ARCH_AARCH64 | ||
| 572 | t = ff_yuv2rgb_init_aarch64(c); | ||
| 573 | #endif | ||
| 574 | |||
| 575 |
2/2✓ Branch 0 taken 672 times.
✓ Branch 1 taken 1176 times.
|
1848 | if (t) |
| 576 | 672 | return t; | |
| 577 | |||
| 578 | 1176 | av_log(c, AV_LOG_WARNING, | |
| 579 | "No accelerated colorspace conversion found from %s to %s.\n", | ||
| 580 | 1176 | av_get_pix_fmt_name(c->opts.src_format), av_get_pix_fmt_name(c->opts.dst_format)); | |
| 581 | |||
| 582 |
2/2✓ Branch 0 taken 392 times.
✓ Branch 1 taken 784 times.
|
1176 | if (c->opts.src_format == AV_PIX_FMT_YUV422P) { |
| 583 |
7/15✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 80 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 24 times.
✗ Branch 14 not taken.
|
392 | switch (c->opts.dst_format) { |
| 584 | ✗ | case AV_PIX_FMT_BGR48BE: | |
| 585 | case AV_PIX_FMT_BGR48LE: | ||
| 586 | ✗ | return yuv422p_bgr48_c; | |
| 587 | ✗ | case AV_PIX_FMT_RGB48BE: | |
| 588 | case AV_PIX_FMT_RGB48LE: | ||
| 589 | ✗ | return yuv422p_rgb48_c; | |
| 590 | 112 | case AV_PIX_FMT_ARGB: | |
| 591 | case AV_PIX_FMT_ABGR: | ||
| 592 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
|
112 | if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) |
| 593 | ✗ | return yuva422p_argb_c; | |
| 594 | av_fallthrough; | ||
| 595 | case AV_PIX_FMT_RGBA: | ||
| 596 | case AV_PIX_FMT_BGRA: | ||
| 597 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
|
160 | return (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) ? yuva422p_rgba_c : yuv422p_rgb32_c; |
| 598 | 24 | case AV_PIX_FMT_RGB24: | |
| 599 | 24 | return yuv422p_rgb24_c; | |
| 600 | 24 | case AV_PIX_FMT_BGR24: | |
| 601 | 24 | return yuv422p_bgr24_c; | |
| 602 | 80 | case AV_PIX_FMT_RGB565: | |
| 603 | case AV_PIX_FMT_BGR565: | ||
| 604 | 80 | return yuv422p_bgr16; | |
| 605 | 80 | case AV_PIX_FMT_RGB555: | |
| 606 | case AV_PIX_FMT_BGR555: | ||
| 607 | 80 | return yuv422p_bgr15; | |
| 608 | ✗ | case AV_PIX_FMT_RGB444: | |
| 609 | case AV_PIX_FMT_BGR444: | ||
| 610 | ✗ | return yuv422p_bgr12; | |
| 611 | ✗ | case AV_PIX_FMT_RGB8: | |
| 612 | case AV_PIX_FMT_BGR8: | ||
| 613 | ✗ | return yuv422p_bgr8; | |
| 614 | ✗ | case AV_PIX_FMT_RGB4: | |
| 615 | case AV_PIX_FMT_BGR4: | ||
| 616 | ✗ | return yuv422p_bgr4; | |
| 617 | ✗ | case AV_PIX_FMT_RGB4_BYTE: | |
| 618 | case AV_PIX_FMT_BGR4_BYTE: | ||
| 619 | ✗ | return yuv422p_bgr4_byte; | |
| 620 | ✗ | case AV_PIX_FMT_MONOBLACK: | |
| 621 | ✗ | return yuv2rgb_c_1_ordered_dither; | |
| 622 | 24 | case AV_PIX_FMT_GBRP: | |
| 623 | 24 | return yuv422p_gbrp_c; | |
| 624 | } | ||
| 625 | } else { | ||
| 626 |
7/15✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 224 times.
✓ Branch 3 taken 96 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 160 times.
✓ Branch 7 taken 160 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 48 times.
✗ Branch 14 not taken.
|
784 | switch (c->opts.dst_format) { |
| 627 | ✗ | case AV_PIX_FMT_BGR48BE: | |
| 628 | case AV_PIX_FMT_BGR48LE: | ||
| 629 | ✗ | return yuv2rgb_c_bgr48; | |
| 630 | ✗ | case AV_PIX_FMT_RGB48BE: | |
| 631 | case AV_PIX_FMT_RGB48LE: | ||
| 632 | ✗ | return yuv2rgb_c_48; | |
| 633 | 224 | case AV_PIX_FMT_ARGB: | |
| 634 | case AV_PIX_FMT_ABGR: | ||
| 635 |
2/2✓ Branch 1 taken 112 times.
✓ Branch 2 taken 112 times.
|
224 | if (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) |
| 636 | 112 | return yuva2argb_c; | |
| 637 | av_fallthrough; | ||
| 638 | case AV_PIX_FMT_RGBA: | ||
| 639 | case AV_PIX_FMT_BGRA: | ||
| 640 |
2/2✓ Branch 1 taken 48 times.
✓ Branch 2 taken 160 times.
|
208 | return (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format)) ? yuva2rgba_c : yuv2rgb_c_32; |
| 641 | 48 | case AV_PIX_FMT_RGB24: | |
| 642 | 48 | return yuv2rgb_c_24_rgb; | |
| 643 | 48 | case AV_PIX_FMT_BGR24: | |
| 644 | 48 | return yuv2rgb_c_24_bgr; | |
| 645 | 160 | case AV_PIX_FMT_RGB565: | |
| 646 | case AV_PIX_FMT_BGR565: | ||
| 647 | 160 | return yuv2rgb_c_16_ordered_dither; | |
| 648 | 160 | case AV_PIX_FMT_RGB555: | |
| 649 | case AV_PIX_FMT_BGR555: | ||
| 650 | 160 | return yuv2rgb_c_15_ordered_dither; | |
| 651 | ✗ | case AV_PIX_FMT_RGB444: | |
| 652 | case AV_PIX_FMT_BGR444: | ||
| 653 | ✗ | return yuv2rgb_c_12_ordered_dither; | |
| 654 | ✗ | case AV_PIX_FMT_RGB8: | |
| 655 | case AV_PIX_FMT_BGR8: | ||
| 656 | ✗ | return yuv2rgb_c_8_ordered_dither; | |
| 657 | ✗ | case AV_PIX_FMT_RGB4: | |
| 658 | case AV_PIX_FMT_BGR4: | ||
| 659 | ✗ | return yuv2rgb_c_4_ordered_dither; | |
| 660 | ✗ | case AV_PIX_FMT_RGB4_BYTE: | |
| 661 | case AV_PIX_FMT_BGR4_BYTE: | ||
| 662 | ✗ | return yuv2rgb_c_4b_ordered_dither; | |
| 663 | ✗ | case AV_PIX_FMT_MONOBLACK: | |
| 664 | ✗ | return yuv2rgb_c_1_ordered_dither; | |
| 665 | 48 | case AV_PIX_FMT_GBRP: | |
| 666 | 48 | return yuv420p_gbrp_c; | |
| 667 | } | ||
| 668 | } | ||
| 669 | ✗ | return NULL; | |
| 670 | } | ||
| 671 | |||
| 672 | 37895 | static void fill_table(uint8_t* table[256 + 2*YUVRGB_TABLE_HEADROOM], const int elemsize, | |
| 673 | const int64_t inc, void *y_tab) | ||
| 674 | { | ||
| 675 | int i; | ||
| 676 | 37895 | uint8_t *y_table = y_tab; | |
| 677 | |||
| 678 | 37895 | y_table -= elemsize * (inc >> 9); | |
| 679 | |||
| 680 |
2/2✓ Branch 0 taken 48505600 times.
✓ Branch 1 taken 37895 times.
|
48543495 | for (i = 0; i < 256 + 2*YUVRGB_TABLE_HEADROOM; i++) { |
| 681 | 48505600 | int64_t cb = av_clip_uint8(i-YUVRGB_TABLE_HEADROOM)*inc; | |
| 682 | 48505600 | table[i] = y_table + elemsize * (cb >> 16); | |
| 683 | } | ||
| 684 | 37895 | } | |
| 685 | |||
| 686 | 12817 | static void fill_gv_table(int table[256 + 2*YUVRGB_TABLE_HEADROOM], const int elemsize, const int64_t inc) | |
| 687 | { | ||
| 688 | int i; | ||
| 689 | 12817 | int off = -(inc >> 9); | |
| 690 | |||
| 691 |
2/2✓ Branch 0 taken 16405760 times.
✓ Branch 1 taken 12817 times.
|
16418577 | for (i = 0; i < 256 + 2*YUVRGB_TABLE_HEADROOM; i++) { |
| 692 | 16405760 | int64_t cb = av_clip_uint8(i-YUVRGB_TABLE_HEADROOM)*inc; | |
| 693 | 16405760 | table[i] = elemsize * (off + (cb >> 16)); | |
| 694 | } | ||
| 695 | 12817 | } | |
| 696 | |||
| 697 | 177708 | static uint16_t roundToInt16(int64_t f) | |
| 698 | { | ||
| 699 | 177708 | int r = (f + (1 << 15)) >> 16; | |
| 700 | |||
| 701 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 177708 times.
|
177708 | if (r < -0x7FFF) |
| 702 | ✗ | return 0x8000; | |
| 703 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 177708 times.
|
177708 | else if (r > 0x7FFF) |
| 704 | ✗ | return 0x7FFF; | |
| 705 | else | ||
| 706 | 177708 | return r; | |
| 707 | } | ||
| 708 | |||
| 709 | 14809 | av_cold int ff_yuv2rgb_c_init_tables(SwsInternal *c, const int inv_table[4], | |
| 710 | int fullRange, int brightness, | ||
| 711 | int contrast, int saturation) | ||
| 712 | { | ||
| 713 | 43604 | const int isRgb = c->opts.dst_format == AV_PIX_FMT_RGB32 || | |
| 714 |
2/2✓ Branch 0 taken 13718 times.
✓ Branch 1 taken 268 times.
|
13986 | c->opts.dst_format == AV_PIX_FMT_RGB32_1 || |
| 715 |
2/2✓ Branch 0 taken 13304 times.
✓ Branch 1 taken 414 times.
|
13718 | c->opts.dst_format == AV_PIX_FMT_BGR24 || |
| 716 |
2/2✓ Branch 0 taken 13236 times.
✓ Branch 1 taken 68 times.
|
13304 | c->opts.dst_format == AV_PIX_FMT_RGB565BE || |
| 717 |
2/2✓ Branch 0 taken 12886 times.
✓ Branch 1 taken 350 times.
|
13236 | c->opts.dst_format == AV_PIX_FMT_RGB565LE || |
| 718 |
2/2✓ Branch 0 taken 12818 times.
✓ Branch 1 taken 68 times.
|
12886 | c->opts.dst_format == AV_PIX_FMT_RGB555BE || |
| 719 |
2/2✓ Branch 0 taken 12461 times.
✓ Branch 1 taken 357 times.
|
12818 | c->opts.dst_format == AV_PIX_FMT_RGB555LE || |
| 720 |
2/2✓ Branch 0 taken 12395 times.
✓ Branch 1 taken 66 times.
|
12461 | c->opts.dst_format == AV_PIX_FMT_RGB444BE || |
| 721 |
2/2✓ Branch 0 taken 12329 times.
✓ Branch 1 taken 66 times.
|
12395 | c->opts.dst_format == AV_PIX_FMT_RGB444LE || |
| 722 |
1/2✓ Branch 0 taken 12329 times.
✗ Branch 1 not taken.
|
12329 | c->opts.dst_format == AV_PIX_FMT_X2RGB10BE || |
| 723 |
2/2✓ Branch 0 taken 12195 times.
✓ Branch 1 taken 134 times.
|
12329 | c->opts.dst_format == AV_PIX_FMT_X2RGB10LE || |
| 724 |
2/2✓ Branch 0 taken 12125 times.
✓ Branch 1 taken 70 times.
|
12195 | c->opts.dst_format == AV_PIX_FMT_RGB8 || |
| 725 |
2/2✓ Branch 0 taken 12083 times.
✓ Branch 1 taken 42 times.
|
12125 | c->opts.dst_format == AV_PIX_FMT_RGB4 || |
| 726 |
4/4✓ Branch 0 taken 13986 times.
✓ Branch 1 taken 823 times.
✓ Branch 2 taken 12015 times.
✓ Branch 3 taken 68 times.
|
40810 | c->opts.dst_format == AV_PIX_FMT_RGB4_BYTE || |
| 727 |
2/2✓ Branch 0 taken 135 times.
✓ Branch 1 taken 11880 times.
|
12015 | c->opts.dst_format == AV_PIX_FMT_MONOBLACK; |
| 728 | 44359 | const int isNotNe = c->opts.dst_format == AV_PIX_FMT_NE(RGB565LE, RGB565BE) || | |
| 729 |
2/2✓ Branch 0 taken 14673 times.
✓ Branch 1 taken 68 times.
|
14741 | c->opts.dst_format == AV_PIX_FMT_NE(RGB555LE, RGB555BE) || |
| 730 |
2/2✓ Branch 0 taken 14607 times.
✓ Branch 1 taken 66 times.
|
14673 | c->opts.dst_format == AV_PIX_FMT_NE(RGB444LE, RGB444BE) || |
| 731 |
2/2✓ Branch 0 taken 14540 times.
✓ Branch 1 taken 67 times.
|
14607 | c->opts.dst_format == AV_PIX_FMT_NE(BGR565LE, BGR565BE) || |
| 732 |
2/2✓ Branch 0 taken 14473 times.
✓ Branch 1 taken 67 times.
|
14540 | c->opts.dst_format == AV_PIX_FMT_NE(BGR555LE, BGR555BE) || |
| 733 |
2/2✓ Branch 0 taken 14407 times.
✓ Branch 1 taken 66 times.
|
14473 | c->opts.dst_format == AV_PIX_FMT_NE(BGR444LE, BGR444BE) || |
| 734 |
3/4✓ Branch 0 taken 14741 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 14407 times.
✗ Branch 3 not taken.
|
43957 | c->opts.dst_format == AV_PIX_FMT_NE(X2RGB10LE, X2RGB10BE) || |
| 735 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14407 times.
|
14407 | c->opts.dst_format == AV_PIX_FMT_NE(X2BGR10LE, X2BGR10BE); |
| 736 | 14809 | const int bpp = c->dstFormatBpp; | |
| 737 | uint8_t *y_table; | ||
| 738 | uint16_t *y_table16; | ||
| 739 | uint32_t *y_table32; | ||
| 740 | 14809 | int i, base, rbase, gbase, bbase, av_uninit(abase), needAlpha; | |
| 741 |
2/2✓ Branch 0 taken 688 times.
✓ Branch 1 taken 14121 times.
|
14809 | const int yoffs = (fullRange ? 384 : 326) + YUVRGB_TABLE_LUMA_HEADROOM; |
| 742 | 14809 | const int table_plane_size = 1024 + 2*YUVRGB_TABLE_LUMA_HEADROOM; | |
| 743 | |||
| 744 | 14809 | int64_t crv = inv_table[0]; | |
| 745 | 14809 | int64_t cbu = inv_table[1]; | |
| 746 | 14809 | int64_t cgu = -inv_table[2]; | |
| 747 | 14809 | int64_t cgv = -inv_table[3]; | |
| 748 | 14809 | int64_t cy = 1 << 16; | |
| 749 | 14809 | int64_t oy = 0; | |
| 750 | 14809 | int64_t yb = 0; | |
| 751 | |||
| 752 |
2/2✓ Branch 0 taken 14121 times.
✓ Branch 1 taken 688 times.
|
14809 | if (!fullRange) { |
| 753 | 14121 | cy = (cy * 255) / 219; | |
| 754 | 14121 | oy = 16 << 16; | |
| 755 | } else { | ||
| 756 | 688 | crv = (crv * 224) / 255; | |
| 757 | 688 | cbu = (cbu * 224) / 255; | |
| 758 | 688 | cgu = (cgu * 224) / 255; | |
| 759 | 688 | cgv = (cgv * 224) / 255; | |
| 760 | } | ||
| 761 | |||
| 762 | 14809 | cy = (cy * contrast) >> 16; | |
| 763 | 14809 | crv = (crv * contrast * saturation) >> 32; | |
| 764 | 14809 | cbu = (cbu * contrast * saturation) >> 32; | |
| 765 | 14809 | cgu = (cgu * contrast * saturation) >> 32; | |
| 766 | 14809 | cgv = (cgv * contrast * saturation) >> 32; | |
| 767 | 14809 | oy -= 256LL * brightness; | |
| 768 | |||
| 769 | 14809 | c->uOffset = 0x0400040004000400LL; | |
| 770 | 14809 | c->vOffset = 0x0400040004000400LL; | |
| 771 | 14809 | c->yCoeff = roundToInt16(cy * (1 << 13)) * 0x0001000100010001ULL; | |
| 772 | 14809 | c->vrCoeff = roundToInt16(crv * (1 << 13)) * 0x0001000100010001ULL; | |
| 773 | 14809 | c->ubCoeff = roundToInt16(cbu * (1 << 13)) * 0x0001000100010001ULL; | |
| 774 | 14809 | c->vgCoeff = roundToInt16(cgv * (1 << 13)) * 0x0001000100010001ULL; | |
| 775 | 14809 | c->ugCoeff = roundToInt16(cgu * (1 << 13)) * 0x0001000100010001ULL; | |
| 776 | 14809 | c->yOffset = roundToInt16(oy * (1 << 3)) * 0x0001000100010001ULL; | |
| 777 | |||
| 778 | 14809 | c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy * (1 << 13)); | |
| 779 | 14809 | c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy * (1 << 9)); | |
| 780 | 14809 | c->yuv2rgb_v2r_coeff = (int16_t)roundToInt16(crv * (1 << 13)); | |
| 781 | 14809 | c->yuv2rgb_v2g_coeff = (int16_t)roundToInt16(cgv * (1 << 13)); | |
| 782 | 14809 | c->yuv2rgb_u2g_coeff = (int16_t)roundToInt16(cgu * (1 << 13)); | |
| 783 | 14809 | c->yuv2rgb_u2b_coeff = (int16_t)roundToInt16(cbu * (1 << 13)); | |
| 784 | |||
| 785 | //scale coefficients by cy | ||
| 786 | 14809 | crv = ((crv * (1 << 16)) + 0x8000) / FFMAX(cy, 1); | |
| 787 | 14809 | cbu = ((cbu * (1 << 16)) + 0x8000) / FFMAX(cy, 1); | |
| 788 | 14809 | cgu = ((cgu * (1 << 16)) + 0x8000) / FFMAX(cy, 1); | |
| 789 | 14809 | cgv = ((cgv * (1 << 16)) + 0x8000) / FFMAX(cy, 1); | |
| 790 | |||
| 791 | 14809 | av_freep(&c->yuvTable); | |
| 792 | |||
| 793 | #define ALLOC_YUV_TABLE(x) \ | ||
| 794 | c->yuvTable = av_malloc(x); \ | ||
| 795 | if (!c->yuvTable) \ | ||
| 796 | return AVERROR(ENOMEM); | ||
| 797 |
9/9✓ Branch 0 taken 278 times.
✓ Branch 1 taken 219 times.
✓ Branch 2 taken 154 times.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 1451 times.
✓ Branch 5 taken 6686 times.
✓ Branch 6 taken 1524 times.
✓ Branch 7 taken 2241 times.
✓ Branch 8 taken 1992 times.
|
14809 | switch (bpp) { |
| 798 | 278 | case 1: | |
| 799 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 278 times.
|
278 | ALLOC_YUV_TABLE(table_plane_size); |
| 800 | 278 | y_table = c->yuvTable; | |
| 801 | 278 | yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy; | |
| 802 |
2/2✓ Branch 0 taken 538764 times.
✓ Branch 1 taken 278 times.
|
539042 | for (i = 0; i < table_plane_size - 110; i++) { |
| 803 | 538764 | y_table[i + 110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7; | |
| 804 | 538764 | yb += cy; | |
| 805 | } | ||
| 806 | 278 | fill_table(c->table_gU, 1, cgu, y_table + yoffs); | |
| 807 | 278 | fill_gv_table(c->table_gV, 1, cgv); | |
| 808 | 278 | break; | |
| 809 | 219 | case 4: | |
| 810 | case 4 | 128: | ||
| 811 |
2/2✓ Branch 0 taken 110 times.
✓ Branch 1 taken 109 times.
|
219 | rbase = isRgb ? 3 : 0; |
| 812 | 219 | gbase = 1; | |
| 813 |
2/2✓ Branch 0 taken 110 times.
✓ Branch 1 taken 109 times.
|
219 | bbase = isRgb ? 0 : 3; |
| 814 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 219 times.
|
219 | ALLOC_YUV_TABLE(table_plane_size * 3); |
| 815 | 219 | y_table = c->yuvTable; | |
| 816 | 219 | yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy; | |
| 817 |
2/2✓ Branch 0 taken 424422 times.
✓ Branch 1 taken 219 times.
|
424641 | for (i = 0; i < table_plane_size - 110; i++) { |
| 818 | 424422 | int yval = av_clip_uint8((yb + 0x8000) >> 16); | |
| 819 | 424422 | y_table[i + 110] = (yval >> 7) << rbase; | |
| 820 | 424422 | y_table[i + 37 + table_plane_size] = ((yval + 43) / 85) << gbase; | |
| 821 | 424422 | y_table[i + 110 + 2*table_plane_size] = (yval >> 7) << bbase; | |
| 822 | 424422 | yb += cy; | |
| 823 | } | ||
| 824 | 219 | fill_table(c->table_rV, 1, crv, y_table + yoffs); | |
| 825 | 219 | fill_table(c->table_gU, 1, cgu, y_table + yoffs + table_plane_size); | |
| 826 | 219 | fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2*table_plane_size); | |
| 827 | 219 | fill_gv_table(c->table_gV, 1, cgv); | |
| 828 | 219 | break; | |
| 829 | 154 | case 8: | |
| 830 |
2/2✓ Branch 0 taken 70 times.
✓ Branch 1 taken 84 times.
|
154 | rbase = isRgb ? 5 : 0; |
| 831 |
2/2✓ Branch 0 taken 70 times.
✓ Branch 1 taken 84 times.
|
154 | gbase = isRgb ? 2 : 3; |
| 832 |
2/2✓ Branch 0 taken 70 times.
✓ Branch 1 taken 84 times.
|
154 | bbase = isRgb ? 0 : 6; |
| 833 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
|
154 | ALLOC_YUV_TABLE(table_plane_size * 3); |
| 834 | 154 | y_table = c->yuvTable; | |
| 835 | 154 | yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy; | |
| 836 |
2/2✓ Branch 0 taken 309540 times.
✓ Branch 1 taken 154 times.
|
309694 | for (i = 0; i < table_plane_size - 38; i++) { |
| 837 | 309540 | int yval = av_clip_uint8((yb + 0x8000) >> 16); | |
| 838 | 309540 | y_table[i + 16] = ((yval + 18) / 36) << rbase; | |
| 839 | 309540 | y_table[i + 16 + table_plane_size] = ((yval + 18) / 36) << gbase; | |
| 840 | 309540 | y_table[i + 37 + 2*table_plane_size] = ((yval + 43) / 85) << bbase; | |
| 841 | 309540 | yb += cy; | |
| 842 | } | ||
| 843 | 154 | fill_table(c->table_rV, 1, crv, y_table + yoffs); | |
| 844 | 154 | fill_table(c->table_gU, 1, cgu, y_table + yoffs + table_plane_size); | |
| 845 | 154 | fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2*table_plane_size); | |
| 846 | 154 | fill_gv_table(c->table_gV, 1, cgv); | |
| 847 | 154 | break; | |
| 848 | 264 | case 12: | |
| 849 |
2/2✓ Branch 0 taken 132 times.
✓ Branch 1 taken 132 times.
|
264 | rbase = isRgb ? 8 : 0; |
| 850 | 264 | gbase = 4; | |
| 851 |
2/2✓ Branch 0 taken 132 times.
✓ Branch 1 taken 132 times.
|
264 | bbase = isRgb ? 0 : 8; |
| 852 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 264 times.
|
264 | ALLOC_YUV_TABLE(table_plane_size * 3 * 2); |
| 853 | 264 | y_table16 = c->yuvTable; | |
| 854 | 264 | yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy; | |
| 855 |
2/2✓ Branch 0 taken 540672 times.
✓ Branch 1 taken 264 times.
|
540936 | for (i = 0; i < table_plane_size; i++) { |
| 856 | 540672 | uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16); | |
| 857 | 540672 | y_table16[i] = (yval >> 4) << rbase; | |
| 858 | 540672 | y_table16[i + table_plane_size] = (yval >> 4) << gbase; | |
| 859 | 540672 | y_table16[i + 2*table_plane_size] = (yval >> 4) << bbase; | |
| 860 | 540672 | yb += cy; | |
| 861 | } | ||
| 862 |
2/2✓ Branch 0 taken 132 times.
✓ Branch 1 taken 132 times.
|
264 | if (isNotNe) |
| 863 |
2/2✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 132 times.
|
811140 | for (i = 0; i < table_plane_size * 3; i++) |
| 864 | 811008 | y_table16[i] = av_bswap16(y_table16[i]); | |
| 865 | 264 | fill_table(c->table_rV, 2, crv, y_table16 + yoffs); | |
| 866 | 264 | fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + table_plane_size); | |
| 867 | 264 | fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2*table_plane_size); | |
| 868 | 264 | fill_gv_table(c->table_gV, 2, cgv); | |
| 869 | 264 | break; | |
| 870 | 1451 | case 15: | |
| 871 | case 16: | ||
| 872 |
2/2✓ Branch 0 taken 843 times.
✓ Branch 1 taken 608 times.
|
1451 | rbase = isRgb ? bpp - 5 : 0; |
| 873 | 1451 | gbase = 5; | |
| 874 |
2/2✓ Branch 0 taken 608 times.
✓ Branch 1 taken 843 times.
|
1451 | bbase = isRgb ? 0 : (bpp - 5); |
| 875 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1451 times.
|
1451 | ALLOC_YUV_TABLE(table_plane_size * 3 * 2); |
| 876 | 1451 | y_table16 = c->yuvTable; | |
| 877 | 1451 | yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy; | |
| 878 |
2/2✓ Branch 0 taken 2971648 times.
✓ Branch 1 taken 1451 times.
|
2973099 | for (i = 0; i < table_plane_size; i++) { |
| 879 | 2971648 | uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16); | |
| 880 | 2971648 | y_table16[i] = (yval >> 3) << rbase; | |
| 881 | 2971648 | y_table16[i + table_plane_size] = (yval >> (18 - bpp)) << gbase; | |
| 882 | 2971648 | y_table16[i + 2*table_plane_size] = (yval >> 3) << bbase; | |
| 883 | 2971648 | yb += cy; | |
| 884 | } | ||
| 885 |
2/2✓ Branch 0 taken 270 times.
✓ Branch 1 taken 1181 times.
|
1451 | if (isNotNe) |
| 886 |
2/2✓ Branch 0 taken 1658880 times.
✓ Branch 1 taken 270 times.
|
1659150 | for (i = 0; i < table_plane_size * 3; i++) |
| 887 | 1658880 | y_table16[i] = av_bswap16(y_table16[i]); | |
| 888 | 1451 | fill_table(c->table_rV, 2, crv, y_table16 + yoffs); | |
| 889 | 1451 | fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + table_plane_size); | |
| 890 | 1451 | fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2*table_plane_size); | |
| 891 | 1451 | fill_gv_table(c->table_gV, 2, cgv); | |
| 892 | 1451 | break; | |
| 893 | 6686 | case 24: | |
| 894 | case 48: | ||
| 895 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 6686 times.
|
6686 | ALLOC_YUV_TABLE(table_plane_size); |
| 896 | 6686 | y_table = c->yuvTable; | |
| 897 | 6686 | yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy; | |
| 898 |
2/2✓ Branch 0 taken 13692928 times.
✓ Branch 1 taken 6686 times.
|
13699614 | for (i = 0; i < table_plane_size; i++) { |
| 899 | 13692928 | y_table[i] = av_clip_uint8((yb + 0x8000) >> 16); | |
| 900 | 13692928 | yb += cy; | |
| 901 | } | ||
| 902 | 6686 | fill_table(c->table_rV, 1, crv, y_table + yoffs); | |
| 903 | 6686 | fill_table(c->table_gU, 1, cgu, y_table + yoffs); | |
| 904 | 6686 | fill_table(c->table_bU, 1, cbu, y_table + yoffs); | |
| 905 | 6686 | fill_gv_table(c->table_gV, 1, cgv); | |
| 906 | 6686 | break; | |
| 907 | 1524 | case 30: | |
| 908 |
2/2✓ Branch 0 taken 134 times.
✓ Branch 1 taken 1390 times.
|
1524 | rbase = isRgb ? 20 : 0; |
| 909 | 1524 | gbase = 10; | |
| 910 |
2/2✓ Branch 0 taken 134 times.
✓ Branch 1 taken 1390 times.
|
1524 | bbase = isRgb ? 0 : 20; |
| 911 | 1524 | needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format); | |
| 912 |
2/2✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 16 times.
|
1524 | if (!needAlpha) |
| 913 | 1508 | abase = 30; | |
| 914 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1524 times.
|
1524 | ALLOC_YUV_TABLE(table_plane_size * 3 * 4); |
| 915 | 1524 | y_table32 = c->yuvTable; | |
| 916 | 1524 | yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy; | |
| 917 |
2/2✓ Branch 0 taken 3121152 times.
✓ Branch 1 taken 1524 times.
|
3122676 | for (i = 0; i < table_plane_size; i++) { |
| 918 | 3121152 | unsigned yval = av_clip_uintp2((yb + 0x8000) >> 14, 10); | |
| 919 |
2/2✓ Branch 0 taken 3088384 times.
✓ Branch 1 taken 32768 times.
|
3121152 | y_table32[i]= (yval << rbase) + (needAlpha ? 0 : (255u << abase)); |
| 920 | 3121152 | y_table32[i + table_plane_size] = yval << gbase; | |
| 921 | 3121152 | y_table32[i + 2 * table_plane_size] = yval << bbase; | |
| 922 | 3121152 | yb += cy; | |
| 923 | } | ||
| 924 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1524 times.
|
1524 | if (isNotNe) { |
| 925 | ✗ | for (i = 0; i < table_plane_size * 3; i++) | |
| 926 | ✗ | y_table32[i] = av_bswap32(y_table32[i]); | |
| 927 | } | ||
| 928 | 1524 | fill_table(c->table_rV, 4, crv, y_table32 + yoffs); | |
| 929 | 1524 | fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + table_plane_size); | |
| 930 | 1524 | fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2 * table_plane_size); | |
| 931 | 1524 | fill_gv_table(c->table_gV, 4, cgv); | |
| 932 | 1524 | break; | |
| 933 | 2241 | case 32: | |
| 934 | case 64: | ||
| 935 | 6455 | base = (c->opts.dst_format == AV_PIX_FMT_RGB32_1 || | |
| 936 |
4/4✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 268 times.
✓ Branch 2 taken 288 times.
✓ Branch 3 taken 1685 times.
|
2241 | c->opts.dst_format == AV_PIX_FMT_BGR32_1) ? 8 : 0; |
| 937 |
2/2✓ Branch 0 taken 1091 times.
✓ Branch 1 taken 1150 times.
|
2241 | rbase = base + (isRgb ? 16 : 0); |
| 938 | 2241 | gbase = base + 8; | |
| 939 |
2/2✓ Branch 0 taken 1091 times.
✓ Branch 1 taken 1150 times.
|
2241 | bbase = base + (isRgb ? 0 : 16); |
| 940 | 2241 | needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format); | |
| 941 |
2/2✓ Branch 0 taken 1529 times.
✓ Branch 1 taken 712 times.
|
2241 | if (!needAlpha) |
| 942 | 1529 | abase = (base + 24) & 31; | |
| 943 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2241 times.
|
2241 | ALLOC_YUV_TABLE(table_plane_size * 3 * 4); |
| 944 | 2241 | y_table32 = c->yuvTable; | |
| 945 | 2241 | yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy; | |
| 946 |
2/2✓ Branch 0 taken 4589568 times.
✓ Branch 1 taken 2241 times.
|
4591809 | for (i = 0; i < table_plane_size; i++) { |
| 947 | 4589568 | unsigned yval = av_clip_uint8((yb + 0x8000) >> 16); | |
| 948 | 9179136 | y_table32[i] = (yval << rbase) + | |
| 949 |
2/2✓ Branch 0 taken 3131392 times.
✓ Branch 1 taken 1458176 times.
|
4589568 | (needAlpha ? 0 : (255u << abase)); |
| 950 | 4589568 | y_table32[i + table_plane_size] = yval << gbase; | |
| 951 | 4589568 | y_table32[i + 2*table_plane_size] = yval << bbase; | |
| 952 | 4589568 | yb += cy; | |
| 953 | } | ||
| 954 | 2241 | fill_table(c->table_rV, 4, crv, y_table32 + yoffs); | |
| 955 | 2241 | fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + table_plane_size); | |
| 956 | 2241 | fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2*table_plane_size); | |
| 957 | 2241 | fill_gv_table(c->table_gV, 4, cgv); | |
| 958 | 2241 | break; | |
| 959 | 1992 | default: | |
| 960 |
2/4✓ Branch 1 taken 1992 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1992 times.
|
1992 | if(!isPlanar(c->opts.dst_format) || bpp <= 24) |
| 961 | ✗ | av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp); | |
| 962 | 1992 | return AVERROR(EINVAL); | |
| 963 | } | ||
| 964 | 12817 | return 0; | |
| 965 | } | ||
| 966 |