VideoDecoderOutputBuffer


@UnstableApi
public class VideoDecoderOutputBuffer extends DecoderOutputBuffer


Video decoder output buffer containing video frame data.

Summary

Constants

static final int
static final int
static final int
static final int

Public fields

int
@Nullable ByteBuffer

RGB buffer for RGB mode.

int

Decoder private data.

@Nullable Format

The format of the input from which this output buffer was decoded.

int
int

Output mode.

@Nullable ByteBuffer

Supplemental data related to the output frame, if hasSupplementalData returns true.

int
@Nullable ByteBuffer[]

YUV planes for YUV mode.

@Nullable int[]

Public constructors

Creates VideoDecoderOutputBuffer.

Public methods

void
init(
    long timeUs,
    @C.VideoOutputMode int mode,
    @Nullable ByteBuffer supplementalData
)

Initializes the buffer.

void
initForPrivateFrame(int width, int height)

Configures the buffer for the given frame dimensions when passing actual frame data via decoderPrivate.

boolean
initForYuvFrame(
    int width,
    int height,
    int yStride,
    int uvStride,
    int colorspace
)

Resizes the buffer based on the given stride.

void

Releases the output buffer for reuse.

Inherited fields

From androidx.media3.decoder.DecoderOutputBuffer
boolean

Whether this buffer should be skipped, usually because the decoding process generated no data or invalid data.

int

The number of buffers immediately prior to this one that were skipped in the Decoder.

long

The presentation timestamp for the buffer, in microseconds.

Inherited methods

From androidx.media3.decoder.Buffer
final void

Adds the flag to this buffer's flags.

final void

Removes the flag from this buffer's flags, if it is set.

final boolean

Returns whether the specified flag has been set on this buffer.

final boolean

Returns whether the BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA flag is set.

final boolean

This method is deprecated.

Check instead whether the buffer time is greater or equal to the desired start time.

final boolean

Returns whether the BUFFER_FLAG_END_OF_STREAM flag is set.

final boolean

Returns whether the BUFFER_FLAG_FIRST_SAMPLE flag is set.

final boolean

Returns whether the BUFFER_FLAG_KEY_FRAME flag is set.

final boolean

Returns whether the BUFFER_FLAG_LAST_SAMPLE flag is set.

final void
setFlags(@C.BufferFlags int flags)

Replaces this buffer's flags with flags.

From androidx.media3.decoder.DecoderOutputBuffer
void

Clears the buffer.

Constants

COLORSPACE_BT2020

public static final int COLORSPACE_BT2020 = 3

COLORSPACE_BT601

public static final int COLORSPACE_BT601 = 1

COLORSPACE_BT709

public static final int COLORSPACE_BT709 = 2

COLORSPACE_UNKNOWN

public static final int COLORSPACE_UNKNOWN = 0

Public fields

colorspace

public int colorspace

data

public @Nullable ByteBuffer data

RGB buffer for RGB mode.

decoderPrivate

public int decoderPrivate

Decoder private data. Used from native code.

format

public @Nullable Format format

The format of the input from which this output buffer was decoded.

height

public int height

mode

@C.VideoOutputMode
public int mode

Output mode.

supplementalData

public @Nullable ByteBuffer supplementalData

Supplemental data related to the output frame, if hasSupplementalData returns true. If present, the buffer is populated with supplemental data from position 0 to its limit.

width

public int width

yuvPlanes

public @Nullable ByteBuffer[] yuvPlanes

YUV planes for YUV mode.

yuvStrides

public @Nullable int[] yuvStrides

Public constructors

VideoDecoderOutputBuffer

public VideoDecoderOutputBuffer(
    DecoderOutputBuffer.Owner<VideoDecoderOutputBuffer> owner
)

Creates VideoDecoderOutputBuffer.

Parameters
DecoderOutputBuffer.Owner<VideoDecoderOutputBuffer> owner

Buffer owner.

Public methods

init

public void init(
    long timeUs,
    @C.VideoOutputMode int mode,
    @Nullable ByteBuffer supplementalData
)

Initializes the buffer.

Parameters
long timeUs

The presentation timestamp for the buffer, in microseconds.

@C.VideoOutputMode int mode

The output mode. One of VIDEO_OUTPUT_MODE_NONE, VIDEO_OUTPUT_MODE_YUV and VIDEO_OUTPUT_MODE_SURFACE_YUV.

@Nullable ByteBuffer supplementalData

Supplemental data associated with the frame, or null if not present. It is safe to reuse the provided buffer after this method returns.

initForPrivateFrame

public void initForPrivateFrame(int width, int height)

Configures the buffer for the given frame dimensions when passing actual frame data via decoderPrivate. Called via JNI after decoding completes.

initForYuvFrame

public boolean initForYuvFrame(
    int width,
    int height,
    int yStride,
    int uvStride,
    int colorspace
)

Resizes the buffer based on the given stride. Called via JNI after decoding completes.

Returns
boolean

Whether the buffer was resized successfully.

release

public void release()

Releases the output buffer for reuse. Must be called when the buffer is no longer needed.