Re: YUYVYUYV -> YYYY,UU,VV. How can I do this using SSE ?

From: Bernie (spamtrap_at_crayne.org)
Date: 09/22/04

  • Next message: Robert Wessel: "Re: Writing simple profiler"
    Date: Wed, 22 Sep 2004 17:51:42 +0000 (UTC)
    
    

    "kamil" <spamtrap@crayne.org> a écrit dans le message de
    news:cfinoj$ach$1@nemesis.news.tpi.pl...
    > I have byte data in following format :
    >
    > src_ptr1: Y U Y V Y U Y V .....
    >
    > and I need it to be written as:
    >
    > dst_ptr1: Y Y Y Y ...
    > dst_ptr2: U U ...
    > dst_ptr3: V V ...
    >
    > Cound you give me some advice ? which instruction should be used to unpack
    > this data ?
    >
    > Thanks in advance,
    > Kamil
    >
    >

    Based on the following you could write full split and join function :

    void SPLITTER_YUV422_YUYV(unsigned char* pimage, unsigned char* lumi)
    {
     static _declspec(align(16)) unsigned char xmmAndmaskSplit[16] =
     { 0xFF, 0x0, 0xFF, 0x0, 0xFF, 0x0, 0xFF, 0x0, 0xFF, 0x0, 0xFF, 0x0, 0xFF,
    0x0, 0xFF, 0x0};
     _declspec(align(16)) unsigned char* msk = xmmAndmaskSplit;

     int step = 720*2;
     unsigned char* src;
     unsigned char* Y;

     for (int y=0; y<576; y++ )
     {
      Y=lumi + y*720;
      src=pimage + y*step;
      for (int x=0; x<720; x+=16)
      {
       _asm
       {
        mov eax, src;
        mov edx, Y;
        mov esi, msk;
        pxor xmm6, xmm6;
        movdqa xmm4, [esi]; //Load byte mask in mm4 register
               //0 FF 0 FF 0 FF 0 FF 0 FF 0 FF 0 FF 0 FF 0 FF 0 FF

        //LOAD FROM YUYV BUFFER 2x8 pels IN 2 XMM REGISTER
        movdqa xmm0, [eax]; //128bits 16*8bits x15 x14 x13 x12 x11 x10 x9 x8 x7
    x6 x5 x4 x3 x2 x1 x0
        movdqa xmm2, [eax+16]; //y15 y14 y13 y12 y11 y10 y9 y8 y7 y6 y5 y4 y3 y2
    y1 y0

        pand xmm0, xmm4; //0 x14 0 x12 0 x10 0 x8 0 x6 0 x5 0 x3 0 x0
        pand xmm2, xmm4; //0 y14 0 y12 0 y10 0 y8 0 y6 0 y5 0 y3 0 y0

        //BUILD ==> y14 y12 y10 y8 y6 y5 y3 y0 x14 x12 x10 x8 x6 x5 x3 x0
        packuswb xmm0, xmm2;

        //SAVE TO INTERNAL BUFFER 2x8pels FROM 1 XMM REGISTER
        movdqa [edx], xmm0;

       }
       Y+=16;
       src+=32;
      }
     }
    }


  • Next message: Robert Wessel: "Re: Writing simple profiler"

    Relevant Pages

    • [NT] Analysis of LSDs Buffer Overrun in Windows RPC Interface
      ... one is a local stack overflow and the other is a remote ... text:761543DA push ebp ... text:761543E0 mov eax, ... unsigned char request1={ ...
      (Securiteam)
    • Re: endof
      ... str_copy(const unsigned char *src, ... return dst - start; ... The lim pointers are just "fence post"s. ... the src < slim check very consistent and less prone to error because ...
      (comp.lang.c)
    • Re: Harmless Fluffy Bunny
      ... to snuff out all of the spl/mov pairs in Bunny. ... boot spl 2,0 ... mov d3,>5000 ... mov <src, {dest ...
      (rec.games.corewar)
    • Keil C51/A51 ASM Code in C
      ... void myop (unsigned char idx, unsigned char pos1, unsigned char pos2, ... mov a, #x ... ECRYPT.C: warning C280: 'pos1': unreferenced local variable ... access the unsigned char idata x-array from the assembler code? ...
      (comp.arch.embedded)
    • Re: Implementing my own memcpy
      ... > With your code fragment, I find that you are using unsigned char*, but ... The void * type can point at arbitrary things, ... void *dupmem(void *src, size_t sz) ... no deficiencies and the other way is to make it so complicated ...
      (comp.lang.c)