libmix: query decode hardware max resolution capability
BZ: 146858
query decode hardware max resolution capability for AVC/MPEG4/VC1/VP8
Change-Id: Iad7636eb02ed05854c62f113932ef4836f6a3f54
Signed-off-by: Gu, Wangyi <wangyi.gu@intel.com>
Signed-off-by: pingshix <pingx.shi@intel.com>
diff --git a/videodecoder/Android.mk b/videodecoder/Android.mk
index 7f3add5..243b49a 100644
--- a/videodecoder/Android.mk
+++ b/videodecoder/Android.mk
@@ -7,7 +7,6 @@
VideoDecoderWMV.cpp \
VideoDecoderMPEG4.cpp \
VideoDecoderAVC.cpp \
- VideoDecoderPAVC.cpp \
VideoDecoderTrace.cpp
# LOCAL_CFLAGS :=
diff --git a/videodecoder/VideoDecoderAVC.cpp b/videodecoder/VideoDecoderAVC.cpp
index 72131aa..d34965d 100644
--- a/videodecoder/VideoDecoderAVC.cpp
+++ b/videodecoder/VideoDecoderAVC.cpp
@@ -848,46 +848,20 @@
return maxDPBSize;
}
-#ifdef USE_AVC_SHORT_FORMAT
-Decode_Status VideoDecoderAVC::getCodecSpecificConfigs(
- VAProfile profile, VAConfigID *config)
-{
+Decode_Status VideoDecoderAVC::checkHardwareCapability(VAProfile profile) {
+#ifndef USE_GEN_HW
VAStatus vaStatus;
- VAConfigAttrib attrib[2];
-
- if (config == NULL) {
- ETRACE("Invalid parameter!");
- return DECODE_FAIL;
+ VAConfigAttrib cfgAttribs[2];
+ cfgAttribs[0].type = VAConfigAttribMaxPictureWidth;
+ cfgAttribs[1].type = VAConfigAttribMaxPictureHeight;
+ vaStatus = vaGetConfigAttributes(mVADisplay, VAProfileH264High,
+ VAEntrypointVLD, cfgAttribs, 2);
+ CHECK_VA_STATUS("vaGetConfigAttributes");
+ if (cfgAttribs[0].value * cfgAttribs[1].value < (uint32_t)mVideoFormatInfo.width * (uint32_t)mVideoFormatInfo.height) {
+ ETRACE("hardware supports resolution %d * %d smaller than the clip resolution %d * %d",
+ cfgAttribs[0].value, cfgAttribs[1].value, mVideoFormatInfo.width, mVideoFormatInfo.height);
+ return DECODE_DRIVER_FAIL;
}
-
- attrib[0].type = VAConfigAttribRTFormat;
- attrib[0].value = VA_RT_FORMAT_YUV420;
- attrib[1].type = VAConfigAttribDecSliceMode;
- attrib[1].value = VA_DEC_SLICE_MODE_NORMAL;
-
- vaStatus = vaGetConfigAttributes(mVADisplay,profile,VAEntrypointVLD, &attrib[1], 1);
-
- if (attrib[1].value & VA_DEC_SLICE_MODE_BASE)
- {
- ITRACE("AVC short format used");
- attrib[1].value = VA_DEC_SLICE_MODE_BASE;
- } else if (attrib[1].value & VA_DEC_SLICE_MODE_NORMAL) {
- ITRACE("AVC long format used");
- attrib[1].value = VA_DEC_SLICE_MODE_NORMAL;
- } else {
- ETRACE("Unsupported Decode Slice Mode!");
- return DECODE_FAIL;
- }
-
- vaStatus = vaCreateConfig(
- mVADisplay,
- profile,
- VAEntrypointVLD,
- &attrib[0],
- 2,
- config);
- CHECK_VA_STATUS("vaCreateConfig");
-
+#endif
return DECODE_SUCCESS;
}
-#endif
diff --git a/videodecoder/VideoDecoderAVC.h b/videodecoder/VideoDecoderAVC.h
index 6f3855d..1b3280c 100644
--- a/videodecoder/VideoDecoderAVC.h
+++ b/videodecoder/VideoDecoderAVC.h
@@ -58,9 +58,8 @@
Decode_Status handleNewSequence(vbp_data_h264 *data);
bool isNewFrame(vbp_data_h264 *data, bool equalPTS);
int32_t getDPBSize(vbp_data_h264 *data);
-#ifdef USE_AVC_SHORT_FORMAT
- virtual Decode_Status getCodecSpecificConfigs(VAProfile profile, VAConfigID*config);
-#endif
+ virtual Decode_Status checkHardwareCapability(VAProfile profile);
+
private:
struct DecodedPictureBuffer {
VideoSurfaceBuffer *surfaceBuffer;
diff --git a/videodecoder/VideoDecoderBase.cpp b/videodecoder/VideoDecoderBase.cpp
index c67ed7c..f62c706 100755
--- a/videodecoder/VideoDecoderBase.cpp
+++ b/videodecoder/VideoDecoderBase.cpp
@@ -770,8 +770,8 @@
if ((int32_t)profile != VAProfileSoftwareDecoding) {
- status = isHardwareSupported(profile);
- CHECK_STATUS("isHardwareSupported");
+ status = checkHardwareCapability(profile);
+ CHECK_STATUS("checkHardwareCapability");
#ifdef USE_AVC_SHORT_FORMAT
status = getCodecSpecificConfigs(profile, &mVAConfig);
@@ -1326,7 +1326,7 @@
return DECODE_SUCCESS;
}
#endif
-Decode_Status VideoDecoderBase::isHardwareSupported(VAProfile profile) {
+Decode_Status VideoDecoderBase::checkHardwareCapability(VAProfile profile) {
return DECODE_SUCCESS;
}
diff --git a/videodecoder/VideoDecoderBase.h b/videodecoder/VideoDecoderBase.h
index 7db79f5..e823b22 100644
--- a/videodecoder/VideoDecoderBase.h
+++ b/videodecoder/VideoDecoderBase.h
@@ -94,7 +94,7 @@
Decode_Status setParserType(_vbp_parser_type type);
virtual Decode_Status getCodecSpecificConfigs(VAProfile profile, VAConfigID *config);
#endif
- virtual Decode_Status isHardwareSupported(VAProfile profile);
+ virtual Decode_Status checkHardwareCapability(VAProfile profile);
private:
Decode_Status mapSurface(void);
void initSurfaceBuffer(bool reset);
diff --git a/videodecoder/VideoDecoderHost.cpp b/videodecoder/VideoDecoderHost.cpp
index 93e86c1..973ab22 100644
--- a/videodecoder/VideoDecoderHost.cpp
+++ b/videodecoder/VideoDecoderHost.cpp
@@ -25,7 +25,6 @@
#include "VideoDecoderWMV.h"
#include "VideoDecoderMPEG4.h"
#include "VideoDecoderAVC.h"
-#include "VideoDecoderPAVC.h"
#ifdef USE_INTEL_SECURE_AVC
#include "VideoDecoderAVCSecure.h"
#endif
diff --git a/videodecoder/VideoDecoderMPEG4.cpp b/videodecoder/VideoDecoderMPEG4.cpp
index be3c662..b99ed2e 100644
--- a/videodecoder/VideoDecoderMPEG4.cpp
+++ b/videodecoder/VideoDecoderMPEG4.cpp
@@ -577,17 +577,13 @@
mVideoFormatInfo.valid = true;
}
-Decode_Status VideoDecoderMPEG4::isHardwareSupported(VAProfile profile) {
- if (!mIsShortHeader) {
- // TODO: add support for MPEG4 in the future;
- return DECODE_SUCCESS;
- }
-
+Decode_Status VideoDecoderMPEG4::checkHardwareCapability(VAProfile profile) {
VAStatus vaStatus;
VAConfigAttrib cfgAttribs[2];
cfgAttribs[0].type = VAConfigAttribMaxPictureWidth;
cfgAttribs[1].type = VAConfigAttribMaxPictureHeight;
- vaStatus = vaGetConfigAttributes(mVADisplay, VAProfileH263Baseline,
+ vaStatus = vaGetConfigAttributes(mVADisplay,
+ mIsShortHeader ? VAProfileH263Baseline : VAProfileMPEG4AdvancedSimple,
VAEntrypointVLD, cfgAttribs, 2);
CHECK_VA_STATUS("vaGetConfigAttributes");
if (cfgAttribs[0].value * cfgAttribs[1].value < (uint32_t)mVideoFormatInfo.width * (uint32_t)mVideoFormatInfo.height) {
diff --git a/videodecoder/VideoDecoderMPEG4.h b/videodecoder/VideoDecoderMPEG4.h
index 5f641ee..aa86330 100644
--- a/videodecoder/VideoDecoderMPEG4.h
+++ b/videodecoder/VideoDecoderMPEG4.h
@@ -39,7 +39,7 @@
virtual Decode_Status decode(VideoDecodeBuffer *buffer);
protected:
- virtual Decode_Status isHardwareSupported(VAProfile profile);
+ virtual Decode_Status checkHardwareCapability(VAProfile profile);
private:
Decode_Status decodeFrame(VideoDecodeBuffer *buffer, vbp_data_mp42 *data);
diff --git a/videodecoder/VideoDecoderPAVC.cpp b/videodecoder/VideoDecoderPAVC.cpp
deleted file mode 100644
index c05330a..0000000
--- a/videodecoder/VideoDecoderPAVC.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/* INTEL CONFIDENTIAL
-* Copyright (c) 2009-2011 Intel Corporation. All rights reserved.
-*
-* The source code contained or described herein and all documents
-* related to the source code ("Material") are owned by Intel
-* Corporation or its suppliers or licensors. Title to the
-* Material remains with Intel Corporation or its suppliers and
-* licensors. The Material contains trade secrets and proprietary
-* and confidential information of Intel or its suppliers and
-* licensors. The Material is protected by worldwide copyright and
-* trade secret laws and treaty provisions. No part of the Material
-* may be used, copied, reproduced, modified, published, uploaded,
-* posted, transmitted, distributed, or disclosed in any way without
-* Intel's prior express written permission.
-*
-* No license under any patent, copyright, trade secret or other
-* intellectual property right is granted to or conferred upon you
-* by disclosure or delivery of the Materials, either expressly, by
-* implication, inducement, estoppel or otherwise. Any license
-* under such intellectual property rights must be express and
-* approved by Intel in writing.
-*
-*/
-
-#include "VideoDecoderPAVC.h"
-#include "VideoDecoderTrace.h"
-#include <string.h>
-
-VideoDecoderPAVC::VideoDecoderPAVC(const char *mimeType)
- : VideoDecoderAVC(mimeType),
- mMetadata(NULL) {
-}
-
-VideoDecoderPAVC::~VideoDecoderPAVC() {
-}
-
-Decode_Status VideoDecoderPAVC::decode(VideoDecodeBuffer *buffer) {
- // TODO: preprocessing protected content here
-
- mMetadata = NULL;
-
- if (buffer->flag & HAS_EXTRADATA) {
- mMetadata = buffer->data + buffer->size;
- }
-
- return VideoDecoderAVC::decode(buffer);
-}
-
-
-Decode_Status VideoDecoderPAVC::decodeSlice(vbp_data_h264 *data, uint32_t picIndex, uint32_t sliceIndex) {
- if (mMetadata == NULL) {
- // non-protected content playback path
- return VideoDecoderAVC::decodeSlice(data, picIndex, sliceIndex);
- }
-
- Decode_Status status;
- VAStatus vaStatus;
- uint32_t bufferIDCount = 0;
- // maximum 4 buffers to render a slice: picture parameter, IQMatrix, slice parameter, slice data
- VABufferID bufferIDs[4];
-
- vbp_picture_data_h264 *picData = &(data->pic_data[picIndex]);
- vbp_slice_data_h264 *sliceData = &(picData->slc_data[sliceIndex]);
- VAPictureParameterBufferH264 *picParam = picData->pic_parms;
- VASliceParameterBufferH264 *sliceParam = &(sliceData->slc_parms);
-
- if (sliceParam->first_mb_in_slice == 0 || mDecodingFrame == false) {
- // either condition indicates start of a new frame
- if (sliceParam->first_mb_in_slice != 0) {
- WTRACE("The first slice is lost.");
- // TODO: handle the first slice lost
- }
- if (mDecodingFrame) {
- // interlace content, complete decoding the first field
- vaStatus = vaEndPicture(mVADisplay, mVAContext);
- CHECK_VA_STATUS("vaEndPicture");
-
- // for interlace content, top field may be valid only after the second field is parsed
- mAcquiredBuffer->pictureOrder= picParam->CurrPic.TopFieldOrderCnt;
- }
-
- // Check there is no reference frame loss before decoding a frame
-
- // Update the reference frames and surface IDs for DPB and current frame
- status = updateDPB(picParam);
- CHECK_STATUS("updateDPB");
-
- //We have to provide a hacked DPB rather than complete DPB for libva as workaround
- status = updateReferenceFrames(picData);
- CHECK_STATUS("updateReferenceFrames");
-
- vaStatus = vaBeginPicture(mVADisplay, mVAContext, mAcquiredBuffer->renderBuffer.surface);
- CHECK_VA_STATUS("vaBeginPicture");
-
- // start decoding a frame
- mDecodingFrame = true;
-
- vaStatus = vaCreateBuffer(
- mVADisplay,
- mVAContext,
- VAPictureParameterBufferType,
- sizeof(VAPictureParameterBufferH264),
- 1,
- picParam,
- &bufferIDs[bufferIDCount]);
- CHECK_VA_STATUS("vaCreatePictureParameterBuffer");
- bufferIDCount++;
-
- vaStatus = vaCreateBuffer(
- mVADisplay,
- mVAContext,
- VAIQMatrixBufferType,
- sizeof(VAIQMatrixBufferH264),
- 1,
- data->IQ_matrix_buf,
- &bufferIDs[bufferIDCount]);
- CHECK_VA_STATUS("vaCreateIQMatrixBuffer");
- bufferIDCount++;
- }
-
- status = setReference(sliceParam);
- CHECK_STATUS("setReference");
-
- // find which medata is correlated to current slice
- PAVCMetadata *pMetadata = (PAVCMetadata*)mMetadata;
- uint32_t accumulatedClearNALUSize = 0;
- uint32_t clearNALUSize = 0;
- do {
- clearNALUSize = pMetadata->clearHeaderSize + pMetadata->decryptionDataSize;
- if (clearNALUSize == 0) {
- LOGE("Could not find meta data for current NAL unit.");
- return DECODE_INVALID_DATA;
- }
-
- if (accumulatedClearNALUSize + clearNALUSize > sliceData->slice_offset) {
- break;
- }
- accumulatedClearNALUSize += clearNALUSize;
- pMetadata++;
- } while (1);
-
- // add bytes that are encrypted
- sliceParam->slice_data_size += pMetadata->encryptionDataSize;
- sliceData->slice_size = sliceParam->slice_data_size;
-
- // no need to update:
- // sliceParam->slice_data_offset - 0 always
- // sliceParam->slice_data_bit_offset - relative to sliceData->slice_offset
-
- vaStatus = vaCreateBuffer(
- mVADisplay,
- mVAContext,
- VASliceParameterBufferType,
- sizeof(VASliceParameterBufferH264),
- 1,
- sliceParam,
- &bufferIDs[bufferIDCount]);
- CHECK_VA_STATUS("vaCreateSliceParameterBuffer");
- bufferIDCount++;
-
- // sliceData->slice_offset - accumulatedClearNALUSize is the absolute offset to start codes of current NAL unit
- // offset points to first byte of NAL unit
- uint32_t offset = pMetadata->clearHeaderIMROffset + sliceData->slice_offset - accumulatedClearNALUSize;
- vaStatus = vaCreateBuffer(
- mVADisplay,
- mVAContext,
- //VASliceDataBufferType,
- VAProtectedSliceDataBufferType,
- sliceData->slice_size, //size
- 1, //num_elements
- //sliceData->buffer_addr + sliceData->slice_offset,
- (uint8_t*)offset,
- &bufferIDs[bufferIDCount]);
- CHECK_VA_STATUS("vaCreateSliceDataBuffer");
- bufferIDCount++;
-
- vaStatus = vaRenderPicture(
- mVADisplay,
- mVAContext,
- bufferIDs,
- bufferIDCount);
- CHECK_VA_STATUS("vaRenderPicture");
-
- return DECODE_SUCCESS;
-}
-
diff --git a/videodecoder/VideoDecoderPAVC.h b/videodecoder/VideoDecoderPAVC.h
deleted file mode 100644
index 195c07d..0000000
--- a/videodecoder/VideoDecoderPAVC.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* INTEL CONFIDENTIAL
-* Copyright (c) 2009-2011 Intel Corporation. All rights reserved.
-*
-* The source code contained or described herein and all documents
-* related to the source code ("Material") are owned by Intel
-* Corporation or its suppliers or licensors. Title to the
-* Material remains with Intel Corporation or its suppliers and
-* licensors. The Material contains trade secrets and proprietary
-* and confidential information of Intel or its suppliers and
-* licensors. The Material is protected by worldwide copyright and
-* trade secret laws and treaty provisions. No part of the Material
-* may be used, copied, reproduced, modified, published, uploaded,
-* posted, transmitted, distributed, or disclosed in any way without
-* Intel's prior express written permission.
-*
-* No license under any patent, copyright, trade secret or other
-* intellectual property right is granted to or conferred upon you
-* by disclosure or delivery of the Materials, either expressly, by
-* implication, inducement, estoppel or otherwise. Any license
-* under such intellectual property rights must be express and
-* approved by Intel in writing.
-*
-*/
-
-#ifndef VIDEO_DECODER_PAVC_H_
-#define VIDEO_DECODER_PAVC_H_
-
-#include "VideoDecoderAVC.h"
-
-
-class VideoDecoderPAVC : public VideoDecoderAVC {
-public:
- VideoDecoderPAVC(const char *mimeType);
- virtual ~VideoDecoderPAVC();
-
- // data in the decoded buffer only contains clearHeader and decrypted data.
- // encrypted data is not included in the buffer as it may contain start code emulation bytes.
- virtual Decode_Status decode(VideoDecodeBuffer *buffer);
-
-private:
- virtual Decode_Status decodeSlice(vbp_data_h264 *data, uint32_t picIndex, uint32_t sliceIndex);
-
- // structure PAVCMetadata is appended after the VideodecodeBuffer::data + VideoDecoderBuffer::size
- // number of structures is equal to number of nal units in the buffer.
- struct PAVCMetadata
- {
- uint32_t clearHeaderSize; // 0 means no more meta data
- uint32_t decryptionDataSize;
- uint32_t encryptionDataSize;
- uint32_t clearHeaderIMROffset; // always points to clear header in the IMR
- };
-
-private:
- uint8_t *mMetadata; // pointer to metadata appended at end of buffer
-};
-
-
-
-#endif /* VIDEO_DECODER_PAVC_H_ */
diff --git a/videodecoder/VideoDecoderVP8.cpp b/videodecoder/VideoDecoderVP8.cpp
index c1a3545..2e1180d 100644
--- a/videodecoder/VideoDecoderVP8.cpp
+++ b/videodecoder/VideoDecoderVP8.cpp
@@ -415,3 +415,21 @@
}
}
+
+Decode_Status VideoDecoderVP8::checkHardwareCapability(VAProfile profile) {
+ VAStatus vaStatus;
+ VAConfigAttrib cfgAttribs[2];
+ cfgAttribs[0].type = VAConfigAttribMaxPictureWidth;
+ cfgAttribs[1].type = VAConfigAttribMaxPictureHeight;
+ vaStatus = vaGetConfigAttributes(mVADisplay, VAProfileVP8Version0_3,
+ VAEntrypointVLD, cfgAttribs, 2);
+ CHECK_VA_STATUS("vaGetConfigAttributes");
+ if (cfgAttribs[0].value * cfgAttribs[1].value < (uint32_t)mVideoFormatInfo.width * (uint32_t)mVideoFormatInfo.height) {
+ ETRACE("hardware supports resolution %d * %d smaller than the clip resolution %d * %d",
+ cfgAttribs[0].value, cfgAttribs[1].value, mVideoFormatInfo.width, mVideoFormatInfo.height);
+ return DECODE_DRIVER_FAIL;
+ }
+
+ return DECODE_SUCCESS;
+}
+
diff --git a/videodecoder/VideoDecoderVP8.h b/videodecoder/VideoDecoderVP8.h
index 61db40d..d9f88fd 100644
--- a/videodecoder/VideoDecoderVP8.h
+++ b/videodecoder/VideoDecoderVP8.h
@@ -38,6 +38,9 @@
virtual void flush(void);
virtual Decode_Status decode(VideoDecodeBuffer *buffer);
+protected:
+ virtual Decode_Status checkHardwareCapability(VAProfile profile);
+
private:
Decode_Status decodeFrame(VideoDecodeBuffer* buffer, vbp_data_vp8 *data);
Decode_Status decodePicture(vbp_data_vp8 *data, int32_t picIndex);
diff --git a/videodecoder/VideoDecoderWMV.cpp b/videodecoder/VideoDecoderWMV.cpp
index 41b3cda..6b3f4fb 100644
--- a/videodecoder/VideoDecoderWMV.cpp
+++ b/videodecoder/VideoDecoderWMV.cpp
@@ -522,3 +522,21 @@
}
+Decode_Status VideoDecoderWMV::checkHardwareCapability(VAProfile profile) {
+ VAStatus vaStatus;
+ VAConfigAttrib cfgAttribs[2];
+ cfgAttribs[0].type = VAConfigAttribMaxPictureWidth;
+ cfgAttribs[1].type = VAConfigAttribMaxPictureHeight;
+ vaStatus = vaGetConfigAttributes(mVADisplay, VAProfileVC1Advanced,
+ VAEntrypointVLD, cfgAttribs, 2);
+ CHECK_VA_STATUS("vaGetConfigAttributes");
+ if (cfgAttribs[0].value * cfgAttribs[1].value < (uint32_t)mVideoFormatInfo.width * (uint32_t)mVideoFormatInfo.height) {
+ ETRACE("hardware supports resolution %d * %d smaller than the clip resolution %d * %d",
+ cfgAttribs[0].value, cfgAttribs[1].value, mVideoFormatInfo.width, mVideoFormatInfo.height);
+ return DECODE_DRIVER_FAIL;
+ }
+
+ return DECODE_SUCCESS;
+}
+
+
diff --git a/videodecoder/VideoDecoderWMV.h b/videodecoder/VideoDecoderWMV.h
index 6a4a6bb..b201bbf 100644
--- a/videodecoder/VideoDecoderWMV.h
+++ b/videodecoder/VideoDecoderWMV.h
@@ -38,6 +38,9 @@
virtual void flush(void);
virtual Decode_Status decode(VideoDecodeBuffer *buffer);
+protected:
+ virtual Decode_Status checkHardwareCapability(VAProfile profile);
+
private:
Decode_Status decodeFrame(VideoDecodeBuffer *buffer, vbp_data_vc1 *data);
Decode_Status decodePicture(vbp_data_vc1 *data, int32_t picIndex);