VideoDecoderAVC: Add timestamp checking when first slice is lost.
BZ: 28186
In a streaming case, the first slice is lost, so the mix
doesn't treat it as a new frame, then call continueDecodingFrame
causing decode fail.
Add timestamp checking when first slice is lost. if have difference
timestamp then treat it as new frame. It is a workaround here.
Change-Id: I053d016aef83816d49cb31f965e54d2f2433ba45
Signed-off-by: xiao <fengx.xiao@intel.com>
Reviewed-on: http://android.intel.com:8080/40784
Reviewed-by: Qiu, Junhai <junhai.qiu@intel.com>
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/videodecoder/VideoDecoderAVC.cpp b/videodecoder/VideoDecoderAVC.cpp
index dbb13d4..2fd539f 100644
--- a/videodecoder/VideoDecoderAVC.cpp
+++ b/videodecoder/VideoDecoderAVC.cpp
@@ -153,7 +153,7 @@
mCurrentPTS = buffer->timeStamp;
//if (lastPTS != mCurrentPTS) {
- if (isNewFrame(data)) {
+ if (isNewFrame(data, lastPTS == mCurrentPTS)) {
// finish decoding the last frame
status = endDecodingFrame(false);
CHECK_STATUS("endDecodingFrame");
@@ -682,7 +682,7 @@
return DECODE_SUCCESS;
}
-bool VideoDecoderAVC::isNewFrame(vbp_data_h264 *data) {
+bool VideoDecoderAVC::isNewFrame(vbp_data_h264 *data, bool equalPTS) {
if (data->num_pictures == 0) {
ETRACE("num_pictures == 0");
return true;
@@ -701,6 +701,11 @@
// not the first slice, assume it is continuation of a partial frame
// TODO: check if it is new frame boundary as the first slice may get lost in streaming case.
WTRACE("first_mb_in_slice != 0");
+ if (!equalPTS) {
+ // return true if different timestamp, it is a workaround here for a streaming case
+ WTRACE("different PTS, treat it as a new frame");
+ return true;
+ }
} else {
if ((picData->pic_parms->CurrPic.flags & fieldFlags) == fieldFlags) {
ETRACE("Current picture has both odd field and even field.");
diff --git a/videodecoder/VideoDecoderAVC.h b/videodecoder/VideoDecoderAVC.h
index 1794e03..339e05a 100644
--- a/videodecoder/VideoDecoderAVC.h
+++ b/videodecoder/VideoDecoderAVC.h
@@ -55,7 +55,7 @@
Decode_Status startVA(vbp_data_h264 *data);
void updateFormatInfo(vbp_data_h264 *data);
Decode_Status handleNewSequence(vbp_data_h264 *data);
- bool isNewFrame(vbp_data_h264 *data);
+ bool isNewFrame(vbp_data_h264 *data, bool equalPTS);
int32_t getDPBSize(vbp_data_h264 *data);
private: