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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( | 221 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( |
222 VideoPixelFormat format, | 222 VideoPixelFormat format, |
223 const gpu::MailboxHolder& mailbox_holder, | 223 const gpu::MailboxHolder& mailbox_holder, |
224 const ReleaseMailboxCB& mailbox_holder_release_cb, | 224 const ReleaseMailboxCB& mailbox_holder_release_cb, |
225 const gfx::Size& coded_size, | 225 const gfx::Size& coded_size, |
226 const gfx::Rect& visible_rect, | 226 const gfx::Rect& visible_rect, |
227 const gfx::Size& natural_size, | 227 const gfx::Size& natural_size, |
228 base::TimeDelta timestamp) { | 228 base::TimeDelta timestamp) { |
229 if (format != PIXEL_FORMAT_ARGB && format != PIXEL_FORMAT_XRGB && | 229 if (format != PIXEL_FORMAT_ARGB && format != PIXEL_FORMAT_XRGB && |
230 format != PIXEL_FORMAT_UYVY && format != PIXEL_FORMAT_NV12) { | 230 format != PIXEL_FORMAT_UYVY && format != PIXEL_FORMAT_NV12) { |
231 DLOG(ERROR) << "Unsupported pixel format supported, got " | 231 LOG(DFATAL) << "Unsupported pixel format supported, got " |
232 << VideoPixelFormatToString(format); | 232 << VideoPixelFormatToString(format); |
233 return nullptr; | 233 return nullptr; |
234 } | 234 } |
235 const StorageType storage = STORAGE_OPAQUE; | 235 const StorageType storage = STORAGE_OPAQUE; |
236 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { | 236 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { |
237 DLOG(ERROR) << __FUNCTION__ << " Invalid config." | 237 LOG(DFATAL) << __FUNCTION__ << " Invalid config." |
238 << ConfigToString(format, storage, coded_size, visible_rect, | 238 << ConfigToString(format, storage, coded_size, visible_rect, |
239 natural_size); | 239 natural_size); |
240 return nullptr; | 240 return nullptr; |
241 } | 241 } |
242 | 242 |
243 gpu::MailboxHolder mailbox_holders[kMaxPlanes]; | 243 gpu::MailboxHolder mailbox_holders[kMaxPlanes]; |
244 mailbox_holders[kARGBPlane] = mailbox_holder; | 244 mailbox_holders[kARGBPlane] = mailbox_holder; |
245 return new VideoFrame(format, storage, coded_size, visible_rect, natural_size, | 245 return new VideoFrame(format, storage, coded_size, visible_rect, natural_size, |
246 mailbox_holders, mailbox_holder_release_cb, timestamp); | 246 mailbox_holders, mailbox_holder_release_cb, timestamp); |
247 } | 247 } |
248 | 248 |
249 // static | 249 // static |
250 scoped_refptr<VideoFrame> VideoFrame::WrapYUV420NativeTextures( | 250 scoped_refptr<VideoFrame> VideoFrame::WrapYUV420NativeTextures( |
251 const gpu::MailboxHolder& y_mailbox_holder, | 251 const gpu::MailboxHolder& y_mailbox_holder, |
252 const gpu::MailboxHolder& u_mailbox_holder, | 252 const gpu::MailboxHolder& u_mailbox_holder, |
253 const gpu::MailboxHolder& v_mailbox_holder, | 253 const gpu::MailboxHolder& v_mailbox_holder, |
254 const ReleaseMailboxCB& mailbox_holder_release_cb, | 254 const ReleaseMailboxCB& mailbox_holder_release_cb, |
255 const gfx::Size& coded_size, | 255 const gfx::Size& coded_size, |
256 const gfx::Rect& visible_rect, | 256 const gfx::Rect& visible_rect, |
257 const gfx::Size& natural_size, | 257 const gfx::Size& natural_size, |
258 base::TimeDelta timestamp) { | 258 base::TimeDelta timestamp) { |
259 const StorageType storage = STORAGE_OPAQUE; | 259 const StorageType storage = STORAGE_OPAQUE; |
260 VideoPixelFormat format = PIXEL_FORMAT_I420; | 260 VideoPixelFormat format = PIXEL_FORMAT_I420; |
261 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { | 261 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { |
262 DLOG(ERROR) << __FUNCTION__ << " Invalid config." | 262 LOG(DFATAL) << __FUNCTION__ << " Invalid config." |
263 << ConfigToString(format, storage, coded_size, visible_rect, | 263 << ConfigToString(format, storage, coded_size, visible_rect, |
264 natural_size); | 264 natural_size); |
265 return nullptr; | 265 return nullptr; |
266 } | 266 } |
267 | 267 |
268 gpu::MailboxHolder mailbox_holders[kMaxPlanes]; | 268 gpu::MailboxHolder mailbox_holders[kMaxPlanes]; |
269 mailbox_holders[kYPlane] = y_mailbox_holder; | 269 mailbox_holders[kYPlane] = y_mailbox_holder; |
270 mailbox_holders[kUPlane] = u_mailbox_holder; | 270 mailbox_holders[kUPlane] = u_mailbox_holder; |
271 mailbox_holders[kVPlane] = v_mailbox_holder; | 271 mailbox_holders[kVPlane] = v_mailbox_holder; |
272 return new VideoFrame(format, storage, coded_size, visible_rect, natural_size, | 272 return new VideoFrame(format, storage, coded_size, visible_rect, natural_size, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 const gfx::Size& natural_size, | 311 const gfx::Size& natural_size, |
312 int32 y_stride, | 312 int32 y_stride, |
313 int32 u_stride, | 313 int32 u_stride, |
314 int32 v_stride, | 314 int32 v_stride, |
315 uint8* y_data, | 315 uint8* y_data, |
316 uint8* u_data, | 316 uint8* u_data, |
317 uint8* v_data, | 317 uint8* v_data, |
318 base::TimeDelta timestamp) { | 318 base::TimeDelta timestamp) { |
319 const StorageType storage = STORAGE_UNOWNED_MEMORY; | 319 const StorageType storage = STORAGE_UNOWNED_MEMORY; |
320 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { | 320 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { |
321 DLOG(ERROR) << __FUNCTION__ << " Invalid config." | 321 LOG(DFATAL) << __FUNCTION__ << " Invalid config." |
322 << ConfigToString(format, storage, coded_size, visible_rect, | 322 << ConfigToString(format, storage, coded_size, visible_rect, |
323 natural_size); | 323 natural_size); |
324 return nullptr; | 324 return nullptr; |
325 } | 325 } |
326 | 326 |
327 scoped_refptr<VideoFrame> frame(new VideoFrame( | 327 scoped_refptr<VideoFrame> frame(new VideoFrame( |
328 format, storage, coded_size, visible_rect, natural_size, timestamp)); | 328 format, storage, coded_size, visible_rect, natural_size, timestamp)); |
329 frame->strides_[kYPlane] = y_stride; | 329 frame->strides_[kYPlane] = y_stride; |
330 frame->strides_[kUPlane] = u_stride; | 330 frame->strides_[kUPlane] = u_stride; |
331 frame->strides_[kVPlane] = v_stride; | 331 frame->strides_[kVPlane] = v_stride; |
(...skipping 14 matching lines...) Expand all Loading... |
346 int32 v_stride, | 346 int32 v_stride, |
347 uint8* y_data, | 347 uint8* y_data, |
348 uint8* u_data, | 348 uint8* u_data, |
349 uint8* v_data, | 349 uint8* v_data, |
350 const gfx::GpuMemoryBufferHandle& y_handle, | 350 const gfx::GpuMemoryBufferHandle& y_handle, |
351 const gfx::GpuMemoryBufferHandle& u_handle, | 351 const gfx::GpuMemoryBufferHandle& u_handle, |
352 const gfx::GpuMemoryBufferHandle& v_handle, | 352 const gfx::GpuMemoryBufferHandle& v_handle, |
353 base::TimeDelta timestamp) { | 353 base::TimeDelta timestamp) { |
354 const StorageType storage = STORAGE_GPU_MEMORY_BUFFERS; | 354 const StorageType storage = STORAGE_GPU_MEMORY_BUFFERS; |
355 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { | 355 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { |
356 DLOG(ERROR) << __FUNCTION__ << " Invalid config." | 356 LOG(DFATAL) << __FUNCTION__ << " Invalid config." |
357 << ConfigToString(format, storage, coded_size, visible_rect, | 357 << ConfigToString(format, storage, coded_size, visible_rect, |
358 natural_size); | 358 natural_size); |
359 return nullptr; | 359 return nullptr; |
360 } | 360 } |
361 | 361 |
362 scoped_refptr<VideoFrame> frame(new VideoFrame( | 362 scoped_refptr<VideoFrame> frame(new VideoFrame( |
363 format, storage, coded_size, visible_rect, natural_size, timestamp)); | 363 format, storage, coded_size, visible_rect, natural_size, timestamp)); |
364 frame->strides_[kYPlane] = y_stride; | 364 frame->strides_[kYPlane] = y_stride; |
365 frame->strides_[kUPlane] = u_stride; | 365 frame->strides_[kUPlane] = u_stride; |
366 frame->strides_[kVPlane] = v_stride; | 366 frame->strides_[kVPlane] = v_stride; |
(...skipping 14 matching lines...) Expand all Loading... |
381 const gfx::Rect& visible_rect, | 381 const gfx::Rect& visible_rect, |
382 const gfx::Size& natural_size, | 382 const gfx::Size& natural_size, |
383 const std::vector<int>& dmabuf_fds, | 383 const std::vector<int>& dmabuf_fds, |
384 base::TimeDelta timestamp) { | 384 base::TimeDelta timestamp) { |
385 #if defined(OS_CHROMEOS) | 385 #if defined(OS_CHROMEOS) |
386 DCHECK_EQ(format, PIXEL_FORMAT_NV12); | 386 DCHECK_EQ(format, PIXEL_FORMAT_NV12); |
387 #endif | 387 #endif |
388 | 388 |
389 const StorageType storage = STORAGE_DMABUFS; | 389 const StorageType storage = STORAGE_DMABUFS; |
390 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { | 390 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { |
391 DLOG(ERROR) << __FUNCTION__ << " Invalid config." | 391 LOG(DFATAL) << __FUNCTION__ << " Invalid config." |
392 << ConfigToString(format, storage, coded_size, visible_rect, | 392 << ConfigToString(format, storage, coded_size, visible_rect, |
393 natural_size); | 393 natural_size); |
394 return nullptr; | 394 return nullptr; |
395 } | 395 } |
396 | 396 |
397 gpu::MailboxHolder mailbox_holders[kMaxPlanes]; | 397 gpu::MailboxHolder mailbox_holders[kMaxPlanes]; |
398 scoped_refptr<VideoFrame> frame = | 398 scoped_refptr<VideoFrame> frame = |
399 new VideoFrame(format, storage, coded_size, visible_rect, natural_size, | 399 new VideoFrame(format, storage, coded_size, visible_rect, natural_size, |
400 mailbox_holders, ReleaseMailboxCB(), timestamp); | 400 mailbox_holders, ReleaseMailboxCB(), timestamp); |
401 if (!frame || !frame->DuplicateFileDescriptors(dmabuf_fds)) | 401 if (!frame || !frame->DuplicateFileDescriptors(dmabuf_fds)) { |
| 402 LOG(DFATAL) << __FUNCTION__ << " Couldn't duplicate fds."; |
402 return nullptr; | 403 return nullptr; |
| 404 } |
403 return frame; | 405 return frame; |
404 } | 406 } |
405 #endif | 407 #endif |
406 | 408 |
407 #if defined(OS_MACOSX) | 409 #if defined(OS_MACOSX) |
408 // static | 410 // static |
409 scoped_refptr<VideoFrame> VideoFrame::WrapCVPixelBuffer( | 411 scoped_refptr<VideoFrame> VideoFrame::WrapCVPixelBuffer( |
410 CVPixelBufferRef cv_pixel_buffer, | 412 CVPixelBufferRef cv_pixel_buffer, |
411 base::TimeDelta timestamp) { | 413 base::TimeDelta timestamp) { |
412 DCHECK(cv_pixel_buffer); | 414 DCHECK(cv_pixel_buffer); |
413 DCHECK(CFGetTypeID(cv_pixel_buffer) == CVPixelBufferGetTypeID()); | 415 DCHECK(CFGetTypeID(cv_pixel_buffer) == CVPixelBufferGetTypeID()); |
414 | 416 |
415 const OSType cv_format = CVPixelBufferGetPixelFormatType(cv_pixel_buffer); | 417 const OSType cv_format = CVPixelBufferGetPixelFormatType(cv_pixel_buffer); |
416 VideoPixelFormat format; | 418 VideoPixelFormat format; |
417 // There are very few compatible CV pixel formats, so just check each. | 419 // There are very few compatible CV pixel formats, so just check each. |
418 if (cv_format == kCVPixelFormatType_420YpCbCr8Planar) { | 420 if (cv_format == kCVPixelFormatType_420YpCbCr8Planar) { |
419 format = PIXEL_FORMAT_I420; | 421 format = PIXEL_FORMAT_I420; |
420 } else if (cv_format == kCVPixelFormatType_444YpCbCr8) { | 422 } else if (cv_format == kCVPixelFormatType_444YpCbCr8) { |
421 format = PIXEL_FORMAT_YV24; | 423 format = PIXEL_FORMAT_YV24; |
422 } else if (cv_format == '420v') { | 424 } else if (cv_format == '420v') { |
423 // TODO(jfroy): Use kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange when the | 425 // TODO(jfroy): Use kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange when the |
424 // minimum OS X and iOS SDKs permits it. | 426 // minimum OS X and iOS SDKs permits it. |
425 format = PIXEL_FORMAT_NV12; | 427 format = PIXEL_FORMAT_NV12; |
426 } else { | 428 } else { |
427 DLOG(ERROR) << "CVPixelBuffer format not supported: " << cv_format; | 429 LOG(DFATAL) << "CVPixelBuffer format not supported: " << cv_format; |
428 return nullptr; | 430 return nullptr; |
429 } | 431 } |
430 | 432 |
431 const gfx::Size coded_size(CVImageBufferGetEncodedSize(cv_pixel_buffer)); | 433 const gfx::Size coded_size(CVImageBufferGetEncodedSize(cv_pixel_buffer)); |
432 const gfx::Rect visible_rect(CVImageBufferGetCleanRect(cv_pixel_buffer)); | 434 const gfx::Rect visible_rect(CVImageBufferGetCleanRect(cv_pixel_buffer)); |
433 const gfx::Size natural_size(CVImageBufferGetDisplaySize(cv_pixel_buffer)); | 435 const gfx::Size natural_size(CVImageBufferGetDisplaySize(cv_pixel_buffer)); |
434 const StorageType storage = STORAGE_UNOWNED_MEMORY; | 436 const StorageType storage = STORAGE_UNOWNED_MEMORY; |
435 | 437 |
436 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { | 438 if (!IsValidConfig(format, storage, coded_size, visible_rect, natural_size)) { |
437 DLOG(ERROR) << __FUNCTION__ << " Invalid config." | 439 LOG(DFATAL) << __FUNCTION__ << " Invalid config." |
438 << ConfigToString(format, storage, coded_size, visible_rect, | 440 << ConfigToString(format, storage, coded_size, visible_rect, |
439 natural_size); | 441 natural_size); |
440 return nullptr; | 442 return nullptr; |
441 } | 443 } |
442 | 444 |
443 scoped_refptr<VideoFrame> frame(new VideoFrame( | 445 scoped_refptr<VideoFrame> frame(new VideoFrame( |
444 format, storage, coded_size, visible_rect, natural_size, timestamp)); | 446 format, storage, coded_size, visible_rect, natural_size, timestamp)); |
445 | 447 |
446 frame->cv_pixel_buffer_.reset(cv_pixel_buffer, base::scoped_policy::RETAIN); | 448 frame->cv_pixel_buffer_.reset(cv_pixel_buffer, base::scoped_policy::RETAIN); |
447 return frame; | 449 return frame; |
448 } | 450 } |
449 #endif | 451 #endif |
450 | 452 |
451 // static | 453 // static |
452 scoped_refptr<VideoFrame> VideoFrame::WrapVideoFrame( | 454 scoped_refptr<VideoFrame> VideoFrame::WrapVideoFrame( |
453 const scoped_refptr<VideoFrame>& frame, | 455 const scoped_refptr<VideoFrame>& frame, |
454 const gfx::Rect& visible_rect, | 456 const gfx::Rect& visible_rect, |
455 const gfx::Size& natural_size) { | 457 const gfx::Size& natural_size) { |
456 // Frames with textures need mailbox info propagated, and there's no support | 458 // Frames with textures need mailbox info propagated, and there's no support |
457 // for that here yet, see http://crbug/362521. | 459 // for that here yet, see http://crbug/362521. |
458 CHECK(!frame->HasTextures()); | 460 CHECK(!frame->HasTextures()); |
459 | 461 |
460 DCHECK(frame->visible_rect().Contains(visible_rect)); | 462 DCHECK(frame->visible_rect().Contains(visible_rect)); |
461 | 463 |
462 if (!IsValidConfig(frame->format(), frame->storage_type(), | 464 if (!IsValidConfig(frame->format(), frame->storage_type(), |
463 frame->coded_size(), visible_rect, natural_size)) { | 465 frame->coded_size(), visible_rect, natural_size)) { |
464 DLOG(ERROR) << __FUNCTION__ << " Invalid config." | 466 LOG(DFATAL) << __FUNCTION__ << " Invalid config." |
465 << ConfigToString(frame->format(), frame->storage_type(), | 467 << ConfigToString(frame->format(), frame->storage_type(), |
466 frame->coded_size(), visible_rect, | 468 frame->coded_size(), visible_rect, |
467 natural_size); | 469 natural_size); |
468 return nullptr; | 470 return nullptr; |
469 } | 471 } |
470 | 472 |
471 scoped_refptr<VideoFrame> wrapping_frame(new VideoFrame( | 473 scoped_refptr<VideoFrame> wrapping_frame(new VideoFrame( |
472 frame->format(), frame->storage_type(), frame->coded_size(), visible_rect, | 474 frame->format(), frame->storage_type(), frame->coded_size(), visible_rect, |
473 natural_size, frame->timestamp())); | 475 natural_size, frame->timestamp())); |
474 if (frame->metadata()->IsTrue(VideoFrameMetadata::END_OF_STREAM)) { | 476 if (frame->metadata()->IsTrue(VideoFrameMetadata::END_OF_STREAM)) { |
475 wrapping_frame->metadata()->SetBoolean(VideoFrameMetadata::END_OF_STREAM, | 477 wrapping_frame->metadata()->SetBoolean(VideoFrameMetadata::END_OF_STREAM, |
476 true); | 478 true); |
477 } | 479 } |
478 | 480 |
479 for (size_t i = 0; i < NumPlanes(frame->format()); ++i) { | 481 for (size_t i = 0; i < NumPlanes(frame->format()); ++i) { |
480 wrapping_frame->strides_[i] = frame->stride(i); | 482 wrapping_frame->strides_[i] = frame->stride(i); |
481 wrapping_frame->data_[i] = frame->data(i); | 483 wrapping_frame->data_[i] = frame->data(i); |
482 } | 484 } |
483 | 485 |
484 #if defined(OS_LINUX) | 486 #if defined(OS_LINUX) |
485 // If there are any |dmabuf_fds_| plugged in, we should duplicate them. | 487 // If there are any |dmabuf_fds_| plugged in, we should duplicate them. |
486 if (frame->storage_type() == STORAGE_DMABUFS) { | 488 if (frame->storage_type() == STORAGE_DMABUFS) { |
487 std::vector<int> original_fds; | 489 std::vector<int> original_fds; |
488 for (size_t i = 0; i < kMaxPlanes; ++i) | 490 for (size_t i = 0; i < kMaxPlanes; ++i) |
489 original_fds.push_back(frame->dmabuf_fd(i)); | 491 original_fds.push_back(frame->dmabuf_fd(i)); |
490 if (!wrapping_frame->DuplicateFileDescriptors(original_fds)) | 492 if (!wrapping_frame->DuplicateFileDescriptors(original_fds)) { |
| 493 LOG(DFATAL) << __FUNCTION__ << " Invalid config."; |
491 return nullptr; | 494 return nullptr; |
| 495 } |
492 } | 496 } |
493 #endif | 497 #endif |
494 | 498 |
495 if (frame->storage_type() == STORAGE_SHMEM) | 499 if (frame->storage_type() == STORAGE_SHMEM) |
496 wrapping_frame->AddSharedMemoryHandle(frame->shared_memory_handle_); | 500 wrapping_frame->AddSharedMemoryHandle(frame->shared_memory_handle_); |
497 | 501 |
498 return wrapping_frame; | 502 return wrapping_frame; |
499 } | 503 } |
500 | 504 |
501 // static | 505 // static |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 // maintained by the general compositor team. Please contact | 548 // maintained by the general compositor team. Please contact |
545 // wonsik@chromium.org . | 549 // wonsik@chromium.org . |
546 | 550 |
547 // static | 551 // static |
548 scoped_refptr<VideoFrame> VideoFrame::CreateHoleFrame( | 552 scoped_refptr<VideoFrame> VideoFrame::CreateHoleFrame( |
549 const gfx::Size& size) { | 553 const gfx::Size& size) { |
550 const VideoPixelFormat format = PIXEL_FORMAT_UNKNOWN; | 554 const VideoPixelFormat format = PIXEL_FORMAT_UNKNOWN; |
551 const StorageType storage = STORAGE_HOLE; | 555 const StorageType storage = STORAGE_HOLE; |
552 const gfx::Rect visible_rect = gfx::Rect(size); | 556 const gfx::Rect visible_rect = gfx::Rect(size); |
553 if (!IsValidConfig(format, storage, size, visible_rect, size)) { | 557 if (!IsValidConfig(format, storage, size, visible_rect, size)) { |
554 DLOG(ERROR) << __FUNCTION__ << " Invalid config." | 558 LOG(DFATAL) << __FUNCTION__ << " Invalid config." |
555 << ConfigToString(format, storage, size, visible_rect, size); | 559 << ConfigToString(format, storage, size, visible_rect, size); |
556 return nullptr; | 560 return nullptr; |
557 } | 561 } |
558 scoped_refptr<VideoFrame> frame(new VideoFrame( | 562 scoped_refptr<VideoFrame> frame(new VideoFrame( |
559 format, storage, size, gfx::Rect(size), size, base::TimeDelta())); | 563 format, storage, size, gfx::Rect(size), size, base::TimeDelta())); |
560 return frame; | 564 return frame; |
561 } | 565 } |
562 #endif // defined(VIDEO_HOLE) | 566 #endif // defined(VIDEO_HOLE) |
563 | 567 |
564 // static | 568 // static |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 uint8* data, | 832 uint8* data, |
829 size_t data_size, | 833 size_t data_size, |
830 base::TimeDelta timestamp, | 834 base::TimeDelta timestamp, |
831 base::SharedMemoryHandle handle, | 835 base::SharedMemoryHandle handle, |
832 size_t data_offset) { | 836 size_t data_offset) { |
833 DCHECK(IsStorageTypeMappable(storage_type)); | 837 DCHECK(IsStorageTypeMappable(storage_type)); |
834 | 838 |
835 // TODO(miu): This function should support any pixel format. | 839 // TODO(miu): This function should support any pixel format. |
836 // http://crbug.com/555909 | 840 // http://crbug.com/555909 |
837 if (format != PIXEL_FORMAT_I420) { | 841 if (format != PIXEL_FORMAT_I420) { |
838 DLOG(ERROR) << "Only PIXEL_FORMAT_I420 format supported: " | 842 LOG(DFATAL) << "Only PIXEL_FORMAT_I420 format supported: " |
839 << VideoPixelFormatToString(format); | 843 << VideoPixelFormatToString(format); |
840 return nullptr; | 844 return nullptr; |
841 } | 845 } |
842 | 846 |
843 if (!IsValidConfig(format, storage_type, coded_size, visible_rect, | 847 if (!IsValidConfig(format, storage_type, coded_size, visible_rect, |
844 natural_size)) { | 848 natural_size)) { |
845 DLOG(ERROR) << __FUNCTION__ << " Invalid config." | 849 LOG(DFATAL) << __FUNCTION__ << " Invalid config." |
846 << ConfigToString(format, storage_type, coded_size, | 850 << ConfigToString(format, storage_type, coded_size, |
847 visible_rect, natural_size); | 851 visible_rect, natural_size); |
848 return nullptr; | 852 return nullptr; |
849 } | 853 } |
850 | 854 |
851 scoped_refptr<VideoFrame> frame; | 855 scoped_refptr<VideoFrame> frame; |
852 if (storage_type == STORAGE_SHMEM) { | 856 if (storage_type == STORAGE_SHMEM) { |
853 frame = new VideoFrame(format, storage_type, coded_size, visible_rect, | 857 frame = new VideoFrame(format, storage_type, coded_size, visible_rect, |
854 natural_size, timestamp, handle, data_offset); | 858 natural_size, timestamp, handle, data_offset); |
855 } else { | 859 } else { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 const gfx::Size alignment = CommonAlignment(format); | 967 const gfx::Size alignment = CommonAlignment(format); |
964 const gfx::Size new_coded_size = | 968 const gfx::Size new_coded_size = |
965 gfx::Size(RoundUp(coded_size.width(), alignment.width()), | 969 gfx::Size(RoundUp(coded_size.width(), alignment.width()), |
966 RoundUp(coded_size.height(), alignment.height())); | 970 RoundUp(coded_size.height(), alignment.height())); |
967 DCHECK((new_coded_size.width() % alignment.width() == 0) && | 971 DCHECK((new_coded_size.width() % alignment.width() == 0) && |
968 (new_coded_size.height() % alignment.height() == 0)); | 972 (new_coded_size.height() % alignment.height() == 0)); |
969 | 973 |
970 const StorageType storage = STORAGE_OWNED_MEMORY; | 974 const StorageType storage = STORAGE_OWNED_MEMORY; |
971 if (!IsValidConfig(format, storage, new_coded_size, visible_rect, | 975 if (!IsValidConfig(format, storage, new_coded_size, visible_rect, |
972 natural_size)) { | 976 natural_size)) { |
973 DLOG(ERROR) << __FUNCTION__ << " Invalid config." | 977 LOG(DFATAL) << __FUNCTION__ << " Invalid config." |
974 << ConfigToString(format, storage, coded_size, visible_rect, | 978 << ConfigToString(format, storage, coded_size, visible_rect, |
975 natural_size); | 979 natural_size); |
976 return nullptr; | 980 return nullptr; |
977 } | 981 } |
978 | 982 |
979 scoped_refptr<VideoFrame> frame(new VideoFrame( | 983 scoped_refptr<VideoFrame> frame(new VideoFrame( |
980 format, storage, new_coded_size, visible_rect, natural_size, timestamp)); | 984 format, storage, new_coded_size, visible_rect, natural_size, timestamp)); |
981 frame->AllocateYUV(zero_initialize_memory); | 985 frame->AllocateYUV(zero_initialize_memory); |
982 return frame; | 986 return frame; |
983 } | 987 } |
(...skipping 27 matching lines...) Expand all Loading... |
1011 if (zero_initialize_memory) | 1015 if (zero_initialize_memory) |
1012 memset(data, 0, data_size); | 1016 memset(data, 0, data_size); |
1013 | 1017 |
1014 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) | 1018 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
1015 data_[plane] = data + offset[plane]; | 1019 data_[plane] = data + offset[plane]; |
1016 | 1020 |
1017 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); | 1021 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); |
1018 } | 1022 } |
1019 | 1023 |
1020 } // namespace media | 1024 } // namespace media |
OLD | NEW |