OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/capture/video/file_video_capture_device.h" | 5 #include "media/capture/video/file_video_capture_device.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // This function parses the ASCII string in |header| as belonging to a Y4M file, | 41 // This function parses the ASCII string in |header| as belonging to a Y4M file, |
42 // returning the collected format in |video_format|. For a non authoritative | 42 // returning the collected format in |video_format|. For a non authoritative |
43 // explanation of the header format, check | 43 // explanation of the header format, check |
44 // http://wiki.multimedia.cx/index.php?title=YUV4MPEG2 | 44 // http://wiki.multimedia.cx/index.php?title=YUV4MPEG2 |
45 // Restrictions: Only interlaced I420 pixel format is supported, and pixel | 45 // Restrictions: Only interlaced I420 pixel format is supported, and pixel |
46 // aspect ratio is ignored. | 46 // aspect ratio is ignored. |
47 // Implementation notes: Y4M header should end with an ASCII 0x20 (whitespace) | 47 // Implementation notes: Y4M header should end with an ASCII 0x20 (whitespace) |
48 // character, however all examples mentioned in the Y4M header description end | 48 // character, however all examples mentioned in the Y4M header description end |
49 // with a newline character instead. Also, some headers do _not_ specify pixel | 49 // with a newline character instead. Also, some headers do _not_ specify pixel |
50 // format, in this case it means I420. | 50 // format, in this case it means I420. |
51 // This code was inspired by third_party/libvpx_new/.../y4minput.* . | 51 // This code was inspired by third_party/libvpx/.../y4minput.* . |
52 void ParseY4MTags(const std::string& file_header, | 52 void ParseY4MTags(const std::string& file_header, |
53 media::VideoCaptureFormat* video_format) { | 53 media::VideoCaptureFormat* video_format) { |
54 media::VideoCaptureFormat format; | 54 media::VideoCaptureFormat format; |
55 format.pixel_format = media::PIXEL_FORMAT_I420; | 55 format.pixel_format = media::PIXEL_FORMAT_I420; |
56 size_t index = 0; | 56 size_t index = 0; |
57 size_t blank_position = 0; | 57 size_t blank_position = 0; |
58 base::StringPiece token; | 58 base::StringPiece token; |
59 while ((blank_position = file_header.find_first_of("\n ", index)) != | 59 while ((blank_position = file_header.find_first_of("\n ", index)) != |
60 std::string::npos) { | 60 std::string::npos) { |
61 // Every token is supposed to have an identifier letter and a bunch of | 61 // Every token is supposed to have an identifier letter and a bunch of |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 if (next_frame_time_ < current_time) | 381 if (next_frame_time_ < current_time) |
382 next_frame_time_ = current_time; | 382 next_frame_time_ = current_time; |
383 } | 383 } |
384 base::MessageLoop::current()->PostDelayedTask( | 384 base::MessageLoop::current()->PostDelayedTask( |
385 FROM_HERE, base::Bind(&FileVideoCaptureDevice::OnCaptureTask, | 385 FROM_HERE, base::Bind(&FileVideoCaptureDevice::OnCaptureTask, |
386 base::Unretained(this)), | 386 base::Unretained(this)), |
387 next_frame_time_ - current_time); | 387 next_frame_time_ - current_time); |
388 } | 388 } |
389 | 389 |
390 } // namespace media | 390 } // namespace media |
OLD | NEW |