shithub: openh264

Download patch

ref: efdefdba28559dfd83a3259eadd71c932bd5555a
parent: e4b373a8000914f6326f094951e40cc9218c833c
author: huili2 <huili2@cisco.com>
date: Sun Sep 28 14:06:17 EDT 2014

add API only for decode parser for HW decoding support

--- a/codec/api/svc/codec_api.h
+++ b/codec/api/svc/codec_api.h
@@ -107,6 +107,14 @@
       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.
    */
   virtual DECODING_STATE EXTAPI DecodeFrameEx (const unsigned char* pSrc,
@@ -168,6 +176,10 @@
                                 const int iSrcLen,
                                 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,
--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -447,4 +447,12 @@
   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__
--- a/codec/decoder/plus/inc/welsDecoderExt.h
+++ b/codec/decoder/plus/inc/welsDecoderExt.h
@@ -85,6 +85,9 @@
     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,
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -453,6 +453,13 @@
   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,
--- a/test/api/c_interface_test.c
+++ b/test/api/c_interface_test.c
@@ -27,8 +27,9 @@
   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 {
--- a/test/api/cpp_interface_test.cpp
+++ b/test/api/cpp_interface_test.cpp
@@ -88,13 +88,18 @@
     EXPECT_TRUE (gThis == this);
     return static_cast<DECODING_STATE> (5);
   }
+  virtual DECODING_STATE EXTAPI DecodeParser (const unsigned char* pSrc,
+      const int iSrcLen, SParserBsInfo* pDstInfo) {
+    EXPECT_TRUE (gThis == this);
+    return static_cast<DECODING_STATE> (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;
   }
 };