aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaitao Ding <haitao.ding@intel.com>2015-05-19 18:10:12 -0400
committerPatrick Tjin <pattjin@google.com>2015-06-09 07:56:24 -0700
commit9892b9c8b325cc6fc1e3fb98455b3701e89c8885 (patch)
tree84958609d8415dc9d2746406ce271dec70211d9c
parent1175ce579a69e847027026f615a053af76b792d5 (diff)
downloadlibmix-9892b9c8b325cc6fc1e3fb98455b3701e89c8885.tar.gz
libmix: refine code to keep consistency with parser
add constrained high profile handling for AVC error concealment if vol is missing for MPPEG4 pass the color info for BT.601 and BT.708 Change-Id: Ie7fc037ba5f8f709777df9e1004c224f9478ceff Signed-off-by: Haitao Ding <haitao.ding@intel.com>
-rw-r--r--videodecoder/VideoDecoderAVC.cpp19
-rw-r--r--videodecoder/VideoDecoderBase.cpp39
-rwxr-xr-xvideodecoder/VideoDecoderBase.h19
-rw-r--r--videodecoder/VideoDecoderMPEG4.cpp20
-rw-r--r--videodecoder/VideoDecoderVP8.cpp14
-rw-r--r--videodecoder/VideoDecoderWMV.cpp5
6 files changed, 98 insertions, 18 deletions
diff --git a/videodecoder/VideoDecoderAVC.cpp b/videodecoder/VideoDecoderAVC.cpp
index f16bfe9..6f2006c 100644
--- a/videodecoder/VideoDecoderAVC.cpp
+++ b/videodecoder/VideoDecoderAVC.cpp
@@ -699,15 +699,6 @@ Decode_Status VideoDecoderAVC::startVA(vbp_data_h264 *data) {
DPBSize = 19 - AVC_EXTRA_SURFACE_NUMBER;
}
- if (mConfigBuffer.flag & WANT_ADAPTIVE_PLAYBACK) {
- // When Adaptive playback is enabled, turn off low delay mode.
- // Otherwise there may be a 240ms stuttering if the output mode is changed from LowDelay to Delay.
- enableLowDelayMode(false);
- } else {
- // for baseline profile, enable low delay mode automatically
- enableLowDelayMode(data->codec_data->profile_idc == 66);
- }
-
return VideoDecoderBase::setupVA(DPBSize + AVC_EXTRA_SURFACE_NUMBER, vaProfile);
}
@@ -718,6 +709,15 @@ void VideoDecoderAVC::updateFormatInfo(vbp_data_h264 *data) {
ITRACE("updateFormatInfo: current size: %d x %d, new size: %d x %d",
mVideoFormatInfo.width, mVideoFormatInfo.height, width, height);
+ if (mConfigBuffer.flag & WANT_ADAPTIVE_PLAYBACK) {
+ // When Adaptive playback is enabled, turn off low delay mode.
+ // Otherwise there may be a 240ms stuttering if the output mode is changed from LowDelay to Delay.
+ enableLowDelayMode(false);
+ } else {
+ // for baseline profile or constrained high profile, enable low delay mode automatically
+ enableLowDelayMode((data->codec_data->profile_idc == 66) || (data->codec_data->profile_idc == 100 && data->codec_data->constraint_set4_flag == 1 && data->codec_data->constraint_set5_flag == 1));
+ }
+
if ((mConfigBuffer.flag & USE_NATIVE_GRAPHIC_BUFFER) && mStoreMetaData) {
pthread_mutex_lock(&mFormatLock);
}
@@ -800,6 +800,7 @@ void VideoDecoderAVC::updateFormatInfo(vbp_data_h264 *data) {
}
setRenderRect();
+ setColorSpaceInfo(mVideoFormatInfo.colorMatrix, mVideoFormatInfo.videoRange);
}
bool VideoDecoderAVC::isWiDiStatusChanged() {
diff --git a/videodecoder/VideoDecoderBase.cpp b/videodecoder/VideoDecoderBase.cpp
index 906cf06..581b8ac 100644
--- a/videodecoder/VideoDecoderBase.cpp
+++ b/videodecoder/VideoDecoderBase.cpp
@@ -885,6 +885,7 @@ Decode_Status VideoDecoderBase::setupVA(uint32_t numSurface, VAProfile profile,
}
setRenderRect();
+ setColorSpaceInfo(mVideoFormatInfo.colorMatrix, mVideoFormatInfo.videoRange);
int32_t format = VA_RT_FORMAT_YUV420;
if (mConfigBuffer.flag & WANT_SURFACE_PROTECTION) {
@@ -1647,10 +1648,46 @@ void VideoDecoderBase::setRenderRect() {
VADisplayAttribute render_rect;
render_rect.type = VADisplayAttribRenderRect;
- render_rect.value = (long)&rect;
+ render_rect.attrib_ptr = &rect;
ret = vaSetDisplayAttributes(mVADisplay, &render_rect, 1);
if (ret) {
ETRACE("Failed to set rotation degree.");
}
}
+
+void VideoDecoderBase::setColorSpaceInfo(int32_t colorMatrix, int32_t videoRange) {
+ ITRACE("set colorMatrix: 0x%x ", colorMatrix);
+ VADisplayAttribute cm;
+ cm.type = VADisplayAttribCSCMatrix;
+ if (colorMatrix == VA_SRC_BT601) {
+ cm.attrib_ptr = &s601;
+ } else if (colorMatrix == VA_SRC_BT709) {
+ cm.attrib_ptr = &s709;
+ } else {
+ // if we can't get the color matrix or it's not BT601 or BT709
+ // we decide the color matrix according to clip resolution
+ if (mVideoFormatInfo.width < 1280 && mVideoFormatInfo.height < 720)
+ cm.attrib_ptr = &s601;
+ else
+ cm.attrib_ptr = &s709;
+ }
+
+ VAStatus ret = vaSetDisplayAttributes(mVADisplay, &cm, 1);
+
+ if (ret) {
+ ETRACE("Failed to set colorMatrix.");
+ }
+
+ // 1: full range, 0: reduced range
+ ITRACE("set videoRange: %d ", videoRange);
+ VADisplayAttribute vr;
+ vr.type = VADisplayAttribColorRange;
+ vr.value = (videoRange == 1) ? VA_SOURCE_RANGE_FULL : VA_SOURCE_RANGE_REDUCED;
+
+ ret = vaSetDisplayAttributes(mVADisplay, &vr, 1);
+
+ if (ret) {
+ ETRACE("Failed to set videoRange.");
+ }
+}
diff --git a/videodecoder/VideoDecoderBase.h b/videodecoder/VideoDecoderBase.h
index 0838515..5b42bc2 100755
--- a/videodecoder/VideoDecoderBase.h
+++ b/videodecoder/VideoDecoderBase.h
@@ -42,6 +42,24 @@ typedef unsigned int Display;
// POC: 4P, 8P, 10P, 6B and mNextOutputPOC = 5
#define OUTPUT_WINDOW_SIZE 8
+/*
+ * ITU-R BT.601, BT.709 transfer matrices from VA 2.0
+ * Video Color Field definitions Design Spec(Version 0.03).
+ * [R', G', B'] values are in the range [0, 1], Y' is in the range [0,1]
+ * and [Pb, Pr] components are in the range [-0.5, 0.5].
+*/
+static float s601[9] = {
+ 1, -0.000001, 1.402,
+ 1, -0.344136, -0.714136,
+ 1, 1.772, 0
+};
+
+static float s709[9] = {
+ 1, 0, 1.5748,
+ 1, -0.187324, -0.468124,
+ 1, 1.8556, 0
+};
+
class VideoDecoderBase : public IVideoDecoder {
public:
VideoDecoderBase(const char *mimeType, _vbp_parser_type type);
@@ -186,6 +204,7 @@ protected:
void enableLowDelayMode(bool enable) {mLowDelay = enable;}
void setRotationDegrees(int32_t rotationDegrees);
void setRenderRect(void);
+ void setColorSpaceInfo(int32_t colorMatrix, int32_t videoRange);
};
diff --git a/videodecoder/VideoDecoderMPEG4.cpp b/videodecoder/VideoDecoderMPEG4.cpp
index d0b25d6..6472446 100644
--- a/videodecoder/VideoDecoderMPEG4.cpp
+++ b/videodecoder/VideoDecoderMPEG4.cpp
@@ -159,12 +159,14 @@ Decode_Status VideoDecoderMPEG4::decodeFrame(VideoDecodeBuffer *buffer, vbp_data
WTRACE("number_picture_data == 0");
return DECODE_SUCCESS;
}
-
- // When the MPEG4 parser gets the invaild parameters, add the check
- // and return error to OMX to avoid mediaserver crash.
- if (data->picture_data && (data->picture_data->picture_param.vop_width == 0
- || data->picture_data->picture_param.vop_height == 0)) {
- return DECODE_PARSER_FAIL;
+ if (data->picture_data && (data->picture_data->picture_param.vop_width == 0 || data->picture_data->picture_param.vop_height == 0)) {
+ if (!data->codec_data.got_vol && data->codec_data.got_vop) {
+ // error enhancement if vol is missing
+ data->picture_data->picture_param.vop_width = mVideoFormatInfo.width;
+ data->picture_data->picture_param.vop_height = mVideoFormatInfo.height;
+ } else {
+ return DECODE_PARSER_FAIL;
+ }
}
uint64_t lastPTS = mCurrentPTS;
@@ -600,6 +602,11 @@ void VideoDecoderMPEG4::updateFormatInfo(vbp_data_mp42 *data) {
mVideoFormatInfo.width, mVideoFormatInfo.height,
data->codec_data.video_object_layer_width,
data->codec_data.video_object_layer_height);
+ // error enhancement if vol is missing
+ if (!data->codec_data.got_vol && data->codec_data.got_vop) {
+ data->codec_data.video_object_layer_width = mVideoFormatInfo.width;
+ data->codec_data.video_object_layer_height = mVideoFormatInfo.height;
+ }
mVideoFormatInfo.cropBottom = data->codec_data.video_object_layer_height > mVideoFormatInfo.height ?
data->codec_data.video_object_layer_height - mVideoFormatInfo.height : 0;
@@ -644,6 +651,7 @@ void VideoDecoderMPEG4::updateFormatInfo(vbp_data_mp42 *data) {
mVideoFormatInfo.valid = true;
setRenderRect();
+ setColorSpaceInfo(mVideoFormatInfo.colorMatrix, mVideoFormatInfo.videoRange);
}
Decode_Status VideoDecoderMPEG4::checkHardwareCapability() {
diff --git a/videodecoder/VideoDecoderVP8.cpp b/videodecoder/VideoDecoderVP8.cpp
index c4c96c9..ab561da 100644
--- a/videodecoder/VideoDecoderVP8.cpp
+++ b/videodecoder/VideoDecoderVP8.cpp
@@ -66,6 +66,19 @@ void VideoDecoderVP8::updateFormatInfo(vbp_data_vp8 *data) {
mVideoFormatInfo.height = height;
}
+ // video_range has default value of 0. Y ranges from 16 to 235.
+ mVideoFormatInfo.videoRange = 0;
+
+ switch (data->codec_data->clr_type) {
+ case 0:
+ mVideoFormatInfo.colorMatrix = VA_SRC_BT601;
+ break;
+ case 1:
+ default:
+ mVideoFormatInfo.colorMatrix = 0;
+ break;
+ }
+
mVideoFormatInfo.cropLeft = data->codec_data->crop_left;
mVideoFormatInfo.cropRight = data->codec_data->crop_right;
mVideoFormatInfo.cropTop = data->codec_data->crop_top;
@@ -85,6 +98,7 @@ void VideoDecoderVP8::updateFormatInfo(vbp_data_vp8 *data) {
}
setRenderRect();
+ setColorSpaceInfo(mVideoFormatInfo.colorMatrix, mVideoFormatInfo.videoRange);
}
Decode_Status VideoDecoderVP8::startVA(vbp_data_vp8 *data) {
diff --git a/videodecoder/VideoDecoderWMV.cpp b/videodecoder/VideoDecoderWMV.cpp
index 4945640..88b09b3 100644
--- a/videodecoder/VideoDecoderWMV.cpp
+++ b/videodecoder/VideoDecoderWMV.cpp
@@ -495,8 +495,8 @@ void VideoDecoderWMV::updateFormatInfo(vbp_data_vc1 *data) {
ITRACE("Video size is changed.");
}
- // scaling has been performed on the decoded image.
- mVideoFormatInfo.videoRange = 1;
+ // video_range has default value of 0. Y ranges from 16 to 235.
+ mVideoFormatInfo.videoRange = 0;
switch (data->se_data->MATRIX_COEF) {
case 1:
@@ -518,6 +518,7 @@ void VideoDecoderWMV::updateFormatInfo(vbp_data_vc1 *data) {
mVideoFormatInfo.valid = true;
setRenderRect();
+ setColorSpaceInfo(mVideoFormatInfo.colorMatrix, mVideoFormatInfo.videoRange);
}
Decode_Status VideoDecoderWMV::allocateVABufferIDs(int32_t number) {