Stay organized with collections Save and categorize content based on your preferences.

Gav1Decoder

@VisibleForTesting(otherwise = 3)
@UnstableApi
class Gav1Decoder : SimpleDecoder


Gav1 decoder.

Summary

Public constructors

Gav1Decoder(
    numInputBuffers: Int,
    numOutputBuffers: Int,
    initialInputBufferSize: Int,
    threads: Int
)

Creates a Gav1Decoder.

Public functions

String!

Returns the name of the decoder.

Unit

Releases the decoder.

Unit
renderToSurface(outputBuffer: VideoDecoderOutputBuffer!, surface: Surface!)

Renders output buffer to the given surface.

Unit

Sets the output mode for frames rendered by the decoder.

Protected functions

DecoderInputBuffer!

Creates a new input buffer.

VideoDecoderOutputBuffer!

Creates a new output buffer.

Gav1DecoderException!

Creates an exception to propagate for an unexpected decode error.

Gav1DecoderException?
decode(
    inputBuffer: DecoderInputBuffer!,
    outputBuffer: VideoDecoderOutputBuffer!,
    reset: Boolean
)

Decodes the inputBuffer and stores any decoded output in outputBuffer.

Unit

Releases an output buffer back to the decoder.

Inherited functions

From androidx.media3.decoder.SimpleDecoder
I?

Dequeues the next input buffer to be filled and queued to the decoder.

O?

Dequeues the next output buffer from the decoder.

Unit

Flushes the decoder.

Unit
queueInputBuffer(inputBuffer: I!)

Queues an input buffer to the decoder.

Unit

Sets the initial size of each input buffer.

Public constructors

Gav1Decoder

Gav1Decoder(
    numInputBuffers: Int,
    numOutputBuffers: Int,
    initialInputBufferSize: Int,
    threads: Int
)

Creates a Gav1Decoder.

Parameters
numInputBuffers: Int

Number of input buffers.

numOutputBuffers: Int

Number of output buffers.

initialInputBufferSize: Int

The initial size of each input buffer, in bytes.

threads: Int

Number of threads libgav1 will use to decode. If THREAD_COUNT_AUTODETECT is passed, then this class will auto detect the number of threads to be used.

Throws
androidx.media3.decoder.av1.Gav1DecoderException: androidx.media3.decoder.av1.Gav1DecoderException

Thrown if an exception occurs when initializing the decoder.

Public functions

getName

fun getName(): String!

Returns the name of the decoder.

Returns
String!

The name of the decoder.

release

fun release(): Unit

Releases the decoder. Must be called when the decoder is no longer needed.

renderToSurface

fun renderToSurface(outputBuffer: VideoDecoderOutputBuffer!, surface: Surface!): Unit

Renders output buffer to the given surface. Must only be called when in VIDEO_OUTPUT_MODE_SURFACE_YUV mode.

Parameters
outputBuffer: VideoDecoderOutputBuffer!

Output buffer.

surface: Surface!

Output surface.

Throws
androidx.media3.decoder.av1.Gav1DecoderException: androidx.media3.decoder.av1.Gav1DecoderException

Thrown if called with invalid output mode or frame rendering fails.

setOutputMode

fun setOutputMode(@C.VideoOutputMode outputMode: Int): Unit

Sets the output mode for frames rendered by the decoder.

Parameters
@C.VideoOutputMode outputMode: Int

The output mode.

Protected functions

createInputBuffer

protected fun createInputBuffer(): DecoderInputBuffer!

Creates a new input buffer.

createOutputBuffer

protected fun createOutputBuffer(): VideoDecoderOutputBuffer!

Creates a new output buffer.

createUnexpectedDecodeException

protected fun createUnexpectedDecodeException(error: Throwable!): Gav1DecoderException!

Creates an exception to propagate for an unexpected decode error.

Parameters
error: Throwable!

The unexpected decode error.

Returns
Gav1DecoderException!

The exception to propagate.

decode

protected fun decode(
    inputBuffer: DecoderInputBuffer!,
    outputBuffer: VideoDecoderOutputBuffer!,
    reset: Boolean
): Gav1DecoderException?

Decodes the inputBuffer and stores any decoded output in outputBuffer.

Parameters
inputBuffer: DecoderInputBuffer!

The buffer to decode.

outputBuffer: VideoDecoderOutputBuffer!

The output buffer to store decoded data. The flag BUFFER_FLAG_DECODE_ONLY will be set if the same flag is set on inputBuffer, but may be set/unset as required. If the flag is set when the call returns then the output buffer will not be made available to dequeue. The output buffer may not have been populated in this case.

reset: Boolean

Whether the decoder must be reset before decoding.

Returns
Gav1DecoderException?

A decoder exception if an error occurred, or null if decoding was successful.

releaseOutputBuffer

protected fun releaseOutputBuffer(outputBuffer: VideoDecoderOutputBuffer!): Unit

Releases an output buffer back to the decoder.

Parameters
outputBuffer: VideoDecoderOutputBuffer!

The output buffer being released.