| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <queue> | 11 #include <queue> |
| 12 | 12 |
| 13 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
| 14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
| 19 #include "content/common/gpu/media/h264_dpb.h" | 19 #include "content/common/gpu/media/h264_poc.h" |
| 20 #include "content/common/gpu/media/vt.h" | 20 #include "content/common/gpu/media/vt.h" |
| 21 #include "media/filters/h264_parser.h" | 21 #include "media/filters/h264_parser.h" |
| 22 #include "media/video/video_decode_accelerator.h" | 22 #include "media/video/video_decode_accelerator.h" |
| 23 #include "ui/gfx/geometry/size.h" | 23 #include "ui/gfx/geometry/size.h" |
| 24 #include "ui/gl/gl_context_cgl.h" | 24 #include "ui/gl/gl_context_cgl.h" |
| 25 | 25 |
| 26 namespace base { | 26 namespace base { |
| 27 class SingleThreadTaskRunner; | 27 class SingleThreadTaskRunner; |
| 28 } // namespace base | 28 } // namespace base |
| 29 | 29 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 struct Frame { | 72 struct Frame { |
| 73 Frame(int32_t bitstream_id); | 73 Frame(int32_t bitstream_id); |
| 74 ~Frame(); | 74 ~Frame(); |
| 75 | 75 |
| 76 // ID of the bitstream buffer this Frame will be decoded from. | 76 // ID of the bitstream buffer this Frame will be decoded from. |
| 77 int32_t bitstream_id; | 77 int32_t bitstream_id; |
| 78 | 78 |
| 79 // Relative presentation order of this frame (see AVC spec). | 79 // Relative presentation order of this frame (see AVC spec). |
| 80 // TODO(sandersd): Reorder window size. | |
| 81 int32_t pic_order_cnt; | 80 int32_t pic_order_cnt; |
| 82 | 81 |
| 82 // Nnumber of frames after this one in decode order that can appear before |
| 83 // before it in presentation order. |
| 84 int32_t reorder_window; |
| 85 |
| 83 // Size of the decoded frame. | 86 // Size of the decoded frame. |
| 84 // TODO(sandersd): visible_rect. | 87 // TODO(sandersd): visible_rect. |
| 85 gfx::Size coded_size; | 88 gfx::Size coded_size; |
| 86 | 89 |
| 87 // VideoToolbox decoded image, if decoding was successful. | 90 // VideoToolbox decoded image, if decoding was successful. |
| 88 base::ScopedCFTypeRef<CVImageBufferRef> image; | 91 base::ScopedCFTypeRef<CVImageBufferRef> image; |
| 89 }; | 92 }; |
| 90 | 93 |
| 91 struct Task { | 94 struct Task { |
| 92 Task(TaskType type); | 95 Task(TaskType type); |
| 93 ~Task(); | 96 ~Task(); |
| 94 | 97 |
| 95 TaskType type; | 98 TaskType type; |
| 96 linked_ptr<Frame> frame; | 99 linked_ptr<Frame> frame; |
| 97 }; | 100 }; |
| 98 | 101 |
| 99 // | 102 // |
| 100 // Methods for interacting with VideoToolbox. Run on |decoder_thread_|. | 103 // Methods for interacting with VideoToolbox. Run on |decoder_thread_|. |
| 101 // | 104 // |
| 102 | 105 |
| 106 // Compute the |pic_order_cnt| for a frame. Returns true or calls |
| 107 // NotifyError() before returning false. |
| 108 bool ComputePicOrderCnt( |
| 109 const media::H264SPS* sps, |
| 110 const media::H264SliceHeader& slice_hdr, |
| 111 Frame* frame); |
| 112 |
| 103 // Set up VideoToolbox using the current SPS and PPS. Returns true or calls | 113 // Set up VideoToolbox using the current SPS and PPS. Returns true or calls |
| 104 // NotifyError() before returning false. | 114 // NotifyError() before returning false. |
| 105 bool ConfigureDecoder(); | 115 bool ConfigureDecoder(); |
| 106 | 116 |
| 107 // Wait for VideoToolbox to output all pending frames. Returns true or calls | 117 // Wait for VideoToolbox to output all pending frames. Returns true or calls |
| 108 // NotifyError() before returning false. | 118 // NotifyError() before returning false. |
| 109 bool FinishDelayedFrames(); | 119 bool FinishDelayedFrames(); |
| 110 | 120 |
| 111 // |frame| is owned by |pending_frames_|. | 121 // |frame| is owned by |pending_frames_|. |
| 112 void DecodeTask(const media::BitstreamBuffer&, Frame* frame); | 122 void DecodeTask(const media::BitstreamBuffer&, Frame* frame); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 base::ScopedCFTypeRef<CMFormatDescriptionRef> format_; | 201 base::ScopedCFTypeRef<CMFormatDescriptionRef> format_; |
| 192 base::ScopedCFTypeRef<VTDecompressionSessionRef> session_; | 202 base::ScopedCFTypeRef<VTDecompressionSessionRef> session_; |
| 193 media::H264Parser parser_; | 203 media::H264Parser parser_; |
| 194 gfx::Size coded_size_; | 204 gfx::Size coded_size_; |
| 195 | 205 |
| 196 int last_sps_id_; | 206 int last_sps_id_; |
| 197 std::vector<uint8_t> last_sps_; | 207 std::vector<uint8_t> last_sps_; |
| 198 std::vector<uint8_t> last_spsext_; | 208 std::vector<uint8_t> last_spsext_; |
| 199 int last_pps_id_; | 209 int last_pps_id_; |
| 200 std::vector<uint8_t> last_pps_; | 210 std::vector<uint8_t> last_pps_; |
| 211 H264POC poc_; |
| 201 | 212 |
| 202 // | 213 // |
| 203 // Shared state (set up and torn down on GPU thread). | 214 // Shared state (set up and torn down on GPU thread). |
| 204 // | 215 // |
| 205 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_; | 216 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_; |
| 206 base::ThreadChecker gpu_thread_checker_; | 217 base::ThreadChecker gpu_thread_checker_; |
| 207 base::WeakPtr<VTVideoDecodeAccelerator> weak_this_; | 218 base::WeakPtr<VTVideoDecodeAccelerator> weak_this_; |
| 208 base::Thread decoder_thread_; | 219 base::Thread decoder_thread_; |
| 209 | 220 |
| 210 // Declared last to ensure that all weak pointers are invalidated before | 221 // Declared last to ensure that all weak pointers are invalidated before |
| 211 // other destructors run. | 222 // other destructors run. |
| 212 base::WeakPtrFactory<VTVideoDecodeAccelerator> weak_this_factory_; | 223 base::WeakPtrFactory<VTVideoDecodeAccelerator> weak_this_factory_; |
| 213 | 224 |
| 214 DISALLOW_COPY_AND_ASSIGN(VTVideoDecodeAccelerator); | 225 DISALLOW_COPY_AND_ASSIGN(VTVideoDecodeAccelerator); |
| 215 }; | 226 }; |
| 216 | 227 |
| 217 } // namespace content | 228 } // namespace content |
| 218 | 229 |
| 219 #endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ | 230 #endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |