| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // |min_size| Minimum size needed by libvpx to decompress the next frame. | 111 // |min_size| Minimum size needed by libvpx to decompress the next frame. |
| 112 // |fb| Pointer to the frame buffer to update. | 112 // |fb| Pointer to the frame buffer to update. |
| 113 // Returns 0 on success. Returns < 0 on failure. | 113 // Returns 0 on success. Returns < 0 on failure. |
| 114 static int32 GetVP9FrameBuffer(void* user_priv, size_t min_size, | 114 static int32 GetVP9FrameBuffer(void* user_priv, size_t min_size, |
| 115 vpx_codec_frame_buffer* fb); | 115 vpx_codec_frame_buffer* fb); |
| 116 | 116 |
| 117 // Callback that will be called by libvpx when the frame buffer is no longer | 117 // Callback that will be called by libvpx when the frame buffer is no longer |
| 118 // being used by libvpx. Parameters: | 118 // being used by libvpx. Parameters: |
| 119 // |user_priv| Private data passed to libvpx (pointer to memory pool). | 119 // |user_priv| Private data passed to libvpx (pointer to memory pool). |
| 120 // |fb| Pointer to the frame buffer that's being released. | 120 // |fb| Pointer to the frame buffer that's being released. |
| 121 static int32 ReleaseVP9FrameBuffer(void *user_priv, | 121 static int32 ReleaseVP9FrameBuffer(void* user_priv, |
| 122 vpx_codec_frame_buffer *fb); | 122 vpx_codec_frame_buffer* fb); |
| 123 | 123 |
| 124 // Generates a "no_longer_needed" closure that holds a reference to this pool. | 124 // Generates a "no_longer_needed" closure that holds a reference to this pool. |
| 125 base::Closure CreateFrameCallback(void* fb_priv_data); | 125 base::Closure CreateFrameCallback(void* fb_priv_data); |
| 126 | 126 |
| 127 // base::MemoryDumpProvider. | 127 // base::MemoryDumpProvider. |
| 128 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 128 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 129 base::trace_event::ProcessMemoryDump* pmd) override; | 129 base::trace_event::ProcessMemoryDump* pmd) override; |
| 130 | 130 |
| 131 int NumberOfFrameBuffersInUseByDecoder() const; | 131 int NumberOfFrameBuffersInUseByDecoder() const; |
| 132 int NumberOfFrameBuffersInUseByDecoderAndVideoFrame() const; | 132 int NumberOfFrameBuffersInUseByDecoderAndVideoFrame() const; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 fb->size = fb_to_use->data.size(); | 209 fb->size = fb_to_use->data.size(); |
| 210 ++fb_to_use->ref_cnt; | 210 ++fb_to_use->ref_cnt; |
| 211 ++memory_pool->in_use_by_decoder_; | 211 ++memory_pool->in_use_by_decoder_; |
| 212 | 212 |
| 213 // Set the frame buffer's private data to point at the external frame buffer. | 213 // Set the frame buffer's private data to point at the external frame buffer. |
| 214 fb->priv = static_cast<void*>(fb_to_use); | 214 fb->priv = static_cast<void*>(fb_to_use); |
| 215 return 0; | 215 return 0; |
| 216 } | 216 } |
| 217 | 217 |
| 218 int32 VpxVideoDecoder::MemoryPool::ReleaseVP9FrameBuffer( | 218 int32 VpxVideoDecoder::MemoryPool::ReleaseVP9FrameBuffer( |
| 219 void *user_priv, vpx_codec_frame_buffer *fb) { | 219 void* user_priv, |
| 220 vpx_codec_frame_buffer* fb) { |
| 220 DCHECK(user_priv); | 221 DCHECK(user_priv); |
| 221 DCHECK(fb); | 222 DCHECK(fb); |
| 222 VP9FrameBuffer* frame_buffer = static_cast<VP9FrameBuffer*>(fb->priv); | 223 VP9FrameBuffer* frame_buffer = static_cast<VP9FrameBuffer*>(fb->priv); |
| 223 --frame_buffer->ref_cnt; | 224 --frame_buffer->ref_cnt; |
| 224 | 225 |
| 225 VpxVideoDecoder::MemoryPool* memory_pool = | 226 VpxVideoDecoder::MemoryPool* memory_pool = |
| 226 static_cast<VpxVideoDecoder::MemoryPool*>(user_priv); | 227 static_cast<VpxVideoDecoder::MemoryPool*>(user_priv); |
| 227 --memory_pool->in_use_by_decoder_; | 228 --memory_pool->in_use_by_decoder_; |
| 228 if (frame_buffer->ref_cnt) | 229 if (frame_buffer->ref_cnt) |
| 229 --memory_pool->in_use_by_decoder_and_video_frame_; | 230 --memory_pool->in_use_by_decoder_and_video_frame_; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 bound_decode_cb.Run(kOk); | 345 bound_decode_cb.Run(kOk); |
| 345 return; | 346 return; |
| 346 } | 347 } |
| 347 | 348 |
| 348 scoped_refptr<VideoFrame> video_frame; | 349 scoped_refptr<VideoFrame> video_frame; |
| 349 if (!VpxDecode(buffer, &video_frame)) { | 350 if (!VpxDecode(buffer, &video_frame)) { |
| 350 state_ = kError; | 351 state_ = kError; |
| 351 bound_decode_cb.Run(kDecodeError); | 352 bound_decode_cb.Run(kDecodeError); |
| 352 return; | 353 return; |
| 353 } | 354 } |
| 354 // We might get a successfull VpxDecode but not a frame if only a partial | 355 // We might get a successful VpxDecode but not a frame if only a partial |
| 355 // decode happened. | 356 // decode happened. |
| 356 if (video_frame.get()) | 357 if (video_frame.get()) |
| 357 output_cb_.Run(video_frame); | 358 output_cb_.Run(video_frame); |
| 358 | 359 |
| 359 // VideoDecoderShim expects |decode_cb| call after |output_cb_|. | 360 // VideoDecoderShim expects |decode_cb| call after |output_cb_|. |
| 360 bound_decode_cb.Run(kOk); | 361 bound_decode_cb.Run(kOk); |
| 361 } | 362 } |
| 362 | 363 |
| 363 void VpxVideoDecoder::Reset(const base::Closure& closure) { | 364 void VpxVideoDecoder::Reset(const base::Closure& closure) { |
| 364 DCHECK(thread_checker_.CalledOnValidThread()); | 365 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 (*video_frame)->visible_data(VideoFrame::kYPlane), | 602 (*video_frame)->visible_data(VideoFrame::kYPlane), |
| 602 (*video_frame)->stride(VideoFrame::kYPlane), | 603 (*video_frame)->stride(VideoFrame::kYPlane), |
| 603 (*video_frame)->visible_data(VideoFrame::kUPlane), | 604 (*video_frame)->visible_data(VideoFrame::kUPlane), |
| 604 (*video_frame)->stride(VideoFrame::kUPlane), | 605 (*video_frame)->stride(VideoFrame::kUPlane), |
| 605 (*video_frame)->visible_data(VideoFrame::kVPlane), | 606 (*video_frame)->visible_data(VideoFrame::kVPlane), |
| 606 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(), | 607 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(), |
| 607 coded_size.height()); | 608 coded_size.height()); |
| 608 } | 609 } |
| 609 | 610 |
| 610 } // namespace media | 611 } // namespace media |
| OLD | NEW |