⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dc1394_conversions.c

📁 This library provides functionality to control any camera that conforms to the 1394-Based Digital C
💻 C
📖 第 1 页 / 共 2 页
字号:
{  register int i = ( ((width*height) + ( (width*height) << 1 )) << 1 ) -1;  register int j = ((width*height) << 1)-1;  register int y0, y1, u0, u1, v0, v1 ;  register int r, g, b, t;  switch (byte_order) {  case DC1394_BYTE_ORDER_YUYV:    while (i >= 0) {      t =src[i--];      b = (uchar_t) ((t + (src[i--]<<8)) >>(bits-8));      t =src[i--];      g = (uchar_t) ((t + (src[i--]<<8)) >>(bits-8));      t =src[i--];      r = (uchar_t) ((t + (src[i--]<<8)) >>(bits-8));      RGB2YUV (r, g, b, y0, u0 , v0);      t =src[i--];       b = (uchar_t) ((t + (src[i--]<<8)) >>(bits-8));      t =src[i--];      g = (uchar_t) ((t + (src[i--]<<8)) >>(bits-8));       t =src[i--];      r = (uchar_t) ((t + (src[i--]<<8)) >>(bits-8));      RGB2YUV (r, g, b, y1, u1 , v1);      dest[j--] = (v0+v1) >> 1;      dest[j--] = y0;      dest[j--] = (u0+u1) >> 1;      dest[j--] = y1;    }     break;  case DC1394_BYTE_ORDER_UYVY:    while (i >= 0) {      t =src[i--];       b = (uchar_t) ((t + (src[i--]<<8)) >>(bits-8));      t =src[i--];       g = (uchar_t) ((t + (src[i--]<<8)) >>(bits-8));      t =src[i--];       r = (uchar_t) ((t + (src[i--]<<8)) >>(bits-8));      RGB2YUV (r, g, b, y0, u0 , v0);      t =src[i--];       b = (uchar_t) ((t + (src[i--]<<8)) >>(bits-8));      t =src[i--];       g = (uchar_t) ((t + (src[i--]<<8)) >>(bits-8));      t =src[i--];       r = (uchar_t) ((t + (src[i--]<<8)) >>(bits-8));      RGB2YUV (r, g, b, y1, u1 , v1);      dest[j--] = y0;      dest[j--] = (v0+v1) >> 1;      dest[j--] = y1;      dest[j--] = (u0+u1) >> 1;    }    break;  default:    fprintf(stderr,"Invalid overlay byte order\n");    break;  }}/********************************************************************** * *  CONVERSION FUNCTIONS TO RGB 24bpp  * **********************************************************************/voiddc1394_RGB16_to_RGB8(uchar_t *restrict src, uchar_t *restrict dest, uint_t width, uint_t height, uint_t bits){  register int i = (((width*height) + ( (width*height) << 1 )) << 1)-1;  register int j = (width*height) + ( (width*height) << 1 ) -1;  register int t;  while (i >= 0) {    t = src[i--];    t = (t + (src[i--]<<8))>>(bits-8);    dest[j--]=t;    t = src[i--];    t = (t + (src[i--]<<8))>>(bits-8);    dest[j--]=t;    t = src[i--];    t = (t + (src[i--]<<8))>>(bits-8);    dest[j--]=t;  }}voiddc1394_YUV444_to_RGB8(uchar_t *restrict src, uchar_t *restrict dest, uint_t width, uint_t height){  register int i = (width*height) + ( (width*height) << 1 ) -1;  register int j = (width*height) + ( (width*height) << 1 ) -1;  register int y, u, v;  register int r, g, b;  while (i >= 0) {    v = (uchar_t) src[i--] - 128;    y = (uchar_t) src[i--];    u = (uchar_t) src[i--] - 128;    YUV2RGB (y, u, v, r, g, b);    dest[j--] = b;    dest[j--] = g;    dest[j--] = r;    }}voiddc1394_YUV422_to_RGB8(uchar_t *restrict src, uchar_t *restrict dest, uint_t width, uint_t height, uint_t byte_order){  register int i = ((width*height) << 1)-1;  register int j = (width*height) + ( (width*height) << 1 ) -1;  register int y0, y1, u, v;  register int r, g, b;    switch (byte_order) {  case DC1394_BYTE_ORDER_YUYV:    while (i >= 0) {      v  = (uchar_t) src[i--] -128;      y1 = (uchar_t) src[i--];      u  = (uchar_t) src[i--] -128;      y0  = (uchar_t) src[i--];      YUV2RGB (y1, u, v, r, g, b);      dest[j--] = b;      dest[j--] = g;      dest[j--] = r;      YUV2RGB (y0, u, v, r, g, b);      dest[j--] = b;      dest[j--] = g;      dest[j--] = r;    }    break;  case DC1394_BYTE_ORDER_UYVY:    while (i >= 0) {      y1 = (uchar_t) src[i--];      v  = (uchar_t) src[i--] - 128;      y0 = (uchar_t) src[i--];      u  = (uchar_t) src[i--] - 128;      YUV2RGB (y1, u, v, r, g, b);      dest[j--] = b;      dest[j--] = g;      dest[j--] = r;      YUV2RGB (y0, u, v, r, g, b);      dest[j--] = b;      dest[j--] = g;      dest[j--] = r;    }    break;  default:    fprintf(stderr,"Invalid overlay byte order\n");    break;  }  }voiddc1394_YUV411_to_RGB8(uchar_t *restrict src, uchar_t *restrict dest, uint_t width, uint_t height){  register int i = (width*height) + ( (width*height) >> 1 )-1;  register int j = (width*height) + ( (width*height) << 1 )-1;  register int y0, y1, y2, y3, u, v;  register int r, g, b;    while (i >= 0) {    y3 = (uchar_t) src[i--];    y2 = (uchar_t) src[i--];    v  = (uchar_t) src[i--] - 128;    y1 = (uchar_t) src[i--];    y0 = (uchar_t) src[i--];    u  = (uchar_t) src[i--] - 128;    YUV2RGB (y3, u, v, r, g, b);    dest[j--] = b;    dest[j--] = g;    dest[j--] = r;    YUV2RGB (y2, u, v, r, g, b);    dest[j--] = b;    dest[j--] = g;    dest[j--] = r;    YUV2RGB (y1, u, v, r, g, b);    dest[j--] = b;    dest[j--] = g;    dest[j--] = r;    YUV2RGB (y0, u, v, r, g, b);    dest[j--] = b;    dest[j--] = g;    dest[j--] = r;  }}voiddc1394_MONO8_to_RGB8(uchar_t *restrict src, uchar_t *restrict dest, uint_t width, uint_t height){  register int i = (width*height)-1;  register int j = (width*height) + ( (width*height) << 1 )-1;  register int y;  while (i >= 0) {    y = (uchar_t) src[i--];    dest[j--] = y;    dest[j--] = y;    dest[j--] = y;  }}voiddc1394_MONO16_to_RGB8(uchar_t *restrict src, uchar_t *restrict dest, uint_t width, uint_t height, uint_t bits){  register int i = ((width*height) << 1)-1;  register int j = (width*height) + ( (width*height) << 1 )-1;  register int y;  while (i > 0) {    y = src[i--];    y = (y + (src[i--]<<8))>>(bits-8);    dest[j--] = y;    dest[j--] = y;    dest[j--] = y;  }}// change a 16bit stereo image (8bit/channel) into two 8bit images on top// of each othervoiddc1394_deinterlace_stereo(uchar_t *restrict src, uchar_t *restrict dest, uint_t width, uint_t height){  register int i = (width*height)-1;  register int j = ((width*height)>>1)-1;  register int k = (width*height)-1;  while (i >= 0) {    dest[k--] = src[i--];    dest[j--] = src[i--];  }}dc1394error_tdc1394_convert_to_YUV422(uchar_t *restrict src, uchar_t *restrict dest, uint_t width, uint_t height, uint_t byte_order,			 dc1394color_coding_t source_coding, uint_t bits){  switch(source_coding) {  case DC1394_COLOR_CODING_YUV422:    dc1394_YUV422_to_YUV422(src, dest, width, height, byte_order);    break;  case DC1394_COLOR_CODING_YUV411:    dc1394_YUV411_to_YUV422(src, dest, width, height, byte_order);    break;  case DC1394_COLOR_CODING_YUV444:    dc1394_YUV444_to_YUV422(src, dest, width, height, byte_order);    break;  case DC1394_COLOR_CODING_RGB8:    dc1394_RGB8_to_YUV422(src, dest, width, height, byte_order);    break;  case DC1394_COLOR_CODING_MONO8:  case DC1394_COLOR_CODING_RAW8:    dc1394_MONO8_to_YUV422(src, dest, width, height, byte_order);    break;  case DC1394_COLOR_CODING_MONO16:    dc1394_MONO16_to_YUV422(src, dest, width, height, byte_order, bits);    break;  case DC1394_COLOR_CODING_RGB16:    dc1394_RGB16_to_YUV422(src, dest, width, height, byte_order, bits);    break;  default:    fprintf(stderr,"Conversion to YUV422 from this color coding is not supported\n");    return DC1394_FAILURE;  }  return DC1394_SUCCESS;}dc1394error_tdc1394_convert_to_MONO8(uchar_t *restrict src, uchar_t *restrict dest, uint_t width, uint_t height, uint_t byte_order,			dc1394color_coding_t source_coding, uint_t bits){  switch(source_coding) {  case DC1394_COLOR_CODING_MONO16:    dc1394_MONO16_to_MONO8(src, dest, width, height, bits);    break;  case DC1394_COLOR_CODING_MONO8:    memcpy(dest, src, width*height);    break;  default:    fprintf(stderr,"Conversion to MONO8 from this color coding is not supported\n");    return DC1394_FAILURE;  }  return DC1394_SUCCESS;}dc1394error_tdc1394_convert_to_RGB8(uchar_t *restrict src, uchar_t *restrict dest, uint_t width, uint_t height, uint_t byte_order,		       dc1394color_coding_t source_coding, uint_t bits){  switch(source_coding) {  case DC1394_COLOR_CODING_RGB16:    dc1394_RGB16_to_RGB8 (src, dest, width, height, bits);    break;  case DC1394_COLOR_CODING_YUV444:    dc1394_YUV444_to_RGB8 (src, dest, width, height);    break;  case DC1394_COLOR_CODING_YUV422:    dc1394_YUV422_to_RGB8 (src, dest, width, height, byte_order);    break;  case DC1394_COLOR_CODING_YUV411:    dc1394_YUV411_to_RGB8 (src, dest, width, height);    break;  case DC1394_COLOR_CODING_MONO8:  case DC1394_COLOR_CODING_RAW8:    dc1394_MONO8_to_RGB8 (src, dest, width, height);    break;  case DC1394_COLOR_CODING_MONO16:    dc1394_MONO16_to_RGB8 (src, dest, width, height,bits);    break;  case DC1394_COLOR_CODING_RGB8:    memcpy(dest, src, width*height*3);    break;  default:    fprintf(stderr,"Conversion to RGB8 from this color coding is not supported\n");    return DC1394_FAILURE;  }  return DC1394_SUCCESS;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -