/*
- * rgb2rgb.c, Software RGB to RGB convertor
- * pluralize by Software PAL8 to RGB convertor
- * Software YUV to YUV convertor
- * Software YUV to RGB convertor
- * Written by Nick Kurshev.
- * palette & YUV & runtime CPU stuff by Michael (michaelni@gmx.at)
+ * software RGB to RGB converter
+ * pluralize by software PAL8 to RGB converter
+ * software YUV to YUV converter
+ * software YUV to RGB converter
+ * Written by Nick Kurshev.
+ * palette & YUV & runtime CPU stuff by Michael (michaelni@gmx.at)
*
* This file is part of FFmpeg.
*
* along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * the C code (not assembly, mmx, ...) of this file can be used
- * under the LGPL license too
+ * The C code (not assembly, MMX, ...) of this file can be used
+ * under the LGPL license.
*/
#include <inttypes.h>
#include "config.h"
+#include "libavutil/x86_cpu.h"
+#include "libavutil/bswap.h"
#include "rgb2rgb.h"
#include "swscale.h"
#include "swscale_internal.h"
-#include "x86_cpu.h"
-#include "bswap.h"
-#define FAST_BGR2YV12 // use 7 bit coeffs instead of 15bit
+#define FAST_BGR2YV12 // use 7-bit instead of 15-bit coefficients
void (*rgb24to32)(const uint8_t *src, uint8_t *dst, long src_size);
void (*rgb24to16)(const uint8_t *src, uint8_t *dst, long src_size);
DECLARE_ASM_CONST(8, uint64_t, green_15mask) = 0x000003e0000003e0ULL;
DECLARE_ASM_CONST(8, uint64_t, blue_15mask) = 0x0000001f0000001fULL;
-#ifdef FAST_BGR2YV12
-DECLARE_ASM_CONST(8, uint64_t, bgr2YCoeff) = 0x000000210041000DULL;
-DECLARE_ASM_CONST(8, uint64_t, bgr2UCoeff) = 0x0000FFEEFFDC0038ULL;
-DECLARE_ASM_CONST(8, uint64_t, bgr2VCoeff) = 0x00000038FFD2FFF8ULL;
-#else
-DECLARE_ASM_CONST(8, uint64_t, bgr2YCoeff) = 0x000020E540830C8BULL;
-DECLARE_ASM_CONST(8, uint64_t, bgr2UCoeff) = 0x0000ED0FDAC23831ULL;
-DECLARE_ASM_CONST(8, uint64_t, bgr2VCoeff) = 0x00003831D0E6F6EAULL;
-#endif
-DECLARE_ASM_CONST(8, uint64_t, bgr2YOffset) = 0x1010101010101010ULL;
-DECLARE_ASM_CONST(8, uint64_t, bgr2UVOffset) = 0x8080808080808080ULL;
-DECLARE_ASM_CONST(8, uint64_t, w1111) = 0x0001000100010001ULL;
-
#if 0
static volatile uint64_t __attribute__((aligned(8))) b5Dither;
static volatile uint64_t __attribute__((aligned(8))) g5Dither;
#define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
#define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5))
-//Note: we have C, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one
-//Plain C versions
+//Note: We have C, MMX, MMX2, 3DNOW versions, there is no 3DNOW + MMX2 one.
+//plain C versions
#undef HAVE_MMX
#undef HAVE_MMX2
#undef HAVE_3DNOW
#endif //ARCH_X86 || ARCH_X86_64
/*
- rgb15->rgb16 Original by Strepto/Astral
+ RGB15->RGB16 original by Strepto/Astral
ported to gcc & bugfixed : A'rpi
MMX2, 3DNOW optimization by Nick Kurshev
- 32bit c version, and and&add trick by Michael Niedermayer
+ 32-bit C version, and and&add trick by Michael Niedermayer
*/
void sws_rgb2rgb_init(int flags){
{
long i;
/*
- writes 1 byte o much and might cause alignment issues on some architectures?
+ Writes 1 byte too much and might cause alignment issues on some architectures?
for (i=0; i<num_pixels; i++)
((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[src[i]];
*/
{
long i;
/*
- writes 1 byte o much and might cause alignment issues on some architectures?
+ Writes 1 byte too much and might cause alignment issues on some architectures?
for (i=0; i<num_pixels; i++)
((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[src[i]];
*/
}
/**
- * Palette is assumed to contain bgr16, see rgb32to16 to convert the palette
+ * Palette is assumed to contain BGR16, see rgb32to16 to convert the palette.
*/
void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
{
long i;
for (i=0; i<num_pixels; i++)
- ((uint16_t *)dst)[i] = ((uint16_t *)palette)[src[i]];
+ ((uint16_t *)dst)[i] = ((const uint16_t *)palette)[src[i]];
}
void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
{
long i;
for (i=0; i<num_pixels; i++)
- ((uint16_t *)dst)[i] = bswap_16(((uint16_t *)palette)[src[i]]);
+ ((uint16_t *)dst)[i] = bswap_16(((const uint16_t *)palette)[src[i]]);
}
/**
{
long i;
for (i=0; i<num_pixels; i++)
- ((uint16_t *)dst)[i] = ((uint16_t *)palette)[src[i]];
+ ((uint16_t *)dst)[i] = ((const uint16_t *)palette)[src[i]];
}
void palette8tobgr15(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
{
long i;
for (i=0; i<num_pixels; i++)
- ((uint16_t *)dst)[i] = bswap_16(((uint16_t *)palette)[src[i]]);
+ ((uint16_t *)dst)[i] = bswap_16(((const uint16_t *)palette)[src[i]]);
}
void rgb32tobgr24(const uint8_t *src, uint8_t *dst, long src_size)
void rgb16tobgr32(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
- uint8_t *d = (uint8_t *)dst;
- const uint16_t *s = (uint16_t *)src;
+ uint8_t *d = dst;
+ const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
while (s < end)
{
void rgb16tobgr24(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
- uint8_t *d = (uint8_t *)dst;
+ uint8_t *d = dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
while (s < end)
void rgb15tobgr32(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
- uint8_t *d = (uint8_t *)dst;
+ uint8_t *d = dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
while (s < end)
void rgb15tobgr24(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
- uint8_t *d = (uint8_t *)dst;
- const uint16_t *s = (uint16_t *)src;
+ uint8_t *d = dst;
+ const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
while (s < end)
{