• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libswscale/x86/rgb2rgb.c

Go to the documentation of this file.
00001 /*
00002  * software RGB to RGB converter
00003  * pluralize by software PAL8 to RGB converter
00004  *              software YUV to YUV converter
00005  *              software YUV to RGB converter
00006  * Written by Nick Kurshev.
00007  * palette & YUV & runtime CPU stuff by Michael (michaelni@gmx.at)
00008  *
00009  * This file is part of Libav.
00010  *
00011  * Libav is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU Lesser General Public
00013  * License as published by the Free Software Foundation; either
00014  * version 2.1 of the License, or (at your option) any later version.
00015  *
00016  * Libav is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with Libav; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00024  */
00025 
00026 #include <stdint.h>
00027 
00028 #include "config.h"
00029 #include "libavutil/x86_cpu.h"
00030 #include "libavutil/cpu.h"
00031 #include "libavutil/bswap.h"
00032 #include "libswscale/rgb2rgb.h"
00033 #include "libswscale/swscale.h"
00034 #include "libswscale/swscale_internal.h"
00035 
00036 DECLARE_ASM_CONST(8, uint64_t, mmx_ff)       = 0x00000000000000FFULL;
00037 DECLARE_ASM_CONST(8, uint64_t, mmx_null)     = 0x0000000000000000ULL;
00038 DECLARE_ASM_CONST(8, uint64_t, mmx_one)      = 0xFFFFFFFFFFFFFFFFULL;
00039 DECLARE_ASM_CONST(8, uint64_t, mask32b)      = 0x000000FF000000FFULL;
00040 DECLARE_ASM_CONST(8, uint64_t, mask32g)      = 0x0000FF000000FF00ULL;
00041 DECLARE_ASM_CONST(8, uint64_t, mask32r)      = 0x00FF000000FF0000ULL;
00042 DECLARE_ASM_CONST(8, uint64_t, mask32a)      = 0xFF000000FF000000ULL;
00043 DECLARE_ASM_CONST(8, uint64_t, mask32)       = 0x00FFFFFF00FFFFFFULL;
00044 DECLARE_ASM_CONST(8, uint64_t, mask3216br)   = 0x00F800F800F800F8ULL;
00045 DECLARE_ASM_CONST(8, uint64_t, mask3216g)    = 0x0000FC000000FC00ULL;
00046 DECLARE_ASM_CONST(8, uint64_t, mask3215g)    = 0x0000F8000000F800ULL;
00047 DECLARE_ASM_CONST(8, uint64_t, mul3216)      = 0x2000000420000004ULL;
00048 DECLARE_ASM_CONST(8, uint64_t, mul3215)      = 0x2000000820000008ULL;
00049 DECLARE_ASM_CONST(8, uint64_t, mask24b)      = 0x00FF0000FF0000FFULL;
00050 DECLARE_ASM_CONST(8, uint64_t, mask24g)      = 0xFF0000FF0000FF00ULL;
00051 DECLARE_ASM_CONST(8, uint64_t, mask24r)      = 0x0000FF0000FF0000ULL;
00052 DECLARE_ASM_CONST(8, uint64_t, mask24l)      = 0x0000000000FFFFFFULL;
00053 DECLARE_ASM_CONST(8, uint64_t, mask24h)      = 0x0000FFFFFF000000ULL;
00054 DECLARE_ASM_CONST(8, uint64_t, mask24hh)     = 0xffff000000000000ULL;
00055 DECLARE_ASM_CONST(8, uint64_t, mask24hhh)    = 0xffffffff00000000ULL;
00056 DECLARE_ASM_CONST(8, uint64_t, mask24hhhh)   = 0xffffffffffff0000ULL;
00057 DECLARE_ASM_CONST(8, uint64_t, mask15b)      = 0x001F001F001F001FULL; /* 00000000 00011111  xxB */
00058 DECLARE_ASM_CONST(8, uint64_t, mask15rg)     = 0x7FE07FE07FE07FE0ULL; /* 01111111 11100000  RGx */
00059 DECLARE_ASM_CONST(8, uint64_t, mask15s)      = 0xFFE0FFE0FFE0FFE0ULL;
00060 DECLARE_ASM_CONST(8, uint64_t, mask15g)      = 0x03E003E003E003E0ULL;
00061 DECLARE_ASM_CONST(8, uint64_t, mask15r)      = 0x7C007C007C007C00ULL;
00062 #define mask16b mask15b
00063 DECLARE_ASM_CONST(8, uint64_t, mask16g)      = 0x07E007E007E007E0ULL;
00064 DECLARE_ASM_CONST(8, uint64_t, mask16r)      = 0xF800F800F800F800ULL;
00065 DECLARE_ASM_CONST(8, uint64_t, red_16mask)   = 0x0000f8000000f800ULL;
00066 DECLARE_ASM_CONST(8, uint64_t, green_16mask) = 0x000007e0000007e0ULL;
00067 DECLARE_ASM_CONST(8, uint64_t, blue_16mask)  = 0x0000001f0000001fULL;
00068 DECLARE_ASM_CONST(8, uint64_t, red_15mask)   = 0x00007c0000007c00ULL;
00069 DECLARE_ASM_CONST(8, uint64_t, green_15mask) = 0x000003e0000003e0ULL;
00070 DECLARE_ASM_CONST(8, uint64_t, blue_15mask)  = 0x0000001f0000001fULL;
00071 
00072 #define RGB2YUV_SHIFT 8
00073 #define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5))
00074 #define BV ((int)(-0.071*(1<<RGB2YUV_SHIFT)+0.5))
00075 #define BU ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
00076 #define GY ((int)( 0.504*(1<<RGB2YUV_SHIFT)+0.5))
00077 #define GV ((int)(-0.368*(1<<RGB2YUV_SHIFT)+0.5))
00078 #define GU ((int)(-0.291*(1<<RGB2YUV_SHIFT)+0.5))
00079 #define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5))
00080 #define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
00081 #define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5))
00082 
00083 //Note: We have C, MMX, MMX2, 3DNOW versions, there is no 3DNOW + MMX2 one.
00084 
00085 #define COMPILE_TEMPLATE_MMX2 0
00086 #define COMPILE_TEMPLATE_AMD3DNOW 0
00087 #define COMPILE_TEMPLATE_SSE2 0
00088 
00089 //MMX versions
00090 #undef RENAME
00091 #define RENAME(a) a ## _MMX
00092 #include "rgb2rgb_template.c"
00093 
00094 //MMX2 versions
00095 #undef RENAME
00096 #undef COMPILE_TEMPLATE_MMX2
00097 #define COMPILE_TEMPLATE_MMX2 1
00098 #define RENAME(a) a ## _MMX2
00099 #include "rgb2rgb_template.c"
00100 
00101 //SSE2 versions
00102 #undef RENAME
00103 #undef COMPILE_TEMPLATE_SSE2
00104 #define COMPILE_TEMPLATE_SSE2 1
00105 #define RENAME(a) a ## _SSE2
00106 #include "rgb2rgb_template.c"
00107 
00108 //3DNOW versions
00109 #undef RENAME
00110 #undef COMPILE_TEMPLATE_MMX2
00111 #undef COMPILE_TEMPLATE_SSE2
00112 #undef COMPILE_TEMPLATE_AMD3DNOW
00113 #define COMPILE_TEMPLATE_MMX2 0
00114 #define COMPILE_TEMPLATE_SSE2 0
00115 #define COMPILE_TEMPLATE_AMD3DNOW 1
00116 #define RENAME(a) a ## _3DNOW
00117 #include "rgb2rgb_template.c"
00118 
00119 /*
00120  RGB15->RGB16 original by Strepto/Astral
00121  ported to gcc & bugfixed : A'rpi
00122  MMX2, 3DNOW optimization by Nick Kurshev
00123  32-bit C version, and and&add trick by Michael Niedermayer
00124 */
00125 
00126 void rgb2rgb_init_x86(void)
00127 {
00128     int cpu_flags = av_get_cpu_flags();
00129 
00130     if (cpu_flags & AV_CPU_FLAG_MMX)
00131         rgb2rgb_init_MMX();
00132     if (HAVE_AMD3DNOW && cpu_flags & AV_CPU_FLAG_3DNOW)
00133         rgb2rgb_init_3DNOW();
00134     if (HAVE_MMX2     && cpu_flags & AV_CPU_FLAG_MMX2)
00135         rgb2rgb_init_MMX2();
00136     if (HAVE_SSE      && cpu_flags & AV_CPU_FLAG_SSE2)
00137         rgb2rgb_init_SSE2();
00138 }
Generated on Thu Jan 24 2013 17:08:56 for Libav by doxygen 1.7.1