Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: media/filters/vpx_video_decoder.cc

Issue 16297002: Update media/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 demuxer_stream_->Read(base::Bind( 219 demuxer_stream_->Read(base::Bind(
220 &VpxVideoDecoder::DoDecryptOrDecodeBuffer, weak_this_)); 220 &VpxVideoDecoder::DoDecryptOrDecodeBuffer, weak_this_));
221 } 221 }
222 222
223 void VpxVideoDecoder::DoDecryptOrDecodeBuffer( 223 void VpxVideoDecoder::DoDecryptOrDecodeBuffer(
224 DemuxerStream::Status status, 224 DemuxerStream::Status status,
225 const scoped_refptr<DecoderBuffer>& buffer) { 225 const scoped_refptr<DecoderBuffer>& buffer) {
226 DCHECK(message_loop_->BelongsToCurrentThread()); 226 DCHECK(message_loop_->BelongsToCurrentThread());
227 DCHECK_NE(state_, kDecodeFinished); 227 DCHECK_NE(state_, kDecodeFinished);
228 DCHECK_EQ(status != DemuxerStream::kOk, !buffer) << status; 228 DCHECK_EQ(status != DemuxerStream::kOk, !buffer.get()) << status;
229 229
230 if (state_ == kUninitialized) 230 if (state_ == kUninitialized)
231 return; 231 return;
232 232
233 DCHECK(!read_cb_.is_null()); 233 DCHECK(!read_cb_.is_null());
234 234
235 if (!reset_cb_.is_null()) { 235 if (!reset_cb_.is_null()) {
236 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); 236 base::ResetAndReturn(&read_cb_).Run(kOk, NULL);
237 DoReset(); 237 DoReset();
238 return; 238 return;
(...skipping 10 matching lines...) Expand all
249 } 249 }
250 250
251 void VpxVideoDecoder::DecodeBuffer( 251 void VpxVideoDecoder::DecodeBuffer(
252 const scoped_refptr<DecoderBuffer>& buffer) { 252 const scoped_refptr<DecoderBuffer>& buffer) {
253 DCHECK(message_loop_->BelongsToCurrentThread()); 253 DCHECK(message_loop_->BelongsToCurrentThread());
254 DCHECK_NE(state_, kUninitialized); 254 DCHECK_NE(state_, kUninitialized);
255 DCHECK_NE(state_, kDecodeFinished); 255 DCHECK_NE(state_, kDecodeFinished);
256 DCHECK_NE(state_, kError); 256 DCHECK_NE(state_, kError);
257 DCHECK(reset_cb_.is_null()); 257 DCHECK(reset_cb_.is_null());
258 DCHECK(!read_cb_.is_null()); 258 DCHECK(!read_cb_.is_null());
259 DCHECK(buffer); 259 DCHECK(buffer.get());
260 260
261 // Transition to kDecodeFinished on the first end of stream buffer. 261 // Transition to kDecodeFinished on the first end of stream buffer.
262 if (state_ == kNormal && buffer->IsEndOfStream()) { 262 if (state_ == kNormal && buffer->IsEndOfStream()) {
263 state_ = kDecodeFinished; 263 state_ = kDecodeFinished;
264 base::ResetAndReturn(&read_cb_).Run(kOk, VideoFrame::CreateEmptyFrame()); 264 base::ResetAndReturn(&read_cb_).Run(kOk, VideoFrame::CreateEmptyFrame());
265 return; 265 return;
266 } 266 }
267 267
268 scoped_refptr<VideoFrame> video_frame; 268 scoped_refptr<VideoFrame> video_frame;
269 if (!Decode(buffer, &video_frame)) { 269 if (!Decode(buffer, &video_frame)) {
270 state_ = kError; 270 state_ = kError;
271 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL); 271 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL);
272 return; 272 return;
273 } 273 }
274 274
275 // Any successful decode counts! 275 // Any successful decode counts!
276 if (buffer->GetDataSize() && buffer->GetSideDataSize()) { 276 if (buffer->GetDataSize() && buffer->GetSideDataSize()) {
277 PipelineStatistics statistics; 277 PipelineStatistics statistics;
278 statistics.video_bytes_decoded = buffer->GetDataSize(); 278 statistics.video_bytes_decoded = buffer->GetDataSize();
279 statistics_cb_.Run(statistics); 279 statistics_cb_.Run(statistics);
280 } 280 }
281 281
282 // If we didn't get a frame we need more data. 282 // If we didn't get a frame we need more data.
283 if (!video_frame) { 283 if (!video_frame.get()) {
284 ReadFromDemuxerStream(); 284 ReadFromDemuxerStream();
285 return; 285 return;
286 } 286 }
287 287
288 base::ResetAndReturn(&read_cb_).Run(kOk, video_frame); 288 base::ResetAndReturn(&read_cb_).Run(kOk, video_frame);
289 } 289 }
290 290
291 bool VpxVideoDecoder::Decode( 291 bool VpxVideoDecoder::Decode(
292 const scoped_refptr<DecoderBuffer>& buffer, 292 const scoped_refptr<DecoderBuffer>& buffer,
293 scoped_refptr<VideoFrame>* video_frame) { 293 scoped_refptr<VideoFrame>* video_frame) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 VideoFrame::YV12A : 388 VideoFrame::YV12A :
389 VideoFrame::YV12, 389 VideoFrame::YV12,
390 size, 390 size,
391 gfx::Rect(size), 391 gfx::Rect(size),
392 natural_size, 392 natural_size,
393 kNoTimestamp()); 393 kNoTimestamp());
394 394
395 CopyYPlane(vpx_image->planes[VPX_PLANE_Y], 395 CopyYPlane(vpx_image->planes[VPX_PLANE_Y],
396 vpx_image->stride[VPX_PLANE_Y], 396 vpx_image->stride[VPX_PLANE_Y],
397 vpx_image->d_h, 397 vpx_image->d_h,
398 *video_frame); 398 video_frame->get());
399 CopyUPlane(vpx_image->planes[VPX_PLANE_U], 399 CopyUPlane(vpx_image->planes[VPX_PLANE_U],
400 vpx_image->stride[VPX_PLANE_U], 400 vpx_image->stride[VPX_PLANE_U],
401 vpx_image->d_h / 2, 401 vpx_image->d_h / 2,
402 *video_frame); 402 video_frame->get());
403 CopyVPlane(vpx_image->planes[VPX_PLANE_V], 403 CopyVPlane(vpx_image->planes[VPX_PLANE_V],
404 vpx_image->stride[VPX_PLANE_V], 404 vpx_image->stride[VPX_PLANE_V],
405 vpx_image->d_h / 2, 405 vpx_image->d_h / 2,
406 *video_frame); 406 video_frame->get());
407 if (!vpx_codec_alpha_) 407 if (!vpx_codec_alpha_)
408 return; 408 return;
409 if (!vpx_image_alpha) { 409 if (!vpx_image_alpha) {
410 MakeOpaqueAPlane(vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, 410 MakeOpaqueAPlane(
411 *video_frame); 411 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get());
412 return; 412 return;
413 } 413 }
414 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], 414 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y],
415 vpx_image->stride[VPX_PLANE_Y], 415 vpx_image->stride[VPX_PLANE_Y],
416 vpx_image->d_h, 416 vpx_image->d_h,
417 *video_frame); 417 video_frame->get());
418 } 418 }
419 419
420 } // namespace media 420 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/video_renderer_base_unittest.cc ('k') | media/tools/demuxer_bench/demuxer_bench.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698