ref: 88f5d1dde7bff070a35b29e1831bab12f67c03d7
parent: a384df3246a1741ecd9d1eeff8e060567c21fb1f
author: huili2 <huili2@cisco.com>
date: Tue Mar 24 10:31:24 EDT 2015
remove nal_prefix in encoder
--- a/codec/build/iOS/enc/welsenc/welsenc.xcodeproj/project.pbxproj
+++ b/codec/build/iOS/enc/welsenc/welsenc.xcodeproj/project.pbxproj
@@ -94,7 +94,6 @@
4CE446BB18BC605C0017DF25 /* mt_defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mt_defs.h; sourceTree = "<group>"; };
4CE446BC18BC605C0017DF25 /* mv_pred.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mv_pred.h; sourceTree = "<group>"; };
4CE446BD18BC605C0017DF25 /* nal_encap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nal_encap.h; sourceTree = "<group>"; };
- 4CE446BE18BC605C0017DF25 /* nal_prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nal_prefix.h; sourceTree = "<group>"; };
4CE446BF18BC605C0017DF25 /* param_svc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = param_svc.h; sourceTree = "<group>"; };
4CE446C018BC605C0017DF25 /* parameter_sets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parameter_sets.h; sourceTree = "<group>"; };
4CE446C118BC605C0017DF25 /* picture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = picture.h; sourceTree = "<group>"; };
@@ -274,7 +273,6 @@
4CE446BB18BC605C0017DF25 /* mt_defs.h */,
4CE446BC18BC605C0017DF25 /* mv_pred.h */,
4CE446BD18BC605C0017DF25 /* nal_encap.h */,
- 4CE446BE18BC605C0017DF25 /* nal_prefix.h */,
4CE446BF18BC605C0017DF25 /* param_svc.h */,
4CE446C018BC605C0017DF25 /* parameter_sets.h */,
4CE446C118BC605C0017DF25 /* picture.h */,
--- a/codec/common/inc/wels_common_defs.h
+++ b/codec/common/inc/wels_common_defs.h
@@ -226,6 +226,36 @@
// need pointer to next byte start position in case 0 bit left then 8 instead
} SBitStringAux, *PBitStringAux;
+/* NAL Unix Header in AVC, refer to Page 56 in JVT X201wcm */
+typedef struct TagNalUnitHeader {
+ uint8_t uiForbiddenZeroBit;
+ uint8_t uiNalRefIdc;
+ EWelsNalUnitType eNalUnitType;
+ uint8_t uiReservedOneByte; // only padding usage
+} SNalUnitHeader, *PNalUnitHeader;
+
+/* NAL Unit Header in scalable extension syntax, refer to Page 390 in JVT X201wcm */
+typedef struct TagNalUnitHeaderExt {
+ SNalUnitHeader sNalUnitHeader;
+
+ // uint8_t reserved_one_bit;
+ bool bIdrFlag;
+ uint8_t uiPriorityId;
+ int8_t iNoInterLayerPredFlag; // change as int8_t to support 3 values probably in encoder
+ uint8_t uiDependencyId;
+
+ uint8_t uiQualityId;
+ uint8_t uiTemporalId;
+ bool bUseRefBasePicFlag;
+ bool bDiscardableFlag;
+
+ bool bOutputFlag;
+ uint8_t uiReservedThree2Bits;
+ // Derived variable(s)
+ uint8_t uiLayerDqId;
+ bool bNalExtFlag;
+} SNalUnitHeaderExt, *PNalUnitHeaderExt;
+
/* AVC MB types*/
#define MB_TYPE_INTRA4x4 0x00000001
#define MB_TYPE_INTRA16x16 0x00000002
--- a/codec/decoder/core/inc/nal_prefix.h
+++ b/codec/decoder/core/inc/nal_prefix.h
@@ -42,36 +42,6 @@
///////////////////////////////////NAL Unit prefix/headers///////////////////////////////////
-/* NAL Unix Header in AVC, refer to Page 56 in JVT X201wcm */
-typedef struct TagNalUnitHeader {
-uint8_t uiForbiddenZeroBit;
-uint8_t uiNalRefIdc;
-EWelsNalUnitType eNalUnitType;
-uint8_t uiReservedOneByte; // only padding usage
-} SNalUnitHeader, *PNalUnitHeader;
-
-/* NAL Unit Header in scalable extension syntax, refer to Page 390 in JVT X201wcm */
-typedef struct TagNalUnitHeaderExt {
-SNalUnitHeader sNalUnitHeader;
-
-// uint8_t reserved_one_bit;
-bool bIdrFlag;
-uint8_t uiPriorityId;
-int8_t iNoInterLayerPredFlag; // change as int8_t to support 3 values probably in encoder
-uint8_t uiDependencyId;
-
-uint8_t uiQualityId;
-uint8_t uiTemporalId;
-bool bUseRefBasePicFlag;
-bool bDiscardableFlag;
-
-bool bOutputFlag;
-uint8_t uiReservedThree2Bits;
-// Derived variable(s)
-uint8_t uiLayerDqId;
-bool bNalExtFlag;
-} SNalUnitHeaderExt, *PNalUnitHeaderExt;
-
/* Prefix NAL Unix syntax, refer to Page 392 in JVT X201wcm */
typedef struct TagPrefixNalUnit {
SRefBasePicMarking sRefPicBaseMarking;
--- a/codec/encoder/core/inc/nal_encap.h
+++ b/codec/encoder/core/inc/nal_encap.h
@@ -41,7 +41,10 @@
#define WELS_NAL_UNIT_ENCAPSULATION_H__
#include "typedefs.h"
-#include "nal_prefix.h"
+#include "wels_common_defs.h"
+#include "wels_const.h"
+
+using namespace WelsCommon;
//SBitStringAux
namespace WelsEnc {
--- a/codec/encoder/core/inc/nal_prefix.h
+++ /dev/null
@@ -1,63 +1,0 @@
-/*!
- * \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.
- *
- */
-
-//nal_prefix.h - definitions for NAL Unit Header(/Ext) and PrefixNALUnit
-#ifndef WELS_NAL_UNIT_PREFIX_H__
-#define WELS_NAL_UNIT_PREFIX_H__
-
-#include "typedefs.h"
-#include "slice.h"
-
-namespace WelsEnc {
-///////////////////////////////////NAL Unit prefix/headers///////////////////////////////////
-
-/* NAL Unix Header in AVC, refer to Page 56 in JVT X201wcm */
-typedef struct TagNalUnitHeader {
-uint8_t uiForbiddenZeroBit;
-uint8_t uiNalRefIdc;
-EWelsNalUnitType eNalUnitType;
-uint8_t uiReservedOneByte;
-} SNalUnitHeader, *PNalUnitHeader;
-
-/* NAL Unit Header in scalable extension syntax, refer to Page 390 in JVT X201wcm */
-typedef struct TagNalUnitHeaderExt {
-SNalUnitHeader sNalHeader;
-
-bool bIdrFlag;
-uint8_t uiDependencyId;
-uint8_t uiTemporalId;
-bool bDiscardableFlag;
-
-
-} SNalUnitHeaderExt, *PNalUnitHeaderExt;
-}
-#endif//WELS_NAL_UNIT_PREFIX_H__
--- a/codec/encoder/core/inc/svc_enc_frame.h
+++ b/codec/encoder/core/inc/svc_enc_frame.h
@@ -38,7 +38,6 @@
#include "wels_const.h"
#include "wels_common_basis.h"
#include "parameter_sets.h"
-#include "nal_prefix.h"
#include "slice.h"
#include "picture.h"
#include "svc_enc_macroblock.h"
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -2815,7 +2815,7 @@
const bool kbUseSubsetSpsFlag = (!pParam->bSimulcastAVC) && (kiCurDid > BASE_DEPENDENCY_ID);
SSpatialLayerConfig* fDlp = &pParam->sSpatialLayers[kiCurDid];
SNalUnitHeaderExt* pNalHdExt = &pCurDq->sLayerInfo.sNalHeaderExt;
- SNalUnitHeader* pNalHd = &pNalHdExt->sNalHeader;
+ SNalUnitHeader* pNalHd = &pNalHdExt->sNalUnitHeader;
SDqIdc* pDqIdc = &pCtx->pDqIdcMap[kiCurDid];
int32_t iIdx = 0;
int32_t iSliceCount = 0;
--- a/codec/encoder/core/src/nal_encap.cpp
+++ b/codec/encoder/core/src/nal_encap.cpp
@@ -47,12 +47,12 @@
const int32_t/*EWelsNalRefIdc*/ kiNalRefIdc) {
SWelsEncoderOutput* pWelsEncoderOuput = pEncoderOuput;
SWelsNalRaw* pRawNal = &pWelsEncoderOuput->sNalList[ pWelsEncoderOuput->iNalIndex ];
- SNalUnitHeader* sNalHeader = &pRawNal->sNalExt.sNalHeader;
+ SNalUnitHeader* sNalUnitHeader = &pRawNal->sNalExt.sNalUnitHeader;
const int32_t kiStartPos = (BsGetBitsPos (&pWelsEncoderOuput->sBsWrite) >> 3);
- sNalHeader->eNalUnitType = (EWelsNalUnitType)kiType;
- sNalHeader->uiNalRefIdc = (EWelsNalRefIdc)kiNalRefIdc;
- sNalHeader->uiForbiddenZeroBit = 0;
+ sNalUnitHeader->eNalUnitType = (EWelsNalUnitType)kiType;
+ sNalUnitHeader->uiNalRefIdc = (EWelsNalRefIdc)kiNalRefIdc;
+ sNalUnitHeader->uiForbiddenZeroBit = 0;
pRawNal->pRawData = &pWelsEncoderOuput->pBsBuffer[kiStartPos];
pRawNal->iStartPos = kiStartPos;
@@ -81,13 +81,13 @@
const int32_t/*EWelsNalRefIdc*/ kiNalRefIdc) {
SWelsSliceBs* pSliceBs = pSliceBsIn;
SWelsNalRaw* pRawNal = &pSliceBs->sNalList[ pSliceBs->iNalIndex ];
- SNalUnitHeader* sNalHeader = &pRawNal->sNalExt.sNalHeader;
+ SNalUnitHeader* sNalUnitHeader = &pRawNal->sNalExt.sNalUnitHeader;
SBitStringAux* pBitStringAux = &pSliceBs->sBsWrite;
const int32_t kiStartPos = (BsGetBitsPos (pBitStringAux) >> 3);
- sNalHeader->eNalUnitType = (EWelsNalUnitType)kiType;
- sNalHeader->uiNalRefIdc = (EWelsNalRefIdc)kiNalRefIdc;
- sNalHeader->uiForbiddenZeroBit = 0;
+ sNalUnitHeader->eNalUnitType = (EWelsNalUnitType)kiType;
+ sNalUnitHeader->uiNalRefIdc = (EWelsNalRefIdc)kiNalRefIdc;
+ sNalUnitHeader->uiForbiddenZeroBit = 0;
pRawNal->pRawData = &pSliceBs->pBsBuffer[kiStartPos];
pRawNal->iStartPos = kiStartPos;
@@ -122,8 +122,8 @@
//TODO 2: complete the realloc©
int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t kiDstBufferLen, void* pDst,
int32_t* pDstLen) {
- const bool kbNALExt = pRawNal->sNalExt.sNalHeader.eNalUnitType == NAL_UNIT_PREFIX
- || pRawNal->sNalExt.sNalHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_EXT;
+ const bool kbNALExt = pRawNal->sNalExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_PREFIX
+ || pRawNal->sNalExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_EXT;
int32_t iAssumedNeededLength = NAL_HEADER_SIZE + (kbNALExt ? 3 : 0) + pRawNal->iPayloadSize + 1;
WELS_VERIFY_RETURN_IF (ENC_RETURN_UNEXPECTED, (iAssumedNeededLength <= 0))
@@ -145,7 +145,8 @@
pDstPointer += 4;
/* NAL Unit Header */
- *pDstPointer++ = (pRawNal->sNalExt.sNalHeader.uiNalRefIdc << 5) | (pRawNal->sNalExt.sNalHeader.eNalUnitType & 0x1f);
+ *pDstPointer++ = (pRawNal->sNalExt.sNalUnitHeader.uiNalRefIdc << 5) | (pRawNal->sNalExt.sNalUnitHeader.eNalUnitType &
+ 0x1f);
if (kbNALExt) {
SNalUnitHeaderExt* sNalExt = (SNalUnitHeaderExt*)pNalHeaderExt;
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -267,7 +267,7 @@
if (!pNalHead->bIdrFlag)
WriteReferenceReorder (pBs, pSliceHeader);
- if (pNalHead->sNalHeader.uiNalRefIdc) {
+ if (pNalHead->sNalUnitHeader.uiNalRefIdc) {
WriteRefPicMarking (pBs, pSliceHeader, pNalHead);
}
@@ -335,7 +335,7 @@
if (!pNalHead->bIdrFlag)
WriteReferenceReorder (pBs, pSliceHeader);
- if (pNalHead->sNalHeader.uiNalRefIdc) {
+ if (pNalHead->sNalUnitHeader.uiNalRefIdc) {
WriteRefPicMarking (pBs, pSliceHeader, pNalHead);
if (!pSubSps->sSpsSvcExt.bSliceHeaderRestrictionFlag) {
@@ -839,7 +839,7 @@
//init next pSlice info
pNextSlice->bSliceHeaderExtFlag =
- (NAL_UNIT_CODED_SLICE_EXT == pCurLayer->sLayerInfo.sNalHeaderExt.sNalHeader.eNalUnitType);
+ (NAL_UNIT_CODED_SLICE_EXT == pCurLayer->sLayerInfo.sNalHeaderExt.sNalUnitHeader.eNalUnitType);
memcpy (&pNextSlice->sSliceHeaderExt, &pCurSlice->sSliceHeaderExt,
sizeof (SSliceHeaderExt)); // confirmed_safe_unsafe_usage