Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

l1394_converter.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           converter.cpp  -  description
00003                              -------------------
00004     begin                : Thu Nov 30 2000
00005     copyright            : (C) 2000-2004 by Michael Repplinger
00006     email                : repplinger@cs.uni-sb.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "l1394_converter.h"
00019 #include <iostream>
00020 #include <l1394_resource.h>
00021 namespace L1394_MM
00022 {
00023 
00024 Converter::Converter(){
00025 }
00026 Converter::~Converter(){
00027 }
00028 
00029 //int Converter::UYVYtoBGRA32_MMX(unsigned char* source, int source_size,unsigned char* destination)
00030 //{
00031 //  unpack422rgb32_mmx(source, source_size,destination);
00032 //  return (2*source_size);
00033 //}
00034 
00035 
00036 int Converter::UYVYtoBGRA32(unsigned char *src, int n,unsigned char *dst)
00037 {
00038   if (!src || !dst) {
00039     cerr << "Source or destination is 0" << endl;
00040     return 0;
00041   }
00042   if (n <= 0)
00043   {
00044     cout << "frame size is "<< n<<endl;
00045     return L1394_FAILED;
00046   }
00047   unsigned char *end=src+n;
00048   int r, g, b;
00049   int r1, g1, b1;
00050   int r2, g2, b2;
00051 
00052   while(src!=end)
00053     {
00054       r=((((int)src[0]-128)*0x166E9)>>16);
00055       g=-((((int)src[2]-128)*0x05819)>>16)-((((int)src[0]-128)*0x0B6D1)>>16);
00056       b=((((int)src[2]-128)*0x1C5A1)>>16);
00057 
00058       r1=r+src[1];
00059       g1=g+src[1];
00060       b1=b+src[1];
00061       r2=r+src[3];
00062       g2=g+src[3];
00063       b2=b+src[3];
00064 
00065       r1=CLIPPED(r1);
00066       g1=CLIPPED(g1);
00067       b1=CLIPPED(b1);
00068       r2=CLIPPED(r2);
00069       g2=CLIPPED(g2);
00070       b2=CLIPPED(b2);
00071 
00072       dst[0]=r1;
00073       dst[1]=g1;
00074       dst[2]=b1;
00075       dst[3]=0;
00076       dst[4]=r2;
00077       dst[5]=g2;
00078       dst[6]=b2;
00079       dst[7]=0;
00080 
00081       src+=4;
00082       dst+=8;
00083   }
00084   return (2*n);
00085 }
00086 int Converter::RGB24toBGRA32(unsigned char *src, int n,unsigned char *dst)
00087 {
00088   int i = 0; int j = 0;
00089   while(i<n)
00090   {
00091     dst[j+0] = src[i+2];
00092     dst[j+1] = src[i+1];
00093     dst[j+2] = src[i+0];
00094     dst[j+3] = (char) 0x0;
00095     i+=3;
00096     j+=4;
00097   }
00098   return j;
00099 }
00100 
00101 l1394_converter Converter::getConverter(string source_format, string destination_format, bool mmx)
00102 {
00103   string format_string = source_format+"to"+destination_format;
00104   if (mmx)
00105     format_string +="_MMX";
00106 
00107   map<string, l1394_converter>::iterator tmp_iterator;
00108   cout << "searching for " << format_string << endl;
00109    tmp_iterator = converter_map.find(format_string);
00110    if (tmp_iterator == converter_map.end())
00111    {
00112      cout << "L1394_Decoder " << " :> No valid convert found in converter_map" << endl;
00113      return 0;
00114    }
00115    return converter_map[format_string];
00116 }
00117 
00118 void Converter::createMap()
00119 {
00120  /* converter_map["UYVYtoBGRA32"]     =
00121   converter_map["UYVYtoBGRA32_MMX"] =
00122   converter_map["RGB24toBGRA32"]    =
00123    */
00124 }
00125 }

Generated on Wed Aug 24 00:36:40 2005 for L1394 by doxygen 1.4.2
L1394 library (NMM) grahics.cs.uni-sb.de/~repplix/l1394_home/