| 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 #ifndef MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ |
| 6 #define MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ | 6 #define MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 enum DecoderState { | 50 enum DecoderState { |
| 51 kUninitialized, | 51 kUninitialized, |
| 52 kNormal, | 52 kNormal, |
| 53 kFlushCodec, | 53 kFlushCodec, |
| 54 kDecodeFinished, | 54 kDecodeFinished, |
| 55 kError | 55 kError |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 // Return values for decoding alpha plane. |
| 59 enum AlphaDecodeStatus { |
| 60 kAlphaPlaneProcessed, // Alpha plane (if found) was decoded successfully. |
| 61 kNoAlphaPlaneData, // Alpha plane was found, but decoder did not return any |
| 62 // data. |
| 63 kAlphaPlaneError // Fatal error occured when trying to decode alpha plane. |
| 64 }; |
| 65 |
| 58 // Handles (re-)initializing the decoder with a (new) config. | 66 // Handles (re-)initializing the decoder with a (new) config. |
| 59 // Returns true when initialization was successful. | 67 // Returns true when initialization was successful. |
| 60 bool ConfigureDecoder(const VideoDecoderConfig& config); | 68 bool ConfigureDecoder(const VideoDecoderConfig& config); |
| 61 | 69 |
| 62 void CloseDecoder(); | 70 void CloseDecoder(); |
| 63 | 71 |
| 64 // Try to decode |buffer| into |video_frame|. Return true if all decoding | 72 // Try to decode |buffer| into |video_frame|. Return true if all decoding |
| 65 // succeeded. Note that decoding can succeed and still |video_frame| be | 73 // succeeded. Note that decoding can succeed and still |video_frame| be |
| 66 // nullptr if there has been a partial decoding. | 74 // nullptr if there has been a partial decoding. |
| 67 bool VpxDecode(const scoped_refptr<DecoderBuffer>& buffer, | 75 bool VpxDecode(const scoped_refptr<DecoderBuffer>& buffer, |
| 68 scoped_refptr<VideoFrame>* video_frame); | 76 scoped_refptr<VideoFrame>* video_frame); |
| 69 | 77 |
| 70 bool CopyVpxImageToVideoFrame(const struct vpx_image* vpx_image, | 78 bool CopyVpxImageToVideoFrame(const struct vpx_image* vpx_image, |
| 79 const struct vpx_image* vpx_image_alpha, |
| 71 scoped_refptr<VideoFrame>* video_frame); | 80 scoped_refptr<VideoFrame>* video_frame); |
| 72 | 81 |
| 82 AlphaDecodeStatus DecodeAlphaPlane( |
| 83 const struct vpx_image* vpx_image, |
| 84 const struct vpx_image** vpx_image_alpha, |
| 85 const scoped_refptr<DecoderBuffer>& buffer); |
| 86 |
| 73 base::ThreadChecker thread_checker_; | 87 base::ThreadChecker thread_checker_; |
| 74 | 88 |
| 75 DecoderState state_; | 89 DecoderState state_; |
| 76 | 90 |
| 77 OutputCB output_cb_; | 91 OutputCB output_cb_; |
| 78 | 92 |
| 79 VideoDecoderConfig config_; | 93 VideoDecoderConfig config_; |
| 80 | 94 |
| 81 vpx_codec_ctx* vpx_codec_; | 95 vpx_codec_ctx* vpx_codec_; |
| 82 vpx_codec_ctx* vpx_codec_alpha_; | 96 vpx_codec_ctx* vpx_codec_alpha_; |
| 83 | 97 |
| 84 // |memory_pool_| is a single-threaded memory pool used for VP9 decoding | 98 // |memory_pool_| is a single-threaded memory pool used for VP9 decoding |
| 85 // with no alpha. |frame_pool_| is used for all other cases. | 99 // with no alpha. |frame_pool_| is used for all other cases. |
| 86 class MemoryPool; | 100 class MemoryPool; |
| 87 scoped_refptr<MemoryPool> memory_pool_; | 101 scoped_refptr<MemoryPool> memory_pool_; |
| 88 | 102 |
| 89 VideoFramePool frame_pool_; | 103 VideoFramePool frame_pool_; |
| 90 | 104 |
| 91 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); | 105 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); |
| 92 }; | 106 }; |
| 93 | 107 |
| 94 } // namespace media | 108 } // namespace media |
| 95 | 109 |
| 96 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ | 110 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ |
| OLD | NEW |