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/filters/vpx_video_decoder.h" | 5 #include "media/filters/vpx_video_decoder.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 *video_frame = nullptr; | 457 *video_frame = nullptr; |
458 return true; | 458 return true; |
459 } | 459 } |
460 | 460 |
461 if (vpx_image->user_priv != user_priv) { | 461 if (vpx_image->user_priv != user_priv) { |
462 DLOG(ERROR) << "Invalid output timestamp."; | 462 DLOG(ERROR) << "Invalid output timestamp."; |
463 return false; | 463 return false; |
464 } | 464 } |
465 | 465 |
466 CopyVpxImageToVideoFrame(vpx_image, video_frame); | 466 CopyVpxImageToVideoFrame(vpx_image, video_frame); |
467 if (!video_frame->get()) { | |
468 DLOG(ERROR) << "Couldn't create video frame"; | |
469 return false; | |
470 } | |
467 (*video_frame)->set_timestamp(base::TimeDelta::FromMicroseconds(timestamp)); | 471 (*video_frame)->set_timestamp(base::TimeDelta::FromMicroseconds(timestamp)); |
468 | 472 |
469 // Default to the color space from the config, but if the bistream specifies | 473 // Default to the color space from the config, but if the bistream specifies |
470 // one, prefer that instead. | 474 // one, prefer that instead. |
471 ColorSpace color_space = config_.color_space(); | 475 ColorSpace color_space = config_.color_space(); |
472 if (vpx_image->cs == VPX_CS_BT_709) | 476 if (vpx_image->cs == VPX_CS_BT_709) |
473 color_space = COLOR_SPACE_HD_REC709; | 477 color_space = COLOR_SPACE_HD_REC709; |
474 else if (vpx_image->cs == VPX_CS_BT_601) | 478 else if (vpx_image->cs == VPX_CS_BT_601) |
475 color_space = COLOR_SPACE_SD_REC601; | 479 color_space = COLOR_SPACE_SD_REC601; |
476 (*video_frame) | 480 (*video_frame) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
569 *video_frame = VideoFrame::WrapExternalYuvData( | 573 *video_frame = VideoFrame::WrapExternalYuvData( |
570 codec_format, | 574 codec_format, |
571 coded_size, gfx::Rect(visible_size), config_.natural_size(), | 575 coded_size, gfx::Rect(visible_size), config_.natural_size(), |
572 vpx_image->stride[VPX_PLANE_Y], | 576 vpx_image->stride[VPX_PLANE_Y], |
573 vpx_image->stride[VPX_PLANE_U], | 577 vpx_image->stride[VPX_PLANE_U], |
574 vpx_image->stride[VPX_PLANE_V], | 578 vpx_image->stride[VPX_PLANE_V], |
575 vpx_image->planes[VPX_PLANE_Y], | 579 vpx_image->planes[VPX_PLANE_Y], |
576 vpx_image->planes[VPX_PLANE_U], | 580 vpx_image->planes[VPX_PLANE_U], |
577 vpx_image->planes[VPX_PLANE_V], | 581 vpx_image->planes[VPX_PLANE_V], |
578 kNoTimestamp()); | 582 kNoTimestamp()); |
579 video_frame->get()->AddDestructionObserver( | 583 if (video_frame->get()) |
580 memory_pool_->CreateFrameCallback(vpx_image->fb_priv)); | 584 video_frame->get()->AddDestructionObserver( |
585 memory_pool_->CreateFrameCallback(vpx_image->fb_priv)); | |
581 | 586 |
582 UMA_HISTOGRAM_COUNTS("Media.Vpx.VideoDecoderBuffersInUseByDecoder", | 587 UMA_HISTOGRAM_COUNTS("Media.Vpx.VideoDecoderBuffersInUseByDecoder", |
583 memory_pool_->NumberOfFrameBuffersInUseByDecoder()); | 588 memory_pool_->NumberOfFrameBuffersInUseByDecoder()); |
584 UMA_HISTOGRAM_COUNTS( | 589 UMA_HISTOGRAM_COUNTS( |
585 "Media.Vpx.VideoDecoderBuffersInUseByDecoderAndVideoFrame", | 590 "Media.Vpx.VideoDecoderBuffersInUseByDecoderAndVideoFrame", |
586 memory_pool_->NumberOfFrameBuffersInUseByDecoderAndVideoFrame()); | 591 memory_pool_->NumberOfFrameBuffersInUseByDecoderAndVideoFrame()); |
587 | 592 |
588 return; | 593 return; |
589 } | 594 } |
590 | 595 |
591 DCHECK(codec_format == PIXEL_FORMAT_YV12 || | 596 DCHECK(codec_format == PIXEL_FORMAT_YV12 || |
592 codec_format == PIXEL_FORMAT_YV12A); | 597 codec_format == PIXEL_FORMAT_YV12A); |
593 | 598 |
594 *video_frame = frame_pool_.CreateFrame( | 599 *video_frame = frame_pool_.CreateFrame( |
Pawel Osciak
2015/11/26 01:19:03
I think this may also fail and return nullptr.
emircan
2015/12/04 04:20:09
My bad. I was trying to handle nullptr in the retu
| |
595 codec_format, visible_size, gfx::Rect(visible_size), | 600 codec_format, visible_size, gfx::Rect(visible_size), |
596 config_.natural_size(), kNoTimestamp()); | 601 config_.natural_size(), kNoTimestamp()); |
597 | 602 |
598 libyuv::I420Copy( | 603 libyuv::I420Copy( |
599 vpx_image->planes[VPX_PLANE_Y], vpx_image->stride[VPX_PLANE_Y], | 604 vpx_image->planes[VPX_PLANE_Y], vpx_image->stride[VPX_PLANE_Y], |
600 vpx_image->planes[VPX_PLANE_U], vpx_image->stride[VPX_PLANE_U], | 605 vpx_image->planes[VPX_PLANE_U], vpx_image->stride[VPX_PLANE_U], |
601 vpx_image->planes[VPX_PLANE_V], vpx_image->stride[VPX_PLANE_V], | 606 vpx_image->planes[VPX_PLANE_V], vpx_image->stride[VPX_PLANE_V], |
602 (*video_frame)->visible_data(VideoFrame::kYPlane), | 607 (*video_frame)->visible_data(VideoFrame::kYPlane), |
603 (*video_frame)->stride(VideoFrame::kYPlane), | 608 (*video_frame)->stride(VideoFrame::kYPlane), |
604 (*video_frame)->visible_data(VideoFrame::kUPlane), | 609 (*video_frame)->visible_data(VideoFrame::kUPlane), |
605 (*video_frame)->stride(VideoFrame::kUPlane), | 610 (*video_frame)->stride(VideoFrame::kUPlane), |
606 (*video_frame)->visible_data(VideoFrame::kVPlane), | 611 (*video_frame)->visible_data(VideoFrame::kVPlane), |
607 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(), | 612 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(), |
608 coded_size.height()); | 613 coded_size.height()); |
609 } | 614 } |
610 | 615 |
611 } // namespace media | 616 } // namespace media |
OLD | NEW |