| 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 // Helper method for decoding buffers either on the offload thread or directly | 72 // Helper method for decoding buffers either on the offload thread or directly |
| 65 // on the media thread. |bound_decode_cb| must be bound to the thread that | 73 // on the media thread. |bound_decode_cb| must be bound to the thread that |
| 66 // called Decode(). | 74 // called Decode(). |
| 67 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer, | 75 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer, |
| 68 const DecodeCB& bound_decode_cb); | 76 const DecodeCB& bound_decode_cb); |
| 69 | 77 |
| 70 // Try to decode |buffer| into |video_frame|. Return true if all decoding | 78 // Try to decode |buffer| into |video_frame|. Return true if all decoding |
| 71 // succeeded. Note that decoding can succeed and still |video_frame| be | 79 // succeeded. Note that decoding can succeed and still |video_frame| be |
| 72 // nullptr if there has been a partial decoding. | 80 // nullptr if there has been a partial decoding. |
| 73 bool VpxDecode(const scoped_refptr<DecoderBuffer>& buffer, | 81 bool VpxDecode(const scoped_refptr<DecoderBuffer>& buffer, |
| 74 scoped_refptr<VideoFrame>* video_frame); | 82 scoped_refptr<VideoFrame>* video_frame); |
| 75 | 83 |
| 76 bool CopyVpxImageToVideoFrame(const struct vpx_image* vpx_image, | 84 bool CopyVpxImageToVideoFrame(const struct vpx_image* vpx_image, |
| 85 const struct vpx_image* vpx_image_alpha, |
| 77 scoped_refptr<VideoFrame>* video_frame); | 86 scoped_refptr<VideoFrame>* video_frame); |
| 78 | 87 |
| 88 AlphaDecodeStatus DecodeAlphaPlane( |
| 89 const struct vpx_image* vpx_image, |
| 90 const struct vpx_image** vpx_image_alpha, |
| 91 const scoped_refptr<DecoderBuffer>& buffer); |
| 92 |
| 79 base::ThreadChecker thread_checker_; | 93 base::ThreadChecker thread_checker_; |
| 80 | 94 |
| 81 // |state_| must only be read and written to on |offload_task_runner_| if it | 95 // |state_| must only be read and written to on |offload_task_runner_| if it |
| 82 // is non-null and there are outstanding tasks on the offload thread. | 96 // is non-null and there are outstanding tasks on the offload thread. |
| 83 DecoderState state_; | 97 DecoderState state_; |
| 84 | 98 |
| 85 OutputCB output_cb_; | 99 OutputCB output_cb_; |
| 86 | 100 |
| 87 VideoDecoderConfig config_; | 101 VideoDecoderConfig config_; |
| 88 | 102 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 99 scoped_refptr<base::SingleThreadTaskRunner> offload_task_runner_; | 113 scoped_refptr<base::SingleThreadTaskRunner> offload_task_runner_; |
| 100 | 114 |
| 101 VideoFramePool frame_pool_; | 115 VideoFramePool frame_pool_; |
| 102 | 116 |
| 103 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); | 117 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); |
| 104 }; | 118 }; |
| 105 | 119 |
| 106 } // namespace media | 120 } // namespace media |
| 107 | 121 |
| 108 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ | 122 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ |
| OLD | NEW |