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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 output_cb_ = BindToCurrentLoop(output_cb); | 394 output_cb_ = BindToCurrentLoop(output_cb); |
395 bound_init_cb.Run(true); | 395 bound_init_cb.Run(true); |
396 } | 396 } |
397 | 397 |
398 void VpxVideoDecoder::DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer, | 398 void VpxVideoDecoder::DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer, |
399 const DecodeCB& bound_decode_cb) { | 399 const DecodeCB& bound_decode_cb) { |
400 DCHECK_NE(state_, kUninitialized) | 400 DCHECK_NE(state_, kUninitialized) |
401 << "Called Decode() before successful Initialize()"; | 401 << "Called Decode() before successful Initialize()"; |
402 | 402 |
403 if (state_ == kError) { | 403 if (state_ == kError) { |
404 bound_decode_cb.Run(kDecodeError); | 404 bound_decode_cb.Run(DecodeStatus::DECODE_ERROR); |
405 return; | 405 return; |
406 } | 406 } |
407 | 407 |
408 if (state_ == kDecodeFinished) { | 408 if (state_ == kDecodeFinished) { |
409 bound_decode_cb.Run(kOk); | 409 bound_decode_cb.Run(DecodeStatus::OK); |
410 return; | 410 return; |
411 } | 411 } |
412 | 412 |
413 if (state_ == kNormal && buffer->end_of_stream()) { | 413 if (state_ == kNormal && buffer->end_of_stream()) { |
414 state_ = kDecodeFinished; | 414 state_ = kDecodeFinished; |
415 bound_decode_cb.Run(kOk); | 415 bound_decode_cb.Run(DecodeStatus::OK); |
416 return; | 416 return; |
417 } | 417 } |
418 | 418 |
419 scoped_refptr<VideoFrame> video_frame; | 419 scoped_refptr<VideoFrame> video_frame; |
420 if (!VpxDecode(buffer, &video_frame)) { | 420 if (!VpxDecode(buffer, &video_frame)) { |
421 state_ = kError; | 421 state_ = kError; |
422 bound_decode_cb.Run(kDecodeError); | 422 bound_decode_cb.Run(DecodeStatus::DECODE_ERROR); |
423 return; | 423 return; |
424 } | 424 } |
425 | 425 |
426 // We might get a successful VpxDecode but not a frame if only a partial | 426 // We might get a successful VpxDecode but not a frame if only a partial |
427 // decode happened. | 427 // decode happened. |
428 if (video_frame) { | 428 if (video_frame) { |
429 // Safe to call |output_cb_| here even if we're on the offload thread since | 429 // Safe to call |output_cb_| here even if we're on the offload thread since |
430 // it is only set once during Initialize() and never changed. | 430 // it is only set once during Initialize() and never changed. |
431 output_cb_.Run(video_frame); | 431 output_cb_.Run(video_frame); |
432 } | 432 } |
433 | 433 |
434 // VideoDecoderShim expects |decode_cb| call after |output_cb_|. | 434 // VideoDecoderShim expects |decode_cb| call after |output_cb_|. |
435 bound_decode_cb.Run(kOk); | 435 bound_decode_cb.Run(DecodeStatus::OK); |
436 } | 436 } |
437 | 437 |
438 void VpxVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, | 438 void VpxVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, |
439 const DecodeCB& decode_cb) { | 439 const DecodeCB& decode_cb) { |
440 DCHECK(thread_checker_.CalledOnValidThread()); | 440 DCHECK(thread_checker_.CalledOnValidThread()); |
441 DCHECK(buffer.get()); | 441 DCHECK(buffer.get()); |
442 DCHECK(!decode_cb.is_null()); | 442 DCHECK(!decode_cb.is_null()); |
443 | 443 |
444 DecodeCB bound_decode_cb = BindToCurrentLoop(decode_cb); | 444 DecodeCB bound_decode_cb = BindToCurrentLoop(decode_cb); |
445 | 445 |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 (*video_frame)->visible_data(VideoFrame::kUPlane), | 725 (*video_frame)->visible_data(VideoFrame::kUPlane), |
726 (*video_frame)->stride(VideoFrame::kUPlane), | 726 (*video_frame)->stride(VideoFrame::kUPlane), |
727 (*video_frame)->visible_data(VideoFrame::kVPlane), | 727 (*video_frame)->visible_data(VideoFrame::kVPlane), |
728 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(), | 728 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(), |
729 coded_size.height()); | 729 coded_size.height()); |
730 | 730 |
731 return true; | 731 return true; |
732 } | 732 } |
733 | 733 |
734 } // namespace media | 734 } // namespace media |
OLD | NEW |