annotate libswscale/rgb2rgb.c @ 19445:f95c2db61ee3

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