annotate libswscale/rgb2rgb.c @ 22800:da9729d2bdf8

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