videoeditorengine/h263decoder/inc/vdc263.h
branchRCL_3
changeset 3 e0b5df5c0969
parent 0 951a5db380a0
child 5 4c409de21d23
equal deleted inserted replaced
0:951a5db380a0 3:e0b5df5c0969
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 * An application programming interface for core functions of
       
    17 * video decoder.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef _VDC263_H_
       
    23 #define _VDC263_H_
       
    24 
       
    25 
       
    26 /*
       
    27  * Includes
       
    28  */ 
       
    29 
       
    30 
       
    31 #include "biblin.h"
       
    32 #include "vdeims.h"
       
    33 
       
    34 
       
    35 /*
       
    36  * Defines
       
    37  */
       
    38 
       
    39 /* Return values */
       
    40 // unify error codes
       
    41 #define VDC_OK_BUT_NOT_CODED H263D_OK_BUT_NOT_CODED 
       
    42                                     /* not coded frame, 
       
    43                                        copied to output as is, 
       
    44                                        no decoded output generated */  
       
    45 #define VDC_OK_BUT_FRAME_USELESS H263D_OK_BUT_FRAME_USELESS  
       
    46                                     /* Decoder behaved normally the decoded
       
    47                                        frame(s) should not be displayed since
       
    48                                        it is too heavily corrupted. */
       
    49 
       
    50 #define VDC_OK_BUT_BIT_ERROR H263D_OK_BUT_BIT_ERROR  
       
    51                                     /* The decoded frame(s) are degraded due
       
    52                                        to transmission errors but can be
       
    53                                        displayed due to successful error
       
    54                                        concealment. */
       
    55 
       
    56 #define VDC_OK            H263D_OK  /* Everything ok. */
       
    57 
       
    58 #define VDC_ERR         H263D_ERROR /* An unexpected processing error 
       
    59                                        occured. */
       
    60 #define VDC_ERR_NO_INTRA H263D_ERROR_NO_INTRA /* No INTRA frame has been decoded
       
    61                                        and the current frame is INTER  */
       
    62 
       
    63 /* vdcPictureHeader_t and vdxSEI_t related definitions */
       
    64 #define VDX_MAX_BYTES_IN_PIC_HEADER 44
       
    65                                     /* Maximum number of bytes allowed in
       
    66                                        SEI picture header repetition.
       
    67 
       
    68                                        Picture headers not including
       
    69                                        BCM (Annex N video-mux back-channel),
       
    70                                        RPRP (Annex P warping parameters), and
       
    71                                        Annex U 
       
    72                                        allocate 152 bits = 19 bytes in 
       
    73                                        the worst case.
       
    74                                        Our decoder does not support the features
       
    75                                        mentioned above. However, to ensure
       
    76                                        that introduction of any of the mentioned
       
    77                                        tools would not break this mechanism,
       
    78                                        a relatively large buffer is allocated
       
    79                                        for picture header copies. Note that
       
    80                                        Annex U does not have an upper limit
       
    81                                        for picture header lengths. */
       
    82 
       
    83 
       
    84 /*
       
    85  * Structs and typedefs
       
    86  */
       
    87 
       
    88 /* {{-output"vdcHInstance_t_info.txt" -ignore"*" -noCR}}
       
    89    vdcHInstance_t is used as a unique identifier of a VDC instance.
       
    90    The type can be casted to u_int32 or void pointer and then back to
       
    91    vdcHInstance_t without any problems.
       
    92    {{-output"vdcHInstance_t_info.txt"}} */
       
    93 
       
    94 /* {{-output"vdcHInstance_t.txt"}} */
       
    95 typedef void * vdcHInstance_t;
       
    96 /* {{-output"vdcHInstance_t.txt"}} */
       
    97 
       
    98 
       
    99 /* The following vdx data types are defined here, because VDC exports
       
   100    these structures (see vdcDecodePictureHeader). */
       
   101 
       
   102 /*
       
   103  * vdxPictureHeader_t
       
   104  */
       
   105 
       
   106 /* {{-output"vdxPictureHeader_t_info.txt" -ignore"*" -noCR}}
       
   107    The vdxGetPictureHeader function uses this structure to return the picture
       
   108    header parameters.
       
   109    {{-output"vdxPictureHeader_t_info.txt"}} */
       
   110 
       
   111 /* {{-output"vdxPictureHeader_t.txt"}} */
       
   112 typedef struct {
       
   113    /* The following fields are always set */
       
   114       int numBits;               /* number of bits in the picture header,
       
   115                                     including PSC, excluding PSTUFF, PSUPP and
       
   116                                     PEI */
       
   117 
       
   118       int tr;                    /* the TR field or a combination of ETR and TR
       
   119                                     if ETR is used */
       
   120 
       
   121       int fSplitScreen;
       
   122       int fDocumentCamera;
       
   123       int fFreezePictureRelease;
       
   124 
       
   125       int pictureType;           /* Picture type is one of the following:
       
   126                                        VDX_PIC_TYPE_I       INTRA
       
   127                                        VDX_PIC_TYPE_P       INTER
       
   128                                        VDX_PIC_TYPE_PB      PB (Annex G)
       
   129                                        VDX_PIC_TYPE_IPB     Improved PB
       
   130                                        VDX_PIC_TYPE_B       B (Annex O)
       
   131                                        VDX_PIC_TYPE_EI      EI (Annex O)
       
   132                                        VDX_PIC_TYPE_EP      EP (Annex O) */
       
   133 
       
   134       int fPLUSPTYPE;            /* 0 = no PLUSPTYPE, 1 = PLUSPTYPE exists */
       
   135 
       
   136       int cpm;                   /* The CPM field */
       
   137       int psbi;                  /* The PSBI field, valid only if cpm == 1 */
       
   138 
       
   139       int pquant;                /* The PQUANT field */
       
   140       int pquantPosition;        /* Number of bits preceding the PQUANT field,
       
   141                                     including PSC, excluding PSTUFF */
       
   142 
       
   143    /* The following fields are set 
       
   144       if pictureType == VDX_PIC_TYPE_PB || pictureType == VDX_PIC_TYPE_IPB */
       
   145       int trb;                   /* The TRB field */
       
   146       int dbquant;               /* The DBQUANT field */
       
   147 
       
   148    /* The following fields are set if fPLUSPTYPE == 0 || ufep == 1 */
       
   149       int lumWidth;              /* the width and height of the luminance */
       
   150       int lumHeight;             /* image */
       
   151 
       
   152       int fUMV;                  /* Unrestricted Motion Vector Mode */
       
   153       int fSAC;                  /* Syntax-based Arithmetic Coding Mode */
       
   154       int fAP;                   /* Advanced Prediction Mode */
       
   155 
       
   156    /* The following fields are set if fPLUSPTYPE == 1 */
       
   157       int ufep;                  /* The UFEP field */
       
   158 
       
   159       int fRPR;                  /* Reference Picture Resampling Mode */
       
   160       int fRRU;                  /* Reduced-Resolution Update Mode */
       
   161       int rtype;                 /* Rounding type (RTYPE) */
       
   162 
       
   163 
       
   164       /* If Annex O is in use */
       
   165          int elnum;              /* Enhancement layer number */
       
   166 
       
   167       /* If the Reference Picture Selection mode is in use */
       
   168          int trpi;               /* 1 = trp is valid */
       
   169          int trp;                /* Temporal reference for prediction */
       
   170 
       
   171       /* The following fields are set if ufep == 1 */
       
   172          int fCustomSourceFormat;
       
   173    
       
   174          int fAIC;               /* Advanced INTRA Coding Mode */
       
   175          int fDF;                /* Deblocking Filter Mode */
       
   176          int fSS;                /* Slice Structured Mode */
       
   177          int fRPS;               /* Reference Picture Selection Mode */
       
   178          int fISD;               /* Independent Segment Decoding Mode */
       
   179          int fAIV;               /* Alternate INTER VLC Mode */
       
   180          int fMQ;                /* Modified Quantization Mode */
       
   181 
       
   182          int parWidth;           /* Pixel aspect ratio = parWidth : parHeight */
       
   183          int parHeight;
       
   184 
       
   185                                  /* Picture Clock Frequence (PCF) fields */
       
   186          int fCustomPCF;         /* 0 = CIF PCF, 1 = custom PCF */
       
   187          int pcfRate;            /* PCF = pcfRate / pcfScale Hz */
       
   188          int pcfScale;
       
   189 
       
   190          /* If fUMV == 1 */
       
   191             int fUMVLimited;     /* 0 = motion vector range is not limited,
       
   192                                     1 = motion vector range is limited
       
   193                                         according to Annex D */
       
   194 
       
   195          /* If fSS == 1 */
       
   196             int fRectangularSlices;  
       
   197                                  /* 0 = free-running slices, 
       
   198                                     1 = rectangular slices */
       
   199 
       
   200             int fArbitrarySliceOrdering;
       
   201                                  /* 0 = sequential order */
       
   202                                  /* 1 = arbitrary order */
       
   203 
       
   204          /* If Annex O is in use */                                 
       
   205             int rlnum;           /* Reference layer number */
       
   206 
       
   207 
       
   208          /* If fRPS == 1 */
       
   209             int rpsMode;         /* Reference Picture Selection Mode:
       
   210                                        VDX_RPS_MODE_NO_MSGS
       
   211                                        VDX_RPS_MODE_ACK
       
   212                                        VDX_RPS_MODE_NACK
       
   213                                        VDX_RPS_MODE_BOTH_MSGS */
       
   214 } vdxPictureHeader_t;
       
   215 /* {{-output"vdxPictureHeader_t.txt"}} */
       
   216 
       
   217 
       
   218 /*
       
   219  * vdxSEI_t
       
   220  */
       
   221 
       
   222 /* {{-output"vdxSEI_t_info.txt" -ignore"*" -noCR}}
       
   223    This structure is used to return parameters parsed from Supplemental
       
   224    Enhancement Information.
       
   225    {{-output"vdxSEI_t_info.txt"}} */
       
   226 
       
   227 /* {{-output"vdxSEI_t.txt"}} */
       
   228 typedef struct {
       
   229    int fFullPictureFreezeRequest;   /* 1 = Full-picture freeze requested as in
       
   230                                        section L.4 of H.263, 0 otherwise */
       
   231 
       
   232    int fFullPictureSnapshot;        /* 1 = Full-picture snapshot tag as in
       
   233                                         section L.8 of H.263, 0 otherwise */
       
   234 
       
   235    u_int32 snapshotId;              /* Snapshot identification number */
       
   236    
       
   237    u_int8 snapshotStatus;           /* Snapshot transmission status */
       
   238 
       
   239    int scalabilityLayer;            /* Annex N scalability layer for 
       
   240                                        the picture, -1 if not defined */
       
   241 
       
   242    int numScalabilityLayers;        /* Number of Annex N scalability layers,
       
   243                                        value from 2 to 15, 
       
   244                                        0 if no scalability layers in use. */
       
   245 
       
   246    u_char prevPicHeader[VDX_MAX_BYTES_IN_PIC_HEADER];
       
   247                                     /* Previous picture header repetition
       
   248                                        in bit-stream syntax including
       
   249                                        the first two bytes of PSC */
       
   250 
       
   251    int numBytesInPrevPicHeader;     /* Number of bytes valid in prevPicHeader,
       
   252                                        including the first two bytes of PSC
       
   253                                        and the last byte of picture header
       
   254                                        where the LSB bits are possibly not
       
   255                                        belonging to the picture header copy */
       
   256 
       
   257    int numBitsInLastByteOfPrevPicHeader;
       
   258                                     /* Number of valid bits in the last byte
       
   259                                        of prevPicHeader (1..8) */
       
   260 
       
   261    int fPrevPicHeaderTooLarge;      /* 1 if the previous picture header copy 
       
   262                                        did not fit into prevPicHeader,
       
   263                                        0 otherwise */
       
   264 } vdxSEI_t;
       
   265 /* {{-output"vdxSEI_t.txt"}} */
       
   266 
       
   267 
       
   268 /*
       
   269  * Function prototypes, core.c
       
   270  */
       
   271 
       
   272 int vdcClose(vdcHInstance_t hInstance);
       
   273 
       
   274 class CMPEG4Transcoder;
       
   275 int vdcDecodeFrame(vdcHInstance_t hInstance, bibBuffer_t *inBuffer, bibBuffer_t *outBuffer,
       
   276 									 bibBufferEdit_t *bufEdit, int aColorEffect, TBool aGetDecodedFrame,
       
   277 									 CMPEG4Transcoder *hTranscoder);
       
   278 
       
   279 
       
   280 int vdcDecodePictureHeader(
       
   281    vdcHInstance_t hInstance,
       
   282    bibBuffer_t *inBuffer,
       
   283    vdxPictureHeader_t *header,
       
   284    vdxSEI_t *sei);
       
   285 
       
   286 int vdcFree(void);
       
   287 
       
   288 vdeImsItem_t *vdcGetImsItem(vdcHInstance_t hInstance, int index);
       
   289 
       
   290 int vdcGetNumberOfAnnexNScalabilityLayers(
       
   291    vdcHInstance_t hInstance);
       
   292 
       
   293 int vdcGetNumberOfOutputFrames(vdcHInstance_t hInstance);
       
   294 
       
   295 void vdcGetTR(void *inpBuffer, u_int8 *tr);
       
   296 
       
   297 int vdcIsEOSReached(vdcHInstance_t hInstance);
       
   298 
       
   299 int vdcIsINTRA(
       
   300    vdcHInstance_t hInstance,
       
   301    void *frameStart,
       
   302    unsigned frameLength);
       
   303 
       
   304 int vdcIsINTRAGot(vdcHInstance_t hInstance);
       
   305 
       
   306 int vdcIsPB(
       
   307    vdcHInstance_t hInstance,
       
   308    void *frameStart,
       
   309    unsigned frameLength);
       
   310 
       
   311 int vdcLoad(void);
       
   312 
       
   313 vdcHInstance_t vdcOpen(
       
   314    vdeIms_t *imageStore, 
       
   315    int numReferenceFrames,
       
   316    void *hParent);
       
   317 
       
   318 void vdcRestartVideo(vdcHInstance_t hInstance);
       
   319 
       
   320 int vdcSetBackChannelUsage(vdcHInstance_t hInstance, int fSendMessages);
       
   321 
       
   322 int vdcSetErrorResilience(vdcHInstance_t hInstance, int feature, int value);
       
   323 
       
   324 int vdcSetStartOrEndSnapshotCallback(
       
   325    vdcHInstance_t hInstance, 
       
   326    u_int32 mode,
       
   327    u_int32 callback);
       
   328 
       
   329 int vdcGetSnapshotStatus(vdcHInstance_t hInstance);
       
   330 
       
   331 int vdcSetReportPictureSizeCallback(
       
   332    vdcHInstance_t hInstance, 
       
   333    u_int32 callback);
       
   334 
       
   335 /*
       
   336  * Function prototypes, core_mpeg.c
       
   337  */
       
   338 
       
   339    int vdcDecodeMPEGVolHeader(vdcHInstance_t hInstance, bibBuffer_t *inBuffer, CMPEG4Transcoder *hTranscoder);
       
   340 
       
   341    int vdcDecodeMPEGVop(vdcHInstance_t hInstance, bibBuffer_t *inBuffer, bibBuffer_t *outBuffer,
       
   342                         bibBufferEdit_t *bufEdit, int aColorEffect, TBool aGetDecodedFrame, 
       
   343 						int aStartByteIndex, int aStartBitIndex, CMPEG4Transcoder *hTranscoder);
       
   344 
       
   345    int vdcIsMPEGINTRA(
       
   346       vdcHInstance_t hInstance,
       
   347       void *frameStart,
       
   348       unsigned frameLength);
       
   349 
       
   350 #endif
       
   351 // End of File