annotate postproc/yuv2rgb.c @ 6548:e56e991d2ee7

EvEqualeaser --> EvEqualizer, since Atmos just committed my typo fix.
author diego
date Mon, 24 Jun 2002 11:07:50 +0000
parents e7635c03910f
children aad616b63bed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
1 /*
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
2 * yuv2rgb.c, Software YUV to RGB coverter
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
3 *
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
4 * Copyright (C) 1999, Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
5 * All Rights Reserved.
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
6 *
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
7 * Functions broken out from display_x11.c and several new modes
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
8 * added by Håkan Hjort <d95hjort@dtek.chalmers.se>
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
9 *
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
10 * 15 & 16 bpp support by Franck Sicard <Franck.Sicard@solsoft.fr>
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
11 *
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
12 * This file is part of mpeg2dec, a free MPEG-2 video decoder
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
13 *
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
14 * mpeg2dec is free software; you can redistribute it and/or modify
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
15 * it under the terms of the GNU General Public License as published by
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
16 * the Free Software Foundation; either version 2, or (at your option)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
17 * any later version.
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
18 *
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
19 * mpeg2dec is distributed in the hope that it will be useful,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
22 * GNU General Public License for more details.
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
23 *
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
24 * You should have received a copy of the GNU General Public License
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
25 * along with GNU Make; see the file COPYING. If not, write to
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
26 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
27 *
3143
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
28 * MMX/MMX2 Template stuff from Michael Niedermayer (michaelni@gmx.at) (needed for fast movntq support)
6456
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
29 * 1,4,8bpp support by Michael Niedermayer (michaelni@gmx.at)
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
30 */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
31
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
32 #include <stdio.h>
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
33 #include <stdlib.h>
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
34 #include <inttypes.h>
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
35
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
36 #include "config.h"
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
37 //#include "video_out.h"
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
38 #include "rgb2rgb.h"
3143
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
39 #include "../cpudetect.h"
4285
20806e535b96 add mangling
atmos4
parents: 3143
diff changeset
40 #include "../mangle.h"
5937
4b18bf35f153 printf to mp_msg
albeu
parents: 4285
diff changeset
41 #include "../mp_msg.h"
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
42
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
43 #ifdef HAVE_MLIB
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
44 #include "yuv2rgb_mlib.c"
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
45 #endif
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
46
3143
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
47 #define DITHER1XBPP // only for mmx
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
48
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
49 #ifdef ARCH_X86
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
50 #define CAN_COMPILE_X86_ASM
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
51 #endif
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
52
6458
michael
parents: 6456
diff changeset
53 uint8_t __attribute__((aligned(8))) dither_8x8_32[8][8]={
michael
parents: 6456
diff changeset
54 { 17, 9, 23, 15, 16, 8, 22, 14, },
michael
parents: 6456
diff changeset
55 { 5, 29, 3, 27, 4, 28, 2, 26, },
michael
parents: 6456
diff changeset
56 { 21, 13, 19, 11, 20, 12, 18, 10, },
michael
parents: 6456
diff changeset
57 { 0, 24, 6, 30, 1, 25, 7, 31, },
michael
parents: 6456
diff changeset
58 { 16, 8, 22, 14, 17, 9, 23, 15, },
michael
parents: 6456
diff changeset
59 { 4, 28, 2, 26, 5, 29, 3, 27, },
michael
parents: 6456
diff changeset
60 { 20, 12, 18, 10, 21, 13, 19, 11, },
michael
parents: 6456
diff changeset
61 { 1, 25, 7, 31, 0, 24, 6, 30, },
michael
parents: 6456
diff changeset
62 };
michael
parents: 6456
diff changeset
63
michael
parents: 6456
diff changeset
64 uint8_t __attribute__((aligned(8))) dither_8x8_64[8][8]={
michael
parents: 6456
diff changeset
65 { 0, 48, 12, 60, 3, 51, 15, 63, },
michael
parents: 6456
diff changeset
66 { 32, 16, 44, 28, 35, 19, 47, 31, },
michael
parents: 6456
diff changeset
67 { 8, 56, 4, 52, 11, 59, 7, 55, },
michael
parents: 6456
diff changeset
68 { 40, 24, 36, 20, 43, 27, 39, 23, },
michael
parents: 6456
diff changeset
69 { 2, 50, 14, 62, 1, 49, 13, 61, },
michael
parents: 6456
diff changeset
70 { 34, 18, 46, 30, 33, 17, 45, 29, },
michael
parents: 6456
diff changeset
71 { 10, 58, 6, 54, 9, 57, 5, 53, },
michael
parents: 6456
diff changeset
72 { 42, 26, 38, 22, 41, 25, 37, 21, },
michael
parents: 6456
diff changeset
73 };
michael
parents: 6456
diff changeset
74
michael
parents: 6456
diff changeset
75 uint8_t __attribute__((aligned(8))) dither_8x8_128[8][8]={
michael
parents: 6456
diff changeset
76 { 68, 36, 92, 60, 66, 34, 90, 58, },
michael
parents: 6456
diff changeset
77 { 20, 116, 12, 108, 18, 114, 10, 106, },
michael
parents: 6456
diff changeset
78 { 84, 52, 76, 44, 82, 50, 74, 42, },
michael
parents: 6456
diff changeset
79 { 0, 96, 24, 120, 6, 102, 30, 126, },
michael
parents: 6456
diff changeset
80 { 64, 32, 88, 56, 70, 38, 94, 62, },
michael
parents: 6456
diff changeset
81 { 16, 112, 8, 104, 22, 118, 14, 110, },
michael
parents: 6456
diff changeset
82 { 80, 48, 72, 40, 86, 54, 78, 46, },
michael
parents: 6456
diff changeset
83 { 4, 100, 28, 124, 2, 98, 26, 122, },
michael
parents: 6456
diff changeset
84 };
michael
parents: 6456
diff changeset
85
3143
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
86 #ifdef CAN_COMPILE_X86_ASM
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
87
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
88 /* hope these constant values are cache line aligned */
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
89 uint64_t __attribute__((aligned(8))) mmx_80w = 0x0080008000800080;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
90 uint64_t __attribute__((aligned(8))) mmx_10w = 0x1010101010101010;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
91 uint64_t __attribute__((aligned(8))) mmx_00ffw = 0x00ff00ff00ff00ff;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
92 uint64_t __attribute__((aligned(8))) mmx_Y_coeff = 0x253f253f253f253f;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
93
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
94 /* hope these constant values are cache line aligned */
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
95 uint64_t __attribute__((aligned(8))) mmx_U_green = 0xf37df37df37df37d;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
96 uint64_t __attribute__((aligned(8))) mmx_U_blue = 0x4093409340934093;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
97 uint64_t __attribute__((aligned(8))) mmx_V_red = 0x3312331233123312;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
98 uint64_t __attribute__((aligned(8))) mmx_V_green = 0xe5fce5fce5fce5fc;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
99
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
100 /* hope these constant values are cache line aligned */
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
101 uint64_t __attribute__((aligned(8))) mmx_redmask = 0xf8f8f8f8f8f8f8f8;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
102 uint64_t __attribute__((aligned(8))) mmx_grnmask = 0xfcfcfcfcfcfcfcfc;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
103
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
104 uint64_t __attribute__((aligned(8))) M24A= 0x00FF0000FF0000FFLL;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
105 uint64_t __attribute__((aligned(8))) M24B= 0xFF0000FF0000FF00LL;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
106 uint64_t __attribute__((aligned(8))) M24C= 0x0000FF0000FF0000LL;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
107
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
108 // the volatile is required because gcc otherwise optimizes some writes away not knowing that these
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
109 // are read in the asm block
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
110 volatile uint64_t __attribute__((aligned(8))) b5Dither;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
111 volatile uint64_t __attribute__((aligned(8))) g5Dither;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
112 volatile uint64_t __attribute__((aligned(8))) g6Dither;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
113 volatile uint64_t __attribute__((aligned(8))) r5Dither;
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
114
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
115 uint64_t __attribute__((aligned(8))) dither4[2]={
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
116 0x0103010301030103LL,
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
117 0x0200020002000200LL,};
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
118
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
119 uint64_t __attribute__((aligned(8))) dither8[2]={
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
120 0x0602060206020602LL,
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
121 0x0004000400040004LL,};
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
122
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
123 #undef HAVE_MMX
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
124 #undef ARCH_X86
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
125
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
126 //MMX versions
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
127 #undef RENAME
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
128 #define HAVE_MMX
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
129 #undef HAVE_MMX2
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
130 #undef HAVE_3DNOW
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
131 #define ARCH_X86
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
132 #define RENAME(a) a ## _MMX
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
133 #include "yuv2rgb_template.c"
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
134
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
135 //MMX2 versions
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
136 #undef RENAME
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
137 #define HAVE_MMX
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
138 #define HAVE_MMX2
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
139 #undef HAVE_3DNOW
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
140 #define ARCH_X86
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
141 #define RENAME(a) a ## _MMX2
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
142 #include "yuv2rgb_template.c"
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
143
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
144 #endif // CAN_COMPILE_X86_ASM
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
145
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
146 uint32_t matrix_coefficients = 6;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
147
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
148 const int32_t Inverse_Table_6_9[8][4] = {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
149 {117504, 138453, 13954, 34903}, /* no sequence_display_extension */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
150 {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
151 {104597, 132201, 25675, 53279}, /* unspecified */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
152 {104597, 132201, 25675, 53279}, /* reserved */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
153 {104448, 132798, 24759, 53109}, /* FCC */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
154 {104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
155 {104597, 132201, 25675, 53279}, /* SMPTE 170M */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
156 {117579, 136230, 16907, 35559} /* SMPTE 240M (1987) */
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
157 };
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
158
6492
e7635c03910f sync with mplayer xp
arpi
parents: 6458
diff changeset
159 static void yuv2rgb_c_init (unsigned bpp, int mode);
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
160
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
161 yuv2rgb_fun yuv2rgb;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
162
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
163 static void (* yuv2rgb_c_internal) (uint8_t *, uint8_t *,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
164 uint8_t *, uint8_t *,
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
165 void *, void *, int, int);
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
166
3143
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
167 static void yuv2rgb_c (void * dst, uint8_t * py,
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
168 uint8_t * pu, uint8_t * pv,
6492
e7635c03910f sync with mplayer xp
arpi
parents: 6458
diff changeset
169 unsigned h_size, unsigned v_size,
e7635c03910f sync with mplayer xp
arpi
parents: 6458
diff changeset
170 unsigned rgb_stride, unsigned y_stride, unsigned uv_stride)
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
171 {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
172 v_size >>= 1;
6492
e7635c03910f sync with mplayer xp
arpi
parents: 6458
diff changeset
173
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
174 while (v_size--) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
175 yuv2rgb_c_internal (py, py + y_stride, pu, pv, dst, dst + rgb_stride,
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
176 h_size, v_size<<1);
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
177
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
178 py += 2 * y_stride;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
179 pu += uv_stride;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
180 pv += uv_stride;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
181 dst += 2 * rgb_stride;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
182 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
183 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
184
6492
e7635c03910f sync with mplayer xp
arpi
parents: 6458
diff changeset
185 void yuv2rgb_init (unsigned bpp, int mode)
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
186 {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
187 yuv2rgb = NULL;
3143
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
188 #ifdef CAN_COMPILE_X86_ASM
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
189 if(gCpuCaps.hasMMX2)
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
190 {
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
191 if (yuv2rgb == NULL /*&& (config.flags & VO_MMX_ENABLE)*/) {
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
192 yuv2rgb = yuv2rgb_init_MMX2 (bpp, mode);
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
193 if (yuv2rgb != NULL)
5937
4b18bf35f153 printf to mp_msg
albeu
parents: 4285
diff changeset
194 mp_msg(MSGT_SWS,MSGL_INFO,"Using MMX2 for colorspace transform\n");
3143
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
195 else
5937
4b18bf35f153 printf to mp_msg
albeu
parents: 4285
diff changeset
196 mp_msg(MSGT_SWS,MSGL_WARN,"Cannot init MMX2 colorspace transform\n");
3143
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
197 }
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
198 }
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
199 else if(gCpuCaps.hasMMX)
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
200 {
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
201 if (yuv2rgb == NULL /*&& (config.flags & VO_MMX_ENABLE)*/) {
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
202 yuv2rgb = yuv2rgb_init_MMX (bpp, mode);
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
203 if (yuv2rgb != NULL)
5937
4b18bf35f153 printf to mp_msg
albeu
parents: 4285
diff changeset
204 mp_msg(MSGT_SWS,MSGL_INFO,"Using MMX for colorspace transform\n");
3143
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
205 else
5937
4b18bf35f153 printf to mp_msg
albeu
parents: 4285
diff changeset
206 mp_msg(MSGT_SWS,MSGL_WARN,"Cannot init MMX colorspace transform\n");
3143
86910f54c391 runtime cpu detection
michael
parents: 2732
diff changeset
207 }
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
208 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
209 #endif
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
210 #ifdef HAVE_MLIB
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
211 if (yuv2rgb == NULL /*&& (config.flags & VO_MLIB_ENABLE)*/) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
212 yuv2rgb = yuv2rgb_init_mlib (bpp, mode);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
213 if (yuv2rgb != NULL)
5937
4b18bf35f153 printf to mp_msg
albeu
parents: 4285
diff changeset
214 mp_msg(MSGT_SWS,MSGL_INFO,"Using mlib for colorspace transform\n");
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
215 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
216 #endif
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
217 if (yuv2rgb == NULL) {
5937
4b18bf35f153 printf to mp_msg
albeu
parents: 4285
diff changeset
218 mp_msg(MSGT_SWS,MSGL_INFO,"No accelerated colorspace conversion found\n");
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
219 yuv2rgb_c_init (bpp, mode);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
220 yuv2rgb = (yuv2rgb_fun)yuv2rgb_c;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
221 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
222 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
223
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
224 void * table_rV[256];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
225 void * table_gU[256];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
226 int table_gV[256];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
227 void * table_bU[256];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
228
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
229 #define RGB(i) \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
230 U = pu[i]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
231 V = pv[i]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
232 r = table_rV[V]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
233 g = table_gU[U] + table_gV[V]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
234 b = table_bU[U];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
235
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
236 #define DST1(i) \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
237 Y = py_1[2*i]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
238 dst_1[2*i] = r[Y] + g[Y] + b[Y]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
239 Y = py_1[2*i+1]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
240 dst_1[2*i+1] = r[Y] + g[Y] + b[Y];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
241
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
242 #define DST2(i) \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
243 Y = py_2[2*i]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
244 dst_2[2*i] = r[Y] + g[Y] + b[Y]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
245 Y = py_2[2*i+1]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
246 dst_2[2*i+1] = r[Y] + g[Y] + b[Y];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
247
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
248 #define DST1RGB(i) \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
249 Y = py_1[2*i]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
250 dst_1[6*i] = r[Y]; dst_1[6*i+1] = g[Y]; dst_1[6*i+2] = b[Y]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
251 Y = py_1[2*i+1]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
252 dst_1[6*i+3] = r[Y]; dst_1[6*i+4] = g[Y]; dst_1[6*i+5] = b[Y];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
253
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
254 #define DST2RGB(i) \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
255 Y = py_2[2*i]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
256 dst_2[6*i] = r[Y]; dst_2[6*i+1] = g[Y]; dst_2[6*i+2] = b[Y]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
257 Y = py_2[2*i+1]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
258 dst_2[6*i+3] = r[Y]; dst_2[6*i+4] = g[Y]; dst_2[6*i+5] = b[Y];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
259
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
260 #define DST1BGR(i) \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
261 Y = py_1[2*i]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
262 dst_1[6*i] = b[Y]; dst_1[6*i+1] = g[Y]; dst_1[6*i+2] = r[Y]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
263 Y = py_1[2*i+1]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
264 dst_1[6*i+3] = b[Y]; dst_1[6*i+4] = g[Y]; dst_1[6*i+5] = r[Y];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
265
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
266 #define DST2BGR(i) \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
267 Y = py_2[2*i]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
268 dst_2[6*i] = b[Y]; dst_2[6*i+1] = g[Y]; dst_2[6*i+2] = r[Y]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
269 Y = py_2[2*i+1]; \
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
270 dst_2[6*i+3] = b[Y]; dst_2[6*i+4] = g[Y]; dst_2[6*i+5] = r[Y];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
271
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
272 static void yuv2rgb_c_32 (uint8_t * py_1, uint8_t * py_2,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
273 uint8_t * pu, uint8_t * pv,
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
274 void * _dst_1, void * _dst_2, int h_size, int v_pos)
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
275 {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
276 int U, V, Y;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
277 uint32_t * r, * g, * b;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
278 uint32_t * dst_1, * dst_2;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
279
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
280 h_size >>= 3;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
281 dst_1 = _dst_1;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
282 dst_2 = _dst_2;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
283
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
284 while (h_size--) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
285 RGB(0);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
286 DST1(0);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
287 DST2(0);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
288
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
289 RGB(1);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
290 DST2(1);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
291 DST1(1);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
292
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
293 RGB(2);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
294 DST1(2);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
295 DST2(2);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
296
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
297 RGB(3);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
298 DST2(3);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
299 DST1(3);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
300
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
301 pu += 4;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
302 pv += 4;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
303 py_1 += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
304 py_2 += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
305 dst_1 += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
306 dst_2 += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
307 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
308 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
309
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
310 // This is very near from the yuv2rgb_c_32 code
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
311 static void yuv2rgb_c_24_rgb (uint8_t * py_1, uint8_t * py_2,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
312 uint8_t * pu, uint8_t * pv,
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
313 void * _dst_1, void * _dst_2, int h_size, int v_pos)
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
314 {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
315 int U, V, Y;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
316 uint8_t * r, * g, * b;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
317 uint8_t * dst_1, * dst_2;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
318
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
319 h_size >>= 3;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
320 dst_1 = _dst_1;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
321 dst_2 = _dst_2;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
322
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
323 while (h_size--) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
324 RGB(0);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
325 DST1RGB(0);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
326 DST2RGB(0);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
327
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
328 RGB(1);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
329 DST2RGB(1);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
330 DST1RGB(1);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
331
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
332 RGB(2);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
333 DST1RGB(2);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
334 DST2RGB(2);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
335
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
336 RGB(3);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
337 DST2RGB(3);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
338 DST1RGB(3);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
339
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
340 pu += 4;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
341 pv += 4;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
342 py_1 += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
343 py_2 += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
344 dst_1 += 24;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
345 dst_2 += 24;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
346 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
347 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
348
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
349 // only trivial mods from yuv2rgb_c_24_rgb
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
350 static void yuv2rgb_c_24_bgr (uint8_t * py_1, uint8_t * py_2,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
351 uint8_t * pu, uint8_t * pv,
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
352 void * _dst_1, void * _dst_2, int h_size, int v_pos)
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
353 {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
354 int U, V, Y;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
355 uint8_t * r, * g, * b;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
356 uint8_t * dst_1, * dst_2;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
357
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
358 h_size >>= 3;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
359 dst_1 = _dst_1;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
360 dst_2 = _dst_2;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
361
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
362 while (h_size--) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
363 RGB(0);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
364 DST1BGR(0);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
365 DST2BGR(0);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
366
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
367 RGB(1);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
368 DST2BGR(1);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
369 DST1BGR(1);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
370
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
371 RGB(2);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
372 DST1BGR(2);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
373 DST2BGR(2);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
374
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
375 RGB(3);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
376 DST2BGR(3);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
377 DST1BGR(3);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
378
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
379 pu += 4;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
380 pv += 4;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
381 py_1 += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
382 py_2 += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
383 dst_1 += 24;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
384 dst_2 += 24;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
385 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
386 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
387
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
388 // This is exactly the same code as yuv2rgb_c_32 except for the types of
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
389 // r, g, b, dst_1, dst_2
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
390 static void yuv2rgb_c_16 (uint8_t * py_1, uint8_t * py_2,
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
391 uint8_t * pu, uint8_t * pv,
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
392 void * _dst_1, void * _dst_2, int h_size, int v_pos)
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
393 {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
394 int U, V, Y;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
395 uint16_t * r, * g, * b;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
396 uint16_t * dst_1, * dst_2;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
397
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
398 h_size >>= 3;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
399 dst_1 = _dst_1;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
400 dst_2 = _dst_2;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
401
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
402 while (h_size--) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
403 RGB(0);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
404 DST1(0);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
405 DST2(0);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
406
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
407 RGB(1);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
408 DST2(1);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
409 DST1(1);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
410
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
411 RGB(2);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
412 DST1(2);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
413 DST2(2);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
414
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
415 RGB(3);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
416 DST2(3);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
417 DST1(3);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
418
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
419 pu += 4;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
420 pv += 4;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
421 py_1 += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
422 py_2 += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
423 dst_1 += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
424 dst_2 += 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
425 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
426 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
427
6451
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
428 // This is exactly the same code as yuv2rgb_c_32 except for the types of
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
429 // r, g, b, dst_1, dst_2
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
430 static void yuv2rgb_c_8 (uint8_t * py_1, uint8_t * py_2,
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
431 uint8_t * pu, uint8_t * pv,
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
432 void * _dst_1, void * _dst_2, int h_size, int v_pos)
6451
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
433 {
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
434 int U, V, Y;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
435 uint8_t * r, * g, * b;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
436 uint8_t * dst_1, * dst_2;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
437
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
438 h_size >>= 3;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
439 dst_1 = _dst_1;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
440 dst_2 = _dst_2;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
441
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
442 while (h_size--) {
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
443 RGB(0);
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
444 DST1(0);
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
445 DST2(0);
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
446
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
447 RGB(1);
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
448 DST2(1);
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
449 DST1(1);
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
450
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
451 RGB(2);
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
452 DST1(2);
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
453 DST2(2);
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
454
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
455 RGB(3);
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
456 DST2(3);
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
457 DST1(3);
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
458
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
459 pu += 4;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
460 pv += 4;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
461 py_1 += 8;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
462 py_2 += 8;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
463 dst_1 += 8;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
464 dst_2 += 8;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
465 }
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
466 }
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
467
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
468 // r, g, b, dst_1, dst_2
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
469 static void yuv2rgb_c_8_ordered_dither (uint8_t * py_1, uint8_t * py_2,
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
470 uint8_t * pu, uint8_t * pv,
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
471 void * _dst_1, void * _dst_2, int h_size, int v_pos)
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
472 {
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
473 int U, V, Y;
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
474 uint8_t * r, * g, * b;
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
475 uint8_t * dst_1, * dst_2;
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
476
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
477 h_size >>= 3;
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
478 dst_1 = _dst_1;
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
479 dst_2 = _dst_2;
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
480
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
481 while (h_size--) {
6456
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
482 uint8_t *d32= dither_8x8_32[v_pos&7];
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
483 uint8_t *d64= dither_8x8_64[v_pos&7];
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
484 #define DST1bpp8(i,o) \
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
485 Y = py_1[2*i]; \
6456
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
486 dst_1[2*i] = r[Y+d32[0+o]] + g[Y+d32[0+o]] + b[Y+d64[0+o]]; \
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
487 Y = py_1[2*i+1]; \
6456
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
488 dst_1[2*i+1] = r[Y+d32[1+o]] + g[Y+d32[1+o]] + b[Y+d64[1+o]];
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
489
6456
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
490 #define DST2bpp8(i,o) \
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
491 Y = py_2[2*i]; \
6456
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
492 dst_2[2*i] = r[Y+d32[8+o]] + g[Y+d32[8+o]] + b[Y+d64[8+o]]; \
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
493 Y = py_2[2*i+1]; \
6456
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
494 dst_2[2*i+1] = r[Y+d32[9+o]] + g[Y+d32[9+o]] + b[Y+d64[9+o]];
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
495
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
496
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
497 RGB(0);
6456
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
498 DST1bpp8(0,0);
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
499 DST2bpp8(0,0);
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
500
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
501 RGB(1);
6456
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
502 DST2bpp8(1,2);
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
503 DST1bpp8(1,2);
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
504
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
505 RGB(2);
6456
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
506 DST1bpp8(2,4);
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
507 DST2bpp8(2,4);
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
508
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
509 RGB(3);
6456
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
510 DST2bpp8(3,6);
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
511 DST1bpp8(3,6);
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
512
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
513 pu += 4;
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
514 pv += 4;
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
515 py_1 += 8;
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
516 py_2 += 8;
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
517 dst_1 += 8;
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
518 dst_2 += 8;
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
519 }
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
520 }
6451
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
521
6453
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
522
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
523 // This is exactly the same code as yuv2rgb_c_32 except for the types of
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
524 // r, g, b, dst_1, dst_2
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
525 static void yuv2rgb_c_4 (uint8_t * py_1, uint8_t * py_2,
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
526 uint8_t * pu, uint8_t * pv,
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
527 void * _dst_1, void * _dst_2, int h_size, int v_pos)
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
528 {
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
529 int U, V, Y, out;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
530 uint8_t * r, * g, * b;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
531 uint8_t * dst_1, * dst_2;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
532
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
533 h_size >>= 3;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
534 dst_1 = _dst_1;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
535 dst_2 = _dst_2;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
536
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
537 while (h_size--) {
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
538 RGB(0);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
539 DST1(0);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
540 DST2(0);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
541
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
542 RGB(1);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
543 DST2(1);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
544 DST1(1);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
545
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
546 RGB(2);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
547 DST1(2);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
548 DST2(2);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
549
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
550 RGB(3);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
551 DST2(3);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
552 DST1(3);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
553
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
554 pu += 4;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
555 pv += 4;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
556 py_1 += 8;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
557 py_2 += 8;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
558 dst_1 += 8;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
559 dst_2 += 8;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
560 }
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
561 }
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
562
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
563 static void yuv2rgb_c_4_ordered_dither (uint8_t * py_1, uint8_t * py_2,
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
564 uint8_t * pu, uint8_t * pv,
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
565 void * _dst_1, void * _dst_2, int h_size, int v_pos)
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
566 {
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
567 int U, V, Y;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
568 uint8_t * r, * g, * b;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
569 uint8_t * dst_1, * dst_2;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
570
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
571 h_size >>= 3;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
572 dst_1 = _dst_1;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
573 dst_2 = _dst_2;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
574
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
575 while (h_size--) {
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
576 uint8_t *d64= dither_8x8_64 [v_pos&7];
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
577 uint8_t *d128=dither_8x8_128[v_pos&7];
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
578
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
579 #define DST1bpp4(i,o) \
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
580 Y = py_1[2*i]; \
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
581 dst_1[2*i] = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
582 Y = py_1[2*i+1]; \
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
583 dst_1[2*i+1] = r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]];
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
584
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
585 #define DST2bpp4(i,o) \
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
586 Y = py_2[2*i]; \
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
587 dst_2[2*i] = r[Y+d128[8+o]] + g[Y+d64[8+o]] + b[Y+d128[8+o]]; \
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
588 Y = py_2[2*i+1]; \
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
589 dst_2[2*i+1] = r[Y+d128[9+o]] + g[Y+d64[9+o]] + b[Y+d128[9+o]];
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
590
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
591
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
592 RGB(0);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
593 DST1bpp4(0,0);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
594 DST2bpp4(0,0);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
595
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
596 RGB(1);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
597 DST2bpp4(1,2);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
598 DST1bpp4(1,2);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
599
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
600 RGB(2);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
601 DST1bpp4(2,4);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
602 DST2bpp4(2,4);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
603
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
604 RGB(3);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
605 DST2bpp4(3,6);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
606 DST1bpp4(3,6);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
607
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
608 pu += 4;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
609 pv += 4;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
610 py_1 += 8;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
611 py_2 += 8;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
612 dst_1 += 8;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
613 dst_2 += 8;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
614 }
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
615 }
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
616
6456
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
617 static void yuv2rgb_c_1_ordered_dither (uint8_t * py_1, uint8_t * py_2,
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
618 uint8_t * pu, uint8_t * pv,
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
619 void * _dst_1, void * _dst_2, int h_size, int v_pos)
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
620 {
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
621 int U, V, Y;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
622 uint8_t * r, * g, * b;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
623 uint8_t * dst_1, * dst_2;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
624
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
625 h_size >>= 3;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
626 dst_1 = _dst_1;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
627 dst_2 = _dst_2;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
628 g= table_gU[128] + table_gV[128];
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
629
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
630 while (h_size--) {
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
631 uint8_t *d128=dither_8x8_128[v_pos&7];
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
632 char out_1=0, out_2=0;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
633
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
634 #define DST1bpp1(i,o) \
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
635 Y = py_1[2*i]; \
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
636 out_1+= out_1 + g[Y+d128[0+o]]; \
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
637 Y = py_1[2*i+1]; \
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
638 out_1+= out_1 + g[Y+d128[1+o]];
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
639
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
640 #define DST2bpp1(i,o) \
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
641 Y = py_2[2*i]; \
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
642 out_2+= out_2 + g[Y+d128[8+o]]; \
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
643 Y = py_2[2*i+1]; \
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
644 out_2+= out_2 + g[Y+d128[9+o]];
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
645
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
646 DST1bpp1(0,0);
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
647 DST2bpp1(0,0);
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
648
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
649 DST2bpp1(1,2);
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
650 DST1bpp1(1,2);
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
651
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
652 DST1bpp1(2,4);
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
653 DST2bpp1(2,4);
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
654
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
655 DST2bpp1(3,6);
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
656 DST1bpp1(3,6);
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
657
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
658 dst_1[0]= out_1;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
659 dst_2[0]= out_2;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
660
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
661 pu += 4;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
662 pv += 4;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
663 py_1 += 8;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
664 py_2 += 8;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
665 dst_1 ++;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
666 dst_2 ++;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
667 }
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
668 }
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
669
6453
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
670
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
671 static int div_round (int dividend, int divisor)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
672 {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
673 if (dividend > 0)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
674 return (dividend + (divisor>>1)) / divisor;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
675 else
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
676 return -((-dividend + (divisor>>1)) / divisor);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
677 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
678
6492
e7635c03910f sync with mplayer xp
arpi
parents: 6458
diff changeset
679 static void yuv2rgb_c_init (unsigned bpp, int mode)
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
680 {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
681 int i;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
682 uint8_t table_Y[1024];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
683 uint32_t *table_32 = 0;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
684 uint16_t *table_16 = 0;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
685 uint8_t *table_8 = 0;
6451
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
686 uint8_t *table_332 = 0;
6453
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
687 uint8_t *table_121 = 0;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
688 uint8_t *table_1 = 0;
6140
44dcc49a0d80 64bit incompatibility bug, patch by Artur Grabowski <art@blahonga.org>
arpi
parents: 5937
diff changeset
689 int entry_size = 0;
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
690 void *table_r = 0, *table_g = 0, *table_b = 0;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
691
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
692 int crv = Inverse_Table_6_9[matrix_coefficients][0];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
693 int cbu = Inverse_Table_6_9[matrix_coefficients][1];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
694 int cgu = -Inverse_Table_6_9[matrix_coefficients][2];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
695 int cgv = -Inverse_Table_6_9[matrix_coefficients][3];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
696
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
697 for (i = 0; i < 1024; i++) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
698 int j;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
699
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
700 j = (76309 * (i - 384 - 16) + 32768) >> 16;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
701 j = (j < 0) ? 0 : ((j > 255) ? 255 : j);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
702 table_Y[i] = j;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
703 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
704
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
705 switch (bpp) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
706 case 32:
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
707 yuv2rgb_c_internal = yuv2rgb_c_32;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
708
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
709 table_32 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t));
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
710
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
711 entry_size = sizeof (uint32_t);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
712 table_r = table_32 + 197;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
713 table_b = table_32 + 197 + 685;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
714 table_g = table_32 + 197 + 2*682;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
715
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
716 for (i = -197; i < 256+197; i++)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
717 ((uint32_t *)table_r)[i] = table_Y[i+384] << ((mode==MODE_RGB) ? 16 : 0);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
718 for (i = -132; i < 256+132; i++)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
719 ((uint32_t *)table_g)[i] = table_Y[i+384] << 8;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
720 for (i = -232; i < 256+232; i++)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
721 ((uint32_t *)table_b)[i] = table_Y[i+384] << ((mode==MODE_RGB) ? 0 : 16);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
722 break;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
723
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
724 case 24:
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
725 // yuv2rgb_c_internal = (mode==MODE_RGB) ? yuv2rgb_c_24_rgb : yuv2rgb_c_24_bgr;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
726 yuv2rgb_c_internal = (mode!=MODE_RGB) ? yuv2rgb_c_24_rgb : yuv2rgb_c_24_bgr;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
727
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
728 table_8 = malloc ((256 + 2*232) * sizeof (uint8_t));
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
729
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
730 entry_size = sizeof (uint8_t);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
731 table_r = table_g = table_b = table_8 + 232;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
733 for (i = -232; i < 256+232; i++)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
734 ((uint8_t * )table_b)[i] = table_Y[i+384];
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
735 break;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
736
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
737 case 15:
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
738 case 16:
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
739 yuv2rgb_c_internal = yuv2rgb_c_16;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
740
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
741 table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
742
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
743 entry_size = sizeof (uint16_t);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
744 table_r = table_16 + 197;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
745 table_b = table_16 + 197 + 685;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
746 table_g = table_16 + 197 + 2*682;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
747
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
748 for (i = -197; i < 256+197; i++) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
749 int j = table_Y[i+384] >> 3;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
750
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
751 if (mode == MODE_RGB)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
752 j <<= ((bpp==16) ? 11 : 10);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
753
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
754 ((uint16_t *)table_r)[i] = j;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
755 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
756 for (i = -132; i < 256+132; i++) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
757 int j = table_Y[i+384] >> ((bpp==16) ? 2 : 3);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
758
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
759 ((uint16_t *)table_g)[i] = j << 5;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
760 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
761 for (i = -232; i < 256+232; i++) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
762 int j = table_Y[i+384] >> 3;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
763
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
764 if (mode == MODE_BGR)
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
765 j <<= ((bpp==16) ? 11 : 10);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
766
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
767 ((uint16_t *)table_b)[i] = j;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
768 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
769 break;
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
770
6451
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
771 case 8:
6452
dae4143c636b ordered dither for 8bpp
michael
parents: 6451
diff changeset
772 yuv2rgb_c_internal = yuv2rgb_c_8_ordered_dither; //yuv2rgb_c_8;
6451
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
773
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
774 table_332 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
775
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
776 entry_size = sizeof (uint8_t);
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
777 table_r = table_332 + 197;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
778 table_b = table_332 + 197 + 685;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
779 table_g = table_332 + 197 + 2*682;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
780
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
781 for (i = -197; i < 256+197; i++) {
6453
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
782 int j = (table_Y[i+384] - 16) >> 5;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
783 if(j<0) j=0;
6451
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
784
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
785 if (mode == MODE_RGB)
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
786 j <<= 5;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
787
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
788 ((uint8_t *)table_r)[i] = j;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
789 }
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
790 for (i = -132; i < 256+132; i++) {
6453
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
791 int j = (table_Y[i+384] - 16) >> 5;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
792 if(j<0) j=0;
6451
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
793
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
794 if (mode == MODE_BGR)
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
795 j <<= 1;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
796
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
797 ((uint8_t *)table_g)[i] = j << 2;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
798 }
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
799 for (i = -232; i < 256+232; i++) {
6453
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
800 int j = (table_Y[i+384] - 32) >> 6;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
801 if(j<0) j=0;
6451
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
802
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
803 if (mode == MODE_BGR)
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
804 j <<= 6;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
805
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
806 ((uint8_t *)table_b)[i] = j;
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
807 }
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
808 break;
6453
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
809 case 4:
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
810 yuv2rgb_c_internal = yuv2rgb_c_4_ordered_dither; //yuv2rgb_c_4;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
811
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
812 table_121 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
813
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
814 entry_size = sizeof (uint8_t);
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
815 table_r = table_121 + 197;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
816 table_b = table_121 + 197 + 685;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
817 table_g = table_121 + 197 + 2*682;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
818
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
819 for (i = -197; i < 256+197; i++) {
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
820 int j = (table_Y[i+384] - 64) >> 7;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
821 if(j<0) j=0;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
822
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
823 if (mode == MODE_RGB)
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
824 j <<= 3;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
825
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
826 ((uint8_t *)table_r)[i] = j;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
827 }
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
828 for (i = -132; i < 256+132; i++) {
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
829 int j = (table_Y[i+384] - 32) >> 6;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
830 if(j<0) j=0;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
831
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
832 ((uint8_t *)table_g)[i] = j << 1;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
833 }
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
834 for (i = -232; i < 256+232; i++) {
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
835 int j =(table_Y[i+384] - 64) >> 7;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
836 if(j<0) j=0;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
837
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
838 if (mode == MODE_BGR)
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
839 j <<= 3;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
840
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
841 ((uint8_t *)table_b)[i] = j;
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
842 }
7f06ef0d58a6 8bpp bugfixes (brightness, contrast ...)
michael
parents: 6452
diff changeset
843 break;
6451
ed906af317da 8bpp support (no dithering yet, use -vop noise for now)
michael
parents: 6140
diff changeset
844
6456
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
845 case 1:
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
846 yuv2rgb_c_internal = yuv2rgb_c_1_ordered_dither;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
847
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
848 table_1 = malloc ((132*2 + 256) * sizeof (uint8_t));
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
849
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
850 entry_size = sizeof (uint8_t);
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
851 table_g = table_1 + 132;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
852 table_r = table_b = NULL;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
853
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
854 for (i = -132; i < 256+132; i++) {
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
855 int j = (table_Y[i+384] - 64) >> 7;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
856 if(j<0) j=0;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
857
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
858 ((uint8_t *)table_g)[i] = j;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
859 }
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
860 break;
f0b64210ce97 1bpp support
michael
parents: 6453
diff changeset
861
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
862 default:
5937
4b18bf35f153 printf to mp_msg
albeu
parents: 4285
diff changeset
863 mp_msg(MSGT_SWS,MSGL_ERR,"%ibpp not supported by yuv2rgb\n", bpp);
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
864 //exit (1);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
865 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
866
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
867 for (i = 0; i < 256; i++) {
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
868 table_rV[i] = table_r + entry_size * div_round (crv * (i-128), 76309);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
869 table_gU[i] = table_g + entry_size * div_round (cgu * (i-128), 76309);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
870 table_gV[i] = entry_size * div_round (cgv * (i-128), 76309);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
871 table_bU[i] = table_b + entry_size * div_round (cbu * (i-128), 76309);
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
872 }
ae79207a3055 Move yuv2rgb to postprocess
nick
parents:
diff changeset
873 }