os/ossrv/genericopenlibs/liboil/tsrc/testsuite/jpeg/src/yuv2rgb.c
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 
    17 
    18 #ifdef HAVE_CONFIG_H
    19 #include "config.h"
    20 #endif
    21 
    22 #include <liboil/liboil.h>
    23 #include <liboil/liboilfunction.h>
    24 #include <stdio.h>
    25 #include <string.h>
    26 #include <globals.h>
    27 
    28 #define LOG_FILE "c:\\logs\\testsuite_yuv2rgb_log.txt"
    29 #include "std_log_result.h"
    30 #define LOG_FILENAME_LINE __FILE__, __LINE__
    31 #define MAX_SIZE 10
    32 #define RES_SIZE 40
    33 
    34 void create_xml(int result)
    35 {
    36     if(result)
    37         assert_failed = 1;
    38     
    39     testResultXml("testsuite_yuv2rgb");
    40     close_log_file();
    41 }
    42 
    43 
    44 void test_yuv2rgbx_u8()
    45     {
    46     uint8_t src1[MAX_SIZE], src2[MAX_SIZE], src3[MAX_SIZE];
    47     uint8_t res[RES_SIZE],check[RES_SIZE]={0,135,0,0,0,134,0,0,0,134,0,0,0,134,0,0,0,134,0,0,0,134,0,0,0,134,0,0,0,134,0,0,0,134,0,0,0,134,0,0};
    48     int i;
    49     
    50     for(i=0;i<MAX_SIZE;i++)
    51 	{
    52           src1[i]=i+1;
    53           src2[i]=i;
    54           src3[i]=i+2;
    55 	}
    56     
    57     for(i=0;i<RES_SIZE;i++)
    58         res[i]=0;
    59         
    60     oil_yuv2rgbx_u8(res,src1,src2,src3,MAX_SIZE);
    61        
    62 	for(i=0;i<RES_SIZE;i++)
    63     if(res[i] == check[i])
    64         {
    65          std_log(LOG_FILENAME_LINE,"oil_yuv2rgbx_u8 successful, res[%d] = %d", i,res[i]); 
    66         }
    67     else
    68         {
    69          assert_failed=1;
    70          std_log(LOG_FILENAME_LINE,"oil_yuv2rgbx_u8 unsuccessful, Expected =%d,Obtained =%d",check[i],res[i]);
    71         }
    72     }
    73 
    74 
    75 void test_yuv2rgbx_sub2_u8()
    76     {
    77     uint8_t src1[MAX_SIZE], src2[MAX_SIZE], src3[MAX_SIZE];
    78     uint8_t res[RES_SIZE],check[RES_SIZE]={0,134,0,0,0,135,0,0,0,135,0,0,0,136,0,0,0,136,0,0,0,137,0,0,0,137,0,0,0,138,0,0,0,138,0,0,0,139,0,0};
    79     int i;
    80     
    81     for(i=0;i<MAX_SIZE;i++)
    82     {
    83           src1[i]=i;
    84           src2[i]=i+1;
    85           src3[i]=i+1;
    86     }
    87     
    88     for(i=0;i<RES_SIZE;i++)
    89         res[i]=0;
    90         
    91     oil_yuv2rgbx_sub2_u8(res,src1,src2,src3,MAX_SIZE);
    92     
    93     for(i=0;i<RES_SIZE;i++)
    94     if(res[i] == check[i])
    95         {
    96          std_log(LOG_FILENAME_LINE,"oil_yuv2rgbx_sub2_u8 successful, res[%d] = %d", i,res[i]); 
    97         }
    98     else
    99         {
   100          assert_failed=1;
   101          std_log(LOG_FILENAME_LINE,"oil_yuv2rgbx_sub2_u8 unsuccessful, Expected =%d,Obtained =%d",check[i],res[i]);
   102         }
   103     }
   104 
   105 
   106 
   107 void test_yuv2rgbx_sub4_u8()
   108     {
   109     uint8_t src1[MAX_SIZE], src2[MAX_SIZE], src3[MAX_SIZE];
   110     uint8_t res[RES_SIZE],check[RES_SIZE]={0,137,0,0,0,138,0,0,0,139,0,0,0,140,0,0,0,140,0,0,0,141,0,0,0,142,0,0,0,143,0,0,0,0,0,0,0,0,0,0};
   111     int i;
   112     
   113     for(i=0;i<MAX_SIZE;i++)
   114     {
   115           src1[i]=i+2;
   116           src2[i]=i+1;
   117           src3[i]=i;
   118     }
   119     
   120     for(i=0;i<RES_SIZE;i++)
   121         res[i]=0;
   122         
   123     oil_yuv2rgbx_sub4_u8(res,src1,src2,src3,MAX_SIZE);
   124     
   125     for(i=0;i<RES_SIZE;i++)
   126     if(res[i] == check[i])
   127         {
   128          std_log(LOG_FILENAME_LINE,"oil_yuv2rgbx_sub4_u8 successful, res[%d] = %d", i,res[i]); 
   129         }
   130     else
   131         {
   132          assert_failed=1;
   133          std_log(LOG_FILENAME_LINE,"oil_yuv2rgbx_sub4_u8 unsuccessful,Expected =%d,Obtained =%d",check[i],res[i]);
   134         }
   135     }
   136 
   137 
   138 int main()
   139     {
   140     std_log(LOG_FILENAME_LINE,"Test started testsuite_yuv2rgb8x8");
   141     oil_init ();
   142 
   143     std_log(LOG_FILENAME_LINE,"oil_yuv2rgbx_u8");
   144     test_yuv2rgbx_u8(); 
   145     
   146     std_log(LOG_FILENAME_LINE,"oil_yuv2rgbx_sub2_u8");
   147     test_yuv2rgbx_sub2_u8(); 
   148     
   149     std_log(LOG_FILENAME_LINE,"oil_yuv2rgbx_sub4_u8");
   150     test_yuv2rgbx_sub4_u8(); 
   151 
   152       
   153     if(assert_failed)
   154            std_log(LOG_FILENAME_LINE,"Test Fail");
   155     else
   156            std_log(LOG_FILENAME_LINE,"Test Successful");
   157     create_xml(0);
   158     return 0;
   159     }