# DecoderCounters

# DecoderCounters

Artifact:[androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3)  
[View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/DecoderCounters.java+class:androidx.media3.exoplayer.DecoderCounters)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/exoplayer/DecoderCounters "View this page in Java")

<br />

```
@UnstableApi
class DecoderCounters
```

<br />

*** ** * ** ***

Maintains decoder event counts, for debugging purposes only.

Counters should be written from the playback thread only. Counters may be read from any thread. To ensure that the counter values are made visible across threads, users of this class should invoke[ensureUpdated](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#ensureUpdated())prior to reading and after writing.

## Summary

|                                                      ### Public constructors                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------|
| [DecoderCounters](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#DecoderCounters())`()` |

|                                     ### Public functions                                     |
|----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                | [addVideoFrameProcessingOffset](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#addVideoFrameProcessingOffset(long))`(processingOffsetUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Adds a video frame processing offset to[totalVideoFrameProcessingOffsetUs](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#totalVideoFrameProcessingOffsetUs())and increases[videoFrameProcessingOffsetCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#videoFrameProcessingOffsetCount())by one. |
| `synchronized `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [ensureUpdated](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#ensureUpdated())`()` Should be called to ensure counter values are made visible across threads.                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                | [merge](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#merge(androidx.media3.exoplayer.DecoderCounters))`(other: `[DecoderCounters](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters)`!)` Merges the counts from`other`into this instance.                                                                                                                                                                                                                                                                                                                                   |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!`         | [toString](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#toString())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

|                             ### Public properties                             |
|-------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | [decoderInitCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#decoderInitCount()) The number of times a decoder has been initialized.                                                                   |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | [decoderReleaseCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#decoderReleaseCount()) The number of times a decoder has been released.                                                                |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | [droppedBufferCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#droppedBufferCount()) The number of dropped buffers.                                                                                    |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | [droppedInputBufferCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#droppedInputBufferCount()) The number of input buffers dropped.                                                                    |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | [droppedToKeyframeCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#droppedToKeyframeCount()) The number of times all buffers to a keyframe were dropped.                                               |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | [maxConsecutiveDroppedBufferCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#maxConsecutiveDroppedBufferCount()) The maximum number of dropped buffers without an interleaving rendered output buffer. |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | [queuedInputBufferCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#queuedInputBufferCount()) The number of input buffers queued to the decoder.                                                        |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | [renderedOutputBufferCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#renderedOutputBufferCount()) The number of rendered output buffers.                                                              |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | [skippedInputBufferCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#skippedInputBufferCount()) The number of skipped input buffers.                                                                    |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | [skippedOutputBufferCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#skippedOutputBufferCount()) The number of skipped output buffers.                                                                 |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | [totalVideoFrameProcessingOffsetUs](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#totalVideoFrameProcessingOffsetUs()) The sum of the video frame processing offsets in microseconds.                      |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | [videoFrameProcessingOffsetCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#videoFrameProcessingOffsetCount()) The number of video frame processing offsets added.                                     |

## Public constructors

### DecoderCounters

```
DecoderCounters()
```  

## Public functions

### addVideoFrameProcessingOffset

```
fun addVideoFrameProcessingOffset(processingOffsetUs: Long): Unit
```

Adds a video frame processing offset to[totalVideoFrameProcessingOffsetUs](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#totalVideoFrameProcessingOffsetUs())and increases[videoFrameProcessingOffsetCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#videoFrameProcessingOffsetCount())by one.

Convenience method to ensure both fields are updated when adding a single offset.  

|                                             Parameters                                              |
|-----------------------------------------------------------------------------------------------------|----------------------------------------------------|
| `processingOffsetUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The video frame processing offset in microseconds. |

### ensureUpdated

```
synchronized fun ensureUpdated(): Unit
```

Should be called to ensure counter values are made visible across threads. The playback thread should call this method after updating the counter values. Any other thread should call this method before reading the counters.  

### merge

```
fun merge(other: DecoderCounters!): Unit
```

Merges the counts from`other`into this instance.  

|                                                       Parameters                                                        |
|-------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|
| `other: `[DecoderCounters](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters)`!` | The[DecoderCounters](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters)to merge into this instance. |

### toString

```
fun toString(): String!
```  

## Public properties

### decoderInitCount

```
val decoderInitCount: Int
```

The number of times a decoder has been initialized.  

### decoderReleaseCount

```
val decoderReleaseCount: Int
```

The number of times a decoder has been released.  

### droppedBufferCount

```
val droppedBufferCount: Int
```

The number of dropped buffers.

A dropped buffer is a buffer that was supposed to be decoded/rendered, but was instead dropped because it could not be rendered in time.

This includes all of[droppedInputBufferCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#droppedInputBufferCount())in addition to buffers dropped after being queued to the decoder.  

### droppedInputBufferCount

```
val droppedInputBufferCount: Int
```

The number of input buffers dropped.

A dropped input buffer is a buffer that was not queued to the decoder because it would not be rendered in time.  

### droppedToKeyframeCount

```
val droppedToKeyframeCount: Int
```

The number of times all buffers to a keyframe were dropped.

Each time buffers to a keyframe are dropped:

- This counter is incremented by one.
- [droppedInputBufferCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#droppedInputBufferCount())is incremented by the number of buffers dropped from the source to advance to the keyframe.
- [droppedBufferCount](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#droppedBufferCount())is incremented by the sum of the number of buffers dropped from the source to advance to the keyframe and the number of buffers 'inside' the decoder.  

### maxConsecutiveDroppedBufferCount

```
val maxConsecutiveDroppedBufferCount: Int
```

The maximum number of dropped buffers without an interleaving rendered output buffer.

Skipped buffers are ignored for the purposes of calculating this value.  

### queuedInputBufferCount

```
val queuedInputBufferCount: Int
```

The number of input buffers queued to the decoder.  

### renderedOutputBufferCount

```
val renderedOutputBufferCount: Int
```

The number of rendered output buffers.  

### skippedInputBufferCount

```
val skippedInputBufferCount: Int
```

The number of skipped input buffers.

A skipped input buffer is an input buffer that was deliberately not queued to the decoder.  

### skippedOutputBufferCount

```
val skippedOutputBufferCount: Int
```

The number of skipped output buffers.

A skipped output buffer is an output buffer that was deliberately not rendered. This includes buffers that were never dequeued from the decoder and instead skipped while 'inside' the codec due to a flush.  

### totalVideoFrameProcessingOffsetUs

```
val totalVideoFrameProcessingOffsetUs: Long
```

The sum of the video frame processing offsets in microseconds.

The processing offset for a video frame is the difference between the time at which the frame became available to render, and the time at which it was scheduled to be rendered. A positive value indicates the frame became available early enough, whereas a negative value indicates that the frame wasn't available until after the time at which it should have been rendered.

Note: Use[addVideoFrameProcessingOffset](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#addVideoFrameProcessingOffset(long))to update this field instead of updating it directly.  

### videoFrameProcessingOffsetCount

```
val videoFrameProcessingOffsetCount: Int
```

The number of video frame processing offsets added.

Note: Use[addVideoFrameProcessingOffset](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DecoderCounters#addVideoFrameProcessingOffset(long))to update this field instead of updating it directly.