videoeditorengine/vedtranscoder/inc/ctrscaler.h
changeset 9 d87d32eab1a9
parent 0 951a5db380a0
equal deleted inserted replaced
0:951a5db380a0 9:d87d32eab1a9
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 * Resampling framework for YUV 4.2.0.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #ifndef CTRSCALER_H
       
    23 #define CTRSCALER_H
       
    24 
       
    25 
       
    26 // INCLUDES
       
    27 #include <e32base.h>
       
    28 #include "ctrcommon.h"
       
    29 
       
    30 
       
    31 // Scaler operations
       
    32 enum EResamplingOpereation
       
    33     {
       
    34     EOperationNone,
       
    35     EDoubleSize,          // Resize to 200%
       
    36     EUpSampling,          // Resize to 101% or more
       
    37     EOperationCopy,       // No resize (100%)
       
    38     EOperationCopyWithBB, // No resize, add black borders
       
    39     EDownSampling,        // Resize to 99% or less
       
    40     EHalveSize,           // Resize to 50%
       
    41     EUpDownSampling       // Resize with strech    
       
    42     };
       
    43 
       
    44 // Scaler class, supports resampling operations with YUV 4.2.0 format;
       
    45 NONSHARABLE_CLASS(CTRScaler) : public CBase
       
    46     {
       
    47     public:
       
    48         static CTRScaler* NewL();
       
    49 
       
    50         // Destructor
       
    51         ~CTRScaler();
       
    52 
       
    53     public:
       
    54         void Scale();
       
    55 
       
    56         // Sets operations
       
    57         void SetScalerOptionsL( TPtr8& aSrc, TPtr8& aTrg, TSize& aSrcSize, TSize& aTrgSize );
       
    58         
       
    59         // Checks if aspect ratio is wide
       
    60         TBool IsWideAspectRatio(TSize aSize);        
       
    61         
       
    62         // Calculates intermediate resolution for use with black boxing
       
    63         TBool GetIntermediateResolution(TSize aSrcSize, TSize aTrgSize, TSize& aTargetResolution, TSize& aBlackBoxing);
       
    64         
       
    65         // Returns a time estimate of how long it takes to resample a frame
       
    66         TReal EstimateResampleFrameTime(const TTRVideoFormat& aInput, const TTRVideoFormat& aOutput);
       
    67 
       
    68     private:
       
    69         CTRScaler();
       
    70 
       
    71         // Second phase constructor
       
    72         void ConstructL();
       
    73 
       
    74         // Resampling operations
       
    75         void ResampleBilinear(TSize& aSrcSize, TSize& aTrgSize, TSize& aBlackBoxing);
       
    76         void ResampleHalve(TSize& aSrcSize, TSize& aTrgSize, TSize& aBlackBoxing);
       
    77         void ResampleDouble(TSize& aSrcSize, TSize& aTrgSize);
       
    78         
       
    79         // Called when resizing to less than 50% of the original size
       
    80         void DoHalveAndBilinearResampleL();
       
    81         
       
    82         // No resampling, copy frame and add black borders.
       
    83         void CopyWithBlackBoxing(TSize& aSrcSize, TSize& aTrgSize, TSize& aBlackBoxing);
       
    84 
       
    85     private:
       
    86         // Source buffer
       
    87         TUint8* iSrc;
       
    88 
       
    89         // Destination buffer
       
    90         TUint8* iTrg;
       
    91 
       
    92         // Source resolution
       
    93         TSize iSrcSize; 
       
    94 
       
    95         // Target resolution
       
    96         TSize iTrgSize;
       
    97         
       
    98         // Resampling operation
       
    99         TInt iOperation;
       
   100 
       
   101         // Trg data size
       
   102         TUint iTrgDataSize;
       
   103         
       
   104         // Initial src ptr
       
   105         TUint8* iSrcInit;
       
   106 
       
   107         // Initial trg ptr
       
   108         TUint8* iTrgInit;
       
   109 
       
   110         // Scale X
       
   111         TInt iScaleXInt;
       
   112 
       
   113         // Scale Y
       
   114         TInt iScaleYInt;
       
   115         
       
   116         TPtr8* iTrgBuffer;
       
   117         
       
   118         // For storing width/height of black border area
       
   119         TSize iBlackBoxing;
       
   120         
       
   121     };
       
   122 
       
   123 
       
   124 
       
   125 
       
   126 #endif