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