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