comparison libswscale/rgb2rgb.c @ 27158:65b8334df960

spelling/grammar/wording overhaul
author diego
date Fri, 04 Jul 2008 13:49:45 +0000
parents 794c8b614799
children e05965c550fc
comparison
equal deleted inserted replaced
27157:e2797c291ba9 27158:65b8334df960
1 /* 1 /*
2 * rgb2rgb.c, Software RGB to RGB convertor 2 * software RGB to RGB converter
3 * pluralize by Software PAL8 to RGB convertor 3 * pluralize by software PAL8 to RGB converter
4 * Software YUV to YUV convertor 4 * software YUV to YUV converter
5 * Software YUV to RGB convertor 5 * software YUV to RGB converter
6 * Written by Nick Kurshev. 6 * Written by Nick Kurshev.
7 * palette & YUV & runtime CPU stuff by Michael (michaelni@gmx.at) 7 * palette & YUV & runtime CPU stuff by Michael (michaelni@gmx.at)
8 * 8 *
9 * This file is part of FFmpeg. 9 * This file is part of FFmpeg.
10 * 10 *
11 * FFmpeg is free software; you can redistribute it and/or modify 11 * FFmpeg is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
20 * 20 *
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with FFmpeg; if not, write to the Free Software 22 * along with FFmpeg; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 * 24 *
25 * the C code (not assembly, mmx, ...) of this file can be used 25 * The C code (not assembly, MMX, ...) of this file can be used
26 * under the LGPL license too 26 * under the LGPL license.
27 */ 27 */
28 #include <inttypes.h> 28 #include <inttypes.h>
29 #include "config.h" 29 #include "config.h"
30 #include "libavutil/x86_cpu.h" 30 #include "libavutil/x86_cpu.h"
31 #include "libavutil/bswap.h" 31 #include "libavutil/bswap.h"
32 #include "rgb2rgb.h" 32 #include "rgb2rgb.h"
33 #include "swscale.h" 33 #include "swscale.h"
34 #include "swscale_internal.h" 34 #include "swscale_internal.h"
35 35
36 #define FAST_BGR2YV12 // use 7 bit coeffs instead of 15bit 36 #define FAST_BGR2YV12 // use 7-bit instead of 15-bit coefficients
37 37
38 void (*rgb24to32)(const uint8_t *src, uint8_t *dst, long src_size); 38 void (*rgb24to32)(const uint8_t *src, uint8_t *dst, long src_size);
39 void (*rgb24to16)(const uint8_t *src, uint8_t *dst, long src_size); 39 void (*rgb24to16)(const uint8_t *src, uint8_t *dst, long src_size);
40 void (*rgb24to15)(const uint8_t *src, uint8_t *dst, long src_size); 40 void (*rgb24to15)(const uint8_t *src, uint8_t *dst, long src_size);
41 void (*rgb32to24)(const uint8_t *src, uint8_t *dst, long src_size); 41 void (*rgb32to24)(const uint8_t *src, uint8_t *dst, long src_size);
147 #define GU ((int)(-0.291*(1<<RGB2YUV_SHIFT)+0.5)) 147 #define GU ((int)(-0.291*(1<<RGB2YUV_SHIFT)+0.5))
148 #define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5)) 148 #define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5))
149 #define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5)) 149 #define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
150 #define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5)) 150 #define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5))
151 151
152 //Note: we have C, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one 152 //Note: We have C, MMX, MMX2, 3DNOW versions, there is no 3DNOW + MMX2 one.
153 //Plain C versions 153 //plain C versions
154 #undef HAVE_MMX 154 #undef HAVE_MMX
155 #undef HAVE_MMX2 155 #undef HAVE_MMX2
156 #undef HAVE_3DNOW 156 #undef HAVE_3DNOW
157 #undef HAVE_SSE2 157 #undef HAVE_SSE2
158 #define RENAME(a) a ## _C 158 #define RENAME(a) a ## _C
188 #include "rgb2rgb_template.c" 188 #include "rgb2rgb_template.c"
189 189
190 #endif //ARCH_X86 || ARCH_X86_64 190 #endif //ARCH_X86 || ARCH_X86_64
191 191
192 /* 192 /*
193 rgb15->rgb16 Original by Strepto/Astral 193 RGB15->RGB16 original by Strepto/Astral
194 ported to gcc & bugfixed : A'rpi 194 ported to gcc & bugfixed : A'rpi
195 MMX2, 3DNOW optimization by Nick Kurshev 195 MMX2, 3DNOW optimization by Nick Kurshev
196 32bit c version, and and&add trick by Michael Niedermayer 196 32-bit C version, and and&add trick by Michael Niedermayer
197 */ 197 */
198 198
199 void sws_rgb2rgb_init(int flags){ 199 void sws_rgb2rgb_init(int flags){
200 #if (defined(HAVE_MMX2) || defined(HAVE_3DNOW) || defined(HAVE_MMX)) && defined(CONFIG_GPL) 200 #if (defined(HAVE_MMX2) || defined(HAVE_3DNOW) || defined(HAVE_MMX)) && defined(CONFIG_GPL)
201 if (flags & SWS_CPU_CAPS_MMX2) 201 if (flags & SWS_CPU_CAPS_MMX2)
264 */ 264 */
265 void palette8torgb24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) 265 void palette8torgb24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
266 { 266 {
267 long i; 267 long i;
268 /* 268 /*
269 writes 1 byte o much and might cause alignment issues on some architectures? 269 Writes 1 byte too much and might cause alignment issues on some architectures?
270 for (i=0; i<num_pixels; i++) 270 for (i=0; i<num_pixels; i++)
271 ((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[src[i]]; 271 ((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[src[i]];
272 */ 272 */
273 for (i=0; i<num_pixels; i++) 273 for (i=0; i<num_pixels; i++)
274 { 274 {
282 282
283 void palette8tobgr24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) 283 void palette8tobgr24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
284 { 284 {
285 long i; 285 long i;
286 /* 286 /*
287 writes 1 byte o much and might cause alignment issues on some architectures? 287 Writes 1 byte too much and might cause alignment issues on some architectures?
288 for (i=0; i<num_pixels; i++) 288 for (i=0; i<num_pixels; i++)
289 ((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[src[i]]; 289 ((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[src[i]];
290 */ 290 */
291 for (i=0; i<num_pixels; i++) 291 for (i=0; i<num_pixels; i++)
292 { 292 {
297 dst+= 3; 297 dst+= 3;
298 } 298 }
299 } 299 }
300 300
301 /** 301 /**
302 * Palette is assumed to contain bgr16, see rgb32to16 to convert the palette 302 * Palette is assumed to contain BGR16, see rgb32to16 to convert the palette.
303 */ 303 */
304 void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) 304 void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
305 { 305 {
306 long i; 306 long i;
307 for (i=0; i<num_pixels; i++) 307 for (i=0; i<num_pixels; i++)