codec_api.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*!
  2. *@page License
  3. *
  4. * \copy
  5. * Copyright (c) 2013, Cisco Systems
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * * Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * * Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  24. * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  26. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  28. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  30. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  31. * POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. */
  34. #ifndef WELS_VIDEO_CODEC_SVC_API_H__
  35. #define WELS_VIDEO_CODEC_SVC_API_H__
  36. #ifndef __cplusplus
  37. #if defined(_MSC_VER) && (_MSC_VER < 1800)
  38. typedef unsigned char bool;
  39. #else
  40. #include <stdbool.h>
  41. #endif
  42. #endif
  43. #include "codec_app_def.h"
  44. #include "codec_def.h"
  45. #if defined(_WIN32) || defined(__cdecl)
  46. #define EXTAPI __cdecl
  47. #else
  48. #define EXTAPI
  49. #endif
  50. /**
  51. * @file codec_api.h
  52. */
  53. /**
  54. * @page Overview
  55. * * This page is for openh264 codec API usage.
  56. * * For how to use the encoder,please refer to page UsageExampleForEncoder
  57. * * For how to use the decoder,please refer to page UsageExampleForDecoder
  58. * * For more detail about ISVEncoder,please refer to page ISVCEncoder
  59. * * For more detail about ISVDecoder,please refer to page ISVCDecoder
  60. */
  61. /**
  62. * @page DecoderUsageExample
  63. *
  64. * @brief
  65. * * An example for using the decoder for Decoding only or Parsing only
  66. *
  67. * Step 1:decoder declaration
  68. * @code
  69. *
  70. * //decoder declaration
  71. * ISVCDecoder *pSvcDecoder;
  72. * //input: encoded bitstream start position; should include start code prefix
  73. * unsigned char *pBuf =...;
  74. * //input: encoded bit stream length; should include the size of start code prefix
  75. * int iSize =...;
  76. * //output: [0~2] for Y,U,V buffer for Decoding only
  77. * unsigned char *pData[3] =...;
  78. * //in-out: for Decoding only: declare and initialize the output buffer info, this should never co-exist with Parsing only
  79. * SBufferInfo sDstBufInfo;
  80. * memset(&sDstBufInfo, 0, sizeof(SBufferInfo));
  81. * //in-out: for Parsing only: declare and initialize the output bitstream buffer info for parse only, this should never co-exist with Decoding only
  82. * SParserBsInfo sDstParseInfo;
  83. * memset(&sDstParseInfo, 0, sizeof(SParserBsInfo));
  84. * sDstParseInfo.pDstBuff = new unsigned char[PARSE_SIZE]; //In Parsing only, allocate enough buffer to save transcoded bitstream for a frame
  85. *
  86. * @endcode
  87. *
  88. * Step 2:decoder creation
  89. * @code
  90. * WelsCreateDecoder(&pSvcDecoder);
  91. * @endcode
  92. *
  93. * Step 3:declare required parameter, used to differentiate Decoding only and Parsing only
  94. * @code
  95. * SDecodingParam sDecParam = {0};
  96. * sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_AVC;
  97. * //for Parsing only, the assignment is mandatory
  98. * sDecParam.bParseOnly = true;
  99. * @endcode
  100. *
  101. * Step 4:initialize the parameter and decoder context, allocate memory
  102. * @code
  103. * pSvcDecoder->Initialize(&sDecParam);
  104. * @endcode
  105. *
  106. * Step 5:do actual decoding process in slice level;
  107. * this can be done in a loop until data ends
  108. * @code
  109. * //for Decoding only
  110. * iRet = pSvcDecoder->DecodeFrameNoDelay(pBuf, iSize, pData, &sDstBufInfo);
  111. * //or
  112. * iRet = pSvcDecoder->DecodeFrame2(pBuf, iSize, pData, &sDstBufInfo);
  113. * //for Parsing only
  114. * iRet = pSvcDecoder->DecodeParser(pBuf, iSize, &sDstParseInfo);
  115. * //decode failed
  116. * If (iRet != 0){
  117. * //error handling (RequestIDR or something like that)
  118. * }
  119. * //for Decoding only, pData can be used for render.
  120. * if (sDstBufInfo.iBufferStatus==1){
  121. * //output handling (pData[0], pData[1], pData[2])
  122. * }
  123. * //for Parsing only, sDstParseInfo can be used for, e.g., HW decoding
  124. * if (sDstBufInfo.iNalNum > 0){
  125. * //Hardware decoding sDstParseInfo;
  126. * }
  127. * //no-delay decoding can be realized by directly calling DecodeFrameNoDelay(), which is the recommended usage.
  128. * //no-delay decoding can also be realized by directly calling DecodeFrame2() again with NULL input, as in the following. In this case, decoder would immediately reconstruct the input data. This can also be used similarly for Parsing only. Consequent decoding error and output indication should also be considered as above.
  129. * iRet = pSvcDecoder->DecodeFrame2(NULL, 0, pData, &sDstBufInfo);
  130. * //judge iRet, sDstBufInfo.iBufferStatus ...
  131. * @endcode
  132. *
  133. * Step 6:uninitialize the decoder and memory free
  134. * @code
  135. * pSvcDecoder->Uninitialize();
  136. * @endcode
  137. *
  138. * Step 7:destroy the decoder
  139. * @code
  140. * DestroyDecoder(pSvcDecoder);
  141. * @endcode
  142. *
  143. */
  144. /**
  145. * @page EncoderUsageExample1
  146. *
  147. * @brief
  148. * * An example for using encoder with basic parameter
  149. *
  150. * Step1:setup encoder
  151. * @code
  152. * ISVCEncoder* encoder_;
  153. * int rv = WelsCreateSVCEncoder (&encoder_);
  154. * assert (rv == 0);
  155. * assert (encoder_ != NULL);
  156. * @endcode
  157. *
  158. * Step2:initilize with basic parameter
  159. * @code
  160. * SEncParamBase param;
  161. * memset (&param, 0, sizeof (SEncParamBase));
  162. * param.iUsageType = usageType; //from EUsageType enum
  163. * param.fMaxFrameRate = frameRate;
  164. * param.iPicWidth = width;
  165. * param.iPicHeight = height;
  166. * param.iTargetBitrate = 5000000;
  167. * encoder_->Initialize (&param);
  168. * @endcode
  169. *
  170. * Step3:set option, set option during encoding process
  171. * @code
  172. * encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &g_LevelSetting);
  173. * int videoFormat = videoFormatI420;
  174. * encoder_->SetOption (ENCODER_OPTION_DATAFORMAT, &videoFormat);
  175. * @endcode
  176. *
  177. * Step4: encode and store ouput bistream
  178. * @code
  179. * int frameSize = width * height * 3 / 2;
  180. * BufferedData buf;
  181. * buf.SetLength (frameSize);
  182. * assert (buf.Length() == (size_t)frameSize);
  183. * SFrameBSInfo info;
  184. * memset (&info, 0, sizeof (SFrameBSInfo));
  185. * SSourcePicture pic;
  186. * memset (&pic, 0, sizeof (SsourcePicture));
  187. * pic.iPicWidth = width;
  188. * pic.iPicHeight = height;
  189. * pic.iColorFormat = videoFormatI420;
  190. * pic.iStride[0] = pic.iPicWidth;
  191. * pic.iStride[1] = pic.iStride[2] = pic.iPicWidth >> 1;
  192. * pic.pData[0] = buf.data();
  193. * pic.pData[1] = pic.pData[0] + width * height;
  194. * pic.pData[2] = pic.pData[1] + (width * height >> 2);
  195. * for(int num = 0;num<total_num;num++) {
  196. * //prepare input data
  197. * rv = encoder_->EncodeFrame (&pic, &info);
  198. * assert (rv == cmResultSuccess);
  199. * if (info.eFrameType != videoFrameTypeSkip) {
  200. * //output bitstream handling
  201. * }
  202. * }
  203. * @endcode
  204. *
  205. * Step5:teardown encoder
  206. * @code
  207. * if (encoder_) {
  208. * encoder_->Uninitialize();
  209. * WelsDestroySVCEncoder (encoder_);
  210. * }
  211. * @endcode
  212. *
  213. */
  214. /**
  215. * @page EncoderUsageExample2
  216. *
  217. * @brief
  218. * * An example for using the encoder with extension parameter.
  219. * * The same operation on Step 1,3,4,5 with Example-1
  220. *
  221. * Step 2:initialize with extension parameter
  222. * @code
  223. * SEncParamExt param;
  224. * encoder_->GetDefaultParams (&param);
  225. * param.iUsageType = usageType;
  226. * param.fMaxFrameRate = frameRate;
  227. * param.iPicWidth = width;
  228. * param.iPicHeight = height;
  229. * param.iTargetBitrate = 5000000;
  230. * param.bEnableDenoise = denoise;
  231. * param.iSpatialLayerNum = layers;
  232. * //SM_DYN_SLICE don't support multi-thread now
  233. * if (sliceMode != SM_SINGLE_SLICE && sliceMode != SM_DYN_SLICE)
  234. * param.iMultipleThreadIdc = 2;
  235. *
  236. * for (int i = 0; i < param.iSpatialLayerNum; i++) {
  237. * param.sSpatialLayers[i].iVideoWidth = width >> (param.iSpatialLayerNum - 1 - i);
  238. * param.sSpatialLayers[i].iVideoHeight = height >> (param.iSpatialLayerNum - 1 - i);
  239. * param.sSpatialLayers[i].fFrameRate = frameRate;
  240. * param.sSpatialLayers[i].iSpatialBitrate = param.iTargetBitrate;
  241. *
  242. * param.sSpatialLayers[i].sSliceCfg.uiSliceMode = sliceMode;
  243. * if (sliceMode == SM_DYN_SLICE) {
  244. * param.sSpatialLayers[i].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 600;
  245. * param.uiMaxNalSize = 1500;
  246. * }
  247. * }
  248. * param.iTargetBitrate *= param.iSpatialLayerNum;
  249. * encoder_->InitializeExt (&param);
  250. * int videoFormat = videoFormatI420;
  251. * encoder_->SetOption (ENCODER_OPTION_DATAFORMAT, &videoFormat);
  252. *
  253. * @endcode
  254. */
  255. #ifdef __cplusplus
  256. /**
  257. * @brief Endocder definition
  258. */
  259. class ISVCEncoder {
  260. public:
  261. /**
  262. * @brief Initialize the encoder
  263. * @param pParam basic encoder parameter
  264. * @return CM_RETURN: 0 - success; otherwise - failed;
  265. */
  266. virtual int EXTAPI Initialize (const SEncParamBase* pParam) = 0;
  267. /**
  268. * @brief Initilaize encoder by using extension parameters.
  269. * @param pParam extension parameter for encoder
  270. * @return CM_RETURN: 0 - success; otherwise - failed;
  271. */
  272. virtual int EXTAPI InitializeExt (const SEncParamExt* pParam) = 0;
  273. /**
  274. * @brief Get the default extension parameters.
  275. * If you want to change some parameters of encoder, firstly you need to get the default encoding parameters,
  276. * after that you can change part of parameters you want to.
  277. * @param pParam extension parameter for encoder
  278. * @return CM_RETURN: 0 - success; otherwise - failed;
  279. * */
  280. virtual int EXTAPI GetDefaultParams (SEncParamExt* pParam) = 0;
  281. /// uninitialize the encoder
  282. virtual int EXTAPI Uninitialize() = 0;
  283. /**
  284. * @brief Encode one frame
  285. * @param kpSrcPic the pointer to the source luminance plane
  286. * chrominance data:
  287. * CbData = kpSrc + m_iMaxPicWidth * m_iMaxPicHeight;
  288. * CrData = CbData + (m_iMaxPicWidth * m_iMaxPicHeight)/4;
  289. * the application calling this interface needs to ensure the data validation between the location
  290. * @param pBsInfo output bit stream
  291. * @return 0 - success; otherwise -failed;
  292. */
  293. virtual int EXTAPI EncodeFrame (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo) = 0;
  294. /**
  295. * @brief Encode the parameters from output bit stream
  296. * @param pBsInfo output bit stream
  297. * @return 0 - success; otherwise - failed;
  298. */
  299. virtual int EXTAPI EncodeParameterSets (SFrameBSInfo* pBsInfo) = 0;
  300. /**
  301. * @brief Force encoder to encoder frame as IDR if bIDR set as true
  302. * @param bIDR true: force encoder to encode frame as IDR frame;false, return 1 and nothing to do
  303. * @return 0 - success; otherwise - failed;
  304. */
  305. virtual int EXTAPI ForceIntraFrame (bool bIDR, int iLayerId = -1) = 0;
  306. /**
  307. * @brief Set option for encoder, detail option type, please refer to enumurate ENCODER_OPTION.
  308. * @param pOption option for encoder such as InDataFormat, IDRInterval, SVC Encode Param, Frame Rate, Bitrate,...
  309. * @return CM_RETURN: 0 - success; otherwise - failed;
  310. */
  311. virtual int EXTAPI SetOption (ENCODER_OPTION eOptionId, void* pOption) = 0;
  312. /**
  313. * @brief Get option for encoder, detail option type, please refer to enumurate ENCODER_OPTION.
  314. * @param pOption option for encoder such as InDataFormat, IDRInterval, SVC Encode Param, Frame Rate, Bitrate,...
  315. * @return CM_RETURN: 0 - success; otherwise - failed;
  316. */
  317. virtual int EXTAPI GetOption (ENCODER_OPTION eOptionId, void* pOption) = 0;
  318. virtual ~ISVCEncoder() {}
  319. };
  320. /**
  321. * @brief Decoder definition
  322. */
  323. class ISVCDecoder {
  324. public:
  325. /**
  326. * @brief Initilaize decoder
  327. * @param pParam parameter for decoder
  328. * @return 0 - success; otherwise - failed;
  329. */
  330. virtual long EXTAPI Initialize (const SDecodingParam* pParam) = 0;
  331. /// Uninitialize the decoder
  332. virtual long EXTAPI Uninitialize() = 0;
  333. /**
  334. * @brief Decode one frame
  335. * @param pSrc the h264 stream to be decoded
  336. * @param iSrcLen the length of h264 stream
  337. * @param ppDst buffer pointer of decoded data (YUV)
  338. * @param pStride output stride
  339. * @param iWidth output width
  340. * @param iHeight output height
  341. * @return 0 - success; otherwise -failed;
  342. */
  343. virtual DECODING_STATE EXTAPI DecodeFrame (const unsigned char* pSrc,
  344. const int iSrcLen,
  345. unsigned char** ppDst,
  346. int* pStride,
  347. int& iWidth,
  348. int& iHeight) = 0;
  349. /**
  350. * @brief For slice level DecodeFrameNoDelay() (4 parameters input),
  351. * whatever the function return value is, the output data
  352. * of I420 format will only be available when pDstInfo->iBufferStatus == 1,.
  353. * This function will parse and reconstruct the input frame immediately if it is complete
  354. * It is recommended as the main decoding function for H.264/AVC format input
  355. * @param pSrc the h264 stream to be decoded
  356. * @param iSrcLen the length of h264 stream
  357. * @param ppDst buffer pointer of decoded data (YUV)
  358. * @param pDstInfo information provided to API(width, height, etc.)
  359. * @return 0 - success; otherwise -failed;
  360. */
  361. virtual DECODING_STATE EXTAPI DecodeFrameNoDelay (const unsigned char* pSrc,
  362. const int iSrcLen,
  363. unsigned char** ppDst,
  364. SBufferInfo* pDstInfo) = 0;
  365. /**
  366. * @brief For slice level DecodeFrame2() (4 parameters input),
  367. * whatever the function return value is, the output data
  368. * of I420 format will only be available when pDstInfo->iBufferStatus == 1,.
  369. * (e.g., in multi-slice cases, only when the whole picture
  370. * is completely reconstructed, this variable would be set equal to 1.)
  371. * @param pSrc the h264 stream to be decoded
  372. * @param iSrcLen the length of h264 stream
  373. * @param ppDst buffer pointer of decoded data (YUV)
  374. * @param pDstInfo information provided to API(width, height, etc.)
  375. * @return 0 - success; otherwise -failed;
  376. */
  377. virtual DECODING_STATE EXTAPI DecodeFrame2 (const unsigned char* pSrc,
  378. const int iSrcLen,
  379. unsigned char** ppDst,
  380. SBufferInfo* pDstInfo) = 0;
  381. /**
  382. * @brief This function gets a decoded ready frame remaining in buffers after the last frame has been decoded.
  383. * Use GetOption with option DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER to get the number of frames remaining in buffers.
  384. * Note that it is only applicable for profile_idc != 66
  385. * @param ppDst buffer pointer of decoded data (YUV)
  386. * @param pDstInfo information provided to API(width, height, etc.)
  387. * @return 0 - success; otherwise -failed;
  388. */
  389. virtual DECODING_STATE EXTAPI FlushFrame (unsigned char** ppDst,
  390. SBufferInfo* pDstInfo) = 0;
  391. /**
  392. * @brief This function parse input bitstream only, and rewrite possible SVC syntax to AVC syntax
  393. * @param pSrc the h264 stream to be decoded
  394. * @param iSrcLen the length of h264 stream
  395. * @param pDstInfo bit stream info
  396. * @return 0 - success; otherwise -failed;
  397. */
  398. virtual DECODING_STATE EXTAPI DecodeParser (const unsigned char* pSrc,
  399. const int iSrcLen,
  400. SParserBsInfo* pDstInfo) = 0;
  401. /**
  402. * @brief This API does not work for now!! This is for future use to support non-I420 color format output.
  403. * @param pSrc the h264 stream to be decoded
  404. * @param iSrcLen the length of h264 stream
  405. * @param pDst buffer pointer of decoded data (YUV)
  406. * @param iDstStride output stride
  407. * @param iDstLen bit stream info
  408. * @param iWidth output width
  409. * @param iHeight output height
  410. * @param iColorFormat output color format
  411. * @return to do ...
  412. */
  413. virtual DECODING_STATE EXTAPI DecodeFrameEx (const unsigned char* pSrc,
  414. const int iSrcLen,
  415. unsigned char* pDst,
  416. int iDstStride,
  417. int& iDstLen,
  418. int& iWidth,
  419. int& iHeight,
  420. int& iColorFormat) = 0;
  421. /**
  422. * @brief Set option for decoder, detail option type, please refer to enumurate DECODER_OPTION.
  423. * @param pOption option for decoder such as OutDataFormat, Eos Flag, EC method, ...
  424. * @return CM_RETURN: 0 - success; otherwise - failed;
  425. */
  426. virtual long EXTAPI SetOption (DECODER_OPTION eOptionId, void* pOption) = 0;
  427. /**
  428. * @brief Get option for decoder, detail option type, please refer to enumurate DECODER_OPTION.
  429. * @param pOption option for decoder such as OutDataFormat, Eos Flag, EC method, ...
  430. * @return CM_RETURN: 0 - success; otherwise - failed;
  431. */
  432. virtual long EXTAPI GetOption (DECODER_OPTION eOptionId, void* pOption) = 0;
  433. virtual ~ISVCDecoder() {}
  434. };
  435. extern "C"
  436. {
  437. #else
  438. typedef struct ISVCEncoderVtbl ISVCEncoderVtbl;
  439. typedef const ISVCEncoderVtbl* ISVCEncoder;
  440. struct ISVCEncoderVtbl {
  441. int (*Initialize) (ISVCEncoder*, const SEncParamBase* pParam);
  442. int (*InitializeExt) (ISVCEncoder*, const SEncParamExt* pParam);
  443. int (*GetDefaultParams) (ISVCEncoder*, SEncParamExt* pParam);
  444. int (*Uninitialize) (ISVCEncoder*);
  445. int (*EncodeFrame) (ISVCEncoder*, const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo);
  446. int (*EncodeParameterSets) (ISVCEncoder*, SFrameBSInfo* pBsInfo);
  447. int (*ForceIntraFrame) (ISVCEncoder*, bool bIDR);
  448. int (*SetOption) (ISVCEncoder*, ENCODER_OPTION eOptionId, void* pOption);
  449. int (*GetOption) (ISVCEncoder*, ENCODER_OPTION eOptionId, void* pOption);
  450. };
  451. typedef struct ISVCDecoderVtbl ISVCDecoderVtbl;
  452. typedef const ISVCDecoderVtbl* ISVCDecoder;
  453. struct ISVCDecoderVtbl {
  454. long (*Initialize) (ISVCDecoder*, const SDecodingParam* pParam);
  455. long (*Uninitialize) (ISVCDecoder*);
  456. DECODING_STATE (*DecodeFrame) (ISVCDecoder*, const unsigned char* pSrc,
  457. const int iSrcLen,
  458. unsigned char** ppDst,
  459. int* pStride,
  460. int* iWidth,
  461. int* iHeight);
  462. DECODING_STATE (*DecodeFrameNoDelay) (ISVCDecoder*, const unsigned char* pSrc,
  463. const int iSrcLen,
  464. unsigned char** ppDst,
  465. SBufferInfo* pDstInfo);
  466. DECODING_STATE (*DecodeFrame2) (ISVCDecoder*, const unsigned char* pSrc,
  467. const int iSrcLen,
  468. unsigned char** ppDst,
  469. SBufferInfo* pDstInfo);
  470. DECODING_STATE (*FlushFrame) (ISVCDecoder*, unsigned char** ppDst,
  471. SBufferInfo* pDstInfo);
  472. DECODING_STATE (*DecodeParser) (ISVCDecoder*, const unsigned char* pSrc,
  473. const int iSrcLen,
  474. SParserBsInfo* pDstInfo);
  475. DECODING_STATE (*DecodeFrameEx) (ISVCDecoder*, const unsigned char* pSrc,
  476. const int iSrcLen,
  477. unsigned char* pDst,
  478. int iDstStride,
  479. int* iDstLen,
  480. int* iWidth,
  481. int* iHeight,
  482. int* iColorFormat);
  483. long (*SetOption) (ISVCDecoder*, DECODER_OPTION eOptionId, void* pOption);
  484. long (*GetOption) (ISVCDecoder*, DECODER_OPTION eOptionId, void* pOption);
  485. };
  486. #endif
  487. typedef void (*WelsTraceCallback) (void* ctx, int level, const char* string);
  488. /** @brief Create encoder
  489. * @param ppEncoder encoder
  490. * @return 0 - success; otherwise - failed;
  491. */
  492. int WelsCreateSVCEncoder (ISVCEncoder** ppEncoder);
  493. /** @brief Destroy encoder
  494. * @param pEncoder encoder
  495. * @return void
  496. */
  497. void WelsDestroySVCEncoder (ISVCEncoder* pEncoder);
  498. /** @brief Get the capability of decoder
  499. * @param pDecCapability decoder capability
  500. * @return 0 - success; otherwise - failed;
  501. */
  502. int WelsGetDecoderCapability (SDecoderCapability* pDecCapability);
  503. /** @brief Create decoder
  504. * @param ppDecoder decoder
  505. * @return 0 - success; otherwise - failed;
  506. */
  507. long WelsCreateDecoder (ISVCDecoder** ppDecoder);
  508. /** @brief Destroy decoder
  509. * @param pDecoder decoder
  510. * @return void
  511. */
  512. void WelsDestroyDecoder (ISVCDecoder* pDecoder);
  513. /** @brief Get codec version
  514. * Note, old versions of Mingw (GCC < 4.7) are buggy and use an
  515. * incorrect/different ABI for calling this function, making it
  516. * incompatible with MSVC builds.
  517. * @return The linked codec version
  518. */
  519. OpenH264Version WelsGetCodecVersion (void);
  520. /** @brief Get codec version
  521. * @param pVersion struct to fill in with the version
  522. */
  523. void WelsGetCodecVersionEx (OpenH264Version* pVersion);
  524. #ifdef __cplusplus
  525. }
  526. #endif
  527. #endif//WELS_VIDEO_CODEC_SVC_API_H__