Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: talk/app/webrtc/java/jni/androidmediacodeccommon.h

Issue 1587943004: Add QP statistics logging to Android HW encoder. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Address comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | talk/app/webrtc/java/jni/androidmediadecoder_jni.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 23 matching lines...) Expand all
34 #include "webrtc/base/thread.h" 34 #include "webrtc/base/thread.h"
35 #include "webrtc/base/logging.h" 35 #include "webrtc/base/logging.h"
36 #include "webrtc/system_wrappers/include/tick_util.h" 36 #include "webrtc/system_wrappers/include/tick_util.h"
37 37
38 namespace webrtc_jni { 38 namespace webrtc_jni {
39 39
40 // Uncomment this define to enable verbose logging for every encoded/decoded 40 // Uncomment this define to enable verbose logging for every encoded/decoded
41 // video frame. 41 // video frame.
42 //#define TRACK_BUFFER_TIMING 42 //#define TRACK_BUFFER_TIMING
43 43
44 #define TAG "MediaCodecVideo" 44 #define TAG_COMMON "MediaCodecVideo"
45 #ifdef TRACK_BUFFER_TIMING
46 #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__)
47 #else
48 #define ALOGV(...)
49 #endif
50 #define ALOGD LOG_TAG(rtc::LS_INFO, TAG)
51 #define ALOGW LOG_TAG(rtc::LS_WARNING, TAG)
52 #define ALOGE LOG_TAG(rtc::LS_ERROR, TAG)
53 45
54 // Color formats supported by encoder - should mirror supportedColorList 46 // Color formats supported by encoder - should mirror supportedColorList
55 // from MediaCodecVideoEncoder.java 47 // from MediaCodecVideoEncoder.java
56 enum COLOR_FORMATTYPE { 48 enum COLOR_FORMATTYPE {
57 COLOR_FormatYUV420Planar = 0x13, 49 COLOR_FormatYUV420Planar = 0x13,
58 COLOR_FormatYUV420SemiPlanar = 0x15, 50 COLOR_FormatYUV420SemiPlanar = 0x15,
59 COLOR_QCOM_FormatYUV420SemiPlanar = 0x7FA30C00, 51 COLOR_QCOM_FormatYUV420SemiPlanar = 0x7FA30C00,
60 // NV12 color format supported by QCOM codec, but not declared in MediaCodec - 52 // NV12 color format supported by QCOM codec, but not declared in MediaCodec -
61 // see /hardware/qcom/media/mm-core/inc/OMX_QCOMExtns.h 53 // see /hardware/qcom/media/mm-core/inc/OMX_QCOMExtns.h
62 // This format is presumably similar to COLOR_FormatYUV420SemiPlanar, 54 // This format is presumably similar to COLOR_FormatYUV420SemiPlanar,
63 // but requires some (16, 32?) byte alignment. 55 // but requires some (16, 32?) byte alignment.
64 COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m = 0x7FA30C04 56 COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m = 0x7FA30C04
65 }; 57 };
66 58
67 // Arbitrary interval to poll the codec for new outputs. 59 // Arbitrary interval to poll the codec for new outputs.
68 enum { kMediaCodecPollMs = 10 }; 60 enum { kMediaCodecPollMs = 10 };
69 // Media codec maximum output buffer ready timeout. 61 // Media codec maximum output buffer ready timeout.
70 enum { kMediaCodecTimeoutMs = 1000 }; 62 enum { kMediaCodecTimeoutMs = 1000 };
71 // Interval to print codec statistics (bitrate, fps, encoding/decoding time). 63 // Interval to print codec statistics (bitrate, fps, encoding/decoding time).
72 enum { kMediaCodecStatisticsIntervalMs = 3000 }; 64 enum { kMediaCodecStatisticsIntervalMs = 3000 };
73 // Maximum amount of pending frames for VP8 decoder. 65 // Maximum amount of pending frames for VP8 decoder.
74 enum { kMaxPendingFramesVp8 = 1 }; 66 enum { kMaxPendingFramesVp8 = 1 };
75 // Maximum amount of pending frames for VP9 decoder. 67 // Maximum amount of pending frames for VP9 decoder.
76 enum { kMaxPendingFramesVp9 = 1 }; 68 enum { kMaxPendingFramesVp9 = 1 };
77 // Maximum amount of pending frames for H.264 decoder. 69 // Maximum amount of pending frames for H.264 decoder.
78 enum { kMaxPendingFramesH264 = 30 }; 70 enum { kMaxPendingFramesH264 = 30 };
79 // Maximum amount of decoded frames for which per-frame logging is enabled. 71 // Maximum amount of decoded frames for which per-frame logging is enabled.
80 enum { kMaxDecodedLogFrames = 5 }; 72 enum { kMaxDecodedLogFrames = 5 };
73 // Maximum amount of encoded frames for which per-frame logging is enabled.
74 enum { kMaxEncodedLogFrames = 5 };
81 75
82 static inline int64_t GetCurrentTimeMs() { 76 static inline int64_t GetCurrentTimeMs() {
83 return webrtc::TickTime::Now().Ticks() / 1000000LL; 77 return webrtc::TickTime::Now().Ticks() / 1000000LL;
84 } 78 }
85 79
86 static inline void AllowBlockingCalls() { 80 static inline void AllowBlockingCalls() {
87 rtc::Thread* current_thread = rtc::Thread::Current(); 81 rtc::Thread* current_thread = rtc::Thread::Current();
88 if (current_thread != NULL) 82 if (current_thread != NULL)
89 current_thread->SetAllowBlockingCalls(true); 83 current_thread->SetAllowBlockingCalls(true);
90 } 84 }
91 85
92 // Return the (singleton) Java Enum object corresponding to |index|; 86 // Return the (singleton) Java Enum object corresponding to |index|;
93 // |state_class_fragment| is something like "MediaSource$State". 87 // |state_class_fragment| is something like "MediaSource$State".
94 static inline jobject JavaEnumFromIndex( 88 static inline jobject JavaEnumFromIndex(
95 JNIEnv* jni, const std::string& state_class_fragment, int index) { 89 JNIEnv* jni, const std::string& state_class_fragment, int index) {
96 const std::string state_class = "org/webrtc/" + state_class_fragment; 90 const std::string state_class = "org/webrtc/" + state_class_fragment;
97 return JavaEnumFromIndex(jni, FindClass(jni, state_class.c_str()), 91 return JavaEnumFromIndex(jni, FindClass(jni, state_class.c_str()),
98 state_class, index); 92 state_class, index);
99 } 93 }
100 94
101 // Checks for any Java exception, prints stack backtrace and clears 95 // Checks for any Java exception, prints stack backtrace and clears
102 // currently thrown exception. 96 // currently thrown exception.
103 static inline bool CheckException(JNIEnv* jni) { 97 static inline bool CheckException(JNIEnv* jni) {
104 if (jni->ExceptionCheck()) { 98 if (jni->ExceptionCheck()) {
105 ALOGE << "Java JNI exception."; 99 LOG_TAG(rtc::LS_ERROR, TAG_COMMON) << "Java JNI exception.";
106 jni->ExceptionDescribe(); 100 jni->ExceptionDescribe();
107 jni->ExceptionClear(); 101 jni->ExceptionClear();
108 return true; 102 return true;
109 } 103 }
110 return false; 104 return false;
111 } 105 }
112 106
113 } // namespace webrtc_jni 107 } // namespace webrtc_jni
114 108
115 #endif // TALK_APP_WEBRTC_JAVA_JNI_ANDROIDMEDIACODECCOMMON_H_ 109 #endif // TALK_APP_WEBRTC_JAVA_JNI_ANDROIDMEDIACODECCOMMON_H_
OLDNEW
« no previous file with comments | « no previous file | talk/app/webrtc/java/jni/androidmediadecoder_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698