videoeditorengine/h263decoder/src/vedh263dimp.cpp
changeset 0 951a5db380a0
equal deleted inserted replaced
-1:000000000000 0:951a5db380a0
       
     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 * H.263 Decoder API implementation class.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "vde.h"
       
    24 #include "h263dapi.h"
       
    25 #include "vedh263dimp.h"
       
    26 /* MVE */
       
    27 #include "MPEG4Transcoder.h"
       
    28 
       
    29 // An assertion macro wrapper to clean up the code a bit
       
    30 #define DLASSERT(x) __ASSERT_DEBUG(x, User::Panic(_L("CVedH263Dec"), EInternalAssertionFailure))
       
    31 
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CVedH263DecImp::CVedH263DecImp
       
    37 // C++ default constructor can NOT contain any code, that
       
    38 // might leave.
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CVedH263DecImp::CVedH263DecImp(TSize aFrameSize, TInt /*aNumReferencePictures*/)
       
    42 {
       
    43     iH263dHandle = 0;
       
    44     iFrameSize = aFrameSize;
       
    45 }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CVedH263DecImp::ConstructL
       
    49 // Symbian 2nd phase constructor can leave.
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 void CVedH263DecImp::ConstructL()
       
    53 {
       
    54 
       
    55     // Open a decoder instance
       
    56     h263dOpen_t openParams;
       
    57     openParams.numPreallocatedFrames = 1;
       
    58     openParams.lumWidth = iFrameSize.iWidth;
       
    59     openParams.lumHeight = iFrameSize.iHeight;
       
    60 
       
    61     openParams.fRPS = 0; // reference picture selection mode not in use
       
    62     openParams.numReferenceFrames = 1;
       
    63     openParams.freeSpace = 0;
       
    64     iH263dHandle = h263dOpen(&openParams);
       
    65     if (!iH263dHandle)
       
    66         User::Leave(KErrGeneral);
       
    67 
       
    68 }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CVedH263DecImp::NewL
       
    72 // Two-phased constructor.
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 EXPORT_C CVedH263Dec* CVedH263Dec::NewL(const TSize aFrameSize, const TInt aNumReferencePictures)
       
    76 {
       
    77 
       
    78     CVedH263DecImp* self = new (ELeave) CVedH263DecImp(aFrameSize, aNumReferencePictures);
       
    79     CleanupStack::PushL(self);
       
    80     self->ConstructL();
       
    81     CleanupStack::Pop(self);    
       
    82     return self;    
       
    83 }
       
    84 
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CVedH263DecImp::~CVedH263DecImp
       
    88 // Destructor
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 CVedH263DecImp::~CVedH263DecImp()
       
    92 {
       
    93     // Close the decoder instance if one has been opened
       
    94     if (iH263dHandle)
       
    95     {
       
    96         h263dClose(iH263dHandle);
       
    97         iH263dHandle = 0;
       
    98     }
       
    99 
       
   100 }
       
   101 
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CVedH263DecImp::SetRendererL
       
   105 // Sets the renderer object which the decoder will use
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 void CVedH263DecImp::SetRendererL(MVideoRenderer* /*aRenderer*/)
       
   109 {
       
   110     // this method is not supported any more
       
   111     User::Panic(_L("CVedH263Dec - method not supported"), EInternalAssertionFailure);
       
   112 }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CVedH263DecImp::SetPostFilterL
       
   116 // Sets the post-filter to be used in decoding
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 void CVedH263DecImp::SetPostFilterL(const TPostFilter /*aFilter*/)
       
   120 {
       
   121     // this method is not supported any more
       
   122     User::Panic(_L("CVedH263Dec - method not supported"), EInternalAssertionFailure);
       
   123 }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CVedH263DecImp::GetYUVFrame
       
   127 // Retrieves the YUV buffer for the last decoded frame
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 TUint8* CVedH263DecImp::GetYUVFrame()
       
   131 {
       
   132     // this method is not supported any more
       
   133     User::Panic(_L("CVedH263Dec - method not supported"), EInternalAssertionFailure);
       
   134 
       
   135     return NULL; 
       
   136 
       
   137 }
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // CVedH263DecImp::GetYUVBuffers
       
   141 // Retrieves the Y/U/V buffers for the given frame
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 TInt CVedH263DecImp::GetYUVBuffers(const TAny */*aFrame*/, TUint8*& /*aYFrame*/, TUint8*& /*aUFrame*/, 
       
   145                                    TUint8*& /*aVFrame*/, TSize& /*aFrameSize*/)
       
   146 {
       
   147     // this method is not supported any more
       
   148     User::Panic(_L("CVedH263Dec - method not supported"), EInternalAssertionFailure);
       
   149     return KErrNotSupported;
       
   150 }
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CVedH263DecImp::DecodeFrameL
       
   154 // Decodes / Transcodes a compressed frame
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 
       
   158 void CVedH263DecImp::DecodeFrameL(const TPtrC8& aInputBuffer, TPtr8& aOutputBuffer,
       
   159                                   TBool& aFirstFrame, TInt& aBytesDecoded,
       
   160                                   vdeDecodeParamters_t *aDecoderInfo)
       
   161 {
       
   162         
       
   163     TInt error = KErrNone;
       
   164     
       
   165     TInt bytesProduced = 0;
       
   166 
       
   167     error = h263dDecodeFrameL(iH263dHandle, (TAny*)aInputBuffer.Ptr(), (TAny*)aOutputBuffer.Ptr(), 
       
   168                              aInputBuffer.Length(), (TUint8*)&aFirstFrame, &aBytesDecoded, 
       
   169                              &bytesProduced, aDecoderInfo);    
       
   170 
       
   171     aOutputBuffer.SetLength(bytesProduced);
       
   172     
       
   173     switch ( error )
       
   174         {
       
   175         case H263D_ERROR_NO_INTRA:
       
   176             {
       
   177             User::Leave( EDecoderNoIntra );
       
   178             }
       
   179             break;
       
   180         case H263D_OK_BUT_FRAME_USELESS:
       
   181         case H263D_OK_BUT_BIT_ERROR:
       
   182             {
       
   183             User::Leave( EDecoderCorrupted );
       
   184             }
       
   185             break;
       
   186         case H263D_OK:
       
   187         case H263D_OK_EOS:
       
   188         case H263D_OK_BUT_NOT_CODED:
       
   189             {
       
   190             // ok
       
   191             return;
       
   192             }
       
   193         default:
       
   194             {
       
   195             User::Leave(EDecoderFailure);
       
   196             }
       
   197             break;
       
   198 
       
   199         }
       
   200     
       
   201 }
       
   202 
       
   203 
       
   204 // -----------------------------------------------------------------------------
       
   205 // CVedH263DecImp::DecodeFrameL
       
   206 // Decodes / Transcodes a compressed frame
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 void CVedH263DecImp::DecodeFrameL(const TPtrC8& /*aInputBuffer*/, TPtr8& /*aOutputBuffer*/,
       
   210                                   TBool& /*aFirstFrame*/, TInt& /*aBytesDecoded*/, 
       
   211                                   const TColorEffect /*aColorEffect*/,
       
   212                                   const TBool /*aGetDecodedFrame*/, TInt /*aFrameOperation*/,
       
   213                                   TInt* /*aTrP*/, TInt* /*aTrD*/, TInt /*aVideoClipNumber*/, TInt /*aSMSpeed*/, 
       
   214                                   TInt /*aDataFormat*/)
       
   215 {
       
   216     // this method is not supported any more
       
   217     User::Panic(_L("CVedH263Dec - method not supported"), EInternalAssertionFailure);
       
   218 }
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // CVedH263DecImp::DecodeFrameL
       
   222 // Decodes a compressed frame
       
   223 // -----------------------------------------------------------------------------
       
   224 //      
       
   225 void CVedH263DecImp::DecodeFrameL(const TPtrC8& /*aInputBuffer*/, TBool& /*aFirstFrame*/, TInt& /*aBytesDecoded*/, 
       
   226                                                                     TInt /*aDataFormat*/)
       
   227 {    
       
   228     // this method is not supported any more
       
   229     User::Panic(_L("CVedH263Dec - method not supported"), EInternalAssertionFailure);
       
   230 }
       
   231 
       
   232 // -----------------------------------------------------------------------------
       
   233 // CVedH263DecImp::FrameValid
       
   234 // Checks if the given frame is valid
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 TBool CVedH263DecImp::FrameValid(const TAny */*aFrame*/)
       
   238 {
       
   239     return ETrue;
       
   240 
       
   241 }
       
   242 
       
   243 // -----------------------------------------------------------------------------
       
   244 // CVedH263DecImp::FrameRendered
       
   245 // Returns the given frame to the decoder after it is no longer needed
       
   246 // -----------------------------------------------------------------------------
       
   247 //
       
   248 void CVedH263DecImp::FrameRendered(const TAny */*aFrame*/)
       
   249 {
       
   250     // Return frame to the decoder rendering subsystem
       
   251 }
       
   252 
       
   253 // -----------------------------------------------------------------------------
       
   254 // CVedH263DecImp::CheckVOSHeaderL
       
   255 // Check and change the VOS header (resync marker bit needs to be set) 
       
   256 // -----------------------------------------------------------------------------
       
   257 //
       
   258 TBool CVedH263DecImp::CheckVOSHeaderL(TPtrC8& aInputBuffer)
       
   259 {
       
   260    return vdtChangeVosHeaderRegResyncL(aInputBuffer, aInputBuffer.Length());
       
   261 
       
   262 }
       
   263 
       
   264 
       
   265 
       
   266 
       
   267 
       
   268 // End of file
       
   269 
       
   270 
       
   271