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

Unified Diff: webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc

Issue 2833493003: Don't re-randomize picture_id/tl0_pic_idx when re-initializing internal encoders. (Closed)
Patch Set: Change back TimeMills() -> TimeMicros(). Created 3 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
Index: webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
index 07474e140fbea33a914648b7d3262c56b2fc9e81..65d1a155d52275edbfb1e81ea773545ed5157e21 100644
--- a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
+++ b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
@@ -22,9 +22,10 @@
#include "vpx/vp8dx.h"
#include "webrtc/base/checks.h"
-#include "webrtc/base/timeutils.h"
#include "webrtc/base/keep_ref_until_done.h"
#include "webrtc/base/logging.h"
+#include "webrtc/base/random.h"
+#include "webrtc/base/timeutils.h"
#include "webrtc/base/trace_event.h"
#include "webrtc/common_video/include/video_frame_buffer.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
@@ -67,14 +68,12 @@ VP9EncoderImpl::VP9EncoderImpl()
encoded_complete_callback_(NULL),
inited_(false),
timestamp_(0),
- picture_id_(0),
cpu_speed_(3),
rc_max_intra_target_(0),
encoder_(NULL),
config_(NULL),
raw_(NULL),
input_image_(NULL),
- tl0_pic_idx_(0),
frames_since_kf_(0),
num_temporal_layers_(0),
num_spatial_layers_(0),
@@ -84,8 +83,10 @@ VP9EncoderImpl::VP9EncoderImpl()
spatial_layer_(new ScreenshareLayersVP9(2)) {
memset(&codec_, 0, sizeof(codec_));
memset(&svc_params_, 0, sizeof(vpx_svc_extra_cfg_t));
- uint32_t seed = rtc::Time32();
- srand(seed);
+
+ Random random(rtc::TimeMicros());
+ picture_id_ = random.Rand<uint16_t>() & 0x7FFF;
+ tl0_pic_idx_ = random.Rand<uint8_t>();
}
VP9EncoderImpl::~VP9EncoderImpl() {
@@ -262,10 +263,6 @@ int VP9EncoderImpl::InitEncode(const VideoCodec* inst,
}
if (encoder_ == NULL) {
encoder_ = new vpx_codec_ctx_t;
- // Only randomize pid/tl0 the first time the encoder is initialized
- // in order to not make random jumps mid-stream.
- picture_id_ = static_cast<uint16_t>(rand()) & 0x7FFF; // NOLINT
- tl0_pic_idx_ = static_cast<uint8_t>(rand()); // NOLINT
}
if (config_ == NULL) {
config_ = new vpx_codec_enc_cfg_t;

Powered by Google App Engine
This is Rietveld 408576698