Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from hankzh89/droid265
Browse files Browse the repository at this point in the history
Fixed issues for Android H.265 after rebasing on M70.
  • Loading branch information
Hänk authored Nov 9, 2018
2 parents 59a3082 + a6744a3 commit e2c05f7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
3 changes: 3 additions & 0 deletions sdk/android/src/jni/androidmediacodeccommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ enum { kMaxPendingFramesVp8 = 1 };
enum { kMaxPendingFramesVp9 = 1 };
// Maximum amount of pending frames for H.264 decoder.
enum { kMaxPendingFramesH264 = 4 };
// TODO(zhanghe): update the value after checking more devices if needed.
// Maximum amount of pending frames for H.265 decoder.
enum { kMaxPendingFramesH265 = 4 };
// Maximum amount of decoded frames for which per-frame logging is enabled.
enum { kMaxDecodedLogFrames = 10 };
// Maximum amount of encoded frames for which per-frame logging is enabled.
Expand Down
42 changes: 21 additions & 21 deletions sdk/android/src/jni/androidmediaencoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1039,27 +1039,6 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) {
info.codecSpecific.VP9.gof.CopyGofInfoVP9(gof_);
}
}
#ifndef DISABLE_H265
else if (codec_type == kVideoCodecH265) {
const std::vector<H265::NaluIndex> nalu_idxs =
H265::FindNaluIndices(payload, payload_size);
if (nalu_idxs.empty()) {
ALOGE << "Start code is not found!";
ALOGE << "Data:" << image->_buffer[0] << " " << image->_buffer[1]
<< " " << image->_buffer[2] << " " << image->_buffer[3]
<< " " << image->_buffer[4] << " " << image->_buffer[5];
ProcessHWError(true /* reset_if_fallback_unavailable */);
return false;
}
header.VerifyAndAllocateFragmentationHeader(nalu_idxs.size());
for (size_t i = 0; i < nalu_idxs.size(); i++) {
header.fragmentationOffset[i] = nalu_idxs[i].payload_start_offset;
header.fragmentationLength[i] = nalu_idxs[i].payload_size;
header.fragmentationPlType[i] = 0;
header.fragmentationTimeDiff[i] = 0;
}
}
#endif
// Generate a header describing a single fragment.
RTPFragmentationHeader header;
memset(&header, 0, sizeof(header));
Expand Down Expand Up @@ -1108,6 +1087,27 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) {
header.fragmentationTimeDiff[i] = 0;
}
}
#ifndef DISABLE_H265
else if (codec_type == kVideoCodecH265) {
const std::vector<H265::NaluIndex> nalu_idxs =
H265::FindNaluIndices(payload, payload_size);
if (nalu_idxs.empty()) {
ALOGE << "Start code is not found!";
ALOGE << "Data:" << image->_buffer[0] << " " << image->_buffer[1]
<< " " << image->_buffer[2] << " " << image->_buffer[3]
<< " " << image->_buffer[4] << " " << image->_buffer[5];
ProcessHWError(true /* reset_if_fallback_unavailable */);
return false;
}
header.VerifyAndAllocateFragmentationHeader(nalu_idxs.size());
for (size_t i = 0; i < nalu_idxs.size(); i++) {
header.fragmentationOffset[i] = nalu_idxs[i].payload_start_offset;
header.fragmentationLength[i] = nalu_idxs[i].payload_size;
header.fragmentationPlType[i] = 0;
header.fragmentationTimeDiff[i] = 0;
}
}
#endif

callback_result = callback_->OnEncodedImage(*image, &info, &header);
}
Expand Down

0 comments on commit e2c05f7

Please sign in to comment.