summaryrefslogtreecommitdiffstats
path: root/content/renderer/media
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-18 22:53:05 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-18 22:53:05 +0000
commit54370ef679aee533c10cf16d504184f4d2825f36 (patch)
treeeba544281e4c2e381152c57e9608c2288dff2d9e /content/renderer/media
parent43823995b45f01bbf8549cbf195a7aea7cb1227d (diff)
downloadchromium_src-54370ef679aee533c10cf16d504184f4d2825f36.zip
chromium_src-54370ef679aee533c10cf16d504184f4d2825f36.tar.gz
chromium_src-54370ef679aee533c10cf16d504184f4d2825f36.tar.bz2
Clean up VideoFrame::CreateXXX and VideoFrame::AllocXXX methods.
No need to confuse people with potentially-NULL pointers due to out-of-memory conditions. Review URL: http://codereview.chromium.org/7396007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92917 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/media')
-rw-r--r--content/renderer/media/rtc_video_decoder.cc45
1 files changed, 7 insertions, 38 deletions
diff --git a/content/renderer/media/rtc_video_decoder.cc b/content/renderer/media/rtc_video_decoder.cc
index d9fbac7..6a92775 100644
--- a/content/renderer/media/rtc_video_decoder.cc
+++ b/content/renderer/media/rtc_video_decoder.cc
@@ -131,37 +131,7 @@ void RTCVideoDecoder::Seek(base::TimeDelta time, const FilterStatusCB& cb) {
// Create output buffer pool and pass the frames to renderer
// so that the renderer can complete the seeking
for (size_t i = 0; i < Limits::kMaxVideoFrames; ++i) {
- scoped_refptr<VideoFrame> video_frame;
- VideoFrame::CreateFrame(VideoFrame::YV12,
- width_,
- height_,
- kNoTimestamp,
- kNoTimestamp,
- &video_frame);
- if (!video_frame.get()) {
- break;
- }
-
- // Create black frame
- const uint8 kBlackY = 0x00;
- const uint8 kBlackUV = 0x80;
- // Fill the Y plane.
- uint8* y_plane = video_frame->data(VideoFrame::kYPlane);
- for (size_t i = 0; i < height_; ++i) {
- memset(y_plane, kBlackY, width_);
- y_plane += video_frame->stride(VideoFrame::kYPlane);
- }
- // Fill the U and V planes.
- uint8* u_plane = video_frame->data(VideoFrame::kUPlane);
- uint8* v_plane = video_frame->data(VideoFrame::kVPlane);
- for (size_t i = 0; i < (height_ / 2); ++i) {
- memset(u_plane, kBlackUV, width_ / 2);
- memset(v_plane, kBlackUV, width_ / 2);
- u_plane += video_frame->stride(VideoFrame::kUPlane);
- v_plane += video_frame->stride(VideoFrame::kVPlane);
- }
-
- VideoFrameReady(video_frame);
+ VideoFrameReady(VideoFrame::CreateBlackFrame(width_, height_));
}
state_ = kNormal;
@@ -220,19 +190,18 @@ bool RTCVideoDecoder::RenderFrame(const cricket::VideoFrame* frame) {
// Check if there's a size change
if (video_frame->width() != width_ || video_frame->height() != height_) {
- video_frame.release();
// Allocate new buffer based on the new size
- VideoFrame::CreateFrame(VideoFrame::YV12,
- width_,
- height_,
- kNoTimestamp,
- kNoTimestamp,
- &video_frame);
+ video_frame = VideoFrame::CreateFrame(VideoFrame::YV12,
+ width_,
+ height_,
+ kNoTimestamp,
+ kNoTimestamp);
}
video_frame->SetTimestamp(host()->GetTime());
video_frame->SetDuration(base::TimeDelta::FromMilliseconds(30));
+ // TODO(scherkus): deduplicate YUV copying code.
uint8* y_plane = video_frame->data(VideoFrame::kYPlane);
const uint8* y_plane_src = frame->GetYPlane();
for (size_t row = 0; row < video_frame->height(); ++row) {