| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "media/base/buffers.h" | 8 #include "media/base/buffers.h" |
| 9 | 9 |
| 10 namespace media { | 10 namespace media { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 RGB555, // 16bpp RGB packed 5:5:5 | 29 RGB555, // 16bpp RGB packed 5:5:5 |
| 30 RGB565, // 16bpp RGB packed 5:6:5 | 30 RGB565, // 16bpp RGB packed 5:6:5 |
| 31 RGB24, // 24bpp RGB packed 8:8:8 | 31 RGB24, // 24bpp RGB packed 8:8:8 |
| 32 RGB32, // 32bpp RGB packed with extra byte 8:8:8 | 32 RGB32, // 32bpp RGB packed with extra byte 8:8:8 |
| 33 RGBA, // 32bpp RGBA packed 8:8:8:8 | 33 RGBA, // 32bpp RGBA packed 8:8:8:8 |
| 34 YV12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples | 34 YV12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples |
| 35 YV16, // 16bpp YVU planar 1x1 Y, 2x1 VU samples | 35 YV16, // 16bpp YVU planar 1x1 Y, 2x1 VU samples |
| 36 EMPTY, // An empty frame. | 36 EMPTY, // An empty frame. |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 enum BufferType { |
| 40 TYPE_SYSTEM_MEMORY, |
| 41 TYPE_OMX_BUFFER_HEAD, |
| 42 TYPE_EGL_IMAGE, |
| 43 }; |
| 44 |
| 39 public: | 45 public: |
| 40 // Creates a new frame with given parameters. Buffers for the frame are | 46 // Creates a new frame with given parameters. Buffers for the frame are |
| 41 // allocated but not initialized. | 47 // allocated but not initialized. |
| 42 static void CreateFrame(Format format, | 48 static void CreateFrame(Format format, |
| 43 size_t width, | 49 size_t width, |
| 44 size_t height, | 50 size_t height, |
| 45 base::TimeDelta timestamp, | 51 base::TimeDelta timestamp, |
| 46 base::TimeDelta duration, | 52 base::TimeDelta duration, |
| 47 scoped_refptr<VideoFrame>* frame_out); | 53 scoped_refptr<VideoFrame>* frame_out); |
| 48 | 54 |
| 49 // Creates a frame with format equals to VideoFrame::EMPTY, width, height | 55 // Creates a frame with format equals to VideoFrame::EMPTY, width, height |
| 50 // timestamp and duration are all 0. | 56 // timestamp and duration are all 0. |
| 51 static void CreateEmptyFrame(scoped_refptr<VideoFrame>* frame_out); | 57 static void CreateEmptyFrame(scoped_refptr<VideoFrame>* frame_out); |
| 52 | 58 |
| 53 // Allocates YV12 frame based on |width| and |height|, and sets its data to | 59 // Allocates YV12 frame based on |width| and |height|, and sets its data to |
| 54 // the YUV equivalent of RGB(0,0,0). | 60 // the YUV equivalent of RGB(0,0,0). |
| 55 static void CreateBlackFrame(int width, int height, | 61 static void CreateBlackFrame(int width, int height, |
| 56 scoped_refptr<VideoFrame>* frame_out); | 62 scoped_refptr<VideoFrame>* frame_out); |
| 57 | 63 |
| 64 virtual BufferType type() const { return TYPE_SYSTEM_MEMORY; } |
| 65 |
| 58 Format format() const { return format_; } | 66 Format format() const { return format_; } |
| 59 | 67 |
| 60 size_t width() const { return width_; } | 68 size_t width() const { return width_; } |
| 61 | 69 |
| 62 size_t height() const { return height_; } | 70 size_t height() const { return height_; } |
| 63 | 71 |
| 64 size_t planes() const { return planes_; } | 72 size_t planes() const { return planes_; } |
| 65 | 73 |
| 66 int32 stride(size_t plane) const { return strides_[plane]; } | 74 int32 stride(size_t plane) const { return strides_[plane]; } |
| 67 | 75 |
| 68 // Returns pointer to the buffer for a given plane. The memory is owned by | 76 // Returns pointer to the buffer for a given plane. The memory is owned by |
| 69 // VideoFrame object and must not be freed by the caller. | 77 // VideoFrame object and must not be freed by the caller. |
| 70 uint8* data(size_t plane) const { return data_[plane]; } | 78 uint8* data(size_t plane) const { return data_[plane]; } |
| 71 | 79 |
| 72 // StreamSample interface. | 80 // StreamSample interface. |
| 73 virtual bool IsEndOfStream() const; | 81 virtual bool IsEndOfStream() const; |
| 74 | 82 |
| 75 int GetRepeatCount() const { | 83 int GetRepeatCount() const { |
| 76 return repeat_count_; | 84 return repeat_count_; |
| 77 } | 85 } |
| 78 | 86 |
| 79 void SetRepeatCount(int repeat_count) { | 87 void SetRepeatCount(int repeat_count) { |
| 80 repeat_count_ = repeat_count; | 88 repeat_count_ = repeat_count; |
| 81 } | 89 } |
| 82 | 90 |
| 83 private: | 91 protected: |
| 84 // Clients must use the static CreateFrame() method to create a new frame. | 92 // Clients must use the static CreateFrame() method to create a new frame. |
| 85 VideoFrame(Format format, | 93 VideoFrame(Format format, |
| 86 size_t video_width, | 94 size_t video_width, |
| 87 size_t video_height); | 95 size_t video_height); |
| 88 | 96 |
| 89 virtual ~VideoFrame(); | 97 virtual ~VideoFrame(); |
| 90 | 98 |
| 91 // Used internally by CreateFrame(). | 99 // Used internally by CreateFrame(). |
| 92 bool AllocateRGB(size_t bytes_per_pixel); | 100 bool AllocateRGB(size_t bytes_per_pixel); |
| 93 bool AllocateYUV(); | 101 bool AllocateYUV(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 113 | 121 |
| 114 // Display meta data | 122 // Display meta data |
| 115 int repeat_count_; | 123 int repeat_count_; |
| 116 | 124 |
| 117 DISALLOW_COPY_AND_ASSIGN(VideoFrame); | 125 DISALLOW_COPY_AND_ASSIGN(VideoFrame); |
| 118 }; | 126 }; |
| 119 | 127 |
| 120 } // namespace media | 128 } // namespace media |
| 121 | 129 |
| 122 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 130 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
| OLD | NEW |