Home | History | Annotate | Download | only in inc
      1 
      2 /*
      3  * Copyright (C) Texas Instruments - http://www.ti.com/
      4  *
      5  * This library is free software; you can redistribute it and/or
      6  * modify it under the terms of the GNU Lesser General Public
      7  * License as published by the Free Software Foundation; either
      8  * version 2.1 of the License, or (at your option) any later version.
      9  *
     10  *
     11  * This library is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14  * Lesser General Public License for more details.
     15  *
     16  *
     17  * You should have received a copy of the GNU Lesser General Public
     18  * License along with this library; if not, write to the Free Software
     19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
     20  */
     21 /* =============================================================================
     22 *             Texas Instruments OMAP(TM) Platform Software
     23 *  (c) Copyright Texas Instruments, Incorporated.  All Rights Reserved.
     24 *
     25 *  Use of this software is controlled by the terms and conditions found
     26 *  in the license agreement under which this software has been supplied.
     27 * =========================================================================== */
     28 /**
     29 * @file OMX_VideoEnc_DSP.h
     30 *
     31 * This is a header file for a TI OMX video component that is fully
     32 * compliant with the OMX Video specification.
     33 * This the file that the application that uses OMX would include
     34 * in its code.
     35 *
     36 * @path $(CSLPATH)\
     37 *
     38 * @rev 0.1
     39 */
     40 /* -------------------------------------------------------------------------- */
     41 
     42 #ifndef OMX_VIDEOENC_DSP__H
     43 #define OMX_VIDEOENC_DSP__H
     44 
     45 #define OMX_H264ENC_NUM_DLLS 3
     46 #define OMX_MP4ENC_NUM_DLLS  3
     47 #define MAXNUMSLCGPS      8  /*< max. number of slice groups*/
     48 
     49 #ifndef UNDER_CE
     50     #define H264_ENC_NODE_DLL "h264venc_sn.dll64P"
     51     #define MP4_ENC_NODE_DLL  "m4venc_sn.dll64P"
     52     #define USN_DLL           "usn.dll64P"
     53 #else
     54     #define H264_ENC_NODE_DLL "/windows/h264venc_sn.dll64P"
     55     #define MP4_ENC_NODE_DLL  "/windows/m4venc_sn.dll64P"
     56     #define USN_DLL           "/windows/usn.dll64P"
     57 #endif
     58 
     59 typedef enum {
     60     USN_ERR_NONE,
     61     USN_ERR_WARNING,
     62     USN_ERR_PROCESS,
     63     USN_ERR_PAUSE,
     64     USN_ERR_STOP,
     65     USN_ERR_ALGCTRL,
     66     USN_ERR_STRMCTRL,
     67     USN_ERR_UNKNOWN_MSG
     68 } USN_ErrTypes;
     69 
     70 typedef enum {
     71     USN_STRMCMD_PLAY,
     72     USN_STRMCMD_PAUSE,
     73     USN_STRMCMD_STOP,
     74     USN_STRMCMD_SETCODECPARAMS,
     75     USN_STRMCMD_IDLE,
     76     USN_STRMCMD_FLUSH
     77 }USN_StrmCmd;
     78 
     79 typedef enum
     80 {
     81   IH264_BYTE_STREAM = 0,
     82   IH264_NALU_STREAM
     83 
     84 }IH264VENC_StreamFormat;
     85 
     86 /*H264 Encoder Specific Error Code bits*/
     87 typedef enum
     88 {
     89   IH264VENC_SEQPARAMERR=0,          /* Indicates error during sequence parameter set generation*/
     90   IH264VENC_PICPARAMERR,            /* Indicates error during picture parameter set generation*/
     91   IH264VENC_COMPRESSEDSIZEOVERFLOW, /* Compressed data exceeds the maximum compressed size limit*/
     92   IH264VENC_INVALIDQPPARAMETER,     /* Out of Range initial Quantization parameter*/
     93   IH264VENC_INVALIDPROFILELEVEL,    /* Invalid profile or Level*/
     94   IH264VENC_INVALIDRCALGO,          /* Invalid RateControl Algorithm*/
     95   IH264VENC_SLICEEXCEEDSMAXBYTES,   /* Slice exceeds the maximum allowed bytes*/
     96   IH264VENC_DEVICENOTREADY          /* Indicates the device is not ready*/
     97 
     98 
     99 } IH264VENC_ErrorBit;
    100 
    101 /* H.264 Encoder Slice and Picture level Loop Filter Control*/
    102 typedef enum
    103 {
    104   FILTER_ALL_EDGES = 0,             /* Enable filtering of all the edges*/
    105   DISABLE_FILTER_ALL_EDGES,         /* Disable filtering of all the edges*/
    106   DISABLE_FILTER_SLICE_EDGES        /* Disable filtering of slice edges */
    107 
    108 } IH264VENC_LoopFilterParams ;
    109 
    110 
    111 /* H.264 Encoder Slice level Control for Intra4x4 Modes */
    112 typedef enum
    113 {
    114   INTRA4x4_NONE = 0 ,   /* Disable Intra4x4 modes */
    115   INTRA4x4_ISLICES  ,   /* Enable Intra4x4 modes only in I Slices*/
    116   INTRA4x4_IPSLICES     /* Enable Intra4x4 modes only in I and P Slices*/
    117 
    118 } IH264VENC_Intra4x4Params ;
    119 
    120 /* Level Identifier for H.264 Encoder*/
    121 typedef enum
    122 {
    123   IH264_LEVEL_10 = 10,  /* Level 1.0*/
    124   IH264_LEVEL_1b =  9,  /* Level 1.b*/
    125   IH264_LEVEL_11 = 11,  /* Level 1.1*/
    126   IH264_LEVEL_12 = 12,  /* Level 1.2*/
    127   IH264_LEVEL_13 = 13,  /* Level 1.3*/
    128   IH264_LEVEL_20 = 20,  /* Level 2.0*/
    129   IH264_LEVEL_21 = 21,  /* Level 2.1*/
    130   IH264_LEVEL_22 = 22,  /* Level 2.2*/
    131   IH264_LEVEL_30 = 30   /* Level 3.0*/
    132 
    133 } IH264VENC_Level ;
    134 
    135 
    136 /* Picture Order Count Type Identifier for H.264 Encoder*/
    137 typedef enum
    138 {
    139   IH264_POC_TYPE_0 = 0,  /* POC type 0*/
    140   IH264_POC_TYPE_2 = 2   /* POC type 2*/
    141 
    142 } IH264VENC_PicOrderCountType ;
    143 
    144 /* Picture Order Count Type Identifier for H.264 Encoder*/
    145 typedef enum
    146 {
    147   IH264_INTRAREFRESH_NONE       = 0 ,  /* Doesn't insert forcefully intra macro blocks*/
    148   IH264_INTRAREFRESH_CYCLIC_MBS     ,  /* Insters intra macro blocks in a cyclic fashion :*/
    149                                        /* cyclic interval is equal to airMbPeriod*/
    150   IH264_INTRAREFRESH_CYCLIC_SLICES  ,  /* Insters Intra Slices in a cyclic fashion: */
    151                                        /* no of intra slices is equal to sliceRefreshRowNumber*/
    152   IH264_INTRAREFRESH_RDOPT_MBS         /* position of intra macro blocks is intelligently */
    153                                        /* chosen by encoder, but the number of forcely coded*/
    154                                        /* intra macro blocks in a frame is gaurnteed to be */
    155                                        /* equal to totalMbsInFrame/airMbPeriod : Not valid for DM6446*/
    156 
    157 } IH264VENC_IntraRefreshMethods ;
    158 
    159 typedef enum
    160 {
    161   IH264_INTERLEAVED_SLICE_GRP             = 0 , /* 0 : Interleaved Slices*/
    162   IH264_FOREGRND_WITH_LEFTOVER_SLICE_GRP  = 2 , /* 2 : ForeGround with Left Over*/
    163   IH264_RASTER_SCAN_SLICE_GRP             = 4   /* 4 : Raster Scan*/
    164 
    165 } IH264VENC_SliceGroupMapType ;
    166 
    167 typedef enum
    168 {
    169   IH264_RASTER_SCAN             = 0 , /* 0 : Raster scan order*/
    170   IH264_REVERSE_RASTER_SCAN           /* 1 : Reverse Raster Scan Order*/
    171 
    172 } IH264VENC_SliceGroupChangeDirection ;
    173 
    174 /* H264 Encoder DSP s/n create phase arguments */
    175 typedef struct H264VE_GPP_SN_Obj_CreatePhase {
    176     unsigned short usNumStreams;
    177     unsigned short usStreamId;
    178     unsigned short usBuffTypeInStream;
    179     unsigned short usMaxBuffsInStream;
    180     unsigned short usStreamId2;
    181     unsigned short usBuffTypeInStream2;
    182     unsigned short usMaxBuffsInStream2;
    183 
    184     unsigned short usReserved1;
    185 
    186     unsigned int   ulWidth;
    187     unsigned int   ulHeight;
    188     unsigned int   ulTargetBitRate;
    189     unsigned int   ulBitstreamBuffSize;
    190     unsigned int   ulIntraFramePeriod;
    191     unsigned int   ulFrameRate;
    192 
    193     unsigned char  ucYUVFormat;
    194     unsigned char  ucUnrestrictedMV;
    195     unsigned char  ucNumRefFrames;
    196     unsigned char  ucRateControlAlgorithm;
    197     unsigned char  ucIDREnable;
    198     unsigned char  ucDeblockingEnable;
    199     unsigned char  ucMVRange;
    200     unsigned char  ucQPIFrame;
    201     unsigned char  ucProfile;
    202     unsigned char  ucLevel;
    203 
    204     unsigned short usNalCallback;
    205 
    206     unsigned int   ulEncodingPreset;
    207     unsigned int   ulRcAlgo;
    208     unsigned short endArgs;
    209 } H264VE_GPP_SN_Obj_CreatePhase;
    210 
    211 /* H264 Encoder DSP s/n run-time dynamic parameters*/
    212 typedef struct IVIDENC_DynamicParams {
    213      OMX_U32    size;              /*  size of this structure             */
    214      OMX_U32    inputHeight;       /*  Input frame height                 */
    215      OMX_U32    inputWidth;        /*  Input frame width                  */
    216      OMX_U32    refFrameRate;      /*  Reference or input frame rate*1000 */
    217      OMX_U32    targetFrameRate;   /*  Target frame rate * 1000           */
    218      OMX_U32    targetBitRate;     /*  Target bit rate in bits per second */
    219      OMX_U32    intraFrameInterval;/*  I frame interval e.g. 30           */
    220      OMX_U32    generateHeader;    /*  XDM_ENCODE_AU, XDM_GENERATE_HEADER */
    221      OMX_U32    captureWidth;      /*  DEFAULT(0): use imagewidth as pitch
    222                                        *  else use given capture width for
    223                                        *  pitch provided it is greater than
    224                                        *  image width.
    225                                        */
    226      OMX_U32    forceIFrame;       /*  Force given frame as I or IDR (in H.264)
    227                                              frame       */
    228 } IVIDENC_DynamicParams;
    229 
    230 typedef struct IH264VENC_DynamicParams {
    231     IVIDENC_DynamicParams videncDynamicParams ; /* must be followed for all video encoders*/
    232     OMX_U32      qpIntra                   ; /* initial QP of I frames Range[-1,51]. -1 is for auto initialization.*/
    233     OMX_U32      qpInter                   ; /* initial QP of P frames Range[-1,51]. -1 is for auto initialization.*/
    234     OMX_U32      qpMax                     ; /* Maximum QP to be used  Range[0,51]*/
    235     OMX_U32      qpMin                     ; /*< Minimum QP to be used  Range[0,51]*/
    236     OMX_U32      lfDisableIdc              ; /* Controls enable/disable loop filter, See IH264VENC_LoopFilterParams for more details*/
    237     OMX_U32      quartPelDisable           ; /*< enable/disable Quarter Pel Interpolation*/
    238     OMX_U32      airMbPeriod               ; /* Adaptive Intra Refesh MB Period: Period at which intra macro blocks should be insterted in a frame*/
    239     OMX_U32      maxMBsPerSlice            ; /* Maximum number of macro block in a slice <minimum value is 8>*/
    240     OMX_U32      maxBytesPerSlice          ; /* Maximum number of bytes in a slice */
    241     OMX_U32      sliceRefreshRowStartNumber; /* Row number from which slice needs to be intra coded*/
    242     OMX_U32      sliceRefreshRowNumber     ; /* Number of rows to be coded as intra slice*/
    243     OMX_U32      filterOffsetA             ; /* alpha offset for loop filter [-12, 12] even number*/
    244     OMX_U32      filterOffsetB             ; /* beta offset for loop filter [-12, 12] even number*/
    245     OMX_U32      log2MaxFNumMinus4         ; /*Limits the maximum frame number in the bit-stream to (1<< (log2MaxFNumMinus4 + 4)) Range[0,12]*/
    246     OMX_U32      chromaQPIndexOffset       ; /*Specifies offset to be added to luma QP for addressing QPC values table for chroma components. Valid value is between -12 and 12, (inclusive)*/
    247     OMX_U32      constrainedIntraPredEnable; /* Controls the intra macroblock coding in P slices [0,1]*/
    248     OMX_U32      picOrderCountType         ; /* Picture Order count type Valid values 0, 2*/
    249     OMX_U32      maxMVperMB                ; /* enable/Disable Multiple Motion vector per MB, valid values are [1, 4] [For DM6446, allowed value is only 1]*/
    250     OMX_U32      intra4x4EnableIdc         ; /* See IH264VENC_Intra4x4Params for more details*/
    251     OMX_U32      mvDataEnable              ; /*enable/Disable Motion vector access*/
    252     OMX_U32      hierCodingEnable          ; /*Enable/Disable Hierarchical P Frame (non-reference P frame) Coding. [Not useful for DM6446]*/
    253     OMX_U32      streamFormat              ; /* Signals the type of stream generated with Call-back*/
    254     OMX_U32      intraRefreshMethod        ; /* Mechanism to do intra Refresh, see IH264VENC_IntraRefreshMethods for valid values*/
    255     OMX_U32      perceptualQuant           ; /* Enable Perceptual Quantization a.k.a. Perceptual Rate Control*/
    256     OMX_U32      sceneChangeDet            ; /* Enable Scene Change Detection*/
    257 
    258     void   (*pfNalUnitCallBack)(OMX_U32 *pNalu, OMX_U32 *pPacketSizeInBytes, void *pContext) ; /* Function pointer of the call-back function to be used by Encoder*/
    259     void *pContext                          ; /*pointer to context structure used during callback*/
    260     /*Following Parameter are related to Arbitrary Slice Ordering (ASO)*/
    261     OMX_U32 numSliceASO                    ; /* Number of valid enteries in asoSliceOrder array valid range is [0,8],
    262                                                where 0 and 1 doesn't have any effect*/
    263     OMX_U32 asoSliceOrder[MAXNUMSLCGPS]    ; /* Array containing the order of slices in which they should
    264                                                 be present in bit-stream. vaild enteries are [0, any entry lesser than numSlicesASO]*/
    265     /* Following Parameter are related to Flexible macro block ordering (FMO)*/
    266     OMX_U32 numSliceGroups                 ; /* Total Number of slice groups, valid enteries are [0,8]*/
    267     OMX_U32 sliceGroupMapType              ; /* Slice GroupMapType : For Valid enteries see IH264VENC_SliceGroupMapType*/
    268     OMX_U32 sliceGroupChangeDirectionFlag  ; /* Slice Group Change Direction Flag: Only valid when sliceGroupMapType
    269                                                  is equal to IH264_RASTER_SCAN_SLICE_GRP.
    270                                                  For valid values refer IH264VENC_SliceGroupChangeDirection*/
    271     OMX_U32 sliceGroupChangeRate           ; /* Slice Group Change Rate: Only valid when sliceGroupMapType
    272                                               is equal to IH264_RASTER_SCAN_SLICE_GRP.
    273                                                valid values are : [0, factor of number of Mbs in a row]*/
    274     OMX_U32 sliceGroupChangeCycle          ; /* Slice Group Change Cycle: Only valid when sliceGroupMapType
    275                                                is equal to IH264_RASTER_SCAN_SLICE_GRP.
    276                                                Valid values can be 0 to numMbsRowsInPicture, also constrained
    277                                                by sliceGroupChangeRate*sliceGroupChangeCycle < totalMbsInFrame*/
    278     OMX_U32 sliceGroupParams[MAXNUMSLCGPS] ; /* This field is useful in case of sliceGroupMapType equal to either
    279                                               IH264_INTERLEAVED_SLICE_GRP or IH264_FOREGRND_WITH_LEFTOVER_SLICE_GRP
    280                                               In both cases it has different meaning:
    281                                               In case of IH264_INTERLEAVED_SLICE_GRP:
    282                                               The i-th entery in this array is used to specify the number of consecutive
    283                                                slice group macroblocks to be assigned to the i-th slice group in
    284                                                raster scan order of slice group macroblock units.
    285                                                Valid values are 0 to totalMbsInFrame again constrained by sum of all the elements
    286                                                shouldn't exceed totalMbsInFrame
    287                                                In case of IH264_FOREGRND_WITH_LEFTOVER_SLICE_GRP:
    288                                                First entry in the array specify the start position of foreground region in terms
    289                                                of macroblock number, valid values are [0, totalMbsInFrame-1]
    290                                                Second entry in the array specify the end position of foreground region in terms
    291                                                of macroblock number, valid values are [0, totalMbsInFrame-1] with following constrains:
    292                                                endPos > startPos && endPos%mbsInOneRow > startPos%mbsInOneRow*/
    293 } IH264VENC_DynamicParams;
    294 
    295 /* H264 Encoder DSP s/n run-time input parameters */
    296 typedef struct H264VE_GPP_SN_UALGInputParams
    297 {
    298 
    299     IH264VENC_DynamicParams H264VENC_TI_DYNAMICPARAMS;
    300     OMX_U32   ulFrameIndex;
    301 
    302 } H264VE_GPP_SN_UALGInputParams;
    303 
    304 /* H264 Encoder DSP s/n run-time output parameters */
    305 typedef struct H264VE_GPP_SN_UALGOutputParams {
    306     OMX_U32   ulBitstreamSize;
    307     OMX_S32   lFrameType;
    308     OMX_U32   ulNALUnitsPerFrame;   /*Number of total NAL units per frame*/
    309     OMX_U32   ulNALUnitsSizes[240];
    310     OMX_U32   ulFrameIndex;         /*Gives the number of the input frame wich NAL unit belongs*/
    311     OMX_U32   ulNALUnitIndex;       /*Number of current NAL unit inside the frame*/
    312 } H264VE_GPP_SN_UALGOutputParams;
    313 
    314 /* MPEG4/H263 Encoder DSP s/n create phase arguments */
    315 typedef struct MP4VE_GPP_SN_Obj_CreatePhase {
    316     unsigned short usNumStreams;
    317     unsigned short usStreamId;
    318     unsigned short usBuffTypeInStream;
    319     unsigned short usMaxBuffsInStream;
    320     unsigned short usStreamId2;
    321     unsigned short usBuffTypeInStream2;
    322     unsigned short usMaxBuffsInStream2;
    323     unsigned short usReserved1;
    324 
    325     unsigned int   ulWidth;
    326     unsigned int   ulHeight;
    327     unsigned int   ulTargetBitRate;
    328     unsigned int   ulVBVSize;
    329     unsigned int   ulGOBHeadersInterval;
    330 
    331     unsigned char  ucIsMPEG4;
    332     unsigned char  ucYUVFormat;
    333     unsigned char  ucHEC;
    334     unsigned char  ucResyncMarker;
    335     unsigned char  ucDataPartitioning;
    336     unsigned char  ucReversibleVLC;
    337     unsigned char  ucUnrestrictedMV;
    338     unsigned char  ucFrameRate;
    339     unsigned char  ucRateControlAlgorithm;
    340     unsigned char  ucQPFirstIFrame;
    341     unsigned char  ucProfile;
    342     unsigned char  ucLevel;
    343     unsigned int   ulMaxDelay;
    344 
    345 #ifndef MODE_3410
    346     unsigned int   ulVbvParamEnable;
    347     unsigned int   ulH263SliceMode;
    348 #endif
    349 
    350     unsigned int   ulUseGOV;
    351     unsigned int   ulUseVOS;
    352     unsigned int   enableH263AnnexI;
    353     unsigned int   enableH263AnnexJ;
    354     unsigned int   enableH263AnnexT;
    355 
    356     unsigned short endArgs;
    357 } MP4VE_GPP_SN_Obj_CreatePhase;
    358 
    359 /* MPEG4/H263 Encoder DSP s/n run-time input parameters */
    360 typedef struct MP4VE_GPP_SN_UALGInputParams {
    361     unsigned int   ulFrameIndex;
    362     unsigned int   ulTargetFrameRate;
    363     unsigned int   ulTargetBitRate;
    364     unsigned int   ulIntraFrameInterval;
    365     unsigned int   ulGenerateHeader;
    366     unsigned int   ulForceIFrame;
    367 
    368     unsigned int   ulResyncInterval;
    369     unsigned int   ulHecInterval;
    370     unsigned int   ulAIRRate;
    371     unsigned int   ulMIRRate;
    372     unsigned int   ulQPIntra;
    373     unsigned int   ulfCode;
    374     unsigned int   ulHalfPel;
    375     unsigned int   ulACPred;
    376     unsigned int   ul4MV;
    377     unsigned int   uluseUMV;
    378     unsigned int   ulMVDataEnable;
    379     unsigned int   ulResyncDataEnable;
    380 
    381     unsigned int   ulQPInter;               /* default QP for P frame, range 1 to 31  */
    382     unsigned int   ulLastFrame;
    383     unsigned int   ulcapturewidth;
    384     unsigned int   ulQpMax;
    385     unsigned int   ulQpMin;
    386 } MP4VE_GPP_SN_UALGInputParams;
    387 
    388 /* MPEG4/H263 Encoder DSP s/n run-time output parameters */
    389 typedef struct MP4VE_GPP_SN_UALGOutputParams {
    390     unsigned int   ulBitstreamSize;
    391     unsigned int  cFrameType;/*changed from unsigned char  as SN did*/
    392     unsigned int   mvDataSize;
    393     unsigned int   numPackets;
    394     #ifdef MODE_3410
    395     unsigned char   MVData[9600];
    396     unsigned char   ResyncData[4800];
    397     #else
    398     unsigned char   MVData[12960];
    399     unsigned int    ResyncData[1620];
    400     #endif
    401 } MP4VE_GPP_SN_UALGOutputParams;
    402 
    403 /*
    404  *  ======== IVIDEO_RateControlPreset ========
    405  *  IVIDEO_DEFAULT => Default rate control of encoder
    406  *  IVIDEO_LOW_DELAY => CBR rate control for video conferencing
    407  *  IVIDEO_STORAGE => VBR rate control for local storage (DVD) recording
    408  *  IVIDEO_TWOPASS => two pass rate control for non real time applications
    409  *  IVIDEO_USER_DEFINED => User defined configuration using advanced parameters
    410  */
    411 typedef enum {
    412     IVIDEO_LOW_DELAY =1, IVIDEO_STORAGE, IVIDEO_TWOPASS, IVIDEO_NONE, IVIDEO_USER_DEFINED
    413 } IVIDEO_RateControlPreset;
    414 
    415 #endif
    416