[Ffmpeg-devel] question on cs_test testing semantics.

Marc Hoffman mmh
Thu Mar 29 14:40:56 CEST 2007

This function is called in a big loop running over src with an offset
which advances by 1 in each iteration.  This causes a misaligned
access violation on some non X86 architectures. I'm curious as to why
this test is written this way. Is the intent to start sampling the
input pixels at odd memory locations as the beginning of the first

src points to (rgb16 sample 0) at the start even if the pointer is odd?


 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
static inline void RENAME(rgb15to16)(const uint8_t *src,uint8_t *dst,long src_size)
  register const uint8_t* s=src;
  register uint8_t* d=dst;
  register const uint8_t *end;
  const uint8_t *mm_end;
  end = s + src_size;
#ifdef HAVE_MMX
  __asm __volatile(PREFETCH"	%0"::"m"(*s));
  __asm __volatile("movq	%0, %%mm4"::"m"(mask15s));
  mm_end = end - 15;
	__asm __volatile(
		PREFETCH"	32%1\n\t"
		"movq	%1, %%mm0\n\t"
		"movq	8%1, %%mm2\n\t"
		"movq	%%mm0, %%mm1\n\t"
		"movq	%%mm2, %%mm3\n\t"
		"pand	%%mm4, %%mm0\n\t"
		"pand	%%mm4, %%mm2\n\t"
		"paddw	%%mm1, %%mm0\n\t"
		"paddw	%%mm3, %%mm2\n\t"
		MOVNTQ"	%%mm0, %0\n\t"
		MOVNTQ"	%%mm2, 8%0"
  __asm __volatile(SFENCE:::"memory");
  __asm __volatile(EMMS:::"memory");
    mm_end = end - 3;
    while(s < mm_end)
	register unsigned x= *((uint32_t *)s);
	*((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0);
    if(s < end)
	register unsigned short x= *((uint16_t *)s);
	*((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0);

More information about the ffmpeg-devel mailing list