From efdefdba28559dfd83a3259eadd71c932bd5555a Mon Sep 17 00:00:00 2001 From: huili2 Date: Sun, 28 Sep 2014 18:06:17 -0700 Subject: [PATCH] add API only for decode parser for HW decoding support --- codec/api/svc/codec_api.h | 12 ++++++++++++ codec/api/svc/codec_app_def.h | 8 ++++++++ codec/decoder/plus/inc/welsDecoderExt.h | 3 +++ codec/decoder/plus/src/welsDecoderExt.cpp | 7 +++++++ test/api/c_interface_test.c | 5 +++-- test/api/cpp_interface_test.cpp | 9 +++++++-- 6 files changed, 40 insertions(+), 4 deletions(-) diff --git a/codec/api/svc/codec_api.h b/codec/api/svc/codec_api.h index 5e2ce64c..26e79e39 100644 --- a/codec/api/svc/codec_api.h +++ b/codec/api/svc/codec_api.h @@ -106,6 +106,14 @@ class ISVCDecoder { unsigned char** ppDst, SBufferInfo* pDstInfo) = 0; + /* + * This function parse input bitstream only, and rewrite possible SVC syntax to AVC syntax + * return: 0 - success; otherwise -failed; + */ + virtual DECODING_STATE EXTAPI DecodeParser (const unsigned char* pSrc, + const int iSrcLen, + SParserBsInfo* pDstInfo) = 0; + /* * this API does not work for now!! This is for future use to support non-I420 color format output. */ @@ -169,6 +177,10 @@ DECODING_STATE (*DecodeFrame2) (ISVCDecoder*, const unsigned char* pSrc, unsigned char** ppDst, SBufferInfo* pDstInfo); +DECODING_STATE (*DecodeParser) (ISVCDecoder*, const unsigned char* pSrc, + const int iSrcLen, + SParserBsInfo* pDstInfo); + DECODING_STATE (*DecodeFrameEx) (ISVCDecoder*, const unsigned char* pSrc, const int iSrcLen, unsigned char* pDst, diff --git a/codec/api/svc/codec_app_def.h b/codec/api/svc/codec_app_def.h index cbef2af7..4798a760 100644 --- a/codec/api/svc/codec_app_def.h +++ b/codec/api/svc/codec_app_def.h @@ -447,4 +447,12 @@ typedef struct TagDecoderCapability { bool bRedPicCap; } SDecoderCapability; +typedef struct TagParserBsInfo { + int iNalNum; //total NAL number in current AU + int iNalLenInByte [MAX_NAL_UNITS_IN_LAYER]; //each nal length + unsigned char* pDstBuff; //outputted dst buffer for parsed bitstream + int iSpsWidthInPixel; //required SPS width info + int iSpsHeightInPixel; //required SPS height info +} SParserBsInfo, PParserBsInfo; + #endif//WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__ diff --git a/codec/decoder/plus/inc/welsDecoderExt.h b/codec/decoder/plus/inc/welsDecoderExt.h index 2431024f..763aaeb9 100644 --- a/codec/decoder/plus/inc/welsDecoderExt.h +++ b/codec/decoder/plus/inc/welsDecoderExt.h @@ -85,6 +85,9 @@ virtual DECODING_STATE EXTAPI DecodeFrame2 (const unsigned char* kpSrc, const int kiSrcLen, unsigned char** ppDst, SBufferInfo* pDstInfo); +virtual DECODING_STATE EXTAPI DecodeParser (const unsigned char* kpSrc, + const int kiSrcLen, + SParserBsInfo* pDstInfo); virtual DECODING_STATE EXTAPI DecodeFrameEx (const unsigned char* kpSrc, const int kiSrcLen, unsigned char* pDst, diff --git a/codec/decoder/plus/src/welsDecoderExt.cpp b/codec/decoder/plus/src/welsDecoderExt.cpp index efe8d7c5..a0d8677f 100644 --- a/codec/decoder/plus/src/welsDecoderExt.cpp +++ b/codec/decoder/plus/src/welsDecoderExt.cpp @@ -453,6 +453,13 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, return dsErrorFree; } +DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc, + const int kiSrcLen, + SParserBsInfo* pDstInfo) { +//TODO, add function here + return (DECODING_STATE) m_pDecContext->iErrorCode; +} + DECODING_STATE CWelsDecoder::DecodeFrame (const unsigned char* kpSrc, const int kiSrcLen, unsigned char** ppDst, diff --git a/test/api/c_interface_test.c b/test/api/c_interface_test.c index bc6a7289..81a945e3 100644 --- a/test/api/c_interface_test.c +++ b/test/api/c_interface_test.c @@ -27,8 +27,9 @@ void CheckDecoderInterface(ISVCDecoder* p, CheckFunc check) { CHECK(3, p, DecodeFrame); CHECK(4, p, DecodeFrame2); CHECK(5, p, DecodeFrameEx); - CHECK(6, p, SetOption); - CHECK(7, p, GetOption); + CHECK(6, p, DecodeParser); + CHECK(7, p, SetOption); + CHECK(8, p, GetOption); } struct bool_test_struct { diff --git a/test/api/cpp_interface_test.cpp b/test/api/cpp_interface_test.cpp index 8eed00a4..30fb046a 100644 --- a/test/api/cpp_interface_test.cpp +++ b/test/api/cpp_interface_test.cpp @@ -88,13 +88,18 @@ struct SVCDecoderImpl : public ISVCDecoder { EXPECT_TRUE (gThis == this); return static_cast (5); } + virtual DECODING_STATE EXTAPI DecodeParser (const unsigned char* pSrc, + const int iSrcLen, SParserBsInfo* pDstInfo) { + EXPECT_TRUE (gThis == this); + return static_cast (6); + } virtual long EXTAPI SetOption (DECODER_OPTION eOptionId, void* pOption) { EXPECT_TRUE (gThis == this); - return 6; + return 7; } virtual long EXTAPI GetOption (DECODER_OPTION eOptionId, void* pOption) { EXPECT_TRUE (gThis == this); - return 7; + return 8; } };