OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef MEDIA_TOOLS_PLAYER_WTL_VIEW_H_ | 5 #ifndef MEDIA_TOOLS_PLAYER_WTL_VIEW_H_ |
6 #define MEDIA_TOOLS_PLAYER_WTL_VIEW_H_ | 6 #define MEDIA_TOOLS_PLAYER_WTL_VIEW_H_ |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <process.h> | 9 #include <process.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // Convert the video frame to RGB and Blit. | 137 // Convert the video frame to RGB and Blit. |
138 void ConvertFrame(media::VideoFrame* video_frame) { | 138 void ConvertFrame(media::VideoFrame* video_frame) { |
139 BITMAP bm; | 139 BITMAP bm; |
140 bmp_.GetBitmap(&bm); | 140 bmp_.GetBitmap(&bm); |
141 int dibwidth = bm.bmWidth; | 141 int dibwidth = bm.bmWidth; |
142 int dibheight = bm.bmHeight; | 142 int dibheight = bm.bmHeight; |
143 | 143 |
144 uint8 *movie_dib_bits = reinterpret_cast<uint8 *>(bm.bmBits) + | 144 uint8 *movie_dib_bits = reinterpret_cast<uint8 *>(bm.bmBits) + |
145 bm.bmWidthBytes * (bm.bmHeight - 1); | 145 bm.bmWidthBytes * (bm.bmHeight - 1); |
146 int dibrowbytes = -bm.bmWidthBytes; | 146 int dibrowbytes = -bm.bmWidthBytes; |
147 int clipped_width = video_frame->width(); | 147 int clipped_width = video_frame->data_size().width(); |
148 if (dibwidth < clipped_width) { | 148 if (dibwidth < clipped_width) { |
149 clipped_width = dibwidth; | 149 clipped_width = dibwidth; |
150 } | 150 } |
151 int clipped_height = video_frame->height(); | 151 int clipped_height = video_frame->data_size().height(); |
152 if (dibheight < clipped_height) { | 152 if (dibheight < clipped_height) { |
153 clipped_height = dibheight; | 153 clipped_height = dibheight; |
154 } | 154 } |
155 | 155 |
156 int scaled_width = clipped_width; | 156 int scaled_width = clipped_width; |
157 int scaled_height = clipped_height; | 157 int scaled_height = clipped_height; |
158 switch (view_size_) { | 158 switch (view_size_) { |
159 case 0: | 159 case 0: |
160 scaled_width = clipped_width / 4; | 160 scaled_width = clipped_width / 4; |
161 scaled_height = clipped_height / 4; | 161 scaled_height = clipped_height / 4; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 236 } |
237 | 237 |
238 void DoPaint(CDCHandle dc) { | 238 void DoPaint(CDCHandle dc) { |
239 AllocateVideoBitmap(dc); | 239 AllocateVideoBitmap(dc); |
240 if (!bmp_.IsNull()) { | 240 if (!bmp_.IsNull()) { |
241 scoped_refptr<media::VideoFrame> frame; | 241 scoped_refptr<media::VideoFrame> frame; |
242 renderer_->GetCurrentFrame(&frame); | 242 renderer_->GetCurrentFrame(&frame); |
243 if (frame) { | 243 if (frame) { |
244 // Size the window the first time we get a frame. | 244 // Size the window the first time we get a frame. |
245 if (!last_frame_) | 245 if (!last_frame_) |
246 SetSize(frame->width(), frame->height()); | 246 SetSize(frame->data_size().width(), frame->data_size().height()); |
247 | 247 |
248 base::TimeDelta frame_timestamp = frame->GetTimestamp(); | 248 base::TimeDelta frame_timestamp = frame->GetTimestamp(); |
249 if (frame != last_frame_ || frame_timestamp != last_timestamp_) { | 249 if (frame != last_frame_ || frame_timestamp != last_timestamp_) { |
250 last_frame_ = frame; | 250 last_frame_ = frame; |
251 last_timestamp_ = frame_timestamp; | 251 last_timestamp_ = frame_timestamp; |
252 ConvertFrame(frame); | 252 ConvertFrame(frame); |
253 } | 253 } |
254 } | 254 } |
255 renderer_->PutCurrentFrame(frame); | 255 renderer_->PutCurrentFrame(frame); |
256 | 256 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 view_rotate_, | 428 view_rotate_, |
429 view_filter_); | 429 view_filter_); |
430 } | 430 } |
431 } | 431 } |
432 | 432 |
433 // Diagnostic function to write out YUV in format compatible with PYUV tool. | 433 // Diagnostic function to write out YUV in format compatible with PYUV tool. |
434 void DumpYUV(const media::VideoFrame* video_frame) { | 434 void DumpYUV(const media::VideoFrame* video_frame) { |
435 FILE * file_yuv = fopen("raw.yuv", "ab+"); // Open for append binary. | 435 FILE * file_yuv = fopen("raw.yuv", "ab+"); // Open for append binary. |
436 if (file_yuv != NULL) { | 436 if (file_yuv != NULL) { |
437 fseek(file_yuv, 0, SEEK_END); | 437 fseek(file_yuv, 0, SEEK_END); |
438 const size_t frame_size = | 438 const int frame_size = |
439 video_frame->width() * video_frame->height(); | 439 video_frame->data_size().width() * video_frame->data_size().height(); |
440 for (size_t y = 0; y < video_frame->height(); ++y) | 440 for (int y = 0; y < video_frame->data_size().height(); ++y) |
441 fwrite(video_frame->data(0) + video_frame->stride(0)*y, | 441 fwrite(video_frame->data(0) + video_frame->stride(0)*y, |
442 video_frame->width(), sizeof(uint8), file_yuv); | 442 video_frame->data_size().width(), sizeof(uint8), file_yuv); |
443 for (size_t y = 0; y < video_frame->height()/2; ++y) | 443 for (int y = 0; y < video_frame->data_size().height()/2; ++y) |
444 fwrite(video_frame->data(1) + video_frame->stride(1)*y, | 444 fwrite(video_frame->data(1) + video_frame->stride(1)*y, |
445 video_frame->width() / 2, sizeof(uint8), file_yuv); | 445 video_frame->data_size().width() / 2, sizeof(uint8), file_yuv); |
446 for (size_t y = 0; y < video_frame->height()/2; ++y) | 446 for (int y = 0; y < video_frame->data_size().height()/2; ++y) |
447 fwrite(video_frame->data(2) + video_frame->stride(2)*y, | 447 fwrite(video_frame->data(2) + video_frame->stride(2)*y, |
448 video_frame->width() / 2, sizeof(uint8), file_yuv); | 448 video_frame->data_size().width() / 2, sizeof(uint8), file_yuv); |
449 fclose(file_yuv); | 449 fclose(file_yuv); |
450 | 450 |
451 #if TESTING | 451 #if TESTING |
452 static int frame_dump_count = 0; | 452 static int frame_dump_count = 0; |
453 char outputbuf[512]; | 453 char outputbuf[512]; |
454 _snprintf_s(outputbuf, sizeof(outputbuf), "yuvdump %4d %dx%d stride %d\n", | 454 _snprintf_s(outputbuf, sizeof(outputbuf), "yuvdump %4d %dx%d stride %d\n", |
455 frame_dump_count, video_frame->width(), | 455 frame_dump_count, video_frame->data_size().width(), |
456 video_frame->height(), | 456 video_frame->data_size().height(), |
457 video_frame->stride(0)); | 457 video_frame->stride(0)); |
458 OutputDebugStringA(outputbuf); | 458 OutputDebugStringA(outputbuf); |
459 ++frame_dump_count; | 459 ++frame_dump_count; |
460 #endif | 460 #endif |
461 } | 461 } |
462 } | 462 } |
463 | 463 |
464 media::VideoFrame* last_frame_; | 464 media::VideoFrame* last_frame_; |
465 base::TimeDelta last_timestamp_; | 465 base::TimeDelta last_timestamp_; |
466 | 466 |
467 DISALLOW_COPY_AND_ASSIGN(WtlVideoWindow); | 467 DISALLOW_COPY_AND_ASSIGN(WtlVideoWindow); |
468 }; | 468 }; |
469 | 469 |
470 #endif // MEDIA_TOOLS_PLAYER_WTL_VIEW_H_ | 470 #endif // MEDIA_TOOLS_PLAYER_WTL_VIEW_H_ |
OLD | NEW |