swscale/x86/rgb2rgb_template: fix 1 byte overread in yuyvtoyuv420 and uyvytoyuv420

might fix ticket 3410

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/77/head
Michael Niedermayer 11 years ago
parent 4eb13cdfb0
commit 1e3f77b53a
  1. 42
      libswscale/x86/rgb2rgb_template.c

@ -2186,6 +2186,44 @@ static void RENAME(extract_even)(const uint8_t *src, uint8_t *dst, x86_reg count
}
}
static void RENAME(extract_odd)(const uint8_t *src, uint8_t *dst, x86_reg count)
{
src ++;
dst += count;
src += 2*count;
count= - count;
if(count < -16) {
count += 16;
__asm__ volatile(
"pcmpeqw %%mm7, %%mm7 \n\t"
"psrlw $8, %%mm7 \n\t"
"1: \n\t"
"movq -32(%1, %0, 2), %%mm0 \n\t"
"movq -24(%1, %0, 2), %%mm1 \n\t"
"movq -16(%1, %0, 2), %%mm2 \n\t"
"movq -8(%1, %0, 2), %%mm3 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm7, %%mm1 \n\t"
"pand %%mm7, %%mm2 \n\t"
"pand %%mm7, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm0,-16(%2, %0) \n\t"
MOVNTQ" %%mm2,- 8(%2, %0) \n\t"
"add $16, %0 \n\t"
" js 1b \n\t"
: "+r"(count)
: "r"(src), "r"(dst)
);
count -= 16;
}
while(count<0) {
dst[count]= src[2*count];
count++;
}
}
#if !COMPILE_TEMPLATE_AMD3DNOW
static void RENAME(extract_even2)(const uint8_t *src, uint8_t *dst0, uint8_t *dst1, x86_reg count)
{
@ -2449,7 +2487,7 @@ static void RENAME(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, co
const int chromWidth = FF_CEIL_RSHIFT(width, 1);
for (y=0; y<height; y++) {
RENAME(extract_even)(src+1, ydst, width);
RENAME(extract_odd)(src, ydst, width);
if(y&1) {
RENAME(extract_even2avg)(src-srcStride, src, udst, vdst, chromWidth);
udst+= chromStride;
@ -2475,7 +2513,7 @@ static void RENAME(uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, co
const int chromWidth = FF_CEIL_RSHIFT(width, 1);
for (y=0; y<height; y++) {
RENAME(extract_even)(src+1, ydst, width);
RENAME(extract_odd)(src, ydst, width);
RENAME(extract_even2)(src, udst, vdst, chromWidth);
src += srcStride;

Loading…
Cancel
Save