aboutsummaryrefslogtreecommitdiff
path: root/talk/app
diff options
context:
space:
mode:
authorglaznev <glaznev@webrtc.org>2015-10-28 10:30:32 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-28 17:30:38 +0000
commite55c42c13ee2620b46376ab708e7d4c0d698cf51 (patch)
treea994c8e35f4fff39ed3635cb8df252bc42fcda26 /talk/app
parent98f53510b222f71fdd8b799b2f33737ceeb28c61 (diff)
downloadwebrtc-e55c42c13ee2620b46376ab708e7d4c0d698cf51.tar.gz
Remove limitation on the amount of maximum pending HW decoder inputs.
Plus log first few decoder frames in and out events. BUG=b/25287910 Review URL: https://codereview.webrtc.org/1423843005 Cr-Commit-Position: refs/heads/master@{#10439}
Diffstat (limited to 'talk/app')
-rw-r--r--talk/app/webrtc/java/jni/androidmediacodeccommon.h2
-rw-r--r--talk/app/webrtc/java/jni/androidmediadecoder_jni.cc33
2 files changed, 23 insertions, 12 deletions
diff --git a/talk/app/webrtc/java/jni/androidmediacodeccommon.h b/talk/app/webrtc/java/jni/androidmediacodeccommon.h
index cd1a732d83..348a716496 100644
--- a/talk/app/webrtc/java/jni/androidmediacodeccommon.h
+++ b/talk/app/webrtc/java/jni/androidmediacodeccommon.h
@@ -74,6 +74,8 @@ enum { kMediaCodecStatisticsIntervalMs = 3000 };
enum { kMaxPendingFramesVp8 = 1 };
// Maximum amount of pending frames for H.264 decoder.
enum { kMaxPendingFramesH264 = 30 };
+// Maximum amount of decoded frames for which per-frame logging is enabled.
+enum { kMaxDecodedLogFrames = 5 };
static inline int64_t GetCurrentTimeMs() {
return webrtc::TickTime::Now().Ticks() / 1000000LL;
diff --git a/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc b/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
index dc74c1ff78..b664f16e2e 100644
--- a/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
+++ b/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
@@ -283,7 +283,8 @@ int32_t MediaCodecVideoDecoder::InitDecode(const VideoCodec* inst,
if (&codec_ != inst) {
codec_ = *inst;
}
- codec_.maxFramerate = (codec_.maxFramerate >= 1) ? codec_.maxFramerate : 1;
+ // If maxFramerate is not set then assume 30 fps.
+ codec_.maxFramerate = (codec_.maxFramerate >= 1) ? codec_.maxFramerate : 30;
// Call Java init.
return codec_thread_->Invoke<int32_t>(
@@ -348,8 +349,7 @@ int32_t MediaCodecVideoDecoder::InitDecodeOnCodecThread() {
jobjectArray input_buffers = (jobjectArray)GetObjectField(
jni, *j_media_codec_video_decoder_, j_input_buffers_field_);
size_t num_input_buffers = jni->GetArrayLength(input_buffers);
- max_pending_frames_ =
- std::min(max_pending_frames_, static_cast<uint32_t>(num_input_buffers));
+ ALOGD << "Maximum amount of pending frames: " << max_pending_frames_;
input_buffers_.resize(num_input_buffers);
for (size_t i = 0; i < num_input_buffers; ++i) {
input_buffers_[i] =
@@ -387,7 +387,8 @@ int32_t MediaCodecVideoDecoder::ReleaseOnCodecThread() {
}
CheckOnCodecThread();
JNIEnv* jni = AttachCurrentThreadIfNeeded();
- ALOGD << "DecoderReleaseOnCodecThread: Frames received: " << frames_received_;
+ ALOGD << "DecoderReleaseOnCodecThread: Frames received: " <<
+ frames_received_ << ". Frames decoded: " << frames_decoded_;
ScopedLocalRefFrame local_ref_frame(jni);
for (size_t i = 0; i < input_buffers_.size(); i++) {
jni->DeleteGlobalRef(input_buffers_[i]);
@@ -504,11 +505,13 @@ int32_t MediaCodecVideoDecoder::DecodeOnCodecThread(
ALOGV("Received: %d. Decoded: %d. Wait for output...",
frames_received_, frames_decoded_);
if (!DeliverPendingOutputs(jni, kMediaCodecTimeoutMs * 1000)) {
- ALOGE << "DeliverPendingOutputs error";
+ ALOGE << "DeliverPendingOutputs error. Frames received: " <<
+ frames_received_ << ". Frames decoded: " << frames_decoded_;
return ProcessHWErrorOnCodecThread();
}
if (frames_received_ > frames_decoded_ + max_pending_frames_) {
- ALOGE << "Output buffer dequeue timeout";
+ ALOGE << "Output buffer dequeue timeout. Frames received: " <<
+ frames_received_ << ". Frames decoded: " << frames_decoded_;
return ProcessHWErrorOnCodecThread();
}
}
@@ -533,9 +536,12 @@ int32_t MediaCodecVideoDecoder::DecodeOnCodecThread(
return ProcessHWErrorOnCodecThread();
}
jlong timestamp_us = (frames_received_ * 1000000) / codec_.maxFramerate;
- ALOGV("Decoder frame in # %d. Type: %d. Buffer # %d. TS: %lld. Size: %d",
- frames_received_, inputImage._frameType, j_input_buffer_index,
- timestamp_us / 1000, inputImage._length);
+ if (frames_decoded_ < kMaxDecodedLogFrames) {
+ ALOGD << "Decoder frame in # " << frames_received_ << ". Type: "
+ << inputImage._frameType << ". Buffer # " <<
+ j_input_buffer_index << ". TS: " << (int)(timestamp_us / 1000)
+ << ". Size: " << inputImage._length;
+ }
memcpy(buffer, inputImage._buffer, inputImage._length);
// Save input image timestamps for later output.
@@ -697,9 +703,12 @@ bool MediaCodecVideoDecoder::DeliverPendingOutputs(
frame_decoding_time_ms = GetCurrentTimeMs() - frame_rtc_times_ms_.front();
frame_rtc_times_ms_.erase(frame_rtc_times_ms_.begin());
}
- ALOGV("Decoder frame out # %d. %d x %d. %d x %d. Color: 0x%x. TS: %ld."
- " DecTime: %lld", frames_decoded_, width, height, stride, slice_height,
- color_format, output_timestamps_ms, frame_decoding_time_ms);
+ if (frames_decoded_ < kMaxDecodedLogFrames) {
+ ALOGD << "Decoder frame out # " << frames_decoded_ << ". " << width <<
+ " x " << height << ". " << stride << " x " << slice_height <<
+ ". Color: " << color_format << ". TS:" << (int)output_timestamps_ms <<
+ ". DecTime: " << (int)frame_decoding_time_ms;
+ }
// Calculate and print decoding statistics - every 3 seconds.
frames_decoded_++;