Home | History | Annotate | Download | only in include
      1 /*
      2  *
      3  * Copyright 2012 Samsung Electronics S.LSI Co. LTD
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at
      8  *
      9  *      http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  */
     17 
     18 #ifndef _EXYNOS_VIDEO_API_H_
     19 #define _EXYNOS_VIDEO_API_H_
     20 
     21 #include "exynos_v4l2.h"
     22 
     23 /* Fixed */
     24 #define VIDEO_BUFFER_MAX_PLANES 3
     25 #define VIDEO_BUFFER_MAX_NUM    32
     26 
     27 typedef enum _ExynosVideoBoolType {
     28     VIDEO_FALSE = 0,
     29     VIDEO_TRUE  = 1,
     30 } ExynosVideoBoolType;
     31 
     32 typedef enum _ExynosVideoErrorType {
     33     VIDEO_ERROR_NONE      =  1,
     34     VIDEO_ERROR_BADPARAM  = -1,
     35     VIDEO_ERROR_OPENFAIL  = -2,
     36     VIDEO_ERROR_NOMEM     = -3,
     37     VIDEO_ERROR_APIFAIL   = -4,
     38     VIDEO_ERROR_MAPFAIL   = -5,
     39     VIDEO_ERROR_NOBUFFERS = -6,
     40     VIDEO_ERROR_POLL      = -7,
     41     VIDEO_ERROR_WRONGBUFFERSIZE = -8,
     42 } ExynosVideoErrorType;
     43 
     44 typedef enum _ExynosVideoCodingType {
     45     VIDEO_CODING_UNKNOWN = 0,
     46     VIDEO_CODING_MPEG2,
     47     VIDEO_CODING_H263,
     48     VIDEO_CODING_MPEG4,
     49     VIDEO_CODING_VC1,
     50     VIDEO_CODING_VC1_RCV,
     51     VIDEO_CODING_AVC,
     52     VIDEO_CODING_MVC,
     53     VIDEO_CODING_VP8,
     54     VIDEO_CODING_RESERVED,
     55 } ExynosVideoCodingType;
     56 
     57 typedef enum _ExynosVideoColorFormatType {
     58     VIDEO_COLORFORMAT_UNKNOWN = 0,
     59     VIDEO_COLORFORMAT_NV12,
     60     VIDEO_COLORFORMAT_NV21,
     61     VIDEO_COLORFORMAT_NV12_TILED,
     62     VIDEO_COLORFORMAT_RESERVED,
     63 } ExynosVideoColorFormatType;
     64 
     65 typedef enum _ExynosVideoFrameType {
     66     VIDEO_FRAME_NOT_CODED = 0,
     67     VIDEO_FRAME_I,
     68     VIDEO_FRAME_P,
     69     VIDEO_FRAME_B,
     70     VIDEO_FRAME_SKIPPED,
     71     VIDEO_FRAME_OTHERS,
     72 } ExynosVideoFrameType;
     73 
     74 typedef enum _ExynosVideoFrameStatusType {
     75     VIDEO_FRAME_STATUS_UNKNOWN = 0,
     76     VIDEO_FRAME_STATUS_DECODING_ONLY,
     77     VIDEO_FRAME_STATUS_DISPLAY_DECODING,
     78     VIDEO_FRAME_STATUS_DISPLAY_ONLY,
     79     VIDEO_FRAME_STATUS_DECODING_FINISHED,
     80     VIDEO_FRAME_STATUS_CHANGE_RESOL,
     81 } ExynosVideoFrameStatusType;
     82 
     83 typedef enum _ExynosVideoFrameSkipMode {
     84     VIDEO_FRAME_SKIP_DISABLED = 0,
     85     VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT,
     86     VIDEO_FRAME_SKIP_MODE_BUF_LIMIT,
     87 } ExynosVideoFrameSkipMode;
     88 
     89 typedef struct _ExynosVideoRect {
     90     unsigned int nTop;
     91     unsigned int nLeft;
     92     unsigned int nWidth;
     93     unsigned int nHeight;
     94 } ExynosVideoRect;
     95 
     96 typedef struct _ExynosVideoGeometry {
     97     unsigned int               nFrameWidth;
     98     unsigned int               nFrameHeight;
     99     unsigned int               nSizeImage;
    100     ExynosVideoRect            cropRect;
    101     ExynosVideoCodingType      eCompressionFormat;
    102     ExynosVideoColorFormatType eColorFormat;
    103 } ExynosVideoGeometry;
    104 
    105 typedef struct _ExynosVideoPlane {
    106     void          *addr;
    107     unsigned int   allocSize;
    108     unsigned int   dataSize;
    109     unsigned long  offset;
    110     int            fd;
    111 } ExynosVideoPlane;
    112 
    113 typedef struct _ReleaseDPB {
    114     int fd;
    115     int fd1;
    116     int fd2;
    117 } ReleaseDPB;
    118 
    119 typedef struct _PrivateDataShareBuffer {
    120     int index;
    121     ReleaseDPB dpbFD[VIDEO_BUFFER_MAX_NUM];
    122 }PrivateDataShareBuffer;
    123 
    124 typedef struct _ExynosVideoBuffer {
    125     ExynosVideoPlane            planes[VIDEO_BUFFER_MAX_PLANES];
    126     ExynosVideoGeometry        *pGeometry;
    127     ExynosVideoFrameStatusType  displayStatus;
    128     ExynosVideoFrameType        frameType;
    129     ExynosVideoBoolType         bQueued;
    130     ExynosVideoBoolType         bSlotUsed;
    131     ExynosVideoBoolType         bRegistered;
    132     void                       *pPrivate;
    133     PrivateDataShareBuffer      PDSB;
    134     int                         nIndexUseCnt;
    135 } ExynosVideoBuffer;
    136 
    137 typedef struct _ExynosVideoFramePacking{
    138     int           available;
    139     unsigned int  arrangement_id;
    140     int           arrangement_cancel_flag;
    141     unsigned char arrangement_type;
    142     int           quincunx_sampling_flag;
    143     unsigned char content_interpretation_type;
    144     int           spatial_flipping_flag;
    145     int           frame0_flipped_flag;
    146     int           field_views_flag;
    147     int           current_frame_is_frame0_flag;
    148     unsigned char frame0_grid_pos_x;
    149     unsigned char frame0_grid_pos_y;
    150     unsigned char frame1_grid_pos_x;
    151     unsigned char frame1_grid_pos_y;
    152 } ExynosVideoFramePacking;
    153 
    154 typedef struct _ExynosVideoEncInitParam{
    155     /* Initial parameters */
    156     ExynosVideoFrameSkipMode FrameSkip; /* [IN] frame skip mode */
    157     int FMO;
    158     int ASO;
    159 }ExynosVideoEncInitParam;
    160 
    161 typedef struct _ExynosVideoEncCommonParam{
    162     /* common parameters */
    163     int SourceWidth;                    /* [IN] width of video to be encoded */
    164     int SourceHeight;                   /* [IN] height of video to be encoded */
    165     int IDRPeriod;                      /* [IN] GOP number(interval of I-frame) */
    166     int SliceMode;                      /* [IN] Multi slice mode */
    167     int RandomIntraMBRefresh;           /* [IN] cyclic intra refresh */
    168     int EnableFRMRateControl;           /* [IN] frame based rate control enable */
    169     int EnableMBRateControl;            /* [IN] Enable macroblock-level rate control */
    170     int Bitrate;                        /* [IN] rate control parameter(bit rate) */
    171     int FrameQp;                        /* [IN] The quantization parameter of the frame */
    172     int FrameQp_P;                      /* [IN] The quantization parameter of the P frame */
    173     int QSCodeMax;                      /* [IN] Maximum Quantization value */
    174     int QSCodeMin;                      /* [IN] Minimum Quantization value */
    175     int CBRPeriodRf;                    /* [IN] Reaction coefficient parameter for rate control */
    176     int PadControlOn;                   /* [IN] Enable padding control */
    177     int LumaPadVal;                     /* [IN] Luma pel value used to fill padding area */
    178     int CbPadVal;                       /* [IN] CB pel value used to fill padding area */
    179     int CrPadVal;                       /* [IN] CR pel value used to fill padding area */
    180     int FrameMap;                       /* [IN] Encoding input mode(tile mode or linear mode) */
    181 }ExynosVideoEncCommonParam;
    182 
    183 typedef struct _ExynosVideoEncH264Param{
    184     /* H.264 specific parameters */
    185     int ProfileIDC;                     /* [IN] profile */
    186     int LevelIDC;                       /* [IN] level */
    187     int FrameQp_B;                      /* [IN] The quantization parameter of the B frame */
    188     int FrameRate;                      /* [IN] rate control parameter(frame rate) */
    189     int SliceArgument;                  /* [IN] MB number or byte number */
    190     int NumberBFrames;                  /* [IN] The number of consecutive B frame inserted */
    191     int NumberReferenceFrames;          /* [IN] The number of reference pictures used */
    192     int NumberRefForPframes;            /* [IN] The number of reference pictures used for encoding P pictures */
    193     int LoopFilterDisable;              /* [IN] disable the loop filter */
    194     int LoopFilterAlphaC0Offset;        /* [IN] Alpha & C0 offset for H.264 loop filter */
    195     int LoopFilterBetaOffset;           /* [IN] Beta offset for H.264 loop filter */
    196     int SymbolMode;                     /* [IN] The mode of entropy coding(CABAC, CAVLC) */
    197     int PictureInterlace;               /* [IN] Enables the interlace mode */
    198     int Transform8x8Mode;               /* [IN] Allow 8x8 transform(This is allowed only for high profile) */
    199     int DarkDisable;                    /* [IN] Disable adaptive rate control on dark region */
    200     int SmoothDisable;                  /* [IN] Disable adaptive rate control on smooth region */
    201     int StaticDisable;                  /* [IN] Disable adaptive rate control on static region */
    202     int ActivityDisable;                /* [IN] Disable adaptive rate control on high activity region */
    203 } ExynosVideoEncH264Param;
    204 
    205 typedef struct _ExynosVideoEncMpeg4Param {
    206     /* MPEG4 specific parameters */
    207     int ProfileIDC;                     /* [IN] profile */
    208     int LevelIDC;                       /* [IN] level */
    209     int FrameQp_B;                      /* [IN] The quantization parameter of the B frame */
    210     int TimeIncreamentRes;              /* [IN] frame rate */
    211     int VopTimeIncreament;              /* [IN] frame rate */
    212     int SliceArgument;                  /* [IN] MB number or byte number */
    213     int NumberBFrames;                  /* [IN] The number of consecutive B frame inserted */
    214     int DisableQpelME;                  /* [IN] disable quarter-pixel motion estimation */
    215 } ExynosVideoEncMpeg4Param;
    216 
    217 typedef struct _ExynosVideoEncH263Param {
    218     /* H.263 specific parameters */
    219     int FrameRate;                      /* [IN] rate control parameter(frame rate) */
    220 } ExynosVideoEncH263Param;
    221 
    222 typedef union _ExynosVideoEncCodecParam {
    223     ExynosVideoEncH264Param     h264;
    224     ExynosVideoEncMpeg4Param    mpeg4;
    225     ExynosVideoEncH263Param     h263;
    226 } ExynosVideoEncCodecParam;
    227 
    228 typedef struct _ExynosVideoEncParam {
    229     ExynosVideoCodingType       eCompressionFormat;
    230     ExynosVideoEncInitParam     initParam;
    231     ExynosVideoEncCommonParam   commonParam;
    232     ExynosVideoEncCodecParam    codecParam;
    233 } ExynosVideoEncParam;
    234 
    235 typedef struct _ExynosVideoDecOps {
    236     unsigned int            nSize;
    237 
    238     void *                (*Init)(int nMemoryType);
    239     ExynosVideoErrorType  (*Finalize)(void *pHandle);
    240 
    241     /* Add new ops at the end of structure, no order change */
    242     ExynosVideoErrorType  (*Set_FrameTag)(void *pHandle, int frameTag);
    243     int                   (*Get_FrameTag)(void *pHandle);
    244     int                   (*Get_ActualBufferCount)(void *pHandle);
    245     ExynosVideoErrorType  (*Set_DisplayDelay)(void *pHandle, int delay);
    246     ExynosVideoErrorType  (*Set_IFrameDecoding)(void *pHandle);
    247     ExynosVideoErrorType  (*Enable_PackedPB)(void *pHandle);
    248     ExynosVideoErrorType  (*Enable_LoopFilter)(void *pHandle);
    249     ExynosVideoErrorType  (*Enable_SliceMode)(void *pHandle);
    250     ExynosVideoErrorType  (*Enable_SEIParsing)(void *pHandle);
    251     ExynosVideoErrorType  (*Get_FramePackingInfo)(void *pHandle, ExynosVideoFramePacking *pFramepacking);
    252 } ExynosVideoDecOps;
    253 
    254 typedef struct _ExynosVideoEncOps {
    255     unsigned int           nSize;
    256     void *               (*Init)(int nMemoryType);
    257     ExynosVideoErrorType (*Finalize)(void *pHandle);
    258 
    259     /* Add new ops at the end of structure, no order change */
    260     ExynosVideoErrorType (*Set_EncParam)(void *pHandle, ExynosVideoEncParam*encParam);
    261     ExynosVideoErrorType (*Set_FrameTag)(void *pHandle, int frameTag);
    262     int (*Get_FrameTag)(void *pHandle);
    263     ExynosVideoErrorType (*Set_FrameType)(void *pHandle, int frameType);
    264     ExynosVideoErrorType (*Set_FrameRate)(void *pHandle, int frameRate);
    265     ExynosVideoErrorType (*Set_BitRate)(void *pHandle, int bitRate);
    266     ExynosVideoErrorType (*Set_FrameSkip)(void *pHandle, int frameSkip);
    267     ExynosVideoErrorType (*Set_IDRPeriod)(void *pHandle, int period);
    268     ExynosVideoErrorType (*Enable_PrependSpsPpsToIdr)(void *pHandle);
    269 } ExynosVideoEncOps;
    270 
    271 typedef struct _ExynosVideoDecBufferOps {
    272     unsigned int            nSize;
    273 
    274     /* Add new ops at the end of structure, no order change */
    275     ExynosVideoErrorType  (*Enable_Cacheable)(void *pHandle);
    276     ExynosVideoErrorType  (*Set_Shareable)(void *pHandle);
    277     ExynosVideoErrorType  (*Get_Buffer)(void *pHandle, int nIndex, ExynosVideoBuffer **pBuffer);
    278     ExynosVideoErrorType  (*Set_Geometry)(void *pHandle, ExynosVideoGeometry *bufferConf);
    279     ExynosVideoErrorType  (*Get_Geometry)(void *pHandle, ExynosVideoGeometry *bufferConf);
    280     ExynosVideoErrorType  (*Setup)(void *pHandle, unsigned int nBufferCount);
    281     ExynosVideoErrorType  (*Run)(void *pHandle);
    282     ExynosVideoErrorType  (*Stop)(void *pHandle);
    283     ExynosVideoErrorType  (*Enqueue)(void *pHandle, unsigned char *pBuffer[], unsigned int dataSize[], int nPlanes, void *pPrivate);
    284     ExynosVideoErrorType  (*Enqueue_All)(void *pHandle);
    285     ExynosVideoBuffer *   (*Dequeue)(void *pHandle);
    286     ExynosVideoErrorType  (*Register)(void *pHandle, ExynosVideoPlane *planes, int nPlanes);
    287     ExynosVideoErrorType  (*Clear_RegisteredBuffer)(void *pHandle);
    288     ExynosVideoErrorType  (*Clear_Queue)(void *pHandle);
    289     ExynosVideoErrorType  (*Cleanup_Buffer)(void *pHandle);
    290     ExynosVideoErrorType  (*ExtensionEnqueue)(void *pHandle, unsigned char *pBuffer[], unsigned int *pFd[], unsigned int allocLen[], unsigned int dataSize[], int nPlanes, void *pPrivate);
    291     ExynosVideoErrorType  (*ExtensionDequeue)(void *pHandle, ExynosVideoBuffer *pVideoBuffer);
    292     ExynosVideoErrorType  (*Enable_DynamicDPB)(void *pHandle);
    293 } ExynosVideoDecBufferOps;
    294 
    295 typedef struct _ExynosVideoEncBufferOps {
    296     unsigned int            nSize;
    297 
    298     /* Add new ops at the end of structure, no order change */
    299     ExynosVideoErrorType  (*Enable_Cacheable)(void *pHandle);
    300     ExynosVideoErrorType  (*Set_Shareable)(void *pHandle);
    301     ExynosVideoErrorType  (*Get_Buffer)(void *pHandle, int nIndex, ExynosVideoBuffer **pBuffer);
    302     ExynosVideoErrorType  (*Set_Geometry)(void *pHandle, ExynosVideoGeometry *bufferConf);
    303     ExynosVideoErrorType  (*Get_Geometry)(void *pHandle, ExynosVideoGeometry *bufferConf);
    304     ExynosVideoErrorType  (*Setup)(void *pHandle, unsigned int nBufferCount);
    305     ExynosVideoErrorType  (*Run)(void *pHandle);
    306     ExynosVideoErrorType  (*Stop)(void *pHandle);
    307     ExynosVideoErrorType  (*Enqueue)(void *pHandle, unsigned char *pBuffer[], unsigned int dataSize[], int nPlanes, void *pPrivate);
    308     ExynosVideoErrorType  (*Enqueue_All)(void *pHandle);
    309     ExynosVideoBuffer *   (*Dequeue)(void *pHandle);
    310     ExynosVideoErrorType  (*Register)(void *pHandle, ExynosVideoPlane *planes, int nPlanes);
    311     ExynosVideoErrorType  (*Clear_RegisteredBuffer)(void *pHandle);
    312     ExynosVideoErrorType  (*Clear_Queue)(void *pHandle);
    313     ExynosVideoErrorType  (*ExtensionEnqueue)(void *pHandle, unsigned char *pBuffer[], unsigned int *pFd[], unsigned int allocLen[], unsigned int dataSize[], int nPlanes, void *pPrivate);
    314     ExynosVideoErrorType  (*ExtensionDequeue)(void *pHandle, ExynosVideoBuffer *pVideoBuffer);
    315 } ExynosVideoEncBufferOps;
    316 
    317 int Exynos_Video_Register_Decoder(
    318     ExynosVideoDecOps       *pDecOps,
    319     ExynosVideoDecBufferOps *pInbufOps,
    320     ExynosVideoDecBufferOps *pOutbufOps);
    321 
    322 int Exynos_Video_Register_Encoder(
    323     ExynosVideoEncOps       *pEncOps,
    324     ExynosVideoEncBufferOps *pInbufOps,
    325     ExynosVideoEncBufferOps *pOutbufOps);
    326 
    327 #endif /* _EXYNOS_VIDEO_API_H_ */
    328