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

Side by Side Diff: media/cast/sender/vp8_encoder.cc

Issue 581903002: [Cast] Fix referenced_frame_ids emitted by Vp8Encoder, with massive test clean-up. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « media/cast/sender/video_encoder_impl_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/sender/vp8_encoder.h" 5 #include "media/cast/sender/vp8_encoder.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 const_cast<uint8*>(video_frame->data(VideoFrame::kYPlane)); 127 const_cast<uint8*>(video_frame->data(VideoFrame::kYPlane));
128 raw_image_->planes[PLANE_U] = 128 raw_image_->planes[PLANE_U] =
129 const_cast<uint8*>(video_frame->data(VideoFrame::kUPlane)); 129 const_cast<uint8*>(video_frame->data(VideoFrame::kUPlane));
130 raw_image_->planes[PLANE_V] = 130 raw_image_->planes[PLANE_V] =
131 const_cast<uint8*>(video_frame->data(VideoFrame::kVPlane)); 131 const_cast<uint8*>(video_frame->data(VideoFrame::kVPlane));
132 132
133 raw_image_->stride[VPX_PLANE_Y] = video_frame->stride(VideoFrame::kYPlane); 133 raw_image_->stride[VPX_PLANE_Y] = video_frame->stride(VideoFrame::kYPlane);
134 raw_image_->stride[VPX_PLANE_U] = video_frame->stride(VideoFrame::kUPlane); 134 raw_image_->stride[VPX_PLANE_U] = video_frame->stride(VideoFrame::kUPlane);
135 raw_image_->stride[VPX_PLANE_V] = video_frame->stride(VideoFrame::kVPlane); 135 raw_image_->stride[VPX_PLANE_V] = video_frame->stride(VideoFrame::kVPlane);
136 136
137 uint8 latest_frame_id_to_reference; 137 uint32 latest_frame_id_to_reference;
138 Vp8Buffers buffer_to_update; 138 Vp8Buffers buffer_to_update;
139 vpx_codec_flags_t flags = 0; 139 vpx_codec_flags_t flags = 0;
140 if (key_frame_requested_) { 140 if (key_frame_requested_) {
141 flags = VPX_EFLAG_FORCE_KF; 141 flags = VPX_EFLAG_FORCE_KF;
142 // Self reference. 142 // Self reference.
143 latest_frame_id_to_reference = last_encoded_frame_id_ + 1; 143 latest_frame_id_to_reference = last_encoded_frame_id_ + 1;
144 // We can pick any buffer as buffer_to_update since we update 144 // We can pick any buffer as buffer_to_update since we update
145 // them all. 145 // them all.
146 buffer_to_update = kLastBuffer; 146 buffer_to_update = kLastBuffer;
147 } else { 147 } else {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 if (buffer_to_update != kNoBuffer) { 221 if (buffer_to_update != kNoBuffer) {
222 buffer_state_[buffer_to_update].state = kBufferSent; 222 buffer_state_[buffer_to_update].state = kBufferSent;
223 buffer_state_[buffer_to_update].frame_id = encoded_image->frame_id; 223 buffer_state_[buffer_to_update].frame_id = encoded_image->frame_id;
224 } 224 }
225 } 225 }
226 return true; 226 return true;
227 } 227 }
228 228
229 uint32 Vp8Encoder::GetCodecReferenceFlags(vpx_codec_flags_t* flags) { 229 uint32 Vp8Encoder::GetCodecReferenceFlags(vpx_codec_flags_t* flags) {
230 if (!use_multiple_video_buffers_) 230 if (!use_multiple_video_buffers_)
231 return last_encoded_frame_id_ + 1; 231 return last_encoded_frame_id_;
232 232
233 const uint32 kMagicFrameOffset = 512; 233 const uint32 kMagicFrameOffset = 512;
234 // We set latest_frame_to_reference to an old frame so that 234 // We set latest_frame_to_reference to an old frame so that
235 // IsNewerFrameId will work correctly. 235 // IsNewerFrameId will work correctly.
236 uint32 latest_frame_to_reference = 236 uint32 latest_frame_to_reference =
237 last_encoded_frame_id_ - kMagicFrameOffset; 237 last_encoded_frame_id_ - kMagicFrameOffset;
238 238
239 // Reference all acked frames. 239 // Reference all acked frames.
240 // TODO(hubbe): We may also want to allow references to the 240 // TODO(hubbe): We may also want to allow references to the
241 // last encoded frame, if that frame was assigned to a buffer. 241 // last encoded frame, if that frame was assigned to a buffer.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 float scale_parameter = 0.5; 416 float scale_parameter = 0.5;
417 uint32 target_pct = optimal_buffer_size_ms * scale_parameter * 417 uint32 target_pct = optimal_buffer_size_ms * scale_parameter *
418 cast_config_.max_frame_rate / 10; 418 cast_config_.max_frame_rate / 10;
419 419
420 // Don't go below 3 times the per frame bandwidth. 420 // Don't go below 3 times the per frame bandwidth.
421 return std::max(target_pct, kMinIntra); 421 return std::max(target_pct, kMinIntra);
422 } 422 }
423 423
424 } // namespace cast 424 } // namespace cast
425 } // namespace media 425 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/video_encoder_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698