annotate libswscale/rgb2rgb.c @ 20328:5d9f47834495

Do not use sh_audio->wf values if they are definitely invalid
author reimar
date Sat, 21 Oct 2006 17:01:45 +0000
parents aca9e9783f67
children 9e7c80f126d6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18861
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
1 /*
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
2 *
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
3 * rgb2rgb.c, Software RGB to RGB convertor
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
4 * pluralize by Software PAL8 to RGB convertor
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
5 * Software YUV to YUV convertor
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
6 * Software YUV to RGB convertor
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
7 * Written by Nick Kurshev.
19703
ad7f49a1ba95 Add official GPL header to make license explicit as discussed on ffmpeg-devel.
diego
parents: 19361
diff changeset
8 * palette & YUV & runtime CPU stuff by Michael (michaelni@gmx.at)
ad7f49a1ba95 Add official GPL header to make license explicit as discussed on ffmpeg-devel.
diego
parents: 19361
diff changeset
9 *
20094
aca9e9783f67 Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents: 19703
diff changeset
10 * This file is part of FFmpeg.
aca9e9783f67 Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents: 19703
diff changeset
11 *
aca9e9783f67 Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents: 19703
diff changeset
12 * FFmpeg is free software; you can redistribute it and/or modify
19703
ad7f49a1ba95 Add official GPL header to make license explicit as discussed on ffmpeg-devel.
diego
parents: 19361
diff changeset
13 * it under the terms of the GNU General Public License as published by
ad7f49a1ba95 Add official GPL header to make license explicit as discussed on ffmpeg-devel.
diego
parents: 19361
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
ad7f49a1ba95 Add official GPL header to make license explicit as discussed on ffmpeg-devel.
diego
parents: 19361
diff changeset
15 * (at your option) any later version.
ad7f49a1ba95 Add official GPL header to make license explicit as discussed on ffmpeg-devel.
diego
parents: 19361
diff changeset
16 *
20094
aca9e9783f67 Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents: 19703
diff changeset
17 * FFmpeg is distributed in the hope that it will be useful,
19703
ad7f49a1ba95 Add official GPL header to make license explicit as discussed on ffmpeg-devel.
diego
parents: 19361
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ad7f49a1ba95 Add official GPL header to make license explicit as discussed on ffmpeg-devel.
diego
parents: 19361
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ad7f49a1ba95 Add official GPL header to make license explicit as discussed on ffmpeg-devel.
diego
parents: 19361
diff changeset
20 * GNU General Public License for more details.
ad7f49a1ba95 Add official GPL header to make license explicit as discussed on ffmpeg-devel.
diego
parents: 19361
diff changeset
21 *
ad7f49a1ba95 Add official GPL header to make license explicit as discussed on ffmpeg-devel.
diego
parents: 19361
diff changeset
22 * You should have received a copy of the GNU General Public License
20094
aca9e9783f67 Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents: 19703
diff changeset
23 * along with FFmpeg; if not, write to the Free Software
19703
ad7f49a1ba95 Add official GPL header to make license explicit as discussed on ffmpeg-devel.
diego
parents: 19361
diff changeset
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18861
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
25 */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
26 #include <inttypes.h>
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
27 #include "config.h"
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
28 #include "rgb2rgb.h"
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
29 #include "swscale.h"
19143
c4dac777b44c Use libavutil in libswscale, and allow it to be built out of the mplayer tree
lucabe
parents: 18861
diff changeset
30 #include "swscale_internal.h"
c4dac777b44c Use libavutil in libswscale, and allow it to be built out of the mplayer tree
lucabe
parents: 18861
diff changeset
31 #include "x86_cpu.h"
18861
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
32 #include "bswap.h"
19143
c4dac777b44c Use libavutil in libswscale, and allow it to be built out of the mplayer tree
lucabe
parents: 18861
diff changeset
33 #ifdef USE_FASTMEMCPY
18861
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
34 #include "libvo/fastmemcpy.h"
19143
c4dac777b44c Use libavutil in libswscale, and allow it to be built out of the mplayer tree
lucabe
parents: 18861
diff changeset
35 #endif
18861
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
36
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
37 #define FAST_BGR2YV12 // use 7 bit coeffs instead of 15bit
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
38
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
39 void (*rgb24to32)(const uint8_t *src,uint8_t *dst,long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
40 void (*rgb24to16)(const uint8_t *src,uint8_t *dst,long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
41 void (*rgb24to15)(const uint8_t *src,uint8_t *dst,long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
42 void (*rgb32to24)(const uint8_t *src,uint8_t *dst,long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
43 void (*rgb32to16)(const uint8_t *src,uint8_t *dst,long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
44 void (*rgb32to15)(const uint8_t *src,uint8_t *dst,long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
45 void (*rgb15to16)(const uint8_t *src,uint8_t *dst,long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
46 void (*rgb15to24)(const uint8_t *src,uint8_t *dst,long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
47 void (*rgb15to32)(const uint8_t *src,uint8_t *dst,long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
48 void (*rgb16to15)(const uint8_t *src,uint8_t *dst,long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
49 void (*rgb16to24)(const uint8_t *src,uint8_t *dst,long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
50 void (*rgb16to32)(const uint8_t *src,uint8_t *dst,long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
51 //void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
52 void (*rgb24tobgr24)(const uint8_t *src, uint8_t *dst, long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
53 void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
54 void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
55 void (*rgb32tobgr32)(const uint8_t *src, uint8_t *dst, long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
56 //void (*rgb32tobgr24)(const uint8_t *src, uint8_t *dst, long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
57 void (*rgb32tobgr16)(const uint8_t *src, uint8_t *dst, long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
58 void (*rgb32tobgr15)(const uint8_t *src, uint8_t *dst, long src_size);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
59
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
60 void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
61 long width, long height,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
62 long lumStride, long chromStride, long dstStride);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
63 void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
64 long width, long height,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
65 long lumStride, long chromStride, long dstStride);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
66 void (*yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
67 long width, long height,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
68 long lumStride, long chromStride, long dstStride);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
69 void (*yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
70 long width, long height,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
71 long lumStride, long chromStride, long srcStride);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
72 void (*rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
73 long width, long height,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
74 long lumStride, long chromStride, long srcStride);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
75 void (*planar2x)(const uint8_t *src, uint8_t *dst, long width, long height,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
76 long srcStride, long dstStride);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
77 void (*interleaveBytes)(uint8_t *src1, uint8_t *src2, uint8_t *dst,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
78 long width, long height, long src1Stride,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
79 long src2Stride, long dstStride);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
80 void (*vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
81 uint8_t *dst1, uint8_t *dst2,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
82 long width, long height,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
83 long srcStride1, long srcStride2,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
84 long dstStride1, long dstStride2);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
85 void (*yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2, const uint8_t *src3,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
86 uint8_t *dst,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
87 long width, long height,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
88 long srcStride1, long srcStride2,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
89 long srcStride3, long dstStride);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
90
19361
f38f0b2e3aa3 Fix compilation with MMX disabled, the mmx_null and mmx_one constants don't need to
diego
parents: 19333
diff changeset
91 #if defined(ARCH_X86) || defined(ARCH_X86_64)
18861
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
92 static const uint64_t mmx_null __attribute__((aligned(8))) = 0x0000000000000000ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
93 static const uint64_t mmx_one __attribute__((aligned(8))) = 0xFFFFFFFFFFFFFFFFULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
94 static const uint64_t mask32b attribute_used __attribute__((aligned(8))) = 0x000000FF000000FFULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
95 static const uint64_t mask32g attribute_used __attribute__((aligned(8))) = 0x0000FF000000FF00ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
96 static const uint64_t mask32r attribute_used __attribute__((aligned(8))) = 0x00FF000000FF0000ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
97 static const uint64_t mask32 __attribute__((aligned(8))) = 0x00FFFFFF00FFFFFFULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
98 static const uint64_t mask3216br __attribute__((aligned(8)))=0x00F800F800F800F8ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
99 static const uint64_t mask3216g __attribute__((aligned(8)))=0x0000FC000000FC00ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
100 static const uint64_t mask3215g __attribute__((aligned(8)))=0x0000F8000000F800ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
101 static const uint64_t mul3216 __attribute__((aligned(8))) = 0x2000000420000004ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
102 static const uint64_t mul3215 __attribute__((aligned(8))) = 0x2000000820000008ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
103 static const uint64_t mask24b attribute_used __attribute__((aligned(8))) = 0x00FF0000FF0000FFULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
104 static const uint64_t mask24g attribute_used __attribute__((aligned(8))) = 0xFF0000FF0000FF00ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
105 static const uint64_t mask24r attribute_used __attribute__((aligned(8))) = 0x0000FF0000FF0000ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
106 static const uint64_t mask24l __attribute__((aligned(8))) = 0x0000000000FFFFFFULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
107 static const uint64_t mask24h __attribute__((aligned(8))) = 0x0000FFFFFF000000ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
108 static const uint64_t mask24hh __attribute__((aligned(8))) = 0xffff000000000000ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
109 static const uint64_t mask24hhh __attribute__((aligned(8))) = 0xffffffff00000000ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
110 static const uint64_t mask24hhhh __attribute__((aligned(8))) = 0xffffffffffff0000ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
111 static const uint64_t mask15b __attribute__((aligned(8))) = 0x001F001F001F001FULL; /* 00000000 00011111 xxB */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
112 static const uint64_t mask15rg __attribute__((aligned(8))) = 0x7FE07FE07FE07FE0ULL; /* 01111111 11100000 RGx */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
113 static const uint64_t mask15s __attribute__((aligned(8))) = 0xFFE0FFE0FFE0FFE0ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
114 static const uint64_t mask15g __attribute__((aligned(8))) = 0x03E003E003E003E0ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
115 static const uint64_t mask15r __attribute__((aligned(8))) = 0x7C007C007C007C00ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
116 #define mask16b mask15b
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
117 static const uint64_t mask16g __attribute__((aligned(8))) = 0x07E007E007E007E0ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
118 static const uint64_t mask16r __attribute__((aligned(8))) = 0xF800F800F800F800ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
119 static const uint64_t red_16mask __attribute__((aligned(8))) = 0x0000f8000000f800ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
120 static const uint64_t green_16mask __attribute__((aligned(8)))= 0x000007e0000007e0ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
121 static const uint64_t blue_16mask __attribute__((aligned(8))) = 0x0000001f0000001fULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
122 static const uint64_t red_15mask __attribute__((aligned(8))) = 0x00007c000000f800ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
123 static const uint64_t green_15mask __attribute__((aligned(8)))= 0x000003e0000007e0ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
124 static const uint64_t blue_15mask __attribute__((aligned(8))) = 0x0000001f0000001fULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
125
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
126 #ifdef FAST_BGR2YV12
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
127 static const uint64_t bgr2YCoeff attribute_used __attribute__((aligned(8))) = 0x000000210041000DULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
128 static const uint64_t bgr2UCoeff attribute_used __attribute__((aligned(8))) = 0x0000FFEEFFDC0038ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
129 static const uint64_t bgr2VCoeff attribute_used __attribute__((aligned(8))) = 0x00000038FFD2FFF8ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
130 #else
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
131 static const uint64_t bgr2YCoeff attribute_used __attribute__((aligned(8))) = 0x000020E540830C8BULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
132 static const uint64_t bgr2UCoeff attribute_used __attribute__((aligned(8))) = 0x0000ED0FDAC23831ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
133 static const uint64_t bgr2VCoeff attribute_used __attribute__((aligned(8))) = 0x00003831D0E6F6EAULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
134 #endif
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
135 static const uint64_t bgr2YOffset attribute_used __attribute__((aligned(8))) = 0x1010101010101010ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
136 static const uint64_t bgr2UVOffset attribute_used __attribute__((aligned(8)))= 0x8080808080808080ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
137 static const uint64_t w1111 attribute_used __attribute__((aligned(8))) = 0x0001000100010001ULL;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
138
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
139 #if 0
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
140 static volatile uint64_t __attribute__((aligned(8))) b5Dither;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
141 static volatile uint64_t __attribute__((aligned(8))) g5Dither;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
142 static volatile uint64_t __attribute__((aligned(8))) g6Dither;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
143 static volatile uint64_t __attribute__((aligned(8))) r5Dither;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
144
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
145 static uint64_t __attribute__((aligned(8))) dither4[2]={
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
146 0x0103010301030103LL,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
147 0x0200020002000200LL,};
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
148
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
149 static uint64_t __attribute__((aligned(8))) dither8[2]={
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
150 0x0602060206020602LL,
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
151 0x0004000400040004LL,};
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
152 #endif
19206
c629606a0702 Comment some #endif lines.
diego
parents: 19143
diff changeset
153 #endif /* defined(ARCH_X86) || defined(ARCH_X86_64) */
18861
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
154
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
155 #define RGB2YUV_SHIFT 8
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
156 #define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5))
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
157 #define BV ((int)(-0.071*(1<<RGB2YUV_SHIFT)+0.5))
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
158 #define BU ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
159 #define GY ((int)( 0.504*(1<<RGB2YUV_SHIFT)+0.5))
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
160 #define GV ((int)(-0.368*(1<<RGB2YUV_SHIFT)+0.5))
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
161 #define GU ((int)(-0.291*(1<<RGB2YUV_SHIFT)+0.5))
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
162 #define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5))
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
163 #define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
164 #define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5))
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
165
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
166 //Note: we have C, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
167 //Plain C versions
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
168 #undef HAVE_MMX
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
169 #undef HAVE_MMX2
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
170 #undef HAVE_3DNOW
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
171 #undef HAVE_SSE2
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
172 #define RENAME(a) a ## _C
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
173 #include "rgb2rgb_template.c"
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
174
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
175 #if defined(ARCH_X86) || defined(ARCH_X86_64)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
176
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
177 //MMX versions
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
178 #undef RENAME
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
179 #define HAVE_MMX
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
180 #undef HAVE_MMX2
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
181 #undef HAVE_3DNOW
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
182 #undef HAVE_SSE2
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
183 #define RENAME(a) a ## _MMX
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
184 #include "rgb2rgb_template.c"
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
185
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
186 //MMX2 versions
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
187 #undef RENAME
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
188 #define HAVE_MMX
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
189 #define HAVE_MMX2
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
190 #undef HAVE_3DNOW
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
191 #undef HAVE_SSE2
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
192 #define RENAME(a) a ## _MMX2
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
193 #include "rgb2rgb_template.c"
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
194
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
195 //3DNOW versions
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
196 #undef RENAME
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
197 #define HAVE_MMX
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
198 #undef HAVE_MMX2
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
199 #define HAVE_3DNOW
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
200 #undef HAVE_SSE2
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
201 #define RENAME(a) a ## _3DNOW
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
202 #include "rgb2rgb_template.c"
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
203
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
204 #endif //ARCH_X86 || ARCH_X86_64
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
205
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
206 /*
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
207 rgb15->rgb16 Original by Strepto/Astral
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
208 ported to gcc & bugfixed : A'rpi
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
209 MMX2, 3DNOW optimization by Nick Kurshev
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
210 32bit c version, and and&add trick by Michael Niedermayer
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
211 */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
212
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
213 void sws_rgb2rgb_init(int flags){
19333
4f5e2e0529b1 Do not assemble MMX, MMX2 or 3DNOW code unconditionally on X86 and X86_64.
diego
parents: 19206
diff changeset
214 #if defined(HAVE_MMX2) || defined(HAVE_3DNOW) || defined(HAVE_MMX)
18861
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
215 if(flags & SWS_CPU_CAPS_MMX2){
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
216 rgb15to16= rgb15to16_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
217 rgb15to24= rgb15to24_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
218 rgb15to32= rgb15to32_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
219 rgb16to24= rgb16to24_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
220 rgb16to32= rgb16to32_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
221 rgb16to15= rgb16to15_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
222 rgb24to16= rgb24to16_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
223 rgb24to15= rgb24to15_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
224 rgb24to32= rgb24to32_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
225 rgb32to16= rgb32to16_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
226 rgb32to15= rgb32to15_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
227 rgb32to24= rgb32to24_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
228 rgb24tobgr15= rgb24tobgr15_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
229 rgb24tobgr16= rgb24tobgr16_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
230 rgb24tobgr24= rgb24tobgr24_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
231 rgb32tobgr32= rgb32tobgr32_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
232 rgb32tobgr16= rgb32tobgr16_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
233 rgb32tobgr15= rgb32tobgr15_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
234 yv12toyuy2= yv12toyuy2_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
235 yv12touyvy= yv12touyvy_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
236 yuv422ptoyuy2= yuv422ptoyuy2_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
237 yuy2toyv12= yuy2toyv12_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
238 // uyvytoyv12= uyvytoyv12_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
239 // yvu9toyv12= yvu9toyv12_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
240 planar2x= planar2x_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
241 rgb24toyv12= rgb24toyv12_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
242 interleaveBytes= interleaveBytes_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
243 vu9_to_vu12= vu9_to_vu12_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
244 yvu9_to_yuy2= yvu9_to_yuy2_MMX2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
245 }else if(flags & SWS_CPU_CAPS_3DNOW){
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
246 rgb15to16= rgb15to16_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
247 rgb15to24= rgb15to24_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
248 rgb15to32= rgb15to32_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
249 rgb16to24= rgb16to24_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
250 rgb16to32= rgb16to32_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
251 rgb16to15= rgb16to15_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
252 rgb24to16= rgb24to16_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
253 rgb24to15= rgb24to15_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
254 rgb24to32= rgb24to32_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
255 rgb32to16= rgb32to16_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
256 rgb32to15= rgb32to15_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
257 rgb32to24= rgb32to24_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
258 rgb24tobgr15= rgb24tobgr15_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
259 rgb24tobgr16= rgb24tobgr16_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
260 rgb24tobgr24= rgb24tobgr24_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
261 rgb32tobgr32= rgb32tobgr32_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
262 rgb32tobgr16= rgb32tobgr16_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
263 rgb32tobgr15= rgb32tobgr15_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
264 yv12toyuy2= yv12toyuy2_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
265 yv12touyvy= yv12touyvy_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
266 yuv422ptoyuy2= yuv422ptoyuy2_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
267 yuy2toyv12= yuy2toyv12_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
268 // uyvytoyv12= uyvytoyv12_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
269 // yvu9toyv12= yvu9toyv12_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
270 planar2x= planar2x_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
271 rgb24toyv12= rgb24toyv12_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
272 interleaveBytes= interleaveBytes_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
273 vu9_to_vu12= vu9_to_vu12_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
274 yvu9_to_yuy2= yvu9_to_yuy2_3DNOW;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
275 }else if(flags & SWS_CPU_CAPS_MMX){
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
276 rgb15to16= rgb15to16_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
277 rgb15to24= rgb15to24_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
278 rgb15to32= rgb15to32_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
279 rgb16to24= rgb16to24_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
280 rgb16to32= rgb16to32_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
281 rgb16to15= rgb16to15_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
282 rgb24to16= rgb24to16_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
283 rgb24to15= rgb24to15_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
284 rgb24to32= rgb24to32_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
285 rgb32to16= rgb32to16_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
286 rgb32to15= rgb32to15_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
287 rgb32to24= rgb32to24_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
288 rgb24tobgr15= rgb24tobgr15_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
289 rgb24tobgr16= rgb24tobgr16_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
290 rgb24tobgr24= rgb24tobgr24_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
291 rgb32tobgr32= rgb32tobgr32_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
292 rgb32tobgr16= rgb32tobgr16_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
293 rgb32tobgr15= rgb32tobgr15_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
294 yv12toyuy2= yv12toyuy2_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
295 yv12touyvy= yv12touyvy_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
296 yuv422ptoyuy2= yuv422ptoyuy2_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
297 yuy2toyv12= yuy2toyv12_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
298 // uyvytoyv12= uyvytoyv12_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
299 // yvu9toyv12= yvu9toyv12_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
300 planar2x= planar2x_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
301 rgb24toyv12= rgb24toyv12_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
302 interleaveBytes= interleaveBytes_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
303 vu9_to_vu12= vu9_to_vu12_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
304 yvu9_to_yuy2= yvu9_to_yuy2_MMX;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
305 }else
19333
4f5e2e0529b1 Do not assemble MMX, MMX2 or 3DNOW code unconditionally on X86 and X86_64.
diego
parents: 19206
diff changeset
306 #endif /* defined(HAVE_MMX2) || defined(HAVE_3DNOW) || defined(HAVE_MMX) */
18861
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
307 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
308 rgb15to16= rgb15to16_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
309 rgb15to24= rgb15to24_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
310 rgb15to32= rgb15to32_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
311 rgb16to24= rgb16to24_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
312 rgb16to32= rgb16to32_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
313 rgb16to15= rgb16to15_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
314 rgb24to16= rgb24to16_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
315 rgb24to15= rgb24to15_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
316 rgb24to32= rgb24to32_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
317 rgb32to16= rgb32to16_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
318 rgb32to15= rgb32to15_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
319 rgb32to24= rgb32to24_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
320 rgb24tobgr15= rgb24tobgr15_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
321 rgb24tobgr16= rgb24tobgr16_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
322 rgb24tobgr24= rgb24tobgr24_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
323 rgb32tobgr32= rgb32tobgr32_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
324 rgb32tobgr16= rgb32tobgr16_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
325 rgb32tobgr15= rgb32tobgr15_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
326 yv12toyuy2= yv12toyuy2_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
327 yv12touyvy= yv12touyvy_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
328 yuv422ptoyuy2= yuv422ptoyuy2_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
329 yuy2toyv12= yuy2toyv12_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
330 // uyvytoyv12= uyvytoyv12_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
331 // yvu9toyv12= yvu9toyv12_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
332 planar2x= planar2x_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
333 rgb24toyv12= rgb24toyv12_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
334 interleaveBytes= interleaveBytes_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
335 vu9_to_vu12= vu9_to_vu12_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
336 yvu9_to_yuy2= yvu9_to_yuy2_C;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
337 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
338 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
339
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
340 /**
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
341 * Pallete is assumed to contain bgr32
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
342 */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
343 void palette8torgb32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
344 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
345 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
346
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
347 /*
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
348 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
349 ((unsigned *)dst)[i] = ((unsigned *)palette)[ src[i] ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
350 */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
351
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
352 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
353 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
354 #ifdef WORDS_BIGENDIAN
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
355 dst[3]= palette[ src[i]*4+2 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
356 dst[2]= palette[ src[i]*4+1 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
357 dst[1]= palette[ src[i]*4+0 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
358 #else
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
359 //FIXME slow?
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
360 dst[0]= palette[ src[i]*4+2 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
361 dst[1]= palette[ src[i]*4+1 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
362 dst[2]= palette[ src[i]*4+0 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
363 //dst[3]= 0; /* do we need this cleansing? */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
364 #endif
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
365 dst+= 4;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
366 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
367 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
368
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
369 void palette8tobgr32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
370 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
371 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
372 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
373 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
374 #ifdef WORDS_BIGENDIAN
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
375 dst[3]= palette[ src[i]*4+0 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
376 dst[2]= palette[ src[i]*4+1 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
377 dst[1]= palette[ src[i]*4+2 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
378 #else
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
379 //FIXME slow?
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
380 dst[0]= palette[ src[i]*4+0 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
381 dst[1]= palette[ src[i]*4+1 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
382 dst[2]= palette[ src[i]*4+2 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
383 //dst[3]= 0; /* do we need this cleansing? */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
384 #endif
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
385
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
386 dst+= 4;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
387 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
388 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
389
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
390 /**
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
391 * Pallete is assumed to contain bgr32
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
392 */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
393 void palette8torgb24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
394 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
395 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
396 /*
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
397 writes 1 byte o much and might cause alignment issues on some architectures?
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
398 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
399 ((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[ src[i] ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
400 */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
401 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
402 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
403 //FIXME slow?
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
404 dst[0]= palette[ src[i]*4+2 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
405 dst[1]= palette[ src[i]*4+1 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
406 dst[2]= palette[ src[i]*4+0 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
407 dst+= 3;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
408 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
409 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
410
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
411 void palette8tobgr24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
412 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
413 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
414 /*
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
415 writes 1 byte o much and might cause alignment issues on some architectures?
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
416 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
417 ((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[ src[i] ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
418 */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
419 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
420 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
421 //FIXME slow?
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
422 dst[0]= palette[ src[i]*4+0 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
423 dst[1]= palette[ src[i]*4+1 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
424 dst[2]= palette[ src[i]*4+2 ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
425 dst+= 3;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
426 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
427 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
428
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
429 /**
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
430 * Palette is assumed to contain bgr16, see rgb32to16 to convert the palette
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
431 */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
432 void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
433 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
434 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
435 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
436 ((uint16_t *)dst)[i] = ((uint16_t *)palette)[ src[i] ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
437 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
438 void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
439 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
440 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
441 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
442 ((uint16_t *)dst)[i] = bswap_16(((uint16_t *)palette)[ src[i] ]);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
443 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
444
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
445 /**
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
446 * Pallete is assumed to contain bgr15, see rgb32to15 to convert the palette
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
447 */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
448 void palette8torgb15(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
449 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
450 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
451 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
452 ((uint16_t *)dst)[i] = ((uint16_t *)palette)[ src[i] ];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
453 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
454 void palette8tobgr15(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
455 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
456 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
457 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
458 ((uint16_t *)dst)[i] = bswap_16(((uint16_t *)palette)[ src[i] ]);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
459 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
460
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
461 void rgb32tobgr24(const uint8_t *src, uint8_t *dst, long src_size)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
462 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
463 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
464 long num_pixels = src_size >> 2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
465 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
466 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
467 #ifdef WORDS_BIGENDIAN
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
468 /* RGB32 (= A,B,G,R) -> BGR24 (= B,G,R) */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
469 dst[3*i + 0] = src[4*i + 1];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
470 dst[3*i + 1] = src[4*i + 2];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
471 dst[3*i + 2] = src[4*i + 3];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
472 #else
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
473 dst[3*i + 0] = src[4*i + 2];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
474 dst[3*i + 1] = src[4*i + 1];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
475 dst[3*i + 2] = src[4*i + 0];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
476 #endif
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
477 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
478 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
479
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
480 void rgb24tobgr32(const uint8_t *src, uint8_t *dst, long src_size)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
481 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
482 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
483 for(i=0; 3*i<src_size; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
484 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
485 #ifdef WORDS_BIGENDIAN
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
486 /* RGB24 (= R,G,B) -> BGR32 (= A,R,G,B) */
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
487 dst[4*i + 0] = 0;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
488 dst[4*i + 1] = src[3*i + 0];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
489 dst[4*i + 2] = src[3*i + 1];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
490 dst[4*i + 3] = src[3*i + 2];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
491 #else
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
492 dst[4*i + 0] = src[3*i + 2];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
493 dst[4*i + 1] = src[3*i + 1];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
494 dst[4*i + 2] = src[3*i + 0];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
495 dst[4*i + 3] = 0;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
496 #endif
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
497 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
498 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
499
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
500 void rgb16tobgr32(const uint8_t *src, uint8_t *dst, long src_size)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
501 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
502 const uint16_t *end;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
503 uint8_t *d = (uint8_t *)dst;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
504 const uint16_t *s = (uint16_t *)src;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
505 end = s + src_size/2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
506 while(s < end)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
507 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
508 register uint16_t bgr;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
509 bgr = *s++;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
510 #ifdef WORDS_BIGENDIAN
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
511 *d++ = 0;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
512 *d++ = (bgr&0x1F)<<3;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
513 *d++ = (bgr&0x7E0)>>3;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
514 *d++ = (bgr&0xF800)>>8;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
515 #else
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
516 *d++ = (bgr&0xF800)>>8;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
517 *d++ = (bgr&0x7E0)>>3;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
518 *d++ = (bgr&0x1F)<<3;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
519 *d++ = 0;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
520 #endif
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
521 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
522 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
523
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
524 void rgb16tobgr24(const uint8_t *src, uint8_t *dst, long src_size)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
525 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
526 const uint16_t *end;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
527 uint8_t *d = (uint8_t *)dst;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
528 const uint16_t *s = (const uint16_t *)src;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
529 end = s + src_size/2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
530 while(s < end)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
531 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
532 register uint16_t bgr;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
533 bgr = *s++;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
534 *d++ = (bgr&0xF800)>>8;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
535 *d++ = (bgr&0x7E0)>>3;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
536 *d++ = (bgr&0x1F)<<3;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
537 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
538 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
539
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
540 void rgb16tobgr16(const uint8_t *src, uint8_t *dst, long src_size)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
541 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
542 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
543 long num_pixels = src_size >> 1;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
544
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
545 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
546 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
547 unsigned b,g,r;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
548 register uint16_t rgb;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
549 rgb = src[2*i];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
550 r = rgb&0x1F;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
551 g = (rgb&0x7E0)>>5;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
552 b = (rgb&0xF800)>>11;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
553 dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
554 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
555 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
556
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
557 void rgb16tobgr15(const uint8_t *src, uint8_t *dst, long src_size)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
558 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
559 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
560 long num_pixels = src_size >> 1;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
561
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
562 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
563 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
564 unsigned b,g,r;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
565 register uint16_t rgb;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
566 rgb = src[2*i];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
567 r = rgb&0x1F;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
568 g = (rgb&0x7E0)>>5;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
569 b = (rgb&0xF800)>>11;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
570 dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
571 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
572 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
573
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
574 void rgb15tobgr32(const uint8_t *src, uint8_t *dst, long src_size)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
575 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
576 const uint16_t *end;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
577 uint8_t *d = (uint8_t *)dst;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
578 const uint16_t *s = (const uint16_t *)src;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
579 end = s + src_size/2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
580 while(s < end)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
581 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
582 register uint16_t bgr;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
583 bgr = *s++;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
584 #ifdef WORDS_BIGENDIAN
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
585 *d++ = 0;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
586 *d++ = (bgr&0x1F)<<3;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
587 *d++ = (bgr&0x3E0)>>2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
588 *d++ = (bgr&0x7C00)>>7;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
589 #else
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
590 *d++ = (bgr&0x7C00)>>7;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
591 *d++ = (bgr&0x3E0)>>2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
592 *d++ = (bgr&0x1F)<<3;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
593 *d++ = 0;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
594 #endif
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
595 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
596 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
597
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
598 void rgb15tobgr24(const uint8_t *src, uint8_t *dst, long src_size)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
599 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
600 const uint16_t *end;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
601 uint8_t *d = (uint8_t *)dst;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
602 const uint16_t *s = (uint16_t *)src;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
603 end = s + src_size/2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
604 while(s < end)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
605 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
606 register uint16_t bgr;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
607 bgr = *s++;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
608 *d++ = (bgr&0x7C00)>>7;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
609 *d++ = (bgr&0x3E0)>>2;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
610 *d++ = (bgr&0x1F)<<3;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
611 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
612 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
613
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
614 void rgb15tobgr16(const uint8_t *src, uint8_t *dst, long src_size)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
615 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
616 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
617 long num_pixels = src_size >> 1;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
618
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
619 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
620 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
621 unsigned b,g,r;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
622 register uint16_t rgb;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
623 rgb = src[2*i];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
624 r = rgb&0x1F;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
625 g = (rgb&0x3E0)>>5;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
626 b = (rgb&0x7C00)>>10;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
627 dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
628 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
629 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
630
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
631 void rgb15tobgr15(const uint8_t *src, uint8_t *dst, long src_size)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
632 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
633 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
634 long num_pixels = src_size >> 1;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
635
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
636 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
637 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
638 unsigned b,g,r;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
639 register uint16_t rgb;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
640 rgb = src[2*i];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
641 r = rgb&0x1F;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
642 g = (rgb&0x3E0)>>5;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
643 b = (rgb&0x7C00)>>10;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
644 dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
645 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
646 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
647
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
648 void rgb8tobgr8(const uint8_t *src, uint8_t *dst, long src_size)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
649 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
650 long i;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
651 long num_pixels = src_size;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
652 for(i=0; i<num_pixels; i++)
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
653 {
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
654 unsigned b,g,r;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
655 register uint8_t rgb;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
656 rgb = src[i];
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
657 r = (rgb&0x07);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
658 g = (rgb&0x38)>>3;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
659 b = (rgb&0xC0)>>6;
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
660 dst[i] = ((b<<1)&0x07) | ((g&0x07)<<3) | ((r&0x03)<<6);
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
661 }
8579acff875e Move postproc ---> libswscale
lucabe
parents:
diff changeset
662 }