Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
|
Pawel Osciak
2016/01/07 09:22:36
We'll have to s/2015/2016/ at some point I think.
Owen Lin
2016/01/12 09:30:23
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_ | |
| 6 #define CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_ | |
| 7 | |
| 8 #include <list> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/callback.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "content/common/gpu/media/arc/arc_video_accelerator.h" | |
| 14 #include "media/video/video_decode_accelerator.h" | |
| 15 | |
| 16 namespace content { | |
| 17 namespace arc { | |
| 18 | |
| 19 class ArcGpuVideoDecodeAccelerator | |
|
Pawel Osciak
2016/01/07 09:22:36
Please document what this class is for.
Owen Lin
2016/01/12 09:30:23
Done.
| |
| 20 : public ArcVideoAccelerator, | |
| 21 public media::VideoDecodeAccelerator::Client { | |
| 22 public: | |
| 23 ArcGpuVideoDecodeAccelerator(); | |
| 24 | |
| 25 // Implementation of the ArcVideoAccelerator interface. | |
| 26 status_t Initialize(DeviceType device, | |
| 27 ArcVideoAccelerator::Client* client) override; | |
| 28 status_t SetBufferCount(PortType port, size_t* count) override; | |
| 29 status_t SetBufferFormat(PortType port, const BufferFormat& format) override; | |
| 30 status_t BindSharedBuffer(PortType port, | |
| 31 uint32_t index, | |
| 32 int ashmem_fd, | |
| 33 size_t offset, | |
| 34 size_t length) override; | |
| 35 status_t BindGraphicBuffer(PortType port, | |
| 36 uint32_t index, | |
| 37 int dmabuf_fd) override; | |
| 38 void UseBuffer(PortType port, | |
| 39 uint32_t index, | |
| 40 const BufferMetadata& metadata) override; | |
| 41 void Reset() override; | |
| 42 | |
| 43 // Implementation of the VideoDecodeAccelerator::Client interface. | |
| 44 void ProvidePictureBuffers(uint32_t requested_num_of_buffers, | |
| 45 const gfx::Size& dimensions, | |
| 46 uint32_t texture_target) override; | |
| 47 void DismissPictureBuffer(int32_t picture_buffer); | |
|
Pawel Osciak
2016/01/07 09:22:36
override
Owen Lin
2016/01/12 09:30:23
Done.
| |
| 48 void PictureReady(const media::Picture& picture) override; | |
| 49 void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override; | |
| 50 void NotifyFlushDone() override; | |
| 51 void NotifyResetDone() override; | |
| 52 void NotifyError(media::VideoDecodeAccelerator::Error error) override; | |
| 53 | |
| 54 private: | |
| 55 // Enumerations indicate the state of an buffer. | |
| 56 enum BufferState { | |
| 57 NOT_BOUND, // The buffer is not bound yet. | |
| 58 OWNED_BY_CLIENT, // The buffer is sent to and used by |client_|. | |
| 59 OWNED_BY_US, // The buffer is owned by us. | |
| 60 OWNED_BY_VDA, // The buffer is sent to and used by |vda_|. | |
| 61 }; | |
| 62 | |
| 63 struct BufferInfo { | |
|
Pawel Osciak
2016/01/07 09:22:36
For bitstream buffers (inputs), I think we could s
Owen Lin
2016/01/12 09:30:23
Done.
| |
| 64 BufferState state; | |
| 65 | |
| 66 // The file handle to access the buffer. It is owned by this ArcGVDA and | |
| 67 // should be freed if not used. | |
| 68 base::ScopedFD handle; | |
| 69 off_t offset; | |
| 70 size_t length; | |
| 71 | |
| 72 BufferInfo(); | |
| 73 }; | |
| 74 | |
| 75 struct PortInfo { | |
| 76 MemoryType memory_type; | |
| 77 std::vector<BufferInfo> buffers; | |
| 78 | |
| 79 PortInfo(); | |
| 80 }; | |
| 81 | |
| 82 // The related information of a bitstream buffer. | |
| 83 struct InputRecord { | |
| 84 int32_t bitstream_buffer_id; | |
| 85 uint32_t index; | |
| 86 int64_t timestamp; | |
| 87 | |
| 88 InputRecord(int32_t bitstream_buffer_id, uint32_t index, int64_t timestamp); | |
| 89 }; | |
| 90 | |
| 91 // Helper function to Send the end-of-stream output buffer if | |
| 92 // |pending_eos_output_buffer_| is true, or reuse the picture in ArcVDA. | |
| 93 void SendEosIfNeededOrReusePicture(uint32_t index, BufferInfo* info); | |
| 94 | |
| 95 // Helper function to get a BufferInfo. Returns |nullptr| if the |port| or | |
| 96 // |index| is invalid. | |
| 97 BufferInfo* GetBufferInfo(PortType port, uint32_t index); | |
| 98 | |
| 99 // Helper function to get the used buffer index and timestamp of the | |
| 100 // |bitstream_buffer_id|. | |
| 101 void GetInputRecord(int32_t bitstream_buffer_id, | |
| 102 uint32_t* index, | |
| 103 int64_t* timestamp); | |
| 104 | |
| 105 // Helper function to set the used buffer index and timestamp of the | |
| 106 // |bitstream_buffer_id|. | |
| 107 void SetInputRecord(int32_t bitstream_buffer_id, | |
| 108 uint32_t index, | |
| 109 int64_t timestamp); | |
| 110 | |
| 111 // Indicates a pending EOS output buffer. When it is true, an EOS output | |
| 112 // buffer need to be sent to |arc_client_| once an output buffer is available. | |
| 113 bool pending_eos_output_buffer_; | |
| 114 scoped_ptr<media::VideoDecodeAccelerator> vda_; | |
| 115 | |
| 116 // It's safe to use the pointer here, the life cycle of the |arc_client_| | |
| 117 // is longer than this ArcGpuVideoDecodeAccelerator. | |
| 118 ArcVideoAccelerator::Client* arc_client_; | |
| 119 | |
| 120 // The callback called when reset completes. | |
| 121 base::Closure reset_done_callback_; | |
| 122 | |
| 123 PortInfo port_info_[PORT_COUNT]; | |
| 124 | |
| 125 // The serial number used as the bitstream_buffer_id, started from 0. | |
| 126 int32_t bitstream_buffer_serial_; | |
| 127 | |
| 128 std::list<InputRecord> input_records_; | |
| 129 | |
| 130 gfx::Size coded_size_; | |
| 131 }; | |
| 132 | |
| 133 } // namespace arc | |
| 134 } // namespace content | |
| 135 | |
| 136 #endif // CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_ | |
| OLD | NEW |