From: NoEmail@nospicedham.trraxvfeqa.prg   
      
   On Mon, 5 Feb 2018 16:06:08 -0700   
   "Benjamin David Lunt" wrote:   
      
   > I have been working on my USB Camera code and have a routine   
   > to convert the stream of data from yuy2 to RGB.   
      
   Doesn't FFMPEG on Linux do such conversions? ...   
      
   > Here is my (generic) C routine:   
   >   
   > void yuy2_to_rgb565(void *targ, void *src, int cnt) {   
   > bit8u *s = (bit8u *) src;   
   > bit16u *t = (bit16u *) targ;   
   >   
   > while (cnt > 0) {   
   > int y0 = *s++;   
   > int u0 = *s++;   
   > int y1 = *s++;   
   > int v0 = *s++;   
   > cnt -= 4;   
   >   
   > int c = y0 - 16; // luma   
   > int d = u0 - 128; // cr   
   > int e = v0 - 128; // cb   
   >   
   > *t++ =   
   > ((298 * c + 409 * e + 128) & 0xF800) | // R   
   > (((298 * c - 100 * d - 208 * e + 128) & 0xFC00) >> 5) | //G   
   > (((298 * c + 516 * d + 128) & 0xF800) >> 11); // B   
   >   
   > c = y1 - 16;   
   >   
   > *t++ =   
   > ((298 * c + 409 * e + 128) & 0xF800) | // R   
   > (((298 * c - 100 * d - 208 * e + 128) & 0xFC00) >> 5) | // G   
   > (((298 * c + 516 * d + 128) & 0xF800) >> 11); // B   
   > }   
   > }   
   >   
   > (I tried to make it narrow enough not to wrap in the post, but   
   > please watch for wrap)   
   >   
      
   Well, I'm not familiar with these video formats or their mathematical   
   conversion, but I do notice an awful lot of multiplication, masking,   
   shifting, etc, while I don't see any look-up tables to reduce shifting   
   and masking, etc. I.e., I really doubt this is as fast as C can go.   
      
   Without a full test harness, i.e., a program to read in YUY2 file and   
   write out a RGB file, and sample YUY2 input video with converted RGB   
   output video, so I can to verify a replacement routine, I'm not about to   
   play around with this.   
      
   If you want to explain YUY2 format to us, you could drop a post on   
   a.l.a, a.o.d, or your website.   
      
      
   Rod Pemberton   
   --   
   "The strongest, richest, greatest nation in the world shouldn't leave   
   anyone behind," said Joe Kennedy. "We're going to put a lot of coal   
   miners and coal country out of business," said Hillary Clinton.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|