videoeditorengine/vedengine/videoprocessor/src/Yuv2rgb16.cpp
author Mikael Laine <mikael.laine@ixonos.com>
Fri, 29 Jan 2010 14:08:33 +0200
changeset 0 951a5db380a0
permissions -rw-r--r--
Committing the Video Editor package under the Eclipse Public License
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
     1
/*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
     2
* Copyright (c) 2010 Ixonos Plc.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
     3
* All rights reserved.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
     5
* under the terms of the "Eclipse Public License v1.0"
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
     8
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
     9
* Initial Contributors:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    10
* Nokia Corporation - Initial contribution
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    11
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    12
* Contributors:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    13
* Ixonos Plc
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    14
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    15
* Description:  
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    16
* Implementation of class CYuv2Rgb16.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    17
* YUV to EColor64K colorspace converter concrete classes.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    18
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    19
*/
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    20
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    21
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    22
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    23
#include "yuv2rgb16.h"
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    24
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    25
// ---------------------------------------------------------
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    26
// CYuv2Rgb16::CYuv2Rgb16()
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    27
// Standard C++ constructor.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    28
// ---------------------------------------------------------
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    29
//
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    30
CYuv2Rgb16::CYuv2Rgb16()
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    31
{
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    32
    iWidth = iHeight = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    33
}
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    34
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    35
// ---------------------------------------------------------
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    36
// CYuv2Rgb16::~CYuv2Rgb16()
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    37
// Destructor
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    38
// ---------------------------------------------------------
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    39
//
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    40
CYuv2Rgb16::~CYuv2Rgb16()
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    41
{
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    42
}
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    43
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    44
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    45
// ---------------------------------------------------------
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    46
// CYuv2Rgb16::ConstructL()
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    47
// Symbian 2nd phase constructor can leave.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    48
// ---------------------------------------------------------
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    49
//
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    50
void CYuv2Rgb16::ConstructL(TUint aWidth, TUint aHeight, TUint /*aMaxWidth*/, TUint /*aMaxHeight*/)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    51
{
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    52
    iWidth = aWidth;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    53
    iHeight = aHeight;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    54
}
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    55
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    56
// ---------------------------------------------------------
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    57
// CYuv2Rgb16::Convert()
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    58
// Converts a YUV frame to a EColor64K frame
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    59
// ---------------------------------------------------------
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    60
//
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    61
void CYuv2Rgb16::Convert(const TUint8 *aYBuf, const TUint8 *aUBuf,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    62
                         const TUint8 *aVBuf,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    63
                         TUint aBufWidth, TUint aBufHeight,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    64
                         TUint8 *aTarget, TUint aTargetScanlineLength)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    65
{
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    66
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    67
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    68
    TUint cols;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    69
    TUint rows = iHeight;       
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    70
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    71
    __ASSERT_ALWAYS((aBufWidth >= iWidth) && (aBufHeight >= iHeight),
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    72
        User::Invariant());
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    73
        
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    74
    // Convert all rows, two at a time
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    75
    while ( rows )  
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    76
    {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    77
        // Convert all pixels in this row, two at a time
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    78
        cols = iWidth;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    79
        
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    80
        TUint8* target1 = aTarget;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    81
        TUint8* target2 = aTarget + aTargetScanlineLength;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    82
        const TUint8* YPtr1 = aYBuf;  
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    83
        const TUint8* YPtr2 = aYBuf + aBufWidth;        
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    84
        const TUint8* UPtr = aUBuf;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    85
        const TUint8* VPtr = aVBuf;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    86
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    87
        TUint    y, u, v;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    88
        TInt rDiff, gDiff, bDiff;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    89
        TInt     r, g, b;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    90
       
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    91
        while ( cols )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    92
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    93
            y = *(YPtr1)++;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    94
            u = *(UPtr)++ - 128;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    95
            v = *(VPtr)++ - 128;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    96
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    97
            rDiff = UvToRDiff(v, u);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    98
            gDiff = UvToGDiff(v, u);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    99
            bDiff = UvToBDiff(v, u);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   100
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   101
            // Convert upper left pixel            
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   102
            r = (TInt)y + rDiff;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   103
            r = r<0 ? 0 : r>255 ? 0xF800 : (r<<8)&0xF800;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   104
            g = (TInt)y - gDiff;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   105
            g = g<0 ? 0 : g>255 ? 0x07E0 : (g<<3)&0x07E0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   106
            b = (TInt)y + bDiff;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   107
            b = b<0 ? 0 : b>255 ? 0x001F : (b>>3)&0x001F;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   108
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   109
            // Write the pixel in RGB format
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   110
            *(TUint16*)target1 = (TUint16)(r | g | b);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   111
            target1 += 2;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   112
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   113
            // Convert upper right pixel
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   114
            y = *(YPtr1)++;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   115
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   116
            r = (TInt)y + rDiff;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   117
            r = r<0 ? 0 : r>255 ? 0xF800 : (r<<8)&0xF800;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   118
            g = (TInt)y - gDiff;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   119
            g = g<0 ? 0 : g>255 ? 0x07E0 : (g<<3)&0x07E0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   120
            b = (TInt)y + bDiff;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   121
            b = b<0 ? 0 : b>255 ? 0x001F : (b>>3)&0x001F;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   122
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   123
            *(TUint16*)target1 = (TUint16)(r | g | b);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   124
            target1 += 2;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   125
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   126
            // Convert lower left pixel
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   127
            y = *(YPtr2)++;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   128
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   129
            r = (TInt)y + rDiff;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   130
            r = r<0 ? 0 : r>255 ? 0xF800 : (r<<8)&0xF800;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   131
            g = (TInt)y - gDiff;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   132
            g = g<0 ? 0 : g>255 ? 0x07E0 : (g<<3)&0x07E0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   133
            b = (TInt)y + bDiff;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   134
            b = b<0 ? 0 : b>255 ? 0x001F : (b>>3)&0x001F;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   135
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   136
            *(TUint16*)target2 = (TUint16)(r | g | b);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   137
            target2 += 2;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   138
                
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   139
            // Convert lower right pixel
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   140
            y = *(YPtr2)++;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   141
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   142
            r = (TInt)y + rDiff;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   143
            r = r<0 ? 0 : r>255 ? 0xF800 : (r<<8)&0xF800;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   144
            g = (TInt)y - gDiff;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   145
            g = g<0 ? 0 : g>255 ? 0x07E0 : (g<<3)&0x07E0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   146
            b = (TInt)y + bDiff;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   147
            b = b<0 ? 0 : b>255 ? 0x001F : (b>>3)&0x001F;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   148
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   149
            *(TUint16*)target2 = (TUint16)(r | g | b);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   150
            target2 += 2;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   151
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   152
            // Next two pixels                                   
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   153
            cols -= 2;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   154
        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   155
        
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   156
        // Next rows
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   157
        rows -= 2;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   158
        aYBuf += 2*aBufWidth;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   159
        aUBuf += aBufWidth/2;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   160
        aVBuf += aBufWidth/2;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   161
        aTarget += 2*aTargetScanlineLength;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   162
    }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   163
}