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