| 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_BASE_VIDEO_FRAME_H_ | 5 #ifndef MEDIA_BASE_VIDEO_FRAME_H_ |
| 6 #define MEDIA_BASE_VIDEO_FRAME_H_ | 6 #define MEDIA_BASE_VIDEO_FRAME_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 // Creates a new frame in system memory with given parameters. Buffers for | 72 // Creates a new frame in system memory with given parameters. Buffers for |
| 73 // the frame are allocated but not initialized. | 73 // the frame are allocated but not initialized. |
| 74 static scoped_refptr<VideoFrame> CreateFrame( | 74 static scoped_refptr<VideoFrame> CreateFrame( |
| 75 Format format, | 75 Format format, |
| 76 const gfx::Size& coded_size, | 76 const gfx::Size& coded_size, |
| 77 const gfx::Rect& visible_rect, | 77 const gfx::Rect& visible_rect, |
| 78 const gfx::Size& natural_size, | 78 const gfx::Size& natural_size, |
| 79 base::TimeDelta timestamp); | 79 base::TimeDelta timestamp); |
| 80 | 80 |
| 81 // Returns true if |plane| is a valid plane number for the given format. This |
| 82 // can be used to DCHECK() plane parameters. |
| 83 static bool IsValidPlane(size_t plane, VideoFrame::Format format); |
| 84 |
| 81 // Call prior to CreateFrame to ensure validity of frame configuration. Called | 85 // Call prior to CreateFrame to ensure validity of frame configuration. Called |
| 82 // automatically by VideoDecoderConfig::IsValidConfig(). | 86 // automatically by VideoDecoderConfig::IsValidConfig(). |
| 83 // TODO(scherkus): VideoDecoderConfig shouldn't call this method | 87 // TODO(scherkus): VideoDecoderConfig shouldn't call this method |
| 84 static bool IsValidConfig(Format format, const gfx::Size& coded_size, | 88 static bool IsValidConfig(Format format, const gfx::Size& coded_size, |
| 85 const gfx::Rect& visible_rect, | 89 const gfx::Rect& visible_rect, |
| 86 const gfx::Size& natural_size); | 90 const gfx::Size& natural_size); |
| 87 | 91 |
| 88 // CB to write pixels from the texture backing this frame into the | 92 // CB to write pixels from the texture backing this frame into the |
| 89 // |const SkBitmap&| parameter. | 93 // |const SkBitmap&| parameter. |
| 90 typedef base::Callback<void(const SkBitmap&)> ReadPixelsCB; | 94 typedef base::Callback<void(const SkBitmap&)> ReadPixelsCB; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // Allocates a hole frame. | 223 // Allocates a hole frame. |
| 220 static scoped_refptr<VideoFrame> CreateHoleFrame(const gfx::Size& size); | 224 static scoped_refptr<VideoFrame> CreateHoleFrame(const gfx::Size& size); |
| 221 #endif // defined(VIDEO_HOLE) | 225 #endif // defined(VIDEO_HOLE) |
| 222 | 226 |
| 223 static size_t NumPlanes(Format format); | 227 static size_t NumPlanes(Format format); |
| 224 | 228 |
| 225 // Returns the required allocation size for a (tightly packed) frame of the | 229 // Returns the required allocation size for a (tightly packed) frame of the |
| 226 // given coded size and format. | 230 // given coded size and format. |
| 227 static size_t AllocationSize(Format format, const gfx::Size& coded_size); | 231 static size_t AllocationSize(Format format, const gfx::Size& coded_size); |
| 228 | 232 |
| 229 // Returns the plane size for a plane of the given coded size and format. | 233 // Returns the plane size (in bytes) for a plane of the given coded size and |
| 234 // format. |
| 230 static gfx::Size PlaneSize(Format format, | 235 static gfx::Size PlaneSize(Format format, |
| 231 size_t plane, | 236 size_t plane, |
| 232 const gfx::Size& coded_size); | 237 const gfx::Size& coded_size); |
| 233 | 238 |
| 234 // Returns the required allocation size for a (tightly packed) plane of the | 239 // Returns the required allocation size for a (tightly packed) plane of the |
| 235 // given coded size and format. | 240 // given coded size and format. |
| 236 static size_t PlaneAllocationSize(Format format, | 241 static size_t PlaneAllocationSize(Format format, |
| 237 size_t plane, | 242 size_t plane, |
| 238 const gfx::Size& coded_size); | 243 const gfx::Size& coded_size); |
| 239 | 244 |
| 240 // Returns horizontal bits per pixel for given |plane| and |format|. | 245 // Returns horizontal bits per pixel for given |plane| and |format|. |
| 241 static int PlaneHorizontalBitsPerPixel(Format format, size_t plane); | 246 static int PlaneHorizontalBitsPerPixel(Format format, size_t plane); |
| 242 | 247 |
| 243 // Returns the number of bytes per row for the given plane, format, and width. | 248 // Returns the number of bytes per row for the given plane, format, and width. |
| 244 // The width may be aligned to format requirements. | 249 // The width may be aligned to format requirements. |
| 245 static size_t RowBytes(size_t plane, Format format, int width); | 250 static size_t RowBytes(size_t plane, Format format, int width); |
| 246 | 251 |
| 247 // Returns the number of rows for the given plane, format, and height. | 252 // Returns the number of rows for the given plane, format, and height. |
| 248 // The height may be aligned to format requirements. | 253 // The height may be aligned to format requirements. |
| 249 static size_t Rows(size_t plane, Format format, int height); | 254 static size_t Rows(size_t plane, Format format, int height); |
| 250 | 255 |
| 256 // Returns the number of columns for the given plane, format, and width. |
| 257 // The width may be aligned to format requirements. |
| 258 static size_t Columns(size_t plane, Format format, int width); |
| 259 |
| 251 Format format() const { return format_; } | 260 Format format() const { return format_; } |
| 252 | 261 |
| 253 const gfx::Size& coded_size() const { return coded_size_; } | 262 const gfx::Size& coded_size() const { return coded_size_; } |
| 254 const gfx::Rect& visible_rect() const { return visible_rect_; } | 263 const gfx::Rect& visible_rect() const { return visible_rect_; } |
| 255 const gfx::Size& natural_size() const { return natural_size_; } | 264 const gfx::Size& natural_size() const { return natural_size_; } |
| 256 | 265 |
| 257 int stride(size_t plane) const; | 266 int stride(size_t plane) const; |
| 258 | 267 |
| 259 // Returns the number of bytes per row and number of rows for a given plane. | 268 // Returns the number of bytes per row and number of rows for a given plane. |
| 260 // | 269 // |
| 261 // As opposed to stride(), row_bytes() refers to the bytes representing | 270 // As opposed to stride(), row_bytes() refers to the bytes representing |
| 262 // frame data scanlines (coded_size.width() pixels, without stride padding). | 271 // frame data scanlines (coded_size.width() pixels, without stride padding). |
| 263 int row_bytes(size_t plane) const; | 272 int row_bytes(size_t plane) const; |
| 264 int rows(size_t plane) const; | 273 int rows(size_t plane) const; |
| 265 | 274 |
| 266 // Returns pointer to the buffer for a given plane. The memory is owned by | 275 // Returns pointer to the buffer for a given plane. The memory is owned by |
| 267 // VideoFrame object and must not be freed by the caller. | 276 // VideoFrame object and must not be freed by the caller. |
| 268 uint8* data(size_t plane) const; | 277 const uint8* data(size_t plane) const; |
| 278 uint8* data(size_t plane); |
| 279 |
| 280 // Returns pointer to the data in the visible region of the frame. I.e. the |
| 281 // returned pointer is offsetted into the plane buffer specified by |
| 282 // visible_rect().origin(). Memory is owned by VideoFrame object and must not |
| 283 // be freed by the caller. |
| 284 const uint8* visible_data(size_t plane) const; |
| 285 uint8* visible_data(size_t plane); |
| 269 | 286 |
| 270 // Returns the mailbox holder of the native texture wrapped by this frame. | 287 // Returns the mailbox holder of the native texture wrapped by this frame. |
| 271 // Only valid to call if this is a NATIVE_TEXTURE frame. Before using the | 288 // Only valid to call if this is a NATIVE_TEXTURE frame. Before using the |
| 272 // mailbox, the caller must wait for the included sync point. | 289 // mailbox, the caller must wait for the included sync point. |
| 273 const gpu::MailboxHolder* mailbox_holder() const; | 290 const gpu::MailboxHolder* mailbox_holder() const; |
| 274 | 291 |
| 275 // Returns the shared-memory handle, if present | 292 // Returns the shared-memory handle, if present |
| 276 base::SharedMemoryHandle shared_memory_handle() const; | 293 base::SharedMemoryHandle shared_memory_handle() const; |
| 277 | 294 |
| 278 #if defined(OS_POSIX) | 295 #if defined(OS_POSIX) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 // This method is thread safe. Both blink and compositor threads can call it. | 329 // This method is thread safe. Both blink and compositor threads can call it. |
| 313 void UpdateReleaseSyncPoint(SyncPointClient* client); | 330 void UpdateReleaseSyncPoint(SyncPointClient* client); |
| 314 | 331 |
| 315 // Used to keep a running hash of seen frames. Expects an initialized MD5 | 332 // Used to keep a running hash of seen frames. Expects an initialized MD5 |
| 316 // context. Calls MD5Update with the context and the contents of the frame. | 333 // context. Calls MD5Update with the context and the contents of the frame. |
| 317 void HashFrameForTesting(base::MD5Context* context); | 334 void HashFrameForTesting(base::MD5Context* context); |
| 318 | 335 |
| 319 private: | 336 private: |
| 320 friend class base::RefCountedThreadSafe<VideoFrame>; | 337 friend class base::RefCountedThreadSafe<VideoFrame>; |
| 321 | 338 |
| 322 // Returns true if |plane| is a valid plane number for the given format. This | |
| 323 // can be used to DCHECK() plane parameters. | |
| 324 static bool IsValidPlane(size_t plane, VideoFrame::Format format); | |
| 325 | |
| 326 // Clients must use the static CreateFrame() method to create a new frame. | 339 // Clients must use the static CreateFrame() method to create a new frame. |
| 327 VideoFrame(Format format, | 340 VideoFrame(Format format, |
| 328 const gfx::Size& coded_size, | 341 const gfx::Size& coded_size, |
| 329 const gfx::Rect& visible_rect, | 342 const gfx::Rect& visible_rect, |
| 330 const gfx::Size& natural_size, | 343 const gfx::Size& natural_size, |
| 331 scoped_ptr<gpu::MailboxHolder> mailbox_holder, | 344 scoped_ptr<gpu::MailboxHolder> mailbox_holder, |
| 332 base::TimeDelta timestamp, | 345 base::TimeDelta timestamp, |
| 333 bool end_of_stream); | 346 bool end_of_stream); |
| 334 virtual ~VideoFrame(); | 347 virtual ~VideoFrame(); |
| 335 | 348 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 uint32 release_sync_point_; | 402 uint32 release_sync_point_; |
| 390 | 403 |
| 391 const bool end_of_stream_; | 404 const bool end_of_stream_; |
| 392 | 405 |
| 393 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 406 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
| 394 }; | 407 }; |
| 395 | 408 |
| 396 } // namespace media | 409 } // namespace media |
| 397 | 410 |
| 398 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 411 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
| OLD | NEW |