Index: media/gpu/v4l2_video_decode_accelerator.h |
diff --git a/media/gpu/v4l2_video_decode_accelerator.h b/media/gpu/v4l2_video_decode_accelerator.h |
index 5540b013088f1a76b681c7bb78a6d49daa17b555..a010dfd6ce57373c7253289a23fe88be92729210 100644 |
--- a/media/gpu/v4l2_video_decode_accelerator.h |
+++ b/media/gpu/v4l2_video_decode_accelerator.h |
@@ -12,6 +12,7 @@ |
#include <stddef.h> |
#include <stdint.h> |
+#include <list> |
#include <memory> |
#include <queue> |
#include <vector> |
@@ -99,6 +100,9 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator |
bool Initialize(const Config& config, Client* client) override; |
void Decode(const BitstreamBuffer& bitstream_buffer) override; |
void AssignPictureBuffers(const std::vector<PictureBuffer>& buffers) override; |
+ void ImportBufferForPicture( |
+ int32_t picture_buffer_id, |
+ const gfx::GpuMemoryBufferHandle& gpu_memory_buffer_handles) override; |
void ReusePictureBuffer(int32_t picture_buffer_id) override; |
void Flush() override; |
void Reset() override; |
@@ -183,10 +187,13 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator |
EGLImageKHR egl_image; // EGLImageKHR for the output buffer. |
EGLSyncKHR egl_sync; // sync the compositor's use of the EGLImage. |
int32_t picture_id; // picture buffer id as returned to PictureReady(). |
+ GLuint texture_id; |
bool cleared; // Whether the texture is cleared and safe to render |
// from. See TextureManager for details. |
- // Exported fds for image processor to import. |
- std::vector<base::ScopedFD> fds; |
+ // Input fds of the processor. Exported from the decoder. |
+ std::vector<base::ScopedFD> processor_input_fds; |
+ // Output fds of the processor. Used only when OutputMode is IMPORT. |
+ std::vector<base::ScopedFD> processor_output_fds; |
}; |
// |
@@ -222,17 +229,44 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator |
// via AssignPictureBuffers() on decoder thread. |
void AssignPictureBuffersTask(const std::vector<PictureBuffer>& buffers); |
- // Create EGLImages bound to textures in |buffers| for given |
- // |output_format_fourcc| and |output_planes_count|. |
- void CreateEGLImages(const std::vector<media::PictureBuffer>& buffers, |
- uint32_t output_format_fourcc, |
- size_t output_planes_count); |
- |
- // Assign |egl_images| to previously-allocated V4L2 buffers in |
- // output_buffer_map_ and picture ids from |buffers| and finish the resolution |
- // change sequence. |
- void AssignEGLImages(const std::vector<media::PictureBuffer>& buffers, |
- const std::vector<EGLImageKHR>& egl_images); |
+ // Use buffer backed by dmabuf file descriptors in |passed_dmabuf_fds| for the |
+ // OutputRecord associated with |picture_buffer_id|, taking ownership of the |
+ // file descriptors. |
+ void ImportBufferForPictureTask( |
+ int32_t picture_buffer_id, |
+ // TODO(posciak): (crbug.com/561749) we should normally be able to pass |
+ // the vector by itself via std::move, but it's not possible to do this |
+ // if this method is used as a callback. |
+ std::unique_ptr<std::vector<base::ScopedFD>> passed_dmabuf_fds, |
+ int32_t stride); |
+ |
+ // Create an EGLImage for the buffer associated with V4L2 |buffer_index| and |
+ // for |picture_buffer_id|, backed by dmabuf file descriptors in |
+ // |passed_dmabuf_fds|, taking ownership of them. |
+ // The buffer should be bound to |texture_id| and is of |size| and format |
+ // described by |fourcc|. |
+ void CreateEGLImageFor( |
+ size_t buffer_index, |
+ int32_t picture_buffer_id, |
+ // TODO(posciak): (crbug.com/561749) we should normally be able to pass |
+ // the vector by itself via std::move, but it's not possible to do this |
+ // if this method is used as a callback. |
+ std::unique_ptr<std::vector<base::ScopedFD>> passed_dmabuf_fds, |
+ GLuint texture_id, |
+ const gfx::Size& size, |
+ uint32_t fourcc); |
+ |
+ // Take the EGLImage |egl_image|, created for |picture_buffer_id|, and use it |
+ // for OutputRecord at |buffer_index|. The buffer is backed by |
+ // |passed_dmabuf_fds|, and the OutputRecord takes ownership of them. |
+ void AssignEGLImage( |
+ size_t buffer_index, |
+ int32_t picture_buffer_id, |
+ EGLImageKHR egl_image, |
+ // TODO(posciak): (crbug.com/561749) we should normally be able to pass |
+ // the vector by itself via std::move, but it's not possible to do this |
+ // if this method is used as a callback. |
+ std::unique_ptr<std::vector<base::ScopedFD>> passed_dmabuf_fds); |
// Service I/O on the V4L2 devices. This task should only be scheduled from |
// DevicePollTask(). If |event_pending| is true, one or more events |
@@ -336,6 +370,15 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator |
// Return a usable output format of image processor. Return 0 if not found. |
uint32_t FindImageProcessorOutputFormat(); |
+ void CreateImageProcessor(); |
+ |
+ // Image processor returns a processed frame. Its id is |bitstream_buffer_id| |
+ // and stored in |output_buffer_index| buffer of image processor. |
+ void FrameProcessed(int32_t bitstream_buffer_id, int output_buffer_index); |
+ |
+ // Image processor notifies an error. |
+ void ImageProcessorError(); |
+ |
// |
// Methods run on child thread. |
// |
@@ -348,6 +391,7 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator |
// up as much as possible, so return false if this happens, so that the |
// caller can error out on resolution change. |
bool DestroyOutputBuffers(); |
+ bool DestroyEGLImages(); |
void ResolutionChangeDestroyBuffers(); |
// Send decoded pictures to PictureReady. |
@@ -356,13 +400,6 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator |
// Callback that indicates a picture has been cleared. |
void PictureCleared(); |
- // Image processor returns a processed frame. Its id is |bitstream_buffer_id| |
- // and stored in |output_buffer_index| buffer of image processor. |
- void FrameProcessed(int32_t bitstream_buffer_id, int output_buffer_index); |
- |
- // Image processor notifies an error. |
- void ImageProcessorError(); |
- |
// Our original calling task runner for the child thread. |
scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; |
@@ -397,6 +434,9 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator |
base::Thread decoder_thread_; |
// Decoder state machine state. |
State decoder_state_; |
+ |
+ Config::OutputMode output_mode_; |
+ |
// BitstreamBuffer we're presently reading. |
std::unique_ptr<BitstreamBufferRef> decoder_current_bitstream_buffer_; |
// The V4L2Device this class is operating upon. |
@@ -453,7 +493,7 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator |
int output_buffer_queued_count_; |
// Output buffers ready to use, as a FIFO since we want oldest-first to hide |
// synchronization latency with GL. |
- std::queue<int> free_output_buffers_; |
+ std::list<int> free_output_buffers_; |
// Mapping of int index to output buffer record. |
std::vector<OutputRecord> output_buffer_map_; |
// Required size of DPB for decoding. |