# EncoderPreference

Artifact: [androidx.heifwriter:heifwriter](https://developer.android.com/jetpack/androidx/releases/heifwriter) [View Source](https://cs.android.com/search?q=file:androidx/heifwriter/EncoderPreference.java+class:androidx.heifwriter.EncoderPreference) Added in [1.2.0-rc02](https://developer.android.com/jetpack/androidx/releases/heifwriter#1.2.0-rc02)

*** ** * ** ***


```
class EncoderPreference
```

<br />

*** ** * ** ***

Defines the configuration for an encoder, including hardware/software preference and constant quality (CQ) bitrate mode preference.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference.Builder` Builder class for constructing a `https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference` object from specified parameters. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference#CONSTANT_QUALITY_MODE_ONLY() = 1` Only choose the encoder that supports constant quality mode. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference#CONSTANT_QUALITY_MODE_PREFERRED() = 0` This is the default mode. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference#HARDWARE_ENCODER_ONLY() = 1` Only use a hardware encoder. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference#HARDWARE_ENCODER_PREFERRED() = 2` Prefer a hardware encoder, but fall back to a software encoder. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference#NO_ENCODER_PREFERENCE() = 0` This is the default mode. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference#SOFTWARE_ENCODER_ONLY() = 3` Only use a software encoder. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference#SOFTWARE_ENCODER_PREFERRED() = 4` Prefer a software encoder, but fall back to a hardware encoder. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference#getBitrateMode()()` Gets the preferred bitrate mode. |
| `java-static https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference` | `https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference#getDefaultEncoderPreference()()` Gets the default encoder preference. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference#getEncoderType()()` Gets the preferred encoding type. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference#toString()()` |

## Constants

### CONSTANT_QUALITY_MODE_ONLY

Added in [1.2.0-rc02](https://developer.android.com/jetpack/androidx/releases/heifwriter#1.2.0-rc02)

```
const val CONSTANT_QUALITY_MODE_ONLY = 1: Int
```

Only choose the encoder that supports constant quality mode.

### CONSTANT_QUALITY_MODE_PREFERRED

Added in [1.2.0-rc02](https://developer.android.com/jetpack/androidx/releases/heifwriter#1.2.0-rc02)

```
const val CONSTANT_QUALITY_MODE_PREFERRED = 0: Int
```

This is the default mode. Constant quality is not enforced, but encoders with constant quality support are prioritized.

### HARDWARE_ENCODER_ONLY

Added in [1.2.0-rc02](https://developer.android.com/jetpack/androidx/releases/heifwriter#1.2.0-rc02)

```
const val HARDWARE_ENCODER_ONLY = 1: Int
```

Only use a hardware encoder.

### HARDWARE_ENCODER_PREFERRED

Added in [1.2.0-rc02](https://developer.android.com/jetpack/androidx/releases/heifwriter#1.2.0-rc02)

```
const val HARDWARE_ENCODER_PREFERRED = 2: Int
```

Prefer a hardware encoder, but fall back to a software encoder.

### NO_ENCODER_PREFERENCE

Added in [1.2.0-rc02](https://developer.android.com/jetpack/androidx/releases/heifwriter#1.2.0-rc02)

```
const val NO_ENCODER_PREFERENCE = 0: Int
```

This is the default mode. System will use its default behavior.

### SOFTWARE_ENCODER_ONLY

Added in [1.2.0-rc02](https://developer.android.com/jetpack/androidx/releases/heifwriter#1.2.0-rc02)

```
const val SOFTWARE_ENCODER_ONLY = 3: Int
```

Only use a software encoder.

### SOFTWARE_ENCODER_PREFERRED

Added in [1.2.0-rc02](https://developer.android.com/jetpack/androidx/releases/heifwriter#1.2.0-rc02)

```
const val SOFTWARE_ENCODER_PREFERRED = 4: Int
```

Prefer a software encoder, but fall back to a hardware encoder.

## Public functions

### getBitrateMode

Added in [1.2.0-rc02](https://developer.android.com/jetpack/androidx/releases/heifwriter#1.2.0-rc02)

```
fun getBitrateMode(): Int
```

Gets the preferred bitrate mode.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The BitrateMode. |

### getDefaultEncoderPreference

Added in [1.2.0-rc02](https://developer.android.com/jetpack/androidx/releases/heifwriter#1.2.0-rc02)

```
java-static fun getDefaultEncoderPreference(): EncoderPreference
```

Gets the default encoder preference.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/heifwriter/EncoderPreference` | The EncoderPreference object. |

### getEncoderType

Added in [1.2.0-rc02](https://developer.android.com/jetpack/androidx/releases/heifwriter#1.2.0-rc02)

```
fun getEncoderType(): Int
```

Gets the preferred encoding type.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The EncoderType. |

### toString

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