Commit 61ae3ddf authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

media/gpu/v4l2vd: move stateless-specific parts into backend class

There are two V4L2 decode APIs: stateless and stateful. In the VDA era
these were implemented as two completely separate classes
(V4L2VideoDecodeAccelerator and V4L2SliceVideoDecodeAccelerator), which
resulted in a lot of duplicated code and bugs due to fixes not being
replicated on both classes.

For the VD-based decoder, we want to avoid doing the same error and
use a single V4L2 decoder, supported by different backends depending on
which V4L2 API we are using.

This CL is the first step towards that direction: it splits the
V4L2SliceVideoDecoder into its general V4L2 part and the one that is
specific to the stateless API.

Bug: 1003223
Test: video_decode_accelerator_tests passing on Kevin.

Change-Id: I373f3ea739b6799ecad009d053ca7e415b8484bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1840034
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarDavid Staessens <dstaessens@chromium.org>
Reviewed-by: default avatarChih-Yu Huang <akahuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705894}
parent a33a2c5c
...@@ -51,6 +51,10 @@ source_set("v4l2") { ...@@ -51,6 +51,10 @@ source_set("v4l2") {
"v4l2_vda_helpers.h", "v4l2_vda_helpers.h",
"v4l2_video_decode_accelerator.cc", "v4l2_video_decode_accelerator.cc",
"v4l2_video_decode_accelerator.h", "v4l2_video_decode_accelerator.h",
"v4l2_video_decoder_backend.cc",
"v4l2_video_decoder_backend.h",
"v4l2_video_decoder_backend_stateless.cc",
"v4l2_video_decoder_backend_stateless.h",
"v4l2_video_encode_accelerator.cc", "v4l2_video_encode_accelerator.cc",
"v4l2_video_encode_accelerator.h", "v4l2_video_encode_accelerator.h",
"v4l2_vp8_accelerator.cc", "v4l2_vp8_accelerator.cc",
......
This diff is collapsed.
...@@ -27,18 +27,18 @@ ...@@ -27,18 +27,18 @@
#include "media/base/video_frame_layout.h" #include "media/base/video_frame_layout.h"
#include "media/base/video_types.h" #include "media/base/video_types.h"
#include "media/gpu/media_gpu_export.h" #include "media/gpu/media_gpu_export.h"
#include "media/gpu/v4l2/v4l2_decode_surface_handler.h"
#include "media/gpu/v4l2/v4l2_device.h" #include "media/gpu/v4l2/v4l2_device.h"
#include "media/gpu/v4l2/v4l2_video_decoder_backend.h"
#include "media/video/supported_video_decoder_config.h" #include "media/video/supported_video_decoder_config.h"
namespace media { namespace media {
class AcceleratedVideoDecoder; class AcceleratedVideoDecoder;
class DmabufVideoFramePool; class DmabufVideoFramePool;
class V4L2DecodeSurface;
class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder, class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder
public V4L2DecodeSurfaceHandler { : public VideoDecoder,
public V4L2VideoDecoderBackend::Client {
public: public:
using GetFramePoolCB = base::RepeatingCallback<DmabufVideoFramePool*()>; using GetFramePoolCB = base::RepeatingCallback<DmabufVideoFramePool*()>;
...@@ -68,17 +68,18 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder, ...@@ -68,17 +68,18 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder,
void Reset(base::OnceClosure closure) override; void Reset(base::OnceClosure closure) override;
void Decode(scoped_refptr<DecoderBuffer> buffer, DecodeCB decode_cb) override; void Decode(scoped_refptr<DecoderBuffer> buffer, DecodeCB decode_cb) override;
// V4L2DecodeSurfaceHandler implementation. // V4L2VideoDecoderBackend::Client implementation
scoped_refptr<V4L2DecodeSurface> CreateSurface() override; void OnBackendError() override;
bool SubmitSlice(const scoped_refptr<V4L2DecodeSurface>& dec_surface, bool IsDecoding() const override;
const uint8_t* data, void InitiateFlush() override;
size_t size) override; void CompleteFlush() override;
void DecodeSurface( bool ChangeResolution(gfx::Size pic_size,
const scoped_refptr<V4L2DecodeSurface>& dec_surface) override; gfx::Rect visible_rect,
void SurfaceReady(const scoped_refptr<V4L2DecodeSurface>& dec_surface, size_t num_output_frames) override;
int32_t bitstream_id, void RunDecodeCB(DecodeCB cb, DecodeStatus status) override;
const gfx::Rect& visible_rect, void OutputFrame(scoped_refptr<VideoFrame> frame,
const VideoColorSpace& /* color_space */) override; const gfx::Rect& visible_rect,
base::TimeDelta timestamp) override;
private: private:
friend class V4L2SliceVideoDecoderTest; friend class V4L2SliceVideoDecoderTest;
...@@ -91,29 +92,6 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder, ...@@ -91,29 +92,6 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder,
~V4L2SliceVideoDecoder() override; ~V4L2SliceVideoDecoder() override;
void Destroy() override; void Destroy() override;
// Request for decoding buffer. Every Decode() call generates 1 DecodeRequest.
struct DecodeRequest {
// The decode buffer passed from Decode().
scoped_refptr<DecoderBuffer> buffer;
// The callback function passed from Decode().
DecodeCB decode_cb;
// The identifier for the decoder buffer.
int32_t bitstream_id;
DecodeRequest(scoped_refptr<DecoderBuffer> buf, DecodeCB cb, int32_t id);
// Allow move, but not copy
DecodeRequest(DecodeRequest&&);
DecodeRequest& operator=(DecodeRequest&&);
~DecodeRequest();
DISALLOW_COPY_AND_ASSIGN(DecodeRequest);
};
// Request for displaying the surface or calling the decode callback.
struct OutputRequest;
enum class State { enum class State {
// Initial state. Transitions to |kDecoding| if Initialize() is successful, // Initial state. Transitions to |kDecoding| if Initialize() is successful,
// |kError| otherwise. // |kError| otherwise.
...@@ -128,18 +106,6 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder, ...@@ -128,18 +106,6 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder,
kError, kError,
}; };
// The reason the decoding is paused.
enum class PauseReason {
// Not stopped, decoding normally.
kNone,
// Cannot create a new V4L2 surface. Waiting for surfaces to be released.
kRanOutOfSurfaces,
// A VP9 superframe contains multiple subframes. Before decoding the next
// subframe, we need to wait for previous subframes decoded and update the
// context.
kWaitSubFrameDecoded,
};
class BitstreamIdGenerator { class BitstreamIdGenerator {
public: public:
BitstreamIdGenerator() { DETACH_FROM_SEQUENCE(sequence_checker_); } BitstreamIdGenerator() { DETACH_FROM_SEQUENCE(sequence_checker_); }
...@@ -185,30 +151,11 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder, ...@@ -185,30 +151,11 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder,
void DestroyTask(); void DestroyTask();
// Reset on decoder thread. // Reset on decoder thread.
void ResetTask(base::OnceClosure closure); void ResetTask(base::OnceClosure closure);
// Reset |avd_|, clear all pending requests, and call all pending decode
// callback with |status| argument.
void ClearPendingRequests(DecodeStatus status);
// Enqueue |request| to the pending decode request queue, and try to decode // Enqueue |buffer| to be decoded. |decode_cb| will be called once |buffer|
// from the queue. // is no longer used.
void EnqueueDecodeTask(scoped_refptr<DecoderBuffer> buffer, void EnqueueDecodeTask(scoped_refptr<DecoderBuffer> buffer,
V4L2SliceVideoDecoder::DecodeCB decode_cb); V4L2SliceVideoDecoder::DecodeCB decode_cb);
// Try to decode buffer from the pending decode request queue.
// This method stops decoding when:
// - Run out of surface
// - Flushing or changing resolution
// Invoke this method again when these situation ends.
void PumpDecodeTask();
// Try to output surface from |output_request_queue_|.
// This method stops outputting surface when the first surface is not dequeued
// from the V4L2 device. Invoke this method again when any surface is
// dequeued from the V4L2 device.
void PumpOutputSurfaces();
// Setup the format of V4L2 output buffer, and allocate new buffer set.
bool ChangeResolution();
// Callback which is called when V4L2 surface is destroyed.
void ReuseOutputBuffer(V4L2ReadableBufferRef buffer);
// Start streaming V4L2 input and output queues. Attempt to start // Start streaming V4L2 input and output queues. Attempt to start
// |device_poll_thread_| before starting streaming. // |device_poll_thread_| before starting streaming.
bool StartStreamV4L2Queue(); bool StartStreamV4L2Queue();
...@@ -218,27 +165,18 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder, ...@@ -218,27 +165,18 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder,
// Try to dequeue input and output buffers from device. // Try to dequeue input and output buffers from device.
void ServiceDeviceTask(bool event); void ServiceDeviceTask(bool event);
// Convert the frame and call the output callback.
void RunOutputCB(scoped_refptr<VideoFrame> frame,
const gfx::Rect& visible_rect,
base::TimeDelta timestamp);
// Call the decode callback and count the number of pending callbacks.
void RunDecodeCB(DecodeCB cb, DecodeStatus status);
// Change the state and check the state transition is valid. // Change the state and check the state transition is valid.
void SetState(State new_state); void SetState(State new_state);
// Check whether request api is supported or not. // The V4L2 backend, i.e. the part of the decoder that sends
bool CheckRequestAPISupport(); // decoding jobs to the kernel.
// Allocate necessary request buffers is request api is supported. std::unique_ptr<V4L2VideoDecoderBackend> backend_;
bool AllocateRequests();
// V4L2 device in use. // V4L2 device in use.
scoped_refptr<V4L2Device> device_; scoped_refptr<V4L2Device> device_;
// VideoFrame manager used to allocate and recycle video frame. // VideoFrame manager used to allocate and recycle video frame.
GetFramePoolCB get_pool_cb_; GetFramePoolCB get_pool_cb_;
DmabufVideoFramePool* frame_pool_ = nullptr; DmabufVideoFramePool* frame_pool_ = nullptr;
// Video decoder used to parse stream headers by software.
std::unique_ptr<AcceleratedVideoDecoder> avd_;
// Client task runner. All public methods of VideoDecoder interface are // Client task runner. All public methods of VideoDecoder interface are
// executed at this task runner. // executed at this task runner.
...@@ -249,8 +187,6 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder, ...@@ -249,8 +187,6 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder,
// State of the instance. // State of the instance.
State state_ = State::kUninitialized; State state_ = State::kUninitialized;
// Indicates why decoding is currently paused.
PauseReason pause_reason_ = PauseReason::kNone;
// Parameters for generating output VideoFrame. // Parameters for generating output VideoFrame.
base::Optional<VideoFrameLayout> frame_layout_; base::Optional<VideoFrameLayout> frame_layout_;
...@@ -259,41 +195,16 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder, ...@@ -259,41 +195,16 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder,
// Callbacks passed from Initialize(). // Callbacks passed from Initialize().
OutputCB output_cb_; OutputCB output_cb_;
// Callbacks of EOS buffer passed from Decode().
DecodeCB flush_cb_;
// V4L2 input and output queue. // V4L2 input and output queue.
scoped_refptr<V4L2Queue> input_queue_; scoped_refptr<V4L2Queue> input_queue_;
scoped_refptr<V4L2Queue> output_queue_; scoped_refptr<V4L2Queue> output_queue_;
// The time at which each buffer decode operation started. Not each decode BitstreamIdGenerator bitstream_id_generator_;
// operation leads to a frame being output and frames might be reordered, so
// we don't know when it's safe to drop a timestamp. This means we need to use
// a cache here, with a size large enough to account for frame reordering.
base::MRUCache<int32_t, base::TimeDelta> bitstream_id_to_timestamp_;
// Queue of pending decode request.
base::queue<DecodeRequest> decode_request_queue_;
// Surfaces enqueued to V4L2 device. Since we are stateless, they are
// guaranteed to be proceeded in FIFO order.
base::queue<scoped_refptr<V4L2DecodeSurface>> surfaces_at_device_;
// The decode request which is currently processed.
base::Optional<DecodeRequest> current_decode_request_;
// Queue of pending output request.
base::queue<OutputRequest> output_request_queue_;
// True if the decoder needs bitstream conversion before decoding. // True if the decoder needs bitstream conversion before decoding.
bool needs_bitstream_conversion_ = false; bool needs_bitstream_conversion_ = false;
BitstreamIdGenerator bitstream_id_generator_;
// Set to true by CreateInputBuffers() if the codec driver supports requests.
bool supports_requests_ = false;
// FIFO queue of requests, only used if supports_requests_ is true.
std::queue<base::ScopedFD> requests_;
// Stores the media file descriptor, only used if supports_requests_ is true.
base::ScopedFD media_fd_;
SEQUENCE_CHECKER(client_sequence_checker_); SEQUENCE_CHECKER(client_sequence_checker_);
SEQUENCE_CHECKER(decoder_sequence_checker_); SEQUENCE_CHECKER(decoder_sequence_checker_);
......
// Copyright 2019 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.
#include "media/gpu/v4l2/v4l2_video_decoder_backend.h"
#include "base/logging.h"
#include "media/gpu/macros.h"
#include "media/gpu/v4l2/v4l2_device.h"
namespace media {
V4L2VideoDecoderBackend::V4L2VideoDecoderBackend(
Client* const client,
scoped_refptr<V4L2Device> device)
: client_(client), device_(std::move(device)) {
input_queue_ = device_->GetQueue(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
output_queue_ = device_->GetQueue(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
if (!input_queue_ || !output_queue_) {
VLOGF(1) << "Failed to get V4L2 queue. This should not happen since the "
<< "queues are supposed to be initialized when we are called.";
NOTREACHED();
}
}
V4L2VideoDecoderBackend::~V4L2VideoDecoderBackend() = default;
} // namespace media
// Copyright 2019 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 MEDIA_GPU_V4L2_V4L2_VIDEO_DECODER_BACKEND_H_
#define MEDIA_GPU_V4L2_V4L2_VIDEO_DECODER_BACKEND_H_
#include "base/memory/scoped_refptr.h"
#include "media/base/decode_status.h"
#include "media/base/video_decoder.h"
#include "ui/gfx/geometry/rect.h"
namespace media {
class V4L2Device;
class V4L2Queue;
class V4L2ReadableBuffer;
using V4L2ReadableBufferRef = scoped_refptr<V4L2ReadableBuffer>;
// Abstract class that performs the low-level V4L2 decoding tasks depending
// on the decoding API chosen (stateful or stateless).
//
// The backend receives encoded buffers via EnqueueDecodeTask() and is
// responsible for acquiring the V4L2 resources (output and capture buffers,
// etc) and sending them to the V4L2 driver. When a decoded buffer is dequeued,
// |OutputBufferDequeued| is automatically called from the decoder.
//
// The backend can call into some of the decoder methods, notably OutputFrame()
// to send a |VideoFrame| to the decoder's client, and Error() to signal that
// an unrecoverable error has occurred.
//
// This class must run entirely inside the decoder thread. All overridden
// methods must check that they are called from sequence_checker_.
class V4L2VideoDecoderBackend {
public:
// Interface for the backend to call back into the decoder it is serving.
// All methods must be called from the same sequence as the backend.
class Client {
public:
// Inform that an unrecoverable error has occurred in the backend.
virtual void OnBackendError() = 0;
// Returns true is we are in a state that allows decoding to proceed.
virtual bool IsDecoding() const = 0;
// Start flushing. No new decoding requests will be processed until
// CompleteFlush() is called.
virtual void InitiateFlush() = 0;
// Inform the flushing is complete.
virtual void CompleteFlush() = 0;
// Stop the stream to reallocate the CAPTURE buffers. Can only be done
// between calls to |InitiateFlush| and |CompleteFlush|.
virtual bool ChangeResolution(gfx::Size pic_size,
gfx::Rect visible_rect,
size_t num_output_frames) = 0;
// Call the decode callback and count the number of pending callbacks.
virtual void RunDecodeCB(VideoDecoder::DecodeCB cb,
DecodeStatus status) = 0;
// Convert the frame and call the output callback.
virtual void OutputFrame(scoped_refptr<VideoFrame> frame,
const gfx::Rect& visible_rect,
base::TimeDelta timestamp) = 0;
};
virtual ~V4L2VideoDecoderBackend();
virtual bool Initialize() = 0;
// Schedule |buffer| to be processed, with bitstream ID |bitstream_id|.
// The backend must call V4L2SliceVideoDecoder::RunDecodeCB() with |decode_cb|
// as argument once the buffer is not used anymore.
virtual void EnqueueDecodeTask(scoped_refptr<DecoderBuffer> buffer,
VideoDecoder::DecodeCB decode_cb,
int32_t bitstream_id) = 0;
// Called by the decoder when it has dequeued a buffer from the CAPTURE queue.
virtual void OnOutputBufferDequeued(V4L2ReadableBufferRef buf) = 0;
// Called whenever the V4L2 stream is stopped (|Streamoff| called on both
// |V4L2Queue|s).
virtual void OnStreamStopped() = 0;
// Clear all pending decoding tasks and call all pending decode callbacks
// with |status| as argument.
virtual void ClearPendingRequests(DecodeStatus status) = 0;
protected:
V4L2VideoDecoderBackend(Client* const client,
scoped_refptr<V4L2Device> device);
// The decoder we are serving. |client_| is the owner of this backend
// instance, and is guaranteed to live longer than it. Thus it is safe to use
// a raw pointer here.
Client* const client_;
// V4L2 device to use.
scoped_refptr<V4L2Device> device_;
// Input and output queued from which to get buffers.
scoped_refptr<V4L2Queue> input_queue_;
scoped_refptr<V4L2Queue> output_queue_;
SEQUENCE_CHECKER(sequence_checker_);
DISALLOW_COPY_AND_ASSIGN(V4L2VideoDecoderBackend);
};
} // namespace media
#endif // MEDIA_GPU_V4L2_V4L2_VIDEO_DECODER_BACKEND_H_
This diff is collapsed.
// Copyright 2019 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 MEDIA_GPU_V4L2_V4L2_VIDEO_DECODER_BACKEND_STATELESS_H_
#define MEDIA_GPU_V4L2_V4L2_VIDEO_DECODER_BACKEND_STATELESS_H_
#include "base/containers/mru_cache.h"
#include "base/containers/queue.h"
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h"
#include "base/sequenced_task_runner.h"
#include "media/base/decode_status.h"
#include "media/base/video_decoder.h"
#include "media/gpu/linux/dmabuf_video_frame_pool.h"
#include "media/gpu/v4l2/v4l2_decode_surface_handler.h"
#include "media/gpu/v4l2/v4l2_video_decoder_backend.h"
namespace media {
class AcceleratedVideoDecoder;
class V4L2StatelessVideoDecoderBackend : public V4L2VideoDecoderBackend,
public V4L2DecodeSurfaceHandler {
public:
// Constructor for the stateless backend. Arguments are:
// |client| the decoder we will be backing.
// |device| the V4L2 decoder device.
// |frame_pool| pool from which to get backing memory for decoded frames.
// |profile| profile of the codec we will decode.
// |task_runner| the decoder task runner, to which we will post our tasks.
V4L2StatelessVideoDecoderBackend(
Client* const client,
scoped_refptr<V4L2Device> device,
DmabufVideoFramePool* const frame_pool,
VideoCodecProfile profile,
scoped_refptr<base::SequencedTaskRunner> task_runner);
~V4L2StatelessVideoDecoderBackend() override;
// V4L2VideoDecoderBackend implementation
bool Initialize() override;
void EnqueueDecodeTask(scoped_refptr<DecoderBuffer> buffer,
VideoDecoder::DecodeCB decode_cb,
int32_t bitstream_id) override;
void OnOutputBufferDequeued(V4L2ReadableBufferRef buffer) override;
void OnStreamStopped() override;
void ClearPendingRequests(DecodeStatus status) override;
// V4L2DecodeSurfaceHandler implementation.
scoped_refptr<V4L2DecodeSurface> CreateSurface() override;
bool SubmitSlice(const scoped_refptr<V4L2DecodeSurface>& dec_surface,
const uint8_t* data,
size_t size) override;
void DecodeSurface(
const scoped_refptr<V4L2DecodeSurface>& dec_surface) override;
void SurfaceReady(const scoped_refptr<V4L2DecodeSurface>& dec_surface,
int32_t bitstream_id,
const gfx::Rect& visible_rect,
const VideoColorSpace& color_space) override;
private:
// Request for displaying the surface or calling the decode callback.
struct OutputRequest;
// Request for decoding buffer. Every EnqueueDecodeTask() call generates 1
// DecodeRequest.
struct DecodeRequest {
// The decode buffer passed to EnqueueDecodeTask().
scoped_refptr<DecoderBuffer> buffer;
// The callback function passed to EnqueueDecodeTask().
VideoDecoder::DecodeCB decode_cb;
// The identifier for the decoder buffer.
int32_t bitstream_id;
DecodeRequest(scoped_refptr<DecoderBuffer> buf,
VideoDecoder::DecodeCB cb,
int32_t id);
// Allow move, but not copy
DecodeRequest(DecodeRequest&&);
DecodeRequest& operator=(DecodeRequest&&);
~DecodeRequest();
DISALLOW_COPY_AND_ASSIGN(DecodeRequest);
};
// The reason the decoding is paused.
enum class PauseReason {
// Not stopped, decoding normally.
kNone,
// Cannot create a new V4L2 surface. Waiting for surfaces to be released.
kRanOutOfSurfaces,
// A VP9 superframe contains multiple subframes. Before decoding the next
// subframe, we need to wait for previous subframes decoded and update the
// context.
kWaitSubFrameDecoded,
};
// Callback which is called when V4L2 surface is destroyed.
void ReuseOutputBuffer(V4L2ReadableBufferRef buffer);
// Try to advance the decoding work.
void DoDecodeWork();
// Try to decode buffer from the pending decode request queue.
// This method stops decoding when:
// - Run out of surface
// - Flushing or changing resolution
// Invoke this method again when these situation ends.
bool PumpDecodeTask();
// Try to output surface from |output_request_queue_|.
// This method stops outputting surface when the first surface is not dequeued
// from the V4L2 device. Invoke this method again when any surface is
// dequeued from the V4L2 device.
void PumpOutputSurfaces();
// Setup the format of V4L2 output buffer, and allocate new buffer set.
bool ChangeResolution();
// Check whether request api is supported or not.
bool CheckRequestAPISupport();
// Allocate necessary request buffers is request api is supported.
bool AllocateRequests();
// Video frame pool provided by the decoder.
DmabufVideoFramePool* const frame_pool_;
// Video profile we will be decoding.
const VideoCodecProfile profile_;
// Video decoder used to parse stream headers by software.
std::unique_ptr<AcceleratedVideoDecoder> avd_;
// The decode request which is currently processed.
base::Optional<DecodeRequest> current_decode_request_;
// Surfaces enqueued to V4L2 device. Since we are stateless, they are
// guaranteed to be proceeded in FIFO order.
base::queue<scoped_refptr<V4L2DecodeSurface>> surfaces_at_device_;
// Queue of pending decode request.
base::queue<DecodeRequest> decode_request_queue_;
// Queue of pending output request.
base::queue<OutputRequest> output_request_queue_;
// Indicates why decoding is currently paused.
PauseReason pause_reason_ = PauseReason::kNone;
// The time at which each buffer decode operation started. Not each decode
// operation leads to a frame being output and frames might be reordered, so
// we don't know when it's safe to drop a timestamp. This means we need to use
// a cache here, with a size large enough to account for frame reordering.
base::MRUCache<int32_t, base::TimeDelta> bitstream_id_to_timestamp_;
// The task runner we are running on, for convenience.
const scoped_refptr<base::SequencedTaskRunner> task_runner_;
// Callbacks of EOS buffer passed from Decode().
VideoDecoder::DecodeCB flush_cb_;
// Set to true during Initialize() if the codec driver supports request API.
bool supports_requests_ = false;
// FIFO queue of requests, only used if supports_requests_ is true.
base::queue<base::ScopedFD> requests_;
// Stores the media file descriptor, only used if supports_requests_ is true.
base::ScopedFD media_fd_;
base::WeakPtr<V4L2StatelessVideoDecoderBackend> weak_this_;
base::WeakPtrFactory<V4L2StatelessVideoDecoderBackend> weak_this_factory_{
this};
DISALLOW_COPY_AND_ASSIGN(V4L2StatelessVideoDecoderBackend);
};
} // namespace media
#endif // MEDIA_GPU_V4L2_V4L2_VIDEO_DECODER_BACKEND_STATELESS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment