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->data_size().width(); | 147 // Not accounting for cropping presently. |
| 148 int clipped_width = video_frame->coded_size().width(); |
148 if (dibwidth < clipped_width) { | 149 if (dibwidth < clipped_width) { |
149 clipped_width = dibwidth; | 150 clipped_width = dibwidth; |
150 } | 151 } |
151 int clipped_height = video_frame->data_size().height(); | 152 int clipped_height = video_frame->coded_size().height(); |
152 if (dibheight < clipped_height) { | 153 if (dibheight < clipped_height) { |
153 clipped_height = dibheight; | 154 clipped_height = dibheight; |
154 } | 155 } |
155 | 156 |
156 int scaled_width = clipped_width; | 157 int scaled_width = clipped_width; |
157 int scaled_height = clipped_height; | 158 int scaled_height = clipped_height; |
158 switch (view_size_) { | 159 switch (view_size_) { |
159 case 0: | 160 case 0: |
160 scaled_width = clipped_width / 4; | 161 scaled_width = clipped_width / 4; |
161 scaled_height = clipped_height / 4; | 162 scaled_height = clipped_height / 4; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 237 } |
237 | 238 |
238 void DoPaint(CDCHandle dc) { | 239 void DoPaint(CDCHandle dc) { |
239 AllocateVideoBitmap(dc); | 240 AllocateVideoBitmap(dc); |
240 if (!bmp_.IsNull()) { | 241 if (!bmp_.IsNull()) { |
241 scoped_refptr<media::VideoFrame> frame; | 242 scoped_refptr<media::VideoFrame> frame; |
242 renderer_->GetCurrentFrame(&frame); | 243 renderer_->GetCurrentFrame(&frame); |
243 if (frame) { | 244 if (frame) { |
244 // Size the window the first time we get a frame. | 245 // Size the window the first time we get a frame. |
245 if (!last_frame_) | 246 if (!last_frame_) |
246 SetSize(frame->data_size().width(), frame->data_size().height()); | 247 SetSize(frame->coded_size().width(), frame->coded_size().height()); |
247 | 248 |
248 base::TimeDelta frame_timestamp = frame->GetTimestamp(); | 249 base::TimeDelta frame_timestamp = frame->GetTimestamp(); |
249 if (frame != last_frame_ || frame_timestamp != last_timestamp_) { | 250 if (frame != last_frame_ || frame_timestamp != last_timestamp_) { |
250 last_frame_ = frame; | 251 last_frame_ = frame; |
251 last_timestamp_ = frame_timestamp; | 252 last_timestamp_ = frame_timestamp; |
252 ConvertFrame(frame); | 253 ConvertFrame(frame); |
253 } | 254 } |
254 } | 255 } |
255 renderer_->PutCurrentFrame(frame); | 256 renderer_->PutCurrentFrame(frame); |
256 | 257 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 view_filter_); | 430 view_filter_); |
430 } | 431 } |
431 } | 432 } |
432 | 433 |
433 // Diagnostic function to write out YUV in format compatible with PYUV tool. | 434 // Diagnostic function to write out YUV in format compatible with PYUV tool. |
434 void DumpYUV(const media::VideoFrame* video_frame) { | 435 void DumpYUV(const media::VideoFrame* video_frame) { |
435 FILE * file_yuv = fopen("raw.yuv", "ab+"); // Open for append binary. | 436 FILE * file_yuv = fopen("raw.yuv", "ab+"); // Open for append binary. |
436 if (file_yuv != NULL) { | 437 if (file_yuv != NULL) { |
437 fseek(file_yuv, 0, SEEK_END); | 438 fseek(file_yuv, 0, SEEK_END); |
438 const int frame_size = | 439 const int frame_size = |
439 video_frame->data_size().width() * video_frame->data_size().height(); | 440 video_frame->coded_size().width() * video_frame->coded_size().height(); |
440 for (int y = 0; y < video_frame->data_size().height(); ++y) | 441 for (int y = 0; y < video_frame->coded_size().height(); ++y) |
441 fwrite(video_frame->data(0) + video_frame->stride(0)*y, | 442 fwrite(video_frame->data(0) + video_frame->stride(0)*y, |
442 video_frame->data_size().width(), sizeof(uint8), file_yuv); | 443 video_frame->coded_size().width(), sizeof(uint8), file_yuv); |
443 for (int y = 0; y < video_frame->data_size().height()/2; ++y) | 444 for (int y = 0; y < video_frame->coded_size().height()/2; ++y) |
444 fwrite(video_frame->data(1) + video_frame->stride(1)*y, | 445 fwrite(video_frame->data(1) + video_frame->stride(1)*y, |
445 video_frame->data_size().width() / 2, sizeof(uint8), file_yuv); | 446 video_frame->coded_size().width() / 2, sizeof(uint8), file_yuv); |
446 for (int y = 0; y < video_frame->data_size().height()/2; ++y) | 447 for (int y = 0; y < video_frame->coded_size().height()/2; ++y) |
447 fwrite(video_frame->data(2) + video_frame->stride(2)*y, | 448 fwrite(video_frame->data(2) + video_frame->stride(2)*y, |
448 video_frame->data_size().width() / 2, sizeof(uint8), file_yuv); | 449 video_frame->coded_size().width() / 2, sizeof(uint8), file_yuv); |
449 fclose(file_yuv); | 450 fclose(file_yuv); |
450 | 451 |
451 #if TESTING | 452 #if TESTING |
452 static int frame_dump_count = 0; | 453 static int frame_dump_count = 0; |
453 char outputbuf[512]; | 454 char outputbuf[512]; |
454 _snprintf_s(outputbuf, sizeof(outputbuf), "yuvdump %4d %dx%d stride %d\n", | 455 _snprintf_s(outputbuf, sizeof(outputbuf), "yuvdump %4d %dx%d stride %d\n", |
455 frame_dump_count, video_frame->data_size().width(), | 456 frame_dump_count, video_frame->coded_size().width(), |
456 video_frame->data_size().height(), | 457 video_frame->coded_size().height(), |
457 video_frame->stride(0)); | 458 video_frame->stride(0)); |
458 OutputDebugStringA(outputbuf); | 459 OutputDebugStringA(outputbuf); |
459 ++frame_dump_count; | 460 ++frame_dump_count; |
460 #endif | 461 #endif |
461 } | 462 } |
462 } | 463 } |
463 | 464 |
464 media::VideoFrame* last_frame_; | 465 media::VideoFrame* last_frame_; |
465 base::TimeDelta last_timestamp_; | 466 base::TimeDelta last_timestamp_; |
466 | 467 |
467 DISALLOW_COPY_AND_ASSIGN(WtlVideoWindow); | 468 DISALLOW_COPY_AND_ASSIGN(WtlVideoWindow); |
468 }; | 469 }; |
469 | 470 |
470 #endif // MEDIA_TOOLS_PLAYER_WTL_VIEW_H_ | 471 #endif // MEDIA_TOOLS_PLAYER_WTL_VIEW_H_ |
OLD | NEW |