# 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)

*** ** * ** ***


```
public class EncoderPreference
```

<br />

*** ** * ** ***

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

## Summary

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

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

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/heifwriter/EncoderPreference#getBitrateMode()()` Gets the preferred bitrate mode. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/heifwriter/EncoderPreference` | `https://developer.android.com/reference/androidx/heifwriter/EncoderPreference#getDefaultEncoderPreference()()` Gets the default encoder preference. |
| `int` | `https://developer.android.com/reference/androidx/heifwriter/EncoderPreference#getEncoderType()()` Gets the preferred encoding type. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/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)

```
public static final int CONSTANT_QUALITY_MODE_ONLY = 1
```

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)

```
public static final int CONSTANT_QUALITY_MODE_PREFERRED = 0
```

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)

```
public static final int HARDWARE_ENCODER_ONLY = 1
```

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)

```
public static final int HARDWARE_ENCODER_PREFERRED = 2
```

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)

```
public static final int NO_ENCODER_PREFERENCE = 0
```

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)

```
public static final int SOFTWARE_ENCODER_ONLY = 3
```

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)

```
public static final int SOFTWARE_ENCODER_PREFERRED = 4
```

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

## Public methods

### getBitrateMode

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

```
public int getBitrateMode()
```

Gets the preferred bitrate mode.

| Returns |
|---|---|
| `int` | The BitrateMode. |

### getDefaultEncoderPreference

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

```
public static @NonNull EncoderPreference getDefaultEncoderPreference()
```

Gets the default encoder preference.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/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)

```
public int getEncoderType()
```

Gets the preferred encoding type.

| Returns |
|---|---|
| `int` | The EncoderType. |

### toString

```
public String toString()
```