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

Unified Diff: chrome/gpu/arc_video_accelerator.h

Issue 1549473002: Add ArcGpuVideoDecodeAccelerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add check for |vda_| in IPC functions. Created 4 years, 9 months 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: chrome/gpu/arc_video_accelerator.h
diff --git a/chrome/gpu/arc_video_accelerator.h b/chrome/gpu/arc_video_accelerator.h
new file mode 100644
index 0000000000000000000000000000000000000000..74d7ec2d0ec7a1d9d8883fa3d86507da008f8aa3
--- /dev/null
+++ b/chrome/gpu/arc_video_accelerator.h
@@ -0,0 +1,133 @@
+// Copyright 2016 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 CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_
+#define CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_
+
+namespace chromeos {
+namespace arc {
+
+enum HalPixelFormatExtension {
+ HAL_PIXEL_FORMAT_H264 = 0x34363248,
+ HAL_PIXEL_FORMAT_VP8 = 0x00385056,
+};
+
+enum PortType {
+ PORT_INPUT = 0,
+ PORT_OUTPUT = 1,
+ PORT_COUNT = 2,
+};
+
+enum BufferFlag {
+ BUFFER_FLAG_EOS = 1,
Pawel Osciak 2016/03/22 08:36:11 Perhaps 1 << 0 to further emphasize these to be bi
Owen Lin 2016/03/24 03:01:11 Done.
+};
+
+struct BufferMetadata {
+ int64_t timestamp = 0; // in microseconds
+ uint32_t flags = 0;
Pawel Osciak 2016/03/22 08:36:11 Please add a comment this should use values from B
Owen Lin 2016/03/24 03:01:10 Done.
+ uint32_t bytes_used = 0;
+};
+
+struct VideoFormat {
+ uint32_t pixel_format = 0;
+ uint32_t buffer_size = 0;
+
+ // minimal number of buffers required to process the video.
Pawel Osciak 2016/03/22 08:36:11 s/minimal/Minimum/ s/process the video/decode\/enc
Owen Lin 2016/03/24 03:01:10 Done.
+ uint32_t min_num_buffers = 0;
+ uint32_t coded_width = 0;
+ uint32_t coded_height = 0;
+ uint32_t crop_left = 0;
+ uint32_t crop_width = 0;
+ uint32_t crop_top = 0;
+ uint32_t crop_height = 0;
+};
+
+// ArcVideoAccelerator is a component of ArcCodec to deal with video
+// buffers. It is also an IPC interface between Android and Chromium.
+// So that the video buffers are sent to Chromium side and decoded.
+// ArcCodec implements ArcVideoAccelerator::Client and is responsible for
Pawel Osciak 2016/03/22 08:36:11 Please remove or rephrase this sentence so that it
Owen Lin 2016/03/24 03:01:10 Done.
+// rendering and interacting with the Android media framework.
+class ArcVideoAccelerator {
+ public:
+ enum Error {
+ ILLEGAL_STATE = 1,
+ INVALID_ARGUMENT = 2,
+ UNREADABLE_INPUT = 3,
+ PLATFORM_FAILURE = 4,
+ };
+
+ struct Config {
+ enum DeviceType {
+ DEVICE_ENCODER = 0,
+ DEVICE_DECODER = 1,
+ };
+
+ DeviceType device_type = DEVICE_DECODER;
+ size_t num_input_buffers = 0;
+ uint32_t input_pixel_format = 0;
+ // TODO: Add output_pixel_format. For now only the native pixel format
Pawel Osciak 2016/03/22 08:36:11 TODO(owner):
Owen Lin 2016/03/24 03:01:10 Done.
+ // of each VDA on Chromium is supported.
+ };
+
+ // The callbacks of the ArcVideoAccelerator. ArcCodec implmenets this
Pawel Osciak 2016/03/22 08:36:11 Please update the last sentence.
Owen Lin 2016/03/24 03:01:10 Done.
+ // interface.
+ class Client {
+ public:
+ virtual ~Client() {}
+
+ // Called when an asynchronous error happens. Asynchronous errors happen
+ // only when the accelerator processes the input buffer and tried to
Pawel Osciak 2016/03/22 08:36:10 Is this still applicable? I think we may OnError()
Owen Lin 2016/03/24 03:01:10 Indeed. Remove the last sentence.
+ // generate the output to the output buffer.
+ virtual void OnError(Error error) = 0;
+
+ // Called when a buffer with the specified |index| and |port| has been
+ // processed and is no longer used in the accelerator. For input buffer,
+ // it can be filled with new content. For output buffer, it is ready to
Pawel Osciak 2016/03/22 08:36:11 s/buffer, it can be filled/buffers, the Client may
Owen Lin 2016/03/24 03:01:10 Done.
+ // be consumed by the client.
+ virtual void OnBufferDone(PortType port,
+ uint32_t index,
+ const BufferMetadata& metadata) = 0;
+
+ // Called when the output format has changed or the output format
+ // becomes available at beginning of the stream after initial parsing.
+ virtual void OnOutputFormatChanged(const VideoFormat& format) = 0;
+ };
+
+ virtual bool Initialize(const Config& config, Client* client) = 0;
Pawel Osciak 2016/03/22 08:36:11 Please document.
Owen Lin 2016/03/24 03:01:11 Done.
+
+ // Assigns a shared memory to be used for the accelerator at the specified
+ // port and index. A buffer must be bound before asking the accelerator to
Pawel Osciak 2016/03/22 08:36:10 A buffer must be successfully bound using this met
Owen Lin 2016/03/24 03:01:10 Done.
+ // use it via useBuffer().
+ virtual void BindSharedMemory(PortType port,
+ uint32_t index,
+ int ashmem_fd,
+ off_t offset,
+ size_t length) = 0;
+
+ // Assigns a graphic buffer to be used for the accelerator at the specified
Pawel Osciak 2016/03/22 08:36:11 s/graphic//
Owen Lin 2016/03/24 03:01:10 Done.
+ // port and index. A buffer must be bound before asking the accelerator to
+ // use it via useBuffer().
+ virtual void BindDmabuf(PortType port, uint32_t index, int dmabuf_fd) = 0;
+
+ // Passes a buffer to the accelerator. For input buffer, the accelerator
+ // will process it. For output buffer, the accelerator will output content
+ // to it.
+ virtual void UseBuffer(PortType port,
+ uint32_t index,
+ const BufferMetadata& metadata) = 0;
+
+ // Sets the number of output buffers.
Pawel Osciak 2016/03/22 08:36:10 Please document whether this can fail and what hap
Owen Lin 2016/03/24 03:01:10 This is not likely to fail in current implementati
+ virtual void SetNumberOfOutputBuffers(size_t number) = 0;
+
+ // Resets the accelerator. After this function, all buffers won't be
+ // accessed by the accelerator and there won't be more callbacks.
+ virtual void Reset() = 0;
+
+ virtual ~ArcVideoAccelerator() {}
+};
+
+} // namespace arc
+} // namespace chromeos
+
+#endif // CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_

Powered by Google App Engine
This is Rietveld 408576698