int64_t timeUs = AV_NOPTS_VALUE;
int key = 0;
status_t status = OK;
+ int max_negative_time_frame = 100;
int64_t startTimeUs = mStream->start_time == AV_NOPTS_VALUE ? 0 :
av_rescale_q(mStream->start_time, mStream->time_base, AV_TIME_BASE_Q);
//copy data
if ((mIsAVC || mIsHEVC) && mNal2AnnexB) {
/* This only works for NAL sizes 3-4 */
- CHECK(mNALLengthSize == 3 || mNALLengthSize == 4);
+ if ((mNALLengthSize != 3) && (mNALLengthSize != 4)) {
+ ALOGE("cannot use convertNal2AnnexB, nal size: %d", mNALLengthSize);
+ mediaBuffer->release();
+ mediaBuffer = NULL;
+ av_packet_unref(&pkt);
+ return ERROR_MALFORMED;
+ }
uint8_t *dst = (uint8_t *)mediaBuffer->data();
/* Convert H.264 NAL format to annex b */
}
if (pktTS != AV_NOPTS_VALUE)
- timeUs = av_rescale_q(pktTS, mStream->time_base, AV_TIME_BASE_Q) + startTimeUs;
+ timeUs = av_rescale_q(pktTS, mStream->time_base, AV_TIME_BASE_Q) - startTimeUs;
else
timeUs = SF_NOPTS_VALUE; //FIXME AV_NOPTS_VALUE is negative, but stagefright need positive
mediaBuffer->release();
mediaBuffer = NULL;
av_packet_unref(&pkt);
- return ERROR_MALFORMED;
+ if (max_negative_time_frame-- > 0) {
+ goto retry;
+ } else {
+ ALOGE("too many negative timestamp packets, abort decoding");
+ return ERROR_MALFORMED;
+ }
}
// predict the next PTS to use for exact-frame seek below