| 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 | |
| 66 // Handles (re-)initializing the decoder with a (new) config. | 58 // Handles (re-)initializing the decoder with a (new) config. |
| 67 // Returns true when initialization was successful. | 59 // Returns true when initialization was successful. |
| 68 bool ConfigureDecoder(const VideoDecoderConfig& config); | 60 bool ConfigureDecoder(const VideoDecoderConfig& config); |
| 69 | 61 |
| 70 void CloseDecoder(); | 62 void CloseDecoder(); |
| 71 | 63 |
| 72 // Try to decode |buffer| into |video_frame|. Return true if all decoding | 64 // Try to decode |buffer| into |video_frame|. Return true if all decoding |
| 73 // succeeded. Note that decoding can succeed and still |video_frame| be | 65 // succeeded. Note that decoding can succeed and still |video_frame| be |
| 74 // nullptr if there has been a partial decoding. | 66 // nullptr if there has been a partial decoding. |
| 75 bool VpxDecode(const scoped_refptr<DecoderBuffer>& buffer, | 67 bool VpxDecode(const scoped_refptr<DecoderBuffer>& buffer, |
| 76 scoped_refptr<VideoFrame>* video_frame); | 68 scoped_refptr<VideoFrame>* video_frame); |
| 77 | 69 |
| 78 bool CopyVpxImageToVideoFrame(const struct vpx_image* vpx_image, | 70 bool CopyVpxImageToVideoFrame(const struct vpx_image* vpx_image, |
| 79 const struct vpx_image* vpx_image_alpha, | |
| 80 scoped_refptr<VideoFrame>* video_frame); | 71 scoped_refptr<VideoFrame>* video_frame); |
| 81 | 72 |
| 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 | |
| 87 base::ThreadChecker thread_checker_; | 73 base::ThreadChecker thread_checker_; |
| 88 | 74 |
| 89 DecoderState state_; | 75 DecoderState state_; |
| 90 | 76 |
| 91 OutputCB output_cb_; | 77 OutputCB output_cb_; |
| 92 | 78 |
| 93 VideoDecoderConfig config_; | 79 VideoDecoderConfig config_; |
| 94 | 80 |
| 95 vpx_codec_ctx* vpx_codec_; | 81 vpx_codec_ctx* vpx_codec_; |
| 96 vpx_codec_ctx* vpx_codec_alpha_; | 82 vpx_codec_ctx* vpx_codec_alpha_; |
| 97 | 83 |
| 98 // |memory_pool_| is a single-threaded memory pool used for VP9 decoding | 84 // |memory_pool_| is a single-threaded memory pool used for VP9 decoding |
| 99 // with no alpha. |frame_pool_| is used for all other cases. | 85 // with no alpha. |frame_pool_| is used for all other cases. |
| 100 class MemoryPool; | 86 class MemoryPool; |
| 101 scoped_refptr<MemoryPool> memory_pool_; | 87 scoped_refptr<MemoryPool> memory_pool_; |
| 102 | 88 |
| 103 VideoFramePool frame_pool_; | 89 VideoFramePool frame_pool_; |
| 104 | 90 |
| 105 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); | 91 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); |
| 106 }; | 92 }; |
| 107 | 93 |
| 108 } // namespace media | 94 } // namespace media |
| 109 | 95 |
| 110 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ | 96 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ |
| OLD | NEW |