home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / Meia / source / convert_scalar.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2009-09-14  |  4.2 KB  |  130 lines

  1. #include <vd2/Meia/MPEGConvert.h>
  2. #include "tables.h"
  3.  
  4. ///////////////////////////////////////////////////////////////////////////
  5.  
  6. using namespace nsVDMPEGTables;
  7.  
  8. extern "C" void asm_YUVtoRGB16_row(
  9.         void *ARGB1_pointer,
  10.         void *ARGB2_pointer,
  11.         const void *Y1_pointer,
  12.         const void *Y2_pointer,
  13.         const void *U_pointer,
  14.         const void *V_pointer,
  15.         long width
  16.         );
  17.  
  18. extern "C" void asm_YUVtoRGB24_row(
  19.         void *ARGB1_pointer,
  20.         void *ARGB2_pointer,
  21.         const void *Y1_pointer,
  22.         const void *Y2_pointer,
  23.         const void *U_pointer,
  24.         const void *V_pointer,
  25.         long width
  26.         );
  27.  
  28. extern "C" void asm_YUVtoRGB32_row(
  29.         void *ARGB1_pointer,
  30.         void *ARGB2_pointer,
  31.         const void *Y1_pointer,
  32.         const void *Y2_pointer,
  33.         const void *U_pointer,
  34.         const void *V_pointer,
  35.         long width
  36.         );
  37.  
  38. namespace nsVDMPEGConvertScalar {
  39.  
  40.     void DecodeRGB15(void *_dst, ptrdiff_t dpitch, const unsigned char *srcY1, ptrdiff_t ypitch, const unsigned char *srcCr, const unsigned char *srcCb, ptrdiff_t cpitch, int mbw, int height) {
  41.         char *dst1 = (char *)_dst;
  42.         char *dst2 = (char *)_dst + dpitch;
  43.         const unsigned char *srcY2 = srcY1 + ypitch;
  44.  
  45.         dpitch *= 2;
  46.         ypitch *= 2;
  47.  
  48.         do {
  49.             if (height == 1) {
  50.                 srcY2 = srcY1;
  51.                 dst2 = dst1;
  52.             }
  53.             asm_YUVtoRGB16_row(dst1, dst2, srcY1, srcY2, srcCb, srcCr, mbw*8);
  54.             dst1 += dpitch;
  55.             dst2 += dpitch;
  56.             srcY1 += ypitch;
  57.             srcY2 += ypitch;
  58.             srcCr += cpitch;
  59.             srcCb += cpitch;
  60.         } while((height-=2)>0);
  61.     }
  62.  
  63.     void DecodeRGB24(void *_dst, ptrdiff_t dpitch, const unsigned char *srcY1, ptrdiff_t ypitch, const unsigned char *srcCr, const unsigned char *srcCb, ptrdiff_t cpitch, int mbw, int height) {
  64.         char *dst1 = (char *)_dst;
  65.         char *dst2 = (char *)_dst + dpitch;
  66.         const unsigned char *srcY2 = srcY1 + ypitch;
  67.  
  68.         dpitch *= 2;
  69.         ypitch *= 2;
  70.  
  71.         do {
  72.             if (height == 1) {
  73.                 srcY2 = srcY1;
  74.                 dst2 = dst1;
  75.             }
  76.             asm_YUVtoRGB24_row(dst1, dst2, srcY1, srcY2, srcCb, srcCr, mbw*8);
  77.             dst1 += dpitch;
  78.             dst2 += dpitch;
  79.             srcY1 += ypitch;
  80.             srcY2 += ypitch;
  81.             srcCr += cpitch;
  82.             srcCb += cpitch;
  83.         } while((height-=2)>0);
  84.     }
  85.  
  86.     void DecodeRGB32(void *_dst, ptrdiff_t dpitch, const unsigned char *srcY1, ptrdiff_t ypitch, const unsigned char *srcCr, const unsigned char *srcCb, ptrdiff_t cpitch, int mbw, int height) {
  87.         char *dst1 = (char *)_dst;
  88.         char *dst2 = (char *)_dst + dpitch;
  89.         const unsigned char *srcY2 = srcY1 + ypitch;
  90.  
  91.         dpitch *= 2;
  92.         ypitch *= 2;
  93.  
  94.         do {
  95.             if (height == 1) {
  96.                 srcY2 = srcY1;
  97.                 dst2 = dst1;
  98.             }
  99.             asm_YUVtoRGB32_row(dst1, dst2, srcY1, srcY2, srcCb, srcCr, mbw*8);
  100.             dst1 += dpitch;
  101.             dst2 += dpitch;
  102.             srcY1 += ypitch;
  103.             srcY2 += ypitch;
  104.             srcCr += cpitch;
  105.             srcCb += cpitch;
  106.         } while((height-=2)>0);
  107.     }
  108. };
  109.  
  110. ///////////////////////////////////////////////////////////////////////////
  111.  
  112. namespace nsVDMPEGConvertReference {
  113.     extern void DecodeUYVY(void *_dst, ptrdiff_t dpitch, const unsigned char *srcY1, ptrdiff_t ypitch, const unsigned char *srcCr, const unsigned char *srcCb, ptrdiff_t cpitch, int mbw, int height);
  114.     extern void DecodeYUYV(void *_dst, ptrdiff_t dpitch, const unsigned char *srcY1, ptrdiff_t ypitch, const unsigned char *srcCr, const unsigned char *srcCb, ptrdiff_t cpitch, int mbw, int height);
  115.     extern void DecodeYVYU(void *_dst, ptrdiff_t dpitch, const unsigned char *srcY1, ptrdiff_t ypitch, const unsigned char *srcCr, const unsigned char *srcCb, ptrdiff_t cpitch, int mbw, int height);
  116.     extern void DecodeY41P(void *_dst, ptrdiff_t dpitch, const unsigned char *srcY1, ptrdiff_t ypitch, const unsigned char *srcCr, const unsigned char *srcCb, ptrdiff_t cpitch, int mbw, int height);
  117.     extern void DecodeRGB16(void *dst, ptrdiff_t dpitch, const unsigned char *srcY, ptrdiff_t ypitch, const unsigned char *srcCr, const unsigned char *srcCb, ptrdiff_t cpitch, int mbw, int height);
  118. }
  119.  
  120. const struct VDMPEGConverterSet g_VDMPEGConvert_scalar = {
  121.     nsVDMPEGConvertReference::DecodeUYVY,
  122.     nsVDMPEGConvertReference::DecodeYUYV,
  123.     nsVDMPEGConvertReference::DecodeYVYU,
  124.     nsVDMPEGConvertReference::DecodeY41P,
  125.     nsVDMPEGConvertScalar::DecodeRGB15,
  126.     nsVDMPEGConvertReference::DecodeRGB16,
  127.     nsVDMPEGConvertScalar::DecodeRGB24,
  128.     nsVDMPEGConvertScalar::DecodeRGB32,
  129. };
  130.