Debian Codegraph @

thirdparty/misc/yuv2rgb.h

raw symbols SCIP
1 /* Thirdparty code presumably from http://wss.co.uk/pinknoise/yuv2rgb/ */
2
3 /*
4 This YUV2RGB code is Copyright (C) 2008-11 Robin Watts
5 <[email protected]>.
6
7 The software is released under the BSD license.
8
9 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
10 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
11 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
12 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
13 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
14 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
15 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
16 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
17 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
19 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20
21 In particular, I warrant absolutely nothing about how patent free
22 this method is. It is your responsibility to ensure that this code
23 does not infringe any patents that apply in your area before you
24 ship it.
25 */
26
27 /*
28 * Please note that this version has been modified for various reasons:
29 * 1. Using the Godot core typedefs
30 * 2. At some point or another the code relied on the byte order of a uint32_t, this has been fixed
31 * 3. Output has been reordered to struct { uint8_t r, g, b, a; } precisely in accordance with the function names
32 * 4. Removing unused 'dither' parameter
33 * 5. Fix last line not being converted (and therefore was transparent)
34 */
35
36 #ifndef YUV2RGB_H
37 #define YUV2RGB_H
38
39 #include "core/typedefs.h"
40
41 static const uint32_t tables[256*3] = {
42 /* y_table */
43 0x7FFFFFEDU,
44 0x7FFFFFEFU,
45 0x7FFFFFF0U,
46 0x7FFFFFF1U,
47 0x7FFFFFF2U,
48 0x7FFFFFF3U,
49 0x7FFFFFF4U,
50 0x7FFFFFF6U,
51 0x7FFFFFF7U,
52 0x7FFFFFF8U,
53 0x7FFFFFF9U,
54 0x7FFFFFFAU,
55 0x7FFFFFFBU,
56 0x7FFFFFFDU,
57 0x7FFFFFFEU,
58 0x7FFFFFFFU,
59 0x80000000U,
60 0x80400801U,
61 0x80A01002U,
62 0x80E01803U,
63 0x81202805U,
64 0x81803006U,
65 0x81C03807U,
66 0x82004008U,
67 0x82604809U,
68 0x82A0500AU,
69 0x82E0600CU,
70 0x8340680DU,
71 0x8380700EU,
72 0x83C0780FU,
73 0x84208010U,
74 0x84608811U,
75 0x84A09813U,
76 0x8500A014U,
77 0x8540A815U,
78 0x8580B016U,
79 0x85E0B817U,
80 0x8620C018U,
81 0x8660D01AU,
82 0x86C0D81BU,
83 0x8700E01CU,
84 0x8740E81DU,
85 0x87A0F01EU,
86 0x87E0F81FU,
87 0x88210821U,
88 0x88811022U,
89 0x88C11823U,
90 0x89012024U,
91 0x89412825U,
92 0x89A13026U,
93 0x89E14028U,
94 0x8A214829U,
95 0x8A81502AU,
96 0x8AC1582BU,
97 0x8B01602CU,
98 0x8B61682DU,
99 0x8BA1782FU,
100 0x8BE18030U,
101 0x8C418831U,
102 0x8C819032U,
103 0x8CC19833U,
104 0x8D21A034U,
105 0x8D61B036U,
106 0x8DA1B837U,
107 0x8E01C038U,
108 0x8E41C839U,
109 0x8E81D03AU,
110 0x8EE1D83BU,
111 0x8F21E83DU,
112 0x8F61F03EU,
113 0x8FC1F83FU,
114 0x90020040U,
115 0x90420841U,
116 0x90A21042U,
117 0x90E22044U,
118 0x91222845U,
119 0x91823046U,
120 0x91C23847U,
121 0x92024048U,
122 0x92624849U,
123 0x92A2504AU,
124 0x92E2604CU,
125 0x9342684DU,
126 0x9382704EU,
127 0x93C2784FU,
128 0x94228050U,
129 0x94628851U,
130 0x94A29853U,
131 0x9502A054U,
132 0x9542A855U,
133 0x9582B056U,
134 0x95E2B857U,
135 0x9622C058U,
136 0x9662D05AU,
137 0x96C2D85BU,
138 0x9702E05CU,
139 0x9742E85DU,
140 0x97A2F05EU,
141 0x97E2F85FU,
142 0x98230861U,
143 0x98831062U,
144 0x98C31863U,
145 0x99032064U,
146 0x99632865U,
147 0x99A33066U,
148 0x99E34068U,
149 0x9A434869U,
150 0x9A83506AU,
151 0x9AC3586BU,
152 0x9B23606CU,
153 0x9B63686DU,
154 0x9BA3786FU,
155 0x9BE38070U,
156 0x9C438871U,
157 0x9C839072U,
158 0x9CC39873U,
159 0x9D23A074U,
160 0x9D63B076U,
161 0x9DA3B877U,
162 0x9E03C078U,
163 0x9E43C879U,
164 0x9E83D07AU,
165 0x9EE3D87BU,
166 0x9F23E87DU,
167 0x9F63F07EU,
168 0x9FC3F87FU,
169 0xA0040080U,
170 0xA0440881U,
171 0xA0A41082U,
172 0xA0E42084U,
173 0xA1242885U,
174 0xA1843086U,
175 0xA1C43887U,
176 0xA2044088U,
177 0xA2644889U,
178 0xA2A4588BU,
179 0xA2E4608CU,
180 0xA344688DU,
181 0xA384708EU,
182 0xA3C4788FU,
183 0xA4248090U,
184 0xA4649092U,
185 0xA4A49893U,
186 0xA504A094U,
187 0xA544A895U,
188 0xA584B096U,
189 0xA5E4B897U,
190 0xA624C098U,
191 0xA664D09AU,
192 0xA6C4D89BU,
193 0xA704E09CU,
194 0xA744E89DU,
195 0xA7A4F09EU,
196 0xA7E4F89FU,
197 0xA82508A1U,
198 0xA88510A2U,
199 0xA8C518A3U,
200 0xA90520A4U,
201 0xA96528A5U,
202 0xA9A530A6U,
203 0xA9E540A8U,
204 0xAA4548A9U,
205 0xAA8550AAU,
206 0xAAC558ABU,
207 0xAB2560ACU,
208 0xAB6568ADU,
209 0xABA578AFU,
210 0xAC0580B0U,
211 0xAC4588B1U,
212 0xAC8590B2U,
213 0xACE598B3U,
214 0xAD25A0B4U,
215 0xAD65B0B6U,
216 0xADA5B8B7U,
217 0xAE05C0B8U,
218 0xAE45C8B9U,
219 0xAE85D0BAU,
220 0xAEE5D8BBU,
221 0xAF25E8BDU,
222 0xAF65F0BEU,
223 0xAFC5F8BFU,
224 0xB00600C0U,
225 0xB04608C1U,
226 0xB0A610C2U,
227 0xB0E620C4U,
228 0xB12628C5U,
229 0xB18630C6U,
230 0xB1C638C7U,
231 0xB20640C8U,
232 0xB26648C9U,
233 0xB2A658CBU,
234 0xB2E660CCU,
235 0xB34668CDU,
236 0xB38670CEU,
237 0xB3C678CFU,
238 0xB42680D0U,
239 0xB46690D2U,
240 0xB4A698D3U,
241 0xB506A0D4U,
242 0xB546A8D5U,
243 0xB586B0D6U,
244 0xB5E6B8D7U,
245 0xB626C8D9U,
246 0xB666D0DAU,
247 0xB6C6D8DBU,
248 0xB706E0DCU,
249 0xB746E8DDU,
250 0xB7A6F0DEU,
251 0xB7E6F8DFU,
252 0xB82708E1U,
253 0xB88710E2U,
254 0xB8C718E3U,
255 0xB90720E4U,
256 0xB96728E5U,
257 0xB9A730E6U,
258 0xB9E740E8U,
259 0xBA4748E9U,
260 0xBA8750EAU,
261 0xBAC758EBU,
262 0xBB2760ECU,
263 0xBB6768EDU,
264 0xBBA778EFU,
265 0xBC0780F0U,
266 0xBC4788F1U,
267 0xBC8790F2U,
268 0xBCE798F3U,
269 0xBD27A0F4U,
270 0xBD67B0F6U,
271 0xBDC7B8F7U,
272 0xBE07C0F8U,
273 0xBE47C8F9U,
274 0xBEA7D0FAU,
275 0xBEE7D8FBU,
276 0xBF27E8FDU,
277 0xBF87F0FEU,
278 0xBFC7F8FFU,
279 0xC0080100U,
280 0xC0480901U,
281 0xC0A81102U,
282 0xC0E82104U,
283 0xC0E82104U,
284 0xC0E82104U,
285 0xC0E82104U,
286 0xC0E82104U,
287 0xC0E82104U,
288 0xC0E82104U,
289 0xC0E82104U,
290 0xC0E82104U,
291 0xC0E82104U,
292 0xC0E82104U,
293 0xC0E82104U,
294 0xC0E82104U,
295 0xC0E82104U,
296 0xC0E82104U,
297 0xC0E82104U,
298 0xC0E82104U,
299 /* u_table */
300 0x0C400103U,
301 0x0C200105U,
302 0x0C200107U,
303 0x0C000109U,
304 0x0BE0010BU,
305 0x0BC0010DU,
306 0x0BA0010FU,
307 0x0BA00111U,
308 0x0B800113U,
309 0x0B600115U,
310 0x0B400117U,
311 0x0B400119U,
312 0x0B20011BU,
313 0x0B00011DU,
314 0x0AE0011FU,
315 0x0AE00121U,
316 0x0AC00123U,
317 0x0AA00125U,
318 0x0A800127U,
319 0x0A600129U,
320 0x0A60012BU,
321 0x0A40012DU,
322 0x0A20012FU,
323 0x0A000131U,
324 0x0A000132U,
325 0x09E00134U,
326 0x09C00136U,
327 0x09A00138U,
328 0x09A0013AU,
329 0x0980013CU,
330 0x0960013EU,
331 0x09400140U,
332 0x09400142U,
333 0x09200144U,
334 0x09000146U,
335 0x08E00148U,
336 0x08C0014AU,
337 0x08C0014CU,
338 0x08A0014EU,
339 0x08800150U,
340 0x08600152U,
341 0x08600154U,
342 0x08400156U,
343 0x08200158U,
344 0x0800015AU,
345 0x0800015CU,
346 0x07E0015EU,
347 0x07C00160U,
348 0x07A00162U,
349 0x07A00164U,
350 0x07800166U,
351 0x07600168U,
352 0x0740016AU,
353 0x0720016CU,
354 0x0720016EU,
355 0x07000170U,
356 0x06E00172U,
357 0x06C00174U,
358 0x06C00176U,
359 0x06A00178U,
360 0x0680017AU,
361 0x0660017CU,
362 0x0660017EU,
363 0x06400180U,
364 0x06200182U,
365 0x06000184U,
366 0x05E00185U,
367 0x05E00187U,
368 0x05C00189U,
369 0x05A0018BU,
370 0x0580018DU,
371 0x0580018FU,
372 0x05600191U,
373 0x05400193U,
374 0x05200195U,
375 0x05200197U,
376 0x05000199U,
377 0x04E0019BU,
378 0x04C0019DU,
379 0x04C0019FU,
380 0x04A001A1U,
381 0x048001A3U,
382 0x046001A5U,
383 0x044001A7U,
384 0x044001A9U,
385 0x042001ABU,
386 0x040001ADU,
387 0x03E001AFU,
388 0x03E001B1U,
389 0x03C001B3U,
390 0x03A001B5U,
391 0x038001B7U,
392 0x038001B9U,
393 0x036001BBU,
394 0x034001BDU,
395 0x032001BFU,
396 0x032001C1U,
397 0x030001C3U,
398 0x02E001C5U,
399 0x02C001C7U,
400 0x02A001C9U,
401 0x02A001CBU,
402 0x028001CDU,
403 0x026001CFU,
404 0x024001D1U,
405 0x024001D3U,
406 0x022001D5U,
407 0x020001D7U,
408 0x01E001D8U,
409 0x01E001DAU,
410 0x01C001DCU,
411 0x01A001DEU,
412 0x018001E0U,
413 0x016001E2U,
414 0x016001E4U,
415 0x014001E6U,
416 0x012001E8U,
417 0x010001EAU,
418 0x010001ECU,
419 0x00E001EEU,
420 0x00C001F0U,
421 0x00A001F2U,
422 0x00A001F4U,
423 0x008001F6U,
424 0x006001F8U,
425 0x004001FAU,
426 0x004001FCU,
427 0x002001FEU,
428 0x00000200U,
429 0xFFE00202U,
430 0xFFC00204U,
431 0xFFC00206U,
432 0xFFA00208U,
433 0xFF80020AU,
434 0xFF60020CU,
435 0xFF60020EU,
436 0xFF400210U,
437 0xFF200212U,
438 0xFF000214U,
439 0xFF000216U,
440 0xFEE00218U,
441 0xFEC0021AU,
442 0xFEA0021CU,
443 0xFEA0021EU,
444 0xFE800220U,
445 0xFE600222U,
446 0xFE400224U,
447 0xFE200226U,
448 0xFE200228U,
449 0xFE000229U,
450 0xFDE0022BU,
451 0xFDC0022DU,
452 0xFDC0022FU,
453 0xFDA00231U,
454 0xFD800233U,
455 0xFD600235U,
456 0xFD600237U,
457 0xFD400239U,
458 0xFD20023BU,
459 0xFD00023DU,
460 0xFCE0023FU,
461 0xFCE00241U,
462 0xFCC00243U,
463 0xFCA00245U,
464 0xFC800247U,
465 0xFC800249U,
466 0xFC60024BU,
467 0xFC40024DU,
468 0xFC20024FU,
469 0xFC200251U,
470 0xFC000253U,
471 0xFBE00255U,
472 0xFBC00257U,
473 0xFBC00259U,
474 0xFBA0025BU,
475 0xFB80025DU,
476 0xFB60025FU,
477 0xFB400261U,
478 0xFB400263U,
479 0xFB200265U,
480 0xFB000267U,
481 0xFAE00269U,
482 0xFAE0026BU,
483 0xFAC0026DU,
484 0xFAA0026FU,
485 0xFA800271U,
486 0xFA800273U,
487 0xFA600275U,
488 0xFA400277U,
489 0xFA200279U,
490 0xFA20027BU,
491 0xFA00027CU,
492 0xF9E0027EU,
493 0xF9C00280U,
494 0xF9A00282U,
495 0xF9A00284U,
496 0xF9800286U,
497 0xF9600288U,
498 0xF940028AU,
499 0xF940028CU,
500 0xF920028EU,
501 0xF9000290U,
502 0xF8E00292U,
503 0xF8E00294U,
504 0xF8C00296U,
505 0xF8A00298U,
506 0xF880029AU,
507 0xF860029CU,
508 0xF860029EU,
509 0xF84002A0U,
510 0xF82002A2U,
511 0xF80002A4U,
512 0xF80002A6U,
513 0xF7E002A8U,
514 0xF7C002AAU,
515 0xF7A002ACU,
516 0xF7A002AEU,
517 0xF78002B0U,
518 0xF76002B2U,
519 0xF74002B4U,
520 0xF74002B6U,
521 0xF72002B8U,
522 0xF70002BAU,
523 0xF6E002BCU,
524 0xF6C002BEU,
525 0xF6C002C0U,
526 0xF6A002C2U,
527 0xF68002C4U,
528 0xF66002C6U,
529 0xF66002C8U,
530 0xF64002CAU,
531 0xF62002CCU,
532 0xF60002CEU,
533 0xF60002CFU,
534 0xF5E002D1U,
535 0xF5C002D3U,
536 0xF5A002D5U,
537 0xF5A002D7U,
538 0xF58002D9U,
539 0xF56002DBU,
540 0xF54002DDU,
541 0xF52002DFU,
542 0xF52002E1U,
543 0xF50002E3U,
544 0xF4E002E5U,
545 0xF4C002E7U,
546 0xF4C002E9U,
547 0xF4A002EBU,
548 0xF48002EDU,
549 0xF46002EFU,
550 0xF46002F1U,
551 0xF44002F3U,
552 0xF42002F5U,
553 0xF40002F7U,
554 0xF3E002F9U,
555 0xF3E002FBU,
556 /* v_table */
557 0x1A09A000U,
558 0x19E9A800U,
559 0x19A9B800U,
560 0x1969C800U,
561 0x1949D000U,
562 0x1909E000U,
563 0x18C9E800U,
564 0x18A9F800U,
565 0x186A0000U,
566 0x182A1000U,
567 0x180A2000U,
568 0x17CA2800U,
569 0x17AA3800U,
570 0x176A4000U,
571 0x172A5000U,
572 0x170A6000U,
573 0x16CA6800U,
574 0x168A7800U,
575 0x166A8000U,
576 0x162A9000U,
577 0x160AA000U,
578 0x15CAA800U,
579 0x158AB800U,
580 0x156AC000U,
581 0x152AD000U,
582 0x14EAE000U,
583 0x14CAE800U,
584 0x148AF800U,
585 0x146B0000U,
586 0x142B1000U,
587 0x13EB2000U,
588 0x13CB2800U,
589 0x138B3800U,
590 0x134B4000U,
591 0x132B5000U,
592 0x12EB6000U,
593 0x12CB6800U,
594 0x128B7800U,
595 0x124B8000U,
596 0x122B9000U,
597 0x11EBA000U,
598 0x11ABA800U,
599 0x118BB800U,
600 0x114BC000U,
601 0x112BD000U,
602 0x10EBE000U,
603 0x10ABE800U,
604 0x108BF800U,
605 0x104C0000U,
606 0x100C1000U,
607 0x0FEC2000U,
608 0x0FAC2800U,
609 0x0F8C3800U,
610 0x0F4C4000U,
611 0x0F0C5000U,
612 0x0EEC5800U,
613 0x0EAC6800U,
614 0x0E6C7800U,
615 0x0E4C8000U,
616 0x0E0C9000U,
617 0x0DEC9800U,
618 0x0DACA800U,
619 0x0D6CB800U,
620 0x0D4CC000U,
621 0x0D0CD000U,
622 0x0CCCD800U,
623 0x0CACE800U,
624 0x0C6CF800U,
625 0x0C4D0000U,
626 0x0C0D1000U,
627 0x0BCD1800U,
628 0x0BAD2800U,
629 0x0B6D3800U,
630 0x0B2D4000U,
631 0x0B0D5000U,
632 0x0ACD5800U,
633 0x0AAD6800U,
634 0x0A6D7800U,
635 0x0A2D8000U,
636 0x0A0D9000U,
637 0x09CD9800U,
638 0x098DA800U,
639 0x096DB800U,
640 0x092DC000U,
641 0x090DD000U,
642 0x08CDD800U,
643 0x088DE800U,
644 0x086DF800U,
645 0x082E0000U,
646 0x07EE1000U,
647 0x07CE1800U,
648 0x078E2800U,
649 0x076E3800U,
650 0x072E4000U,
651 0x06EE5000U,
652 0x06CE5800U,
653 0x068E6800U,
654 0x064E7800U,
655 0x062E8000U,
656 0x05EE9000U,
657 0x05CE9800U,
658 0x058EA800U,
659 0x054EB800U,
660 0x052EC000U,
661 0x04EED000U,
662 0x04AED800U,
663 0x048EE800U,
664 0x044EF000U,
665 0x042F0000U,
666 0x03EF1000U,
667 0x03AF1800U,
668 0x038F2800U,
669 0x034F3000U,
670 0x030F4000U,
671 0x02EF5000U,
672 0x02AF5800U,
673 0x028F6800U,
674 0x024F7000U,
675 0x020F8000U,
676 0x01EF9000U,
677 0x01AF9800U,
678 0x016FA800U,
679 0x014FB000U,
680 0x010FC000U,
681 0x00EFD000U,
682 0x00AFD800U,
683 0x006FE800U,
684 0x004FF000U,
685 0x00100000U,
686 0xFFD01000U,
687 0xFFB01800U,
688 0xFF702800U,
689 0xFF303000U,
690 0xFF104000U,
691 0xFED05000U,
692 0xFEB05800U,
693 0xFE706800U,
694 0xFE307000U,
695 0xFE108000U,
696 0xFDD09000U,
697 0xFD909800U,
698 0xFD70A800U,
699 0xFD30B000U,
700 0xFD10C000U,
701 0xFCD0D000U,
702 0xFC90D800U,
703 0xFC70E800U,
704 0xFC30F000U,
705 0xFBF10000U,
706 0xFBD11000U,
707 0xFB911800U,
708 0xFB712800U,
709 0xFB313000U,
710 0xFAF14000U,
711 0xFAD14800U,
712 0xFA915800U,
713 0xFA516800U,
714 0xFA317000U,
715 0xF9F18000U,
716 0xF9D18800U,
717 0xF9919800U,
718 0xF951A800U,
719 0xF931B000U,
720 0xF8F1C000U,
721 0xF8B1C800U,
722 0xF891D800U,
723 0xF851E800U,
724 0xF831F000U,
725 0xF7F20000U,
726 0xF7B20800U,
727 0xF7921800U,
728 0xF7522800U,
729 0xF7123000U,
730 0xF6F24000U,
731 0xF6B24800U,
732 0xF6925800U,
733 0xF6526800U,
734 0xF6127000U,
735 0xF5F28000U,
736 0xF5B28800U,
737 0xF5729800U,
738 0xF552A800U,
739 0xF512B000U,
740 0xF4F2C000U,
741 0xF4B2C800U,
742 0xF472D800U,
743 0xF452E800U,
744 0xF412F000U,
745 0xF3D30000U,
746 0xF3B30800U,
747 0xF3731800U,
748 0xF3532800U,
749 0xF3133000U,
750 0xF2D34000U,
751 0xF2B34800U,
752 0xF2735800U,
753 0xF2336800U,
754 0xF2137000U,
755 0xF1D38000U,
756 0xF1B38800U,
757 0xF1739800U,
758 0xF133A800U,
759 0xF113B000U,
760 0xF0D3C000U,
761 0xF093C800U,
762 0xF073D800U,
763 0xF033E000U,
764 0xF013F000U,
765 0xEFD40000U,
766 0xEF940800U,
767 0xEF741800U,
768 0xEF342000U,
769 0xEEF43000U,
770 0xEED44000U,
771 0xEE944800U,
772 0xEE745800U,
773 0xEE346000U,
774 0xEDF47000U,
775 0xEDD48000U,
776 0xED948800U,
777 0xED549800U,
778 0xED34A000U,
779 0xECF4B000U,
780 0xECD4C000U,
781 0xEC94C800U,
782 0xEC54D800U,
783 0xEC34E000U,
784 0xEBF4F000U,
785 0xEBB50000U,
786 0xEB950800U,
787 0xEB551800U,
788 0xEB352000U,
789 0xEAF53000U,
790 0xEAB54000U,
791 0xEA954800U,
792 0xEA555800U,
793 0xEA156000U,
794 0xE9F57000U,
795 0xE9B58000U,
796 0xE9958800U,
797 0xE9559800U,
798 0xE915A000U,
799 0xE8F5B000U,
800 0xE8B5C000U,
801 0xE875C800U,
802 0xE855D800U,
803 0xE815E000U,
804 0xE7F5F000U,
805 0xE7B60000U,
806 0xE7760800U,
807 0xE7561800U,
808 0xE7162000U,
809 0xE6D63000U,
810 0xE6B64000U,
811 0xE6764800U,
812 0xE6365800U
813 };
814
815 /* -- Common -- */
816
817 #define FLAGS 0x40080100
818 #define READUV(U,V) (tables[256 + (U)] + tables[512 + (V)])
819 #define READY(Y) tables[Y]
820 #define FIXUP(Y) \
821 do { \
822 int tmp = (Y) & FLAGS; \
823 if (tmp != 0) \
824 { \
825 tmp -= tmp>>8; \
826 (Y) |= tmp; \
827 tmp = FLAGS & ~(Y>>1); \
828 (Y) += tmp>>8; \
829 } \
830 } while (0 == 1)
831
832 #define STORE(Y,DSTPTR) \
833 do { \
834 *(DSTPTR)++ = (Y)>>11; \
835 *(DSTPTR)++ = (Y)>>22; \
836 *(DSTPTR)++ = (Y); \
837 *(DSTPTR)++ = 255; \
838 } while (0 == 1)
839
840 /* -- End Common -- */
841
842 static void yuv422_2_rgb8888(uint8_t *dst_ptr,
843 const uint8_t *y_ptr,
844 const uint8_t *u_ptr,
845 const uint8_t *v_ptr,
846 int32_t width,
847 int32_t height,
848 int32_t y_span,
849 int32_t uv_span,
850 int32_t dst_span)
851 {
852 while (height > 0)
853 {
854 height -= width<<16;
855 height += 1<<16;
856 while (height < 0)
857 {
858 /* Do top row pair */
859 uint32_t uv, y0, y1;
860
861 uv = READUV(*u_ptr++,*v_ptr++);
862 y0 = uv + READY(*y_ptr++);
863 y1 = uv + READY(*y_ptr++);
864 FIXUP(y0);
865 FIXUP(y1);
866 STORE(y0, dst_ptr);
867 STORE(y1, dst_ptr);
868 height += (2<<16);
869 }
870 if ((height>>16) == 0)
871 {
872 /* Trailing top row pix */
873 uint32_t uv, y0;
874
875 uv = READUV(*u_ptr,*v_ptr);
876 y0 = uv + READY(*y_ptr++);
877 FIXUP(y0);
878 STORE(y0, dst_ptr);
879 }
880 dst_ptr += dst_span-width*4;
881 y_ptr += y_span-width;
882 u_ptr += uv_span-(width>>1);
883 v_ptr += uv_span-(width>>1);
884 height = (height<<16)>>16;
885 height -= 1;
886 if (height == 0)
887 break;
888 height -= width<<16;
889 height += 1<<16;
890 while (height < 0)
891 {
892 /* Do second row pair */
893 uint32_t uv, y0, y1;
894
895 uv = READUV(*u_ptr++,*v_ptr++);
896 y0 = uv + READY(*y_ptr++);
897 y1 = uv + READY(*y_ptr++);
898 FIXUP(y0);
899 FIXUP(y1);
900 STORE(y0, dst_ptr);
901 STORE(y1, dst_ptr);
902 height += (2<<16);
903 }
904 if ((height>>16) == 0)
905 {
906 /* Trailing bottom row pix */
907 uint32_t uv, y0;
908
909 uv = READUV(*u_ptr,*v_ptr);
910 y0 = uv + READY(*y_ptr++);
911 FIXUP(y0);
912 STORE(y0, dst_ptr);
913 }
914 dst_ptr += dst_span-width*4;
915 y_ptr += y_span-width;
916 u_ptr += uv_span-(width>>1);
917 v_ptr += uv_span-(width>>1);
918 height = (height<<16)>>16;
919 height -= 1;
920 }
921 }
922
923 static void yuv420_2_rgb8888(uint8_t *dst_ptr,
924 const uint8_t *y_ptr,
925 const uint8_t *u_ptr,
926 const uint8_t *v_ptr,
927 int32_t width,
928 int32_t height,
929 int32_t y_span,
930 int32_t uv_span,
931 int32_t dst_span)
932 {
933 /* The 'dst_ptr as uint32_t' thing is not endianness-aware, so that's been removed. */
934 height -= 1;
935 while (height > 0)
936 {
937 height -= width<<16;
938 height += 1<<16;
939 while (height < 0)
940 {
941 /* Do 2 column pairs */
942 uint32_t uv, y0, y1;
943 uint8_t * dst_ptr_1span = dst_ptr + dst_span;
944
945 uv = READUV(*u_ptr++,*v_ptr++);
946 y1 = uv + READY(y_ptr[y_span]);
947 y0 = uv + READY(*y_ptr++);
948 FIXUP(y1);
949 FIXUP(y0);
950 STORE(y1, dst_ptr_1span);
951 STORE(y0, dst_ptr);
952 y1 = uv + READY(y_ptr[y_span]);
953 y0 = uv + READY(*y_ptr++);
954 FIXUP(y1);
955 FIXUP(y0);
956 STORE(y1, dst_ptr_1span);
957 STORE(y0, dst_ptr);
958 height += (2<<16);
959 }
960 if ((height>>16) == 0)
961 {
962 /* Trailing column pair */
963 uint32_t uv, y0, y1;
964 uint8_t * dst_ptr_1span = dst_ptr + dst_span;
965
966 uv = READUV(*u_ptr,*v_ptr);
967 y1 = uv + READY(y_ptr[y_span]);
968 y0 = uv + READY(*y_ptr++);
969 FIXUP(y1);
970 FIXUP(y0);
971 STORE(y0, dst_ptr_1span);
972 STORE(y1, dst_ptr);
973 }
974 dst_ptr += (dst_span * 2) - (width * 4);
975 y_ptr += y_span*2-width;
976 u_ptr += uv_span-(width>>1);
977 v_ptr += uv_span-(width>>1);
978 height = (height<<16)>>16;
979 height -= 2;
980 }
981 if (height == 0)
982 {
983 /* Trail row */
984 height -= width<<16;
985 height += 1<<16;
986 while (height < 0)
987 {
988 /* Do a row pair */
989 uint32_t uv, y0, y1;
990
991 uv = READUV(*u_ptr++,*v_ptr++);
992 y1 = uv + READY(*y_ptr++);
993 y0 = uv + READY(*y_ptr++);
994 FIXUP(y1);
995 FIXUP(y0);
996 STORE(y1, dst_ptr);
997 STORE(y0, dst_ptr);
998 height += (2<<16);
999 }
1000 if ((height>>16) == 0)
1001 {
1002 /* Trailing pix */
1003 uint32_t uv, y0;
1004
1005 uv = READUV(*u_ptr++,*v_ptr++);
1006 y0 = uv + READY(*y_ptr++);
1007 FIXUP(y0);
1008 STORE(y0, dst_ptr);
1009 }
1010 }
1011 }
1012
1013 static void yuv444_2_rgb8888(uint8_t *dst_ptr,
1014 const uint8_t *y_ptr,
1015 const uint8_t *u_ptr,
1016 const uint8_t *v_ptr,
1017 int32_t width,
1018 int32_t height,
1019 int32_t y_span,
1020 int32_t uv_span,
1021 int32_t dst_span)
1022 {
1023 while (height > 0)
1024 {
1025 height -= width<<16;
1026 height += 1<<16;
1027 while (height < 0)
1028 {
1029 /* Do top row pair */
1030 uint32_t uv, y0, y1;
1031
1032 uv = READUV(*u_ptr++,*v_ptr++);
1033 y0 = uv + READY(*y_ptr++);
1034 FIXUP(y0);
1035 STORE(y0, dst_ptr);
1036 uv = READUV(*u_ptr++,*v_ptr++);
1037 y1 = uv + READY(*y_ptr++);
1038 FIXUP(y1);
1039 STORE(y1, dst_ptr);
1040 height += (2<<16);
1041 }
1042 if ((height>>16) == 0)
1043 {
1044 /* Trailing top row pix */
1045 uint32_t uv, y0;
1046
1047 uv = READUV(*u_ptr++,*v_ptr++);
1048 y0 = uv + READY(*y_ptr++);
1049 FIXUP(y0);
1050 STORE(y0, dst_ptr);
1051 }
1052 dst_ptr += dst_span-width*4;
1053 y_ptr += y_span-width;
1054 u_ptr += uv_span-width;
1055 v_ptr += uv_span-width;
1056 height = (height<<16)>>16;
1057 height -= 1;
1058 if (height == 0)
1059 break;
1060 height -= width<<16;
1061 height += 1<<16;
1062 while (height < 0)
1063 {
1064 /* Do second row pair */
1065 uint32_t uv, y0, y1;
1066
1067 uv = READUV(*u_ptr++,*v_ptr++);
1068 y0 = uv + READY(*y_ptr++);
1069 FIXUP(y0);
1070 STORE(y0, dst_ptr);
1071 uv = READUV(*u_ptr++,*v_ptr++);
1072 y1 = uv + READY(*y_ptr++);
1073 FIXUP(y1);
1074 STORE(y1, dst_ptr);
1075 height += (2<<16);
1076 }
1077 if ((height>>16) == 0)
1078 {
1079 /* Trailing bottom row pix */
1080 uint32_t uv, y0;
1081
1082 uv = READUV(*u_ptr++,*v_ptr++);
1083 y0 = uv + READY(*y_ptr++);
1084 FIXUP(y0);
1085 STORE(y0, dst_ptr);
1086 }
1087 dst_ptr += dst_span-width*4;
1088 y_ptr += y_span-width;
1089 u_ptr += uv_span-width;
1090 v_ptr += uv_span-width;
1091 height = (height<<16)>>16;
1092 height -= 1;
1093 }
1094 }
1095
1096 #undef FLAGS
1097 #undef READUV
1098 #undef READY
1099 #undef FIXUP
1100 #undef STORE
1101
1102 #endif // YUV2RGB_H