Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: content/common/gpu/media/arc/arc_gpu_video_decode_accelerator.h

Issue 1549473002: Add ArcGpuVideoDecodeAccelerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/media/arc/arc_gpu_video_decode_accelerator.h
diff --git a/content/common/gpu/media/arc/arc_gpu_video_decode_accelerator.h b/content/common/gpu/media/arc/arc_gpu_video_decode_accelerator.h
new file mode 100644
index 0000000000000000000000000000000000000000..0ba0776835500bd5e020659a094b3d9b7cea2d12
--- /dev/null
+++ b/content/common/gpu/media/arc/arc_gpu_video_decode_accelerator.h
@@ -0,0 +1,138 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_
+#define CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_
+
+#include <list>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/common/gpu/media/arc/arc_video_accelerator.h"
+#include "content/common/gpu/media/arc/arc_video_decode_accelerator.h"
+
+namespace content {
+namespace arc {
+
+class ArcGpuVideoDecodeAccelerator : public ArcVideoAccelerator,
+ public ArcVideoDecodeAccelerator::Client {
+ public:
+ ArcGpuVideoDecodeAccelerator();
+
+ // Implementation of the VideoAccelerator interface.
kcwu 2015/12/23 06:25:43 s/ArcVideoAccelerator/
Owen Lin 2015/12/31 07:22:14 Done.
+ status_t initialize(DeviceType device,
+ ArcVideoAccelerator::Client* client) override;
+
kcwu 2015/12/23 06:25:43 remove blank lines between ArcVideoAccelerator met
Owen Lin 2015/12/31 07:22:14 Done.
+ status_t setBufferCount(PortType port, size_t* count) override;
+
+ status_t setBufferFormat(PortType port, const BufferFormat& format) override;
+
+ status_t bindSharedBuffer(PortType port,
+ uint32_t index,
+ int ashmem_fd,
+ size_t offset,
+ size_t length) override;
+
+ status_t bindGraphicBuffer(PortType port,
+ uint32_t index,
+ int dmabuf_fd) override;
+
+ void useBuffer(PortType port,
+ uint32_t index,
+ const BufferMetadata& metadata) override;
+
+ void reset() override;
+
+ // Implementation of the VideoDecodeAccelerator::Client interface.
+ void RequestPictureBuffers(size_t requested_num_of_buffers,
+ const gfx::Size& coded_size,
+ const gfx::Rect& crop_rect) override;
+ void DismissPictureBuffer(int32_t picture_buffer);
+ void PictureReady(const media::Picture& picture) override;
+ void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override;
+ void NotifyFlushDone() override;
+ void NotifyResetDone() override;
+ void NotifyError(ArcVideoDecodeAccelerator::Error error) override;
+
+ private:
+ // Enumerations indicates the state of an buffer.
kcwu 2015/12/23 06:25:43 s/indicates/indicate/
+ enum BufferState {
+ OWNED_BY_CLIENT, // The buffer is sent to and used by |client_|.
kcwu 2015/12/23 06:25:43 How about add a new state, something like NO_BINDE
Owen Lin 2015/12/31 07:22:14 Done.
+ OWNED_BY_US, // The buffer is owned by us.
+ OWNED_BY_VDA, // The buffer is sent to and used by |arc_vda_|.
+ };
+
+ struct BufferInfo {
+ BufferState state;
+
+ // The file handle to access the buffer. It is owned by this ArcGVDA and
+ // should be freed if not used.
+ base::ScopedFD handle;
+ off_t offset;
+ size_t length;
+
+ BufferInfo();
+ };
+
+ struct PortInfo {
+ MemoryType memory_type;
+ std::vector<BufferInfo> buffers;
+
+ PortInfo();
+ };
+
+ // The related information of a bitstream buffer.
+ struct InputRecord {
+ int32_t bitstream_buffer_id;
+ uint32_t index;
+ int64_t timestamp;
+
+ InputRecord(int32_t bitstream_buffer_id, uint32_t index, int64_t timestamp);
+ };
+
+ // Indicates a pending EOS output buffer. When it is true, an EOS output
+ // buffer need to be sent to |arc_client_| once an output buffer is available.
+ bool pending_eos_output_buffer_;
+ scoped_ptr<ArcVideoDecodeAccelerator> arc_vda_;
+
+ // It's safe to use the pointer here, the life cycle of the |arc_client_|
+ // is longer than this ArcGpuVideoDecodeAccelerator.
+ ArcVideoAccelerator::Client* arc_client_;
+
+ // The callback called when reset completes.
+ base::Closure reset_done_callback_;
+
+ PortInfo port_info_[PORT_COUNT];
+
+ // The serial number used as the bitstream_buffer_id, started from 0.
+ int32_t bitstream_buffer_serial_;
+
+ std::list<InputRecord> input_records_;
+
+ // Helper function to Send the end-of-stream output buffer if
kcwu 2015/12/23 06:25:43 Put these member functions before member variables
Owen Lin 2015/12/31 07:22:14 Done.
+ // |pending_eos_output_buffer_| is true, or reuse the picture in ArcVDA.
+ void SendEosIfNeededOrReusePicture(uint32_t index, BufferInfo* info);
+
+ // Helper function to get a BufferInfo. Returns |nullptr| if the |port| or
+ // |index| is invalid.
+ BufferInfo* GetBufferInfo(PortType port, uint32_t index);
+
+ // Helper function to get the used buffer index and timestamp of the
+ // |bitstream_buffer_id|.
+ void GetInputRecord(int32_t bitstream_buffer_id,
+ uint32_t* index,
+ int64_t* timestamp);
+
+ // Helper function to set the used buffer index and timestamp of the
+ // |bitstream_buffer_id|.
+ void SetInputRecord(int32_t bitstream_buffer_id,
+ uint32_t index,
+ int64_t timestamp);
+};
+
+} // namespace arc
+} // namespace content
+
+#endif // CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_

Powered by Google App Engine
This is Rietveld 408576698