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