Revert "fix libmix encoder klockwork issues, rename IntelMetadatabuffer APIs"
BZ: 50965
This reverts commit fefa62b938fb4764d49345f509f8718cd6a2a269.
The reason is wrong BZ number
Change-Id: I8938b2ad89d1b770a91387a919210b5d32eee8b8
Signed-off-by: Zhao Liang <leo.zhao@intel.com>
Reviewed-on: http://android.intel.com:8080/62247
Reviewed-by: Ding, Haitao <haitao.ding@intel.com>
Tested-by: Ding, Haitao <haitao.ding@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
diff --git a/test/btest.cpp b/test/btest.cpp
index 13b790b..26f104f 100644
--- a/test/btest.cpp
+++ b/test/btest.cpp
@@ -37,7 +37,7 @@
ret = mb1->SetValueInfo(&vi1);
ret = mb1->SetExtraValues(ev1, 10);
}
- ret = mb1->Serialize(bytes, size);
+ ret = mb1->GetBytes(bytes, size);
printf("assembling IntelMetadataBuffer %s, ret = %d\n", (ret == IMB_SUCCESS)?"Success":"Fail", ret );
printf("size = %d, bytes = ", size);
@@ -48,7 +48,7 @@
printf("\n");
mb2 = new IntelMetadataBuffer();
- ret = mb2->UnSerialize(bytes, size);
+ ret = mb2->SetBytes(bytes, size);
printf("parsing IntelMetadataBuffer %s, ret = %d\n", (ret == IMB_SUCCESS)?"Success":"Fail", ret );
ret = mb2->GetType(t2);
diff --git a/test/mix_encoder.cpp b/test/mix_encoder.cpp
index d4b88c0..38fbc00 100644
--- a/test/mix_encoder.cpp
+++ b/test/mix_encoder.cpp
@@ -697,7 +697,7 @@
{
if (gMode != 4)
{
- gIMB[i % gSrcFrames]->Serialize(data, size);
+ gIMB[i % gSrcFrames]->GetBytes(data, size);
// printf("srcno =%d, data=%x, size=%d\n", i % gSrcFrames, data, size);
}else
{
@@ -729,10 +729,11 @@
stat.total_frames, stat.skipped_frames, stat.average_encode_time, stat.max_encode_time, stat.max_encode_frame, \
stat.min_encode_time, stat.min_encode_frame );
}
+ if(gVideoEncoder) {
+ releaseVideoEncoder(gVideoEncoder);
+ gVideoEncoder = NULL;
+ }
- gVideoEncoder->stop();
- releaseVideoEncoder(gVideoEncoder);
- gVideoEncoder = NULL;
switch(gMode)
{
diff --git a/videoencoder/IntelMetadataBuffer.cpp b/videoencoder/IntelMetadataBuffer.cpp
index eb9fe43..531d0ca 100644
--- a/videoencoder/IntelMetadataBuffer.cpp
+++ b/videoencoder/IntelMetadataBuffer.cpp
@@ -60,55 +60,6 @@
delete[] mBytes;
}
-
-IntelMetadataBuffer::IntelMetadataBuffer(const IntelMetadataBuffer& imb)
- :mType(imb.mType), mValue(imb.mValue), mInfo(NULL), mExtraValues(NULL),
- mExtraValues_Count(imb.mExtraValues_Count), mBytes(NULL), mSize(imb.mSize)
-{
- if (imb.mInfo)
- mInfo = new ValueInfo(*imb.mInfo);
-
- if (imb.mExtraValues)
- {
- mExtraValues = new int32_t[mExtraValues_Count];
- memcpy(mExtraValues, imb.mExtraValues, 4 * mExtraValues_Count);
- }
-
- if (imb.mBytes)
- {
- mBytes = new uint8_t[mSize];
- memcpy(mBytes, imb.mBytes, mSize);
- }
-}
-
-const IntelMetadataBuffer& IntelMetadataBuffer::operator=(const IntelMetadataBuffer& imb)
-{
- mType = imb.mType;
- mValue = imb.mValue;
- mInfo = NULL;
- mExtraValues = NULL;
- mExtraValues_Count = imb.mExtraValues_Count;
- mBytes = NULL;
- mSize = imb.mSize;
-
- if (imb.mInfo)
- mInfo = new ValueInfo(*imb.mInfo);
-
- if (imb.mExtraValues)
- {
- mExtraValues = new int32_t[mExtraValues_Count];
- memcpy(mExtraValues, imb.mExtraValues, 4 * mExtraValues_Count);
- }
-
- if (imb.mBytes)
- {
- mBytes = new uint8_t[mSize];
- memcpy(mBytes, imb.mBytes, mSize);
- }
-
- return *this;
-}
-
IMB_Result IntelMetadataBuffer::GetType(MetadataBufferType& type)
{
type = mType;
@@ -192,7 +143,7 @@
return IMB_SUCCESS;
}
-IMB_Result IntelMetadataBuffer::UnSerialize(uint8_t* data, uint32_t size)
+IMB_Result IntelMetadataBuffer::SetBytes(uint8_t* data, uint32_t size)
{
if (!data || size == 0)
return IMB_INVAL_PARAM;
@@ -263,12 +214,7 @@
return IMB_SUCCESS;
}
-IMB_Result IntelMetadataBuffer::SetBytes(uint8_t* data, uint32_t size)
-{
- return UnSerialize(data, size);
-}
-
-IMB_Result IntelMetadataBuffer::Serialize(uint8_t* &data, uint32_t& size)
+IMB_Result IntelMetadataBuffer::GetBytes(uint8_t* &data, uint32_t& size)
{
if (mBytes == NULL)
{
@@ -307,11 +253,6 @@
return IMB_SUCCESS;
}
-IMB_Result IntelMetadataBuffer::GetBytes(uint8_t* &data, uint32_t& size)
-{
- return Serialize(data, size);
-}
-
uint32_t IntelMetadataBuffer::GetMaxBufferSize()
{
return 256;
diff --git a/videoencoder/IntelMetadataBuffer.h b/videoencoder/IntelMetadataBuffer.h
index 2eacc5f..802ef7b 100644
--- a/videoencoder/IntelMetadataBuffer.h
+++ b/videoencoder/IntelMetadataBuffer.h
@@ -72,9 +72,6 @@
IntelMetadataBuffer(MetadataBufferType type, int32_t value); //for quick generator
~IntelMetadataBuffer();
- IntelMetadataBuffer(const IntelMetadataBuffer& imb);
- const IntelMetadataBuffer& operator=(const IntelMetadataBuffer& imb);
-
IMB_Result GetType(MetadataBufferType &type);
IMB_Result SetType(MetadataBufferType type);
IMB_Result GetValue(int32_t &value);
@@ -84,14 +81,11 @@
IMB_Result GetExtraValues(int32_t* &values, uint32_t &num);
IMB_Result SetExtraValues(int32_t *values, uint32_t num);
- //for bytes input, also for parser, will be obsoleted
+ //for bytes input, also for parser
IMB_Result SetBytes(uint8_t* data, uint32_t size);
- //for bytes output, also for generator, will be obsoleted
- IMB_Result GetBytes(uint8_t* &data, uint32_t& size);
- //New API for bytes input/ouput, UnSerialize=SetBytes, Serialize=GetBytes
- IMB_Result UnSerialize(uint8_t* data, uint32_t size);
- IMB_Result Serialize(uint8_t* &data, uint32_t& size);
+ //for bytes output, also for generator
+ IMB_Result GetBytes(uint8_t* &data, uint32_t& size);
//Static, for get max IntelMetadataBuffer size
static uint32_t GetMaxBufferSize();
diff --git a/videoencoder/VideoEncoderAVC.cpp b/videoencoder/VideoEncoderAVC.cpp
index 738eefa..5922e6a 100644
--- a/videoencoder/VideoEncoderAVC.cpp
+++ b/videoencoder/VideoEncoderAVC.cpp
@@ -197,6 +197,9 @@
Encode_Status ret = ENCODE_SUCCESS;
VAStatus vaStatus = VA_STATUS_SUCCESS;
bool useLocalBuffer = false;
+ uint32_t nalType = 0;
+ uint32_t nalSize = 0;
+ uint32_t nalOffset = 0;
uint32_t idrPeroid = mComParams.intraPeriod * mVideoParamsAVC.idrInterval;
LOG_V("Begin\n");
@@ -280,6 +283,8 @@
uint32_t *nalType, uint32_t *nalOffset, uint32_t status) {
uint32_t pos = 0;
uint32_t zeroByteCount = 0;
+ uint32_t prefixLength = 0;
+ uint32_t leadingZeroCnt = 0;
uint32_t singleByteTable[3][2] = {{1,0},{2,0},{2,3}};
uint32_t dataRemaining = 0;
uint8_t *dataPtr;
@@ -515,6 +520,7 @@
uint32_t nalSize = 0;
uint32_t nalOffset = 0;
uint32_t sizeCopiedHere = 0;
+ uint32_t sizeToBeCopied = 0;
CHECK_NULL_RETURN_IFFAIL(mCurSegment->buf);
@@ -642,6 +648,7 @@
Encode_Status VideoEncoderAVC::renderMaxSliceSize() {
VAStatus vaStatus = VA_STATUS_SUCCESS;
+ Encode_Status ret = ENCODE_SUCCESS;
LOG_V( "Begin\n\n");
if (mComParams.rcMode != RATE_CONTROL_VCM) {
@@ -787,6 +794,12 @@
avcSeqParams.intra_idr_period = mVideoParamsAVC.idrInterval;
avcSeqParams.picture_width_in_mbs = (mComParams.resolution.width + 15) / 16;
avcSeqParams.picture_height_in_mbs = (mComParams.resolution.height + 15) / 16;
+ if((avcSeqParams.picture_width_in_mbs >=1920)|| (avcSeqParams.picture_height_in_mbs >=1080))
+ {
+ device_info = vaQueryVendorString(mVADisplay);
+ if(strstr(device_info, "LEXINGTON"))
+ return ENCODE_INVALID_PARAMS;
+ }
level = calcLevel (avcSeqParams.picture_width_in_mbs * avcSeqParams.picture_height_in_mbs);
avcSeqParams.level_idc = level;
@@ -900,6 +913,7 @@
VAStatus vaStatus = VA_STATUS_SUCCESS;
uint32_t sliceNum = 0;
+ uint32_t sliceHeight = 0;
uint32_t sliceIndex = 0;
uint32_t sliceHeightInMB = 0;
uint32_t maxSliceNum = 0;
diff --git a/videoencoder/VideoEncoderBase.cpp b/videoencoder/VideoEncoderBase.cpp
index 417aab0..ae29aef 100644
--- a/videoencoder/VideoEncoderBase.cpp
+++ b/videoencoder/VideoEncoderBase.cpp
@@ -657,6 +657,7 @@
Encode_Status VideoEncoderBase::prepareForOutput(
VideoEncOutputBuffer *outBuffer, bool *useLocalBuffer) {
+ Encode_Status ret = ENCODE_SUCCESS;
VAStatus vaStatus = VA_STATUS_SUCCESS;
VACodedBufferSegment *vaCodedSeg = NULL;
uint32_t status = 0;
@@ -740,6 +741,7 @@
Encode_Status VideoEncoderBase::cleanupForOutput() {
VAStatus vaStatus = VA_STATUS_SUCCESS;
+ Encode_Status ret = ENCODE_SUCCESS;
//mCurSegment is NULL means all data has been copied out
if (mCurSegment == NULL && mCodedBufferMapped) {
@@ -1739,23 +1741,25 @@
int32_t *extravalues = NULL;
unsigned int extravalues_count = 0;
- IntelMetadataBuffer imb;
+ IntelMetadataBuffer *imb = new IntelMetadataBuffer;
SurfaceMap *map = NULL;
if (mStoreMetaDataInBuffers.isEnabled) {
//metadatabuffer mode
LOG_I("in metadata mode, data=%p, size=%d\n", inBuffer->data, inBuffer->size);
- if (imb.UnSerialize(inBuffer->data, inBuffer->size) != IMB_SUCCESS) {
+ if (imb->SetBytes(inBuffer->data, inBuffer->size) != IMB_SUCCESS) {
//fail to parse buffer
+ delete imb;
return ENCODE_NO_REQUEST_DATA;
}
- imb.GetType(type);
- imb.GetValue(value);
+ imb->GetType(type);
+ imb->GetValue(value);
} else {
//raw mode
LOG_I("in raw mode, data=%p, size=%d\n", inBuffer->data, inBuffer->size);
if (! inBuffer->data || inBuffer->size == 0) {
+ delete imb;
return ENCODE_NULL_PTR;
}
@@ -1771,6 +1775,7 @@
LOG_I("direct find surface %d from value %x\n", map->surface, value);
mCurSurface = map->surface;
+ delete imb;
return ret;
}
@@ -1792,8 +1797,8 @@
vinfo.s3dformat = 0xFFFFFFFF;
} else {
//get all info mapping needs
- imb.GetValueInfo(pvinfo);
- imb.GetExtraValues(extravalues, extravalues_count);
+ imb->GetValueInfo(pvinfo);
+ imb->GetExtraValues(extravalues, extravalues_count);
}
} else {
@@ -1828,6 +1833,7 @@
mSrcSurfaceMapList = appendSurfaceMap(mSrcSurfaceMapList, map);
} else {
delete map;
+ delete imb;
LOG_E("surface mapping failed, wrong info or meet serious error\n");
return ret;
}
@@ -1836,6 +1842,7 @@
} else {
//can't map due to no info
+ delete imb;
LOG_E("surface mapping failed, missing information\n");
return ENCODE_NO_REQUEST_DATA;
}
@@ -1862,6 +1869,8 @@
}
}
+ delete imb;
+
return ret;
}
diff --git a/videoencoder/VideoEncoderH263.cpp b/videoencoder/VideoEncoderH263.cpp
index cbe1e09..68f8741 100644
--- a/videoencoder/VideoEncoderH263.cpp
+++ b/videoencoder/VideoEncoderH263.cpp
@@ -120,6 +120,7 @@
Encode_Status VideoEncoderH263::renderSliceParams() {
VAStatus vaStatus = VA_STATUS_SUCCESS;
+ uint32_t sliceNum;
uint32_t sliceHeight;
uint32_t sliceHeightInMB;
diff --git a/videoencoder/VideoEncoderMP4.cpp b/videoencoder/VideoEncoderMP4.cpp
index d93d774..51068f4 100644
--- a/videoencoder/VideoEncoderMP4.cpp
+++ b/videoencoder/VideoEncoderMP4.cpp
@@ -22,7 +22,9 @@
Encode_Status VideoEncoderMP4::getHeaderPos(
uint8_t *inBuffer, uint32_t bufSize, uint32_t *headerSize) {
+ uint8_t *buf = inBuffer;
uint32_t bytesLeft = bufSize;
+ Encode_Status ret = ENCODE_SUCCESS;
*headerSize = 0;
CHECK_NULL_RETURN_IFFAIL(inBuffer);