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

Unified Diff: webrtc/api/java/jni/androidmediaencoder_jni.cc

Issue 1886113003: Add rotation to EncodedImage and make sure it is passed through encoders. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: IOS Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/java/jni/androidmediaencoder_jni.cc
diff --git a/webrtc/api/java/jni/androidmediaencoder_jni.cc b/webrtc/api/java/jni/androidmediaencoder_jni.cc
index 35291dfb1e4d43f6eae3986b99a6a30d2ec646d2..948f9356ea89667b26203e30a474cf5892166075 100644
--- a/webrtc/api/java/jni/androidmediaencoder_jni.cc
+++ b/webrtc/api/java/jni/androidmediaencoder_jni.cc
@@ -12,6 +12,9 @@
// androidmediacodeccommon.h to avoid build errors.
#include "webrtc/api/java/jni/androidmediaencoder_jni.h"
+#include <algorithm>
pbos-webrtc 2016/04/14 14:29:57 Not needed, right?
perkj_webrtc 2016/04/15 12:37:39 git cl lint say its needed.
+#include <list>
+
#include "third_party/libyuv/include/libyuv/convert.h"
#include "third_party/libyuv/include/libyuv/convert_from.h"
#include "third_party/libyuv/include/libyuv/video_common.h"
@@ -229,13 +232,27 @@ class MediaCodecVideoEncoder : public webrtc::VideoEncoder,
int current_encoding_time_ms_; // Overall encoding time in the current second
int64_t last_input_timestamp_ms_; // Timestamp of last received yuv frame.
int64_t last_output_timestamp_ms_; // Timestamp of last encoded frame.
- std::vector<int32_t> timestamps_; // Video frames timestamp queue.
- std::vector<int64_t> render_times_ms_; // Video frames render time queue.
+
+ struct InputFrameInfo {
+ InputFrameInfo(int32_t timestamp,
+ int64_t render_time_ms,
+ webrtc::VideoRotation rotation)
+ : timestamp(timestamp),
+ render_time_ms(render_time_ms),
+ rotation(rotation) {}
+ const int32_t timestamp;
+ const int64_t render_time_ms;
+ const webrtc::VideoRotation rotation;
+ };
+ std::list<InputFrameInfo> input_frame_infos_;
std::vector<int64_t> frame_rtc_times_ms_; // Time when video frame is sent to
magjed_webrtc 2016/04/15 09:43:30 Can you add a rtc_time member in InputFrameInfo an
perkj_webrtc 2016/04/15 12:37:39 Done.
// encoder input.
- int32_t output_timestamp_; // Last output frame timestamp from timestamps_ Q.
+ int32_t output_timestamp_; // Last output frame timestamp from
magjed_webrtc 2016/04/15 09:43:30 Can you replace |output_timestamp_|, |output_rende
perkj_webrtc 2016/04/15 12:37:39 I could but that would mean a slight beaviour diff
+ // |input_frame_infos_|.
int64_t output_render_time_ms_; // Last output frame render time from
- // render_times_ms_ queue.
+ // |input_frame_infos_|.
+ webrtc::VideoRotation output_rotation_; // Last output frame rotation from
+ // |input_frame_infos_|.
// Frame size in bytes fed to MediaCodec.
int yuv_size_;
// True only when between a callback_->Encoded() call return a positive value
@@ -523,8 +540,7 @@ int32_t MediaCodecVideoEncoder::InitEncodeOnCodecThread(
last_output_timestamp_ms_ = -1;
output_timestamp_ = 0;
output_render_time_ms_ = 0;
- timestamps_.clear();
- render_times_ms_.clear();
+ input_frame_infos_.clear();
frame_rtc_times_ms_.clear();
drop_next_input_frame_ = false;
use_surface_ = use_surface;
@@ -735,8 +751,10 @@ int32_t MediaCodecVideoEncoder::EncodeOnCodecThread(
frames_in_queue_++;
// Save input image timestamps for later output
- timestamps_.push_back(input_frame.timestamp());
- render_times_ms_.push_back(input_frame.render_time_ms());
+
magjed_webrtc 2016/04/15 09:43:30 nit: remove empty line
perkj_webrtc 2016/04/15 12:37:39 Done.
+ input_frame_infos_.push_back(InputFrameInfo(input_frame.timestamp(),
magjed_webrtc 2016/04/15 09:43:30 emplace_back is allowed now according to http://ch
perkj_webrtc 2016/04/15 12:37:39 Done.
+ input_frame.render_time_ms(),
+ input_frame.rotation()));
current_timestamp_us_ += rtc::kNumMicrosecsPerSec / last_set_fps_;
if (!DeliverPendingOutputs(jni)) {
@@ -943,10 +961,11 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) {
GetOutputBufferInfoPresentationTimestampUs(jni, j_output_buffer_info) /
1000;
if (frames_in_queue_ > 0) {
magjed_webrtc 2016/04/15 09:43:30 Can you CHECK_GT(frames_in_queue_, 0) here? It loo
perkj_webrtc 2016/04/15 12:37:39 as discussed- I don't want to in this cl. The comm
- output_timestamp_ = timestamps_.front();
- timestamps_.erase(timestamps_.begin());
- output_render_time_ms_ = render_times_ms_.front();
- render_times_ms_.erase(render_times_ms_.begin());
+ const InputFrameInfo& frame_info = input_frame_infos_.front();
+ output_timestamp_ = frame_info.timestamp;
+ output_render_time_ms_ = frame_info.render_time_ms;
+ output_rotation_ = frame_info.rotation;
+ input_frame_infos_.pop_front();
frame_encoding_time_ms = GetCurrentTimeMs() - frame_rtc_times_ms_.front();
frame_rtc_times_ms_.erase(frame_rtc_times_ms_.begin());
frames_in_queue_--;
@@ -978,6 +997,7 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) {
image->_encodedHeight = height_;
image->_timeStamp = output_timestamp_;
image->capture_time_ms_ = output_render_time_ms_;
+ image->rotation_ = output_rotation_;
image->_frameType =
(key_frame ? webrtc::kVideoFrameKey : webrtc::kVideoFrameDelta);
image->_completeFrame = true;
« no previous file with comments | « no previous file | webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698