annotate libswscale/rgb2rgb.c @ 19962:c76d6a7332e8

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