| 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 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 decode_cb_ = BindToCurrentLoop(decode_cb); | 166 decode_cb_ = BindToCurrentLoop(decode_cb); |
| 167 | 167 |
| 168 if (state_ == kError) { | 168 if (state_ == kError) { |
| 169 base::ResetAndReturn(&decode_cb_).Run(kDecodeError, NULL); | 169 base::ResetAndReturn(&decode_cb_).Run(kDecodeError, NULL); |
| 170 return; | 170 return; |
| 171 } | 171 } |
| 172 | 172 |
| 173 // Return empty frames if decoding has finished. | 173 // Return empty frames if decoding has finished. |
| 174 if (state_ == kDecodeFinished) { | 174 if (state_ == kDecodeFinished) { |
| 175 base::ResetAndReturn(&decode_cb_).Run(kOk, VideoFrame::CreateEmptyFrame()); | 175 base::ResetAndReturn(&decode_cb_).Run(kOk, VideoFrame::CreateEOSFrame()); |
| 176 return; | 176 return; |
| 177 } | 177 } |
| 178 | 178 |
| 179 DecodeBuffer(buffer); | 179 DecodeBuffer(buffer); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void VpxVideoDecoder::Reset(const base::Closure& closure) { | 182 void VpxVideoDecoder::Reset(const base::Closure& closure) { |
| 183 DCHECK(message_loop_->BelongsToCurrentThread()); | 183 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 184 DCHECK(reset_cb_.is_null()); | 184 DCHECK(reset_cb_.is_null()); |
| 185 reset_cb_ = BindToCurrentLoop(closure); | 185 reset_cb_ = BindToCurrentLoop(closure); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 DCHECK_NE(state_, kUninitialized); | 217 DCHECK_NE(state_, kUninitialized); |
| 218 DCHECK_NE(state_, kDecodeFinished); | 218 DCHECK_NE(state_, kDecodeFinished); |
| 219 DCHECK_NE(state_, kError); | 219 DCHECK_NE(state_, kError); |
| 220 DCHECK(reset_cb_.is_null()); | 220 DCHECK(reset_cb_.is_null()); |
| 221 DCHECK(!decode_cb_.is_null()); | 221 DCHECK(!decode_cb_.is_null()); |
| 222 DCHECK(buffer); | 222 DCHECK(buffer); |
| 223 | 223 |
| 224 // Transition to kDecodeFinished on the first end of stream buffer. | 224 // Transition to kDecodeFinished on the first end of stream buffer. |
| 225 if (state_ == kNormal && buffer->end_of_stream()) { | 225 if (state_ == kNormal && buffer->end_of_stream()) { |
| 226 state_ = kDecodeFinished; | 226 state_ = kDecodeFinished; |
| 227 base::ResetAndReturn(&decode_cb_).Run(kOk, VideoFrame::CreateEmptyFrame()); | 227 base::ResetAndReturn(&decode_cb_).Run(kOk, VideoFrame::CreateEOSFrame()); |
| 228 return; | 228 return; |
| 229 } | 229 } |
| 230 | 230 |
| 231 scoped_refptr<VideoFrame> video_frame; | 231 scoped_refptr<VideoFrame> video_frame; |
| 232 if (!VpxDecode(buffer, &video_frame)) { | 232 if (!VpxDecode(buffer, &video_frame)) { |
| 233 state_ = kError; | 233 state_ = kError; |
| 234 base::ResetAndReturn(&decode_cb_).Run(kDecodeError, NULL); | 234 base::ResetAndReturn(&decode_cb_).Run(kDecodeError, NULL); |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 | 237 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); | 362 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); |
| 363 return; | 363 return; |
| 364 } | 364 } |
| 365 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], | 365 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], |
| 366 vpx_image->stride[VPX_PLANE_Y], | 366 vpx_image->stride[VPX_PLANE_Y], |
| 367 vpx_image->d_h, | 367 vpx_image->d_h, |
| 368 video_frame->get()); | 368 video_frame->get()); |
| 369 } | 369 } |
| 370 | 370 |
| 371 } // namespace media | 371 } // namespace media |
| OLD | NEW |