| 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 #include "media/base/video_frame.h" | 5 #include "media/base/video_frame.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <climits> | 8 #include <climits> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 VideoPixelFormat format, | 149 VideoPixelFormat format, |
| 150 const gfx::Size& coded_size, | 150 const gfx::Size& coded_size, |
| 151 const gfx::Rect& visible_rect, | 151 const gfx::Rect& visible_rect, |
| 152 const gfx::Size& natural_size, | 152 const gfx::Size& natural_size, |
| 153 base::TimeDelta timestamp) { | 153 base::TimeDelta timestamp) { |
| 154 return CreateFrameInternal(format, coded_size, visible_rect, natural_size, | 154 return CreateFrameInternal(format, coded_size, visible_rect, natural_size, |
| 155 timestamp, true); | 155 timestamp, true); |
| 156 } | 156 } |
| 157 | 157 |
| 158 // static | 158 // static |
| 159 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( | 159 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTextures( |
| 160 VideoPixelFormat format, | 160 VideoPixelFormat format, |
| 161 const gpu::MailboxHolder& mailbox_holder, | 161 const gpu::MailboxHolder (&mailbox_holders)[kMaxPlanes], |
| 162 const ReleaseMailboxCB& mailbox_holder_release_cb, | 162 const ReleaseMailboxCB& mailbox_holder_release_cb, |
| 163 const gfx::Size& coded_size, | 163 const gfx::Size& coded_size, |
| 164 const gfx::Rect& visible_rect, | 164 const gfx::Rect& visible_rect, |
| 165 const gfx::Size& natural_size, | 165 const gfx::Size& natural_size, |
| 166 base::TimeDelta timestamp) { | 166 base::TimeDelta timestamp) { |
| 167 if (format != PIXEL_FORMAT_ARGB && format != PIXEL_FORMAT_XRGB && | 167 if (format != PIXEL_FORMAT_ARGB && format != PIXEL_FORMAT_XRGB && |
| 168 format != PIXEL_FORMAT_UYVY && format != PIXEL_FORMAT_NV12) { | 168 format != PIXEL_FORMAT_UYVY && format != PIXEL_FORMAT_NV12 && |
| 169 format != PIXEL_FORMAT_I420) { |
| 169 LOG(DFATAL) << "Unsupported pixel format supported, got " | 170 LOG(DFATAL) << "Unsupported pixel format supported, got " |
| 170 << VideoPixelFormatToString(format); | 171 << VideoPixelFormatToString(format); |
| 171 return nullptr; | 172 return nullptr; |
| 172 } | 173 } |
| 173 const StorageType storage = STORAGE_OPAQUE; | 174 const StorageType storage = STORAGE_OPAQUE; |
| 174 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { | 175 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { |
| 175 LOG(DFATAL) << __FUNCTION__ << " Invalid config." | 176 LOG(DFATAL) << __FUNCTION__ << " Invalid config." |
| 176 << ConfigToString(format, storage, coded_size, visible_rect, | 177 << ConfigToString(format, storage, coded_size, visible_rect, |
| 177 natural_size); | 178 natural_size); |
| 178 return nullptr; | 179 return nullptr; |
| 179 } | 180 } |
| 180 | 181 |
| 181 gpu::MailboxHolder mailbox_holders[kMaxPlanes]; | |
| 182 mailbox_holders[kARGBPlane] = mailbox_holder; | |
| 183 return new VideoFrame(format, storage, coded_size, visible_rect, natural_size, | 182 return new VideoFrame(format, storage, coded_size, visible_rect, natural_size, |
| 184 mailbox_holders, mailbox_holder_release_cb, timestamp); | 183 mailbox_holders, mailbox_holder_release_cb, timestamp); |
| 185 } | 184 } |
| 186 | |
| 187 // static | |
| 188 scoped_refptr<VideoFrame> VideoFrame::WrapYUV420NativeTextures( | |
| 189 const gpu::MailboxHolder& y_mailbox_holder, | |
| 190 const gpu::MailboxHolder& u_mailbox_holder, | |
| 191 const gpu::MailboxHolder& v_mailbox_holder, | |
| 192 const ReleaseMailboxCB& mailbox_holder_release_cb, | |
| 193 const gfx::Size& coded_size, | |
| 194 const gfx::Rect& visible_rect, | |
| 195 const gfx::Size& natural_size, | |
| 196 base::TimeDelta timestamp) { | |
| 197 const StorageType storage = STORAGE_OPAQUE; | |
| 198 VideoPixelFormat format = PIXEL_FORMAT_I420; | |
| 199 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { | |
| 200 LOG(DFATAL) << __FUNCTION__ << " Invalid config." | |
| 201 << ConfigToString(format, storage, coded_size, visible_rect, | |
| 202 natural_size); | |
| 203 return nullptr; | |
| 204 } | |
| 205 | |
| 206 gpu::MailboxHolder mailbox_holders[kMaxPlanes]; | |
| 207 mailbox_holders[kYPlane] = y_mailbox_holder; | |
| 208 mailbox_holders[kUPlane] = u_mailbox_holder; | |
| 209 mailbox_holders[kVPlane] = v_mailbox_holder; | |
| 210 return new VideoFrame(format, storage, coded_size, visible_rect, natural_size, | |
| 211 mailbox_holders, mailbox_holder_release_cb, timestamp); | |
| 212 } | |
| 213 | 185 |
| 214 // static | 186 // static |
| 215 scoped_refptr<VideoFrame> VideoFrame::WrapExternalData( | 187 scoped_refptr<VideoFrame> VideoFrame::WrapExternalData( |
| 216 VideoPixelFormat format, | 188 VideoPixelFormat format, |
| 217 const gfx::Size& coded_size, | 189 const gfx::Size& coded_size, |
| 218 const gfx::Rect& visible_rect, | 190 const gfx::Rect& visible_rect, |
| 219 const gfx::Size& natural_size, | 191 const gfx::Size& natural_size, |
| 220 uint8_t* data, | 192 uint8_t* data, |
| 221 size_t data_size, | 193 size_t data_size, |
| 222 base::TimeDelta timestamp) { | 194 base::TimeDelta timestamp) { |
| (...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 if (zero_initialize_memory) | 1083 if (zero_initialize_memory) |
| 1112 memset(data, 0, data_size); | 1084 memset(data, 0, data_size); |
| 1113 | 1085 |
| 1114 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) | 1086 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
| 1115 data_[plane] = data + offset[plane]; | 1087 data_[plane] = data + offset[plane]; |
| 1116 | 1088 |
| 1117 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); | 1089 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); |
| 1118 } | 1090 } |
| 1119 | 1091 |
| 1120 } // namespace media | 1092 } // namespace media |
| OLD | NEW |