From 14e5d740cd3c3b8477c17591221e80a6e7b06753 Mon Sep 17 00:00:00 2001 From: ruil2 Date: Fri, 30 May 2014 11:05:31 +0800 Subject: [PATCH] clean up expand picture. --- codec/build/win32/dec/WelsDecCore.vcproj | 8 +- codec/build/win32/enc/WelsEncCore.vcproj | 8 +- .../{expand_picture_common.h => expand_pic.h} | 20 +- .../core => common}/src/expand_pic.cpp | 55 +++--- codec/common/targets.mk | 1 + codec/decoder/core/inc/decoder_context.h | 6 +- codec/decoder/core/inc/expand_pic.h | 57 ------ codec/decoder/core/inc/wels_const.h | 1 - codec/decoder/core/src/decoder_core.cpp | 5 +- codec/decoder/core/src/error_concealment.cpp | 5 +- codec/decoder/core/src/expand_pic.cpp | 171 ------------------ codec/decoder/targets.mk | 1 - codec/encoder/core/inc/expand_pic.h | 55 ------ codec/encoder/core/inc/wels_const.h | 2 +- codec/encoder/core/inc/wels_func_ptr_def.h | 5 +- codec/encoder/core/src/encoder.cpp | 2 +- codec/encoder/core/src/ref_list_mgr_svc.cpp | 8 +- codec/encoder/targets.mk | 1 - test/decoder/DecUT_ExpandPicture.cpp | 8 +- test/encoder/EncUT_ExpandPic.cpp | 120 ++++++------ 20 files changed, 131 insertions(+), 408 deletions(-) rename codec/common/inc/{expand_picture_common.h => expand_pic.h} (82%) rename codec/{encoder/core => common}/src/expand_pic.cpp (73%) delete mode 100644 codec/decoder/core/inc/expand_pic.h delete mode 100644 codec/decoder/core/src/expand_pic.cpp delete mode 100644 codec/encoder/core/inc/expand_pic.h diff --git a/codec/build/win32/dec/WelsDecCore.vcproj b/codec/build/win32/dec/WelsDecCore.vcproj index a30864f8..064ed171 100644 --- a/codec/build/win32/dec/WelsDecCore.vcproj +++ b/codec/build/win32/dec/WelsDecCore.vcproj @@ -730,11 +730,7 @@ > - - - - #include "expand_pic.h" #include "cpu_core.h" -#include "wels_func_ptr_def.h" -namespace WelsSVCEnc { // rewrite it (split into luma & chroma) that is helpful for mmx/sse2 optimization perform, 9/27/2009 static inline void ExpandPictureLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH) { @@ -116,60 +114,61 @@ static inline void ExpandPictureChroma_c (uint8_t* pDst, const int32_t kiStride, } while (i < kiPicH); } -void InitExpandPictureFunc (void* pL, const uint32_t kuiCPUFlag) { - SWelsFuncPtrList* pFuncList = (SWelsFuncPtrList*)pL; - pFuncList->pfExpandLumaPicture = ExpandPictureLuma_c; - pFuncList->pfExpandChromaPicture[0] = ExpandPictureChroma_c; - pFuncList->pfExpandChromaPicture[1] = ExpandPictureChroma_c; +void InitExpandPictureFunc (SExpandPicFunc* pExpandPicFunc, const uint32_t kuiCPUFlag) { + pExpandPicFunc->pfExpandLumaPicture = ExpandPictureLuma_c; + pExpandPicFunc->pfExpandChromaPicture[0] = ExpandPictureChroma_c; + pExpandPicFunc->pfExpandChromaPicture[1] = ExpandPictureChroma_c; #if defined(X86_ASM) if ((kuiCPUFlag & WELS_CPU_SSE2) == WELS_CPU_SSE2) { - pFuncList->pfExpandLumaPicture = ExpandPictureLuma_sse2; - pFuncList->pfExpandChromaPicture[0] = ExpandPictureChromaUnalign_sse2; - pFuncList->pfExpandChromaPicture[1] = ExpandPictureChromaAlign_sse2; + pExpandPicFunc->pfExpandLumaPicture = ExpandPictureLuma_sse2; + pExpandPicFunc->pfExpandChromaPicture[0] = ExpandPictureChromaUnalign_sse2; + pExpandPicFunc->pfExpandChromaPicture[1] = ExpandPictureChromaAlign_sse2; } #endif//X86_ASM #if defined(HAVE_NEON) if (kuiCPUFlag & WELS_CPU_NEON) { - pFuncList->pfExpandLumaPicture = ExpandPictureLuma_neon; - pFuncList->pfExpandChromaPicture[0] = ExpandPictureChroma_neon; - pFuncList->pfExpandChromaPicture[1] = ExpandPictureChroma_neon; + pExpandPicFunc->pfExpandLumaPicture = ExpandPictureLuma_neon; + pExpandPicFunc->pfExpandChromaPicture[0] = ExpandPictureChroma_neon; + pExpandPicFunc->pfExpandChromaPicture[1] = ExpandPictureChroma_neon; } #endif//HAVE_NEON #if defined(HAVE_NEON_AARCH64) if (kuiCPUFlag & WELS_CPU_NEON) { - pFuncList->pfExpandLumaPicture = ExpandPictureLuma_AArch64_neon; - pFuncList->pfExpandChromaPicture[0] = ExpandPictureChroma_AArch64_neon; - pFuncList->pfExpandChromaPicture[1] = ExpandPictureChroma_AArch64_neon; + pExpandPicFunc->pfExpandLumaPicture = ExpandPictureLuma_AArch64_neon; + pExpandPicFunc->pfExpandChromaPicture[0] = ExpandPictureChroma_AArch64_neon; + pExpandPicFunc->pfExpandChromaPicture[1] = ExpandPictureChroma_AArch64_neon; } #endif//HAVE_NEON_AARCH64 } -void ExpandReferencingPicture (SPicture* pPic, PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChrom[2]) { +//void ExpandReferencingPicture (SPicture* pPic, PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChrom[2]) { +void ExpandReferencingPicture (uint8_t* pData[3], int32_t iWidth, int32_t iHeight, int32_t iStride[3], + PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChrom[2]) { /*local variable*/ - uint8_t* pPicY = pPic->pData[0]; - uint8_t* pPicCb = pPic->pData[1]; - uint8_t* pPicCr = pPic->pData[2]; - const int32_t kiWidthY = pPic->iWidthInPixel; - const int32_t kiHeightY = pPic->iHeightInPixel; + uint8_t* pPicY = pData[0]; + uint8_t* pPicCb = pData[1]; + uint8_t* pPicCr = pData[2]; + const int32_t kiWidthY = iWidth; + const int32_t kiHeightY = iHeight; const int32_t kiWidthUV = kiWidthY >> 1; const int32_t kiHeightUV = kiHeightY >> 1; - pExpLuma (pPicY, pPic->iLineSize[0], kiWidthY, kiHeightY); + pExpLuma (pPicY, iStride[0], kiWidthY, kiHeightY); if (kiWidthUV >= 16) { // fix coding picture size as 16x16 const bool kbChrAligned = /*(iWidthUV >= 16) && */ ((kiWidthUV & 0x0F) == 0); // chroma planes: (16+iWidthUV) & 15 - pExpChrom[kbChrAligned] (pPicCb, pPic->iLineSize[1], kiWidthUV, kiHeightUV); - pExpChrom[kbChrAligned] (pPicCr, pPic->iLineSize[2], kiWidthUV, kiHeightUV); + pExpChrom[kbChrAligned] (pPicCb, iStride[1], kiWidthUV, kiHeightUV); + pExpChrom[kbChrAligned] (pPicCr, iStride[2], kiWidthUV, kiHeightUV); } else { // fix coding picture size as 16x16 - ExpandPictureChroma_c (pPicCb, pPic->iLineSize[1], kiWidthUV, kiHeightUV); - ExpandPictureChroma_c (pPicCr, pPic->iLineSize[2], kiWidthUV, kiHeightUV); + ExpandPictureChroma_c (pPicCb, iStride[1], kiWidthUV, kiHeightUV); + ExpandPictureChroma_c (pPicCr, iStride[2], kiWidthUV, kiHeightUV); } -} + } diff --git a/codec/common/targets.mk b/codec/common/targets.mk index 631786e8..1b73ced1 100644 --- a/codec/common/targets.mk +++ b/codec/common/targets.mk @@ -4,6 +4,7 @@ COMMON_CPP_SRCS=\ $(COMMON_SRCDIR)/src/cpu.cpp\ $(COMMON_SRCDIR)/src/crt_util_safe_x.cpp\ $(COMMON_SRCDIR)/src/deblocking_common.cpp\ + $(COMMON_SRCDIR)/src/expand_pic.cpp\ $(COMMON_SRCDIR)/src/logging.cpp\ $(COMMON_SRCDIR)/src/sad_common.cpp\ $(COMMON_SRCDIR)/src/WelsThreadLib.cpp\ diff --git a/codec/decoder/core/inc/decoder_context.h b/codec/decoder/core/inc/decoder_context.h index 28576eaf..53570ae8 100644 --- a/codec/decoder/core/inc/decoder_context.h +++ b/codec/decoder/core/inc/decoder_context.h @@ -53,6 +53,7 @@ #include "as264_common.h" // for LONG_TERM_REF macro,can be delete if not need this macro #include "crt_util_safe_x.h" #include "mb_cache.h" +#include "expand_pic.h" namespace WelsDec { @@ -151,11 +152,6 @@ typedef int32_t (*PWelsParseIntra4x4ModeFunc) (PNeighAvail pNeighAvail, int8_t* PDqLayer pCurDqLayer); typedef int32_t (*PWelsParseIntra16x16ModeFunc) (PNeighAvail pNeighAvail, PBitStringAux pBs, PDqLayer pCurDqLayer); -typedef struct TagExpandPicFunc { - PExpandPictureFunc pExpandLumaPicture; - PExpandPictureFunc pExpandChromaPicture[2]; -} SExpandPicFunc; - enum { OVERWRITE_NONE = 0, OVERWRITE_PPS = 1, diff --git a/codec/decoder/core/inc/expand_pic.h b/codec/decoder/core/inc/expand_pic.h deleted file mode 100644 index a772ca89..00000000 --- a/codec/decoder/core/inc/expand_pic.h +++ /dev/null @@ -1,57 +0,0 @@ -/*! - * \copy - * Copyright (c) 2009-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. - * - * - * \file expand_pic.h - * - * \brief Interface for expanding reconstructed picture to be used for reference - * - * \date 06/08/2009 Created - ************************************************************************************* - */ - -#ifndef WELS_EXPAND_PIC_H__ -#define WELS_EXPAND_PIC_H__ - -#include "decoder_context.h" -#include "picture.h" - -#include "expand_picture_common.h" - -namespace WelsDec { - -void ExpandReferencingPicture (PPicture pPic, PExpandPictureFunc pExpandPictureLuma, - PExpandPictureFunc pExpandPictureChroma[2]); - -void InitExpandPictureFunc (SExpandPicFunc* pExpandPicFunc, const uint32_t kuiCpuFlags); - -} // namespace WelsDec - -#endif//WELS_EXPAND_PIC_H__ diff --git a/codec/decoder/core/inc/wels_const.h b/codec/decoder/core/inc/wels_const.h index 0d2fc590..a6177fbd 100644 --- a/codec/decoder/core/inc/wels_const.h +++ b/codec/decoder/core/inc/wels_const.h @@ -81,7 +81,6 @@ #define ALIGN_RBSP_LEN_FIX 4 -#define PADDING_LENGTH 32 // reference extension #define BASE_QUALITY_ID 0 //#define BASE_DEPENDENCY_ID 0 diff --git a/codec/decoder/core/src/decoder_core.cpp b/codec/decoder/core/src/decoder_core.cpp index a0c6a6d8..83b10164 100644 --- a/codec/decoder/core/src/decoder_core.cpp +++ b/codec/decoder/core/src/decoder_core.cpp @@ -1919,8 +1919,9 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 return iRet; } } - ExpandReferencingPicture (pCtx->pDec, pCtx->sExpandPicFunc.pExpandLumaPicture, - pCtx->sExpandPicFunc.pExpandChromaPicture); + ExpandReferencingPicture (pCtx->pDec->pData, pCtx->pDec->iWidthInPixel, pCtx->pDec->iHeightInPixel, + pCtx->pDec->iLinesize, + pCtx->sExpandPicFunc.pfExpandLumaPicture, pCtx->sExpandPicFunc.pfExpandChromaPicture); pCtx->pDec = NULL; } } diff --git a/codec/decoder/core/src/error_concealment.cpp b/codec/decoder/core/src/error_concealment.cpp index 6aef529f..ee8a030a 100644 --- a/codec/decoder/core/src/error_concealment.cpp +++ b/codec/decoder/core/src/error_concealment.cpp @@ -149,8 +149,9 @@ int32_t MarkECFrameAsRef (PWelsDecoderContext pCtx) { pCtx->pDec = NULL; return iRet; } - ExpandReferencingPicture (pCtx->pDec, pCtx->sExpandPicFunc.pExpandLumaPicture, - pCtx->sExpandPicFunc.pExpandChromaPicture); + ExpandReferencingPicture (pCtx->pDec->pData, pCtx->pDec->iWidthInPixel, pCtx->pDec->iHeightInPixel, + pCtx->pDec->iLinesize, + pCtx->sExpandPicFunc.pfExpandLumaPicture, pCtx->sExpandPicFunc.pfExpandChromaPicture); pCtx->pDec = NULL; return ERR_NONE; diff --git a/codec/decoder/core/src/expand_pic.cpp b/codec/decoder/core/src/expand_pic.cpp deleted file mode 100644 index 80f85d4c..00000000 --- a/codec/decoder/core/src/expand_pic.cpp +++ /dev/null @@ -1,171 +0,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. - * - */ - - -#include "expand_pic.h" -#include "cpu_core.h" - -namespace WelsDec { - -// rewrite it (split into luma & chroma) that is helpful for mmx/sse2 optimization perform, 9/27/2009 -static inline void ExpandPictureLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicWidth, - const int32_t kiPicHeight) { - uint8_t* pTmp = pDst; - uint8_t* pDstLastLine = pTmp + (kiPicHeight - 1) * kiStride; - const int32_t kiPaddingLen = PADDING_LENGTH; - const uint8_t kuiTopLeft = pTmp[0]; - const uint8_t kuiTopRight = pTmp[kiPicWidth - 1]; - const uint8_t kuiBottomLeft = pDstLastLine[0]; - const uint8_t kuiBottomRight = pDstLastLine[kiPicWidth - 1]; - int32_t i = 0; - - do { - const int32_t kiStrides = (1 + i) * kiStride; - uint8_t* pTop = pTmp - kiStrides; - uint8_t* pBottom = pDstLastLine + kiStrides; - - // pad pTop and pBottom - memcpy (pTop, pTmp, kiPicWidth); - memcpy (pBottom, pDstLastLine, kiPicWidth); - - // pad corners - memset (pTop - kiPaddingLen, kuiTopLeft, kiPaddingLen); //pTop left - memset (pTop + kiPicWidth, kuiTopRight, kiPaddingLen); //pTop right - memset (pBottom - kiPaddingLen, kuiBottomLeft, kiPaddingLen); //pBottom left - memset (pBottom + kiPicWidth, kuiBottomRight, kiPaddingLen); //pBottom right - - ++ i; - } while (i < kiPaddingLen); - - // pad left and right - i = 0; - do { - memset (pTmp - kiPaddingLen, pTmp[0], kiPaddingLen); - memset (pTmp + kiPicWidth, pTmp[kiPicWidth - 1], kiPaddingLen); - - pTmp += kiStride; - ++ i; - } while (i < kiPicHeight); -} - -static inline void ExpandPictureChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicWidth, - const int32_t kiPicHeight) { - uint8_t* pTmp = pDst; - uint8_t* pDstLastLine = pTmp + (kiPicHeight - 1) * kiStride; - const int32_t kiPaddingLen = (PADDING_LENGTH >> 1); - const uint8_t kuiTopLeft = pTmp[0]; - const uint8_t kuiTopRight = pTmp[kiPicWidth - 1]; - const uint8_t kuiBottomLeft = pDstLastLine[0]; - const uint8_t kuiBottomRight = pDstLastLine[kiPicWidth - 1]; - int32_t i = 0; - - do { - const int32_t kiStrides = (1 + i) * kiStride; - uint8_t* pTop = pTmp - kiStrides; - uint8_t* pBottom = pDstLastLine + kiStrides; - - // pad pTop and pBottom - memcpy (pTop, pTmp, kiPicWidth); - memcpy (pBottom, pDstLastLine, kiPicWidth); - - // pad corners - memset (pTop - kiPaddingLen, kuiTopLeft, kiPaddingLen); //pTop left - memset (pTop + kiPicWidth, kuiTopRight, kiPaddingLen); //pTop right - memset (pBottom - kiPaddingLen, kuiBottomLeft, kiPaddingLen); //pBottom left - memset (pBottom + kiPicWidth, kuiBottomRight, kiPaddingLen); //pBottom right - - ++ i; - } while (i < kiPaddingLen); - - // pad left and right - i = 0; - do { - memset (pTmp - kiPaddingLen, pTmp[0], kiPaddingLen); - memset (pTmp + kiPicWidth, pTmp[kiPicWidth - 1], kiPaddingLen); - - pTmp += kiStride; - ++ i; - } while (i < kiPicHeight); -} - -void InitExpandPictureFunc (SExpandPicFunc* pExpandPicFunc, const uint32_t kuiCpuFlags) { - pExpandPicFunc->pExpandLumaPicture = ExpandPictureLuma_c; - pExpandPicFunc->pExpandChromaPicture[0] = ExpandPictureChroma_c; - pExpandPicFunc->pExpandChromaPicture[1] = ExpandPictureChroma_c; - -#if defined(X86_ASM) - if ((kuiCpuFlags & WELS_CPU_SSE2) == WELS_CPU_SSE2) { - pExpandPicFunc->pExpandLumaPicture = ExpandPictureLuma_sse2; - pExpandPicFunc->pExpandChromaPicture[0] = ExpandPictureChromaUnalign_sse2; - pExpandPicFunc->pExpandChromaPicture[1] = ExpandPictureChromaAlign_sse2; - } -#endif//X86_ASM -#if defined(HAVE_NEON) - if ((kuiCpuFlags & WELS_CPU_NEON) == WELS_CPU_NEON) { - pExpandPicFunc->pExpandLumaPicture = ExpandPictureLuma_neon; - pExpandPicFunc->pExpandChromaPicture[0] = ExpandPictureChroma_neon; - pExpandPicFunc->pExpandChromaPicture[1] = ExpandPictureChroma_neon; - } -#endif//HAVE_NEON -#if defined(HAVE_NEON_AARCH64) - if ((kuiCpuFlags & WELS_CPU_NEON) == WELS_CPU_NEON) { - pExpandPicFunc->pExpandLumaPicture = ExpandPictureLuma_AArch64_neon; - pExpandPicFunc->pExpandChromaPicture[0] = ExpandPictureChroma_AArch64_neon; - pExpandPicFunc->pExpandChromaPicture[1] = ExpandPictureChroma_AArch64_neon; - } -#endif//HAVE_NEON_AARCH64 -} - -void ExpandReferencingPicture (PPicture pPic, PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChroma[2]) { - /*local variable*/ - uint8_t* pPicY = pPic->pData[0]; - uint8_t* pPicCb = pPic->pData[1]; - uint8_t* pPicCr = pPic->pData[2]; - const int32_t kiWidthY = pPic->iWidthInPixel; - const int32_t kiHeightY = pPic->iHeightInPixel; - const int32_t kiWidthUV = kiWidthY >> 1; - const int32_t kiHeightUV = kiHeightY >> 1; - - pExpLuma (pPicY, pPic->iLinesize[0], kiWidthY, kiHeightY); - if (kiWidthUV >= 16) { - // fix coding picture size as 16x16 issues 7/27/2010 - const bool kbChrAligned = /*(kiWidthUV >= 16) && */ ((kiWidthUV & 0x0F) == 0); // chroma planes: (16+kiWidthUV) & 15 - pExpChroma[kbChrAligned] (pPicCb, pPic->iLinesize[1], kiWidthUV, kiHeightUV); - pExpChroma[kbChrAligned] (pPicCr, pPic->iLinesize[2], kiWidthUV, kiHeightUV); - } else { - // fix coding picture size as 16x16 issues 7/27/2010 - ExpandPictureChroma_c (pPicCb, pPic->iLinesize[1], kiWidthUV, kiHeightUV); - ExpandPictureChroma_c (pPicCr, pPic->iLinesize[2], kiWidthUV, kiHeightUV); - } -} - -} // namespace WelsDec diff --git a/codec/decoder/targets.mk b/codec/decoder/targets.mk index 6998f4d6..ab1943f9 100644 --- a/codec/decoder/targets.mk +++ b/codec/decoder/targets.mk @@ -9,7 +9,6 @@ DECODER_CPP_SRCS=\ $(DECODER_SRCDIR)/core/src/decoder_core.cpp\ $(DECODER_SRCDIR)/core/src/decoder_data_tables.cpp\ $(DECODER_SRCDIR)/core/src/error_concealment.cpp\ - $(DECODER_SRCDIR)/core/src/expand_pic.cpp\ $(DECODER_SRCDIR)/core/src/fmo.cpp\ $(DECODER_SRCDIR)/core/src/get_intra_predictor.cpp\ $(DECODER_SRCDIR)/core/src/manage_dec_ref.cpp\ diff --git a/codec/encoder/core/inc/expand_pic.h b/codec/encoder/core/inc/expand_pic.h deleted file mode 100644 index e5774241..00000000 --- a/codec/encoder/core/inc/expand_pic.h +++ /dev/null @@ -1,55 +0,0 @@ -/*! - * \copy - * Copyright (c) 2009-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. - * - * - * \file expand_pic.h - * - * \brief Interface for expanding reconstructed picture to be used for reference - * - * \date 06/08/2009 - ************************************************************************************* - */ - -#ifndef EXPAND_PIC_H -#define EXPAND_PIC_H - -#include "typedefs.h" -#include "picture.h" - -#include "expand_picture_common.h" - -namespace WelsSVCEnc { -typedef void (*PExpandPictureFunc) (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, const int32_t kiPicH); - -void ExpandReferencingPicture (SPicture* pPic, PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChrom[2]); - -void InitExpandPictureFunc (void* pL, const uint32_t kuiCPUFlags); -} -#endif diff --git a/codec/encoder/core/inc/wels_const.h b/codec/encoder/core/inc/wels_const.h index 73c55cda..995d95d2 100644 --- a/codec/encoder/core/inc/wels_const.h +++ b/codec/encoder/core/inc/wels_const.h @@ -103,7 +103,7 @@ #define ALIGN_RBSP_LEN_FIX 4 -#define PADDING_LENGTH 32 // reference extension + #define INTPEL_NEEDED_MARGIN (3) // for safe sub-pel MC #define I420_PLANES 3 diff --git a/codec/encoder/core/inc/wels_func_ptr_def.h b/codec/encoder/core/inc/wels_func_ptr_def.h index dc4582a0..3b56860d 100644 --- a/codec/encoder/core/inc/wels_func_ptr_def.h +++ b/codec/encoder/core/inc/wels_func_ptr_def.h @@ -192,10 +192,7 @@ typedef void (*PMarkPicFunc) (void* pCtx); typedef bool (*PUpdateRefListFunc) (void* pCtx); struct TagWelsFuncPointerList { - PExpandPictureFunc pfExpandLumaPicture; - PExpandPictureFunc - pfExpandChromaPicture[2];// 0: for chroma unalignment && width_uv >= 16; 1: for chroma alignment && width_uv >= 16; - + SExpandPicFunc sExpandPicFunc; PFillInterNeighborCacheFunc pfFillInterNeighborCache; PGetVarianceFromIntraVaaFunc pfGetVarianceFromIntraVaa; diff --git a/codec/encoder/core/src/encoder.cpp b/codec/encoder/core/src/encoder.cpp index bfa587ff..3631bd09 100644 --- a/codec/encoder/core/src/encoder.cpp +++ b/codec/encoder/core/src/encoder.cpp @@ -178,7 +178,7 @@ int32_t InitFunctionPointers (SWelsFuncPtrList* pFuncList, SWelsSvcCodingParam* } #endif - InitExpandPictureFunc (pFuncList, uiCpuFlag); + InitExpandPictureFunc (& (pFuncList->sExpandPicFunc), uiCpuFlag); /* Intra_Prediction_fn*/ WelsInitFillingPredFuncs (uiCpuFlag); diff --git a/codec/encoder/core/src/ref_list_mgr_svc.cpp b/codec/encoder/core/src/ref_list_mgr_svc.cpp index e21ccb58..04c2a209 100644 --- a/codec/encoder/core/src/ref_list_mgr_svc.cpp +++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp @@ -378,7 +378,9 @@ bool WelsUpdateRefList (void* pEncCtx) { if ((pParamD->iHighestTemporalId == 0) || (kuiTid < pParamD->iHighestTemporalId)) #endif// !ENABLE_FRAME_DUMP // Expanding picture for future reference - ExpandReferencingPicture (pCtx->pDecPic, pCtx->pFuncList->pfExpandLumaPicture, pCtx->pFuncList->pfExpandChromaPicture); + ExpandReferencingPicture (pCtx->pDecPic->pData, pCtx->pDecPic->iWidthInPixel, pCtx->pDecPic->iHeightInPixel, + pCtx->pDecPic->iLineSize, + pCtx->pFuncList->sExpandPicFunc.pfExpandLumaPicture, pCtx->pFuncList->sExpandPicFunc.pfExpandChromaPicture); // move picture in list pCtx->pDecPic->uiTemporalId = kuiTid; @@ -720,7 +722,9 @@ bool WelsUpdateRefListScreen (void* pEncCtx) { if ((pParamD->iHighestTemporalId == 0) || (kuiTid < pParamD->iHighestTemporalId)) #endif// !ENABLE_FRAME_DUMP // Expanding picture for future reference - ExpandReferencingPicture (pCtx->pDecPic, pCtx->pFuncList->pfExpandLumaPicture, pCtx->pFuncList->pfExpandChromaPicture); + ExpandReferencingPicture (pCtx->pDecPic->pData, pCtx->pDecPic->iWidthInPixel, pCtx->pDecPic->iHeightInPixel, + pCtx->pDecPic->iLineSize, + pCtx->pFuncList->sExpandPicFunc.pfExpandLumaPicture, pCtx->pFuncList->sExpandPicFunc.pfExpandChromaPicture); // move picture in list pCtx->pDecPic->uiTemporalId = pCtx->uiTemporalId; diff --git a/codec/encoder/targets.mk b/codec/encoder/targets.mk index 90db5da6..e65a591e 100644 --- a/codec/encoder/targets.mk +++ b/codec/encoder/targets.mk @@ -7,7 +7,6 @@ ENCODER_CPP_SRCS=\ $(ENCODER_SRCDIR)/core/src/encoder.cpp\ $(ENCODER_SRCDIR)/core/src/encoder_data_tables.cpp\ $(ENCODER_SRCDIR)/core/src/encoder_ext.cpp\ - $(ENCODER_SRCDIR)/core/src/expand_pic.cpp\ $(ENCODER_SRCDIR)/core/src/get_intra_predictor.cpp\ $(ENCODER_SRCDIR)/core/src/mc.cpp\ $(ENCODER_SRCDIR)/core/src/md.cpp\ diff --git a/test/decoder/DecUT_ExpandPicture.cpp b/test/decoder/DecUT_ExpandPicture.cpp index cdd0abe2..f947a31d 100644 --- a/test/decoder/DecUT_ExpandPicture.cpp +++ b/test/decoder/DecUT_ExpandPicture.cpp @@ -2,6 +2,7 @@ #include "codec_def.h" #include "expand_pic.h" #include "mem_align.h" +#include "decoder_context.h" using namespace WelsDec; #define EXPAND_PIC_TEST_NUM 10 namespace WelsDec { @@ -120,7 +121,7 @@ TEST (ExpandPicture, ExpandPictureLuma) { } } H264ExpandPictureLumaAnchor_c (pAnchorDst, iStride, iPicWidth, iPicHeight); - sExpandPicFunc.pExpandLumaPicture (pTestDst, iStride, iPicWidth, iPicHeight); + sExpandPicFunc.pfExpandLumaPicture (pTestDst, iStride, iPicWidth, iPicHeight); EXPECT_EQ (CompareBuff (pAnchorDstBuff, pTestDstBuff, iStride, iPicWidth + H264_PADDING_LENGTH_LUMA * 2, iPicHeight + H264_PADDING_LENGTH_LUMA * 2), true); @@ -155,7 +156,7 @@ TEST (ExpandPicture, ExpandPictureChroma) { } } H264ExpandPictureChromaAnchor_c (pAnchorDst, iStride, iPicWidth, iPicHeight); - sExpandPicFunc.pExpandChromaPicture[0] (pTestDst, iStride, iPicWidth, iPicHeight); + sExpandPicFunc.pfExpandChromaPicture[0] (pTestDst, iStride, iPicWidth, iPicHeight); EXPECT_EQ (CompareBuff (pAnchorDstBuff, pTestDstBuff, iStride, iPicWidth + H264_PADDING_LENGTH_CHROMA * 2, iPicHeight + H264_PADDING_LENGTH_CHROMA * 2), true); @@ -199,7 +200,8 @@ TEST (ExpandPicture, ExpandPicForMotion) { H264ExpandPictureLumaAnchor_c (pPicAnchor->pData[0], iStride, iPicWidth, iPicHeight); H264ExpandPictureChromaAnchor_c (pPicAnchor->pData[1], iStrideC, iPicWidth / 2, iPicHeight / 2); H264ExpandPictureChromaAnchor_c (pPicAnchor->pData[2], iStrideC, iPicWidth / 2, iPicHeight / 2); - ExpandReferencingPicture (sCtx.pDec, sExpandPicFunc.pExpandLumaPicture, sExpandPicFunc.pExpandChromaPicture); + ExpandReferencingPicture (sCtx.pDec->pData, sCtx.pDec->iWidthInPixel, sCtx.pDec->iHeightInPixel, sCtx.pDec->iLinesize, + sExpandPicFunc.pfExpandLumaPicture, sExpandPicFunc.pfExpandChromaPicture); EXPECT_EQ (CompareBuff (pPicAnchor->pBuffer[0], pPicTest->pBuffer[0], iStride, iPicWidth + PADDING_LENGTH * 2, iPicHeight + PADDING_LENGTH * 2), true); diff --git a/test/encoder/EncUT_ExpandPic.cpp b/test/encoder/EncUT_ExpandPic.cpp index a3b1fe04..5da93ecd 100644 --- a/test/encoder/EncUT_ExpandPic.cpp +++ b/test/encoder/EncUT_ExpandPic.cpp @@ -6,59 +6,59 @@ using namespace WelsSVCEnc; -TEST(ExpandPicTest, TestExpandPictureLuma_c) { +TEST (ExpandPicTest, TestExpandPictureLuma_c) { SWelsFuncPtrList sFuncList; - InitExpandPictureFunc( &sFuncList, 0 ); + InitExpandPictureFunc (& (sFuncList.sExpandPicFunc), 0); - int32_t iPicW = rand()%256 + 1; - int32_t iPicH = rand()%256 + 1; - int32_t iStride = iPicW + rand()%16 + 1 + PADDING_LENGTH * 2; + int32_t iPicW = rand() % 256 + 1; + int32_t iPicH = rand() % 256 + 1; + int32_t iStride = iPicW + rand() % 16 + 1 + PADDING_LENGTH * 2; const int32_t kiPaddingLen = PADDING_LENGTH; - const int32_t kiMemSize = (iStride+kiPaddingLen*2) * (iPicH+kiPaddingLen*2); + const int32_t kiMemSize = (iStride + kiPaddingLen * 2) * (iPicH + kiPaddingLen * 2); - uint8_t *pRef = new uint8_t[kiMemSize]; + uint8_t* pRef = new uint8_t[kiMemSize]; - for(int i=0; i= iPicW+kiPaddingLen) { - EXPECT_EQ(pRef[k+j],pDst[iPicW-1]); + EXPECT_EQ (pRef[k + j], pDst[0]); + } else if (j >= iPicW + kiPaddingLen) { + EXPECT_EQ (pRef[k + j], pDst[iPicW - 1]); } else - EXPECT_EQ(pRef[k+j],pDst[j-kiPaddingLen]); + EXPECT_EQ (pRef[k + j], pDst[j - kiPaddingLen]); } k += iStride; } k = (iPicH + kiPaddingLen - 1) * iStride; //bottom and bottom corner - for (int i=iPicH+kiPaddingLen; i= iPicW+kiPaddingLen) { - EXPECT_EQ(pRef[k+j],pDst[(iPicH-1) * iStride+iPicW-1]); + EXPECT_EQ (pRef[k + j], pDst[ (iPicH - 1) * iStride]); + } else if (j >= iPicW + kiPaddingLen) { + EXPECT_EQ (pRef[k + j], pDst[ (iPicH - 1) * iStride + iPicW - 1]); } else - EXPECT_EQ(pRef[k+j],pDst[(iPicH-1) * iStride+j-kiPaddingLen]); + EXPECT_EQ (pRef[k + j], pDst[ (iPicH - 1) * iStride + j - kiPaddingLen]); } k += iStride; } k = kiPaddingLen * iStride; int l = 0; - for (int i=0; i>1); - int32_t iStride = iPicW + rand()%16 + 1 + kiPaddingLen*2; + const int32_t kiPaddingLen = (PADDING_LENGTH >> 1); + int32_t iStride = iPicW + rand() % 16 + 1 + kiPaddingLen * 2; - const int32_t kiMemSize = (iStride+kiPaddingLen*2) * (iPicH+kiPaddingLen*2); + const int32_t kiMemSize = (iStride + kiPaddingLen * 2) * (iPicH + kiPaddingLen * 2); - uint8_t *pRef = new uint8_t[kiMemSize]; + uint8_t* pRef = new uint8_t[kiMemSize]; - for (int i=0; i= iPicW+kiPaddingLen) { - EXPECT_EQ(pRef[k+j],pDst[iPicW-1]); + EXPECT_EQ (pRef[k + j], pDst[0]); + } else if (j >= iPicW + kiPaddingLen) { + EXPECT_EQ (pRef[k + j], pDst[iPicW - 1]); } else - EXPECT_EQ(pRef[k+j],pDst[j-kiPaddingLen]); + EXPECT_EQ (pRef[k + j], pDst[j - kiPaddingLen]); } k += iStride; } k = (iPicH + kiPaddingLen - 1) * iStride; //bottom and bottom corner - for (int i=iPicH+kiPaddingLen; i= iPicW+kiPaddingLen) { - EXPECT_EQ(pRef[k+j],pDst[(iPicH-1) * iStride + iPicW - 1]); + EXPECT_EQ (pRef[k + j], pDst[ (iPicH - 1) * iStride]); + } else if (j >= iPicW + kiPaddingLen) { + EXPECT_EQ (pRef[k + j], pDst[ (iPicH - 1) * iStride + iPicW - 1]); } else - EXPECT_EQ(pRef[k+j],pDst[(iPicH-1) * iStride + j - kiPaddingLen]); + EXPECT_EQ (pRef[k + j], pDst[ (iPicH - 1) * iStride + j - kiPaddingLen]); } k += iStride; } k = kiPaddingLen * iStride; - int l=0; - for (int i=0; i