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

Side by Side Diff: content/renderer/media/capture_video_decoder.cc

Issue 7932005: Reland r101418: Fix aspect ratio and clarify video frame dimensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/renderer/media/capture_video_decoder.h" 5 #include "content/renderer/media/capture_video_decoder.h"
6 6
7 #include "content/renderer/media/video_capture_impl_manager.h" 7 #include "content/renderer/media/video_capture_impl_manager.h"
8 #include "media/base/filter_host.h" 8 #include "media/base/filter_host.h"
9 #include "media/base/limits.h" 9 #include "media/base/limits.h"
10 #include "media/base/video_util.h" 10 #include "media/base/video_util.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 void CaptureVideoDecoder::ProduceVideoFrame( 44 void CaptureVideoDecoder::ProduceVideoFrame(
45 scoped_refptr<media::VideoFrame> video_frame) { 45 scoped_refptr<media::VideoFrame> video_frame) {
46 message_loop_proxy_->PostTask( 46 message_loop_proxy_->PostTask(
47 FROM_HERE, 47 FROM_HERE,
48 NewRunnableMethod( 48 NewRunnableMethod(
49 this, 49 this,
50 &CaptureVideoDecoder::ProduceVideoFrameOnDecoderThread, video_frame)); 50 &CaptureVideoDecoder::ProduceVideoFrameOnDecoderThread, video_frame));
51 } 51 }
52 52
53 int CaptureVideoDecoder::width() { 53 gfx::Size CaptureVideoDecoder::natural_size() {
54 return capability_.width; 54 return gfx::Size(capability_.width, capability_.height);
55 }
56
57 int CaptureVideoDecoder::height() {
58 return capability_.height;
59 } 55 }
60 56
61 void CaptureVideoDecoder::Play(media::FilterCallback* callback) { 57 void CaptureVideoDecoder::Play(media::FilterCallback* callback) {
62 message_loop_proxy_->PostTask( 58 message_loop_proxy_->PostTask(
63 FROM_HERE, 59 FROM_HERE,
64 NewRunnableMethod(this, 60 NewRunnableMethod(this,
65 &CaptureVideoDecoder::PlayOnDecoderThread, 61 &CaptureVideoDecoder::PlayOnDecoderThread,
66 callback)); 62 callback));
67 } 63 }
68 64
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 capture->FeedBuffer(buf); 212 capture->FeedBuffer(buf);
217 return; 213 return;
218 } 214 }
219 215
220 scoped_refptr<media::VideoFrame> video_frame = available_frames_.front(); 216 scoped_refptr<media::VideoFrame> video_frame = available_frames_.front();
221 available_frames_.pop_front(); 217 available_frames_.pop_front();
222 218
223 if (buf->width != capability_.width || buf->height != capability_.height) { 219 if (buf->width != capability_.width || buf->height != capability_.height) {
224 capability_.width = buf->width; 220 capability_.width = buf->width;
225 capability_.height = buf->height; 221 capability_.height = buf->height;
226 host()->SetVideoSize(capability_.width, capability_.height); 222 host()->SetNaturalVideoSize(
223 gfx::Size(capability_.width, capability_.height));
227 } 224 }
228 225
229 // Check if there's a size change. 226 // Check if there's a size change.
230 if (static_cast<int>(video_frame->width()) != capability_.width || 227 if (static_cast<int>(video_frame->width()) != capability_.width ||
231 static_cast<int>(video_frame->height()) != capability_.height) { 228 static_cast<int>(video_frame->height()) != capability_.height) {
232 // Allocate new buffer based on the new size. 229 // Allocate new buffer based on the new size.
233 video_frame = media::VideoFrame::CreateFrame(media::VideoFrame::YV12, 230 video_frame = media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
234 capability_.width, 231 capability_.width,
235 capability_.height, 232 capability_.height,
236 media::kNoTimestamp, 233 media::kNoTimestamp,
237 media::kNoTimestamp); 234 media::kNoTimestamp);
238 } 235 }
239 236
240 video_frame->SetTimestamp(buf->timestamp - start_time_); 237 video_frame->SetTimestamp(buf->timestamp - start_time_);
241 video_frame->SetDuration(base::TimeDelta::FromMilliseconds(33)); 238 video_frame->SetDuration(base::TimeDelta::FromMilliseconds(33));
242 239
243 uint8* buffer = buf->memory_pointer; 240 uint8* buffer = buf->memory_pointer;
244 241
242 // Assume YV12 format.
243 // TODO(vrk): This DCHECK fails in content_unittests ... it should not!
244 // DCHECK(capability_.raw_type == media::VideoFrame::YV12);
245 int y_width = capability_.width; 245 int y_width = capability_.width;
246 int y_height = capability_.height; 246 int y_height = capability_.height;
247 int uv_width = capability_.width / 2; 247 int uv_width = capability_.width / 2;
248 int uv_height = capability_.height / 2; // YV12 format. 248 int uv_height = capability_.height / 2; // YV12 format.
249 CopyYPlane(buffer, y_width, y_height, video_frame); 249 CopyYPlane(buffer, y_width, y_height, video_frame);
250 buffer += y_width * y_height; 250 buffer += y_width * y_height;
251 CopyUPlane(buffer, uv_width, uv_height, video_frame); 251 CopyUPlane(buffer, uv_width, uv_height, video_frame);
252 buffer += uv_width * uv_height; 252 buffer += uv_width * uv_height;
253 CopyVPlane(buffer, uv_width, uv_height, video_frame); 253 CopyVPlane(buffer, uv_width, uv_height, video_frame);
254 254
255 VideoFrameReady(video_frame); 255 VideoFrameReady(video_frame);
256 capture->FeedBuffer(buf); 256 capture->FeedBuffer(buf);
257 } 257 }
OLDNEW
« no previous file with comments | « content/renderer/media/capture_video_decoder.h ('k') | content/renderer/media/rtc_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698