class SurfaceBufferManager

Defined at line 55 of file ../../src/media/codec/codecs/vaapi/codec_adapter_vaapi_decoder.h

Interface used to manage output buffer, DPB surfaces and their relationship to each other. The

goal of this class is to abstract away the implementation details on how linear and tiled

surfaces are handled differently.

Protected Members

std::mutex & codec_lock_
mutex surface_lock_
uint64_t surface_generation_
Size dpb_surface_size_
Size coded_picture_size_
BufferPool output_buffer_pool_

Public Methods

void AddBuffer (const CodecBuffer * buffer)

Adds a output CodecBuffer under the management of the class

void RecycleBuffer (const CodecBuffer * buffer)

Called when an output buffer that was shared with the client is no longer by that client and

now can be used again.

void DeconfigureBuffers ()

Deconfigures all output buffers under the manager's control

scoped_refptr<VASurface> GetDPBSurface ()

Get a surface that will be used as a DPB for the codec. If no current surfaces are available

this function will block until either a DPB surfaces becomes available or Reset() is called

std::optional<std::pair<const CodecBuffer *, uint32_t>> ProcessOutputSurface (scoped_refptr<VASurface> dpb_surface)

This function returns an output CodecBuffer to be sent to the client for the given DPB surface

void Reset ()

Resets any underlying blocking data structures after a call to StopAllWaits(). This allows the

data structures to block again.

void StopAllWaits ()

Stops all blocking calls, specially the potentially blocking call of GetDPBSurface() or

ProcessOutputSurface(). Will cause blocking calls to immediately return with default

constructed objects as their return values.

gfx::Size GetRequiredSurfaceSize (const gfx::Size & picture_size)

Given the new picture size, return the dimensions of the surface needed to hold the new picture

size. This function will use historic data of the picture size, meaning that if a surface size

can not decrease, due to Intel media driver requirements, this function will take that into

consideration when returning a required surface size. Note that this function does not take

into account the pixel format.

bool NeedsKeyframeForBufferAllocation ()

TODO(https://fxbug.dev/42060469): This is a temporary workaround until the new media APIs are

adopted Returns true if the surface manager can not have outstanding reference frames when new

buffers are required to hold the new coded picture size.

void ~SurfaceBufferManager ()

Defined at line 59 of file ../../src/media/codec/codecs/vaapi/codec_adapter_vaapi_decoder.h

void UpdatePictureSize (const gfx::Size & new_picture_size, size_t num_of_surfaces)

Updates the picture size of the current stream. If the surfaces that are currently under

management are too small to handle the new picture size, OnSurfaceGenerationUpdatedLocked()

will be called to generate new surfaces that will be able to hold the new picture size.

Defined at line 103 of file ../../src/media/codec/codecs/vaapi/codec_adapter_vaapi_decoder.h

gfx::Size GetDPBSurfaceSize ()

Defined at line 138 of file ../../src/media/codec/codecs/vaapi/codec_adapter_vaapi_decoder.h

Protected Methods

void OnSurfaceGenerationUpdatedLocked (size_t num_of_surfaces)

Event method subclass must implement. Called when the surface generation has been incremented

and a new surface size is available. This function is guaranteed to be called with the

surface_lock_ locked.

void SurfaceBufferManager (std::mutex & codec_lock, CodecFailureCallback failure_callback)

Defined at line 144 of file ../../src/media/codec/codecs/vaapi/codec_adapter_vaapi_decoder.h

void SetCodecFailure (const std::string & codec_failure)

Used to set any codec failures that happen during the management of the buffers

Defined at line 148 of file ../../src/media/codec/codecs/vaapi/codec_adapter_vaapi_decoder.h