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