ref: 8935bfaa91c514b48e6f778b8bf4a0ed4c826107
parent: 81f7b0c10891ddb22f65c18601e28bbbdd278d25
parent: 6d4a62833102ba323e0b0ab2136484f0af9e557d
author: ruil2 <[email protected]>
date: Wed Aug 27 13:04:49 EDT 2014
Merge pull request #1308 from dongzha/ModifyEncOutput add crop output for encoder
--- a/codec/encoder/core/inc/encoder.h
+++ b/codec/encoder/core/inc/encoder.h
@@ -91,12 +91,12 @@
* \brief Dump reconstruction for dependency layer
*/
-extern "C" void DumpDependencyRec (SPicture* pSrcPic, const char* kpFileName, const int8_t kiDid, bool bAppend);
+extern "C" void DumpDependencyRec (SPicture* pSrcPic, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer);
/*!
* \brief Dump the reconstruction pictures
*/
-void DumpRecFrame (SPicture* pSrcPic, const char* kpFileName, bool bAppend);
+void DumpRecFrame (SPicture* pSrcPic, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer);
/*!
--- a/codec/encoder/core/src/encoder.cpp
+++ b/codec/encoder/core/src/encoder.cpp
@@ -363,10 +363,13 @@
* \brief Dump reconstruction for dependency layer
*/
-extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend) {
+extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer) {
WelsFileHandle* pDumpRecFile = NULL;
int32_t iWrittenSize = 0;
const char* openMode = bAppend ? "ab" : "wb";
+ SWelsSPS* pSpsTmp = (kiDid> BASE_DEPENDENCY_ID)? &(pDqLayer->sLayerInfo.pSubsetSpsP->pSps) : pDqLayer->sLayerInfo.pSpsP;
+ bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag;
+ SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop;
if (NULL == pCurPicture || NULL == kpFileName || kiDid >= MAX_DEPENDENCY_LAYER)
return;
@@ -385,13 +388,14 @@
int32_t i = 0;
int32_t j = 0;
const int32_t kiStrideY = pCurPicture->iLineSize[0];
- const int32_t kiLumaWidth = pCurPicture->iWidthInPixel;
- const int32_t kiLumaHeight = pCurPicture->iHeightInPixel;
+ const int32_t kiLumaWidth = bFrameCroppingFlag?(pCurPicture->iWidthInPixel-(( pFrameCrop->iCropLeft + pFrameCrop->iCropRight ) << 1 )) : pCurPicture->iWidthInPixel;
+ const int32_t kiLumaHeight = bFrameCroppingFlag?(pCurPicture->iHeightInPixel-(( pFrameCrop->iCropTop + pFrameCrop->iCropBottom ) << 1 )) : pCurPicture->iHeightInPixel;
const int32_t kiChromaWidth = kiLumaWidth >> 1;
const int32_t kiChromaHeight = kiLumaHeight >> 1;
-
+ uint8_t* pSrc = NULL;
+ pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * ( pFrameCrop->iCropTop << 1 ) + ( pFrameCrop->iCropLeft << 1 )) : pCurPicture->pData[0];
for (j = 0; j < kiLumaHeight; ++ j) {
- iWrittenSize = WelsFwrite (&pCurPicture->pData[0][j * kiStrideY], 1, kiLumaWidth, pDumpRecFile);
+ iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile);
assert (iWrittenSize == kiLumaWidth);
if (iWrittenSize < kiLumaWidth) {
assert (0); // make no sense for us if writing failed
@@ -401,8 +405,9 @@
}
for (i = 1; i < I420_PLANES; ++ i) {
const int32_t kiStrideUV = pCurPicture->iLineSize[i];
+ pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) : pCurPicture->pData[i];
for (j = 0; j < kiChromaHeight; ++ j) {
- iWrittenSize = WelsFwrite (&pCurPicture->pData[i][j * kiStrideUV], 1, kiChromaWidth, pDumpRecFile);
+ iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile);
assert (iWrittenSize == kiChromaWidth);
if (iWrittenSize < kiChromaWidth) {
assert (0); // make no sense for us if writing failed
@@ -420,8 +425,12 @@
* \brief Dump the reconstruction pictures
*/
-void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, bool bAppend) {
+void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer) {
WelsFileHandle* pDumpRecFile = NULL;
+ SWelsSPS* pSpsTmp = (kiDid> BASE_DEPENDENCY_ID)? &(pDqLayer->sLayerInfo.pSubsetSpsP->pSps) : pDqLayer->sLayerInfo.pSpsP;
+ bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag;
+ SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop;
+
int32_t iWrittenSize = 0;
const char* openMode = bAppend ? "ab" : "wb";
@@ -440,13 +449,14 @@
int32_t i = 0;
int32_t j = 0;
const int32_t kiStrideY = pCurPicture->iLineSize[0];
- const int32_t kiLumaWidth = pCurPicture->iWidthInPixel;
- const int32_t kiLumaHeight = pCurPicture->iHeightInPixel;
+ const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel-(( pFrameCrop->iCropLeft + pFrameCrop->iCropRight ) << 1 )) : pCurPicture->iWidthInPixel;
+ const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel-(( pFrameCrop->iCropTop + pFrameCrop->iCropBottom ) << 1 )) : pCurPicture->iHeightInPixel;
const int32_t kiChromaWidth = kiLumaWidth >> 1;
const int32_t kiChromaHeight = kiLumaHeight >> 1;
-
+ uint8_t* pSrc = NULL;
+ pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * ( pFrameCrop->iCropTop << 1 ) + ( pFrameCrop->iCropLeft << 1 )) : pCurPicture->pData[0];
for (j = 0; j < kiLumaHeight; ++ j) {
- iWrittenSize = WelsFwrite (&pCurPicture->pData[0][j * kiStrideY], 1, kiLumaWidth, pDumpRecFile);
+ iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile);
assert (iWrittenSize == kiLumaWidth);
if (iWrittenSize < kiLumaWidth) {
assert (0); // make no sense for us if writing failed
@@ -456,8 +466,9 @@
}
for (i = 1; i < I420_PLANES; ++ i) {
const int32_t kiStrideUV = pCurPicture->iLineSize[i];
+ pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) : pCurPicture->pData[i];
for (j = 0; j < kiChromaHeight; ++ j) {
- iWrittenSize = WelsFwrite (&pCurPicture->pData[i][j * kiStrideUV], 1, kiChromaWidth, pDumpRecFile);
+ iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile);
assert (iWrittenSize == kiChromaWidth);
if (iWrittenSize < kiChromaWidth) {
assert (0); // make no sense for us if writing failed
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3434,7 +3434,7 @@
#ifdef ENABLE_FRAME_DUMP
if (iCurDid + 1 < pSvcParam->iSpatialLayerNum) {
DumpDependencyRec (fsnr, &pSvcParam->sDependencyLayers[iCurDid].sRecFileName[0], iCurDid,
- pCtx->bDependencyRecFlag[iCurDid]);
+ pCtx->bDependencyRecFlag[iCurDid], pCtx->pCurDqLayer);
pCtx->bDependencyRecFlag[iCurDid] = true;
}
#endif//ENABLE_FRAME_DUMP
@@ -3601,8 +3601,7 @@
}
#ifdef ENABLE_FRAME_DUMP
- DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum - 1].sRecFileName[0],
- pCtx->bRecFlag); // pDecPic: final reconstruction output
+ DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum - 1].sRecFileName[0], pSvcParam->iSpatialLayerNum - 1, pCtx->bRecFlag, pCtx->pCurDqLayer); // pDecPic: final reconstruction output
pCtx->bRecFlag = true;
#endif//ENABLE_FRAME_DUMP