summaryrefslogtreecommitdiffstats
path: root/thirdparties/common/include/wels/codec_api.h
blob: f7347f61a645b2168a7f27fd5d0c7477636d7e97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*!
 * \copy
 *     Copyright (c)  2013, Cisco Systems
 *     All rights reserved.
 *
 *     Redistribution and use in source and binary forms, with or without
 *     modification, are permitted provided that the following conditions
 *     are met:
 *
 *        * Redistributions of source code must retain the above copyright
 *          notice, this list of conditions and the following disclaimer.
 *
 *        * Redistributions in binary form must reproduce the above copyright
 *          notice, this list of conditions and the following disclaimer in
 *          the documentation and/or other materials provided with the
 *          distribution.
 *
 *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *     POSSIBILITY OF SUCH DAMAGE.
 *
 */

#ifndef WELS_VIDEO_CODEC_SVC_API_H__
#define WELS_VIDEO_CODEC_SVC_API_H__

#ifndef __cplusplus
#ifdef _MSC_VER
typedef unsigned char bool;
#else
#include <stdbool.h>
#endif
#endif

#include "codec_app_def.h"
#include "codec_def.h"

#if defined(_WIN32) || defined(__cdecl)
#define EXTAPI __cdecl
#else
#define EXTAPI
#endif

#ifdef __cplusplus
class ISVCEncoder
{
public:
    /*
     * return: CM_RETURN: 0 - success; otherwise - failed;
     */
    virtual int EXTAPI Initialize (const SEncParamBase* pParam) = 0;
    virtual int EXTAPI InitializeExt (const SEncParamExt* pParam) = 0;

    virtual int EXTAPI GetDefaultParams (SEncParamExt* pParam) = 0;

    virtual int EXTAPI Uninitialize() = 0;

    /*
     * return: 0 - success; otherwise -failed;
     */
    virtual int EXTAPI EncodeFrame (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo) = 0;
    /*
     * return: 0 - success; otherwise - failed;
     */
    virtual int EXTAPI EncodeParameterSets (SFrameBSInfo* pBsInfo) = 0;

    /*
     * return: 0 - success; otherwise - failed;
     */
    virtual int EXTAPI PauseFrame (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo) = 0;

    /*
     * return: 0 - success; otherwise - failed;
     */
    virtual int EXTAPI ForceIntraFrame (bool bIDR) = 0;

    /************************************************************************
     * InDataFormat, IDRInterval, SVC Encode Param, Frame Rate, Bitrate,..
     ************************************************************************/
    /*
     * return: CM_RETURN: 0 - success; otherwise - failed;
     */
    virtual int EXTAPI SetOption (ENCODER_OPTION eOptionId, void* pOption) = 0;
    virtual int EXTAPI GetOption (ENCODER_OPTION eOptionId, void* pOption) = 0;
    virtual ~ISVCEncoder() {}
};

class ISVCDecoder
{
public:
    virtual long EXTAPI Initialize (const SDecodingParam* pParam) = 0;
    virtual long EXTAPI Uninitialize() = 0;

    virtual DECODING_STATE EXTAPI DecodeFrame (const unsigned char* pSrc,
            const int iSrcLen,
            unsigned char** ppDst,
            int* pStride,
            int& iWidth,
            int& iHeight) = 0;
    /*
     * return: 0 - success; otherwise -failed;
     */
    virtual DECODING_STATE EXTAPI DecodeFrame2 (const unsigned char* pSrc,
            const int iSrcLen,
            unsigned char** ppDst,
            SBufferInfo* pDstInfo) = 0;

    /*
     *  this API does not work for now!! This is for future use to support non-I420 color format output.
     */
    virtual DECODING_STATE EXTAPI DecodeFrameEx (const unsigned char* pSrc,
            const int iSrcLen,
            unsigned char* pDst,
            int iDstStride,
            int& iDstLen,
            int& iWidth,
            int& iHeight,
            int& iColorFormat) = 0;

    /*************************************************************************
     * OutDataFormat, Eos Flag, EC method, ...
     *************************************************************************/
    virtual long EXTAPI SetOption (DECODER_OPTION eOptionId, void* pOption) = 0;
    virtual long EXTAPI GetOption (DECODER_OPTION eOptionId, void* pOption) = 0;
    virtual ~ISVCDecoder() {}
};


extern "C"
{
#else

typedef struct ISVCEncoderVtbl ISVCEncoderVtbl;
typedef const ISVCEncoderVtbl* ISVCEncoder;
struct ISVCEncoderVtbl {

    int (*Initialize) (ISVCEncoder*, const SEncParamBase* pParam);
    int (*InitializeExt) (ISVCEncoder*, const SEncParamExt* pParam);

    int (*GetDefaultParams) (ISVCEncoder*, SEncParamExt* pParam);

    int (*Uninitialize) (ISVCEncoder*);

    int (*EncodeFrame) (ISVCEncoder*, const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo);
    int (*EncodeParameterSets) (ISVCEncoder*, SFrameBSInfo* pBsInfo);

    int (*PauseFrame) (ISVCEncoder*, const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo);

    int (*ForceIntraFrame) (ISVCEncoder*, bool bIDR);

    int (*SetOption) (ISVCEncoder*, ENCODER_OPTION eOptionId, void* pOption);
    int (*GetOption) (ISVCEncoder*, ENCODER_OPTION eOptionId, void* pOption);
};

typedef struct ISVCDecoderVtbl ISVCDecoderVtbl;
typedef const ISVCDecoderVtbl* ISVCDecoder;
struct ISVCDecoderVtbl {
    long (*Initialize) (ISVCDecoder*, const SDecodingParam* pParam);
    long (*Uninitialize) (ISVCDecoder*);

    DECODING_STATE (*DecodeFrame) (ISVCDecoder*, const unsigned char* pSrc,
                                   const int iSrcLen,
                                   unsigned char** ppDst,
                                   int* pStride,
                                   int* iWidth,
                                   int* iHeight);

    DECODING_STATE (*DecodeFrame2) (ISVCDecoder*, const unsigned char* pSrc,
                                    const int iSrcLen,
                                    unsigned char** ppDst,
                                    SBufferInfo* pDstInfo);

    DECODING_STATE (*DecodeFrameEx) (ISVCDecoder*, const unsigned char* pSrc,
                                     const int iSrcLen,
                                     unsigned char* pDst,
                                     int iDstStride,
                                     int* iDstLen,
                                     int* iWidth,
                                     int* iHeight,
                                     int* iColorFormat);

    long (*SetOption) (ISVCDecoder*, DECODER_OPTION eOptionId, void* pOption);
    long (*GetOption) (ISVCDecoder*, DECODER_OPTION eOptionId, void* pOption);
};
#endif

typedef void (*WelsTraceCallback) (void* ctx, int level, const char* string);

int  WelsCreateSVCEncoder (ISVCEncoder** ppEncoder);
void WelsDestroySVCEncoder (ISVCEncoder* pEncoder);

long WelsCreateDecoder (ISVCDecoder** ppDecoder);
void WelsDestroyDecoder (ISVCDecoder* pDecoder);

#ifdef __cplusplus
}
#endif

#endif//WELS_VIDEO_CODEC_SVC_API_H__
OpenPOWER on IntegriCloud