videoeditorengine/h263decoder/src/h263dntc.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
* Video decoder control interface.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    17
*
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
 * Includes
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
/* Include the definition header for the active build target */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    27
#include "h263dConfig.h"
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    28
/* Include the header for this file */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    29
#include "h263dntc.h"
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    30
/* All other inclusions */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    31
#include "biblin.h"
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    32
#include "h263dapi.h"
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    33
#include "vde.h"
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    34
#include "vdemain.h"
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    35
#include "vdeti.h"
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    36
#include "biblin.h"
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    37
/* MVE */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    38
//#include "InnerTranscoder.h"
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    39
#include "core.h"
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    40
#include "MPEG4Transcoder.h"
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
 * Constants 
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
const TUint KH263StartCodeLength = 3;  // H.263 picture start code length
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    46
const TUint KMPEG4StartCodeLength = 4; // MPEG4 picture start code length
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    47
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
* Global functions
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    50
*/
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
/* {{-output"h263dClose.txt"}} */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    53
/*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    54
* h263dClose
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
* Parameters:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    58
*    hInstance                  instance handle
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
* Function:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    61
*    This function closes an H.263 decoder instance.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    62
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    63
* Returns:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    64
*    Nothing
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
void H263D_CC h263dClose(h263dHInstance_t hInstance)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    68
/* {{-output"h263dClose.txt"}} */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    69
{
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    70
    if (hInstance)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    71
        vdeShutDown(hInstance);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    72
}
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
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    75
/* {{-output"h263dDecodeFrame.txt"}} */
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
* h263dDecodeFrameL
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    78
*    
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
* Parameters:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    81
*    hInstance                  instance data
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    82
*    pStreamBuffer              pointer to input data (>= 1 video frames)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    83
*    streamBufferSize           size of pStreamBuffer
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    84
*    fFirstFrame                pointer to flag telling if the very first
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    85
*                               frame is being decoded
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    86
*    frameSize                  If non-NULL, frameSize is used to return 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    87
*                               the number of bytes that were decoded 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    88
*                               to produce the reconstructed output frame.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    89
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    90
* Function:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    91
*    This function decodes the bitstream until it gets at least one decoded
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    92
*    frame. It also shows the resulting frames. 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    93
*    In addition, the function handles the parameter updating synchronization.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    94
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    95
* Returns:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    96
*    H263D_OK                   if the function was successful
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    97
*    H263D_OK_EOS               if the end of stream has been reached
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    98
*    H263D_ERROR                if a fatal error, from which the decoder
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    99
*                               cannot be restored, has occured
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   100
*    H263D_ERROR_HALTED         the instance is halted, it should be closed
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   101
*/
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   102
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   103
int H263D_CC h263dDecodeFrameL(h263dHInstance_t hInstance,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   104
                               void *pStreamBuffer,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   105
                               void *pOutStreamBuffer,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   106
                               unsigned streamBufferSize,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   107
                               u_char *fFirstFrame,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   108
                               TInt *frameSize,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   109
                               TInt *outframeSize, 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   110
                               vdeDecodeParamters_t *aDecoderInfo
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   111
                               )
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
/* {{-output"h263dDecodeFrame.txt"}} */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   114
{
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   115
    TInt colorEffect = aDecoderInfo->aColorEffect;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   116
    TInt colorToneU  = aDecoderInfo->aColorToneU;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   117
    TInt colorToneV  = aDecoderInfo->aColorToneV;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   118
    TInt frameOperation = aDecoderInfo->aFrameOperation;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   119
    TInt* trP = aDecoderInfo->aTrP;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   120
    TInt* trD = aDecoderInfo->aTrD; 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   121
    TInt videoClipNumber = aDecoderInfo->aVideoClipNumber; 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   122
    TInt smSpeed = aDecoderInfo->aSMSpeed;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   123
    TInt getDecodedFrame = aDecoderInfo->aGetDecodedFrame; 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   124
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   125
    bibBuffer_t 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   126
        *buffer = 0;                   /* input buffer */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   127
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   128
    bibBuffer_t 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   129
        *outbuffer = 0;               /* output buffer */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   130
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   131
    bibBuffer_t 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   132
        *tmpbuffer = 0;                /* temporary buffer */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   133
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   134
    u_char* tmpbuf=0;
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
    bibBufferEdit_t
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   137
        *bufEdit = 0;
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
    int StartByteIndex=0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   140
    int StartBitIndex=7;
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
    int tr = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   143
    int newtr = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   144
    int efftr;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   145
    int numBitsGot;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   146
    int bitsErrorIndication;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   147
    int16 bibError;
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
    int retValue;                  /* return value for vde functions */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   150
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   151
    int leaveError = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   152
     
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   153
    int16
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   154
        errorCode = 0;             /* return code for bib functions */
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
  /* MVE */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   157
    int startCodeLen = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   158
    CMPEG4Transcoder *hTranscoder = NULL;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   159
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   160
    TBool modifyMPEG4Afterwards = EFalse;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   161
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   162
    vdeAssert(hInstance);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   163
    vdeAssert(pStreamBuffer);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   164
    vdeAssert(pOutStreamBuffer);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   165
    vdeAssert(streamBufferSize);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   166
    vdeAssert(fFirstFrame);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   167
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   168
    vdeInstance_t *vdeinstance = (vdeInstance_t *) hInstance;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   169
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   170
    /* Create bit buffer */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   171
    buffer = bibCreate(pStreamBuffer, streamBufferSize, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   172
     if (!buffer || errorCode)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   173
         return H263D_ERROR;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   174
     
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   175
     /* MVE */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   176
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   177
     if ((aDecoderInfo->streamMode==EVedVideoBitstreamModeMPEG4ShortHeader) || (aDecoderInfo->streamMode == EVedVideoBitstreamModeH263) )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   178
         outbuffer = bibCreate(pOutStreamBuffer, streamBufferSize-3, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   179
     else
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   180
         outbuffer = bibCreate(pOutStreamBuffer, streamBufferSize-4-3, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   181
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   182
     if (!outbuffer || errorCode)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   183
     {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   184
         bibDelete(buffer, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   185
         return H263D_ERROR;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   186
     }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   187
     
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   188
     bufEdit = bibBufferEditCreate(&errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   189
     if (!bufEdit || errorCode)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   190
     {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   191
         bibDelete(outbuffer, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   192
         bibDelete(buffer, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   193
         return H263D_ERROR;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   194
     }   
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   195
     
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   196
     if(frameOperation==4 /*ENoDecodeNoWrite*/)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   197
     {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   198
         bufEdit->copyMode = CopyNone;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   199
     }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   200
     
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   201
     if(colorEffect==1 || colorEffect==2)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   202
     {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   203
         outbuffer->numBytesRead=0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   204
         outbuffer->size=0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   205
     }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   206
     
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   207
   /* Associate bit buffer with the VDE instance */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   208
     retValue = vdeSetInputBuffer(hInstance, buffer);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   209
     if (retValue < 0)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   210
         goto freeBufferAndReturn;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   211
     
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   212
     /* Associate output bit buffer with the VDE instance */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   213
     retValue = vdeSetOutputBuffer(hInstance, outbuffer);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   214
     if (retValue < 0)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   215
         goto freeBufferAndReturn;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   216
     
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   217
     retValue = vdeSetBufferEdit(hInstance, bufEdit);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   218
     if (retValue < 0)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   219
         goto freeBufferAndReturn;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   220
     
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   221
     retValue = vdeSetVideoEditParams(hInstance, colorEffect,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   222
       getDecodedFrame, colorToneU, colorToneV);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   223
     if (retValue < 0)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   224
         goto freeBufferAndReturn;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   225
     
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   226
   /* MVE */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   227
     if (aDecoderInfo->streamMode == EVedVideoBitstreamModeH263 /*H.263*/)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   228
     {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   229
         /* read current TR */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   230
         bibForwardBits(22,buffer); // streamBufferSize is in bytes
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   231
         tr = bibGetBits(8,buffer,&numBitsGot, &bitsErrorIndication, &bibError);    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   232
         bibRewindBits(30,buffer,&bibError);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   233
     }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   234
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   235
  /* get first frame's QP */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   236
  if (!(*fFirstFrame))
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   237
  {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   238
    vdeinstance->iRefQp = aDecoderInfo->aFirstFrameQp;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   239
  }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   240
  vdeinstance->iColorEffect = aDecoderInfo->aColorEffect;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   241
  vdeinstance->iColorToneU = aDecoderInfo->aColorToneU;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   242
  vdeinstance->iColorToneV = aDecoderInfo->aColorToneV;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   243
  
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   244
  /* MVE */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   245
  /* one frame is ready, initialize the transcoder */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   246
    TRAP( leaveError, (hTranscoder = CMPEG4Transcoder::NewL(vdeinstance, vdeinstance->inBuffer, vdeinstance->outBuffer)) );
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   247
    if ( leaveError != 0 )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   248
    {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   249
        retValue = leaveError;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   250
        goto freeBufferAndReturn;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   251
    }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   252
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   253
    if (aDecoderInfo->aGetVideoMode)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   254
    {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   255
        /* we are to determine the bitstream mode */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   256
        aDecoderInfo->aOutputVideoFormat = EVedVideoTypeNoVideo;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   257
        int dummy1, dummy2; // position of the error resillence bit,not used here
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   258
        vdtGetVideoBitstreamInfo(buffer, aDecoderInfo, &dummy1, &dummy2);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   259
    }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   260
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   261
    /* set transcoding information */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   262
    retValue = hTranscoder->SetTranscoding(aDecoderInfo);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   263
    if ( retValue != TX_OK )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   264
    {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   265
        goto freeBufferAndReturn;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   266
    }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   267
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   268
    /* before the first frame is decoded, determine the stream type */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   269
    if (*fFirstFrame) {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   270
        retValue = vdeDetermineStreamType(hInstance, hTranscoder);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   271
        if (retValue < 0)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   272
            goto freeBufferAndReturn;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   273
        
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   274
    /* MVE */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   275
        /* for the first frame of the bitstream, we may need to construct a new VOS */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   276
        hTranscoder->ConstructVOSHeader(vdeinstance->fMPEG4, aDecoderInfo);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   277
        
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   278
        if (vdeinstance->fMPEG4 == 1 )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   279
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   280
            StartByteIndex = buffer->getIndex;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   281
            StartBitIndex  = buffer->bitIndex;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   282
            
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   283
            /* for MPEG4 (not including shortheader) stuffing bits are inserted at the end of the VOS
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   284
            but the index here indicates the position of the stuffing bits
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   285
            */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   286
            if (StartBitIndex != 7)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   287
            {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   288
                StartByteIndex += 1;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   289
                StartBitIndex = 7;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   290
            }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   291
            
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   292
            // update the output stream size by removing VOS size
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   293
            streamBufferSize -= StartByteIndex; 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   294
        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   295
        
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   296
        else if (aDecoderInfo->streamMode == EVedVideoBitstreamModeMPEG4ShortHeader)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   297
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   298
            if (aDecoderInfo->aOutputVideoFormat == EVedVideoTypeH263Profile0Level10 ||
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   299
                aDecoderInfo->aOutputVideoFormat == EVedVideoTypeH263Profile0Level45)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   300
            {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   301
                // we don't need the VOS header
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   302
                StartByteIndex = buffer->getIndex;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   303
                StartBitIndex  = buffer->bitIndex;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   304
                // update the output stream size by removing VOS size
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   305
                streamBufferSize -= StartByteIndex; 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   306
            }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   307
            else if (aDecoderInfo->aOutputVideoFormat == EVedVideoTypeMPEG4SimpleProfile &&
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   308
                aDecoderInfo->fModeChanged == EFalse)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   309
            {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   310
                // update the output stream size by removing VOS size
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   311
                // but we need the original MPEG4 shortheader VOS, which is not yet copied to the output buffer
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   312
                streamBufferSize -= buffer->getIndex;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   313
                
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   314
            }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   315
        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   316
        
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   317
    }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   318
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   319
    /* This may produce multiple output frames, and that is why it is commented
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   320
     out. However, it may be useful if the bitstream is corrupted and picture
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   321
     start codes are lost
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   322
     while (buffer->bitsLeft > 8) { */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   323
     /* Decode frame */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   324
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   325
  /* MVE */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   326
  /* The buffer size is changed in h263decoder.cpp
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   327
    In the old version, it is fixed to 3, which may be incorrect 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   328
    */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   329
    startCodeLen = (aDecoderInfo->streamMode == EVedVideoBitstreamModeH263)? KH263StartCodeLength : KMPEG4StartCodeLength;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   330
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   331
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   332
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   333
    if ( ((aDecoderInfo->aOutputVideoFormat == EVedVideoTypeMPEG4SimpleProfile) 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   334
            && !(aDecoderInfo->streamMode == EVedVideoBitstreamModeMPEG4ShortHeader))
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   335
        || ((aDecoderInfo->streamMode == EVedVideoBitstreamModeMPEG4ShortHeader) && aDecoderInfo->fModeChanged) )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   336
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   337
        modifyMPEG4Afterwards = ETrue;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   338
        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   339
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   340
    if (frameOperation==1/*EDecodeAndWrite*/ || frameOperation==2/*EDecodeNoWrite*/)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   341
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   342
        if ( vdeinstance->fMPEG4 == 1 )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   343
            {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   344
            buffer->size -= startCodeLen;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   345
            buffer->bitsLeft -= ( startCodeLen << 3 );
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   346
            }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   347
        retValue = vdeDecodeFrame(hInstance, StartByteIndex, StartBitIndex, hTranscoder);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   348
        if ( retValue < VDE_OK )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   349
            {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   350
            // negative means fatal error
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   351
            goto freeBufferAndReturn;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   352
            }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   353
         // get first frame QP for possible color toning
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   354
         if (*fFirstFrame)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   355
         {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   356
           aDecoderInfo->aFirstFrameQp = hTranscoder->GetRefQP();
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   357
        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   358
     }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   359
     else if (frameOperation==3/*EWriteNoDecode*/) 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   360
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   361
        /* first reset bit counter to beginning of buffer */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   362
        /* copy input frame as it is */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   363
        bibForwardBits((streamBufferSize-startCodeLen)<<3,buffer); // streamBufferSize is in bytes
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   364
         
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   365
        if (aDecoderInfo->streamMode == EVedVideoBitstreamModeMPEG4ShortHeader &&
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   366
            aDecoderInfo->aOutputVideoFormat == EVedVideoTypeMPEG4SimpleProfile &&
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   367
            !(aDecoderInfo->fModeChanged))
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   368
            {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   369
            bibRewindBits(32,buffer,&bibError);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   370
            }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   371
         
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   372
        /* reset buffer edit to CopyWhole mode */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   373
        bufEdit->copyMode = CopyWhole/*CopyWhole*/;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   374
         
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   375
        if ( vdeinstance->fMPEG4 == 1 )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   376
            {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   377
            if (*fFirstFrame)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   378
                {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   379
                buffer->getIndex = buffer->size - startCodeLen;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   380
                buffer->bitIndex = 7;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   381
                buffer->bitsLeft = 24;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   382
                buffer->numBytesRead = buffer->size - startCodeLen;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   383
                }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   384
             
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   385
            if ( buffer->numBytesRead > 4 )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   386
                {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   387
                buffer->numBytesRead -= 4;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   388
                buffer->getIndex = buffer->numBytesRead;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   389
                }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   390
            }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   391
         // Reassign pointers so that outbuffer actually has the pointer to (in)buffer's data, 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   392
         // if we have MPEG4 output (not short header) and we need to change e.g. timestamps
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   393
         // This eliminates 2 memory copies - otherwise we would copy from buffer to outbuffer to tmpbuffer to outbuffer; 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   394
         // the content is modified when copying from tmpbuffer to outbuffer. 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   395
         // tmpbuffer is needed since we can't modify the content directly in the outbuffer.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   396
         // Now we can copy directly from buffer to outbuffer.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   397
         // In this branch we don't call vdeDecodeFrame at all, but use either CopyEditVopL for MPEG-4 or
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   398
         // CopyStream for H.263
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   399
         if ( modifyMPEG4Afterwards )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   400
             {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   401
             tmpbuffer = buffer;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   402
             }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   403
         else
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   404
             {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   405
             /* copy from buffer to outbuffer. This simulates vdeDecodeFrame with EDecodeAndWrite */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   406
             CopyStream(buffer,outbuffer,bufEdit,StartByteIndex,StartBitIndex);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   407
             }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   408
         retValue=0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   409
     }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   410
     
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   411
     outbuffer->size = outbuffer->getIndex;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   412
     outbuffer->bitsLeft = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   413
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   414
     if ( !tmpbuffer )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   415
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   416
         /* if tr values are changes, need another buffer */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   417
         /* first create temp buffer in memory */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   418
         tmpbuf = (u_char*) malloc(outbuffer->size + 4);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   419
         if (tmpbuf == NULL) 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   420
         {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   421
             bibDelete(outbuffer, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   422
             bibDelete(buffer, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   423
             bibBufEditDelete(bufEdit, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   424
             return H263D_ERROR;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   425
         }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   426
         tmpbuffer = bibCreate((void*)tmpbuf, outbuffer->size + 4, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   427
         if (!tmpbuffer || errorCode)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   428
         {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   429
            free(tmpbuf);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   430
            bibDelete(outbuffer, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   431
            bibDelete(buffer, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   432
            bibBufEditDelete(bufEdit, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   433
            return H263D_ERROR;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   434
         }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   435
        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   436
     
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   437
   /* MVE */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   438
     if (aDecoderInfo->aOutputVideoFormat != EVedVideoTypeNoVideo)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   439
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   440
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   441
        if ( modifyMPEG4Afterwards )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   442
            {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   443
            if ( tmpbuffer != buffer )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   444
                {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   445
                // the bitstream was decoded too, need to copy it temporarily from outbuffer to tmpbuffer since it needs to be modified
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   446
                bibRewindBits(bibNumberOfFlushedBits(tmpbuffer),tmpbuffer,&bibError);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   447
                bibRewindBits(bibNumberOfFlushedBits(outbuffer),outbuffer,&bibError);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   448
                bibForwardBits(((outbuffer->size)<<3),outbuffer);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   449
                outbuffer->bitsLeft = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   450
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   451
                StartByteIndex = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   452
                StartBitIndex = 7;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   453
                
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   454
                CopyStream(outbuffer,tmpbuffer,bufEdit,StartByteIndex,StartBitIndex);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   455
                tmpbuffer->baseAddr[tmpbuffer->getIndex] = 0x0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   456
                tmpbuffer->baseAddr[tmpbuffer->getIndex+1] = 0x0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   457
                tmpbuffer->baseAddr[tmpbuffer->getIndex+2] = 0x01;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   458
                tmpbuffer->baseAddr[tmpbuffer->getIndex+3] = 0xb6;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   459
                }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   460
             else
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   461
                {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   462
                // the tmpbuffer was used as a shortcut to the buffer, no need to copy anything here. 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   463
                tmpbuffer->bitsLeft = 32;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   464
                // the following ones are probably not needed
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   465
                tmpbuffer->baseAddr[tmpbuffer->getIndex+4] = 0x0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   466
                tmpbuffer->baseAddr[tmpbuffer->getIndex+5] = 0x0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   467
                tmpbuffer->baseAddr[tmpbuffer->getIndex+6] = 0x01;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   468
                tmpbuffer->baseAddr[tmpbuffer->getIndex+7] = 0xb6;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   469
                }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   470
                
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   471
           
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   472
            bibForwardBits(32,tmpbuffer);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   473
            
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   474
            // Copy bitstream part-by-part, possibly modifying it, from tmp to output. 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   475
            // StartByteIndex may be > 0 if there is VOS header in tmpbuffer already. It is always byte-aligned so no need to have StartBitIndex
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   476
            TInt skip = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   477
            if ( StartByteIndex > 0 )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   478
                {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   479
                // startByteIndex refers to input buffer. 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   480
                // The skip however should refer to the output buffer. The output header size is in aDecoderInfo
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   481
                skip = aDecoderInfo->vosHeaderSize;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   482
                }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   483
            int retVal= CopyEditVop(hInstance, skip, tmpbuffer, aDecoderInfo);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   484
            if(retVal<0)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   485
                {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   486
                retValue = retVal;  //will be handled later
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   487
                }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   488
            }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   489
        else
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   490
            {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   491
            /* copy input frame while changing TR */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   492
            if((videoClipNumber>0) || (smSpeed!=1000))
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   493
                {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   494
                if ((frameOperation==1) || ((frameOperation==2) && !getDecodedFrame))
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   495
                    {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   496
                    /* if the output buffer will not be use, leave it as it is! */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   497
                    }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   498
                else
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   499
                    {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   500
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   501
                    /* get new TR */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   502
                    StartByteIndex = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   503
                    StartBitIndex = 7;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   504
                    outbuffer->bitsLeft = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   505
                    newtr = GetNewTrValue(tr, trP, trD, smSpeed);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   506
                    /* change TR value in output bitstream */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   507
                    /* prepare editing position */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   508
                    if (!bufEdit->editParams)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   509
                        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   510
                        bufEdit->editParams = (bibEditParams_t *) malloc(sizeof(bibEditParams_t));
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   511
                        if (bufEdit->editParams == NULL)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   512
                            {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   513
                            retValue = H263D_ERROR;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   514
                            goto freeBufferAndReturn;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   515
                            }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   516
                        
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   517
                        bufEdit->numChanges=1;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   518
                        bufEdit->copyMode = CopyWithEdit; // CopyWithEdit
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   519
                        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   520
                    bufEdit->editParams->curNumBits = bufEdit->editParams->newNumBits = 8; 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   521
                    bufEdit->editParams->StartByteIndex=2; //2;     // starting position for the TR marker 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   522
                    bufEdit->editParams->StartBitIndex=1; //1;          // starting position for the TR marker 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   523
                    bufEdit->editParams->newValue=newtr; 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   524
                    /* copy the input buffer to the output buffer with TR changes */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   525
                    CopyStream(outbuffer,tmpbuffer,bufEdit,StartByteIndex,StartBitIndex);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   526
                    bibRewindBits((streamBufferSize)<<3,buffer,&bibError);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   527
                    /* copy the changed bitstream from tmpbuffer back to buffer */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   528
                    bufEdit->copyMode = CopyWhole; // CopyWhole
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   529
                    bibRewindBits(bibNumberOfFlushedBits(outbuffer),outbuffer,&bibError);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   530
                    CopyStream(tmpbuffer,outbuffer,bufEdit,StartByteIndex,StartBitIndex);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   531
                    bibRewindBits((streamBufferSize)<<3,buffer,&bibError);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   532
                    }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   533
                }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   534
            /* update TR values */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   535
            efftr = (videoClipNumber>0 || smSpeed!=1000) ? newtr : tr; 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   536
            *trP = efftr;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   537
            *trD = tr; 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   538
        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   539
    }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   540
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   541
    *fFirstFrame = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   542
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   543
    if (retValue < 0)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   544
        goto freeBufferAndReturn;   
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   545
        /* See the comment above.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   546
        else if (retValue == H263D_OK_EOS)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   547
        break;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   548
   } */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   549
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   550
    if (frameSize)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   551
        *frameSize = bibNumberOfFlushedBytes(buffer) + 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   552
        ((bibNumberOfFlushedBits(buffer) % 8 > 0) ? 1 : 0);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   553
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   554
    *outframeSize = outbuffer->numBytesRead; 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   555
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   556
        
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   557
freeBufferAndReturn:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   558
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   559
    int bitError = buffer->error;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   560
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   561
    if (hTranscoder)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   562
    {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   563
        delete hTranscoder;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   564
        hTranscoder = NULL;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   565
    }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   566
     
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   567
    if ( tmpbuffer == buffer )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   568
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   569
        // tmpbuffer was a shortcut to inbuffer, set it to NULL to avoid deleting it
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   570
        tmpbuffer = NULL;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   571
        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   572
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   573
    int16 deleteError = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   574
    /* Delete bit buffer */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   575
    bibDelete(buffer, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   576
    if ( errorCode )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   577
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   578
        deleteError = errorCode;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   579
        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   580
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   581
    /* Delete output bit buffer */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   582
    bibDelete(outbuffer, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   583
    if ( errorCode )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   584
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   585
        deleteError = errorCode;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   586
        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   587
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   588
    /* Delete tmp bit buffer, if it was used */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   589
    if ( tmpbuffer )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   590
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   591
        bibDelete(tmpbuffer, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   592
        if ( errorCode )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   593
            {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   594
            deleteError = errorCode;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   595
            }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   596
        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   597
    if(tmpbuf)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   598
        free(tmpbuf);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   599
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   600
    /* Delete bufEdit */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   601
    bibBufEditDelete(bufEdit, &errorCode);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   602
    if ( errorCode )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   603
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   604
        deleteError = errorCode;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   605
        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   606
    if (deleteError || errorCode)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   607
        return H263D_ERROR;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   608
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   609
    if ( bitError )
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   610
        {
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   611
        return H263D_OK_BUT_FRAME_USELESS;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   612
        }
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   613
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   614
    return retValue;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   615
}
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   616
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   617
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   618
/* {{-output"h263dGetLatestFrame.txt"}} */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   619
/*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   620
* h263dGetLatestFrame
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   621
*    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   622
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   623
* Parameters:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   624
*    hInstance                  instance data
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   625
*    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   626
*    ppy, ppu, ppv              used to return Y, U and V frame pointers
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   627
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   628
*    pLumWidth, pLumHeight      used to return luminance image width and height
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   629
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   630
*    pFrameNum                  used to return frame number
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   631
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   632
* Function:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   633
*    This function returns the latest correctly decoded frame
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   634
*    (and some side-information).
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   635
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   636
* Returns:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   637
*    H263D_OK                   if the function was successful
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   638
*    H263D_ERROR                if a fatal error, from which the decoder
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   639
*                               cannot be restored, has occured
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   640
*    H263D_ERROR_HALTED         the instance is halted, it should be closed
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   641
*/
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   642
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   643
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   644
int H263D_CC h263dGetLatestFrame(
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   645
                                                                 h263dHInstance_t hInstance,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   646
                                                                 u_char **ppy, u_char **ppu, u_char **ppv,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   647
                                                                 int *pLumWidth, int *pLumHeight,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   648
                                                                 int *pFrameNum)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   649
                                                                 /* {{-output"h263dGetLatestFrame.txt"}} */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   650
{
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   651
    vdeAssert(hInstance);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   652
    vdeAssert(ppy);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   653
    vdeAssert(ppu);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   654
    vdeAssert(ppv);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   655
    vdeAssert(pLumWidth);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   656
    vdeAssert(pLumHeight);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   657
    vdeAssert(pFrameNum);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   658
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   659
    return vdeGetLatestFrame(hInstance, ppy, ppu, ppv, pLumWidth, pLumHeight,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   660
        pFrameNum);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   661
}
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   662
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   663
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   664
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   665
/* {{-output"h263dIsIntra.txt"}} */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   666
/*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   667
* h263dIsIntra
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   668
*    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   669
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   670
* Parameters:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   671
*    hInstance                  handle of instance data
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   672
*    frameStart                 pointer to memory chunk containing a frame
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   673
*    frameLength                number of bytes in frame
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   674
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   675
* Function:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   676
*    This function returns 1 if the passed frame is an INTRA frame.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   677
*    Otherwise the function returns 0.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   678
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   679
* Returns:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   680
*    See above.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   681
*/
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   682
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   683
int h263dIsIntra(
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   684
                                 h263dHInstance_t hInstance,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   685
                                 void *frameStart,
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   686
                                 unsigned frameLength)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   687
                                 /* {{-output"h263dIsIntra.txt"}} */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   688
{
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   689
    vdeAssert(hInstance);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   690
    vdeAssert(frameStart);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   691
    vdeAssert(frameLength);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   692
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   693
    return vdeIsINTRA(hInstance, frameStart, frameLength);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   694
}
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   695
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   696
/* {{-output"h263dOpen.txt"}} */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   697
/*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   698
* h263dOpen
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   699
*    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   700
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   701
* Parameters:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   702
*    openParam                  initialization parameters
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   703
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   704
* Function:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   705
*    This function creates and initializes a new H.263 decoder instance.
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   706
*
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   707
* Returns:
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   708
*    an instance handle if the function was successful
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   709
*    NULL if an error occured
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   710
*/
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   711
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   712
h263dHInstance_t H263D_CC h263dOpen(h263dOpen_t *openParam)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   713
/* {{-output"h263dOpen.txt"}} */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   714
{
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   715
    vdeAssert(openParam);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   716
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   717
    /* No extra space needs to be allocated after the VDE instance data
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   718
    (of type vdeInstance_t) due to the fact that no thread specific
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   719
    data is needed. */
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   720
    openParam->freeSpace = 0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   721
    
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   722
    return vdeInit(openParam);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   723
}
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   724
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   725
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   726
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   727
int GetNewTrValue(int aTrCurOrig, int* aTrPrevNew, int* aTrPrevOrig, int aSMSpeed)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   728
{
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   729
    int trCurNew=0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   730
    int trDiff=0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   731
    TReal speedFactor = (TReal)aSMSpeed/1000.0;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   732
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   733
    trDiff = aTrCurOrig - *aTrPrevOrig;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   734
    if(trDiff==0)  // if corrupt TR values
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   735
        trDiff=1;  
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   736
    else if(trDiff<0)  // jump in TR values (change of clip or end of limit)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   737
        trDiff = 3;    // arbitrary, for 10 fps default
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   738
    // check for slow motion 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   739
    vdeAssert(aSMSpeed);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   740
    if(aSMSpeed!=1000)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   741
        trDiff = (int)((TReal)trDiff/speedFactor + 0.5);
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   742
    trCurNew = *aTrPrevNew + trDiff; 
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   743
    if(trCurNew>255)
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   744
        trCurNew = trCurNew%256;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   745
    return trCurNew;
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   746
}
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   747
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   748
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   749
951a5db380a0 Committing the Video Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   750
// End of File