/*
- * 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)
- * lot of big-endian byteorder fixes by Alex Beregszaszi
+ * 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)
+ * lot of big-endian byte order fixes by Alex Beregszaszi
*
* 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
+ * The C code (not assembly, MMX, ...) of this file can be used
* under the LGPL license.
*/
}
/*
- Original by Strepto/Astral
- ported to gcc & bugfixed : A'rpi
+ original by Strepto/Astral
+ ported to gcc & bugfixed: A'rpi
MMX2, 3DNOW optimization by Nick Kurshev
- 32 bit C version, and and&add trick by Michael Niedermayer
+ 32-bit C version, and and&add trick by Michael Niedermayer
*/
static inline void RENAME(rgb15to16)(const uint8_t *src, uint8_t *dst, long src_size)
{
mm_end = end - 3;
while (s < mm_end)
{
- register unsigned x= *((uint32_t *)s);
+ register unsigned x= *((const uint32_t *)s);
*((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0);
d+=4;
s+=4;
}
if (s < end)
{
- register unsigned short x= *((uint16_t *)s);
+ register unsigned short x= *((const uint16_t *)s);
*((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0);
}
}
mm_end = end - 3;
while (s < mm_end)
{
- register uint32_t x= *s;
+ register uint32_t x= *((const uint32_t*)s);
*((uint32_t *)d) = ((x>>1)&0x7FE07FE0) | (x&0x001F001F);
s+=4;
d+=4;
}
if (s < end)
{
- register uint16_t x= *s;
+ register uint16_t x= *((const uint16_t*)s);
*((uint16_t *)d) = ((x>>1)&0x7FE0) | (x&0x001F);
s+=2;
d+=2;
#endif
while (s < end)
{
- register int rgb = *(uint32_t*)s; s += 4;
+ register int rgb = *(const uint32_t*)s; s += 4;
*d++ = ((rgb&0xFF)>>3) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>8);
}
}
#endif
while (s < end)
{
- register int rgb = *(uint32_t*)s; s += 4;
+ register int rgb = *(const uint32_t*)s; s += 4;
*d++ = ((rgb&0xF8)<<8) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>19);
}
}
#endif
while (s < end)
{
- register int rgb = *(uint32_t*)s; s += 4;
+ register int rgb = *(const uint32_t*)s; s += 4;
*d++ = ((rgb&0xFF)>>3) + ((rgb&0xF800)>>6) + ((rgb&0xF80000)>>9);
}
}
#endif
while (s < end)
{
- register int rgb = *(uint32_t*)s; s += 4;
+ register int rgb = *(const uint32_t*)s; s += 4;
*d++ = ((rgb&0xF8)<<7) + ((rgb&0xF800)>>6) + ((rgb&0xF80000)>>19);
}
}
----------------
1 1 0 1 1 1 1 0
|=======| |===|
- | Leftmost Bits Repeated to Fill Open Bits
+ | leftmost bits repeated to fill open bits
|
- Original Bits
+ original bits
*/
static inline void RENAME(rgb15to24)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *mm_end;
#endif
uint8_t *d = dst;
- const uint16_t *s = (uint16_t *)src;
+ const uint16_t *s = (const uint16_t*)src;
end = s + src_size/2;
#ifdef HAVE_MMX
asm volatile(PREFETCH" %0"::"m"(*s):"memory");
:"=m"(*d)
:"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r), "m"(mmx_null)
:"memory");
- /* Borrowed 32 to 24 */
+ /* borrowed 32 to 24 */
asm volatile(
"movq %%mm0, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
:"=m"(*d)
:"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mmx_null)
:"memory");
- /* Borrowed 32 to 24 */
+ /* borrowed 32 to 24 */
asm volatile(
"movq %%mm0, %%mm4 \n\t"
"movq %%mm3, %%mm5 \n\t"
const uint16_t *mm_end;
#endif
uint8_t *d = dst;
- const uint16_t *s = (uint16_t *)src;
+ const uint16_t *s = (const uint16_t*)src;
end = s + src_size/2;
#ifdef HAVE_MMX
asm volatile(PREFETCH" %0"::"m"(*s):"memory");
static inline void RENAME(rgb32tobgr32)(const uint8_t *src, uint8_t *dst, long src_size)
{
long idx = 15 - src_size;
- uint8_t *s = src-idx, *d = dst-idx;
+ const uint8_t *s = src-idx;
+ uint8_t *d = dst-idx;
#ifdef HAVE_MMX
asm volatile(
"test %0, %0 \n\t"
: "memory");
#endif
for (; idx<15; idx+=4) {
- register int v = *(uint32_t *)&s[idx], g = v & 0xff00ff00;
+ register int v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00;
v &= 0xff00ff;
*(uint32_t *)&d[idx] = (v>>16) + g + (v<<16);
}
asm volatile(SFENCE:::"memory");
asm volatile(EMMS:::"memory");
- if (mmx_size==23) return; //finihsed, was multiple of 8
+ if (mmx_size==23) return; //finished, was multiple of 8
src+= src_size;
dst+= src_size;
}
/**
- * Height should be a multiple of 2 and width should be a multiple of 16 (if
- * this is a problem for anyone then tell me, and I will fix it).
+ * Height should be a multiple of 2 and width should be a multiple of 16.
+ * (If this is a problem for anyone then tell me, and I will fix it.)
*/
static inline void RENAME(yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
long width, long height,
(vc[0] << 8) + (yc[1] << 0);
#else
*idst++ = uc[0] + (yc[0] << 8) +
- (vc[0] << 16) + (yc[1] << 24);
+ (vc[0] << 16) + (yc[1] << 24);
#endif
yc += 2;
uc++;
}
/**
- * Height should be a multiple of 2 and width should be a multiple of 16 (if
- * this is a problem for anyone then tell me, and I will fix it).
+ * Height should be a multiple of 2 and width should be a multiple of 16
+ * (If this is a problem for anyone then tell me, and I will fix it.)
*/
static inline void RENAME(yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
long width, long height,
}
/**
- * Height should be a multiple of 2 and width should be a multiple of 16 (if
- * this is a problem for anyone then tell me, and I will fix it).
+ * Height should be a multiple of 2 and width should be a multiple of 16.
+ * (If this is a problem for anyone then tell me, and I will fix it.)
*/
static inline void RENAME(yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
long width, long height,
}
/**
- * Height should be a multiple of 2 and width should be a multiple of 16 (if
- * this is a problem for anyone then tell me, and I will fix it).
- * Chrominance data is only taken from every secound line, others are ignored.
+ * Height should be a multiple of 2 and width should be a multiple of 16.
+ * (If this is a problem for anyone then tell me, and I will fix it.)
+ * Chrominance data is only taken from every second line, others are ignored.
* FIXME: Write HQ version.
*/
static inline void RENAME(uyvytoyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
}
/**
- * Height should be a multiple of 2 and width should be a multiple of 2 (if
- * this is a problem for anyone then tell me, and I will fix it).
- * Chrominance data is only taken from every secound line,
+ * Height should be a multiple of 2 and width should be a multiple of 2.
+ * (If this is a problem for anyone then tell me, and I will fix it.)
+ * Chrominance data is only taken from every second line,
* others are ignored in the C version.
* FIXME: Write HQ version.
*/